Class: YARP::CallOperatorOrWriteNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::CallOperatorOrWriteNode
- 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
-
#operator_loc ⇒ Object
readonly
attr_reader operator_loc: Location.
-
#target ⇒ Object
readonly
attr_reader target: CallNode.
-
#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) -> CallOperatorOrWriteNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(target, value, operator_loc, location) ⇒ CallOperatorOrWriteNode
constructor
def initialize: (target: CallNode, value: Node, operator_loc: Location, location: Location) -> void.
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(target, value, operator_loc, location) ⇒ CallOperatorOrWriteNode
def initialize: (target: CallNode, value: Node, operator_loc: Location, location: Location) -> void
1090 1091 1092 1093 1094 1095 |
# File 'lib/yarp/node.rb', line 1090 def initialize(target, value, operator_loc, location) @target = target @value = value @operator_loc = operator_loc @location = location end |
Instance Attribute Details
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
1087 1088 1089 |
# File 'lib/yarp/node.rb', line 1087 def operator_loc @operator_loc end |
#target ⇒ Object (readonly)
attr_reader target: CallNode
1081 1082 1083 |
# File 'lib/yarp/node.rb', line 1081 def target @target end |
#value ⇒ Object (readonly)
attr_reader value: Node
1084 1085 1086 |
# File 'lib/yarp/node.rb', line 1084 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
1098 1099 1100 |
# File 'lib/yarp/node.rb', line 1098 def accept(visitor) visitor.visit_call_operator_or_write_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
1103 1104 1105 |
# File 'lib/yarp/node.rb', line 1103 def child_nodes [target, value] end |
#copy(**params) ⇒ Object
def copy: (**params) -> CallOperatorOrWriteNode
1108 1109 1110 1111 1112 1113 1114 1115 |
# File 'lib/yarp/node.rb', line 1108 def copy(**params) CallOperatorOrWriteNode.new( params.fetch(:target) { target }, params.fetch(:value) { value }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
1121 1122 1123 |
# File 'lib/yarp/node.rb', line 1121 def deconstruct_keys(keys) { target: target, value: value, operator_loc: operator_loc, location: location } end |
#operator ⇒ Object
def operator: () -> String
1126 1127 1128 |
# File 'lib/yarp/node.rb', line 1126 def operator operator_loc.slice end |