Class: Csvtool::Interface::CLI::Workflows::Presenters::RowExtractionPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/csvtool/interface/cli/workflows/presenters/row_extraction_presenter.rb

Instance Method Summary collapse

Constructor Details

#initialize(stdout:, headers:, col_sep:, row_formatter: Output::Formatters::CsvRowFormatter.new) ⇒ RowExtractionPresenter

Returns a new instance of RowExtractionPresenter.



11
12
13
14
15
16
17
# File 'lib/csvtool/interface/cli/workflows/presenters/row_extraction_presenter.rb', line 11

def initialize(stdout:, headers:, col_sep:, row_formatter: Output::Formatters::CsvRowFormatter.new)
  @stdout = stdout
  @headers = headers
  @col_sep = col_sep
  @row_formatter = row_formatter
  @printed_header = false
end

Instance Method Details



27
28
29
# File 'lib/csvtool/interface/cli/workflows/presenters/row_extraction_presenter.rb', line 27

def print_file_written(path)
  @stdout.puts "Wrote output to #{path}"
end


19
20
21
22
23
24
25
# File 'lib/csvtool/interface/cli/workflows/presenters/row_extraction_presenter.rb', line 19

def print_row(fields)
  unless @printed_header
    @stdout.puts @row_formatter.call(fields: @headers, col_sep: @col_sep)
    @printed_header = true
  end
  @stdout.puts @row_formatter.call(fields: fields, col_sep: @col_sep)
end