Class: RandomUser

Inherits:
Object
  • Object
show all
Includes:
Attrio
Defined in:
lib/random_user.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_from_hash(hash) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/random_user.rb', line 34

def self.create_from_hash(hash)
  user = RandomUser.new
  user.name =         hash['name']
  user.email =        hash['email']
  user.gender =       hash['gender']
  user.username =     hash['username']
  user.password =     hash['password']
  user.salt =         hash['salt']
  user.md5 =          hash['md5']
  user.sha1 =         hash['sha1']
  user.sha256 =       hash['sha256']
  user.dob =          Time.at(hash['dob'].to_i) if hash['dob']
  user.phone =        hash['phone']
  user.cell =         hash['cell']
  user.nationality =  hash['nationality']
  user.location =     hash['location']
  user.registered =   Time.at(hash['registered'].to_i) if hash['registered']
  user.picture =      hash['picture']
  return user if user.valid?
end

Instance Method Details

#first_nameObject



30
31
32
# File 'lib/random_user.rb', line 30

def first_name
  name[""]
end

#valid?Boolean

Returns:



26
27
28
# File 'lib/random_user.rb', line 26

def valid?
  self.email
end