diff --git a/README.rdoc b/README.rdoc index b2c0511..e813c45 100644 --- a/README.rdoc +++ b/README.rdoc @@ -15,9 +15,10 @@ Require the library like you would expect: Then create a new MemInfo object: m = MemInfo.new - m.memtotal => 70000 - m.memfree => 54300 - m.memused => 15700 + m.memtotal => 70000 + m.memfree => 54300 + m.memused => 15700 + m.free_buffers => 75000 Take a look in lib/mem_info.rb for all fields that are available. diff --git a/lib/mem_info.rb b/lib/mem_info.rb index 8582441..b9cf268 100644 --- a/lib/mem_info.rb +++ b/lib/mem_info.rb @@ -9,7 +9,8 @@ class MemInfo @@attributes = { :memtotal => "MemTotal", :memfree => "MemFree", - :buffers => "Cached", + :buffers => "Buffers", + :cached => "Cached", :swapcached => "SwapCached", :active => "Active", :inactive => "Inactive", @@ -58,10 +59,14 @@ def initialize def memused @memtotal - @memfree end + + def free_buffers + @memfree + @buffers + @cached + end private def regex_match(attribute, line) regex = Regexp.new("#{@@attributes[attribute]}:\\s*(.*?)\\s") regex.match(line)[1] if regex === line end -end \ No newline at end of file +end