Class: Yt::Models::Snippet
- Inherits:
-
Object
- Object
- Yt::Models::Snippet
- Defined in:
- lib/yt/models/snippet.rb
Overview
Encapsulates information about the snippet of a resource, for instance a channel.
Instance Method Summary collapse
-
#description ⇒ Yt::Models::Description
The resource’s description.
-
#initialize(options = {}) ⇒ Snippet
constructor
A new instance of Snippet.
-
#published_at ⇒ Time or nil
The date and time that the resource was created.
-
#tags ⇒ Array
Return the tags of a YouTube resource.
-
#thumbnail_url(size = :default) ⇒ String
A thumbnail image associated with the resource.
-
#title ⇒ String
The resource’s title.
Constructor Details
#initialize(options = {}) ⇒ Snippet
Returns a new instance of Snippet.
9 10 11 |
# File 'lib/yt/models/snippet.rb', line 9 def initialize( = {}) @data = [:data] end |
Instance Method Details
#description ⇒ Yt::Models::Description
Returns the resource’s description.
19 20 21 |
# File 'lib/yt/models/snippet.rb', line 19 def description @description ||= Description.new @data.fetch('description', '') end |
#published_at ⇒ Time or nil
Returns the date and time that the resource was created.
24 25 26 |
# File 'lib/yt/models/snippet.rb', line 24 def published_at @published_at ||= Time.parse @data['publishedAt'] end |
#tags ⇒ Array
Note:
YouTube API only includes tags in a resource’s snippet if the resource is a video belonging to the authenticated account.
Return the tags of a YouTube resource.
34 35 36 |
# File 'lib/yt/models/snippet.rb', line 34 def @tags ||= @data.fetch 'tags', [] end |
#thumbnail_url(size = :default) ⇒ String
Returns a thumbnail image associated with the resource.
45 46 47 48 |
# File 'lib/yt/models/snippet.rb', line 45 def thumbnail_url(size = :default) @thumbnails ||= @data.fetch 'thumbnails', {} @thumbnails.fetch(size.to_s, {})['url'] end |
#title ⇒ String
Returns the resource’s title.
14 15 16 |
# File 'lib/yt/models/snippet.rb', line 14 def title @title ||= @data.fetch 'title', '' end |