Class: Eco::CSV::Split
- Includes:
- Language::AuxiliarLogger
- Defined in:
- lib/eco/csv/split.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Attributes included from Language::AuxiliarLogger
Instance Method Summary collapse
-
#call {|idx, file| ... } ⇒ Array<String>
Names of the generated files.
-
#initialize(filename, max_rows:, **kargs) ⇒ Split
constructor
A new instance of Split.
Methods included from Language::AuxiliarLogger
Constructor Details
#initialize(filename, max_rows:, **kargs) ⇒ Split
Returns a new instance of Split.
8 9 10 11 12 13 14 |
# File 'lib/eco/csv/split.rb', line 8 def initialize(filename, max_rows:, **kargs) raise ArgumentError, "File '#{filename}' does not exist" unless ::File.exist?(filename) @filename = filename @max_rows = max_rows @params = kargs init end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
6 7 8 |
# File 'lib/eco/csv/split.rb', line 6 def filename @filename end |
Instance Method Details
#call {|idx, file| ... } ⇒ Array<String>
Returns names of the generated files.
22 23 24 25 26 27 28 29 30 |
# File 'lib/eco/csv/split.rb', line 22 def call(&block) stream.for_each do |row, ridx| copy_row(row, ridx, &block) end out_files ensure puts "Close at row #{row_idx}" @csv&.close end |