class PProf::OutputFormatter::ASCIITable
A small helper to print ASCII tables
Public Class Methods
new(*widths)
click to toggle source
Create a new ASCII table
@param [Int…] widths
The list of width for each colum of the table
# File lib/pprof/output_formatter.rb, line 21 def initialize(*widths) @widths = widths end
Public Instance Methods
row(*cols)
click to toggle source
Add a new row to the ASCII table
@param [String…] cols
The content of each column of the row to add
# File lib/pprof/output_formatter.rb, line 29 def row(*cols) '| ' + cols.zip(@widths).map do |c,w| (c || '<nil>').to_s.ljust(w)[0...w] end.join(' | ') + ' |' end
separator()
click to toggle source
Add a separator line to the ASCII table
# File lib/pprof/output_formatter.rb, line 36 def separator '+' + @widths.map { |w| '-' * (w+2) }.join('+') + '+' end