[Feature Request] Force minimal unit in number_to_human_size

I’d want to show “0 MB” instead of “0 Bytes” when presenting the space and memory used by virtual machines in VirtKick. It doesn’t make big sense to be that byte or kilobyte-specific in that. Please provide feedback and let me know if you want me to implement it in NumberToHumanSizeConverter.

number_to_human_size(123, minimal: :mb) # => 0 MB

number_to_human_size(1234, minimal: :mb) # => 0 MB

number_to_human_size(12345, minimal: :mb) # => 0.01 MB

number_to_human_size(123456, minimal: :mb) # => 0.12 MB

number_to_human_size(1234567, minimal: :mb) # => 1.18 MB

number_to_human_size(1234567890, minimal: :mb) # => 1.15 GB

number_to_human_size(1234567890123, minimal: :mb) # => 1.12 TB

(Assumed the default precision of 2)


How about “unit” instead of “minimal”?


unit is confusing too. Since once it reach 1000mb it will switch to GB.

what about initial_unit ?

I think min_unit, but feels a bit incomplete without also adding max_unit.