Class: Stages::Limit
Instance Attribute Summary
Attributes inherited from Stage
#source
Instance Method Summary
collapse
Methods inherited from Stage
#die, #done?, #drop_leftmost!, #each, #end?, #handle_value, #initialize_loop, #input, #length, #output, #root_source, #run, #source_empty?, #to_enum, #|
Constructor Details
#initialize(allowed) ⇒ Limit
3
4
5
6
7
|
# File 'lib/stages/limit.rb', line 3
def initialize(allowed)
@allowed = allowed
@sent = 0
super()
end
|
Instance Method Details
#process ⇒ Object
9
10
11
12
13
14
|
# File 'lib/stages/limit.rb', line 9
def process
while @sent < @allowed
handle_value input
@sent += 1
end
end
|
#reset ⇒ Object
16
17
18
19
|
# File 'lib/stages/limit.rb', line 16
def reset
@sent = 0
super()
end
|