Class: Enumerable::Enumerator
- Defined in:
- lib/backports/1.8.7/enumerator/next.rb,
lib/backports/1.8.7/enumerator/rewind.rb,
lib/backports/1.8.7/enumerator/with_index.rb
Instance Method Summary collapse
Instance Method Details
#next ⇒ Object
7 8 9 10 11 12 |
# File 'lib/backports/1.8.7/enumerator/next.rb', line 7 def next require 'generator' @generator ||= ::Generator.new(self) raise StopIteration unless @generator.next? @generator.next end |
#rewind ⇒ Object
5 6 7 8 9 10 |
# File 'lib/backports/1.8.7/enumerator/rewind.rb', line 5 def rewind require 'generator' @generator ||= ::Generator.new(self) @generator.rewind self end |
#with_index(offset = 0) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/backports/1.8.7/enumerator/with_index.rb', line 5 def with_index(offset = 0) return to_enum(:with_index, offset) unless block_given? each do |*args| yield args.size == 1 ? args[0] : args, offset offset += 1 end end |