Class: Waiting
- Inherits:
-
Object
- Object
- Waiting
- Defined in:
- lib/waiting.rb,
lib/waiting/waiter.rb,
lib/waiting/version.rb,
lib/waiting/timed_out_error.rb
Overview
Waits for things so you don’t have to
Defined Under Namespace
Classes: TimedOutError, Waiter
Constant Summary collapse
- VERSION =
The version of Waiting
'1.0.0'.freeze
Class Attribute Summary collapse
-
.default_exp_base ⇒ Numeric
The default exp base.
-
.default_interval ⇒ Numeric
The default interval.
-
.default_max_attempts ⇒ Numeric
The default max attempts.
-
.default_max_interval ⇒ Numeric
The default max interval.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(exp_base: self.class.default_exp_base, interval: self.class.default_interval, max_attempts: self.class.default_max_attempts, max_interval: self.class.default_max_interval) {|waiter| ... } ⇒ Waiting
constructor
A new instance of Waiting.
- #wait(exp_base: @exp_base, interval: @interval, max_attempts: @max_attempts, max_interval: @max_interval) {|waiter| ... } ⇒ Object
Constructor Details
#initialize(exp_base: self.class.default_exp_base, interval: self.class.default_interval, max_attempts: self.class.default_max_attempts, max_interval: self.class.default_max_interval) {|waiter| ... } ⇒ Waiting
Returns a new instance of Waiting.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/waiting.rb', line 14 def initialize(exp_base: self.class.default_exp_base, interval: self.class.default_interval, max_attempts: self.class.default_max_attempts, max_interval: self.class.default_max_interval, &block) @exp_base = exp_base @interval = interval @max_attempts = max_attempts @max_interval = max_interval @block = block end |
Class Attribute Details
.default_exp_base ⇒ Numeric
The default exp base
33 34 35 |
# File 'lib/waiting.rb', line 33 def default_exp_base @default_exp_base end |
.default_interval ⇒ Numeric
The default interval
39 40 41 |
# File 'lib/waiting.rb', line 39 def default_interval @default_interval end |
.default_max_attempts ⇒ Numeric
The default max attempts
45 46 47 |
# File 'lib/waiting.rb', line 45 def default_max_attempts @default_max_attempts end |
.default_max_interval ⇒ Numeric
The default max interval
51 52 53 |
# File 'lib/waiting.rb', line 51 def default_max_interval @default_max_interval end |
Class Method Details
.wait(exp_base: default_exp_base, interval: default_interval, max_attempts: default_max_attempts, max_interval: default_max_interval) {|waiter| ... } ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/waiting.rb', line 91 def self.wait(exp_base: default_exp_base, interval: default_interval, max_attempts: default_max_attempts, max_interval: default_max_interval, &block) new(exp_base: exp_base, interval: interval, max_attempts: max_attempts, max_interval: max_interval, &block).wait end |
Instance Method Details
#wait(exp_base: @exp_base, interval: @interval, max_attempts: @max_attempts, max_interval: @max_interval) {|waiter| ... } ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/waiting.rb', line 67 def wait(exp_base: @exp_base, interval: @interval, max_attempts: @max_attempts, max_interval: @max_interval, &block) Waiter.new( exp_base: exp_base, interval: interval, max_attempts: max_attempts, max_interval: max_interval ).wait(&(block || @block)) end |