Sha256: 22ee48f768bfa140faa1372b513c542a59932c89c875c95f7c36c03fcebb567c

Contents?: true

Size: 531 Bytes

Versions: 2

Compression:

Stored size: 531 Bytes

Contents

# frozen_string_literal: true

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

      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

2 entries across 2 versions & 1 rubygems

Version Path
gitlab-5.1.0 lib/gitlab/headers/total.rb
gitlab-5.0.0 lib/gitlab/headers/total.rb