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
5320 5321 5322 5323 5324 5325 5326 5327 5328 |
# File 'lib/yarp/node.rb', line 5320 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?
5317 5318 5319 |
# File 'lib/yarp/node.rb', line 5317 def consequent @consequent end |
#exceptions ⇒ Object (readonly)
attr_reader exceptions: Array
5305 5306 5307 |
# File 'lib/yarp/node.rb', line 5305 def exceptions @exceptions end |
#keyword_loc ⇒ Object (readonly)
attr_reader keyword_loc: Location
5302 5303 5304 |
# File 'lib/yarp/node.rb', line 5302 def keyword_loc @keyword_loc end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location?
5308 5309 5310 |
# File 'lib/yarp/node.rb', line 5308 def operator_loc @operator_loc end |
#reference ⇒ Object (readonly)
attr_reader reference: Node?
5311 5312 5313 |
# File 'lib/yarp/node.rb', line 5311 def reference @reference end |
#statements ⇒ Object (readonly)
attr_reader statements: Node?
5314 5315 5316 |
# File 'lib/yarp/node.rb', line 5314 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
5331 5332 5333 |
# File 'lib/yarp/node.rb', line 5331 def accept(visitor) visitor.visit_rescue_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
5336 5337 5338 |
# File 'lib/yarp/node.rb', line 5336 def child_nodes [*exceptions, reference, statements, consequent] end |
#deconstruct_keys(keys) ⇒ Object
5344 5345 5346 |
# File 'lib/yarp/node.rb', line 5344 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
5349 5350 5351 |
# File 'lib/yarp/node.rb', line 5349 def keyword keyword_loc.slice end |
#operator ⇒ Object
def operator: () -> String?
5354 5355 5356 |
# File 'lib/yarp/node.rb', line 5354 def operator operator_loc&.slice end |