Class: Yt::Models::Snippet
Overview
Provides methods to interact with the snippet of YouTube resources.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#complete? ⇒ Boolean
Returns whether YouTube API includes all attributes in this snippet.
-
#initialize(options = {}) ⇒ Snippet
constructor
A new instance of Snippet.
- #thumbnail_url(size = :default) ⇒ Object
Methods included from Associations::HasOne
Methods included from Associations::HasMany
Methods included from Associations::HasAuthentication
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( = {}) @data = [:data] @auth = [:auth] end |
Instance Attribute Details
#data ⇒ Object (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.
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 |