Class: Valideez::Regon
- Includes:
- Common
- Defined in:
- lib/valideez/regon.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(val, options = {}) ⇒ Regon
constructor
A new instance of Regon.
- #is_long? ⇒ Boolean
- #validate_sum_control ⇒ Object
Methods included from Common
#validate_format, #validate_length
Methods inherited from Base
Constructor Details
#initialize(val, options = {}) ⇒ Regon
Returns a new instance of Regon.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/valideez/regon.rb', line 5 def initialize(val, = {}) super val assign({ :format => /\A(\d{9}|\d{14})\Z/, :length => [9, 14], :mask => [8, 9, 2, 3, 4, 5, 6, 7], :mask_long => [2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8], :modulo => 11, :sum_control => true, }.merge()) @arr = [] end |
Instance Method Details
#is_long? ⇒ Boolean
20 21 22 |
# File 'lib/valideez/regon.rb', line 20 def is_long? val.size === 14 end |
#validate_sum_control ⇒ Object
24 25 26 27 |
# File 'lib/valideez/regon.rb', line 24 def validate_sum_control mod = checksum % modulo mod === @arr.shift end |