Methods
Public Class
Public Instance
Included modules
- Comparable
Attributes
interval | [R] |
Public Class methods
new(interval)
[show source]
# File lib/httpx/timers.rb 56 def initialize(interval) 57 @interval = interval 58 @callbacks = [] 59 @on_empty = nil 60 end
Public Instance methods
<<(callback)
[show source]
# File lib/httpx/timers.rb 80 def <<(callback) 81 @callbacks << callback 82 end
<=>(other)
[show source]
# File lib/httpx/timers.rb 66 def <=>(other) 67 @interval <=> other.interval 68 end
==(other)
[show source]
# File lib/httpx/timers.rb 70 def ==(other) 71 return @interval == other if other.is_a?(Numeric) 72 73 @interval == other.to_f # rubocop:disable Lint/FloatComparison 74 end
delete(callback)
[show source]
# File lib/httpx/timers.rb 84 def delete(callback) 85 @callbacks.delete(callback) 86 @on_empty.call if @callbacks.empty? 87 end
elapse(elapsed)
[show source]
# File lib/httpx/timers.rb 97 def elapse(elapsed) 98 @interval -= elapsed 99 100 if @interval <= 0 101 cb = @callbacks.dup 102 cb.each(&:call) 103 end 104 105 @interval 106 end
no_callbacks?()
[show source]
# File lib/httpx/timers.rb 89 def no_callbacks? 90 @callbacks.empty? 91 end
on_empty(&blk)
[show source]
# File lib/httpx/timers.rb 62 def on_empty(&blk) 63 @on_empty = blk 64 end