| 1 |
package main |
| 2 |
|
| 3 |
import "fmt" |
| 4 |
|
| 5 |
|
| 6 |
type Filter interface { |
| 7 |
Bounds(srcBounds string) (dstBounds string) |
| 8 |
} |
| 9 |
|
| 10 |
|
| 11 |
type GIFT struct { |
| 12 |
Filters []Filter |
| 13 |
} |
| 14 |
|
| 15 |
|
| 16 |
func New(filters ...Filter) *GIFT { |
| 17 |
return &GIFT{ |
| 18 |
Filters: filters, |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
func (g *GIFT) Bounds(srcBounds string) (dstBounds string) { |
| 24 |
dstBounds = srcBounds |
| 25 |
for _, f := range g.Filters { |
| 26 |
dstBounds = f.Bounds(dstBounds) |
| 27 |
} |
| 28 |
return dstBounds |
| 29 |
} |
| 30 |
|
| 31 |
func main() { |
| 32 |
var filters []Filter |
| 33 |
bounds := "foo" |
| 34 |
g := New(filters...) |
| 35 |
fmt.Println(g.Bounds(bounds)) |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|