Class: SyntaxTree::ArrayLiteral::QWordsFormatter
- Inherits:
-
Object
- Object
- SyntaxTree::ArrayLiteral::QWordsFormatter
- Defined in:
- lib/syntax_tree.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
- Args
-
the contents of the array.
Instance Method Summary collapse
- #format(q) ⇒ Object
-
#initialize(contents) ⇒ QWordsFormatter
constructor
A new instance of QWordsFormatter.
Constructor Details
#initialize(contents) ⇒ QWordsFormatter
Returns a new instance of QWordsFormatter.
1343 1344 1345 |
# File 'lib/syntax_tree.rb', line 1343 def initialize(contents) @contents = contents end |
Instance Attribute Details
#contents ⇒ Object (readonly)
- Args
-
the contents of the array
1341 1342 1343 |
# File 'lib/syntax_tree.rb', line 1341 def contents @contents end |
Instance Method Details
#format(q) ⇒ Object
1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 |
# File 'lib/syntax_tree.rb', line 1347 def format(q) q.group(0, "%w[", "]") do q.indent do q.breakable("") q.seplist(contents.parts, -> { q.breakable }) do |part| q.format(part.parts.first) end end q.breakable("") end end |