5 DEFAULT_OPTIONS = {} unless defined?(DEFAULT_OPTIONS)
7 def initialize(lyrics, options = {})
8 @options = DEFAULT_OPTIONS.merge(options)
18 @parsed_lyrics ||= parse!
25 parsed[:slides] = @lyrics.strip.gsub("\r\n", "\n").split(/\n[ \t]*\n/)
26 parsed[:slides].collect! { |s| s.strip }
27 parsed[:slides].reject! { |s| s.empty? }
29 parsed[:slides].each_with_index do |s,idx|
30 [:chorus, :bridge].each do |sub|
31 if s =~ Regexp.new("^\\[#{sub}\\]") and !parsed.has_key?(sub)
32 parsed[sub] = s.split("\n")[1..-1].join("\n")
33 parsed[:slides][idx] = parsed[sub]
36 parsed[:slides][idx].gsub!("[#{sub}]", parsed[sub]) if parsed[sub]
39 if s =~ /^\[([2-9])x\]/
40 parsed[:slides][idx] = (1..($1.to_i)).collect { s.split("\n")[1..-1].join("\n") }
44 parsed[:slides].flatten!
46 parsed[:slides].each_with_index do |s,idx|
47 slide = parsed[:slides][idx].split("\n")
48 slide.each_with_index do |line,i|
49 if line.strip =~ /\[([2-9])x\]$/
51 line = line.gsub("[#{num}x]", "").strip
52 slide[i] = (1..num).collect { line }
55 parsed[:slides][idx] = slide.flatten.join("\n")