Class: ArrayAccessQuestion
- Inherits:
-
DataStructureAccessQuestion
- Object
- Question
- DataStructureQuestion
- DataStructureAccessQuestion
- ArrayAccessQuestion
- Defined in:
- lib/battleroom/models/array_access_question.rb
Instance Attribute Summary
Attributes inherited from DataStructureQuestion
#data_structure, #hint, #possible_assignments
Attributes inherited from Question
#answer_value, #data, #data_structure, #data_structure_class, #evaluation_scope, #explanation, #input_mechanism, #user_input, #variable_name, #variable_value
Instance Method Summary collapse
Methods inherited from DataStructureAccessQuestion
#eval_returns_the_correct_value?, #evaluate_data_structure_access_input, #generate_readable_single_line_hash, #print_data_structure_access_prompt, #print_data_structure_on_single_line, #provide_evaluation_scope_with_variable_assignment_necessary_for_answer_eval, #user_input_uses_variable?
Methods inherited from DataStructureQuestion
#convert_keys_to_strings, #cull_hash_to_valid_size_for_output, #find_number_of_boolean_values_in_hash
Methods inherited from Question
#congratulation_sequence, #enter_evaluation_loop, generate_question, #get_input, #handle_syntax_error_exceptions, #initialize
Constructor Details
This class inherits a constructor from Question
Instance Method Details
#format_array_for_access ⇒ Object
15 16 17 18 19 |
# File 'lib/battleroom/models/array_access_question.rb', line 15 def format_array_for_access self.data_structure = data_structure[0, rand(4..6)] self.answer_value = data_structure.sample self.hint = 'index values start at 0.' end |
#post_initialize ⇒ Object
8 9 10 11 12 13 |
# File 'lib/battleroom/models/array_access_question.rb', line 8 def post_initialize super format_array_for_access print_data_structure_access_prompt evaluate_data_structure_access_input end |