Class: SyntaxTree::ArrayLiteral::VarRefsFormatter
- Inherits:
-
Object
- Object
- SyntaxTree::ArrayLiteral::VarRefsFormatter
- Defined in:
- lib/syntax_tree/node.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.
783 784 785 |
# File 'lib/syntax_tree/node.rb', line 783 def initialize(contents) @contents = contents end |
Instance Attribute Details
#contents ⇒ Object (readonly)
- Args
-
the contents of the array
781 782 783 |
# File 'lib/syntax_tree/node.rb', line 781 def contents @contents end |
Instance Method Details
#format(q) ⇒ Object
787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 |
# File 'lib/syntax_tree/node.rb', line 787 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 |