Class: SiSU_HarvestAuthors::Songsheet

Inherits:
Object
  • Object
show all
Defined in:
lib/sisu/html_harvest_authors.rb

Constant Summary collapse

@@the_idx_authors =
{}

Instance Method Summary collapse

Constructor Details

#initialize(opt, env) ⇒ Songsheet

Returns a new instance of Songsheet.



62
63
64
65
# File 'lib/sisu/html_harvest_authors.rb', line 62

def initialize(opt,env)
  @opt,@env=opt,env
  @file_list=opt.files
end

Instance Method Details

#songsheetObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/sisu/html_harvest_authors.rb', line 66

def songsheet
  idx_array={}
  @opt.f_pths.each do |y|
    lang_hash_file_array={}
    name=y[:f]
    filename=y[:pth] + '/' + y[:f]
    File.open(filename,'r') do |file|
      file.each_line("\n\n") do |line|
        if line =~/^@(?:title|creator|date):(?:\s|$)/m
          lang_hash_file_array[y[:lng_is]] ||= []
          lang_hash_file_array[y[:lng_is]] << line
        elsif line =~/^@\S+?:(?:\s|$)/m \
        or line =~/^(?:\s*\n|%+ )/
        else break
        end
      end
    end
    lang_hash_file_array.each_pair do |lang,a|
      idx_array[lang] ||= []
      idx_array=SiSU_HarvestAuthors::Harvest.new(
        @opt,
        @env,
        a,
        filename,
        name,
        idx_array,
        lang
      ).extract_harvest
    end
  end
  the_idx=SiSU_HarvestAuthors::Index.new(
    idx_array,
    @@the_idx_authors
  ).construct_book_author_index
  SiSU_HarvestAuthors::OutputIndex.new(
    @opt,
    the_idx
  ).html_print.html_songsheet
end