class TTY::Table::Operation::Alignment

A class which responsiblity is to align table rows and header.

def align_field(field, col)

Other tags:
    Api: - private

Returns:
  • (TTY::Table::Field) -

Parameters:
  • col (Integer) --
  • field (TTY::Table::Field) --
def align_field(field, col)
  column_width = widths[col]
  direction    = field.alignment || alignments[col] || DEFAULT
  Strings.align(field.content, column_width, direction: direction)
end

def call(field, row, col)

Other tags:
    Api: - public

Returns:
  • (TTY::Table::Field) -

Parameters:
  • col (Integer) --
  • row (Array) --
  • field (TTY::Table::Field) --
def call(field, row, col)
  align_field(field, col)
end

def initialize(alignments, widths = nil)

Other tags:
    Api: - private
def initialize(alignments, widths = nil)
  @alignments = alignments
  @widths     = widths
end