Class: SyntaxTree::XML::Reference

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

Overview

A Reference is either a character or entity reference. It contains a single value that is the token it contains.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#format, #pretty_print

Constructor Details

#initialize(value:, location:) ⇒ Reference

Returns a new instance of Reference.



315
316
317
318
# File 'lib/syntax_tree/xml/nodes.rb', line 315

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

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



313
314
315
# File 'lib/syntax_tree/xml/nodes.rb', line 313

def location
  @location
end

#valueObject (readonly)

Returns the value of attribute value.



313
314
315
# File 'lib/syntax_tree/xml/nodes.rb', line 313

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



320
321
322
# File 'lib/syntax_tree/xml/nodes.rb', line 320

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

#child_nodesObject Also known as: deconstruct



324
325
326
# File 'lib/syntax_tree/xml/nodes.rb', line 324

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object



330
331
332
# File 'lib/syntax_tree/xml/nodes.rb', line 330

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