Class: MakeMenu::Text::Table
- Inherits:
-
Object
- Object
- MakeMenu::Text::Table
- Defined in:
- lib/make_menu/text/table.rb
Overview
This class displays the menu groups in columns across the screen. Each group is kept together in a column, and once a column has exceeded the calculated height, a new column is added.
Constant Summary collapse
- MAX_COLUMNS =
4
Instance Method Summary collapse
-
#initialize(groups) ⇒ Table
constructor
A new instance of Table.
-
#to_s ⇒ String
The entire table, centered on the screen.
Constructor Details
#initialize(groups) ⇒ Table
Returns a new instance of Table.
14 15 16 17 18 19 |
# File 'lib/make_menu/text/table.rb', line 14 def initialize(groups) @groups = groups @columns = [] calculate_table_dimensions build_table end |
Instance Method Details
#to_s ⇒ String
Returns The entire table, centered on the screen.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/make_menu/text/table.rb', line 22 def to_s buffer = '' max_height.times do |i| row = '' columns.each do |column| row += column.row(i) unless column.empty? end buffer += "#{row.align(:center)}\n" end buffer end |