Sha256: 59362b170bd5599beed338452a7eb70bd8816c7a2787cd21ab80fc004a2b3a4b

Contents?: true

Size: 535 Bytes

Versions: 11

Compression:

Stored size: 535 Bytes

Contents

module Csv2hash
  class TypeCoercer < Struct.new(:data)

    def deserialize!
      data.each do |line|
        line.each do |key, value|
          _value = value.to_s.strip.downcase
          change.each do |keys, v|
            line[key] = v if keys.include?(_value)
          end
        end
      end
    end

    private

    def change
      {
        Csv2hash.configuration.true_values  => true,
        Csv2hash.configuration.false_values => false,
        Csv2hash.configuration.nil_values   => nil,
      }
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
csv2hash-0.7.7 lib/csv2hash/coercers/type_coercer.rb
csv2hash-0.7.6 lib/csv2hash/coercers/type_coercer.rb
csv2hash-0.7.5 lib/csv2hash/coercers/type_coercer.rb
csv2hash-0.7.3 lib/csv2hash/coercers/type_coercer.rb
csv2hash-0.7.2 lib/csv2hash/coercers/type_coercer.rb
csv2hash-0.7.1 lib/csv2hash/coercers/type_coercer.rb
csv2hash-0.7.0 lib/csv2hash/coercers/type_coercer.rb
csv2hash-0.6.8 lib/csv2hash/coercers/type_coercer.rb
csv2hash-0.6.7 lib/csv2hash/coercers/type_coercer.rb
csv2hash-0.6.6 lib/csv2hash/coercers/type_coercer.rb
csv2hash-0.6.5 lib/csv2hash/coercers/type_coercer.rb