BarFillerBuilderFunc type adapter
Vladimir Bauer
4 years ago
| 25 | 25 | Build() BarFiller |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | // BarFillerFunc is function type adapter to convert function into BarFiller. | |
| 28 | // BarFillerFunc is function type adapter to convert compatible function | |
| 29 | // into BarFiller interface. | |
| 29 | 30 | type BarFillerFunc func(w io.Writer, reqWidth int, stat decor.Statistics) |
| 30 | 31 | |
| 31 | 32 | func (f BarFillerFunc) Fill(w io.Writer, reqWidth int, stat decor.Statistics) { |
| 32 | 33 | f(w, reqWidth, stat) |
| 33 | 34 | } |
| 34 | 35 | |
| 36 | // BarFillerBuilderFunc is function type adapter to convert compatible | |
| 37 | // function into BarFillerBuilder interface. | |
| 38 | type BarFillerBuilderFunc func() BarFiller | |
| 39 | ||
| 40 | func (f BarFillerBuilderFunc) Build() BarFiller { | |
| 41 | return f() | |
| 42 | } | |
| 43 | ||
| 35 | 44 | // NewBarFiller constructs a BarFiller from provided BarFillerBuilder. |
| 36 | 45 | func NewBarFiller(b BarFillerBuilder) BarFiller { |
| 37 | 46 | return b.Build() |