Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/shot_libs/helper_loader.rb,
lib/shot_libs/library_loader.rb

Instance Method Summary collapse

Instance Method Details

#underscoreObject

Converts a CamelCased string to a underscore_string



16
17
18
19
20
21
22
# File 'lib/shot_libs/helper_loader.rb', line 16

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