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.
1413 1414 1415 |
# File 'lib/syntax_tree.rb', line 1413 def initialize(contents) @contents = contents end |
Instance Attribute Details
#contents ⇒ Object (readonly)
- Args
-
the contents of the array
1411 1412 1413 |
# File 'lib/syntax_tree.rb', line 1411 def contents @contents end |
Instance Method Details
#format(q) ⇒ Object
1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 |
# File 'lib/syntax_tree.rb', line 1417 def format(q) q.group(0, "%w[", "]") do q.indent do q.breakable("") q.seplist(contents.parts, -> { q.breakable }) do |part| if part.is_a?(StringLiteral) q.format(part.parts.first) else q.text(part.value[1..-1]) end end end q.breakable("") end end |