Class: Coradoc::Input::HTML::Converters::Audio

Inherits:
Base
  • Object
show all
Defined in:
lib/coradoc/input/html/converters/audio.rb

Instance Method Summary collapse

Methods inherited from Base

#convert, #extract_leading_trailing_whitespace, #extract_title, #node_has_ancestor?, #textnode_after_start_with?, #textnode_before_end_with?, #treat, #treat_children, #treat_children_coradoc, #treat_coradoc, #unconstrained_after?, #unconstrained_before?

Instance Method Details

#options(node) ⇒ Object



15
16
17
18
19
20
# File 'lib/coradoc/input/html/converters/audio.rb', line 15

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

#to_coradoc(node, _state = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/coradoc/input/html/converters/audio.rb', line 4

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::Audio.new(title, id: id, src: src,
                                     attributes: attributes)
end