Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/cfnvpn/string.rb
Instance Method Summary collapse
- #colorize(color_code) ⇒ Object
- #event_id_safe ⇒ Object
- #green ⇒ Object
- #red ⇒ Object
- #resource_safe ⇒ Object
- #underscore ⇒ Object
- #yellow ⇒ Object
Instance Method Details
#colorize(color_code) ⇒ Object
18 19 20 |
# File 'lib/cfnvpn/string.rb', line 18 def colorize(color_code) "\e[#{color_code}m#{self}\e[0m" end |
#event_id_safe ⇒ Object
14 15 16 |
# File 'lib/cfnvpn/string.rb', line 14 def event_id_safe self.gsub('*', 'wildcard').gsub(/[^\.\-_A-Za-z0-9]+/, "").downcase end |
#green ⇒ Object
26 27 28 |
# File 'lib/cfnvpn/string.rb', line 26 def green colorize(32) end |
#red ⇒ Object
22 23 24 |
# File 'lib/cfnvpn/string.rb', line 22 def red colorize(31) end |
#resource_safe ⇒ Object
10 11 12 |
# File 'lib/cfnvpn/string.rb', line 10 def resource_safe self.gsub(/[^a-zA-Z0-9]/, "").capitalize end |
#underscore ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/cfnvpn/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 |
#yellow ⇒ Object
30 31 32 |
# File 'lib/cfnvpn/string.rb', line 30 def yellow colorize(33) end |