Class: String

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

Instance Method Summary collapse

Instance Method Details

#bg_blackObject



31
32
33
# File 'lib/string_extensions.rb', line 31

def bg_black
  colorize self, 40
end

#bg_blueObject



43
44
45
# File 'lib/string_extensions.rb', line 43

def bg_blue
  colorize self, 44
end

#bg_cyanObject



49
50
51
# File 'lib/string_extensions.rb', line 49

def bg_cyan
  colorize self, 46
end

#bg_greenObject



37
38
39
# File 'lib/string_extensions.rb', line 37

def bg_green
	  colorize self, 42
end

#bg_magentaObject



46
47
48
# File 'lib/string_extensions.rb', line 46

def bg_magenta
  colorize self, 45
end

#bg_redObject



34
35
36
# File 'lib/string_extensions.rb', line 34

def bg_red
  colorize self, 41
end

#bg_whiteObject



40
41
42
# File 'lib/string_extensions.rb', line 40

def bg_white
  colorize self, 43 
end

#bg_yellowObject



52
53
54
# File 'lib/string_extensions.rb', line 52

def bg_yellow
  colorize self, 47
end

#blackObject



6
7
8
# File 'lib/string_extensions.rb', line 6

def black
  colorize self, 30
end


65
66
67
# File 'lib/string_extensions.rb', line 65

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

#blueObject



18
19
20
# File 'lib/string_extensions.rb', line 18

def blue
  colorize self, 34
end

#boldObject



56
57
58
# File 'lib/string_extensions.rb', line 56

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

#colorize(text, color_code) ⇒ Object



3
4
5
# File 'lib/string_extensions.rb', line 3

def colorize(text, color_code)
 		"\e[#{color_code}m#{text}\e[0m"
end

#cyanObject



24
25
26
# File 'lib/string_extensions.rb', line 24

def cyan
  colorize self, 36
end

#expand_with(list) ⇒ Object



72
73
74
75
76
77
78
79
80
81
# File 'lib/string_extensions.rb', line 72

def expand_with list
	out = []
	list.each{ |i|
		f = self + '.' + i
		if File.exists? f
			out << f
		end
	}
	out
end

#greenObject



12
13
14
# File 'lib/string_extensions.rb', line 12

def green
  colorize self, 32
end

#italicObject



59
60
61
# File 'lib/string_extensions.rb', line 59

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

#magentaObject



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

def magenta
  colorize self, 35
end

#redObject



9
10
11
# File 'lib/string_extensions.rb', line 9

def red
  colorize self, 31
end

#reverse_colorObject



68
69
70
# File 'lib/string_extensions.rb', line 68

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

#underlineObject



62
63
64
# File 'lib/string_extensions.rb', line 62

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

#whiteObject



15
16
17
# File 'lib/string_extensions.rb', line 15

def white
  colorize self, 33
end

#yellowObject



27
28
29
# File 'lib/string_extensions.rb', line 27

def yellow
  colorize self, 37
end