Class: Songsterr::Song
- Inherits:
-
Data::Base
- Object
- Data::Base
- Songsterr::Song
- Defined in:
- lib/songsterr/song.rb
Instance Attribute Summary
Attributes inherited from Data::Base
Class Method Summary collapse
Instance Method Summary collapse
-
#artist ⇒ Object
Instance Methods.
- #revision ⇒ Object
Methods inherited from Data::Base
#attachment_url, #info, #initialize, #method_missing
Constructor Details
This class inherits a constructor from Songsterr::Data::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Songsterr::Data::Base
Class Method Details
.find_by_id(id) ⇒ Object
10 11 12 |
# File 'lib/songsterr/song.rb', line 10 def find_by_id(id) self.new(Request.get("player/song/#{id}")) end |
.where(data = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/songsterr/song.rb', line 14 def where(data={}) if data[:id] return self.find_by_id(data[:id]) elsif (artists = (data[:artist] || data[:artists])) artists = [artists] unless artists.kind_of? Array artists.collect!{|a| "\"#{a}\"" } songs = Request.get('songs/byartists', :artists => artists.join(',')) elsif data[:pattern] songs = Request.get('songs', :pattern => data[:pattern]) end songs.collect {|data| self.new(data) } end |
Instance Method Details
#artist ⇒ Object
Instance Methods
34 35 36 |
# File 'lib/songsterr/song.rb', line 34 def artist @artist ||= Artist.new(info(:artist)) end |
#revision ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/songsterr/song.rb', line 38 def revision @revision ||= begin unless info(:latest_available_revision) self.class.find_by_id(info(:id)).revision else Data::SongRevision.new(info(:latest_available_revision)) end end end |