module Ronin::Support::CLI::ANSI
Defines ANSI
colors.
@api public
@since 1.0.0
Constants
- BLACK
ANSI
color code for black- BLUE
ANSI
color code for blue- BOLD_OFF
ANSI
code to disable boldness- BOLD_ON
ANSI
code for bold text- CYAN
ANSI
color code for cyan- GREEN
ANSI
color code for green- MAGENTA
ANSI
color code for magenta- RED
ANSI
color code for red- RESET
ANSI
reset code- RESET_COLOR
ANSI
color for the default foreground color- WHITE
ANSI
color code for white- YELLOW
ANSI
color code for yellow
Public Instance Methods
Sets the text color to black.
@param [String, nil] string
An optional string.
@return [String]
The colorized string or just {BLACK} if no arguments were given.
@see BLACK
@api public
# File lib/ronin/support/cli/ansi.rb, line 140 def black(string=nil) if string if $stdout.tty? then "#{BLACK}#{string}#{RESET_COLOR}" else string end else if $stdout.tty? then BLACK else '' end end end
Sets the text color to blue.
@param [String, nil] string
An optional string.
@return [String]
The colorized string or just {BLUE} if no arguments were given.
@see BLUE
@api public
# File lib/ronin/support/cli/ansi.rb, line 240 def blue(string=nil) if string if $stdout.tty? then "#{BLUE}#{string}#{RESET_COLOR}" else string end else if $stdout.tty? then BLUE else '' end end end
Bolds the text.
@param [String, nil] string
An optional string.
@return [String]
The bolded string or just {BOLD_ON} if no arguments were given.
@see BOLD_ON
@api public
# File lib/ronin/support/cli/ansi.rb, line 111 def bold(string=nil) if string if $stdout.tty? then "#{BOLD_ON}#{string}#{BOLD_OFF}" else string end else if $stdout.tty? then BOLD_ON else '' end end end
Alias for {reset}.
@return [String, nil]
The ANSI reset String or `nil` if STDOUT is not a TTY.
@see reset
@api public
# File lib/ronin/support/cli/ansi.rb, line 94 def clear reset end
Sets the text color to cyan.
@param [String, nil] string
An optional string.
@return [String]
The colorized string or just {CYAN} if no arguments were given.
@see CYAN
@api public
# File lib/ronin/support/cli/ansi.rb, line 290 def cyan(string=nil) if string if $stdout.tty? then "#{CYAN}#{string}#{RESET_COLOR}" else string end else if $stdout.tty? then CYAN else '' end end end
Sets the text color to green.
@param [String, nil] string
An optional string.
@return [String]
The colorized string or just {GREEN} if no arguments were given.
@see GREEN
@api public
# File lib/ronin/support/cli/ansi.rb, line 190 def green(string=nil) if string if $stdout.tty? then "#{GREEN}#{string}#{RESET_COLOR}" else string end else if $stdout.tty? then GREEN else '' end end end
Sets the text color to magenta.
@param [String, nil] string
An optional string.
@return [String]
The colorized string or just {MAGENTA} if no arguments were given.
@see MAGENTA
@api public
# File lib/ronin/support/cli/ansi.rb, line 265 def magenta(string=nil) if string if $stdout.tty? then "#{MAGENTA}#{string}#{RESET_COLOR}" else string end else if $stdout.tty? then MAGENTA else '' end end end
Sets the text color to red.
@param [String, nil] string
An optional string.
@return [String]
The colorized string or just {RED} if no arguments were given.
@see RED
@api public
# File lib/ronin/support/cli/ansi.rb, line 165 def red(string=nil) if string if $stdout.tty? then "#{RED}#{string}#{RESET_COLOR}" else string end else if $stdout.tty? then RED else '' end end end
Resets text formatting.
@return [String, nil]
The ANSI reset String or `nil` if STDOUT is not a TTY.
@see RESET
@api public
# File lib/ronin/support/cli/ansi.rb, line 78 def reset if $stdout.tty? then RESET else '' end end
Sets the text color to white.
@param [String, nil] string
An optional string.
@return [String]
The colorized string or just {WHITE} if no arguments were given.
@see WHITE
@api public
# File lib/ronin/support/cli/ansi.rb, line 315 def white(string=nil) if string if $stdout.tty? then "#{WHITE}#{string}#{RESET_COLOR}" else string end else if $stdout.tty? then WHITE else '' end end end
Sets the text color to yellow.
@param [String, nil] string
An optional string.
@return [String]
The colorized string or just {YELLOW} if no arguments were given.
@see YELLOW
@api public
# File lib/ronin/support/cli/ansi.rb, line 215 def yellow(string=nil) if string if $stdout.tty? then "#{YELLOW}#{string}#{RESET_COLOR}" else string end else if $stdout.tty? then YELLOW else '' end end end