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 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.
15 16 17 18 |
# File 'lib/yt/models/snippet.rb', line 15 def initialize( = {}) @data = [:data] @auth = [:auth] end |
Instance Method Details
#category_id ⇒ String?
103 |
# File 'lib/yt/models/snippet.rb', line 103 has_attribute :category_id |
#channel_id ⇒ String?
76 |
# File 'lib/yt/models/snippet.rb', line 76 has_attribute :channel_id |
#channel_title ⇒ String?
85 |
# File 'lib/yt/models/snippet.rb', line 85 has_attribute :channel_title |
#description ⇒ Yt::Models::Description
37 38 39 |
# File 'lib/yt/models/snippet.rb', line 37 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.
155 156 157 |
# File 'lib/yt/models/snippet.rb', line 155 def @includes_tags ||= @data.fetch :includes_tags, true end |
#live_broadcast_content ⇒ String?
112 |
# File 'lib/yt/models/snippet.rb', line 112 has_attribute :live_broadcast_content |
#playlist_id ⇒ String?
119 |
# File 'lib/yt/models/snippet.rb', line 119 has_attribute :playlist_id |
#position ⇒ Integer?
127 |
# File 'lib/yt/models/snippet.rb', line 127 has_attribute :position, type: Integer |
#published_at ⇒ Time
49 |
# File 'lib/yt/models/snippet.rb', line 49 has_attribute :published_at, type: Time |
#tags ⇒ Array<Yt::Models::Tag>
95 |
# File 'lib/yt/models/snippet.rb', line 95 has_attribute :tags, default: [] |
#thumbnail_url(size = :default) ⇒ String?
65 66 67 |
# File 'lib/yt/models/snippet.rb', line 65 def thumbnail_url(size = :default) thumbnails.fetch(size.to_s, {})['url'] end |
#title ⇒ String
26 |
# File 'lib/yt/models/snippet.rb', line 26 has_attribute :title, default: '' |
#video ⇒ Yt::Models::Video?
143 144 145 |
# File 'lib/yt/models/snippet.rb', line 143 def video @video ||= Video.new id: video_id, auth: @auth if video_id end |
#video_id ⇒ String?
134 135 136 |
# File 'lib/yt/models/snippet.rb', line 134 def video_id resource_id['videoId'] end |