Class: Gly::GlyConvertor
- Inherits:
-
Object
- Object
- Gly::GlyConvertor
- Defined in:
- lib/gly/gly_convertor.rb
Overview
converts gabc to gly
Instance Method Summary collapse
-
#convert(score, output_stream = StringIO.new) ⇒ Object
score - GabcScore (from the lygre gem).
- #header(score) ⇒ Object
- #lyrics(score) ⇒ Object
- #music(score) ⇒ Object
- #word(word) ⇒ Object
Instance Method Details
#convert(score, output_stream = StringIO.new) ⇒ Object
score - GabcScore (from the lygre gem)
7 8 9 10 11 12 13 14 |
# File 'lib/gly/gly_convertor.rb', line 7 def convert(score, output_stream=StringIO.new) out = NonemptyPrinter.new output_stream out.puts '\score' out.puts header score out.puts music score out.puts lyrics score out end |
#header(score) ⇒ Object
16 17 18 19 20 |
# File 'lib/gly/gly_convertor.rb', line 16 def header(score) score.header.each_pair.collect do |key,value| "#{key}: #{value}" end.join "\n" end |
#lyrics(score) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/gly/gly_convertor.rb', line 34 def lyrics(score) score.music.words .collect {|w| word w } .select {|w_str| ! w_str.empty? } .join(' ') end |
#music(score) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gly/gly_convertor.rb', line 22 def music(score) score.music.words.collect do |word| word.each_syllable.collect do |syl| syl = syl.notes.collect(&:text_value).join '' if syl.include? ' ' || syl.empty? syl = "(#{syl})" end syl end.join ' ' end.flatten.join ' ' end |
#word(word) ⇒ Object
41 42 43 |
# File 'lib/gly/gly_convertor.rb', line 41 def word(word) word.each_syllable.collect {|s| s.lyrics }.join ' -- ' end |