Correct Number Units plugin

Plugin details

This plugin corrects everything in Rails, including the number_to_human_size helper of ActiveView. It is to be used by people who believe in standards and who respect their users enough not to show numbers measured in wrong units.

Repositoryhttps://idonee.irb.hr/svn_mislav/public/rails/correct_number_units/ Author Mislav Marohnić Tags number, unit LicenseUnknown

Documentation

Install the plugin:
ruby script/plugin install https://idonee.irb.hr/svn_mislav/public/rails/correct_number_units/

The Rails framework prides itself on being very strict about things like the HTTP protocol (cleary seen in the excellent REST implementation), testing practices, MVC (model-view-controller) separation and more. This is why some people were surprised to see that number conversion methods of ActiveSupport like "1.kilobyte" or "1.megabyte" still measure in wrong units.

A kilobyte is 1000 bytes, not 1024 like the current implementation. This inconsistency has been the source of many confusion and lawsuits (typical companies sued were those who advertise hard-disk capacity in wrong units). The article that sums this up nicely can be found on:

http://meta.ath0.com/articles/2005/02/23/a-plea-for-sanity

What is 1024 bytes, then? Well, 1024 bytes is a "kibibyte". Following that is "mebibyte", "gibibyte" and so on. Those prefixes indicate that we are measuring in base 2 units (the powers of 2). "Kilo" and "mega" were always stricly powers of 10.

http://physics.nist.gov/cuu/Units/binary.html

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, 7 months ago