-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
blood.go
54 lines (42 loc) · 1.12 KB
/
blood.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
package faker
import (
"fmt"
"reflect"
"github.com/go-faker/faker/v4/pkg/options"
)
var bloodTypes = []string{"O", "A", "B", "AB"}
var bloodRhFactors = []string{"+", "-"}
func GetBlood(opts ...options.OptionFunc) Blooder {
opt := options.BuildOptions(opts)
db := &Blood{
fakerOption: *opt,
}
return db
}
type Blooder interface {
BloodType(v reflect.Value) (interface{}, error)
BloodRHFactor(v reflect.Value) (interface{}, error)
BloodGroup(v reflect.Value) (interface{}, error)
}
// Internet struct
type Blood struct {
fakerOption options.Options
}
func (b Blood) bloodType() string {
return randomElementFromSliceString(bloodTypes)
}
func (b Blood) BloodType(v reflect.Value) (interface{}, error) {
return b.bloodType(), nil
}
func (b Blood) bloodRhFactor() string {
return randomElementFromSliceString(bloodRhFactors)
}
func (b Blood) BloodRHFactor(v reflect.Value) (interface{}, error) {
return b.bloodRhFactor(), nil
}
func (b Blood) bloodGroup() string {
return fmt.Sprintf("%s%s", b.bloodType(), b.bloodRhFactor())
}
func (b Blood) BloodGroup(v reflect.Value) (interface{}, error) {
return b.bloodGroup(), nil
}