Class: VideoStore::Vimeo

Inherits:
Video
  • Object
show all
Defined in:
lib/videostore.rb

Overview

end of Youtube class

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

Methods inherited from Video

#inspect

Constructor Details

#initialize(video_id) ⇒ Vimeo

Returns a new instance of Vimeo.



127
128
129
130
# File 'lib/videostore.rb', line 127

def initialize(video_id) 
  @video_id = video_id
  populate_attributes
end

Instance Method Details

#infoObject



155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/videostore.rb', line 155

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_attributesObject



141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/videostore.rb', line 141

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']
    @comment_count =  @response['stats_number_of_comments']
    @duration =  @response['duration']
  end
end

#present?Boolean

Returns:

  • (Boolean)


132
133
134
135
# File 'lib/videostore.rb', line 132

def present?
  ::Vimeo::Simple::Video.info(@video_id
    ).parsed_response.class == Array
end

#uriObject



137
138
139
# File 'lib/videostore.rb', line 137

def uri
  "http:://vimeo.com/#{@video_id}"
end

#vimeo?Boolean

Returns:

  • (Boolean)


169
# File 'lib/videostore.rb', line 169

def vimeo? ; true ; end

#youtube?Boolean

Returns:

  • (Boolean)


168
# File 'lib/videostore.rb', line 168

def youtube? ; false ; end