-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunitofmeasurement.go
49 lines (41 loc) · 936 Bytes
/
unitofmeasurement.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
package gossamer
const (
UNIT_VOLTAGE = "Voltage"
UNIT_CELSIUS = "Celsius"
)
type UnitOfMeasurement interface {
GetName() string
GetSymbol() string
GetDefinition() string
}
type GossamerUnitOfMeasurement struct {
name string
symbol string
definition string
}
func (u *GossamerUnitOfMeasurement) GetName() string {
return u.name
}
func (u *GossamerUnitOfMeasurement) GetSymbol() string {
return u.symbol
}
func (u *GossamerUnitOfMeasurement) GetDefinition() string {
return u.definition
}
func NewUnitOfMeasurementBySymbol(symbol string) UnitOfMeasurement {
switch symbol {
case UNIT_VOLTAGE:
return &GossamerUnitOfMeasurement{
name: "Voltage",
symbol: "V",
definition: "http://dbpedia.org/page/Voltage",
}
case UNIT_CELSIUS:
return &GossamerUnitOfMeasurement{
name: "Celsius",
symbol: "°C",
definition: "http://dbpedia.org/page/Celsius",
}
}
return nil
}