forked from n04ln/EL317-Patterns-and-Language
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcolorFormatters.go
40 lines (30 loc) · 870 Bytes
/
colorFormatters.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
package main
import (
"fmt"
"github.com/aybabtme/color/brush"
)
type ColorFormatter interface {
direction(s string) string
place(s string) string
time(s string) string
}
type ConsoleFormatter struct{}
func (c ConsoleFormatter) direction(s string) string {
return fmt.Sprintf("%s", brush.Red(s))
}
func (c ConsoleFormatter) place(s string) string {
return fmt.Sprintf("%s", brush.Blue(s))
}
func (c ConsoleFormatter) time(s string) string {
return fmt.Sprintf("%s", brush.Green(s))
}
type WebFormatter struct{}
func (w WebFormatter) direction(s string) string {
return fmt.Sprintf("<span style=\"color:red;\">%s</span>", s)
}
func (w WebFormatter) place(s string) string {
return fmt.Sprintf("<span style=\"color:blue;\">%s</span>", s)
}
func (w WebFormatter) time(s string) string {
return fmt.Sprintf("<span style=\"color:green;\">%s</span>", s)
}