Class: BankAccountStatement::App
- Inherits:
-
Object
- Object
- BankAccountStatement::App
- Defined in:
- lib/bank-account-statement/app.rb
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ App
constructor
A new instance of App.
- #run ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ App
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/bank-account-statement/app.rb', line 8 def initialize(opts = {}) @in = opts[:in].to_s @in_format = BankAccountStatement::Inputs::Base.formats[opts[:in_format]] raise "IN_FORMAT unknown" unless @in_format @out = opts[:out].to_s raise "OUT not directory" unless Dir.exist?(@out) @out_format = BankAccountStatement::Outputs::Base.formats[opts[:out_format]] raise "OUT_FORMAT unknown" unless @out_format @logger = opts[:logger] || Logger.new(nil) end |
Instance Method Details
#run ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bank-account-statement/app.rb', line 23 def run Dir.glob(@in) do |f_in| f_o_n = File.basename(f_in, @in_format::FILE_EXT) + @out_format::FILE_EXT f_out = File.join(@out, f_o_n) if File.exist?(f_out) @logger.warn { "SKIPPED\t#{f_in}" } else begin _convert(f_in, f_out) @logger.info { "CONVERTED\t#{f_in}\t#{f_out}" } rescue @logger.error { "ERRORED\t#{f_in}" } raise end end end end |