Class: SyntaxTree::ERB::Document
- Defined in:
- lib/syntax_tree/erb/nodes.rb
Overview
The Document node is the top of the syntax tree. It contains any number of:
-
Text
-
HtmlNode
-
ErbNodes
Instance Attribute Summary collapse
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(elements:, location:) ⇒ Document
constructor
A new instance of Document.
Methods inherited from Node
#format, #pretty_print, #skip?, #without_new_line
Constructor Details
#initialize(elements:, location:) ⇒ Document
Returns a new instance of Document.
59 60 61 62 |
# File 'lib/syntax_tree/erb/nodes.rb', line 59 def initialize(elements:, location:) @elements = elements @location = location end |
Instance Attribute Details
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
57 58 59 |
# File 'lib/syntax_tree/erb/nodes.rb', line 57 def elements @elements end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
57 58 59 |
# File 'lib/syntax_tree/erb/nodes.rb', line 57 def location @location end |
Instance Method Details
#accept(visitor) ⇒ Object
64 65 66 |
# File 'lib/syntax_tree/erb/nodes.rb', line 64 def accept(visitor) visitor.visit_document(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
68 69 70 |
# File 'lib/syntax_tree/erb/nodes.rb', line 68 def child_nodes [*elements].compact end |
#deconstruct_keys(keys) ⇒ Object
74 75 76 |
# File 'lib/syntax_tree/erb/nodes.rb', line 74 def deconstruct_keys(keys) { elements: elements, location: location } end |