rails/rails — pull request #17344 by nelsond (2014-10-21 08:54:54+00:00)
Title: Add SI prefix option to numeric bytes core extension

I am aware that you guys already had a discussion about the use of SI and binary prefixes.

However, I am missing some kind of symmetry between the `number_to_human_size` helper and the numeric bytes core extension.

While `1.kilobyte`, `1.megabyte` etc. use the binary prefix, `number_to_human_size` actually allows you to choose a prefix (:si or :binary). This can lead to some odd behavior:
```ruby
NumberHelper.number_to_human_size(1.kilobyte, prefix: :si) # => "1.02 KB"
```

I added an option to the numeric bytes core extension:

```ruby
1.kilobyte # => 1024
1.kilobyte(:si) # => 1000
1.kilobyte(prefix: :si) # => 1000

NumberHelper.number_to_human_size(1.kilobyte(:si), prefix: :si) # => "1 KB"
```

Maybe this isn't the best solution, so I am open for ideas and changes.