Class: Prism::NumberedReferenceReadNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::NumberedReferenceReadNode
- Defined in:
- lib/prism/node.rb,
sig/generated/prism/node.rbs,
ext/prism/api_node.c
Overview
Represents reading a numbered reference to a capture in the previous match.
$1
^^
Class Method Summary collapse
-
.type ⇒ :numbered_reference_read_node
See
Node.type.
Instance Method Summary collapse
-
#===(other) ⇒ boolish
: (untyped other) -> boolish.
-
#accept(visitor) ⇒ Object
See Node.accept.
-
#child_nodes ⇒ Array[node?]
(also: #deconstruct)
See Node.child_nodes.
-
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, number: self.number) ⇒ NumberedReferenceReadNode
:call-seq: copy(**fields) -> NumberedReferenceReadNode.
-
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped].
-
#each_child_node {|arg0| ... } ⇒ Object
See Node.each_child_node.
-
#initialize(source, node_id, location, flags, number) ⇒ NumberedReferenceReadNode
constructor
Initialize a new NumberedReferenceReadNode node.
-
#inspect ⇒ String
: () -> String.
-
#number ⇒ Integer
:call-seq: number -> Integer.
-
#type ⇒ :numbered_reference_read_node
See
Node#type.
Constructor Details
#initialize(source, node_id, location, flags, number) ⇒ NumberedReferenceReadNode
Initialize a new NumberedReferenceReadNode node.
: (Source source, Integer node_id, Location location, Integer flags, Integer number) -> void
25325 25326 25327 25328 25329 25330 25331 |
# File 'lib/prism/node.rb', line 25325 def initialize(source, node_id, location, flags, number) @source = source @node_id = node_id @location = location @flags = flags @number = number end |
Class Method Details
.type ⇒ :numbered_reference_read_node
See Node.type.
: () -> :numbered_reference_read_node
25409 25410 25411 |
# File 'lib/prism/node.rb', line 25409 def self.type :numbered_reference_read_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
25445 25446 25447 25448 |
# File 'lib/prism/node.rb', line 25445 def ===(other) # :nodoc: other.is_a?(NumberedReferenceReadNode) && (number === other.number) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
25347 25348 25349 |
# File 'lib/prism/node.rb', line 25347 def accept(visitor) visitor.visit_numbered_reference_read_node(self) end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
25354 25355 25356 |
# File 'lib/prism/node.rb', line 25354 def child_nodes [] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
25370 25371 25372 |
# File 'lib/prism/node.rb', line 25370 def compact_child_nodes [] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, number: self.number) ⇒ NumberedReferenceReadNode
:call-seq:
copy(**fields) -> NumberedReferenceReadNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?number: Integer) -> NumberedReferenceReadNode
25380 25381 25382 |
# File 'lib/prism/node.rb', line 25380 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) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
25387 25388 25389 25390 25391 25392 25393 25394 25395 25396 25397 |
# File 'lib/prism/node.rb', line 25387 def deconstruct_keys(keys) # :nodoc: (keys || i[node_id location number]).each_with_object( {} #: Hash[Symbol, untyped] ) do |key, deconstructed| case key when :node_id then deconstructed[:node_id] = self.node_id when :location then deconstructed[:location] = self.location when :number then deconstructed[:number] = self.number end end end |
#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
25362 25363 25364 25365 |
# File 'lib/prism/node.rb', line 25362 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? end |
#inspect ⇒ String
: () -> String
25414 25415 25416 |
# File 'lib/prism/node.rb', line 25414 def inspect # :nodoc: InspectVisitor.compose(self) end |
#number ⇒ Integer
:call-seq:
number -> Integer
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`
: () -> Integer
25436 25437 25438 |
# File 'lib/prism/node.rb', line 25436 def number @number end |
#type ⇒ :numbered_reference_read_node
See Node#type.
: () -> :numbered_reference_read_node
25402 25403 25404 |
# File 'lib/prism/node.rb', line 25402 def type :numbered_reference_read_node end |