Class: HasVimeoVideo::VimeoVideo
- Inherits:
-
Object
- Object
- HasVimeoVideo::VimeoVideo
- Defined in:
- lib/has_vimeo_video/vimeo_video.rb
Class Method Summary collapse
Instance Method Summary collapse
- #embed_url ⇒ Object
- #id ⇒ Object
- #info ⇒ Object
-
#initialize(url) ⇒ VimeoVideo
constructor
A new instance of VimeoVideo.
- #thumbnail ⇒ Object
Constructor Details
#initialize(url) ⇒ VimeoVideo
Returns a new instance of VimeoVideo.
8 9 10 |
# File 'lib/has_vimeo_video/vimeo_video.rb', line 8 def initialize url @url = url end |
Class Method Details
.regex ⇒ Object
4 5 6 |
# File 'lib/has_vimeo_video/vimeo_video.rb', line 4 def self.regex /https?:\/\/(www\.)?vimeo.com\/(\d+)/ end |
Instance Method Details
#embed_url ⇒ Object
33 34 35 |
# File 'lib/has_vimeo_video/vimeo_video.rb', line 33 def "http://player.vimeo.com/video/#{id}" end |
#id ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/has_vimeo_video/vimeo_video.rb', line 12 def id return @id if @id return unless @url if result = @url.match(self.class.regex) @id = result[2] end end |
#info ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/has_vimeo_video/vimeo_video.rb', line 20 def info return @info if @info return unless id @info = Vimeo::Simple::Video.info(id) if @info.parsed_response and @info.parsed_response[0] @info = @info.parsed_response[0] else @info = nil end rescue @info = nil end |
#thumbnail ⇒ Object
37 38 39 40 |
# File 'lib/has_vimeo_video/vimeo_video.rb', line 37 def thumbnail return unless info info["thumbnail_large"] end |