Class: RemoveBg::RateLimitInfo
- Inherits:
-
Object
- Object
- RemoveBg::RateLimitInfo
- Defined in:
- lib/remove_bg/rate_limit_info.rb
Instance Attribute Summary collapse
-
#remaining ⇒ Object
readonly
Returns the value of attribute remaining.
-
#retry_after_seconds ⇒ Object
readonly
Returns the value of attribute retry_after_seconds.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
-
#initialize(headers) ⇒ RateLimitInfo
constructor
A new instance of RateLimitInfo.
- #reset_at ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(headers) ⇒ RateLimitInfo
Returns a new instance of RateLimitInfo.
7 8 9 10 11 12 13 14 |
# File 'lib/remove_bg/rate_limit_info.rb', line 7 def initialize(headers) @total = headers["X-RateLimit-Limit"]&.to_i @remaining = headers["X-RateLimit-Remaining"]&.to_i @reset_timestamp = headers["X-RateLimit-Reset"]&.to_i # Only present if rate limit exceeded @retry_after_seconds = headers["Retry-After"]&.to_i end |
Instance Attribute Details
#remaining ⇒ Object (readonly)
Returns the value of attribute remaining.
5 6 7 |
# File 'lib/remove_bg/rate_limit_info.rb', line 5 def remaining @remaining end |
#retry_after_seconds ⇒ Object (readonly)
Returns the value of attribute retry_after_seconds.
5 6 7 |
# File 'lib/remove_bg/rate_limit_info.rb', line 5 def retry_after_seconds @retry_after_seconds end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
5 6 7 |
# File 'lib/remove_bg/rate_limit_info.rb', line 5 def total @total end |
Instance Method Details
#reset_at ⇒ Object
16 17 18 19 |
# File 'lib/remove_bg/rate_limit_info.rb', line 16 def reset_at return if .nil? Time.at().utc end |
#to_s ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/remove_bg/rate_limit_info.rb', line 21 def to_s "<RateLimit"\ " reset_at='#{reset_at.iso8601}'"\ " retry_after_seconds=#{retry_after_seconds}"\ " total=#{total}"\ " remaining=#{remaining}"\ ">" end |