Class: SyntaxTree::Begin
Overview
Begin represents a begin..end chain.
begin
value
end
Instance Attribute Summary collapse
-
#bodystmt ⇒ Object
readonly
- BodyStmt
-
the bodystmt that contains the contents of this begin block.
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(bodystmt:, location:, comments: []) ⇒ Begin
constructor
A new instance of Begin.
Methods inherited from Node
Constructor Details
#initialize(bodystmt:, location:, comments: []) ⇒ Begin
Returns a new instance of Begin.
1398 1399 1400 1401 1402 |
# File 'lib/syntax_tree/node.rb', line 1398 def initialize(bodystmt:, location:, comments: []) @bodystmt = bodystmt @location = location @comments = comments end |
Instance Attribute Details
#bodystmt ⇒ Object (readonly)
- BodyStmt
-
the bodystmt that contains the contents of this begin block
1393 1394 1395 |
# File 'lib/syntax_tree/node.rb', line 1393 def bodystmt @bodystmt end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
1396 1397 1398 |
# File 'lib/syntax_tree/node.rb', line 1396 def comments @comments end |
Instance Method Details
#accept(visitor) ⇒ Object
1404 1405 1406 |
# File 'lib/syntax_tree/node.rb', line 1404 def accept(visitor) visitor.visit_begin(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
1408 1409 1410 |
# File 'lib/syntax_tree/node.rb', line 1408 def child_nodes [bodystmt] end |
#deconstruct_keys(keys) ⇒ Object
1414 1415 1416 |
# File 'lib/syntax_tree/node.rb', line 1414 def deconstruct_keys(keys) { bodystmt: bodystmt, location: location, comments: comments } end |
#format(q) ⇒ Object
1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 |
# File 'lib/syntax_tree/node.rb', line 1418 def format(q) q.text("begin") unless bodystmt.empty? q.indent do q.breakable(force: true) unless bodystmt.statements.empty? q.format(bodystmt) end end q.breakable(force: true) q.text("end") end |