lib/logirel/q_model.rb in logirel-0.0.14 vs lib/logirel/q_model.rb in logirel-0.0.15
- old
+ new
@@ -50,12 +50,14 @@
@answer.empty? ? @default : @answer
end
def exec
@io_target.print @question + " [#{@default}]: "
+ valid = false
begin
@answer = @io_source.gets.chomp
- end while !@answer.empty? && !@validator.call(@answer)
+ valid = @validator.call(@answer)
+ end while !valid || (!valid && @answer.empty?)
@answer = @answer.empty? ? @default : @answer
@io_target.puts "Chose '#{@answer}'."
@answer
end
end
\ No newline at end of file