Class: Ibanizator::BankDb
- Inherits:
-
Object
- Object
- Ibanizator::BankDb
- Defined in:
- lib/ibanizator/bank_db.rb
Defined Under Namespace
Classes: BankNotFoundError
Instance Attribute Summary collapse
-
#bank_code_index ⇒ Object
readonly
Returns the value of attribute bank_code_index.
-
#bic_index ⇒ Object
readonly
Returns the value of attribute bic_index.
-
#known_banks ⇒ Object
readonly
Returns the value of attribute known_banks.
Instance Method Summary collapse
- #bank_by_bank_code(bank_code) ⇒ Object
- #bank_by_bic(bic) ⇒ Object
-
#initialize ⇒ BankDb
constructor
A new instance of BankDb.
Constructor Details
#initialize ⇒ BankDb
Returns a new instance of BankDb.
7 8 9 10 11 12 |
# File 'lib/ibanizator/bank_db.rb', line 7 def initialize @known_banks = [] @bic_index = {} @bank_code_index = {} populate_known_banks! end |
Instance Attribute Details
#bank_code_index ⇒ Object (readonly)
Returns the value of attribute bank_code_index.
5 6 7 |
# File 'lib/ibanizator/bank_db.rb', line 5 def bank_code_index @bank_code_index end |
#bic_index ⇒ Object (readonly)
Returns the value of attribute bic_index.
5 6 7 |
# File 'lib/ibanizator/bank_db.rb', line 5 def bic_index @bic_index end |
#known_banks ⇒ Object (readonly)
Returns the value of attribute known_banks.
5 6 7 |
# File 'lib/ibanizator/bank_db.rb', line 5 def known_banks @known_banks end |
Instance Method Details
#bank_by_bank_code(bank_code) ⇒ Object
20 21 22 23 24 |
# File 'lib/ibanizator/bank_db.rb', line 20 def bank_by_bank_code(bank_code) @bank_code_index.fetch(sanitize_bank_code(bank_code)) do error!("No bank for bank_code: #{bank_code} found") end end |
#bank_by_bic(bic) ⇒ Object
14 15 16 17 18 |
# File 'lib/ibanizator/bank_db.rb', line 14 def bank_by_bic(bic) @bic_index.fetch(bic.to_s) do error!("No bank for bic: #{bic} found") end end |