Class: SyntaxTree::ArrayLiteral::EmptyWithCommentsFormatter
- Inherits:
-
Object
- Object
- SyntaxTree::ArrayLiteral::EmptyWithCommentsFormatter
- Defined in:
- lib/syntax_tree/node.rb
Overview
This is a special formatter used if the array 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
-
#lbracket ⇒ Object
readonly
- LBracket
-
the opening bracket.
Instance Method Summary collapse
- #format(q) ⇒ Object
-
#initialize(lbracket) ⇒ EmptyWithCommentsFormatter
constructor
A new instance of EmptyWithCommentsFormatter.
Constructor Details
#initialize(lbracket) ⇒ EmptyWithCommentsFormatter
930 931 932 |
# File 'lib/syntax_tree/node.rb', line 930 def initialize(lbracket) @lbracket = lbracket end |
Instance Attribute Details
#lbracket ⇒ Object (readonly)
- LBracket
-
the opening bracket
928 929 930 |
# File 'lib/syntax_tree/node.rb', line 928 def lbracket @lbracket end |
Instance Method Details
#format(q) ⇒ Object
934 935 936 937 938 939 940 941 942 943 944 945 946 |
# File 'lib/syntax_tree/node.rb', line 934 def format(q) q.group do q.text("[") q.indent do lbracket.comments.each do |comment| q.breakable_force comment.format(q) end end q.breakable_force q.text("]") end end |