Sha256: 35b5a6633ab993aa6e1bbb79d1fdca85f5839c3da2a24080912108d203a0ecb3

Contents?: true

Size: 693 Bytes

Versions: 25

Compression:

Stored size: 693 Bytes

Contents

# frozen_string_literal: true

#
# Copyright 2013 whiteleaf. All rights reserved.
#

module Command
  class Update < CommandBase
    class Interval
      MIN = 2.5               # 作品間ウェイトの最低秒数(処理時間含む)
      FORCE_WAIT_TIME = 2.0   # 強制待機時間

      def initialize(interval)
        @time = Time.now - MIN
        interval = interval.to_f
        @interval_time = interval >= MIN ? interval : MIN
      end

      def wait
        wait_time = Time.now - @time
        sleep(@interval_time - wait_time) if wait_time < @interval_time
        @time = Time.now
      end

      def force_wait
        sleep(FORCE_WAIT_TIME)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
narou-3.9.1 lib/command/update/interval.rb
narou-3.9.0 lib/command/update/interval.rb
narou-3.8.2 lib/command/update/interval.rb
narou-3.8.1 lib/command/update/interval.rb
narou-3.8.0 lib/command/update/interval.rb
narou-3.7.2 lib/command/update/interval.rb
narou-3.7.1 lib/command/update/interval.rb
narou-3.7.0 lib/command/update/interval.rb
narou-3.6.0 lib/command/update/interval.rb
narou-3.5.1 lib/command/update/interval.rb
narou-3.5.0.1 lib/command/update/interval.rb
narou-3.5.0 lib/command/update/interval.rb
narou-3.4.8 lib/command/update/interval.rb
narou-3.4.7.1 lib/command/update/interval.rb
narou-3.4.7 lib/command/update/interval.rb
narou-3.4.6.1 lib/command/update/interval.rb
narou-3.4.6 lib/command/update/interval.rb
narou-3.4.5 lib/command/update/interval.rb
narou-3.4.3 lib/command/update/interval.rb
narou-3.4.2 lib/command/update/interval.rb