-
Notifications
You must be signed in to change notification settings - Fork 114
/
properties.go
58 lines (49 loc) · 1.08 KB
/
properties.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package block
import "strconv"
//go:generate go run ./generator/properties/main.go
type Boolean bool
func (b Boolean) MarshalText() (text []byte, err error) {
return []byte(strconv.FormatBool(bool(b))), nil
}
func (b *Boolean) UnmarshalText(text []byte) (err error) {
*((*bool)(b)), err = strconv.ParseBool(string(text))
return
}
type Integer int
func (i Integer) MarshalText() (text []byte, err error) {
return []byte(strconv.Itoa(int(i))), nil
}
func (i *Integer) UnmarshalText(text []byte) (err error) {
*((*int)(i)), err = strconv.Atoi(string(text))
return
}
func (f FrontAndTop) Directions() (front, top Direction) {
switch f {
case DownEast:
return Down, East
case DownNorth:
return Down, North
case DownSouth:
return Down, South
case DownWest:
return Down, West
case UpEast:
return Up, East
case UpNorth:
return Up, North
case UpSouth:
return Up, South
case UpWest:
return Up, West
case WestUp:
return West, Up
case EastUp:
return East, Up
case NorthUp:
return North, Up
case SouthUp:
return South, Up
default:
panic("invalid FrontAndTop")
}
}