Last active
August 29, 2015 14:00
-
-
Save ramalho/11179819 to your computer and use it in GitHub Desktop.
Value object for Pingo.io pin states
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 State(object): | |
| def __init__(self, value): | |
| self.value = value | |
| def __repr__(self): | |
| return '%s(%r)' % (self.__class__.__name__, self.value) | |
| def __str__(self): | |
| return state.value | |
| def __bool__(self): | |
| return self.value == 'HIGH' | |
| __int__ = __bool__ | |
| HIGH = PinState('HIGH') | |
| LOW = PinState('LOW') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment