Skip to content

Instantly share code, notes, and snippets.

@ahmad19
Last active July 8, 2020 13:06
Show Gist options
  • Save ahmad19/a2cddf3f7e6c16b078784a41721a3ca3 to your computer and use it in GitHub Desktop.
Save ahmad19/a2cddf3f7e6c16b078784a41721a3ca3 to your computer and use it in GitHub Desktop.
Sample code for displaying a menu terminal using ruby
def menu
puts 'List your options below: \n
1. first option \n
2. second option \n
3. Exit'
end
loop do
menu
option = gets.chomp
case option
when '1'
puts "Do first option"
when '2'
puts 'Another question?'
input = gets.chomp
puts "Do as input says"
when '3'
break
else
puts 'Invalid command'
puts 'Exiting..'
break
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment