rbs 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +5 -0
- data/CHANGELOG.md +23 -0
- data/README.md +6 -1
- data/core/array.rbs +2866 -1086
- data/core/basic_object.rbs +150 -30
- data/core/binding.rbs +33 -0
- data/core/builtin.rbs +4 -4
- data/core/class.rbs +43 -5
- data/core/comparable.rbs +57 -0
- data/core/complex.rbs +170 -4
- data/core/constants.rbs +51 -0
- data/core/deprecated.rbs +7 -0
- data/core/dir.rbs +305 -20
- data/core/encoding.rbs +472 -77
- data/core/enumerable.rbs +2173 -234
- data/core/enumerator.rbs +448 -182
- data/core/env.rbs +448 -1
- data/core/errno.rbs +1 -10
- data/core/errors.rbs +152 -2
- data/core/exception.rbs +201 -127
- data/core/false_class.rbs +27 -0
- data/core/fiber.rbs +118 -37
- data/core/fiber_error.rbs +8 -9
- data/core/file.rbs +1059 -139
- data/core/file_test.rbs +287 -32
- data/core/float.rbs +776 -300
- data/core/gc.rbs +185 -34
- data/core/global_variables.rbs +5 -1
- data/core/hash.rbs +1582 -649
- data/core/integer.rbs +974 -204
- data/core/io/buffer.rbs +710 -0
- data/core/io/wait.rbs +29 -8
- data/core/io.rbs +2438 -417
- data/core/kernel.rbs +2315 -316
- data/core/marshal.rbs +37 -2
- data/core/match_data.rbs +123 -6
- data/core/math.rbs +126 -6
- data/core/method.rbs +226 -102
- data/core/module.rbs +421 -45
- data/core/nil_class.rbs +64 -0
- data/core/numeric.rbs +620 -142
- data/core/object.rbs +453 -81
- data/core/object_space.rbs +92 -2
- data/core/proc.rbs +482 -285
- data/core/process.rbs +443 -34
- data/core/ractor.rbs +232 -9
- data/core/random.rbs +151 -52
- data/core/range.rbs +885 -160
- data/core/rational.rbs +122 -6
- data/core/rb_config.rbs +14 -4
- data/core/refinement.rbs +44 -0
- data/core/regexp.rbs +156 -14
- data/core/ruby_vm.rbs +42 -3
- data/core/signal.rbs +78 -39
- data/core/string.rbs +2123 -567
- data/core/string_io.rbs +204 -0
- data/core/struct.rbs +283 -28
- data/core/symbol.rbs +304 -30
- data/core/thread.rbs +1288 -688
- data/core/thread_group.rbs +66 -10
- data/core/time.rbs +643 -217
- data/core/trace_point.rbs +100 -12
- data/core/true_class.rbs +24 -0
- data/core/unbound_method.rbs +73 -7
- data/core/warning.rbs +37 -12
- data/docs/CONTRIBUTING.md +40 -34
- data/docs/stdlib.md +3 -102
- data/lib/rbs/annotate/annotations.rb +197 -0
- data/lib/rbs/annotate/formatter.rb +80 -0
- data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
- data/lib/rbs/annotate/rdoc_source.rb +120 -0
- data/lib/rbs/annotate.rb +6 -0
- data/lib/rbs/cli.rb +45 -1
- data/lib/rbs/definition_builder.rb +5 -1
- data/lib/rbs/location_aux.rb +12 -0
- data/lib/rbs/prototype/rb.rb +12 -0
- data/lib/rbs/version.rb +1 -1
- data/sig/annotate/annotations.rbs +102 -0
- data/sig/annotate/formatter.rbs +24 -0
- data/sig/annotate/rdoc_annotater.rbs +82 -0
- data/sig/annotate/rdoc_source.rbs +30 -0
- data/sig/cli.rbs +2 -0
- data/sig/collection/{collections.rbs → sources.rbs} +0 -0
- data/sig/location.rbs +6 -0
- data/sig/method_types.rbs +5 -1
- data/sig/polyfill.rbs +78 -0
- data/stdlib/abbrev/0/abbrev.rbs +6 -0
- data/stdlib/abbrev/0/array.rbs +26 -0
- data/stdlib/base64/0/base64.rbs +31 -0
- data/stdlib/benchmark/0/benchmark.rbs +74 -3
- data/stdlib/bigdecimal/0/big_decimal.rbs +614 -165
- data/stdlib/bigdecimal-math/0/big_math.rbs +41 -64
- data/stdlib/cgi/0/core.rbs +59 -0
- data/stdlib/coverage/0/coverage.rbs +164 -2
- data/stdlib/csv/0/csv.rbs +2862 -398
- data/stdlib/date/0/date.rbs +483 -25
- data/stdlib/date/0/date_time.rbs +187 -12
- data/stdlib/dbm/0/dbm.rbs +152 -17
- data/stdlib/digest/0/digest.rbs +146 -0
- data/stdlib/erb/0/erb.rbs +65 -245
- data/stdlib/fiber/0/fiber.rbs +73 -91
- data/stdlib/fileutils/0/fileutils.rbs +301 -1
- data/stdlib/find/0/find.rbs +9 -0
- data/stdlib/forwardable/0/forwardable.rbs +65 -1
- data/stdlib/io-console/0/io-console.rbs +227 -15
- data/stdlib/ipaddr/0/ipaddr.rbs +161 -0
- data/stdlib/json/0/json.rbs +1146 -144
- data/stdlib/logger/0/formatter.rbs +24 -0
- data/stdlib/logger/0/log_device.rbs +64 -0
- data/stdlib/logger/0/logger.rbs +165 -13
- data/stdlib/logger/0/period.rbs +10 -0
- data/stdlib/logger/0/severity.rbs +26 -0
- data/stdlib/monitor/0/monitor.rbs +163 -0
- data/stdlib/mutex_m/0/mutex_m.rbs +35 -6
- data/stdlib/net-http/0/net-http.rbs +1492 -683
- data/stdlib/nkf/0/nkf.rbs +372 -0
- data/stdlib/objspace/0/objspace.rbs +149 -90
- data/stdlib/openssl/0/openssl.rbs +8108 -71
- data/stdlib/optparse/0/optparse.rbs +487 -19
- data/stdlib/pathname/0/pathname.rbs +425 -124
- data/stdlib/prettyprint/0/prettyprint.rbs +120 -99
- data/stdlib/prime/0/integer-extension.rbs +20 -2
- data/stdlib/prime/0/prime.rbs +88 -21
- data/stdlib/pstore/0/pstore.rbs +102 -0
- data/stdlib/pty/0/pty.rbs +64 -14
- data/stdlib/resolv/0/resolv.rbs +420 -31
- data/stdlib/rubygems/0/basic_specification.rbs +4 -1
- data/stdlib/rubygems/0/config_file.rbs +33 -1
- data/stdlib/rubygems/0/dependency_installer.rbs +4 -3
- data/stdlib/rubygems/0/installer.rbs +13 -1
- data/stdlib/rubygems/0/path_support.rbs +4 -1
- data/stdlib/rubygems/0/platform.rbs +5 -1
- data/stdlib/rubygems/0/request_set.rbs +44 -2
- data/stdlib/rubygems/0/requirement.rbs +65 -2
- data/stdlib/rubygems/0/rubygems.rbs +407 -0
- data/stdlib/rubygems/0/source_list.rbs +13 -0
- data/stdlib/rubygems/0/specification.rbs +21 -1
- data/stdlib/rubygems/0/stream_ui.rbs +3 -1
- data/stdlib/rubygems/0/uninstaller.rbs +8 -1
- data/stdlib/rubygems/0/version.rbs +60 -157
- data/stdlib/securerandom/0/securerandom.rbs +44 -0
- data/stdlib/set/0/set.rbs +420 -106
- data/stdlib/shellwords/0/shellwords.rbs +55 -77
- data/stdlib/singleton/0/singleton.rbs +20 -0
- data/stdlib/socket/0/addrinfo.rbs +210 -9
- data/stdlib/socket/0/basic_socket.rbs +103 -11
- data/stdlib/socket/0/ip_socket.rbs +31 -9
- data/stdlib/socket/0/socket.rbs +586 -38
- data/stdlib/socket/0/tcp_server.rbs +22 -2
- data/stdlib/socket/0/tcp_socket.rbs +12 -1
- data/stdlib/socket/0/udp_socket.rbs +25 -2
- data/stdlib/socket/0/unix_server.rbs +22 -2
- data/stdlib/socket/0/unix_socket.rbs +45 -5
- data/stdlib/strscan/0/string_scanner.rbs +210 -9
- data/stdlib/tempfile/0/tempfile.rbs +58 -10
- data/stdlib/time/0/time.rbs +208 -116
- data/stdlib/timeout/0/timeout.rbs +10 -0
- data/stdlib/tmpdir/0/tmpdir.rbs +13 -4
- data/stdlib/tsort/0/cyclic.rbs +1 -0
- data/stdlib/tsort/0/interfaces.rbs +1 -0
- data/stdlib/tsort/0/tsort.rbs +42 -0
- data/stdlib/uri/0/common.rbs +57 -8
- data/stdlib/uri/0/file.rbs +55 -109
- data/stdlib/uri/0/ftp.rbs +6 -3
- data/stdlib/uri/0/generic.rbs +556 -327
- data/stdlib/uri/0/http.rbs +26 -115
- data/stdlib/uri/0/https.rbs +8 -102
- data/stdlib/uri/0/ldap.rbs +143 -137
- data/stdlib/uri/0/ldaps.rbs +8 -102
- data/stdlib/uri/0/mailto.rbs +3 -0
- data/stdlib/uri/0/rfc2396_parser.rbs +66 -26
- data/stdlib/uri/0/ws.rbs +6 -3
- data/stdlib/uri/0/wss.rbs +5 -3
- data/stdlib/yaml/0/dbm.rbs +151 -87
- data/stdlib/yaml/0/store.rbs +6 -0
- data/stdlib/zlib/0/zlib.rbs +90 -31
- metadata +17 -5
- data/lib/rbs/location.rb +0 -221
data/core/random.rbs
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# <!-- rdoc-file=random.c -->
|
1
2
|
# Random provides an interface to Ruby's pseudo-random number generator, or
|
2
3
|
# PRNG. The PRNG produces a deterministic sequence of bits which approximate
|
3
4
|
# true randomness. The sequence may be represented by integers, floats, or
|
@@ -8,19 +9,24 @@
|
|
8
9
|
#
|
9
10
|
# The class method Random.rand provides the base functionality of Kernel.rand
|
10
11
|
# along with better handling of floating point values. These are both interfaces
|
11
|
-
# to
|
12
|
+
# to the Ruby system PRNG.
|
12
13
|
#
|
13
|
-
# Random.new will create a new PRNG with a state independent of
|
14
|
-
# allowing multiple generators with different seed values or sequence
|
15
|
-
# to exist simultaneously. Random objects can be marshaled, allowing
|
16
|
-
# to be saved and resumed.
|
14
|
+
# Random.new will create a new PRNG with a state independent of the Ruby system
|
15
|
+
# PRNG, allowing multiple generators with different seed values or sequence
|
16
|
+
# positions to exist simultaneously. Random objects can be marshaled, allowing
|
17
|
+
# sequences to be saved and resumed.
|
17
18
|
#
|
18
19
|
# PRNGs are currently implemented as a modified Mersenne Twister with a period
|
19
|
-
# of 2**19937-1.
|
20
|
+
# of 2**19937-1. As this algorithm is *not* for cryptographical use, you must
|
21
|
+
# use SecureRandom for security purpose, instead of this PRNG.
|
20
22
|
#
|
21
23
|
class Random < Object
|
22
24
|
include Random::Formatter
|
23
25
|
|
26
|
+
# <!--
|
27
|
+
# rdoc-file=random.c
|
28
|
+
# - prng1 == prng2 -> true or false
|
29
|
+
# -->
|
24
30
|
# Returns true if the two generators have the same internal state, otherwise
|
25
31
|
# false. Equivalent generators will return the same sequence of pseudo-random
|
26
32
|
# numbers. Two generators will generally have the same state only if they were
|
@@ -43,6 +49,10 @@ class Random < Object
|
|
43
49
|
#
|
44
50
|
def ==: (untyped arg0) -> bool
|
45
51
|
|
52
|
+
# <!--
|
53
|
+
# rdoc-file=random.c
|
54
|
+
# - prng.bytes(size) -> string
|
55
|
+
# -->
|
46
56
|
# Returns a random binary string containing `size` bytes.
|
47
57
|
#
|
48
58
|
# random_string = Random.new.bytes(10) # => "\xD7:R\xAB?\x83\xCE\xFAkO"
|
@@ -50,6 +60,10 @@ class Random < Object
|
|
50
60
|
#
|
51
61
|
def bytes: (Integer size) -> String
|
52
62
|
|
63
|
+
# <!--
|
64
|
+
# rdoc-file=random.c
|
65
|
+
# - Random.new(seed = Random.new_seed) -> prng
|
66
|
+
# -->
|
53
67
|
# Creates a new PRNG using `seed` to set the initial state. If `seed` is
|
54
68
|
# omitted, the generator is initialized with Random.new_seed.
|
55
69
|
#
|
@@ -57,6 +71,12 @@ class Random < Object
|
|
57
71
|
#
|
58
72
|
def initialize: (?Integer seed) -> void
|
59
73
|
|
74
|
+
# <!--
|
75
|
+
# rdoc-file=random.c
|
76
|
+
# - prng.rand -> float
|
77
|
+
# - prng.rand(max) -> number
|
78
|
+
# - prng.rand(range) -> number
|
79
|
+
# -->
|
60
80
|
# When `max` is an Integer, `rand` returns a random integer greater than or
|
61
81
|
# equal to zero and less than `max`. Unlike Kernel.rand, when `max` is a
|
62
82
|
# negative integer or zero, `rand` raises an ArgumentError.
|
@@ -69,8 +89,8 @@ class Random < Object
|
|
69
89
|
#
|
70
90
|
# prng.rand(1.5) # => 1.4600282860034115
|
71
91
|
#
|
72
|
-
# When `
|
73
|
-
# range.member?(number) == true
|
92
|
+
# When `range` is a Range, `rand` returns a random number where
|
93
|
+
# `range.member?(number) == true`.
|
74
94
|
#
|
75
95
|
# prng.rand(5..9) # => one of [5, 6, 7, 8, 9]
|
76
96
|
# prng.rand(5...9) # => one of [5, 6, 7, 8]
|
@@ -84,6 +104,10 @@ class Random < Object
|
|
84
104
|
| (Integer | ::Range[Integer] max) -> Integer
|
85
105
|
| (Float | ::Range[Float] max) -> Float
|
86
106
|
|
107
|
+
# <!--
|
108
|
+
# rdoc-file=random.c
|
109
|
+
# - prng.seed -> integer
|
110
|
+
# -->
|
87
111
|
# Returns the seed value used to initialize the generator. This may be used to
|
88
112
|
# initialize another generator with the same state at a later time, causing it
|
89
113
|
# to produce the same sequence of numbers.
|
@@ -97,6 +121,10 @@ class Random < Object
|
|
97
121
|
#
|
98
122
|
def seed: () -> Integer
|
99
123
|
|
124
|
+
# <!--
|
125
|
+
# rdoc-file=random.c
|
126
|
+
# - Random.new_seed -> integer
|
127
|
+
# -->
|
100
128
|
# Returns an arbitrary seed value. This is used by Random.new when no seed value
|
101
129
|
# is specified as an argument.
|
102
130
|
#
|
@@ -104,14 +132,26 @@ class Random < Object
|
|
104
132
|
#
|
105
133
|
def self.new_seed: () -> Integer
|
106
134
|
|
107
|
-
#
|
135
|
+
# <!--
|
136
|
+
# rdoc-file=random.c
|
137
|
+
# - Random.rand -> float
|
138
|
+
# - Random.rand(max) -> number
|
139
|
+
# - Random.rand(range) -> number
|
140
|
+
# -->
|
141
|
+
# Returns a random number using the Ruby system PRNG.
|
142
|
+
#
|
143
|
+
# See also Random#rand.
|
108
144
|
#
|
109
145
|
def self.rand: () -> Float
|
110
146
|
| (Integer | ::Range[Integer] max) -> Integer
|
111
147
|
| (Float | ::Range[Float] max) -> Float
|
112
148
|
|
113
|
-
#
|
114
|
-
#
|
149
|
+
# <!--
|
150
|
+
# rdoc-file=random.c
|
151
|
+
# - srand(number = Random.new_seed) -> old_seed
|
152
|
+
# -->
|
153
|
+
# Seeds the system pseudo-random number generator, with `number`. The previous
|
154
|
+
# seed value is returned.
|
115
155
|
#
|
116
156
|
# If `number` is omitted, seeds the generator using a source of entropy provided
|
117
157
|
# by the operating system, if available (/dev/urandom on Unix systems or the RSA
|
@@ -131,16 +171,60 @@ class Random < Object
|
|
131
171
|
def self.srand: (?Integer number) -> Integer
|
132
172
|
end
|
133
173
|
|
134
|
-
# The default Pseudorandom number generator. Used by class methods of Random.
|
135
|
-
#
|
136
|
-
#
|
137
174
|
Random::DEFAULT: Random
|
138
175
|
|
139
|
-
#
|
176
|
+
# <!-- rdoc-file=lib/random/formatter.rb -->
|
177
|
+
# ## Random number formatter.
|
178
|
+
#
|
179
|
+
# Formats generated random numbers in many manners.
|
180
|
+
#
|
181
|
+
# ### Examples
|
182
|
+
#
|
183
|
+
# Generate random hexadecimal strings:
|
184
|
+
#
|
185
|
+
# require 'random/formatter'
|
186
|
+
#
|
187
|
+
# prng.hex(10) #=> "52750b30ffbc7de3b362"
|
188
|
+
# prng.hex(10) #=> "92b15d6c8dc4beb5f559"
|
189
|
+
# prng.hex(13) #=> "39b290146bea6ce975c37cfc23"
|
190
|
+
#
|
191
|
+
# Generate random base64 strings:
|
192
|
+
#
|
193
|
+
# prng.base64(10) #=> "EcmTPZwWRAozdA=="
|
194
|
+
# prng.base64(10) #=> "KO1nIU+p9DKxGg=="
|
195
|
+
# prng.base64(12) #=> "7kJSM/MzBJI+75j8"
|
196
|
+
#
|
197
|
+
# Generate random binary strings:
|
198
|
+
#
|
199
|
+
# prng.random_bytes(10) #=> "\016\t{\370g\310pbr\301"
|
200
|
+
# prng.random_bytes(10) #=> "\323U\030TO\234\357\020\a\337"
|
140
201
|
#
|
202
|
+
# Generate alphanumeric strings:
|
203
|
+
#
|
204
|
+
# prng.alphanumeric(10) #=> "S8baxMJnPl"
|
205
|
+
# prng.alphanumeric(10) #=> "aOxAg8BAJe"
|
206
|
+
#
|
207
|
+
# Generate UUIDs:
|
208
|
+
#
|
209
|
+
# prng.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594"
|
210
|
+
# prng.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab"
|
211
|
+
#
|
212
|
+
# <!-- rdoc-file=random.c -->
|
213
|
+
# Generate a random number in the given range as Random does
|
214
|
+
#
|
215
|
+
# prng.random_number #=> 0.5816771641321361
|
216
|
+
# prng.random_number(1000) #=> 485
|
217
|
+
# prng.random_number(1..6) #=> 3
|
218
|
+
# prng.rand #=> 0.5816771641321361
|
219
|
+
# prng.rand(1000) #=> 485
|
220
|
+
# prng.rand(1..6) #=> 3
|
141
221
|
#
|
142
222
|
module Random::Formatter
|
143
|
-
#
|
223
|
+
# <!--
|
224
|
+
# rdoc-file=lib/random/formatter.rb
|
225
|
+
# - base64(n=nil)
|
226
|
+
# -->
|
227
|
+
# Random::Formatter#base64 generates a random base64 string.
|
144
228
|
#
|
145
229
|
# The argument *n* specifies the length, in bytes, of the random number to be
|
146
230
|
# generated. The length of the result string is about 4/3 of *n*.
|
@@ -150,19 +234,20 @@ module Random::Formatter
|
|
150
234
|
#
|
151
235
|
# The result may contain A-Z, a-z, 0-9, "+", "/" and "=".
|
152
236
|
#
|
153
|
-
# require '
|
154
|
-
#
|
155
|
-
# SecureRandom.base64 #=> "/2BuBuLf3+WfSKyQbRcc/A=="
|
156
|
-
# SecureRandom.base64 #=> "6BbW0pxO0YENxn38HMUbcQ=="
|
237
|
+
# require 'random/formatter'
|
157
238
|
#
|
158
|
-
#
|
159
|
-
#
|
239
|
+
# prng.base64 #=> "/2BuBuLf3+WfSKyQbRcc/A=="
|
240
|
+
# prng.base64 #=> "6BbW0pxO0YENxn38HMUbcQ=="
|
160
241
|
#
|
161
242
|
# See RFC 3548 for the definition of base64.
|
162
243
|
#
|
163
244
|
def base64: (?Integer? n) -> String
|
164
245
|
|
165
|
-
#
|
246
|
+
# <!--
|
247
|
+
# rdoc-file=lib/random/formatter.rb
|
248
|
+
# - hex(n=nil)
|
249
|
+
# -->
|
250
|
+
# Random::Formatter#hex generates a random hexadecimal string.
|
166
251
|
#
|
167
252
|
# The argument *n* specifies the length, in bytes, of the random number to be
|
168
253
|
# generated. The length of the resulting hexadecimal string is twice of *n*.
|
@@ -172,16 +257,14 @@ module Random::Formatter
|
|
172
257
|
#
|
173
258
|
# The result may contain 0-9 and a-f.
|
174
259
|
#
|
175
|
-
# require '
|
260
|
+
# require 'random/formatter'
|
176
261
|
#
|
177
|
-
#
|
178
|
-
#
|
179
|
-
#
|
180
|
-
# If a secure random number generator is not available, `NotImplementedError` is
|
181
|
-
# raised.
|
262
|
+
# prng.hex #=> "eb693ec8252cd630102fd0d0fb7c3485"
|
263
|
+
# prng.hex #=> "91dc3bfb4de5b11d029d376634589b61"
|
182
264
|
#
|
183
265
|
def hex: (?Integer? n) -> String
|
184
266
|
|
267
|
+
# <!-- rdoc-file=random.c -->
|
185
268
|
# Generates formatted random number from raw random bytes. See Random#rand.
|
186
269
|
#
|
187
270
|
def rand: () -> Float
|
@@ -192,7 +275,11 @@ module Random::Formatter
|
|
192
275
|
| (?::Range[Integer]? n) -> Integer
|
193
276
|
| (?::Range[Numeric]? n) -> Numeric
|
194
277
|
|
195
|
-
#
|
278
|
+
# <!--
|
279
|
+
# rdoc-file=lib/random/formatter.rb
|
280
|
+
# - random_bytes(n=nil)
|
281
|
+
# -->
|
282
|
+
# Random::Formatter#random_bytes generates a random binary string.
|
196
283
|
#
|
197
284
|
# The argument *n* specifies the length of the result string.
|
198
285
|
#
|
@@ -200,16 +287,22 @@ module Random::Formatter
|
|
200
287
|
#
|
201
288
|
# The result may contain any byte: "x00" - "xff".
|
202
289
|
#
|
203
|
-
# require '
|
204
|
-
#
|
205
|
-
# SecureRandom.random_bytes #=> "\xD8\\\xE0\xF4\r\xB2\xFC*WM\xFF\x83\x18\xF45\xB6"
|
206
|
-
# SecureRandom.random_bytes #=> "m\xDC\xFC/\a\x00Uf\xB2\xB2P\xBD\xFF6S\x97"
|
290
|
+
# require 'random/formatter'
|
207
291
|
#
|
208
|
-
#
|
209
|
-
#
|
292
|
+
# prng.random_bytes #=> "\xD8\\\xE0\xF4\r\xB2\xFC*WM\xFF\x83\x18\xF45\xB6"
|
293
|
+
# prng.random_bytes #=> "m\xDC\xFC/\a\x00Uf\xB2\xB2P\xBD\xFF6S\x97"
|
210
294
|
#
|
211
295
|
def random_bytes: (?Integer? n) -> String
|
212
296
|
|
297
|
+
# <!--
|
298
|
+
# rdoc-file=random.c
|
299
|
+
# - prng.random_number -> float
|
300
|
+
# - prng.random_number(max) -> number
|
301
|
+
# - prng.random_number(range) -> number
|
302
|
+
# - prng.rand -> float
|
303
|
+
# - prng.rand(max) -> number
|
304
|
+
# - prng.rand(range) -> number
|
305
|
+
# -->
|
213
306
|
# Generates formatted random number from raw random bytes. See Random#rand.
|
214
307
|
#
|
215
308
|
def random_number: () -> Float
|
@@ -220,7 +313,11 @@ module Random::Formatter
|
|
220
313
|
| (?::Range[Integer]? n) -> Integer
|
221
314
|
| (?::Range[Numeric]? n) -> Numeric
|
222
315
|
|
223
|
-
#
|
316
|
+
# <!--
|
317
|
+
# rdoc-file=lib/random/formatter.rb
|
318
|
+
# - urlsafe_base64(n=nil, padding=false)
|
319
|
+
# -->
|
320
|
+
# Random::Formatter#urlsafe_base64 generates a random URL-safe base64 string.
|
224
321
|
#
|
225
322
|
# The argument *n* specifies the length, in bytes, of the random number to be
|
226
323
|
# generated. The length of the result string is about 4/3 of *n*.
|
@@ -235,28 +332,30 @@ module Random::Formatter
|
|
235
332
|
# The result may contain A-Z, a-z, 0-9, "-" and "_". "=" is also used if
|
236
333
|
# *padding* is true.
|
237
334
|
#
|
238
|
-
# require '
|
239
|
-
#
|
240
|
-
# SecureRandom.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg"
|
241
|
-
# SecureRandom.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg"
|
335
|
+
# require 'random/formatter'
|
242
336
|
#
|
243
|
-
#
|
244
|
-
#
|
337
|
+
# prng.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg"
|
338
|
+
# prng.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg"
|
245
339
|
#
|
246
|
-
#
|
247
|
-
#
|
340
|
+
# prng.urlsafe_base64(nil, true) #=> "i0XQ-7gglIsHGV2_BNPrdQ=="
|
341
|
+
# prng.urlsafe_base64(nil, true) #=> "-M8rLhr7JEpJlqFGUMmOxg=="
|
248
342
|
#
|
249
343
|
# See RFC 3548 for the definition of URL-safe base64.
|
250
344
|
#
|
251
345
|
def urlsafe_base64: (?Integer? n, ?boolish padding) -> String
|
252
346
|
|
253
|
-
#
|
254
|
-
#
|
255
|
-
#
|
256
|
-
#
|
257
|
-
#
|
258
|
-
#
|
259
|
-
#
|
347
|
+
# <!--
|
348
|
+
# rdoc-file=lib/random/formatter.rb
|
349
|
+
# - uuid()
|
350
|
+
# -->
|
351
|
+
# Random::Formatter#uuid generates a random v4 UUID (Universally Unique
|
352
|
+
# IDentifier).
|
353
|
+
#
|
354
|
+
# require 'random/formatter'
|
355
|
+
#
|
356
|
+
# prng.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594"
|
357
|
+
# prng.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab"
|
358
|
+
# prng.uuid #=> "62936e70-1815-439b-bf89-8492855a7e6b"
|
260
359
|
#
|
261
360
|
# The version 4 UUID is purely random (except the version). It doesn't contain
|
262
361
|
# meaningful information such as MAC addresses, timestamps, etc.
|