Class: ACH::File::Reader
- Inherits:
-
Object
- Object
- ACH::File::Reader
- Includes:
- Constants
- Defined in:
- lib/ach/file/reader.rb
Overview
The ACH::File::Reader
class builds a corresponding ACH::File
object from a given set of data. The constructor takes an enum
object representing a sequence of ACH lines (strings). This enum
object may be a file handler, an array, or any other object that responds to the #each
method.
Constant Summary
Constants included from Constants
Constants::BATCH_ADDENDA_RECORD_TYPE, Constants::BATCH_CONTROL_RECORD_TYPE, Constants::BATCH_ENTRY_RECORD_TYPE, Constants::BATCH_HEADER_RECORD_TYPE, Constants::BLOCKING_FACTOR, Constants::FILE_CONTROL_RECORD_TYPE, Constants::FILE_HEADER_RECORD_TYPE, Constants::FORMAT_CODE, Constants::RECORD_SIZE, Constants::ROWS_DELIMITER
Instance Method Summary collapse
-
#initialize(enum) ⇒ Reader
constructor
A new instance of Reader.
- #to_ach ⇒ Object
Constructor Details
#initialize(enum) ⇒ Reader
Returns a new instance of Reader.
10 11 12 |
# File 'lib/ach/file/reader.rb', line 10 def initialize(enum) @enum = enum end |
Instance Method Details
#to_ach ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ach/file/reader.rb', line 14 def to_ach header_line, batch_lines, control_line = ach_data File.new do build_header header_line batch_lines.each do |batch_data| batch do build_header batch_data[:header] batch_data[:entries].each do |entry_line| build_entry entry_line if batch_data[:addendas].key?(entry_line) batch_data[:addendas][entry_line].each do |addenda_line| build_addenda addenda_line end end end build_control batch_data[:control] end end build_control control_line end end |