Class: Quiz
Instance Method Summary collapse
- #add_question(question) ⇒ Object
-
#initialize ⇒ Quiz
constructor
A new instance of Quiz.
- #last_question ⇒ Object
- #run_quiz ⇒ Object
Constructor Details
#initialize ⇒ Quiz
Returns a new instance of Quiz.
9 10 11 |
# File 'lib/depscale.rb', line 9 def initialize @questions = [] end |
Instance Method Details
#add_question(question) ⇒ Object
13 14 15 |
# File 'lib/depscale.rb', line 13 def add_question(question) @questions << question end |
#last_question ⇒ Object
17 18 19 |
# File 'lib/depscale.rb', line 17 def last_question @questions.last end |
#run_quiz ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/depscale.rb', line 21 def run_quiz count=0 @questions.each { |q| count += 1 if q.ask } puts "You got a score of #{count} \n" case count when 1..5 puts "You are in good mood , there is no evidence of depression" when 6..10 puts "Your answers are suggestive of depression \n There is a need for more assessment" when 11..20 puts "Your answers are indicative of depression, you need to seek psychiatric consultation" end end |