class BankOCR::ReportGenerator

Creates a text file with generated report

Public Class Methods

new(output_path, account_numbers) click to toggle source
# File lib/report_generator.rb, line 4
def initialize(output_path, account_numbers)
  @output_path     = output_path
  @account_numbers = account_numbers
end

Public Instance Methods

save!() click to toggle source
# File lib/report_generator.rb, line 9
def save!
  file = File.open(@output_path, 'w+')

  @account_numbers.each do |account|
    file.write "#{account}#{error(account)}\n"
  end

  file.close
end

Private Instance Methods

error(account) click to toggle source
# File lib/report_generator.rb, line 21
def error(account)
  if account.to_s.include?('?')
    ' ILL'
  elsif !account.valid?
    ' ERR'
  end
end