From 127db38021e15f8ce9e095bea1a4b917c44f0a8a Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 11 Jan 2015 22:14:48 -0500 Subject: d: utils_response, ease selection options --- lib/sisu/develop/utils_response.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/sisu/develop/utils_response.rb b/lib/sisu/develop/utils_response.rb index 31092bed..4603646e 100644 --- a/lib/sisu/develop/utils_response.rb +++ b/lib/sisu/develop/utils_response.rb @@ -56,17 +56,20 @@ =end module SiSU_Response class Response - def response?(ask) #move to more appropriate directory later + def available_selections_ + %{'yes', 'no', 'quit' or 'exit'; [ynqx]} + end + def response?(ask) response='redo' - print ask + " ['yes', 'no' or 'quit']: " + print ask + %{ [#{available_selections_}]: } response=File.new('/dev/tty').gets.strip - ans=if response=='yes' then true - elsif response=='no' then false - elsif response =~/^quit|exit$/ then exit - else puts "[please type: 'yes', 'no' or 'quit']" + case response + when /^(?:y|yes)$/ then true + when /^(?:n|no)$/ then false + when /^(?:[qx]|quit|exit)$/ then exit + else puts %{[please type: #{available_selections_}]} response?(ask) end - ans end end end -- cgit v1.2.3