Class: PProf::OutputFormatter::ASCIITable
- Inherits:
-
Object
- Object
- PProf::OutputFormatter::ASCIITable
- Defined in:
- lib/pprof/output_formatter.rb
Overview
A small helper to print ASCII tables
Instance Method Summary collapse
-
#initialize(*widths) ⇒ ASCIITable
constructor
Create a new ASCII table.
-
#row(*cols) ⇒ Object
Add a new row to the ASCII table.
-
#separator ⇒ Object
Add a separator line to the ASCII table.
Constructor Details
#initialize(*widths) ⇒ ASCIITable
Create a new ASCII table
21 22 23 |
# File 'lib/pprof/output_formatter.rb', line 21 def initialize(*widths) @widths = widths end |
Instance Method Details
#row(*cols) ⇒ Object
Add a new row to the ASCII table
29 30 31 32 33 |
# 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 ⇒ Object
Add a separator line to the ASCII table
36 37 38 |
# File 'lib/pprof/output_formatter.rb', line 36 def separator '+' + @widths.map { |w| '-' * (w+2) }.join('+') + '+' end |