Class: MetaSpotify::Artist

Inherits:
Base
  • Object
show all
Defined in:
lib/meta-spotify/artist.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#name, #popularity, #uri

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

lookup, search, #spotify_id

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

#albumsObject (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_regexObject



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_uriObject



24
25
26
# File 'lib/meta-spotify/artist.rb', line 24

def http_uri
  "http://open.spotify.com/artist/#{spotify_id}"
end