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.
The released gem (recommended):
$ gem install madison
Madison can be mixed into a class, or its singleton methods
can be called directly on the Madison
module.
Require madison:
require 'madison'
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>
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'
# },
# ...
#]