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.
3865 3866 3867 3868 3869 3870 |
# File 'lib/syntax_tree/node.rb', line 3865 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
3863 3864 3865 |
# File 'lib/syntax_tree/node.rb', line 3863 def comments @comments end |
#keyword ⇒ Object (readonly)
- Kw
-
the ensure keyword that began this node
3857 3858 3859 |
# File 'lib/syntax_tree/node.rb', line 3857 def keyword @keyword end |
#statements ⇒ Object (readonly)
- Statements
-
the expressions to be executed
3860 3861 3862 |
# File 'lib/syntax_tree/node.rb', line 3860 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
3872 3873 3874 |
# File 'lib/syntax_tree/node.rb', line 3872 def accept(visitor) visitor.visit_ensure(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
3876 3877 3878 |
# File 'lib/syntax_tree/node.rb', line 3876 def child_nodes [keyword, statements] end |
#deconstruct_keys(keys) ⇒ Object
3882 3883 3884 3885 3886 3887 3888 3889 |
# File 'lib/syntax_tree/node.rb', line 3882 def deconstruct_keys(keys) { keyword: keyword, statements: statements, location: location, comments: comments } end |
#format(q) ⇒ Object
3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 |
# File 'lib/syntax_tree/node.rb', line 3891 def format(q) q.format(keyword) unless statements.empty? q.indent do q.breakable(force: true) q.format(statements) end end end |