Class: Prism::BackReferenceReadNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::BackReferenceReadNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents reading a reference to a field in the previous match.
$'
^^
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The name of the back-reference variable, including the leading ‘$`.
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, name: self.name) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> BackReferenceReadNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol }.
-
#initialize(source, node_id, location, flags, name) ⇒ BackReferenceReadNode
constructor
Initialize a new BackReferenceReadNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, name) ⇒ BackReferenceReadNode
Initialize a new BackReferenceReadNode node.
1236 1237 1238 1239 1240 1241 1242 |
# File 'lib/prism/node.rb', line 1236 def initialize(source, node_id, location, flags, name) @source = source @node_id = node_id @location = location @flags = flags @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
The name of the back-reference variable, including the leading ‘$`.
$& # name `:$&`
$+ # name `:$+`
1282 1283 1284 |
# File 'lib/prism/node.rb', line 1282 def name @name end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
1295 1296 1297 |
# File 'lib/prism/node.rb', line 1295 def self.type :back_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.
1301 1302 1303 1304 |
# File 'lib/prism/node.rb', line 1301 def ===(other) other.is_a?(BackReferenceReadNode) && (name === other.name) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
1245 1246 1247 |
# File 'lib/prism/node.rb', line 1245 def accept(visitor) visitor.visit_back_reference_read_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
1250 1251 1252 |
# File 'lib/prism/node.rb', line 1250 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
1260 1261 1262 |
# File 'lib/prism/node.rb', line 1260 def comment_targets [] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
1255 1256 1257 |
# File 'lib/prism/node.rb', line 1255 def compact_child_nodes [] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> BackReferenceReadNode
1265 1266 1267 |
# File 'lib/prism/node.rb', line 1265 def copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name) BackReferenceReadNode.new(source, node_id, location, flags, name) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol }
1273 1274 1275 |
# File 'lib/prism/node.rb', line 1273 def deconstruct_keys(keys) { node_id: node_id, location: location, name: name } end |
#inspect ⇒ Object
def inspect -> String
1285 1286 1287 |
# File 'lib/prism/node.rb', line 1285 def inspect InspectVisitor.compose(self) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
1290 1291 1292 |
# File 'lib/prism/node.rb', line 1290 def type :back_reference_read_node end |