Class: Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/csv2qif/processor.rb

Class Method Summary collapse

Class Method Details

.initObject



6
7
8
# File 'lib/csv2qif/processor.rb', line 6

def init
  @qif = QIF.new
end

.process(stdin, stdout, arguments, options) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/csv2qif/processor.rb', line 10

def process stdin, stdout, arguments, options
  if arguments.empty?
    process_file stdin, stdout, options
  else
    arguments.each do |file|
      mode = ['r', options[:encoding]].compact.join(':')
      stream_in = File.open(file, mode)
      stream_out = File.new esub(file, :csv, :qif), "w"
      begin
        process_file stream_in, stream_out, options
      ensure
        stream_in.close
        stream_out.close
      end
    end
  end
end