Class: String

Inherits:
Object show all
Defined in:
lib/active_component/core_extensions.rb

Instance Method Summary collapse

Instance Method Details

#hyphenizeObject

Performs same transformation as underscore, but with hyphens



22
23
24
25
26
27
28
29
# File 'lib/active_component/core_extensions.rb', line 22

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