Class: SyntaxTree::XML::Misc

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

Overview

A Misc is a catch-all for miscellaneous content outside the root tag of the XML document. It contains a single token which can be either a comment, a processing instruction, or whitespace.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#format, #pretty_print

Constructor Details

#initialize(value:, location:) ⇒ Misc

Returns a new instance of Misc.



393
394
395
396
# File 'lib/syntax_tree/xml/nodes.rb', line 393

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

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



391
392
393
# File 'lib/syntax_tree/xml/nodes.rb', line 391

def location
  @location
end

#valueObject (readonly)

Returns the value of attribute value.



391
392
393
# File 'lib/syntax_tree/xml/nodes.rb', line 391

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



398
399
400
# File 'lib/syntax_tree/xml/nodes.rb', line 398

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

#child_nodesObject Also known as: deconstruct



402
403
404
# File 'lib/syntax_tree/xml/nodes.rb', line 402

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object



408
409
410
# File 'lib/syntax_tree/xml/nodes.rb', line 408

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