repo.or.cz
/
mwamko.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
history
|
raw
|
HEAD
Fixing database_for_scripts library
[mwamko.git]
/
lib
/
kilobytes2human.rb
blob
64bdcb60b3e29df5be054145be84359a20885504
1
class Kilobytes2Human
2
def self.convert( kilobytes )
3
4
conversion_table = {
5
1.0 => 'Kb',
6
1024.0 => 'Mb',
7
1024.0**2 => 'Gb'
8
}
9
10
out = 0.0
11
conversion_table.each_pair do |key, val|
12
if kilobytes > key - 1 && kilobytes <= key ** 2
13
out = (kilobytes / key).round
14
out = out.to_s << ' ' << val
15
end
16
end
17
18
out
19
end
20
end
21