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 `exception` field.
Attributes
attr_reader exceptions: Array
attr_reader reference: LocalVariableTargetNode
| InstanceVariableTargetNode
| ClassVariableTargetNode
| GlobalVariableTargetNode
| ConstantTargetNode
| ConstantPathTargetNode
| CallTargetNode
| IndexTargetNode
| BackReferenceReadNode
| NumberedReferenceReadNode
| MissingNode
| nil
attr_reader statements: StatementsNode
?
attr_reader subsequent: RescueNode
?
Public Class Methods
Initialize a new RescueNode
node.
# File prism/node.rb, line 14225 def initialize(source, node_id, location, flags, keyword_loc, exceptions, operator_loc, reference, statements, subsequent) @source = source @node_id = node_id @location = location @flags = flags @keyword_loc = keyword_loc @exceptions = exceptions @operator_loc = operator_loc @reference = reference @statements = statements @subsequent = subsequent end
Return a symbol representation of this node type. See ‘Node::type`.
# File prism/node.rb, line 14329 def self.type :rescue_node end
Public Instance Methods
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
# File prism/node.rb, line 14335 def ===(other) other.is_a?(RescueNode) && (keyword_loc.nil? == other.keyword_loc.nil?) && (exceptions.length == other.exceptions.length) && exceptions.zip(other.exceptions).all? { |left, right| left === right } && (operator_loc.nil? == other.operator_loc.nil?) && (reference === other.reference) && (statements === other.statements) && (subsequent === other.subsequent) end
def accept: (Visitor
visitor) -> void
# File prism/node.rb, line 14239 def accept(visitor) visitor.visit_rescue_node(self) end
def child_nodes
: () -> Array[nil | Node]
# File prism/node.rb, line 14244 def child_nodes [*exceptions, reference, statements, subsequent] end
def comment_targets
: () -> Array[Node | Location]
# File prism/node.rb, line 14259 def comment_targets [keyword_loc, *exceptions, *operator_loc, *reference, *statements, *subsequent] #: Array[Prism::node | Location] end
def compact_child_nodes
: () -> Array
# File prism/node.rb, line 14249 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
Returns the subsequent rescue clause of the rescue node. This method is deprecated in favor of subsequent
.
# File prism/node_ext.rb, line 494 def consequent deprecated("subsequent") subsequent end
def copy: (?node_id: Integer, ?location: Location
, ?flags: Integer, ?keyword_loc: Location
, ?exceptions: Array, ?operator_loc: Location
?, ?reference: LocalVariableTargetNode
| InstanceVariableTargetNode
| ClassVariableTargetNode
| GlobalVariableTargetNode
| ConstantTargetNode
| ConstantPathTargetNode
| CallTargetNode
| IndexTargetNode
| BackReferenceReadNode
| NumberedReferenceReadNode
| MissingNode
| nil, ?statements: StatementsNode
?, ?subsequent: RescueNode
?) -> RescueNode
# File prism/node.rb, line 14264 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, statements: self.statements, subsequent: self.subsequent) RescueNode.new(source, node_id, location, flags, keyword_loc, exceptions, operator_loc, reference, statements, subsequent) end
def deconstruct_keys
: (Array keys) -> { node_id: Integer, location: Location
, keyword_loc
: Location
, exceptions: Array, operator_loc
: Location
?, reference: LocalVariableTargetNode
| InstanceVariableTargetNode
| ClassVariableTargetNode
| GlobalVariableTargetNode
| ConstantTargetNode
| ConstantPathTargetNode
| CallTargetNode
| IndexTargetNode
| BackReferenceReadNode
| NumberedReferenceReadNode
| MissingNode
| nil, statements: StatementsNode
?, subsequent: RescueNode
? }
# File prism/node.rb, line 14272 def deconstruct_keys(keys) { node_id: node_id, location: location, keyword_loc: keyword_loc, exceptions: exceptions, operator_loc: operator_loc, reference: reference, statements: statements, subsequent: subsequent } end
def inspect -> String
# File prism/node.rb, line 14319 def inspect InspectVisitor.compose(self) end
def keyword: () -> String
# File prism/node.rb, line 14309 def keyword keyword_loc.slice end
attr_reader keyword_loc
: Location
# File prism/node.rb, line 14277 def keyword_loc location = @keyword_loc return location if location.is_a?(Location) @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
def operator: () -> String?
# File prism/node.rb, line 14314 def operator operator_loc&.slice end
attr_reader operator_loc
: Location
?
# File prism/node.rb, line 14287 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
Return a symbol representation of this node type. See ‘Node#type`.
# File prism/node.rb, line 14324 def type :rescue_node end