Class: UnixPs::UnixProcess
- Inherits:
-
Object
- Object
- UnixPs::UnixProcess
- Defined in:
- lib/unix-ps/unix_process.rb
Overview
Class that represents a unix process’ basic information
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#cpu ⇒ Object
Returns the value of attribute cpu.
-
#mem ⇒ Object
Returns the value of attribute mem.
-
#pid ⇒ Object
Returns the value of attribute pid.
-
#rss ⇒ Object
Returns the value of attribute rss.
-
#start ⇒ Object
Returns the value of attribute start.
-
#stat ⇒ Object
Returns the value of attribute stat.
-
#time ⇒ Object
Returns the value of attribute time.
-
#tty ⇒ Object
Returns the value of attribute tty.
-
#user ⇒ Object
Returns the value of attribute user.
-
#vsz ⇒ Object
Returns the value of attribute vsz.
Instance Method Summary collapse
-
#initialize(columns) ⇒ UnixProcess
constructor
A new instance of UnixProcess.
-
#kill!(sig = nil) ⇒ Object
Kill a process.
Constructor Details
#initialize(columns) ⇒ UnixProcess
Returns a new instance of UnixProcess.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/unix-ps/unix_process.rb', line 9 def initialize(columns) # Assign the columns @user = columns[0] @pid = columns[1].to_i @cpu = columns[2].to_f @mem = columns[3].to_f @vsz = columns[4] @rss = columns[5] @tty = columns[6] @stat = columns[7] @start = Time.parse(columns[8]) @time = columns[9] @command = columns[10] end |
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
7 8 9 |
# File 'lib/unix-ps/unix_process.rb', line 7 def command @command end |
#cpu ⇒ Object
Returns the value of attribute cpu.
7 8 9 |
# File 'lib/unix-ps/unix_process.rb', line 7 def cpu @cpu end |
#mem ⇒ Object
Returns the value of attribute mem.
7 8 9 |
# File 'lib/unix-ps/unix_process.rb', line 7 def mem @mem end |
#pid ⇒ Object
Returns the value of attribute pid.
7 8 9 |
# File 'lib/unix-ps/unix_process.rb', line 7 def pid @pid end |
#rss ⇒ Object
Returns the value of attribute rss.
7 8 9 |
# File 'lib/unix-ps/unix_process.rb', line 7 def rss @rss end |
#start ⇒ Object
Returns the value of attribute start.
7 8 9 |
# File 'lib/unix-ps/unix_process.rb', line 7 def start @start end |
#stat ⇒ Object
Returns the value of attribute stat.
7 8 9 |
# File 'lib/unix-ps/unix_process.rb', line 7 def stat @stat end |
#time ⇒ Object
Returns the value of attribute time.
7 8 9 |
# File 'lib/unix-ps/unix_process.rb', line 7 def time @time end |
#tty ⇒ Object
Returns the value of attribute tty.
7 8 9 |
# File 'lib/unix-ps/unix_process.rb', line 7 def tty @tty end |
#user ⇒ Object
Returns the value of attribute user.
7 8 9 |
# File 'lib/unix-ps/unix_process.rb', line 7 def user @user end |
#vsz ⇒ Object
Returns the value of attribute vsz.
7 8 9 |
# File 'lib/unix-ps/unix_process.rb', line 7 def vsz @vsz end |
Instance Method Details
#kill!(sig = nil) ⇒ Object
Kill a process
25 26 27 28 |
# File 'lib/unix-ps/unix_process.rb', line 25 def kill!(sig=nil) sig ||= 'INT' Process.kill(sig, self.pid) end |