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.



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

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

Instance Attribute Details

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/provider/vimeo/vimeo.rb', line 3

def url
  @url
end

Class Method Details

.new_from_video_id(video_id, fetched = nil) ⇒ Object



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

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

.useable?(url) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
# File 'lib/provider/vimeo/vimeo.rb', line 8

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

Instance Method Details

#api_urlObject



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

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

#default_attributesObject



38
39
40
41
42
43
44
45
46
47
# File 'lib/provider/vimeo/vimeo.rb', line 38

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

#descriptionObject



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

def description
  fetch.description
end

#durationObject



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

def duration
  fetch.duration
end

#embed_urlObject



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

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

#providerObject



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

def provider
  "Vimeo"
end

#thumbnail_largeObject



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

def thumbnail_large
  fetch.thumbnail_large
end

#thumbnail_mediumObject



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

def thumbnail_medium
  fetch.thumbnail_medium
end

#thumbnail_smallObject



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

def thumbnail_small
  fetch.thumbnail_small
end

#titleObject



49
50
51
# File 'lib/provider/vimeo/vimeo.rb', line 49

def title
  fetch.title
end

#unpack_intoObject



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

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

#upload_dateObject



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

def upload_date
  fetch.upload_date
end

#video_idObject



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

def video_id
  @video_id ||= calculate_video_id
end