class BankAccountTools::BBAN

Public Class Methods

new(country_code, code) click to toggle source
# File lib/bank_account_tools/bban.rb, line 5
def initialize(country_code, code)
  @country_code, @code = country_code, code
end

Private Class Methods

specifications() click to toggle source
# File lib/bank_account_tools/bban.rb, line 40
def self.specifications
  @@specs ||= BankAccountTools.load_specifications(:iban)
end

Public Instance Methods

country_applies_iban?() click to toggle source
# File lib/bank_account_tools/bban.rb, line 26
def country_applies_iban?
  !!specification
end
to_s() click to toggle source
# File lib/bank_account_tools/bban.rb, line 9
def to_s
  @code
end
valid?() click to toggle source
# File lib/bank_account_tools/bban.rb, line 13
def valid?
  valid_length? && !data.nil?
end
valid_length?() click to toggle source

the bban is the iban minus the first 4 characters (country_code, check_digits)

# File lib/bank_account_tools/bban.rb, line 18
def valid_length?
  specification && specification['length'] - 4  == @code.length
end

Private Instance Methods

data() click to toggle source
# File lib/bank_account_tools/bban.rb, line 32
def data
  @code.match(/^#{specification['regexp']}$/x) if specification
end
specification() click to toggle source
# File lib/bank_account_tools/bban.rb, line 36
def specification
  @specification ||= self.class.specifications[@country_code.downcase]
end