Class: UserAttrs
- Inherits:
-
Object
- Object
- UserAttrs
- Defined in:
- lib/user_attributes.rb
Instance Method Summary collapse
- #aboutMe ⇒ Object
- #birthday ⇒ Object
- #books ⇒ Object
- #currentLocation ⇒ Object
- #displayName ⇒ Object
- #email ⇒ Object
- #familyName ⇒ Object
- #gender ⇒ Object
- #givenName ⇒ Object
-
#initialize ⇒ UserAttrs
constructor
A new instance of UserAttrs.
- #interests ⇒ Object
- #janRandomGenerated ⇒ Object
- #middleName ⇒ Object
- #movies ⇒ Object
- #music ⇒ Object
Constructor Details
#initialize ⇒ UserAttrs
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
#aboutMe ⇒ Object
18 19 20 |
# File 'lib/user_attributes.rb', line 18 def aboutMe @aboutMe ||= Faker::Lorem.paragraph end |
#birthday ⇒ Object
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 |
#books ⇒ Object
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 |
#currentLocation ⇒ Object
54 55 56 |
# File 'lib/user_attributes.rb', line 54 def currentLocation @currentLocation ||= Faker::Address.city + ', ' + Faker::Address.state end |
#displayName ⇒ Object
42 43 44 |
# File 'lib/user_attributes.rb', line 42 def displayName @displayName ||= [givenName(),familyName()].join(' ') end |
#email ⇒ Object
50 51 52 |
# File 'lib/user_attributes.rb', line 50 def email @email ||= Faker::Internet.email([givenName(),familyName()].join(' ')) end |
#familyName ⇒ Object
46 47 48 |
# File 'lib/user_attributes.rb', line 46 def familyName @familyName ||= Faker::Name.last_name end |
#gender ⇒ Object
58 59 60 |
# File 'lib/user_attributes.rb', line 58 def gender @gender ||= ['male', 'female'].sample end |
#givenName ⇒ Object
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 |
#interests ⇒ Object
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 |
#janRandomGenerated ⇒ Object
78 79 80 |
# File 'lib/user_attributes.rb', line 78 def janRandomGenerated "Y" end |
#middleName ⇒ Object
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 |
#movies ⇒ Object
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 |
#music ⇒ Object
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 |