Class: YARP::CallOperatorOrWriteNode

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

Overview

Represents the use of the ‘||=` operator on a call.

foo.bar ||= value
^^^^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, value, operator_loc, location) ⇒ CallOperatorOrWriteNode

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



920
921
922
923
924
925
# File 'lib/yarp/node.rb', line 920

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

Instance Attribute Details

#operator_locObject (readonly)

attr_reader operator_loc: Location



917
918
919
# File 'lib/yarp/node.rb', line 917

def operator_loc
  @operator_loc
end

#targetObject (readonly)

attr_reader target: Node



911
912
913
# File 'lib/yarp/node.rb', line 911

def target
  @target
end

#valueObject (readonly)

attr_reader value: Node



914
915
916
# File 'lib/yarp/node.rb', line 914

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



928
929
930
# File 'lib/yarp/node.rb', line 928

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

#child_nodesObject Also known as: deconstruct

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



934
935
936
# File 'lib/yarp/node.rb', line 934

def child_nodes
  [target, value]
end

#deconstruct_keys(keys) ⇒ Object

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



942
943
944
# File 'lib/yarp/node.rb', line 942

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

#operatorObject

def operator: () -> String



947
948
949
# File 'lib/yarp/node.rb', line 947

def operator
  operator_loc.slice
end