class Columnize::Columnizer
def arrange_by_column(list, nrows, ncols)
arrange_by_column((1..5).to_a, 2, 3) =>
Here is an example:
information.
access this for the list data or for the width
In either horizontal or vertical arrangement, we will need to
array into a 2-dimensional lists of lists organized by columns.
Given +list+, +ncols+, +nrows+, arrange the one-dimensional
def arrange_by_column(list, nrows, ncols) (0...ncols).map do |i| (0..nrows-1).inject([]) do |row, j| k = i + (j * ncols) k < list.length ? row << list[k] : row end end end