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
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 11687 def initialize(value:, location:) @value = value @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 11725 def ===(other) other.is_a?(PinnedVarRef) && value === other.value end
Source
# File lib/syntax_tree/node.rb, line 11693 def accept(visitor) visitor.visit_pinned_var_ref(self) end
Source
# File lib/syntax_tree/node.rb, line 11697 def child_nodes [value] end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 11701 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
Source
# File lib/syntax_tree/node.rb, line 11714 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 11718 def format(q) q.group do q.text("^") q.format(value) end end