Class: CategoryTextKeyGenerator
- Inherits:
-
Object
- Object
- CategoryTextKeyGenerator
- Includes:
- GenerateAnswerKey
- Defined in:
- lib/category_text_key_generator.rb
Overview
Generate a key with location of the correct answer based length of the category text
Class Method Summary collapse
-
.decrypt_answer_key(question) ⇒ integer
Decrypt answer key.
-
.update_answer_key(question) ⇒ hash
Encrypt answer_key.
Methods included from GenerateAnswerKey
get_random_key, get_random_phrase, get_random_word
Class Method Details
.decrypt_answer_key(question) ⇒ integer
Decrypt answer key
34 35 36 37 |
# File 'lib/category_text_key_generator.rb', line 34 def self.decrypt_answer_key(question) location = question[:category].length % 10 question[:answer_key][location].to_i end |
.update_answer_key(question) ⇒ hash
Encrypt answer_key
18 19 20 21 22 23 24 25 |
# File 'lib/category_text_key_generator.rb', line 18 def self.update_answer_key(question) correct_answer = question[:answer_key].to_s location = question[:category].length % 10 answer_key = GenerateAnswerKey.get_random_key(location) + correct_answer + GenerateAnswerKey.get_random_key(9 - location) question[:answer_key] = answer_key end |