Class: Daru::IO::Exporters::Base
- Defined in:
- lib/daru/io/exporters/base.rb
Overview
Base Exporter Class that contains generic helper methods, to be used by other Exporters via inheritence
Instance Method Summary collapse
-
#initialize(dataframe) ⇒ Base
constructor
Checks whether the first argument given to any
Daru::IO::<Exporter>
module is aDaru::DataFrame
. -
#to_s ⇒ Object
Exports an Exporter instance to a file-writable String.
Methods inherited from Base
Constructor Details
#initialize(dataframe) ⇒ Base
Checks whether the first argument given to any Daru::IO::<Exporter>
module
is a Daru::DataFrame
. Raises an error when it's not a Daru::DataFrame
.
27 28 29 30 31 32 33 34 |
# File 'lib/daru/io/exporters/base.rb', line 27 def initialize(dataframe) unless dataframe.is_a?(Daru::DataFrame) raise ArgumentError, 'Expected first argument to be a Daru::DataFrame, '\ "received #{dataframe.class} instead." end @dataframe = dataframe end |
Instance Method Details
#to_s ⇒ Object
Exports an Exporter instance to a file-writable String.
44 45 46 47 48 49 50 |
# File 'lib/daru/io/exporters/base.rb', line 44 def to_s tempfile = Tempfile.new('tempfile') path = tempfile.path write(path) File.read(path) end |