Class: WebMock::ResponsesSequence

Inherits:
Object
  • Object
show all
Defined in:
lib/webmock/responses_sequence.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(responses) ⇒ ResponsesSequence

Returns a new instance of ResponsesSequence.



7
8
9
10
11
# File 'lib/webmock/responses_sequence.rb', line 7

def initialize(responses)
  @times_to_repeat = 1
  @responses = responses
  @current_position = 0
end

Instance Attribute Details

#times_to_repeatObject

Returns the value of attribute times_to_repeat.



5
6
7
# File 'lib/webmock/responses_sequence.rb', line 5

def times_to_repeat
  @times_to_repeat
end

Instance Method Details

#end?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/webmock/responses_sequence.rb', line 13

def end?
  @times_to_repeat == 0
end

#next_responseObject



17
18
19
20
21
22
23
24
25
# File 'lib/webmock/responses_sequence.rb', line 17

def next_response
  if @times_to_repeat > 0
    response = @responses[@current_position]
    increase_position
    response
  else
    @responses.last
  end
end