Class: Yt::Playlist
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
- #delete ⇒ Object
- #exists? ⇒ Boolean
-
#update(options = {}) ⇒ Object
Valid body (no defaults) are: title (string), description (string), privacy_status (string), tags (array of strings) - since title is required, we set it again if it’s not passed.
Methods inherited from Resource
Methods included from Associations
Methods included from Actions::Update
Constructor Details
This class inherits a constructor from Yt::Resource
Instance Method Details
#delete ⇒ Object
7 8 9 10 |
# File 'lib/yt/models/playlist.rb', line 7 def delete do_delete {@id = nil} !exists? end |
#exists? ⇒ Boolean
35 36 37 |
# File 'lib/yt/models/playlist.rb', line 35 def exists? !@id.nil? end |
#update(options = {}) ⇒ Object
Valid body (no defaults) are: title (string), description (string), privacy_status (string), tags (array of strings) - since title is required, we set it again if it’s not passed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/yt/models/playlist.rb', line 14 def update( = {}) parts, body = [], {id: @id} [:title] ||= title parts << :snippet body[:snippet] = .slice :title, :description, :tags if status = [:privacy_status] parts << :status body[:status] = {privacyStatus: status} end params = {params: {part: parts.join(',')}, body: body} do_update(params, expect: Net::HTTPOK) do |data| @id = data['id'] @snippet = Snippet.new data: data['snippet'] if data['snippet'] @status = Status.new data: data['status'] if data['status'] true end end |