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

#pretty_print, #to_json

Constructor Details

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



7800
7801
7802
7803
7804
# File 'lib/syntax_tree/node.rb', line 7800

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



7798
7799
7800
# File 'lib/syntax_tree/node.rb', line 7798

def comments
  @comments
end

#valueObject (readonly)

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

the value of the

symbol



7795
7796
7797
# File 'lib/syntax_tree/node.rb', line 7795

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



7806
7807
7808
# File 'lib/syntax_tree/node.rb', line 7806

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

#child_nodesObject Also known as: deconstruct



7810
7811
7812
# File 'lib/syntax_tree/node.rb', line 7810

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object



7816
7817
7818
# File 'lib/syntax_tree/node.rb', line 7816

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

#format(q) ⇒ Object



7820
7821
7822
7823
# File 'lib/syntax_tree/node.rb', line 7820

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