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.



10514
10515
10516
10517
# File 'lib/syntax_tree/node.rb', line 10514

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



10512
10513
10514
# File 'lib/syntax_tree/node.rb', line 10512

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



10540
10541
10542
# File 'lib/syntax_tree/node.rb', line 10540

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

#accept(visitor) ⇒ Object



10519
10520
10521
# File 'lib/syntax_tree/node.rb', line 10519

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

#child_nodesObject Also known as: deconstruct



10523
10524
10525
# File 'lib/syntax_tree/node.rb', line 10523

def child_nodes
  []
end

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



10527
10528
10529
10530
10531
10532
# File 'lib/syntax_tree/node.rb', line 10527

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

#deconstruct_keys(_keys) ⇒ Object



10536
10537
10538
# File 'lib/syntax_tree/node.rb', line 10536

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