class Yt::Models::PlaylistItem
Provides methods to interact with YouTube playlist items. @see developers.google.com/youtube/v3/docs/playlistItems
Public Class Methods
Source
# File lib/yt/models/playlist_item.rb, line 93 def initialize(options = {}) super options @video = options[:video] if options[:video] end
@private Override Resource’s new to set video if the response includes it
Public Instance Methods
Source
# File lib/yt/models/playlist_item.rb, line 61 def delete(options = {}) do_delete {@id = nil} !exists? end
Deletes the playlist item. @return [Boolean] whether the playlist item does not exist anymore. @raise [Yt::Errors::Unauthorized] if {Resource#auth auth} is not an
authenticated Yt::Account with permissions to delete the item.
Source
# File lib/yt/models/playlist_item.rb, line 51 def position ensure_complete_snippet :position end
@return [Integer] the order in which the item appears in a playlist.
The value is zero-based, so the first item has a position of 0.
Source
# File lib/yt/models/playlist_item.rb, line 73 def update(attributes = {}) super end
Updates the attributes of a playlist item. @return [Boolean] whether the item was successfully updated. @raise [Yt::Errors::Unauthorized] if {Resource#auth auth} is not an
authenticated Yt::Account with permissions to update the item.
@param [Hash] attributes the attributes to update. @option attributes [Integer] the order in which the item should appear
in a playlist. The value is zero-based, so the first position of 0.
Source
# File lib/yt/models/playlist_item.rb, line 80 def video @video ||= Video.new id: video_id, auth: @auth if video_id end
@return [Yt::Models::Video] the video referred by the item.
Source
# File lib/yt/models/playlist_item.rb, line 45 def video_id snippet.resource_id['videoId'] end
@return [String] the ID of the video referred by the item.
Private Instance Methods
Source
# File lib/yt/models/playlist_item.rb, line 104 def delete_params super.tap do |params| params[:params] ||= {} params[:params].merge! @auth.playlist_items_params end end
Source
# File lib/yt/models/playlist_item.rb, line 100 def resource_id {kind: 'youtube#video', videoId: video_id} end
Source
# File lib/yt/models/playlist_item.rb, line 112 def update_parts keys = [:position, :playlist_id, :resource_id] snippet = {keys: keys, required: true} {snippet: snippet} end
@see developers.google.com/youtube/v3/docs/playlistItems/update