Sha256: 2ce067c157d10bb2975cb84e329d3346d59b5979b92f58799a3357fe8d07e971

Contents?: true

Size: 538 Bytes

Versions: 5

Compression:

Stored size: 538 Bytes

Contents

# frozen_string_literal: true

module Gitlab
  module Headers
    # Parses total header.
    #
    # @private
    class Total
      HEADER_TOTAL = 'x-total'
      TOTAL_REGEX = /^\d+$/.freeze

      attr_accessor :total

      def initialize(headers)
        header_total = headers[HEADER_TOTAL]

        extract_total(header_total) if header_total
      end

      private

      def extract_total(header_total)
        TOTAL_REGEX.match(header_total.strip) do |match|
          @total = match[0]
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
gitlab-4.20.1 lib/gitlab/headers/total.rb
gitlab-4.20.0 lib/gitlab/headers/total.rb
fs-gitlab-4.19.3 lib/gitlab/headers/total.rb
fs-gitlab-4.19.2 lib/gitlab/headers/total.rb
fs-gitlab-4.19.1 lib/gitlab/headers/total.rb