class Metacrunch::File::CSVSource

Constants

DEFAULT_OPTIONS

Public Class Methods

new(csv_filename, options = {}) click to toggle source
# File lib/metacrunch/file/csv_source.rb, line 15
def initialize(csv_filename, options = {})
  @filename = csv_filename
  @options = DEFAULT_OPTIONS.merge(options)
end

Public Instance Methods

each() { |line| ... } click to toggle source
# File lib/metacrunch/file/csv_source.rb, line 20
def each(&block)
  return enum_for(__method__) unless block_given?

  SmarterCSV.process(@filename, {
    headers_in_file: @options[:headers],
    col_sep: @options[:col_sep],
    row_sep: @options[:row_sep],
    quote_char: @options[:quote_char],
    file_encoding: @options[:file_encoding]
  }) do |line|
    yield line
  end
end