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.



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

#elementsObject (readonly)

Returns the value of attribute elements.



57
58
59
# File 'lib/syntax_tree/erb/nodes.rb', line 57

def elements
  @elements
end

#locationObject (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_nodesObject 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