-
Notifications
You must be signed in to change notification settings - Fork 0
/
option.go
76 lines (64 loc) · 1.28 KB
/
option.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package trend_prediction
const (
DefaultWindowLength = 3
DefaultWindowEscapeLength = 60
)
type option struct {
WindowLength int
WindowTimeEscape int
OnlyUseLength bool
OnlyUseEscape bool
CheckIncreasing bool
CheckDescending bool
CheckAverage bool
AverageTarget int
Threshold int
}
type Option func(o *option)
func getDefaultOption() *option {
return &option{
WindowLength: DefaultWindowLength,
WindowTimeEscape: DefaultWindowEscapeLength,
}
}
func WithThreshold(threshold int) Option {
return func(o *option) {
o.Threshold = threshold
}
}
func WithCheckAverage(target int) Option {
return func(o *option) {
o.CheckAverage = true
o.AverageTarget = target
}
}
func WithCheckIncreasing() Option {
return func(o *option) {
o.CheckIncreasing = true
}
}
func WithCheckDescending() Option {
return func(o *option) {
o.CheckDescending = true
}
}
func WithWindowLength(length int) Option {
return func(o *option) {
o.WindowLength = length
}
}
func WithWindowTimeEscape(escape int) Option {
return func(o *option) {
o.WindowTimeEscape = escape
}
}
func WithOnlyUseLength() Option {
return func(o *option) {
o.OnlyUseLength = true
}
}
func WithOnlyUseEscape() Option {
return func(o *option) {
o.OnlyUseEscape = true
}
}