Class: Webex::RateLimiter
- Inherits:
-
Object
- Object
- Webex::RateLimiter
- Defined in:
- lib/webex/rate_limiter.rb
Instance Attribute Summary collapse
-
#daily_based_cost_threshold ⇒ Object
readonly
Returns the value of attribute daily_based_cost_threshold.
-
#daily_retry_after_in_second ⇒ Object
readonly
Returns the value of attribute daily_retry_after_in_second.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#second_based_cost_threshold ⇒ Object
readonly
Returns the value of attribute second_based_cost_threshold.
-
#secondly_retry_after_in_ms ⇒ Object
readonly
Returns the value of attribute secondly_retry_after_in_ms.
-
#used_daily_based_cost ⇒ Object
readonly
Returns the value of attribute used_daily_based_cost.
-
#used_second_based_cost ⇒ Object
readonly
Returns the value of attribute used_second_based_cost.
Instance Method Summary collapse
-
#initialize(headers) ⇒ RateLimiter
constructor
A new instance of RateLimiter.
- #parse_daily_based_cost ⇒ Object
- #parse_daily_retry_after ⇒ Object
- #parse_second_based_cost ⇒ Object
- #parse_secondly_retry_after ⇒ Object
Constructor Details
#initialize(headers) ⇒ RateLimiter
Returns a new instance of RateLimiter.
9 10 11 12 13 14 15 16 |
# File 'lib/webex/rate_limiter.rb', line 9 def initialize(headers) @headers = headers parse_second_based_cost parse_daily_based_cost parse_daily_retry_after parse_daily_retry_after parse_secondly_retry_after end |
Instance Attribute Details
#daily_based_cost_threshold ⇒ Object (readonly)
Returns the value of attribute daily_based_cost_threshold.
6 7 8 |
# File 'lib/webex/rate_limiter.rb', line 6 def daily_based_cost_threshold @daily_based_cost_threshold end |
#daily_retry_after_in_second ⇒ Object (readonly)
Returns the value of attribute daily_retry_after_in_second.
7 8 9 |
# File 'lib/webex/rate_limiter.rb', line 7 def daily_retry_after_in_second @daily_retry_after_in_second end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/webex/rate_limiter.rb', line 5 def headers @headers end |
#second_based_cost_threshold ⇒ Object (readonly)
Returns the value of attribute second_based_cost_threshold.
5 6 7 |
# File 'lib/webex/rate_limiter.rb', line 5 def second_based_cost_threshold @second_based_cost_threshold end |
#secondly_retry_after_in_ms ⇒ Object (readonly)
Returns the value of attribute secondly_retry_after_in_ms.
7 8 9 |
# File 'lib/webex/rate_limiter.rb', line 7 def secondly_retry_after_in_ms @secondly_retry_after_in_ms end |
#used_daily_based_cost ⇒ Object (readonly)
Returns the value of attribute used_daily_based_cost.
6 7 8 |
# File 'lib/webex/rate_limiter.rb', line 6 def used_daily_based_cost @used_daily_based_cost end |
#used_second_based_cost ⇒ Object (readonly)
Returns the value of attribute used_second_based_cost.
5 6 7 |
# File 'lib/webex/rate_limiter.rb', line 5 def used_second_based_cost @used_second_based_cost end |
Instance Method Details
#parse_daily_based_cost ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/webex/rate_limiter.rb', line 30 def parse_daily_based_cost if (value = headers[:HTTP_X_DAILY_CALL_LIMIT]) used, threshold = value.split('/') @used_daily_based_cost = Integer(used) @daily_based_cost_threshold = Integer(threshold) end end |
#parse_daily_retry_after ⇒ Object
24 25 26 27 28 |
# File 'lib/webex/rate_limiter.rb', line 24 def parse_daily_retry_after if (value = headers[:HTTP_X_DAILY_RETRY_AFTER]) @daily_retry_after_in_second = Integer(value) end end |
#parse_second_based_cost ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/webex/rate_limiter.rb', line 38 def parse_second_based_cost if (value = headers[:HTTP_X_SECONDLY_CALL_LIMIT]) used, threshold = value.split('/') @used_second_based_cost = Integer(used) @second_based_cost_threshold = Integer(threshold) end end |
#parse_secondly_retry_after ⇒ Object
18 19 20 21 22 |
# File 'lib/webex/rate_limiter.rb', line 18 def parse_secondly_retry_after if (value = headers[:HTTP_X_SECONDLY_RETRY_AFTER]) @secondly_retry_after_in_ms = Integer(value) end end |