A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.aws.amazon.com/sdkforruby/api/Aws/PageableResponse.html below:

PageableResponse — AWS SDK for Ruby V2

You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Module: Aws::PageableResponse
Defined in:
aws-sdk-core/lib/aws-sdk-core/pageable_response.rb
Overview

Decorates a Seahorse::Client::Response with paging methods:

resp = s3.list_objects(params)
resp.last_page?

resp = resp.next_page
resp.last_page?

resp.next_page

You can enumerate all response pages with a block

ec2.describe_instances(params).each do |page|
    page.reservations.each do |r|
      end
end

Or using #next_page and #last_page?:

resp.last_page?
resp = resp.next_page until resp.last_page?
Defined Under Namespace

Modules: UnsafeEnumerableMethods Classes: LastPageError

Instance Attribute Summary collapse Class Method Summary collapse Instance Method Summary collapse Instance Attribute Details
41
42
43
# File 'aws-sdk-core/lib/aws-sdk-core/pageable_response.rb', line 41

def 
  @pager
end
Class Method Details .extended(base) ⇒ Object
33
34
35
36
37
38
# File 'aws-sdk-core/lib/aws-sdk-core/pageable_response.rb', line 33

def self.extended(base)
  base.send(:extend, Enumerable)
  base.send(:extend, UnsafeEnumerableMethods)
  base.instance_variable_set("@last_page", nil)
  base.instance_variable_set("@more_results", nil)
end
Instance Method Details #each {|response| ... } ⇒ Enumerable? Also known as: each_page

Yields the current and each following response to the given block.

72
73
74
75
76
77
78
79
80
# File 'aws-sdk-core/lib/aws-sdk-core/pageable_response.rb', line 72

def each(&block)
  return enum_for(:each_page) unless block_given?
  response = self
  yield(response)
  until response.last_page?
    response = response.next_page
    yield(response)
  end
end
#last_page? ⇒ Boolean

Returns true if there are no more results. Calling #next_page when this method returns false will raise an error.

46
47
48
49
50
51
# File 'aws-sdk-core/lib/aws-sdk-core/pageable_response.rb', line 46

def last_page?
  if @last_page.nil?
    @last_page = !@pager.truncated?(self)
  end
  @last_page
end
#next_page(params = {}) ⇒ Seahorse::Client::Response
61
62
63
64
65
66
67
# File 'aws-sdk-core/lib/aws-sdk-core/pageable_response.rb', line 61

def next_page(params = {})
  if last_page?
    raise LastPageError.new(self)
  else
    next_response(params)
  end
end
#next_page? ⇒ Boolean

Returns true if there are more results. Calling #next_page will return the next response.

56
57
58
# File 'aws-sdk-core/lib/aws-sdk-core/pageable_response.rb', line 56

def next_page?
  !last_page?
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4