glob/match/any_of.go

32 lines
432 B
Go
Raw Normal View History

2016-01-08 20:14:31 +03:00
package match
import (
"fmt"
)
type AnyOf struct {
Matchers Matchers
}
func (self *AnyOf) Add(m Matcher) {
self.Matchers = append(self.Matchers, m)
}
func (self AnyOf) Match(s string) bool {
for _, m := range self.Matchers {
if m.Match(s) {
return true
}
}
return false
}
func (self AnyOf) Kind() Kind {
return KindAnyOf
}
func (self AnyOf) String() string {
return fmt.Sprintf("[any_of:%s]", self.Matchers)
}