Class: WebMock::ResponsesSequence
- Inherits:
-
Object
- Object
- WebMock::ResponsesSequence
- Defined in:
- lib/webmock/responses_sequence.rb
Instance Attribute Summary collapse
-
#times_to_repeat ⇒ Object
Returns the value of attribute times_to_repeat.
Instance Method Summary collapse
- #end? ⇒ Boolean
-
#initialize(responses) ⇒ ResponsesSequence
constructor
A new instance of ResponsesSequence.
- #next_response ⇒ Object
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_repeat ⇒ Object
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
13 14 15 |
# File 'lib/webmock/responses_sequence.rb', line 13 def end? @times_to_repeat == 0 end |
#next_response ⇒ Object
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 |