Created
November 20, 2008 19:22
-
-
Save sintaxi/27148 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def title_case! | |
self.split.map{ |w| w.capitalize }.join(' ') | |
end | |
end | |
class Hash | |
def title_case_keys! | |
self.each_pair do |k,v| | |
self[k.title_case!] = v | |
self.delete k | |
end | |
end | |
end | |
countries = {"UNITED STATES" => "USA" , "UNITED KINGDOM" => "UK"}.title_case_keys! | |
p countries |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment