Module: Archfiend::String::Camelize

Defined in:
lib/archfiend/core_ext/string/camelize.rb

Instance Method Summary collapse

Instance Method Details

#camelizeString

rubocop:disable Style/PerlBackrefs

Returns:

  • (String)

    String in the camelized format, first letter capital



6
7
8
9
10
11
# File 'lib/archfiend/core_ext/string/camelize.rb', line 6

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