Class: Arrow::CSVLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/arrow/csv-loader.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path_or_data, **options) ⇒ CSVLoader

Returns a new instance of CSVLoader.



30
31
32
33
34
35
36
37
# File 'lib/arrow/csv-loader.rb', line 30

def initialize(path_or_data, **options)
  @path_or_data = path_or_data
  @options = options
  if @options.key?(:delimiter)
    @options[:col_sep] = @options.delete(:delimiter)
  end
  @compression = @options.delete(:compression)
end

Class Method Details

.load(path_or_data, **options) ⇒ Object



25
26
27
# File 'lib/arrow/csv-loader.rb', line 25

def load(path_or_data, **options)
  new(path_or_data, **options).load
end

Instance Method Details

#loadObject



39
40
41
42
43
44
45
46
47
48
# File 'lib/arrow/csv-loader.rb', line 39

def load
  case @path_or_data
  when Pathname
    load_from_path(@path_or_data.to_path)
  when /\A.+\.csv\z/i
    load_from_path(@path_or_data)
  else
    load_data(@path_or_data)
  end
end