-
Notifications
You must be signed in to change notification settings - Fork 0
/
string.rb
92 lines (70 loc) · 1.05 KB
/
string.rb
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
91
92
# frozen_string_literal: true
# String class for text formatting
class String
def black
"\e[30m#{self}\e[0m"
end
def white
"\e[37m#{self}\e[0m"
end
def red
"\e[31m#{self}\e[0m"
end
def green
"\e[32m#{self}\e[0m"
end
def brown
"\e[33m#{self}\e[0m"
end
def blue
"\e[34m#{self}\e[0m"
end
def magenta
"\e[35m#{self}\e[0m"
end
def cyan
"\e[36m#{self}\e[0m"
end
def gray
"\e[37m#{self}\e[0m"
end
def bold
"\e[1m#{self}\e[22m"
end
def italic
"\e[3m#{self}\e[23m"
end
def underline
"\e[4m#{self}\e[24m"
end
def blink
"\e[5m#{self}\e[25m"
end
def reverse_color
"\e[7m#{self}\e[27m"
end
def bg_black
"\e[40m#{self}\e[0m"
end
def bg_red
"\e[41m#{self}\e[0m"
end
def bg_green
"\e[42m#{self}\e[0m"
end
def bg_brown
"\e[43m#{self}\e[0m"
end
def bg_blue
"\e[44m#{self}\e[0m"
end
def bg_magenta
"\e[45m#{self}\e[0m"
end
def bg_cyan
"\e[46m#{self}\e[0m"
end
def bg_gray
"\e[47m#{self}\e[0m"
end
end