Sha256: 80392df07f09a102a13ad315487a60f21921ef4954690c552fa9843e7f429fd7
Contents?: true
Size: 571 Bytes
Versions: 2
Compression:
Stored size: 571 Bytes
Contents
#!/usr/bin/env ruby # encoding: utf-8 module Aurb module CoreExt module String # Available colors for <tt>String#colorize</tt>. COLORS = [:gray, :red, :green, :yellow, :blue, :purple, :cyan, :white] # Colors a string with +color+. # # "Hello".colorize(:blue) def colorize(effect) if STDOUT.tty? && ENV['TERM'] "\033[0;#{30+COLORS.index(effect.to_sym)}m#{self}\033[0m" else self end rescue self end end end end String.send :include, Aurb::CoreExt::String
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
aurb-1.4.1 | lib/aurb/core_ext/string.rb |
aurb-1.4.0 | lib/aurb/core_ext/string.rb |