Project

nreadable

0.0
No commit activity in last 3 years
No release in over 3 years
Extends the Numeric Class with the ability to create better readable representations of numeric values as a String. In the current version it supports thousands separated numbers, an exponential notation with self-adjusting precision, SI-Prefixes, Binary Prefixes and a large-number naming system.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

nreadable

Extends the Numeric Class with the ability to create better readable representations of numeric values as a String.

gem install nreadable

Features

  • thousands separated numbers ( e.g. 1,000,000 )
  • exponential notation with self-adjusting precision ( e.g. 1e+06 )
  • SI-Prefixes ( e.g. 1000000 = 1M )
  • Binary Prefixes ( e.g. 1048576 = 1Mi )
  • large-number naming system ( e.g. 1 million )

Usage

1000.delimited         #=> "1,000"
123000000.scientific   #=> "1.23e+08"
123000000.si_prefixed  #=> "123M"
0.000123.si_prefixed   #=> "123ยต"
123000000.bin_prefixed #=> "117.3Mi"
123000000.named        #=> "123 million"

for more details and options, see http://rubydoc.info/gems/nreadable/0.2.1/Numeric

License

The MIT license. See LICENSE file.