When you give a 10 digit phone number, this will return all possible words or combination of words from the provided dictionary, that can be mapped back as a whole to the number.
With this we can generate numbers like 1-800-motortruck which is easier to remember then 1-800-6686787825 The phone number mapping to letters is as follows:
2 = a b c
3 = d e f
4 = g h i
5 = j k l
6 = m n o
7 = p q r s
8 = t u v
9 = w x y z
The phone numbers will never contain a 0 or 1. Words have to be at least 3 characters.
To get give you an initial verification, the following must be true:
6686787825 should return the following list [["motor", "usual"], ["noun", "struck"], ["nouns", "truck"], ["nouns", "usual"], ["onto", "struck"], "motortruck"] 2282668687 should return the following list [["act", "amounts"], ["act", "contour"], ["acta", "mounts"], ["bat", "amounts"], ["bat", "contour"], ["cat", "contour"], "catamounts"]
Add this line to your application's Gemfile:
gem 'phone_number_to_words'
And then execute:
$ bundle
Or install it yourself as:
$ gem install phone_number_to_words
require 'phone_number_to_words'
@words = PhoneNumberToWords::Convert.new
@words.generate_words('2282668687')
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
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/sivamca19/phone_number_to_words. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the PhoneNumberToWords project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.