module Ibandit::IBANSplitter
Public Class Methods
Source
# File lib/ibandit/iban_splitter.rb, line 50 def self.account_number_from(iban) return unless decomposable?(iban) iban.slice( structure(iban)[:account_number_position] - 1, structure(iban)[:account_number_length], ) end
Source
# File lib/ibandit/iban_splitter.rb, line 31 def self.bank_code_from(iban) return unless decomposable?(iban) iban.slice( structure(iban)[:bank_code_position] - 1, structure(iban)[:bank_code_length], ) end
Source
# File lib/ibandit/iban_splitter.rb, line 40 def self.branch_code_from(iban) return unless decomposable?(iban) && structure(iban)[:branch_code_length]&.positive? iban.slice( structure(iban)[:branch_code_position] - 1, structure(iban)[:branch_code_length], ) end
Source
# File lib/ibandit/iban_splitter.rb, line 25 def self.check_digits_from(iban) return unless decomposable?(iban) iban.slice(2, 2) end
Source
# File lib/ibandit/iban_splitter.rb, line 19 def self.country_code_from(iban) return if iban.nil? || iban.empty? iban.slice(0, 2) end
Component parts #
Source
# File lib/ibandit/iban_splitter.rb, line 59 def self.decomposable?(iban) structure(iban) && iban.length == structure(iban)[:total_length] end
Source
# File lib/ibandit/iban_splitter.rb, line 5 def self.split(iban) { country_code: country_code_from(iban), check_digits: check_digits_from(iban), bank_code: bank_code_from(iban), branch_code: branch_code_from(iban), account_number: account_number_from(iban), } end
Source
# File lib/ibandit/iban_splitter.rb, line 63 def self.structure(iban) Ibandit.structures[country_code_from(iban)] end