Skip to content

Instantly share code, notes, and snippets.

@burtlo
Created May 9, 2012 03:19
Show Gist options
  • Save burtlo/2641529 to your computer and use it in GitHub Desktop.
Save burtlo/2641529 to your computer and use it in GitHub Desktop.
modules
module BeginState
def add_player
# really add the player
end
def add_ship
# really do it
end
def shoot
puts "You cannot shoot while we are setting up"
end
end
module PlayingState
def add_player
puts "You cannot add a player now that the game has started"
end
def add_ship
puts "Stop Cheating!"
end
def shoot
# actually do the shoot method
end
end
module EndGameState
def announce_game_is_over
puts "Start a new game"
end
alias_method :add_player, :announce_game_is_over
alias_method :add_ship, :announce_game_is_over
alias_method :shoot, :announce_game_is_over
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment