Methods
Public Class
Public Instance
Included modules
- Comparable
Attributes
interval | [R] |
Public Class methods
new(interval)
[show source]
# File lib/httpx/timers.rb 67 def initialize(interval) 68 @interval = interval 69 @callbacks = [] 70 @on_empty = nil 71 end
Public Instance methods
<<(callback)
[show source]
# File lib/httpx/timers.rb 95 def <<(callback) 96 @callbacks << callback 97 end
<=>(other)
[show source]
# File lib/httpx/timers.rb 81 def <=>(other) 82 @interval <=> other.interval 83 end
==(other)
[show source]
# File lib/httpx/timers.rb 85 def ==(other) 86 return @interval == other if other.is_a?(Numeric) 87 88 @interval == other.to_f # rubocop:disable Lint/FloatComparison 89 end
delete(callback)
[show source]
# File lib/httpx/timers.rb 99 def delete(callback) 100 @callbacks.delete(callback) 101 @on_empty.call if @callbacks.empty? 102 end
elapse(elapsed)
[show source]
# File lib/httpx/timers.rb 112 def elapse(elapsed) 113 @interval -= elapsed 114 115 if @interval <= 0 116 cb = @callbacks.dup 117 cb.each(&:call) 118 end 119 120 @interval 121 end
no_callbacks?()
[show source]
# File lib/httpx/timers.rb 104 def no_callbacks? 105 @callbacks.empty? 106 end
on_empty(&blk)
[show source]
# File lib/httpx/timers.rb 73 def on_empty(&blk) 74 @on_empty = blk 75 end