Class: String

Inherits:
Object show all
Defined in:
lib/ruby_ext.rb

Instance Method Summary collapse

Instance Method Details

#methodizeObject

From the Facets package.

Changes a module name in a method compatible name.



99
100
101
# File 'lib/ruby_ext.rb', line 99

def methodize
  to_s.gsub(/([A-Z])/, '_\1').downcase.gsub(/^_/,'').gsub(/(::|\/)_?/, '__')
end

#modulizeObject

From the Facets package.

Changes a method name in a module compatible name.



106
107
108
# File 'lib/ruby_ext.rb', line 106

def modulize
  to_s.gsub(/(__|\/)(.?)/){ "::" + $2.upcase }.gsub(/(^|_)(.)/){ $2.upcase }
end