Sha256: 183579df8d60e6c8121d2bc897c394ad5f3718cd00d54e07ced076efb907e1dc

Contents?: true

Size: 474 Bytes

Versions: 40

Compression:

Stored size: 474 Bytes

Contents

require 'arc-furnace/sink'

module ArcFurnace
  class CSVSink < Sink
    private_attr_reader :csv, :fields

    def initialize(filename: , fields: , encoding: 'UTF-8', force_quotes: false)
      @csv = CSV.open(filename, 'wb', encoding: encoding, headers: true, force_quotes: force_quotes)
      @fields = fields
      csv << fields
    end

    def finalize
      csv.close
    end

    def row(hash)
      csv << fields.map { |field_id| hash[field_id] }
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
arc-furnace-0.1.22 lib/arc-furnace/csv_sink.rb
arc-furnace-0.1.21 lib/arc-furnace/csv_sink.rb
arc-furnace-0.1.20 lib/arc-furnace/csv_sink.rb
arc-furnace-0.1.19 lib/arc-furnace/csv_sink.rb
arc-furnace-0.1.18 lib/arc-furnace/csv_sink.rb
arc-furnace-0.1.16 lib/arc-furnace/csv_sink.rb
arc-furnace-0.1.15 lib/arc-furnace/csv_sink.rb
arc-furnace-0.1.14 lib/arc-furnace/csv_sink.rb
arc-furnace-0.1.13 lib/arc-furnace/csv_sink.rb
arc-furnace-0.1.12 lib/arc-furnace/csv_sink.rb
arc-furnace-0.1.11 lib/arc-furnace/csv_sink.rb
arc-furnace-0.1.10 lib/arc-furnace/csv_sink.rb
arc-furnace-0.1.9 lib/arc-furnace/csv_sink.rb
arc-furnace-0.1.8 lib/arc-furnace/csv_sink.rb
arc-furnace-0.1.7 lib/arc-furnace/csv_sink.rb
arc-furnace-0.1.6 lib/arc-furnace/csv_sink.rb
arc-furnace-0.1.5 lib/arc-furnace/csv_sink.rb
arc-furnace-0.1.4 lib/arc-furnace/csv_sink.rb
arc-furnace-0.1.3 lib/arc-furnace/csv_sink.rb
arc-furnace-0.1.0 lib/arc-furnace/csv_sink.rb