Class: BankTools::GB::SortCode

Inherits:
Object
  • Object
show all
Defined in:
lib/banktools-gb/sort_code.rb

Constant Summary collapse

LENGTH =
6

Instance Method Summary collapse

Instance Method Details

#compacted_valueObject



27
28
29
# File 'lib/banktools-gb/sort_code.rb', line 27

def compacted_value
  original_value.to_s.gsub(/[\s-]/, "")
end

#errorsObject



17
18
19
20
21
22
23
24
25
# File 'lib/banktools-gb/sort_code.rb', line 17

def errors
  errors = []

  errors << Errors::SORT_CODE_TOO_SHORT if compacted_value.length < LENGTH
  errors << Errors::SORT_CODE_TOO_LONG if compacted_value.length > LENGTH
  errors << Errors::SORT_CODE_INVALID_CHARACTERS if any_non_digits?

  errors
end

#valid?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/banktools-gb/sort_code.rb', line 13

def valid?
  errors.none?
end