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.
674 675 676 677 678 |
# File 'lib/syntax_tree/node.rb', line 674 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
672 673 674 |
# File 'lib/syntax_tree/node.rb', line 672 def comments @comments end |
#value ⇒ Object (readonly)
- nil | untyped
-
the expression being turned into a block
669 670 671 |
# File 'lib/syntax_tree/node.rb', line 669 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
680 681 682 |
# File 'lib/syntax_tree/node.rb', line 680 def accept(visitor) visitor.visit_arg_block(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
684 685 686 |
# File 'lib/syntax_tree/node.rb', line 684 def child_nodes [value] end |
#deconstruct_keys(_keys) ⇒ Object
690 691 692 |
# File 'lib/syntax_tree/node.rb', line 690 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
694 695 696 697 |
# File 'lib/syntax_tree/node.rb', line 694 def format(q) q.text("&") q.format(value) if value end |