forked from jedld/pretentious
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_classes.rb
102 lines (75 loc) · 1.2 KB
/
test_classes.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
require 'digest/md5'
class Fibonacci
def fib(n)
return 0 if (n == 0)
return 1 if (n == 1)
return 1 if (n == 2)
return fib(n - 1) + fib(n - 2)
end
def self.say_hello
"hello"
end
end
class TestClass1
def initialize(message)
@message = message
end
def set_block(&block)
@block = block
end
def call_block
@block.call(@message)
end
def message
@message
end
def just_returns_true
true
end
def print_message
puts @message
end
def something_is_wrong
raise StandardError.new
end
end
class TestClass2
def initialize(message)
@message = {message: message}
end
def print_message
puts @message[:message]
end
end
class TestClass3
def initialize(testclass1, testclass2)
@class1 = testclass1
@class2 = testclass2
end
def show_messages
@class1.print_message
@class2.print_message
"awesome!!!"
end
def swap_hash(j, &block)
h = []
j.each do |k,v|
h << block.call(v,k)
end
h
end
def check_proc
@class2.call(1,2,3)
end
end
class TestClass4
def initialize(&block)
@message = block.call
end
def message
@message
end
def to_s
@message
end
end