Class: YARP::ConstantPathOrWriteNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::ConstantPathOrWriteNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents the use of the ‘||=` operator for assignment to a constant path.
Parent::Child ||= value
^^^^^^^^^^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#operator_loc ⇒ Object
readonly
attr_reader operator_loc: Location.
-
#target ⇒ Object
readonly
attr_reader target: ConstantPathNode.
-
#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) -> ConstantPathOrWriteNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(target, operator_loc, value, location) ⇒ ConstantPathOrWriteNode
constructor
def initialize: (target: ConstantPathNode, operator_loc: Location, value: Node, location: Location) -> void.
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(target, operator_loc, value, location) ⇒ ConstantPathOrWriteNode
def initialize: (target: ConstantPathNode, operator_loc: Location, value: Node, location: Location) -> void
2099 2100 2101 2102 2103 2104 |
# File 'lib/yarp/node.rb', line 2099 def initialize(target, operator_loc, value, location) @target = target @operator_loc = operator_loc @value = value @location = location end |
Instance Attribute Details
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
2093 2094 2095 |
# File 'lib/yarp/node.rb', line 2093 def operator_loc @operator_loc end |
#target ⇒ Object (readonly)
attr_reader target: ConstantPathNode
2090 2091 2092 |
# File 'lib/yarp/node.rb', line 2090 def target @target end |
#value ⇒ Object (readonly)
attr_reader value: Node
2096 2097 2098 |
# File 'lib/yarp/node.rb', line 2096 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
2107 2108 2109 |
# File 'lib/yarp/node.rb', line 2107 def accept(visitor) visitor.visit_constant_path_or_write_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
2112 2113 2114 |
# File 'lib/yarp/node.rb', line 2112 def child_nodes [target, value] end |
#copy(**params) ⇒ Object
def copy: (**params) -> ConstantPathOrWriteNode
2117 2118 2119 2120 2121 2122 2123 2124 |
# File 'lib/yarp/node.rb', line 2117 def copy(**params) ConstantPathOrWriteNode.new( params.fetch(:target) { target }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:value) { value }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
2130 2131 2132 |
# File 'lib/yarp/node.rb', line 2130 def deconstruct_keys(keys) { target: target, operator_loc: operator_loc, value: value, location: location } end |
#operator ⇒ Object
def operator: () -> String
2135 2136 2137 |
# File 'lib/yarp/node.rb', line 2135 def operator operator_loc.slice end |