Class: ProtoPharm::ResponsesSequence

Inherits:
Object
  • Object
show all
Defined in:
lib/proto_pharm/response_sequence.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#repeatObject

Returns the value of attribute repeat.



5
6
7
# File 'lib/proto_pharm/response_sequence.rb', line 5

def repeat
  @repeat
end

#responsesObject (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

Returns:

  • (Boolean)


15
16
17
# File 'lib/proto_pharm/response_sequence.rb', line 15

def end?
  @repeat == 0
end

#nextObject



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