class BankTools::Global::BIC

Constants

COUNTRY_CODES
E
RE

sv.wikipedia.org/wiki/ISO_9362

Public Class Methods

new(raw) click to toggle source
# File lib/banktools/global/bic.rb, line 18
def initialize(raw)
  @raw = raw
end

Public Instance Methods

errors() click to toggle source
# File lib/banktools/global/bic.rb, line 26
def errors
  match = @raw.to_s.match(RE)
  return [ E::BAD_FORMAT ] unless match

  country_code = match.captures.first.upcase
  return [ E::UNKNOWN_COUNTRY ] unless COUNTRY_CODES.include?(country_code)

  []
end
normalize() click to toggle source
# File lib/banktools/global/bic.rb, line 36
def normalize
  @raw.to_s.upcase.gsub(/\s/, "")
end
valid?() click to toggle source
# File lib/banktools/global/bic.rb, line 22
def valid?
  errors.empty?
end