class Prism::EnsureNode
Represents an ensure clause in a begin statement.
begin foo ensure ^^^^^^ bar end
Public Class Methods
Source
# File lib/prism/node.rb, line 8968 def initialize(source, node_id, location, flags, ensure_keyword_loc, statements, end_keyword_loc) @source = source @node_id = node_id @location = location @flags = flags @ensure_keyword_loc = ensure_keyword_loc @statements = statements @end_keyword_loc = end_keyword_loc end
Initialize a new EnsureNode node.
Public Instance Methods
Source
# File lib/prism/node.rb, line 9070 def statements @statements end
Returns the statements attribute.
Locations
Public Instance Methods
Source
# File lib/prism/node.rb, line 9079 def end_keyword_loc location = @end_keyword_loc return location if location.is_a?(Location) @end_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Returns the Location represented by end_keyword_loc.
Source
# File lib/prism/node.rb, line 9053 def ensure_keyword_loc location = @ensure_keyword_loc return location if location.is_a?(Location) @ensure_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Returns the Location represented by ensure_keyword_loc.
Node Interface
Public Class Methods
Public Instance Methods
Source
# File lib/prism/node.rb, line 8990 def accept(visitor) visitor.visit_ensure_node(self) end
See Node.accept.
Source
# File lib/prism/node.rb, line 8995 def child_nodes [statements] end
See Node.child_nodes.
Also aliased as: deconstruct
Source
# File lib/prism/node.rb, line 9014 def comment_targets [ensure_keyword_loc, *statements, end_keyword_loc] #: Array[Prism::node | Location] end
See Node.comment_targets.
Source
# File lib/prism/node.rb, line 9007 def compact_child_nodes compact = [] #: Array[Prism::node] compact << statements if statements compact end
Source
# File lib/prism/node.rb, line 9022 def copy(node_id: self.node_id, location: self.location, flags: self.flags, ensure_keyword_loc: self.ensure_keyword_loc, statements: self.statements, end_keyword_loc: self.end_keyword_loc) EnsureNode.new(source, node_id, location, flags, ensure_keyword_loc, statements, end_keyword_loc) end
Creates a copy of self with the given fields, using self as the template.
Source
# File lib/prism/node.rb, line 9000 def each_child_node return to_enum(:each_child_node) unless block_given? yield statements if statements end
See Node.each_child_node.
Repository
Public Instance Methods
Source
# File lib/prism/node.rb, line 9088 def save_end_keyword_loc(repository) repository.enter(node_id, :end_keyword_loc) end
Save the end_keyword_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 9062 def save_ensure_keyword_loc(repository) repository.enter(node_id, :ensure_keyword_loc) end
Save the ensure_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 9106 def end_keyword end_keyword_loc.slice end
Slice the location of end_keyword_loc from the source.
Source
# File lib/prism/node.rb, line 9098 def ensure_keyword ensure_keyword_loc.slice end
Slice the location of ensure_keyword_loc from the source.