Class: String

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

Overview

Add some ome simple colorization methods for formatting console output. Prefix methods with rs_ so they don’t collide with other gems.

Instance Method Summary collapse

Instance Method Details

#rs_colorize(color_code) ⇒ Object



4
5
6
# File 'lib/rspec_starter/core_ext/string.rb', line 4

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

#rs_greenObject



12
13
14
# File 'lib/rspec_starter/core_ext/string.rb', line 12

def rs_green
  rs_colorize(32)
end

#rs_redObject



8
9
10
# File 'lib/rspec_starter/core_ext/string.rb', line 8

def rs_red
  rs_colorize(31)
end

#rs_yellowObject



16
17
18
# File 'lib/rspec_starter/core_ext/string.rb', line 16

def rs_yellow
  rs_colorize(33)
end