Class: MonitorManager

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

Instance Method Summary collapse

Constructor Details

#initializeMonitorManager

Returns a new instance of MonitorManager.



3
4
5
# File 'lib/MonitorManager.rb', line 3

def initialize
    @list = Array.new
end

Instance Method Details

#add(monitor) ⇒ Object



7
8
9
# File 'lib/MonitorManager.rb', line 7

def add( monitor )
    @list.push monitor
end

#runObject

The main run loop



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/MonitorManager.rb', line 12

def run
    while true do
        @list.each do |m|
            begin
                m.run
                rescue MonitorTypeExceptionHandled => e
                m.alert( e.message )
            end
        end
        sleep 0.2
    end
    
    rescue Interrupt => e
    string = "Exiting on request ...\n"
    puts string

    rescue Exception => e
    string = "#{e.class.name}\n"
    string = "#{string}*** This is really unexpected.\n"
    string = "#{string}Message: #{e.message}\n"
    string = "#{string}e.backtrace\n"
    puts string
end