Sha256: d05edbb56bde27a20ef4d076116675c6358ee6b6c4452e8eee5cd848b45c2a49

Contents?: true

Size: 360 Bytes

Versions: 2

Compression:

Stored size: 360 Bytes

Contents

# frozen_string_literal: true

module CpfCnpj
  class Generator
    NUMBERS = [*0..9].freeze

    def self.generate(size, verifier_digit_generator)
      numbers = Array.new(size) { NUMBERS.sample }
      numbers << verifier_digit_generator.generate(numbers)
      numbers << verifier_digit_generator.generate(numbers)
      numbers.join("")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cpf_cnpj-0.5.0 lib/cpf_cnpj/generator.rb
cpf_cnpj-0.4.1 lib/cpf_cnpj/generator.rb