Class: SyntaxTree::ArgBlock
Overview
ArgBlock represents using a block operator on an expression.
method(&expression)
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#value ⇒ Object
readonly
- nil | untyped
-
the expression being turned into a 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(value:, location:, comments: []) ⇒ ArgBlock
constructor
A new instance of ArgBlock.
Methods inherited from Node
Constructor Details
#initialize(value:, location:, comments: []) ⇒ ArgBlock
Returns a new instance of ArgBlock.
614 615 616 617 618 |
# File 'lib/syntax_tree/node.rb', line 614 def initialize(value:, location:, comments: []) @value = value @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
612 613 614 |
# File 'lib/syntax_tree/node.rb', line 612 def comments @comments end |
#value ⇒ Object (readonly)
- nil | untyped
-
the expression being turned into a block
609 610 611 |
# File 'lib/syntax_tree/node.rb', line 609 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
620 621 622 |
# File 'lib/syntax_tree/node.rb', line 620 def accept(visitor) visitor.visit_arg_block(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
624 625 626 |
# File 'lib/syntax_tree/node.rb', line 624 def child_nodes [value] end |
#deconstruct_keys(keys) ⇒ Object
630 631 632 |
# File 'lib/syntax_tree/node.rb', line 630 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
634 635 636 637 |
# File 'lib/syntax_tree/node.rb', line 634 def format(q) q.text("&") q.format(value) if value end |