Class: SyntaxTree::ArrayLiteral::VarRefsFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents) ⇒ VarRefsFormatter

Returns a new instance of VarRefsFormatter.



1440
1441
1442
# File 'lib/syntax_tree.rb', line 1440

def initialize(contents)
  @contents = contents
end

Instance Attribute Details

#contentsObject (readonly)

Args

the contents of the array



1438
1439
1440
# File 'lib/syntax_tree.rb', line 1438

def contents
  @contents
end

Instance Method Details

#format(q) ⇒ Object



1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
# File 'lib/syntax_tree.rb', line 1444

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