Class: Evrone::Common::Spawn::ReadTimeout
- Inherits:
-
Object
- Object
- Evrone::Common::Spawn::ReadTimeout
- Defined in:
- lib/evrone/common/spawn/read_timeout.rb
Instance Method Summary collapse
- #happened? ⇒ Boolean
-
#initialize(val) ⇒ ReadTimeout
constructor
A new instance of ReadTimeout.
- #reset ⇒ Object
- #value ⇒ Object
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
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 |
#reset ⇒ Object
11 12 13 |
# File 'lib/evrone/common/spawn/read_timeout.rb', line 11 def reset @tm = Time.new if @value end |
#value ⇒ Object
22 23 24 |
# File 'lib/evrone/common/spawn/read_timeout.rb', line 22 def value @value end |