Class: Yt::Models::Snippet

Inherits:
Base
  • Object
show all
Defined in:
lib/yt/models/snippet.rb

Overview

Provides methods to interact with the snippet of YouTube resources.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Associations::HasOne

#has_one

Methods included from Associations::HasMany

#has_many

Methods included from Associations::HasAuthentication

#has_authentication

Constructor Details

#initialize(options = {}) ⇒ Snippet

Returns a new instance of Snippet.



13
14
15
16
# File 'lib/yt/models/snippet.rb', line 13

def initialize(options = {})
  @data = options[:data]
  @auth = options[:auth]
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



11
12
13
# File 'lib/yt/models/snippet.rb', line 11

def data
  @data
end

Instance Method Details

#complete?Boolean

Returns whether YouTube API includes all attributes in this snippet. For instance, YouTube API only returns tags and categoryId on Videos#list, not on Videos#search. And returns position on PlaylistItems#list, not on PlaylistItems#insert. This method is used to guarantee that, when a video was instantiated by one of the methods above, an additional call to is made to retrieve the full snippet in case an attribute is missing.

Returns:

  • (Boolean)

    whether YouTube API includes the complete snippet.

See Also:



44
45
46
# File 'lib/yt/models/snippet.rb', line 44

def complete?
  @complete ||= data.fetch :complete, true
end

#thumbnail_url(size = :default) ⇒ Object



31
32
33
# File 'lib/yt/models/snippet.rb', line 31

def thumbnail_url(size = :default)
  thumbnails.fetch(size.to_s, {})['url']
end