class Prism::LocalVariableOrWriteNode
Represents the use of the ||= operator for assignment to a local variable.
target ||= value ^^^^^^^^^^^^^^^^
Public Class Methods
new(source, node_id, location, flags, name_loc, operator_loc, value, name, depth)
click to toggle source
Initialize a new LocalVariableOrWriteNode node.
# File lib/prism/node.rb, line 20378 def initialize(source, node_id, location, flags, name_loc, operator_loc, value, name, depth) @source = source @node_id = node_id @location = location @flags = flags @name_loc = name_loc @operator_loc = operator_loc @value = value @name = name @depth = depth end
Public Instance Methods
depth → Integer
click to toggle source
Returns the depth attribute.
# File lib/prism/node.rb, line 20547 def depth @depth end
name → Symbol
click to toggle source
Returns the name attribute.
# File lib/prism/node.rb, line 20537 def name @name end
value → Node
click to toggle source
Returns the value attribute.
# File lib/prism/node.rb, line 20527 def value @value end
Locations
↑ topPublic Instance Methods
name_loc → Location
click to toggle source
Returns the Location represented by name_loc.
# File lib/prism/node.rb, line 20484 def name_loc location = @name_loc return location if location.is_a?(Location) @name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
operator_loc → Location
click to toggle source
Returns the Location represented by operator_loc.
# File lib/prism/node.rb, line 20506 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Node Interface
↑ topPublic Class Methods
type()
click to toggle source
See Node.type.
# File lib/prism/node.rb, line 20466 def self.type :local_variable_or_write_node end
Public Instance Methods
accept(visitor)
click to toggle source
See Node.accept.
# File lib/prism/node.rb, line 20404 def accept(visitor) visitor.visit_local_variable_or_write_node(self) end
child_nodes()
click to toggle source
See Node.child_nodes.
# File lib/prism/node.rb, line 20411 def child_nodes [value] end
Also aliased as: deconstruct
comment_targets()
click to toggle source
See Node.comment_targets.
# File lib/prism/node.rb, line 20435 def comment_targets [name_loc, operator_loc, value] #: Array[Prism::node | Location] end
compact_child_nodes()
click to toggle source
# File lib/prism/node.rb, line 20428 def compact_child_nodes [value] end
copy(**fields) → LocalVariableOrWriteNode
click to toggle source
Creates a copy of self with the given fields, using self as the template.
# File lib/prism/node.rb, line 20445 def copy(node_id: self.node_id, location: self.location, flags: self.flags, name_loc: self.name_loc, operator_loc: self.operator_loc, value: self.value, name: self.name, depth: self.depth) LocalVariableOrWriteNode.new(source, node_id, location, flags, name_loc, operator_loc, value, name, depth) end
each_child_node() { |value| ... }
click to toggle source
See Node.each_child_node.
# File lib/prism/node.rb, line 20419 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield value end
type()
click to toggle source
See Node#type.
# File lib/prism/node.rb, line 20459 def type :local_variable_or_write_node end
Repository
↑ topPublic Instance Methods
save_name_loc(repository)
click to toggle source
Save the name_loc location using the given saved source so that it can be retrieved later.
# File lib/prism/node.rb, line 20495 def save_name_loc(repository) repository.enter(node_id, :name_loc) end
save_operator_loc(repository)
click to toggle source
Save the operator_loc location using the given saved source so that it can be retrieved later.
# File lib/prism/node.rb, line 20517 def save_operator_loc(repository) repository.enter(node_id, :operator_loc) end
Slicing
↑ topPublic Instance Methods
operator → String
click to toggle source
Slice the location of operator_loc from the source.
# File lib/prism/node.rb, line 20559 def operator operator_loc.slice end