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.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/dato/local/field_type/video.rb', line 22 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.
7 8 9 |
# File 'lib/dato/local/field_type/video.rb', line 7 def height @height end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
7 8 9 |
# File 'lib/dato/local/field_type/video.rb', line 7 def provider @provider end |
#provider_uid ⇒ Object (readonly)
Returns the value of attribute provider_uid.
7 8 9 |
# File 'lib/dato/local/field_type/video.rb', line 7 def provider_uid @provider_uid end |
#provider_url ⇒ Object (readonly)
Returns the value of attribute provider_url.
7 8 9 |
# File 'lib/dato/local/field_type/video.rb', line 7 def provider_url @provider_url end |
#thumbnail_url ⇒ Object (readonly)
Returns the value of attribute thumbnail_url.
7 8 9 |
# File 'lib/dato/local/field_type/video.rb', line 7 def thumbnail_url @thumbnail_url end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/dato/local/field_type/video.rb', line 7 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.
7 8 9 |
# File 'lib/dato/local/field_type/video.rb', line 7 def width @width end |
Class Method Details
.parse(value, _repo) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dato/local/field_type/video.rb', line 9 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
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/dato/local/field_type/video.rb', line 42 def (width = self.width, height = self.height) # rubocop:disable Layout/LineLength case provider when "youtube" %(<iframe width="#{width}" height="#{height}" src="//www.youtube.com/embed/#{provider_uid}?rel=0" frameborder="0" allowfullscreen></iframe>) when "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>) when "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 Layout/LineLength end |
#to_hash(*_args) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/dato/local/field_type/video.rb', line 55 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 |