Class: Grooveshark::Song
- Inherits:
-
Object
- Object
- Grooveshark::Song
- Defined in:
- lib/grooveshark/song.rb
Instance Attribute Summary collapse
-
#album ⇒ Object
readonly
Returns the value of attribute album.
-
#album_id ⇒ Object
readonly
Returns the value of attribute album_id.
-
#artist ⇒ Object
readonly
Returns the value of attribute artist.
-
#artist_id ⇒ Object
readonly
Returns the value of attribute artist_id.
-
#artwork ⇒ Object
readonly
Returns the value of attribute artwork.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#playcount ⇒ Object
readonly
Returns the value of attribute playcount.
-
#track ⇒ Object
readonly
Returns the value of attribute track.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
-
#initialize(data = nil) ⇒ Song
constructor
A new instance of Song.
-
#to_hash ⇒ Object
Hash export for API usage.
-
#to_s ⇒ Object
Presentable format.
Constructor Details
#initialize(data = nil) ⇒ Song
Returns a new instance of Song.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/grooveshark/song.rb', line 8 def initialize(data=nil) unless data.nil? @data = data @id = data['song_id'] @name = data['song_name'] || data['name'] @artist = data['artist_name'] @artist_id = data['artist_id'] @album = data['album_name'] @album_id = data['album_id'] @track = data['track_num'] @duration = data['estimate_duration'] @artwork = data['cover_art_filename'] @playcount = data['song_plays'] @year = data['year'] end end |
Instance Attribute Details
#album ⇒ Object (readonly)
Returns the value of attribute album.
5 6 7 |
# File 'lib/grooveshark/song.rb', line 5 def album @album end |
#album_id ⇒ Object (readonly)
Returns the value of attribute album_id.
4 5 6 |
# File 'lib/grooveshark/song.rb', line 4 def album_id @album_id end |
#artist ⇒ Object (readonly)
Returns the value of attribute artist.
5 6 7 |
# File 'lib/grooveshark/song.rb', line 5 def artist @artist end |
#artist_id ⇒ Object (readonly)
Returns the value of attribute artist_id.
4 5 6 |
# File 'lib/grooveshark/song.rb', line 4 def artist_id @artist_id end |
#artwork ⇒ Object (readonly)
Returns the value of attribute artwork.
6 7 8 |
# File 'lib/grooveshark/song.rb', line 6 def artwork @artwork end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/grooveshark/song.rb', line 3 def data @data end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
6 7 8 |
# File 'lib/grooveshark/song.rb', line 6 def duration @duration end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/grooveshark/song.rb', line 4 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/grooveshark/song.rb', line 5 def name @name end |
#playcount ⇒ Object (readonly)
Returns the value of attribute playcount.
6 7 8 |
# File 'lib/grooveshark/song.rb', line 6 def playcount @playcount end |
#track ⇒ Object (readonly)
Returns the value of attribute track.
5 6 7 |
# File 'lib/grooveshark/song.rb', line 5 def track @track end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
5 6 7 |
# File 'lib/grooveshark/song.rb', line 5 def year @year end |
Instance Method Details
#to_hash ⇒ Object
Hash export for API usage
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/grooveshark/song.rb', line 31 def to_hash { 'songID' => @id, 'songName' => @name, 'artistName' => @artist, 'artistID' => @artist_id, 'albumName' => @album, 'albumID' => @album_id, 'track' => @track } end |
#to_s ⇒ Object
Presentable format
26 27 28 |
# File 'lib/grooveshark/song.rb', line 26 def to_s [@id, @name, @artist].join(' - ') end |