title: Ruby parsing arguments of current URI
body: <p>I'm using ruby to generate CGI (not on rails).</p>
  
  <p>I want to parse arguments for a script running locally (with requests like <code>localhost:3000/apage.cgi?key=value</code>) in the same way I would do <code>ARGV[0]</code> for command line arguments.</p>
  
  <p>When I try: <code>params = CGI.parse(request.query_string)</code>, I get `"undefined local variable or method request'".</p>
  
  <p>EDIT: Here's the code. That's why I didn't put it in the first place :)</p>
  
  <pre><code>#!/usr/bin/env ruby
  require 'cgi'
  print "Content-type: text/plain\n\n"
  #print CGI.parse(URI.parse(request.fullpath).query)
  </code></pre>