class Prism::RescueNode
Represents a rescue statement.
begin rescue Foo, *splat, Bar => ex foo ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ end
Foo, *splat, Bar are in the exceptions field. ex is in the reference field.
Public Class Methods
Source
# File lib/prism/node.rb, line 21659 def initialize(source, node_id, location, flags, keyword_loc, exceptions, operator_loc, reference, then_keyword_loc, statements, subsequent) @source = source @node_id = node_id @location = location @flags = flags @keyword_loc = keyword_loc @exceptions = exceptions @operator_loc = operator_loc @reference = reference @then_keyword_loc = then_keyword_loc @statements = statements @subsequent = subsequent end
Initialize a new RescueNode node.
Public Instance Methods
Source
# File lib/prism/node_ext.rb, line 505 def consequent deprecated("subsequent") subsequent end
Returns the subsequent rescue clause of the rescue node. This method is deprecated in favor of subsequent.
Source
# File lib/prism/node.rb, line 21771 def exceptions @exceptions end
Returns the exceptions attribute.
Source
# File lib/prism/node.rb, line 21802 def reference @reference end
Returns the reference attribute.
Source
# File lib/prism/node.rb, line 21833 def statements @statements end
Returns the statements attribute.
Source
# File lib/prism/node.rb, line 21841 def subsequent @subsequent end
Returns the subsequent attribute.
Locations
Public Instance Methods
Source
# File lib/prism/node.rb, line 21754 def keyword_loc location = @keyword_loc return location if location.is_a?(Location) @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Returns the Location represented by keyword_loc.
Source
# File lib/prism/node.rb, line 21780 def operator_loc location = @operator_loc case location when nil nil when Location location else @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end
Returns the Location represented by operator_loc.
Source
# File lib/prism/node.rb, line 21811 def then_keyword_loc location = @then_keyword_loc case location when nil nil when Location location else @then_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end
Returns the Location represented by then_keyword_loc.
Node Interface
Public Class Methods
Public Instance Methods
Source
# File lib/prism/node.rb, line 21685 def accept(visitor) visitor.visit_rescue_node(self) end
See Node.accept.
Source
# File lib/prism/node.rb, line 21690 def child_nodes [*exceptions, reference, statements, subsequent] end
See Node.child_nodes.
Source
# File lib/prism/node.rb, line 21715 def comment_targets [keyword_loc, *exceptions, *operator_loc, *reference, *then_keyword_loc, *statements, *subsequent] #: Array[Prism::node | Location] end
See Node.comment_targets.
Source
# File lib/prism/node.rb, line 21705 def compact_child_nodes compact = [] #: Array[Prism::node] compact.concat(exceptions) compact << reference if reference compact << statements if statements compact << subsequent if subsequent compact end
Source
# File lib/prism/node.rb, line 21723 def copy(node_id: self.node_id, location: self.location, flags: self.flags, keyword_loc: self.keyword_loc, exceptions: self.exceptions, operator_loc: self.operator_loc, reference: self.reference, then_keyword_loc: self.then_keyword_loc, statements: self.statements, subsequent: self.subsequent) RescueNode.new(source, node_id, location, flags, keyword_loc, exceptions, operator_loc, reference, then_keyword_loc, statements, subsequent) end
Creates a copy of self with the given fields, using self as the template.
Source
# File lib/prism/node.rb, line 21695 def each_child_node return to_enum(:each_child_node) unless block_given? exceptions.each { |node| yield node } yield reference if reference yield statements if statements yield subsequent if subsequent end
See Node.each_child_node.
Repository
Public Instance Methods
Source
# File lib/prism/node.rb, line 21763 def save_keyword_loc(repository) repository.enter(node_id, :keyword_loc) end
Save the keyword_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 21795 def save_operator_loc(repository) repository.enter(node_id, :operator_loc) unless @operator_loc.nil? end
Save the operator_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 21826 def save_then_keyword_loc(repository) repository.enter(node_id, :then_keyword_loc) unless @then_keyword_loc.nil? end
Save the then_keyword_loc location using the given saved source so that it can be retrieved later.
Slicing
Public Instance Methods
Source
# File lib/prism/node.rb, line 21851 def keyword keyword_loc.slice end
Slice the location of keyword_loc from the source.
Source
# File lib/prism/node.rb, line 21859 def operator operator_loc&.slice end
Slice the location of operator_loc from the source.
Source
# File lib/prism/node.rb, line 21867 def then_keyword then_keyword_loc&.slice end
Slice the location of then_keyword_loc from the source.