Method: String#underscore
- Defined in:
- lib/string_overrides.rb
#underscore ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/string_overrides.rb', line 3 def underscore gsub(/::/, '/') .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('-', '_') .downcase end |