Class: ProconBypassMan::SafeTimeout

Inherits:
Object
  • Object
show all
Defined in:
lib/procon_bypass_man/support/safe_timeout.rb

Defined Under Namespace

Classes: Timeout

Instance Method Summary collapse

Constructor Details

#initialize(timeout: Time.now + 5) ⇒ SafeTimeout

5秒後がタイムアウト



6
7
8
# File 'lib/procon_bypass_man/support/safe_timeout.rb', line 6

def initialize(timeout: Time.now + 5)
  @timeout = timeout
end

Instance Method Details

#throw_if_timeout!Object

Raises:



11
12
13
# File 'lib/procon_bypass_man/support/safe_timeout.rb', line 11

def throw_if_timeout!
  raise Timeout if timeout?
end

#timeout?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/procon_bypass_man/support/safe_timeout.rb', line 16

def timeout?
  @timeout < Time.now
end