5 def initialize(lyrics, options = {})
6 @options = DEFAULT_OPTIONS.merge(options)
11 @parsed_lyrics ||= parse!
18 parsed[:slides] = @lyrics.strip.gsub("\r\n", "\n").split(/\n[ \t]*\n/)
19 parsed[:slides].collect! { |s| s.strip }
20 parsed[:slides].reject! { |s| s.empty? }
22 parsed[:slides].each_with_index do |s,idx|
23 [:chorus, :bridge].each do |sub|
24 if s =~ Regexp.new("^\\[#{sub}\\]") and !parsed.has_key?(sub)
25 parsed[sub] = s.split("\n")[1..-1].join("\n")
26 parsed[:slides][idx] = parsed[sub]
29 parsed[:slides][idx].gsub!("[#{sub}]", parsed[sub]) if parsed[sub]
32 if s =~ /^\[([2-9])x\]/
33 parsed[:slides][idx] = (1..($1.to_i)).collect { s.split("\n")[1..-1].join("\n") }
37 parsed[:slides].flatten!
39 parsed[:slides].each_with_index do |s,idx|
40 slide = parsed[:slides][idx].split("\n")
41 slide.each_with_index do |line,i|
43 if line.strip =~ /\[([2-9])x\]$/
45 line = line.gsub("[#{num}x]", "").strip
46 slide[i] = (1..num).collect { line }
49 parsed[:slides][idx] = slide.flatten.join("\n")