Class: SyntaxTree::ArrayLiteral::VarRefsFormatter
- Inherits:
-
Object
- Object
- SyntaxTree::ArrayLiteral::VarRefsFormatter
- 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) ⇒ VarRefsFormatter
constructor
A new instance of VarRefsFormatter.
Constructor Details
#initialize(contents) ⇒ VarRefsFormatter
Returns a new instance of VarRefsFormatter.
1459 1460 1461 |
# File 'lib/syntax_tree.rb', line 1459 def initialize(contents) @contents = contents end |
Instance Attribute Details
#contents ⇒ Object (readonly)
- Args
-
the contents of the array
1457 1458 1459 |
# File 'lib/syntax_tree.rb', line 1457 def contents @contents end |
Instance Method Details
#format(q) ⇒ Object
1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 |
# File 'lib/syntax_tree.rb', line 1463 def format(q) q.group(0, "[", "]") do q.indent do q.breakable("") separator = -> do q.text(",") q.fill_breakable end q.seplist(contents.parts, separator) { |part| q.format(part) } end q.breakable("") end end |