class Prism::IndexOperatorWriteNode
Represents the use of an assignment operator on a call to [].
foo.bar[baz] += value ^^^^^^^^^^^^^^^^^^^^^
Public Class Methods
(Source source, Integer node_id, Location location, Integer flags, Prism::node? receiver, Location? call_operator_loc, Location opening_loc, ArgumentsNode? arguments, Location closing_loc, BlockArgumentNode? block, Symbol binary_operator, Location binary_operator_loc, Prism::node value) → void
Source
# File lib/prism/node.rb, line 15732 def initialize(source, node_id, location, flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, binary_operator, binary_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 @binary_operator = binary_operator @binary_operator_loc = binary_operator_loc @value = value end
Initialize a new IndexOperatorWriteNode node.
Public Instance Methods
Source
# File lib/prism/node.rb, line 15940 def arguments @arguments end
Returns the arguments attribute.
Source
# File lib/prism/node.rb, line 15982 def binary_operator @binary_operator end
Returns the binary_operator attribute.
Source
# File lib/prism/node.rb, line 15972 def block @block end
Returns the block attribute.
() → Prism::node?
Source
# File lib/prism/node.rb, line 15881 def receiver @receiver end
Returns the receiver attribute.
() → Prism::node
Source
# File lib/prism/node.rb, line 16014 def value @value end
Returns the value attribute.
Flags
Public Instance Methods
() → bool
Source
# File lib/prism/node.rb, line 15863 def attribute_write? flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE) end
a call that is an attribute write, so the value being written should be returned
() → bool
Source
# File lib/prism/node.rb, line 15871 def ignore_visibility? flags.anybits?(CallNodeFlags::IGNORE_VISIBILITY) end
a call that ignores method visibility
() → bool
Source
# File lib/prism/node.rb, line 15855 def variable_call? flags.anybits?(CallNodeFlags::VARIABLE_CALL) end
a call that could have been a local variable
Locations
Public Instance Methods
() → Location
Source
# File lib/prism/node.rb, line 15993 def binary_operator_loc location = @binary_operator_loc return location if location.is_a?(Location) @binary_operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Returns the Location represented by binary_operator_loc.
() → Location?
Source
# File lib/prism/node.rb, line 15892 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.
() → Location
Source
# File lib/prism/node.rb, line 15951 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.
() → Location
Source
# File lib/prism/node.rb, line 15919 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.
Node Interface
These methods are present on all subclasses of Node. Read the node interface docs for more information.
Public Class Methods
Public Instance Methods
(_Visitor visitor) → untyped
Source
# File lib/prism/node.rb, line 15762 def accept(visitor) visitor.visit_index_operator_write_node(self) end
See Node.accept.
() → Array[node?]
Source
# File lib/prism/node.rb, line 15769 def child_nodes [receiver, arguments, block, value] end
See Node.child_nodes.
() → Array[node | Location]
Source
# File lib/prism/node.rb, line 15801 def comment_targets [*receiver, *call_operator_loc, opening_loc, *arguments, closing_loc, *block, binary_operator_loc, value] #: Array[Prism::node | Location] end
See Node.comment_targets.
() → Array[node]
Source
# File lib/prism/node.rb, line 15789 def compact_child_nodes compact = [] #: Array[Prism::node] if (receiver = self.receiver); compact << receiver; end if (arguments = self.arguments); compact << arguments; end if (block = self.block); compact << block; end compact << value compact end
(?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?, ?binary_operator: Symbol, ?binary_operator_loc: Location, ?value: Prism::node) → IndexOperatorWriteNode
Source
# File lib/prism/node.rb, line 15811 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, binary_operator: self.binary_operator, binary_operator_loc: self.binary_operator_loc, value: self.value) IndexOperatorWriteNode.new(source, node_id, location, flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, binary_operator, binary_operator_loc, value) end
Creates a copy of self with the given fields, using self as the template.
() → Enumerator[node, void]
() { (node) → void } → void
Source
# File lib/prism/node.rb, line 15777 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? if (receiver = self.receiver); yield receiver; end if (arguments = self.arguments); yield arguments; end if (block = self.block); yield block; end yield value end
See Node.each_child_node.
Repository
Methods related to Relocation.
Public Instance Methods
(_Repository repository) → Relocation::Entry
Source
# File lib/prism/node.rb, line 16004 def save_binary_operator_loc(repository) repository.enter(node_id, :binary_operator_loc) end
Save the binary_operator_loc location using the given saved source so that it can be retrieved later.
(_Repository repository) → Relocation::Entry?
Source
# File lib/prism/node.rb, line 15909 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.
(_Repository repository) → Relocation::Entry
Source
# File lib/prism/node.rb, line 15962 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.
(_Repository repository) → Relocation::Entry
Source
# File lib/prism/node.rb, line 15930 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.
Slicing
Public Instance Methods
Source
# File lib/prism/node.rb, line 16026 def call_operator call_operator_loc&.slice end
Slice the location of call_operator_loc from the source.
() → String
Source
# File lib/prism/node.rb, line 16046 def closing closing_loc.slice end
Slice the location of closing_loc from the source.
() → String
Source
# File lib/prism/node.rb, line 16036 def opening opening_loc.slice end
Slice the location of opening_loc from the source.