rbs 3.6.1 → 3.9.5

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 (268) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +2 -2
  3. data/.github/workflows/dependabot.yml +1 -1
  4. data/.github/workflows/ruby.yml +34 -10
  5. data/.github/workflows/windows.yml +20 -3
  6. data/.gitignore +1 -0
  7. data/.rubocop.yml +26 -1
  8. data/CHANGELOG.md +241 -0
  9. data/Rakefile +54 -4
  10. data/config.yml +317 -0
  11. data/core/array.rbs +1756 -1591
  12. data/core/basic_object.rbs +38 -35
  13. data/core/comparable.rbs +1 -1
  14. data/core/complex.rbs +166 -94
  15. data/core/data.rbs +2 -2
  16. data/core/dir.rbs +2 -18
  17. data/core/encoding.rbs +12 -32
  18. data/core/enumerable.rbs +270 -266
  19. data/core/enumerator.rbs +14 -4
  20. data/core/env.rbs +1 -1
  21. data/core/errno.rbs +33 -16
  22. data/core/errors.rbs +6 -2
  23. data/core/exception.rbs +342 -167
  24. data/core/fiber.rbs +3 -2
  25. data/core/file.rbs +26 -75
  26. data/core/float.rbs +125 -72
  27. data/core/gc.rbs +158 -42
  28. data/core/hash.rbs +122 -143
  29. data/core/integer.rbs +79 -50
  30. data/core/io/buffer.rbs +49 -43
  31. data/core/io.rbs +108 -151
  32. data/core/kernel.rbs +341 -209
  33. data/core/match_data.rbs +76 -2
  34. data/core/math.rbs +0 -36
  35. data/core/method.rbs +2 -2
  36. data/core/module.rbs +32 -27
  37. data/core/nil_class.rbs +2 -2
  38. data/core/numeric.rbs +101 -104
  39. data/core/object.rbs +1 -5
  40. data/core/object_space/weak_key_map.rbs +3 -4
  41. data/core/object_space.rbs +3 -3
  42. data/core/proc.rbs +82 -14
  43. data/core/process.rbs +110 -58
  44. data/core/ractor.rbs +57 -4
  45. data/core/range.rbs +114 -87
  46. data/core/rational.rbs +0 -2
  47. data/core/rbs/unnamed/argf.rbs +237 -36
  48. data/core/rbs/unnamed/env_class.rbs +35 -53
  49. data/core/rbs/unnamed/random.rbs +1 -2
  50. data/core/regexp.rbs +10 -56
  51. data/core/ruby_vm.rbs +88 -9
  52. data/core/rubygems/config_file.rbs +3 -0
  53. data/core/rubygems/errors.rbs +3 -6
  54. data/core/rubygems/platform.rbs +0 -9
  55. data/core/rubygems/rubygems.rbs +3 -6
  56. data/core/rubygems/version.rbs +8 -8
  57. data/core/set.rbs +4 -16
  58. data/core/string.rbs +271 -264
  59. data/core/struct.rbs +6 -18
  60. data/core/symbol.rbs +14 -21
  61. data/core/thread.rbs +32 -35
  62. data/core/time.rbs +131 -50
  63. data/core/trace_point.rbs +124 -113
  64. data/core/true_class.rbs +0 -1
  65. data/core/unbound_method.rbs +1 -1
  66. data/core/warning.rbs +9 -2
  67. data/docs/architecture.md +1 -1
  68. data/docs/syntax.md +17 -10
  69. data/ext/rbs_extension/extconf.rb +11 -0
  70. data/ext/rbs_extension/location.c +61 -29
  71. data/ext/rbs_extension/location.h +4 -3
  72. data/ext/rbs_extension/main.c +23 -1
  73. data/ext/rbs_extension/parser.c +506 -517
  74. data/ext/rbs_extension/parserstate.c +109 -30
  75. data/ext/rbs_extension/parserstate.h +6 -4
  76. data/ext/rbs_extension/rbs_extension.h +1 -10
  77. data/{ext/rbs_extension → include/rbs}/constants.h +21 -19
  78. data/include/rbs/ruby_objs.h +72 -0
  79. data/include/rbs/util/rbs_constant_pool.h +219 -0
  80. data/include/rbs.h +7 -0
  81. data/lib/rbs/annotate/annotations.rb +3 -3
  82. data/lib/rbs/annotate/rdoc_source.rb +2 -2
  83. data/lib/rbs/ast/declarations.rb +9 -4
  84. data/lib/rbs/ast/directives.rb +10 -0
  85. data/lib/rbs/ast/members.rb +2 -0
  86. data/lib/rbs/ast/type_param.rb +2 -12
  87. data/lib/rbs/cli/diff.rb +3 -3
  88. data/lib/rbs/cli/validate.rb +2 -1
  89. data/lib/rbs/cli.rb +16 -16
  90. data/lib/rbs/collection/config/lockfile_generator.rb +58 -8
  91. data/lib/rbs/collection/config.rb +5 -3
  92. data/lib/rbs/collection/sources/rubygems.rb +1 -1
  93. data/lib/rbs/collection.rb +1 -0
  94. data/lib/rbs/definition.rb +51 -34
  95. data/lib/rbs/definition_builder/ancestor_builder.rb +5 -3
  96. data/lib/rbs/definition_builder.rb +83 -24
  97. data/lib/rbs/environment.rb +33 -18
  98. data/lib/rbs/environment_loader.rb +6 -1
  99. data/lib/rbs/errors.rb +24 -0
  100. data/lib/rbs/locator.rb +2 -0
  101. data/lib/rbs/method_type.rb +2 -0
  102. data/lib/rbs/namespace.rb +1 -0
  103. data/lib/rbs/parser_aux.rb +40 -3
  104. data/lib/rbs/prototype/rb.rb +20 -12
  105. data/lib/rbs/prototype/rbi.rb +11 -6
  106. data/lib/rbs/prototype/runtime/value_object_generator.rb +7 -5
  107. data/lib/rbs/prototype/runtime.rb +7 -5
  108. data/lib/rbs/subtractor.rb +3 -3
  109. data/lib/rbs/test/hook.rb +47 -42
  110. data/lib/rbs/test/type_check.rb +7 -5
  111. data/lib/rbs/type_name.rb +14 -9
  112. data/lib/rbs/types.rb +63 -14
  113. data/lib/rbs/unit_test/spy.rb +4 -2
  114. data/lib/rbs/unit_test/type_assertions.rb +19 -13
  115. data/lib/rbs/unit_test/with_aliases.rb +3 -1
  116. data/lib/rbs/validator.rb +7 -1
  117. data/lib/rbs/version.rb +1 -1
  118. data/lib/rbs/writer.rb +10 -5
  119. data/lib/rbs.rb +1 -0
  120. data/lib/rdoc_plugin/parser.rb +2 -2
  121. data/rbs.gemspec +6 -2
  122. data/sig/ancestor_graph.rbs +5 -5
  123. data/sig/annotate/rdoc_source.rbs +2 -0
  124. data/sig/cli.rbs +2 -0
  125. data/sig/collection/config/lockfile_generator.rbs +9 -1
  126. data/sig/declarations.rbs +10 -3
  127. data/sig/definition.rbs +80 -12
  128. data/sig/definition_builder.rbs +18 -4
  129. data/sig/directives.rbs +17 -1
  130. data/sig/environment.rbs +3 -1
  131. data/sig/errors.rbs +19 -0
  132. data/sig/namespace.rbs +2 -3
  133. data/sig/parser.rbs +5 -1
  134. data/sig/prototype/rb.rbs +1 -1
  135. data/sig/resolver/constant_resolver.rbs +2 -2
  136. data/sig/resolver/context.rbs +1 -1
  137. data/sig/subtractor.rbs +1 -1
  138. data/sig/test/type_check.rbs +2 -2
  139. data/sig/type_alias_dependency.rbs +2 -2
  140. data/sig/type_alias_regularity.rbs +6 -6
  141. data/sig/type_param.rbs +4 -4
  142. data/sig/typename.rbs +8 -5
  143. data/sig/types.rbs +1 -1
  144. data/sig/unit_test/spy.rbs +2 -0
  145. data/sig/unit_test/type_assertions.rbs +2 -0
  146. data/sig/use_map.rbs +1 -1
  147. data/sig/validator.rbs +6 -2
  148. data/sig/vendorer.rbs +1 -1
  149. data/sig/writer.rbs +1 -1
  150. data/{ext/rbs_extension → src}/constants.c +35 -36
  151. data/src/ruby_objs.c +799 -0
  152. data/src/util/rbs_constant_pool.c +342 -0
  153. data/stdlib/base64/0/base64.rbs +0 -9
  154. data/stdlib/benchmark/0/benchmark.rbs +11 -2
  155. data/stdlib/bigdecimal/0/big_decimal.rbs +26 -182
  156. data/stdlib/cgi/0/core.rbs +60 -3
  157. data/stdlib/cgi/0/manifest.yaml +1 -0
  158. data/stdlib/coverage/0/coverage.rbs +0 -3
  159. data/stdlib/csv/0/csv.rbs +18 -58
  160. data/stdlib/csv/0/manifest.yaml +1 -0
  161. data/stdlib/date/0/date.rbs +27 -42
  162. data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -6
  163. data/stdlib/digest/0/digest.rbs +25 -2
  164. data/stdlib/erb/0/erb.rbs +0 -1
  165. data/stdlib/etc/0/etc.rbs +51 -34
  166. data/stdlib/fileutils/0/fileutils.rbs +3 -44
  167. data/stdlib/io-console/0/io-console.rbs +69 -15
  168. data/stdlib/ipaddr/0/ipaddr.rbs +16 -4
  169. data/stdlib/json/0/json.rbs +107 -120
  170. data/stdlib/logger/0/log_device.rbs +1 -1
  171. data/stdlib/logger/0/logger.rbs +3 -18
  172. data/stdlib/minitest/0/kernel.rbs +2 -2
  173. data/stdlib/minitest/0/minitest/abstract_reporter.rbs +4 -1
  174. data/stdlib/minitest/0/minitest/assertion.rbs +1 -0
  175. data/stdlib/minitest/0/minitest/assertions.rbs +58 -13
  176. data/stdlib/minitest/0/minitest/backtrace_filter.rbs +7 -0
  177. data/stdlib/minitest/0/minitest/bench_spec.rbs +8 -8
  178. data/stdlib/minitest/0/minitest/benchmark.rbs +17 -16
  179. data/stdlib/minitest/0/minitest/compress.rbs +13 -0
  180. data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
  181. data/stdlib/minitest/0/minitest/mock.rbs +9 -5
  182. data/stdlib/minitest/0/minitest/parallel/executor.rbs +4 -0
  183. data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +0 -1
  184. data/stdlib/minitest/0/minitest/pride_io.rbs +8 -0
  185. data/stdlib/minitest/0/minitest/pride_lol.rbs +2 -0
  186. data/stdlib/minitest/0/minitest/progress_reporter.rbs +1 -1
  187. data/stdlib/minitest/0/minitest/reportable.rbs +2 -0
  188. data/stdlib/minitest/0/minitest/runnable.rbs +33 -1
  189. data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +1 -1
  190. data/stdlib/minitest/0/minitest/spec/dsl.rbs +10 -6
  191. data/stdlib/minitest/0/minitest/spec.rbs +1 -1
  192. data/stdlib/minitest/0/minitest/statistics_reporter.rbs +5 -0
  193. data/stdlib/minitest/0/minitest/summary_reporter.rbs +0 -7
  194. data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +1 -1
  195. data/stdlib/minitest/0/minitest/test.rbs +7 -14
  196. data/stdlib/minitest/0/minitest/unexpected_error.rbs +2 -0
  197. data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
  198. data/stdlib/minitest/0/minitest/unit.rbs +1 -2
  199. data/stdlib/minitest/0/minitest.rbs +41 -892
  200. data/stdlib/monitor/0/monitor.rbs +13 -4
  201. data/stdlib/net-http/0/net-http.rbs +42 -109
  202. data/stdlib/nkf/0/nkf.rbs +30 -0
  203. data/stdlib/objspace/0/objspace.rbs +1 -2
  204. data/stdlib/observable/0/observable.rbs +1 -1
  205. data/stdlib/open-uri/0/manifest.yaml +1 -0
  206. data/stdlib/open-uri/0/open-uri.rbs +52 -0
  207. data/stdlib/open3/0/open3.rbs +0 -8
  208. data/stdlib/openssl/0/manifest.yaml +1 -0
  209. data/stdlib/openssl/0/openssl.rbs +235 -143
  210. data/stdlib/optparse/0/optparse.rbs +58 -18
  211. data/stdlib/pathname/0/pathname.rbs +2 -8
  212. data/stdlib/pp/0/pp.rbs +3 -1
  213. data/stdlib/prettyprint/0/prettyprint.rbs +0 -4
  214. data/stdlib/pstore/0/pstore.rbs +0 -6
  215. data/stdlib/psych/0/core_ext.rbs +12 -0
  216. data/stdlib/psych/0/psych.rbs +15 -4
  217. data/stdlib/pty/0/pty.rbs +46 -4
  218. data/stdlib/rdoc/0/code_object.rbs +0 -4
  219. data/stdlib/rdoc/0/markup.rbs +10 -12
  220. data/stdlib/rdoc/0/rdoc.rbs +13 -8
  221. data/stdlib/resolv/0/resolv.rbs +21 -12
  222. data/stdlib/ripper/0/ripper.rbs +0 -2
  223. data/stdlib/securerandom/0/securerandom.rbs +7 -2
  224. data/stdlib/shellwords/0/shellwords.rbs +11 -12
  225. data/stdlib/singleton/0/singleton.rbs +0 -1
  226. data/stdlib/socket/0/addrinfo.rbs +1 -2
  227. data/stdlib/socket/0/basic_socket.rbs +0 -5
  228. data/stdlib/socket/0/socket.rbs +32 -27
  229. data/stdlib/socket/0/tcp_server.rbs +0 -3
  230. data/stdlib/socket/0/tcp_socket.rbs +36 -3
  231. data/stdlib/socket/0/udp_socket.rbs +0 -1
  232. data/stdlib/socket/0/unix_server.rbs +0 -3
  233. data/stdlib/socket/0/unix_socket.rbs +4 -2
  234. data/{core/string_io.rbs → stdlib/stringio/0/stringio.rbs} +1 -1
  235. data/stdlib/strscan/0/string_scanner.rbs +1265 -422
  236. data/stdlib/tempfile/0/tempfile.rbs +135 -28
  237. data/stdlib/time/0/time.rbs +48 -35
  238. data/stdlib/timeout/0/timeout.rbs +11 -8
  239. data/stdlib/tmpdir/0/tmpdir.rbs +10 -3
  240. data/stdlib/tsort/0/tsort.rbs +0 -4
  241. data/stdlib/uri/0/common.rbs +28 -30
  242. data/stdlib/uri/0/ftp.rbs +1 -1
  243. data/stdlib/uri/0/generic.rbs +22 -18
  244. data/stdlib/uri/0/http.rbs +2 -2
  245. data/stdlib/uri/0/rfc2396_parser.rbs +3 -0
  246. data/stdlib/zlib/0/buf_error.rbs +1 -70
  247. data/stdlib/zlib/0/data_error.rbs +1 -70
  248. data/stdlib/zlib/0/deflate.rbs +8 -72
  249. data/stdlib/zlib/0/error.rbs +1 -70
  250. data/stdlib/zlib/0/gzip_file/crc_error.rbs +2 -105
  251. data/stdlib/zlib/0/gzip_file/error.rbs +2 -105
  252. data/stdlib/zlib/0/gzip_file/length_error.rbs +2 -105
  253. data/stdlib/zlib/0/gzip_file/no_footer.rbs +2 -105
  254. data/stdlib/zlib/0/gzip_file.rbs +1 -71
  255. data/stdlib/zlib/0/gzip_reader.rbs +3 -74
  256. data/stdlib/zlib/0/gzip_writer.rbs +1 -70
  257. data/stdlib/zlib/0/inflate.rbs +4 -71
  258. data/stdlib/zlib/0/mem_error.rbs +1 -70
  259. data/stdlib/zlib/0/need_dict.rbs +1 -70
  260. data/stdlib/zlib/0/stream_end.rbs +1 -70
  261. data/stdlib/zlib/0/stream_error.rbs +1 -70
  262. data/stdlib/zlib/0/version_error.rbs +1 -70
  263. data/stdlib/zlib/0/zlib.rbs +0 -2
  264. data/stdlib/zlib/0/zstream.rbs +4 -72
  265. metadata +17 -13
  266. data/ext/rbs_extension/ruby_objs.c +0 -602
  267. data/ext/rbs_extension/ruby_objs.h +0 -51
  268. data/stdlib/minitest/0/manifest.yaml +0 -2
data/core/file.rbs CHANGED
@@ -49,7 +49,6 @@
49
49
  # * May also contain a 1-character [file-create
50
50
  # mode](rdoc-ref:File@File-Create+Mode).
51
51
  #
52
- #
53
52
  # #### Read/Write Mode
54
53
  #
55
54
  # The read/write `mode` determines:
@@ -61,14 +60,11 @@
61
60
  # * The initial read position in the file.
62
61
  # * Where in the file reading can occur.
63
62
  #
64
- #
65
63
  # * Whether writing is allowed, and if so:
66
64
  #
67
65
  # * The initial write position in the file.
68
66
  # * Where in the file writing can occur.
69
67
  #
70
- #
71
- #
72
68
  # These tables summarize:
73
69
  #
74
70
  # Read/Write Modes for Existing File
@@ -110,7 +106,6 @@
110
106
  # * `Error` means that an exception is raised if disallowed reading or writing
111
107
  # is attempted.
112
108
  #
113
- #
114
109
  # ##### Read/Write Modes for Existing File
115
110
  #
116
111
  # * `'r'`:
@@ -142,7 +137,6 @@
142
137
  #
143
138
  # f.write('foo') # Raises IOError.
144
139
  #
145
- #
146
140
  # * `'w'`:
147
141
  #
148
142
  # * File is initially truncated:
@@ -197,7 +191,6 @@
197
191
  #
198
192
  # f.read # Raises IOError.
199
193
  #
200
- #
201
194
  # * `'a'`:
202
195
  #
203
196
  # * File is not initially truncated:
@@ -230,7 +223,6 @@
230
223
  #
231
224
  # f.read # Raises IOError.
232
225
  #
233
- #
234
226
  # * `'r+'`:
235
227
  #
236
228
  # * File is not initially truncated:
@@ -286,7 +278,6 @@
286
278
  # File.read(path)
287
279
  # # => "WWWst lineXXXecond line\nFourth line\nFifth YYYe\n\u0000\u0000ZZZ"
288
280
  #
289
- #
290
281
  # * `'a+'`:
291
282
  #
292
283
  # * File is not initially truncated:
@@ -326,8 +317,6 @@
326
317
  # f.seek(-3, :END)
327
318
  # f.read # => "bat"
328
319
  #
329
- #
330
- #
331
320
  # ##### Read/Write Modes for File To Be Created
332
321
  #
333
322
  # Note that modes `'r'` and `'r+'` are not allowed for a non-existent file
@@ -383,7 +372,6 @@
383
372
  #
384
373
  # f.read # Raises IOError.
385
374
  #
386
- #
387
375
  # * `'a'`:
388
376
  #
389
377
  # * File's initial write position is 0:
@@ -411,7 +399,6 @@
411
399
  #
412
400
  # f.read # Raises IOError.
413
401
  #
414
- #
415
402
  # * `'w+'`:
416
403
  #
417
404
  # * File's initial position is 0:
@@ -476,7 +463,6 @@
476
463
  # f.read
477
464
  # # => "bah"
478
465
  #
479
- #
480
466
  # * `'a+'`:
481
467
  #
482
468
  # * File's initial write position is 0:
@@ -515,8 +501,6 @@
515
501
  # f.pos = 800
516
502
  # f.read # => ""
517
503
  #
518
- #
519
- #
520
504
  # #### Data Mode
521
505
  #
522
506
  # To specify whether data is to be treated as text or as binary data, either of
@@ -529,7 +513,6 @@
529
513
  # `Encoding::ASCII_8BIT`; on Windows, suppresses conversion between EOL and
530
514
  # CRLF and disables interpreting `0x1A` as an end-of-file marker.
531
515
  #
532
- #
533
516
  # If neither is given, the stream defaults to text data.
534
517
  #
535
518
  # Examples:
@@ -550,7 +533,6 @@
550
533
  # * `'x'`: Creates the file if it does not exist; raises an exception if the
551
534
  # file exists.
552
535
  #
553
- #
554
536
  # Example:
555
537
  #
556
538
  # File.new('t.tmp', 'wx')
@@ -571,7 +553,6 @@
571
553
  # * `File::RDWR`: Open for reading and writing.
572
554
  # * `File::APPEND`: Open for appending only.
573
555
  #
574
- #
575
556
  # Examples:
576
557
  #
577
558
  # File.new('t.txt', File::RDONLY)
@@ -588,7 +569,6 @@
588
569
  # * `File::EXCL`: Raise an exception if `File::CREAT` is given and the file
589
570
  # exists.
590
571
  #
591
- #
592
572
  # ### Data Mode Specified as an Integer
593
573
  #
594
574
  # Data mode cannot be specified as an integer. When the stream access mode is
@@ -699,7 +679,6 @@
699
679
  # methods for creating, reading, and writing files
700
680
  # * Includes module FileTest, which provides dozens of additional methods.
701
681
  #
702
- #
703
682
  # Here, class File provides methods that are useful for:
704
683
  #
705
684
  # * [Creating](rdoc-ref:File@Creating)
@@ -707,7 +686,6 @@
707
686
  # * [Settings](rdoc-ref:File@Settings)
708
687
  # * [Other](rdoc-ref:File@Other)
709
688
  #
710
- #
711
689
  # ### Creating
712
690
  #
713
691
  # * ::new: Opens the file at the given path; returns the file.
@@ -717,7 +695,6 @@
717
695
  # * ::mkfifo: Returns the FIFO file created at the given path.
718
696
  # * ::symlink: Creates a symbolic link for the given file path.
719
697
  #
720
- #
721
698
  # ### Querying
722
699
  #
723
700
  # *Paths*
@@ -744,7 +721,6 @@
744
721
  # * #path (aliased as #to_path): Returns the string representation of the
745
722
  # given path.
746
723
  #
747
- #
748
724
  # *Times*
749
725
  #
750
726
  # * ::atime: Returns a Time for the most recent access to the given file.
@@ -758,7 +734,6 @@
758
734
  # * #mtime: Returns a Time for the most recent data modification to the
759
735
  # content of `self`.
760
736
  #
761
- #
762
737
  # *Types*
763
738
  #
764
739
  # * ::blockdev?: Returns whether the file at the given path is a block device.
@@ -805,7 +780,6 @@
805
780
  # * #lstat: Returns the File::Stat object for the last symbolic link in the
806
781
  # path for `self`.
807
782
  #
808
- #
809
783
  # *Contents*
810
784
  #
811
785
  # * ::empty? (aliased as ::zero?): Returns whether the file at the given path
@@ -815,7 +789,6 @@
815
789
  # file is empty; otherwise returns the file size (bytes).
816
790
  # * #size: Returns the size (bytes) of `self`.
817
791
  #
818
- #
819
792
  # ### Settings
820
793
  #
821
794
  # * ::chmod: Changes permissions of the file at the given path.
@@ -829,7 +802,6 @@
829
802
  # given paths.
830
803
  # * #flock: Locks or unlocks `self`.
831
804
  #
832
- #
833
805
  # ### Other
834
806
  #
835
807
  # * ::truncate: Truncates the file at the given file path to the given size.
@@ -1193,10 +1165,13 @@ class File < IO
1193
1165
  #
1194
1166
  # `*`
1195
1167
  # : Matches all regular files
1168
+ #
1196
1169
  # `c*`
1197
1170
  # : Matches all files beginning with `c`
1171
+ #
1198
1172
  # `*c`
1199
1173
  # : Matches all files ending with `c`
1174
+ #
1200
1175
  # `*c*`
1201
1176
  # : Matches all files that have `c` in them (including at the beginning or
1202
1177
  # end).
@@ -1205,19 +1180,24 @@ class File < IO
1205
1180
  # To match hidden files (that start with a `.`) set the File::FNM_DOTMATCH
1206
1181
  # flag.
1207
1182
  #
1183
+ #
1208
1184
  # `**`
1209
1185
  # : Matches directories recursively or files expansively.
1210
1186
  #
1187
+ #
1211
1188
  # `?`
1212
1189
  # : Matches any one character. Equivalent to `/.{1}/` in regexp.
1213
1190
  #
1191
+ #
1214
1192
  # `[set]`
1215
1193
  # : Matches any one character in `set`. Behaves exactly like character sets
1216
1194
  # in Regexp, including set negation (`[^a-z]`).
1217
1195
  #
1196
+ #
1218
1197
  # `\`
1219
1198
  # : Escapes the next metacharacter.
1220
1199
  #
1200
+ #
1221
1201
  # `{a,b}`
1222
1202
  # : Matches pattern a and pattern b if File::FNM_EXTGLOB flag is enabled.
1223
1203
  # Behaves like a Regexp union (`(?:a|b)`).
@@ -1334,7 +1314,7 @@ class File < IO
1334
1314
  #
1335
1315
  # File.join("usr", "mail", "gumby") #=> "usr/mail/gumby"
1336
1316
  #
1337
- def self.join: (*string) -> String
1317
+ def self.join: (*path) -> String
1338
1318
 
1339
1319
  # <!--
1340
1320
  # rdoc-file=file.c
@@ -1836,46 +1816,19 @@ class File < IO
1836
1816
  # rdoc-file=file.c
1837
1817
  # - flock(locking_constant) -> 0 or false
1838
1818
  # -->
1839
- # Locks or unlocks a file according to the given `locking_constant`,
1819
+ # Locks or unlocks file `self` according to the given `locking_constant`,
1840
1820
  # a bitwise OR of the values in the table below.
1841
1821
  # Not available on all platforms.
1842
1822
  # Returns `false` if `File::LOCK_NB` is specified and the operation would have
1843
1823
  # blocked;
1844
1824
  # otherwise returns `0`.
1845
- #
1846
- # <table>
1847
- # <tr>
1848
- # <th colspan="3">Locking Constants</th>
1849
- # </tr>
1850
- # <tr>
1851
- # <th>Constant</th>
1852
- # <th>Lock</th>
1853
- # <th>Effect</th>
1854
- # </tr>
1855
- # <tr>
1856
- # <td><tt>File::LOCK_EX</tt></td>
1857
- # <td>Exclusive</td>
1858
- # <td>Only one process may hold an exclusive lock for <tt>self</tt> at a time.</td>
1859
- # </tr>
1860
- # <tr>
1861
- # <td><tt>File::LOCK_NB</tt></td>
1862
- # <td>Non-blocking</td>
1863
- # <td>
1864
- # No blocking; may be combined with other <tt>File::LOCK_SH</tt> or <tt>File::LOCK_EX</tt>
1865
- # using the bitwise OR operator <tt>|</tt>.
1866
- # </td>
1867
- # </tr>
1868
- # <tr>
1869
- # <td><tt>File::LOCK_SH</tt></td>
1870
- # <td>Shared</td>
1871
- # <td>Multiple processes may each hold a shared lock for <tt>self</tt> at the same time.</td>
1872
- # </tr>
1873
- # <tr>
1874
- # <td><tt>File::LOCK_UN</tt></td>
1875
- # <td>Unlock</td>
1876
- # <td>Remove an existing lock held by this process.</td>
1877
- # </tr>
1878
- # </table>
1825
+ # Constant | Lock | Effect
1826
+ # ---------------|------------|--------------------------------------------------------------------------------------------------------------
1827
+ # +File::LOCK_EX+| Exclusive | Only one process may hold an exclusive lock for +self+ at a time.
1828
+ # +File::LOCK_NB+|Non-blocking|No blocking; may be combined with +File::LOCK_SH+ or +File::LOCK_EX+ using the bitwise OR operator <tt>|</tt>.
1829
+ # +File::LOCK_SH+| Shared | Multiple processes may each hold a shared lock for +self+ at the same time.
1830
+ # +File::LOCK_UN+| Unlock | Remove an existing lock held by this process.
1831
+ # Example:
1879
1832
  # # Update a counter using an exclusive lock.
1880
1833
  # # Don't use File::WRONLY because it truncates the file.
1881
1834
  # File.open('counter', File::RDWR | File::CREAT, 0644) do |f|
@@ -2010,7 +1963,6 @@ File::Separator: String
2010
1963
  # globbing](rdoc-ref:File::Constants@Filename+Globbing+Constants+-28File-3A-
2011
1964
  # 3AFNM_-2A-29).
2012
1965
  #
2013
- #
2014
1966
  # File constants defined for the local process may be retrieved with method
2015
1967
  # File::Constants.constants:
2016
1968
  #
@@ -2034,7 +1986,6 @@ File::Separator: String
2034
1986
  # * StringIO.open.
2035
1987
  # * StringIO#reopen.
2036
1988
  #
2037
- #
2038
1989
  # ### Read/Write Access
2039
1990
  #
2040
1991
  # Read-write access for a stream may be specified by a file-access constant.
@@ -2045,7 +1996,7 @@ File::Separator: String
2045
1996
  #
2046
1997
  # #### File::RDONLY
2047
1998
  #
2048
- # Flag File::RDONLY specifies the the stream should be opened for reading only:
1999
+ # Flag File::RDONLY specifies the stream should be opened for reading only:
2049
2000
  #
2050
2001
  # filepath = '/tmp/t.tmp'
2051
2002
  # f = File.new(filepath, File::RDONLY)
@@ -2133,7 +2084,6 @@ File::Separator: String
2133
2084
  # * File::NOFOLLOW.
2134
2085
  # * File::TMPFILE.
2135
2086
  #
2136
- #
2137
2087
  # #### File::SYNC, File::RSYNC, and File::DSYNC
2138
2088
  #
2139
2089
  # Flag File::SYNC, File::RSYNC, or File::DSYNC specifies synchronization of I/O
@@ -2160,7 +2110,6 @@ File::Separator: String
2160
2110
  # be flushed to the underlying storage device; this differs from File::SYNC,
2161
2111
  # which requires that *metadata* also be synchronized.
2162
2112
  #
2163
- #
2164
2113
  # Note that the behavior of these flags may vary slightly depending on the
2165
2114
  # operating system and filesystem being used. Additionally, using these flags
2166
2115
  # can have an impact on performance due to the synchronous nature of the I/O
@@ -2214,11 +2163,13 @@ File::Separator: String
2214
2163
  #
2215
2164
  # Flag File::BINARY specifies that the stream is to be accessed in binary mode.
2216
2165
  #
2217
- # #### File::SHARE_DELETE (Windows Only)
2166
+ # #### File::SHARE_DELETE
2218
2167
  #
2219
2168
  # Flag File::SHARE_DELETE enables other processes to open the stream with delete
2220
2169
  # access.
2221
2170
  #
2171
+ # Windows only.
2172
+ #
2222
2173
  # If the stream is opened for (local) delete access without File::SHARE_DELETE,
2223
2174
  # and another process attempts to open it with delete access, the attempt fails
2224
2175
  # and the stream is not opened for that process.
@@ -2257,7 +2208,6 @@ File::Separator: String
2257
2208
  # * Pathname.glob.
2258
2209
  # * Pathname#glob.
2259
2210
  #
2260
- #
2261
2211
  # The constants are:
2262
2212
  #
2263
2213
  # #### File::FNM_CASEFOLD
@@ -2290,9 +2240,11 @@ File::Separator: String
2290
2240
  # Flag File::FNM_PATHNAME specifies that patterns `'*'` and `'?'` do not match
2291
2241
  # the directory separator (the value of constant File::SEPARATOR).
2292
2242
  #
2293
- # #### File::FNM_SHORTNAME (Windows Only)
2243
+ # #### File::FNM_SHORTNAME
2244
+ #
2245
+ # Flag File::FNM_SHORTNAME allows patterns to match short names if they exist.
2294
2246
  #
2295
- # Flag File::FNM_SHORTNAME Allows patterns to match short names if they exist.
2247
+ # Windows only.
2296
2248
  #
2297
2249
  # #### File::FNM_SYSCASE
2298
2250
  #
@@ -2439,8 +2391,7 @@ File::Constants::RDWR: Integer
2439
2391
  File::Constants::RSYNC: Integer
2440
2392
 
2441
2393
  # <!-- rdoc-file=file.c -->
2442
- # [File::SHARE_DELETE](rdoc-ref:File::Constants@File-3A-3ASHARE_DELETE+-28Window
2443
- # s+Only-29)
2394
+ # [File::SHARE_DELETE](rdoc-ref:File::Constants@File-3A-3ASHARE_DELETE)
2444
2395
  #
2445
2396
  File::Constants::SHARE_DELETE: Integer
2446
2397
 
data/core/float.rbs CHANGED
@@ -10,23 +10,21 @@
10
10
  # ys-floats-imprecise
11
11
  # * https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
12
12
  #
13
- #
14
13
  # You can create a Float object explicitly with:
15
14
  #
16
15
  # * A [floating-point literal](rdoc-ref:syntax/literals.rdoc@Float+Literals).
17
16
  #
18
- #
19
17
  # You can convert certain objects to Floats with:
20
18
  #
21
19
  # * Method #Float.
22
20
  #
23
- #
24
21
  # ## What's Here
25
22
  #
26
23
  # First, what's elsewhere. Class Float:
27
24
  #
28
- # * Inherits from [class Numeric](rdoc-ref:Numeric@What-27s+Here).
29
- #
25
+ # * Inherits from [class Numeric](rdoc-ref:Numeric@What-27s+Here) and [class
26
+ # Object](rdoc-ref:Object@What-27s+Here).
27
+ # * Includes [module Comparable](rdoc-ref:Comparable@What-27s+Here).
30
28
  #
31
29
  # Here, class Float provides methods for:
32
30
  #
@@ -34,7 +32,6 @@
34
32
  # * [Comparing](rdoc-ref:Float@Comparing)
35
33
  # * [Converting](rdoc-ref:Float@Converting)
36
34
  #
37
- #
38
35
  # ### Querying
39
36
  #
40
37
  # * #finite?: Returns whether `self` is finite.
@@ -42,7 +39,6 @@
42
39
  # * #infinite?: Returns whether `self` is infinite.
43
40
  # * #nan?: Returns whether `self` is a NaN (not-a-number).
44
41
  #
45
- #
46
42
  # ### Comparing
47
43
  #
48
44
  # * #<: Returns whether `self` is less than the given value.
@@ -54,7 +50,6 @@
54
50
  # * #>: Returns whether `self` is greater than the given value.
55
51
  # * #>=: Returns whether `self` is greater than or equal to the given value.
56
52
  #
57
- #
58
53
  # ### Converting
59
54
  #
60
55
  # * #% (aliased as #modulo): Returns `self` modulo the given value.
@@ -241,7 +236,6 @@ class Float < Numeric
241
236
  # * 1, if `self` is greater than `other`.
242
237
  # * `nil`, if the two values are incommensurate.
243
238
  #
244
- #
245
239
  # Examples:
246
240
  #
247
241
  # 2.0 <=> 2 # => 0
@@ -351,33 +345,58 @@ class Float < Numeric
351
345
  # rdoc-file=numeric.c
352
346
  # - ceil(ndigits = 0) -> float or integer
353
347
  # -->
354
- # Returns the smallest number greater than or equal to `self` with a precision
355
- # of `ndigits` decimal digits.
356
- #
357
- # When `ndigits` is positive, returns a float with `ndigits` digits after the
358
- # decimal point (as available):
359
- #
348
+ # Returns a numeric that is a "ceiling" value for `self`,
349
+ # as specified by the given `ndigits`,
350
+ # which must be an
351
+ # [integer-convertible
352
+ # object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
353
+ # When `ndigits` is positive, returns a Float with `ndigits`
354
+ # decimal digits after the decimal point
355
+ # (as available, but no fewer than 1):
360
356
  # f = 12345.6789
361
- # f.ceil(1) # => 12345.7
362
- # f.ceil(3) # => 12345.679
363
- # f = -12345.6789
364
- # f.ceil(1) # => -12345.6
365
- # f.ceil(3) # => -12345.678
366
- #
367
- # When `ndigits` is non-positive, returns an integer with at least `ndigits.abs`
368
- # trailing zeros:
369
- #
370
- # f = 12345.6789
371
- # f.ceil(0) # => 12346
372
- # f.ceil(-3) # => 13000
373
- # f = -12345.6789
374
- # f.ceil(0) # => -12345
375
- # f.ceil(-3) # => -12000
376
- #
377
- # Note that the limited precision of floating-point arithmetic may lead to
378
- # surprising results:
379
- #
380
- # (2.1 / 0.7).ceil #=> 4 (!)
357
+ # f.ceil(1) # => 12345.7
358
+ # f.ceil(3) # => 12345.679
359
+ # f.ceil(30) # => 12345.6789
360
+ # f = -12345.6789
361
+ # f.ceil(1) # => -12345.6
362
+ # f.ceil(3) # => -12345.678
363
+ # f.ceil(30) # => -12345.6789
364
+ # f = 0.0
365
+ # f.ceil(1) # => 0.0
366
+ # f.ceil(100) # => 0.0
367
+ #
368
+ # When `ndigits` is non-positive,
369
+ # returns an Integer based on a computed granularity:
370
+ # * The granularity is `10 ** ndigits.abs`.
371
+ # * The returned value is the largest multiple of the granularity
372
+ # that is less than or equal to `self`.
373
+ # Examples with positive `self`:
374
+ # ndigits|Granularity|12345.6789.ceil(ndigits)
375
+ # -------|-----------|------------------------
376
+ # 0| 1| 12346
377
+ # -1| 10| 12350
378
+ # -2| 100| 12400
379
+ # -3| 1000| 13000
380
+ # -4| 10000| 20000
381
+ # -5| 100000| 100000
382
+ # Examples with negative `self`:
383
+ # ndigits|Granularity|-12345.6789.ceil(ndigits)
384
+ # -------|-----------|-------------------------
385
+ # 0| 1| -12345
386
+ # -1| 10| -12340
387
+ # -2| 100| -12300
388
+ # -3| 1000| -12000
389
+ # -4| 10000| -10000
390
+ # -5| 100000| 0
391
+ # When `self` is zero and `ndigits` is non-positive,
392
+ # returns Integer zero:
393
+ # 0.0.ceil(0) # => 0
394
+ # 0.0.ceil(-1) # => 0
395
+ # 0.0.ceil(-2) # => 0
396
+ #
397
+ # Note that the limited precision of floating-point arithmetic
398
+ # may lead to surprising results:
399
+ # (2.1 / 0.7).ceil #=> 4 # Not 3 (because 2.1 / 0.7 # => 3.0000000000000004, not 3.0)
381
400
  #
382
401
  # Related: Float#floor.
383
402
  #
@@ -498,33 +517,59 @@ class Float < Numeric
498
517
  # rdoc-file=numeric.c
499
518
  # - floor(ndigits = 0) -> float or integer
500
519
  # -->
501
- # Returns the largest number less than or equal to `self` with a precision of
502
- # `ndigits` decimal digits.
503
- #
504
- # When `ndigits` is positive, returns a float with `ndigits` digits after the
505
- # decimal point (as available):
506
- #
507
- # f = 12345.6789
508
- # f.floor(1) # => 12345.6
509
- # f.floor(3) # => 12345.678
510
- # f = -12345.6789
511
- # f.floor(1) # => -12345.7
512
- # f.floor(3) # => -12345.679
513
- #
514
- # When `ndigits` is non-positive, returns an integer with at least `ndigits.abs`
515
- # trailing zeros:
516
- #
520
+ # Returns a float or integer that is a "floor" value for `self`,
521
+ # as specified by `ndigits`,
522
+ # which must be an
523
+ # [integer-convertible
524
+ # object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
525
+ # When `self` is zero,
526
+ # returns a zero value:
527
+ # a float if `ndigits` is positive,
528
+ # an integer otherwise:
529
+ # f = 0.0 # => 0.0
530
+ # f.floor(20) # => 0.0
531
+ # f.floor(0) # => 0
532
+ # f.floor(-20) # => 0
533
+ #
534
+ # When `self` is non-zero and `ndigits` is positive, returns a float with
535
+ # `ndigits`
536
+ # digits after the decimal point (as available):
517
537
  # f = 12345.6789
518
- # f.floor(0) # => 12345
519
- # f.floor(-3) # => 12000
520
- # f = -12345.6789
521
- # f.floor(0) # => -12346
522
- # f.floor(-3) # => -13000
523
- #
524
- # Note that the limited precision of floating-point arithmetic may lead to
525
- # surprising results:
526
- #
527
- # (0.3 / 0.1).floor #=> 2 (!)
538
+ # f.floor(1) # => 12345.6
539
+ # f.floor(3) # => 12345.678
540
+ # f.floor(30) # => 12345.6789
541
+ # f = -12345.6789
542
+ # f.floor(1) # => -12345.7
543
+ # f.floor(3) # => -12345.679
544
+ # f.floor(30) # => -12345.6789
545
+ #
546
+ # When `self` is non-zero and `ndigits` is non-positive,
547
+ # returns an integer value based on a computed granularity:
548
+ # * The granularity is `10 ** ndigits.abs`.
549
+ # * The returned value is the largest multiple of the granularity
550
+ # that is less than or equal to `self`.
551
+ # Examples with positive `self`:
552
+ # ndigits|Granularity|12345.6789.floor(ndigits)
553
+ # -------|-----------|-------------------------
554
+ # 0| 1| 12345
555
+ # -1| 10| 12340
556
+ # -2| 100| 12300
557
+ # -3| 1000| 12000
558
+ # -4| 10000| 10000
559
+ # -5| 100000| 0
560
+ # Examples with negative `self`:
561
+ # ndigits|Granularity|-12345.6789.floor(ndigits)
562
+ # -------|-----------|--------------------------
563
+ # 0| 1| -12346
564
+ # -1| 10| -12350
565
+ # -2| 100| -12400
566
+ # -3| 1000| -13000
567
+ # -4| 10000| -20000
568
+ # -5| 100000| -100000
569
+ # -6| 1000000| -1000000
570
+ # Note that the limited precision of floating-point arithmetic
571
+ # may lead to surprising results:
572
+ # (0.3 / 0.1).floor # => 2 # Not 3, (because (0.3 / 0.1) # => 2.9999999999999996, not 3.0)
528
573
  #
529
574
  # Related: Float#ceil.
530
575
  #
@@ -557,7 +602,6 @@ class Float < Numeric
557
602
  # * -1 if `self` is `-Infinity`.
558
603
  # * `nil`, otherwise.
559
604
  #
560
- #
561
605
  # Examples:
562
606
  #
563
607
  # f = 1.0/0.0 # => Infinity
@@ -576,14 +620,19 @@ class Float < Numeric
576
620
  # of `self`, the string representation may contain:
577
621
  #
578
622
  # * A fixed-point number.
623
+ # 3.14.to_s # => "3.14"
624
+ #
579
625
  # * A number in "scientific notation" (containing an exponent).
626
+ # (10.1**50).to_s # => "1.644631821843879e+50"
627
+ #
580
628
  # * 'Infinity'.
629
+ # (10.1**500).to_s # => "Infinity"
630
+ #
581
631
  # * '-Infinity'.
582
- # * 'NaN' (indicating not-a-number).
632
+ # (-10.1**500).to_s # => "-Infinity"
583
633
  #
584
- # 3.14.to_s # => "3.14" (10.1**50).to_s # =>
585
- # "1.644631821843879e+50" (10.1**500).to_s # => "Infinity"
586
- # (-10.1**500).to_s # => "-Infinity" (0.0/0.0).to_s # => "NaN"
634
+ # * 'NaN' (indicating not-a-number).
635
+ # (0.0/0.0).to_s # => "NaN"
587
636
  #
588
637
  alias inspect to_s
589
638
 
@@ -798,7 +847,7 @@ class Float < Numeric
798
847
 
799
848
  # <!--
800
849
  # rdoc-file=numeric.c
801
- # - round(ndigits = 0, half: :up]) -> integer or float
850
+ # - round(ndigits = 0, half: :up) -> integer or float
802
851
  # -->
803
852
  # Returns `self` rounded to the nearest value with a precision of `ndigits`
804
853
  # decimal digits.
@@ -844,7 +893,6 @@ class Float < Numeric
844
893
  # 3.5.round(half: :even) # => 4
845
894
  # (-2.5).round(half: :even) # => -2
846
895
  #
847
- #
848
896
  # Raises and exception if the value for `half` is invalid.
849
897
  #
850
898
  # Related: Float#truncate.
@@ -926,14 +974,19 @@ class Float < Numeric
926
974
  # of `self`, the string representation may contain:
927
975
  #
928
976
  # * A fixed-point number.
977
+ # 3.14.to_s # => "3.14"
978
+ #
929
979
  # * A number in "scientific notation" (containing an exponent).
980
+ # (10.1**50).to_s # => "1.644631821843879e+50"
981
+ #
930
982
  # * 'Infinity'.
983
+ # (10.1**500).to_s # => "Infinity"
984
+ #
931
985
  # * '-Infinity'.
932
- # * 'NaN' (indicating not-a-number).
986
+ # (-10.1**500).to_s # => "-Infinity"
933
987
  #
934
- # 3.14.to_s # => "3.14" (10.1**50).to_s # =>
935
- # "1.644631821843879e+50" (10.1**500).to_s # => "Infinity"
936
- # (-10.1**500).to_s # => "-Infinity" (0.0/0.0).to_s # => "NaN"
988
+ # * 'NaN' (indicating not-a-number).
989
+ # (0.0/0.0).to_s # => "NaN"
937
990
  #
938
991
  def to_s: () -> String
939
992