Class: String

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

Instance Method Summary collapse

Instance Method Details

#camelize(first_letter_in_uppercase = true) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/myway.rb', line 17

def camelize(first_letter_in_uppercase = true)
  if first_letter_in_uppercase
    self.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
  else
    self.first + camelize(self)[1..-1]
  end
end