Class: YARP::ClassVariableWriteNode

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

Overview

Represents writing to a class variable.

@@foo = 1
^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name_loc, value, operator_loc, location) ⇒ ClassVariableWriteNode

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



1385
1386
1387
1388
1389
1390
# File 'lib/yarp/node.rb', line 1385

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

Instance Attribute Details

#name_locObject (readonly)

attr_reader name_loc: Location



1376
1377
1378
# File 'lib/yarp/node.rb', line 1376

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location?



1382
1383
1384
# File 'lib/yarp/node.rb', line 1382

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node?



1379
1380
1381
# File 'lib/yarp/node.rb', line 1379

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



1393
1394
1395
# File 'lib/yarp/node.rb', line 1393

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

#child_nodesObject Also known as: deconstruct

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



1399
1400
1401
# File 'lib/yarp/node.rb', line 1399

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object

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



1407
1408
1409
# File 'lib/yarp/node.rb', line 1407

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

#nameObject

def name: () -> String



1412
1413
1414
# File 'lib/yarp/node.rb', line 1412

def name
  name_loc.slice
end

#operatorObject

def operator: () -> String?



1417
1418
1419
# File 'lib/yarp/node.rb', line 1417

def operator
  operator_loc&.slice
end