Class: YARP::CallOperatorAndWriteNode

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, operator_loc, value, location) ⇒ CallOperatorAndWriteNode

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



873
874
875
876
877
878
# File 'lib/yarp/node.rb', line 873

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

Instance Attribute Details

#operator_locObject (readonly)

attr_reader operator_loc: Location



867
868
869
# File 'lib/yarp/node.rb', line 867

def operator_loc
  @operator_loc
end

#targetObject (readonly)

attr_reader target: Node



864
865
866
# File 'lib/yarp/node.rb', line 864

def target
  @target
end

#valueObject (readonly)

attr_reader value: Node



870
871
872
# File 'lib/yarp/node.rb', line 870

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



881
882
883
# File 'lib/yarp/node.rb', line 881

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

#child_nodesObject Also known as: deconstruct

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



887
888
889
# File 'lib/yarp/node.rb', line 887

def child_nodes
  [target, value]
end

#deconstruct_keys(keys) ⇒ Object

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



895
896
897
# File 'lib/yarp/node.rb', line 895

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

#operatorObject

def operator: () -> String



900
901
902
# File 'lib/yarp/node.rb', line 900

def operator
  operator_loc.slice
end