Class: AutoPilot::ResultsStatePoller
- Inherits:
-
Object
- Object
- AutoPilot::ResultsStatePoller
- Defined in:
- lib/auto_pilot/poller.rb
Overview
Poller for the ResultsState.
Instance Attribute Summary collapse
-
#interval ⇒ Object
Returns the value of attribute interval.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize ⇒ ResultsStatePoller
constructor
A new instance of ResultsStatePoller.
- #start ⇒ Object
- #stop ⇒ Object
- #stop? ⇒ Boolean
Constructor Details
#initialize ⇒ ResultsStatePoller
Returns a new instance of ResultsStatePoller.
18 19 20 21 22 |
# File 'lib/auto_pilot/poller.rb', line 18 def initialize self.timeout = DEFAULT_TIMEOUT self.interval = DEFAULT_INTERVAL @stop = false end |
Instance Attribute Details
#interval ⇒ Object
Returns the value of attribute interval.
16 17 18 |
# File 'lib/auto_pilot/poller.rb', line 16 def interval @interval end |
#timeout ⇒ Object
Returns the value of attribute timeout.
16 17 18 |
# File 'lib/auto_pilot/poller.rb', line 16 def timeout @timeout end |
Instance Method Details
#start ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/auto_pilot/poller.rb', line 24 def start total_time = 0 while ResultsState.waiting? puts "still waiting: #{total_time} of #{self.timeout}" sleep self.interval total_time += self.interval break if total_time >= self.timeout || self.stop? end end |
#stop ⇒ Object
33 34 35 |
# File 'lib/auto_pilot/poller.rb', line 33 def stop @stop = true end |
#stop? ⇒ Boolean
36 37 38 |
# File 'lib/auto_pilot/poller.rb', line 36 def stop? @stop end |