Class: YARP::InstanceVariableOperatorWriteNode

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

Overview

Represents assigning to an instance variable using an operator that isn’t ‘=`.

@target += value
^^^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, name_loc, operator_loc, value, operator, location) ⇒ InstanceVariableOperatorWriteNode

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



3972
3973
3974
3975
3976
3977
3978
3979
# File 'lib/yarp/node.rb', line 3972

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

Instance Attribute Details

#nameObject (readonly)

attr_reader name: Symbol



3957
3958
3959
# File 'lib/yarp/node.rb', line 3957

def name
  @name
end

#name_locObject (readonly)

attr_reader name_loc: Location



3960
3961
3962
# File 'lib/yarp/node.rb', line 3960

def name_loc
  @name_loc
end

#operatorObject (readonly)

attr_reader operator: Symbol



3969
3970
3971
# File 'lib/yarp/node.rb', line 3969

def operator
  @operator
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



3963
3964
3965
# File 'lib/yarp/node.rb', line 3963

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node



3966
3967
3968
# File 'lib/yarp/node.rb', line 3966

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



3982
3983
3984
# File 'lib/yarp/node.rb', line 3982

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

#child_nodesObject Also known as: deconstruct

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



3987
3988
3989
# File 'lib/yarp/node.rb', line 3987

def child_nodes
  [value]
end

#copy(**params) ⇒ Object

def copy: (**params) -> InstanceVariableOperatorWriteNode



3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
# File 'lib/yarp/node.rb', line 3992

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

#deconstruct_keys(keys) ⇒ Object

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



4007
4008
4009
# File 'lib/yarp/node.rb', line 4007

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