Class: WiMP::Playlist
Class Method Summary collapse
-
.create(title) ⇒ Object
Playlist.
-
.find(uuid) ⇒ Object
Playlist.
Instance Method Summary collapse
-
#add_tracks(tracks, options = {}) ⇒ Object
@options Integer Where should the new tracks be added?.
-
#add_tracks_by_id(track_ids, options = {}) ⇒ Object
@options Integer Where should the new tracks be added?.
-
#count ⇒ Object
Integer.
-
#initialize(oplaylist) ⇒ Playlist
constructor
A new instance of Playlist.
-
#remove_tracks_by_indices(indices) ⇒ Object
Boolean Were the request successfull?.
- #tracks ⇒ Object
-
#url ⇒ Object
String.
-
#uuid ⇒ Object
String.
Methods inherited from Base
execute, #execute, session, #session
Constructor Details
Class Method Details
.create(title) ⇒ Object
Returns Playlist.
12 13 14 15 16 |
# File 'lib/wimp/playlist.rb', line 12 def self.create(title) execute do |client| new(client.addUserPlaylist(title, session)) end end |
.find(uuid) ⇒ Object
Returns Playlist.
22 23 24 25 26 |
# File 'lib/wimp/playlist.rb', line 22 def self.find(uuid) execute do |client| new(client.getUserPlaylistByUuid(uuid, session)) end end |
Instance Method Details
#add_tracks(tracks, options = {}) ⇒ Object
@options Integer Where
should the new tracks be added?
34 35 36 |
# File 'lib/wimp/playlist.rb', line 34 def add_tracks(tracks, = {}) add_tracks_by_id(tracks.map(&:id), ) end |
#add_tracks_by_id(track_ids, options = {}) ⇒ Object
@options Integer Where
should the new tracks be added?
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/wimp/playlist.rb', line 44 def add_tracks_by_id(track_ids, = {}) execute do |client| client.addTracksToUserPlaylist( uuid, track_ids, .fetch(:start_position, 0), session ) end end |
#count ⇒ Object
Returns Integer.
89 90 91 |
# File 'lib/wimp/playlist.rb', line 89 def count @o.count end |
#remove_tracks_by_indices(indices) ⇒ Object
Returns Boolean Were the request successfull?.
59 60 61 62 63 |
# File 'lib/wimp/playlist.rb', line 59 def remove_tracks_by_indices(indices) execute do |client| client.removeUserPlaylistTracks(uuid, indices, session) end end |
#tracks ⇒ Object
82 83 84 |
# File 'lib/wimp/playlist.rb', line 82 def tracks @tracks end |
#url ⇒ Object
Returns String.
68 69 70 |
# File 'lib/wimp/playlist.rb', line 68 def url "http://wimpmusic.se/playlist/#{uuid}" end |
#uuid ⇒ Object
Returns String.
75 76 77 |
# File 'lib/wimp/playlist.rb', line 75 def uuid @o.uuid end |