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.
9 10 11 12 13 14 15 16 |
# File 'lib/remove_bg/rate_limit_info.rb', line 9 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.
7 8 9 |
# File 'lib/remove_bg/rate_limit_info.rb', line 7 def remaining @remaining end |
#retry_after_seconds ⇒ Object (readonly)
Returns the value of attribute retry_after_seconds.
7 8 9 |
# File 'lib/remove_bg/rate_limit_info.rb', line 7 def retry_after_seconds @retry_after_seconds end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
7 8 9 |
# File 'lib/remove_bg/rate_limit_info.rb', line 7 def total @total end |
Instance Method Details
#reset_at ⇒ Object
18 19 20 21 22 |
# File 'lib/remove_bg/rate_limit_info.rb', line 18 def reset_at return if .nil? Time.at().utc end |
#to_s ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/remove_bg/rate_limit_info.rb', line 24 def to_s "<RateLimit " \ "reset_at='#{reset_at.iso8601}' " \ "retry_after_seconds=#{retry_after_seconds} " \ "total=#{total} " \ "remaining=#{remaining}" \ ">" end |