Class: Command::Update::Interval

Inherits:
Object
  • Object
show all
Defined in:
lib/command/update.rb

Constant Summary collapse

MIN =

作品間ウェイトの最低秒数(処理時間含む)

2.5
FORCE_WAIT_TIME =

強制待機時間

2.0

Instance Method Summary collapse

Constructor Details

#initialize(interval) ⇒ Interval

Returns a new instance of Interval.



21
22
23
24
25
# File 'lib/command/update.rb', line 21

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

Instance Method Details

#force_waitObject



33
34
35
# File 'lib/command/update.rb', line 33

def force_wait
  sleep(FORCE_WAIT_TIME)
end

#waitObject



27
28
29
30
31
# File 'lib/command/update.rb', line 27

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