Class: UkAccountValidator::Validators::BaseValidator

Inherits:
Object
  • Object
show all
Includes:
NumberIndices
Defined in:
lib/uk_account_validator/validators/base_validator.rb

Direct Known Subclasses

DoubleAlternate, StandardModulus

Constant Summary

Constants included from NumberIndices

NumberIndices::NUMBER_INDEX

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account_number, sort_code, modulus_weight, exception) ⇒ BaseValidator

Returns a new instance of BaseValidator.



8
9
10
11
12
13
14
15
# File 'lib/uk_account_validator/validators/base_validator.rb', line 8

def initialize(, sort_code, modulus_weight, exception)
  @account_number = 
  @sort_code      = sort_code
  @modulus_weight = modulus_weight
  @exception      = exception

  @sort_code = exception.apply_sort_code_substitutions
end

Instance Attribute Details

#account_numberObject (readonly)

Returns the value of attribute account_number.



6
7
8
# File 'lib/uk_account_validator/validators/base_validator.rb', line 6

def 
  @account_number
end

#exceptionObject (readonly)

Returns the value of attribute exception.



6
7
8
# File 'lib/uk_account_validator/validators/base_validator.rb', line 6

def exception
  @exception
end

#modulus_weightObject (readonly)

Returns the value of attribute modulus_weight.



6
7
8
# File 'lib/uk_account_validator/validators/base_validator.rb', line 6

def modulus_weight
  @modulus_weight
end

#sort_codeObject (readonly)

Returns the value of attribute sort_code.



6
7
8
# File 'lib/uk_account_validator/validators/base_validator.rb', line 6

def sort_code
  @sort_code
end

Instance Method Details

#applying_exceptions(test_digits) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/uk_account_validator/validators/base_validator.rb', line 17

def applying_exceptions(test_digits)
  @modulus_weight = exception.replace_weight(test_digits)

  total = yield

  total = exception.after_calculate_total(total, test_digits)

  total
end