rbs 2.0.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +34 -0
  3. data/.github/workflows/ruby.yml +5 -0
  4. data/CHANGELOG.md +82 -0
  5. data/README.md +6 -1
  6. data/Rakefile +56 -21
  7. data/core/array.rbs +2866 -1086
  8. data/core/basic_object.rbs +150 -30
  9. data/core/binding.rbs +33 -0
  10. data/core/builtin.rbs +4 -4
  11. data/core/class.rbs +43 -5
  12. data/core/comparable.rbs +57 -0
  13. data/core/complex.rbs +170 -4
  14. data/core/constants.rbs +51 -0
  15. data/core/deprecated.rbs +7 -0
  16. data/core/dir.rbs +305 -20
  17. data/core/encoding.rbs +1214 -77
  18. data/core/enumerable.rbs +2173 -234
  19. data/core/enumerator.rbs +448 -182
  20. data/core/env.rbs +448 -1
  21. data/core/errno.rbs +1 -10
  22. data/core/errors.rbs +152 -2
  23. data/core/exception.rbs +201 -127
  24. data/core/false_class.rbs +27 -0
  25. data/core/fiber.rbs +118 -37
  26. data/core/fiber_error.rbs +8 -9
  27. data/core/file.rbs +1060 -142
  28. data/core/file_test.rbs +287 -32
  29. data/core/float.rbs +776 -300
  30. data/core/gc.rbs +185 -34
  31. data/core/global_variables.rbs +5 -1
  32. data/core/hash.rbs +1582 -649
  33. data/core/integer.rbs +974 -204
  34. data/core/io/buffer.rbs +710 -0
  35. data/core/io/wait.rbs +29 -8
  36. data/core/io.rbs +2438 -417
  37. data/core/kernel.rbs +2319 -318
  38. data/core/marshal.rbs +37 -2
  39. data/core/match_data.rbs +123 -6
  40. data/core/math.rbs +126 -6
  41. data/core/method.rbs +226 -102
  42. data/core/module.rbs +421 -45
  43. data/core/nil_class.rbs +64 -0
  44. data/core/numeric.rbs +620 -142
  45. data/core/object.rbs +453 -81
  46. data/core/object_space.rbs +92 -2
  47. data/core/proc.rbs +482 -285
  48. data/core/process.rbs +443 -34
  49. data/core/ractor.rbs +232 -9
  50. data/core/random.rbs +151 -52
  51. data/core/range.rbs +885 -160
  52. data/core/rational.rbs +122 -6
  53. data/core/rb_config.rbs +14 -4
  54. data/core/refinement.rbs +44 -0
  55. data/core/regexp.rbs +156 -14
  56. data/core/ruby_vm.rbs +42 -3
  57. data/core/signal.rbs +78 -39
  58. data/core/string.rbs +2123 -567
  59. data/core/string_io.rbs +204 -0
  60. data/core/struct.rbs +283 -28
  61. data/core/symbol.rbs +304 -30
  62. data/core/thread.rbs +1288 -688
  63. data/core/thread_group.rbs +66 -10
  64. data/core/time.rbs +643 -217
  65. data/core/trace_point.rbs +100 -12
  66. data/core/true_class.rbs +24 -0
  67. data/core/unbound_method.rbs +73 -7
  68. data/core/warning.rbs +37 -12
  69. data/docs/CONTRIBUTING.md +40 -34
  70. data/docs/stdlib.md +3 -102
  71. data/docs/syntax.md +54 -11
  72. data/ext/rbs_extension/extconf.rb +1 -0
  73. data/ext/rbs_extension/lexer.h +5 -0
  74. data/ext/rbs_extension/lexstate.c +6 -0
  75. data/ext/rbs_extension/parser.c +85 -10
  76. data/ext/rbs_extension/ruby_objs.c +4 -2
  77. data/ext/rbs_extension/ruby_objs.h +2 -2
  78. data/goodcheck.yml +0 -11
  79. data/lib/rbs/annotate/annotations.rb +197 -0
  80. data/lib/rbs/annotate/formatter.rb +80 -0
  81. data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
  82. data/lib/rbs/annotate/rdoc_source.rb +120 -0
  83. data/lib/rbs/annotate.rb +6 -0
  84. data/lib/rbs/ast/members.rb +21 -13
  85. data/lib/rbs/buffer.rb +17 -11
  86. data/lib/rbs/cli.rb +48 -1
  87. data/lib/rbs/definition_builder/method_builder.rb +28 -16
  88. data/lib/rbs/definition_builder.rb +6 -2
  89. data/lib/rbs/environment.rb +8 -4
  90. data/lib/rbs/location_aux.rb +12 -0
  91. data/lib/rbs/namespace.rb +1 -1
  92. data/lib/rbs/prototype/rb.rb +12 -0
  93. data/lib/rbs/type_alias_regularity.rb +6 -4
  94. data/lib/rbs/type_name.rb +1 -1
  95. data/lib/rbs/types.rb +1 -1
  96. data/lib/rbs/validator.rb +6 -0
  97. data/lib/rbs/version.rb +1 -1
  98. data/lib/rbs/writer.rb +54 -4
  99. data/lib/rbs.rb +0 -2
  100. data/schema/typeParam.json +3 -3
  101. data/sig/annotate/annotations.rbs +102 -0
  102. data/sig/annotate/formatter.rbs +24 -0
  103. data/sig/annotate/rdoc_annotater.rbs +82 -0
  104. data/sig/annotate/rdoc_source.rbs +30 -0
  105. data/sig/buffer.rbs +6 -2
  106. data/sig/cli.rbs +2 -0
  107. data/sig/collection/{collections.rbs → sources.rbs} +0 -0
  108. data/sig/location.rbs +6 -0
  109. data/sig/members.rbs +24 -18
  110. data/sig/method_builder.rbs +5 -4
  111. data/sig/method_types.rbs +5 -1
  112. data/sig/polyfill.rbs +78 -0
  113. data/sig/validator.rbs +3 -1
  114. data/sig/writer.rbs +79 -2
  115. data/stdlib/abbrev/0/abbrev.rbs +6 -0
  116. data/stdlib/abbrev/0/array.rbs +26 -0
  117. data/stdlib/base64/0/base64.rbs +31 -0
  118. data/stdlib/benchmark/0/benchmark.rbs +74 -3
  119. data/stdlib/bigdecimal/0/big_decimal.rbs +614 -165
  120. data/stdlib/bigdecimal-math/0/big_math.rbs +41 -64
  121. data/stdlib/cgi/0/core.rbs +649 -21
  122. data/stdlib/coverage/0/coverage.rbs +164 -2
  123. data/stdlib/csv/0/csv.rbs +2862 -398
  124. data/stdlib/date/0/date.rbs +483 -25
  125. data/stdlib/date/0/date_time.rbs +187 -12
  126. data/stdlib/dbm/0/dbm.rbs +152 -17
  127. data/stdlib/digest/0/digest.rbs +146 -0
  128. data/stdlib/erb/0/erb.rbs +65 -245
  129. data/stdlib/fiber/0/fiber.rbs +73 -91
  130. data/stdlib/fileutils/0/fileutils.rbs +301 -1
  131. data/stdlib/find/0/find.rbs +9 -0
  132. data/stdlib/forwardable/0/forwardable.rbs +65 -1
  133. data/stdlib/io-console/0/io-console.rbs +227 -15
  134. data/stdlib/ipaddr/0/ipaddr.rbs +161 -0
  135. data/stdlib/json/0/json.rbs +1147 -145
  136. data/stdlib/logger/0/formatter.rbs +24 -0
  137. data/stdlib/logger/0/log_device.rbs +64 -0
  138. data/stdlib/logger/0/logger.rbs +165 -13
  139. data/stdlib/logger/0/period.rbs +10 -0
  140. data/stdlib/logger/0/severity.rbs +26 -0
  141. data/stdlib/monitor/0/monitor.rbs +163 -0
  142. data/stdlib/mutex_m/0/mutex_m.rbs +35 -6
  143. data/stdlib/net-http/0/manifest.yaml +1 -0
  144. data/stdlib/net-http/0/net-http.rbs +1513 -683
  145. data/stdlib/nkf/0/nkf.rbs +372 -0
  146. data/stdlib/objspace/0/objspace.rbs +149 -90
  147. data/stdlib/openssl/0/openssl.rbs +8108 -71
  148. data/stdlib/optparse/0/optparse.rbs +487 -19
  149. data/stdlib/pathname/0/pathname.rbs +425 -124
  150. data/stdlib/prettyprint/0/prettyprint.rbs +120 -99
  151. data/stdlib/prime/0/integer-extension.rbs +20 -2
  152. data/stdlib/prime/0/prime.rbs +88 -21
  153. data/stdlib/pstore/0/pstore.rbs +102 -0
  154. data/stdlib/pty/0/pty.rbs +64 -14
  155. data/stdlib/resolv/0/resolv.rbs +420 -31
  156. data/stdlib/rubygems/0/basic_specification.rbs +4 -1
  157. data/stdlib/rubygems/0/config_file.rbs +33 -1
  158. data/stdlib/rubygems/0/dependency_installer.rbs +4 -3
  159. data/stdlib/rubygems/0/installer.rbs +13 -1
  160. data/stdlib/rubygems/0/path_support.rbs +4 -1
  161. data/stdlib/rubygems/0/platform.rbs +5 -1
  162. data/stdlib/rubygems/0/request_set.rbs +44 -2
  163. data/stdlib/rubygems/0/requirement.rbs +65 -2
  164. data/stdlib/rubygems/0/rubygems.rbs +407 -0
  165. data/stdlib/rubygems/0/source_list.rbs +13 -0
  166. data/stdlib/rubygems/0/specification.rbs +21 -1
  167. data/stdlib/rubygems/0/stream_ui.rbs +3 -1
  168. data/stdlib/rubygems/0/uninstaller.rbs +8 -1
  169. data/stdlib/rubygems/0/version.rbs +60 -157
  170. data/stdlib/securerandom/0/securerandom.rbs +44 -0
  171. data/stdlib/set/0/set.rbs +423 -109
  172. data/stdlib/shellwords/0/shellwords.rbs +55 -77
  173. data/stdlib/singleton/0/singleton.rbs +20 -0
  174. data/stdlib/socket/0/addrinfo.rbs +210 -9
  175. data/stdlib/socket/0/basic_socket.rbs +103 -11
  176. data/stdlib/socket/0/ip_socket.rbs +31 -9
  177. data/stdlib/socket/0/socket.rbs +586 -38
  178. data/stdlib/socket/0/tcp_server.rbs +22 -2
  179. data/stdlib/socket/0/tcp_socket.rbs +12 -1
  180. data/stdlib/socket/0/udp_socket.rbs +25 -2
  181. data/stdlib/socket/0/unix_server.rbs +22 -2
  182. data/stdlib/socket/0/unix_socket.rbs +45 -5
  183. data/stdlib/strscan/0/string_scanner.rbs +210 -9
  184. data/stdlib/tempfile/0/tempfile.rbs +58 -10
  185. data/stdlib/time/0/time.rbs +208 -116
  186. data/stdlib/timeout/0/timeout.rbs +10 -0
  187. data/stdlib/tmpdir/0/tmpdir.rbs +13 -4
  188. data/stdlib/tsort/0/cyclic.rbs +1 -0
  189. data/stdlib/tsort/0/interfaces.rbs +1 -0
  190. data/stdlib/tsort/0/tsort.rbs +42 -0
  191. data/stdlib/uri/0/common.rbs +57 -8
  192. data/stdlib/uri/0/file.rbs +55 -109
  193. data/stdlib/uri/0/ftp.rbs +6 -3
  194. data/stdlib/uri/0/generic.rbs +558 -329
  195. data/stdlib/uri/0/http.rbs +60 -114
  196. data/stdlib/uri/0/https.rbs +8 -102
  197. data/stdlib/uri/0/ldap.rbs +143 -137
  198. data/stdlib/uri/0/ldaps.rbs +8 -102
  199. data/stdlib/uri/0/mailto.rbs +3 -0
  200. data/stdlib/uri/0/rfc2396_parser.rbs +66 -26
  201. data/stdlib/uri/0/ws.rbs +6 -3
  202. data/stdlib/uri/0/wss.rbs +5 -3
  203. data/stdlib/yaml/0/dbm.rbs +151 -87
  204. data/stdlib/yaml/0/store.rbs +6 -0
  205. data/stdlib/zlib/0/zlib.rbs +90 -31
  206. metadata +18 -6
  207. data/lib/rbs/location.rb +0 -221
  208. data/sig/char_scanner.rbs +0 -9
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 Random::DEFAULT, the Ruby system PRNG.
12
+ # to the Ruby system PRNG.
12
13
  #
13
- # Random.new will create a new PRNG with a state independent of Random::DEFAULT,
14
- # allowing multiple generators with different seed values or sequence positions
15
- # to exist simultaneously. Random objects can be marshaled, allowing sequences
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 `max` is a Range, `rand` returns a random number where
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
- # Alias of Random::DEFAULT.rand.
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
- # Seeds the system pseudo-random number generator, Random::DEFAULT, with
114
- # `number`. The previous seed value is returned.
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
- # Format raw random number as Random does
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
- # SecureRandom.base64 generates a random base64 string.
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 'securerandom'
154
- #
155
- # SecureRandom.base64 #=> "/2BuBuLf3+WfSKyQbRcc/A=="
156
- # SecureRandom.base64 #=> "6BbW0pxO0YENxn38HMUbcQ=="
237
+ # require 'random/formatter'
157
238
  #
158
- # If a secure random number generator is not available, `NotImplementedError` is
159
- # raised.
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
- # SecureRandom.hex generates a random hexadecimal string.
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 'securerandom'
260
+ # require 'random/formatter'
176
261
  #
177
- # SecureRandom.hex #=> "eb693ec8252cd630102fd0d0fb7c3485"
178
- # SecureRandom.hex #=> "91dc3bfb4de5b11d029d376634589b61"
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
- # SecureRandom.random_bytes generates a random binary string.
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 'securerandom'
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
- # If a secure random number generator is not available, `NotImplementedError` is
209
- # raised.
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
- # SecureRandom.urlsafe_base64 generates a random URL-safe base64 string.
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 'securerandom'
239
- #
240
- # SecureRandom.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg"
241
- # SecureRandom.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg"
335
+ # require 'random/formatter'
242
336
  #
243
- # SecureRandom.urlsafe_base64(nil, true) #=> "i0XQ-7gglIsHGV2_BNPrdQ=="
244
- # SecureRandom.urlsafe_base64(nil, true) #=> "-M8rLhr7JEpJlqFGUMmOxg=="
337
+ # prng.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg"
338
+ # prng.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg"
245
339
  #
246
- # If a secure random number generator is not available, `NotImplementedError` is
247
- # raised.
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
- # SecureRandom.uuid generates a random v4 UUID (Universally Unique IDentifier).
254
- #
255
- # require 'securerandom'
256
- #
257
- # SecureRandom.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594"
258
- # SecureRandom.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab"
259
- # SecureRandom.uuid #=> "62936e70-1815-439b-bf89-8492855a7e6b"
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.