Class: Daru::IO::Importers::Base
- Defined in:
- lib/daru/io/importers/base.rb
Overview
Base Importer Class that contains generic helper methods, to be used by other Importers via inheritence
Class Method Summary collapse
-
.from(relation) ⇒ Object
Adds the
from
class method to all inheriting children Importer classes, which calls corresponding Importer'sinitialize
and instance methodfrom
. -
.guess_parse(keys, vals) ⇒ Object
Guesses the
Daru::DataFrame
from the parsed set of key-value pairs. -
.read(path) ⇒ Object
Adds the
read
class method to all inheriting children Importer classes, which calls corresponding Importer'sinitialize
and instance methodread
.
Methods inherited from Base
Class Method Details
.from(relation) ⇒ Object
Adds the from
class method to all inheriting children Importer classes, which
calls corresponding Importer's initialize
and instance method from
.
50 51 52 |
# File 'lib/daru/io/importers/base.rb', line 50 def self.from(relation) new.from(relation) end |
.guess_parse(keys, vals) ⇒ Object
Guesses the Daru::DataFrame
from the parsed set of key-value pairs.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/daru/io/importers/base.rb', line 37 def self.guess_parse(keys, vals) case vals.first when Array case vals.first.first when Hash then Daru::DataFrame.new(vals.flatten) else Daru::DataFrame.rows(vals.transpose, order: keys) end when Hash then Daru::DataFrame.new(vals.flatten, index: keys) end end |
.read(path) ⇒ Object
Adds the read
class method to all inheriting children Importer classes, which
calls corresponding Importer's initialize
and instance method read
.
56 57 58 |
# File 'lib/daru/io/importers/base.rb', line 56 def self.read(path) new.read(path) end |