class String

Public Instance Methods

colorize(color_code) click to toggle source

colorization

# File lib/ra10ke/monkey_patches.rb, line 5
def colorize(color_code)
  "\e[#{color_code}m#{self}\e[0m"
end
green() click to toggle source
# File lib/ra10ke/monkey_patches.rb, line 13
def green
  colorize(32)
end
red() click to toggle source
# File lib/ra10ke/monkey_patches.rb, line 9
def red
  colorize(31)
end
strip_comment(markers = [' click to toggle source

removes specified markes from string. @return [String] - the string with markers removed

# File lib/ra10ke/monkey_patches.rb, line 23
def strip_comment(markers = ['#', "\n"])
  re = Regexp.union(markers)
  index = (self =~ re)
  index.nil? ? rstrip : self[0, index].rstrip
end
yellow() click to toggle source
# File lib/ra10ke/monkey_patches.rb, line 17
def yellow
  colorize(33)
end