class VimeoMetaCache
Public Instance Methods
embed(geometry, options = {})
click to toggle source
# File app/models/vimeo_meta_cache.rb, line 15 def embed geometry, options = {} VimeoEmbedCache.embed(self.vid, geometry, options) end
update_cache(images = false)
click to toggle source
# File app/models/vimeo_meta_cache.rb, line 23 def update_cache images = false cache true, images self.save end
url()
click to toggle source
# File app/models/vimeo_meta_cache.rb, line 19 def url "http://www.vimeo.com/#{self.vid}" end
Private Instance Methods
cache(force = false, images = false)
click to toggle source
# File app/models/vimeo_meta_cache.rb, line 30 def cache force = false, images = false if !self.title? or !self.image_id? or !self.description? or force video_info_request = Vimeo::Advanced::Video.new( account[:consumer_key], account[:consumer_secret], :token => account[:token], :secret => account[:secret]) video_info = video_info_request.get_info(self.vid)["video"].first # By default omitt image if we already have one. # If we force an update, we need to specifically force images as well by # calling this method with force and images true. if images or !image_id? # Save fetched image url vimeo_thumb_url = video_info["thumbnails"]["thumbnail"].last["_content"] self.create_image(:image => ::Refinery::VimeoVideos::URLTempfile.new(vimeo_thumb_url)) end # Save fetched title self.title = video_info["title"] if !self.title? or force # Save fetched description self.description = "<p>#{video_info['description']}</p>" if !self.description? or force end end