Class: String

Inherits:
Object
  • Object
show all
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

Instance Method Details

#blackString

changes the color of the string to black

Returns:

  • (String)

    the formatted string



63
64
65
# File 'lib/ruby_utils/string.rb', line 63

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

#black_bgString

changes the background of the string to black

Returns:

  • (String)

    the formatted string



159
160
161
# File 'lib/ruby_utils/string.rb', line 159

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

changes the style of the string to blink (not supported by every terminal application)

Returns:

  • (String)

    the formatted string



33
34
35
# File 'lib/ruby_utils/string.rb', line 33

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

#blueString

changes the color of the string to blue

Returns:

  • (String)

    the formatted string



105
106
107
# File 'lib/ruby_utils/string.rb', line 105

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

#blue_bgString

changes the background of the string to blue

Returns:

  • (String)

    the formatted string



201
202
203
# File 'lib/ruby_utils/string.rb', line 201

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

#brightString

change the string to colored bright

Returns:

  • (String)

    the formatted string



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

def bright
  "\e[1m#{self}\e[0m"
end

#cyanString

changes the color of the string to cyan

Returns:

  • (String)

    the formatted string



129
130
131
# File 'lib/ruby_utils/string.rb', line 129

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

#cyan_bgString

changes the background of the string to cyan

Returns:

  • (String)

    the formatted string



225
226
227
# File 'lib/ruby_utils/string.rb', line 225

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

#dark_grayString

changes the color of the string to dark_gray

Returns:

  • (String)

    the formatted string



147
148
149
# File 'lib/ruby_utils/string.rb', line 147

def dark_gray
  "\e[90m#{self}\e[0m"
end

#dark_gray_bgString

changes the background of the string to dark_gray

Returns:

  • (String)

    the formatted string



249
250
251
# File 'lib/ruby_utils/string.rb', line 249

def dark_gray_bg
  "\e[100m#{self}\e[0m"
end

#default_backgroundString

changes the color of the string to the default background color

Returns:

  • (String)

    the formatted string



57
58
59
# File 'lib/ruby_utils/string.rb', line 57

def default_background
  "\e[49m#{self}\e[0m"
end

#default_foregroundString

changes the color of the string to the default foreground color

Returns:

  • (String)

    the formatted string



51
52
53
# File 'lib/ruby_utils/string.rb', line 51

def default_foreground
  "\e[39m#{self}\e[0m"
end

#exchange_groundsString

exchanges the color and background of the string

Returns:

  • (String)

    the formatted string



39
40
41
# File 'lib/ruby_utils/string.rb', line 39

def exchange_grounds
  "\e[7m#{self}\e[0m"
end

#grayString

changes the color of the string to gray

Returns:

  • (String)

    the formatted string



14
15
16
# File 'lib/ruby_utils/string.rb', line 14

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

#greenString

changes the color of the string to green

Returns:

  • (String)

    the formatted string



81
82
83
# File 'lib/ruby_utils/string.rb', line 81

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

#green_bgString

changes the background of the string to green

Returns:

  • (String)

    the formatted string



177
178
179
# File 'lib/ruby_utils/string.rb', line 177

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

#hideString

changes the color of the string to the background color

Returns:

  • (String)

    the formatted string



45
46
47
# File 'lib/ruby_utils/string.rb', line 45

def hide
  "\e[8m#{self}\e[0m"
end

#italicString

changes the format of the string to italic

Returns:

  • (String)

    the formatted string



20
21
22
# File 'lib/ruby_utils/string.rb', line 20

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

#light_blueString

changes the color of the string to light_blue

Returns:

  • (String)

    the formatted string



111
112
113
# File 'lib/ruby_utils/string.rb', line 111

def light_blue
  "\e[94m#{self}\e[0m"
end

#light_blue_bgString

changes the background of the string to light_blue

Returns:

  • (String)

    the formatted string



207
208
209
# File 'lib/ruby_utils/string.rb', line 207

def light_blue_bg
  "\e[104m#{self}\e[0m"
end

#light_cyanString

changes the color of the string to light_cyan

Returns:

  • (String)

    the formatted string



135
136
137
# File 'lib/ruby_utils/string.rb', line 135

def light_cyan
  "\e[96m#{self}\e[0m"
end

#light_cyan_bgString

changes the background of the string to light_cyan

Returns:

  • (String)

    the formatted string



231
232
233
# File 'lib/ruby_utils/string.rb', line 231

def light_cyan_bg
  "\e[106m#{self}\e[0m"
end

#light_grayString

changes the color of the string to light_gray

Returns:

  • (String)

    the formatted string



141
142
143
# File 'lib/ruby_utils/string.rb', line 141

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

#light_gray_bgString

changes the background of the string to light_gray

Returns:

  • (String)

    the formatted string



243
244
245
# File 'lib/ruby_utils/string.rb', line 243

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

#light_greenString

changes the color of the string to light_green

Returns:

  • (String)

    the formatted string



87
88
89
# File 'lib/ruby_utils/string.rb', line 87

def light_green
  "\e[92m#{self}\e[0m"
end

#light_green_bgString

changes the background of the string to light_green

Returns:

  • (String)

    the formatted string



183
184
185
# File 'lib/ruby_utils/string.rb', line 183

def light_green_bg
  "\e[102m#{self}\e[0m"
end

#light_magentaString

changes the color of the string to light_magenta

Returns:

  • (String)

    the formatted string



123
124
125
# File 'lib/ruby_utils/string.rb', line 123

def light_magenta
  "\e[95m#{self}\e[0m"
end

#light_magenta_bgString

changes the background of the string to light_magenta

Returns:

  • (String)

    the formatted string



219
220
221
# File 'lib/ruby_utils/string.rb', line 219

def light_magenta_bg
  "\e[105m#{self}\e[0m"
end

#light_redString

changes the color of the string to light_red

Returns:

  • (String)

    the formatted string



75
76
77
# File 'lib/ruby_utils/string.rb', line 75

def light_red
  "\e[91m#{self}\e[0m"
end

#light_red_bgString

changes the background of the string to light_red

Returns:

  • (String)

    the formatted string



171
172
173
# File 'lib/ruby_utils/string.rb', line 171

def light_red_bg
  "\e[101m#{self}\e[0m"
end

#light_yellowString

changes the color of the string to light_yellow

Returns:

  • (String)

    the formatted string



99
100
101
# File 'lib/ruby_utils/string.rb', line 99

def light_yellow
  "\e[93m#{self}\e[0m"
end

#light_yellow_bgString

changes the background of the string to light_yellow

Returns:

  • (String)

    the formatted string



195
196
197
# File 'lib/ruby_utils/string.rb', line 195

def light_yellow_bg
  "\e[103m#{self}\e[0m"
end

#magentaString

changes the color of the string to magenta

Returns:

  • (String)

    the formatted string



117
118
119
# File 'lib/ruby_utils/string.rb', line 117

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

#magenta_bgString

changes the background of the string to magenta

Returns:

  • (String)

    the formatted string



213
214
215
# File 'lib/ruby_utils/string.rb', line 213

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

#redString

changes the color of the string to red

Returns:

  • (String)

    the formatted string



69
70
71
# File 'lib/ruby_utils/string.rb', line 69

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

#red_bgString

changes the background of the string to red

Returns:

  • (String)

    the formatted string



165
166
167
# File 'lib/ruby_utils/string.rb', line 165

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

#underlineString

underlines the string

Returns:

  • (String)

    the formatted string



26
27
28
# File 'lib/ruby_utils/string.rb', line 26

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

#whiteString

changes the color of the string to white

Returns:

  • (String)

    the formatted string



153
154
155
# File 'lib/ruby_utils/string.rb', line 153

def white
  "\e[97m#{self}\e[0m"
end

#white_bgString

changes the background of the string to white

Returns:

  • (String)

    the formatted string



237
238
239
# File 'lib/ruby_utils/string.rb', line 237

def white_bg
  "\e[107m#{self}\e[0m"
end

#yellowString

changes the color of the string to yellow

Returns:

  • (String)

    the formatted string



93
94
95
# File 'lib/ruby_utils/string.rb', line 93

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

#yellow_bgString

changes the background of the string to yellow

Returns:

  • (String)

    the formatted string



189
190
191
# File 'lib/ruby_utils/string.rb', line 189

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