Method: Processes#initialize
- Defined in:
- lib/resources/processes.rb
#initialize(grep) ⇒ Processes
Returns a new instance of Processes.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/resources/processes.rb', line 22 def initialize(grep) # turn into a regexp if it isn't one yet if grep.class == String grep = '(/[^/]*)*'+grep if grep[0] != '/' grep = Regexp.new('^' + grep + '(\s|$)') end all_cmds = ps_aux @list = all_cmds.find_all do |hm| hm[:command] =~ grep end { users: :user, states: :stat }.each do |var, key| instance_variable_set("@#{var}", @list.map { |l| l[key] }.uniq) end end |