glob/match/raw.go

39 lines
534 B
Go
Raw Normal View History

2015-12-24 17:54:54 +03:00
package match
import (
"fmt"
2016-01-08 20:14:31 +03:00
"strings"
2015-12-24 17:54:54 +03:00
)
// raw represents raw string to match
type Raw struct {
Str string
}
func (self Raw) Match(s string) bool {
return self.Str == s
}
2016-01-09 02:34:41 +03:00
func (self Raw) Len() int {
return len(self.Str)
}
2015-12-24 17:54:54 +03:00
func (self Raw) Kind() Kind {
return KindRaw
}
2016-01-09 02:34:41 +03:00
func (self Raw) Index(s string) (index int, segments []int) {
2016-01-08 20:14:31 +03:00
index = strings.Index(s, self.Str)
2015-12-24 17:54:54 +03:00
if index == -1 {
return
}
2016-01-09 02:34:41 +03:00
segments = []int{len(self.Str)}
2015-12-24 17:54:54 +03:00
return
}
func (self Raw) String() string {
2016-01-11 10:17:19 +03:00
return fmt.Sprintf("<raw:%s>", self.Str)
2015-12-24 17:54:54 +03:00
}