rbs 3.3.2 → 3.4.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +2 -5
  3. data/.github/workflows/ruby.yml +7 -8
  4. data/.github/workflows/typecheck.yml +37 -0
  5. data/CHANGELOG.md +50 -0
  6. data/Gemfile +1 -1
  7. data/Gemfile.lock +11 -11
  8. data/Steepfile +2 -2
  9. data/core/array.rbs +19 -49
  10. data/core/basic_object.rbs +2 -2
  11. data/core/comparable.rbs +17 -8
  12. data/core/complex.rbs +82 -43
  13. data/core/data.rbs +2 -4
  14. data/core/dir.rbs +635 -295
  15. data/core/enumerable.rbs +11 -18
  16. data/core/enumerator.rbs +37 -31
  17. data/core/errors.rbs +4 -0
  18. data/core/false_class.rbs +34 -15
  19. data/core/fiber.rbs +23 -0
  20. data/core/file.rbs +329 -120
  21. data/core/float.rbs +17 -32
  22. data/core/gc.rbs +17 -11
  23. data/core/hash.rbs +22 -44
  24. data/core/integer.rbs +82 -113
  25. data/core/io/buffer.rbs +90 -47
  26. data/core/io.rbs +39 -116
  27. data/core/kernel.rbs +442 -489
  28. data/core/match_data.rbs +55 -56
  29. data/core/module.rbs +45 -1
  30. data/core/nil_class.rbs +98 -35
  31. data/core/numeric.rbs +22 -32
  32. data/core/object_space/weak_key_map.rbs +102 -0
  33. data/core/process.rbs +1242 -655
  34. data/core/ractor.rbs +139 -120
  35. data/core/range.rbs +100 -4
  36. data/core/rational.rbs +0 -4
  37. data/core/rbs/unnamed/argf.rbs +16 -8
  38. data/core/rbs/unnamed/env_class.rbs +0 -24
  39. data/core/refinement.rbs +8 -0
  40. data/core/regexp.rbs +1149 -598
  41. data/core/ruby_vm.rbs +126 -12
  42. data/core/rubygems/platform.rbs +9 -0
  43. data/core/rubygems/rubygems.rbs +1 -1
  44. data/core/rubygems/version.rbs +5 -1
  45. data/core/set.rbs +20 -22
  46. data/core/signal.rbs +4 -4
  47. data/core/string.rbs +283 -230
  48. data/core/string_io.rbs +2 -14
  49. data/core/struct.rbs +404 -24
  50. data/core/symbol.rbs +1 -19
  51. data/core/thread.rbs +29 -12
  52. data/core/time.rbs +227 -104
  53. data/core/trace_point.rbs +2 -5
  54. data/core/true_class.rbs +54 -21
  55. data/core/warning.rbs +14 -11
  56. data/docs/data_and_struct.md +29 -0
  57. data/docs/syntax.md +3 -5
  58. data/docs/tools.md +1 -0
  59. data/ext/rbs_extension/lexer.c +643 -559
  60. data/ext/rbs_extension/lexer.re +5 -1
  61. data/ext/rbs_extension/parser.c +12 -3
  62. data/ext/rbs_extension/unescape.c +7 -47
  63. data/lib/rbs/cli/diff.rb +4 -1
  64. data/lib/rbs/cli/validate.rb +280 -0
  65. data/lib/rbs/cli.rb +2 -194
  66. data/lib/rbs/collection/config.rb +5 -6
  67. data/lib/rbs/collection/sources/git.rb +1 -1
  68. data/lib/rbs/collection.rb +1 -0
  69. data/lib/rbs/diff.rb +7 -4
  70. data/lib/rbs/errors.rb +11 -0
  71. data/lib/rbs/test/errors.rb +4 -1
  72. data/lib/rbs/test/guaranteed.rb +2 -3
  73. data/lib/rbs/test/type_check.rb +15 -10
  74. data/lib/rbs/test.rb +3 -3
  75. data/lib/rbs/types.rb +29 -0
  76. data/lib/rbs/unit_test/convertibles.rb +176 -0
  77. data/lib/rbs/unit_test/spy.rb +136 -0
  78. data/lib/rbs/unit_test/type_assertions.rb +341 -0
  79. data/lib/rbs/unit_test/with_aliases.rb +143 -0
  80. data/lib/rbs/unit_test.rb +6 -0
  81. data/lib/rbs/version.rb +1 -1
  82. data/sig/cli/validate.rbs +43 -0
  83. data/sig/diff.rbs +3 -1
  84. data/sig/errors.rbs +8 -0
  85. data/sig/rbs.rbs +1 -1
  86. data/sig/test/errors.rbs +52 -0
  87. data/sig/test/guranteed.rbs +9 -0
  88. data/sig/test/type_check.rbs +19 -0
  89. data/sig/test.rbs +82 -0
  90. data/sig/types.rbs +6 -1
  91. data/sig/unit_test/convertibles.rbs +154 -0
  92. data/sig/unit_test/spy.rbs +28 -0
  93. data/sig/unit_test/type_assertions.rbs +194 -0
  94. data/sig/unit_test/with_aliases.rbs +136 -0
  95. data/stdlib/base64/0/base64.rbs +307 -45
  96. data/stdlib/bigdecimal/0/big_decimal.rbs +35 -15
  97. data/stdlib/coverage/0/coverage.rbs +2 -2
  98. data/stdlib/csv/0/csv.rbs +25 -55
  99. data/stdlib/date/0/date.rbs +1 -43
  100. data/stdlib/date/0/date_time.rbs +1 -13
  101. data/stdlib/delegate/0/delegator.rbs +186 -0
  102. data/stdlib/delegate/0/kernel.rbs +47 -0
  103. data/stdlib/delegate/0/simple_delegator.rbs +98 -0
  104. data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -1
  105. data/stdlib/erb/0/erb.rbs +2 -2
  106. data/stdlib/fileutils/0/fileutils.rbs +0 -19
  107. data/stdlib/io-console/0/io-console.rbs +12 -1
  108. data/stdlib/ipaddr/0/ipaddr.rbs +2 -1
  109. data/stdlib/json/0/json.rbs +320 -81
  110. data/stdlib/logger/0/logger.rbs +9 -5
  111. data/stdlib/monitor/0/monitor.rbs +78 -0
  112. data/stdlib/net-http/0/net-http.rbs +1880 -543
  113. data/stdlib/objspace/0/objspace.rbs +19 -13
  114. data/stdlib/openssl/0/openssl.rbs +508 -127
  115. data/stdlib/optparse/0/optparse.rbs +25 -11
  116. data/stdlib/pathname/0/pathname.rbs +1 -1
  117. data/stdlib/pp/0/pp.rbs +2 -5
  118. data/stdlib/prettyprint/0/prettyprint.rbs +2 -2
  119. data/stdlib/pstore/0/pstore.rbs +2 -4
  120. data/stdlib/rdoc/0/comment.rbs +1 -2
  121. data/stdlib/resolv/0/resolv.rbs +4 -2
  122. data/stdlib/socket/0/socket.rbs +2 -2
  123. data/stdlib/socket/0/unix_socket.rbs +2 -2
  124. data/stdlib/strscan/0/string_scanner.rbs +3 -2
  125. data/stdlib/tempfile/0/tempfile.rbs +1 -1
  126. data/stdlib/uri/0/common.rbs +245 -123
  127. metadata +23 -4
  128. data/lib/rbs/test/spy.rb +0 -6
data/core/time.rbs CHANGED
@@ -1,5 +1,5 @@
1
1
  # <!-- rdoc-file=timev.rb -->
2
- # A Time object represents a date and time:
2
+ # A `Time` object represents a date and time:
3
3
  #
4
4
  # Time.new(2000, 1, 1, 0, 0, 0) # => 2000-01-01 00:00:00 -0600
5
5
  #
@@ -42,14 +42,14 @@
42
42
  #
43
43
  # ## Time Resolution
44
44
  #
45
- # A Time object derived from the system clock (for example, by method Time.now)
46
- # has the resolution supported by the system.
45
+ # A `Time` object derived from the system clock (for example, by method
46
+ # Time.now) has the resolution supported by the system.
47
47
  #
48
48
  # ## Examples
49
49
  #
50
50
  # All of these examples were done using the EST timezone which is GMT-5.
51
51
  #
52
- # ### Creating a New Time Instance
52
+ # ### Creating a New `Time` Instance
53
53
  #
54
54
  # You can create a new instance of Time with Time.new. This will use the current
55
55
  # system time. Time.now is an alias for this. You can also pass parts of the
@@ -66,7 +66,7 @@
66
66
  #
67
67
  # Time.new(2002, 10, 31, 2, 2, 2, "+02:00") #=> 2002-10-31 02:02:02 +0200
68
68
  #
69
- # Or a timezone object:
69
+ # Or [a timezone object](rdoc-ref:Time@Timezone+Objects):
70
70
  #
71
71
  # zone = timezone("Europe/Athens") # Eastern European Time, UTC+2
72
72
  # Time.new(2002, 10, 31, 2, 2, 2, zone) #=> 2002-10-31 02:02:02 +0200
@@ -80,7 +80,7 @@
80
80
  #
81
81
  # Time.at(628232400) #=> 1989-11-28 00:00:00 -0500
82
82
  #
83
- # ### Working with an Instance of Time
83
+ # ### Working with an Instance of `Time`
84
84
  #
85
85
  # Once you have an instance of Time there is a multitude of things you can do
86
86
  # with it. Below are some examples. For all of the following examples, we will
@@ -122,20 +122,20 @@
122
122
  #
123
123
  # ## What's Here
124
124
  #
125
- # First, what's elsewhere. Class Time:
125
+ # First, what's elsewhere. Class `Time`:
126
126
  #
127
127
  # * Inherits from [class Object](rdoc-ref:Object@What-27s+Here).
128
128
  # * Includes [module Comparable](rdoc-ref:Comparable@What-27s+Here).
129
129
  #
130
130
  #
131
- # Here, class Time provides methods that are useful for:
131
+ # Here, class `Time` provides methods that are useful for:
132
132
  #
133
- # * [Creating \Time objects](rdoc-ref:Time@Methods+for+Creating).
134
- # * [Fetching \Time values](rdoc-ref:Time@Methods+for+Fetching).
135
- # * [Querying a \Time object](rdoc-ref:Time@Methods+for+Querying).
136
- # * [Comparing \Time objects](rdoc-ref:Time@Methods+for+Comparing).
137
- # * [Converting a \Time object](rdoc-ref:Time@Methods+for+Converting).
138
- # * [Rounding a \Time](rdoc-ref:Time@Methods+for+Rounding).
133
+ # * {Creating `Time`[objects}](rdoc-ref:Time@Methods+for+Creating).
134
+ # * {Fetching `Time`[values}](rdoc-ref:Time@Methods+for+Fetching).
135
+ # * {Querying a `Time`[object}](rdoc-ref:Time@Methods+for+Querying).
136
+ # * {Comparing `Time`[objects}](rdoc-ref:Time@Methods+for+Comparing).
137
+ # * {Converting a `Time`[object}](rdoc-ref:Time@Methods+for+Converting).
138
+ # * {Rounding a `Time`[}](rdoc-ref:Time@Methods+for+Rounding).
139
139
  #
140
140
  #
141
141
  # ### Methods for Creating
@@ -219,7 +219,174 @@
219
219
  #
220
220
  #
221
221
  # For the forms of argument `zone`, see [Timezone
222
- # Specifiers](rdoc-ref:timezones.rdoc).
222
+ # Specifiers](rdoc-ref:Time@Timezone+Specifiers).
223
+ #
224
+ # ## Timezone Specifiers
225
+ #
226
+ # Certain `Time` methods accept arguments that specify timezones:
227
+ #
228
+ # * Time.at: keyword argument `in:`.
229
+ # * Time.new: positional argument `zone` or keyword argument `in:`.
230
+ # * Time.now: keyword argument `in:`.
231
+ # * Time#getlocal: positional argument `zone`.
232
+ # * Time#localtime: positional argument `zone`.
233
+ #
234
+ #
235
+ # The value given with any of these must be one of the following (each detailed
236
+ # below):
237
+ #
238
+ # * [Hours/minutes offset](rdoc-ref:Time@Hours-2FMinutes+Offsets).
239
+ # * [Single-letter offset](rdoc-ref:Time@Single-Letter+Offsets).
240
+ # * [Integer offset](rdoc-ref:Time@Integer+Offsets).
241
+ # * [Timezone object](rdoc-ref:Time@Timezone+Objects).
242
+ # * [Timezone name](rdoc-ref:Time@Timezone+Names).
243
+ #
244
+ #
245
+ # ### Hours/Minutes Offsets
246
+ #
247
+ # The zone value may be a string offset from UTC in the form `'+HH:MM'` or
248
+ # `'-HH:MM'`, where:
249
+ #
250
+ # * `HH` is the 2-digit hour in the range `0..23`.
251
+ # * `MM` is the 2-digit minute in the range `0..59`.
252
+ #
253
+ #
254
+ # Examples:
255
+ #
256
+ # t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
257
+ # Time.at(t, in: '-23:59') # => 1999-12-31 20:16:01 -2359
258
+ # Time.at(t, in: '+23:59') # => 2000-01-02 20:14:01 +2359
259
+ #
260
+ # ### Single-Letter Offsets
261
+ #
262
+ # The zone value may be a letter in the range `'A'..'I'` or `'K'..'Z'`; see
263
+ # [List of military time
264
+ # zones](https://en.wikipedia.org/wiki/List_of_military_time_zones):
265
+ #
266
+ # t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
267
+ # Time.at(t, in: 'A') # => 2000-01-01 21:15:01 +0100
268
+ # Time.at(t, in: 'I') # => 2000-01-02 05:15:01 +0900
269
+ # Time.at(t, in: 'K') # => 2000-01-02 06:15:01 +1000
270
+ # Time.at(t, in: 'Y') # => 2000-01-01 08:15:01 -1200
271
+ # Time.at(t, in: 'Z') # => 2000-01-01 20:15:01 UTC
272
+ #
273
+ # ### Integer Offsets
274
+ #
275
+ # The zone value may be an integer number of seconds in the range
276
+ # `-86399..86399`:
277
+ #
278
+ # t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
279
+ # Time.at(t, in: -86399) # => 1999-12-31 20:15:02 -235959
280
+ # Time.at(t, in: 86399) # => 2000-01-02 20:15:00 +235959
281
+ #
282
+ # ### Timezone Objects
283
+ #
284
+ # The zone value may be an object responding to certain timezone methods, an
285
+ # instance of [Timezone](https://github.com/panthomakos/timezone) and
286
+ # [TZInfo](https://tzinfo.github.io) for example.
287
+ #
288
+ # The timezone methods are:
289
+ #
290
+ # * `local_to_utc`:
291
+ #
292
+ # * Called when Time.new is invoked with `tz` as the value of positional
293
+ # argument `zone` or keyword argument `in:`.
294
+ # * Argument: a [Time-like object](rdoc-ref:Time@Time-Like+Objects).
295
+ # * Returns: a [Time-like object](rdoc-ref:Time@Time-Like+Objects) in the
296
+ # UTC timezone.
297
+ #
298
+ #
299
+ # * `utc_to_local`:
300
+ #
301
+ # * Called when Time.at or Time.now is invoked with `tz` as the value for
302
+ # keyword argument `in:`, and when Time#getlocal or Time#localtime is
303
+ # called with `tz` as the value for positional argument `zone`.
304
+ # * Argument: a [Time-like object](rdoc-ref:Time@Time-Like+Objects).
305
+ # * Returns: a [Time-like object](rdoc-ref:Time@Time-Like+Objects) in the
306
+ # local timezone.
307
+ #
308
+ #
309
+ #
310
+ # A custom timezone class may have these instance methods, which will be called
311
+ # if defined:
312
+ #
313
+ # * `abbr`:
314
+ #
315
+ # * Called when Time#strftime is invoked with a format involving `%Z`.
316
+ # * Argument: a [Time-like object](rdoc-ref:Time@Time-Like+Objects).
317
+ # * Returns: a string abbreviation for the timezone name.
318
+ #
319
+ #
320
+ # * `dst?`:
321
+ #
322
+ # * Called when Time.at or Time.now is invoked with `tz` as the value for
323
+ # keyword argument `in:`, and when Time#getlocal or Time#localtime is
324
+ # called with `tz` as the value for positional argument `zone`.
325
+ # * Argument: a [Time-like object](rdoc-ref:Time@Time-Like+Objects).
326
+ # * Returns: whether the time is daylight saving time.
327
+ #
328
+ #
329
+ # * `name`:
330
+ #
331
+ # * Called when `Marshal.dump(t)` is invoked
332
+ # * Argument: none.
333
+ # * Returns: the string name of the timezone.
334
+ #
335
+ #
336
+ #
337
+ # #### `Time`-Like Objects
338
+ #
339
+ # A `Time`-like object is a container object capable of interfacing with
340
+ # timezone libraries for timezone conversion.
341
+ #
342
+ # The argument to the timezone conversion methods above will have attributes
343
+ # similar to Time, except that timezone related attributes are meaningless.
344
+ #
345
+ # The objects returned by `local_to_utc` and `utc_to_local` methods of the
346
+ # timezone object may be of the same class as their arguments, of arbitrary
347
+ # object classes, or of class Integer.
348
+ #
349
+ # For a returned class other than `Integer`, the class must have the following
350
+ # methods:
351
+ #
352
+ # * `year`
353
+ # * `mon`
354
+ # * `mday`
355
+ # * `hour`
356
+ # * `min`
357
+ # * `sec`
358
+ # * `isdst`
359
+ # * `to_i`
360
+ #
361
+ #
362
+ # For a returned `Integer`, its components, decomposed in UTC, are interpreted
363
+ # as times in the specified timezone.
364
+ #
365
+ # ### Timezone Names
366
+ #
367
+ # If the class (the receiver of class methods, or the class of the receiver of
368
+ # instance methods) has `find_timezone` singleton method, this method is called
369
+ # to achieve the corresponding timezone object from a timezone name.
370
+ #
371
+ # For example, using [Timezone](https://github.com/panthomakos/timezone):
372
+ # class TimeWithTimezone < Time
373
+ # require 'timezone'
374
+ # def self.find_timezone(z) = Timezone[z]
375
+ # end
376
+ #
377
+ # TimeWithTimezone.now(in: "America/New_York") #=> 2023-12-25 00:00:00 -0500
378
+ # TimeWithTimezone.new("2023-12-25 America/New_York") #=> 2023-12-25 00:00:00 -0500
379
+ #
380
+ # Or, using [TZInfo](https://tzinfo.github.io):
381
+ # class TimeWithTZInfo < Time
382
+ # require 'tzinfo'
383
+ # def self.find_timezone(z) = TZInfo::Timezone.get(z)
384
+ # end
385
+ #
386
+ # TimeWithTZInfo.now(in: "America/New_York") #=> 2023-12-25 00:00:00 -0500
387
+ # TimeWithTZInfo.new("2023-12-25 America/New_York") #=> 2023-12-25 00:00:00 -0500
388
+ #
389
+ # You can define this method per subclasses, or on the toplevel Time class.
223
390
  #
224
391
  class Time < Object
225
392
  include Comparable
@@ -228,11 +395,11 @@ class Time < Object
228
395
  # rdoc-file=timev.rb
229
396
  # - at(time, subsec = false, unit = :microsecond, in: nil)
230
397
  # -->
231
- # Returns a new Time object based on the given arguments.
398
+ # Returns a new `Time` object based on the given arguments.
232
399
  #
233
400
  # Required argument `time` may be either of:
234
401
  #
235
- # * A Time object, whose value is the basis for the returned time; also
402
+ # * A `Time` object, whose value is the basis for the returned time; also
236
403
  # influenced by optional keyword argument `in:` (see below).
237
404
  # * A numeric number of [Epoch seconds](rdoc-ref:Time@Epoch+Seconds) for the
238
405
  # returned time.
@@ -274,14 +441,14 @@ class Time < Object
274
441
  # Time.at(secs, -1000000000, :nanosecond) # => 2000-12-31 23:59:58 -0600
275
442
  #
276
443
  #
277
- # Optional keyword argument `+in: zone` specifies the timezone for the returned
444
+ # Optional keyword argument `in: zone` specifies the timezone for the returned
278
445
  # time:
279
446
  #
280
447
  # Time.at(secs, in: '+12:00') # => 2001-01-01 17:59:59 +1200
281
448
  # Time.at(secs, in: '-12:00') # => 2000-12-31 17:59:59 -1200
282
449
  #
283
450
  # For the forms of argument `zone`, see [Timezone
284
- # Specifiers](rdoc-ref:timezones.rdoc).
451
+ # Specifiers](rdoc-ref:Time@Timezone+Specifiers).
285
452
  #
286
453
  def self.at: (Time, ?in: String | Integer | nil) -> Time
287
454
  | (Numeric, ?in: String | Integer | nil) -> Time
@@ -290,7 +457,7 @@ class Time < Object
290
457
  type subsec_unit = :msec | :millisecond | :usec | :microsecond | :nsec | :nanosecond
291
458
 
292
459
  # <!-- rdoc-file=time.c -->
293
- # Returns a new Time object based the on given arguments, in the UTC timezone.
460
+ # Returns a new `Time` object based the on given arguments, in the UTC timezone.
294
461
  #
295
462
  # With one to seven arguments given, the arguments are interpreted as in the
296
463
  # first calling sequence above:
@@ -367,7 +534,7 @@ class Time < Object
367
534
  # # => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
368
535
  # Time.utc(*a) # => 0005-04-03 02:01:00 UTC
369
536
  #
370
- # This form is useful for creating a Time object from a 10-element array
537
+ # This form is useful for creating a `Time` object from a 10-element array
371
538
  # returned by Time.to_a:
372
539
  #
373
540
  # t = Time.new(2000, 1, 2, 3, 4, 5, 6) # => 2000-01-02 03:04:05 +000006
@@ -381,8 +548,6 @@ class Time < Object
381
548
  # Raises an exception if the number of arguments is eight, nine, or greater than
382
549
  # ten.
383
550
  #
384
- # Time.gm is an alias for Time.utc.
385
- #
386
551
  # Related: Time.local.
387
552
  #
388
553
  def self.gm: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
@@ -392,7 +557,7 @@ class Time < Object
392
557
  # - Time.local(year, month = 1, mday = 1, hour = 0, min = 0, sec = 0, usec = 0) -> new_time
393
558
  # - Time.local(sec, min, hour, mday, month, year, dummy, dummy, dummy, dummy) -> new_time
394
559
  # -->
395
- # Like Time.utc, except that the returned Time object has the local timezone,
560
+ # Like Time.utc, except that the returned `Time` object has the local timezone,
396
561
  # not the UTC timezone:
397
562
  #
398
563
  # # With seven arguments.
@@ -408,14 +573,14 @@ class Time < Object
408
573
  # rdoc-file=timev.rb
409
574
  # - now(in: nil)
410
575
  # -->
411
- # Creates a new Time object from the current system time. This is the same as
576
+ # Creates a new `Time` object from the current system time. This is the same as
412
577
  # Time.new without arguments.
413
578
  #
414
579
  # Time.now # => 2009-06-24 12:39:54 +0900
415
580
  # Time.now(in: '+04:00') # => 2009-06-24 07:39:54 +0400
416
581
  #
417
582
  # For forms of argument `zone`, see [Timezone
418
- # Specifiers](rdoc-ref:timezones.rdoc).
583
+ # Specifiers](rdoc-ref:Time@Timezone+Specifiers).
419
584
  #
420
585
  def self.now: (?in: String | Integer | nil) -> Time
421
586
 
@@ -424,7 +589,7 @@ class Time < Object
424
589
  # - Time.utc(year, month = 1, mday = 1, hour = 0, min = 0, sec = 0, usec = 0) -> new_time
425
590
  # - Time.utc(sec, min, hour, mday, month, year, dummy, dummy, dummy, dummy) -> new_time
426
591
  # -->
427
- # Returns a new Time object based the on given arguments, in the UTC timezone.
592
+ # Returns a new `Time` object based the on given arguments, in the UTC timezone.
428
593
  #
429
594
  # With one to seven arguments given, the arguments are interpreted as in the
430
595
  # first calling sequence above:
@@ -501,7 +666,7 @@ class Time < Object
501
666
  # # => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
502
667
  # Time.utc(*a) # => 0005-04-03 02:01:00 UTC
503
668
  #
504
- # This form is useful for creating a Time object from a 10-element array
669
+ # This form is useful for creating a `Time` object from a 10-element array
505
670
  # returned by Time.to_a:
506
671
  #
507
672
  # t = Time.new(2000, 1, 2, 3, 4, 5, 6) # => 2000-01-02 03:04:05 +000006
@@ -515,8 +680,6 @@ class Time < Object
515
680
  # Raises an exception if the number of arguments is eight, nine, or greater than
516
681
  # ten.
517
682
  #
518
- # Time.gm is an alias for Time.utc.
519
- #
520
683
  # Related: Time.local.
521
684
  #
522
685
  def self.utc: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
@@ -525,7 +688,7 @@ class Time < Object
525
688
  # rdoc-file=time.c
526
689
  # - self + numeric -> new_time
527
690
  # -->
528
- # Returns a new Time object whose value is the sum of the numeric value of
691
+ # Returns a new `Time` object whose value is the sum of the numeric value of
529
692
  # `self` and the given `numeric`:
530
693
  #
531
694
  # t = Time.new(2000) # => 2000-01-01 00:00:00 -0600
@@ -541,7 +704,7 @@ class Time < Object
541
704
  # - self - numeric -> new_time
542
705
  # - self - other_time -> float
543
706
  # -->
544
- # When `numeric` is given, returns a new Time object whose value is the
707
+ # When `numeric` is given, returns a new `Time` object whose value is the
545
708
  # difference of the numeric value of `self` and `numeric`:
546
709
  #
547
710
  # t = Time.new(2000) # => 2000-01-01 00:00:00 -0600
@@ -549,7 +712,7 @@ class Time < Object
549
712
  # t - 0.5 # => 1999-12-31 23:59:59.5 -0600
550
713
  #
551
714
  # When `other_time` is given, returns a Float whose value is the difference of
552
- # the numeric values of `self` and `other_time`:
715
+ # the numeric values of `self` and `other_time` in seconds:
553
716
  #
554
717
  # t - t # => 0.0
555
718
  #
@@ -606,8 +769,6 @@ class Time < Object
606
769
  # t.strftime('%a %b %e %T %Y') # => "Sun Dec 31 23:59:59 2000"
607
770
  # t.strftime('%c') # => "Sun Dec 31 23:59:59 2000"
608
771
  #
609
- # Time#asctime is an alias for Time#ctime.
610
- #
611
772
  # Related: Time#to_s, Time#inspect:
612
773
  #
613
774
  # t.inspect # => "2000-12-31 23:59:59.5 +000001"
@@ -628,8 +789,6 @@ class Time < Object
628
789
  # t.strftime('%a %b %e %T %Y') # => "Sun Dec 31 23:59:59 2000"
629
790
  # t.strftime('%c') # => "Sun Dec 31 23:59:59 2000"
630
791
  #
631
- # Time#asctime is an alias for Time#ctime.
632
- #
633
792
  # Related: Time#to_s, Time#inspect:
634
793
  #
635
794
  # t.inspect # => "2000-12-31 23:59:59.5 +000001"
@@ -644,8 +803,6 @@ class Time < Object
644
803
  # # => 2000-01-02 03:04:05 +000006
645
804
  # t.mday # => 2
646
805
  #
647
- # Time#day is an alias for Time#mday.
648
- #
649
806
  # Related: Time#year, Time#hour, Time#min.
650
807
  #
651
808
  def day: () -> Integer
@@ -695,16 +852,14 @@ class Time < Object
695
852
  # t.zone # => "Central Daylight Time"
696
853
  # t.dst? # => true
697
854
  #
698
- # Time#isdst is an alias for Time#dst?.
699
- #
700
855
  def dst?: () -> bool
701
856
 
702
857
  # <!--
703
858
  # rdoc-file=time.c
704
859
  # - eql?(other_time)
705
860
  # -->
706
- # Returns `true` if `self` and `other_time` are both Time objects with the exact
707
- # same time value.
861
+ # Returns `true` if `self` and `other_time` are both `Time` objects with the
862
+ # exact same time value.
708
863
  #
709
864
  def eql?: (untyped arg0) -> bool
710
865
 
@@ -725,7 +880,7 @@ class Time < Object
725
880
  # rdoc-file=time.c
726
881
  # - getutc -> new_time
727
882
  # -->
728
- # Returns a new Time object representing the value of `self` converted to the
883
+ # Returns a new `Time` object representing the value of `self` converted to the
729
884
  # UTC timezone:
730
885
  #
731
886
  # local = Time.local(2000) # => 2000-01-01 00:00:00 -0600
@@ -734,15 +889,13 @@ class Time < Object
734
889
  # utc.utc? # => true
735
890
  # utc == local # => true
736
891
  #
737
- # Time#getgm is an alias for Time#getutc.
738
- #
739
892
  def getgm: () -> Time
740
893
 
741
894
  # <!--
742
895
  # rdoc-file=time.c
743
896
  # - getlocal(zone = nil) -> new_time
744
897
  # -->
745
- # Returns a new Time object representing the value of `self` converted to a
898
+ # Returns a new `Time` object representing the value of `self` converted to a
746
899
  # given timezone; if `zone` is `nil`, the local timezone is used:
747
900
  #
748
901
  # t = Time.utc(2000) # => 2000-01-01 00:00:00 UTC
@@ -750,12 +903,12 @@ class Time < Object
750
903
  # t.getlocal('+12:00') # => 2000-01-01 12:00:00 +1200
751
904
  #
752
905
  # For forms of argument `zone`, see [Timezone
753
- # Specifiers](rdoc-ref:timezones.rdoc).
906
+ # Specifiers](rdoc-ref:Time@Timezone+Specifiers).
754
907
  #
755
908
  def getlocal: (?Integer utc_offset) -> Time
756
909
 
757
910
  # <!-- rdoc-file=time.c -->
758
- # Returns a new Time object representing the value of `self` converted to the
911
+ # Returns a new `Time` object representing the value of `self` converted to the
759
912
  # UTC timezone:
760
913
  #
761
914
  # local = Time.local(2000) # => 2000-01-01 00:00:00 -0600
@@ -764,8 +917,6 @@ class Time < Object
764
917
  # utc.utc? # => true
765
918
  # utc == local # => true
766
919
  #
767
- # Time#getgm is an alias for Time#getutc.
768
- #
769
920
  def getutc: () -> Time
770
921
 
771
922
  # <!-- rdoc-file=time.c -->
@@ -778,8 +929,6 @@ class Time < Object
778
929
  # # => 2000-01-01 20:15:01 UTC
779
930
  # utc.utc? # => true
780
931
  #
781
- # Time#gmt? is an alias for Time#utc?.
782
- #
783
932
  # Related: Time.utc.
784
933
  #
785
934
  def gmt?: () -> bool
@@ -790,8 +939,6 @@ class Time < Object
790
939
  # Time.utc(2000, 1, 1).utc_offset # => 0
791
940
  # Time.local(2000, 1, 1).utc_offset # => -21600 # -6*3600, or minus six hours.
792
941
  #
793
- # Time#gmt_offset and Time#gmtoff are aliases for Time#utc_offset.
794
- #
795
942
  def gmt_offset: () -> Integer
796
943
 
797
944
  # <!--
@@ -805,9 +952,7 @@ class Time < Object
805
952
  # t.utc # => 2000-01-01 06:00:00 UTC
806
953
  # t.utc? # => true
807
954
  #
808
- # Time#gmtime is an alias for Time#utc.
809
- #
810
- # Related: Time#getutc (returns a new converted Time object).
955
+ # Related: Time#getutc (returns a new converted `Time` object).
811
956
  #
812
957
  def gmtime: () -> Time
813
958
 
@@ -837,16 +982,16 @@ class Time < Object
837
982
 
838
983
  # <!--
839
984
  # rdoc-file=timev.rb
840
- # - new(year = (now = true), mon = (str = year; nil), mday = nil, hour = nil, min = nil, sec = nil, zone = nil, in: nil, precision: 9)
985
+ # - Time.new(year = nil, mon = nil, mday = nil, hour = nil, min = nil, sec = nil, zone = nil, in: nil, precision: 9)
841
986
  # -->
842
- # Returns a new Time object based on the given arguments, by default in the
987
+ # Returns a new `Time` object based on the given arguments, by default in the
843
988
  # local timezone.
844
989
  #
845
990
  # With no positional arguments, returns the value of Time.now:
846
991
  #
847
992
  # Time.new # => 2021-04-24 17:27:46.0512465 -0500
848
993
  #
849
- # With one string argument that represents a time, returns a new Time object
994
+ # With one string argument that represents a time, returns a new `Time` object
850
995
  # based on the given argument, in the local timezone.
851
996
  #
852
997
  # Time.new('2000-12-31 23:59:59.5') # => 2000-12-31 23:59:59.5 -0600
@@ -855,7 +1000,7 @@ class Time < Object
855
1000
  # Time.new('2000-12-31 23:59:59.5') # => 2000-12-31 23:59:59.5 -0600
856
1001
  # Time.new('2000-12-31 23:59:59.56789', precision: 3) # => 2000-12-31 23:59:59.567 -0600
857
1002
  #
858
- # With one to six arguments, returns a new Time object based on the given
1003
+ # With one to six arguments, returns a new `Time` object based on the given
859
1004
  # arguments, in the local timezone.
860
1005
  #
861
1006
  # Time.new(2000, 1, 2, 3, 4, 5) # => 2000-01-02 03:04:05 -0600
@@ -918,8 +1063,8 @@ class Time < Object
918
1063
  #
919
1064
  #
920
1065
  # When positional argument `zone` or keyword argument `in:` is given, the new
921
- # Time object is in the specified timezone. For the forms of argument `zone`,
922
- # see [Timezone Specifiers](rdoc-ref:timezones.rdoc):
1066
+ # `Time` object is in the specified timezone. For the forms of argument `zone`,
1067
+ # see [Timezone Specifiers](rdoc-ref:Time@Timezone+Specifiers):
923
1068
  #
924
1069
  # Time.new(2000, 1, 1, 0, 0, 0, '+12:00')
925
1070
  # # => 2000-01-01 00:00:00 +1200
@@ -928,9 +1073,15 @@ class Time < Object
928
1073
  # Time.new(in: '-12:00')
929
1074
  # # => 2022-08-23 08:49:26.1941467 -1200
930
1075
  #
1076
+ # Since `in:` keyword argument just provides the default, so if the first
1077
+ # argument in single string form contains time zone information, this keyword
1078
+ # argument will be silently ignored.
1079
+ #
1080
+ # Time.new('2000-01-01 00:00:00 +0100', in: '-0500').utc_offset # => 3600
1081
+ #
931
1082
  # * `precision`: maximum effective digits in sub-second part, default is 9.
932
- # More digits will be truncated, as other operations of Time. Ignored unless
933
- # the first argument is a string.
1083
+ # More digits will be truncated, as other operations of `Time`. Ignored
1084
+ # unless the first argument is a string.
934
1085
  #
935
1086
  def initialize: (?Integer? year, ?Integer? month, ?Integer? day, ?Integer? hour, ?Integer? min, ?Numeric? sec, ?String | Integer | nil) -> void
936
1087
  | (?Integer? year, ?Integer? month, ?Integer? day, ?Integer? hour, ?Integer? min, ?Numeric? sec, in: String | Integer | nil) -> void
@@ -965,8 +1116,6 @@ class Time < Object
965
1116
  # t.zone # => "Central Daylight Time"
966
1117
  # t.dst? # => true
967
1118
  #
968
- # Time#isdst is an alias for Time#dst?.
969
- #
970
1119
  def isdst: () -> bool
971
1120
 
972
1121
  # <!--
@@ -977,20 +1126,20 @@ class Time < Object
977
1126
  # With no argument given:
978
1127
  #
979
1128
  # * Returns `self` if `self` is a local time.
980
- # * Otherwise returns a new Time in the user's local timezone:
1129
+ # * Otherwise returns a new `Time` in the user's local timezone:
981
1130
  #
982
1131
  # t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
983
1132
  # t.localtime # => 2000-01-01 14:15:01 -0600
984
1133
  #
985
1134
  #
986
- # With argument `zone` given, returns the new Time object created by converting
987
- # `self` to the given time zone:
1135
+ # With argument `zone` given, returns the new `Time` object created by
1136
+ # converting `self` to the given time zone:
988
1137
  #
989
1138
  # t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
990
1139
  # t.localtime("-09:00") # => 2000-01-01 11:15:01 -0900
991
1140
  #
992
1141
  # For forms of argument `zone`, see [Timezone
993
- # Specifiers](rdoc-ref:timezones.rdoc).
1142
+ # Specifiers](rdoc-ref:Time@Timezone+Specifiers).
994
1143
  #
995
1144
  def localtime: (?String utc_offset) -> Time
996
1145
 
@@ -1004,8 +1153,6 @@ class Time < Object
1004
1153
  # # => 2000-01-02 03:04:05 +000006
1005
1154
  # t.mday # => 2
1006
1155
  #
1007
- # Time#day is an alias for Time#mday.
1008
- #
1009
1156
  # Related: Time#year, Time#hour, Time#min.
1010
1157
  #
1011
1158
  def mday: () -> Integer
@@ -1034,8 +1181,6 @@ class Time < Object
1034
1181
  # # => 2000-01-02 03:04:05 +000006
1035
1182
  # t.mon # => 1
1036
1183
  #
1037
- # Time#month is an alias for Time#mday.
1038
- #
1039
1184
  # Related: Time#year, Time#hour, Time#min.
1040
1185
  #
1041
1186
  def mon: () -> Integer
@@ -1062,15 +1207,13 @@ class Time < Object
1062
1207
  #
1063
1208
  # Related: Time#subsec (returns exact subseconds).
1064
1209
  #
1065
- # Time#tv_nsec is an alias for Time#usec.
1066
- #
1067
1210
  def nsec: () -> Integer
1068
1211
 
1069
1212
  # <!--
1070
1213
  # rdoc-file=time.c
1071
1214
  # - round(ndigits = 0) -> new_time
1072
1215
  # -->
1073
- # Returns a new Time object whose numeric value is that of `self`, with its
1216
+ # Returns a new `Time` object whose numeric value is that of `self`, with its
1074
1217
  # seconds value rounded to precision `ndigits`:
1075
1218
  #
1076
1219
  # t = Time.utc(2010, 3, 30, 5, 43, 25.123456789r)
@@ -1188,7 +1331,7 @@ class Time < Object
1188
1331
  # # [sec, min, hour, day, mon, year, wday, yday, dst?, zone]
1189
1332
  #
1190
1333
  # The returned array is suitable for use as an argument to Time.utc or
1191
- # Time.local to create a new Time object.
1334
+ # Time.local to create a new `Time` object.
1192
1335
  #
1193
1336
  def to_a: () -> [ Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, bool, String ]
1194
1337
 
@@ -1223,8 +1366,6 @@ class Time < Object
1223
1366
  # Time.utc(1950, 1, 1, 0, 0, 0).to_i # => -631152000
1224
1367
  # Time.utc(1990, 1, 1, 0, 0, 0).to_i # => 631152000
1225
1368
  #
1226
- # Time#tv_sec is an alias for Time#to_i.
1227
- #
1228
1369
  # Related: Time#to_f Time#to_r.
1229
1370
  #
1230
1371
  def to_i: () -> Integer
@@ -1283,8 +1424,6 @@ class Time < Object
1283
1424
  #
1284
1425
  # Related: Time#subsec (returns exact subseconds).
1285
1426
  #
1286
- # Time#tv_nsec is an alias for Time#usec.
1287
- #
1288
1427
  def tv_nsec: () -> Integer
1289
1428
 
1290
1429
  # <!-- rdoc-file=time.c -->
@@ -1296,8 +1435,6 @@ class Time < Object
1296
1435
  # Time.utc(1950, 1, 1, 0, 0, 0).to_i # => -631152000
1297
1436
  # Time.utc(1990, 1, 1, 0, 0, 0).to_i # => 631152000
1298
1437
  #
1299
- # Time#tv_sec is an alias for Time#to_i.
1300
- #
1301
1438
  # Related: Time#to_f Time#to_r.
1302
1439
  #
1303
1440
  def tv_sec: () -> Integer
@@ -1314,8 +1451,6 @@ class Time < Object
1314
1451
  #
1315
1452
  # Related: Time#subsec (returns exact subseconds).
1316
1453
  #
1317
- # Time#tv_usec is an alias for Time#usec.
1318
- #
1319
1454
  def tv_usec: () -> Integer
1320
1455
 
1321
1456
  # <!-- rdoc-file=time.c -->
@@ -1327,8 +1462,6 @@ class Time < Object
1327
1462
  #
1328
1463
  # Related: Time#subsec (returns exact subseconds).
1329
1464
  #
1330
- # Time#tv_usec is an alias for Time#usec.
1331
- #
1332
1465
  def usec: () -> Integer
1333
1466
 
1334
1467
  # <!-- rdoc-file=time.c -->
@@ -1339,9 +1472,7 @@ class Time < Object
1339
1472
  # t.utc # => 2000-01-01 06:00:00 UTC
1340
1473
  # t.utc? # => true
1341
1474
  #
1342
- # Time#gmtime is an alias for Time#utc.
1343
- #
1344
- # Related: Time#getutc (returns a new converted Time object).
1475
+ # Related: Time#getutc (returns a new converted `Time` object).
1345
1476
  #
1346
1477
  def utc: () -> Time
1347
1478
 
@@ -1358,8 +1489,6 @@ class Time < Object
1358
1489
  # # => 2000-01-01 20:15:01 UTC
1359
1490
  # utc.utc? # => true
1360
1491
  #
1361
- # Time#gmt? is an alias for Time#utc?.
1362
- #
1363
1492
  # Related: Time.utc.
1364
1493
  #
1365
1494
  def utc?: () -> bool
@@ -1370,8 +1499,6 @@ class Time < Object
1370
1499
  # Time.utc(2000, 1, 1).utc_offset # => 0
1371
1500
  # Time.local(2000, 1, 1).utc_offset # => -21600 # -6*3600, or minus six hours.
1372
1501
  #
1373
- # Time#gmt_offset and Time#gmtoff are aliases for Time#utc_offset.
1374
- #
1375
1502
  def utc_offset: () -> Integer
1376
1503
 
1377
1504
  # <!--
@@ -1440,7 +1567,7 @@ class Time < Object
1440
1567
  def zone: () -> String
1441
1568
 
1442
1569
  # <!-- rdoc-file=time.c -->
1443
- # Like Time.utc, except that the returned Time object has the local timezone,
1570
+ # Like Time.utc, except that the returned `Time` object has the local timezone,
1444
1571
  # not the UTC timezone:
1445
1572
  #
1446
1573
  # # With seven arguments.
@@ -1461,8 +1588,6 @@ class Time < Object
1461
1588
  # Time.utc(2000, 1, 1).utc_offset # => 0
1462
1589
  # Time.local(2000, 1, 1).utc_offset # => -21600 # -6*3600, or minus six hours.
1463
1590
  #
1464
- # Time#gmt_offset and Time#gmtoff are aliases for Time#utc_offset.
1465
- #
1466
1591
  def gmtoff: () -> Integer
1467
1592
 
1468
1593
  # <!-- rdoc-file=time.c -->
@@ -1472,8 +1597,6 @@ class Time < Object
1472
1597
  # # => 2000-01-02 03:04:05 +000006
1473
1598
  # t.mon # => 1
1474
1599
  #
1475
- # Time#month is an alias for Time#mday.
1476
- #
1477
1600
  # Related: Time#year, Time#hour, Time#min.
1478
1601
  #
1479
1602
  def month: () -> Integer
@@ -1482,7 +1605,7 @@ class Time < Object
1482
1605
  # rdoc-file=time.c
1483
1606
  # - floor(ndigits = 0) -> new_time
1484
1607
  # -->
1485
- # Returns a new Time object whose numerical value is less than or equal to
1608
+ # Returns a new `Time` object whose numerical value is less than or equal to
1486
1609
  # `self` with its seconds truncated to precision `ndigits`:
1487
1610
  #
1488
1611
  # t = Time.utc(2010, 3, 30, 5, 43, 25.123456789r)
@@ -1509,7 +1632,7 @@ class Time < Object
1509
1632
  # rdoc-file=time.c
1510
1633
  # - ceil(ndigits = 0) -> new_time
1511
1634
  # -->
1512
- # Returns a new Time object whose numerical value is greater than or equal to
1635
+ # Returns a new `Time` object whose numerical value is greater than or equal to
1513
1636
  # `self` with its seconds truncated to precision `ndigits`:
1514
1637
  #
1515
1638
  # t = Time.utc(2010, 3, 30, 5, 43, 25.123456789r)