Class: Stages::Limit
Instance Attribute Summary
Attributes inherited from Stage
Instance Method Summary collapse
-
#initialize(allowed) ⇒ Limit
constructor
A new instance of Limit.
- #process ⇒ Object
- #reset ⇒ Object
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
Returns a new instance of 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 |