2020-01-07 16:36:49 +00:00
|
|
|
package txt
|
2019-05-16 06:41:16 +00:00
|
|
|
|
|
|
|
import (
|
2019-06-13 18:26:01 +00:00
|
|
|
"strings"
|
2019-05-16 06:41:16 +00:00
|
|
|
)
|
|
|
|
|
2020-01-31 14:29:06 +00:00
|
|
|
// Bool casts a string to bool.
|
|
|
|
func Bool(s string) bool {
|
|
|
|
s = strings.TrimSpace(s)
|
|
|
|
|
2021-05-26 07:51:00 +00:00
|
|
|
if s == "" || No(s) {
|
2020-01-31 14:29:06 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
2021-05-26 07:51:00 +00:00
|
|
|
|
2022-03-24 17:30:59 +00:00
|
|
|
// Yes tests if a string represents "yes".
|
2021-05-26 07:51:00 +00:00
|
|
|
func Yes(s string) bool {
|
2021-09-29 18:09:34 +00:00
|
|
|
if s == "" {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-05-26 07:51:00 +00:00
|
|
|
s = strings.ToLower(strings.TrimSpace(s))
|
|
|
|
|
2021-09-23 12:23:00 +00:00
|
|
|
return strings.IndexAny(s, "ytjposiд") == 0
|
2021-05-26 07:51:00 +00:00
|
|
|
}
|
|
|
|
|
2022-03-24 17:30:59 +00:00
|
|
|
// No tests if a string represents "no".
|
2021-05-26 07:51:00 +00:00
|
|
|
func No(s string) bool {
|
2021-09-29 18:09:34 +00:00
|
|
|
if s == "" {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-05-26 07:51:00 +00:00
|
|
|
s = strings.ToLower(strings.TrimSpace(s))
|
|
|
|
|
2021-09-23 12:23:00 +00:00
|
|
|
return strings.IndexAny(s, "0nhufeн") == 0
|
2021-05-26 07:51:00 +00:00
|
|
|
}
|
2021-09-29 18:09:34 +00:00
|
|
|
|
2022-03-24 17:30:59 +00:00
|
|
|
// New tests if a string represents "new".
|
2021-09-29 18:09:34 +00:00
|
|
|
func New(s string) bool {
|
|
|
|
if s == "" {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
s = strings.ToLower(strings.TrimSpace(s))
|
|
|
|
|
2021-10-13 14:12:56 +00:00
|
|
|
return s == EnNew
|
2021-09-29 18:09:34 +00:00
|
|
|
}
|