Class: Watcher::Process

Inherits:
BasicWatcher show all
Defined in:
lib/informer/watcher/process.rb

Instance Attribute Summary collapse

Attributes inherited from BasicWatcher

#message

Instance Method Summary collapse

Constructor Details

#initialize(command, options = {}, &block) ⇒ Process

Returns a new instance of Process.



6
7
8
9
10
# File 'lib/informer/watcher/process.rb', line 6

def initialize(command, options = {}, &block)
  @custom_message = block if block_given?
  @command = command
  @handle = options[:handle] || command
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



4
5
6
# File 'lib/informer/watcher/process.rb', line 4

def command
  @command
end

#handleObject (readonly)

Returns the value of attribute handle.



4
5
6
# File 'lib/informer/watcher/process.rb', line 4

def handle
  @handle
end

#processObject (readonly)

Returns the value of attribute process.



4
5
6
# File 'lib/informer/watcher/process.rb', line 4

def process
  @process
end

Instance Method Details

#reportObject



12
13
14
15
# File 'lib/informer/watcher/process.rb', line 12

def report
  return @custom_message.call(self) if @custom_message
  "#{@handle} is #{running? ? '' : 'not '}running"
end

#running?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/informer/watcher/process.rb', line 17

def running?
  process_matcher === processes
end