Sha256: cbdb10380bb209d8d07f71d449b33498074991a5ed3d996f1c107731ee9f7323
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
module Clieop class File attr_accessor :batches attr_reader :file_info def initialize(file_info = {}) file_info[:date] = Date.today unless file_info[:date] file_info[:date] = file_info[:date].strftime('%d%m%y') if file_info[:date].respond_to?(:strftime) @file_info = file_info @batches = [] end # renders this file as a CLIEOP03 formatted string def to_clieop clieop_data = Clieop::Record.new(:file_header, @file_info).to_clieop @batches.each { |batch| clieop_data << batch.to_clieop } clieop_data << Clieop::Record.new(:file_footer).to_clieop end # Alias for to_clieop alias :to_s :to_clieop def payment_batch(options) @payment << Clieop::Batch.payment_batch(options, block) yield(@batches.last) if block_given? return @batches.last end def invoice_batch(options) @batches << Clieop::Batch.invoice_batch(options) yield(@batches.last) if block_given? return @batches.last end def save(filename) File.open(filename, 'w') do |f| f.write(self.to_clieop) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
clieop-0.1.3 | lib/clieop/file.rb |
clieop-0.1.1 | lib/clieop/file.rb |