lib/interactive/question.rb in interactive-0.5.0 vs lib/interactive/question.rb in interactive-0.6.0
- old
+ new
@@ -1,19 +1,23 @@
require 'forwardable'
module Interactive
class Question
extend Forwardable
- attr_accessor :question, :options
+ attr_accessor :question, :options, :columns
def_delegators :@question_type, :reask!
def initialize(&block)
yield self
- @options = Interactive::Options(Array(@options))
+ @options = Interactive::Options(Array(@options), @columns)
raise ArgumentError, "question cannot be nil nor empty." if question.nil? || question.empty?
- @question_type = @options.has_hash? ? QuestionWithEagerFullExplanation.new(self) : QuestionWithLazyFullExplanation.new(self)
+ if @columns || @options.has_hash?
+ @question_type = QuestionWithEagerFullExplanation.new(self)
+ else
+ @question_type = QuestionWithLazyFullExplanation.new(self)
+ end
end
def ask_and_wait_for_valid_response(&block)
@question_type.ask_and_wait_for_valid_response(&block)
end