Class: UtilsDrawer::TableDrawer::Table
- Inherits:
-
Object
- Object
- UtilsDrawer::TableDrawer::Table
- Defined in:
- lib/utils_drawer/table_drawer/table.rb
Instance Method Summary collapse
- #add(row) ⇒ Object
-
#initialize(min_column_size) ⇒ Table
constructor
A new instance of Table.
- #to_s ⇒ Object
Constructor Details
#initialize(min_column_size) ⇒ Table
Returns a new instance of Table.
8 9 10 11 12 |
# File 'lib/utils_drawer/table_drawer/table.rb', line 8 def initialize(min_column_size) @rows = [] @header_column_sizes = [] @min_column_size = min_column_size end |
Instance Method Details
#add(row) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/utils_drawer/table_drawer/table.rb', line 14 def add(row) # Means the header if @rows.size.zero? set_header_column_size(row) else if row.columns.size != @header_column_sizes.size fail "Bud number of columns (#{row.columns.size} for #{@header_column_sizes.size})" end end @rows << row end |
#to_s ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/utils_drawer/table_drawer/table.rb', line 28 def to_s puts separate @rows.each.with_index do |row, index| puts format_line(row) puts separate if index != @rows.size - 1 end puts separate end |