Last active
December 21, 2015 22:28
-
-
Save svs/6375246 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Assuming your execute command is more complex than a simple puts, | |
# you will need separate classes | |
class GoodbyeCommand | |
def execute | |
# complex logic here | |
end | |
end | |
class TwitterCommand | |
def execute | |
# complex logic here | |
end | |
end | |
def process(input) | |
begin | |
"#{input.camelize}Command".constantize.new.execute | |
rescue NameError | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment