Module: Tablesmith::ArrayRowsSource
- Defined in:
- lib/tablesmith/array_rows_source.rb
Instance Method Summary collapse
-
#build_columns ⇒ Object
TODO: no support for deep.
- #convert_item_to_hash_row(item) ⇒ Object
- #create_headers(rows) ⇒ Object
- #text_table ⇒ Object
Instance Method Details
#build_columns ⇒ Object
TODO: no support for deep
14 15 16 17 18 19 20 |
# File 'lib/tablesmith/array_rows_source.rb', line 14 def build_columns @columns ||= [] map do |array_row| @columns << array_row.map { |item| Tablesmith::Column.new(name: item) } end @columns.flatten! end |
#convert_item_to_hash_row(item) ⇒ Object
9 10 11 |
# File 'lib/tablesmith/array_rows_source.rb', line 9 def convert_item_to_hash_row(item) item end |
#create_headers(rows) ⇒ Object
22 23 24 25 |
# File 'lib/tablesmith/array_rows_source.rb', line 22 def create_headers(rows) column_names = rows.shift grouped_headers(column_names) + [apply_column_aliases(column_names), :separator] end |
#text_table ⇒ Object
4 5 6 7 |
# File 'lib/tablesmith/array_rows_source.rb', line 4 def text_table build_columns if columns.nil? super end |