Damian Nowak
2014-Sep-21 04:46 UTC
[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 <https://demo.virtkick.io/>. 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) Damian -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.