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
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:, comments: []) ⇒ ArgBlock
Returns a new instance of ArgBlock.
654 655 656 657 658 |
# File 'lib/syntax_tree/node.rb', line 654 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
652 653 654 |
# File 'lib/syntax_tree/node.rb', line 652 def comments @comments end |
#value ⇒ Object (readonly)
- nil | untyped
-
the expression being turned into a block
649 650 651 |
# File 'lib/syntax_tree/node.rb', line 649 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
660 661 662 |
# File 'lib/syntax_tree/node.rb', line 660 def accept(visitor) visitor.visit_arg_block(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
664 665 666 |
# File 'lib/syntax_tree/node.rb', line 664 def child_nodes [value] end |
#deconstruct_keys(_keys) ⇒ Object
670 671 672 |
# File 'lib/syntax_tree/node.rb', line 670 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
674 675 676 677 |
# File 'lib/syntax_tree/node.rb', line 674 def format(q) q.text("&") q.format(value) if value end |