Class: PhraseApp::RequestErrors::RateLimitingError
- Inherits:
-
Object
- Object
- PhraseApp::RequestErrors::RateLimitingError
- Defined in:
- lib/request_handler.rb
Instance Attribute Summary collapse
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#remaining ⇒ Object
Returns the value of attribute remaining.
-
#reset ⇒ Object
Returns the value of attribute reset.
Instance Method Summary collapse
-
#initialize(resp) ⇒ RateLimitingError
constructor
A new instance of RateLimitingError.
- #to_s ⇒ Object
Constructor Details
#initialize(resp) ⇒ RateLimitingError
Returns a new instance of RateLimitingError.
44 45 46 47 48 49 50 51 |
# File 'lib/request_handler.rb', line 44 def initialize(resp) re = RateLimitingError.new(resp) puts resp.body.inspect re.limit = resp["X-Rate-Limit-Limit"].to_i re.remaining = resp["X-Rate-Limit-Remaining"].to_i re.reset = Time.at(resp["X-Rate-Limit-Reset"].to_i) return re, nil end |
Instance Attribute Details
#limit ⇒ Object
Returns the value of attribute limit.
42 43 44 |
# File 'lib/request_handler.rb', line 42 def limit @limit end |
#remaining ⇒ Object
Returns the value of attribute remaining.
42 43 44 |
# File 'lib/request_handler.rb', line 42 def remaining @remaining end |
#reset ⇒ Object
Returns the value of attribute reset.
42 43 44 |
# File 'lib/request_handler.rb', line 42 def reset @reset end |
Instance Method Details
#to_s ⇒ Object
53 54 55 |
# File 'lib/request_handler.rb', line 53 def to_s sprintf("Rate limit exceeded: from %d requests %d are remaning (reset in %d seconds)", self.limit, self.remaining, int64(rle.Reset.Sub(time.Now()).Seconds())) end |