- Create a route in Sinatra using a parameter
- Use a before filter
- Validate parameters and respond appropriately
http://www.sinatrarb.com/intro.html#Routes
- Create a folder called
rock_paper_scissor
- Create a file called
game.rb
- In this file, require Sinatra
- Create a
Game
module to wrap your app in. - Inside the
Game
module, create aRPS_App
class that extendsSinatra::Application
- Create a file called
config.ru
- Inside
config.ru
require game - Then call a run to your app (don't forget that it is wrapped in a module!)
Our app will be played at the path /throw
. To play, a user will hit /throw/:type
, for example: /throw/rock
will play rock.
- Define a route at
/throw
that responds to a get request and takes a single parameter called:type
- This route should randomly generate a move by the computer.
- The computer move and user move should be compared.
- The results of the match should be displayed on the page.
- Create an error if the user tries to throw an incorrect move.
- Extend the game to include a new move, see RPS Variations.
- Creating a landing page with links, so one does not need to edit the URL in the browser.
- Make it look pretty!