Class: RPS::ProcessEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/rps/process_entry.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ ProcessEntry

Returns a new instance of ProcessEntry.



7
8
9
# File 'lib/rps/process_entry.rb', line 7

def initialize(dir)
  @dir = dir
end

Class Method Details

.allObject



3
4
5
# File 'lib/rps/process_entry.rb', line 3

def self.all
  Dir['/proc/*'].map { |dir| new(dir) if File.basename(dir) =~ /^\d+$/ }.compact
end

Instance Method Details

#command_lineObject



27
28
29
# File 'lib/rps/process_entry.rb', line 27

def command_line
  @command_line ||= File.read(cmdline_path).split("\000")
end

#exeObject



19
20
21
# File 'lib/rps/process_entry.rb', line 19

def exe
  @exe ||= File.readlink(exe_path)
end

#pidObject



23
24
25
# File 'lib/rps/process_entry.rb', line 23

def pid
  @pid ||= Integer(File.basename(@dir))
end

#readable?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/rps/process_entry.rb', line 11

def readable?
  File.readable? exe_path
end

#ruby?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/rps/process_entry.rb', line 15

def ruby?
  exe.include? "ruby" # is this good enough?
end