-
-
Notifications
You must be signed in to change notification settings - Fork 86
/
numeric_report_column.go
42 lines (34 loc) · 1.02 KB
/
numeric_report_column.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
// Copyright (c) 2021-2024 Onur Cinar.
// The source code is provided under GNU AGPLv3 License.
// https://github.com/cinar/indicator
package helper
import "fmt"
// numericReportColumn is the number report column struct.
type numericReportColumn[T Number] struct {
ReportColumn
name string
values <-chan T
}
// NewNumericReportColumn returns a new instance of a numeric data column for a report.
func NewNumericReportColumn[T Number](name string, values <-chan T) ReportColumn {
return &numericReportColumn[T]{
name: name,
values: values,
}
}
// Name returns the name of the report column.
func (c *numericReportColumn[T]) Name() string {
return c.name
}
// Type returns number as the data type.
func (*numericReportColumn[T]) Type() string {
return "number"
}
// Role returns the role of the report column.
func (*numericReportColumn[T]) Role() string {
return "data"
}
// Value returns the next data value for the report column.
func (c *numericReportColumn[T]) Value() string {
return fmt.Sprintf("%v", <-c.values)
}