i don't know how many times i've written this...
spec = '2000GB'
size =
case spec
when /gb\s*$/io
spec.to_i * (2 ** 30)
when /mb\s*$/io
spec.to_i * (2 ** 20)
when /kb\s*$/io
spec.to_i * (2 ** 10)
else
spec.to_i
end
is there anything which parses memory specs anywhere in the stdlib?
should there be?
-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL :: http://www.ngdc.noaa.gov/stp/
| TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done
===============================================================================