Class: SyntaxTree::XML::CharData

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

Overview

A CharData contains either plain text or whitespace within an element. It wraps a single token value.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#format, #pretty_print

Constructor Details

#initialize(value:, location:) ⇒ CharData

Returns a new instance of CharData.



367
368
369
370
# File 'lib/syntax_tree/xml/nodes.rb', line 367

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

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



365
366
367
# File 'lib/syntax_tree/xml/nodes.rb', line 365

def location
  @location
end

#valueObject (readonly)

Returns the value of attribute value.



365
366
367
# File 'lib/syntax_tree/xml/nodes.rb', line 365

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



372
373
374
# File 'lib/syntax_tree/xml/nodes.rb', line 372

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

#child_nodesObject Also known as: deconstruct



376
377
378
# File 'lib/syntax_tree/xml/nodes.rb', line 376

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object



382
383
384
# File 'lib/syntax_tree/xml/nodes.rb', line 382

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