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 27019 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.rb, line 27156 def exceptions @exceptions end
Returns the exceptions attribute.
Source
# File lib/prism/node.rb, line 27193 def reference @reference end
Returns the reference attribute.
Source
# File lib/prism/node.rb, line 27230 def statements @statements end
Returns the statements attribute.
Source
# File lib/prism/node.rb, line 27240 def subsequent @subsequent end
Returns the subsequent attribute.
Locations
Public Instance Methods
Source
# File lib/prism/node.rb, line 27135 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 27167 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 27204 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
These methods are present on all subclasses of Node. Read the node interface docs for more information.
Public Class Methods
Public Instance Methods
Source
# File lib/prism/node.rb, line 27047 def accept(visitor) visitor.visit_rescue_node(self) end
See Node.accept.
Source
# File lib/prism/node.rb, line 27054 def child_nodes [*exceptions, reference, statements, subsequent] end
See Node.child_nodes.
Source
# File lib/prism/node.rb, line 27086 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 27074 def compact_child_nodes compact = [] #: Array[Prism::node] compact.concat(exceptions) if (reference = self.reference); compact << reference; end if (statements = self.statements); compact << statements; end if (subsequent = self.subsequent); compact << subsequent; end compact end
Source
# File lib/prism/node.rb, line 27096 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 27062 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? exceptions.each { |node| yield node } if (reference = self.reference); yield reference; end if (statements = self.statements); yield statements; end if (subsequent = self.subsequent); yield subsequent; end end
See Node.each_child_node.
Repository
Methods related to Relocation.
Public Instance Methods
Source
# File lib/prism/node.rb, line 27146 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 27184 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 27221 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 27252 def keyword keyword_loc.slice end
Slice the location of keyword_loc from the source.
Source
# File lib/prism/node.rb, line 27262 def operator operator_loc&.slice end
Slice the location of operator_loc from the source.
Source
# File lib/prism/node.rb, line 27272 def then_keyword then_keyword_loc&.slice end
Slice the location of then_keyword_loc from the source.