-
Notifications
You must be signed in to change notification settings - Fork 1
/
assets.go
44 lines (38 loc) · 880 Bytes
/
assets.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
package crawler
// Asset provides metadata about data for an item.
type Asset map[string]interface{}
// Href returns the asset's href.
func (a Asset) Href() string {
value, _ := a["href"].(string)
return value
}
// Type returns the asset's type.
func (a Asset) Type() string {
value, _ := a["type"].(string)
return value
}
// Title returns the asset's title.
func (a Asset) Title() string {
value, _ := a["title"].(string)
return value
}
// Description returns the asset's description.
func (a Asset) Description() string {
value, _ := a["description"].(string)
return value
}
// Roles returns the asset's description.
func (a Asset) Roles() []string {
var roles = []string{}
list, ok := a["roles"].([]interface{})
if !ok {
return roles
}
for _, item := range list {
role, ok := item.(string)
if ok {
roles = append(roles, role)
}
}
return roles
}