Class: YARP::ConstantPathOperatorAndWriteNode

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 a constant path.

Parent::Child &&= value
^^^^^^^^^^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, operator_loc, value, location) ⇒ ConstantPathOperatorAndWriteNode

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



1619
1620
1621
1622
1623
1624
# File 'lib/yarp/node.rb', line 1619

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

Instance Attribute Details

#operator_locObject (readonly)

attr_reader operator_loc: Location



1613
1614
1615
# File 'lib/yarp/node.rb', line 1613

def operator_loc
  @operator_loc
end

#targetObject (readonly)

attr_reader target: Node



1610
1611
1612
# File 'lib/yarp/node.rb', line 1610

def target
  @target
end

#valueObject (readonly)

attr_reader value: Node



1616
1617
1618
# File 'lib/yarp/node.rb', line 1616

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



1627
1628
1629
# File 'lib/yarp/node.rb', line 1627

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

#child_nodesObject Also known as: deconstruct

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



1632
1633
1634
# File 'lib/yarp/node.rb', line 1632

def child_nodes
  [target, value]
end

#deconstruct_keys(keys) ⇒ Object

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



1640
1641
1642
# File 'lib/yarp/node.rb', line 1640

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

#operatorObject

def operator: () -> String



1645
1646
1647
# File 'lib/yarp/node.rb', line 1645

def operator
  operator_loc.slice
end