Class: ReverseAsciidoctor::Converters::Video

Inherits:
Base
  • Object
show all
Defined in:
lib/reverse_asciidoctor/converters/video.rb

Instance Method Summary collapse

Methods inherited from Base

#escape_keychars, #extract_title, #treat, #treat_children

Instance Method Details

#convert(node, state = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/reverse_asciidoctor/converters/video.rb', line 4

def convert(node, state = {})
  autoplay   = node['autoplay']
  loop_attr   = node['loop']
  controls   = node['controls']
  src   = node['src']
  id = node['id']
  anchor = id ? "[[#{id}]]\n" : ""
  title = extract_title(node)
  title = ".#{title}\n" unless title.empty?
  [anchor, title, "video::", src, "[", options(node), "]"].join("")
end

#options(node) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/reverse_asciidoctor/converters/video.rb', line 16

def options(node)
  autoplay   = node['autoplay']
  loop_attr   = node['loop']
  controls   = node['controls']
  width   = node['width']
  ret = ""
  if autoplay || loop_attr || controls
    out = []
    out << "autoplay" if autoplay
    out << "loop" if loop_attr
    out << "controls" if controls
    out << "width=#{width}" if width
    ret = %{options="#{out.join(',')}"}
  end
  ret
end