This code will no longer be updated. Please go to https://github.com/matismasters/dictable
GitHub Copilot: EasyToDictateNumbers is an opinionated Ruby gem designed to convert numbers into their spoken equivalents. This gem is particularly useful in situations where precise verbal communication of numbers is required, such as during phone calls or dictation. It makes certain decisions about the "best" way to pronounce numbers, which may be subject to debate.
Add this line to your application's Gemfile:
gem 'easy_to_dictate_numbers'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install easy_to_dictate_numbers
To use EasyToDictateNumbers, simply call the to_dictable
method on any Integer
, this converts the number into its easy to dictate word representation.
require 'easy_to_dictate_numbers'
puts 123.to_dictable
# Output: "one twenty three"
puts "1243".to_dictable_number
# Output: "twelve forty three"
List of samples from specs:
100
is converted toone hundred
123
is converted toone twenty three
'001'
is converted tozero zero one
'010'
is converted tozero ten
'0000'
is converted tozero zero zero zero
1000
is converted toone thousand
4321
is converted toforty three twenty one
4300
is converted toforty three hundred
'0001'
is converted tozero zero zero one
'0010'
is converted tozero zero ten
'0100'
is converted tozero one hundred
Please note that the numbers in quotes are treated as strings, which allows leading zeroes to be preserved.
After checking out the repo, run bin/setup
to install dependencies. You can also run bin/console
for an interactive prompt that will allow you to experiment.
Bug reports and pull requests are welcome on GitHub. This project aims to be a safe, welcoming space for collaboration, and contributors are expected to adhere to a code of conduct.
The gem is available as open source under the terms of the MIT License.