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
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(exceptions:, variable:, location:, comments: []) ⇒ RescueEx
Returns a new instance of RescueEx.
7583 7584 7585 7586 7587 7588 |
# File 'lib/syntax_tree/node.rb', line 7583 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
7581 7582 7583 |
# File 'lib/syntax_tree/node.rb', line 7581 def comments @comments end |
#exceptions ⇒ Object (readonly)
[untyped] the list of exceptions being rescued
7574 7575 7576 |
# File 'lib/syntax_tree/node.rb', line 7574 def exceptions @exceptions end |
#variable ⇒ Object (readonly)
[nil | Field | VarField] the expression being used to capture the raised exception
7578 7579 7580 |
# File 'lib/syntax_tree/node.rb', line 7578 def variable @variable end |
Instance Method Details
#accept(visitor) ⇒ Object
7590 7591 7592 |
# File 'lib/syntax_tree/node.rb', line 7590 def accept(visitor) visitor.visit_rescue_ex(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
7594 7595 7596 |
# File 'lib/syntax_tree/node.rb', line 7594 def child_nodes [*exceptions, variable] end |
#deconstruct_keys(_keys) ⇒ Object
7600 7601 7602 7603 7604 7605 7606 7607 |
# File 'lib/syntax_tree/node.rb', line 7600 def deconstruct_keys(_keys) { exceptions: exceptions, variable: variable, location: location, comments: comments } end |
#format(q) ⇒ Object
7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 |
# File 'lib/syntax_tree/node.rb', line 7609 def format(q) q.group do if exceptions q.text(" ") q.format(exceptions) end if variable q.text(" => ") q.format(variable) end end end |