Class: String

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

Instance Method Summary collapse

Instance Method Details

#blueObject



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

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

#boldObject



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

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

#colorize(color_code) ⇒ Object

rubocop:disable Layout/EmptyLineBetweenDefs rubocop:disable Style/SingleLineMethods



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

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

#commifyObject



8
9
10
# File 'lib/ext/commify.rb', line 8

def commify
  gsub(/(\d)(?=(\d{3})+(\..*)?$)/, '\1,')
end

#greenObject



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

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

#invertObject



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

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

#redObject



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

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

#undentObject



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

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