Created
April 10, 2019 20:15
-
-
Save Sean-Bradley/c4a07f530d050106959c0e9f74ecd56f 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
class Switch: | |
"""The Invoker Class""" | |
def __init__(self): | |
self._commands = {} | |
self._history = [] | |
@property | |
def history(self): | |
return self._history | |
def register(self, command_name, command): | |
self._commands[command_name] = command | |
def execute(self, command_name): | |
if command_name in self._commands.keys(): | |
self._history.append((time.time(), command_name)) | |
self._commands[command_name].execute() | |
else: | |
print(f"Command [{command_name}] not recognised") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment