Module: MysqlCasualExplain::PrettyPrinter

Defined in:
lib/mysql_casual_explain/pretty_printer.rb

Constant Summary collapse

BOLD =
ActiveSupport::LogSubscriber::BOLD
RED =
ActiveSupport::LogSubscriber::RED
CLEAR =
ActiveSupport::LogSubscriber::CLEAR

Instance Method Summary collapse

Instance Method Details

#pp(result, elapsed) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/mysql_casual_explain/pretty_printer.rb', line 9

def pp(result, elapsed)
  widths    = compute_column_widths(result)
  separator = build_separator(widths)

  pp = []

  pp << separator
  pp << build_cells(result.columns, result.columns, widths)
  pp << separator

  result.rows.each do |row|
    pp << build_cells(result.columns, row, widths)
  end

  pp << separator
  pp << build_footer(result.rows.length, elapsed)

  "#{pp.join("\n")}\n"
end