diff options
author | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-05-31 00:32:29 -0300 |
---|---|---|
committer | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-05-31 00:32:29 -0300 |
commit | b6bc845d06544a94f4466110b7e97d3ab1fb8ad9 (patch) | |
tree | c5927d556288001c109886b502a182aec9fc1d91 | |
parent | de934b4ee1109277a8c5e7b97d59c14ac4240c44 (diff) | |
download | highline-b6bc845d06544a94f4466110b7e97d3ab1fb8ad9.tar.gz |
Add Question#get_response_or_default and simplify HighLine#ask_once
-rwxr-xr-x | lib/highline.rb | 2 | ||||
-rwxr-xr-x | lib/highline/question.rb | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/highline.rb b/lib/highline.rb index e6fd95a..8cdb7f9 100755 --- a/lib/highline.rb +++ b/lib/highline.rb @@ -530,7 +530,7 @@ class HighLine say(question) unless ((question.readline) and (question.echo == true and question.limit.nil?)) begin - question.answer = question.answer_or_default(question.get_response(self)) + question.answer = question.get_response_or_default(self) raise NotValidQuestionError unless question.valid_answer?(question.answer) question.answer = question.convert(question.answer) diff --git a/lib/highline/question.rb b/lib/highline/question.rb index 673d139..4d1069e 100755 --- a/lib/highline/question.rb +++ b/lib/highline/question.rb @@ -485,6 +485,10 @@ class HighLine end end + def get_response_or_default(highline) + answer_or_default(get_response(highline)) + end + def ask_at(highline) return highline.gather(self) if gather return highline.ask_once(self) |