Class: SiSU_HarvestTopics::Songsheet

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

Constant Summary collapse

@@the_idx_topics =
{}

Instance Method Summary collapse

Constructor Details

#initialize(opt, env) ⇒ Songsheet

Returns a new instance of Songsheet.



63
64
65
66
# File 'lib/sisu/html_harvest_topics.rb', line 63

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

Instance Method Details

#songsheetObject



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
105
106
107
# File 'lib/sisu/html_harvest_topics.rb', line 67

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|classify):(?:\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|\s*$|%+ )/
        else break
        end
      end
    end
    lang_hash_file_array.each_pair do |lang,a|
      idx_array[lang] ||=[]
      idx_array=SiSU_HarvestTopics::Harvest.new(
        @opt,
        @env,
        a,
        filename,
        name,
        idx_array,
        lang
      ).extract_harvest
    end
  end
  the_hash=SiSU_HarvestTopics::Index.new(
    @opt,
    @env,
    idx_array,
    @@the_idx_topics
  ).song
  SiSU_HarvestTopics::OutputIndex.new(
    @opt,
    the_hash
  ).html_print.html_songsheet
end