module FFaker::IdentificationMX

Constants

CONSONANTS
HOMOCLAVE
VOWELS

Public Instance Methods

curp() click to toggle source

es.wikipedia.org/wiki/Clave_%C3%9Anica_de_Registro_de_Poblaci%C3%B3n Clave Única de Registro de Población

# File lib/ffaker/identification_mx.rb, line 41
def curp
  all_letters = CONSONANTS + VOWELS
  hm = %w[H M]
  [
    fetch_sample(CONSONANTS), fetch_sample(VOWELS),
    fetch_sample(all_letters, count: 2).join, date, fetch_sample(hm),
    fetch_sample(ESTADOS_CURP), fetch_sample(CONSONANTS, count: 3).join,
    fetch_sample(HOMOCLAVE), rand(0..9)
  ].join
end
rfc() click to toggle source

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

# File lib/ffaker/identification_mx.rb, line 35
def rfc
  fetch_sample([rfc_persona_moral, rfc_persona_fisica])
end
rfc_persona_fisica() click to toggle source

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

# File lib/ffaker/identification_mx.rb, line 14
def rfc_persona_fisica
  consonants_n = CONSONANTS + ['Ñ']
  [
    fetch_sample(consonants_n),
    fetch_sample(VOWELS),
    fetch_sample(consonants_n + VOWELS, count: 2).join,
    date,
    fetch_sample(HOMOCLAVE, count: 3).join
  ].join
end
rfc_persona_moral() click to toggle source

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

# File lib/ffaker/identification_mx.rb, line 27
def rfc_persona_moral
  consonants_n_amp = CONSONANTS + ['Ñ', '&']
  all_letters = consonants_n_amp + VOWELS
  [fetch_sample(all_letters, count: 3), date, fetch_sample(HOMOCLAVE, count: 3)].flatten.join
end

Private Instance Methods

date() click to toggle source
# File lib/ffaker/identification_mx.rb, line 54
def date
  ::Time.at(rand * ::Time.now.to_f).strftime('%y%m%d')
end