Class: BrDocuments::IE::TO

Inherits:
Pattern1 show all
Defined in:
lib/br_documents/ie/to.rb

Instance Method Summary collapse

Methods included from Commons::Mod11

#generate_check_digit, #reduce_weights

Methods inherited from Base

#formatted, #valid?

Constructor Details

#initialize(number) ⇒ TO

Returns a new instance of TO.



6
7
8
9
10
11
12
13
14
15
# File 'lib/br_documents/ie/to.rb', line 6

def initialize(number)
  super
  if number.gsub(/(\.)|(\-)/, '').length == 9
    @mask = /^(\d{2}\.\d{6}\-\d{1})$|^(\d{9})$/
    @weight = [9, 8, 7, 6, 5, 4, 3, 2]
  else
    @mask = /^(\d{2}\.\d{2}\.\d{6}\-\d{1})$|^(\d{11})$/
    @weight = [9, 8, 0, 0, 7, 6, 5, 4, 3, 2]
  end
end