1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-24 03:54:20 +00:00
royalnet/dirty.py

24 lines
523 B
Python
Raw Normal View History

2018-12-18 16:34:34 +00:00
class Dirty:
def __init__(self, initial_value):
self.initial_value = initial_value
self.value = initial_value
def is_clean(self):
return self.initial_value == self.value
def is_dirty(self):
return not self.is_clean()
def __bool__(self):
return self.is_dirty()
2019-01-23 14:00:30 +00:00
class DirtyDelta(Dirty):
@property
def delta(self):
return self.value - self.initial_value
@delta.setter
def delta(self, value):
self.value = self.initial_value + value