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.
1446 1447 1448 1449 1450 |
# File 'lib/syntax_tree/node.rb', line 1446 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
1441 1442 1443 |
# File 'lib/syntax_tree/node.rb', line 1441 def bodystmt @bodystmt end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
1444 1445 1446 |
# File 'lib/syntax_tree/node.rb', line 1444 def comments @comments end |
Instance Method Details
#accept(visitor) ⇒ Object
1452 1453 1454 |
# File 'lib/syntax_tree/node.rb', line 1452 def accept(visitor) visitor.visit_begin(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
1456 1457 1458 |
# File 'lib/syntax_tree/node.rb', line 1456 def child_nodes [bodystmt] end |
#deconstruct_keys(keys) ⇒ Object
1462 1463 1464 |
# File 'lib/syntax_tree/node.rb', line 1462 def deconstruct_keys(keys) { bodystmt: bodystmt, location: location, comments: comments } end |
#format(q) ⇒ Object
1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 |
# File 'lib/syntax_tree/node.rb', line 1466 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 |