class TableGen::Column
Instances of this class are created automatically by {TableGen#column TableGen#column
}.
Attributes
The alignment of the row fields. Possible values:
-
:left
-
:center
-
:right
(Defaults to :left)
@return [Symbol] @see header_alignment
Whether the column can be hidden to respect the table's width constraint. (Defaults to false)
@return [Boolean]
The row formatter. The default block converts the original data to a {String}.
@example Progress Bar
# formats 0.4 to [#### ] column.format = proc {|fraction, width_hint| fill_width = width_hint - 2 # bar borders repeat = fraction * fill_width "[%-#{fill_width}s]" % ['#' * repeat] } # works best with: column.min_width = 12 column.stretch = true
@param [Object] data whatever you passed to {TableGen#row} @param [Fixnum] width_hint @return [Proc]
The alignment of the header fields. Possible values:
-
:auto (row alignment)
-
:left
-
:center
-
:right
(Defaults to :auto)
@return [Symbol]
@see alignment
The column's index.
@return [Fixnum]
The column's minimum width (in characters). (Defaults to 0)
@return [Fixnum]
The field padding character. (Defaults to a space)
@return [String]
Whether to stretch the column to fill the table's width constraint. (Defaults to false)
@return [Boolean]
Public Class Methods
@api private
# File lib/tablegen/column.rb, line 76 def initialize(index) @index = index @alignment = :left @collapse = false @format = proc {|data| data.to_s } @header_alignment = :auto @min_width = 0 @padding = "\x20" @stretch = false end