Class: SyntaxTree::RescueEx
- Inherits:
-
Object
- Object
- SyntaxTree::RescueEx
- Defined in:
- lib/syntax_tree.rb
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.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#variable ⇒ Object
readonly
- nil | Field | VarField
-
the expression being used to capture the raised exception.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(exceptions:, variable:, location:, comments: []) ⇒ RescueEx
constructor
A new instance of RescueEx.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(exceptions:, variable:, location:, comments: []) ⇒ RescueEx
Returns a new instance of RescueEx.
10182 10183 10184 10185 10186 10187 |
# File 'lib/syntax_tree.rb', line 10182 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
10180 10181 10182 |
# File 'lib/syntax_tree.rb', line 10180 def comments @comments end |
#exceptions ⇒ Object (readonly)
- untyped
-
the list of exceptions being rescued
10170 10171 10172 |
# File 'lib/syntax_tree.rb', line 10170 def exceptions @exceptions end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
10177 10178 10179 |
# File 'lib/syntax_tree.rb', line 10177 def location @location end |
#variable ⇒ Object (readonly)
- nil | Field | VarField
-
the expression being used to capture the raised
exception
10174 10175 10176 |
# File 'lib/syntax_tree.rb', line 10174 def variable @variable end |
Instance Method Details
#child_nodes ⇒ Object
10189 10190 10191 |
# File 'lib/syntax_tree.rb', line 10189 def child_nodes [*exceptions, variable] end |
#format(q) ⇒ Object
10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 |
# File 'lib/syntax_tree.rb', line 10193 def format(q) q.group do if exceptions q.text(" ") q.format(exceptions) end if variable q.text(" => ") q.format(variable) end end end |
#pretty_print(q) ⇒ Object
10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 |
# File 'lib/syntax_tree.rb', line 10207 def pretty_print(q) q.group(2, "(", ")") do q.text("rescue_ex") q.breakable q.pp(exceptions) q.breakable q.pp(variable) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
10221 10222 10223 10224 10225 10226 10227 10228 10229 |
# File 'lib/syntax_tree.rb', line 10221 def to_json(*opts) { type: :rescue_ex, extns: exceptions, var: variable, loc: location, cmts: comments }.to_json(*opts) end |