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.
- checksums.yaml +4 -4
- data/.github/workflows/comments.yml +2 -5
- data/.github/workflows/ruby.yml +7 -8
- data/.github/workflows/typecheck.yml +37 -0
- data/CHANGELOG.md +50 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +11 -11
- data/Steepfile +2 -2
- data/core/array.rbs +19 -49
- data/core/basic_object.rbs +2 -2
- data/core/comparable.rbs +17 -8
- data/core/complex.rbs +82 -43
- data/core/data.rbs +2 -4
- data/core/dir.rbs +635 -295
- data/core/enumerable.rbs +11 -18
- data/core/enumerator.rbs +37 -31
- data/core/errors.rbs +4 -0
- data/core/false_class.rbs +34 -15
- data/core/fiber.rbs +23 -0
- data/core/file.rbs +329 -120
- data/core/float.rbs +17 -32
- data/core/gc.rbs +17 -11
- data/core/hash.rbs +22 -44
- data/core/integer.rbs +82 -113
- data/core/io/buffer.rbs +90 -47
- data/core/io.rbs +39 -116
- data/core/kernel.rbs +442 -489
- data/core/match_data.rbs +55 -56
- data/core/module.rbs +45 -1
- data/core/nil_class.rbs +98 -35
- data/core/numeric.rbs +22 -32
- data/core/object_space/weak_key_map.rbs +102 -0
- data/core/process.rbs +1242 -655
- data/core/ractor.rbs +139 -120
- data/core/range.rbs +100 -4
- data/core/rational.rbs +0 -4
- data/core/rbs/unnamed/argf.rbs +16 -8
- data/core/rbs/unnamed/env_class.rbs +0 -24
- data/core/refinement.rbs +8 -0
- data/core/regexp.rbs +1149 -598
- data/core/ruby_vm.rbs +126 -12
- data/core/rubygems/platform.rbs +9 -0
- data/core/rubygems/rubygems.rbs +1 -1
- data/core/rubygems/version.rbs +5 -1
- data/core/set.rbs +20 -22
- data/core/signal.rbs +4 -4
- data/core/string.rbs +283 -230
- data/core/string_io.rbs +2 -14
- data/core/struct.rbs +404 -24
- data/core/symbol.rbs +1 -19
- data/core/thread.rbs +29 -12
- data/core/time.rbs +227 -104
- data/core/trace_point.rbs +2 -5
- data/core/true_class.rbs +54 -21
- data/core/warning.rbs +14 -11
- data/docs/data_and_struct.md +29 -0
- data/docs/syntax.md +3 -5
- data/docs/tools.md +1 -0
- data/ext/rbs_extension/lexer.c +643 -559
- data/ext/rbs_extension/lexer.re +5 -1
- data/ext/rbs_extension/parser.c +12 -3
- data/ext/rbs_extension/unescape.c +7 -47
- data/lib/rbs/cli/diff.rb +4 -1
- data/lib/rbs/cli/validate.rb +280 -0
- data/lib/rbs/cli.rb +2 -194
- data/lib/rbs/collection/config.rb +5 -6
- data/lib/rbs/collection/sources/git.rb +1 -1
- data/lib/rbs/collection.rb +1 -0
- data/lib/rbs/diff.rb +7 -4
- data/lib/rbs/errors.rb +11 -0
- data/lib/rbs/test/errors.rb +4 -1
- data/lib/rbs/test/guaranteed.rb +2 -3
- data/lib/rbs/test/type_check.rb +15 -10
- data/lib/rbs/test.rb +3 -3
- data/lib/rbs/types.rb +29 -0
- data/lib/rbs/unit_test/convertibles.rb +176 -0
- data/lib/rbs/unit_test/spy.rb +136 -0
- data/lib/rbs/unit_test/type_assertions.rb +341 -0
- data/lib/rbs/unit_test/with_aliases.rb +143 -0
- data/lib/rbs/unit_test.rb +6 -0
- data/lib/rbs/version.rb +1 -1
- data/sig/cli/validate.rbs +43 -0
- data/sig/diff.rbs +3 -1
- data/sig/errors.rbs +8 -0
- data/sig/rbs.rbs +1 -1
- data/sig/test/errors.rbs +52 -0
- data/sig/test/guranteed.rbs +9 -0
- data/sig/test/type_check.rbs +19 -0
- data/sig/test.rbs +82 -0
- data/sig/types.rbs +6 -1
- data/sig/unit_test/convertibles.rbs +154 -0
- data/sig/unit_test/spy.rbs +28 -0
- data/sig/unit_test/type_assertions.rbs +194 -0
- data/sig/unit_test/with_aliases.rbs +136 -0
- data/stdlib/base64/0/base64.rbs +307 -45
- data/stdlib/bigdecimal/0/big_decimal.rbs +35 -15
- data/stdlib/coverage/0/coverage.rbs +2 -2
- data/stdlib/csv/0/csv.rbs +25 -55
- data/stdlib/date/0/date.rbs +1 -43
- data/stdlib/date/0/date_time.rbs +1 -13
- data/stdlib/delegate/0/delegator.rbs +186 -0
- data/stdlib/delegate/0/kernel.rbs +47 -0
- data/stdlib/delegate/0/simple_delegator.rbs +98 -0
- data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -1
- data/stdlib/erb/0/erb.rbs +2 -2
- data/stdlib/fileutils/0/fileutils.rbs +0 -19
- data/stdlib/io-console/0/io-console.rbs +12 -1
- data/stdlib/ipaddr/0/ipaddr.rbs +2 -1
- data/stdlib/json/0/json.rbs +320 -81
- data/stdlib/logger/0/logger.rbs +9 -5
- data/stdlib/monitor/0/monitor.rbs +78 -0
- data/stdlib/net-http/0/net-http.rbs +1880 -543
- data/stdlib/objspace/0/objspace.rbs +19 -13
- data/stdlib/openssl/0/openssl.rbs +508 -127
- data/stdlib/optparse/0/optparse.rbs +25 -11
- data/stdlib/pathname/0/pathname.rbs +1 -1
- data/stdlib/pp/0/pp.rbs +2 -5
- data/stdlib/prettyprint/0/prettyprint.rbs +2 -2
- data/stdlib/pstore/0/pstore.rbs +2 -4
- data/stdlib/rdoc/0/comment.rbs +1 -2
- data/stdlib/resolv/0/resolv.rbs +4 -2
- data/stdlib/socket/0/socket.rbs +2 -2
- data/stdlib/socket/0/unix_socket.rbs +2 -2
- data/stdlib/strscan/0/string_scanner.rbs +3 -2
- data/stdlib/tempfile/0/tempfile.rbs +1 -1
- data/stdlib/uri/0/common.rbs +245 -123
- metadata +23 -4
- data/lib/rbs/test/spy.rb +0 -6
data/stdlib/csv/0/csv.rbs
CHANGED
@@ -1,15 +1,6 @@
|
|
1
1
|
# <!-- rdoc-file=lib/csv.rb -->
|
2
2
|
# ## CSV
|
3
3
|
#
|
4
|
-
# ### In a Hurry?
|
5
|
-
#
|
6
|
-
# If you are familiar with CSV data and have a particular task in mind, you may
|
7
|
-
# want to go directly to the:
|
8
|
-
# * [Recipes for CSV](doc/csv/recipes/recipes_rdoc.html).
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# Otherwise, read on here, about the API: classes, methods, and constants.
|
12
|
-
#
|
13
4
|
# ### CSV Data
|
14
5
|
#
|
15
6
|
# CSV (comma-separated values) data is a text representation of a table:
|
@@ -380,15 +371,6 @@
|
|
380
371
|
# feature will be used as the line-ending translation can cause problems with
|
381
372
|
# resetting the document position to where it was before the read ahead.
|
382
373
|
#
|
383
|
-
# ---
|
384
|
-
#
|
385
|
-
# Raises an exception if the given value is not String-convertible:
|
386
|
-
# row_sep = BasicObject.new
|
387
|
-
# # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>)
|
388
|
-
# CSV.generate(ary, row_sep: row_sep)
|
389
|
-
# # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>)
|
390
|
-
# CSV.parse(str, row_sep: row_sep)
|
391
|
-
#
|
392
374
|
# ###### Option `col_sep`
|
393
375
|
#
|
394
376
|
# Specifies the String field separator to be used for both parsing and
|
@@ -445,13 +427,6 @@
|
|
445
427
|
# # Raises ArgumentError (:col_sep must be 1 or more characters: "")
|
446
428
|
# CSV.parse("foo0\nbar1\nbaz2\n", col_sep: col_sep)
|
447
429
|
#
|
448
|
-
# Raises an exception if the given value is not String-convertible:
|
449
|
-
# col_sep = BasicObject.new
|
450
|
-
# # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>)
|
451
|
-
# CSV.generate(line, col_sep: col_sep)
|
452
|
-
# # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>)
|
453
|
-
# CSV.parse(str, col_sep: col_sep)
|
454
|
-
#
|
455
430
|
# ###### Option `quote_char`
|
456
431
|
#
|
457
432
|
# Specifies the character (String of length 1) used used to quote fields in both
|
@@ -832,13 +807,14 @@
|
|
832
807
|
#
|
833
808
|
# ###### Option `liberal_parsing`
|
834
809
|
#
|
835
|
-
# Specifies the boolean value that determines whether CSV will attempt
|
836
|
-
# input not conformant with RFC 4180, such as double quotes in unquoted
|
810
|
+
# Specifies the boolean or hash value that determines whether CSV will attempt
|
811
|
+
# to parse input not conformant with RFC 4180, such as double quotes in unquoted
|
812
|
+
# fields.
|
837
813
|
#
|
838
814
|
# Default value:
|
839
815
|
# CSV::DEFAULT_OPTIONS.fetch(:liberal_parsing) # => false
|
840
816
|
#
|
841
|
-
# For
|
817
|
+
# For the next two examples:
|
842
818
|
# str = 'is,this "three, or four",fields'
|
843
819
|
#
|
844
820
|
# Without `liberal_parsing`:
|
@@ -849,6 +825,24 @@
|
|
849
825
|
# ary = CSV.parse_line(str, liberal_parsing: true)
|
850
826
|
# ary # => ["is", "this \"three", " or four\"", "fields"]
|
851
827
|
#
|
828
|
+
# Use the `backslash_quote` sub-option to parse values that use a backslash to
|
829
|
+
# escape a double-quote character. This causes the parser to treat `\"` as if
|
830
|
+
# it were `""`.
|
831
|
+
#
|
832
|
+
# For the next two examples:
|
833
|
+
# str = 'Show,"Harry \"Handcuff\" Houdini, the one and only","Tampa Theater"'
|
834
|
+
#
|
835
|
+
# With `liberal_parsing`, but without the `backslash_quote` sub-option:
|
836
|
+
# # Incorrect interpretation of backslash; incorrectly interprets the quoted comma as a field separator.
|
837
|
+
# ary = CSV.parse_line(str, liberal_parsing: true)
|
838
|
+
# ary # => ["Show", "\"Harry \\\"Handcuff\\\" Houdini", " the one and only\"", "Tampa Theater"]
|
839
|
+
# puts ary[1] # => "Harry \"Handcuff\" Houdini
|
840
|
+
#
|
841
|
+
# With `liberal_parsing` and its `backslash_quote` sub-option:
|
842
|
+
# ary = CSV.parse_line(str, liberal_parsing: { backslash_quote: true })
|
843
|
+
# ary # => ["Show", "Harry \"Handcuff\" Houdini, the one and only", "Tampa Theater"]
|
844
|
+
# puts ary[1] # => Harry "Handcuff" Houdini, the one and only
|
845
|
+
#
|
852
846
|
# ###### Option `nil_value`
|
853
847
|
#
|
854
848
|
# Specifies the object that is to be substituted for each null (no-text) field.
|
@@ -988,15 +982,6 @@
|
|
988
982
|
# feature will be used as the line-ending translation can cause problems with
|
989
983
|
# resetting the document position to where it was before the read ahead.
|
990
984
|
#
|
991
|
-
# ---
|
992
|
-
#
|
993
|
-
# Raises an exception if the given value is not String-convertible:
|
994
|
-
# row_sep = BasicObject.new
|
995
|
-
# # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>)
|
996
|
-
# CSV.generate(ary, row_sep: row_sep)
|
997
|
-
# # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>)
|
998
|
-
# CSV.parse(str, row_sep: row_sep)
|
999
|
-
#
|
1000
985
|
# ###### Option `col_sep`
|
1001
986
|
#
|
1002
987
|
# Specifies the String field separator to be used for both parsing and
|
@@ -1053,13 +1038,6 @@
|
|
1053
1038
|
# # Raises ArgumentError (:col_sep must be 1 or more characters: "")
|
1054
1039
|
# CSV.parse("foo0\nbar1\nbaz2\n", col_sep: col_sep)
|
1055
1040
|
#
|
1056
|
-
# Raises an exception if the given value is not String-convertible:
|
1057
|
-
# col_sep = BasicObject.new
|
1058
|
-
# # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>)
|
1059
|
-
# CSV.generate(line, col_sep: col_sep)
|
1060
|
-
# # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>)
|
1061
|
-
# CSV.parse(str, col_sep: col_sep)
|
1062
|
-
#
|
1063
1041
|
# ###### Option `quote_char`
|
1064
1042
|
#
|
1065
1043
|
# Specifies the character (String of length 1) used used to quote fields in both
|
@@ -1124,7 +1102,7 @@
|
|
1124
1102
|
#
|
1125
1103
|
# With `write_headers`":
|
1126
1104
|
# CSV.open(file_path,'w',
|
1127
|
-
# :write_headers=> true,
|
1105
|
+
# :write_headers => true,
|
1128
1106
|
# :headers => ['Name','Value']
|
1129
1107
|
# ) do |csv|
|
1130
1108
|
# csv << ['foo', '0']
|
@@ -1192,14 +1170,6 @@
|
|
1192
1170
|
#
|
1193
1171
|
# See also [Write Converters](#class-CSV-label-Write+Converters)
|
1194
1172
|
#
|
1195
|
-
# ---
|
1196
|
-
#
|
1197
|
-
# Raises an exception if the converter returns a value that is neither `nil` nor
|
1198
|
-
# String-convertible:
|
1199
|
-
# bad_converter = proc {|field| BasicObject.new }
|
1200
|
-
# # Raises NoMethodError (undefined method `is_a?' for #<BasicObject:>)
|
1201
|
-
# CSV.generate_line(['a', 'b', 'c'], write_converters: bad_converter)#
|
1202
|
-
#
|
1203
1173
|
# ###### Option `write_nil_value`
|
1204
1174
|
#
|
1205
1175
|
# Specifies the object that is to be substituted for each `nil`-valued field.
|
@@ -1737,8 +1707,8 @@ class CSV < Object
|
|
1737
1707
|
#
|
1738
1708
|
# Arguments:
|
1739
1709
|
# * Argument `path_or_io` must be a file path or an IO stream.
|
1740
|
-
# * Argument `mode`, if given, must be a File mode See [
|
1741
|
-
#
|
1710
|
+
# * Argument `mode`, if given, must be a File mode. See [Access
|
1711
|
+
# Modes](rdoc-ref:File@Access+Modes).
|
1742
1712
|
# * Arguments `**options` must be keyword options. See [Options for
|
1743
1713
|
# Parsing](#class-CSV-label-Options+for+Parsing).
|
1744
1714
|
# * This method optionally accepts an additional `:encoding` option that you
|
data/stdlib/date/0/date.rbs
CHANGED
@@ -92,8 +92,6 @@ class Date
|
|
92
92
|
#
|
93
93
|
# See argument [start](rdoc-ref:calendars.rdoc@Argument+start).
|
94
94
|
#
|
95
|
-
# Date.civil is an alias for Date.new.
|
96
|
-
#
|
97
95
|
# Related: Date.jd.
|
98
96
|
#
|
99
97
|
def initialize: (?Integer year, ?Integer month, ?Integer mday, ?Integer start) -> void
|
@@ -192,8 +190,6 @@ class Date
|
|
192
190
|
#
|
193
191
|
# See argument [limit](rdoc-ref:Date@Argument+limit).
|
194
192
|
#
|
195
|
-
# Date._rfc822 is an alias for Date._rfc2822.
|
196
|
-
#
|
197
193
|
# Related: Date.rfc2822 (returns a Date object).
|
198
194
|
#
|
199
195
|
def self._rfc2822: (String str) -> Hash[Symbol, Integer | String]
|
@@ -230,8 +226,6 @@ class Date
|
|
230
226
|
#
|
231
227
|
# See argument [limit](rdoc-ref:Date@Argument+limit).
|
232
228
|
#
|
233
|
-
# Date._rfc822 is an alias for Date._rfc2822.
|
234
|
-
#
|
235
229
|
# Related: Date.rfc2822 (returns a Date object).
|
236
230
|
#
|
237
231
|
def self._rfc822: (String str) -> Hash[Symbol, Integer | String]
|
@@ -335,8 +329,6 @@ class Date
|
|
335
329
|
# Date.gregorian_leap?(2000) # => true
|
336
330
|
# Date.gregorian_leap?(2001) # => false
|
337
331
|
#
|
338
|
-
# Date.leap? is an alias for Date.gregorian_leap?.
|
339
|
-
#
|
340
332
|
# Related: Date.julian_leap?.
|
341
333
|
#
|
342
334
|
def self.gregorian_leap?: (Integer year) -> bool
|
@@ -465,8 +457,6 @@ class Date
|
|
465
457
|
# Date.gregorian_leap?(2000) # => true
|
466
458
|
# Date.gregorian_leap?(2001) # => false
|
467
459
|
#
|
468
|
-
# Date.leap? is an alias for Date.gregorian_leap?.
|
469
|
-
#
|
470
460
|
# Related: Date.julian_leap?.
|
471
461
|
#
|
472
462
|
def self.leap?: (Integer year) -> bool
|
@@ -533,7 +523,7 @@ class Date
|
|
533
523
|
#
|
534
524
|
# Related: Date._parse (returns a hash).
|
535
525
|
#
|
536
|
-
def self.parse: (String str, ?boolish complete, ?Integer start) -> Date
|
526
|
+
def self.parse: (?String str, ?boolish complete, ?Integer start) -> Date
|
537
527
|
|
538
528
|
# <!--
|
539
529
|
# rdoc-file=ext/date/date_core.c
|
@@ -553,8 +543,6 @@ class Date
|
|
553
543
|
# * Argument [limit](rdoc-ref:Date@Argument+limit).
|
554
544
|
#
|
555
545
|
#
|
556
|
-
# Date.rfc822 is an alias for Date.rfc2822.
|
557
|
-
#
|
558
546
|
# Related: Date._rfc2822 (returns a hash).
|
559
547
|
#
|
560
548
|
def self.rfc2822: (String str, ?Integer start) -> Date
|
@@ -598,8 +586,6 @@ class Date
|
|
598
586
|
# * Argument [limit](rdoc-ref:Date@Argument+limit).
|
599
587
|
#
|
600
588
|
#
|
601
|
-
# Date.rfc822 is an alias for Date.rfc2822.
|
602
|
-
#
|
603
589
|
# Related: Date._rfc2822 (returns a hash).
|
604
590
|
#
|
605
591
|
def self.rfc822: (String str, ?Integer start) -> Date
|
@@ -656,8 +642,6 @@ class Date
|
|
656
642
|
#
|
657
643
|
# See argument [start](rdoc-ref:calendars.rdoc@Argument+start).
|
658
644
|
#
|
659
|
-
# Date.valid_date? is an alias for Date.valid_civil?.
|
660
|
-
#
|
661
645
|
# Related: Date.jd, Date.new.
|
662
646
|
#
|
663
647
|
def self.valid_civil?: (Integer year, Integer month, Integer mday, ?Integer start) -> bool
|
@@ -693,8 +677,6 @@ class Date
|
|
693
677
|
#
|
694
678
|
# See argument [start](rdoc-ref:calendars.rdoc@Argument+start).
|
695
679
|
#
|
696
|
-
# Date.valid_date? is an alias for Date.valid_civil?.
|
697
|
-
#
|
698
680
|
# Related: Date.jd, Date.new.
|
699
681
|
#
|
700
682
|
def self.valid_date?: (Integer year, Integer month, Integer mday, ?Integer start) -> bool
|
@@ -962,8 +944,6 @@ class Date
|
|
962
944
|
#
|
963
945
|
# See [asctime](https://linux.die.net/man/3/asctime).
|
964
946
|
#
|
965
|
-
# Date#ctime is an alias for Date#asctime.
|
966
|
-
#
|
967
947
|
def asctime: () -> String
|
968
948
|
|
969
949
|
# <!-- rdoc-file=ext/date/date_core.c -->
|
@@ -975,8 +955,6 @@ class Date
|
|
975
955
|
#
|
976
956
|
# See [asctime](https://linux.die.net/man/3/asctime).
|
977
957
|
#
|
978
|
-
# Date#ctime is an alias for Date#asctime.
|
979
|
-
#
|
980
958
|
def ctime: () -> String
|
981
959
|
|
982
960
|
# <!--
|
@@ -1016,8 +994,6 @@ class Date
|
|
1016
994
|
#
|
1017
995
|
# Date.new(2001, 2, 3).mday # => 3
|
1018
996
|
#
|
1019
|
-
# Date#day is an alias for Date#mday.
|
1020
|
-
#
|
1021
997
|
def day: () -> Integer
|
1022
998
|
|
1023
999
|
# <!--
|
@@ -1131,8 +1107,6 @@ class Date
|
|
1131
1107
|
#
|
1132
1108
|
# Date.new(2001, 2, 3).iso8601 # => "2001-02-03"
|
1133
1109
|
#
|
1134
|
-
# Date#xmlschema is an alias for Date#iso8601.
|
1135
|
-
#
|
1136
1110
|
def iso8601: () -> String
|
1137
1111
|
|
1138
1112
|
# <!--
|
@@ -1216,8 +1190,6 @@ class Date
|
|
1216
1190
|
#
|
1217
1191
|
# Date.new(2001, 2, 3).mday # => 3
|
1218
1192
|
#
|
1219
|
-
# Date#day is an alias for Date#mday.
|
1220
|
-
#
|
1221
1193
|
def mday: () -> Integer
|
1222
1194
|
|
1223
1195
|
# <!--
|
@@ -1240,8 +1212,6 @@ class Date
|
|
1240
1212
|
#
|
1241
1213
|
# Date.new(2001, 2, 3).mon # => 2
|
1242
1214
|
#
|
1243
|
-
# Date#month is an alias for Date#mon.
|
1244
|
-
#
|
1245
1215
|
def mon: () -> Integer
|
1246
1216
|
|
1247
1217
|
# <!--
|
@@ -1257,8 +1227,6 @@ class Date
|
|
1257
1227
|
#
|
1258
1228
|
# Date.new(2001, 2, 3).mon # => 2
|
1259
1229
|
#
|
1260
|
-
# Date#month is an alias for Date#mon.
|
1261
|
-
#
|
1262
1230
|
def month: () -> Integer
|
1263
1231
|
|
1264
1232
|
# <!--
|
@@ -1286,8 +1254,6 @@ class Date
|
|
1286
1254
|
# d.to_s # => "2001-02-03"
|
1287
1255
|
# d.next.to_s # => "2001-02-04"
|
1288
1256
|
#
|
1289
|
-
# Date#succ is an alias for Date#next.
|
1290
|
-
#
|
1291
1257
|
def next: () -> Date
|
1292
1258
|
|
1293
1259
|
# <!--
|
@@ -1347,8 +1313,6 @@ class Date
|
|
1347
1313
|
#
|
1348
1314
|
# Date.new(2001, 2, 3).rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
|
1349
1315
|
#
|
1350
|
-
# Date#rfc822 is an alias for Date#rfc2822.
|
1351
|
-
#
|
1352
1316
|
def rfc2822: () -> String
|
1353
1317
|
|
1354
1318
|
# <!--
|
@@ -1377,8 +1341,6 @@ class Date
|
|
1377
1341
|
# * Argument [limit](rdoc-ref:Date@Argument+limit).
|
1378
1342
|
#
|
1379
1343
|
#
|
1380
|
-
# Date.rfc822 is an alias for Date.rfc2822.
|
1381
|
-
#
|
1382
1344
|
# Related: Date._rfc2822 (returns a hash).
|
1383
1345
|
#
|
1384
1346
|
def rfc822: () -> String
|
@@ -1467,8 +1429,6 @@ class Date
|
|
1467
1429
|
# d.to_s # => "2001-02-03"
|
1468
1430
|
# d.next.to_s # => "2001-02-04"
|
1469
1431
|
#
|
1470
|
-
# Date#succ is an alias for Date#next.
|
1471
|
-
#
|
1472
1432
|
def succ: () -> Date
|
1473
1433
|
|
1474
1434
|
# <!--
|
@@ -1571,8 +1531,6 @@ class Date
|
|
1571
1531
|
#
|
1572
1532
|
# Date.new(2001, 2, 3).iso8601 # => "2001-02-03"
|
1573
1533
|
#
|
1574
|
-
# Date#xmlschema is an alias for Date#iso8601.
|
1575
|
-
#
|
1576
1534
|
def xmlschema: () -> String
|
1577
1535
|
|
1578
1536
|
# <!--
|
data/stdlib/date/0/date_time.rbs
CHANGED
@@ -468,8 +468,6 @@ class DateTime < Date
|
|
468
468
|
#
|
469
469
|
# DateTime.new(2001, 2, 3, 4, 5, 6).min # => 5
|
470
470
|
#
|
471
|
-
# Date#minute is an alias for Date#min.
|
472
|
-
#
|
473
471
|
def min: () -> Integer
|
474
472
|
|
475
473
|
# <!-- rdoc-file=ext/date/date_core.c -->
|
@@ -477,8 +475,6 @@ class DateTime < Date
|
|
477
475
|
#
|
478
476
|
# DateTime.new(2001, 2, 3, 4, 5, 6).min # => 5
|
479
477
|
#
|
480
|
-
# Date#minute is an alias for Date#min.
|
481
|
-
#
|
482
478
|
def minute: () -> Integer
|
483
479
|
|
484
480
|
# <!--
|
@@ -523,8 +519,6 @@ class DateTime < Date
|
|
523
519
|
#
|
524
520
|
# DateTime.new(2001, 2, 3, 4, 5, 6).sec # => 6
|
525
521
|
#
|
526
|
-
# Date#second is an alias for Date#sec.
|
527
|
-
#
|
528
522
|
def sec: () -> Integer
|
529
523
|
|
530
524
|
# <!--
|
@@ -536,8 +530,6 @@ class DateTime < Date
|
|
536
530
|
#
|
537
531
|
# DateTime.new(2001, 2, 3, 4, 5, 6.5).sec_fraction # => (1/2)
|
538
532
|
#
|
539
|
-
# Date#second_fraction is an alias for Date#sec_fraction.
|
540
|
-
#
|
541
533
|
def sec_fraction: () -> Rational
|
542
534
|
|
543
535
|
# <!-- rdoc-file=ext/date/date_core.c -->
|
@@ -545,8 +537,6 @@ class DateTime < Date
|
|
545
537
|
#
|
546
538
|
# DateTime.new(2001, 2, 3, 4, 5, 6).sec # => 6
|
547
539
|
#
|
548
|
-
# Date#second is an alias for Date#sec.
|
549
|
-
#
|
550
540
|
def second: () -> Integer
|
551
541
|
|
552
542
|
# <!-- rdoc-file=ext/date/date_core.c -->
|
@@ -555,8 +545,6 @@ class DateTime < Date
|
|
555
545
|
#
|
556
546
|
# DateTime.new(2001, 2, 3, 4, 5, 6.5).sec_fraction # => (1/2)
|
557
547
|
#
|
558
|
-
# Date#second_fraction is an alias for Date#sec_fraction.
|
559
|
-
#
|
560
548
|
def second_fraction: () -> Rational
|
561
549
|
|
562
550
|
# <!--
|
@@ -569,7 +557,7 @@ class DateTime < Date
|
|
569
557
|
# DateTime.now.strftime # => "2022-07-01T11:03:19-05:00"
|
570
558
|
#
|
571
559
|
# For other formats, see [Formats for Dates and
|
572
|
-
# Times](
|
560
|
+
# Times](rdoc-ref:strftime_formatting.rdoc):
|
573
561
|
#
|
574
562
|
def strftime: (?String format) -> String
|
575
563
|
|
@@ -0,0 +1,186 @@
|
|
1
|
+
# <!-- rdoc-file=lib/delegate.rb -->
|
2
|
+
# This library provides three different ways to delegate method calls to an
|
3
|
+
# object. The easiest to use is SimpleDelegator. Pass an object to the
|
4
|
+
# constructor and all methods supported by the object will be delegated. This
|
5
|
+
# object can be changed later.
|
6
|
+
#
|
7
|
+
# Going a step further, the top level DelegateClass method allows you to easily
|
8
|
+
# setup delegation through class inheritance. This is considerably more
|
9
|
+
# flexible and thus probably the most common use for this library.
|
10
|
+
#
|
11
|
+
# Finally, if you need full control over the delegation scheme, you can inherit
|
12
|
+
# from the abstract class Delegator and customize as needed. (If you find
|
13
|
+
# yourself needing this control, have a look at Forwardable which is also in the
|
14
|
+
# standard library. It may suit your needs better.)
|
15
|
+
#
|
16
|
+
# SimpleDelegator's implementation serves as a nice example of the use of
|
17
|
+
# Delegator:
|
18
|
+
#
|
19
|
+
# require 'delegate'
|
20
|
+
#
|
21
|
+
# class SimpleDelegator < Delegator
|
22
|
+
# def __getobj__
|
23
|
+
# @delegate_sd_obj # return object we are delegating to, required
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# def __setobj__(obj)
|
27
|
+
# @delegate_sd_obj = obj # change delegation object,
|
28
|
+
# # a feature we're providing
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# ## Notes
|
33
|
+
#
|
34
|
+
# Be advised, RDoc will not detect delegated methods.
|
35
|
+
#
|
36
|
+
class Delegator < BasicObject
|
37
|
+
def self.const_missing: (Symbol n) -> untyped
|
38
|
+
|
39
|
+
def self.delegating_block: (Symbol mid) -> Proc
|
40
|
+
|
41
|
+
def self.public_api: () -> untyped
|
42
|
+
|
43
|
+
public
|
44
|
+
|
45
|
+
# <!--
|
46
|
+
# rdoc-file=lib/delegate.rb
|
47
|
+
# - !()
|
48
|
+
# -->
|
49
|
+
# Delegates ! to the _*getobj*_
|
50
|
+
#
|
51
|
+
def !: () -> untyped
|
52
|
+
|
53
|
+
# <!--
|
54
|
+
# rdoc-file=lib/delegate.rb
|
55
|
+
# - !=(obj)
|
56
|
+
# -->
|
57
|
+
# Returns true if two objects are not considered of equal value.
|
58
|
+
#
|
59
|
+
def !=: (untyped obj) -> bool
|
60
|
+
|
61
|
+
# <!--
|
62
|
+
# rdoc-file=lib/delegate.rb
|
63
|
+
# - ==(obj)
|
64
|
+
# -->
|
65
|
+
# Returns true if two objects are considered of equal value.
|
66
|
+
#
|
67
|
+
def ==: (untyped obj) -> bool
|
68
|
+
|
69
|
+
# <!--
|
70
|
+
# rdoc-file=lib/delegate.rb
|
71
|
+
# - __getobj__()
|
72
|
+
# -->
|
73
|
+
# This method must be overridden by subclasses and should return the object
|
74
|
+
# method calls are being delegated to.
|
75
|
+
#
|
76
|
+
def __getobj__: () -> untyped
|
77
|
+
|
78
|
+
# <!--
|
79
|
+
# rdoc-file=lib/delegate.rb
|
80
|
+
# - __setobj__(obj)
|
81
|
+
# -->
|
82
|
+
# This method must be overridden by subclasses and change the object delegate to
|
83
|
+
# *obj*.
|
84
|
+
#
|
85
|
+
def __setobj__: (untyped obj) -> untyped
|
86
|
+
|
87
|
+
# <!--
|
88
|
+
# rdoc-file=lib/delegate.rb
|
89
|
+
# - eql?(obj)
|
90
|
+
# -->
|
91
|
+
# Returns true if two objects are considered of equal value.
|
92
|
+
#
|
93
|
+
def eql?: (untyped obj) -> bool
|
94
|
+
|
95
|
+
# <!--
|
96
|
+
# rdoc-file=lib/delegate.rb
|
97
|
+
# - freeze()
|
98
|
+
# -->
|
99
|
+
# :method: freeze Freeze both the object returned by _*getobj*_ and self.
|
100
|
+
#
|
101
|
+
def freeze: () -> self
|
102
|
+
|
103
|
+
# <!--
|
104
|
+
# rdoc-file=lib/delegate.rb
|
105
|
+
# - marshal_dump()
|
106
|
+
# -->
|
107
|
+
# Serialization support for the object returned by _*getobj*_.
|
108
|
+
#
|
109
|
+
def marshal_dump: () -> untyped
|
110
|
+
|
111
|
+
# <!--
|
112
|
+
# rdoc-file=lib/delegate.rb
|
113
|
+
# - marshal_load(data)
|
114
|
+
# -->
|
115
|
+
# Reinitializes delegation from a serialized object.
|
116
|
+
#
|
117
|
+
def marshal_load: (untyped data) -> void
|
118
|
+
|
119
|
+
# <!--
|
120
|
+
# rdoc-file=lib/delegate.rb
|
121
|
+
# - method_missing(m, *args, &block)
|
122
|
+
# -->
|
123
|
+
#
|
124
|
+
def method_missing: (Symbol m, *untyped args, **untyped) { (*untyped, **untyped) -> untyped } -> untyped
|
125
|
+
|
126
|
+
# <!--
|
127
|
+
# rdoc-file=lib/delegate.rb
|
128
|
+
# - methods(all=true)
|
129
|
+
# -->
|
130
|
+
# Returns the methods available to this delegate object as the union of this
|
131
|
+
# object's and _*getobj*_ methods.
|
132
|
+
#
|
133
|
+
def methods: (?boolish all) -> Array[Symbol]
|
134
|
+
|
135
|
+
# <!--
|
136
|
+
# rdoc-file=lib/delegate.rb
|
137
|
+
# - protected_methods(all=true)
|
138
|
+
# -->
|
139
|
+
# Returns the methods available to this delegate object as the union of this
|
140
|
+
# object's and _*getobj*_ protected methods.
|
141
|
+
#
|
142
|
+
def protected_methods: (?boolish all) -> Array[Symbol]
|
143
|
+
|
144
|
+
# <!--
|
145
|
+
# rdoc-file=lib/delegate.rb
|
146
|
+
# - public_methods(all=true)
|
147
|
+
# -->
|
148
|
+
# Returns the methods available to this delegate object as the union of this
|
149
|
+
# object's and _*getobj*_ public methods.
|
150
|
+
#
|
151
|
+
def public_methods: (?untyped all) -> Array[Symbol]
|
152
|
+
|
153
|
+
private
|
154
|
+
|
155
|
+
# <!--
|
156
|
+
# rdoc-file=lib/delegate.rb
|
157
|
+
# - new(obj)
|
158
|
+
# -->
|
159
|
+
# Pass in the *obj* to delegate method calls to. All methods supported by *obj*
|
160
|
+
# will be delegated to.
|
161
|
+
#
|
162
|
+
def initialize: (untyped obj) -> void
|
163
|
+
|
164
|
+
def initialize_clone: (self obj, ?freeze: bool?) -> self
|
165
|
+
|
166
|
+
def initialize_dup: (self obj) -> self
|
167
|
+
|
168
|
+
# <!--
|
169
|
+
# rdoc-file=lib/delegate.rb
|
170
|
+
# - respond_to_missing?(m, include_private)
|
171
|
+
# -->
|
172
|
+
# Checks for a method provided by this the delegate object by forwarding the
|
173
|
+
# call through _*getobj*_.
|
174
|
+
#
|
175
|
+
def respond_to_missing?: (Symbol m, bool include_private) -> bool
|
176
|
+
|
177
|
+
# <!--
|
178
|
+
# rdoc-file=lib/delegate.rb
|
179
|
+
# - target_respond_to?(target, m, include_private)
|
180
|
+
# -->
|
181
|
+
# Handle BasicObject instances
|
182
|
+
#
|
183
|
+
def target_respond_to?: (untyped target, Symbol m, bool include_private) -> bool
|
184
|
+
|
185
|
+
VERSION: String
|
186
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
%a{annotate:rdoc:skip}
|
2
|
+
class Object
|
3
|
+
# <!--
|
4
|
+
# rdoc-file=lib/delegate.rb
|
5
|
+
# - DelegateClass(superclass, &block)
|
6
|
+
# -->
|
7
|
+
# The primary interface to this library. Use to setup delegation when defining
|
8
|
+
# your class.
|
9
|
+
#
|
10
|
+
# class MyClass < DelegateClass(ClassToDelegateTo) # Step 1
|
11
|
+
# def initialize
|
12
|
+
# super(obj_of_ClassToDelegateTo) # Step 2
|
13
|
+
# end
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# or:
|
17
|
+
#
|
18
|
+
# MyClass = DelegateClass(ClassToDelegateTo) do # Step 1
|
19
|
+
# def initialize
|
20
|
+
# super(obj_of_ClassToDelegateTo) # Step 2
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# Here's a sample of use from Tempfile which is really a File object with a few
|
25
|
+
# special rules about storage location and when the File should be deleted.
|
26
|
+
# That makes for an almost textbook perfect example of how to use delegation.
|
27
|
+
#
|
28
|
+
# class Tempfile < DelegateClass(File)
|
29
|
+
# # constant and class member data initialization...
|
30
|
+
#
|
31
|
+
# def initialize(basename, tmpdir=Dir::tmpdir)
|
32
|
+
# # build up file path/name in var tmpname...
|
33
|
+
#
|
34
|
+
# @tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL, 0600)
|
35
|
+
#
|
36
|
+
# # ...
|
37
|
+
#
|
38
|
+
# super(@tmpfile)
|
39
|
+
#
|
40
|
+
# # below this point, all methods of File are supported...
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# # ...
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
def DelegateClass: (Class) -> Class
|
47
|
+
end
|