Class: Dato::Local::FieldType::Video
- Inherits:
-
Object
- Object
- Dato::Local::FieldType::Video
- Defined in:
- lib/dato/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.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dato/local/field_type/video.rb', line 29 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.
11 12 13 |
# File 'lib/dato/local/field_type/video.rb', line 11 def height @height end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
12 13 14 |
# File 'lib/dato/local/field_type/video.rb', line 12 def provider @provider end |
#provider_uid ⇒ Object (readonly)
Returns the value of attribute provider_uid.
14 15 16 |
# File 'lib/dato/local/field_type/video.rb', line 14 def provider_uid @provider_uid end |
#provider_url ⇒ Object (readonly)
Returns the value of attribute provider_url.
13 14 15 |
# File 'lib/dato/local/field_type/video.rb', line 13 def provider_url @provider_url end |
#thumbnail_url ⇒ Object (readonly)
Returns the value of attribute thumbnail_url.
8 9 10 |
# File 'lib/dato/local/field_type/video.rb', line 8 def thumbnail_url @thumbnail_url end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
9 10 11 |
# File 'lib/dato/local/field_type/video.rb', line 9 def title @title end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/dato/local/field_type/video.rb', line 7 def url @url end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
10 11 12 |
# File 'lib/dato/local/field_type/video.rb', line 10 def width @width end |
Class Method Details
.parse(value, _repo) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dato/local/field_type/video.rb', line 16 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
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/dato/local/field_type/video.rb', line 49 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
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/dato/local/field_type/video.rb', line 61 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 |