Class: VideoStore::Vimeo
Overview
Constant Summary
Constants inherited
from Video
VideoStore::Video::ATTRIBUTES
Instance Attribute Summary
Attributes inherited from Video
#channel_name, #comment_count, #duration, #likes, #thumbnail_uri, #title, #video_id, #views
Instance Method Summary
collapse
Constructor Details
#initialize(video_id) ⇒ Vimeo
Returns a new instance of Vimeo.
120
121
122
123
|
# File 'lib/videostore.rb', line 120
def initialize(video_id)
@video_id = video_id
populate_attributes
end
|
Instance Method Details
#info ⇒ Object
148
149
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/videostore.rb', line 148
def info
response = {}
if present?
ATTRIBUTES.each do |attribute|
response.merge!({attribute => send(attribute)})
end
else
response.merge!({:video_id => @video_id})
response.merge!({:video_not_found => 'video_not_found'})
end
response
end
|
#populate_attributes ⇒ Object
134
135
136
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/videostore.rb', line 134
def populate_attributes
if present?
fetch_data
@title = @response['title']
@thumbnail_uri = @response['thumbnail_large']
@channel_name = @response['user_name']
@views = @response['stats_number_of_plays']
@likes = @response['stats_number_of_likes']
= @response['stats_number_of_comments']
@duration = @response['duration']
end
end
|
#present? ⇒ Boolean
125
126
127
128
|
# File 'lib/videostore.rb', line 125
def present?
::Vimeo::Simple::Video.info(@video_id
).parsed_response.class == Array
end
|
#uri ⇒ Object
130
131
132
|
# File 'lib/videostore.rb', line 130
def uri
"http:://vimeo.com/#{@video_id}"
end
|
#vimeo? ⇒ Boolean
162
|
# File 'lib/videostore.rb', line 162
def vimeo? ; true ; end
|
#youtube? ⇒ Boolean
161
|
# File 'lib/videostore.rb', line 161
def youtube? ; false ; end
|