Class: Yt::Models::Channel
- Defined in:
- lib/yt/models/channel.rb
Overview
A channel resource contains information about a YouTube channel.
Instance Attribute Summary collapse
-
#content_owner_detail ⇒ Yt::Models::ContentOwnerDetail
readonly
The video’s content owner details.
-
#playlists ⇒ Yt::Collections::Playlists
readonly
The channel’s playlists.
-
#statistics_set ⇒ Yt::Models::StatisticsSet
readonly
The statistics for the video.
-
#subscribed_channels ⇒ Yt::Collections::SubscribedChannels
readonly
The channels that the channel is subscribed to.
-
#subscription ⇒ Yt::Models::Subscription
readonly
The channel’s subscription by auth.
-
#videos ⇒ Yt::Collections::Videos
readonly
The channel’s videos.
Attributes inherited from Resource
Instance Method Summary collapse
-
#comments(options = {}) ⇒ Hash<Date, Float>
The comments for a range of a days.
-
#comments_on(date) ⇒ Float
The comments for a single day.
- #delete_playlists(attrs = {}) ⇒ Object
-
#dislikes(options = {}) ⇒ Hash<Date, Float>
The dislikes for a range of a days.
-
#dislikes_on(date) ⇒ Float
The dislikes for a single day.
-
#earnings(options = {}) ⇒ Hash<Date, Float>
The earnings for a range of a days.
-
#earnings_on(date) ⇒ Float
The earnings for a single day.
-
#impressions(options = {}) ⇒ Hash<Date, Float>
The impressions for a range of a days.
-
#impressions_on(date) ⇒ Float
The impressions for a single day.
-
#initialize(options = {}) ⇒ Channel
constructor
Override Resource’s new to set statistics as well if the response includes them.
-
#likes(options = {}) ⇒ Hash<Date, Float>
The likes for a range of a days.
-
#likes_on(date) ⇒ Float
The likes for a single day.
-
#shares(options = {}) ⇒ Hash<Date, Float>
The shares for a range of a days.
-
#shares_on(date) ⇒ Float
The shares for a single day.
-
#subscribe ⇒ Object
Subscribes the authenticated account to the channel.
-
#subscribe! ⇒ Object
Subscribes the authenticated account to the channel.
-
#subscribed? ⇒ Boolean
Returns whether the authenticated account is subscribed to the channel.
-
#unsubscribe ⇒ Object
Unsubscribes the authenticated account from the channel.
-
#unsubscribe! ⇒ Object
Unsubscribes the authenticated account from the channel.
-
#viewer_percentage(filters = {}) ⇒ Float
The percentage of viewer matching the filters.
-
#viewer_percentages ⇒ Hash<Symbol,Hash<String,Float>>
The viewer percentages.
-
#views(options = {}) ⇒ Hash<Date, Float>
The views for a range of a days.
-
#views_on(date) ⇒ Float
The views for a single day.
Methods inherited from Resource
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
#initialize(options = {}) ⇒ Channel
Override Resource’s new to set statistics as well if the response includes them
68 69 70 71 72 73 74 75 76 |
# File 'lib/yt/models/channel.rb', line 68 def initialize( = {}) super if [:statistics] @statistics_set = StatisticsSet.new data: [:statistics] end if [:viewer_percentages] @viewer_percentages = [:viewer_percentages] end end |
Instance Attribute Details
#content_owner_detail ⇒ Yt::Models::ContentOwnerDetail (readonly)
Returns the video’s content owner details.
49 |
# File 'lib/yt/models/channel.rb', line 49 has_one :content_owner_detail |
#playlists ⇒ Yt::Collections::Playlists (readonly)
Returns the channel’s playlists.
14 |
# File 'lib/yt/models/channel.rb', line 14 has_many :playlists |
#statistics_set ⇒ Yt::Models::StatisticsSet (readonly)
Returns the statistics for the video.
42 |
# File 'lib/yt/models/channel.rb', line 42 has_one :statistics_set |
#subscribed_channels ⇒ Yt::Collections::SubscribedChannels (readonly)
Returns the channels that the channel is subscribed to.
56 |
# File 'lib/yt/models/channel.rb', line 56 has_many :subscribed_channels |
#subscription ⇒ Yt::Models::Subscription (readonly)
Returns the channel’s subscription by auth.
64 |
# File 'lib/yt/models/channel.rb', line 64 has_one :subscription |
#videos ⇒ Yt::Collections::Videos (readonly)
Returns the channel’s videos.
10 |
# File 'lib/yt/models/channel.rb', line 10 has_many :videos |
Instance Method Details
#comments(options = {}) ⇒ Hash<Date, Float>
Returns the comments for a range of a days.
23 |
# File 'lib/yt/models/channel.rb', line 23 has_report :comments |
#comments_on(date) ⇒ Float
Returns the comments for a single day.
23 |
# File 'lib/yt/models/channel.rb', line 23 has_report :comments |
#delete_playlists(attrs = {}) ⇒ Object
146 147 148 |
# File 'lib/yt/models/channel.rb', line 146 def delete_playlists(attrs = {}) playlists.delete_all attrs end |
#dislikes(options = {}) ⇒ Hash<Date, Float>
Returns the dislikes for a range of a days.
29 |
# File 'lib/yt/models/channel.rb', line 29 has_report :dislikes |
#dislikes_on(date) ⇒ Float
Returns the dislikes for a single day.
29 |
# File 'lib/yt/models/channel.rb', line 29 has_report :dislikes |
#earnings(options = {}) ⇒ Hash<Date, Float>
Returns the earnings for a range of a days.
17 |
# File 'lib/yt/models/channel.rb', line 17 has_report :earnings |
#earnings_on(date) ⇒ Float
Returns the earnings for a single day.
17 |
# File 'lib/yt/models/channel.rb', line 17 has_report :earnings |
#impressions(options = {}) ⇒ Hash<Date, Float>
Returns the impressions for a range of a days.
35 |
# File 'lib/yt/models/channel.rb', line 35 has_report :impressions |
#impressions_on(date) ⇒ Float
Returns the impressions for a single day.
35 |
# File 'lib/yt/models/channel.rb', line 35 has_report :impressions |
#likes(options = {}) ⇒ Hash<Date, Float>
Returns the likes for a range of a days.
26 |
# File 'lib/yt/models/channel.rb', line 26 has_report :likes |
#likes_on(date) ⇒ Float
Returns the likes for a single day.
26 |
# File 'lib/yt/models/channel.rb', line 26 has_report :likes |
#shares(options = {}) ⇒ Hash<Date, Float>
Returns the shares for a range of a days.
32 |
# File 'lib/yt/models/channel.rb', line 32 has_report :shares |
#shares_on(date) ⇒ Float
Returns the shares for a single day.
32 |
# File 'lib/yt/models/channel.rb', line 32 has_report :shares |
#subscribe ⇒ Object
139 140 141 142 143 144 |
# File 'lib/yt/models/channel.rb', line 139 def subscribe subscriptions.insert(ignore_errors: true).tap do |subscription| throttle_subscriptions @subscription = subscription end end |
#subscribe! ⇒ Object
125 126 127 128 129 130 |
# File 'lib/yt/models/channel.rb', line 125 def subscribe! subscriptions.insert.tap do |subscription| throttle_subscriptions @subscription = subscription end end |
#subscribed? ⇒ Boolean
85 86 87 88 89 90 |
# File 'lib/yt/models/channel.rb', line 85 def subscribed? sleep [(@subscriptions_updated_at || Time.now) - Time.now, 0].max subscription.exists? rescue Errors::NoItems false end |
#unsubscribe ⇒ Object
112 113 114 |
# File 'lib/yt/models/channel.rb', line 112 def unsubscribe unsubscribe! if subscribed? end |
#unsubscribe! ⇒ Object
101 102 103 |
# File 'lib/yt/models/channel.rb', line 101 def unsubscribe! subscription.delete.tap{ throttle_subscriptions } end |
#viewer_percentage(filters = {}) ⇒ Float
Returns the percentage of viewer matching the filters.
38 |
# File 'lib/yt/models/channel.rb', line 38 has_viewer_percentages |
#viewer_percentages ⇒ Hash<Symbol,Hash<String,Float>>
Returns the viewer percentages. The first-level hash identifies the genres (:female, :male). The second-level hash identifies the age ranges (‘18-24’, ‘25-34’, ‘35-44’, ‘45-54’, ‘55-64’, ‘65-’).
38 |
# File 'lib/yt/models/channel.rb', line 38 has_viewer_percentages |
#views(options = {}) ⇒ Hash<Date, Float>
Returns the views for a range of a days.
20 |
# File 'lib/yt/models/channel.rb', line 20 has_report :views |
#views_on(date) ⇒ Float
Returns the views for a single day.
20 |
# File 'lib/yt/models/channel.rb', line 20 has_report :views |