Class: ActionCable::Connection::TestTimer
- Inherits:
-
Object
- Object
- ActionCable::Connection::TestTimer
- Defined in:
- lib/action_cable/connection/test_case.rb
Instance Attribute Summary collapse
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
Instance Method Summary collapse
- #advance(seconds) ⇒ Object
-
#initialize(interval, &block) ⇒ TestTimer
constructor
A new instance of TestTimer.
- #shutdown ⇒ Object
Constructor Details
#initialize(interval, &block) ⇒ TestTimer
Returns a new instance of TestTimer.
112 113 114 115 116 117 |
# File 'lib/action_cable/connection/test_case.rb', line 112 def initialize(interval, &block) @interval = interval @block = block @elapsed = 0 @shutdown = false end |
Instance Attribute Details
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
110 111 112 |
# File 'lib/action_cable/connection/test_case.rb', line 110 def interval @interval end |
Instance Method Details
#advance(seconds) ⇒ Object
123 124 125 126 127 128 129 130 |
# File 'lib/action_cable/connection/test_case.rb', line 123 def advance(seconds) return if @shutdown @elapsed += seconds while @elapsed >= @interval @elapsed -= @interval @block&.call end end |
#shutdown ⇒ Object
119 120 121 |
# File 'lib/action_cable/connection/test_case.rb', line 119 def shutdown @shutdown = true end |