Project

madison

0.03
No commit activity in last 3 years
No release in over 3 years
Get a U.S. state name from its abbreviation or get a U.S. state abbreviation from its name.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
 Project Readme

Build Status

madison

A dirt simple Ruby gem for working with US state names and abbreviations.

This is the Ruby version of the Node.js madison and was built as an example gem for other developers.

Installation

The released gem (recommended):

$ gem install madison

Usage

Madison can be mixed into a class, or its singleton methods can be called directly on the Madison module.

Require madison:

require 'madison'

Include it as a mixin

class MyClass
  include Madison
end

my_class = MyClass.new

Get a state's abbreviation:

my_class.state_abbrev 'virginia'
# => VA

Get a state's name:

my_class.state_name 'va'
# => Virginia

Get an array of US state names/abbreviations:

my_class.states
# => [
#  {
#    name: 'Virginia',
#    abbr: 'VA'
#  },
#  ...
#]

Get the Madison::Map class used

my_class.madison_map
# => <Madison::Map:0x007f8dbc80e7f0>

Use its singleton methods on the Madison module

Get a state's abbreviation:

Madison.get_abbrev 'virginia'
# => VA

Get a state's name:

Madison.get_name 'va'
# => Virginia

Get an array of US state names/abbreviations:

Madison.states
# => [
#  {
#    name: 'Virginia',
#    abbr: 'VA'
#  },
#  ...
#]