Class: Nexpose::Poller
- Inherits:
-
Object
- Object
- Nexpose::Poller
- Defined in:
- lib/nexpose/wait.rb
Instance Attribute Summary collapse
-
#poll_begin ⇒ Object
readonly
Stand alone object to handle waiting logic.
-
#polling_interval ⇒ Object
readonly
Stand alone object to handle waiting logic.
-
#timeout ⇒ Object
readonly
Stand alone object to handle waiting logic.
Instance Method Summary collapse
-
#initialize(timeout: nil, polling_interval: nil) ⇒ Poller
constructor
A new instance of Poller.
- #wait(condition) ⇒ Object
Constructor Details
#initialize(timeout: nil, polling_interval: nil) ⇒ Poller
Returns a new instance of Poller.
80 81 82 83 84 85 86 |
# File 'lib/nexpose/wait.rb', line 80 def initialize(timeout: nil, polling_interval: nil) global_timeout = set_global_timeout @timeout = timeout.nil? ? global_timeout : timeout global_polling = set_polling_interval @polling_interval = polling_interval.nil? ? global_polling : polling_interval end |
Instance Attribute Details
#poll_begin ⇒ Object (readonly)
Stand alone object to handle waiting logic.
78 79 80 |
# File 'lib/nexpose/wait.rb', line 78 def poll_begin @poll_begin end |
#polling_interval ⇒ Object (readonly)
Stand alone object to handle waiting logic.
78 79 80 |
# File 'lib/nexpose/wait.rb', line 78 def polling_interval @polling_interval end |
#timeout ⇒ Object (readonly)
Stand alone object to handle waiting logic.
78 79 80 |
# File 'lib/nexpose/wait.rb', line 78 def timeout @timeout end |
Instance Method Details
#wait(condition) ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/nexpose/wait.rb', line 88 def wait(condition) @poll_begin = Time.now loop do break if condition.call raise TimeoutError if @poll_begin + @timeout < Time.now sleep @polling_interval end end |