Class: Csvtool::Infrastructure::Output::CsvFileWriter
- Inherits:
-
Object
- Object
- Csvtool::Infrastructure::Output::CsvFileWriter
- Defined in:
- lib/csvtool/infrastructure/output/csv_file_writer.rb
Instance Method Summary collapse
- #call(file_path:, column_name:, col_sep:, skip_blanks:, output_path:) ⇒ Object
-
#initialize(value_streamer:) ⇒ CsvFileWriter
constructor
A new instance of CsvFileWriter.
Constructor Details
#initialize(value_streamer:) ⇒ CsvFileWriter
Returns a new instance of CsvFileWriter.
9 10 11 |
# File 'lib/csvtool/infrastructure/output/csv_file_writer.rb', line 9 def initialize(value_streamer:) @value_streamer = value_streamer end |
Instance Method Details
#call(file_path:, column_name:, col_sep:, skip_blanks:, output_path:) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/csvtool/infrastructure/output/csv_file_writer.rb', line 13 def call(file_path:, column_name:, col_sep:, skip_blanks:, output_path:) ::CSV.open(output_path, "w") do |csv| csv << [column_name] @value_streamer.each(file_path: file_path, column_name: column_name, col_sep: col_sep, skip_blanks: skip_blanks) do |value| csv << [value] end end end |