Class: Cloudinary::BaseApi::Response

Inherits:
Hash show all
Defined in:
lib/cloudinary/base_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_allowedObject (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_remainingObject (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_atObject (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