Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Eliminando

  • Loading branch information...
commit 60980ec8f8814494f2bdc35152e6f57573a20afe 1 parent b2cb558
@marcoskata marcoskata authored
Showing with 0 additions and 40 deletions.
  1. +0 −40 HAML-ERB/rpsCAS.rb
View
40 HAML-ERB/rpsCAS.rb
@@ -1,40 +0,0 @@
-require 'sinatra'
-require 'erb'
-
-before do
- @defeat = { rock: :scissors, paper: :rock, scissors: :paper}
- @throws = @defeat.keys
-end
-
-get '/throw/:type' do
- # the params hash stores querystring and form data
- @player_throw = params[:type].to_sym
-
- halt(403, "You must throw one of the following: '#{@throws.join(', ')}'") unless @throws.include? @player_throw
-
- @computer_throw = @throws.sample
-
- if @player_throw == @computer_throw
- @answer = "There is a tie"
- erb :index
- elsif @player_throw == @defeat[@computer_throw]
- @answer = "Computer wins; #{@computer_throw} defeats #{@player_throw}"
- erb :index
- else
- @answer = "Well done. #{@player_throw} beats #{@computer_throw}"
- erb :index
- end
-end
-__END__
-
-@@index
-<html>
-<head>
-<title>Rock Paper Scissors</title>
-</head>
-<body>
-<h2> Computer chooses: <%= @computer_throw %> </h2>
-<h2> You choose: <%= @player_throw %> </h2>
-<h1> <%= @answer %> </h1>
-</body>
-</html>
Please sign in to comment.
Something went wrong with that request. Please try again.