Created
December 1, 2010 05:37
-
-
Save helino/723020 to your computer and use it in GitHub Desktop.
My first class when learning Ruby...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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