Class ANSI::Columns
In: lib/ansi/columns.rb
Parent: Object

Methods

align=   columns=   format=   inspect   join   list=   new   padding=   to_s  

Attributes

align  [R]  Alignment to apply to cells.
columns  [R]  Default number of columns to display. If nil then the number of coumns is estimated from the size of the terminal.
format  [R]  Formating to apply to cells.
list  [R]  List layout into columns. Each new line is taken to be a row-column cell.
padding  [R]  Padding size to apply to cells.

Public Class methods

Create a column-based layout.

@param [String,Array] list

  Multiline String or Array of strings to columnize.

@param [Hash] options

  Options to customize columnization.

@option options [Fixnum] :columns

  Number of columns.

@option options [Symbol] :align

  Column alignment, either :left, :right or :center.

@option options [String,Fixnum] :padding

  String or number or spaces to append to each column.

The format block MUST return ANSI codes.

Public Instance methods

Set alignment ensuring value is a symbol.

@param [Symbol] Either `:right`, `:left` or `:center`.

Set column count ensuring value is either an integer or nil. The the value given is zero, it will be taken to mean the same as nil, which means fit-to-screen.

Set formatting procedure. The procedure must return ANSI codes, suitable for passing to String#ansi method.

Set padding to string or number (of spaces).

Return string in column layout. The number of columns is determined by the `columns` property or overriden by cols argument.

[Validate]