Class: YARP::ConstantPathOperatorWriteNode

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

Overview

Represents assigning to a constant path using an operator that isn’t ‘=`.

Parent::Child += value
^^^^^^^^^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, operator_loc, value, operator, location) ⇒ ConstantPathOperatorWriteNode

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



1714
1715
1716
1717
1718
1719
1720
# File 'lib/yarp/node.rb', line 1714

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

Instance Attribute Details

#operatorObject (readonly)

attr_reader operator: Symbol



1711
1712
1713
# File 'lib/yarp/node.rb', line 1711

def operator
  @operator
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



1705
1706
1707
# File 'lib/yarp/node.rb', line 1705

def operator_loc
  @operator_loc
end

#targetObject (readonly)

attr_reader target: Node



1702
1703
1704
# File 'lib/yarp/node.rb', line 1702

def target
  @target
end

#valueObject (readonly)

attr_reader value: Node



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

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



1723
1724
1725
# File 'lib/yarp/node.rb', line 1723

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

#child_nodesObject Also known as: deconstruct

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



1728
1729
1730
# File 'lib/yarp/node.rb', line 1728

def child_nodes
  [target, value]
end

#deconstruct_keys(keys) ⇒ Object

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



1736
1737
1738
# File 'lib/yarp/node.rb', line 1736

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