class SyntaxTree::PinnedVarRef

PinnedVarRef represents a pinned variable reference within a pattern matching pattern.

case value
in ^variable
end

This can be a plain local variable like the example above. It can also be a a class variable, a global variable, or an instance variable.

Attributes

comments[R]
Array[ Comment | EmbDoc ]

the comments attached to this node

value[R]
Const | CVar | GVar | Ident | IVar

the value of this node

Public Class Methods

new(value:, location:) click to toggle source
# File lib/syntax_tree/node.rb, line 11668
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 11706
def ===(other)
  other.is_a?(PinnedVarRef) && value === other.value
end
accept(visitor) click to toggle source
# File lib/syntax_tree/node.rb, line 11674
def accept(visitor)
  visitor.visit_pinned_var_ref(self)
end
child_nodes() click to toggle source
# File lib/syntax_tree/node.rb, line 11678
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 11682
def copy(value: nil, location: nil)
  node =
    PinnedVarRef.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 11695
def deconstruct_keys(_keys)
  { value: value, location: location, comments: comments }
end
format(q) click to toggle source
# File lib/syntax_tree/node.rb, line 11699
def format(q)
  q.group do
    q.text("^")
    q.format(value)
  end
end