Class: Nfcollector::CopyFileWriter
- Inherits:
-
Object
- Object
- Nfcollector::CopyFileWriter
- Defined in:
- lib/nfcollector/copy_file_writer.rb
Instance Attribute Summary collapse
-
#partition ⇒ Object
readonly
Returns the value of attribute partition.
Class Method Summary collapse
Instance Method Summary collapse
- #commit! ⇒ Object
-
#initialize(partition) ⇒ CopyFileWriter
constructor
A new instance of CopyFileWriter.
Constructor Details
#initialize(partition) ⇒ CopyFileWriter
Returns a new instance of CopyFileWriter.
12 13 14 15 |
# File 'lib/nfcollector/copy_file_writer.rb', line 12 def initialize(partition) @partition = partition prepare end |
Instance Attribute Details
#partition ⇒ Object (readonly)
Returns the value of attribute partition.
7 8 9 |
# File 'lib/nfcollector/copy_file_writer.rb', line 7 def partition @partition end |
Class Method Details
.open(partition) {|cfw| ... } ⇒ Object
17 18 19 20 21 |
# File 'lib/nfcollector/copy_file_writer.rb', line 17 def self.open(partition) cfw = self.new(partition) yield cfw if block_given? cfw end |
Instance Method Details
#commit! ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/nfcollector/copy_file_writer.rb', line 23 def commit! begin csv = CSV.new(@file, :force_quotes => true, :skip_blanks => true) partition.rows.each { |row| csv << row } rescue => ex @error = ex ensure @file.close end handle_error!(@error) if @error end |