class String

monkey patch in some color effects string methods

Public Instance Methods

camel_case() click to toggle source
# File lib/retrospec.rb, line 12
def camel_case
  return self if self !~ /_/ && self =~ /[A-Z]+.*/
  split('_').map(&:capitalize).join
end
cyan() click to toggle source
# File lib/retrospec.rb, line 6
def cyan;           "\033[36m#{self}\033[0m" end
fatal() click to toggle source
# File lib/retrospec.rb, line 9
def fatal;          red                      end
green() click to toggle source
# File lib/retrospec.rb, line 5
def green;          "\033[32m#{self}\033[0m" end
info() click to toggle source
# File lib/retrospec.rb, line 10
def info;           green                    end
red() click to toggle source
# File lib/retrospec.rb, line 4
def red;            "\033[31m#{self}\033[0m" end
underscore() click to toggle source
# File lib/retrospec.rb, line 17
def underscore
  self.gsub(/::/, '/').
      gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
      gsub(/([a-z\d])([A-Z])/,'\1_\2').
      tr("-", "_").
      downcase
end
warning() click to toggle source
# File lib/retrospec.rb, line 8
def warning;        yellow                   end
yellow() click to toggle source
# File lib/retrospec.rb, line 7
def yellow;         "\033[33m#{self}\033[0m" end