Class: Dnsimple::PaginatedResponse

Inherits:
CollectionResponse show all
Defined in:
lib/dnsimple/response.rb

Overview

The PaginatedResponse is a specific type of Response that also exposes pagination metadata.

Direct Known Subclasses

PaginatedResponseWithQuery

Instance Attribute Summary collapse

Attributes inherited from Response

#data, #http_response, #rate_limit, #rate_limit_remaining, #rate_limit_reset

Instance Method Summary collapse

Constructor Details

#initialize(http_response, collection) ⇒ PaginatedResponse

Initializes a new paginated response from the response metadata, and with given collection.

Parameters:

  • http_response (Hash)

    the HTTP response

  • collection (Array)

    the enumerable collection of records returned in the response data



63
64
65
66
67
68
69
70
71
# File 'lib/dnsimple/response.rb', line 63

def initialize(http_response, collection)
  super

  pagination = http_response["pagination"]
  @page = pagination["current_page"]
  @per_page = pagination["per_page"]
  @total_entries = pagination["total_entries"]
  @total_pages = pagination["total_pages"]
end

Instance Attribute Details

#pageInteger (readonly)

Returns The current page.

Returns:

  • (Integer)

    The current page.



46
47
48
# File 'lib/dnsimple/response.rb', line 46

def page
  @page
end

#per_pageInteger (readonly)

Returns The number of records per page.

Returns:

  • (Integer)

    The number of records per page.



49
50
51
# File 'lib/dnsimple/response.rb', line 49

def per_page
  @per_page
end

#total_entriesInteger (readonly)

Returns The total number of records.

Returns:

  • (Integer)

    The total number of records.



52
53
54
# File 'lib/dnsimple/response.rb', line 52

def total_entries
  @total_entries
end

#total_pagesInteger (readonly)

Returns The total number of pages.

Returns:

  • (Integer)

    The total number of pages.



55
56
57
# File 'lib/dnsimple/response.rb', line 55

def total_pages
  @total_pages
end