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.
-
- (String) next_token
readonly
An opaque token that can be passed the #page method of the collection that returned this page of results.
-
- (Integer) per_page
readonly
Returns the maximum number of results per page.
Instance Method Summary (collapse)
-
- (PageResult) initialize(collection, items, per_page, next_token)
constructor
A new instance of PageResult.
-
- (Boolean) last_page?
Returns
trueif this is the last page of results. -
- (Boolean) more?
Returns
trueif there are more pages of results. - - (PageResult) next_page
Constructor Details
- (PageResult) initialize(collection, items, per_page, next_token)
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 |
- (String) next_token (readonly)
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 |
- (Integer) per_page (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
- (Boolean) last_page?
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 |
- (Boolean) more?
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 |
- (PageResult) next_page
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 |