Class: SyntaxTree::PinnedBegin
Overview
PinnedBegin represents a pinning a nested statement within pattern matching.
case value
in ^(statement)
end
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
[Array[ Comment | EmbDoc ]] the comments attached to this node.
-
#statement ⇒ Object
readonly
[untyped] the expression being pinned.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(_keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(statement:, location:, comments: []) ⇒ PinnedBegin
constructor
A new instance of PinnedBegin.
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(statement:, location:, comments: []) ⇒ PinnedBegin
Returns a new instance of PinnedBegin.
1580 1581 1582 1583 1584 |
# File 'lib/syntax_tree/node.rb', line 1580 def initialize(statement:, location:, comments: []) @statement = statement @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
[Array[ Comment | EmbDoc ]] the comments attached to this node
1578 1579 1580 |
# File 'lib/syntax_tree/node.rb', line 1578 def comments @comments end |
#statement ⇒ Object (readonly)
[untyped] the expression being pinned
1575 1576 1577 |
# File 'lib/syntax_tree/node.rb', line 1575 def statement @statement end |
Instance Method Details
#accept(visitor) ⇒ Object
1586 1587 1588 |
# File 'lib/syntax_tree/node.rb', line 1586 def accept(visitor) visitor.visit_pinned_begin(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
1590 1591 1592 |
# File 'lib/syntax_tree/node.rb', line 1590 def child_nodes [statement] end |
#deconstruct_keys(_keys) ⇒ Object
1596 1597 1598 |
# File 'lib/syntax_tree/node.rb', line 1596 def deconstruct_keys(_keys) { statement: statement, location: location, comments: comments } end |
#format(q) ⇒ Object
1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 |
# File 'lib/syntax_tree/node.rb', line 1600 def format(q) q.group do q.text("^(") q.nest(1) do q.indent do q.breakable("") q.format(statement) end q.breakable("") q.text(")") end end end |