class Ibanizator::Iban
Constants
- LENGTHS
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 LENGTHS.keys.include?(cc) ? cc : :unknown end
extended_data()
click to toggle source
# File lib/ibanizator/iban.rb, line 30 def extended_data if country_code == :DE ExtendedData::DE.new(self) end end
formatted_iban_string()
click to toggle source
# File lib/ibanizator/iban.rb, line 41 def formatted_iban_string iban_string.scan(/.{1,4}/).join(' ') end
valid?()
click to toggle source
# File lib/ibanizator/iban.rb, line 37 def valid? Validator.new(self).validate end
Private Instance Methods
sanitize(input)
click to toggle source
# File lib/ibanizator/iban.rb, line 46 def sanitize(input) input.to_s.gsub(/\s+/,'').upcase end