Sha256: a3a736dd498bd3ce6cb2c97b6b709d7e45eee24ba0346e300d41c09e50a90529

Contents?: true

Size: 787 Bytes

Versions: 2

Compression:

Stored size: 787 Bytes

Contents

module God
  module Conditions
    
    class Lambda < PollCondition
      include ConditionHelper
      attr_accessor :lambda, :times,:trigger_on   # can trigger both on: true or false

      def initialize
        super
        self.trigger_on = true
        self.times = [1, 1]
      end
        
      def prepare
        if self.times.kind_of?(Integer)
          self.times = [self.times, self.times]
        end
        @timeline = Timeline.new(self.times[1])
      end
      
      def reset
        @timeline.clear
      end
      
      def valid?
        valid = true
        valid &= complain("Attribute 'lambda' must be specified", self) if self.lambda.nil?
        valid
      end

      def test  
        return timeline_test(self.lambda.call)
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
olgen-god-0.9.2 lib/god/conditions/lambda.rb
olgen-god-0.9.1 lib/god/conditions/lambda.rb