Sha256: 9f6be5913e2af40a207bcb15e4ffc43df5e4ad813928570629b65eaf23d801e9
Contents?: true
Size: 582 Bytes
Versions: 6
Compression:
Stored size: 582 Bytes
Contents
class TestHarness module Utilities module_function def camelize(string) string = string.sub(/^[a-z\d]*/) { $&.capitalize } string = string.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }.gsub('/', '::') end def constantize(camel_cased_word) names = camel_cased_word.split('::') names.shift if names.empty? || names.first.empty? constant = Object names.each do |name| constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) end constant end end end
Version data entries
6 entries across 6 versions & 1 rubygems