Class: SpeakyCsv::AttrImport
- Inherits:
-
Object
- Object
- SpeakyCsv::AttrImport
- Includes:
- Enumerable
- Defined in:
- lib/speaky_csv/attr_import.rb
Overview
Imports a csv file as attribute hashes.
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
-
#each ⇒ Object
Yields successive attribute hashes for rows in the csv file.
-
#initialize(config, input_io) ⇒ AttrImport
constructor
A new instance of AttrImport.
-
#log ⇒ Object
Returns a string of all the log output from the import.
Constructor Details
#initialize(config, input_io) ⇒ AttrImport
Returns a new instance of AttrImport.
11 12 13 14 15 16 |
# File 'lib/speaky_csv/attr_import.rb', line 11 def initialize(config, input_io) @config = config @input_io = input_io @log_output = StringIO.new @logger = Logger.new @log_output end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
9 10 11 |
# File 'lib/speaky_csv/attr_import.rb', line 9 def logger @logger end |
Instance Method Details
#each ⇒ Object
Yields successive attribute hashes for rows in the csv file
19 20 21 |
# File 'lib/speaky_csv/attr_import.rb', line 19 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.
25 26 27 |
# File 'lib/speaky_csv/attr_import.rb', line 25 def log @log_output.string end |