0.0
The project is in a healthy, maintained state
Validate, format and get the corresponding Brazilian state for a CEP without making HTTP requests.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 5.0
 Project Readme

Gem Version

CodigoPostal

Validate, format and get the corresponding Brazilian state for a CEP without making HTTP requests.

Installation

Add this line to your application's Gemfile:

gem 'codigo_postal'

And then execute:

$ bundle install

Usage

To use CodigoPostal, create a new instance of the CodigoPostal class with a valid Brazilian postal code:

cep = CodigoPostal.new(1001000)
puts cep.state_code # => 'SP'
puts cep.state_name # => 'São Paulo'
puts cep.to_s # => '01001-000'

You can also compare two CodigoPostal instances using the == operator:

cep1 = CodigoPostal.new(4094050)
cep2 = CodigoPostal.new("04.094-050")
puts cep1 == cep2 # => true

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/felipedmesquita/codigo-postal.

License

The gem is available as open source under the terms of the MIT License.