-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.rb
53 lines (41 loc) · 974 Bytes
/
user.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
module Destructable
def destroy(anyobject)
puts "I will destroy the object"
end
end
class User
include Destructable
attr_accessor :name, :email
def initialize(name, email)
@name = name
@email = email
end
def run
puts "I'm rinning"
end
def self.identify_yourself
puts "Hey I am a class method"
end
end
class Buyer < User
def run
puts "Hey I'm not running and I'm in buyer class"
end
end
class Seller < User
end
class Admin < User
end
user = User.new("Vladi", "vladi@example.com")
puts "My user's name is #{user.name} and his email is #{user.email}"
user.destroy("myname")
user.name = "John"
user.email = "john@example.com"
puts "My user's new name is #{user.name} and his email is #{user.email}"
buyer = Buyer.new("John Doe", "johndoe@example.com")
buyer.run
seller = Seller.new("John Doe1", "johndoe1@example.com")
seller.run
admin = Admin.new("John Doe2", "johndoe2@example.com")
admin.run
User.identify_yourself