Class: Epi::ProcessStatus

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/epi/process_status.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.lastself

The last snapshot taken by #take

Returns:

  • (self)


27
28
29
# File 'lib/epi/process_status.rb', line 27

def last
  @last ||= take!
end

.nowself

Current running processes

Returns:

  • (self)


15
16
17
# File 'lib/epi/process_status.rb', line 15

def now
  new
end

.reset!Object



9
10
11
# File 'lib/epi/process_status.rb', line 9

def reset!
  @last = nil
end

.take!self

Take a snapshot of current running processes

Returns:

  • (self)


21
22
23
# File 'lib/epi/process_status.rb', line 21

def take!
  @last = now
end

Instance Method Details

#[](pid) ⇒ RunningProcess|NilClass

Lookup a running process by its PID

Parameters:

  • pid (String|Numeric)

    PID of the process to lookup

Returns:



38
39
40
41
# File 'lib/epi/process_status.rb', line 38

def [](pid)
  pid = pid.to_i
  @running_processes[pid] ||= find_by_pid(pid)
end

#pidsArray

Get a list of PIDs of running processes

Returns:

  • (Array)

    An array of PIDs as ‘Fixnum`s



45
46
47
# File 'lib/epi/process_status.rb', line 45

def pids
  @pids ||= @lines.keys
end