Class: Yt::Models::Snippet
- Inherits:
-
Object
- Object
- Yt::Models::Snippet
- Defined in:
- lib/yt/models/snippet.rb
Instance Method Summary collapse
-
#description ⇒ Yt::Description
Return the description of a YouTube resource.
-
#initialize(options = {}) ⇒ Snippet
constructor
A new instance of Snippet.
-
#published_at ⇒ Time or nil
Return the publication date of a YouTube resource.
-
#tags ⇒ Array
Return the tags of a YouTube resource.
-
#thumbnail_url(size = :default) ⇒ String
Return the URL of a thumbnail image of the YouTube resource.
-
#title ⇒ String
Return the title of the YouTube resource.
Constructor Details
#initialize(options = {}) ⇒ Snippet
Returns a new instance of Snippet.
6 7 8 |
# File 'lib/yt/models/snippet.rb', line 6 def initialize( = {}) @data = [:data] end |
Instance Method Details
#description ⇒ Yt::Description
Return the description of a YouTube resource.
20 21 22 |
# File 'lib/yt/models/snippet.rb', line 20 def description @description ||= Description.new @data.fetch('description', '') end |
#published_at ⇒ Time or nil
Return the publication date of a YouTube resource.
27 28 29 |
# File 'lib/yt/models/snippet.rb', line 27 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.
37 38 39 |
# File 'lib/yt/models/snippet.rb', line 37 def @tags ||= @data.fetch 'tags', [] end |
#thumbnail_url(size = :default) ⇒ String
Return the URL of a thumbnail image of the YouTube resource.
44 45 46 47 |
# File 'lib/yt/models/snippet.rb', line 44 def thumbnail_url(size = :default) @thumbnails ||= @data.fetch 'thumbnails', {} @thumbnails.fetch(size.to_s, {})['url'] end |
#title ⇒ String
Return the title of the YouTube resource.
13 14 15 |
# File 'lib/yt/models/snippet.rb', line 13 def title @title ||= @data.fetch 'title', '' end |