Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/string_extensions.rb
Instance Method Summary collapse
- #bg_black ⇒ Object
- #bg_blue ⇒ Object
- #bg_cyan ⇒ Object
- #bg_green ⇒ Object
- #bg_magenta ⇒ Object
- #bg_red ⇒ Object
- #bg_white ⇒ Object
- #bg_yellow ⇒ Object
- #black ⇒ Object
- #blink ⇒ Object
- #blue ⇒ Object
- #bold ⇒ Object
- #colorize(text, color_code) ⇒ Object
- #cyan ⇒ Object
- #expand_with(list) ⇒ Object
- #green ⇒ Object
- #italic ⇒ Object
- #magenta ⇒ Object
- #red ⇒ Object
- #reverse_color ⇒ Object
- #underline ⇒ Object
- #white ⇒ Object
- #yellow ⇒ Object
Instance Method Details
#bg_black ⇒ Object
31 32 33 |
# File 'lib/string_extensions.rb', line 31 def bg_black colorize self, 40 end |
#bg_blue ⇒ Object
43 44 45 |
# File 'lib/string_extensions.rb', line 43 def bg_blue colorize self, 44 end |
#bg_cyan ⇒ Object
49 50 51 |
# File 'lib/string_extensions.rb', line 49 def bg_cyan colorize self, 46 end |
#bg_green ⇒ Object
37 38 39 |
# File 'lib/string_extensions.rb', line 37 def bg_green colorize self, 42 end |
#bg_magenta ⇒ Object
46 47 48 |
# File 'lib/string_extensions.rb', line 46 def bg_magenta colorize self, 45 end |
#bg_red ⇒ Object
34 35 36 |
# File 'lib/string_extensions.rb', line 34 def bg_red colorize self, 41 end |
#bg_white ⇒ Object
40 41 42 |
# File 'lib/string_extensions.rb', line 40 def bg_white colorize self, 43 end |
#bg_yellow ⇒ Object
52 53 54 |
# File 'lib/string_extensions.rb', line 52 def bg_yellow colorize self, 47 end |
#black ⇒ Object
6 7 8 |
# File 'lib/string_extensions.rb', line 6 def black colorize self, 30 end |
#blink ⇒ Object
65 66 67 |
# File 'lib/string_extensions.rb', line 65 def blink "\e[5m#{self}\e[25m" end |
#blue ⇒ Object
18 19 20 |
# File 'lib/string_extensions.rb', line 18 def blue colorize self, 34 end |
#bold ⇒ Object
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 |
#cyan ⇒ Object
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 list out = [] list.each{ |i| f = self + '.' + i if File.exists? f out << f end } out end |
#green ⇒ Object
12 13 14 |
# File 'lib/string_extensions.rb', line 12 def green colorize self, 32 end |
#italic ⇒ Object
59 60 61 |
# File 'lib/string_extensions.rb', line 59 def italic "\e[3m#{self}\e[23m" end |
#magenta ⇒ Object
21 22 23 |
# File 'lib/string_extensions.rb', line 21 def magenta colorize self, 35 end |
#red ⇒ Object
9 10 11 |
# File 'lib/string_extensions.rb', line 9 def red colorize self, 31 end |
#reverse_color ⇒ Object
68 69 70 |
# File 'lib/string_extensions.rb', line 68 def reverse_color "\e[7m#{self}\e[27m" end |
#underline ⇒ Object
62 63 64 |
# File 'lib/string_extensions.rb', line 62 def underline "\e[4m#{self}\e[24m" end |
#white ⇒ Object
15 16 17 |
# File 'lib/string_extensions.rb', line 15 def white colorize self, 33 end |
#yellow ⇒ Object
27 28 29 |
# File 'lib/string_extensions.rb', line 27 def yellow colorize self, 37 end |