Class: CooCoo::Transformers::Stopper
- Defined in:
- lib/coo-coo/transformer.rb
Instance Method Summary collapse
-
#initialize(enum, n) ⇒ Stopper
constructor
A new instance of Stopper.
- #next ⇒ Object
Methods inherited from Base
bin_op, bin_op_inner, #drop, #first
Constructor Details
#initialize(enum, n) ⇒ Stopper
Returns a new instance of Stopper.
54 55 56 57 58 59 |
# File 'lib/coo-coo/transformer.rb', line 54 def initialize(enum, n) @stop_after = n @index = 0 super(enum) end |
Instance Method Details
#next ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/coo-coo/transformer.rb', line 61 def next if @index < @stop_after @index += 1 super else raise StopIteration end end |