From dc490aced3fc62d7eaa10d2bfc2211da826ea538 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 13 Dec 2021 19:54:38 +0900 Subject: [PATCH] [DOC] Improve Random::Formatter description and example --- lib/random/formatter.rb | 2 ++ random.c | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/random/formatter.rb b/lib/random/formatter.rb index c48886f9e0..0e80bd0f70 100644 --- a/lib/random/formatter.rb +++ b/lib/random/formatter.rb @@ -3,6 +3,8 @@ # == Random number formatter. # +# Formats generated random numbers in many manors. +# # === Examples # # Generate random hexadecimal strings: diff --git a/random.c b/random.c index 580c1f26eb..32c470bdad 100644 --- a/random.c +++ b/random.c @@ -1807,7 +1807,14 @@ InitVM_Random(void) rb_define_private_method(CLASS_OF(rb_cRandom), "left", random_s_left, 0); { - /* Format raw random number as Random does */ + /* + * Generate a random number in the given range as Random does + * + * prng.random_number #=> 0.5816771641321361 + * prng.random_number(1000) #=> 485 + * prng.rand #=> 0.5816771641321361 + * prng.rand(1000) #=> 485 + */ VALUE m = rb_define_module_under(rb_cRandom, "Formatter"); rb_include_module(base, m); rb_extend_object(base, m);