Class: Brid::PIS

Inherits:
GenericID show all
Defined in:
lib/brid/ids/pis.rb

Instance Attribute Summary

Attributes inherited from GenericID

#number

Instance Method Summary collapse

Methods inherited from GenericID

#check_digits_length, #freeze, #initialize, #invalid_sequential?, #valid?

Constructor Details

This class inherits a constructor from GenericID

Instance Method Details

#check_digitsObject



5
6
7
8
9
# File 'lib/brid/ids/pis.rb', line 5

def check_digits
  @check_digits ||= begin
    @number[/.$/]
  end
end

#number_lengthObject



3
# File 'lib/brid/ids/pis.rb', line 3

def number_length; 11; end

#sequentialObject



11
12
13
14
15
# File 'lib/brid/ids/pis.rb', line 11

def sequential
  @sequential ||= begin
    @number[/^(.*).$/, 1]
  end
end

#to_sObject



17
18
19
20
# File 'lib/brid/ids/pis.rb', line 17

def to_s
  er = /^(.{3})(.{5})(.{2})(.{1})/
  "#{@number.gsub(er, '\1.\2.\3-\4')}"
end