class Song::Line

Attributes

chords[RW]
lyrics[RW]
raw_chords[RW]

Public Instance Methods

capo!(fret) click to toggle source
# File Creator/capo.rb, line 42
def capo!(fret)
  log.debug self
  log.debug chords
  return if chords.nil? or chords.empty?
  chords.each do |chord, pos|
    Song.capo(chord, fret)
  end
  log.debug self
  log.debug chords
end
to_html() click to toggle source
# File Creator/html_formatter.rb, line 12
def to_html
  return lyrics.gsub("'", "’").strip.each_line.map{|l| %|<span class="lyricline">#{l}</span>|}.join("\n") if chords.nil? or chords.empty?
  return %|<span class="chords">#{raw_chords}</span><span class="chordlyrics">#{lyrics.gsub("'", "’").strip}</span>|

  return res.gsub("'", "’")
end
to_latex() click to toggle source
# File Creator/latex_formatter.rb, line 7
def to_latex
  return lyrics.gsub("'", "’") if chords.nil? or chords.empty?
  offset = 0
  res = lyrics.dup
  chords.each do |chord, pos|
    cmd = %|\\ch{#{chord}}|
    res = res.ljust(pos + offset + 1, " ").insert(pos + offset, cmd) # Note, this is a unicode emspace
    offset += cmd.length
  end

  return res.gsub("'", "’")
end