class SyntaxTree::SymbolLiteral

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

:symbol

Attributes

comments[R]
Array[ Comment | EmbDoc ]

the comments attached to this node

value[R]
Backtick | Const | CVar | GVar | Ident | IVar | Kw | Op | TStringContent

the value of the symbol

Public Class Methods

new(value:, location:) click to toggle source
# File lib/syntax_tree/node.rb, line 10575
def initialize(value:, location:)
  @value = value
  @location = location
  @comments = []
end

Public Instance Methods

===(other) click to toggle source
# File lib/syntax_tree/node.rb, line 10612
def ===(other)
  other.is_a?(SymbolLiteral) && value === other.value
end
accept(visitor) click to toggle source
# File lib/syntax_tree/node.rb, line 10581
def accept(visitor)
  visitor.visit_symbol_literal(self)
end
child_nodes() click to toggle source
# File lib/syntax_tree/node.rb, line 10585
def child_nodes
  [value]
end
Also aliased as: deconstruct
copy(value: nil, location: nil) click to toggle source
# File lib/syntax_tree/node.rb, line 10589
def copy(value: nil, location: nil)
  node =
    SymbolLiteral.new(
      value: value || self.value,
      location: location || self.location
    )

  node.comments.concat(comments.map(&:copy))
  node
end
deconstruct()
Alias for: child_nodes
deconstruct_keys(_keys) click to toggle source
# File lib/syntax_tree/node.rb, line 10602
def deconstruct_keys(_keys)
  { value: value, location: location, comments: comments }
end
format(q) click to toggle source
# File lib/syntax_tree/node.rb, line 10606
def format(q)
  q.text(":")
  q.text("\\") if value.comments.any?
  q.format(value)
end