Class: Lumiere::Vimeo

Inherits:
Provider show all
Includes:
EmbedCode
Defined in:
lib/provider/vimeo/vimeo.rb

Constant Summary collapse

USEABLE =
['www.vimeo.com', 'vimeo.com', 'player.vimeo.com']

Constants inherited from Provider

Provider::PROVIDERS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from EmbedCode

#embed_code

Methods inherited from Provider

#==, #accessible?, delegate, #embed_code, #playlist_id, #videos

Constructor Details

#initialize(url, fetched = nil) ⇒ Vimeo

Returns a new instance of Vimeo.



20
21
22
23
# File 'lib/provider/vimeo/vimeo.rb', line 20

def initialize(url, fetched=nil)
  @url = url
  @fetched = fetched
end

Instance Attribute Details

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/provider/vimeo/vimeo.rb', line 6

def url
  @url
end

Class Method Details

.new_from_video_id(video_id, fetched = nil) ⇒ Object



16
17
18
# File 'lib/provider/vimeo/vimeo.rb', line 16

def self.new_from_video_id(video_id, fetched=nil)
  new("http://vimeo.com/#{video_id}", fetched)
end

.useable?(url) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/provider/vimeo/vimeo.rb', line 11

def self.useable?(url)
  uri = URISchemeless.parse(url)
  USEABLE.include?(uri.host)
end

Instance Method Details

#api_urlObject



33
34
35
# File 'lib/provider/vimeo/vimeo.rb', line 33

def api_url
  "http://vimeo.com/api/v2/video/#{video_id}.json"
end

#default_attributesObject



41
42
43
44
45
46
47
48
49
50
# File 'lib/provider/vimeo/vimeo.rb', line 41

def default_attributes
  {
    iframe_attributes: {
      frameborder: 0,
      webkitallowfullscreen: true,
      mozallowfullscreen: true,
      allowfullscreen: true
    }
  }
end

#descriptionObject



56
57
58
# File 'lib/provider/vimeo/vimeo.rb', line 56

def description
  fetch.description
end

#durationObject



60
61
62
# File 'lib/provider/vimeo/vimeo.rb', line 60

def duration
  fetch.duration
end

#embed_urlObject



37
38
39
# File 'lib/provider/vimeo/vimeo.rb', line 37

def embed_url
  "//player.vimeo.com/video/#{video_id}"
end

#providerObject



25
26
27
# File 'lib/provider/vimeo/vimeo.rb', line 25

def provider
  "Vimeo"
end

#thumbnail_largeObject



76
77
78
# File 'lib/provider/vimeo/vimeo.rb', line 76

def thumbnail_large
  fetch.thumbnail_large
end

#thumbnail_mediumObject



72
73
74
# File 'lib/provider/vimeo/vimeo.rb', line 72

def thumbnail_medium
  fetch.thumbnail_medium
end

#thumbnail_smallObject



68
69
70
# File 'lib/provider/vimeo/vimeo.rb', line 68

def thumbnail_small
  fetch.thumbnail_small
end

#titleObject



52
53
54
# File 'lib/provider/vimeo/vimeo.rb', line 52

def title
  fetch.title
end

#unpack_intoObject



80
81
82
83
# File 'lib/provider/vimeo/vimeo.rb', line 80

def unpack_into
  struct = []
  struct.extend(VimeoVideosRepresenter)
end

#upload_dateObject



64
65
66
# File 'lib/provider/vimeo/vimeo.rb', line 64

def upload_date
  fetch.upload_date
end

#video_idObject



29
30
31
# File 'lib/provider/vimeo/vimeo.rb', line 29

def video_id
  @video_id ||= calculate_video_id
end