Class: Arrow::TableLoader

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, options = {}) ⇒ TableLoader

Returns a new instance of TableLoader.



26
27
28
29
30
31
# File 'lib/arrow/table-loader.rb', line 26

def initialize(input, options={})
  input = input.to_path if input.respond_to?(:to_path)
  @input = input
  @options = options
  fill_options
end

Class Method Details

.load(input, options = {}) ⇒ Object



21
22
23
# File 'lib/arrow/table-loader.rb', line 21

def load(input, options={})
  new(input, options).load
end

Instance Method Details

#loadObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/arrow/table-loader.rb', line 33

def load
  format = @options[:format]
  custom_load_method = "load_as_#{format}"
  unless respond_to?(custom_load_method, true)
    available_formats = []
    (methods(true) | private_methods(true)).each do |name|
      match_data = /\Aload_as_/.match(name.to_s)
      if match_data
        available_formats << match_data.post_match
      end
    end
    deprecated_formats = ["batch", "stream"]
    available_formats -= deprecated_formats
    message = "Arrow::Table load format must be one of ["
    message << available_formats.join(", ")
    message << "]: #{format.inspect}"
    raise ArgumentError, message
  end
  if method(custom_load_method).arity.zero?
    __send__(custom_load_method)
  else
    # For backward compatibility.
    __send__(custom_load_method, @input)
  end
end