diff options
author | Abinoam P. Marques Jr <abinoam@gmail.com> | 2017-11-04 23:24:32 -0300 |
---|---|---|
committer | Abinoam P. Marques Jr <abinoam@gmail.com> | 2017-11-05 11:26:00 -0300 |
commit | 81d9ee76bd326069142a36dc8216594e47659963 (patch) | |
tree | d1bca6601cfef62a94ccdc9a4bd38bb59c8225f8 /lib/highline | |
parent | b799c5858c99bad7ae8d3c3070acf036848be0ba (diff) | |
download | highline-81d9ee76bd326069142a36dc8216594e47659963.tar.gz |
Implement proc or string for error
Diffstat (limited to 'lib/highline')
-rw-r--r-- | lib/highline/question_asker.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/highline/question_asker.rb b/lib/highline/question_asker.rb index cb8dfa8..52f4959 100644 --- a/lib/highline/question_asker.rb +++ b/lib/highline/question_asker.rb @@ -115,10 +115,15 @@ class HighLine ## Delegate to Highline def explain_error(error) - @highline.say(question.final_responses[error]) if error + @highline.say(error_final_response(error)) if error @highline.say(question.ask_on_error_msg) end + def error_final_response(error) + final_response = question.final_responses[error] + final_response.call(question.answer) rescue final_response + end + def gather_with_array [].tap do |answers| answers << ask_once |