Class: CommonNumbers::Polish::Pesel
- Defined in:
- lib/common_numbers/pesel.rb
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.
6 7 8 9 10 11 12 |
# File 'lib/common_numbers/pesel.rb', line 6 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
14 15 16 17 18 19 |
# File 'lib/common_numbers/pesel.rb', line 14 def validate_sum_control mod = checksum % modulo mod = 10 - mod mod = 0 if mod == 10 mod === magick_array.shift end |