Sha256: 24fc946bc1e7b54718d10a650a067d889b6c19823dc522b23e31bbdd36312814

Contents?: true

Size: 516 Bytes

Versions: 5

Compression:

Stored size: 516 Bytes

Contents

# frozen_string_literal: true

module Lite
  module Report
    module Helpers
      module Converters

        private

        def convert_to_array!(row)
          case row.class.name
          when 'CSV::Row' then row.fields
          else row
          end
        end

        def convert_to_hash!(row)
          case row.class.name
          when 'Array' then (0..(row.size - 1)).zip(row).to_h
          when 'CSV::Row' then row.to_hash
          else row
          end
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lite-report-1.3.2 lib/lite/report/helpers/converters.rb
lite-report-1.3.1 lib/lite/report/helpers/converters.rb
lite-report-1.3.0 lib/lite/report/helpers/converters.rb
lite-report-1.2.0 lib/lite/report/helpers/converters.rb
lite-report-1.1.1 lib/lite/report/helpers/converters.rb