Class: SyntaxTree::MLHSParen
Overview
MLHSParen represents parentheses being used to destruct values in a multiple assignment on the left hand side.
(left, right) = value
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#contents ⇒ Object
readonly
- MLHS | MLHSParen
-
the contents inside of the parentheses.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(contents:, location:, comments: []) ⇒ MLHSParen
constructor
A new instance of MLHSParen.
Methods inherited from Node
Constructor Details
#initialize(contents:, location:, comments: []) ⇒ MLHSParen
Returns a new instance of MLHSParen.
5598 5599 5600 5601 5602 |
# File 'lib/syntax_tree/node.rb', line 5598 def initialize(contents:, location:, comments: []) @contents = contents @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
5596 5597 5598 |
# File 'lib/syntax_tree/node.rb', line 5596 def comments @comments end |
#contents ⇒ Object (readonly)
- MLHS | MLHSParen
-
the contents inside of the parentheses
5593 5594 5595 |
# File 'lib/syntax_tree/node.rb', line 5593 def contents @contents end |
Instance Method Details
#accept(visitor) ⇒ Object
5604 5605 5606 |
# File 'lib/syntax_tree/node.rb', line 5604 def accept(visitor) visitor.visit_mlhs_paren(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
5608 5609 5610 |
# File 'lib/syntax_tree/node.rb', line 5608 def child_nodes [contents] end |
#deconstruct_keys(keys) ⇒ Object
5614 5615 5616 |
# File 'lib/syntax_tree/node.rb', line 5614 def deconstruct_keys(keys) { contents: contents, location: location, comments: comments } end |
#format(q) ⇒ Object
5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 |
# File 'lib/syntax_tree/node.rb', line 5618 def format(q) parent = q.parent if parent.is_a?(MAssign) || parent.is_a?(MLHSParen) q.format(contents) else q.group(0, "(", ")") do q.indent do q.breakable("") q.format(contents) end q.breakable("") end end end |