Class: String
- Inherits:
- 
      Object
      
        - Object
- String
 
- Defined in:
- lib/cloudpassage/cloudpassage.rb
Overview
Add camel-to-snake-case conversion
Instance Method Summary collapse
- 
  
    
      #underscore  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    returns camel-case representation of snake-case string. 
Instance Method Details
#underscore ⇒ Object
returns camel-case representation of snake-case string.
| 22 23 24 25 26 27 | # File 'lib/cloudpassage/cloudpassage.rb', line 22 def underscore self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). gsub(/([a-z\d])([A-Z])/, '\1_\2'). tr('-', '_').downcase end |