Module: Ibandit::GermanDetailsConverter

Defined in:
lib/ibandit/german_details_converter.rb

Defined Under Namespace

Modules: PseudoAccountNumberBehaviour Classes: BaseRule, Rule000000, Rule000100, Rule000200, Rule000300, Rule000400, Rule000503, Rule000600, Rule000700, Rule000800, Rule000900, Rule001001, Rule001100, Rule001201, Rule001301, Rule001400, Rule001501, Rule001600, Rule001700, Rule001800, Rule001900, Rule002002, Rule002101, Rule002200, Rule002300, Rule002400, Rule002500, Rule002600, Rule002700, Rule002800, Rule002900, Rule003000, Rule003101, Rule003200, Rule003301, Rule003400, Rule003501, Rule003600, Rule003700, Rule003800, Rule003900, Rule004001, Rule004100, Rule004200, Rule004201, Rule004301, Rule004400, Rule004501, Rule004600, Rule004700, Rule004800, Rule004900, Rule004901, Rule005000, Rule005100, Rule005200, Rule005300, Rule005401, Rule005500, Rule005600, Rule005700

Class Method Summary collapse

Class Method Details

.convert(opts) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ibandit/german_details_converter.rb', line 16

def self.convert(opts)
  # Fetch the relevant rule number. Default to '000000'
  rule_num = rules.fetch(opts[:bank_code], {}).fetch(:iban_rule, "000000")

  # Convert the bank details using the relevant rule
  updated_bank_details = const_get("Rule#{rule_num}").new(
    opts[:bank_code],
    opts[:account_number],
  ).converted_details

  opts.merge(updated_bank_details)
end

.rulesObject



10
11
12
13
14
# File 'lib/ibandit/german_details_converter.rb', line 10

def self.rules
  @rules ||= YAML.load_file(
    File.expand_path("../../data/german_iban_rules.yml", __dir__),
  )
end