Class: Sqldump::CsvFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/sqldump/csv_formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(sth, io, options) ⇒ CsvFormatter

Returns a new instance of CsvFormatter.



5
6
7
8
9
# File 'lib/sqldump/csv_formatter.rb', line 5

def initialize(sth, io, options)
  @sth = sth
  @io = io
  @options = options
end

Instance Method Details

#outputObject



11
12
13
14
15
16
17
18
# File 'lib/sqldump/csv_formatter.rb', line 11

def output
  if @options.csv_header
    @io.puts @sth.column_names.join(",")
  end
  @sth.fetch do |row|
    @io.puts row.join(",")
  end
end