rbs 4.0.0.dev.4 → 4.0.0.dev.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.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +14 -14
- data/.github/workflows/bundle-update.yml +60 -0
- data/.github/workflows/c-check.yml +11 -8
- data/.github/workflows/comments.yml +3 -3
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/ruby.yml +17 -34
- data/.github/workflows/typecheck.yml +2 -2
- data/.github/workflows/valgrind.yml +42 -0
- data/.github/workflows/windows.yml +2 -2
- data/.rubocop.yml +1 -1
- data/README.md +1 -1
- data/Rakefile +32 -5
- data/config.yml +46 -0
- data/core/array.rbs +96 -46
- data/core/binding.rbs +0 -2
- data/core/builtin.rbs +2 -2
- data/core/comparable.rbs +13 -6
- data/core/complex.rbs +55 -41
- data/core/dir.rbs +4 -4
- data/core/encoding.rbs +7 -10
- data/core/enumerable.rbs +90 -3
- data/core/enumerator/arithmetic_sequence.rbs +70 -0
- data/core/enumerator.rbs +63 -1
- data/core/errno.rbs +8 -0
- data/core/errors.rbs +28 -1
- data/core/exception.rbs +2 -2
- data/core/fiber.rbs +40 -20
- data/core/file.rbs +108 -78
- data/core/file_test.rbs +1 -1
- data/core/float.rbs +225 -69
- data/core/gc.rbs +417 -281
- data/core/hash.rbs +1023 -727
- data/core/integer.rbs +104 -110
- data/core/io/buffer.rbs +21 -10
- data/core/io/wait.rbs +11 -33
- data/core/io.rbs +82 -19
- data/core/kernel.rbs +70 -59
- data/core/marshal.rbs +1 -1
- data/core/match_data.rbs +1 -1
- data/core/math.rbs +42 -3
- data/core/method.rbs +63 -27
- data/core/module.rbs +103 -26
- data/core/nil_class.rbs +3 -3
- data/core/numeric.rbs +43 -35
- data/core/object.rbs +3 -3
- data/core/object_space.rbs +21 -15
- data/core/pathname.rbs +1272 -0
- data/core/proc.rbs +30 -25
- data/core/process.rbs +4 -2
- data/core/ractor.rbs +361 -509
- data/core/random.rbs +17 -0
- data/core/range.rbs +113 -16
- data/core/rational.rbs +56 -85
- data/core/rbs/unnamed/argf.rbs +2 -2
- data/core/rbs/unnamed/env_class.rbs +1 -1
- data/core/rbs/unnamed/random.rbs +4 -113
- data/core/regexp.rbs +25 -20
- data/core/ruby.rbs +53 -0
- data/core/ruby_vm.rbs +6 -4
- data/core/rubygems/errors.rbs +3 -70
- data/core/rubygems/rubygems.rbs +11 -79
- data/core/rubygems/version.rbs +2 -3
- data/core/set.rbs +488 -359
- data/core/signal.rbs +24 -14
- data/core/string.rbs +3171 -1241
- data/core/struct.rbs +1 -1
- data/core/symbol.rbs +17 -11
- data/core/thread.rbs +95 -33
- data/core/time.rbs +35 -9
- data/core/trace_point.rbs +7 -4
- data/core/unbound_method.rbs +14 -6
- data/docs/aliases.md +79 -0
- data/docs/collection.md +2 -2
- data/docs/encoding.md +56 -0
- data/docs/gem.md +0 -1
- data/docs/inline.md +470 -0
- data/docs/sigs.md +3 -3
- data/docs/syntax.md +33 -4
- data/docs/type_fingerprint.md +21 -0
- data/exe/rbs +1 -1
- data/ext/rbs_extension/ast_translation.c +77 -3
- data/ext/rbs_extension/ast_translation.h +3 -0
- data/ext/rbs_extension/class_constants.c +8 -2
- data/ext/rbs_extension/class_constants.h +4 -0
- data/ext/rbs_extension/extconf.rb +5 -1
- data/ext/rbs_extension/legacy_location.c +5 -5
- data/ext/rbs_extension/main.c +37 -20
- data/include/rbs/ast.h +85 -38
- data/include/rbs/defines.h +27 -0
- data/include/rbs/lexer.h +30 -11
- data/include/rbs/parser.h +6 -6
- data/include/rbs/string.h +0 -2
- data/include/rbs/util/rbs_allocator.h +34 -13
- data/include/rbs/util/rbs_assert.h +12 -1
- data/include/rbs/util/rbs_encoding.h +2 -0
- data/include/rbs/util/rbs_unescape.h +2 -1
- data/lib/rbs/ast/annotation.rb +1 -1
- data/lib/rbs/ast/comment.rb +1 -1
- data/lib/rbs/ast/declarations.rb +10 -10
- data/lib/rbs/ast/members.rb +14 -14
- data/lib/rbs/ast/ruby/annotations.rb +137 -0
- data/lib/rbs/ast/ruby/comment_block.rb +24 -0
- data/lib/rbs/ast/ruby/declarations.rb +198 -3
- data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
- data/lib/rbs/ast/ruby/members.rb +159 -1
- data/lib/rbs/ast/type_param.rb +24 -4
- data/lib/rbs/buffer.rb +20 -15
- data/lib/rbs/cli/diff.rb +16 -15
- data/lib/rbs/cli/validate.rb +38 -51
- data/lib/rbs/cli.rb +52 -19
- data/lib/rbs/collection/config/lockfile_generator.rb +8 -0
- data/lib/rbs/collection/sources/git.rb +1 -0
- data/lib/rbs/definition.rb +1 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
- data/lib/rbs/definition_builder/method_builder.rb +20 -0
- data/lib/rbs/definition_builder.rb +91 -2
- data/lib/rbs/diff.rb +7 -1
- data/lib/rbs/environment.rb +227 -74
- data/lib/rbs/environment_loader.rb +0 -6
- data/lib/rbs/errors.rb +27 -7
- data/lib/rbs/inline_parser.rb +341 -5
- data/lib/rbs/location_aux.rb +1 -1
- data/lib/rbs/locator.rb +5 -1
- data/lib/rbs/method_type.rb +5 -3
- data/lib/rbs/parser_aux.rb +2 -2
- data/lib/rbs/prototype/rb.rb +2 -2
- data/lib/rbs/prototype/rbi.rb +2 -0
- data/lib/rbs/prototype/runtime.rb +8 -0
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +116 -38
- data/lib/rbs/subtractor.rb +3 -1
- data/lib/rbs/test/type_check.rb +16 -2
- data/lib/rbs/type_name.rb +1 -1
- data/lib/rbs/types.rb +27 -27
- data/lib/rbs/validator.rb +2 -2
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +1 -1
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +1 -1
- data/rbs.gemspec +3 -2
- data/schema/typeParam.json +17 -1
- data/sig/ast/ruby/annotations.rbs +124 -0
- data/sig/ast/ruby/comment_block.rbs +8 -0
- data/sig/ast/ruby/declarations.rbs +102 -4
- data/sig/ast/ruby/members.rbs +87 -1
- data/sig/cli/diff.rbs +5 -11
- data/sig/cli/validate.rbs +13 -4
- data/sig/cli.rbs +18 -18
- data/sig/definition.rbs +6 -1
- data/sig/environment.rbs +70 -12
- data/sig/errors.rbs +13 -6
- data/sig/inline_parser.rbs +39 -2
- data/sig/locator.rbs +0 -2
- data/sig/manifest.yaml +0 -1
- data/sig/method_builder.rbs +3 -1
- data/sig/method_types.rbs +1 -1
- data/sig/parser.rbs +16 -2
- data/sig/resolver/type_name_resolver.rbs +35 -7
- data/sig/source.rbs +3 -3
- data/sig/type_param.rbs +13 -8
- data/sig/types.rbs +4 -4
- data/src/ast.c +80 -1
- data/src/lexer.c +1392 -1313
- data/src/lexer.re +3 -0
- data/src/lexstate.c +58 -37
- data/src/location.c +4 -4
- data/src/parser.c +412 -145
- data/src/string.c +0 -48
- data/src/util/rbs_allocator.c +89 -71
- data/src/util/rbs_assert.c +1 -1
- data/src/util/rbs_buffer.c +2 -2
- data/src/util/rbs_constant_pool.c +10 -10
- data/src/util/rbs_encoding.c +4 -8
- data/src/util/rbs_unescape.c +56 -20
- data/stdlib/bigdecimal/0/big_decimal.rbs +100 -82
- data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
- data/stdlib/cgi/0/core.rbs +9 -393
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/cgi-escape/0/escape.rbs +171 -0
- data/stdlib/coverage/0/coverage.rbs +3 -1
- data/stdlib/date/0/date.rbs +67 -59
- data/stdlib/date/0/date_time.rbs +1 -1
- data/stdlib/delegate/0/delegator.rbs +10 -7
- data/stdlib/digest/0/digest.rbs +110 -0
- data/stdlib/erb/0/erb.rbs +737 -347
- data/stdlib/fileutils/0/fileutils.rbs +20 -14
- data/stdlib/forwardable/0/forwardable.rbs +3 -0
- data/stdlib/json/0/json.rbs +82 -28
- data/stdlib/net-http/0/net-http.rbs +3 -0
- data/stdlib/objspace/0/objspace.rbs +9 -27
- data/stdlib/open-uri/0/open-uri.rbs +40 -0
- data/stdlib/open3/0/open3.rbs +459 -1
- data/stdlib/openssl/0/openssl.rbs +331 -228
- data/stdlib/optparse/0/optparse.rbs +8 -3
- data/stdlib/pathname/0/pathname.rbs +9 -1379
- data/stdlib/psych/0/psych.rbs +4 -4
- data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
- data/stdlib/rdoc/0/code_object.rbs +2 -1
- data/stdlib/rdoc/0/parser.rbs +1 -1
- data/stdlib/rdoc/0/rdoc.rbs +1 -1
- data/stdlib/rdoc/0/store.rbs +1 -1
- data/stdlib/resolv/0/resolv.rbs +25 -68
- data/stdlib/ripper/0/ripper.rbs +2 -2
- data/stdlib/securerandom/0/manifest.yaml +2 -0
- data/stdlib/securerandom/0/securerandom.rbs +6 -19
- data/stdlib/singleton/0/singleton.rbs +3 -0
- data/stdlib/socket/0/socket.rbs +13 -1
- data/stdlib/socket/0/tcp_socket.rbs +10 -2
- data/stdlib/stringio/0/stringio.rbs +1176 -85
- data/stdlib/strscan/0/string_scanner.rbs +31 -31
- data/stdlib/tempfile/0/tempfile.rbs +3 -3
- data/stdlib/time/0/time.rbs +1 -1
- data/stdlib/timeout/0/timeout.rbs +63 -7
- data/stdlib/tsort/0/cyclic.rbs +3 -0
- data/stdlib/uri/0/common.rbs +16 -2
- data/stdlib/uri/0/file.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +24 -16
- data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
- data/stdlib/zlib/0/gzip_reader.rbs +2 -2
- data/stdlib/zlib/0/gzip_writer.rbs +1 -1
- data/stdlib/zlib/0/zstream.rbs +1 -0
- metadata +30 -4
data/stdlib/date/0/date.rbs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
#
|
|
6
6
|
# * You need both dates and times; Date handles only dates.
|
|
7
7
|
# * You need only Gregorian dates (and not Julian dates); see [Julian and
|
|
8
|
-
# Gregorian Calendars](rdoc-ref:
|
|
8
|
+
# Gregorian Calendars](rdoc-ref:language/calendars.rdoc).
|
|
9
9
|
#
|
|
10
10
|
# A Date object, once created, is immutable, and cannot be modified.
|
|
11
11
|
#
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
#
|
|
54
54
|
# See also the specialized methods in ["Specialized Format Strings" in Formats
|
|
55
55
|
# for Dates and
|
|
56
|
-
# Times](rdoc-ref:strftime_formatting.rdoc@Specialized+Format+Strings)
|
|
56
|
+
# Times](rdoc-ref:language/strftime_formatting.rdoc@Specialized+Format+Strings)
|
|
57
57
|
#
|
|
58
58
|
# ## Argument `limit`
|
|
59
59
|
#
|
|
@@ -88,7 +88,7 @@ class Date
|
|
|
88
88
|
# number of days in the month; when the argument is negative, counts backward
|
|
89
89
|
# from the end of the month.
|
|
90
90
|
#
|
|
91
|
-
# See argument [start](rdoc-ref:
|
|
91
|
+
# See argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
92
92
|
#
|
|
93
93
|
# Related: Date.jd.
|
|
94
94
|
#
|
|
@@ -101,7 +101,7 @@ class Date
|
|
|
101
101
|
# - Date._httpdate(string, limit: 128) -> hash
|
|
102
102
|
# -->
|
|
103
103
|
# Returns a hash of values parsed from `string`, which should be a valid [HTTP
|
|
104
|
-
# date format](rdoc-ref:strftime_formatting.rdoc@HTTP+Format):
|
|
104
|
+
# date format](rdoc-ref:language/strftime_formatting.rdoc@HTTP+Format):
|
|
105
105
|
#
|
|
106
106
|
# d = Date.new(2001, 2, 3)
|
|
107
107
|
# s = d.httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
|
|
@@ -118,7 +118,8 @@ class Date
|
|
|
118
118
|
# -->
|
|
119
119
|
# Returns a hash of values parsed from `string`, which should contain an [ISO
|
|
120
120
|
# 8601 formatted
|
|
121
|
-
# date](rdoc-ref:strftime_formatting.rdoc@ISO+8601+Format+
|
|
121
|
+
# date](rdoc-ref:language/strftime_formatting.rdoc@ISO+8601+Format+Specification
|
|
122
|
+
# s):
|
|
122
123
|
#
|
|
123
124
|
# d = Date.new(2001, 2, 3)
|
|
124
125
|
# s = d.iso8601 # => "2001-02-03"
|
|
@@ -135,7 +136,8 @@ class Date
|
|
|
135
136
|
# - Date._jisx0301(string, limit: 128) -> hash
|
|
136
137
|
# -->
|
|
137
138
|
# Returns a hash of values parsed from `string`, which should be a valid [JIS X
|
|
138
|
-
# 0301 date
|
|
139
|
+
# 0301 date
|
|
140
|
+
# format](rdoc-ref:language/strftime_formatting.rdoc@JIS+X+0301+Format):
|
|
139
141
|
#
|
|
140
142
|
# d = Date.new(2001, 2, 3)
|
|
141
143
|
# s = d.jisx0301 # => "H13.02.03"
|
|
@@ -153,7 +155,8 @@ class Date
|
|
|
153
155
|
# -->
|
|
154
156
|
# **Note**: This method recognizes many forms in `string`, but it is not a
|
|
155
157
|
# validator. For formats, see ["Specialized Format Strings" in Formats for Dates
|
|
156
|
-
# and
|
|
158
|
+
# and
|
|
159
|
+
# Times](rdoc-ref:language/strftime_formatting.rdoc@Specialized+Format+Strings)
|
|
157
160
|
#
|
|
158
161
|
# If `string` does not specify a valid date, the result is unpredictable;
|
|
159
162
|
# consider using Date._strptime instead.
|
|
@@ -179,7 +182,7 @@ class Date
|
|
|
179
182
|
# - Date._rfc2822(string, limit: 128) -> hash
|
|
180
183
|
# -->
|
|
181
184
|
# Returns a hash of values parsed from `string`, which should be a valid [RFC
|
|
182
|
-
# 2822 date format](rdoc-ref:strftime_formatting.rdoc@RFC+2822+Format):
|
|
185
|
+
# 2822 date format](rdoc-ref:language/strftime_formatting.rdoc@RFC+2822+Format):
|
|
183
186
|
#
|
|
184
187
|
# d = Date.new(2001, 2, 3)
|
|
185
188
|
# s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
|
|
@@ -197,7 +200,7 @@ class Date
|
|
|
197
200
|
# - Date._rfc3339(string, limit: 128) -> hash
|
|
198
201
|
# -->
|
|
199
202
|
# Returns a hash of values parsed from `string`, which should be a valid [RFC
|
|
200
|
-
# 3339 format](rdoc-ref:strftime_formatting.rdoc@RFC+3339+Format):
|
|
203
|
+
# 3339 format](rdoc-ref:language/strftime_formatting.rdoc@RFC+3339+Format):
|
|
201
204
|
#
|
|
202
205
|
# d = Date.new(2001, 2, 3)
|
|
203
206
|
# s = d.rfc3339 # => "2001-02-03T00:00:00+00:00"
|
|
@@ -215,7 +218,7 @@ class Date
|
|
|
215
218
|
# - Date._rfc2822(string, limit: 128) -> hash
|
|
216
219
|
# -->
|
|
217
220
|
# Returns a hash of values parsed from `string`, which should be a valid [RFC
|
|
218
|
-
# 2822 date format](rdoc-ref:strftime_formatting.rdoc@RFC+2822+Format):
|
|
221
|
+
# 2822 date format](rdoc-ref:language/strftime_formatting.rdoc@RFC+2822+Format):
|
|
219
222
|
#
|
|
220
223
|
# d = Date.new(2001, 2, 3)
|
|
221
224
|
# s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
|
|
@@ -237,8 +240,8 @@ class Date
|
|
|
237
240
|
# Date._strptime('2001-02-03', '%Y-%m-%d') # => {:year=>2001, :mon=>2, :mday=>3}
|
|
238
241
|
#
|
|
239
242
|
# For other formats, see [Formats for Dates and
|
|
240
|
-
# Times](rdoc-ref:strftime_formatting.rdoc). (Unlike Date.strftime,
|
|
241
|
-
# support flags and width.)
|
|
243
|
+
# Times](rdoc-ref:language/strftime_formatting.rdoc). (Unlike Date.strftime,
|
|
244
|
+
# does not support flags and width.)
|
|
242
245
|
#
|
|
243
246
|
# See also [strptime(3)](https://man7.org/linux/man-pages/man3/strptime.3.html).
|
|
244
247
|
#
|
|
@@ -309,7 +312,7 @@ class Date
|
|
|
309
312
|
# Date.commercial(2020, 1, 1).to_s # => "2019-12-30"
|
|
310
313
|
# Date.commercial(2020, 1, 7).to_s # => "2020-01-05"
|
|
311
314
|
#
|
|
312
|
-
# See argument [start](rdoc-ref:
|
|
315
|
+
# See argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
313
316
|
#
|
|
314
317
|
# Related: Date.jd, Date.new, Date.ordinal.
|
|
315
318
|
#
|
|
@@ -335,7 +338,8 @@ class Date
|
|
|
335
338
|
# - Date.httpdate(string = 'Mon, 01 Jan -4712 00:00:00 GMT', start = Date::ITALY, limit: 128) -> date
|
|
336
339
|
# -->
|
|
337
340
|
# Returns a new Date object with values parsed from `string`, which should be a
|
|
338
|
-
# valid [HTTP date
|
|
341
|
+
# valid [HTTP date
|
|
342
|
+
# format](rdoc-ref:language/strftime_formatting.rdoc@HTTP+Format):
|
|
339
343
|
#
|
|
340
344
|
# d = Date.new(2001, 2, 3)
|
|
341
345
|
# s = d.httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
|
|
@@ -343,7 +347,7 @@ class Date
|
|
|
343
347
|
#
|
|
344
348
|
# See:
|
|
345
349
|
#
|
|
346
|
-
# * Argument [start](rdoc-ref:
|
|
350
|
+
# * Argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
347
351
|
# * Argument [limit](rdoc-ref:Date@Argument+limit).
|
|
348
352
|
#
|
|
349
353
|
# Related: Date._httpdate (returns a hash).
|
|
@@ -356,7 +360,8 @@ class Date
|
|
|
356
360
|
# -->
|
|
357
361
|
# Returns a new Date object with values parsed from `string`, which should
|
|
358
362
|
# contain an [ISO 8601 formatted
|
|
359
|
-
# date](rdoc-ref:strftime_formatting.rdoc@ISO+8601+Format+
|
|
363
|
+
# date](rdoc-ref:language/strftime_formatting.rdoc@ISO+8601+Format+Specification
|
|
364
|
+
# s):
|
|
360
365
|
#
|
|
361
366
|
# d = Date.new(2001, 2, 3)
|
|
362
367
|
# s = d.iso8601 # => "2001-02-03"
|
|
@@ -364,7 +369,7 @@ class Date
|
|
|
364
369
|
#
|
|
365
370
|
# See:
|
|
366
371
|
#
|
|
367
|
-
# * Argument [start](rdoc-ref:
|
|
372
|
+
# * Argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
368
373
|
# * Argument [limit](rdoc-ref:Date@Argument+limit).
|
|
369
374
|
#
|
|
370
375
|
# Related: Date._iso8601 (returns a hash).
|
|
@@ -393,7 +398,7 @@ class Date
|
|
|
393
398
|
#
|
|
394
399
|
# Date.jd(Date::ITALY - 1).julian? # => true
|
|
395
400
|
#
|
|
396
|
-
# See argument [start](rdoc-ref:
|
|
401
|
+
# See argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
397
402
|
#
|
|
398
403
|
# Related: Date.new.
|
|
399
404
|
#
|
|
@@ -405,7 +410,7 @@ class Date
|
|
|
405
410
|
# -->
|
|
406
411
|
# Returns a new Date object with values parsed from `string`, which should be a
|
|
407
412
|
# valid [JIS X 0301
|
|
408
|
-
# format](rdoc-ref:strftime_formatting.rdoc@JIS+X+0301+Format):
|
|
413
|
+
# format](rdoc-ref:language/strftime_formatting.rdoc@JIS+X+0301+Format):
|
|
409
414
|
#
|
|
410
415
|
# d = Date.new(2001, 2, 3)
|
|
411
416
|
# s = d.jisx0301 # => "H13.02.03"
|
|
@@ -417,7 +422,7 @@ class Date
|
|
|
417
422
|
#
|
|
418
423
|
# See:
|
|
419
424
|
#
|
|
420
|
-
# * Argument [start](rdoc-ref:
|
|
425
|
+
# * Argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
421
426
|
# * Argument [limit](rdoc-ref:Date@Argument+limit).
|
|
422
427
|
#
|
|
423
428
|
# Related: Date._jisx0301 (returns a hash).
|
|
@@ -480,7 +485,7 @@ class Date
|
|
|
480
485
|
#
|
|
481
486
|
# Raises an exception if `yday` is zero or out of range.
|
|
482
487
|
#
|
|
483
|
-
# See argument [start](rdoc-ref:
|
|
488
|
+
# See argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
484
489
|
#
|
|
485
490
|
# Related: Date.jd, Date.new.
|
|
486
491
|
#
|
|
@@ -492,9 +497,10 @@ class Date
|
|
|
492
497
|
# -->
|
|
493
498
|
# **Note**: This method recognizes many forms in `string`, but it is not a
|
|
494
499
|
# validator. For formats, see ["Specialized Format Strings" in Formats for Dates
|
|
495
|
-
# and
|
|
496
|
-
#
|
|
497
|
-
#
|
|
500
|
+
# and
|
|
501
|
+
# Times](rdoc-ref:language/strftime_formatting.rdoc@Specialized+Format+Strings)
|
|
502
|
+
# If `string` does not specify a valid date, the result is unpredictable;
|
|
503
|
+
# consider using Date._strptime instead.
|
|
498
504
|
#
|
|
499
505
|
# Returns a new Date object with values parsed from `string`:
|
|
500
506
|
#
|
|
@@ -510,7 +516,7 @@ class Date
|
|
|
510
516
|
#
|
|
511
517
|
# See:
|
|
512
518
|
#
|
|
513
|
-
# * Argument [start](rdoc-ref:
|
|
519
|
+
# * Argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
514
520
|
# * Argument [limit](rdoc-ref:Date@Argument+limit).
|
|
515
521
|
#
|
|
516
522
|
# Related: Date._parse (returns a hash).
|
|
@@ -523,7 +529,7 @@ class Date
|
|
|
523
529
|
# -->
|
|
524
530
|
# Returns a new Date object with values parsed from `string`, which should be a
|
|
525
531
|
# valid [RFC 2822 date
|
|
526
|
-
# format](rdoc-ref:strftime_formatting.rdoc@RFC+2822+Format):
|
|
532
|
+
# format](rdoc-ref:language/strftime_formatting.rdoc@RFC+2822+Format):
|
|
527
533
|
#
|
|
528
534
|
# d = Date.new(2001, 2, 3)
|
|
529
535
|
# s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
|
|
@@ -531,7 +537,7 @@ class Date
|
|
|
531
537
|
#
|
|
532
538
|
# See:
|
|
533
539
|
#
|
|
534
|
-
# * Argument [start](rdoc-ref:
|
|
540
|
+
# * Argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
535
541
|
# * Argument [limit](rdoc-ref:Date@Argument+limit).
|
|
536
542
|
#
|
|
537
543
|
# Related: Date._rfc2822 (returns a hash).
|
|
@@ -543,7 +549,8 @@ class Date
|
|
|
543
549
|
# - Date.rfc3339(string = '-4712-01-01T00:00:00+00:00', start = Date::ITALY, limit: 128) -> date
|
|
544
550
|
# -->
|
|
545
551
|
# Returns a new Date object with values parsed from `string`, which should be a
|
|
546
|
-
# valid [RFC 3339
|
|
552
|
+
# valid [RFC 3339
|
|
553
|
+
# format](rdoc-ref:language/strftime_formatting.rdoc@RFC+3339+Format):
|
|
547
554
|
#
|
|
548
555
|
# d = Date.new(2001, 2, 3)
|
|
549
556
|
# s = d.rfc3339 # => "2001-02-03T00:00:00+00:00"
|
|
@@ -551,7 +558,7 @@ class Date
|
|
|
551
558
|
#
|
|
552
559
|
# See:
|
|
553
560
|
#
|
|
554
|
-
# * Argument [start](rdoc-ref:
|
|
561
|
+
# * Argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
555
562
|
# * Argument [limit](rdoc-ref:Date@Argument+limit).
|
|
556
563
|
#
|
|
557
564
|
# Related: Date._rfc3339 (returns a hash).
|
|
@@ -564,7 +571,7 @@ class Date
|
|
|
564
571
|
# -->
|
|
565
572
|
# Returns a new Date object with values parsed from `string`, which should be a
|
|
566
573
|
# valid [RFC 2822 date
|
|
567
|
-
# format](rdoc-ref:strftime_formatting.rdoc@RFC+2822+Format):
|
|
574
|
+
# format](rdoc-ref:language/strftime_formatting.rdoc@RFC+2822+Format):
|
|
568
575
|
#
|
|
569
576
|
# d = Date.new(2001, 2, 3)
|
|
570
577
|
# s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
|
|
@@ -572,7 +579,7 @@ class Date
|
|
|
572
579
|
#
|
|
573
580
|
# See:
|
|
574
581
|
#
|
|
575
|
-
# * Argument [start](rdoc-ref:
|
|
582
|
+
# * Argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
576
583
|
# * Argument [limit](rdoc-ref:Date@Argument+limit).
|
|
577
584
|
#
|
|
578
585
|
# Related: Date._rfc2822 (returns a hash).
|
|
@@ -595,10 +602,10 @@ class Date
|
|
|
595
602
|
# Date.strptime('sat3feb01', '%a%d%b%y') # => #<Date: 2001-02-03>
|
|
596
603
|
#
|
|
597
604
|
# For other formats, see [Formats for Dates and
|
|
598
|
-
# Times](rdoc-ref:strftime_formatting.rdoc). (Unlike Date.strftime,
|
|
599
|
-
# support flags and width.)
|
|
605
|
+
# Times](rdoc-ref:language/strftime_formatting.rdoc). (Unlike Date.strftime,
|
|
606
|
+
# does not support flags and width.)
|
|
600
607
|
#
|
|
601
|
-
# See argument [start](rdoc-ref:
|
|
608
|
+
# See argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
602
609
|
#
|
|
603
610
|
# See also [strptime(3)](https://man7.org/linux/man-pages/man3/strptime.3.html).
|
|
604
611
|
#
|
|
@@ -614,7 +621,7 @@ class Date
|
|
|
614
621
|
#
|
|
615
622
|
# Date.today.to_s # => "2022-07-06"
|
|
616
623
|
#
|
|
617
|
-
# See argument [start](rdoc-ref:
|
|
624
|
+
# See argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
618
625
|
#
|
|
619
626
|
def self.today: (?Integer start) -> Date
|
|
620
627
|
|
|
@@ -629,7 +636,7 @@ class Date
|
|
|
629
636
|
# Date.valid_date?(2001, 2, 29) # => false
|
|
630
637
|
# Date.valid_date?(2001, 2, -1) # => true
|
|
631
638
|
#
|
|
632
|
-
# See argument [start](rdoc-ref:
|
|
639
|
+
# See argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
633
640
|
#
|
|
634
641
|
# Related: Date.jd, Date.new.
|
|
635
642
|
#
|
|
@@ -647,7 +654,7 @@ class Date
|
|
|
647
654
|
#
|
|
648
655
|
# See Date.commercial.
|
|
649
656
|
#
|
|
650
|
-
# See argument [start](rdoc-ref:
|
|
657
|
+
# See argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
651
658
|
#
|
|
652
659
|
# Related: Date.jd, Date.commercial.
|
|
653
660
|
#
|
|
@@ -664,7 +671,7 @@ class Date
|
|
|
664
671
|
# Date.valid_date?(2001, 2, 29) # => false
|
|
665
672
|
# Date.valid_date?(2001, 2, -1) # => true
|
|
666
673
|
#
|
|
667
|
-
# See argument [start](rdoc-ref:
|
|
674
|
+
# See argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
668
675
|
#
|
|
669
676
|
# Related: Date.jd, Date.new.
|
|
670
677
|
#
|
|
@@ -679,7 +686,7 @@ class Date
|
|
|
679
686
|
#
|
|
680
687
|
# Date.valid_jd?(2451944) # => true
|
|
681
688
|
#
|
|
682
|
-
# See argument [start](rdoc-ref:
|
|
689
|
+
# See argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
683
690
|
#
|
|
684
691
|
# Related: Date.jd.
|
|
685
692
|
#
|
|
@@ -695,7 +702,7 @@ class Date
|
|
|
695
702
|
# Date.valid_ordinal?(2001, 34) # => true
|
|
696
703
|
# Date.valid_ordinal?(2001, 366) # => false
|
|
697
704
|
#
|
|
698
|
-
# See argument [start](rdoc-ref:
|
|
705
|
+
# See argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
699
706
|
#
|
|
700
707
|
# Related: Date.jd, Date.ordinal.
|
|
701
708
|
#
|
|
@@ -714,7 +721,7 @@ class Date
|
|
|
714
721
|
#
|
|
715
722
|
# See:
|
|
716
723
|
#
|
|
717
|
-
# * Argument [start](rdoc-ref:
|
|
724
|
+
# * Argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
718
725
|
# * Argument [limit](rdoc-ref:Date@Argument+limit).
|
|
719
726
|
#
|
|
720
727
|
# Related: Date._xmlschema (returns a hash).
|
|
@@ -922,8 +929,8 @@ class Date
|
|
|
922
929
|
# - asctime -> string
|
|
923
930
|
# -->
|
|
924
931
|
# Equivalent to #strftime with argument `'%a %b %e %T %Y'` (or its [shorthand
|
|
925
|
-
# form](rdoc-ref:strftime_formatting.rdoc@Shorthand+Conversion+
|
|
926
|
-
# `'%c'`):
|
|
932
|
+
# form](rdoc-ref:language/strftime_formatting.rdoc@Shorthand+Conversion+Specifie
|
|
933
|
+
# rs) `'%c'`):
|
|
927
934
|
#
|
|
928
935
|
# Date.new(2001, 2, 3).asctime # => "Sat Feb 3 00:00:00 2001"
|
|
929
936
|
#
|
|
@@ -933,8 +940,8 @@ class Date
|
|
|
933
940
|
|
|
934
941
|
# <!-- rdoc-file=ext/date/date_core.c -->
|
|
935
942
|
# Equivalent to #strftime with argument `'%a %b %e %T %Y'` (or its [shorthand
|
|
936
|
-
# form](rdoc-ref:strftime_formatting.rdoc@Shorthand+Conversion+
|
|
937
|
-
# `'%c'`):
|
|
943
|
+
# form](rdoc-ref:language/strftime_formatting.rdoc@Shorthand+Conversion+Specifie
|
|
944
|
+
# rs) `'%c'`):
|
|
938
945
|
#
|
|
939
946
|
# Date.new(2001, 2, 3).asctime # => "Sat Feb 3 00:00:00 2001"
|
|
940
947
|
#
|
|
@@ -1065,7 +1072,7 @@ class Date
|
|
|
1065
1072
|
# - httpdate -> string
|
|
1066
1073
|
# -->
|
|
1067
1074
|
# Equivalent to #strftime with argument `'%a, %d %b %Y %T GMT'`; see [Formats
|
|
1068
|
-
# for Dates and Times](rdoc-ref:strftime_formatting.rdoc):
|
|
1075
|
+
# for Dates and Times](rdoc-ref:language/strftime_formatting.rdoc):
|
|
1069
1076
|
#
|
|
1070
1077
|
# Date.new(2001, 2, 3).httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
|
|
1071
1078
|
#
|
|
@@ -1087,8 +1094,8 @@ class Date
|
|
|
1087
1094
|
# - iso8601 -> string
|
|
1088
1095
|
# -->
|
|
1089
1096
|
# Equivalent to #strftime with argument `'%Y-%m-%d'` (or its [shorthand
|
|
1090
|
-
# form](rdoc-ref:strftime_formatting.rdoc@Shorthand+Conversion+
|
|
1091
|
-
# `'%F'`);
|
|
1097
|
+
# form](rdoc-ref:language/strftime_formatting.rdoc@Shorthand+Conversion+Specifie
|
|
1098
|
+
# rs) `'%F'`);
|
|
1092
1099
|
#
|
|
1093
1100
|
# Date.new(2001, 2, 3).iso8601 # => "2001-02-03"
|
|
1094
1101
|
#
|
|
@@ -1225,7 +1232,7 @@ class Date
|
|
|
1225
1232
|
# d1 = d0.new_start(Date::JULIAN)
|
|
1226
1233
|
# d1.julian? # => true
|
|
1227
1234
|
#
|
|
1228
|
-
# See argument [start](rdoc-ref:
|
|
1235
|
+
# See argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
1229
1236
|
#
|
|
1230
1237
|
def new_start: (?Integer start) -> Date
|
|
1231
1238
|
|
|
@@ -1294,7 +1301,7 @@ class Date
|
|
|
1294
1301
|
# - rfc2822 -> string
|
|
1295
1302
|
# -->
|
|
1296
1303
|
# Equivalent to #strftime with argument `'%a, %-d %b %Y %T %z'`; see [Formats
|
|
1297
|
-
# for Dates and Times](rdoc-ref:strftime_formatting.rdoc):
|
|
1304
|
+
# for Dates and Times](rdoc-ref:language/strftime_formatting.rdoc):
|
|
1298
1305
|
#
|
|
1299
1306
|
# Date.new(2001, 2, 3).rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
|
|
1300
1307
|
#
|
|
@@ -1305,7 +1312,7 @@ class Date
|
|
|
1305
1312
|
# - rfc3339 -> string
|
|
1306
1313
|
# -->
|
|
1307
1314
|
# Equivalent to #strftime with argument `'%FT%T%:z'`; see [Formats for Dates and
|
|
1308
|
-
# Times](rdoc-ref:strftime_formatting.rdoc):
|
|
1315
|
+
# Times](rdoc-ref:language/strftime_formatting.rdoc):
|
|
1309
1316
|
#
|
|
1310
1317
|
# Date.new(2001, 2, 3).rfc3339 # => "2001-02-03T00:00:00+00:00"
|
|
1311
1318
|
#
|
|
@@ -1314,7 +1321,7 @@ class Date
|
|
|
1314
1321
|
# <!-- rdoc-file=ext/date/date_core.c -->
|
|
1315
1322
|
# Returns a new Date object with values parsed from `string`, which should be a
|
|
1316
1323
|
# valid [RFC 2822 date
|
|
1317
|
-
# format](rdoc-ref:strftime_formatting.rdoc@RFC+2822+Format):
|
|
1324
|
+
# format](rdoc-ref:language/strftime_formatting.rdoc@RFC+2822+Format):
|
|
1318
1325
|
#
|
|
1319
1326
|
# d = Date.new(2001, 2, 3)
|
|
1320
1327
|
# s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
|
|
@@ -1322,7 +1329,7 @@ class Date
|
|
|
1322
1329
|
#
|
|
1323
1330
|
# See:
|
|
1324
1331
|
#
|
|
1325
|
-
# * Argument [start](rdoc-ref:
|
|
1332
|
+
# * Argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
1326
1333
|
# * Argument [limit](rdoc-ref:Date@Argument+limit).
|
|
1327
1334
|
#
|
|
1328
1335
|
# Related: Date._rfc2822 (returns a hash).
|
|
@@ -1355,7 +1362,7 @@ class Date
|
|
|
1355
1362
|
# Date.new(2001, 2, 3, Date::GREGORIAN).start # => -Infinity
|
|
1356
1363
|
# Date.new(2001, 2, 3, Date::JULIAN).start # => Infinity
|
|
1357
1364
|
#
|
|
1358
|
-
# See argument [start](rdoc-ref:
|
|
1365
|
+
# See argument [start](rdoc-ref:language/calendars.rdoc@Argument+start).
|
|
1359
1366
|
#
|
|
1360
1367
|
def start: () -> Float
|
|
1361
1368
|
|
|
@@ -1401,7 +1408,7 @@ class Date
|
|
|
1401
1408
|
# Date.new(2001, 2, 3).strftime # => "2001-02-03"
|
|
1402
1409
|
#
|
|
1403
1410
|
# For other formats, see [Formats for Dates and
|
|
1404
|
-
# Times](rdoc-ref:strftime_formatting.rdoc).
|
|
1411
|
+
# Times](rdoc-ref:language/strftime_formatting.rdoc).
|
|
1405
1412
|
#
|
|
1406
1413
|
def strftime: (?String format) -> String
|
|
1407
1414
|
|
|
@@ -1453,8 +1460,9 @@ class Date
|
|
|
1453
1460
|
# - to_s -> string
|
|
1454
1461
|
# -->
|
|
1455
1462
|
# Returns a string representation of the date in `self` in [ISO 8601 extended
|
|
1456
|
-
# date
|
|
1457
|
-
# (
|
|
1463
|
+
# date
|
|
1464
|
+
# format](rdoc-ref:language/strftime_formatting.rdoc@ISO+8601+Format+Specificati
|
|
1465
|
+
# ons) (`'%Y-%m-%d'`):
|
|
1458
1466
|
#
|
|
1459
1467
|
# Date.new(2001, 2, 3).to_s # => "2001-02-03"
|
|
1460
1468
|
#
|
|
@@ -1509,8 +1517,8 @@ class Date
|
|
|
1509
1517
|
|
|
1510
1518
|
# <!-- rdoc-file=ext/date/date_core.c -->
|
|
1511
1519
|
# Equivalent to #strftime with argument `'%Y-%m-%d'` (or its [shorthand
|
|
1512
|
-
# form](rdoc-ref:strftime_formatting.rdoc@Shorthand+Conversion+
|
|
1513
|
-
# `'%F'`);
|
|
1520
|
+
# form](rdoc-ref:language/strftime_formatting.rdoc@Shorthand+Conversion+Specifie
|
|
1521
|
+
# rs) `'%F'`);
|
|
1514
1522
|
#
|
|
1515
1523
|
# Date.new(2001, 2, 3).iso8601 # => "2001-02-03"
|
|
1516
1524
|
#
|
data/stdlib/date/0/date_time.rbs
CHANGED
|
@@ -555,7 +555,7 @@ class DateTime < Date
|
|
|
555
555
|
# DateTime.now.strftime # => "2022-07-01T11:03:19-05:00"
|
|
556
556
|
#
|
|
557
557
|
# For other formats, see [Formats for Dates and
|
|
558
|
-
# Times](rdoc-ref:strftime_formatting.rdoc):
|
|
558
|
+
# Times](rdoc-ref:language/strftime_formatting.rdoc):
|
|
559
559
|
#
|
|
560
560
|
def strftime: (?String format) -> String
|
|
561
561
|
|
|
@@ -44,7 +44,7 @@ class Delegator < BasicObject
|
|
|
44
44
|
# rdoc-file=lib/delegate.rb
|
|
45
45
|
# - !()
|
|
46
46
|
# -->
|
|
47
|
-
# Delegates ! to the
|
|
47
|
+
# Delegates ! to the `__getobj__`
|
|
48
48
|
#
|
|
49
49
|
def !: () -> untyped
|
|
50
50
|
|
|
@@ -94,7 +94,7 @@ class Delegator < BasicObject
|
|
|
94
94
|
# rdoc-file=lib/delegate.rb
|
|
95
95
|
# - freeze()
|
|
96
96
|
# -->
|
|
97
|
-
# :method: freeze Freeze both the object returned by
|
|
97
|
+
# :method: freeze Freeze both the object returned by `__getobj__` and self.
|
|
98
98
|
#
|
|
99
99
|
def freeze: () -> self
|
|
100
100
|
|
|
@@ -102,7 +102,7 @@ class Delegator < BasicObject
|
|
|
102
102
|
# rdoc-file=lib/delegate.rb
|
|
103
103
|
# - marshal_dump()
|
|
104
104
|
# -->
|
|
105
|
-
# Serialization support for the object returned by
|
|
105
|
+
# Serialization support for the object returned by `__getobj__`.
|
|
106
106
|
#
|
|
107
107
|
def marshal_dump: () -> untyped
|
|
108
108
|
|
|
@@ -126,7 +126,7 @@ class Delegator < BasicObject
|
|
|
126
126
|
# - methods(all=true)
|
|
127
127
|
# -->
|
|
128
128
|
# Returns the methods available to this delegate object as the union of this
|
|
129
|
-
# object's and
|
|
129
|
+
# object's and `__getobj__` methods.
|
|
130
130
|
#
|
|
131
131
|
def methods: (?boolish all) -> Array[Symbol]
|
|
132
132
|
|
|
@@ -135,7 +135,7 @@ class Delegator < BasicObject
|
|
|
135
135
|
# - protected_methods(all=true)
|
|
136
136
|
# -->
|
|
137
137
|
# Returns the methods available to this delegate object as the union of this
|
|
138
|
-
# object's and
|
|
138
|
+
# object's and `__getobj__` protected methods.
|
|
139
139
|
#
|
|
140
140
|
def protected_methods: (?boolish all) -> Array[Symbol]
|
|
141
141
|
|
|
@@ -144,7 +144,7 @@ class Delegator < BasicObject
|
|
|
144
144
|
# - public_methods(all=true)
|
|
145
145
|
# -->
|
|
146
146
|
# Returns the methods available to this delegate object as the union of this
|
|
147
|
-
# object's and
|
|
147
|
+
# object's and `__getobj__` public methods.
|
|
148
148
|
#
|
|
149
149
|
def public_methods: (?untyped all) -> Array[Symbol]
|
|
150
150
|
|
|
@@ -168,7 +168,7 @@ class Delegator < BasicObject
|
|
|
168
168
|
# - respond_to_missing?(m, include_private)
|
|
169
169
|
# -->
|
|
170
170
|
# Checks for a method provided by this the delegate object by forwarding the
|
|
171
|
-
# call through
|
|
171
|
+
# call through `__getobj__`.
|
|
172
172
|
#
|
|
173
173
|
def respond_to_missing?: (Symbol m, bool include_private) -> bool
|
|
174
174
|
|
|
@@ -180,5 +180,8 @@ class Delegator < BasicObject
|
|
|
180
180
|
#
|
|
181
181
|
def target_respond_to?: (untyped target, Symbol m, bool include_private) -> bool
|
|
182
182
|
|
|
183
|
+
# <!-- rdoc-file=lib/delegate.rb -->
|
|
184
|
+
# The version string
|
|
185
|
+
#
|
|
183
186
|
VERSION: String
|
|
184
187
|
end
|
data/stdlib/digest/0/digest.rbs
CHANGED
|
@@ -471,6 +471,116 @@ end
|
|
|
471
471
|
class Digest::SHA1 < Digest::Base
|
|
472
472
|
end
|
|
473
473
|
|
|
474
|
+
# <!-- rdoc-file=ext/digest/sha2/lib/sha2.rb -->
|
|
475
|
+
# A meta digest provider class for SHA256, SHA384 and SHA512.
|
|
476
|
+
#
|
|
477
|
+
# FIPS 180-2 describes SHA2 family of digest algorithms. It defines three
|
|
478
|
+
# algorithms:
|
|
479
|
+
# * one which works on chunks of 512 bits and returns a 256-bit digest
|
|
480
|
+
# (SHA256),
|
|
481
|
+
# * one which works on chunks of 1024 bits and returns a 384-bit digest
|
|
482
|
+
# (SHA384),
|
|
483
|
+
# * and one which works on chunks of 1024 bits and returns a 512-bit digest
|
|
484
|
+
# (SHA512).
|
|
485
|
+
#
|
|
486
|
+
# ## Examples
|
|
487
|
+
# require 'digest'
|
|
488
|
+
#
|
|
489
|
+
# # Compute a complete digest
|
|
490
|
+
# Digest::SHA2.hexdigest 'abc' # => "ba7816bf8..."
|
|
491
|
+
# Digest::SHA2.new(256).hexdigest 'abc' # => "ba7816bf8..."
|
|
492
|
+
# Digest::SHA256.hexdigest 'abc' # => "ba7816bf8..."
|
|
493
|
+
#
|
|
494
|
+
# Digest::SHA2.new(384).hexdigest 'abc' # => "cb00753f4..."
|
|
495
|
+
# Digest::SHA384.hexdigest 'abc' # => "cb00753f4..."
|
|
496
|
+
#
|
|
497
|
+
# Digest::SHA2.new(512).hexdigest 'abc' # => "ddaf35a19..."
|
|
498
|
+
# Digest::SHA512.hexdigest 'abc' # => "ddaf35a19..."
|
|
499
|
+
#
|
|
500
|
+
# # Compute digest by chunks
|
|
501
|
+
# sha2 = Digest::SHA2.new # =>#<Digest::SHA2:256>
|
|
502
|
+
# sha2.update "ab"
|
|
503
|
+
# sha2 << "c" # alias for #update
|
|
504
|
+
# sha2.hexdigest # => "ba7816bf8..."
|
|
505
|
+
#
|
|
506
|
+
# # Use the same object to compute another digest
|
|
507
|
+
# sha2.reset
|
|
508
|
+
# sha2 << "message"
|
|
509
|
+
# sha2.hexdigest # => "ab530a13e..."
|
|
510
|
+
#
|
|
511
|
+
class Digest::SHA2 < Digest::Class
|
|
512
|
+
# <!--
|
|
513
|
+
# rdoc-file=ext/digest/sha2/lib/sha2.rb
|
|
514
|
+
# - Digest::SHA2.new(bitlen = 256) -> digest_obj
|
|
515
|
+
# -->
|
|
516
|
+
# Create a new SHA2 hash object with a given bit length.
|
|
517
|
+
#
|
|
518
|
+
# Valid bit lengths are 256, 384 and 512.
|
|
519
|
+
#
|
|
520
|
+
def initialize: (?(256 | 384 | 512) bitlen) -> void
|
|
521
|
+
|
|
522
|
+
# <!--
|
|
523
|
+
# rdoc-file=ext/digest/sha2/lib/sha2.rb
|
|
524
|
+
# - digest_obj.reset -> digest_obj
|
|
525
|
+
# -->
|
|
526
|
+
# Reset the digest to the initial state and return self.
|
|
527
|
+
#
|
|
528
|
+
def reset: () -> self
|
|
529
|
+
|
|
530
|
+
# <!--
|
|
531
|
+
# rdoc-file=ext/digest/sha2/lib/sha2.rb
|
|
532
|
+
# - digest_obj.update(string) -> digest_obj
|
|
533
|
+
# - digest_obj << string -> digest_obj
|
|
534
|
+
# -->
|
|
535
|
+
# Update the digest using a given *string* and return self.
|
|
536
|
+
#
|
|
537
|
+
def update: (String) -> self
|
|
538
|
+
|
|
539
|
+
private def finish: () -> String
|
|
540
|
+
|
|
541
|
+
# <!--
|
|
542
|
+
# rdoc-file=ext/digest/sha2/lib/sha2.rb
|
|
543
|
+
# - <<(str)
|
|
544
|
+
# -->
|
|
545
|
+
#
|
|
546
|
+
alias << update
|
|
547
|
+
|
|
548
|
+
# <!--
|
|
549
|
+
# rdoc-file=ext/digest/sha2/lib/sha2.rb
|
|
550
|
+
# - digest_obj.block_length -> Integer
|
|
551
|
+
# -->
|
|
552
|
+
# Return the block length of the digest in bytes.
|
|
553
|
+
#
|
|
554
|
+
# Digest::SHA256.new.block_length * 8
|
|
555
|
+
# # => 512
|
|
556
|
+
# Digest::SHA384.new.block_length * 8
|
|
557
|
+
# # => 1024
|
|
558
|
+
# Digest::SHA512.new.block_length * 8
|
|
559
|
+
# # => 1024
|
|
560
|
+
#
|
|
561
|
+
def block_length: () -> Integer
|
|
562
|
+
|
|
563
|
+
# <!--
|
|
564
|
+
# rdoc-file=ext/digest/sha2/lib/sha2.rb
|
|
565
|
+
# - digest_obj.digest_length -> Integer
|
|
566
|
+
# -->
|
|
567
|
+
# Return the length of the hash value (the digest) in bytes.
|
|
568
|
+
#
|
|
569
|
+
# Digest::SHA256.new.digest_length * 8
|
|
570
|
+
# # => 256
|
|
571
|
+
# Digest::SHA384.new.digest_length * 8
|
|
572
|
+
# # => 384
|
|
573
|
+
# Digest::SHA512.new.digest_length * 8
|
|
574
|
+
# # => 512
|
|
575
|
+
#
|
|
576
|
+
# For example, digests produced by Digest::SHA256 will always be 32 bytes (256
|
|
577
|
+
# bits) in size.
|
|
578
|
+
#
|
|
579
|
+
def digest_length: () -> Integer
|
|
580
|
+
|
|
581
|
+
def initialize_copy: (untyped) -> untyped
|
|
582
|
+
end
|
|
583
|
+
|
|
474
584
|
# <!-- rdoc-file=ext/digest/md5/md5init.c -->
|
|
475
585
|
# A class for calculating message digests using the MD5 Message-Digest Algorithm
|
|
476
586
|
# by RSA Data Security, Inc., described in RFC1321.
|