Class: Lf::Formatter::Table

Inherits:
Lf::Formatter show all
Defined in:
lib/lf/formatter/table.rb

Constant Summary

Constants inherited from Lf::Formatter

FORMATTERS

Class Method Summary collapse

Methods inherited from Lf::Formatter

[], []=

Class Method Details

.format(row) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/lf/formatter/table.rb', line 4

def self.format(row)
  field_size = row.keys.map(&:to_s).sort_by(&:length).last.to_s.size + 1

  fields = []
  row.each_pair do |label, val|
    fields << "#{green(label.to_s.ljust(field_size))}: #{cyan(val.to_s)}"
  end

  "----\n" + fields.join("\n")
end