Class: Googol::YoutubeResource
- Inherits:
-
Object
- Object
- Googol::YoutubeResource
- Includes:
- Readable, Requestable, ServerTokens
- Defined in:
- lib/googol/youtube_resource.rb
Overview
Provides read-only access to a Youtube resource (a channel or a video).
Note that this class does not require the user to authenticate.
Instance Method Summary collapse
-
#info ⇒ Hash
Return the profile info of a Youtube account/channel.
-
#initialize(attrs = {}) ⇒ YoutubeResource
constructor
Initialize a resource by URL.
Methods included from ServerTokens
Methods included from Readable
#description, #id, #kind, #thumbnail_url, #title
Methods included from Requestable
Constructor Details
#initialize(attrs = {}) ⇒ YoutubeResource
Initialize a resource by URL
28 29 30 |
# File 'lib/googol/youtube_resource.rb', line 28 def initialize(attrs = {}) @url = attrs[:url] end |
Instance Method Details
#info ⇒ Hash
Return the profile info of a Youtube account/channel.
48 49 50 51 52 53 54 55 |
# File 'lib/googol/youtube_resource.rb', line 48 def info @info_response ||= request! host: 'https://www.googleapis.com', path: "/youtube/v3/#{info_path}" if @info_response[:items].any? @info_response[:items].first else raise RequestError, "Youtube resource not found at #{@url}" end end |