Class: BreweryDB::Response

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

Instance Method Summary collapse

Constructor Details

#initialize(body, request) ⇒ Response

Returns a new instance of Response.



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

def initialize(body, request)
  @body = body
  @request = request
end

Instance Method Details

#collectionObject



12
13
14
# File 'lib/brewery_db/response.rb', line 12

def collection
  Collection.new(self)
end

#countObject



32
33
34
# File 'lib/brewery_db/response.rb', line 32

def count
  @body.total_results
end

#dataObject



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

def data
  @body.data
end

#next_pageObject



20
21
22
# File 'lib/brewery_db/response.rb', line 20

def next_page
  @request.next_page.response
end

#page_countObject



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

def page_count
  @body.number_of_pages
end

#page_numberObject



24
25
26
# File 'lib/brewery_db/response.rb', line 24

def page_number
  @body.current_page
end

#paginated_collectionObject



16
17
18
# File 'lib/brewery_db/response.rb', line 16

def paginated_collection
  PaginatedCollection.new(self)
end