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
-
#initialize(eval_scope) ⇒ NestedDataStructureAccessQuestion
constructor
A new instance of NestedDataStructureAccessQuestion.
Methods inherited from DataStructureAccessQuestion
#evaluate_data_structure_access_input, #print_data_structure_access_prompt
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
Constructor Details
#initialize(eval_scope) ⇒ NestedDataStructureAccessQuestion
Returns a new instance of NestedDataStructureAccessQuestion.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/battleroom/models/nested_data_structure_access_question.rb', line 9 def initialize(eval_scope) super(eval_scope) 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 |
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 |