Class: Csvtool::Infrastructure::Output::CsvRandomizedRowFileWriter
- Inherits:
-
Object
- Object
- Csvtool::Infrastructure::Output::CsvRandomizedRowFileWriter
- Defined in:
- lib/csvtool/infrastructure/output/csv_randomized_row_file_writer.rb
Instance Method Summary collapse
- #call(path:, headers:, file_path:, col_sep:, headers_present:, seed:) ⇒ Object
-
#initialize(row_randomizer:) ⇒ CsvRandomizedRowFileWriter
constructor
A new instance of CsvRandomizedRowFileWriter.
Constructor Details
#initialize(row_randomizer:) ⇒ CsvRandomizedRowFileWriter
Returns a new instance of CsvRandomizedRowFileWriter.
9 10 11 |
# File 'lib/csvtool/infrastructure/output/csv_randomized_row_file_writer.rb', line 9 def initialize(row_randomizer:) @row_randomizer = row_randomizer end |
Instance Method Details
#call(path:, headers:, file_path:, col_sep:, headers_present:, seed:) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/csvtool/infrastructure/output/csv_randomized_row_file_writer.rb', line 13 def call(path:, headers:, file_path:, col_sep:, headers_present:, seed:) ::CSV.open(path, "w", write_headers: !headers.nil?, headers: headers, col_sep: col_sep) do |csv| @row_randomizer.each(file_path: file_path, col_sep: col_sep, headers: headers_present, seed: seed) do |fields| csv << fields end end end |