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 ^bar
^^^^
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].
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#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.
- #inspect(inspector = NodeInspector.new) ⇒ Object
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(variable, operator_loc, location) ⇒ PinnedVariableNode
def initialize: (variable: Node, operator_loc: Location, location: Location) -> void
8017 8018 8019 8020 8021 |
# File 'lib/yarp/node.rb', line 8017 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
8014 8015 8016 |
# File 'lib/yarp/node.rb', line 8014 def operator_loc @operator_loc end |
#variable ⇒ Object (readonly)
attr_reader variable: Node
8011 8012 8013 |
# File 'lib/yarp/node.rb', line 8011 def variable @variable end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
8024 8025 8026 |
# File 'lib/yarp/node.rb', line 8024 def accept(visitor) visitor.visit_pinned_variable_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
8029 8030 8031 |
# File 'lib/yarp/node.rb', line 8029 def child_nodes [variable] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
8034 8035 8036 |
# File 'lib/yarp/node.rb', line 8034 def comment_targets [variable, operator_loc] end |
#copy(**params) ⇒ Object
def copy: (**params) -> PinnedVariableNode
8039 8040 8041 8042 8043 8044 8045 |
# File 'lib/yarp/node.rb', line 8039 def copy(**params) PinnedVariableNode.new( params.fetch(:variable) { variable }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
8051 8052 8053 |
# File 'lib/yarp/node.rb', line 8051 def deconstruct_keys(keys) { variable: variable, operator_loc: operator_loc, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
8060 8061 8062 8063 8064 8065 8066 |
# File 'lib/yarp/node.rb', line 8060 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) inspector << "├── variable:\n" inspector << inspector.child_node(variable, "│ ") inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n" inspector.to_str end |
#operator ⇒ Object
def operator: () -> String
8056 8057 8058 |
# File 'lib/yarp/node.rb', line 8056 def operator operator_loc.slice end |