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



68
69
70
71
72
73
74
75
76
# File 'lib/dnsimple/response.rb', line 68

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.



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

def page
  @page
end

#per_pageInteger (readonly)

Returns The number of records per page.

Returns:

  • (Integer)

    The number of records per page.



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

def per_page
  @per_page
end

#total_entriesInteger (readonly)

Returns The total number of records.

Returns:

  • (Integer)

    The total number of records.



57
58
59
# File 'lib/dnsimple/response.rb', line 57

def total_entries
  @total_entries
end

#total_pagesInteger (readonly)

Returns The total number of pages.

Returns:

  • (Integer)

    The total number of pages.



60
61
62
# File 'lib/dnsimple/response.rb', line 60

def total_pages
  @total_pages
end