Class: DruidClient::CLi::TableFormat

Inherits:
Object
  • Object
show all
Includes:
OutputFormat
Defined in:
lib/druid_client/cli/table_format.rb

Instance Method Summary collapse

Instance Method Details

#format(data) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/druid_client/cli/table_format.rb', line 12

def format(data)
  table = Terminal::Table.new do |t|
    headings = data.first.keys
    t.headings = headings
    data[1..-1].each do |row|
      t << headings.map { |heading| row[heading] }
    end
  end
  table.to_s
end