Class: VESR::ValidationDigitCalculator
- Inherits:
-
Object
- Object
- VESR::ValidationDigitCalculator
- Defined in:
- lib/vesr/validation_digit_calculator.rb
Constant Summary collapse
- ESR9_TABLE =
[0, 9, 4, 6, 8, 2, 7, 1, 3, 5]
Class Method Summary collapse
Class Method Details
.call(value) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/vesr/validation_digit_calculator.rb', line 7 def self.call(value) value = value.to_s digit = 0 value.split('').each do |char| current_digit = digit + char.to_i digit = ESR9_TABLE[current_digit % 10] end digit = (10 - digit) % 10 "#{value}#{digit}" end |