Class: Yt::Models::Playlist
- Defined in:
- lib/yt/models/playlist.rb
Overview
Provides methods to interact with YouTube playlists.
Instance Attribute Summary collapse
-
#playlist_items ⇒ Yt::Collections::PlaylistItems
readonly
The playlist’s items.
Attributes inherited from Resource
Instance Method Summary collapse
-
#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).
- #add_video!(video_id, attributes = {}) ⇒ Object
- #add_videos(video_ids = [], attributes = {}) ⇒ Object
- #add_videos!(video_ids = [], attributes = {}) ⇒ Object
-
#average_time_in_playlist(options = {}) ⇒ Hash<Date, Float>
The average_time_in_playlist for a range of a days.
-
#average_time_in_playlist_on(date) ⇒ Float
The average_time_in_playlist for a single day.
-
#delete(options = {}) ⇒ Boolean
Deletes the playlist.
- #delete_playlist_items(attrs = {}) ⇒ Object
- #exists? ⇒ Boolean
-
#playlist_starts(options = {}) ⇒ Hash<Date, Float>
The playlist_starts for a range of a days.
-
#playlist_starts_on(date) ⇒ Float
The playlist_starts for a single day.
-
#views(options = {}) ⇒ Hash<Date, Float>
The views for a range of a days.
-
#views_on(date) ⇒ Float
The views for a single day.
-
#views_per_playlist_start(options = {}) ⇒ Hash<Date, Float>
The views_per_playlist_start for a range of a days.
-
#views_per_playlist_start_on(date) ⇒ Float
The views_per_playlist_start for a single day.
Methods inherited from Resource
#initialize, #kind, #update, #username
Methods included from Associations::HasReports
Methods included from Associations::HasViewerPercentages
Methods included from Associations::HasOne
Methods included from Associations::HasMany
Methods included from Associations::HasAuthentication
Constructor Details
This class inherits a constructor from Yt::Models::Resource
Instance Attribute Details
#playlist_items ⇒ Yt::Collections::PlaylistItems (readonly)
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
50 51 52 53 |
# File 'lib/yt/models/playlist.rb', line 50 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
55 56 57 58 |
# File 'lib/yt/models/playlist.rb', line 55 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
60 61 62 |
# File 'lib/yt/models/playlist.rb', line 60 def add_videos(video_ids = [], attributes = {}) video_ids.map{|video_id| add_video video_id, attributes} end |
#add_videos!(video_ids = [], attributes = {}) ⇒ Object
64 65 66 |
# File 'lib/yt/models/playlist.rb', line 64 def add_videos!(video_ids = [], attributes = {}) video_ids.map{|video_id| add_video! video_id, attributes} end |
#average_time_in_playlist(options = {}) ⇒ Hash<Date, Float>
Returns the average_time_in_playlist for a range of a days.
21 |
# File 'lib/yt/models/playlist.rb', line 21 has_report :average_time_in_playlist |
#average_time_in_playlist_on(date) ⇒ Float
Returns the average_time_in_playlist for a single day.
21 |
# File 'lib/yt/models/playlist.rb', line 21 has_report :average_time_in_playlist |
#delete(options = {}) ⇒ Boolean
33 34 35 36 |
# File 'lib/yt/models/playlist.rb', line 33 def delete( = {}) do_delete {@id = nil} !exists? end |
#delete_playlist_items(attrs = {}) ⇒ Object
68 69 70 |
# File 'lib/yt/models/playlist.rb', line 68 def delete_playlist_items(attrs = {}) playlist_items.delete_all attrs end |
#exists? ⇒ Boolean
38 39 40 |
# File 'lib/yt/models/playlist.rb', line 38 def exists? !@id.nil? end |
#playlist_starts(options = {}) ⇒ Hash<Date, Float>
Returns the playlist_starts for a range of a days.
18 |
# File 'lib/yt/models/playlist.rb', line 18 has_report :playlist_starts |
#playlist_starts_on(date) ⇒ Float
Returns the playlist_starts for a single day.
18 |
# File 'lib/yt/models/playlist.rb', line 18 has_report :playlist_starts |
#views(options = {}) ⇒ Hash<Date, Float>
Returns the views for a range of a days.
15 |
# File 'lib/yt/models/playlist.rb', line 15 has_report :views |
#views_on(date) ⇒ Float
Returns the views for a single day.
15 |
# File 'lib/yt/models/playlist.rb', line 15 has_report :views |
#views_per_playlist_start(options = {}) ⇒ Hash<Date, Float>
Returns the views_per_playlist_start for a range of a days.
24 |
# File 'lib/yt/models/playlist.rb', line 24 has_report :views_per_playlist_start |
#views_per_playlist_start_on(date) ⇒ Float
Returns the views_per_playlist_start for a single day.
24 |
# File 'lib/yt/models/playlist.rb', line 24 has_report :views_per_playlist_start |