Skip to content

Instantly share code, notes, and snippets.

@svs
Last active December 21, 2015 22:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save svs/6375246 to your computer and use it in GitHub Desktop.
# 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