From 23f64f48104e8dd87271c80aa98f1a46602e671a Mon Sep 17 00:00:00 2001 From: dave Date: Tue, 30 Dec 2003 16:38:32 +0000 Subject: Add RDoc for kernel functions, and tidy up git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@5352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- range.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'range.c') diff --git a/range.c b/range.c index bd9286f09..66e6070cf 100644 --- a/range.c +++ b/range.c @@ -195,6 +195,15 @@ range_eql(range, obj) return Qtrue; } +/* + * call-seq: + * rng.hash => fixnum + * + * 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. + */ + static VALUE range_hash(range) VALUE range; @@ -361,7 +370,9 @@ each_i(v, arg) * rng.each {| i | block } => rng * * Iterates over the elements rng, passing each in turn to the - * block. + * 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). * * (10..15).each do |n| * print n, ' ' @@ -484,6 +495,13 @@ rb_range_beg_len(range, begp, lenp, len, err) return Qnil; } +/* + * call-seq: + * rng.to_s => string + * + * Convert this range object to a printable form. + */ + static VALUE range_to_s(range) VALUE range; @@ -500,6 +518,16 @@ range_to_s(range) return str; } +/* + * call-seq: + * rng.inspect => string + * + * Convert this range object to a printable form (using + * inspect to convert the start and end + * objects). + */ + + static VALUE range_inspect(range) VALUE range; @@ -526,6 +554,14 @@ member_i(v, args) } } +/* + * call-seq: + * rng.member?(val) => true or false + * + * Return +true+ if _val_ is one of the values in _rng_ (that is if + * Range#each would return _val_ at some point). + */ + static VALUE range_member(range, val) VALUE range, val; -- cgit