class SyntaxTree::Const

Const represents a literal value that looks like a constant. This could actually be a reference to a constant:

Constant

It could also be something that looks like a constant in another context, as in a method call to a capitalized method:

object.Constant

or a symbol that starts with a capital letter:

:Constant

Attributes

comments[R]
Array[ Comment | EmbDoc ]

the comments attached to this node

value[R]
String

the name of the constant

Public Class Methods

new(value:, location:) click to toggle source
# File lib/syntax_tree/node.rb, line 3819
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 3854
def ===(other)
  other.is_a?(Const) && value === other.value
end
accept(visitor) click to toggle source
# File lib/syntax_tree/node.rb, line 3825
def accept(visitor)
  visitor.visit_const(self)
end
child_nodes() click to toggle source
# File lib/syntax_tree/node.rb, line 3829
def child_nodes
  []
end
Also aliased as: deconstruct
copy(value: nil, location: nil) click to toggle source
# File lib/syntax_tree/node.rb, line 3833
def copy(value: nil, location: nil)
  node =
    Const.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 3846
def deconstruct_keys(_keys)
  { value: value, location: location, comments: comments }
end
format(q) click to toggle source
# File lib/syntax_tree/node.rb, line 3850
def format(q)
  q.text(value)
end