Class: ThemeCheck::HtmlNode

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/theme_check/html_node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, template) ⇒ HtmlNode

Returns a new instance of HtmlNode.



11
12
13
14
# File 'lib/theme_check/html_node.rb', line 11

def initialize(value, template)
  @value = value
  @template = template
end

Instance Attribute Details

#templateObject (readonly)

Returns the value of attribute template.



7
8
9
# File 'lib/theme_check/html_node.rb', line 7

def template
  @template
end

Instance Method Details

#childrenObject



24
25
26
# File 'lib/theme_check/html_node.rb', line 24

def children
  @value.children.map { |child| HtmlNode.new(child, template) }
end

#element?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/theme_check/html_node.rb', line 20

def element?
  @value.element?
end

#line_numberObject



52
53
54
# File 'lib/theme_check/html_node.rb', line 52

def line_number
  @value.line
end

#literal?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/theme_check/html_node.rb', line 16

def literal?
  @value.name == "text"
end

#markupObject



48
49
50
# File 'lib/theme_check/html_node.rb', line 48

def markup
  @value.to_html
end

#nameObject



32
33
34
35
36
37
38
# File 'lib/theme_check/html_node.rb', line 32

def name
  if @value.name == "#document-fragment"
    "document"
  else
    @value.name
  end
end

#parentObject



28
29
30
# File 'lib/theme_check/html_node.rb', line 28

def parent
  HtmlNode.new(@value.parent, template)
end

#valueObject



40
41
42
43
44
45
46
# File 'lib/theme_check/html_node.rb', line 40

def value
  if literal?
    @value.content
  else
    @value
  end
end