Class: Otter::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/otter/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(headers, response) ⇒ Response

:nodoc:



7
8
9
10
# File 'lib/otter/response.rb', line 7

def initialize(headers, response) # :nodoc:
  @headers = headers
  @response = response
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



4
5
6
# File 'lib/otter/response.rb', line 4

def headers
  @headers
end

#responseObject (readonly)

Returns the value of attribute response.



4
5
6
# File 'lib/otter/response.rb', line 4

def response
  @response
end

Instance Method Details

#pageObject

Current page



33
34
35
# File 'lib/otter/response.rb', line 33

def page
  Integer(self.response['total'])
end

#perpageObject

Number of results per page



38
39
40
# File 'lib/otter/response.rb', line 38

def perpage
  Integer(self.response['perpage'])
end

#rate_limitObject

Total credits that can be allocated.



13
14
15
# File 'lib/otter/response.rb', line 13

def rate_limit
  Integer(self.headers['X_RATELIMIT_LIMIT'])
end

#rate_remainingObject

Total credits available.



18
19
20
# File 'lib/otter/response.rb', line 18

def rate_remaining
  Integer(self.headers['X_RATELIMIT_REMAINING'])
end

#rate_resetObject

Time when the credits will be reset.



23
24
25
# File 'lib/otter/response.rb', line 23

def rate_reset
  Time.at(Integer(self.headers['X_RATELIMIT_RESET']))
end

#totalObject

Total number of results



28
29
30
# File 'lib/otter/response.rb', line 28

def total
  Integer(self.response['page'])
end

#windowObject



42
43
44
# File 'lib/otter/response.rb', line 42

def window
  self.response['window']
end