Class: Memosig::ProcStat
- Inherits:
-
Object
- Object
- Memosig::ProcStat
- Defined in:
- lib/memosig/proc_stat.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#rss ⇒ Object
readonly
Returns the value of attribute rss.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(pid, rss, command) ⇒ ProcStat
constructor
A new instance of ProcStat.
Constructor Details
#initialize(pid, rss, command) ⇒ ProcStat
Returns a new instance of ProcStat.
11 12 13 |
# File 'lib/memosig/proc_stat.rb', line 11 def initialize(pid, rss, command) @pid, @rss, @command = pid.to_i, rss.to_i, command end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
15 16 17 |
# File 'lib/memosig/proc_stat.rb', line 15 def command @command end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
15 16 17 |
# File 'lib/memosig/proc_stat.rb', line 15 def pid @pid end |
#rss ⇒ Object (readonly)
Returns the value of attribute rss.
15 16 17 |
# File 'lib/memosig/proc_stat.rb', line 15 def rss @rss end |
Class Method Details
.all ⇒ Object
2 3 4 5 |
# File 'lib/memosig/proc_stat.rb', line 2 def self.all ps = `ps ax -o pid,rss,command`.lines.to_a[1..-1] ps.map! { |l| from_line(l) } end |
.from_line(line) ⇒ Object
7 8 9 |
# File 'lib/memosig/proc_stat.rb', line 7 def self.from_line(line) new(*line.lstrip.split(/\s+/, 3)) end |