Sha256: 1e80ce27d6994c00ba2d57ad761ef1641cb146bac8e94c844fa09b388324c201

Contents?: true

Size: 843 Bytes

Versions: 2

Compression:

Stored size: 843 Bytes

Contents

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
table_pal-0.3.3 lib/column.rb
table_pal-0.3.2 lib/column.rb