summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-23 02:18:52 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-23 02:18:52 (GMT)
commit96db72ce38b27799dd8e80ca00696e41234db6ba (patch)
tree4c210692772faf26ed8ddac746dc79aec0240e2d /random.c
parentb9d01e225723b3dfb6e18d0dcb790c20fef78d63 (diff)
[DOC] missing docs at toplevel
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'random.c')
-rw-r--r--random.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/random.c b/random.c
index b800f1d..88c05fb 100644
--- a/random.c
+++ b/random.c
@@ -1378,6 +1378,16 @@ rand_random(int argc, VALUE *argv, VALUE obj, rb_random_t *rnd)
return rand_range(obj, rnd, vmax);
}
+/*
+ * call-seq:
+ * prng.random_number -> float
+ * prng.random_number(max) -> number
+ * prng.rand -> float
+ * prng.rand(max) -> number
+ *
+ * Generates formatted random number from raw random bytes.
+ * See Random#rand.
+ */
static VALUE
rand_random_number(int argc, VALUE *argv, VALUE obj)
{
@@ -1644,6 +1654,8 @@ InitVM_Random(void)
{
/* Direct access to Ruby's Pseudorandom number generator (PRNG). */
VALUE rand_default = Init_Random_default();
+ /* The default Pseudorandom number generator. Used by class
+ * methods of Random. */
rb_define_const(rb_cRandom, "DEFAULT", rand_default);
}
@@ -1656,6 +1668,7 @@ InitVM_Random(void)
rb_define_private_method(CLASS_OF(rb_cRandom), "left", random_s_left, 0);
{
+ /* Format raw random number as Random does */
VALUE m = rb_define_module_under(rb_cRandom, "Formatter");
rb_include_module(rb_cRandom, m);
rb_define_method(m, "random_number", rand_random_number, -1);