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.



8560
8561
8562
8563
8564
# File 'lib/syntax_tree/node.rb', line 8560

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

Instance Attribute Details

#comments ⇒ Object (readonly)

[Array[ Comment | EmbDoc ]] the comments attached to this node



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

def comments
  @comments
end

#value ⇒ Object (readonly)

[Backtick | Const | CVar | GVar | Ident | IVar | Kw | Op] the value of the symbol



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

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



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

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

#child_nodes ⇒ Object Also known as: deconstruct



8570
8571
8572
# File 'lib/syntax_tree/node.rb', line 8570

def child_nodes
  [value]
end

#deconstruct_keys(_keys) ⇒ Object



8576
8577
8578
# File 'lib/syntax_tree/node.rb', line 8576

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

#format(q) ⇒ Object



8580
8581
8582
8583
# File 'lib/syntax_tree/node.rb', line 8580

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