Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/puppet_x/enterprisemodules/oci/monkey_patches/string.rb
Overview
Add underscore method to String. Method borrowed from Rails
Instance Method Summary collapse
Instance Method Details
#downcase_first_letter ⇒ Object
15 16 17 |
# File 'lib/puppet_x/enterprisemodules/oci/monkey_patches/string.rb', line 15 def downcase_first_letter self[0].downcase + self[1..-1] end |
#underscore ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/puppet_x/enterprisemodules/oci/monkey_patches/string.rb', line 7 def underscore gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). gsub(/([a-z\d])([A-Z])/, '\1_\2'). tr('-', '_'). downcase end |