Sha256: 6290525e5421d2d26e29471e512503b651233ff08022f543c8ca9829d2e2bd41

Contents?: true

Size: 525 Bytes

Versions: 2

Compression:

Stored size: 525 Bytes

Contents

if RUBY_VERSION >= '1.9'
  require 'csv'
else
  require 'fastercsv'
end

module Mysql2xxxx
  class CSV < Writer
    SLASH_N = '\N'.freeze
    def to_file(f)
      slash_n = config.slash_n

      if slash_n
        f.write keys.map { |v| v.nil? ? SLASH_N : v }.to_csv
      else
        f.write keys.to_csv
      end
      
      stream_arrays do |ary|
        if slash_n
          f.write ary.map { |v| v.nil? ? SLASH_N : v }.to_csv
        else
          f.write ary.to_csv
        end
      end
      nil
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mysql2xxxx-0.2.1 lib/mysql2xxxx/writer/csv.rb
mysql2xxxx-0.2.0 lib/mysql2xxxx/writer/csv.rb