Sha256: b3f05872b5bf0fcb79c3288e6aa63c35f638e040ff08a473b4a4106fcc6f511a

Contents?: true

Size: 592 Bytes

Versions: 2

Compression:

Stored size: 592 Bytes

Contents

# Colorizes text with ASCII colors.
#
# @example
#   include ColorizedText
#
#   puts green "OK"          # => green output
#   puts bold "Running...    # => bold output
#   puts bold green "OK!!!"  # => bold green output
module ColorizedText
  # Colorize text using ASCII color code
  def colorize(text, code)
    "\033[#{code}m#{text}\033[0m"
  end

  # :nodoc:
  def yellow(text)
    colorize(text, 33)
  end

  # :nodoc:
  def green(text)
    colorize(text, 32)
  end

  # :nodoc:
  def red(text)
    colorize(text, 31)
  end

  # :nodoc:
  def bold(text)
    colorize(text, 1)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple_shipping-0.4.7 lib/colorized_text.rb
simple_shipping-0.4.6 lib/colorized_text.rb