Added repeated lyrics to the parser
[lyrix.git] / app / models / song.rb
bloba36d86224889255c57d87391fd245bccf9841f27
1 require_dependency 'lyric_parser'
3 class Song < ActiveRecord::Base
4   belongs_to :user, :dependent => :destroy
5   has_many :usages, :dependent => :destroy
6   has_many :shows, :through => :usages
7   
8   # The entire UI breaks down without a title
9   validates_presence_of :title
10   
11   # Split the song into slides.
12   #
13   # Slides are separated by a blank line, indicated
14   # by two new-line characters. The parser is pretty
15   # tolerant of whitespace. See the RSpecs for examples.
16   def slides
17     Lyrix::LyricParser.new(lyrics).to_slides
18   end
19   
20   def artist
21     attributes["artist"] || ''
22   end
23 end