Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/admincredible/core_ext/string.rb
Instance Method Summary collapse
-
#modulize ⇒ Object
Transforms a string into a module name.
Instance Method Details
#modulize ⇒ Object
Transforms a string into a module name.
We at String Transforming Enterprise, Inc, TM, LLC, Corp, believe in three things;
-
All strings should be allowed to be whatever string they like.
-
??
-
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 |