Class: RPS::LinuxProcess
- Inherits:
-
Object
- Object
- RPS::LinuxProcess
- Defined in:
- lib/rps/linux_process.rb
Constant Summary collapse
- NULL =
"\000"
Class Method Summary collapse
Instance Method Summary collapse
- #command_line ⇒ Object
- #cwd ⇒ Object
- #environment ⇒ Object
- #exe ⇒ Object
-
#initialize(dir) ⇒ LinuxProcess
constructor
A new instance of LinuxProcess.
- #pid ⇒ Object
- #readable? ⇒ Boolean
- #ruby? ⇒ Boolean
Constructor Details
#initialize(dir) ⇒ LinuxProcess
Returns a new instance of LinuxProcess.
9 10 11 |
# File 'lib/rps/linux_process.rb', line 9 def initialize(dir) @dir = dir end |
Class Method Details
.all ⇒ Object
5 6 7 |
# File 'lib/rps/linux_process.rb', line 5 def self.all Dir['/proc/*'].map { |dir| new(dir) if File.basename(dir) =~ /^\d+$/ }.compact end |
Instance Method Details
#command_line ⇒ Object
33 34 35 |
# File 'lib/rps/linux_process.rb', line 33 def command_line @command_line ||= File.read(cmdline_path).split(NULL) end |
#cwd ⇒ Object
29 30 31 |
# File 'lib/rps/linux_process.rb', line 29 def cwd @cwd ||= File.readlink(cwd_path) end |
#environment ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/rps/linux_process.rb', line 37 def environment @environment ||= ( strings = File.read(environ_path).split(NULL) data = strings.map { |e| e.split("=") } Hash[data] ) end |
#exe ⇒ Object
21 22 23 |
# File 'lib/rps/linux_process.rb', line 21 def exe @exe ||= File.readlink(exe_path) end |
#pid ⇒ Object
25 26 27 |
# File 'lib/rps/linux_process.rb', line 25 def pid @pid ||= Integer(File.basename(@dir)) end |
#readable? ⇒ Boolean
13 14 15 |
# File 'lib/rps/linux_process.rb', line 13 def readable? File.readable? exe_path end |
#ruby? ⇒ Boolean
17 18 19 |
# File 'lib/rps/linux_process.rb', line 17 def ruby? exe.include? "ruby" # is this good enough? end |