Class Enumerable::Enumerator
In: enumerator.c
Parent: Object

A class which provides a method `each’ to be used as an Enumerable object.

Methods

each   each_with_index   new   next   rewind   with_index  

Included Modules

Enumerable

Public Class methods

Creates a new Enumerable::Enumerator object, which is to be used as an Enumerable object using the given object‘s given method with the given arguments.

Use of this method is not discouraged. Use Kernel#enum_for() instead.

Public Instance methods

Iterates the given block using the object and the method specified in the first place. If no block is given, returns self.

Iterates the given block for each elements with an index, which start from 0. If no block is given, returns an enumerator.

Returns the next object in the enumerator, and move the internal position forward. When the position reached at the end, internal position is rewinded then StopIteration is raised.

Note that enumeration sequence by next method does not affect other non-external enumeration methods, unless underlying iteration methods itself has side-effect, e.g. IO#each_line.

Caution: Calling this method causes the "generator" library to be loaded.

Rewinds the enumeration sequence by the next method.

Iterates the given block for each elements with an index, which start from 0. If no block is given, returns an enumerator.

[Validate]

ruby-doc.org is a community service provided by James Britt and Happy Camper Studios, a Phoenix, Arizona, Ruby application development company.

Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.

For more information on the Ruby programming language, visit ruby-lang.org.

Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.