module TablePal class PlainTextColoured attr_reader :table def initialize(table:) @table = table table.rows.each do |row| print_row(row) end end private def print_row(row) row.cells_including_empty.each do |cell| print_cell(cell) end puts if row.heading underline empty elsif row.subheading empty end end def print_cell(cell) print cell.column.left_border print cell.column.left_padding print cell.formatted(justified: true, coloured: true) print cell.column.right_padding print cell.column.right_border end def underline table.columns.map do |column| char = '-' print column.left_border print column.left_padding_char(char) print char * column.width print column.right_padding_char(char) print column.right_border end puts end def empty table.create_row.empty_cells.each do |cell| print_cell(cell) end puts end end end