Class: YARP::ClassVariableOperatorWriteNode

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

Overview

Represents assigning to a class 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) ⇒ ClassVariableOperatorWriteNode

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



1307
1308
1309
1310
1311
1312
1313
# File 'lib/yarp/node.rb', line 1307

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



1295
1296
1297
# File 'lib/yarp/node.rb', line 1295

def name_loc
  @name_loc
end

#operatorObject (readonly)

attr_reader operator: Symbol



1304
1305
1306
# File 'lib/yarp/node.rb', line 1304

def operator
  @operator
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



1298
1299
1300
# File 'lib/yarp/node.rb', line 1298

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node



1301
1302
1303
# File 'lib/yarp/node.rb', line 1301

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



1316
1317
1318
# File 'lib/yarp/node.rb', line 1316

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

#child_nodesObject Also known as: deconstruct

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



1322
1323
1324
# File 'lib/yarp/node.rb', line 1322

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object

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



1330
1331
1332
# File 'lib/yarp/node.rb', line 1330

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

#nameObject

def name: () -> String



1335
1336
1337
# File 'lib/yarp/node.rb', line 1335

def name
  name_loc.slice
end