Class: Yt::Models::Snippet
- Inherits:
-
Object
- Object
- Yt::Models::Snippet
- Defined in:
- lib/yt/models/snippet.rb
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
-
#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?
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?
114 115 116 |
# File 'lib/yt/models/snippet.rb', line 114 def category_id @category_id ||= @data['categoryId'] end |
#channel_id ⇒ String?
81 82 83 |
# File 'lib/yt/models/snippet.rb', line 81 def channel_id @channel_id ||= @data['channelId'] end |
#channel_title ⇒ String?
92 93 94 |
# File 'lib/yt/models/snippet.rb', line 92 def channel_title @channel_title ||= @data['channelTitle'] end |
#description ⇒ Yt::Models::Description
39 40 41 |
# File 'lib/yt/models/snippet.rb', line 39 def description @description ||= Description.new @data.fetch('description', '') end |
#live_broadcast_content ⇒ String?
125 126 127 |
# File 'lib/yt/models/snippet.rb', line 125 def live_broadcast_content @live_broadcast_content ||= @data['liveBroadcastContent'] end |
#playlist_id ⇒ String?
134 135 136 |
# File 'lib/yt/models/snippet.rb', line 134 def playlist_id @playlist_id ||= @data['playlistId'] end |
#position ⇒ Integer?
144 145 146 |
# File 'lib/yt/models/snippet.rb', line 144 def position @position ||= @data['position'].to_i end |
#published_at ⇒ Time
51 52 53 |
# File 'lib/yt/models/snippet.rb', line 51 def published_at @published_at ||= Time.parse @data['publishedAt'] end |
#tags ⇒ Array<Yt::Models::Tag>
104 105 106 |
# File 'lib/yt/models/snippet.rb', line 104 def @tags ||= @data.fetch 'tags', [] end |
#thumbnail_url(size = :default) ⇒ String?
69 70 71 72 |
# File 'lib/yt/models/snippet.rb', line 69 def thumbnail_url(size = :default) @thumbnails ||= @data.fetch 'thumbnails', {} @thumbnails.fetch(size.to_s, {})['url'] end |
#title ⇒ String
26 27 28 |
# File 'lib/yt/models/snippet.rb', line 26 def title @title ||= @data.fetch 'title', '' end |
#video ⇒ Yt::Models::Video?
162 163 164 |
# File 'lib/yt/models/snippet.rb', line 162 def video @video ||= Video.new id: video_id, auth: @auth if video_id end |
#video_id ⇒ String?
153 154 155 |
# File 'lib/yt/models/snippet.rb', line 153 def video_id @video_id ||= @data.fetch('resourceId', {})['videoId'] end |