just a thing to find the string representation of a ripple playstyle in go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

playstyle.go 798B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Package playstyle provides an enum for Ripple's playstyles.
  2. package playstyle
  3. import "strings"
  4. // PlayStyle is a bitwise enum containing the instruments a Ripple user likes
  5. // to play with.
  6. type PlayStyle int
  7. // various playstyles on ripple.
  8. const (
  9. Mouse int = 1 << iota
  10. Tablet
  11. Keyboard
  12. Touchscreen
  13. Spoon
  14. LeapMotion
  15. OculusRift
  16. )
  17. // Styles are string representations of the various playstyles someone can have.
  18. var Styles = [...]string{
  19. "Mouse",
  20. "Tablet",
  21. "Keyboard",
  22. "Touchscreen",
  23. "Spoon",
  24. "Leap motion",
  25. "Oculus rift",
  26. }
  27. // String is the string representation of a playstyle.
  28. func (p PlayStyle) String() string {
  29. var parts []string
  30. i := int(p)
  31. for k, v := range Styles {
  32. if i&(1<<uint(k)) > 0 {
  33. parts = append(parts, v)
  34. }
  35. }
  36. return strings.Join(parts, ", ")
  37. }