Class: Rdio::Playlist

Inherits:
PlaylistData show all
Defined in:
lib/rdio/types.rb

Overview


Represents a playlist on Rdio


Instance Attribute Summary collapse

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

#key

Attributes inherited from ApiObj

#api

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseObj

#eql?, #to_k

Methods inherited from ApiObj

#fill

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_iconObject

big icon



331
332
333
# File 'lib/rdio/types.rb', line 331

def big_icon
  @big_icon
end

#track_keysObject

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.



365
366
367
# File 'lib/rdio/types.rb', line 365

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.



355
356
357
# File 'lib/rdio/types.rb', line 355

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.



377
378
379
# File 'lib/rdio/types.rb', line 377

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.



383
384
385
# File 'lib/rdio/types.rb', line 383

def self.from_url(url)
  Rdio::api.getObjectFromUrl url,Playlist
end

.get(key, extras = nil) ⇒ Object

Fetch one object from Rdio of type Playlist.



370
371
372
373
# File 'lib/rdio/types.rb', line 370

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



342
343
344
345
# File 'lib/rdio/types.rb', line 342

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

.top_chartsObject

Return the site-wide most popular items for Playlists



388
389
390
# File 'lib/rdio/types.rb', line 388

def self.top_charts
  Rdio::api.getTopCharts Playlist
end

Instance Method Details

#add_to_playlist(tracks) ⇒ Object

Add a track to a playlist.



348
349
350
# File 'lib/rdio/types.rb', line 348

def add_to_playlist(tracks)
  api.addToPlaylist self,tracks
end

#collaborating=(collaborating) ⇒ Object

Start or stop collaborating on this playlist.



393
394
395
# File 'lib/rdio/types.rb', line 393

def collaborating=(collaborating)
  Rdio::api.setPlaylistCollaborating self,collaborating
end

#collaboration_mode=(mode) ⇒ Object

Start or stop collaborating on this playlist.



398
399
400
# File 'lib/rdio/types.rb', line 398

def collaboration_mode=(mode)
  Rdio::api.setPlaylistCollaborationMode self,mode
end

#deleteObject

Delete a playlist.



360
361
362
# File 'lib/rdio/types.rb', line 360

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).



405
406
407
# File 'lib/rdio/types.rb', line 405

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

#set_fields(name, description) ⇒ Object

Sets the name and description for a playlist.



410
411
412
# File 'lib/rdio/types.rb', line 410

def set_fields(name,description)
  Rdio::api.setPlaylistFields self,name,description
end