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.
12381 12382 12383 12384 12385 12386 12387 |
# File 'lib/prism/node.rb', line 12381 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`
12429 12430 12431 |
# File 'lib/prism/node.rb', line 12429 def number @number end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
12442 12443 12444 |
# File 'lib/prism/node.rb', line 12442 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.
12448 12449 12450 12451 |
# File 'lib/prism/node.rb', line 12448 def ===(other) other.is_a?(NumberedReferenceReadNode) && (number === other.number) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
12390 12391 12392 |
# File 'lib/prism/node.rb', line 12390 def accept(visitor) visitor.visit_numbered_reference_read_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
12395 12396 12397 |
# File 'lib/prism/node.rb', line 12395 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
12405 12406 12407 |
# File 'lib/prism/node.rb', line 12405 def comment_targets [] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
12400 12401 12402 |
# File 'lib/prism/node.rb', line 12400 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
12410 12411 12412 |
# File 'lib/prism/node.rb', line 12410 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 }
12418 12419 12420 |
# File 'lib/prism/node.rb', line 12418 def deconstruct_keys(keys) { node_id: node_id, location: location, number: number } end |
#inspect ⇒ Object
def inspect -> String
12432 12433 12434 |
# File 'lib/prism/node.rb', line 12432 def inspect InspectVisitor.compose(self) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
12437 12438 12439 |
# File 'lib/prism/node.rb', line 12437 def type :numbered_reference_read_node end |