Class: Ibanizator::BankDb

Inherits:
Object
  • Object
show all
Defined in:
lib/ibanizator/bank_db.rb

Defined Under Namespace

Classes: BankNotFoundError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBankDb

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_indexObject (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_indexObject (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_banksObject (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