Class: BankTools::DE::BLZ
- Inherits:
-
Object
- Object
- BankTools::DE::BLZ
- Defined in:
- lib/banktools-de/blz.rb
Constant Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.blz_to_bank_name ⇒ Object
20 21 22 |
# 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 |
Instance Method Details
#bank_name ⇒ Object
44 45 46 |
# File 'lib/banktools-de/blz.rb', line 44 def bank_name blz_to_bank_name.fetch(compacted_value, nil) end |
#errors ⇒ Object
36 37 38 39 40 41 42 |
# 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 ⇒ Object
24 25 26 27 28 29 30 |
# 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? ⇒ Boolean
32 33 34 |
# File 'lib/banktools-de/blz.rb', line 32 def valid? errors.empty? end |