Class: YARP::PinnedVariableNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::PinnedVariableNode
- 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 ^
^^^^
Instance Attribute Summary collapse
-
#operator_loc ⇒ Object
readonly
attr_reader operator_loc: Location.
-
#variable ⇒ Object
readonly
attr_reader variable: Node.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#copy(**params) ⇒ Object
def copy: (**params) -> PinnedVariableNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(variable, operator_loc, location) ⇒ PinnedVariableNode
constructor
def initialize: (variable: Node, operator_loc: Location, location: Location) -> void.
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(variable, operator_loc, location) ⇒ PinnedVariableNode
def initialize: (variable: Node, operator_loc: Location, location: Location) -> void
5977 5978 5979 5980 5981 |
# File 'lib/yarp/node.rb', line 5977 def initialize(variable, operator_loc, location) @variable = variable @operator_loc = operator_loc @location = location end |
Instance Attribute Details
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
5974 5975 5976 |
# File 'lib/yarp/node.rb', line 5974 def operator_loc @operator_loc end |
#variable ⇒ Object (readonly)
attr_reader variable: Node
5971 5972 5973 |
# File 'lib/yarp/node.rb', line 5971 def variable @variable end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
5984 5985 5986 |
# File 'lib/yarp/node.rb', line 5984 def accept(visitor) visitor.visit_pinned_variable_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
5989 5990 5991 |
# File 'lib/yarp/node.rb', line 5989 def child_nodes [variable] end |
#copy(**params) ⇒ Object
def copy: (**params) -> PinnedVariableNode
5994 5995 5996 5997 5998 5999 6000 |
# File 'lib/yarp/node.rb', line 5994 def copy(**params) PinnedVariableNode.new( params.fetch(:variable) { variable }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
6006 6007 6008 |
# File 'lib/yarp/node.rb', line 6006 def deconstruct_keys(keys) { variable: variable, operator_loc: operator_loc, location: location } end |
#operator ⇒ Object
def operator: () -> String
6011 6012 6013 |
# File 'lib/yarp/node.rb', line 6011 def operator operator_loc.slice end |