Class: YARP::PinnedVariableNode

Inherits:
YARPNode
  • Object
show all
Defined in:
lib/yarp/node.rb,
ext/yarp/api_node.c

Overview

Represents the use of the ‘^` operator for pinning a variable in a pattern matching expression.

foo in ^bar
       ^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variable, operator_loc, location) ⇒ PinnedVariableNode

def initialize: (variable: Node, operator_loc: Location, location: Location) -> void



4746
4747
4748
4749
4750
# File 'lib/yarp/node.rb', line 4746

def initialize(variable, operator_loc, location)
  @variable = variable
  @operator_loc = operator_loc
  @location = location
end

Instance Attribute Details

#operator_locObject (readonly)

attr_reader operator_loc: Location



4743
4744
4745
# File 'lib/yarp/node.rb', line 4743

def operator_loc
  @operator_loc
end

#variableObject (readonly)

attr_reader variable: Node



4740
4741
4742
# File 'lib/yarp/node.rb', line 4740

def variable
  @variable
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4753
4754
4755
# File 'lib/yarp/node.rb', line 4753

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



4758
4759
4760
# File 'lib/yarp/node.rb', line 4758

def child_nodes
  [variable]
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]



4766
4767
4768
# File 'lib/yarp/node.rb', line 4766

def deconstruct_keys(keys)
  { variable: variable, operator_loc: operator_loc, location: location }
end

#operatorObject

def operator: () -> String



4771
4772
4773
# File 'lib/yarp/node.rb', line 4771

def operator
  operator_loc.slice
end