Class: BankAccountTools::BBAN

Inherits:
Object
  • Object
show all
Defined in:
lib/bank_account_tools/bban.rb

Overview

Basic Bank Account Number

Instance Method Summary collapse

Constructor Details

#initialize(country_code, code) ⇒ BBAN

Returns a new instance of BBAN.



5
6
7
# File 'lib/bank_account_tools/bban.rb', line 5

def initialize(country_code, code)
  @country_code, @code = country_code, code
end

Instance Method Details

#country_applies_iban?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/bank_account_tools/bban.rb', line 26

def country_applies_iban?
  !!specification
end

#to_sObject



9
10
11
# File 'lib/bank_account_tools/bban.rb', line 9

def to_s
  @code
end

#valid?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/bank_account_tools/bban.rb', line 13

def valid?
  valid_length? && !data.nil?
end

#valid_length?Boolean

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

Returns:

  • (Boolean)


18
19
20
# File 'lib/bank_account_tools/bban.rb', line 18

def valid_length?
  specification && specification['length'] - 4  == @code.length
end