class Ps::AUX

Public Class Methods

find_by_pid(pid) click to toggle source
# File lib/ps.rb, line 24
def find_by_pid(pid)
  list = Ps::AUX.list
  title = list.shift
  index = title.index("PID")
  list.find_all { |datas|  datas.at(index) == pid }
end
list() click to toggle source
# File lib/ps.rb, line 12
def list
  # %w[USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND]
  ps_list  = `#{Ps::PS_COMMAND}`.split("\n")
  ps_title = ps_list.shift.upcase.split(/\s+/)
  ps_list.map { |line|
    datas = line.split(/\s+/)
    _head = datas[0..ps_title.length-2]
    _tail = datas[ps_title.length-1..-1]
    _head.push(_tail.join(" "))
  }.unshift(ps_title)
end
title() click to toggle source
# File lib/ps.rb, line 7
def title
  ps_list  = `#{Ps::PS_COMMAND}`.split("\n")
   ps_list.shift.upcase.split(/\s+/)
end