Sha256: 4e77890c3a7c3ba4d80be26f9d29a17eb3b4804bb74ec48048be87305ea960d5

Contents?: true

Size: 530 Bytes

Versions: 8

Compression:

Stored size: 530 Bytes

Contents

# frozen_string_literal: true

class Lite::Report::Hash < Lite::Report::Base

  def export
    assign_headers_to_csv_options!
    generate_or_stream_export!
  end

  def import
    CSV.foreach(@data, **@csv_options)
       .with_object([]) do |row, array|
         next if header_row?(row)

         row = convert_to_hash!(row)
         array << process_import_row!(row)
       end
  end

  private

  def assign_headers_to_csv_options!
    return unless write_headers?

    @csv_options[:headers] ||= @data.first.keys
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
lite-report-1.3.2 lib/lite/report/hash.rb
lite-report-1.3.1 lib/lite/report/hash.rb
lite-report-1.3.0 lib/lite/report/hash.rb
lite-report-1.2.0 lib/lite/report/hash.rb
lite-report-1.1.1 lib/lite/report/hash.rb
lite-report-1.1.0 lib/lite/report/hash.rb
lite-report-1.0.6 lib/lite/report/hash.rb
lite-report-1.0.5 lib/lite/report/hash.rb