Skip to content

Instantly share code, notes, and snippets.

@helino
Created December 1, 2010 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save helino/723020 to your computer and use it in GitHub Desktop.
Save helino/723020 to your computer and use it in GitHub Desktop.
My first class when learning Ruby...
class Router
def initialize
@routes = {}
end
def get(str, &block)
@routes[str] = block
end
def handle(req)
if not @routes.has_key? req
raise ArgumentError
else
@routes[req].call
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment