Any decorator
Vladimir Bauer
6 years ago
| 0 | package decor | |
| 1 | ||
| 2 | // Any decorator displays text, that can be changed during decorator's | |
| 3 | // lifetime via provided func call back. | |
| 4 | // | |
| 5 | // `f` call back which provides string to display | |
| 6 | // | |
| 7 | // `wcc` optional WC config | |
| 8 | // | |
| 9 | func Any(f func(*Statistics) string, wcc ...WC) Decorator { | |
| 10 | return &any{initWC(wcc...), f} | |
| 11 | } | |
| 12 | ||
| 13 | type any struct { | |
| 14 | WC | |
| 15 | f func(*Statistics) string | |
| 16 | } | |
| 17 | ||
| 18 | func (d *any) Decor(s *Statistics) string { | |
| 19 | return d.FormatMsg(d.f(s)) | |
| 20 | } |