| Total Complexity | 5 |
| Total Lines | 19 |
| Duplicated Lines | 0 % |
| 1 | # -*- coding: utf-8 -*- |
||
| 42 | class Timer(object): |
||
| 43 | |||
| 44 | """The timer class. A simple chronometer.""" |
||
| 45 | |||
| 46 | def __init__(self, duration): |
||
| 47 | self.duration = duration |
||
| 48 | self.start() |
||
| 49 | |||
| 50 | def start(self): |
||
| 51 | self.target = time() + self.duration |
||
| 52 | |||
| 53 | def reset(self): |
||
| 54 | self.start() |
||
| 55 | |||
| 56 | def set(self, duration): |
||
| 57 | self.duration = duration |
||
| 58 | |||
| 59 | def finished(self): |
||
| 60 | return time() > self.target |
||
| 61 |