Top Level Namespace

Defined Under Namespace

Modules: PS

Instance Method Summary collapse

Instance Method Details

#PS(*args) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/ps.rb', line 69

def PS *args
  case args[0]
  when /\:\d+$/
    PS.from_lsof(*args)
  when Regexp
    opts = args[1] || {}
    procs = PS.all(opts)
    procs = procs.select {|proc| proc.command =~ args[0]}
    procs = procs.select {|proc| proc.pid != Process.pid} unless opts[:include_self]
    procs
  when Integer
    if args[1].is_a?(Integer)
      PS.pid(*args)
    else
      PS.pid(*args).first
    end
  when Array
    pids = args[0]
    pids << args[1] || {}
    PS.pid(*pids)
  when Hash
    PS.all(*args)
  end
end