Module: FFaker::IdentificationMX

Extended by:
IdentificationMX, ModuleUtils
Included in:
IdentificationMX
Defined in:
lib/ffaker/identification_mx.rb

Constant Summary collapse

CONSONANTS =
%w(B C D F G H J K L M N P Q R S T V W X Y Z)
VOWELS =
%w(A E I O U)
HOMOCLAVE =
CONSONANTS + VOWELS + [*'0'..'9']

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, underscore

Instance Method Details

#curpObject


41
42
43
44
45
46
# File 'lib/ffaker/identification_mx.rb', line 41

def curp
  all_letters = CONSONANTS + VOWELS
  hm = %w(H M)
  date = ::Time.at(rand * ::Time.now.to_f).strftime('%y%m%d')
  "#{CONSONANTS.sample}#{VOWELS.sample}#{all_letters.sample(2).join}#{date}#{hm.sample}#{ESTADOS_CURP.sample}#{CONSONANTS.sample(3).join}#{HOMOCLAVE.sample}#{rand(10)}"
end

#rfcObject

es.wikipedia.org/wiki/Registro_Federal_de_Contribuyentes_(M%C3%A9xico) Registro Federal de Contribuyentes (R.F.C.)


35
36
37
# File 'lib/ffaker/identification_mx.rb', line 35

def rfc
  [rfc_persona_moral, rfc_persona_fisica].sample
end

#rfc_persona_fisicaObject

es.wikipedia.org/wiki/Registro_Federal_de_Contribuyentes_(M%C3%A9xico) Registro Federal de Contribuyentes (R.F.C.) para persona física


17
18
19
20
21
22
# File 'lib/ffaker/identification_mx.rb', line 17

def rfc_persona_fisica
  consonants_n = CONSONANTS + ["Ñ"]
  all_letters = consonants_n + VOWELS
  date = ::Time.at(rand * ::Time.now.to_f).strftime('%y%m%d')
  "#{consonants_n.sample}#{VOWELS.sample}#{all_letters.sample(2).join}#{date}#{HOMOCLAVE.sample(3).join}"
end

#rfc_persona_moralObject

es.wikipedia.org/wiki/Registro_Federal_de_Contribuyentes_(M%C3%A9xico) Registro Federal de Contribuyentes (R.F.C.) para persona moral


26
27
28
29
30
31
# File 'lib/ffaker/identification_mx.rb', line 26

def rfc_persona_moral
  consonants_n_amp = CONSONANTS + ["Ñ", '&']
  all_letters = consonants_n_amp + VOWELS
  date = ::Time.at(rand * ::Time.now.to_f).strftime('%y%m%d')
  "#{all_letters.sample(3).join}#{date}#{HOMOCLAVE.sample(3).join}"
end