Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/ext/string.rb

Instance Method Summary collapse

Instance Method Details

#blueObject



9
# File 'lib/ext/string.rb', line 9

def blue()  colorize('34'); end

#boldObject



5
# File 'lib/ext/string.rb', line 5

def bold()   colorize('1'); end

#colorize(color_code) ⇒ Object



3
# File 'lib/ext/string.rb', line 3

def colorize(color_code) "\e[#{color_code}m#{self}\e[0m"; end

#greenObject



10
# File 'lib/ext/string.rb', line 10

def green() colorize('32'); end

#invertObject



6
# File 'lib/ext/string.rb', line 6

def invert() colorize('7'); end

#redObject



8
# File 'lib/ext/string.rb', line 8

def red()   colorize('31'); end

#undentObject



12
# File 'lib/ext/string.rb', line 12

def undent() gsub(/^.{#{slice(/^ +/).length}}/, ''); end