Class: SyntaxTree::SymBeg

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

Overview

SymBeg represents the beginning of a symbol literal.

:symbol

SymBeg is also used for dynamic symbols, as in:

:"symbol"

Finally, SymBeg is also used for symbols using the %s syntax, as in:

%s[symbol]

The value of this node is a string. In most cases (as in the first example above) it will contain just “:”. In the case of dynamic symbols it will contain “:‘” or “:"”. In the case of %s symbols, it will contain the start of the symbol including the %s and the delimiter.

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#construct_keys, #format, #pretty_print, #to_json

Constructor Details

#initialize(value:, location:) ⇒ SymBeg

Returns a new instance of SymBeg.



8550
8551
8552
8553
# File 'lib/syntax_tree/node.rb', line 8550

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

Instance Attribute Details

#valueObject (readonly)

String

the beginning of the symbol



8548
8549
8550
# File 'lib/syntax_tree/node.rb', line 8548

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



8555
8556
8557
# File 'lib/syntax_tree/node.rb', line 8555

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

#child_nodesObject Also known as: deconstruct



8559
8560
8561
# File 'lib/syntax_tree/node.rb', line 8559

def child_nodes
  []
end

#deconstruct_keys(_keys) ⇒ Object



8565
8566
8567
# File 'lib/syntax_tree/node.rb', line 8565

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