formatter-number
Format numbers
Installation
Add this line to your application's Gemfile:
gem 'formatter-number'
And then execute:
$ bundle
Or install it yourself as:
$ gem install formatter-number
Usage
formatter = Formatter::Number.new
formatter.format(10.556) # "10.56"
formatter.format(505_000) # "505,000"
formatter = Formatter::Number.new(grouping: 2)
formatter.format(10_000) # "10,000"
formatter.format(505_000) # "5,05,000"
formatter = Formatter::Number.new(grouping: 4)
formatter.format(100_004) # "10,0004"
formatter.format(10_050_026) # "1005,0026"
formatter = Formatter::Number.new(delimiter: ' ')
formatter.format(10_000) # "10 000"
Contributing
- Fork it ( https://github.com/terlar/formatter-number/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