Class: MetaSpotify::Track
Instance Attribute Summary collapse
-
#album ⇒ Object
readonly
Returns the value of attribute album.
-
#allmusic_id ⇒ Object
readonly
Returns the value of attribute allmusic_id.
-
#allmusic_uri ⇒ Object
readonly
Returns the value of attribute allmusic_uri.
-
#artists ⇒ Object
readonly
Returns the value of attribute artists.
-
#isrc_id ⇒ Object
readonly
Returns the value of attribute isrc_id.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#musicbrainz_id ⇒ Object
readonly
Returns the value of attribute musicbrainz_id.
-
#musicbrainz_uri ⇒ Object
readonly
Returns the value of attribute musicbrainz_uri.
-
#track_number ⇒ Object
readonly
Returns the value of attribute track_number.
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #http_uri ⇒ Object
-
#initialize(hash) ⇒ Track
constructor
A new instance of Track.
Methods inherited from Base
Constructor Details
#initialize(hash) ⇒ Track
Returns a new instance of Track.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/meta-spotify/track.rb', line 12 def initialize(hash) @name = hash['name'] @uri = hash['href'] if hash.has_key? 'href' @popularity = hash['popularity'].to_f if hash.has_key? 'popularity' if hash.has_key? 'artist' @artists = [] if hash['artist'].is_a? Array hash['artist'].each { |a| @artists << Artist.new(a) } else @artists << Artist.new(hash['artist']) end end @album = Album.new(hash['album']) if hash.has_key? 'album' @track_number = hash['track_number'].to_i if hash.has_key? 'track_number' @length = hash['length'].to_f if hash.has_key? 'length' case hash['id'] when Hash node_to_id hash['id'] when Array hash['id'].each do |id| node_to_id id end end end |
Instance Attribute Details
#album ⇒ Object (readonly)
Returns the value of attribute album.
8 9 10 |
# File 'lib/meta-spotify/track.rb', line 8 def album @album end |
#allmusic_id ⇒ Object (readonly)
Returns the value of attribute allmusic_id.
8 9 10 |
# File 'lib/meta-spotify/track.rb', line 8 def allmusic_id @allmusic_id end |
#allmusic_uri ⇒ Object (readonly)
Returns the value of attribute allmusic_uri.
8 9 10 |
# File 'lib/meta-spotify/track.rb', line 8 def allmusic_uri @allmusic_uri end |
#artists ⇒ Object (readonly)
Returns the value of attribute artists.
8 9 10 |
# File 'lib/meta-spotify/track.rb', line 8 def artists @artists end |
#isrc_id ⇒ Object (readonly)
Returns the value of attribute isrc_id.
8 9 10 |
# File 'lib/meta-spotify/track.rb', line 8 def isrc_id @isrc_id end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
8 9 10 |
# File 'lib/meta-spotify/track.rb', line 8 def length @length end |
#musicbrainz_id ⇒ Object (readonly)
Returns the value of attribute musicbrainz_id.
8 9 10 |
# File 'lib/meta-spotify/track.rb', line 8 def musicbrainz_id @musicbrainz_id end |
#musicbrainz_uri ⇒ Object (readonly)
Returns the value of attribute musicbrainz_uri.
8 9 10 |
# File 'lib/meta-spotify/track.rb', line 8 def musicbrainz_uri @musicbrainz_uri end |
#track_number ⇒ Object (readonly)
Returns the value of attribute track_number.
8 9 10 |
# File 'lib/meta-spotify/track.rb', line 8 def track_number @track_number end |
Class Method Details
.uri_regex ⇒ Object
4 5 6 |
# File 'lib/meta-spotify/track.rb', line 4 def self.uri_regex /^spotify:track:([A-Za-z0-9]+)$/ end |
Instance Method Details
#http_uri ⇒ Object
40 41 42 |
# File 'lib/meta-spotify/track.rb', line 40 def http_uri "http://open.spotify.com/track/#{spotify_id}" end |