NepaliNumber
NepaliNumber formats numbers using the Nepali numbering system, where digits are grouped as thousands, lakhs, crores, and above. It also converts Devanagari digits, humanizes Nepali units, formats Nepali currency, and includes optional Rails helpers.
Installation
Install the gem and add it to your application's Gemfile:
gem "nepali_number"
Usage
Number formatting
NepaliNumber.format(2870000)
# => "28,70,000"
NepaliNumber.format("123456.78")
# => "1,23,456.78"
Currency
NepaliNumber.currency(100)
# => "रु. 100"
NepaliNumber.currency(1234567.89, nepali: true)
# => "रु. १२,३४,५६७.८९"
Digit conversion
NepaliNumber.to_nepali_digits("12,34,567")
# => "१२,३४,५६७"
NepaliNumber.to_english_digits("१२,३४,५६७")
# => "12,34,567"
Humanized units
NepaliNumber.human(100_000)
# => "1 लाख"
NepaliNumber.human(10_000_000)
# => "1 करोड"
Rails
When Rails is loaded, NepaliNumber adds explicit helpers:
<%= number_to_nepali(2870000) %>
<%= number_to_nepali_currency(100) %>
Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake test 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 the created tag, and push the .gem file to rubygems.org.
Contributing
Bug reports and pull requests are welcome.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the NepaliNumber project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.