<commit_before>module Primer
  class TablePrinter
    attr_reader :rows, :primes, :cell_width
    private :rows, :primes, :cell_width

    def initialize(primes:, rows:)
      @primes = primes
      @rows = rows
      @cell_width = rows.last.last.to_s.size
    end

    def print_multiplication_table
      $stdout.puts(headers)
      $stdout.puts('-' * headers.size)
      print_table
    end

    private

    def headers
      cell('N') + '| ' + primes.map(&method(:cell)).join(' ')
    end

    def print_table
      rows.zip(primes).each do |row, prime|
        $stdout.puts(cell(prime) + '| ' + row.map(&method(:cell)).join(' '))
      end
    end

    def cell(string)
      pad_right(string.to_s, cell_width)
    end

    def pad_right(string, length)
      spacing = ' '<commit_msg>Make table printer take the table object<commit_after>module Primer
  class TablePrinter
    attr_reader :table, :cell_width
    private :table, :cell_width

    def initialize(table)
      @table = table
      @cell_width = table.largest_prime.to_s.size
    end

    def print_table
      $stdout.puts(headers)
      $stdout.puts('-' * headers.size)
      print_rows
    end

    private

    def headers
      cell('N') + '| ' + table.primes.map(&method(:cell)).join(' ')
    end

    def print_rows
      table.rows.zip(table.primes).each do |row, prime|
        $stdout.puts(cell(prime) + '| ' + row.map(&method(:cell)).join(' '))
      end
    end

    def cell(string)
      pad_right(string.to_s, cell_width)
    end

    def pad_right(string, length)
      spacing = ' '
{'fraction_non_alphanumeric': 0.12810707456978968, 'fraction_numerical': 0.0, 'mean_word_length': 2.5123042505592843, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4596846', 'n_tokens_mistral': 543, 'n_tokens_neox': 518, 'n_words': 109}