Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/core_ext/string.rb
Instance Method Summary collapse
- #bg_black ⇒ Object
- #bg_blue ⇒ Object
- #bg_brown ⇒ Object
- #bg_cyan ⇒ Object
- #bg_gray ⇒ Object
- #bg_green ⇒ Object
- #bg_magenta ⇒ Object
- #bg_red ⇒ Object
- #black ⇒ Object
- #blue ⇒ Object
- #bold ⇒ Object
- #brown ⇒ Object
- #cyan ⇒ Object
- #gray ⇒ Object
- #green ⇒ Object
- #magenta ⇒ Object
- #randomize_color ⇒ Object
- #red ⇒ Object
- #reverse_color ⇒ Object
- #trim_and_rjust(len) ⇒ Object
Instance Method Details
#bg_black ⇒ Object
11 |
# File 'lib/core_ext/string.rb', line 11 def bg_black; "\033[40m#{self}\033[0m" end |
#bg_blue ⇒ Object
15 |
# File 'lib/core_ext/string.rb', line 15 def bg_blue; "\033[44m#{self}\033[0m" end |
#bg_brown ⇒ Object
14 |
# File 'lib/core_ext/string.rb', line 14 def bg_brown; "\033[43m#{self}\033[0m" end |
#bg_cyan ⇒ Object
17 |
# File 'lib/core_ext/string.rb', line 17 def bg_cyan; "\033[46m#{self}\033[0m" end |
#bg_gray ⇒ Object
18 |
# File 'lib/core_ext/string.rb', line 18 def bg_gray; "\033[47m#{self}\033[0m" end |
#bg_green ⇒ Object
13 |
# File 'lib/core_ext/string.rb', line 13 def bg_green; "\033[42m#{self}\033[0m" end |
#bg_magenta ⇒ Object
16 |
# File 'lib/core_ext/string.rb', line 16 def bg_magenta; "\033[45m#{self}\033[0m" end |
#bg_red ⇒ Object
12 |
# File 'lib/core_ext/string.rb', line 12 def bg_red; "\033[41m#{self}\033[0m" end |
#black ⇒ Object
3 |
# File 'lib/core_ext/string.rb', line 3 def black; "\033[30m#{self}\033[0m" end |
#blue ⇒ Object
7 |
# File 'lib/core_ext/string.rb', line 7 def blue; "\033[34m#{self}\033[0m" end |
#bold ⇒ Object
19 |
# File 'lib/core_ext/string.rb', line 19 def bold; "\033[1m#{self}\033[22m" end |
#brown ⇒ Object
6 |
# File 'lib/core_ext/string.rb', line 6 def brown; "\033[33m#{self}\033[0m" end |
#cyan ⇒ Object
9 |
# File 'lib/core_ext/string.rb', line 9 def cyan; "\033[36m#{self}\033[0m" end |
#gray ⇒ Object
10 |
# File 'lib/core_ext/string.rb', line 10 def gray; "\033[37m#{self}\033[0m" end |
#green ⇒ Object
5 |
# File 'lib/core_ext/string.rb', line 5 def green; "\033[32m#{self}\033[0m" end |
#magenta ⇒ Object
8 |
# File 'lib/core_ext/string.rb', line 8 def magenta; "\033[35m#{self}\033[0m" end |
#randomize_color ⇒ Object
22 23 24 |
# File 'lib/core_ext/string.rb', line 22 def randomize_color "\033[3#{self.hash % 6 + 1}m#{self}\033[0m" end |
#red ⇒ Object
4 |
# File 'lib/core_ext/string.rb', line 4 def red; "\033[31m#{self}\033[0m" end |
#reverse_color ⇒ Object
20 |
# File 'lib/core_ext/string.rb', line 20 def reverse_color; "\033[7m#{self}\033[27m" end |
#trim_and_rjust(len) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/core_ext/string.rb', line 26 def trim_and_rjust(len) if self.length > len self[0 .. (len/2 - 2)] + ".." + self[-(len/2) .. -1] else self.rjust len end end |