Method: String#underscore

Defined in:
lib/sequel/extensions/inflector.rb

#underscoreObject

The reverse of camelize. Makes an underscored form from the expression in the string. Also changes '::' to '/' to convert namespaces to paths.

Examples "ActiveRecord".underscore #=> "active_record" "ActiveRecord::Errors".underscore #=> active_record/errors



254
255
256
257
# File 'lib/sequel/extensions/inflector.rb', line 254

def underscore
  gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
    gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("-", "_").downcase
end