Class: Yt::Models::Playlist
Overview
Provides methods to interact with YouTube playlists.
Instance Attribute Summary collapse
Attributes inherited from Resource
#auth
Instance Method Summary
collapse
Methods inherited from Resource
#initialize, #kind, #update, #username
#has_report
#has_viewer_percentages
#has_one
#has_many
#has_authentication
Instance Attribute Details
Returns the playlist’s items.
12
|
# File 'lib/yt/models/playlist.rb', line 12
has_many :playlist_items
|
Instance Method Details
#add_video(video_id, attributes = {}) ⇒ Yt::PlaylistItem
Adds a video to the playlist Does not raise an error if the video cannot be added (e.g., unknown).
This method requires auth to return an authenticated instance of Account with permissions to update the playlist.
38
39
40
41
|
# File 'lib/yt/models/playlist.rb', line 38
def add_video(video_id, attributes = {})
playlist_item_params = playlist_item_params(video_id, attributes)
playlist_items.insert playlist_item_params, ignore_errors: true
end
|
#add_video!(video_id, attributes = {}) ⇒ Object
43
44
45
46
|
# File 'lib/yt/models/playlist.rb', line 43
def add_video!(video_id, attributes = {})
playlist_item_params = playlist_item_params(video_id, attributes)
playlist_items.insert playlist_item_params
end
|
#add_videos(video_ids = [], attributes = {}) ⇒ Object
48
49
50
|
# File 'lib/yt/models/playlist.rb', line 48
def add_videos(video_ids = [], attributes = {})
video_ids.map{|video_id| add_video video_id, attributes}
end
|
#add_videos!(video_ids = [], attributes = {}) ⇒ Object
52
53
54
|
# File 'lib/yt/models/playlist.rb', line 52
def add_videos!(video_ids = [], attributes = {})
video_ids.map{|video_id| add_video! video_id, attributes}
end
|
#delete(options = {}) ⇒ Boolean
Deletes the playlist.
This method requires auth to return an authenticated instance of Account with permissions to delete the playlist.
21
22
23
24
|
# File 'lib/yt/models/playlist.rb', line 21
def delete(options = {})
do_delete {@id = nil}
!exists?
end
|
#delete_playlist_items(attrs = {}) ⇒ Object
56
57
58
|
# File 'lib/yt/models/playlist.rb', line 56
def delete_playlist_items(attrs = {})
playlist_items.delete_all attrs
end
|
#exists? ⇒ Boolean
26
27
28
|
# File 'lib/yt/models/playlist.rb', line 26
def exists?
!@id.nil?
end
|