Range

The range object class. See Range Expressions for more information.

Superclass

Included Module

Class Method

Range.new(first, last[, exclude_end])

Creates and returns a range object from first to last. Creates a range object without an end point if exclude_end is true. Includes the end point when exclude_end is omitted.

Methods

self === other

This method is mainly used for comparison within case statements. Returns true if other is within range.

begin
first

Returns the initial element.

each {|item| ... }

Iterates over each element within the range.

end
last

Returns the end point, regardless of whether the range object is inclusive of the end point.

p (1..5).end   # => 5
p (1...5).end  # => 5
exclude_end?

Returns true if the range object is exclusive of the end point.