Sha256: 08231b18f921c8f02454767dc5d6d9587af515628fccbf7b9f82625253e158a0

Contents?: true

Size: 547 Bytes

Versions: 3

Compression:

Stored size: 547 Bytes

Contents

# frozen_string_literal: true

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 ||= []
    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

3 entries across 3 versions & 1 rubygems

Version Path
tablesmith-0.6.2 lib/tablesmith/array_rows_source.rb
tablesmith-0.6.0 lib/tablesmith/array_rows_source.rb
tablesmith-0.5.0 lib/tablesmith/array_rows_source.rb