Files

Class/Module Index [+]

Quicksearch

God::Conditions::Tries

Attributes

times[RW]
within[RW]

Public Instance Methods

prepare() click to toggle source
# File lib/god/conditions/tries.rb, line 7
def prepare
  @timeline = Timeline.new(self.times)
end
reset() click to toggle source
# File lib/god/conditions/tries.rb, line 11
def reset
  @timeline.clear
end
test() click to toggle source
# File lib/god/conditions/tries.rb, line 21
def test
  @timeline << Time.now

  concensus = (@timeline.size == self.times)
  duration = self.within.nil? || (@timeline.last - @timeline.first) < self.within

  if within
    history = "[#{@timeline.size}/#{self.times} within #{(@timeline.last - @timeline.first).to_i}s]"
  else
    history = "[#{@timeline.size}/#{self.times}]"
  end

  if concensus && duration
    self.info = "tries exceeded #{history}"
    return true
  else
    self.info = "tries within bounds #{history}"
    return false
  end
end
valid?() click to toggle source
# File lib/god/conditions/tries.rb, line 15
def valid?
  valid = true
  valid &= complain("Attribute 'times' must be specified", self) if self.times.nil?
  valid
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.