Method: HighLine::ListRenderer#initialize

Defined in:
lib/highline/list_renderer.rb

#initialize(items, mode = :rows, option = nil, highline) ⇒ ListRenderer

The only required parameters are items and highline. Recognized modes are:

:columns_across

items will be placed in columns, flowing from left to right. If given, option is the number of columns to be used. When absent, columns will be determined based on wrap_at or a default of 80 characters.

:columns_down

Identical to :columns_across, save flow goes down.

:uneven_columns_across

Like :columns_across but each column is sized independently.

:uneven_columns_down

Like :columns_down but each column is sized independently.

:inline

All items are placed on a single line. The last two items are separated by option or a default of “ or ”. All other items are separated by “, ”.

:rows

The default mode. Each of the items is placed on its own line. The option parameter is ignored in this mode.

Each member of the items Array is passed through ERb and thus can contain their own expansions. Color escape expansions do not contribute to the final field width.

Parameters:

  • items (Array)

    the Array of items to list

  • mode (Symbol) (defaults to: :rows)

    controls how that list is formed

  • option (defaults to: nil)

    has different effects, depending on the mode.

  • highline (HighLine)

    a HighLine instance to direct the output to.



62
63
64
65
66
67
# File 'lib/highline/list_renderer.rb', line 62

def initialize(items, mode = :rows, option = nil, highline)
  @highline = highline
  @mode     = mode
  @option   = option
  @items    = render_list_items(items)
end