Class: Rdio::Playlist
- Inherits:
-
PlaylistData
- Object
- ApiObj
- BaseObj
- PlaylistData
- Rdio::Playlist
- Defined in:
- lib/rdio/types.rb
Overview
Represents a playlist on Rdio
Instance Attribute Summary collapse
-
#big_icon ⇒ Object
big icon.
-
#track_keys ⇒ Object
track keys.
Attributes inherited from PlaylistData
#base_icon, #embed_url, #icon, #last_updated, #length, #name, #owner, #owner_icon, #owner_key, #owner_url, #short_url, #type, #url
Attributes inherited from BaseObj
Attributes inherited from ApiObj
Class Method Summary collapse
-
.all(keys, extras = nil) ⇒ Object
Fetch one or more objects from Rdio of type Playlist.
-
.create(name, description, tracks, extras = nil) ⇒ Object
Create a new playlist in the current user’s collection.
-
.from_short_code(short_code) ⇒ Object
Return the Playlist that the supplied Rdio short-code is a representation of, or null if the short-code is invalid.
-
.from_url(url) ⇒ Object
Return the Playlist that the supplied Rdio url is a representation of, or null if the url doesn’t represent an object.
-
.get(key, extras = nil) ⇒ Object
Fetch one object from Rdio of type Playlist.
-
.search(query, never_or = nil, extras = nil, start = nil, count = nil) ⇒ Object
Returns an array of Playlist for the query and other params.
-
.top_charts ⇒ Object
Return the site-wide most popular items for Playlists.
Instance Method Summary collapse
-
#add_to_playlist(tracks) ⇒ Object
Add a track to a playlist.
-
#collaborating=(collaborating) ⇒ Object
Start or stop collaborating on this playlist.
-
#collaboration_mode=(mode) ⇒ Object
Start or stop collaborating on this playlist.
-
#delete ⇒ Object
Delete a playlist.
-
#initialize(api) ⇒ Playlist
constructor
A new instance of Playlist.
-
#order=(tracks) ⇒ Object
Saves the given order of tracks in a given playlist.
-
#remove(index, count, tracks) ⇒ Object
Remove an item from a playlist by its position in the playlist.
-
#set_fields(name, description) ⇒ Object
Sets the name and description for a playlist.
-
#tracks ⇒ Object
Returns an array of tracks.
Methods inherited from BaseObj
Methods inherited from ApiObj
Constructor Details
#initialize(api) ⇒ Playlist
Returns a new instance of Playlist.
326 327 328 |
# File 'lib/rdio/types.rb', line 326 def initialize(api) super api end |
Instance Attribute Details
#big_icon ⇒ Object
big icon
331 332 333 |
# File 'lib/rdio/types.rb', line 331 def big_icon @big_icon end |
#track_keys ⇒ Object
track keys
334 335 336 |
# File 'lib/rdio/types.rb', line 334 def track_keys @track_keys end |
Class Method Details
.all(keys, extras = nil) ⇒ Object
Fetch one or more objects from Rdio of type Playlist.
372 373 374 |
# File 'lib/rdio/types.rb', line 372 def self.all(keys,extras=nil) Rdio::api.get keys,Playlist,extras end |
.create(name, description, tracks, extras = nil) ⇒ Object
Create a new playlist in the current user’s collection. The new playlist will be returned if the creation is successful, otherwise null will be returned.
362 363 364 |
# File 'lib/rdio/types.rb', line 362 def self.create(name,description,tracks,extras=nil) Rdio::api.createPlaylist name,description,tracks,extras end |
.from_short_code(short_code) ⇒ Object
Return the Playlist that the supplied Rdio short-code is a representation of, or null if the short-code is invalid.
384 385 386 |
# File 'lib/rdio/types.rb', line 384 def self.from_short_code(short_code) Rdio::api.getObjectFromShortCode short_code,Playlist end |
.from_url(url) ⇒ Object
Return the Playlist that the supplied Rdio url is a representation of, or null if the url doesn’t represent an object.
390 391 392 |
# File 'lib/rdio/types.rb', line 390 def self.from_url(url) Rdio::api.getObjectFromUrl url,Playlist end |
.get(key, extras = nil) ⇒ Object
Fetch one object from Rdio of type Playlist.
377 378 379 380 |
# File 'lib/rdio/types.rb', line 377 def self.get(key,extras=nil) arr = all [key],extras return (arr and not arr.empty?) ? arr[0] : nil end |
.search(query, never_or = nil, extras = nil, start = nil, count = nil) ⇒ Object
Returns an array of Playlist for the query and other params
349 350 351 352 |
# File 'lib/rdio/types.rb', line 349 def self.search(query,never_or=nil,extras=nil,start=nil,count=nil) extras = Rdio::add_to_array extras,'playlists' Search.search query,Playlist,never_or,extras,start,count end |
Instance Method Details
#add_to_playlist(tracks) ⇒ Object
Add a track to a playlist.
355 356 357 |
# File 'lib/rdio/types.rb', line 355 def add_to_playlist(tracks) api.addToPlaylist self,tracks end |
#collaborating=(collaborating) ⇒ Object
Start or stop collaborating on this playlist.
400 401 402 |
# File 'lib/rdio/types.rb', line 400 def () Rdio::api. self, end |
#collaboration_mode=(mode) ⇒ Object
Start or stop collaborating on this playlist.
405 406 407 |
# File 'lib/rdio/types.rb', line 405 def collaboration_mode=(mode) Rdio::api.setPlaylistCollaborationMode self,mode end |
#delete ⇒ Object
Delete a playlist.
367 368 369 |
# File 'lib/rdio/types.rb', line 367 def delete api.deletePlaylist self end |
#order=(tracks) ⇒ Object
Saves the given order of tracks in a given playlist. The new order must have the same tracks as the previous order (this method may not be used to add/remove tracks).
412 413 414 |
# File 'lib/rdio/types.rb', line 412 def order=(tracks) Rdio::api.setPlaylistOrder self,tracks end |
#remove(index, count, tracks) ⇒ Object
Remove an item from a playlist by its position in the playlist.
337 338 339 |
# File 'lib/rdio/types.rb', line 337 def remove(index,count,tracks) api.removeFromPlaylist self,index,count,tracks end |