Sha256: 9f0a749ea69247308add61e8796dc2344c2a751c38a4311ec499d838efe1a6f7

Contents?: true

Size: 595 Bytes

Versions: 4

Compression:

Stored size: 595 Bytes

Contents

module Aid::Colorize
  extend self

  def self.included(base)
    colorize = self

    base.class_eval do
      extend colorize
    end
  end

  COLOR_CODES = {
    black: 30,
    blue: 34,
    brown: 33,
    cyan: 36,
    dark_gray: 90,
    green: 32,
    light_blue: 94,
    light_cyan: 96,
    light_gray: 37,
    light_green: 92,
    light_purple: 95,
    light_red: 91,
    light_yellow: 93,
    purple: 35,
    red: 31,
    white: 97,
    yellow: 33,

    command: 96,
    error: 91,
    info: 93,
  }

  def colorize(color, string)
    "\e[#{COLOR_CODES[color]}m#{string}\e[0m"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aid-0.1.3 lib/aid/colorize.rb
aid-0.1.2 lib/aid/colorize.rb
aid-0.1.1 lib/aid/colorize.rb
aid-0.1.0 lib/aid/colorize.rb