Class: String

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

Overview

Add ability to output colored text to console e.g.: puts “Hello”.red

Instance Method Summary collapse

Instance Method Details

#blueObject



17
# File 'lib/log.rb', line 17

def blue; colorize("\e[1m\e[34m"); end

#boldObject



10
# File 'lib/log.rb', line 10

def bold; colorize("\e[1m\e[29m"); end

#colorize(color_code) ⇒ Object



20
21
22
23
# File 'lib/log.rb', line 20

def colorize(color_code)  
  # Doesn't work with the Windows prompt...
  RUBY_PLATFORM =~ /(win|w)32$/ ? to_s : "#{color_code}#{to_s}\e[0m" 
end

#dark_blueObject



18
# File 'lib/log.rb', line 18

def dark_blue; colorize("\e[34m"); end

#dark_greenObject



15
# File 'lib/log.rb', line 15

def dark_green; colorize("\e[32m"); end

#dark_redObject



13
# File 'lib/log.rb', line 13

def dark_red; colorize("\e[31m"); end

#greenObject



14
# File 'lib/log.rb', line 14

def green; colorize("\e[1m\e[32m"); end

#greyObject



11
# File 'lib/log.rb', line 11

def grey; colorize("\e[30m"); end

#purObject



19
# File 'lib/log.rb', line 19

def pur; colorize("\e[1m\e[35m"); end

#redObject



12
# File 'lib/log.rb', line 12

def red; colorize("\e[1m\e[31m"); end

#yellowObject



16
# File 'lib/log.rb', line 16

def yellow; colorize("\e[1m\e[33m"); end