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.
689 690 691 692 693 |
# File 'lib/syntax_tree/node.rb', line 689 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
687 688 689 |
# File 'lib/syntax_tree/node.rb', line 687 def comments @comments end |
#value ⇒ Object (readonly)
- nil | untyped
-
the expression being turned into a block
684 685 686 |
# File 'lib/syntax_tree/node.rb', line 684 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
695 696 697 |
# File 'lib/syntax_tree/node.rb', line 695 def accept(visitor) visitor.visit_arg_block(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
699 700 701 |
# File 'lib/syntax_tree/node.rb', line 699 def child_nodes [value] end |
#deconstruct_keys(_keys) ⇒ Object
705 706 707 |
# File 'lib/syntax_tree/node.rb', line 705 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
709 710 711 712 |
# File 'lib/syntax_tree/node.rb', line 709 def format(q) q.text("&") q.format(value) if value end |