lib/guard/ui.rb
def color(text, *color_options)
        color_code = ''
        color_options.each do |color_option|
          color_option = color_option.to_s
          if color_option != ''
            if !(color_option =~ /\d+/)
              color_option = const_get("ANSI_ESCAPE_#{ color_option.upcase }")
            end
            color_code += ';' + color_option
          end
        end
        color_enabled? ? "\e[0#{ color_code }m#{ text }\e[0m" : text
      end
# Colorizes a text message. See the constant below for possible
# color_options parameters. You can pass :bright, a foreground
# and a background color.
#
# @example
#   color('Hello World', :red, :bright)
#
# @param [String] the text to colorize
# @param [Array] color_options the color options
#
Colorizes a text message. See the constant below for possible
color_options parameters. You can pass :bright, a foreground
and a background color.
Colorizes a text message . See the constant below for possible color_options parameters . You can pass : bright a foreground and a background color .
def color(text, *color_options)
        color_code = ''
        color_options.each do |color_option|
          color_option = color_option.to_s
          if color_option != ''
            if !(color_option =~ /\d+/)
              color_option = const_get("ANSI_ESCAPE_#{ color_option.upcase }")
            end
            color_code += ';' + color_option
          end
        end
        color_enabled? ? "\e[0#{ color_code }m#{ text }\e[0m" : text
      end
def color ( text , * color_options ) color_code = '' color_options . each do | color_option | color_option = color_option . to_s if color_option != '' if ! ( color_option =~ / \d + / ) color_option = const_get ( "ANSI_ESCAPE_#{ color_option.upcase }" ) end color_code += ';' + color_option end end color_enabled? ? "\e[0#{ color_code }m#{ text }\e[0m" : text end
Colorizes a text message.
Colorizes a text message .
text
color_options
color_options the color options
color_options the color options
example
color('Hello World', :red, :bright)
color ( ' Hello World ' : red : bright )