RateCenter
![Build](https://github.com/somleng/rate_center/actions/workflows/main.yml/badge.svg)
A collection of useful data about NANPA Rate Centers.
Data is currently sourced from Simple Maps and Local Calling Guide.
Installation
Install the gem and add to the application's Gemfile by executing:
bundle add rate_centers
If bundler is not being used to manage dependencies, install the gem by executing:
gem install rate_centers
Usage
Working with Rate Centers
RateCenter.load(:rate_centers, only: { us: [:ny, :ca], ca: [:on] })
rate_center = RateCenter::RateCenter.find_by!(country: "US", region: "NY", name: "NWYRCYZN01")
rate_center.full_name
rate_center.lata
rate_center.ilec_name
rate_center.lat
rate_center.long
rate_center.closest_city.name
rate_center.closest_city.distance_km
Working with Cities
RateCenter.load(:cities, only: { us: [:ny, :ca], ca: [:on] })
city = RateCenter::City.find_by!(country: "US", region: "NY", name: "New York")
city.lat
city.log
city.county
city.nearby_rate_centers.first(10).each do |rate_center|
puts "Rate Center: #{rate_center.name}, Distance: #{rate_center.distance_km} km"
end
Not using Ruby?
The data directory contains all the data as JSON files.
Updating Data
In order to pull data from the sources, run the following script
bin/update_data
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/somleng/rate_center.
License
The gem is available as open source under the terms of the MIT License.