Class: Mathy::Verification
- Inherits:
-
Object
- Object
- Mathy::Verification
- Defined in:
- lib/mathy/verification.rb
Instance Method Summary collapse
- #check_answer(question, correct_answer) ⇒ Object
-
#initialize(console) ⇒ Verification
constructor
A new instance of Verification.
Constructor Details
#initialize(console) ⇒ Verification
Returns a new instance of Verification.
3 4 5 |
# File 'lib/mathy/verification.rb', line 3 def initialize(console) @console = console end |
Instance Method Details
#check_answer(question, correct_answer) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/mathy/verification.rb', line 7 def check_answer(question, correct_answer) @console.report "" @console.report question answer = gets if answer.to_i == correct_answer @console.report "Correct!" return true end @console.report "The correct answer is #{correct_answer}." false end |