Module: FFaker::IdentificationBR
Constant Summary
collapse
- GENDERS =
%w[Feminino Masculino].freeze
- CPF_VERIFICATION_MULTIPLIERS =
[11, 10, 9, 8, 7, 6, 5, 4, 3, 2].freeze
- CNPJ_VERIFICATION_MULTIPLIERS =
[6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2].freeze
Instance Method Summary
collapse
const_missing, k, luhn_check, underscore, unique
#fetch_sample, #rand, #shuffle
Instance Method Details
#cnpj ⇒ Object
23
24
25
26
27
|
# File 'lib/ffaker/identification_br.rb', line 23
def cnpj
cnpj = FFaker.numerify('############')
validators = cnpj_verification_digits(cnpj)
cnpj + validators.join
end
|
#cnpj_verification_digits(cnpj) ⇒ Object
50
51
52
|
# File 'lib/ffaker/identification_br.rb', line 50
def cnpj_verification_digits(cnpj)
document_verification_digits(CNPJ_VERIFICATION_MULTIPLIERS, cnpj)
end
|
#cpf ⇒ Object
12
13
14
15
16
|
# File 'lib/ffaker/identification_br.rb', line 12
def cpf
cpf = FFaker.numerify('#########')
validators = cpf_verification_digits(cpf)
cpf + validators.join
end
|
#cpf_verification_digits(cpf) ⇒ Object
46
47
48
|
# File 'lib/ffaker/identification_br.rb', line 46
def cpf_verification_digits(cpf)
document_verification_digits(CPF_VERIFICATION_MULTIPLIERS, cpf)
end
|
#gender ⇒ Object
42
43
44
|
# File 'lib/ffaker/identification_br.rb', line 42
def gender
fetch_sample(GENDERS)
end
|
#pretty_cnpj ⇒ Object
29
30
31
32
|
# File 'lib/ffaker/identification_br.rb', line 29
def pretty_cnpj
cnpj_numbers = cnpj.to_s.rjust(14, '0')
"#{cnpj_numbers[0..1]}.#{cnpj_numbers[2..4]}.#{cnpj_numbers[5..7]}/#{cnpj_numbers[8..11]}-#{cnpj_numbers[12..14]}"
end
|
#pretty_cpf ⇒ Object
18
19
20
21
|
# File 'lib/ffaker/identification_br.rb', line 18
def pretty_cpf
cpf_numbers = cpf
"#{cpf_numbers[0..2]}.#{cpf_numbers[3..5]}.#{cpf_numbers[6..8]}-#{cpf_numbers[9..10]}"
end
|
#pretty_rg ⇒ Object
38
39
40
|
# File 'lib/ffaker/identification_br.rb', line 38
def pretty_rg
FFaker.numerify('###.###.###')
end
|
#rg ⇒ Object
34
35
36
|
# File 'lib/ffaker/identification_br.rb', line 34
def rg
FFaker.numerify('#########')
end
|