Sha256: ee0eab816012f706d060e05f0914ab12248a718cdc151c74cb7fa003a683f334

Contents?: true

Size: 512 Bytes

Versions: 2

Compression:

Stored size: 512 Bytes

Contents

require 'time'

module Polling
  module Target
    module_function

    def interval(interval,*args)
      init = 60
      now_to_f = Time.now.to_f
      stime = interval - (now_to_f % init)

      args.each do |arg|
        @start = arg[:start]
        @debug = arg[:debug]
      end

      if !@start && stime < 0
        stime = init - stime.abs
      end

      ### debug
      print "sleep #{stime}seconds (until #{Time.at(now_to_f + stime)})\n" if @debug && stime > 0
      return stime
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
polling-0.0.7 lib/polling/target.rb
polling-0.0.5 lib/polling/target.rb