Class: SyntaxTree::HashLiteral::EmptyWithCommentsFormatter
- Inherits:
-
Object
- Object
- SyntaxTree::HashLiteral::EmptyWithCommentsFormatter
- Defined in:
- lib/syntax_tree/node.rb
Overview
This is a special formatter used if the hash literal contains no values but does contain comments. In this case we do some special formatting to make sure the comments gets indented properly.
Instance Attribute Summary collapse
-
#lbrace ⇒ Object
readonly
- LBrace
-
the opening brace.
Instance Method Summary collapse
- #format(q) ⇒ Object
-
#initialize(lbrace) ⇒ EmptyWithCommentsFormatter
constructor
A new instance of EmptyWithCommentsFormatter.
Constructor Details
#initialize(lbrace) ⇒ EmptyWithCommentsFormatter
5546 5547 5548 |
# File 'lib/syntax_tree/node.rb', line 5546 def initialize(lbrace) @lbrace = lbrace end |
Instance Attribute Details
#lbrace ⇒ Object (readonly)
- LBrace
-
the opening brace
5544 5545 5546 |
# File 'lib/syntax_tree/node.rb', line 5544 def lbrace @lbrace end |
Instance Method Details
#format(q) ⇒ Object
5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 |
# File 'lib/syntax_tree/node.rb', line 5550 def format(q) q.group do q.text("{") q.indent do lbrace.comments.each do |comment| q.breakable_force comment.format(q) end end q.breakable_force q.text("}") end end |