Sha256: bd50ad09283af50f04ed58e945dcd3068be0226554f0f347a34d7dd9e0d3ac3e

Contents?: true

Size: 493 Bytes

Versions: 2

Compression:

Stored size: 493 Bytes

Contents

require 'csv'

module Chronicle
  module Etl
    class CsvLoader < Chronicle::Etl::Loader
      def initialize(options={})
        super(options)
        @rows = []
      end

      def load(result)
        if (result.is_a? Hash)
          @rows << result.values
        else
          @rows << result
        end
      end

      def finish
        z = $stdout
        CSV(z) do |csv|
          @rows.each do |row|
            csv << row
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chronicle-etl-0.1.4 lib/chronicle/etl/loaders/csv_loader.rb
chronicle-etl-0.1.3 lib/chronicle/etl/loaders/csv_loader.rb