Class: Valiban::IBAN

Inherits:
Object
  • Object
show all
Defined in:
lib/valiban/iban.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code) ⇒ IBAN

Returns a new instance of IBAN.



20
21
22
# File 'lib/valiban/iban.rb', line 20

def initialize( code )
  @code = code
end

Class Method Details

.get_bank_account_number(code) ⇒ Object



12
13
14
# File 'lib/valiban/iban.rb', line 12

def self.(code)
  new(code).
end

.get_bank_code_number(code) ⇒ Object



8
9
10
# File 'lib/valiban/iban.rb', line 8

def self.get_bank_code_number(code)
  new(code).bank_code_number
end

.get_country_code(code) ⇒ Object



16
17
18
# File 'lib/valiban/iban.rb', line 16

def self.get_country_code(code)
  new(code).country_code
end

Instance Method Details

#bank_account_numberObject



40
41
42
# File 'lib/valiban/iban.rb', line 40

def 
  @code[..@code.length]
end

#bank_account_number_startObject



53
54
55
# File 'lib/valiban/iban.rb', line 53

def 
  bank_code_number_length + 1
end

#bank_code_numberObject



36
37
38
# File 'lib/valiban/iban.rb', line 36

def bank_code_number
  @code[base_length..bank_code_number_length]
end

#bank_code_number_lengthObject



49
50
51
# File 'lib/valiban/iban.rb', line 49

def bank_code_number_length
  rules['bank_code_number_length'] + (base_length - 1)
end

#base_lengthObject



24
25
26
# File 'lib/valiban/iban.rb', line 24

def base_length
  4 #country_code + control_number always amount to 4
end

#codeObject



28
29
30
# File 'lib/valiban/iban.rb', line 28

def code
  @code
end

#country_codeObject



32
33
34
# File 'lib/valiban/iban.rb', line 32

def country_code
  @code[0..1]
end

#rulesObject

Load and cache the default rules from rules.yml



45
46
47
# File 'lib/valiban/iban.rb', line 45

def rules
  @rules ||= Rules.load(self.country_code)
end