Library for checking in which category a german phone number falls in regards to Bundesnetzagentur classes.
This gem is developed for ruby versions '>= 2.7.0'
.
Add the gem to your Gemfile:
gem 'german_phone_number_classifier', '1.0.0.pre'
and run bundle install
.
The module comes with 2 class methods as public interface.
This method is for identifying the a telephone number as part of the german phone number system and will put it in a category identified as symbol:
irb(main):001:0> GermanPhoneNumberClassifier.classify('+4930120849110')
=> :landline
irb(main):002:0> GermanPhoneNumberClassifier.classify('+4830120849110')
=> :non_german_phone_number
irb(main):003:0> GermanPhoneNumberClassifier.classify('+4915012345678')
=> :mobile
Following categories are defined:
:no_phone_number
:non_german_phone_number
:authoritative
see here, here, here and here:provider_selection
:high_connection
:service_hotline
:vpn
see here and here:online_and_traffic
see here and here:personal_number
:free_service_hotline
:dialer
:mobile
:premium_service_hotline
:test_provider
:landline
:unknown_class
Furthermore the gem offers a utility function to get the location from prefix mappings for german phone numbers which are :landline
. All others numbers will get nil
returned.
irb(main):002:0> GermanPhoneNumberClassifier.landline_location('+4930120849110')
=> "Berlin"
Test can be run with rspec: bundle exec rspec
and rubocop: bundle exec rubocop
- Fork it (https://github.com/jethroo/german_phone_number_classifier/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Notes:
- Contributions without tests won't be accepted.
- Please don't update the gem version.
see here