Sha256: 4cafb69af8427929451dda01069dd0bfa0a807fe4c5bb3c0cbdc2462ab3fc198

Contents?: true

Size: 642 Bytes

Versions: 1

Compression:

Stored size: 642 Bytes

Contents

module God
  module Conditions

    module ConditionHelper
      
      def timeline_test(res)
        @timeline << res
        history = " - SUCCESS RATE: [#{@timeline.select { |x| x }.size}/#{@timeline.length}]"
        if @timeline.select { |x| x }.size >= self.times[0]
          self.info = " PASSED #{history}"
          return true
        elsif @timeline.select { |x| !x }.size > self.times[1] - self.times[0]
          self.info = " FAILED #{history}"
          return false
        else
          self.info = "history too short: #{history}"
          return nil # do not trigger a transition
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
olgen-god-0.9.0 lib/god/conditions/condition_helper.rb