2022-10-29 10:09:10 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-11-16 11:40:52 +00:00
|
|
|
AVAILABLE_COLORS = %i[
|
2022-11-17 13:57:39 +00:00
|
|
|
red green yellow pink magenta blue cyan white
|
2022-11-18 09:34:47 +00:00
|
|
|
bg_red bg_green bg_yellow bg_pink bg_magenta bg_blue bg_cyan bg_white
|
2022-11-16 11:40:52 +00:00
|
|
|
].freeze
|
|
|
|
|
2022-10-29 10:09:10 +00:00
|
|
|
# String color
|
|
|
|
class String
|
|
|
|
def colorize(color_code)
|
|
|
|
"\e[#{color_code}m#{self}\e[0m"
|
|
|
|
end
|
|
|
|
|
2022-11-17 13:57:39 +00:00
|
|
|
# foreground
|
2022-10-29 10:09:10 +00:00
|
|
|
def red
|
|
|
|
colorize(31)
|
|
|
|
end
|
|
|
|
|
|
|
|
def green
|
|
|
|
colorize(32)
|
|
|
|
end
|
|
|
|
|
|
|
|
def yellow
|
|
|
|
colorize(33)
|
|
|
|
end
|
|
|
|
|
2022-11-17 13:57:39 +00:00
|
|
|
def blue
|
|
|
|
colorize(34)
|
|
|
|
end
|
|
|
|
|
2022-10-29 10:09:10 +00:00
|
|
|
def pink
|
|
|
|
colorize(35)
|
|
|
|
end
|
2022-11-17 13:57:39 +00:00
|
|
|
|
|
|
|
# keklul pink alias
|
|
|
|
def magenta
|
|
|
|
colorize(35)
|
|
|
|
end
|
|
|
|
|
|
|
|
def cyan
|
|
|
|
colorize(36)
|
|
|
|
end
|
|
|
|
|
|
|
|
def white
|
|
|
|
colorize(37)
|
|
|
|
end
|
|
|
|
|
|
|
|
# background
|
|
|
|
def bg_red
|
|
|
|
colorize(41)
|
|
|
|
end
|
|
|
|
|
|
|
|
def bg_green
|
|
|
|
colorize(42)
|
|
|
|
end
|
|
|
|
|
|
|
|
def bg_yellow
|
|
|
|
colorize(43)
|
|
|
|
end
|
|
|
|
|
|
|
|
def bg_blue
|
|
|
|
colorize(44)
|
|
|
|
end
|
|
|
|
|
|
|
|
def bg_pink
|
|
|
|
colorize(45)
|
|
|
|
end
|
|
|
|
|
|
|
|
# keklul pink alias
|
|
|
|
def bg_magenta
|
|
|
|
colorize(45)
|
|
|
|
end
|
|
|
|
|
|
|
|
def bg_cyan
|
|
|
|
colorize(46)
|
|
|
|
end
|
|
|
|
|
|
|
|
def bg_white
|
|
|
|
colorize(47)
|
|
|
|
end
|
2022-10-29 10:09:10 +00:00
|
|
|
end
|