Sha256: 92420741a40a899357bfbdcf6a3e5e93ff9ace6f33c9fdaa2ae0abbf3ae11078

Contents?: true

Size: 497 Bytes

Versions: 6

Compression:

Stored size: 497 Bytes

Contents

module ConfigmonkeyCli
  class Application
    module Colorize
      COLORMAP = {
        black: 30,
        red: 31,
        green: 32,
        yellow: 33,
        blue: 34,
        magenta: 35,
        cyan: 36,
        white: 37,
      }

      def colorize str, color = :yellow
        ccode = COLORMAP[color.to_sym] || raise(ArgumentError, "Unknown color #{color}!")
        @opts[:colorize] ? "\e[#{ccode}m#{str}\e[0m" : "#{str}"
      end
      alias_method :c, :colorize
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
configmonkey_cli-1.0.5 lib/configmonkey_cli/application/colorize.rb
configmonkey_cli-1.0.4 lib/configmonkey_cli/application/colorize.rb
configmonkey_cli-1.0.3 lib/configmonkey_cli/application/colorize.rb
configmonkey_cli-1.0.2 lib/configmonkey_cli/application/colorize.rb
configmonkey_cli-1.0.1 lib/configmonkey_cli/application/colorize.rb
configmonkey_cli-1.0.0 lib/configmonkey_cli/application/colorize.rb