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.
6833 6834 6835 6836 6837 6838 |
# File 'lib/syntax_tree/node.rb', line 6833 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
6831 6832 6833 |
# File 'lib/syntax_tree/node.rb', line 6831 def comments @comments end |
#exceptions ⇒ Object (readonly)
- untyped
-
the list of exceptions being rescued
6824 6825 6826 |
# File 'lib/syntax_tree/node.rb', line 6824 def exceptions @exceptions end |
#variable ⇒ Object (readonly)
- nil | Field | VarField
-
the expression being used to capture the raised
exception
6828 6829 6830 |
# File 'lib/syntax_tree/node.rb', line 6828 def variable @variable end |
Instance Method Details
#accept(visitor) ⇒ Object
6840 6841 6842 |
# File 'lib/syntax_tree/node.rb', line 6840 def accept(visitor) visitor.visit_rescue_ex(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
6844 6845 6846 |
# File 'lib/syntax_tree/node.rb', line 6844 def child_nodes [*exceptions, variable] end |
#deconstruct_keys(keys) ⇒ Object
6850 6851 6852 6853 6854 6855 6856 6857 |
# File 'lib/syntax_tree/node.rb', line 6850 def deconstruct_keys(keys) { exceptions: exceptions, variable: variable, location: location, comments: comments } end |
#format(q) ⇒ Object
6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 |
# File 'lib/syntax_tree/node.rb', line 6859 def format(q) q.group do if exceptions q.text(" ") q.format(exceptions) end if variable q.text(" => ") q.format(variable) end end end |