class BankTools::DK::Account
Constants
- MAX_LENGTH
- MIN_LENGTH
The number consists of a 4 digit bank registration number followed by a 7-10 digits long account number with no punctuation, dashes or whitespaces. See www.nordea.se/Images/40-11936/utlandsbetalningar-landinformation.pdf for information in Swedish.
Attributes
normalized_number[R]
Public Class Methods
new(number)
click to toggle source
# File lib/banktools-dk/account.rb, line 11 def initialize(number) @normalized_number = normalize(number) end
Public Instance Methods
errors()
click to toggle source
# File lib/banktools-dk/account.rb, line 19 def errors errors = [] errors << :too_short if too_short? errors << :too_long if too_long? errors << :invalid_characters if any_non_digits? errors end
valid?()
click to toggle source
# File lib/banktools-dk/account.rb, line 15 def valid? errors.empty? end
Private Instance Methods
any_non_digits?()
click to toggle source
# File lib/banktools-dk/account.rb, line 37 def any_non_digits? normalized_number.match(/\D/) end
normalize(number)
click to toggle source
# File lib/banktools-dk/account.rb, line 41 def normalize(number) number.gsub(/[\s.-]/, "") end
too_long?()
click to toggle source
# File lib/banktools-dk/account.rb, line 33 def too_long? normalized_number.size > MAX_LENGTH end
too_short?()
click to toggle source
# File lib/banktools-dk/account.rb, line 29 def too_short? normalized_number.size < MIN_LENGTH end