-
Notifications
You must be signed in to change notification settings - Fork 2
/
class.go
43 lines (35 loc) · 1.28 KB
/
class.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
package main
import (
"html/template"
"strings"
)
type Classes []Class
type Class struct {
ClassMethods Methods `json:"class_methods"`
InstanceMethods Methods `json:"instance_methods"`
Name string `json:"name"`
Line int `json:"line"`
Comment template.HTML `json:"comment"`
Filename string
Commit string
Repo string
}
func (c *Class) MatchName(str string) bool {
return c.Name == str || (strings.Contains(str, c.Name) && strings.Contains(str, "Object"))
}
func (c *Class) MatchInstanceMethods(str string) bool {
return (strings.Contains(str, "builtin") || strings.Contains(str, "Builtin")) && strings.Contains(str, "Instance") && strings.Contains(str, "Methods")
}
func (c *Class) MatchClassMethods(str string) bool {
return (strings.Contains(str, "builtin") || strings.Contains(str, "Builtin")) && strings.Contains(str, "Class") && strings.Contains(str, "Methods")
}
func (c *Class) SetClassname(filepath string) {
split_path := strings.Split(filepath, "/")
filename := split_path[len(split_path)-1]
filename_no_ext := strings.Replace(filename, ".go", "", -1)
name := ""
for _, segment := range strings.Split(filename_no_ext, "_") {
name = name + strings.Title(segment)
}
c.Name = name
}