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_id, location) ⇒ CallOperatorWriteNode

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



963
964
965
966
967
968
969
# File 'lib/yarp/node.rb', line 963

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

Instance Attribute Details

#operator_idObject (readonly)

attr_reader operator_id: Symbol



960
961
962
# File 'lib/yarp/node.rb', line 960

def operator_id
  @operator_id
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



954
955
956
# File 'lib/yarp/node.rb', line 954

def operator_loc
  @operator_loc
end

#targetObject (readonly)

attr_reader target: Node



951
952
953
# File 'lib/yarp/node.rb', line 951

def target
  @target
end

#valueObject (readonly)

attr_reader value: Node



957
958
959
# File 'lib/yarp/node.rb', line 957

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



972
973
974
# File 'lib/yarp/node.rb', line 972

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

#child_nodesObject Also known as: deconstruct

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



977
978
979
# File 'lib/yarp/node.rb', line 977

def child_nodes
  [target, value]
end

#deconstruct_keys(keys) ⇒ Object

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



985
986
987
# File 'lib/yarp/node.rb', line 985

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

#operatorObject

def operator: () -> String



990
991
992
# File 'lib/yarp/node.rb', line 990

def operator
  operator_loc.slice
end