class Chordproko::PlainSong
Public Class Methods
new(sheet, options={transpose: 1})
click to toggle source
# File lib/chordproko/plain_song.rb, line 3 def initialize sheet, options={transpose: 1} @sheet = sheet @options = options end
Public Instance Methods
chord_group_format(str)
click to toggle source
# File lib/chordproko/plain_song.rb, line 48 def chord_group_format str str end
chord_line_format(str)
click to toggle source
# File lib/chordproko/plain_song.rb, line 54 def chord_line_format str str end
comment_format(str)
click to toggle source
# File lib/chordproko/plain_song.rb, line 57 def comment_format str str end
content()
click to toggle source
# File lib/chordproko/plain_song.rb, line 10 def content @content ||= generate end
directive_format(str)
click to toggle source
# File lib/chordproko/plain_song.rb, line 60 def directive_format str str end
generate()
click to toggle source
# File lib/chordproko/plain_song.rb, line 13 def generate textified = "" @sheet.each do |line| chords = "" lyrics = "" prev_lyrics = "" prev_chord = "" line.each do |element| element.each do |item| case item.class.to_s when "Chordproko::Comment" textified += item.to_s when "Chordproko::Directive" textified += item.to_s when "Chordproko::ChordGroup" item.key = @options[:transpose] if @options[:transpose] rescue 0 cgroup = item.to_s chords += (" " * (prev_lyrics.size - prev_chord.size).abs) + chord_group_format(cgroup) prev_chord = cgroup when "Chordproko::Lyric" prev_lyrics = item.to_s lyrics += item.to_s end end #case end #line chord_lyrics = [] chord_lyrics << chord_line_format(chords) if chords.size > 0 chord_lyrics << lyric_line_format(lyrics) if lyrics.size > 0 textified += chord_lyrics.join("\n") textified += "\n" end #sheet textified end
lyric_format(str)
click to toggle source
# File lib/chordproko/plain_song.rb, line 63 def lyric_format str str end
lyric_line_format(str)
click to toggle source
# File lib/chordproko/plain_song.rb, line 51 def lyric_line_format str str end
to_s()
click to toggle source
# File lib/chordproko/plain_song.rb, line 7 def to_s content end