Class: SyntaxTree::RescueEx
Overview
RescueEx represents the list of exceptions being rescued in a rescue clause.
begin
rescue Exception => exception
end
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#exceptions ⇒ Object
readonly
- untyped
-
the list of exceptions being rescued.
-
#variable ⇒ Object
readonly
- nil | Field | VarField
-
the expression being used to capture the raised exception.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(exceptions:, variable:, location:, comments: []) ⇒ RescueEx
constructor
A new instance of RescueEx.
Methods inherited from Node
Constructor Details
#initialize(exceptions:, variable:, location:, comments: []) ⇒ RescueEx
Returns a new instance of RescueEx.
7375 7376 7377 7378 7379 7380 |
# File 'lib/syntax_tree/node.rb', line 7375 def initialize(exceptions:, variable:, location:, comments: []) @exceptions = exceptions @variable = variable @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
7373 7374 7375 |
# File 'lib/syntax_tree/node.rb', line 7373 def comments @comments end |
#exceptions ⇒ Object (readonly)
- untyped
-
the list of exceptions being rescued
7366 7367 7368 |
# File 'lib/syntax_tree/node.rb', line 7366 def exceptions @exceptions end |
#variable ⇒ Object (readonly)
- nil | Field | VarField
-
the expression being used to capture the raised
exception
7370 7371 7372 |
# File 'lib/syntax_tree/node.rb', line 7370 def variable @variable end |
Instance Method Details
#accept(visitor) ⇒ Object
7382 7383 7384 |
# File 'lib/syntax_tree/node.rb', line 7382 def accept(visitor) visitor.visit_rescue_ex(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
7386 7387 7388 |
# File 'lib/syntax_tree/node.rb', line 7386 def child_nodes [*exceptions, variable] end |
#deconstruct_keys(keys) ⇒ Object
7392 7393 7394 7395 7396 7397 7398 7399 |
# File 'lib/syntax_tree/node.rb', line 7392 def deconstruct_keys(keys) { exceptions: exceptions, variable: variable, location: location, comments: comments } end |
#format(q) ⇒ Object
7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 |
# File 'lib/syntax_tree/node.rb', line 7401 def format(q) q.group do if exceptions q.text(" ") q.format(exceptions) end if variable q.text(" => ") q.format(variable) end end end |