class Google::Cloud::Bigquery::Table::List
Table::List is a special case Array with additional values.
#
def self.from_gapi gapi_list, service, dataset_id = nil, max = nil
- Private: - New Table::List from a response object.
def self.from_gapi gapi_list, service, dataset_id = nil, max = nil tables = List.new(Array(gapi_list.tables).map { |gapi_object| Table.from_gapi gapi_object, service }) tables.instance_variable_set :@token, gapi_list.next_page_token tables.instance_variable_set :@etag, gapi_list.etag tables.instance_variable_set :@total, gapi_list.total_items tables.instance_variable_set :@service, service tables.instance_variable_set :@dataset_id, dataset_id tables.instance_variable_set :@max, max tables end
def all request_limit: nil, &block
- Example: Limit the number of API requests made: -
Example: Using the enumerator by not passing a block: -
Example: Iterating each result by passing a block: -
Returns:
-
(Enumerator)-
Other tags:
- Yieldparam: table - The table object.
Other tags:
- Yield: - The block for accessing each table.
Parameters:
-
request_limit(Integer) -- The upper limit of API requests to
def all request_limit: nil, &block request_limit = request_limit.to_i if request_limit return enum_for :all, request_limit: request_limit unless block_given? results = self loop do results.each(&block) if request_limit request_limit -= 1 break if request_limit.negative? end break unless results.next? results = results.next end end
def ensure_service!
#
def ensure_service! raise "Must have active connection" unless @service end
def initialize arr = []
- Private: - Create a new Table::List with an array of tables.
def initialize arr = [] super arr end
def next
-
(Table::List)-
def next return nil unless next? ensure_service! gapi = @service.list_tables @dataset_id, token: token, max: @max self.class.from_gapi gapi, @service, @dataset_id, @max end
def next?
-
(Boolean)-
def next? !token.nil? end