glob/every_of.go

29 lines
568 B
Go
Raw Normal View History

2016-05-06 00:40:31 +03:00
package glob
// EveryOf represents a collection of globs
type EveryOf struct {
Globs Globs
}
// NewEveryOf returns a new EveryOf from a list of globs
func NewEveryOf(g ...Glob) EveryOf {
return EveryOf{Globs(g)}
}
// Add adds a glob to the EveryOf collection
func (a *EveryOf) Add(g Glob) {
a.Globs = append(a.Globs, g)
}
// Match checks every glob until one doesn't matches returning false.
// If every glob matches it returns true.
func (a EveryOf) Match(s string) bool {
for _, m := range a.Globs {
if !m.Match(s) {
return false
}
}
return true
}