Class: YARP::ClassVariableOrWriteNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::ClassVariableOrWriteNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents the use of the ‘||=` operator for assignment to a class variable.
@@target ||= value
^^^^^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
attr_reader name: Symbol.
-
#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) -> ClassVariableOrWriteNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(name, name_loc, operator_loc, value, location) ⇒ ClassVariableOrWriteNode
constructor
def initialize: (name: Symbol, name_loc: Location, operator_loc: Location, value: Node, location: Location) -> void.
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(name, name_loc, operator_loc, value, location) ⇒ ClassVariableOrWriteNode
def initialize: (name: Symbol, name_loc: Location, operator_loc: Location, value: Node, location: Location) -> void
1547 1548 1549 1550 1551 1552 1553 |
# File 'lib/yarp/node.rb', line 1547 def initialize(name, name_loc, operator_loc, value, location) @name = name @name_loc = name_loc @operator_loc = operator_loc @value = value @location = location end |
Instance Attribute Details
#name ⇒ Object (readonly)
attr_reader name: Symbol
1535 1536 1537 |
# File 'lib/yarp/node.rb', line 1535 def name @name end |
#name_loc ⇒ Object (readonly)
attr_reader name_loc: Location
1538 1539 1540 |
# File 'lib/yarp/node.rb', line 1538 def name_loc @name_loc end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
1541 1542 1543 |
# File 'lib/yarp/node.rb', line 1541 def operator_loc @operator_loc end |
#value ⇒ Object (readonly)
attr_reader value: Node
1544 1545 1546 |
# File 'lib/yarp/node.rb', line 1544 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
1556 1557 1558 |
# File 'lib/yarp/node.rb', line 1556 def accept(visitor) visitor.visit_class_variable_or_write_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
1561 1562 1563 |
# File 'lib/yarp/node.rb', line 1561 def child_nodes [value] end |
#copy(**params) ⇒ Object
def copy: (**params) -> ClassVariableOrWriteNode
1566 1567 1568 1569 1570 1571 1572 1573 1574 |
# File 'lib/yarp/node.rb', line 1566 def copy(**params) ClassVariableOrWriteNode.new( params.fetch(:name) { name }, 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
1580 1581 1582 |
# File 'lib/yarp/node.rb', line 1580 def deconstruct_keys(keys) { name: name, name_loc: name_loc, operator_loc: operator_loc, value: value, location: location } end |
#operator ⇒ Object
def operator: () -> String
1585 1586 1587 |
# File 'lib/yarp/node.rb', line 1585 def operator operator_loc.slice end |