Sha256: 2f063a1e2a339483d347d8db56e4bcb2dc3b429447d9914befe2d9692265f213

Contents?: true

Size: 699 Bytes

Versions: 4

Compression:

Stored size: 699 Bytes

Contents

module MetaSpotify
  class Artist < MetaSpotify::Base
    
    def self.uri_regex
      /^spotify:artist:([A-Za-z0-9]+)$/
    end
    
    attr_reader :albums
    
    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

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

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
meta-spotify-0.3.3 lib/meta-spotify/artist.rb
meta-spotify-0.3.2 lib/meta-spotify/artist.rb
meta-spotify-0.3.1 lib/meta-spotify/artist.rb
meta-spotify-0.3.0 lib/meta-spotify/artist.rb