word.go 539 B

12345678910111213141516171819202122232425
  1. package muesli
  2. const WordType = TypeValue("Word")
  3. // WordValue are Muesli command words
  4. type WordValue string
  5. func (val WordValue) String() string {
  6. return string(val)
  7. }
  8. func (v WordValue) Type() TypeValue { return WordType }
  9. func (from WordValue) Convert(to interface{}) error {
  10. switch toPtr := to.(type) {
  11. case *string:
  12. (*toPtr) = from.String()
  13. case *WordValue:
  14. (*toPtr) = from
  15. case *Value:
  16. (*toPtr) = from
  17. default:
  18. return NewErrorValuef("Cannot convert WordValue %v to %v", from, to)
  19. }
  20. return nil
  21. }