lib/interactive/question.rb in interactive-0.1.0 vs lib/interactive/question.rb in interactive-0.2.0

- old
+ new

@@ -7,20 +7,15 @@ @options = Interactive::Options.new(Array(@options)) raise ArgumentError, "question cannot be nil nor empty." if question.nil? || question.empty? raise ArgumentError, "options cannot be empty." if options.empty? + + @question_type = @options.has_hash? ? QuestionWithEagerFullExplanation.new(self) : QuestionWithLazyFullExplanation.new(self) end def ask_and_wait_for_valid_response(&block) - loop do - puts "#{question} #{options.shortcuts_string}" - resp = Interactive::Response.new(options) - puts options.shortcuts_meanings if resp.invalid? - - yield resp - break unless resp.invalid? - end + @question_type.ask_and_wait_for_valid_response(&block) end private def response