Sha256: d1635bc462e3b62b5a22352260112bb6ecaf7a9665d8db2ada0ab0aadfb6bc29

Contents?: true

Size: 873 Bytes

Versions: 2

Compression:

Stored size: 873 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']

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

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

      super(options)
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspotify-0.6.0 lib/rspotify/playlist.rb
rspotify-0.5.0 lib/rspotify/playlist.rb