Method: DataDuck::Util.camelcase_to_underscore

Defined in:
lib/dataduck/util.rb

.camelcase_to_underscore(str) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/dataduck/util.rb', line 22

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