Sha256: f34aaba37b254f190bb4036ca784009d9f275cfa3932d3d127971abce4631e0a

Contents?: true

Size: 466 Bytes

Versions: 6

Compression:

Stored size: 466 Bytes

Contents

require_relative 'pattern1'

module BrDocuments
  module IE
    class RR < Pattern1
      def initialize(number)
        super
        @mask = /^(\d{8}\-\d{1})$|^(\d{9})$/
        @weight = [1, 2, 3, 4, 5, 6, 7, 8]
      end

      private

      def format_ie(number)
        number.sub(/(\d{8})(\d{1})/, '\\1-\\2')
      end

      def generate_check_digit(values, weights)
        sum = reduce_weights(values, weights)
        sum % 9
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
br_documents-0.2.5 lib/br_documents/ie/rr.rb
br_documents-0.2.4 lib/br_documents/ie/rr.rb
br_documents-0.2.3 lib/br_documents/ie/rr.rb
br_documents-0.2.2 lib/br_documents/ie/rr.rb
br_documents-0.2.1 lib/br_documents/ie/rr.rb
br_documents-0.2.0 lib/br_documents/ie/rr.rb