Magic8Ball 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/magic8ball.rb +12 -1
- data/lib/magic8ball/answerator.rb +16 -3
- metadata +1 -1
data/lib/magic8ball.rb
CHANGED
@@ -1,6 +1,17 @@
|
|
1
|
+
# The main Magic8Ball driver
|
1
2
|
class Magic8Ball
|
3
|
+
# Answer any question
|
4
|
+
#
|
5
|
+
# Exemple:
|
6
|
+
# >> Magic8Ball.answer("Am I smart?")
|
7
|
+
# >> Maybe?!
|
8
|
+
#
|
9
|
+
# Arguments:
|
10
|
+
# question: (String)
|
11
|
+
|
2
12
|
def self.answer(question = 'May shoud I try?')
|
3
|
-
Answerator.
|
13
|
+
a = Answerator.new
|
14
|
+
a.answer(question)
|
4
15
|
end
|
5
16
|
end
|
6
17
|
|
@@ -1,7 +1,20 @@
|
|
1
|
+
# The main answer's generator
|
1
2
|
class Answerator
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
def initialize
|
5
|
+
@answers = ["Yes", "No", "Maybe?!"]
|
6
|
+
end
|
7
|
+
|
8
|
+
# generate a answer for any question
|
9
|
+
#
|
10
|
+
# Example:
|
11
|
+
# >> obj.answer("Am I dumb?")
|
12
|
+
# => Maybe?!
|
13
|
+
#
|
14
|
+
# Awguments:
|
15
|
+
# question: (String)
|
16
|
+
|
17
|
+
def answer(question)
|
18
|
+
question+" => "+@answers[rand(3)]
|
6
19
|
end
|
7
20
|
end
|