class SyntaxTree::Ensure
Ensure
represents the use of the ensure
keyword and its subsequent statements.
begin ensure end
Attributes
Kw
-
the ensure keyword that began this node
Statements
-
the expressions to be executed
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 5189 def initialize(keyword:, statements:, location:) @keyword = keyword @statements = statements @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 5238 def ===(other) other.is_a?(Ensure) && keyword === other.keyword && statements === other.statements end
Source
# File lib/syntax_tree/node.rb, line 5196 def accept(visitor) visitor.visit_ensure(self) end
Source
# File lib/syntax_tree/node.rb, line 5200 def child_nodes [keyword, statements] end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 5204 def copy(keyword: nil, statements: nil, location: nil) node = Ensure.new( keyword: keyword || self.keyword, statements: statements || self.statements, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
Source
# File lib/syntax_tree/node.rb, line 5218 def deconstruct_keys(_keys) { keyword: keyword, statements: statements, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 5227 def format(q) q.format(keyword) unless statements.empty? q.indent do q.breakable_force q.format(statements) end end end