Magic8Ball 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.answer(question)
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
- def self.answer(question)
4
- puts "Your question: "+question+"\n"
5
- puts "Yes. Try again!"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Magic8Ball
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: