Class: YARP::LocalVariableAndWriteNode

Inherits:
YARPNode
  • Object
show all
Defined in:
lib/yarp/node.rb,
ext/yarp/api_node.c

Overview

Represents the use of the ‘&&=` operator for assignment to a local variable.

target &&= value
^^^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name_loc, operator_loc, value, name, depth, location) ⇒ LocalVariableAndWriteNode

def initialize: (name_loc: Location, operator_loc: Location, value: Node, name: Symbol, depth: Integer, location: Location) -> void



4817
4818
4819
4820
4821
4822
4823
4824
# File 'lib/yarp/node.rb', line 4817

def initialize(name_loc, operator_loc, value, name, depth, location)
  @name_loc = name_loc
  @operator_loc = operator_loc
  @value = value
  @name = name
  @depth = depth
  @location = location
end

Instance Attribute Details

#depthObject (readonly)

attr_reader depth: Integer



4814
4815
4816
# File 'lib/yarp/node.rb', line 4814

def depth
  @depth
end

#nameObject (readonly)

attr_reader name: Symbol



4811
4812
4813
# File 'lib/yarp/node.rb', line 4811

def name
  @name
end

#name_locObject (readonly)

attr_reader name_loc: Location



4802
4803
4804
# File 'lib/yarp/node.rb', line 4802

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



4805
4806
4807
# File 'lib/yarp/node.rb', line 4805

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node



4808
4809
4810
# File 'lib/yarp/node.rb', line 4808

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4827
4828
4829
# File 'lib/yarp/node.rb', line 4827

def accept(visitor)
  visitor.visit_local_variable_and_write_node(self)
end

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



4832
4833
4834
# File 'lib/yarp/node.rb', line 4832

def child_nodes
  [value]
end

#copy(**params) ⇒ Object

def copy: (**params) -> LocalVariableAndWriteNode



4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
# File 'lib/yarp/node.rb', line 4837

def copy(**params)
  LocalVariableAndWriteNode.new(
    params.fetch(:name_loc) { name_loc },
    params.fetch(:operator_loc) { operator_loc },
    params.fetch(:value) { value },
    params.fetch(:name) { name },
    params.fetch(:depth) { depth },
    params.fetch(:location) { location },
  )
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]



4852
4853
4854
# File 'lib/yarp/node.rb', line 4852

def deconstruct_keys(keys)
  { name_loc: name_loc, operator_loc: operator_loc, value: value, name: name, depth: depth, location: location }
end

#operatorObject

def operator: () -> String



4857
4858
4859
# File 'lib/yarp/node.rb', line 4857

def operator
  operator_loc.slice
end