Class: Memosig::Matcher

Inherits:
Object
  • Object
show all
Includes:
Output
Defined in:
lib/memosig/matcher.rb

Instance Method Summary collapse

Methods included from Output

#error, #output, #process_prefix

Constructor Details

#initialize(pattern, config) ⇒ Matcher

Returns a new instance of Matcher.



6
7
8
# File 'lib/memosig/matcher.rb', line 6

def initialize(pattern, config)
  @pattern, @config = prepare_pattern(pattern), config
end

Instance Method Details

#match?(process) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/memosig/matcher.rb', line 10

def match?(process)
  @process = process
  if @process.command =~ @pattern
    if @process.rss > @config.rss_max
      take_action
    else
      lay_low
    end
    true
  else
    false
  end
end