class NdrImport::File::Delimited

This class is a delimited file handler that returns a single table.

Constants

DELIMITED_COL_SEP

Public Class Methods

new(filename, format, options = {}) click to toggle source
Calls superclass method NdrImport::File::Base::new
# File lib/ndr_import/file/delimited.rb, line 17
def initialize(filename, format, options = {})
  super

  @options['col_sep'] ||= DELIMITED_COL_SEP[format]
end

Private Instance Methods

determine_encodings!(*) click to toggle source

Cache working encodings, so that resetting the enumerator doesn't mean the need to recalculate this:

# File lib/ndr_import/file/delimited.rb, line 37
def determine_encodings!(*)
  @encoding ||= super
end
rows() { |row| ... } click to toggle source

Iterate through the file line by line, yielding each one in turn.

# File lib/ndr_import/file/delimited.rb, line 26
def rows
  return enum_for(:rows) unless block_given?

  col_sep = @options['col_sep']
  liberal = @options['liberal_parsing'].presence

  delimited_rows(@filename, col_sep, liberal) { |row| yield row }
end