Class: NestedDataStructureAccessQuestion
- Inherits:
-
DataStructureAccessQuestion
- Object
- Question
- DataStructureQuestion
- DataStructureAccessQuestion
- NestedDataStructureAccessQuestion
- Defined in:
- lib/battleroom/models/nested_data_structure_access_question.rb
Instance Attribute Summary collapse
-
#inner_array ⇒ Object
Returns the value of attribute inner_array.
-
#inner_hash ⇒ Object
Returns the value of attribute inner_hash.
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 Attribute Details
#inner_array ⇒ Object
Returns the value of attribute inner_array.
5 6 7 |
# File 'lib/battleroom/models/nested_data_structure_access_question.rb', line 5 def inner_array @inner_array end |
#inner_hash ⇒ Object
Returns the value of attribute inner_hash.
5 6 7 |
# File 'lib/battleroom/models/nested_data_structure_access_question.rb', line 5 def inner_hash @inner_hash end |
Instance Method Details
#post_initialize ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/battleroom/models/nested_data_structure_access_question.rb', line 9 def post_initialize if data_structure.class == Array self.inner_hash = data_structure.sample self.answer_value = inner_hash[inner_hash.keys.sample] else self.answer_value = data_structure[data_structure.keys.sample] end print_data_structure_access_prompt evaluate_data_structure_access_input end |