Class: Google::Genai::Pager
- Inherits:
-
Object
- Object
- Google::Genai::Pager
- Includes:
- Enumerable
- Defined in:
- lib/google/genai/pagers.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#page_size ⇒ Object
readonly
Returns the value of attribute page_size.
-
#sdk_http_response ⇒ Object
readonly
Returns the value of attribute sdk_http_response.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(name:, request:, response:, config:, item_class:) ⇒ Pager
constructor
A new instance of Pager.
- #next_page ⇒ Object
- #page ⇒ Object
Constructor Details
#initialize(name:, request:, response:, config:, item_class:) ⇒ Pager
Returns a new instance of Pager.
10 11 12 13 |
# File 'lib/google/genai/pagers.rb', line 10 def initialize(name:, request:, response:, config:, item_class:) @item_class = item_class _init_page(name: name, request: request, response: response, config: config) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/google/genai/pagers.rb', line 8 def config @config end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/google/genai/pagers.rb', line 8 def name @name end |
#page_size ⇒ Object (readonly)
Returns the value of attribute page_size.
8 9 10 |
# File 'lib/google/genai/pagers.rb', line 8 def page_size @page_size end |
#sdk_http_response ⇒ Object (readonly)
Returns the value of attribute sdk_http_response.
8 9 10 |
# File 'lib/google/genai/pagers.rb', line 8 def sdk_http_response @sdk_http_response end |
Instance Method Details
#each(&block) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/google/genai/pagers.rb', line 15 def each(&block) loop do @page.each(&block) break unless next_page_token next_page end end |
#next_page ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/google/genai/pagers.rb', line 27 def next_page raise IndexError, 'No more pages to fetch.' unless next_page_token response = @request.call(config: @config) _init_page(name: @name, request: @request, response: response, config: @config) @page end |
#page ⇒ Object
23 24 25 |
# File 'lib/google/genai/pagers.rb', line 23 def page @page end |