Class: YARP::ConstantPathAndWriteNode

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

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



1931
1932
1933
1934
1935
1936
# File 'lib/yarp/node.rb', line 1931

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



1925
1926
1927
# File 'lib/yarp/node.rb', line 1925

def operator_loc
  @operator_loc
end

#targetObject (readonly)

attr_reader target: ConstantPathNode



1922
1923
1924
# File 'lib/yarp/node.rb', line 1922

def target
  @target
end

#valueObject (readonly)

attr_reader value: Node



1928
1929
1930
# File 'lib/yarp/node.rb', line 1928

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



1939
1940
1941
# File 'lib/yarp/node.rb', line 1939

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

#child_nodesObject Also known as: deconstruct

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



1944
1945
1946
# File 'lib/yarp/node.rb', line 1944

def child_nodes
  [target, value]
end

#copy(**params) ⇒ Object

def copy: (**params) -> ConstantPathAndWriteNode



1949
1950
1951
1952
1953
1954
1955
1956
# File 'lib/yarp/node.rb', line 1949

def copy(**params)
  ConstantPathAndWriteNode.new(
    params.fetch(:target) { target },
    params.fetch(:operator_loc) { operator_loc },
    params.fetch(:value) { value },
    params.fetch(:location) { location },
  )
end

#deconstruct_keys(keys) ⇒ Object

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



1962
1963
1964
# File 'lib/yarp/node.rb', line 1962

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

#operatorObject

def operator: () -> String



1967
1968
1969
# File 'lib/yarp/node.rb', line 1967

def operator
  operator_loc.slice
end