class Steep::Drivers::Stats::TablePrinter

def initialize(io:)

def initialize(io:)
  @io = io
end

def print(stats_result)

def print(stats_result)
  rows = []
  stats_result.sort_by {|row| row[:path] }.each do |row|
    if row[:type] == "success"
      rows << [
        row[:target],
        row[:path] + "  ",
        row[:type],
        row[:typed_calls],
        row[:untyped_calls],
        row[:total_calls],
        if row[:total_calls].nonzero?
          "#{(row[:typed_calls].to_f / row[:total_calls] * 100).to_i}%"
        else
          "100%"
        end
      ]
    else
      rows << [
        row[:target],
        row[:path],
        row[:type],
        0,
        0,
        0,
        "N/A"
      ]
    end
  end
  table = Terminal::Table.new(
    headings: ["Target", "File", "Status", "Typed calls", "Untyped calls", "All calls", "Typed %"],
    rows: rows
  )
  table.align_column(3, :right)
  table.align_column(4, :right)
  table.align_column(5, :right)
  table.align_column(6, :right)
  table.style = { border_top: false, border_bottom: false, border_y: "", border_i: "" }
  io.puts(table)
end