4 attr_accessor :watch, :destination, :conditions
6 def initialize(watch, destination)
8 self.destination = destination
12 # Instantiate a Condition of type +kind+ and pass it into the optional
13 # block. Attributes of the condition must be set in the config file
15 # create the condition
17 c = Condition.generate(kind, self.watch)
18 rescue NoSuchConditionError => e
22 # send to block so config can set attributes
23 yield(c) if block_given?
25 # call prepare on the condition
28 # abort if the Condition is invalid, the Condition will have printed
29 # out its own error messages by now
31 abort "Exiting on invalid condition"
34 # inherit interval from watch if no poll condition specific interval was set
35 if c.kind_of?(PollCondition) && !c.interval
36 if self.watch.interval
37 c.interval = self.watch.interval
39 abort "No interval set for Condition '#{c.class.name}' in Watch '#{self.watch.name}', and no default Watch interval from which to inherit"
48 self.conditions.each do |c|
54 self.conditions.each do |c|