Class: SyntaxTree::SymbolLiteral

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

Overview

SymbolLiteral represents a symbol in the system with no interpolation (as opposed to a DynaSymbol which has interpolation).

:symbol

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#construct_keys, #pretty_print, #to_json

Constructor Details

#initialize(value:, location:, comments: []) ⇒ SymbolLiteral

Returns a new instance of SymbolLiteral.



8449
8450
8451
8452
8453
# File 'lib/syntax_tree/node.rb', line 8449

def initialize(value:, location:, comments: [])
  @value = value
  @location = location
  @comments = comments
end

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



8447
8448
8449
# File 'lib/syntax_tree/node.rb', line 8447

def comments
  @comments
end

#valueObject (readonly)

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

the value of the

symbol



8444
8445
8446
# File 'lib/syntax_tree/node.rb', line 8444

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



8455
8456
8457
# File 'lib/syntax_tree/node.rb', line 8455

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

#child_nodesObject Also known as: deconstruct



8459
8460
8461
# File 'lib/syntax_tree/node.rb', line 8459

def child_nodes
  [value]
end

#deconstruct_keys(_keys) ⇒ Object



8465
8466
8467
# File 'lib/syntax_tree/node.rb', line 8465

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

#format(q) ⇒ Object



8469
8470
8471
8472
# File 'lib/syntax_tree/node.rb', line 8469

def format(q)
  q.text(":")
  q.format(value)
end