4 attr_accessor :watch, :destination, :conditions
6 def initialize(watch, destination = nil)
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 # test generic and specific validity
29 unless Condition.valid?(c) && c.valid?
30 abort "Exiting on invalid condition"
33 # inherit interval from watch if no poll condition specific interval was set
34 if c.kind_of?(PollCondition) && !c.interval
35 if self.watch.interval
36 c.interval = self.watch.interval
38 abort "No interval set for Condition '#{c.class.name}' in Watch '#{self.watch.name}', and no default Watch interval from which to inherit"
47 self.conditions.each do |c|
53 self.conditions.each do |c|