Class: Epi::ProcessStatus
- Inherits:
-
Object
- Object
- Epi::ProcessStatus
- Extended by:
- Forwardable
- Defined in:
- lib/epi/process_status.rb
Class Method Summary collapse
-
.last ⇒ self
The last snapshot taken by #take.
-
.now ⇒ self
Current running processes.
- .reset! ⇒ Object
-
.take! ⇒ self
Take a snapshot of current running processes.
Instance Method Summary collapse
-
#[](pid) ⇒ RunningProcess|NilClass
Lookup a running process by its PID.
-
#pids ⇒ Array
Get a list of PIDs of running processes.
Class Method Details
.last ⇒ self
The last snapshot taken by #take
27 28 29 |
# File 'lib/epi/process_status.rb', line 27 def last @last ||= take! end |
.now ⇒ self
Current running processes
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
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
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 |
#pids ⇒ Array
Get a list of PIDs of running processes
45 46 47 |
# File 'lib/epi/process_status.rb', line 45 def pids @pids ||= @lines.keys end |