summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
authordave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-30 16:38:32 +0000
committerdave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-30 16:38:32 +0000
commite8c88007403d6892df7464ad443bd6bacab0546d (patch)
tree05fc392080ae4257df67782f72ad344e500307bb /range.c
parentfbfe706aee4f10560f669e48b51a942aaa206e73 (diff)
Add RDoc for kernel functions, and tidy up
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@5352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'range.c')
-rw-r--r--range.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/range.c b/range.c
index bd9286f..66e6070 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 <i>rng</i>, 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
+ * <code>inspect</code> 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
+ * <code>Range#each</code> would return _val_ at some point).
+ */
+
static VALUE
range_member(range, val)
VALUE range, val;