Class: Valideez::Nip

Inherits:
Base
  • Object
show all
Includes:
Common
Defined in:
lib/valideez/nip.rb

Instance Attribute Summary

Attributes inherited from Base

#val, #validable

Instance Method Summary collapse

Methods included from Common

#validate_format, #validate_length

Methods inherited from Base

#valid?

Constructor Details

#initialize(val, options = {}) ⇒ Nip

Returns a new instance of Nip.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/valideez/nip.rb', line 5

def initialize(val, options = {})
  super val

  assign({ 
    :format => /\A\d{10}\Z/, 
    :length => 10,
    :mask => [6, 5, 7, 2, 3, 4, 5, 6, 7],
    :modulo => 11,
    :sum_control => true,
  }.merge(options))

  @arr = []
end

Instance Method Details

#validate_sum_controlObject



19
20
21
22
# File 'lib/valideez/nip.rb', line 19

def validate_sum_control
  mod = checksum % modulo
  mod === @arr.shift
end