Sha256: d178dc73d67cb4b4b99b3f514a193d77f128f57cf3a94225fbca9076247cf37d

Contents?: true

Size: 846 Bytes

Versions: 11

Compression:

Stored size: 846 Bytes

Contents

module CsvPiper
  class Builder
    def initialize
      @pre_processors = []
      @processors = []
    end

    def from(io_stream)
      @io = io_stream
      self
    end

    def with_pre_processors(pre_processors)
      @pre_processors += pre_processors
      self
    end

    def with_processors(processors)
      @processors += processors
      self
    end

    def with_csv_options(options)
      @csv_options = options
      self
    end

    def requires_headers(headers)
      @required_headers = headers
      self
    end

    def build
      build_options = { io_stream: @io, pre_processors: @pre_processors, processors: @processors }
      build_options[:csv_options] = @csv_options if @csv_options
      build_options[:required_headers] = @required_headers if @required_headers
      Piper.new(build_options)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
csv_piper-1.0.0 lib/csv_piper/builder.rb
csv_piper-0.1.9 lib/csv_piper/builder.rb
csv_piper-0.1.8 lib/csv_piper/builder.rb
csv_piper-0.1.7 lib/csv_piper/builder.rb
csv_piper-0.1.6 lib/csv_piper/builder.rb
csv_piper-0.1.5 lib/csv_piper/builder.rb
csv_piper-0.1.4 lib/csv_piper/builder.rb
csv_piper-0.1.3 lib/csv_piper/builder.rb
csv_piper-0.1.2 lib/csv_piper/builder.rb
csv_piper-0.1.1 lib/csv_piper/builder.rb
csv_piper-0.1.0 lib/csv_piper/builder.rb