Class: MagickNumbers::Pesel
Instance Attribute Summary
Attributes inherited from Base
#length, #magick_array, #magick_number, #mask, #modulo, #regexp
Instance Method Summary collapse
-
#initialize(num) ⇒ Pesel
constructor
A new instance of Pesel.
- #validate_sum_control ⇒ Object
Methods inherited from Base
#checksum, #valid?, #validate, #validate_length, #validate_regexp
Constructor Details
#initialize(num) ⇒ Pesel
Returns a new instance of Pesel.
5 6 7 8 9 10 11 |
# File 'lib/magick_numbers/pesel.rb', line 5 def initialize(num) super num @mask = [ 1, 3, 7, 9, 1, 3, 7, 9, 1, 3] @modulo = 10 @regexp = /\d{11}/ @length = 11 end |
Instance Method Details
#validate_sum_control ⇒ Object
13 14 15 16 17 18 |
# File 'lib/magick_numbers/pesel.rb', line 13 def validate_sum_control mod = checksum % modulo mod = 10 - mod mod = 0 if mod == 10 mod === magick_array.shift end |