Class: CsvFormatGuesser

Inherits:
Object
  • Object
show all
Defined in:
lib/csv_format_guesser.rb

Constant Summary collapse

VERSION =
'0.0.1'
PREVIEW_LINES =
100
PREVIEW_BYTES =
10 * 1024
DEFAULT_ENCODING =
'UTF-8'.freeze
DEFAULT_QUOTE_CHAR =
"\x00".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ CsvFormatGuesser

Returns a new instance of CsvFormatGuesser.



11
12
13
14
15
16
# File 'lib/csv_format_guesser.rb', line 11

def initialize(path)
  @path = path
  guess_encoding()
  guess_col_sep()
  guess_quote_char()
end

Instance Attribute Details

#col_sepObject (readonly)

Returns the value of attribute col_sep.



3
4
5
# File 'lib/csv_format_guesser.rb', line 3

def col_sep
  @col_sep
end

#encodingObject (readonly)

Returns the value of attribute encoding.



3
4
5
# File 'lib/csv_format_guesser.rb', line 3

def encoding
  @encoding
end

#quote_charObject (readonly)

Returns the value of attribute quote_char.



3
4
5
# File 'lib/csv_format_guesser.rb', line 3

def quote_char
  @quote_char
end

Instance Method Details

#csv_optsObject



18
19
20
21
22
23
24
# File 'lib/csv_format_guesser.rb', line 18

def csv_opts
  {
    encoding: @encoding,
    col_sep: @col_sep,
    quote_char: @quote_char,
  }
end