Skip to content

Instantly share code, notes, and snippets.

@matschaffer
Created August 18, 2010 14:29
Show Gist options
  • Save matschaffer/534913 to your computer and use it in GitHub Desktop.
Save matschaffer/534913 to your computer and use it in GitHub Desktop.
def camelize(first_letter_in_uppercase = true)
if first_letter_in_uppercase
gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
else
first.downcase + camelize(lower_case_and_underscored_word)[1..-1]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment