max

rng.max â objrng.max {| a,b | block } â obj Instance Public methods Returns the maximum value in the range. Returns nil if the begin value of the range larger than the end value. Can be given an optional block to override the default comparison method a <=> b. (10..20).max #=> 20

member?

rng.member?(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

min

rng.min â objrng.min {| a,b | block } â obj Instance Public methods Returns the minimum value in the range. Returns nil if the begin value of the range is larger than the end value. Can be given an optional block to override the default comparison method a <=> b. (10..20).min #=> 10

pretty_print

pretty_print(q) Instance Public methods

size

rng.size â num Instance Public methods Returns the number of elements in the range. Both the begin and the end of the Range must be Numeric, otherwise nil is returned. (10..20).size #=> 11 ('a'..'z').size #=> nil (-Float::INFINITY..Float::INFINITY).size #=> Infinity

step

rng.step(n=1) {| obj | block } â rngrng.step(n=1) â an_enumerator Instance Public methods Iterates over the range, passing each nth element to the block. If begin and end are numeric, n is added for each iteration. Otherwise step invokes succ to iterate through range elements. If no block is given, an enumerator is returned instead. range = Xs.new(1)..Xs.new(10) range.step(2) {|x| puts x} puts range.step(3) {|x| puts x} produces: 1 x 3 xxx 5 xxxxx 7 xxx

to_json

to_json(*args) Instance Public methods Stores class name (Range) with JSON array of arguments a which include first (integer), last (integer), and exclude_end? (boolean) as JSON string.

to_s

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

json_create

json_create(object) Class Public methods

*

rat * numeric â numeric Instance Public methods Performs multiplication. Rational(2, 3) * Rational(2, 3) #=> (4/9) Rational(900) * Rational(1) #=> (900/1) Rational(-2, 9) * Rational(-9, 2) #=> (1/1) Rational(9, 8) * 4 #=> (9/2) Rational(20, 9) * 9.8 #=> 21.77777777777778