mirror of https://github.com/gobwas/glob.git
Adds every_of.go
This commit is contained in:
parent
91cccc29e4
commit
62800bb501
|
@ -0,0 +1,28 @@
|
|||
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
|
||||
}
|
Loading…
Reference in New Issue