cover?

rng.cover?(obj) â true or false Instance Public methods Returns true if obj is between the begin and end of the range. This tests begin <= obj <= end when exclude_end? is false and begin <= obj < end when exclude_end? is true. ("a".."z").cover?("c") #=> true ("a".."z").cover?("5") #=> false ("a".."z").cover?("cc") #=> true

each

rng.each {| i | block } â rngrng.each â an_enumerator Instance Public methods Iterates over the elements of range, passing each in turn to the block. The each method can only be used if the begin object of the range supports the succ method. A TypeError is raised if the object does not have succ method defined (like Float). If no block is given, an enumerator is returned instead. (10..15).each {|n| print n, ' ' } # prints: 10 11 12 13 14 15 (2.5..5).each {|n| prin

end

rng.end â obj Instance Public methods Returns the object that defines the end of the range. (1..10).end #=> 10 (1...10).end #=> 10

eql?

rng.eql?(obj) â true or false Instance Public methods Returns true only if obj is a Range, has equivalent begin and end items (by comparing them with eql?), and has the same exclude_end? setting as the range. (0..2).eql?(0..2) #=> true (0..2).eql?(Range.new(0,2)) #=> true (0..2).eql?(0...2) #=> false

exclude_end?

rng.exclude_end? â true or false Instance Public methods Returns true if the range excludes its end value. (1..5).exclude_end? #=> false (1...5).exclude_end? #=> true

first

rng.first â objrng.first(n) â an_array Instance Public methods Returns the first object in the range, or an array of the first n elements. (10..20).first #=> 10 (10..20).first(3) #=> [10, 11, 12]

hash

rng.hash â fixnum Instance Public methods Compute a hash-code for this range. Two ranges with equal begin and end points (using eql?), and the same exclude_end? value will generate the same hash-code.

include?

rng.include?(obj) â true or false Instance Public methods Returns true if obj is an element of the range, false otherwise. If begin and end are numeric, comparison is done according to the magnitude of the values. ("a".."z").include?("g") #=> true ("a".."z").include?("A") #=> false ("a".."z").include?("cc") #=> false

inspect

rng.inspect â string Instance Public methods Convert this range object to a printable form (using inspect to convert the begin and end objects).

last

rng.last â objrng.last(n) â an_array Instance Public methods Returns the last object in the range, or an array of the last n elements. Note that with no arguments last will return the object that defines the end of the range even if exclude_end? is true. (10..20).last #=> 20 (10...20).last #=> 20 (10..20).last(3) #=> [18, 19, 20] (10...20).last(3) #=> [17, 18, 19]