Sha256: e9adbc2845e20ddc11d08a8e587b2a9de3e91e4212955482baccd75340c6c8f7

Contents?: true

Size: 1022 Bytes

Versions: 14

Compression:

Stored size: 1022 Bytes

Contents

# frozen_string_literal: true
require 'active_support/core_ext/hash/compact'
require 'video_embed'

module Dato
  module Local
    module FieldType
      class Video
        def self.parse(value, _repo)
          new(value)
        end

        def initialize(attributes)
          @attributes = attributes
        end

        def url
          @attributes[:url]
        end

        def thumbnail_url
          @attributes[:thumbnail_url]
        end

        def title
          @attributes[:title]
        end

        def width
          @attributes[:width]
        end

        def height
          @attributes[:height]
        end

        def provider
          @attributes[:provider]
        end

        def provider_url
          @attributes[:provider_url]
        end

        def provider_uid
          @attributes[:provider_uid]
        end

        def iframe_embed(width = nil, height = nil)
          VideoEmbed.embed(url, { width: width, height: height }.compact)
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
dato-0.1.20 lib/dato/local/field_type/video.rb
dato-0.1.19 lib/dato/local/field_type/video.rb
dato-0.1.18 lib/dato/local/field_type/video.rb
dato-0.1.17 lib/dato/local/field_type/video.rb
dato-0.1.16 lib/dato/local/field_type/video.rb
dato-0.1.15 lib/dato/local/field_type/video.rb
dato-0.1.14 lib/dato/local/field_type/video.rb
dato-0.1.13 lib/dato/local/field_type/video.rb
dato-0.1.12 lib/dato/local/field_type/video.rb
dato-0.1.11 lib/dato/local/field_type/video.rb
dato-0.1.10 lib/dato/local/field_type/video.rb
dato-0.1.9 lib/dato/local/field_type/video.rb
dato-0.1.8 lib/dato/local/field_type/video.rb
dato-0.1.6 lib/dato/local/field_type/video.rb