Skip to content

Instantly share code, notes, and snippets.

@alexonozor
Created April 22, 2018 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexonozor/1679f9d9f0d6243cee440e25ad833980 to your computer and use it in GitHub Desktop.
Save alexonozor/1679f9d9f0d6243cee440e25ad833980 to your computer and use it in GitHub Desktop.
Code snippet from my ruby hangman gem.
def menu
option_choice = get_input('')
case option_choice
when "1"
menu_start_game
when "2"
load
when "3"
menu_instruction
when "4", "X", "x", "Q", "q", :quit
@display.conclusion
else
menu_invalid_entry
end
end
def menu_start_game
@status = :game_started
game_method
end
def menu_instruction
send_message(@display.instruction)
start_menu
end
def menu_invalid_entry
send_message "Invalid entry, retry"
sleep 1
menu
end
def game_method
until @model.game_complete
select = get_input(@display.game_warning).downcase
break if this_is_a_control_method(select)
break if this_is_the_complete_secret(select)
check_selection(select)
end
you_have_exhausted_all_your_chances if @model.chances == 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment