Last active
July 17, 2023 08:20
-
-
Save rabestro/08be57a2b28b61659eb977ec02aaf634 to your computer and use it in GitHub Desktop.
Bob - Remark.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bob | |
import ( | |
"strings" | |
"unicode" | |
) | |
type Remark string | |
func newRemark(remark string) Remark { | |
return Remark(strings.TrimSpace(remark)) | |
} | |
func (remark Remark) isSilence() bool { | |
return remark == "" | |
} | |
func (remark Remark) isShouting() bool { | |
hasLetters := strings.IndexFunc(string(remark), unicode.IsLetter) >= 0 | |
isUpcased := strings.ToUpper(string(remark)) == string(remark) | |
return hasLetters && isUpcased | |
} | |
func (remark Remark) isQuestion() bool { | |
return strings.HasSuffix(string(remark), "?") | |
} | |
func (remark Remark) isExasperated() bool { | |
return remark.isShouting() && remark.isQuestion() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment