Skip to content

Instantly share code, notes, and snippets.

@postazure
Last active August 29, 2015 14:09
Show Gist options
  • Save postazure/af4968d341fc75e694be to your computer and use it in GitHub Desktop.
Save postazure/af4968d341fc75e694be to your computer and use it in GitHub Desktop.
Constructs a Menu from a Hash
def menu menu_name = :project_menu
@menu_level = {project_menu: "_p", task_menu: "_t"}[menu_name]
while true
print_menu(@instructions[menu_name])
user_input = get_input
break if user_input == "quit"
method = "#{user_input}#{@menu_level}"
@actions[method].call if @actions.include?(method)
end
end
def print_menu instructions
instructions.each do |option|
puts option + "\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment