Module: Robut::Plugin::Quiz::Question
Constant Summary collapse
- GROUP_REGEX =
This regex will find all the questions and parameters specified with the question
/['"]([^'"]+)['"]/
Instance Method Summary collapse
-
#ask ⇒ String
Ask the question that has been proposed.
-
#captured_results ⇒ Hash
Maintains a list of the results that have been captured for the question.
-
#initialize(sender, question_with_parameters) ⇒ Object
Initialize the question with the asker of the question and the details about question that is being asked.
-
#process_question(question_with_parameters) ⇒ Object
This is used internally to process the the question and parameters that sent to the question.
-
#to_s ⇒ String
The question that is being asked.
Instance Method Details
#ask ⇒ String
Ask the question that has been proposed.
49 50 51 |
# File 'lib/question.rb', line 49 def ask "@all Question '#{@question}'" end |
#captured_results ⇒ Hash
Maintains a list of the results that have been captured for the question. The hash that is maintained would be used with the user’s nickname as the key and the value as a response to the question.
60 61 62 |
# File 'lib/question.rb', line 60 def captured_results @captured_results ||= {} end |
#initialize(sender, question_with_parameters) ⇒ Object
Initialize the question with the asker of the question and the details about question that is being asked.
16 17 18 19 |
# File 'lib/question.rb', line 16 def initialize(sender,question_with_parameters) @sender = sender process_question(question_with_parameters) end |
#process_question(question_with_parameters) ⇒ Object
This is used internally to process the the question and parameters that sent to the question.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/question.rb', line 28 def process_question(question_with_parameters) parsed_elements = question_with_parameters.scan(GROUP_REGEX) @question = parsed_elements.first.first # After the target, question type, question, and answer length has been determined # look at all the single quoted items to find the list of parameters if there are any @parameters = Array(parsed_elements[1..-1].flatten) end |
#to_s ⇒ String
Returns the question that is being asked.
41 42 43 |
# File 'lib/question.rb', line 41 def to_s @question end |