Class: String

Inherits:
Object
  • Object
show all
Defined in:
ext/string_camelize.rb

Instance Method Summary collapse

Instance Method Details

#camelize(first_letter_in_uppercase = :lower) ⇒ Object

Stolen from sequel; gives String a camelize method



4
5
6
7
8
# File 'ext/string_camelize.rb', line 4

def camelize(first_letter_in_uppercase = :lower)
  s = gsub(/\/(.?)/){|x| "::#{x[-1..-1].upcase unless x == '/'}"}.gsub(/(^|_)(.)/){|x| x[-1..-1].upcase}
  s[0...1] = s[0...1].downcase unless first_letter_in_uppercase == :upper
  s
end