Class: SimpleSpotify::Model::Playlist

Inherits:
Object
  • Object
show all
Includes:
Resource
Defined in:
lib/simplespotify/models/playlist.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Resource

included

Class Method Details

.create(user, name, client = nil, public: true) ⇒ Object


Create




76
77
78
79
# File 'lib/simplespotify/models/playlist.rb', line 76

def self.create user, name, client=nil, public:true
  client ||= SimpleSpotify.default_client
  client.playlist_create(user, name, public: public)
end

Instance Method Details

#add_tracks(tracks, position = nil, client = nil) ⇒ Object



37
38
39
40
# File 'lib/simplespotify/models/playlist.rb', line 37

def add_tracks tracks, position=nil, client=nil
  client ||= SimpleSpotify.default_client
  client.playlist_tracks_add(self, tracks: tracks, position: position)
end

#change_details!(client = nil) ⇒ Object



24
25
26
27
# File 'lib/simplespotify/models/playlist.rb', line 24

def change_details! client=nil
  client ||= SimpleSpotify.default_client
  client.change_details(self, name: name, public: @public)
end

#follow(client = nil, public: true) ⇒ Object


Follows




62
63
64
65
# File 'lib/simplespotify/models/playlist.rb', line 62

def follow client=nil, public: true
  client ||= SimpleSpotify.default_client
  client.playlist_follow(self, public: public)
end

#public?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/simplespotify/models/playlist.rb', line 19

def public?
  @public == true
end

#remove_tracks(client = nil, tracks: nil, positions: nil, snapshot_id: nil) ⇒ Object



42
43
44
45
46
# File 'lib/simplespotify/models/playlist.rb', line 42

def remove_tracks client=nil, tracks: nil, positions: nil, snapshot_id: nil
  client ||= SimpleSpotify.default_client
  snapshot_id ||= @snapshot_id unless positions.nil?
  client.playlist_tracks_remove(self, tracks: tracks, positions: positions, snapshot_id: snapshot_id)
end

#reorder_tracks(client = nil, payload) ⇒ Object



48
49
50
51
# File 'lib/simplespotify/models/playlist.rb', line 48

def reorder_tracks client=nil, payload
  client ||= SimpleSpotify.default_client
  client.playlist_tracks_reorder(self, payload)
end

#replace_tracks(client = nil, tracks: []) ⇒ Object



53
54
55
56
# File 'lib/simplespotify/models/playlist.rb', line 53

def replace_tracks client=nil, tracks: []
  client ||= SimpleSpotify.default_client
  client.playlist_tracks_reorder(self, tracks: tracks)
end

#tracks!(client = nil, options = {}) ⇒ Object


Tracks




32
33
34
35
# File 'lib/simplespotify/models/playlist.rb', line 32

def tracks! client=nil, options={}
  client ||= SimpleSpotify.default_client
  client.playlist_tracks(self, options)
end

#unfollowObject



67
68
69
70
# File 'lib/simplespotify/models/playlist.rb', line 67

def unfollow
  client ||= SimpleSpotify.default_client
  client.playlist_unfollow(self)
end