Class: Grooveshark::Song
- Inherits:
-
Object
- Object
- Grooveshark::Song
- Defined in:
- lib/grooveshark/song.rb
Overview
Song class
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.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/grooveshark/song.rb', line 10 def initialize(data = nil) return if 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 |
Instance Attribute Details
#album ⇒ Object (readonly)
Returns the value of attribute album.
7 8 9 |
# File 'lib/grooveshark/song.rb', line 7 def album @album end |
#album_id ⇒ Object (readonly)
Returns the value of attribute album_id.
6 7 8 |
# File 'lib/grooveshark/song.rb', line 6 def album_id @album_id end |
#artist ⇒ Object (readonly)
Returns the value of attribute artist.
7 8 9 |
# File 'lib/grooveshark/song.rb', line 7 def artist @artist end |
#artist_id ⇒ Object (readonly)
Returns the value of attribute artist_id.
6 7 8 |
# File 'lib/grooveshark/song.rb', line 6 def artist_id @artist_id end |
#artwork ⇒ Object (readonly)
Returns the value of attribute artwork.
8 9 10 |
# File 'lib/grooveshark/song.rb', line 8 def artwork @artwork end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/grooveshark/song.rb', line 5 def data @data end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
8 9 10 |
# File 'lib/grooveshark/song.rb', line 8 def duration @duration end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/grooveshark/song.rb', line 6 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/grooveshark/song.rb', line 7 def name @name end |
#playcount ⇒ Object (readonly)
Returns the value of attribute playcount.
8 9 10 |
# File 'lib/grooveshark/song.rb', line 8 def playcount @playcount end |
#track ⇒ Object (readonly)
Returns the value of attribute track.
7 8 9 |
# File 'lib/grooveshark/song.rb', line 7 def track @track end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
7 8 9 |
# File 'lib/grooveshark/song.rb', line 7 def year @year end |
Instance Method Details
#to_hash ⇒ Object
Hash export for API usage
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/grooveshark/song.rb', line 33 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
28 29 30 |
# File 'lib/grooveshark/song.rb', line 28 def to_s [@id, @name, @artist].join(' - ') end |