Class: SyntaxTree::DoBlock
Overview
DoBlock represents passing a block to a method call using the do and end keywords.
method do |value|
end
Instance Attribute Summary collapse
-
#block_var ⇒ Object
readonly
- nil | BlockVar
-
the optional variable declaration within this block.
-
#bodystmt ⇒ Object
readonly
- BodyStmt
-
the expressions to be executed within this block.
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#keyword ⇒ Object
readonly
- Kw
-
the do keyword that opens this block.
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:, block_var:, bodystmt:, location:, comments: []) ⇒ DoBlock
constructor
A new instance of DoBlock.
Methods inherited from Node
Constructor Details
#initialize(keyword:, block_var:, bodystmt:, location:, comments: []) ⇒ DoBlock
Returns a new instance of DoBlock.
3635 3636 3637 3638 3639 3640 3641 |
# File 'lib/syntax_tree/node.rb', line 3635 def initialize(keyword:, block_var:, bodystmt:, location:, comments: []) @keyword = keyword @block_var = block_var @bodystmt = bodystmt @location = location @comments = comments end |
Instance Attribute Details
#block_var ⇒ Object (readonly)
- nil | BlockVar
-
the optional variable declaration within this block
3627 3628 3629 |
# File 'lib/syntax_tree/node.rb', line 3627 def block_var @block_var end |
#bodystmt ⇒ Object (readonly)
- BodyStmt
-
the expressions to be executed within this block
3630 3631 3632 |
# File 'lib/syntax_tree/node.rb', line 3630 def bodystmt @bodystmt end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
3633 3634 3635 |
# File 'lib/syntax_tree/node.rb', line 3633 def comments @comments end |
#keyword ⇒ Object (readonly)
- Kw
-
the do keyword that opens this block
3624 3625 3626 |
# File 'lib/syntax_tree/node.rb', line 3624 def keyword @keyword end |
Instance Method Details
#accept(visitor) ⇒ Object
3643 3644 3645 |
# File 'lib/syntax_tree/node.rb', line 3643 def accept(visitor) visitor.visit_do_block(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
3647 3648 3649 |
# File 'lib/syntax_tree/node.rb', line 3647 def child_nodes [keyword, block_var, bodystmt] end |
#deconstruct_keys(keys) ⇒ Object
3653 3654 3655 3656 3657 3658 3659 3660 3661 |
# File 'lib/syntax_tree/node.rb', line 3653 def deconstruct_keys(keys) { keyword: keyword, block_var: block_var, bodystmt: bodystmt, location: location, comments: comments } end |
#format(q) ⇒ Object
3663 3664 3665 |
# File 'lib/syntax_tree/node.rb', line 3663 def format(q) BlockFormatter.new(self, keyword, "end", bodystmt).format(q) end |