Class: RenderAPI::Response
- Inherits:
-
Object
- Object
- RenderAPI::Response
show all
- Includes:
- Enumerable
- Defined in:
- lib/render_api/response.rb
Instance Method Summary
collapse
Constructor Details
#initialize(http_response) ⇒ Response
Returns a new instance of Response.
9
10
11
|
# File 'lib/render_api/response.rb', line 9
def initialize(http_response)
@http_response = http_response
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, **kwargs, &block) ⇒ Object
59
60
61
62
63
|
# File 'lib/render_api/response.rb', line 59
def method_missing(name, *args, **kwargs, &block)
return super unless respond_to_missing?(name, false)
data_objects.first.public_send(name, *args, **kwargs, &block)
end
|
Instance Method Details
#data ⇒ Object
13
14
15
|
# File 'lib/render_api/response.rb', line 13
def data
@data ||= http_response.parse(:json)
end
|
#each(&block) ⇒ Object
17
18
19
|
# File 'lib/render_api/response.rb', line 17
def each(&block)
data_objects.each(&block)
end
|
21
22
23
|
# File 'lib/render_api/response.rb', line 21
def
@headers ||= http_response..to_h
end
|
#length ⇒ Object
25
26
27
|
# File 'lib/render_api/response.rb', line 25
def length
data_objects.length
end
|
#rate_limit ⇒ Object
29
30
31
|
# File 'lib/render_api/response.rb', line 29
def rate_limit
["Ratelimit-Limit"].to_i
end
|
#rate_limit_remaining ⇒ Object
33
34
35
|
# File 'lib/render_api/response.rb', line 33
def rate_limit_remaining
["Ratelimit-Remaining"].to_i
end
|
#rate_limit_reset ⇒ Object
37
38
39
|
# File 'lib/render_api/response.rb', line 37
def rate_limit_reset
["Ratelimit-Reset"].to_i
end
|