Class: Yt::Models::Snippet
Overview
Contains basic information about the resource. The details of the snippet are different for the different types of resources.
Resources with a snippet are: channels, playlists, playlist items and videos.
Constant Summary collapse
- BROADCAST_TYPES =
%q(live none upcoming)
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #category_id ⇒ String?
- #channel_id ⇒ String?
- #channel_title ⇒ String?
- #description ⇒ Yt::Models::Description
-
#includes_tags ⇒ Boolean
Returns whether YouTube API includes tags in this snippet.
-
#initialize(options = {}) ⇒ Snippet
constructor
A new instance of Snippet.
- #live_broadcast_content ⇒ String?
- #playlist_id ⇒ String?
- #position ⇒ Integer?
- #published_at ⇒ Time
- #tags ⇒ Array<Yt::Models::Tag>
- #thumbnail_url(size = :default) ⇒ String?
- #title ⇒ String
- #video ⇒ Yt::Models::Video?
- #video_id ⇒ String?
Methods included from Associations::HasReports
Methods included from Associations::HasViewerPercentages
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.
17 18 19 20 |
# File 'lib/yt/models/snippet.rb', line 17 def initialize( = {}) @data = [:data] @auth = [:auth] end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
15 16 17 |
# File 'lib/yt/models/snippet.rb', line 15 def data @data end |
Instance Method Details
#category_id ⇒ String?
105 |
# File 'lib/yt/models/snippet.rb', line 105 has_attribute :category_id |
#channel_id ⇒ String?
78 |
# File 'lib/yt/models/snippet.rb', line 78 has_attribute :channel_id |
#channel_title ⇒ String?
87 |
# File 'lib/yt/models/snippet.rb', line 87 has_attribute :channel_title |
#description ⇒ Yt::Models::Description
39 40 41 |
# File 'lib/yt/models/snippet.rb', line 39 has_attribute :description, default: '' do |description_text| Description.new description_text end |
#includes_tags ⇒ Boolean
Returns whether YouTube API includes tags in this snippet. YouTube API only returns tags on Videos#list, not on Videos#search. This method is used to guarantee that, when a video was instantiated by calling account.videos or channel.videos, then video.tags is not simply returned as empty, but an additional call to Videos#list is made to retrieve the correct tags.
157 158 159 |
# File 'lib/yt/models/snippet.rb', line 157 def @includes_tags ||= data.fetch :includes_tags, true end |
#live_broadcast_content ⇒ String?
114 |
# File 'lib/yt/models/snippet.rb', line 114 has_attribute :live_broadcast_content |
#playlist_id ⇒ String?
121 |
# File 'lib/yt/models/snippet.rb', line 121 has_attribute :playlist_id |
#position ⇒ Integer?
129 |
# File 'lib/yt/models/snippet.rb', line 129 has_attribute :position, type: Integer |
#published_at ⇒ Time
51 |
# File 'lib/yt/models/snippet.rb', line 51 has_attribute :published_at, type: Time |
#tags ⇒ Array<Yt::Models::Tag>
97 |
# File 'lib/yt/models/snippet.rb', line 97 has_attribute :tags, default: [] |
#thumbnail_url(size = :default) ⇒ String?
67 68 69 |
# File 'lib/yt/models/snippet.rb', line 67 def thumbnail_url(size = :default) thumbnails.fetch(size.to_s, {})['url'] end |
#title ⇒ String
28 |
# File 'lib/yt/models/snippet.rb', line 28 has_attribute :title, default: '' |
#video ⇒ Yt::Models::Video?
145 146 147 |
# File 'lib/yt/models/snippet.rb', line 145 def video @video ||= Video.new id: video_id, auth: @auth if video_id end |
#video_id ⇒ String?
136 137 138 |
# File 'lib/yt/models/snippet.rb', line 136 def video_id resource_id['videoId'] end |