Enumerator::ArithmeticSequence is a subclass of Enumerator, that is a representation of sequences of numbers with common difference. Instances of this class can be generated by the Range#step and Numeric#step methods.

The class can be used for slicing Array (see Array#slice) or custom collections.

Instance Methods

Returns true only if obj is an Enumerator::ArithmeticSequence, has equivalent begin, end, step, and exclude_end? settings.

An alias for ==

Returns the number that defines the first element of this arithmetic sequence.

No documentation available

Returns the number that defines the end of this arithmetic sequence.

An alias for ==

Returns true if this arithmetic sequence excludes its end value.

Returns the first number in this arithmetic sequence, or an array of the first n elements.

Compute a hash-value for this arithmetic sequence. Two arithmetic sequences with same begin, end, step, and exclude_end? values will generate the same hash-value.

See also Object#hash.

Convert this arithmetic sequence to a printable form.

Returns the last number in this arithmetic sequence, or an array of the last n elements.

Returns the number of elements in this arithmetic sequence if it is a finite sequence. Otherwise, returns nil.

Returns the number that defines the common difference between two adjacent elements in this arithmetic sequence.