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
- #===(other) ⇒ Object
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #copy(exceptions: nil, variable: nil, location: nil) ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(exceptions:, variable:, location:) ⇒ RescueEx
constructor
A new instance of RescueEx.
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(exceptions:, variable:, location:) ⇒ RescueEx
Returns a new instance of RescueEx.
9231 9232 9233 9234 9235 9236 |
# File 'lib/syntax_tree/node.rb', line 9231 def initialize(exceptions:, variable:, location:) @exceptions = exceptions @variable = variable @location = location @comments = [] end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
9229 9230 9231 |
# File 'lib/syntax_tree/node.rb', line 9229 def comments @comments end |
#exceptions ⇒ Object (readonly)
- untyped
-
the list of exceptions being rescued
9222 9223 9224 |
# File 'lib/syntax_tree/node.rb', line 9222 def exceptions @exceptions end |
#variable ⇒ Object (readonly)
- nil | Field | VarField
-
the expression being used to capture the raised
exception
9226 9227 9228 |
# File 'lib/syntax_tree/node.rb', line 9226 def variable @variable end |
Instance Method Details
#===(other) ⇒ Object
9283 9284 9285 9286 |
# File 'lib/syntax_tree/node.rb', line 9283 def ===(other) other.is_a?(RescueEx) && exceptions === other.exceptions && variable === other.variable end |
#accept(visitor) ⇒ Object
9238 9239 9240 |
# File 'lib/syntax_tree/node.rb', line 9238 def accept(visitor) visitor.visit_rescue_ex(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9242 9243 9244 |
# File 'lib/syntax_tree/node.rb', line 9242 def child_nodes [*exceptions, variable] end |
#copy(exceptions: nil, variable: nil, location: nil) ⇒ Object
9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 |
# File 'lib/syntax_tree/node.rb', line 9246 def copy(exceptions: nil, variable: nil, location: nil) node = RescueEx.new( exceptions: exceptions || self.exceptions, variable: variable || self.variable, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end |
#deconstruct_keys(_keys) ⇒ Object
9260 9261 9262 9263 9264 9265 9266 9267 |
# File 'lib/syntax_tree/node.rb', line 9260 def deconstruct_keys(_keys) { exceptions: exceptions, variable: variable, location: location, comments: comments } end |
#format(q) ⇒ Object
9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 |
# File 'lib/syntax_tree/node.rb', line 9269 def format(q) q.group do if exceptions q.text(" ") q.format(exceptions) end if variable q.text(" => ") q.format(variable) end end end |