Class: BlueDoc::SML::Rules::Video

Inherits:
Base
  • Object
show all
Defined in:
lib/bluedoc/sml/rules/video.rb

Constant Summary

Constants inherited from Base

Base::INDENT_PX

Class Method Summary collapse

Methods inherited from Base

to_text

Class Method Details

.match?(node) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/bluedoc/sml/rules/video.rb', line 5

def self.match?(node)
  tag_name(node) == "video"
end

.to_html(node, opts = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/bluedoc/sml/rules/video.rb', line 9

def self.to_html(node, opts = {})
  attrs = attributes(node)

  return "" if attrs[:src].blank?

  width = attrs[:width]
  if width == 0 || width.blank?
    width = "100%"
  end

  video_attrs = html_attrs(
    width: width
  )

  nid_attr = name_by_attrs(attrs)

  out = "  <video controls preload=\"no\"\#{video_attrs}\#{nid_attr}>\n    <source src=\"\#{attrs[:src]}\" type=\"\#{attrs[:type]}\">\n  </video>\n  HTML\n\n  out\nend\n"