class BankTools::DE::BLZ

Constants

BLZ_TO_BANK_NAME_PATH
LENGTH

Public Class Methods

blz_to_bank_name() click to toggle source
# File lib/banktools-de/blz.rb, line 20
def self.blz_to_bank_name
  @blz_to_bank_name ||= YAML.load_file(BLZ_TO_BANK_NAME_PATH).fetch(:data)
end

Public Instance Methods

bank_name() click to toggle source
# File lib/banktools-de/blz.rb, line 44
def bank_name
  blz_to_bank_name.fetch(compacted_value, nil)
end
errors() click to toggle source
# File lib/banktools-de/blz.rb, line 36
def errors
  errors = []
  errors << Errors::TOO_SHORT if compacted_value.length < LENGTH
  errors << Errors::TOO_LONG if compacted_value.length > LENGTH
  errors << Errors::INVALID_CHARACTERS if compacted_value.match(/\D/)
  errors
end
normalize() click to toggle source
# File lib/banktools-de/blz.rb, line 24
def normalize
  if compacted_value.match(/\A(\d{3})(\d{3})(\d{2})\z/)
    "#$1 #$2 #$3"
  else
    original_value
  end
end
valid?() click to toggle source
# File lib/banktools-de/blz.rb, line 32
def valid?
  errors.empty?
end

Private Instance Methods

blz_to_bank_name() click to toggle source
# File lib/banktools-de/blz.rb, line 50
def blz_to_bank_name
  self.class.blz_to_bank_name
end
compacted_value() click to toggle source
# File lib/banktools-de/blz.rb, line 54
def compacted_value
  original_value.to_s.gsub(/[\s-]/, "")
end