Skip to content
/ madison.rb Public

A simple Ruby gem for working with U.S. state names and abbreviations.

License

Notifications You must be signed in to change notification settings

mdb/madison.rb

Repository files navigation

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'
#  },
#  ...
#]

About

A simple Ruby gem for working with U.S. state names and abbreviations.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages