Sha256: baa9f71025c9a32bd615ffe53112d0f6cf025a6284d7350bf4e87757b8ec9738

Contents?: true

Size: 566 Bytes

Versions: 4

Compression:

Stored size: 566 Bytes

Contents

module Brid
  class PIS < GenericID
    def number_length; 11; end

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

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

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

    private
    def mod11 number
      Mod11.new(number, :base => 2..9)
    end

    def valid_number
      mod11(sequential) * 1
    end
  end
end

PIS = Brid::PIS if not defined? PIS and not defined? Pis

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
brid-0.1.3 lib/brid/ids/pis.rb
brid-0.1.2 lib/brid/ids/pis.rb
brid-0.1.1 lib/brid/ids/pis.rb
brid-0.1.0 lib/brid/ids/pis.rb