Skip to content

Instantly share code, notes, and snippets.

@jacegu
Created December 3, 2010 15:03
Show Gist options
  • Save jacegu/727068 to your computer and use it in GitHub Desktop.
Save jacegu/727068 to your computer and use it in GitHub Desktop.
More about open classes
class String
def to_camel_case
return self if self == ""
words = self.split
words[1..words.size].each { |word| word.capitalize! }
words.join('')
end
def to_snake_case
self.downcase.gsub(/\s/, '_')
end
end
puts "run this method".to_camel_case
puts "run this method".to_snake_case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment