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 ⇒ Object
Constructor Details
#initialize(collection, items, per_page, next_token) ⇒ PageResult
Returns a new instance of PageResult.
47 48 49 50 51 52 |
# File 'lib/aws/core/page_result.rb', line 47 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.
21 22 23 |
# File 'lib/aws/core/page_result.rb', line 21 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.
32 33 34 |
# File 'lib/aws/core/page_result.rb', line 32 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).
26 27 28 |
# File 'lib/aws/core/page_result.rb', line 26 def per_page @per_page end |
Instance Method Details
#last_page? ⇒ Boolean
Returns true if this is the last page of results.
62 63 64 |
# File 'lib/aws/core/page_result.rb', line 62 def last_page? next_token.nil? end |
#more? ⇒ Boolean
Returns true if there are more pages of results.
67 68 69 |
# File 'lib/aws/core/page_result.rb', line 67 def more? !!next_token end |
#next_page ⇒ Object
54 55 56 57 58 59 |
# File 'lib/aws/core/page_result.rb', line 54 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 |