diff options
author | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-05-31 00:58:34 -0300 |
---|---|---|
committer | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-05-31 00:58:34 -0300 |
commit | dd406657ead08e38d496107a704547dc8086fd0d (patch) | |
tree | 0618b8ed9659ef0da9f666dde54a01902e97fa05 | |
parent | 5130d68b729d90e90c8d70d8a7faac0d9c60c409 (diff) | |
download | highline-dd406657ead08e38d496107a704547dc8086fd0d.tar.gz |
Set Question#answer on Question#get_response_or_default and #convert. Simplify assignments on HighLine#ask_once
-rwxr-xr-x | lib/highline.rb | 4 | ||||
-rwxr-xr-x | lib/highline/question.rb | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/highline.rb b/lib/highline.rb index 784a93b..65845e1 100755 --- a/lib/highline.rb +++ b/lib/highline.rb @@ -530,10 +530,10 @@ class HighLine say(question) unless ((question.readline) and (question.echo == true and question.limit.nil?)) begin - question.answer = question.get_response_or_default(self) + question.get_response_or_default(self) raise NotValidQuestionError unless question.valid_answer? - question.answer = question.convert + question.convert if question.in_range? if question.confirm diff --git a/lib/highline/question.rb b/lib/highline/question.rb index 96f2df8..c03fb5c 100755 --- a/lib/highline/question.rb +++ b/lib/highline/question.rb @@ -312,8 +312,9 @@ class HighLine # completed for any reason. # def convert - return answer unless @answer_type + return unless @answer_type + self.answer = if [::String, HighLine::String].include?(@answer_type) HighLine::String(answer) elsif [Float, Integer, String].include?(@answer_type) @@ -486,7 +487,7 @@ class HighLine end def get_response_or_default(highline) - answer_or_default(get_response(highline)) + self.answer = answer_or_default(get_response(highline)) end def ask_at(highline) |