Class: FauxData::PersonGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/faux_data/person_generator.rb

Instance Method Summary collapse

Constructor Details

#initializePersonGenerator

Returns a new instance of PersonGenerator.


12
13
14
15
16
17
# File 'lib/faux_data/person_generator.rb', line 12

def initialize
  @name = PersonalNameGenerator.new
  @address = AddressGenerator.new
  @national_id = NationalIdGenerator.new(:county_code => 'us')
  @max_age_in_days = (365.2524 * 100).to_i
end

Instance Method Details

#personObject


19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/faux_data/person_generator.rb', line 19

def person
  sex = pick_sex()
  address = @address.address
  person = address.merge({
      :sex => sex,
      :surname => @name.surname,
      :first_name => sex == :male ? @name.given_name_male : @name.given_name_female,
      :middle_name => sex == :male ? @name.given_name_male : @name.given_name_female,
      :ssn => @national_id.national_id,
      :date_of_birth => Date.today - (rand(@max_age_in_days))
  })
  person[:email] = "#{person[:first_name].strip.downcase}.#{person[:surname].strip.downcase}@" + pick_email_domain()
  return person
end