rbs 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +5 -0
  3. data/CHANGELOG.md +23 -0
  4. data/README.md +6 -1
  5. data/core/array.rbs +2866 -1086
  6. data/core/basic_object.rbs +150 -30
  7. data/core/binding.rbs +33 -0
  8. data/core/builtin.rbs +4 -4
  9. data/core/class.rbs +43 -5
  10. data/core/comparable.rbs +57 -0
  11. data/core/complex.rbs +170 -4
  12. data/core/constants.rbs +51 -0
  13. data/core/deprecated.rbs +7 -0
  14. data/core/dir.rbs +305 -20
  15. data/core/encoding.rbs +472 -77
  16. data/core/enumerable.rbs +2173 -234
  17. data/core/enumerator.rbs +448 -182
  18. data/core/env.rbs +448 -1
  19. data/core/errno.rbs +1 -10
  20. data/core/errors.rbs +152 -2
  21. data/core/exception.rbs +201 -127
  22. data/core/false_class.rbs +27 -0
  23. data/core/fiber.rbs +118 -37
  24. data/core/fiber_error.rbs +8 -9
  25. data/core/file.rbs +1059 -139
  26. data/core/file_test.rbs +287 -32
  27. data/core/float.rbs +776 -300
  28. data/core/gc.rbs +185 -34
  29. data/core/global_variables.rbs +5 -1
  30. data/core/hash.rbs +1582 -649
  31. data/core/integer.rbs +974 -204
  32. data/core/io/buffer.rbs +710 -0
  33. data/core/io/wait.rbs +29 -8
  34. data/core/io.rbs +2438 -417
  35. data/core/kernel.rbs +2315 -316
  36. data/core/marshal.rbs +37 -2
  37. data/core/match_data.rbs +123 -6
  38. data/core/math.rbs +126 -6
  39. data/core/method.rbs +226 -102
  40. data/core/module.rbs +421 -45
  41. data/core/nil_class.rbs +64 -0
  42. data/core/numeric.rbs +620 -142
  43. data/core/object.rbs +453 -81
  44. data/core/object_space.rbs +92 -2
  45. data/core/proc.rbs +482 -285
  46. data/core/process.rbs +443 -34
  47. data/core/ractor.rbs +232 -9
  48. data/core/random.rbs +151 -52
  49. data/core/range.rbs +885 -160
  50. data/core/rational.rbs +122 -6
  51. data/core/rb_config.rbs +14 -4
  52. data/core/refinement.rbs +44 -0
  53. data/core/regexp.rbs +156 -14
  54. data/core/ruby_vm.rbs +42 -3
  55. data/core/signal.rbs +78 -39
  56. data/core/string.rbs +2123 -567
  57. data/core/string_io.rbs +204 -0
  58. data/core/struct.rbs +283 -28
  59. data/core/symbol.rbs +304 -30
  60. data/core/thread.rbs +1288 -688
  61. data/core/thread_group.rbs +66 -10
  62. data/core/time.rbs +643 -217
  63. data/core/trace_point.rbs +100 -12
  64. data/core/true_class.rbs +24 -0
  65. data/core/unbound_method.rbs +73 -7
  66. data/core/warning.rbs +37 -12
  67. data/docs/CONTRIBUTING.md +40 -34
  68. data/docs/stdlib.md +3 -102
  69. data/lib/rbs/annotate/annotations.rb +197 -0
  70. data/lib/rbs/annotate/formatter.rb +80 -0
  71. data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
  72. data/lib/rbs/annotate/rdoc_source.rb +120 -0
  73. data/lib/rbs/annotate.rb +6 -0
  74. data/lib/rbs/cli.rb +45 -1
  75. data/lib/rbs/definition_builder.rb +5 -1
  76. data/lib/rbs/location_aux.rb +12 -0
  77. data/lib/rbs/prototype/rb.rb +12 -0
  78. data/lib/rbs/version.rb +1 -1
  79. data/sig/annotate/annotations.rbs +102 -0
  80. data/sig/annotate/formatter.rbs +24 -0
  81. data/sig/annotate/rdoc_annotater.rbs +82 -0
  82. data/sig/annotate/rdoc_source.rbs +30 -0
  83. data/sig/cli.rbs +2 -0
  84. data/sig/collection/{collections.rbs → sources.rbs} +0 -0
  85. data/sig/location.rbs +6 -0
  86. data/sig/method_types.rbs +5 -1
  87. data/sig/polyfill.rbs +78 -0
  88. data/stdlib/abbrev/0/abbrev.rbs +6 -0
  89. data/stdlib/abbrev/0/array.rbs +26 -0
  90. data/stdlib/base64/0/base64.rbs +31 -0
  91. data/stdlib/benchmark/0/benchmark.rbs +74 -3
  92. data/stdlib/bigdecimal/0/big_decimal.rbs +614 -165
  93. data/stdlib/bigdecimal-math/0/big_math.rbs +41 -64
  94. data/stdlib/cgi/0/core.rbs +59 -0
  95. data/stdlib/coverage/0/coverage.rbs +164 -2
  96. data/stdlib/csv/0/csv.rbs +2862 -398
  97. data/stdlib/date/0/date.rbs +483 -25
  98. data/stdlib/date/0/date_time.rbs +187 -12
  99. data/stdlib/dbm/0/dbm.rbs +152 -17
  100. data/stdlib/digest/0/digest.rbs +146 -0
  101. data/stdlib/erb/0/erb.rbs +65 -245
  102. data/stdlib/fiber/0/fiber.rbs +73 -91
  103. data/stdlib/fileutils/0/fileutils.rbs +301 -1
  104. data/stdlib/find/0/find.rbs +9 -0
  105. data/stdlib/forwardable/0/forwardable.rbs +65 -1
  106. data/stdlib/io-console/0/io-console.rbs +227 -15
  107. data/stdlib/ipaddr/0/ipaddr.rbs +161 -0
  108. data/stdlib/json/0/json.rbs +1146 -144
  109. data/stdlib/logger/0/formatter.rbs +24 -0
  110. data/stdlib/logger/0/log_device.rbs +64 -0
  111. data/stdlib/logger/0/logger.rbs +165 -13
  112. data/stdlib/logger/0/period.rbs +10 -0
  113. data/stdlib/logger/0/severity.rbs +26 -0
  114. data/stdlib/monitor/0/monitor.rbs +163 -0
  115. data/stdlib/mutex_m/0/mutex_m.rbs +35 -6
  116. data/stdlib/net-http/0/net-http.rbs +1492 -683
  117. data/stdlib/nkf/0/nkf.rbs +372 -0
  118. data/stdlib/objspace/0/objspace.rbs +149 -90
  119. data/stdlib/openssl/0/openssl.rbs +8108 -71
  120. data/stdlib/optparse/0/optparse.rbs +487 -19
  121. data/stdlib/pathname/0/pathname.rbs +425 -124
  122. data/stdlib/prettyprint/0/prettyprint.rbs +120 -99
  123. data/stdlib/prime/0/integer-extension.rbs +20 -2
  124. data/stdlib/prime/0/prime.rbs +88 -21
  125. data/stdlib/pstore/0/pstore.rbs +102 -0
  126. data/stdlib/pty/0/pty.rbs +64 -14
  127. data/stdlib/resolv/0/resolv.rbs +420 -31
  128. data/stdlib/rubygems/0/basic_specification.rbs +4 -1
  129. data/stdlib/rubygems/0/config_file.rbs +33 -1
  130. data/stdlib/rubygems/0/dependency_installer.rbs +4 -3
  131. data/stdlib/rubygems/0/installer.rbs +13 -1
  132. data/stdlib/rubygems/0/path_support.rbs +4 -1
  133. data/stdlib/rubygems/0/platform.rbs +5 -1
  134. data/stdlib/rubygems/0/request_set.rbs +44 -2
  135. data/stdlib/rubygems/0/requirement.rbs +65 -2
  136. data/stdlib/rubygems/0/rubygems.rbs +407 -0
  137. data/stdlib/rubygems/0/source_list.rbs +13 -0
  138. data/stdlib/rubygems/0/specification.rbs +21 -1
  139. data/stdlib/rubygems/0/stream_ui.rbs +3 -1
  140. data/stdlib/rubygems/0/uninstaller.rbs +8 -1
  141. data/stdlib/rubygems/0/version.rbs +60 -157
  142. data/stdlib/securerandom/0/securerandom.rbs +44 -0
  143. data/stdlib/set/0/set.rbs +420 -106
  144. data/stdlib/shellwords/0/shellwords.rbs +55 -77
  145. data/stdlib/singleton/0/singleton.rbs +20 -0
  146. data/stdlib/socket/0/addrinfo.rbs +210 -9
  147. data/stdlib/socket/0/basic_socket.rbs +103 -11
  148. data/stdlib/socket/0/ip_socket.rbs +31 -9
  149. data/stdlib/socket/0/socket.rbs +586 -38
  150. data/stdlib/socket/0/tcp_server.rbs +22 -2
  151. data/stdlib/socket/0/tcp_socket.rbs +12 -1
  152. data/stdlib/socket/0/udp_socket.rbs +25 -2
  153. data/stdlib/socket/0/unix_server.rbs +22 -2
  154. data/stdlib/socket/0/unix_socket.rbs +45 -5
  155. data/stdlib/strscan/0/string_scanner.rbs +210 -9
  156. data/stdlib/tempfile/0/tempfile.rbs +58 -10
  157. data/stdlib/time/0/time.rbs +208 -116
  158. data/stdlib/timeout/0/timeout.rbs +10 -0
  159. data/stdlib/tmpdir/0/tmpdir.rbs +13 -4
  160. data/stdlib/tsort/0/cyclic.rbs +1 -0
  161. data/stdlib/tsort/0/interfaces.rbs +1 -0
  162. data/stdlib/tsort/0/tsort.rbs +42 -0
  163. data/stdlib/uri/0/common.rbs +57 -8
  164. data/stdlib/uri/0/file.rbs +55 -109
  165. data/stdlib/uri/0/ftp.rbs +6 -3
  166. data/stdlib/uri/0/generic.rbs +556 -327
  167. data/stdlib/uri/0/http.rbs +26 -115
  168. data/stdlib/uri/0/https.rbs +8 -102
  169. data/stdlib/uri/0/ldap.rbs +143 -137
  170. data/stdlib/uri/0/ldaps.rbs +8 -102
  171. data/stdlib/uri/0/mailto.rbs +3 -0
  172. data/stdlib/uri/0/rfc2396_parser.rbs +66 -26
  173. data/stdlib/uri/0/ws.rbs +6 -3
  174. data/stdlib/uri/0/wss.rbs +5 -3
  175. data/stdlib/yaml/0/dbm.rbs +151 -87
  176. data/stdlib/yaml/0/store.rbs +6 -0
  177. data/stdlib/zlib/0/zlib.rbs +90 -31
  178. metadata +17 -5
  179. data/lib/rbs/location.rb +0 -221
data/core/rational.rbs CHANGED
@@ -1,14 +1,24 @@
1
+ # <!-- rdoc-file=rational.c -->
1
2
  # A rational number can be represented as a pair of integer numbers: a/b (b>0),
2
3
  # where a is the numerator and b is the denominator. Integer a equals rational
3
4
  # a/1 mathematically.
4
5
  #
5
- # In Ruby, you can create rational objects with the Kernel#Rational, to_r, or
6
- # rationalize methods or by suffixing `r` to a literal. The return values will
7
- # be irreducible fractions.
6
+ # You can create a Rational object explicitly with:
7
+ #
8
+ # * A [rational
9
+ # literal](doc/syntax/literals_rdoc.html#label-Rational+Literals).
10
+ #
11
+ #
12
+ # You can convert certain objects to Rationals with:
13
+ #
14
+ # * Method [Rational](Kernel.html#method-i-Rational).
15
+ #
16
+ #
17
+ # Examples
8
18
  #
9
19
  # Rational(1) #=> (1/1)
10
20
  # Rational(2, 3) #=> (2/3)
11
- # Rational(4, -6) #=> (-2/3)
21
+ # Rational(4, -6) #=> (-2/3) # Reduced.
12
22
  # 3.to_r #=> (3/1)
13
23
  # 2/3r #=> (2/3)
14
24
  #
@@ -46,6 +56,10 @@ class Rational < Numeric
46
56
  | (Rational) -> Rational
47
57
  | (Numeric) -> Numeric
48
58
 
59
+ # <!--
60
+ # rdoc-file=rational.c
61
+ # - rat * numeric -> numeric
62
+ # -->
49
63
  # Performs multiplication.
50
64
  #
51
65
  # Rational(2, 3) * Rational(2, 3) #=> (4/9)
@@ -58,6 +72,10 @@ class Rational < Numeric
58
72
  | (Complex) -> Complex
59
73
  | (Numeric) -> Numeric
60
74
 
75
+ # <!--
76
+ # rdoc-file=rational.c
77
+ # - rat ** numeric -> numeric
78
+ # -->
61
79
  # Performs exponentiation.
62
80
  #
63
81
  # Rational(2) ** Rational(3) #=> (8/1)
@@ -70,6 +88,10 @@ class Rational < Numeric
70
88
  def **: (Complex) -> Complex
71
89
  | (Numeric) -> Numeric
72
90
 
91
+ # <!--
92
+ # rdoc-file=rational.c
93
+ # - rat + numeric -> numeric
94
+ # -->
73
95
  # Performs addition.
74
96
  #
75
97
  # Rational(2, 3) + Rational(2, 3) #=> (4/3)
@@ -84,6 +106,10 @@ class Rational < Numeric
84
106
 
85
107
  def +@: () -> Rational
86
108
 
109
+ # <!--
110
+ # rdoc-file=rational.c
111
+ # - rat - numeric -> numeric
112
+ # -->
87
113
  # Performs subtraction.
88
114
  #
89
115
  # Rational(2, 3) - Rational(2, 3) #=> (0/1)
@@ -96,10 +122,19 @@ class Rational < Numeric
96
122
  | (Complex) -> Complex
97
123
  | (Numeric) -> Rational
98
124
 
125
+ # <!--
126
+ # rdoc-file=rational.c
127
+ # - -rat -> rational
128
+ # -->
99
129
  # Negates `rat`.
100
130
  #
101
131
  def -@: () -> Rational
102
132
 
133
+ # <!--
134
+ # rdoc-file=rational.c
135
+ # - rat / numeric -> numeric
136
+ # - rat.quo(numeric) -> numeric
137
+ # -->
103
138
  # Performs division.
104
139
  #
105
140
  # Rational(2, 3) / Rational(2, 3) #=> (1/1)
@@ -112,6 +147,10 @@ class Rational < Numeric
112
147
  | (Complex) -> Complex
113
148
  | (Numeric) -> Rational
114
149
 
150
+ # <!--
151
+ # rdoc-file=rational.c
152
+ # - rational <=> numeric -> -1, 0, +1, or nil
153
+ # -->
115
154
  # Returns -1, 0, or +1 depending on whether `rational` is less than, equal to,
116
155
  # or greater than `numeric`.
117
156
  #
@@ -128,6 +167,10 @@ class Rational < Numeric
128
167
  def <=>: (Integer | Rational) -> Integer
129
168
  | (untyped) -> Integer?
130
169
 
170
+ # <!--
171
+ # rdoc-file=rational.c
172
+ # - rat == object -> true or false
173
+ # -->
131
174
  # Returns `true` if `rat` equals `object` numerically.
132
175
  #
133
176
  # Rational(2, 3) == Rational(2, 3) #=> true
@@ -138,6 +181,11 @@ class Rational < Numeric
138
181
  #
139
182
  def ==: (untyped) -> bool
140
183
 
184
+ # <!--
185
+ # rdoc-file=rational.c
186
+ # - rat.abs -> rational
187
+ # - rat.magnitude -> rational
188
+ # -->
141
189
  # Returns the absolute value of `rat`.
142
190
  #
143
191
  # (1/2r).abs #=> (1/2)
@@ -153,6 +201,10 @@ class Rational < Numeric
153
201
 
154
202
  alias arg angle
155
203
 
204
+ # <!--
205
+ # rdoc-file=rational.c
206
+ # - rat.ceil([ndigits]) -> integer or rational
207
+ # -->
156
208
  # Returns the smallest number greater than or equal to `rat` with a precision of
157
209
  # `ndigits` decimal digits (default: 0).
158
210
  #
@@ -175,12 +227,16 @@ class Rational < Numeric
175
227
  def ceil: () -> Integer
176
228
  | (Integer digits) -> (Integer | Rational)
177
229
 
178
- def coerce: (Numeric) -> [Numeric, Numeric]
230
+ def coerce: (Numeric) -> [ Numeric, Numeric ]
179
231
 
180
232
  def conj: () -> Rational
181
233
 
182
234
  def conjugate: () -> Rational
183
235
 
236
+ # <!--
237
+ # rdoc-file=rational.c
238
+ # - rat.denominator -> integer
239
+ # -->
184
240
  # Returns the denominator (always positive).
185
241
  #
186
242
  # Rational(7).denominator #=> 1
@@ -192,12 +248,16 @@ class Rational < Numeric
192
248
 
193
249
  def div: (Numeric) -> Integer
194
250
 
195
- def divmod: (Numeric) -> [Numeric, Numeric]
251
+ def divmod: (Numeric) -> [ Numeric, Numeric ]
196
252
 
197
253
  def dup: () -> self
198
254
 
199
255
  def eql?: (untyped) -> bool
200
256
 
257
+ # <!--
258
+ # rdoc-file=rational.c
259
+ # - rat.fdiv(numeric) -> float
260
+ # -->
201
261
  # Performs division and returns the value as a Float.
202
262
  #
203
263
  # Rational(2, 3).fdiv(1) #=> 0.6666666666666666
@@ -208,6 +268,10 @@ class Rational < Numeric
208
268
 
209
269
  def finite?: () -> bool
210
270
 
271
+ # <!--
272
+ # rdoc-file=rational.c
273
+ # - rat.floor([ndigits]) -> integer or rational
274
+ # -->
211
275
  # Returns the largest number less than or equal to `rat` with a precision of
212
276
  # `ndigits` decimal digits (default: 0).
213
277
  #
@@ -230,6 +294,11 @@ class Rational < Numeric
230
294
  def floor: () -> Integer
231
295
  | (Integer digits) -> (Integer | Rational)
232
296
 
297
+ # <!--
298
+ # rdoc-file=rational.c
299
+ # - hash()
300
+ # -->
301
+ #
233
302
  def hash: () -> Integer
234
303
 
235
304
  def i: () -> Complex
@@ -240,6 +309,10 @@ class Rational < Numeric
240
309
 
241
310
  def infinite?: () -> Integer?
242
311
 
312
+ # <!--
313
+ # rdoc-file=rational.c
314
+ # - rat.inspect -> string
315
+ # -->
243
316
  # Returns the value as a string for inspection.
244
317
  #
245
318
  # Rational(2).inspect #=> "(2/1)"
@@ -250,6 +323,7 @@ class Rational < Numeric
250
323
 
251
324
  def integer?: () -> bool
252
325
 
326
+ # <!-- rdoc-file=rational.c -->
253
327
  # Returns the absolute value of `rat`.
254
328
  #
255
329
  # (1/2r).abs #=> (1/2)
@@ -262,12 +336,20 @@ class Rational < Numeric
262
336
  def modulo: (Float) -> Float
263
337
  | (Numeric) -> Rational
264
338
 
339
+ # <!--
340
+ # rdoc-file=rational.c
341
+ # - rat.negative? -> true or false
342
+ # -->
265
343
  # Returns `true` if `rat` is less than 0.
266
344
  #
267
345
  def negative?: () -> bool
268
346
 
269
347
  def nonzero?: () -> self?
270
348
 
349
+ # <!--
350
+ # rdoc-file=rational.c
351
+ # - rat.numerator -> integer
352
+ # -->
271
353
  # Returns the numerator.
272
354
  #
273
355
  # Rational(7).numerator #=> 7
@@ -281,10 +363,15 @@ class Rational < Numeric
281
363
 
282
364
  def polar: () -> [ Rational, Integer | Float ]
283
365
 
366
+ # <!--
367
+ # rdoc-file=rational.c
368
+ # - rat.positive? -> true or false
369
+ # -->
284
370
  # Returns `true` if `rat` is greater than 0.
285
371
  #
286
372
  def positive?: () -> bool
287
373
 
374
+ # <!-- rdoc-file=rational.c -->
288
375
  # Performs division.
289
376
  #
290
377
  # Rational(2, 3) / Rational(2, 3) #=> (1/1)
@@ -297,6 +384,11 @@ class Rational < Numeric
297
384
  | (Complex) -> Complex
298
385
  | (Numeric) -> Rational
299
386
 
387
+ # <!--
388
+ # rdoc-file=rational.c
389
+ # - rat.rationalize -> self
390
+ # - rat.rationalize(eps) -> rational
391
+ # -->
300
392
  # Returns a simpler approximation of the value if the optional argument `eps` is
301
393
  # given (rat-|eps| <= result <= rat+|eps|), self otherwise.
302
394
  #
@@ -318,6 +410,10 @@ class Rational < Numeric
318
410
  def remainder: (Float) -> Float
319
411
  | (Numeric) -> Rational
320
412
 
413
+ # <!--
414
+ # rdoc-file=rational.c
415
+ # - rat.round([ndigits] [, half: mode]) -> integer or rational
416
+ # -->
321
417
  # Returns `rat` rounded to the nearest value with a precision of `ndigits`
322
418
  # decimal digits (default: 0).
323
419
  #
@@ -359,6 +455,10 @@ class Rational < Numeric
359
455
 
360
456
  def to_c: () -> Complex
361
457
 
458
+ # <!--
459
+ # rdoc-file=rational.c
460
+ # - rat.to_f -> float
461
+ # -->
362
462
  # Returns the value as a Float.
363
463
  #
364
464
  # Rational(2).to_f #=> 2.0
@@ -368,6 +468,10 @@ class Rational < Numeric
368
468
  #
369
469
  def to_f: () -> Float
370
470
 
471
+ # <!--
472
+ # rdoc-file=rational.c
473
+ # - rat.to_i -> integer
474
+ # -->
371
475
  # Returns the truncated value as an integer.
372
476
  #
373
477
  # Equivalent to Rational#truncate.
@@ -382,6 +486,10 @@ class Rational < Numeric
382
486
 
383
487
  alias to_int to_i
384
488
 
489
+ # <!--
490
+ # rdoc-file=rational.c
491
+ # - rat.to_r -> self
492
+ # -->
385
493
  # Returns self.
386
494
  #
387
495
  # Rational(2).to_r #=> (2/1)
@@ -389,6 +497,10 @@ class Rational < Numeric
389
497
  #
390
498
  def to_r: () -> Rational
391
499
 
500
+ # <!--
501
+ # rdoc-file=rational.c
502
+ # - rat.to_s -> string
503
+ # -->
392
504
  # Returns the value as a string.
393
505
  #
394
506
  # Rational(2).to_s #=> "2/1"
@@ -397,6 +509,10 @@ class Rational < Numeric
397
509
  #
398
510
  def to_s: () -> String
399
511
 
512
+ # <!--
513
+ # rdoc-file=rational.c
514
+ # - rat.truncate([ndigits]) -> integer or rational
515
+ # -->
400
516
  # Returns `rat` truncated (toward zero) to a precision of `ndigits` decimal
401
517
  # digits (default: 0).
402
518
  #
data/core/rb_config.rbs CHANGED
@@ -1,3 +1,4 @@
1
+ # <!-- rdoc-file=rbconfig.rb -->
1
2
  # The module storing Ruby interpreter configurations on building.
2
3
  #
3
4
  # This file was created by mkconfig.rb when ruby was built. It contains build
@@ -6,6 +7,11 @@
6
7
  # built.
7
8
  #
8
9
  module RbConfig
10
+ # <!--
11
+ # rdoc-file=rbconfig.rb
12
+ # - RbConfig.expand(val) -> string
13
+ # - RbConfig.expand(val, config) -> string
14
+ # -->
9
15
  # expands variable with given `val` value.
10
16
  #
11
17
  # RbConfig.expand("$(bindir)") # => /home/foobar/all-ruby/ruby19x/bin
@@ -17,14 +23,17 @@ module RbConfig
17
23
  def self.ruby: () -> String
18
24
  end
19
25
 
26
+ # <!-- rdoc-file=rbconfig.rb -->
20
27
  # The hash configurations stored.
21
28
  #
22
29
  RbConfig::CONFIG: Hash[String, String]
23
30
 
31
+ # <!-- rdoc-file=rbconfig.rb -->
24
32
  # DESTDIR on make install.
25
33
  #
26
34
  RbConfig::DESTDIR: String
27
35
 
36
+ # <!-- rdoc-file=rbconfig.rb -->
28
37
  # Almost same with CONFIG. MAKEFILE_CONFIG has other variable reference like
29
38
  # below.
30
39
  #
@@ -35,9 +44,9 @@ RbConfig::DESTDIR: String
35
44
  # require 'rbconfig'
36
45
  #
37
46
  # print <<-END_OF_MAKEFILE
38
- # prefix = #{Config::MAKEFILE_CONFIG['prefix']}
39
- # exec_prefix = #{Config::MAKEFILE_CONFIG['exec_prefix']}
40
- # bindir = #{Config::MAKEFILE_CONFIG['bindir']}
47
+ # prefix = #{RbConfig::MAKEFILE_CONFIG['prefix']}
48
+ # exec_prefix = #{RbConfig::MAKEFILE_CONFIG['exec_prefix']}
49
+ # bindir = #{RbConfig::MAKEFILE_CONFIG['bindir']}
41
50
  # END_OF_MAKEFILE
42
51
  #
43
52
  # => prefix = /usr/local
@@ -47,11 +56,12 @@ RbConfig::DESTDIR: String
47
56
  # RbConfig.expand is used for resolving references like above in rbconfig.
48
57
  #
49
58
  # require 'rbconfig'
50
- # p Config.expand(Config::MAKEFILE_CONFIG["bindir"])
59
+ # p RbConfig.expand(RbConfig::MAKEFILE_CONFIG["bindir"])
51
60
  # # => "/usr/local/bin"
52
61
  #
53
62
  RbConfig::MAKEFILE_CONFIG: Hash[String, String]
54
63
 
64
+ # <!-- rdoc-file=rbconfig.rb -->
55
65
  # Ruby installed directory.
56
66
  #
57
67
  RbConfig::TOPDIR: String
@@ -0,0 +1,44 @@
1
+ # <!-- rdoc-file=class.c -->
2
+ # Refinement is a class of the `self` (current context) inside `refine`
3
+ # statement. It allows to import methods from other modules, see
4
+ # #import_methods.
5
+ #
6
+ class Refinement < Module
7
+ private
8
+
9
+ # <!--
10
+ # rdoc-file=class.c
11
+ # - import_methods(module, ...) -> self
12
+ # -->
13
+ # Imports methods from modules. Unlike Module#include, Refinement#import_methods
14
+ # copies methods and adds them into the refinement, so the refinement is
15
+ # activated in the imported methods.
16
+ #
17
+ # Note that due to method copying, only methods defined in Ruby code can be
18
+ # imported.
19
+ #
20
+ # module StrUtils
21
+ # def indent(level)
22
+ # ' ' * level + self
23
+ # end
24
+ # end
25
+ #
26
+ # module M
27
+ # refine String do
28
+ # import_methods StrUtils
29
+ # end
30
+ # end
31
+ #
32
+ # using M
33
+ # "foo".indent(3)
34
+ # #=> " foo"
35
+ #
36
+ # module M
37
+ # refine String do
38
+ # import_methods Enumerable
39
+ # # Can't import method which is not defined with Ruby code: Enumerable#drop
40
+ # end
41
+ # end
42
+ #
43
+ def import_methods: (*Module) -> self
44
+ end