Class: Dm::DailyMotionResource
- Inherits:
-
Object
- Object
- Dm::DailyMotionResource
- Includes:
- Readable, Requestable, ServerTokens
- Defined in:
- lib/dm/youtube_resource.rb
Overview
Provides read-only access to a DailyMotion 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 DailyMotion account/channel.
-
#initialize(attrs = {}) ⇒ DailyMotionResource
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 = {}) ⇒ DailyMotionResource
Initialize a resource by URL
28 29 30 |
# File 'lib/dm/youtube_resource.rb', line 28 def initialize(attrs = {}) @url = attrs[:url] end |
Instance Method Details
#info ⇒ Hash
Return the profile info of a DailyMotion account/channel.
48 49 50 51 52 53 54 |
# File 'lib/dm/youtube_resource.rb', line 48 def info @info ||= request! method: :get, host: 'https://www.googleapis.com', path: "/dailymotion/v3/#{info_path}", valid_if: -> resp, body {resp.code == '200' && body['items'].any?}, extract: -> body {body['items'].first} end |