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