Permalink
Browse files

Handling terabytes

  • Loading branch information...
1 parent 8108791 commit e20ec4e2e1366d943abdc7b0a6db4120980053dc @itsderek23 itsderek23 committed Aug 23, 2011
Showing with 15 additions and 12 deletions.
  1. +15 −12 zz_archive/overview/overview.rb
@@ -172,19 +172,22 @@ def parse_file_systems(io, &line_handler)
end
end
- # Ensures disk space metrics are in GB. Metrics that don't contain 'G,M,or K' are just
+ # Ensures disk space metrics are in GB. Metrics that don't contain 'T,G,M,or K' are just
# turned into integers.
- def clean_value(value)
- if value =~ /G/i
- value.to_f
- elsif value =~ /M/i
- (value.to_f/1024.to_f).round
- elsif value =~ /K/i
- (value.to_f/1024.to_f/1024.to_f).round
- else
- value.to_f
- end
- end
+ def clean_value(value)
+ value = if value =~ /G/i
+ value.to_f
+ elsif value =~ /M/i
+ (value.to_f/1024.to_f)
+ elsif value =~ /K/i
+ (value.to_f/1024.to_f/1024.to_f)
+ elsif value =~ /T/i
+ (value.to_f*1024.to_f)
+ else
+ value.to_f
+ end
+ ("%.1f" % [value]).to_f
+ end
#-----------------------------------------------------

0 comments on commit e20ec4e

Please sign in to comment.