diff options
author | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-06-06 02:08:17 -0300 |
---|---|---|
committer | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-06-06 02:08:17 -0300 |
commit | 6c03788b0aaa7afe5016302fb7c9dc9ca47cae3a (patch) | |
tree | 33aeda57864402a5f7731f912f4c6e9161837e7e | |
parent | 714643db83097f426346df63230bfb1500e93678 (diff) | |
download | highline-6c03788b0aaa7afe5016302fb7c9dc9ca47cae3a.tar.gz |
Unify Array and Proc AnswerConverter convertions
-rw-r--r-- | lib/highline/question/answer_converter.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/highline/question/answer_converter.rb b/lib/highline/question/answer_converter.rb index 0aa81c8..3f73f9f 100644 --- a/lib/highline/question/answer_converter.rb +++ b/lib/highline/question/answer_converter.rb @@ -25,11 +25,8 @@ class HighLine answer_type.parse(answer) elsif answer_type.is_a? Class send(answer_type.name) - elsif answer_type.is_a?(Array) - self.answer = choices_complete(answer) - answer.last - elsif answer_type.is_a?(Proc) - answer_type.call(answer) + else + send(answer_type.class.name) end check_range @@ -72,6 +69,15 @@ class HighLine self.answer = choices_complete(answer) Pathname.new(File.join(directory.to_s, answer.last)) end + + def Array + self.answer = choices_complete(answer) + answer.last + end + + def Proc + answer_type.call(answer) + end end end end
\ No newline at end of file |