4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/storcs/parsers/utils.rb', line 4
def parse_size(line)
size = line.gsub(/[^a-z0-9().,]/i, '') if size.tr(",.","").match(/(\d+)Bytes\)/)
return $1.to_i
end
size.gsub!(/\(.*/,"")
units = %w(KB MB GB TB PB)
size.gsub!(",","") if size.include?(",") && size.include?(".")
size.gsub!(",","") if size.scan(",").length > 1
size.gsub!(",",".")
num = size.to_f
units.each_with_index do |u,idx|
if size.include?(u)
num = num * 1024 ** (idx+1)
end
end
num.round
end
|