Class: String

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

Instance Method Summary collapse

Instance Method Details

#bg_blackObject



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

def bg_black;       "\e[40m#{self}\e[0m" end

#bg_blueObject



23
# File 'lib/string.rb', line 23

def bg_blue;        "\e[44m#{self}\e[0m" end

#bg_brownObject



22
# File 'lib/string.rb', line 22

def bg_brown;       "\e[43m#{self}\e[0m" end

#bg_cyanObject



25
# File 'lib/string.rb', line 25

def bg_cyan;        "\e[46m#{self}\e[0m" end

#bg_grayObject



26
# File 'lib/string.rb', line 26

def bg_gray;        "\e[47m#{self}\e[0m" end

#bg_greenObject



21
# File 'lib/string.rb', line 21

def bg_green;       "\e[42m#{self}\e[0m" end

#bg_magentaObject



24
# File 'lib/string.rb', line 24

def bg_magenta;     "\e[45m#{self}\e[0m" end

#bg_redObject



20
# File 'lib/string.rb', line 20

def bg_red;         "\e[41m#{self}\e[0m" end

#blackObject



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

def black;          "\e[30m#{self}\e[0m" end


31
# File 'lib/string.rb', line 31

def blink;          "\e[5m#{self}\e[25m" end

#blueObject



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

def blue;           "\e[34m#{self}\e[0m" end

#boldObject



28
# File 'lib/string.rb', line 28

def bold;           "\e[1m#{self}\e[22m" end

#brownObject



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

def brown;          "\e[33m#{self}\e[0m" end

#cyanObject



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

def cyan;           "\e[36m#{self}\e[0m" end

#debug_colorObject



35
# File 'lib/string.rb', line 35

def debug_color; self.green end

#error_colorObject



37
# File 'lib/string.rb', line 37

def error_color; self.red end

#fatal_colorObject



38
# File 'lib/string.rb', line 38

def fatal_color; self.bg_red end

#grayObject



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

def gray;           "\e[37m#{self}\e[0m" end

#greenObject



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

def green;          "\e[32m#{self}\e[0m" end

#italicObject



29
# File 'lib/string.rb', line 29

def italic;         "\e[3m#{self}\e[23m" end

#magentaObject



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

def magenta;        "\e[35m#{self}\e[0m" end

#redObject



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

def red;            "\e[31m#{self}\e[0m" end

#reverse_colorObject



32
# File 'lib/string.rb', line 32

def reverse_color;  "\e[7m#{self}\e[27m" end

#trace_colorObject



34
# File 'lib/string.rb', line 34

def trace_color; self.gray end

#underlineObject



30
# File 'lib/string.rb', line 30

def underline;      "\e[4m#{self}\e[24m" end

#underscoreObject



2
3
4
5
6
7
8
# File 'lib/string.rb', line 2

def underscore
  self.gsub(/::/, '/').
      gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
      gsub(/([a-z\d])([A-Z])/, '\1_\2').
      tr("-", "_").
      downcase
end

#unknown_colorObject



39
# File 'lib/string.rb', line 39

def unknown_color; self.bg_cyan end

#warning_colorObject



36
# File 'lib/string.rb', line 36

def warning_color; self.brown end