Class: Valiban::IBAN
- Inherits:
-
Object
- Object
- Valiban::IBAN
- Defined in:
- lib/valiban/iban.rb
Class Method Summary collapse
- .get_bank_account_number(code) ⇒ Object
- .get_bank_code_number(code) ⇒ Object
- .get_country_code(code) ⇒ Object
Instance Method Summary collapse
- #bank_account_number ⇒ Object
- #bank_account_number_start ⇒ Object
- #bank_code_number ⇒ Object
- #bank_code_number_length ⇒ Object
- #base_length ⇒ Object
- #code ⇒ Object
- #country_code ⇒ Object
-
#initialize(code) ⇒ IBAN
constructor
A new instance of IBAN.
-
#rules ⇒ Object
Load and cache the default rules from rules.yml.
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.get_bank_account_number(code) new(code).bank_account_number 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_number ⇒ Object
40 41 42 |
# File 'lib/valiban/iban.rb', line 40 def bank_account_number @code[bank_account_number_start..@code.length] end |
#bank_account_number_start ⇒ Object
53 54 55 |
# File 'lib/valiban/iban.rb', line 53 def bank_account_number_start bank_code_number_length + 1 end |
#bank_code_number ⇒ Object
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_length ⇒ Object
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_length ⇒ Object
24 25 26 |
# File 'lib/valiban/iban.rb', line 24 def base_length 4 #country_code + control_number always amount to 4 end |
#code ⇒ Object
28 29 30 |
# File 'lib/valiban/iban.rb', line 28 def code @code end |
#country_code ⇒ Object
32 33 34 |
# File 'lib/valiban/iban.rb', line 32 def country_code @code[0..1] end |