Class: SmartIoC::StringUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_ioc/string_utils.rb

Class Method Summary collapse

Class Method Details

.camelize(term) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/smart_ioc/string_utils.rb', line 4

def camelize(term)
  string = term.to_s
  string = string.sub(/^[a-z\d]*/) { |match| match.capitalize }
  string.gsub!(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }
  string.gsub!("/".freeze, "::".freeze)
  string
end