# frozen_string_literal: true module Dato module Local module FieldType class Video attr_reader :url, :thumbnail_url, :title, :width, :height, :provider, :provider_url, :provider_uid 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 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 def iframe_embed(width = self.width, height = self.height) # rubocop:disable Layout/LineLength case provider when "youtube" %() when "vimeo" %() when "facebook" %() end # rubocop:enable Layout/LineLength end 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 end end end end