Class: Indexter::Formatters::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/indexter/formatters/table.rb

Instance Method Summary collapse

Instance Method Details

#format(payload) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/indexter/formatters/table.rb', line 8

def format(payload)
  missing = payload.fetch(:missing, {})

  rows = missing.inject([]) do |acc, (db_table, columns)|
    acc << [db_table, columns.join("\n")]
    acc << :separator
    acc
  end

  headings = ['Table', 'Column'].map { |col| col.color(:blue).bright }

  Terminal::Table.new(headings: headings, rows: rows).to_s
end