class Memory::Status

Constants

Format

Public Class Methods

new() click to toggle source
# File lib/memory_status.rb, line 124
def initialize
  _update
end
parse(str) click to toggle source
# File lib/memory_status.rb, line 135
def self.parse(str)
  status = allocate
  str.scan(/(?:\A\{|\G,)(#{members.join('|')}):(\d+)(?=,|\}\z)/) do
    status[$1] = $2.to_i
  end
  status
end

Public Instance Methods

_update() click to toggle source
# File lib/memory_status.rb, line 114
def _update
  Memory.read_status do |key, val|
    self[key] = val
  end
  self
end
to_s() click to toggle source
# File lib/memory_status.rb, line 128
def to_s
  status = each_pair.map {|n,v|
    "#{n}:#{v}"
  }
  "{#{status.join(",")}}"
end