class Ibanizator::Iban
Constants
- COUNTRY_CODES
according to wikipedia (en.wikipedia.org/wiki/IBAN)
Attributes
iban_string[R]
to_s[R]
Public Class Methods
from_string(a_string)
click to toggle source
# File lib/ibanizator/iban.rb, line 20 def self.from_string(a_string) new(a_string) end
new(an_iban)
click to toggle source
# File lib/ibanizator/iban.rb, line 16 def initialize(an_iban) @iban_string = sanitize(an_iban) end
Public Instance Methods
country_code()
click to toggle source
# File lib/ibanizator/iban.rb, line 24 def country_code cc = iban_string[0..1].to_sym COUNTRY_CODES.keys.include?(cc) ? cc : :unknown end
extended_data()
click to toggle source
# File lib/ibanizator/iban.rb, line 30 def extended_data ExtendedData::DE.new(self) if country_code == :DE end
valid?()
click to toggle source
# File lib/ibanizator/iban.rb, line 35 def valid? Validator.new(self).validate end
Private Instance Methods
sanitize(input)
click to toggle source
# File lib/ibanizator/iban.rb, line 41 def sanitize(input) input.to_s.gsub(/\s+/, '').upcase end