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.newGet a state's abbreviation:
my_class.state_abbrev 'virginia'
# => VAGet a state's name:
my_class.state_name 'va'
# => VirginiaGet 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'
# => VAGet a state's name:
Madison.get_name 'va'
# => VirginiaGet an array of US state names/abbreviations:
Madison.states
# => [
# {
# name: 'Virginia',
# abbr: 'VA'
# },
# ...
#]