Class: YARP::CallOperatorWriteNode

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

Overview

Represents the use of an assignment operator on a call.

foo.bar += baz
^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

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



1149
1150
1151
1152
1153
1154
1155
# File 'lib/yarp/node.rb', line 1149

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



1146
1147
1148
# File 'lib/yarp/node.rb', line 1146

def operator
  @operator
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



1140
1141
1142
# File 'lib/yarp/node.rb', line 1140

def operator_loc
  @operator_loc
end

#targetObject (readonly)

attr_reader target: CallNode



1137
1138
1139
# File 'lib/yarp/node.rb', line 1137

def target
  @target
end

#valueObject (readonly)

attr_reader value: Node



1143
1144
1145
# File 'lib/yarp/node.rb', line 1143

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



1158
1159
1160
# File 'lib/yarp/node.rb', line 1158

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

#child_nodesObject Also known as: deconstruct

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



1163
1164
1165
# File 'lib/yarp/node.rb', line 1163

def child_nodes
  [target, value]
end

#copy(**params) ⇒ Object

def copy: (**params) -> CallOperatorWriteNode



1168
1169
1170
1171
1172
1173
1174
1175
1176
# File 'lib/yarp/node.rb', line 1168

def copy(**params)
  CallOperatorWriteNode.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]



1182
1183
1184
# File 'lib/yarp/node.rb', line 1182

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