lib/total/osx.rb in total-0.1.0 vs lib/total/osx.rb in total-0.2.0

- old
+ new

@@ -30,12 +30,16 @@ module Total # OSX specifics. class OSX # Get the total in bytes def memory - `sysctl -a`.split("\n").each do |t| - return t.split(' ')[1].to_i if t.start_with?('hw.memsize:') + begin + `sysctl -a`.split("\n").each do |t| + return t.split(' ')[1].to_i if t.start_with?('hw.memsize:') + end + rescue Errno::ENOENT => e + raise CantDetect, e.message end - raise 'Can\'t detect memory size via sysctl' + raise CantDetect, 'Can\'t detect memory size via sysctl' end end end