From: Tim Romberg Date: 2010-09-06T06:12:39+09:00 Subject: A better idiomatic way of doing this?! Hi Im new at Ruby and been struggling with this lab I have for a course Im doing in Ruby. Im working on a program were you can register guests and unregister and so on. What I need to do now is to present a menu through a module which we can cal the main_menu. From there you should be able to navigate to two other menus and back again to the main menu this by user input. Until now Ive managed fine with the user input and displaying a menu, but now as I have three menus but only want the main to show I not really sure how to do this. Hopefully someone can help. I have pasted the code below. Thanks! module Menus class Main_Menu # This is a class method because of the "self" def self.main_menu puts "---------------------------" puts " Menu" puts " 1. Checkin" puts " 2. Checkout" puts " 3. Lists" puts " 4. Economy" puts " 5. Exit" puts "" puts " What do you want to do?" puts "---------------------------" print ": " choice = get_input make_choice(choice) end # fetches the menu choice and returns the chosen one def self.get_input input = gets.chomp.to_i while input > 5 || input < 1 do puts "Ooups wrong, please try again :)." input = gets.chomp.to_i end return input end def self.make_choice(choice) # chooses something from the menu based on the choice case choice when 1: check_in when 2: check_out when 3: puts $camping.current_guests when 4: puts $camping.all_guests when 5: puts "You are now leaving the camping, welcome back!" exit end end end end class Main_Menu include Menus Main_Menu.main_menu end -- Posted via http://www.ruby-forum.com/.