Class: AWS::Core::PageResult
- Inherits:
-
Array
- Object
- Array
- AWS::Core::PageResult
- Defined in:
- lib/aws/core/page_result.rb
Instance Attribute Summary collapse
-
#collection ⇒ Collection
readonly
Returns the collection that was used to populated this page of results.
-
#next_token ⇒ String
readonly
An opaque token that can be passed the #page method of the collection that returned this page of results.
-
#per_page ⇒ Integer
readonly
Returns the maximum number of results per page.
Instance Method Summary collapse
-
#initialize(collection, items, per_page, next_token) ⇒ PageResult
constructor
A new instance of PageResult.
-
#last_page? ⇒ Boolean
Returns
true
if this is the last page of results. -
#more? ⇒ Boolean
Returns
true
if there are more pages of results. - #next_page ⇒ PageResult
Constructor Details
#initialize(collection, items, per_page, next_token) ⇒ PageResult
Returns a new instance of PageResult.
46 47 48 49 50 51 |
# File 'lib/aws/core/page_result.rb', line 46 def initialize collection, items, per_page, next_token @collection = collection @per_page = per_page @next_token = next_token super(items) end |
Instance Attribute Details
#collection ⇒ Collection (readonly)
Returns the collection that was used to populated this page of results.
20 21 22 |
# File 'lib/aws/core/page_result.rb', line 20 def collection @collection end |
#next_token ⇒ String (readonly)
Returns An opaque token that can be passed the #page method of the collection that returned this page of results. This next token behaves as a pseudo offset. If next_token
is nil
then there are no more results for the collection.
31 32 33 |
# File 'lib/aws/core/page_result.rb', line 31 def next_token @next_token end |
#per_page ⇒ Integer (readonly)
Returns the maximum number of results per page. The final page in a collection may return fewer than :per_page
items (e.g. :per_page
is 10 and there are only 7 items).
25 26 27 |
# File 'lib/aws/core/page_result.rb', line 25 def per_page @per_page end |
Instance Method Details
#last_page? ⇒ Boolean
Returns true
if this is the last page of results.
64 65 66 |
# File 'lib/aws/core/page_result.rb', line 64 def last_page? next_token.nil? end |
#more? ⇒ Boolean
Returns true
if there are more pages of results.
69 70 71 |
# File 'lib/aws/core/page_result.rb', line 69 def more? !!next_token end |
#next_page ⇒ PageResult
56 57 58 59 60 61 |
# File 'lib/aws/core/page_result.rb', line 56 def next_page if last_page? raise 'unable to get the next page, already at the last page' end collection.page(:per_page => per_page, :next_token => next_token) end |