Class: Interactive::Question
- Inherits:
-
Object
- Object
- Interactive::Question
- Defined in:
- lib/interactive/question.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#question ⇒ Object
Returns the value of attribute question.
Instance Method Summary collapse
- #ask(&block) ⇒ Object
- #ask_and_wait_for_valid_response(&block) ⇒ Object
-
#initialize {|_self| ... } ⇒ Question
constructor
A new instance of Question.
Constructor Details
#initialize {|_self| ... } ⇒ Question
Returns a new instance of Question.
5 6 7 8 9 10 11 12 |
# File 'lib/interactive/question.rb', line 5 def initialize(&block) yield self @options = Interactive::Options(Array(@options)) raise ArgumentError, "question cannot be nil nor empty." if question.nil? || question.empty? @question_type = @options.has_hash? ? QuestionWithEagerFullExplanation.new(self) : QuestionWithLazyFullExplanation.new(self) end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/interactive/question.rb', line 3 def @options end |
#question ⇒ Object
Returns the value of attribute question.
3 4 5 |
# File 'lib/interactive/question.rb', line 3 def question @question end |
Instance Method Details
#ask(&block) ⇒ Object
18 19 20 |
# File 'lib/interactive/question.rb', line 18 def ask(&block) ask_and_wait_for_valid_response(&block) end |
#ask_and_wait_for_valid_response(&block) ⇒ Object
14 15 16 |
# File 'lib/interactive/question.rb', line 14 def ask_and_wait_for_valid_response(&block) @question_type.ask_and_wait_for_valid_response(&block) end |