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
Returns a new instance of EmptyWithCommentsFormatter.
4713 4714 4715 |
# File 'lib/syntax_tree/node.rb', line 4713 def initialize(lbrace) @lbrace = lbrace end |
Instance Attribute Details
#lbrace ⇒ Object (readonly)
- LBrace
-
the opening brace
4711 4712 4713 |
# File 'lib/syntax_tree/node.rb', line 4711 def lbrace @lbrace end |
Instance Method Details
#format(q) ⇒ Object
4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 |
# File 'lib/syntax_tree/node.rb', line 4717 def format(q) q.group do q.text("{") q.indent do lbrace.comments.each do |comment| q.breakable(force: true) comment.format(q) end end q.breakable(force: true) q.text("}") end end |