Class: YARP::ConstantPathOperatorOrWriteNode

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) ⇒ ConstantPathOperatorOrWriteNode

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



1686
1687
1688
1689
1690
1691
# File 'lib/yarp/node.rb', line 1686

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



1680
1681
1682
# File 'lib/yarp/node.rb', line 1680

def operator_loc
  @operator_loc
end

#targetObject (readonly)

attr_reader target: Node



1677
1678
1679
# File 'lib/yarp/node.rb', line 1677

def target
  @target
end

#valueObject (readonly)

attr_reader value: Node



1683
1684
1685
# File 'lib/yarp/node.rb', line 1683

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



1694
1695
1696
# File 'lib/yarp/node.rb', line 1694

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

#child_nodesObject Also known as: deconstruct

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



1700
1701
1702
# File 'lib/yarp/node.rb', line 1700

def child_nodes
  [target, value]
end

#deconstruct_keys(keys) ⇒ Object

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



1708
1709
1710
# File 'lib/yarp/node.rb', line 1708

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

#operatorObject

def operator: () -> String



1713
1714
1715
# File 'lib/yarp/node.rb', line 1713

def operator
  operator_loc.slice
end