Sha256: 50a6ff1202ffdd80027232bd43092e2441facdeee2288df25ff9f7d6ee79ba76

Contents?: true

Size: 480 Bytes

Versions: 1

Compression:

Stored size: 480 Bytes

Contents

require 'time'

module Polling
  module Target
    module_function

    class << self
      #TODO imple delay
      attr_accessor :delay
    end

    def create_time(interval,debug=false)
      init = 60
      now_to_f = Time.now.to_f

      stime = interval - (now_to_f % init)
      if stime < 0
        stime = init - stime.abs
      end

      ### debug
      print "sleep #{stime}seconds (until #{Time.at(now_to_f + stime)})\n" if debug

      return stime
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
polling-0.0.2 lib/polling/target.rb