Class: YARP::AndNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::AndNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents the use of the ‘&&` operator or the `and` keyword.
left and right
^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
attr_reader left: Node.
-
#operator_loc ⇒ Object
readonly
attr_reader operator_loc: Location.
-
#right ⇒ Object
readonly
attr_reader right: Node.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#copy(**params) ⇒ Object
def copy: (**params) -> AndNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(left, right, operator_loc, location) ⇒ AndNode
constructor
def initialize: (left: Node, right: Node, operator_loc: Location, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(left, right, operator_loc, location) ⇒ AndNode
def initialize: (left: Node, right: Node, operator_loc: Location, location: Location) -> void
166 167 168 169 170 171 |
# File 'lib/yarp/node.rb', line 166 def initialize(left, right, operator_loc, location) @left = left @right = right @operator_loc = operator_loc @location = location end |
Instance Attribute Details
#left ⇒ Object (readonly)
attr_reader left: Node
157 158 159 |
# File 'lib/yarp/node.rb', line 157 def left @left end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
163 164 165 |
# File 'lib/yarp/node.rb', line 163 def operator_loc @operator_loc end |
#right ⇒ Object (readonly)
attr_reader right: Node
160 161 162 |
# File 'lib/yarp/node.rb', line 160 def right @right end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
174 175 176 |
# File 'lib/yarp/node.rb', line 174 def accept(visitor) visitor.visit_and_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
179 180 181 |
# File 'lib/yarp/node.rb', line 179 def child_nodes [left, right] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
184 185 186 |
# File 'lib/yarp/node.rb', line 184 def comment_targets [left, right, operator_loc] end |
#copy(**params) ⇒ Object
def copy: (**params) -> AndNode
189 190 191 192 193 194 195 196 |
# File 'lib/yarp/node.rb', line 189 def copy(**params) AndNode.new( params.fetch(:left) { left }, params.fetch(:right) { right }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
202 203 204 |
# File 'lib/yarp/node.rb', line 202 def deconstruct_keys(keys) { left: left, right: right, operator_loc: operator_loc, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
211 212 213 214 215 216 217 218 219 |
# File 'lib/yarp/node.rb', line 211 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) inspector << "├── left:\n" inspector << inspector.child_node(left, "│ ") inspector << "├── right:\n" inspector << inspector.child_node(right, "│ ") inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n" inspector.to_str end |
#operator ⇒ Object
def operator: () -> String
207 208 209 |
# File 'lib/yarp/node.rb', line 207 def operator operator_loc.slice end |