Class: Agave::Local::FieldType::Video

Inherits:
Object
  • Object
show all
Defined in:
lib/agave/local/field_type/video.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, thumbnail_url, title, width, height, provider, provider_url, provider_uid) ⇒ Video

Returns a new instance of Video.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/agave/local/field_type/video.rb', line 30

def initialize(
  url,
  thumbnail_url,
  title,
  width,
  height,
  provider,
  provider_url,
  provider_uid
)
  @url            = url
  @thumbnail_url  = thumbnail_url
  @title          = title
  @width          = width
  @height         = height
  @provider       = provider
  @provider_url   = provider_url
  @provider_uid   = provider_uid
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



12
13
14
# File 'lib/agave/local/field_type/video.rb', line 12

def height
  @height
end

#providerObject (readonly)

Returns the value of attribute provider.



13
14
15
# File 'lib/agave/local/field_type/video.rb', line 13

def provider
  @provider
end

#provider_uidObject (readonly)

Returns the value of attribute provider_uid.



15
16
17
# File 'lib/agave/local/field_type/video.rb', line 15

def provider_uid
  @provider_uid
end

#provider_urlObject (readonly)

Returns the value of attribute provider_url.



14
15
16
# File 'lib/agave/local/field_type/video.rb', line 14

def provider_url
  @provider_url
end

#thumbnail_urlObject (readonly)

Returns the value of attribute thumbnail_url.



9
10
11
# File 'lib/agave/local/field_type/video.rb', line 9

def thumbnail_url
  @thumbnail_url
end

#titleObject (readonly)

Returns the value of attribute title.



10
11
12
# File 'lib/agave/local/field_type/video.rb', line 10

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



8
9
10
# File 'lib/agave/local/field_type/video.rb', line 8

def url
  @url
end

#widthObject (readonly)

Returns the value of attribute width.



11
12
13
# File 'lib/agave/local/field_type/video.rb', line 11

def width
  @width
end

Class Method Details

.parse(value, _repo) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/agave/local/field_type/video.rb', line 17

def self.parse(value, _repo)
  value && new(
    value[:url],
    value[:thumbnail_url],
    value[:title],
    value[:width],
    value[:height],
    value[:provider],
    value[:provider_url],
    value[:provider_uid]
  )
end

Instance Method Details

#iframe_embed(width = self.width, height = self.height) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/agave/local/field_type/video.rb', line 50

def iframe_embed(width = self.width, height = self.height)
  # rubocop:disable Metrics/LineLength
  if provider == 'youtube'
    %(<iframe width="#{width}" height="#{height}" src="//www.youtube.com/embed/#{provider_uid}?rel=0" frameborder="0" allowfullscreen></iframe>)
  elsif provider == 'vimeo'
    %(<iframe src="//player.vimeo.com/video/#{provider_uid}?title=0&amp;byline=0&amp;portrait=0" width="#{width}" height="#{height}" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>)
  elsif provider == 'facebook'
   %(<iframe src="//www.facebook.com/plugins/video.php?href=#{url}&width=#{width}&show_text=false&height=#{height}" width="#{width}" height="#{height}" style="border:none;overflow:hidden;width:100%;" scrolling="no" frameborder="0" allowTransparency="true" allow="encrypted-media" allowFullScreen="true"></iframe>)
  end
  # rubocop:enable Metrics/LineLength
end

#to_hash(*_args) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/agave/local/field_type/video.rb', line 62

def to_hash(*_args)
  {
    url: url,
    thumbnail_url: thumbnail_url,
    title: title,
    width: width,
    height: height,
    provider: provider,
    provider_url: provider_url,
    provider_uid: provider_uid
  }
end