Class: RateLimit::Limit

Inherits:
Object
  • Object
show all
Defined in:
lib/rate_limit/limit.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(threshold, interval) ⇒ Limit

Returns a new instance of Limit.



7
8
9
10
# File 'lib/rate_limit/limit.rb', line 7

def initialize(threshold, interval)
  @threshold = threshold
  @interval  = interval
end

Instance Attribute Details

#intervalObject

Returns the value of attribute interval.



5
6
7
# File 'lib/rate_limit/limit.rb', line 5

def interval
  @interval
end

#thresholdObject

Returns the value of attribute threshold.



5
6
7
# File 'lib/rate_limit/limit.rb', line 5

def threshold
  @threshold
end

Class Method Details

.fetch(topic) ⇒ Object



13
14
15
16
17
# File 'lib/rate_limit/limit.rb', line 13

def fetch(topic)
  RateLimit.config.raw_limits_for(topic).map do |threshold, interval|
    Limit.new(threshold, interval)
  end
end