Class: Evrone::Common::Spawn::ReadTimeout

Inherits:
Object
  • Object
show all
Defined in:
lib/evrone/common/spawn/read_timeout.rb

Instance Method Summary collapse

Constructor Details

#initialize(val) ⇒ ReadTimeout

Returns a new instance of ReadTimeout.



6
7
8
9
# File 'lib/evrone/common/spawn/read_timeout.rb', line 6

def initialize(val)
  @value    = val.to_f > 0 ? val.to_f : nil
  @happened = false
end

Instance Method Details

#happened?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
# File 'lib/evrone/common/spawn/read_timeout.rb', line 15

def happened?
  return true if @happened
  return false unless @tm

  @happened = Time.now > (@tm + @value)
end

#resetObject



11
12
13
# File 'lib/evrone/common/spawn/read_timeout.rb', line 11

def reset
  @tm = Time.new if @value
end

#valueObject



22
23
24
# File 'lib/evrone/common/spawn/read_timeout.rb', line 22

def value
  @value
end