Class: SpeakyCsv::Export
- Inherits:
-
Object
- Object
- SpeakyCsv::Export
- Includes:
- Enumerable
- Defined in:
- lib/speaky_csv/export.rb
Overview
Exports records as csv. Will write a csv to the given IO object
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
-
#each ⇒ Object
Writes csv string to io.
-
#initialize(config, records_enumerator) ⇒ Export
constructor
A new instance of Export.
-
#log ⇒ Object
Returns a string of all the log output from the import.
Constructor Details
#initialize(config, records_enumerator) ⇒ Export
Returns a new instance of Export.
13 14 15 16 17 18 |
# File 'lib/speaky_csv/export.rb', line 13 def initialize(config, records_enumerator) @config = config @records_enumerator = records_enumerator @log_output = StringIO.new @logger = Logger.new @log_output end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
11 12 13 |
# File 'lib/speaky_csv/export.rb', line 11 def logger @logger end |
Instance Method Details
#each ⇒ Object
Writes csv string to io
21 22 23 |
# File 'lib/speaky_csv/export.rb', line 21 def each block_given? ? enumerator.each { |a| yield a } : enumerator end |
#log ⇒ Object
Returns a string of all the log output from the import. Or returns nothing if a custom logger was used.
27 28 29 |
# File 'lib/speaky_csv/export.rb', line 27 def log @log_output.string end |