-
Notifications
You must be signed in to change notification settings - Fork 1
/
indicator.go
31 lines (23 loc) · 848 Bytes
/
indicator.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
package outis
import "time"
type indicator struct {
key string
value float64
createdAt time.Time
}
// NewIndicator creates a new indicator
func (ctx *Context) NewIndicator(key string) *indicator {
indicator := &indicator{key: key, value: 0, createdAt: time.Now()}
ctx.indicator = append(ctx.indicator, indicator)
return indicator
}
// GetKey get the key value of an indicator
func (i *indicator) GetKey() string { return i.key }
// GetValue get the value of an indicator
func (i *indicator) GetValue() float64 { return i.value }
// GetCreatedAt get the creation date of an indicator
func (i *indicator) GetCreatedAt() time.Time { return i.createdAt }
// Inc increments the indicator data
func (i *indicator) Inc() { i.value++ }
// Add add a value to the indicator
func (i *indicator) Add(value float64) { i.value += value }