Module: BrFaker

Defined in:
lib/brfaker.rb,
lib/brfaker/version.rb,
lib/brfaker/cpf_cnpj/cpf.rb,
lib/brfaker/cpf_cnpj/cnpj.rb,
lib/brfaker/cpf_cnpj/cpf_cnpj.rb

Defined Under Namespace

Modules: CpfCnpj, Version Classes: Cnpj, Cpf

Class Method Summary collapse

Class Method Details

.gererate_numbers(quantity) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/brfaker.rb', line 9

def self.gererate_numbers(quantity)
  numbers = []
  quantity.times do
    numbers << random_number
  end
  numbers
end

.mod11(items, range) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/brfaker.rb', line 17

def self.mod11(items, range)
  n = 2
  total = 0
  for item in items          
    total += (item.to_i * n)
    n += 1
    n = 2 if n > range
  end        
  div = 11 - (total % 11)
  return 0 if div > 9
  div
end

.random_numberObject



5
6
7
# File 'lib/brfaker.rb', line 5

def self.random_number
  %w{1 2 3 4 5 6 7 8 9 0}.rand
end