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, #format, #pretty_print, #to_json

Constructor Details

#initialize(value:, location:) ⇒ SymbolContent

Returns a new instance of SymbolContent.



10365
10366
10367
10368
# File 'lib/syntax_tree/node.rb', line 10365

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



10363
10364
10365
# File 'lib/syntax_tree/node.rb', line 10363

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



10391
10392
10393
# File 'lib/syntax_tree/node.rb', line 10391

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

#accept(visitor) ⇒ Object



10370
10371
10372
# File 'lib/syntax_tree/node.rb', line 10370

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

#child_nodesObject Also known as: deconstruct



10374
10375
10376
# File 'lib/syntax_tree/node.rb', line 10374

def child_nodes
  []
end

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



10378
10379
10380
10381
10382
10383
# File 'lib/syntax_tree/node.rb', line 10378

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

#deconstruct_keys(_keys) ⇒ Object



10387
10388
10389
# File 'lib/syntax_tree/node.rb', line 10387

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