Method: CommandKit::Colors#colors

Defined in:
lib/command_kit/colors.rb

#colors(stream = stdout) {|color| ... } ⇒ ANSI, PlainText

Returns the colors available for the given stream.

Examples:

puts colors.green("Hello world")

Using colors with stderr output:

stderr.puts colors(stderr).green("Hello world")

Parameters:

  • stream (IO) (defaults to: stdout)

Yields:

  • (color)

Returns:

  • (ANSI, PlainText)

    The ANSI module or PlainText dummy module.



1027
1028
1029
1030
1031
1032
1033
1034
# File 'lib/command_kit/colors.rb', line 1027

def colors(stream=stdout)
  color = if ansi?(stream) then ANSI
          else                  PlainText
          end

  yield color if block_given?
  return color
end