Class: BankPayments::SwedbankImport::Sequence

Inherits:
Object
  • Object
show all
Defined in:
lib/bank_payments/swedbank_import/sequence.rb

Overview

Contains all records for a sequence. The sequence starts with an opening record followed by an account record, i.e. which account that was debited. It then alternates three records: Name, Address-and Money Record to describe a transaction with it’s beneficiary.

Records are expected to be a text string and passed to the sequence through the “<<”-method.

Author:

  • Michael Litton

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSequence

Returns a new instance of Sequence.



16
17
18
# File 'lib/bank_payments/swedbank_import/sequence.rb', line 16

def initialize
  @records = []
end

Instance Attribute Details

#recordsObject (readonly)

Returns the value of attribute records.



14
15
16
# File 'lib/bank_payments/swedbank_import/sequence.rb', line 14

def records
  @records
end

Instance Method Details

#<<(raw_record) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bank_payments/swedbank_import/sequence.rb', line 20

def <<(raw_record)
  new_record = case raw_record[0]
    when '0'
      OpeningRecord.new(raw_record)
    when '1'
      AccountRecord.new(raw_record)
    when '2'
      NameRecord.new(raw_record)
    when '3'
      AddressRecord.new(raw_record)
    when '5'
      MoneyRecord.new(raw_record)
    when '6'
      ReconciliationRecord.new(raw_record)
    else
      raise 'Unknown record'
  end

  @records << new_record
end