Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/ruby_utils/string.rb
Overview
Extension of the class String to modify a String in color and type Note: e stands for the esc code Note: not all modifications are available for every terminal application
Instance Method Summary collapse
-
#black ⇒ String
changes the color of the string to black.
-
#black_bg ⇒ String
changes the background of the string to black.
-
#blink ⇒ String
changes the style of the string to blink (not supported by every terminal application).
-
#blue ⇒ String
changes the color of the string to blue.
-
#blue_bg ⇒ String
changes the background of the string to blue.
-
#bright ⇒ String
change the string to colored bright.
-
#cyan ⇒ String
changes the color of the string to cyan.
-
#cyan_bg ⇒ String
changes the background of the string to cyan.
-
#dark_gray ⇒ String
changes the color of the string to dark_gray.
-
#dark_gray_bg ⇒ String
changes the background of the string to dark_gray.
-
#default_background ⇒ String
changes the color of the string to the default background color.
-
#default_foreground ⇒ String
changes the color of the string to the default foreground color.
-
#exchange_grounds ⇒ String
exchanges the color and background of the string.
-
#gray ⇒ String
changes the color of the string to gray.
-
#green ⇒ String
changes the color of the string to green.
-
#green_bg ⇒ String
changes the background of the string to green.
-
#hide ⇒ String
changes the color of the string to the background color.
-
#italic ⇒ String
changes the format of the string to italic.
-
#light_blue ⇒ String
changes the color of the string to light_blue.
-
#light_blue_bg ⇒ String
changes the background of the string to light_blue.
-
#light_cyan ⇒ String
changes the color of the string to light_cyan.
-
#light_cyan_bg ⇒ String
changes the background of the string to light_cyan.
-
#light_gray ⇒ String
changes the color of the string to light_gray.
-
#light_gray_bg ⇒ String
changes the background of the string to light_gray.
-
#light_green ⇒ String
changes the color of the string to light_green.
-
#light_green_bg ⇒ String
changes the background of the string to light_green.
-
#light_magenta ⇒ String
changes the color of the string to light_magenta.
-
#light_magenta_bg ⇒ String
changes the background of the string to light_magenta.
-
#light_red ⇒ String
changes the color of the string to light_red.
-
#light_red_bg ⇒ String
changes the background of the string to light_red.
-
#light_yellow ⇒ String
changes the color of the string to light_yellow.
-
#light_yellow_bg ⇒ String
changes the background of the string to light_yellow.
-
#magenta ⇒ String
changes the color of the string to magenta.
-
#magenta_bg ⇒ String
changes the background of the string to magenta.
-
#red ⇒ String
changes the color of the string to red.
-
#red_bg ⇒ String
changes the background of the string to red.
-
#underline ⇒ String
underlines the string.
-
#white ⇒ String
changes the color of the string to white.
-
#white_bg ⇒ String
changes the background of the string to white.
-
#yellow ⇒ String
changes the color of the string to yellow.
-
#yellow_bg ⇒ String
changes the background of the string to yellow.
Instance Method Details
#black ⇒ String
changes the color of the string to black
63 64 65 |
# File 'lib/ruby_utils/string.rb', line 63 def black "\e[30m#{self}\e[0m" end |
#black_bg ⇒ String
changes the background of the string to black
159 160 161 |
# File 'lib/ruby_utils/string.rb', line 159 def black_bg "\e[40m#{self}\e[0m" end |
#blink ⇒ String
changes the style of the string to blink (not supported by every terminal application)
33 34 35 |
# File 'lib/ruby_utils/string.rb', line 33 def blink "\e[5m#{self}\e[25m" end |
#blue ⇒ String
changes the color of the string to blue
105 106 107 |
# File 'lib/ruby_utils/string.rb', line 105 def blue "\e[34m#{self}\e[0m" end |
#blue_bg ⇒ String
changes the background of the string to blue
201 202 203 |
# File 'lib/ruby_utils/string.rb', line 201 def blue_bg "\e[44m#{self}\e[0m" end |
#bright ⇒ String
change the string to colored bright
8 9 10 |
# File 'lib/ruby_utils/string.rb', line 8 def bright "\e[1m#{self}\e[0m" end |
#cyan ⇒ String
changes the color of the string to cyan
129 130 131 |
# File 'lib/ruby_utils/string.rb', line 129 def cyan "\e[36m#{self}\e[0m" end |
#cyan_bg ⇒ String
changes the background of the string to cyan
225 226 227 |
# File 'lib/ruby_utils/string.rb', line 225 def cyan_bg "\e[46m#{self}\e[0m" end |
#dark_gray ⇒ String
changes the color of the string to dark_gray
147 148 149 |
# File 'lib/ruby_utils/string.rb', line 147 def dark_gray "\e[90m#{self}\e[0m" end |
#dark_gray_bg ⇒ String
changes the background of the string to dark_gray
249 250 251 |
# File 'lib/ruby_utils/string.rb', line 249 def dark_gray_bg "\e[100m#{self}\e[0m" end |
#default_background ⇒ String
changes the color of the string to the default background color
57 58 59 |
# File 'lib/ruby_utils/string.rb', line 57 def default_background "\e[49m#{self}\e[0m" end |
#default_foreground ⇒ String
changes the color of the string to the default foreground color
51 52 53 |
# File 'lib/ruby_utils/string.rb', line 51 def default_foreground "\e[39m#{self}\e[0m" end |
#exchange_grounds ⇒ String
exchanges the color and background of the string
39 40 41 |
# File 'lib/ruby_utils/string.rb', line 39 def exchange_grounds "\e[7m#{self}\e[0m" end |
#gray ⇒ String
changes the color of the string to gray
14 15 16 |
# File 'lib/ruby_utils/string.rb', line 14 def gray "\e[2m#{self}\e[0m" end |
#green ⇒ String
changes the color of the string to green
81 82 83 |
# File 'lib/ruby_utils/string.rb', line 81 def green "\e[32m#{self}\e[0m" end |
#green_bg ⇒ String
changes the background of the string to green
177 178 179 |
# File 'lib/ruby_utils/string.rb', line 177 def green_bg "\e[42m#{self}\e[0m" end |
#hide ⇒ String
changes the color of the string to the background color
45 46 47 |
# File 'lib/ruby_utils/string.rb', line 45 def hide "\e[8m#{self}\e[0m" end |
#italic ⇒ String
changes the format of the string to italic
20 21 22 |
# File 'lib/ruby_utils/string.rb', line 20 def italic "\e[3m#{self}\e[0m" end |
#light_blue ⇒ String
changes the color of the string to light_blue
111 112 113 |
# File 'lib/ruby_utils/string.rb', line 111 def light_blue "\e[94m#{self}\e[0m" end |
#light_blue_bg ⇒ String
changes the background of the string to light_blue
207 208 209 |
# File 'lib/ruby_utils/string.rb', line 207 def light_blue_bg "\e[104m#{self}\e[0m" end |
#light_cyan ⇒ String
changes the color of the string to light_cyan
135 136 137 |
# File 'lib/ruby_utils/string.rb', line 135 def light_cyan "\e[96m#{self}\e[0m" end |
#light_cyan_bg ⇒ String
changes the background of the string to light_cyan
231 232 233 |
# File 'lib/ruby_utils/string.rb', line 231 def light_cyan_bg "\e[106m#{self}\e[0m" end |
#light_gray ⇒ String
changes the color of the string to light_gray
141 142 143 |
# File 'lib/ruby_utils/string.rb', line 141 def light_gray "\e[37m#{self}\e[0m" end |
#light_gray_bg ⇒ String
changes the background of the string to light_gray
243 244 245 |
# File 'lib/ruby_utils/string.rb', line 243 def light_gray_bg "\e[47m#{self}\e[0m" end |
#light_green ⇒ String
changes the color of the string to light_green
87 88 89 |
# File 'lib/ruby_utils/string.rb', line 87 def light_green "\e[92m#{self}\e[0m" end |
#light_green_bg ⇒ String
changes the background of the string to light_green
183 184 185 |
# File 'lib/ruby_utils/string.rb', line 183 def light_green_bg "\e[102m#{self}\e[0m" end |
#light_magenta ⇒ String
changes the color of the string to light_magenta
123 124 125 |
# File 'lib/ruby_utils/string.rb', line 123 def light_magenta "\e[95m#{self}\e[0m" end |
#light_magenta_bg ⇒ String
changes the background of the string to light_magenta
219 220 221 |
# File 'lib/ruby_utils/string.rb', line 219 def light_magenta_bg "\e[105m#{self}\e[0m" end |
#light_red ⇒ String
changes the color of the string to light_red
75 76 77 |
# File 'lib/ruby_utils/string.rb', line 75 def light_red "\e[91m#{self}\e[0m" end |
#light_red_bg ⇒ String
changes the background of the string to light_red
171 172 173 |
# File 'lib/ruby_utils/string.rb', line 171 def light_red_bg "\e[101m#{self}\e[0m" end |
#light_yellow ⇒ String
changes the color of the string to light_yellow
99 100 101 |
# File 'lib/ruby_utils/string.rb', line 99 def light_yellow "\e[93m#{self}\e[0m" end |
#light_yellow_bg ⇒ String
changes the background of the string to light_yellow
195 196 197 |
# File 'lib/ruby_utils/string.rb', line 195 def light_yellow_bg "\e[103m#{self}\e[0m" end |
#magenta ⇒ String
changes the color of the string to magenta
117 118 119 |
# File 'lib/ruby_utils/string.rb', line 117 def magenta "\e[35m#{self}\e[0m" end |
#magenta_bg ⇒ String
changes the background of the string to magenta
213 214 215 |
# File 'lib/ruby_utils/string.rb', line 213 def magenta_bg "\e[45m#{self}\e[0m" end |
#red ⇒ String
changes the color of the string to red
69 70 71 |
# File 'lib/ruby_utils/string.rb', line 69 def red "\e[31m#{self}\e[0m" end |
#red_bg ⇒ String
changes the background of the string to red
165 166 167 |
# File 'lib/ruby_utils/string.rb', line 165 def red_bg "\e[41m#{self}\e[0m" end |
#underline ⇒ String
underlines the string
26 27 28 |
# File 'lib/ruby_utils/string.rb', line 26 def underline "\e[4m#{self}\e[0m" end |
#white ⇒ String
changes the color of the string to white
153 154 155 |
# File 'lib/ruby_utils/string.rb', line 153 def white "\e[97m#{self}\e[0m" end |
#white_bg ⇒ String
changes the background of the string to white
237 238 239 |
# File 'lib/ruby_utils/string.rb', line 237 def white_bg "\e[107m#{self}\e[0m" end |
#yellow ⇒ String
changes the color of the string to yellow
93 94 95 |
# File 'lib/ruby_utils/string.rb', line 93 def yellow "\e[33m#{self}\e[0m" end |
#yellow_bg ⇒ String
changes the background of the string to yellow
189 190 191 |
# File 'lib/ruby_utils/string.rb', line 189 def yellow_bg "\e[43m#{self}\e[0m" end |