<commit_before>#--
# Copyright 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

module Gcloud
  module Dns
    class Record
      ##
      # Record::List is a special case Array with additional values.
      class List < DelegateClass(::Array)
        ##
        # If not empty, indicates that there are more records that match
        # the request and this value should be passed to continue.
        attr_accessor :token

        ##
        # Create a new Table::List with an array of jobs.
        def initialize arr = []
          super arr
        end

        ##
        # Whether there a next page of records.
        def next?
          !token.nil?
        end

        ##
        # Retrieve the next page of records.
        def next
          return nil unless next?
          ensure_zone!
          @zone.records token: token
        end

        ##
        # Retrieve all records and add to the current list.
        # This changes the contained records.
        def all
          while next?
            next_records = self.next
            push(*next_records)
            self.token = next_records.token
          end
          self
        end

        ##
        # New Records::List from a response object.
        def self.from_response resp, zone #:nodoc:
          records = new(Array(resp.data["rrsets"]).map do |gapi_object|
            Record.from_gapi gapi_object
          end)
          records.instance_eval do
            @token = resp.data["nextPageToken"]
            @zone = zone
          end<commit_msg>Update docs for DNS Record::List#all<commit_after>#--
# Copyright 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

module Gcloud
  module Dns
    class Record
      ##
      # Record::List is a special case Array with additional values.
      class List < DelegateClass(::Array)
        ##
        # If not empty, indicates that there are more records that match
        # the request and this value should be passed to continue.
        attr_accessor :token

        ##
        # Create a new Table::List with an array of jobs.
        def initialize arr = []
          super arr
        end

        ##
        # Whether there a next page of records.
        def next?
          !token.nil?
        end

        ##
        # Retrieve the next page of records.
        def next
          return nil unless next?
          ensure_zone!
          @zone.records token: token
        end

        ##
        # Retrieves all records by repeatedly loading pages until #next? returns
        # false. Returns the list instance for method chaining.
        #
        # === Example
        #
        #   require "gcloud"
        #
        #   gcloud = Gcloud.new
        #   dns = gcloud.dns
        #   zone = dns.zone "example-zone"
        #   records = zone.records.all # Load all pages of records
        #
        def all
          while next?
            next_records = self.next
            push(*next_records)
            self.token = next_records.token
          end
          self
        end

        ##
        # New Records::List from a response object.
        def self.from_response resp, zone #:nodoc:
          records = new(Array(resp.data["rrsets"]).map do |gapi_object|
            Record.from_gapi gapi_object
          end)
          records.instance_eval do
            @token = resp.data["nextPageToken"]
            @zone = zone
          end
{'fraction_non_alphanumeric': 0.06960608773500447, 'fraction_numerical': 0.0035810205908683975, 'mean_word_length': 1.868421052631579, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2108746', 'n_tokens_mistral': 1148, 'n_tokens_neox': 1123, 'n_words': 466}