Class: Cloudinary::BaseApi::Response
- Defined in:
- lib/cloudinary/base_api.rb
Instance Attribute Summary collapse
-
#rate_limit_allowed ⇒ Object
readonly
Returns the value of attribute rate_limit_allowed.
-
#rate_limit_remaining ⇒ Object
readonly
Returns the value of attribute rate_limit_remaining.
-
#rate_limit_reset_at ⇒ Object
readonly
Returns the value of attribute rate_limit_reset_at.
Instance Method Summary collapse
-
#initialize(response = nil) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(response = nil) ⇒ Response
Returns a new instance of Response.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cloudinary/base_api.rb', line 18 def initialize(response=nil) unless response return end # This sets the instantiated self as the response Hash update Cloudinary::Api.parse_json_response response # According to RFC 2616, header names are case-insensitive. lc_headers = response.headers.transform_keys(&:downcase) @rate_limit_allowed = lc_headers["x-featureratelimit-limit"].to_i if lc_headers["x-featureratelimit-limit"] @rate_limit_reset_at = Time.parse(lc_headers["x-featureratelimit-reset"]) if lc_headers["x-featureratelimit-reset"] @rate_limit_remaining = lc_headers["x-featureratelimit-remaining"].to_i if lc_headers["x-featureratelimit-remaining"] end |
Instance Attribute Details
#rate_limit_allowed ⇒ Object (readonly)
Returns the value of attribute rate_limit_allowed.
16 17 18 |
# File 'lib/cloudinary/base_api.rb', line 16 def rate_limit_allowed @rate_limit_allowed end |
#rate_limit_remaining ⇒ Object (readonly)
Returns the value of attribute rate_limit_remaining.
16 17 18 |
# File 'lib/cloudinary/base_api.rb', line 16 def rate_limit_remaining @rate_limit_remaining end |
#rate_limit_reset_at ⇒ Object (readonly)
Returns the value of attribute rate_limit_reset_at.
16 17 18 |
# File 'lib/cloudinary/base_api.rb', line 16 def rate_limit_reset_at @rate_limit_reset_at end |