Class: MetaSpotify::Artist
Instance Attribute Summary collapse
-
#albums ⇒ Object
readonly
Returns the value of attribute albums.
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #http_uri ⇒ Object
-
#initialize(hash) ⇒ Artist
constructor
A new instance of Artist.
Methods inherited from Base
Constructor Details
#initialize(hash) ⇒ Artist
Returns a new instance of Artist.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/meta-spotify/artist.rb', line 10 def initialize(hash) @name = hash['name'] @popularity = hash['popularity'].to_f if hash.has_key? 'popularity' @uri = hash['href'] if hash.has_key? 'href' if hash.has_key? 'albums' @albums = [] if hash['albums']['album'].is_a? Array hash['albums']['album'].each { |a| @albums << Album.new(a) } else @albums << Album.new(hash['albums']['album']) end end end |
Instance Attribute Details
#albums ⇒ Object (readonly)
Returns the value of attribute albums.
8 9 10 |
# File 'lib/meta-spotify/artist.rb', line 8 def albums @albums end |
Class Method Details
.uri_regex ⇒ Object
4 5 6 |
# File 'lib/meta-spotify/artist.rb', line 4 def self.uri_regex /^spotify:artist:([A-Za-z0-9]+)$/ end |
Instance Method Details
#http_uri ⇒ Object
24 25 26 |
# File 'lib/meta-spotify/artist.rb', line 24 def http_uri "http://open.spotify.com/artist/#{spotify_id}" end |