Sha256: 6497bc3d626c5a2a26a90823dc193ca4c6c2bb0e679cee0b6913ec3f916d8800

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

module RSpotify

  class Album < Base

    attr_accessor :album_type, :artists, :available_markets, :external_ids, :genres, :images,
                  :name, :popularity, :release_date, :release_date_precision, :tracks

    def self.find(id)
      super(id, 'album')
    end

    def self.search(query, limit = 20, offset = 0)
      super(query, 'album', limit, offset)
    end

    def initialize(options = {})
      @album_type             = options['album_type']
      @available_markets      = options['available_markets']
      @external_ids           = options['external_ids']
      @genres                 = options['genres']
      @images                 = options['images']
      @name                   = options['name']
      @popularity             = options['popularity']
      @release_date           = options['release_date']
      @release_date_precision = options['release_date_precision']

      if options['artists']
        artists = options['artists']
        @artists = artists.map { |a| Artist.new a }
      end

      if options['tracks']
        tracks = options['tracks']['items']
        @tracks = tracks.map { |t| Track.new t }
      end

      super(options)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspotify-0.3.1 lib/rspotify/album.rb
rspotify-0.3.0 lib/rspotify/album.rb