Class: SyntaxTree::XML::Prolog

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/xml/nodes.rb

Overview

The prolog to the document includes an XML declaration which opens the tag, any number of attributes, and a closing of the tag.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#format, #pretty_print

Constructor Details

#initialize(opening:, attributes:, closing:, location:) ⇒ Prolog

Returns a new instance of Prolog.



118
119
120
121
122
123
# File 'lib/syntax_tree/xml/nodes.rb', line 118

def initialize(opening:, attributes:, closing:, location:)
  @opening = opening
  @attributes = attributes
  @closing = closing
  @location = location
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

#closingObject (readonly)

Returns the value of attribute closing.



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

def closing
  @closing
end

#locationObject (readonly)

Returns the value of attribute location.



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

def location
  @location
end

#openingObject (readonly)

Returns the value of attribute opening.



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

def opening
  @opening
end

Instance Method Details

#accept(visitor) ⇒ Object



125
126
127
# File 'lib/syntax_tree/xml/nodes.rb', line 125

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

#child_nodesObject Also known as: deconstruct



129
130
131
# File 'lib/syntax_tree/xml/nodes.rb', line 129

def child_nodes
  [opening, *attributes, closing]
end

#deconstruct_keys(keys) ⇒ Object



135
136
137
138
139
140
141
142
# File 'lib/syntax_tree/xml/nodes.rb', line 135

def deconstruct_keys(keys)
  {
    opening: opening,
    attributes: attributes,
    closing: closing,
    location: location
  }
end