Class: YARP::RescueNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::RescueNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents a rescue statement.
begin
rescue Foo, *splat, Bar => ex
^^^^^^
foo
end
‘Foo, *splat, Bar` are in the `exceptions` field. `ex` is in the `exception` field.
Instance Attribute Summary collapse
-
#consequent ⇒ Object
readonly
attr_reader consequent: Node?.
-
#exceptions ⇒ Object
readonly
attr_reader exceptions: Array.
-
#keyword_loc ⇒ Object
readonly
attr_reader keyword_loc: Location.
-
#operator_loc ⇒ Object
readonly
attr_reader operator_loc: Location?.
-
#reference ⇒ Object
readonly
attr_reader reference: Node?.
-
#statements ⇒ Object
readonly
attr_reader statements: Node?.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(keyword_loc, exceptions, operator_loc, reference, statements, consequent, location) ⇒ RescueNode
constructor
def initialize: (keyword_loc: Location, exceptions: Array, operator_loc: Location?, reference: Node?, statements: Node?, consequent: Node?, location: Location) -> void.
-
#keyword ⇒ Object
def keyword: () -> String.
-
#operator ⇒ Object
def operator: () -> String?.
Constructor Details
#initialize(keyword_loc, exceptions, operator_loc, reference, statements, consequent, location) ⇒ RescueNode
def initialize: (keyword_loc: Location, exceptions: Array, operator_loc: Location?, reference: Node?, statements: Node?, consequent: Node?, location: Location) -> void
5266 5267 5268 5269 5270 5271 5272 5273 5274 |
# File 'lib/yarp/node.rb', line 5266 def initialize(keyword_loc, exceptions, operator_loc, reference, statements, consequent, location) @keyword_loc = keyword_loc @exceptions = exceptions @operator_loc = operator_loc @reference = reference @statements = statements @consequent = consequent @location = location end |
Instance Attribute Details
#consequent ⇒ Object (readonly)
attr_reader consequent: Node?
5263 5264 5265 |
# File 'lib/yarp/node.rb', line 5263 def consequent @consequent end |
#exceptions ⇒ Object (readonly)
attr_reader exceptions: Array
5251 5252 5253 |
# File 'lib/yarp/node.rb', line 5251 def exceptions @exceptions end |
#keyword_loc ⇒ Object (readonly)
attr_reader keyword_loc: Location
5248 5249 5250 |
# File 'lib/yarp/node.rb', line 5248 def keyword_loc @keyword_loc end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location?
5254 5255 5256 |
# File 'lib/yarp/node.rb', line 5254 def operator_loc @operator_loc end |
#reference ⇒ Object (readonly)
attr_reader reference: Node?
5257 5258 5259 |
# File 'lib/yarp/node.rb', line 5257 def reference @reference end |
#statements ⇒ Object (readonly)
attr_reader statements: Node?
5260 5261 5262 |
# File 'lib/yarp/node.rb', line 5260 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
5277 5278 5279 |
# File 'lib/yarp/node.rb', line 5277 def accept(visitor) visitor.visit_rescue_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
5283 5284 5285 |
# File 'lib/yarp/node.rb', line 5283 def child_nodes [*exceptions, reference, statements, consequent] end |
#deconstruct_keys(keys) ⇒ Object
5291 5292 5293 |
# File 'lib/yarp/node.rb', line 5291 def deconstruct_keys(keys) { keyword_loc: keyword_loc, exceptions: exceptions, operator_loc: operator_loc, reference: reference, statements: statements, consequent: consequent, location: location } end |
#keyword ⇒ Object
def keyword: () -> String
5296 5297 5298 |
# File 'lib/yarp/node.rb', line 5296 def keyword keyword_loc.slice end |
#operator ⇒ Object
def operator: () -> String?
5301 5302 5303 |
# File 'lib/yarp/node.rb', line 5301 def operator operator_loc&.slice end |