module NerdQuiz::Color
Thanks to @wycats for Color
class! github.com/wycats/thor
Constants
- BLACK
Set the terminal’s foreground ANSI color to black.
- BLUE
Set the terminal’s foreground ANSI color to blue.
- BOLD
The start of an ANSI bold sequence.
- CLEAR
Embed in a String to clear all previous ANSI sequences.
- CYAN
Set the terminal’s foreground ANSI color to cyan.
- GREEN
Set the terminal’s foreground ANSI color to green.
- MAGENTA
Set the terminal’s foreground ANSI color to magenta.
- ON_BLACK
Set the terminal’s background ANSI color to black.
- ON_BLUE
Set the terminal’s background ANSI color to blue.
- ON_CYAN
Set the terminal’s background ANSI color to cyan.
- ON_GREEN
Set the terminal’s background ANSI color to green.
- ON_MAGENTA
Set the terminal’s background ANSI color to magenta.
- ON_RED
Set the terminal’s background ANSI color to red.
- ON_WHITE
Set the terminal’s background ANSI color to white.
- ON_YELLOW
Set the terminal’s background ANSI color to yellow.
- RED
Set the terminal’s foreground ANSI color to red.
- WHITE
Set the terminal’s foreground ANSI color to white.
- YELLOW
Set the terminal’s foreground ANSI color to yellow.
Public Instance Methods
Set color by using a string or one of the defined constants. If a third option is set to true, it also adds bold to the string. This is based on Highline implementation and it automatically appends CLEAR
to the end of the returned String.
# File lib/nerd_quiz/color.rb, line 49 def set_color(string, color, bold=false) color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol) bold = bold ? BOLD : "" "#{bold}#{color}#{string}#{CLEAR}" end