Class: SyntaxTree::ERB::Document

Inherits:
Node
  • Object
show all
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

Instance Method Summary collapse

Methods inherited from Node

#format, #pretty_print

Constructor Details

#initialize(elements:, location:) ⇒ Document

Returns a new instance of Document.



93
94
95
96
# File 'lib/syntax_tree/erb/nodes.rb', line 93

def initialize(elements:, location:)
  @elements = elements
  @location = location
end

Instance Attribute Details

#elementsObject (readonly)

Returns the value of attribute elements.



91
92
93
# File 'lib/syntax_tree/erb/nodes.rb', line 91

def elements
  @elements
end

#locationObject (readonly)

Returns the value of attribute location.



91
92
93
# File 'lib/syntax_tree/erb/nodes.rb', line 91

def location
  @location
end

Instance Method Details

#accept(visitor) ⇒ Object



98
99
100
# File 'lib/syntax_tree/erb/nodes.rb', line 98

def accept(visitor)
  visitor.visit_document(self)
end

#child_nodesObject Also known as: deconstruct



102
103
104
# File 'lib/syntax_tree/erb/nodes.rb', line 102

def child_nodes
  [*elements].compact
end

#deconstruct_keys(keys) ⇒ Object



108
109
110
# File 'lib/syntax_tree/erb/nodes.rb', line 108

def deconstruct_keys(keys)
  { elements: elements, location: location }
end