Class: Answerator
- Inherits:
-
Object
- Object
- Answerator
- Defined in:
- lib/magic8ball/answerator.rb
Overview
The main answer’s generator
Instance Method Summary collapse
-
#answer(question) ⇒ Object
generate a answer for any question.
-
#initialize ⇒ Answerator
constructor
A new instance of Answerator.
Constructor Details
#initialize ⇒ Answerator
Returns a new instance of Answerator.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/magic8ball/answerator.rb', line 4 def initialize @answers = [ "It is certain", "It is decidedly so", "Without a doubt", "Yes definitely", "You may rely on it", "As I see it, yes", " Most likely", "Outlook good", "Yes", "Signs point to yes", "Reply hazy try again", "Ask again later", "Better not tell you now", "Cannot predict now", "Concentrate and ask again", "Don't count on it", "My reply is no", "My sources say no", "Outlook not so good", "Very doubtful"] end |
Instance Method Details
#answer(question) ⇒ Object
generate a answer for any question
Example:
>> obj.answer("Am I dumb?")
=> "My reply is no"
Awguments:
question: (String)
37 38 39 |
# File 'lib/magic8ball/answerator.rb', line 37 def answer(question) question+" => "+@answers[rand(@answers.count)] end |