def self.parse_swap_line(line, kernel, is_size)
case kernel
when /AIX/i
if line =~ /^\/\S+\s.*\s+(\S+)MB\s+(\S+)MB/
(is_size) ? $1.to_i : $2.to_i
else
0
end
when /OpenBSD/i
if line =~ /^total: (\d+) (\d+)-blocks allocated, (\d+) used, (\d+) available$/
(is_size) ? ($1.to_i * $2.to_i) : ($4.to_i * $2.to_i)
else
0
end
when /FreeBSD/i
if line =~ /\S+\s+(\d+)\s+\d+\s+(\d+)\s+\d+%$/
(is_size) ? $1.to_i : $2.to_i
else
0
end
when /Darwin/i
if line =~ /total\s=\s(\S+)M\s+used\s=\s\S+M\s+free\s=\s(\S+)M\s/
(is_size) ? $1.to_i : $2.to_i
else
0
end
when /SunOS/i
if line =~ /^\S+\s.*\s+(\d+)\s+(\d+)$/
(is_size) ? $1.to_i : $2.to_i
else
0
end
end
end