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',
  ...
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

What’s this?

You are currently reading On Postal Abbreviations at The On Blog.

meta

%d bloggers like this: