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.
-
#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 }.
-
#each_child_node ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator.
-
#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.
14747 14748 14749 14750 14751 14752 14753 |
# File 'lib/prism/node.rb', line 14747 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`
14801 14802 14803 |
# File 'lib/prism/node.rb', line 14801 def number @number end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See Node::type.
14814 14815 14816 |
# File 'lib/prism/node.rb', line 14814 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.
14820 14821 14822 14823 |
# File 'lib/prism/node.rb', line 14820 def ===(other) other.is_a?(NumberedReferenceReadNode) && (number === other.number) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
14756 14757 14758 |
# File 'lib/prism/node.rb', line 14756 def accept(visitor) visitor.visit_numbered_reference_read_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
14761 14762 14763 |
# File 'lib/prism/node.rb', line 14761 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
14777 14778 14779 |
# File 'lib/prism/node.rb', line 14777 def comment_targets [] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
14772 14773 14774 |
# File 'lib/prism/node.rb', line 14772 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
14782 14783 14784 |
# File 'lib/prism/node.rb', line 14782 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 }
14790 14791 14792 |
# File 'lib/prism/node.rb', line 14790 def deconstruct_keys(keys) { node_id: node_id, location: location, number: number } end |
#each_child_node ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator
14766 14767 14768 14769 |
# File 'lib/prism/node.rb', line 14766 def each_child_node return to_enum(:each_child_node) unless block_given? end |
#inspect ⇒ Object
def inspect -> String
14804 14805 14806 |
# File 'lib/prism/node.rb', line 14804 def inspect InspectVisitor.compose(self) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
14809 14810 14811 |
# File 'lib/prism/node.rb', line 14809 def type :numbered_reference_read_node end |