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: ConstantPathNode, operator_loc: Location, value: Node, operator: Symbol, location: Location) -> void



2046
2047
2048
2049
2050
2051
2052
# File 'lib/yarp/node.rb', line 2046

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



2043
2044
2045
# File 'lib/yarp/node.rb', line 2043

def operator
  @operator
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



2037
2038
2039
# File 'lib/yarp/node.rb', line 2037

def operator_loc
  @operator_loc
end

#targetObject (readonly)

attr_reader target: ConstantPathNode



2034
2035
2036
# File 'lib/yarp/node.rb', line 2034

def target
  @target
end

#valueObject (readonly)

attr_reader value: Node



2040
2041
2042
# File 'lib/yarp/node.rb', line 2040

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



2055
2056
2057
# File 'lib/yarp/node.rb', line 2055

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

#child_nodesObject Also known as: deconstruct

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



2060
2061
2062
# File 'lib/yarp/node.rb', line 2060

def child_nodes
  [target, value]
end

#copy(**params) ⇒ Object

def copy: (**params) -> ConstantPathOperatorWriteNode



2065
2066
2067
2068
2069
2070
2071
2072
2073
# File 'lib/yarp/node.rb', line 2065

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

#deconstruct_keys(keys) ⇒ Object

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



2079
2080
2081
# File 'lib/yarp/node.rb', line 2079

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