Class: BaseException

Inherits:
Object
  • Object
show all
Includes:
NumberIndices
Defined in:
lib/uk_account_validator/exceptions/base_exception.rb

Constant Summary

Constants included from NumberIndices

NumberIndices::NUMBER_INDEX

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(modulus_weight, account_number, sort_code, check_number) ⇒ BaseException

Returns a new instance of BaseException.



6
7
8
9
10
11
# File 'lib/uk_account_validator/exceptions/base_exception.rb', line 6

def initialize(modulus_weight, , sort_code, check_number)
  @modulus_weight = modulus_weight
  @account_number = 
  @sort_code      = sort_code
  @check_number   = check_number
end

Instance Attribute Details

#account_numberObject (readonly)

Returns the value of attribute account_number.



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

def 
  @account_number
end

#check_numberObject (readonly)

Returns the value of attribute check_number.



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

def check_number
  @check_number
end

#modulus_weightObject (readonly)

Returns the value of attribute modulus_weight.



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

def modulus_weight
  @modulus_weight
end

#sort_codeObject (readonly)

Returns the value of attribute sort_code.



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

def sort_code
  @sort_code
end

Class Method Details

.allow_any?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/uk_account_validator/exceptions/base_exception.rb', line 13

def self.allow_any?
  false
end

Instance Method Details

#after_calculate_total(total, _test_digits) ⇒ Object

Returns the new total after any adjustments



27
28
29
# File 'lib/uk_account_validator/exceptions/base_exception.rb', line 27

def after_calculate_total(total, _test_digits)
  return total
end

#apply_account_number_substitutionsObject



31
32
33
# File 'lib/uk_account_validator/exceptions/base_exception.rb', line 31

def 
  return 
end

#apply_sort_code_substitutionsObject

Returns the new sort code after substitutions



36
37
38
# File 'lib/uk_account_validator/exceptions/base_exception.rb', line 36

def apply_sort_code_substitutions
  return sort_code
end

#override_test?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/uk_account_validator/exceptions/base_exception.rb', line 17

def override_test?
  false
end

#replace_weight(_test_digits) ⇒ Object

Returns the new modulus weight after applying the exception.



22
23
24
# File 'lib/uk_account_validator/exceptions/base_exception.rb', line 22

def replace_weight(_test_digits)
  return modulus_weight
end

#zero_allObject

Zero all weights



43
44
45
46
47
48
49
50
51
# File 'lib/uk_account_validator/exceptions/base_exception.rb', line 43

def zero_all
  UkAccountValidator::ModulusWeight.new(
    modulus_weight.sort_code_start,
    modulus_weight.sort_code_end,
    modulus_weight.modulus,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    modulus_weight.exception
  )
end

#zero_u_bObject

Zero weights for u to b



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/uk_account_validator/exceptions/base_exception.rb', line 54

def zero_u_b
  UkAccountValidator::ModulusWeight.new(
    modulus_weight.sort_code_start,
    modulus_weight.sort_code_end,
    modulus_weight.modulus,
    0, 0, 0, 0, 0, 0, 0, 0,
    modulus_weight.c, modulus_weight.d, modulus_weight.e,
    modulus_weight.f, modulus_weight.g, modulus_weight.h,
    modulus_weight.exception
  )
end