Class: Enumerator
- Inherits:
-
Object
- Object
- Enumerator
- Defined in:
- lib/enzymator/core_ext/enumerator.rb
Instance Method Summary collapse
-
#skip(n) ⇒ Object
Skip the first n elements and return an Enumerator for the rest, or pass them in succession to the block, if given.
Instance Method Details
#skip(n) ⇒ Object
Skip the first n elements and return an Enumerator for the rest, or pass them in succession to the block, if given. Extracted from epitools: github.com/epitron/epitools
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/enzymator/core_ext/enumerator.rb', line 7 def skip(n) if block_given? each do |x| if n > 0 n -= 1 else yield x end end else to_enum(:skip, n) end end |