Class: Scale7Test
Overview
Final Scale7 Test Class
Direct Known Subclasses
Constant Summary
Constants inherited from ScaleTest
Constants inherited from Test
Instance Method Summary collapse
-
#randomize! ⇒ Object
Randomize the answers to a scale test.
-
#set_answer(index, value) ⇒ Object
Set question answer to value.
Methods inherited from ScaleTest
Methods inherited from Test
#answer, #answer=, #answers, #done?, #finished?, #get_question, #initialize, #method_missing, #out_of_index?, #question, #result
Constructor Details
This class inherits a constructor from Test
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Test
Instance Method Details
#randomize! ⇒ Object
Randomize the answers to a scale test
225 226 227 228 229 230 |
# File 'lib/jungi/classes.rb', line 225 def randomize! self.class.const_get(:QUESTIONS).length.times do |num| set_answer(num, rand(1..7)) end nil end |
#set_answer(index, value) ⇒ Object
Set question answer to value
218 219 220 221 222 |
# File 'lib/jungi/classes.rb', line 218 def set_answer(index, value) self.out_of_index? index fail "#{value} is not a scale!" unless Question::Answer.scale7?(value) @answers[index] = value end |