Class: Codabel::Type::AccountStructure

Inherits:
Codabel::Type show all
Defined in:
lib/codabel/type/account_structure.rb

Constant Summary collapse

CODES =
{
  Model::Account::BELGIAN_BBAN => '0',
  Model::Account::FOREIGN_BBAN => '1',
  Model::Account::BELGIAN_IBAN => '2',
  Model::Account::FOREIGN_IBAN => '3'
}.freeze

Instance Method Summary collapse

Methods inherited from Codabel::Type

#check!

Instance Method Details

#to_coda(value, length) ⇒ Object



11
12
13
14
15
16
# File 'lib/codabel/type/account_structure.rb', line 11

def to_coda(value, length)
  return value.to_s.rjust(length, '0') if %w[1 2 3 4].include?(value.to_s)

  structure = Model::Account.dress(value).structure
  CODES[structure].ljust(length, '0')
end