forked from lucasepe/crumbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnote.go
49 lines (41 loc) · 831 Bytes
/
note.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 crumbs
// Entry is a thought, an idea.
type Entry struct {
id string
level int
text string
icon string
parent *Entry
childrens []*Entry
}
// ID returns the node identifier.
func (ti *Entry) ID() string {
return ti.id
}
// Childrens returns the node childs.
func (ti *Entry) Childrens() []*Entry {
return ti.childrens
}
// Text returns the node data.
func (ti *Entry) Text() string {
return ti.text
}
// Icon returns the icon path.
func (ti *Entry) Icon() string {
return ti.icon
}
// Level returns the node depth.
func (ti *Entry) Level() int {
return ti.level
}
// Parent returns the node parent
func (ti *Entry) Parent() *Entry {
return ti.parent
}
// Root returns the root note
func (ti *Entry) Root() *Entry {
if ti.parent == nil {
return ti
}
return ti.parent.Root()
}