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
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(bodystmt:, location:, comments: []) ⇒ Begin
1560 1561 1562 1563 1564 |
# File 'lib/syntax_tree/node.rb', line 1560 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
1555 1556 1557 |
# File 'lib/syntax_tree/node.rb', line 1555 def bodystmt @bodystmt end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
1558 1559 1560 |
# File 'lib/syntax_tree/node.rb', line 1558 def comments @comments end |
Instance Method Details
#accept(visitor) ⇒ Object
1566 1567 1568 |
# File 'lib/syntax_tree/node.rb', line 1566 def accept(visitor) visitor.visit_begin(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
1570 1571 1572 |
# File 'lib/syntax_tree/node.rb', line 1570 def child_nodes [bodystmt] end |
#deconstruct_keys(_keys) ⇒ Object
1576 1577 1578 |
# File 'lib/syntax_tree/node.rb', line 1576 def deconstruct_keys(_keys) { bodystmt: bodystmt, location: location, comments: comments } end |
#format(q) ⇒ Object
1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 |
# File 'lib/syntax_tree/node.rb', line 1580 def format(q) q.text("begin") unless bodystmt.empty? q.indent do q.breakable_force unless bodystmt.statements.empty? q.format(bodystmt) end end q.breakable_force q.text("end") end |