Class: PSTree::ProcStruct
- Inherits:
-
Object
- Object
- PSTree::ProcStruct
- Defined in:
- lib/pstree.rb
Overview
Process structure for storing and formatting process information.
This class encapsulates the essential details of a process including its parent process ID, process ID, owning user, and command line.
Instance Attribute Summary collapse
-
#cmd ⇒ Object
readonly
The cmd reader method returns the command line of this process structure.
-
#pid ⇒ Object
readonly
The pid reader method returns the process ID of this process structure.
-
#ppid ⇒ Object
readonly
The ppid reader method returns the parent process ID of this process structure.
-
#user ⇒ Object
readonly
The user reader method returns the username who owns this process.
Instance Method Summary collapse
-
#initialize(ppid, pid, user, cmd) ⇒ ProcStruct
constructor
Initializes a new process structure with the given process information.
-
#to_s ⇒ String
The to_s method formats the process information into a string representation that displays the process ID, command, and user in a standardized format.
Constructor Details
#initialize(ppid, pid, user, cmd) ⇒ ProcStruct
Initializes a new process structure with the given process information.
36 37 38 |
# File 'lib/pstree.rb', line 36 def initialize(ppid, pid, user, cmd) @ppid, @pid, @user, @cmd = ppid.to_i, pid.to_i, user, cmd end |
Instance Attribute Details
#cmd ⇒ Object (readonly)
The cmd reader method returns the command line of this process structure.
59 60 61 |
# File 'lib/pstree.rb', line 59 def cmd @cmd end |
#pid ⇒ Object (readonly)
The pid reader method returns the process ID of this process structure.
49 50 51 |
# File 'lib/pstree.rb', line 49 def pid @pid end |
#ppid ⇒ Object (readonly)
The ppid reader method returns the parent process ID of this process structure.
44 45 46 |
# File 'lib/pstree.rb', line 44 def ppid @ppid end |
#user ⇒ Object (readonly)
The user reader method returns the username who owns this process
54 55 56 |
# File 'lib/pstree.rb', line 54 def user @user end |
Instance Method Details
#to_s ⇒ String
The to_s method formats the process information into a string representation that displays the process ID, command, and user in a standardized format.
66 67 68 |
# File 'lib/pstree.rb', line 66 def to_s "%05u %s (%s)" % [ pid, cmd, user ] end |