Class: SyntaxTree::Ensure
Overview
Ensure represents the use of the ensure keyword and its subsequent
statements.
begin
ensure
end
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
[Array[ Comment | EmbDoc ]] the comments attached to this node.
-
#keyword ⇒ Object
readonly
[Kw] the ensure keyword that began this node.
-
#statements ⇒ Object
readonly
[Statements] the expressions to be executed.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(keyword:, statements:, location:, comments: []) ⇒ Ensure
constructor
A new instance of Ensure.
Methods inherited from Node
Constructor Details
#initialize(keyword:, statements:, location:, comments: []) ⇒ Ensure
Returns a new instance of Ensure.
4220 4221 4222 4223 4224 4225 |
# File 'lib/syntax_tree/node.rb', line 4220 def initialize(keyword:, statements:, location:, comments: []) @keyword = keyword @statements = statements @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
[Array[ Comment | EmbDoc ]] the comments attached to this node
4218 4219 4220 |
# File 'lib/syntax_tree/node.rb', line 4218 def comments @comments end |
#keyword ⇒ Object (readonly)
[Kw] the ensure keyword that began this node
4212 4213 4214 |
# File 'lib/syntax_tree/node.rb', line 4212 def keyword @keyword end |
#statements ⇒ Object (readonly)
[Statements] the expressions to be executed
4215 4216 4217 |
# File 'lib/syntax_tree/node.rb', line 4215 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
4227 4228 4229 |
# File 'lib/syntax_tree/node.rb', line 4227 def accept(visitor) visitor.visit_ensure(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
4231 4232 4233 |
# File 'lib/syntax_tree/node.rb', line 4231 def child_nodes [keyword, statements] end |
#deconstruct_keys(keys) ⇒ Object
4237 4238 4239 4240 4241 4242 4243 4244 |
# File 'lib/syntax_tree/node.rb', line 4237 def deconstruct_keys(keys) { keyword: keyword, statements: statements, location: location, comments: comments } end |
#format(q) ⇒ Object
4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 |
# File 'lib/syntax_tree/node.rb', line 4246 def format(q) q.format(keyword) unless statements.empty? q.indent do q.breakable(force: true) q.format(statements) end end end |