Class: Scale7Test

Inherits:
ScaleTest show all
Defined in:
lib/jungi/classes.rb

Overview

Final Scale7 Test Class

Direct Known Subclasses

SOC3Test

Constant Summary

Constants inherited from ScaleTest

ScaleTest::QUESTIONS

Constants inherited from Test

Test::QUESTIONS

Instance Method Summary collapse

Methods inherited from ScaleTest

#result

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