Class: SyntaxTree::SymbolContent

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

Overview

SymbolContent represents symbol contents and is always the child of a SymbolLiteral node.

:symbol

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#construct_keys, #end_char, #format, #pretty_print, #start_char, #to_json, #to_mermaid

Constructor Details

#initialize(value:, location:) ⇒ SymbolContent

Returns a new instance of SymbolContent.



10547
10548
10549
10550
# File 'lib/syntax_tree/node.rb', line 10547

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

Instance Attribute Details

#valueObject (readonly)

Backtick | Const | CVar | GVar | Ident | IVar | Kw | Op

the value of the

symbol



10545
10546
10547
# File 'lib/syntax_tree/node.rb', line 10545

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



10573
10574
10575
# File 'lib/syntax_tree/node.rb', line 10573

def ===(other)
  other.is_a?(SymbolContent) && value === other.value
end

#accept(visitor) ⇒ Object



10552
10553
10554
# File 'lib/syntax_tree/node.rb', line 10552

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

#child_nodesObject Also known as: deconstruct



10556
10557
10558
# File 'lib/syntax_tree/node.rb', line 10556

def child_nodes
  []
end

#copy(value: nil, location: nil) ⇒ Object



10560
10561
10562
10563
10564
10565
# File 'lib/syntax_tree/node.rb', line 10560

def copy(value: nil, location: nil)
  SymbolContent.new(
    value: value || self.value,
    location: location || self.location
  )
end

#deconstruct_keys(_keys) ⇒ Object



10569
10570
10571
# File 'lib/syntax_tree/node.rb', line 10569

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