modifying kernel.rb to accept negative value for disk_usage_readable

This commit is contained in:
thibhero 2025-03-04 20:01:07 -05:00
parent b7a298e1ec
commit 49007fbccd

View File

@ -459,13 +459,13 @@ module Kernel
end
def disk_usage_readable(size_in_bytes)
if size_in_bytes >= 1_073_741_824
if size_in_bytes.abs >= 1_073_741_824
size = size_in_bytes.to_f / 1_073_741_824
unit = "GB"
elsif size_in_bytes >= 1_048_576
elsif size_in_bytes.abs >= 1_048_576
size = size_in_bytes.to_f / 1_048_576
unit = "MB"
elsif size_in_bytes >= 1_024
elsif size_in_bytes.abs >= 1_024
size = size_in_bytes.to_f / 1_024
unit = "KB"
else