Module: CommandKit::Colors::ANSI
- Defined in:
- lib/command_kit/colors.rb
Overview
Applies ANSI formatting to text.
Constant Summary collapse
- RESET =
ANSI reset code
"\e[0m"- CLEAR =
RESET- BOLD =
ANSI code for bold text
"\e[1m"- RESET_INTENSITY =
ANSI code to disable boldness
"\e[22m"- BLACK =
ANSI color code for black
"\e[30m"- RED =
ANSI color code for red
"\e[31m"- GREEN =
ANSI color code for green
"\e[32m"- YELLOW =
ANSI color code for yellow
"\e[33m"- BLUE =
ANSI color code for blue
"\e[34m"- MAGENTA =
ANSI color code for megenta
"\e[35m"- CYAN =
ANSI color code for cyan
"\e[36m"- WHITE =
ANSI color code for white
"\e[37m"- RESET_COLOR =
ANSI color for the default foreground color
"\e[39m"
Class Method Summary collapse
-
.black(string = nil) ⇒ String, BLACK
Sets the text color to black.
-
.blue(string = nil) ⇒ String, BLUE
Sets the text color to blue.
-
.bold(string = nil) ⇒ String, BOLD
Bolds the text.
- .clear ⇒ Object
-
.cyan(string = nil) ⇒ String, CYAN
Sets the text color to cyan.
-
.green(string = nil) ⇒ String, GREEN
Sets the text color to green.
-
.magenta(string = nil) ⇒ String, MAGENTA
Sets the text color to magenta.
-
.red(string = nil) ⇒ String, RED
Sets the text color to red.
-
.reset ⇒ RESET
Resets text formatting.
-
.white(string = nil) ⇒ String, WHITE
Sets the text color to white.
-
.yellow(string = nil) ⇒ String, YELLOW
Sets the text color to yellow.
Class Method Details
.black(string = nil) ⇒ String, BLACK
Sets the text color to black.
138 139 140 141 142 |
# File 'lib/command_kit/colors.rb', line 138 def black(string=nil) if string then "#{BLACK}#{string}#{RESET_COLOR}" else BLACK end end |
.blue(string = nil) ⇒ String, BLUE
Sets the text color to blue.
214 215 216 217 218 |
# File 'lib/command_kit/colors.rb', line 214 def blue(string=nil) if string then "#{BLUE}#{string}#{RESET_COLOR}" else BLUE end end |
.bold(string = nil) ⇒ String, BOLD
Bolds the text.
119 120 121 122 123 |
# File 'lib/command_kit/colors.rb', line 119 def bold(string=nil) if string then "#{BOLD}#{string}#{RESET_INTENSITY}" else BOLD end end |
.clear ⇒ Object
102 103 104 |
# File 'lib/command_kit/colors.rb', line 102 def clear reset end |
.cyan(string = nil) ⇒ String, CYAN
Sets the text color to cyan.
252 253 254 255 256 |
# File 'lib/command_kit/colors.rb', line 252 def cyan(string=nil) if string then "#{CYAN}#{string}#{RESET_COLOR}" else CYAN end end |
.green(string = nil) ⇒ String, GREEN
Sets the text color to green.
176 177 178 179 180 |
# File 'lib/command_kit/colors.rb', line 176 def green(string=nil) if string then "#{GREEN}#{string}#{RESET_COLOR}" else GREEN end end |
.magenta(string = nil) ⇒ String, MAGENTA
Sets the text color to magenta.
233 234 235 236 237 |
# File 'lib/command_kit/colors.rb', line 233 def magenta(string=nil) if string then "#{MAGENTA}#{string}#{RESET_COLOR}" else MAGENTA end end |
.red(string = nil) ⇒ String, RED
Sets the text color to red.
157 158 159 160 161 |
# File 'lib/command_kit/colors.rb', line 157 def red(string=nil) if string then "#{RED}#{string}#{RESET_COLOR}" else RED end end |
.reset ⇒ RESET
Resets text formatting.
93 94 95 |
# File 'lib/command_kit/colors.rb', line 93 def reset RESET end |
.white(string = nil) ⇒ String, WHITE
Sets the text color to white.
271 272 273 274 275 |
# File 'lib/command_kit/colors.rb', line 271 def white(string=nil) if string then "#{WHITE}#{string}#{RESET_COLOR}" else WHITE end end |
.yellow(string = nil) ⇒ String, YELLOW
Sets the text color to yellow.
195 196 197 198 199 |
# File 'lib/command_kit/colors.rb', line 195 def yellow(string=nil) if string then "#{YELLOW}#{string}#{RESET_COLOR}" else YELLOW end end |