-
Notifications
You must be signed in to change notification settings - Fork 3
/
name.go
90 lines (74 loc) · 2.03 KB
/
name.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package faker
// Namer interface
type Namer interface {
FirstName() string
LastName() string
FullName() string
JobTitle() string
Prefix() string
Suffix() string
JobDescriptor() string
JobArea() string
JobType() string
Gender() string
}
// Name struct
type Name struct {
*Fake
}
// FirstName returns first name
func (n *Name) FirstName() string {
if directoryExists(n.DefaultLocale+"/"+namePrefix+"/male_first_name") &&
directoryExists(n.DefaultLocale+"/"+namePrefix+"/female_first_name") {
// TODO give gender choice
if !directoryExists(n.DefaultLocale + "/" + namePrefix + "/first_name") {
return n.pick(namePrefix + "/female_first_name")
}
}
return n.pick(namePrefix + "/first_name")
}
// LastName returns last name
func (n *Name) LastName() string {
if directoryExists(n.DefaultLocale+"/"+namePrefix+"/male_last_name") &&
directoryExists(n.DefaultLocale+"/"+namePrefix+"/female_last_name") {
// TODO give gender choice
if !directoryExists(n.DefaultLocale + "/" + namePrefix + "/last_name") {
return n.pick(namePrefix + "/female_last_name")
}
}
return n.pick(namePrefix + "/last_name")
}
// FullName gets full name
func (n *Name) FullName() string {
return n.FirstName() + " " + n.LastName()
}
// JobDescriptor returns a job description
func (n *Name) JobDescriptor() string {
return n.pick(namePrefix + "/title/descriptor")
}
//JobArea returns a job area
func (n *Name) JobArea() string {
return n.pick(namePrefix + "/title/level")
}
//JobType returns a job type
func (n *Name) JobType() string {
return n.pick(namePrefix + "/title/job")
}
//JobTitle returns a job title
func (n *Name) JobTitle() string {
return n.JobDescriptor() + " " + n.JobArea() + " " + n.JobType()
}
// Gender returns a gender
func (n *Name) Gender() string {
return n.pick(namePrefix + "/gender")
}
//Prefix returns a prefix
func (n *Name) Prefix() string {
// TODO handle gender
return n.pick(namePrefix + "/prefix")
}
//Suffix returns a suffix
func (n *Name) Suffix() string {
// TODO handle gender
return n.pick(namePrefix + "/suffix")
}