Sha256: c5cd65da3bad2ff747537ac4b49ac39c15804a0f23e1f4c627c8b4b01c2de7bd

Contents?: true

Size: 521 Bytes

Versions: 5

Compression:

Stored size: 521 Bytes

Contents

module Tablesmith::ArrayRowsSource
  def text_table
    build_columns if columns.nil?
    super
  end

  def convert_item_to_hash_row(item)
    item
  end

  # TODO: no support for deep
  def build_columns
    @columns ||= []
    self.map do |array_row|
      @columns << array_row.map { |item| Tablesmith::Column.new(name: item) }
    end
    @columns.flatten!
  end

  def create_headers(rows)
    column_names = rows.shift
    grouped_headers(column_names) + [apply_column_aliases(column_names), :separator]
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tablesmith-0.4.1 lib/tablesmith/array_rows_source.rb
tablesmith-0.4.0 lib/tablesmith/array_rows_source.rb
tablesmith-0.3.1 lib/tablesmith/array_rows_source.rb
tablesmith-0.3.0 lib/tablesmith/array_rows_source.rb
tablesmith-0.2.2 lib/tablesmith/array_rows_source.rb