Module | Columnize |
In: |
lib/columnize.rb
lib/columnize/version.rb lib/columnize.rb |
Module to format an Array as an Array of String aligned in columns.
Display a list of strings as a compact set of columns.
For example, for a line width of 4 characters (arranged vertically): ['1', '2,', '3', '4'] => '1 3\n2 4\n' or arranged horizontally: ['1', '2,', '3', '4'] => '1 2\n3 4\n'
Each column is only as wide as necessary. By default, columns are separated by two spaces. Options are avalable for setting
Columnize is copyright (C) 2007, 2008, 2009, 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
All rights reserved. You can redistribute and/or modify it under the same terms as Ruby.
Adapted from the routine of the same name in Python +cmd.py+.
DEFAULT_OPTS | = | { :arrange_array => false, :arrange_vertical => true, :array_prefix => '', :array_suffix => '', :colsep => ' ', :displaywidth => 80, :lineprefix => '', :ljust => :auto, :term_adjust => false | When an option is not specified for the below keys, these are the defaults. | |
VERSION | = | '0.3.6' | The current version of this package | |
DEFAULT_OPTS | = | { :arrange_array => false, :arrange_vertical => true, :array_prefix => '', :array_suffix => '', :colsep => ' ', :displaywidth => 80, :lineprefix => '', :ljust => :auto, :term_adjust => false | When an option is not specified for the below keys, these are the defaults. |
Return the length of String cell. If Boolean term_adjust is true, ignore terminal sequences in cell.
Return the length of String cell. If Boolean term_adjust is true, ignore terminal sequences in cell.
or arranged horizontally:
['1', '2,', '3', '4'] => '1 2\n3 4\n'
Each column is only as wide possible, no larger than +displaywidth’. If list is not an array, the empty string, ’’, is returned. By default, columns are separated by two spaces - one was not legible enough. Set colsep to adjust the string separate columns. If arrange_vertical is set false, consecutive items will go across, left to right, top to bottom.
or arranged horizontally:
['1', '2,', '3', '4'] => '1 2\n3 4\n'
Each column is only as wide possible, no larger than +displaywidth’. If list is not an array, the empty string, ’’, is returned. By default, columns are separated by two spaces - one was not legible enough. Set colsep to adjust the string separate columns. If arrange_vertical is set false, consecutive items will go across, left to right, top to bottom.
Options parsing routine for Columnize::columnize. In the preferred newer style, args is either a hash where each key is one of the option names:
the :auto, then right-justify if every element of the data is a kind of Numeric.
In the older style positional arguments are used and the positions are in the order: displaywidth, colsep, arrange_vertical, ljust, and lineprefix.
Options parsing routine for Columnize::columnize. In the preferred newer style, args is either a hash where each key is one of the option names:
the :auto, then right-justify if every element of the data is a kind of Numeric.
In the older style positional arguments are used and the positions are in the order: displaywidth, colsep, arrange_vertical, ljust, and lineprefix.