Class: Yt::Models::Video

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

Overview

Provides methods to interact with YouTube videos.

Instance Attribute Summary collapse

Attributes inherited from Resource

#auth

Instance Method Summary collapse

Methods inherited from Resource

#initialize, #kind, #username

Constructor Details

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

Instance Attribute Details

#annotationsYt::Collections::Annotations (readonly)

Returns the video’s annotations.

Returns:



20
# File 'lib/yt/models/video.rb', line 20

has_many :annotations

#content_detailYt::Models::ContentDetail (readonly)

Returns the video’s content details.

Returns:



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

has_one :content_detail

#ratingYt::Models::Rating (readonly)

Returns the video’s rating.

Returns:



16
# File 'lib/yt/models/video.rb', line 16

has_one :rating

#statistics_setYt::Models::StatisticsSet (readonly)

Returns the statistics for the video.

Returns:



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

has_one :statistics_set

Instance Method Details

#dislikeBoolean

Dislikes the video on behalf of the authenticated account.

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

Returns:

  • (Boolean)

    whether the account does not like the video.

Raises:



58
59
60
61
# File 'lib/yt/models/video.rb', line 58

def dislike
  rating.update :dislike
  !liked?
end

#likeBoolean

Likes the video on behalf of the authenticated account.

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

Returns:

  • (Boolean)

    whether the account likes the video.

Raises:



46
47
48
49
# File 'lib/yt/models/video.rb', line 46

def like
  rating.update :like
  liked?
end

#liked?Boolean

Returns whether the authenticated account likes the video.

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

Returns:

  • (Boolean)

    whether the account likes the video.

Raises:



35
36
37
# File 'lib/yt/models/video.rb', line 35

def liked?
  rating.rating == :like
end

#unlikeBoolean

Resets the rating of the video on behalf of the authenticated account.

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

Returns:

  • (Boolean)

    whether the account does not like the video.

Raises:



70
71
72
73
# File 'lib/yt/models/video.rb', line 70

def unlike
  rating.update :none
  !liked?
end