Class: BankTools::DK::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/banktools-dk/account.rb

Constant Summary collapse

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.

11
MAX_LENGTH =
14

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number) ⇒ Account

Returns a new instance of Account.



11
12
13
# File 'lib/banktools-dk/account.rb', line 11

def initialize(number)
  @normalized_number = normalize(number)
end

Instance Attribute Details

#normalized_numberObject (readonly)

Returns the value of attribute normalized_number.



9
10
11
# File 'lib/banktools-dk/account.rb', line 9

def normalized_number
  @normalized_number
end

Instance Method Details

#errorsObject



19
20
21
22
23
24
25
# 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?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/banktools-dk/account.rb', line 15

def valid?
  errors.empty?
end