Class: Hotfile::Record::BKS39

Inherits:
Hotfile::Record show all
Defined in:
lib/hotfile/record/BKS39.rb

Overview

Commission Record

Instance Method Summary collapse

Constructor Details

#initialize(line) ⇒ BKS39

Returns a new instance of BKS39.



7
8
9
10
11
12
13
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
41
42
# File 'lib/hotfile/record/BKS39.rb', line 7

def initialize(line)
  super

  stat_code, type, rate, amount, type2, rate2, amount2, effective_rate, effective_amount, paid, rdi_indicator,
      cca_indicator, reserved, currency =
    line.scan(/
      ([A-Z0-9 ]{3})
      ([A-Z0-9 ]{6})
      (\d{5})
      (\d{10}.)
      ([A-Z0-9 ]{6})
      ([\d ]{5})
      ([\d ]{10}.)
      (\d{5})
      (\d{10}.)
      ([\d ]{10}.)
      ([A-Z0-9 ])
      ([A-Z0-9 ])
      (.{16})
      ([A-Z0-9]{4})
    /x).flatten

  @data = {
    currency: currency.strip,
    stat_code: stat_code.strip,
    types: [type.strip, type2.strip].reject { |x| x == '' },
    rates: [Hotfile::Integer.new(rate).to_i, Hotfile::Integer.new(rate2).to_i].reject(&:zero?),
    amounts: [Hotfile::Integer.new(amount).to_i, Hotfile::Integer.new(amount2).to_i].reject(&:zero?),
    effective_rate: Hotfile::Integer.new(effective_rate).to_i,
    effective_amount: Hotfile::Integer.new(effective_amount).to_i,
    paid_amount: Hotfile::Integer.new(paid).to_i,
    rdi_indicator: rdi_indicator.strip,
    cca_indicator: cca_indicator.strip,
    reserved: reserved.strip
  }
end