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_loc, operator_loc, value, operator, location) ⇒ InstanceVariableOperatorWriteNode

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



3208
3209
3210
3211
3212
3213
3214
# File 'lib/yarp/node.rb', line 3208

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

Instance Attribute Details

#name_locObject (readonly)

attr_reader name_loc: Location



3196
3197
3198
# File 'lib/yarp/node.rb', line 3196

def name_loc
  @name_loc
end

#operatorObject (readonly)

attr_reader operator: Symbol



3205
3206
3207
# File 'lib/yarp/node.rb', line 3205

def operator
  @operator
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



3199
3200
3201
# File 'lib/yarp/node.rb', line 3199

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node



3202
3203
3204
# File 'lib/yarp/node.rb', line 3202

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



3217
3218
3219
# File 'lib/yarp/node.rb', line 3217

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

#child_nodesObject Also known as: deconstruct

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



3223
3224
3225
# File 'lib/yarp/node.rb', line 3223

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object

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



3231
3232
3233
# File 'lib/yarp/node.rb', line 3231

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

#nameObject

def name: () -> String



3236
3237
3238
# File 'lib/yarp/node.rb', line 3236

def name
  name_loc.slice
end