Skip to content

Instantly share code, notes, and snippets.

@georgeredinger
Created August 15, 2010 07:39
Show Gist options
  • Save georgeredinger/525219 to your computer and use it in GitHub Desktop.
Save georgeredinger/525219 to your computer and use it in GitHub Desktop.
def the_winner_is(env)
candidates_list = env["QUERY_STRING"].to_s.split(",")
winner=candidates_list[rand(candidates_list.size)]
page = <<-TEXT
<h3>Usage: http://picklejar-rack.heroku.com?name,name,name...,name</h1> <br>
<h1>The Winner is: #{winner}</h1>
Chosen at random from <br>
<ol>
TEXT
candidates_list.each {|c| page += "<li> #{c} </li>"}
page += "</ol>"
TEXT
[200, {'Content-Type'=>'text/html'}, page]
end
run method(:the_winner_is)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment