Class: RandomUser
- Inherits:
-
Object
- Object
- RandomUser
- Defined in:
- lib/randomizer/random_user.rb
Instance Attribute Summary collapse
-
#first_name ⇒ Object
readonly
Returns the value of attribute first_name.
-
#last_name ⇒ Object
readonly
Returns the value of attribute last_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#avatar_url ⇒ Object
AVATAR.
-
#email ⇒ Object
EMAIL ADDRESS.
- #full_name ⇒ Object
-
#initialize ⇒ RandomUser
constructor
A new instance of RandomUser.
-
#nickname ⇒ Object
NICKNAME.
-
#password ⇒ Object
PASSWORD.
- #random_email_domain ⇒ Object
- #random_nickname ⇒ Object
- #random_password ⇒ Object
- #regenerate_email ⇒ Object
- #regenerate_nickname ⇒ Object
Constructor Details
#initialize ⇒ RandomUser
Returns a new instance of RandomUser.
7 8 9 10 11 |
# File 'lib/randomizer/random_user.rb', line 7 def initialize names = NameGenerator.instance.random @first_name = names.first @last_name = names.last end |
Instance Attribute Details
#first_name ⇒ Object (readonly)
Returns the value of attribute first_name.
5 6 7 |
# File 'lib/randomizer/random_user.rb', line 5 def first_name @first_name end |
#last_name ⇒ Object (readonly)
Returns the value of attribute last_name.
5 6 7 |
# File 'lib/randomizer/random_user.rb', line 5 def last_name @last_name end |
Class Method Details
.nicknames(first, last) ⇒ Object
53 54 55 56 |
# File 'lib/randomizer/random_user.rb', line 53 def self.nicknames(first, last) first, last = first.downcase, last.downcase [first, last, first[0..0] + last, first + last[0..0], first + last, first + '2', first + '3'] end |
Instance Method Details
#avatar_url ⇒ Object
AVATAR
21 22 23 |
# File 'lib/randomizer/random_user.rb', line 21 def avatar_url @avatar_url ||= AllAvatarsSite.instance.random_url end |
#email ⇒ Object
EMAIL ADDRESS
62 63 64 |
# File 'lib/randomizer/random_user.rb', line 62 def email @email || regenerate_email end |
#full_name ⇒ Object
13 14 15 |
# File 'lib/randomizer/random_user.rb', line 13 def full_name @full_name ||= [@first_name, @last_name].join(' ') end |
#nickname ⇒ Object
NICKNAME
41 42 43 |
# File 'lib/randomizer/random_user.rb', line 41 def nickname @nickname || regenerate_nickname end |
#password ⇒ Object
PASSWORD
29 30 31 |
# File 'lib/randomizer/random_user.rb', line 29 def password @password ||= random_password end |
#random_email_domain ⇒ Object
70 71 72 |
# File 'lib/randomizer/random_user.rb', line 70 def random_email_domain EMAIL_DOMAINS.random end |
#random_nickname ⇒ Object
49 50 51 |
# File 'lib/randomizer/random_user.rb', line 49 def random_nickname RandomUser.nicknames(@first_name, @last_name).random end |
#random_password ⇒ Object
33 34 35 |
# File 'lib/randomizer/random_user.rb', line 33 def random_password Array.new(8, '').collect{PASSWORD_CHARACTERS.random}.join end |
#regenerate_email ⇒ Object
66 67 68 |
# File 'lib/randomizer/random_user.rb', line 66 def regenerate_email @email = random_nickname + '@' + random_email_domain end |
#regenerate_nickname ⇒ Object
45 46 47 |
# File 'lib/randomizer/random_user.rb', line 45 def regenerate_nickname @nickname = random_nickname end |