Class: Memosig::ProcStat

Inherits:
Object
  • Object
show all
Defined in:
lib/memosig/proc_stat.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#commandObject (readonly)

Returns the value of attribute command.



15
16
17
# File 'lib/memosig/proc_stat.rb', line 15

def command
  @command
end

#pidObject (readonly)

Returns the value of attribute pid.



15
16
17
# File 'lib/memosig/proc_stat.rb', line 15

def pid
  @pid
end

#rssObject (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

.allObject



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