Sha256: d133945289d620f5460f1b7dedf17d8cbf3d520eaa2093db268be17b749b9bde

Contents?: true

Size: 904 Bytes

Versions: 1

Compression:

Stored size: 904 Bytes

Contents

module RSpotify

  class Playlist < Base

    def self.find(user_id, id)
      json = RSpotify.auth_get("users/#{user_id}/playlists/#{id}")
      Playlist.new json
    end

    def self.search
      #TODO
    end

    def initialize(options = {})
      @collaborative = options['collaborative']
      @description   = options['description']
      @followers     = options['followers']
      @images        = options['images']
      @name          = options['name']
      @public        = options['public']

      if options['owner']
        @owner = User.new options['owner']
      end

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

      super(options)
    end

    def complete_object!
      initialize RSpotify.auth_get("users/#{@owner.id}/playlists/#{@id}")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspotify-0.4.0 lib/rspotify/playlist.rb