Skip to content

Instantly share code, notes, and snippets.

@andyt
Created January 14, 2010 10:44
Show Gist options
  • Save andyt/277069 to your computer and use it in GitHub Desktop.
Save andyt/277069 to your computer and use it in GitHub Desktop.
# Block gsub for formatting the case of a place name.
# List of stopwords probably not exclusive...
def capitalize_town(name)
name.gsub(/\b([a-z])+\b/) { |match| ['on', 'and', 'in'].include?(match) ? match : match.capitalize }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment