Class: SpotifyWeb::Playlist
- Defined in:
- lib/spotify_web/playlist.rb
Overview
Represents a collection of songs
Constant Summary
Constants inherited from Resource
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
:nodoc:.
-
#songs ⇒ Array<SpotifyWeb::Song>
readonly
The songs that have been added to this playlist.
-
#user ⇒ SpotifyWeb::User
readonly
The user this playlist is managed by.
Attributes inherited from Resource
Instance Method Summary collapse
-
#load ⇒ Object
Loads the attributes for this playlist.
-
#uri_id ⇒ Object
:nodoc:.
Methods inherited from Resource
#==, attribute, #attributes=, #hash, #initialize, #load_metadata, #loaded?, #metadata=, #metadata_uri, #pretty_print, #pretty_print_instance_variables
Methods included from Assertions
#assert_valid_keys, #assert_valid_values
Constructor Details
This class inherits a constructor from SpotifyWeb::Resource
Instance Attribute Details
#name ⇒ Object (readonly)
:nodoc:
16 |
# File 'lib/spotify_web/playlist.rb', line 16 attribute :name |
#songs ⇒ Array<SpotifyWeb::Song> (readonly)
The songs that have been added to this playlist
20 21 22 |
# File 'lib/spotify_web/playlist.rb', line 20 attribute :songs do |songs| ResourceCollection.new(client, songs.map {|song| Song.new(client, :uri => song.uri)}) end |
#user ⇒ SpotifyWeb::User (readonly)
The user this playlist is managed by
12 |
# File 'lib/spotify_web/playlist.rb', line 12 attribute :user, :load => false |
Instance Method Details
#load ⇒ Object
Loads the attributes for this playlist
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/spotify_web/playlist.rb', line 33 def load path = uri_id == 'starred' ? uri_id : "playlist/#{uri_id}" response = api('request', :uri => "hm://playlist/user/#{user.username}/#{path}?from=0&length=100", :response_schema => Schema::Playlist4::SelectedListContent ) result = response['result'] attributes = result.attributes.to_hash attributes[:songs] = result.contents.items self.attributes = attributes super end |
#uri_id ⇒ Object
:nodoc:
28 29 30 |
# File 'lib/spotify_web/playlist.rb', line 28 def uri_id #:nodoc: @uri_id ||= @uri ? @uri.split(':')[4] : super end |