implemented timer
[god.git] / lib / god / meddle.rb
blobd615164ff2aff819a70a37c0692cefe48df4b016
1 module God
2   
3   class Meddle < Base
4     # config
5     attr_accessor :interval
7     # drb
8     attr_accessor :server
9     
10     # api
11     attr_accessor :watches, :timer
12     
13     # Create a new instance that is ready for use by a configuration file
14     def initialize(options = {})
15       self.watches = []
16       self.server  = Server.new(self, options[:host], options[:port])
17       self.timer = Timer.new
18     end
19       
20     # Instantiate a new, empty Watch object and pass it to the mandatory
21     # block. The attributes of the watch will be set by the configuration
22     # file.
23     def watch
24       w = Watch.new(self)
25       yield(w)
26       @watches << w
27     end
28     
29     def monitor
30       
31     end
32     
33     # def monitor
34     #   threads = []
35     #   
36     #   @watches.each do |w|
37     #     threads << Thread.new do
38     #       while true do
39     #         w.run
40     #         sleep self.interval
41     #       end
42     #     end
43     #   end
44     #   
45     #   threads.each { |t| t.join }
46     # end
47   end
48   
49 end