Method: ACH::ACHFile#initialize

Defined in:
lib/ach/ach_file.rb

#initialize(data = nil) ⇒ ACHFile

Returns a new instance of ACHFile.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ach/ach_file.rb', line 11

def initialize data=nil
  @batches = []
  @header = Records::FileHeader.new
  @control = Records::FileControl.new

  if data
    if (data.encode(Encoding.find('ASCII'), **ENCODING_OPTIONS) =~ /\n|\r\n/).nil?
      parse_fixed(data)
    else
      parse(data)
    end
  end
end