Class: YARP::InstanceVariableAndWriteNode

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 an instance variable.

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, name_loc, operator_loc, value, location) ⇒ InstanceVariableAndWriteNode

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



3908
3909
3910
3911
3912
3913
3914
# File 'lib/yarp/node.rb', line 3908

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

Instance Attribute Details

#nameObject (readonly)

attr_reader name: Symbol



3896
3897
3898
# File 'lib/yarp/node.rb', line 3896

def name
  @name
end

#name_locObject (readonly)

attr_reader name_loc: Location



3899
3900
3901
# File 'lib/yarp/node.rb', line 3899

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



3902
3903
3904
# File 'lib/yarp/node.rb', line 3902

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node



3905
3906
3907
# File 'lib/yarp/node.rb', line 3905

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



3917
3918
3919
# File 'lib/yarp/node.rb', line 3917

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

#child_nodesObject Also known as: deconstruct

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



3922
3923
3924
# File 'lib/yarp/node.rb', line 3922

def child_nodes
  [value]
end

#copy(**params) ⇒ Object

def copy: (**params) -> InstanceVariableAndWriteNode



3927
3928
3929
3930
3931
3932
3933
3934
3935
# File 'lib/yarp/node.rb', line 3927

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

#deconstruct_keys(keys) ⇒ Object

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



3941
3942
3943
# File 'lib/yarp/node.rb', line 3941

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

#operatorObject

def operator: () -> String



3946
3947
3948
# File 'lib/yarp/node.rb', line 3946

def operator
  operator_loc.slice
end