From: Ruby Student Date: 2009-02-20T05:24:13+09:00 Subject: Re: ASCII Menu in Ruby, is it possible? --0016368e1c0db46ecb04634b3cc6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On Thu, Feb 19, 2009 at 3:04 PM, Justin Collins wrote: > Ruby Student wrote: > >> Hello Team, >> >> Is there a way in Ruby to create primitive ASCII menus? >> At this point I am shying away from GUI as everything outthere, in the GUI >> world is too.... >> I just want to know if I can create simple menus of the type: >> >> 1 - Enter 1 and press Enter to continue >> 2 - Enter 2 or X and press Enter to exit >> 3 - Etc. >> >> Thank you >> >> >> > Sure you can. > > For example: > > def menu > loop do > puts "1. Do something", "2. Do something else", "3. Nevermind" > > input = gets.strip > > case input > when "1" > puts "Did something" > when "2" > puts "Did something else" > when "3" > puts "Bye!" > return else puts "Invalid option: #{input}" > end end > end > > menu > > -Justin > > Dear Jason, YES, I did first performed a google search, which is this: "ruby" "menu" "ASCII menu" and the above gave me this: http://www.google.com/search?hl=en&q=%22ruby%22+%22menu%22+%22ASCII+menu%22&start=30&sa=N As a routine, I religiously perform first a good search. I also traverse the gems repository. Then I come to the forum. That been said, I appreciate your answer and justin answer. I truly appreciate your help. It was far from my mind using gets to perform this task. Again, thank you! -- Ruby Student --0016368e1c0db46ecb04634b3cc6--