Sha256: 7d1fa690ae90d47dc6d129beb6361acce42e2af8b9f7b1de66683e7a8f40d167

Contents?: true

Size: 826 Bytes

Versions: 2

Compression:

Stored size: 826 Bytes

Contents

module ReverseAdoc
  module Converters
    class Video < Base
      def to_coradoc(node, _state = {})
        src = node["src"]
        id = node["id"]
        title = extract_title(node)
        attributes = Coradoc::Element::AttributeList.new
        options = options(node)
        attributes.add_named("options", options) if options.any?
        Coradoc::Element::Video.new(title, id: id, src: src,
                                           attributes: attributes)
      end

      def convert(node, state = {})
        Coradoc::Generator.gen_adoc(to_coradoc(node, state))
      end

      def options(node)
        autoplay = node["autoplay"]
        loop_attr = node["loop"]
        controls = node["controls"]
        [autoplay, loop_attr, controls].compact
      end
    end

    register :video, Video.new
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
reverse_adoc-1.0.1 lib/reverse_adoc/converters/video.rb
reverse_adoc-1.0.0 lib/reverse_adoc/converters/video.rb