Sha256: 688a7d0895d692c40d87817216f46229528b4a221100b88d94f199fce9da5bb3

Contents?: true

Size: 604 Bytes

Versions: 13

Compression:

Stored size: 604 Bytes

Contents

# frozen_string_literal: true

module GrpcMock
  class ResponsesSequence
    attr_accessor :repeat

    def initialize(responses)
      @repeat = 1
      @responses = responses
      @current = 0
      @last = @responses.length - 1
    end

    def end?
      @repeat == 0
    end

    def next
      if @repeat > 0
        response = @responses[@current]
        next_pos
        response
      else
        @responses.last
      end
    end

    private

    def next_pos
      if @last == @current
        @current = 0
        @repeat -= 1
      else
        @current += 1
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/grpc_mock-0.4.6/lib/grpc_mock/response_sequence.rb
grpc_mock-0.4.6 lib/grpc_mock/response_sequence.rb
grpc_mock-0.4.5 lib/grpc_mock/response_sequence.rb
grpc_mock-0.4.4 lib/grpc_mock/response_sequence.rb
grpc_mock-0.4.3 lib/grpc_mock/response_sequence.rb
grpc_mock-0.4.2 lib/grpc_mock/response_sequence.rb
grpc_mock-0.4.1 lib/grpc_mock/response_sequence.rb
gruffish-0.5.0.pre1 lib/grpc_mock/response_sequence.rb
grpc_mock-0.4.0 lib/grpc_mock/response_sequence.rb
grpc_mock-0.3.1 lib/grpc_mock/response_sequence.rb
grpc_mock-0.3.0 lib/grpc_mock/resopnse_sequence.rb
grpc_mock-0.2.2 lib/grpc_mock/resopnse_sequence.rb
grpc_mock-0.2.1 lib/grpc_mock/resopnse_sequence.rb