Class: Prism::NumberedReferenceReadNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::NumberedReferenceReadNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents reading a numbered reference to a capture in the previous match.
$1
^^
Instance Attribute Summary collapse
-
#number ⇒ Object
readonly
The (1-indexed, from the left) number of the capture group.
Class Method Summary collapse
-
.type ⇒ Object
Return a symbol representation of this node type.
Instance Method Summary collapse
-
#===(other) ⇒ Object
Implements case-equality for the node.
-
#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].
-
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, number: self.number) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?number: Integer) -> NumberedReferenceReadNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, number: Integer }.
-
#initialize(source, node_id, location, flags, number) ⇒ NumberedReferenceReadNode
constructor
Initialize a new NumberedReferenceReadNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, number) ⇒ NumberedReferenceReadNode
Initialize a new NumberedReferenceReadNode node.
12344 12345 12346 12347 12348 12349 12350 |
# File 'lib/prism/node.rb', line 12344 def initialize(source, node_id, location, flags, number) @source = source @node_id = node_id @location = location @flags = flags @number = number end |
Instance Attribute Details
#number ⇒ Object (readonly)
The (1-indexed, from the left) number of the capture group. Numbered references that are too large result in this value being ‘0`.
$1 # number `1`
$5432 # number `5432`
$4294967296 # number `0`
12392 12393 12394 |
# File 'lib/prism/node.rb', line 12392 def number @number end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
12405 12406 12407 |
# File 'lib/prism/node.rb', line 12405 def self.type :numbered_reference_read_node end |
Instance Method Details
#===(other) ⇒ Object
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
12411 12412 12413 12414 |
# File 'lib/prism/node.rb', line 12411 def ===(other) other.is_a?(NumberedReferenceReadNode) && (number === other.number) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
12353 12354 12355 |
# File 'lib/prism/node.rb', line 12353 def accept(visitor) visitor.visit_numbered_reference_read_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
12358 12359 12360 |
# File 'lib/prism/node.rb', line 12358 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
12368 12369 12370 |
# File 'lib/prism/node.rb', line 12368 def comment_targets [] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
12363 12364 12365 |
# File 'lib/prism/node.rb', line 12363 def compact_child_nodes [] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, number: self.number) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?number: Integer) -> NumberedReferenceReadNode
12373 12374 12375 |
# File 'lib/prism/node.rb', line 12373 def copy(node_id: self.node_id, location: self.location, flags: self.flags, number: self.number) NumberedReferenceReadNode.new(source, node_id, location, flags, number) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, number: Integer }
12381 12382 12383 |
# File 'lib/prism/node.rb', line 12381 def deconstruct_keys(keys) { node_id: node_id, location: location, number: number } end |
#inspect ⇒ Object
def inspect -> String
12395 12396 12397 |
# File 'lib/prism/node.rb', line 12395 def inspect InspectVisitor.compose(self) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
12400 12401 12402 |
# File 'lib/prism/node.rb', line 12400 def type :numbered_reference_read_node end |