Class: Yt::Models::Snippet

Inherits:
Object
  • Object
show all
Defined in:
lib/yt/models/snippet.rb

Overview

Encapsulates information about the snippet of a resource, for instance a channel.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Snippet



9
10
11
# File 'lib/yt/models/snippet.rb', line 9

def initialize(options = {})
  @data = options[:data]
end

Instance Method Details

#descriptionYt::Models::Description



19
20
21
# File 'lib/yt/models/snippet.rb', line 19

def description
  @description ||= Description.new @data.fetch('description', '')
end

#published_atTime or nil



24
25
26
# File 'lib/yt/models/snippet.rb', line 24

def published_at
  @published_at ||= Time.parse @data['publishedAt']
end

#tagsArray

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
  @tags ||= @data.fetch 'tags', []
end

#thumbnail_url(size = :default) ⇒ String



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

#titleString



14
15
16
# File 'lib/yt/models/snippet.rb', line 14

def title
  @title ||= @data.fetch 'title', ''
end