-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.rb
49 lines (37 loc) · 878 Bytes
/
test.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
class String
def shuffle
self.split('').shuffle.join
end
end
class Abc
attr_accessor :mother, :father, :child
def initialize(attributes = {})
@mother = attributes[:mother]
@father = attributes[:father]
@child = attributes[:child]
end
def format_params
"Mother:#{@mother}\nFather:#{@father}\nChild#{@child}"
end
end
class User
attr_accessor :name, :email
def initialize(attributes = {})
@name = attributes[:name]
@email = attributes[:email]
end
def formatted_email
"#{@name} <#{@email}>"
end
end
person1 = {first: "josh", last: "rosenkranz"}
person2 = {first: "bob", last: "johnson"}
person3 = {first: "bobette", last: "williams"}
p = Abc.new
p.father = person1
p.mother = person2
p.child = person3
params = {mother: person1, father: person2, child: person3}
puts params
puts p.format_params
puts params[:father][:first]