Class: ProtoPharm::ResponsesSequence
- Inherits:
-
Object
- Object
- ProtoPharm::ResponsesSequence
- Defined in:
- lib/proto_pharm/response_sequence.rb
Instance Attribute Summary collapse
-
#repeat ⇒ Object
Returns the value of attribute repeat.
-
#responses ⇒ Object
readonly
Returns the value of attribute responses.
Instance Method Summary collapse
- #end? ⇒ Boolean
-
#initialize(responses) ⇒ ResponsesSequence
constructor
A new instance of ResponsesSequence.
- #next ⇒ Object
Constructor Details
#initialize(responses) ⇒ ResponsesSequence
Returns a new instance of ResponsesSequence.
8 9 10 11 12 13 |
# File 'lib/proto_pharm/response_sequence.rb', line 8 def initialize(responses) @repeat = 1 @responses = responses @current = 0 @last = @responses.length - 1 end |
Instance Attribute Details
#repeat ⇒ Object
Returns the value of attribute repeat.
5 6 7 |
# File 'lib/proto_pharm/response_sequence.rb', line 5 def repeat @repeat end |
#responses ⇒ Object (readonly)
Returns the value of attribute responses.
6 7 8 |
# File 'lib/proto_pharm/response_sequence.rb', line 6 def responses @responses end |
Instance Method Details
#end? ⇒ Boolean
15 16 17 |
# File 'lib/proto_pharm/response_sequence.rb', line 15 def end? @repeat == 0 end |
#next ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/proto_pharm/response_sequence.rb', line 19 def next if @repeat > 0 response = @responses[@current] next_pos response else @responses.last end end |