Class: PSTree
- Inherits:
-
Object
- Object
- PSTree
- Includes:
- Enumerable
- Defined in:
- lib/pstree.rb,
lib/pstree/version.rb
Defined Under Namespace
Classes: ProcStruct
Constant Summary collapse
- VERSION =
PSTree version
'0.1.0'- VERSION_ARRAY =
:nodoc:
VERSION.split('.').map(&:to_i)
- VERSION_MAJOR =
:nodoc:
VERSION_ARRAY[0]
- VERSION_MINOR =
:nodoc:
VERSION_ARRAY[1]
- VERSION_BUILD =
:nodoc:
VERSION_ARRAY[2]
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(root_pid = nil) ⇒ PSTree
constructor
A new instance of PSTree.
- #to_s ⇒ Object
Constructor Details
#initialize(root_pid = nil) ⇒ PSTree
Returns a new instance of PSTree.
18 19 20 |
# File 'lib/pstree.rb', line 18 def initialize(root_pid = nil) @root_pid = root_pid.to_i end |
Instance Method Details
#each(&block) ⇒ Object
38 39 40 41 42 |
# File 'lib/pstree.rb', line 38 def each(&block) build recurse @root_pid, &block self end |
#to_s ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pstree.rb', line 22 def to_s build result = '' recurse @root_pid, -> children, last { if children.zero? result << (last ? '`-- ' : ' ') else result << (last ? '+-- ' : '| ') end } do |ps| result << ps.to_s << "\n" end result end |