Class: Greenjaguar::Strategies::WaitStrategy
- Inherits:
-
Object
- Object
- Greenjaguar::Strategies::WaitStrategy
- Defined in:
- lib/greenjaguar/strategies/wait_strategy.rb
Direct Known Subclasses
DefaultWaitStrategy, ExponentialBackoffStrategy, FibonacciStrategy, FixedIntervalStrategy, RandomStrategy
Instance Attribute Summary collapse
-
#time_unit ⇒ Object
Returns the value of attribute time_unit.
Instance Method Summary collapse
- #convert_to(time_unit) ⇒ Object
-
#initialize(*args) ⇒ WaitStrategy
constructor
A new instance of WaitStrategy.
- #reset_vars ⇒ Object
- #wait ⇒ Object
Constructor Details
#initialize(*args) ⇒ WaitStrategy
Returns a new instance of WaitStrategy.
6 7 8 |
# File 'lib/greenjaguar/strategies/wait_strategy.rb', line 6 def initialize(*args) @time_unit = :sec # default value is seconds end |
Instance Attribute Details
#time_unit ⇒ Object
Returns the value of attribute time_unit.
4 5 6 |
# File 'lib/greenjaguar/strategies/wait_strategy.rb', line 4 def time_unit @time_unit end |
Instance Method Details
#convert_to(time_unit) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/greenjaguar/strategies/wait_strategy.rb', line 23 def convert_to(time_unit) if time_unit == :sec 1 else 0.001 end end |
#reset_vars ⇒ Object
19 20 21 |
# File 'lib/greenjaguar/strategies/wait_strategy.rb', line 19 def reset_vars raise "reset_vars not implemented by subclass. This method should be implemented by subclasses to init their wait time unit" end |
#wait ⇒ Object
15 16 17 |
# File 'lib/greenjaguar/strategies/wait_strategy.rb', line 15 def wait raise "wait not implemented by subclass" end |