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.
1427 1428 1429 |
# File 'lib/syntax_tree.rb', line 1427 def initialize(contents) @contents = contents end |
Instance Attribute Details
#contents ⇒ Object (readonly)
- Args
-
the contents of the array
1425 1426 1427 |
# File 'lib/syntax_tree.rb', line 1425 def contents @contents end |
Instance Method Details
#format(q) ⇒ Object
1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 |
# File 'lib/syntax_tree.rb', line 1431 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 |