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:



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

has_many :annotations

#details_setYt::Models::DetailsSet (readonly)

Returns the video’s content details.

Returns:



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

has_one :details_set

#ratingYt::Models::Rating (readonly)

Returns the video’s rating.

Returns:



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

has_one :rating

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:



51
52
53
54
# File 'lib/yt/models/video.rb', line 51

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:



39
40
41
42
# File 'lib/yt/models/video.rb', line 39

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:



28
29
30
# File 'lib/yt/models/video.rb', line 28

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:



63
64
65
66
# File 'lib/yt/models/video.rb', line 63

def unlike
  rating.update :none
  !liked?
end