Class: ThemeCheck::HtmlNode
- Inherits:
-
Object
- Object
- ThemeCheck::HtmlNode
- Extended by:
- Forwardable
- Defined in:
- lib/theme_check/html_node.rb
Instance Attribute Summary collapse
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #children ⇒ Object
- #element? ⇒ Boolean
-
#initialize(value, template) ⇒ HtmlNode
constructor
A new instance of HtmlNode.
- #line_number ⇒ Object
- #literal? ⇒ Boolean
- #markup ⇒ Object
- #name ⇒ Object
- #parent ⇒ Object
- #value ⇒ Object
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
#template ⇒ Object (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
#children ⇒ Object
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
20 21 22 |
# File 'lib/theme_check/html_node.rb', line 20 def element? @value.element? end |
#line_number ⇒ Object
52 53 54 |
# File 'lib/theme_check/html_node.rb', line 52 def line_number @value.line end |
#literal? ⇒ Boolean
16 17 18 |
# File 'lib/theme_check/html_node.rb', line 16 def literal? @value.name == "text" end |
#markup ⇒ Object
48 49 50 |
# File 'lib/theme_check/html_node.rb', line 48 def markup @value.to_html end |
#name ⇒ Object
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 |
#parent ⇒ Object
28 29 30 |
# File 'lib/theme_check/html_node.rb', line 28 def parent HtmlNode.new(@value.parent, template) end |
#value ⇒ Object
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 |