Class: Exception10

Inherits:
BaseException show all
Defined in:
lib/uk_account_validator/exceptions/exception_10.rb

Overview

For the exception 10 check, if ab = 09 or ab = 99 and g = 9, zeroise weighting positions u-b.

Constant Summary

Constants included from NumberIndices

NumberIndices::NUMBER_INDEX

Instance Attribute Summary

Attributes inherited from BaseException

#account_number, #check_number, #modulus_weight, #sort_code

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseException

#after_calculate_total, #apply_account_number_substitutions, #apply_sort_code_substitutions, #initialize, #override_test?, #zero_all, #zero_u_b

Constructor Details

This class inherits a constructor from BaseException

Class Method Details

.allow_any?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/uk_account_validator/exceptions/exception_10.rb', line 4

def self.allow_any?
  true
end

Instance Method Details

#replace_weight(test_digits) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/uk_account_validator/exceptions/exception_10.rb', line 8

def replace_weight(test_digits)
  # if ab = 09 or 99 and g=9, zeroise weighting positions u-b.
  a = test_digits[NUMBER_INDEX[:a]]
  b = test_digits[NUMBER_INDEX[:b]]

  return zero_u_b if (a == 0 && b == 9) ||
    (a == 9 && b == 9 && test_digits[NUMBER_INDEX[:g]] == 9)

  return modulus_weight
end