Sha256: 52c2542e00d1e57d1bab5df7bd39f977270a4bc09c8ac665ec1e4f8801da0ed9
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
# some methods borrowed from ActiveSupport # https://github.com/rails/rails/tree/master/activesupport # MIT License (http://www.opensource.org/licenses/MIT) class String def camelize string = self string = string.sub(/^[a-z\d]*/) { $&.capitalize } string = string.gsub(/\-/,'_') string.gsub(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{$2.capitalize}" }.gsub('/', '::') end if Module.method(:const_get).arity == 1 def constantize names = self.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 else def constantize names = self.split('::') names.shift if names.empty? || names.first.empty? constant = Object names.each do |name| constant = constant.const_defined?(name, false) ? constant.const_get(name) : constant.const_missing(name) end constant end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bently-1.0.2 | lib/bently/core_ext/string.rb |
bently-1.0.1 | lib/bently/core_ext/string.rb |
bently-1.0.0 | lib/bently/core_ext/string.rb |