On Postal Abbreviations
June 30, 2011 § Leave a comment
While working on a Rails form that needed a drop down select box for state postal abbreviations I put together a few Ruby hashes to look things up. Below are a few snippets from the different hashes so you can see if they work for what you need. You can check out the full things here.
STATE_ABBR_TO_NAME = {
'AL' => 'Alabama',
'AK' => 'Alaska',
'AS' => 'America Samoa',
'AZ' => 'Arizona',
'AR' => 'Arkansas',
...
STATE_NAME_TO_ABBR = {
'Alabama' => 'AL',
'Alaska' => 'AK',
'America Samoa' => 'AS',
'Arizona' => 'AZ',
'Arkansas' => 'AR',
...
STATE_NAME_TO_ABBR_LOWER = {
'alabama' => 'AL',
'alaska' => 'AK',
'america samoa' => 'AS',
'arizona' => 'AZ',
'arkansas' => 'AR',
...
Leave a comment