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
permalink #initialize(responses) ⇒ ResponsesSequence
Returns a new instance of ResponsesSequence.
9 10 11 12 13 |
# File 'lib/webmock/responses_sequence.rb', line 9 def initialize(responses) @times_to_repeat = 1 @responses = responses @current_position = 0 end |
Instance Attribute Details
permalink #times_to_repeat ⇒ Object
Returns the value of attribute times_to_repeat.
7 8 9 |
# File 'lib/webmock/responses_sequence.rb', line 7 def times_to_repeat @times_to_repeat end |
Instance Method Details
permalink #end? ⇒ Boolean
15 16 17 |
# File 'lib/webmock/responses_sequence.rb', line 15 def end? @times_to_repeat == 0 end |
permalink #next_response ⇒ Object
[View source] [View on GitHub]
19 20 21 22 23 24 25 26 27 |
# File 'lib/webmock/responses_sequence.rb', line 19 def next_response if @times_to_repeat > 0 response = @responses[@current_position] increase_position response else @responses.last end end |