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.
13736 13737 13738 13739 13740 13741 13742 |
# File 'lib/prism/node.rb', line 13736 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`
13784 13785 13786 |
# File 'lib/prism/node.rb', line 13784 def number @number end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
13797 13798 13799 |
# File 'lib/prism/node.rb', line 13797 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.
13803 13804 13805 13806 |
# File 'lib/prism/node.rb', line 13803 def ===(other) other.is_a?(NumberedReferenceReadNode) && (number === other.number) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
13745 13746 13747 |
# File 'lib/prism/node.rb', line 13745 def accept(visitor) visitor.visit_numbered_reference_read_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
13750 13751 13752 |
# File 'lib/prism/node.rb', line 13750 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
13760 13761 13762 |
# File 'lib/prism/node.rb', line 13760 def comment_targets [] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
13755 13756 13757 |
# File 'lib/prism/node.rb', line 13755 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
13765 13766 13767 |
# File 'lib/prism/node.rb', line 13765 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 }
13773 13774 13775 |
# File 'lib/prism/node.rb', line 13773 def deconstruct_keys(keys) { node_id: node_id, location: location, number: number } end |
#inspect ⇒ Object
def inspect -> String
13787 13788 13789 |
# File 'lib/prism/node.rb', line 13787 def inspect InspectVisitor.compose(self) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
13792 13793 13794 |
# File 'lib/prism/node.rb', line 13792 def type :numbered_reference_read_node end |