Ruby Range Functions
EditRocket provides the following information on Range functions in the Ruby source code builder.
begin - Returns the first object in rng.
each - Iterates over the elements rng, passing each in turn to the block. You can only iterate if the start object of the range supports the succ method (which means that you can't iterate over ranges of Float objects).
end - Returns the object that defines the end of rng.
eql?(obj) - "Returns true only if obj is a Range, has equivalent beginning and end items (by comparing them with #eql?), and has the same #exclude_end? setting as rng."
exclude_end? - Returns true if rng excludes its end value.
first - Returns the first object in rng.
hash - Generate a hash value such that two ranges with the same start and end points, and the same value for the "exclude end" flag, generate the same hash value.
include?(val) - Returns true if obj is an element of rng, false otherwise. Conveniently, === is the comparison operator used by case statements.
inspect - Convert this range object to a printable form (using inspect to convert the start and end objects).
last - Returns the object that defines the end of rng.
member?(val) - Returns true if obj is an element of rng, false otherwise. Conveniently, === is the comparison operator used by case statements.
new(start, end, exclusive=false) - Constructs a range using the given start and end. If the third parameter is omitted or is false, the range will include the end object; otherwise, it will be excluded.
pretty_print(q) -
step(n=1) - Iterates over rng, passing each nth element to the block. If the range contains numbers or strings, natural ordering is used. Otherwise step invokes succ to iterate through range elements. The following code uses class Xs, which is defined in the class-level documentation.
to_s - Convert this range object to a printable form.
to_yaml( opts = {} ) -
yaml_new( klass, tag, val ) -