Sha256: a85304d7a38e9427c14fde6565ead630681d8a823a964c5271deac3235b60351
Contents?: true
Size: 492 Bytes
Versions: 5
Compression:
Stored size: 492 Bytes
Contents
class String # Converts a string to module name representation. # # This is essentially #camelcase. It also converts # '/' to '::' which is useful for converting # paths to namespaces. # # Examples # "method_name".modulize #=> "MethodName" # "method/name".modulize #=> "Method::Name" # def modulize gsub('__','/'). gsub(/\/(.?)/){ "::#{$1.upcase}" }. gsub(/(?:_+|-+)([a-z])/){ $1.upcase }. gsub(/(\A|\s)([a-z])/){ $1 + $2.upcase } end end
Version data entries
5 entries across 5 versions & 2 rubygems