Class: User

Inherits:
Object
  • Object
show all
Defined in:
helpers/user.rb

Instance Method Summary collapse

Constructor Details

#initializeUser

Returns a new instance of User.


3
4
5
6
7
8
# File 'helpers/user.rb', line 3

def initialize
  @first=Faker::Name.first_name
  @last=Faker::Name.last_name
  @company="OneLogin Test"
  @phone=Faker::PhoneNumber.phone_number
end

Instance Method Details

#companyObject


22
23
24
# File 'helpers/user.rb', line 22

def company
  return @company
end

#emailObject


26
27
28
29
# File 'helpers/user.rb', line 26

def email
  @email_address = "#{@first.downcase}.#{@last.downcase}[email protected]"
  return @email_address  
end

#first_nameObject


10
11
12
# File 'helpers/user.rb', line 10

def first_name
  return @first
end

#full_nameObject


18
19
20
# File 'helpers/user.rb', line 18

def full_name
  full_name = "#{@first} #{@last}"
end

#last_nameObject


14
15
16
# File 'helpers/user.rb', line 14

def last_name
  return @last
end

#phoneObject


31
32
33
# File 'helpers/user.rb', line 31

def phone 
  return @phone
end

#save_to_file(user, filename) ⇒ Object


39
40
41
42
43
44
45
# File 'helpers/user.rb', line 39

def save_to_file(user, filename)
    p user
    p filename
    File.open("logfiles/users/"+filename,"w") do |f|
      f.write(user.to_json)
    end   
end

#to_jsonObject


35
36
37
# File 'helpers/user.rb', line 35

def to_json
  {'first'=>@first, 'last' => @last, 'company' => 'OneLogin Test', 'password' => :null, 'email' => self.email, 'phone' => @phone}.to_json
end