-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstore_item.rb
More file actions
38 lines (29 loc) · 824 Bytes
/
store_item.rb
File metadata and controls
38 lines (29 loc) · 824 Bytes
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
meatball = {bread: "italian",
meat: "meatballs",
condiment: "marinara"}
ham = {bread: "wheat",
meat: "ham",
condiment: "mustard"}
blt = {:bread => "rye",
:meat => "bacon",
:condiment => "mayo"}
class Sandwich
attr_reader :meat, :bread, :condiment
def initialize(hash_input)
@meat = hash_input[:meat]
@bread = hash_input[:bread]
@condiment = hash_input[:condiment]
end
end
class Perishables < Sandwich
def initialize(hash_input)
super
@shelflife = hash_input[:shelflife]
end
end
roast_beef = Sandwich.new({meat: "roast beef", bread: "white", condiment: "au jus"})
egg_salad = Perishables.new({meat: "eggs", bread: "sourdough", condiment: "mayo", shelflife: 3})
puts roast_beef.meat
puts roast_beef.bread
puts roast_beef.condiment
p egg_salad