Class: Prism::MatchWriteNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::MatchWriteNode
- Defined in:
- lib/prism/node.rb,
sig/generated/prism/node.rbs,
ext/prism/api_node.c
Overview
Represents writing local variables using a regular expression match with named capture groups.
/(?<foo>bar)/ =~ baz
^^^^^^^^^^^^^^^^^^^^
Class Method Summary collapse
-
.type ⇒ :match_write_node
See
Node.type.
Instance Method Summary collapse
-
#===(other) ⇒ boolish
: (untyped other) -> boolish.
-
#accept(visitor) ⇒ Object
See Node.accept.
-
#call ⇒ CallNode
:call-seq: call -> CallNode.
-
#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, call: self.call, targets: self.targets) ⇒ MatchWriteNode
:call-seq: copy(**fields) -> MatchWriteNode.
-
#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, call, targets) ⇒ MatchWriteNode
constructor
Initialize a new MatchWriteNode node.
-
#inspect ⇒ String
: () -> String.
-
#targets ⇒ Array[LocalVariableTargetNode]
:call-seq: targets -> Array.
-
#type ⇒ :match_write_node
See
Node#type.
Constructor Details
#initialize(source, node_id, location, flags, call, targets) ⇒ MatchWriteNode
Initialize a new MatchWriteNode node.
: (Source source, Integer node_id, Location location, Integer flags, CallNode call, Array targets) -> void
23427 23428 23429 23430 23431 23432 23433 23434 |
# File 'lib/prism/node.rb', line 23427 def initialize(source, node_id, location, flags, call, targets) @source = source @node_id = node_id @location = location @flags = flags @call = call @targets = targets end |
Class Method Details
.type ⇒ :match_write_node
See Node.type.
: () -> :match_write_node
23515 23516 23517 |
# File 'lib/prism/node.rb', line 23515 def self.type :match_write_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
23551 23552 23553 23554 23555 23556 |
# File 'lib/prism/node.rb', line 23551 def ===(other) # :nodoc: other.is_a?(MatchWriteNode) && (call === other.call) && (targets.length == other.targets.length) && targets.zip(other.targets).all? { |left, right| left === right } end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
23450 23451 23452 |
# File 'lib/prism/node.rb', line 23450 def accept(visitor) visitor.visit_match_write_node(self) end |
#call ⇒ CallNode
:call-seq:
call -> CallNode
Returns the call attribute.
: () -> CallNode
23532 23533 23534 |
# File 'lib/prism/node.rb', line 23532 def call @call end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
23457 23458 23459 |
# File 'lib/prism/node.rb', line 23457 def child_nodes [call, *targets] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
23475 23476 23477 |
# File 'lib/prism/node.rb', line 23475 def compact_child_nodes [call, *targets] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, call: self.call, targets: self.targets) ⇒ MatchWriteNode
:call-seq:
copy(**fields) -> MatchWriteNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?call: CallNode, ?targets: Array) -> MatchWriteNode
23485 23486 23487 |
# File 'lib/prism/node.rb', line 23485 def copy(node_id: self.node_id, location: self.location, flags: self.flags, call: self.call, targets: self.targets) MatchWriteNode.new(source, node_id, location, flags, call, targets) end |
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
23492 23493 23494 23495 23496 23497 23498 23499 23500 23501 23502 23503 |
# File 'lib/prism/node.rb', line 23492 def deconstruct_keys(keys) # :nodoc: (keys || %i[node_id location call targets]).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 :call then deconstructed[:call] = self.call when :targets then deconstructed[:targets] = self.targets end end end |
#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
23465 23466 23467 23468 23469 23470 |
# File 'lib/prism/node.rb', line 23465 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield call targets.each { |node| yield node } end |
#inspect ⇒ String
: () -> String
23520 23521 23522 |
# File 'lib/prism/node.rb', line 23520 def inspect # :nodoc: InspectVisitor.compose(self) end |
#targets ⇒ Array[LocalVariableTargetNode]
23542 23543 23544 |
# File 'lib/prism/node.rb', line 23542 def targets @targets end |
#type ⇒ :match_write_node
See Node#type.
: () -> :match_write_node
23508 23509 23510 |
# File 'lib/prism/node.rb', line 23508 def type :match_write_node end |