Class: Agave::Local::FieldType::Video
- Inherits:
-
Object
- Object
- Agave::Local::FieldType::Video
- Defined in:
- lib/agave/local/field_type/video.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#provider_uid ⇒ Object
readonly
Returns the value of attribute provider_uid.
-
#provider_url ⇒ Object
readonly
Returns the value of attribute provider_url.
-
#thumbnail_url ⇒ Object
readonly
Returns the value of attribute thumbnail_url.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
- #iframe_embed(width = self.width, height = self.height) ⇒ Object
-
#initialize(url, thumbnail_url, title, width, height, provider, provider_url, provider_uid) ⇒ Video
constructor
A new instance of Video.
- #to_hash(*_args) ⇒ Object
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
#height ⇒ Object (readonly)
Returns the value of attribute height.
12 13 14 |
# File 'lib/agave/local/field_type/video.rb', line 12 def height @height end |
#provider ⇒ Object (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_uid ⇒ Object (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_url ⇒ Object (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_url ⇒ Object (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 |
#title ⇒ Object (readonly)
Returns the value of attribute title.
10 11 12 |
# File 'lib/agave/local/field_type/video.rb', line 10 def title @title end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/agave/local/field_type/video.rb', line 8 def url @url end |
#width ⇒ Object (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 (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&byline=0&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 |