Sha256: caf8ff82506c2bdb7a2999988a90c7f66ea9bbe4ffa43cf27fe38b82d082b266
Contents?: true
Size: 1.04 KB
Versions: 4
Compression:
Stored size: 1.04 KB
Contents
module PS class Process ALL_FORMATS.each do |opt| define_method opt do @data[opt] end end FORMAT_ALIASES.each do |al,orig| define_method al do @data[orig] end end def initialize data @data = {} data.each do |key,value| @data[key] = case value when /^\-?\d+$/ value.to_i when /^\-?\d+\.\d+$/ value.to_f else value.strip end end end def include? value @data.has_key?(value.to_s) end def has @data.keys end def mem rss/1024.0 if rss end def alive? return unless pid Process.getpgid(pid) true rescue Errno::ESRCH false end def display disp = [] disp << pid disp << user disp << lstart disp << pcpu disp << pmem disp << mem disp << command disp.compact.join(' ') end def kill!(sig=nil) sig ||= 'INT' ::Process.kill(sig, pid) if pid end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
ps-0.0.7 | lib/ps/process.rb |
ps-0.0.6 | lib/ps/process.rb |
ps-0.0.5 | lib/ps/process.rb |
ps-0.0.4 | lib/ps/process.rb |