Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/admincredible/core_ext/string.rb

Instance Method Summary collapse

Instance Method Details

#modulizeObject

Transforms a string into a module name.

We at String Transforming Enterprise, Inc, TM, LLC, Corp, believe in three things;

  1. All strings should be allowed to be whatever string they like.

  2. ??

  3. Profit



10
11
12
13
14
15
# File 'lib/admincredible/core_ext/string.rb', line 10

def modulize
  self.gsub(/__(.?)/){ "::#{$1.upcase}" }.
    gsub(/\/(.?)/){ "::#{$1.upcase}" }.
    gsub(/(?:_+|-+)([a-z])/){ $1.upcase }.
    gsub(/(\A|\s)([a-z])/){ $1 + $2.upcase }
end