Class: Norma43::Models::Account::SpanishIban
- Inherits:
-
Object
- Object
- Norma43::Models::Account::SpanishIban
- Defined in:
- lib/norma43/models/account/spanish_iban.rb
Constant Summary collapse
- COUNTRY_CODE =
"ES"
- BANK_CODE_RANGE =
BRANCH_CODE_RANGE = 0..9999
- MAX_BANK_CODE_SIZE =
MAX_BRANCH_CODE_SIZE = 4
- ACCOUNT_NUMBER_RANGE =
0..9_999_999_999
- IBAN_MODULUS =
97
- IBAN_FORMAT_STRING =
"%{country_code}%<checksum_number>02d%{ccc}"
- CCC_MODULUS =
11
- CCC_FORMAT_STRING =
"%<bank_code>04d%<branch_code>04d%<checksum_number>02d%<account_number>010d"
- CCC_WEIGHTS =
Sorted by order of magnitude: units, tens, hundreds, etc.
[6, 3, 7, 9, 10, 5, 8, 4, 2, 1].freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(bank_code:, branch_code:, account_number:) ⇒ SpanishIban
constructor
A new instance of SpanishIban.
- #to_s ⇒ Object
Constructor Details
#initialize(bank_code:, branch_code:, account_number:) ⇒ SpanishIban
Returns a new instance of SpanishIban.
27 28 29 30 31 32 33 34 |
# File 'lib/norma43/models/account/spanish_iban.rb', line 27 def initialize(bank_code:, branch_code:, account_number:) @bank_code, @branch_code, @account_number = if self.class.valid_numbers?(bank_code, branch_code, account_number) [bank_code, branch_code, account_number] else [nil, nil, nil] end end |
Class Method Details
.from_account(account) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/norma43/models/account/spanish_iban.rb', line 17 def self.from_account(account) return nil unless valid_numbers?(account.bank_code, account.branch_code, account.account_number) new( bank_code: account.bank_code, branch_code: account.branch_code, account_number: account.account_number ).to_s end |
Instance Method Details
#to_s ⇒ Object
36 37 38 39 40 |
# File 'lib/norma43/models/account/spanish_iban.rb', line 36 def to_s return "" if [bank_code, branch_code, account_number].any?(nil) iban end |