module Seahorse::Util

def underscore(string)

Returns:
  • (String) - Returns the underscored version of the given string.

Parameters:
  • string (String) --
def underscore(string)
  string.
    gsub(@irregular_regex) { |word| '_' + @irregular_inflections[word] }.
    gsub(/([A-Z0-9]+)([A-Z][a-z])/, '\1_\2').
    scan(/[a-z0-9]+|\d+|[A-Z0-9]+[a-z]*/).
    join('_').downcase
end