aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/current/utils_response.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2015-04-19 14:44:38 -0400
committerRalph Amissah <ralph@amissah.com>2015-05-01 18:49:40 -0400
commit1323f18af45ea0d3aaef5cd9ead0efb5de8b9729 (patch)
treee1abd6d04547c269666f276d8bdb24afa9d7dfee /lib/sisu/current/utils_response.rb
parentsetup.rb s/Config/RbConfig/ (diff)
c<-d: sync, roll develop into current dir branch (5==6)
* two dir branches, same library contents (v5 synced & updated with v6)
Diffstat (limited to 'lib/sisu/current/utils_response.rb')
-rw-r--r--lib/sisu/current/utils_response.rb25
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/sisu/current/utils_response.rb b/lib/sisu/current/utils_response.rb
index c47fab2e..2343dad6 100644
--- a/lib/sisu/current/utils_response.rb
+++ b/lib/sisu/current/utils_response.rb
@@ -55,18 +55,19 @@
=end
module SiSU_Response
- class Response
- def response?(ask) #move to more appropriate directory later
- response='redo'
- print ask + " ['yes', 'no' or 'quit']: "
- 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']"
- response?(ask)
- end
- ans
+ def available_selections_
+ %{'yes', 'no', 'quit' or 'exit'; [ynqx]}
+ end
+ def response?(ask)
+ response='redo'
+ print ask + %{ [#{available_selections_}]: }
+ response=File.new('/dev/tty').gets.strip
+ 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
end
def query