Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/retrospec.rb
Overview
monkey patch in some color effects string methods
Instance Method Summary collapse
- #camel_case ⇒ Object
- #cyan ⇒ Object
- #fatal ⇒ Object
- #green ⇒ Object
- #info ⇒ Object
- #red ⇒ Object
- #underscore ⇒ Object
- #warning ⇒ Object
- #yellow ⇒ Object
Instance Method Details
#camel_case ⇒ Object
12 13 14 15 |
# File 'lib/retrospec.rb', line 12 def camel_case return self if self !~ /_/ && self =~ /[A-Z]+.*/ split('_').map(&:capitalize).join end |
#cyan ⇒ Object
6 |
# File 'lib/retrospec.rb', line 6 def cyan; "\033[36m#{self}\033[0m" end |
#fatal ⇒ Object
9 |
# File 'lib/retrospec.rb', line 9 def fatal; red end |
#green ⇒ Object
5 |
# File 'lib/retrospec.rb', line 5 def green; "\033[32m#{self}\033[0m" end |
#info ⇒ Object
10 |
# File 'lib/retrospec.rb', line 10 def info; green end |
#red ⇒ Object
4 |
# File 'lib/retrospec.rb', line 4 def red; "\033[31m#{self}\033[0m" end |
#underscore ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/retrospec.rb', line 17 def underscore self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end |
#warning ⇒ Object
8 |
# File 'lib/retrospec.rb', line 8 def warning; yellow end |
#yellow ⇒ Object
7 |
# File 'lib/retrospec.rb', line 7 def yellow; "\033[33m#{self}\033[0m" end |