Sha256: 8acba76abe0fbab9ca8dd154920813b8a24bec8b3c3c780819172a9b8d11b841

Contents?: true

Size: 400 Bytes

Versions: 1

Compression:

Stored size: 400 Bytes

Contents

require 'time'

module Polling
  module Target
    module_function

    def interval(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.3 lib/polling/target.rb