Sha256: 8c445272b129cd92d136120f39b959702799fb2b15e84515abc3aa47ed508d52

Contents?: true

Size: 361 Bytes

Versions: 1

Compression:

Stored size: 361 Bytes

Contents

module Backport
  module Server
    class Interval < Base
      def initialize period, &block
        @period = period
        @block = block
        @last_time = Time.now
      end

      def tick
        now = Time.now
        return unless now - @last_time > @period
        @block.call
        @last_time = now
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
backport-0.2.0 lib/backport/server/interval.rb