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, #skip?, #without_new_line

Constructor Details

#initialize(elements:, location:) ⇒ Document

Returns a new instance of Document.



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

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

Instance Attribute Details

#elementsObject (readonly)

Returns the value of attribute elements.



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

def elements
  @elements
end

#locationObject (readonly)

Returns the value of attribute location.



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

def location
  @location
end

Instance Method Details

#accept(visitor) ⇒ Object



106
107
108
# File 'lib/syntax_tree/erb/nodes.rb', line 106

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

#child_nodesObject Also known as: deconstruct



110
111
112
# File 'lib/syntax_tree/erb/nodes.rb', line 110

def child_nodes
  [*elements].compact
end

#deconstruct_keys(keys) ⇒ Object



116
117
118
# File 'lib/syntax_tree/erb/nodes.rb', line 116

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