Class: AutoPilot::ResultsStatePoller

Inherits:
Object
  • Object
show all
Defined in:
lib/auto_pilot/poller.rb

Overview

Poller for the ResultsState.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResultsStatePoller

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

#intervalObject

Returns the value of attribute interval.



16
17
18
# File 'lib/auto_pilot/poller.rb', line 16

def interval
  @interval
end

#timeoutObject

Returns the value of attribute timeout.



16
17
18
# File 'lib/auto_pilot/poller.rb', line 16

def timeout
  @timeout
end

Instance Method Details

#startObject



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

#stopObject



33
34
35
# File 'lib/auto_pilot/poller.rb', line 33

def stop
  @stop = true
end

#stop?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/auto_pilot/poller.rb', line 36

def stop?
  @stop
end