Class: Yt::Models::Channel

Inherits:
Resource show all
Defined in:
lib/yt/models/channel.rb

Overview

A channel resource contains information about a YouTube channel.

Instance Attribute Summary collapse

Attributes inherited from Resource

#auth

Instance Method Summary collapse

Methods inherited from Resource

#initialize, #kind, #username

Methods included from Associations::HasReports

#has_report

Methods included from Associations::HasOne

#has_one

Methods included from Associations::HasMany

#has_many

Methods included from Associations::HasAuthentication

#has_authentication

Constructor Details

This class inherits a constructor from Yt::Models::Resource

Instance Attribute Details

#playlistsYt::Collections::Playlists (readonly)

Returns the channel’s playlists.

Returns:



18
# File 'lib/yt/models/channel.rb', line 18

has_many :playlists

#statistics_setYt::Models::StatisticsSet (readonly)

Returns the statistics for the video.

Returns:



43
# File 'lib/yt/models/channel.rb', line 43

has_one :statistics_set

#subscriptionsYt::Collections::Subscriptions (readonly)

Returns the channel’s subscriptions.

Returns:



10
# File 'lib/yt/models/channel.rb', line 10

has_many :subscriptions

#videosYt::Collections::Videos (readonly)

Returns the channel’s videos.

Returns:



14
# File 'lib/yt/models/channel.rb', line 14

has_many :videos

Instance Method Details

#comments(options = {}) ⇒ Hash<Date, Float>

Returns the comments for a range of a days.

Parameters:

  • options (Hash) (defaults to: {})

    the range of days to get the comments for.

Options Hash (options):

  • :since (#to_date)

    The first day of the range. Also aliased as :from.

  • :until (#to_date)

    The last day of the range. Also aliased as :to.

Returns:

  • (Hash<Date, Float>)

    the comments for a range of a days.



27
# File 'lib/yt/models/channel.rb', line 27

has_report :comments

#comments_on(date) ⇒ Float

Returns the comments for a single day.

Parameters:

  • date (#to_date)

    The single day to get the comments for.

Returns:

  • (Float)

    the comments for a single day.



27
# File 'lib/yt/models/channel.rb', line 27

has_report :comments

#create_playlist(params = {}) ⇒ Object



106
107
108
# File 'lib/yt/models/channel.rb', line 106

def create_playlist(params = {})
  playlists.insert params
end

#delete_playlists(attrs = {}) ⇒ Object



110
111
112
# File 'lib/yt/models/channel.rb', line 110

def delete_playlists(attrs = {})
  playlists.delete_all attrs
end

#dislikes(options = {}) ⇒ Hash<Date, Float>

Returns the dislikes for a range of a days.

Parameters:

  • options (Hash) (defaults to: {})

    the range of days to get the dislikes for.

Options Hash (options):

  • :since (#to_date)

    The first day of the range. Also aliased as :from.

  • :until (#to_date)

    The last day of the range. Also aliased as :to.

Returns:

  • (Hash<Date, Float>)

    the dislikes for a range of a days.



33
# File 'lib/yt/models/channel.rb', line 33

has_report :dislikes

#dislikes_on(date) ⇒ Float

Returns the dislikes for a single day.

Parameters:

  • date (#to_date)

    The single day to get the dislikes for.

Returns:

  • (Float)

    the dislikes for a single day.



33
# File 'lib/yt/models/channel.rb', line 33

has_report :dislikes

#earnings(options = {}) ⇒ Hash<Date, Float>

Returns the earnings for a range of a days.

Parameters:

  • options (Hash) (defaults to: {})

    the range of days to get the earnings for.

Options Hash (options):

  • :since (#to_date)

    The first day of the range. Also aliased as :from.

  • :until (#to_date)

    The last day of the range. Also aliased as :to.

Returns:

  • (Hash<Date, Float>)

    the earnings for a range of a days.



21
# File 'lib/yt/models/channel.rb', line 21

has_report :earnings

#earnings_on(date) ⇒ Float

Returns the earnings for a single day.

Parameters:

  • date (#to_date)

    The single day to get the earnings for.

Returns:

  • (Float)

    the earnings for a single day.



21
# File 'lib/yt/models/channel.rb', line 21

has_report :earnings

#impressions(options = {}) ⇒ Hash<Date, Float>

Returns the impressions for a range of a days.

Parameters:

  • options (Hash) (defaults to: {})

    the range of days to get the impressions for.

Options Hash (options):

  • :since (#to_date)

    The first day of the range. Also aliased as :from.

  • :until (#to_date)

    The last day of the range. Also aliased as :to.

Returns:

  • (Hash<Date, Float>)

    the impressions for a range of a days.



39
# File 'lib/yt/models/channel.rb', line 39

has_report :impressions

#impressions_on(date) ⇒ Float

Returns the impressions for a single day.

Parameters:

  • date (#to_date)

    The single day to get the impressions for.

Returns:

  • (Float)

    the impressions for a single day.



39
# File 'lib/yt/models/channel.rb', line 39

has_report :impressions

#likes(options = {}) ⇒ Hash<Date, Float>

Returns the likes for a range of a days.

Parameters:

  • options (Hash) (defaults to: {})

    the range of days to get the likes for.

Options Hash (options):

  • :since (#to_date)

    The first day of the range. Also aliased as :from.

  • :until (#to_date)

    The last day of the range. Also aliased as :to.

Returns:

  • (Hash<Date, Float>)

    the likes for a range of a days.



30
# File 'lib/yt/models/channel.rb', line 30

has_report :likes

#likes_on(date) ⇒ Float

Returns the likes for a single day.

Parameters:

  • date (#to_date)

    The single day to get the likes for.

Returns:

  • (Float)

    the likes for a single day.



30
# File 'lib/yt/models/channel.rb', line 30

has_report :likes

#shares(options = {}) ⇒ Hash<Date, Float>

Returns the shares for a range of a days.

Parameters:

  • options (Hash) (defaults to: {})

    the range of days to get the shares for.

Options Hash (options):

  • :since (#to_date)

    The first day of the range. Also aliased as :from.

  • :until (#to_date)

    The last day of the range. Also aliased as :to.

Returns:

  • (Hash<Date, Float>)

    the shares for a range of a days.



36
# File 'lib/yt/models/channel.rb', line 36

has_report :shares

#shares_on(date) ⇒ Float

Returns the shares for a single day.

Parameters:

  • date (#to_date)

    The single day to get the shares for.

Returns:

  • (Float)

    the shares for a single day.



36
# File 'lib/yt/models/channel.rb', line 36

has_report :shares

#subscribeObject

Subscribes the authenticated account to the channel. Does not raise an error if the account was already subscribed.

This method requires auth to return an authenticated instance of Account.

Raises:



65
66
67
# File 'lib/yt/models/channel.rb', line 65

def subscribe
  subscriptions.insert ignore_errors: true
end

#subscribe!Object

Subscribes the authenticated account to the channel. Raises an error if the account was already subscribed.

This method requires auth to return an authenticated instance of Account.

Raises:



78
79
80
# File 'lib/yt/models/channel.rb', line 78

def subscribe!
  subscriptions.insert
end

#subscribed?Boolean

Returns whether the authenticated account is subscribed to the channel.

This method requires auth to return an authenticated instance of Account.

Returns:

  • (Boolean)

    whether the account is subscribed to the channel.

Raises:



54
55
56
# File 'lib/yt/models/channel.rb', line 54

def subscribed?
  subscriptions.any?{|s| s.exists?}
end

#unsubscribeObject

Unsubscribes the authenticated account from the channel. Does not raise an error if the account was not subscribed.

This method requires auth to return an authenticated instance of Account.

Raises:



89
90
91
# File 'lib/yt/models/channel.rb', line 89

def unsubscribe
  subscriptions.delete_all({}, ignore_errors: true)
end

#unsubscribe!Object

Unsubscribes the authenticated account from the channel. Raises an error if the account was not subscribed.

This method requires auth to return an authenticated instance of Account.

Raises:



102
103
104
# File 'lib/yt/models/channel.rb', line 102

def unsubscribe!
  subscriptions.delete_all
end

#views(options = {}) ⇒ Hash<Date, Float>

Returns the views for a range of a days.

Parameters:

  • options (Hash) (defaults to: {})

    the range of days to get the views for.

Options Hash (options):

  • :since (#to_date)

    The first day of the range. Also aliased as :from.

  • :until (#to_date)

    The last day of the range. Also aliased as :to.

Returns:

  • (Hash<Date, Float>)

    the views for a range of a days.



24
# File 'lib/yt/models/channel.rb', line 24

has_report :views

#views_on(date) ⇒ Float

Returns the views for a single day.

Parameters:

  • date (#to_date)

    The single day to get the views for.

Returns:

  • (Float)

    the views for a single day.



24
# File 'lib/yt/models/channel.rb', line 24

has_report :views