Class: UserAttrs

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

Instance Method Summary collapse

Constructor Details

#initializeUserAttrs

Returns a new instance of UserAttrs.



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/user_attributes.rb', line 2

def initialize
  @aboutMe
  @birthday
  @givenName
  @middleName
  @displayName
  @familyName
  @email
  @currentLocation
  @gender
  @interests
  @music
  @movies
  @books
end

Instance Method Details

#aboutMeObject



18
19
20
# File 'lib/user_attributes.rb', line 18

def aboutMe
  @aboutMe ||= Faker::Lorem.paragraph
end

#birthdayObject



22
23
24
25
26
# File 'lib/user_attributes.rb', line 22

def birthday
  now = Time.now().to_i()
  d = Faker::Base.bell_random_in_range( now - 13 * 365 * 24 * 3600, now - 60 * 365 * 24 * 3600 )
  Time.at(d).strftime('%Y-%m-%d')
end

#booksObject



74
75
76
# File 'lib/user_attributes.rb', line 74

def books
  @books ||= Random.rand(12).times.map{ Faker::Base.fetch_with_weighting('lorem.books') }.uniq
end

#currentLocationObject



54
55
56
# File 'lib/user_attributes.rb', line 54

def currentLocation
  @currentLocation ||= Faker::Address.city + ', ' + Faker::Address.state
end

#displayNameObject



42
43
44
# File 'lib/user_attributes.rb', line 42

def displayName
  @displayName ||= [givenName(),familyName()].join(' ')
end

#emailObject



50
51
52
# File 'lib/user_attributes.rb', line 50

def email
  @email ||= Faker::Internet.email([givenName(),familyName()].join(' '))
end

#familyNameObject



46
47
48
# File 'lib/user_attributes.rb', line 46

def familyName
  @familyName ||= Faker::Name.last_name
end

#genderObject



58
59
60
# File 'lib/user_attributes.rb', line 58

def gender
  @gender ||=  ['male', 'female'].sample
end

#givenNameObject



28
29
30
31
32
33
# File 'lib/user_attributes.rb', line 28

def givenName
  gender = gender()
  @givenName ||= (gender == 'female') ?
      Faker::Base.fetch_with_weighting('name.female_name_common')
    : Faker::Base.fetch_with_weighting('name.male_name_common')
end

#interestsObject



62
63
64
# File 'lib/user_attributes.rb', line 62

def interests
  @interests ||= Random.rand(12).times.map{ Faker::Base.fetch_with_weighting('lorem.interests') }.uniq
end

#janRandomGeneratedObject



78
79
80
# File 'lib/user_attributes.rb', line 78

def janRandomGenerated
  "Y"
end

#middleNameObject



35
36
37
38
39
40
# File 'lib/user_attributes.rb', line 35

def middleName
  gender = gender()
  @middleName ||= (gender == 'female') ?
      Faker::Base.fetch_with_weighting('name.female_name_common')
    : Faker::Base.fetch_with_weighting('name.male_name_common')
end

#moviesObject



70
71
72
# File 'lib/user_attributes.rb', line 70

def movies
  @movies ||= Random.rand(12).times.map{ Faker::Base.fetch_with_weighting('lorem.movies') }.uniq
end

#musicObject



66
67
68
# File 'lib/user_attributes.rb', line 66

def music
  @music ||= Random.rand(12).times.map{ Faker::Base.fetch_with_weighting('lorem.music') }.uniq
end