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



970
971
972
973
974
975
976
# File 'lib/yarp/node.rb', line 970

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



967
968
969
# File 'lib/yarp/node.rb', line 967

def operator_id
  @operator_id
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



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

def operator_loc
  @operator_loc
end

#targetObject (readonly)

attr_reader target: Node



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

def target
  @target
end

#valueObject (readonly)

attr_reader value: Node



964
965
966
# File 'lib/yarp/node.rb', line 964

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



979
980
981
# File 'lib/yarp/node.rb', line 979

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

#child_nodesObject Also known as: deconstruct

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



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

def child_nodes
  [target, value]
end

#deconstruct_keys(keys) ⇒ Object

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



993
994
995
# File 'lib/yarp/node.rb', line 993

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

#operatorObject

def operator: () -> String



998
999
1000
# File 'lib/yarp/node.rb', line 998

def operator
  operator_loc.slice
end