Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-mws.rb

Instance Method Summary collapse

Instance Method Details

#camelize(first_letter_in_uppercase = true) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/ruby-mws.rb', line 40

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