class GrpcMock::ResponsesSequence

Attributes

repeat[RW]

Public Class Methods

new(responses) click to toggle source
# File lib/grpc_mock/response_sequence.rb, line 7
def initialize(responses)
  @repeat = 1
  @responses = responses
  @current = 0
  @last = @responses.length - 1
end

Public Instance Methods

end?() click to toggle source
# File lib/grpc_mock/response_sequence.rb, line 14
def end?
  @repeat == 0
end
next() click to toggle source
# File lib/grpc_mock/response_sequence.rb, line 18
def next
  if @repeat > 0
    response = @responses[@current]
    next_pos
    response
  else
    @responses.last
  end
end

Private Instance Methods

next_pos() click to toggle source
# File lib/grpc_mock/response_sequence.rb, line 30
def next_pos
  if @last == @current
    @current = 0
    @repeat -= 1
  else
    @current += 1
  end
end