Class: YARP::LocalVariableOperatorAndWriteNode

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

Overview

Represents the use of the ‘&&=` operator for assignment to a local variable.

target &&= value
^^^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name_loc, operator_loc, value, constant_id, location) ⇒ LocalVariableOperatorAndWriteNode

def initialize: (name_loc: Location, operator_loc: Location, value: Node, constant_id: Symbol, location: Location) -> void



3781
3782
3783
3784
3785
3786
3787
# File 'lib/yarp/node.rb', line 3781

def initialize(name_loc, operator_loc, value, constant_id, location)
  @name_loc = name_loc
  @operator_loc = operator_loc
  @value = value
  @constant_id = constant_id
  @location = location
end

Instance Attribute Details

#constant_idObject (readonly)

attr_reader constant_id: Symbol



3778
3779
3780
# File 'lib/yarp/node.rb', line 3778

def constant_id
  @constant_id
end

#name_locObject (readonly)

attr_reader name_loc: Location



3769
3770
3771
# File 'lib/yarp/node.rb', line 3769

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



3772
3773
3774
# File 'lib/yarp/node.rb', line 3772

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node



3775
3776
3777
# File 'lib/yarp/node.rb', line 3775

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



3790
3791
3792
# File 'lib/yarp/node.rb', line 3790

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

#child_nodesObject Also known as: deconstruct

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



3796
3797
3798
# File 'lib/yarp/node.rb', line 3796

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object

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



3804
3805
3806
# File 'lib/yarp/node.rb', line 3804

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

#nameObject

def name: () -> String



3809
3810
3811
# File 'lib/yarp/node.rb', line 3809

def name
  name_loc.slice
end

#operatorObject

def operator: () -> String



3814
3815
3816
# File 'lib/yarp/node.rb', line 3814

def operator
  operator_loc.slice
end