Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/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
- #blink ⇒ Object
- #blue ⇒ Object
- #bold ⇒ Object
- #brown ⇒ Object
- #cyan ⇒ Object
- #debug_color ⇒ Object
- #error_color ⇒ Object
- #fatal_color ⇒ Object
- #gray ⇒ Object
- #green ⇒ Object
- #italic ⇒ Object
- #magenta ⇒ Object
- #red ⇒ Object
- #reverse_color ⇒ Object
- #trace_color ⇒ Object
- #underline ⇒ Object
- #underscore ⇒ Object
- #unknown_color ⇒ Object
- #warning_color ⇒ Object
Instance Method Details
#bg_black ⇒ Object
19 |
# File 'lib/string.rb', line 19 def bg_black; "\e[40m#{self}\e[0m" end |
#bg_blue ⇒ Object
23 |
# File 'lib/string.rb', line 23 def bg_blue; "\e[44m#{self}\e[0m" end |
#bg_brown ⇒ Object
22 |
# File 'lib/string.rb', line 22 def bg_brown; "\e[43m#{self}\e[0m" end |
#bg_cyan ⇒ Object
25 |
# File 'lib/string.rb', line 25 def bg_cyan; "\e[46m#{self}\e[0m" end |
#bg_gray ⇒ Object
26 |
# File 'lib/string.rb', line 26 def bg_gray; "\e[47m#{self}\e[0m" end |
#bg_green ⇒ Object
21 |
# File 'lib/string.rb', line 21 def bg_green; "\e[42m#{self}\e[0m" end |
#bg_magenta ⇒ Object
24 |
# File 'lib/string.rb', line 24 def bg_magenta; "\e[45m#{self}\e[0m" end |
#bg_red ⇒ Object
20 |
# File 'lib/string.rb', line 20 def bg_red; "\e[41m#{self}\e[0m" end |
#black ⇒ Object
10 |
# File 'lib/string.rb', line 10 def black; "\e[30m#{self}\e[0m" end |
#blink ⇒ Object
31 |
# File 'lib/string.rb', line 31 def blink; "\e[5m#{self}\e[25m" end |
#blue ⇒ Object
14 |
# File 'lib/string.rb', line 14 def blue; "\e[34m#{self}\e[0m" end |
#bold ⇒ Object
28 |
# File 'lib/string.rb', line 28 def bold; "\e[1m#{self}\e[22m" end |
#brown ⇒ Object
13 |
# File 'lib/string.rb', line 13 def brown; "\e[33m#{self}\e[0m" end |
#cyan ⇒ Object
16 |
# File 'lib/string.rb', line 16 def cyan; "\e[36m#{self}\e[0m" end |
#debug_color ⇒ Object
35 |
# File 'lib/string.rb', line 35 def debug_color; self.green end |
#error_color ⇒ Object
37 |
# File 'lib/string.rb', line 37 def error_color; self.red end |
#fatal_color ⇒ Object
38 |
# File 'lib/string.rb', line 38 def fatal_color; self.bg_red end |
#gray ⇒ Object
17 |
# File 'lib/string.rb', line 17 def gray; "\e[37m#{self}\e[0m" end |
#green ⇒ Object
12 |
# File 'lib/string.rb', line 12 def green; "\e[32m#{self}\e[0m" end |
#italic ⇒ Object
29 |
# File 'lib/string.rb', line 29 def italic; "\e[3m#{self}\e[23m" end |
#magenta ⇒ Object
15 |
# File 'lib/string.rb', line 15 def magenta; "\e[35m#{self}\e[0m" end |
#red ⇒ Object
11 |
# File 'lib/string.rb', line 11 def red; "\e[31m#{self}\e[0m" end |
#reverse_color ⇒ Object
32 |
# File 'lib/string.rb', line 32 def reverse_color; "\e[7m#{self}\e[27m" end |
#trace_color ⇒ Object
34 |
# File 'lib/string.rb', line 34 def trace_color; self.gray end |
#underline ⇒ Object
30 |
# File 'lib/string.rb', line 30 def underline; "\e[4m#{self}\e[24m" end |
#underscore ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/string.rb', line 2 def underscore self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). gsub(/([a-z\d])([A-Z])/, '\1_\2'). tr("-", "_"). downcase end |
#unknown_color ⇒ Object
39 |
# File 'lib/string.rb', line 39 def unknown_color; self.bg_cyan end |
#warning_color ⇒ Object
36 |
# File 'lib/string.rb', line 36 def warning_color; self.brown end |