Class: Ach::FileControlRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/ach/parser.rb,
lib/ach/creator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ FileControlRecord

Returns a new instance of FileControlRecord.



436
437
438
439
440
441
442
443
444
445
446
# File 'lib/ach/creator.rb', line 436

def initialize(options={})
  @record_type = '9'
  @batch_count = options[:batch_count]
  @block_count = options[:block_count]
  @entry_addenda = options[:entry_addenda]
  @entry_hash_total = options[:entry_hash_total]
  @total_debits = options[:total_debits]
  @total_credits = options[:total_credits]
  @write_to_file = options[:write_to_file]
  encode
end

Instance Attribute Details

#batch_countObject

Returns the value of attribute batch_count.



434
435
436
# File 'lib/ach/creator.rb', line 434

def batch_count
  @batch_count
end

#block_countObject

Returns the value of attribute block_count.



434
435
436
# File 'lib/ach/creator.rb', line 434

def block_count
  @block_count
end

#entry_addendaObject

Returns the value of attribute entry_addenda.



434
435
436
# File 'lib/ach/creator.rb', line 434

def entry_addenda
  @entry_addenda
end

#entry_hash_totalObject

Returns the value of attribute entry_hash_total.



435
436
437
# File 'lib/ach/creator.rb', line 435

def entry_hash_total
  @entry_hash_total
end

#record_typeObject

Returns the value of attribute record_type.



434
435
436
# File 'lib/ach/creator.rb', line 434

def record_type
  @record_type
end

#total_creditsObject

Returns the value of attribute total_credits.



435
436
437
# File 'lib/ach/creator.rb', line 435

def total_credits
  @total_credits
end

#total_debitsObject

Returns the value of attribute total_debits.



435
436
437
# File 'lib/ach/creator.rb', line 435

def total_debits
  @total_debits
end

Class Method Details

.decode(record, processor) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/ach/parser.rb', line 106

def self.decode(record)
  fcr = {}
  msg_codes = []
  msg_codes << record[56,2] unless record[56,2].match(/\s/)
  msg_codes << record [58,2] unless record[58,2].match(/\s/)
  msg_codes << record[60,2] unless record[60,2].match(/\s/)
  fcr[:record_type] = record[0].chr
  fcr[:batch_count] = record[1,6]
  fcr[:block_count] = record[7,6]
  fcr[:entry_addenda_record_count] = record[13,8]
  fcr[:entry_hash_total] = record[21,10]
  fcr[:total_file_debit_entry_amount] = record[31,12]
  fcr[:total_file_credit_entry_amount] = record[43,12]
  fcr[:message_codes] = msg_codes unless msg_codes.empty?
  return fcr
end