Class: YARP::GlobalVariableOrWriteNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::GlobalVariableOrWriteNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents the use of the ‘||=` operator for assignment to a global variable.
$target ||= value
^^^^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#name_loc ⇒ Object
readonly
attr_reader name_loc: Location.
-
#operator_loc ⇒ Object
readonly
attr_reader operator_loc: Location.
-
#value ⇒ Object
readonly
attr_reader value: Node.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#copy(**params) ⇒ Object
def copy: (**params) -> GlobalVariableOrWriteNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(name_loc, operator_loc, value, location) ⇒ GlobalVariableOrWriteNode
constructor
def initialize: (name_loc: Location, operator_loc: Location, value: Node, location: Location) -> void.
-
#name ⇒ Object
def name: () -> String.
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(name_loc, operator_loc, value, location) ⇒ GlobalVariableOrWriteNode
def initialize: (name_loc: Location, operator_loc: Location, value: Node, location: Location) -> void
3391 3392 3393 3394 3395 3396 |
# File 'lib/yarp/node.rb', line 3391 def initialize(name_loc, operator_loc, value, location) @name_loc = name_loc @operator_loc = operator_loc @value = value @location = location end |
Instance Attribute Details
#name_loc ⇒ Object (readonly)
attr_reader name_loc: Location
3382 3383 3384 |
# File 'lib/yarp/node.rb', line 3382 def name_loc @name_loc end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
3385 3386 3387 |
# File 'lib/yarp/node.rb', line 3385 def operator_loc @operator_loc end |
#value ⇒ Object (readonly)
attr_reader value: Node
3388 3389 3390 |
# File 'lib/yarp/node.rb', line 3388 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
3399 3400 3401 |
# File 'lib/yarp/node.rb', line 3399 def accept(visitor) visitor.visit_global_variable_or_write_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
3404 3405 3406 |
# File 'lib/yarp/node.rb', line 3404 def child_nodes [value] end |
#copy(**params) ⇒ Object
def copy: (**params) -> GlobalVariableOrWriteNode
3409 3410 3411 3412 3413 3414 3415 3416 |
# File 'lib/yarp/node.rb', line 3409 def copy(**params) GlobalVariableOrWriteNode.new( params.fetch(:name_loc) { name_loc }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:value) { value }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
3422 3423 3424 |
# File 'lib/yarp/node.rb', line 3422 def deconstruct_keys(keys) { name_loc: name_loc, operator_loc: operator_loc, value: value, location: location } end |
#name ⇒ Object
def name: () -> String
3427 3428 3429 |
# File 'lib/yarp/node.rb', line 3427 def name name_loc.slice end |
#operator ⇒ Object
def operator: () -> String
3432 3433 3434 |
# File 'lib/yarp/node.rb', line 3432 def operator operator_loc.slice end |