Class: YARP::ConstantPathWriteNode

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

Overview

Represents writing to a constant path.

::Foo = 1
^^^^^^^^^

Foo::Bar = 1
^^^^^^^^^^^^

::Foo::Bar = 1
^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

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



1762
1763
1764
1765
1766
1767
# File 'lib/yarp/node.rb', line 1762

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?



1756
1757
1758
# File 'lib/yarp/node.rb', line 1756

def operator_loc
  @operator_loc
end

#targetObject (readonly)

attr_reader target: Node



1753
1754
1755
# File 'lib/yarp/node.rb', line 1753

def target
  @target
end

#valueObject (readonly)

attr_reader value: Node?



1759
1760
1761
# File 'lib/yarp/node.rb', line 1759

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



1770
1771
1772
# File 'lib/yarp/node.rb', line 1770

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

#child_nodesObject Also known as: deconstruct

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



1775
1776
1777
# File 'lib/yarp/node.rb', line 1775

def child_nodes
  [target, value]
end

#deconstruct_keys(keys) ⇒ Object

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



1783
1784
1785
# File 'lib/yarp/node.rb', line 1783

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

#operatorObject

def operator: () -> String?



1788
1789
1790
# File 'lib/yarp/node.rb', line 1788

def operator
  operator_loc&.slice
end