module TablePal class Column attr_reader :table, :left_padding, :right_padding, :left_border, :right_border, :justification, :colour, :formatter def initialize(table:, formatter: nil, left_padding: ' ', right_padding: ' ', left_border: '', right_border: '|', justification: :left, colour: nil) @table = table @formatter = formatter @left_padding = left_padding @right_padding = right_padding @left_border = left_border @right_border = right_border @justification = justification @colour = colour end def width @width ||= table.select_cells(column: self).max_by(&:width).width end def left_padding_char(char) char * left_padding.length end def right_padding_char(char) char * right_padding.length end end end