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
commit349f4e7db766e618d606768d5ead8cbc9f4ef74f (patch)
tree37c299cb289d0563962400250d7f7b9a30a0986c /range.c
parent5e6d81e717879424edc46cda993799d8de7aa635 (diff)
Add RDoc for kernel functions, and tidy up
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@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 bd9286f096..66e6070cf8 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;