Method: String#underscoreize
- Defined in:
- lib/core_ext/string.rb
#underscoreize ⇒ String
Find words breaks and insert underscores
13 14 15 16 17 18 19 |
# File 'lib/core_ext/string.rb', line 13 def underscoreize self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end |