class Prism::IndexAndWriteNode
Represents the use of the &&= operator on a call to the [] method.
foo.bar[baz] &&= value ^^^^^^^^^^^^^^^^^^^^^^
Public Class Methods
Source
# File lib/prism/node.rb, line 12273 def initialize(source, node_id, location, flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, operator_loc, value) @source = source @node_id = node_id @location = location @flags = flags @receiver = receiver @call_operator_loc = call_operator_loc @opening_loc = opening_loc @arguments = arguments @closing_loc = closing_loc @block = block @operator_loc = operator_loc @value = value end
Initialize a new IndexAndWriteNode node.
Public Instance Methods
Source
# File lib/prism/node.rb, line 12441 def arguments @arguments end
Returns the arguments attribute.
Source
# File lib/prism/node.rb, line 12467 def block @block end
Returns the block attribute.
Source
# File lib/prism/node.rb, line 12392 def receiver @receiver end
Returns the receiver attribute.
Source
# File lib/prism/node.rb, line 12493 def value @value end
Returns the value attribute.
Flags
Public Instance Methods
Source
# File lib/prism/node.rb, line 12378 def attribute_write? flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE) end
a call that is an attribute write, so the value being written should be returned
Source
# File lib/prism/node.rb, line 12384 def ignore_visibility? flags.anybits?(CallNodeFlags::IGNORE_VISIBILITY) end
a call that ignores method visibility
Source
# File lib/prism/node.rb, line 12372 def variable_call? flags.anybits?(CallNodeFlags::VARIABLE_CALL) end
a call that could have been a local variable
Locations
Public Instance Methods
Source
# File lib/prism/node.rb, line 12401 def call_operator_loc location = @call_operator_loc case location when nil nil when Location location else @call_operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end
Returns the Location represented by call_operator_loc.
Source
# File lib/prism/node.rb, line 12450 def closing_loc location = @closing_loc return location if location.is_a?(Location) @closing_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Returns the Location represented by closing_loc.
Source
# File lib/prism/node.rb, line 12424 def opening_loc location = @opening_loc return location if location.is_a?(Location) @opening_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Returns the Location represented by opening_loc.
Source
# File lib/prism/node.rb, line 12476 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Returns the Location represented by operator_loc.
Node Interface
Public Class Methods
Public Instance Methods
Source
# File lib/prism/node.rb, line 12300 def accept(visitor) visitor.visit_index_and_write_node(self) end
See Node.accept.
Source
# File lib/prism/node.rb, line 12305 def child_nodes [receiver, arguments, block, value] end
See Node.child_nodes.
Source
# File lib/prism/node.rb, line 12330 def comment_targets [*receiver, *call_operator_loc, opening_loc, *arguments, closing_loc, *block, operator_loc, value] #: Array[Prism::node | Location] end
See Node.comment_targets.
Source
# File lib/prism/node.rb, line 12320 def compact_child_nodes compact = [] #: Array[Prism::node] compact << receiver if receiver compact << arguments if arguments compact << block if block compact << value compact end
Source
# File lib/prism/node.rb, line 12338 def copy(node_id: self.node_id, location: self.location, flags: self.flags, receiver: self.receiver, call_operator_loc: self.call_operator_loc, opening_loc: self.opening_loc, arguments: self.arguments, closing_loc: self.closing_loc, block: self.block, operator_loc: self.operator_loc, value: self.value) IndexAndWriteNode.new(source, node_id, location, flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, operator_loc, value) end
Creates a copy of self with the given fields, using self as the template.
Source
# File lib/prism/node.rb, line 12310 def each_child_node return to_enum(:each_child_node) unless block_given? yield receiver if receiver yield arguments if arguments yield block if block yield value end
See Node.each_child_node.
Repository
Public Instance Methods
Source
# File lib/prism/node.rb, line 12416 def save_call_operator_loc(repository) repository.enter(node_id, :call_operator_loc) unless @call_operator_loc.nil? end
Save the call_operator_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 12459 def save_closing_loc(repository) repository.enter(node_id, :closing_loc) end
Save the closing_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 12433 def save_opening_loc(repository) repository.enter(node_id, :opening_loc) end
Save the opening_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 12485 def save_operator_loc(repository) repository.enter(node_id, :operator_loc) end
Save the operator_loc location using the given saved source so that it can be retrieved later.
Slicing
Public Instance Methods
Source
# File lib/prism/node.rb, line 12503 def call_operator call_operator_loc&.slice end
Slice the location of call_operator_loc from the source.
Source
# File lib/prism/node.rb, line 12519 def closing closing_loc.slice end
Slice the location of closing_loc from the source.
Source
# File lib/prism/node.rb, line 12511 def opening opening_loc.slice end
Slice the location of opening_loc from the source.
Source
# File lib/prism/node.rb, line 12527 def operator operator_loc.slice end
Slice the location of operator_loc from the source.