-
Notifications
You must be signed in to change notification settings - Fork 0
/
subIndustry.go
48 lines (40 loc) · 1.16 KB
/
subIndustry.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
package gics
// SubIndustry represents a sub-industry.
type SubIndustry uint32
// Valid validates the `SubIndustry` value.
func (si SubIndustry) Valid() bool {
_, ok := subIndustryKeys[si]
return ok
}
// String satisfies `fmt.Stringer`.
func (si SubIndustry) String() string {
if s, ok := subIndustryKeys[si]; ok {
return s.name
}
return invalid
}
// Sector returns the `Sector` this `SubIndustry` belongs to.
func (si SubIndustry) Sector() Sector {
return si.Group().Sector()
}
// Group returns the `Group` this `SubIndustry` belongs to.
func (si SubIndustry) Group() Group {
return si.Industry().Group()
}
// Industry returns the `Industry` this `SubIndustry` belongs to.
func (si SubIndustry) Industry() Industry {
return Industry(si / 100)
}
// ParseSubIndustry returns the `SubIndustry` corresponding to a string.
// Returns an invalid `SubIndustry` if no such `SubIndustry` exists.
func ParseSubIndustry(s string) SubIndustry {
return subIndustryValues[s]
}
// SubIndustries returns a `SubIndustrySet` containing all `SubIndustry`s.
func SubIndustries() SubIndustrySet {
sis := make(SubIndustrySet)
for _, si := range subIndustries {
sis.Add(si)
}
return sis
}