rbs 3.10.0.pre.2 → 3.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/c-check.yml +1 -1
  3. data/.github/workflows/comments.yml +3 -3
  4. data/.github/workflows/ruby.yml +7 -8
  5. data/CHANGELOG.md +60 -0
  6. data/core/array.rbs +52 -3
  7. data/core/comparable.rbs +13 -6
  8. data/core/complex.rbs +40 -25
  9. data/core/dir.rbs +2 -2
  10. data/core/encoding.rbs +3 -7
  11. data/core/enumerable.rbs +1 -1
  12. data/core/enumerator.rbs +43 -1
  13. data/core/fiber.rbs +26 -17
  14. data/core/file.rbs +23 -8
  15. data/core/file_test.rbs +1 -1
  16. data/core/float.rbs +223 -32
  17. data/core/gc.rbs +4 -9
  18. data/core/hash.rbs +9 -10
  19. data/core/integer.rbs +104 -63
  20. data/core/io/buffer.rbs +21 -10
  21. data/core/io.rbs +8 -8
  22. data/core/kernel.rbs +12 -8
  23. data/core/method.rbs +49 -19
  24. data/core/module.rbs +30 -12
  25. data/core/numeric.rbs +17 -9
  26. data/core/object_space.rbs +13 -20
  27. data/core/pathname.rbs +2 -37
  28. data/core/proc.rbs +15 -16
  29. data/core/ractor.rbs +156 -145
  30. data/core/range.rbs +1 -1
  31. data/core/rational.rbs +56 -34
  32. data/core/rbs/unnamed/argf.rbs +1 -1
  33. data/core/regexp.rbs +3 -3
  34. data/core/ruby.rbs +53 -0
  35. data/core/rubygems/version.rbs +2 -3
  36. data/core/set.rbs +88 -66
  37. data/core/signal.rbs +24 -14
  38. data/core/string.rbs +304 -166
  39. data/core/symbol.rbs +13 -7
  40. data/core/thread.rbs +12 -13
  41. data/core/trace_point.rbs +7 -4
  42. data/lib/rbs/collection/config/lockfile_generator.rb +7 -0
  43. data/lib/rbs/environment_loader.rb +0 -6
  44. data/lib/rbs/subtractor.rb +3 -1
  45. data/lib/rbs/test/type_check.rb +1 -0
  46. data/lib/rbs/version.rb +1 -1
  47. data/lib/rdoc/discover.rb +1 -1
  48. data/stdlib/bigdecimal/0/big_decimal.rbs +100 -82
  49. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  50. data/stdlib/cgi/0/core.rbs +11 -1
  51. data/stdlib/cgi-escape/0/escape.rbs +33 -15
  52. data/stdlib/date/0/date.rbs +67 -59
  53. data/stdlib/date/0/date_time.rbs +1 -1
  54. data/stdlib/json/0/json.rbs +1 -0
  55. data/stdlib/objspace/0/objspace.rbs +1 -1
  56. data/stdlib/openssl/0/openssl.rbs +150 -80
  57. data/stdlib/pathname/0/pathname.rbs +36 -0
  58. data/stdlib/psych/0/psych.rbs +3 -3
  59. data/stdlib/stringio/0/stringio.rbs +796 -37
  60. data/stdlib/strscan/0/string_scanner.rbs +1 -1
  61. data/stdlib/tempfile/0/tempfile.rbs +2 -2
  62. data/stdlib/time/0/time.rbs +1 -1
  63. data/stdlib/timeout/0/timeout.rbs +63 -7
  64. data/stdlib/uri/0/generic.rbs +1 -1
  65. metadata +4 -2
data/core/string.rbs CHANGED
@@ -187,10 +187,10 @@
187
187
  #
188
188
  # *Counts*
189
189
  #
190
- # * #length (aliased as #size): Returns the count of characters (not bytes).
191
- # * #empty?: Returns whether the length of `self` is zero.
192
190
  # * #bytesize: Returns the count of bytes.
193
191
  # * #count: Returns the count of substrings matching given strings.
192
+ # * #empty?: Returns whether the length of `self` is zero.
193
+ # * #length (aliased as #size): Returns the count of characters (not bytes).
194
194
  #
195
195
  # *Substrings*
196
196
  #
@@ -350,8 +350,8 @@
350
350
  # *Substitution*
351
351
  #
352
352
  # * #dump: Returns a printable version of `self`, enclosed in double-quotes.
353
- # * #undump: Returns a copy of `self` with all `\xNN` notations replaced by
354
- # `\uNNNN` notations and all escaped characters unescaped.
353
+ # * #undump: Inverse of #dump; returns a copy of `self` with changes of the
354
+ # kinds made by #dump "undone."
355
355
  # * #sub: Returns a copy of `self` with the first substring matching a given
356
356
  # pattern replaced with a given replacement string.
357
357
  # * #gsub: Returns a copy of `self` with each substring that matches a given
@@ -660,10 +660,10 @@
660
660
  #
661
661
  # *Counts*
662
662
  #
663
- # * #length (aliased as #size): Returns the count of characters (not bytes).
664
- # * #empty?: Returns whether the length of `self` is zero.
665
663
  # * #bytesize: Returns the count of bytes.
666
664
  # * #count: Returns the count of substrings matching given strings.
665
+ # * #empty?: Returns whether the length of `self` is zero.
666
+ # * #length (aliased as #size): Returns the count of characters (not bytes).
667
667
  #
668
668
  # *Substrings*
669
669
  #
@@ -823,8 +823,8 @@
823
823
  # *Substitution*
824
824
  #
825
825
  # * #dump: Returns a printable version of `self`, enclosed in double-quotes.
826
- # * #undump: Returns a copy of `self` with all `\xNN` notations replaced by
827
- # `\uNNNN` notations and all escaped characters unescaped.
826
+ # * #undump: Inverse of #dump; returns a copy of `self` with changes of the
827
+ # kinds made by #dump "undone."
828
828
  # * #sub: Returns a copy of `self` with the first substring matching a given
829
829
  # pattern replaced with a given replacement string.
830
830
  # * #gsub: Returns a copy of `self` with each substring that matches a given
@@ -1042,7 +1042,7 @@ class String
1042
1042
  # -->
1043
1043
  # Returns the result of formatting `object` into the format specifications
1044
1044
  # contained in `self` (see [Format
1045
- # Specifications](rdoc-ref:format_specifications.rdoc)):
1045
+ # Specifications](rdoc-ref:language/format_specifications.rdoc)):
1046
1046
  #
1047
1047
  # '%05d' % 123 # => "00123"
1048
1048
  #
@@ -1177,23 +1177,28 @@ class String
1177
1177
 
1178
1178
  # <!--
1179
1179
  # rdoc-file=string.c
1180
- # - self <=> other_string -> -1, 0, 1, or nil
1180
+ # - self <=> other -> -1, 0, 1, or nil
1181
1181
  # -->
1182
- # Compares `self` and `other_string`, returning:
1182
+ # Compares `self` and `other`, evaluating their *contents*, not their *lengths*.
1183
1183
  #
1184
- # * -1 if `other_string` is larger.
1185
- # * 0 if the two are equal.
1186
- # * 1 if `other_string` is smaller.
1187
- # * `nil` if the two are incomparable.
1184
+ # Returns:
1185
+ #
1186
+ # * `-1`, if `self` is smaller.
1187
+ # * `0`, if the two are equal.
1188
+ # * `1`, if `self` is larger.
1189
+ # * `nil`, if the two are incomparable.
1188
1190
  #
1189
1191
  # Examples:
1190
1192
  #
1191
- # 'foo' <=> 'foo' # => 0
1192
- # 'foo' <=> 'food' # => -1
1193
- # 'food' <=> 'foo' # => 1
1194
- # 'FOO' <=> 'foo' # => -1
1195
- # 'foo' <=> 'FOO' # => 1
1196
- # 'foo' <=> 1 # => nil
1193
+ # 'a' <=> 'b' # => -1
1194
+ # 'a' <=> 'ab' # => -1
1195
+ # 'a' <=> 'a' # => 0
1196
+ # 'b' <=> 'a' # => 1
1197
+ # 'ab' <=> 'a' # => 1
1198
+ # 'a' <=> :a # => nil
1199
+ #
1200
+ # Class String includes module Comparable, each of whose methods uses String#<=>
1201
+ # for comparison.
1197
1202
  #
1198
1203
  # Related: see [Comparing](rdoc-ref:String@Comparing).
1199
1204
  #
@@ -1306,7 +1311,7 @@ class String
1306
1311
  # 'hello'[0] # => "h"
1307
1312
  # 'hello'[4] # => "o"
1308
1313
  # 'hello'[5] # => nil
1309
- # 'тест'[2] # => "с"
1314
+ # 'Привет'[2] # => "и"
1310
1315
  # 'こんにちは'[4] # => "は"
1311
1316
  #
1312
1317
  # With negative integer argument `index` given, counts backward from the end of
@@ -1387,7 +1392,7 @@ class String
1387
1392
  # 'hello'['ell'] # => "ell"
1388
1393
  # 'hello'[''] # => ""
1389
1394
  # 'hello'['nosuch'] # => nil
1390
- # 'тест'['ес'] # => "ес"
1395
+ # 'Привет'['ив'] # => "ив"
1391
1396
  # 'こんにちは'['んにち'] # => "んにち"
1392
1397
  #
1393
1398
  # Related: see [Converting to New
@@ -1449,7 +1454,7 @@ class String
1449
1454
  # size `length` characters (as available) beginning at character offset
1450
1455
  # specified by `start`.
1451
1456
  #
1452
- # If argument `start` is non-negative, the offset is +start':
1457
+ # If argument `start` is non-negative, the offset is `start`:
1453
1458
  #
1454
1459
  # s = 'hello'
1455
1460
  # s[0, 1] = 'foo' # => "foo"
@@ -1576,9 +1581,9 @@ class String
1576
1581
  # s['ll'] = 'foo' # => "foo"
1577
1582
  # s # => "hefooo"
1578
1583
  #
1579
- # s = 'тест'
1580
- # s['ес'] = 'foo' # => "foo"
1581
- # s # => "тfooт"
1584
+ # s = 'Привет'
1585
+ # s['ив'] = 'foo' # => "foo"
1586
+ # s # => "Прfooет"
1582
1587
  #
1583
1588
  # s = 'こんにちは'
1584
1589
  # s['んにち'] = 'foo' # => "foo"
@@ -1817,8 +1822,8 @@ class String
1817
1822
  # -->
1818
1823
  # Returns an array of the bytes in `self`:
1819
1824
  #
1820
- # 'hello'.bytes # => [104, 101, 108, 108, 111]
1821
- # 'тест'.bytes # => [209, 130, 208, 181, 209, 129, 209, 130]
1825
+ # 'hello'.bytes # => [104, 101, 108, 108, 111]
1826
+ # 'Привет'.bytes # => [208, 159, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130]
1822
1827
  # 'こんにちは'.bytes
1823
1828
  # # => [227, 129, 147, 227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
1824
1829
  #
@@ -1840,9 +1845,9 @@ class String
1840
1845
  # s = 'foo'
1841
1846
  # s.bytesize # => 3
1842
1847
  # s.size # => 3
1843
- # s = 'тест'
1844
- # s.bytesize # => 8
1845
- # s.size # => 4
1848
+ # s = 'Привет'
1849
+ # s.bytesize # => 12
1850
+ # s.size # => 6
1846
1851
  # s = 'こんにちは'
1847
1852
  # s.bytesize # => 15
1848
1853
  # s.size # => 5
@@ -1989,23 +1994,30 @@ class String
1989
1994
 
1990
1995
  # <!--
1991
1996
  # rdoc-file=string.c
1992
- # - capitalize(mapping = :ascii) -> string
1997
+ # - capitalize(mapping = :ascii) -> new_string
1993
1998
  # -->
1994
1999
  # Returns a string containing the characters in `self`, each with possibly
1995
2000
  # changed case:
1996
2001
  #
1997
- # * The first character is upcased.
1998
- # * All other characters are downcased.
2002
+ # * The first character made uppercase.
2003
+ # * All other characters are made lowercase.
1999
2004
  #
2000
2005
  # Examples:
2001
2006
  #
2002
- # 'hello world'.capitalize # => "Hello world"
2003
- # 'HELLO WORLD'.capitalize # => "Hello world"
2007
+ # 'hello'.capitalize # => "Hello"
2008
+ # 'HELLO'.capitalize # => "Hello"
2009
+ # 'straße'.capitalize # => "Straße" # Lowercase 'ß' not changed.
2010
+ # 'STRAẞE'.capitalize # => "Straße" # Uppercase 'ẞ' downcased to 'ß'.
2011
+ # 'привет'.capitalize # => "Привет"
2012
+ # 'ПРИВЕТ'.capitalize # => "Привет"
2004
2013
  #
2005
- # Some characters do not have upcase and downcase, and so are not changed; see
2006
- # [Case Mapping](rdoc-ref:case_mapping.rdoc):
2014
+ # Some characters (and some character sets) do not have upcase and downcase
2015
+ # versions; see [Case Mapping](rdoc-ref:case_mapping.rdoc):
2007
2016
  #
2008
- # '1, 2, 3, ...'.capitalize # => "1, 2, 3, ..."
2017
+ # s = '1, 2, 3, ...'
2018
+ # s.capitalize == s # => true
2019
+ # s = 'こんにちは'
2020
+ # s.capitalize == s # => true
2009
2021
  #
2010
2022
  # The casing is affected by the given `mapping`, which may be `:ascii`, `:fold`,
2011
2023
  # or `:turkic`; see [Case Mappings](rdoc-ref:case_mapping.rdoc@Case+Mappings).
@@ -2101,7 +2113,7 @@ class String
2101
2113
  # 'hello'.center(20, '-|') # => "-|-|-|-hello-|-|-|-|" # Some padding repeated.
2102
2114
  # 'hello'.center(10, 'abcdefg') # => "abhelloabc" # Some padding not used.
2103
2115
  # ' hello '.center(13) # => " hello "
2104
- # 'тест'.center(10) # => " тест "
2116
+ # 'Привет'.center(10) # => " Привет "
2105
2117
  # 'こんにちは'.center(10) # => " こんにちは " # Multi-byte characters.
2106
2118
  #
2107
2119
  # If `size` is less than or equal to the size of `self`, returns an unpadded
@@ -2122,7 +2134,7 @@ class String
2122
2134
  # Returns an array of the characters in `self`:
2123
2135
  #
2124
2136
  # 'hello'.chars # => ["h", "e", "l", "l", "o"]
2125
- # 'тест'.chars # => ["т", "е", "с", "т"]
2137
+ # 'Привет'.chars # => ["П", "р", "и", "в", "е", "т"]
2126
2138
  # 'こんにちは'.chars # => ["こ", "ん", "に", "ち", "は"]
2127
2139
  # ''.chars # => []
2128
2140
  #
@@ -2631,18 +2643,25 @@ class String
2631
2643
 
2632
2644
  # <!--
2633
2645
  # rdoc-file=string.c
2634
- # - downcase(mapping) -> string
2646
+ # - downcase(mapping = :ascii) -> new_string
2635
2647
  # -->
2636
2648
  # Returns a new string containing the downcased characters in `self`:
2637
2649
  #
2638
- # 'Hello, World!'.downcase # => "hello, world!"
2639
- # 'ТЕСТ'.downcase # => "тест"
2640
- # 'よろしくお願いします'.downcase # => "よろしくお願いします"
2650
+ # 'HELLO'.downcase # => "hello"
2651
+ # 'STRAẞE'.downcase # => "straße"
2652
+ # 'ПРИВЕТ'.downcase # => "привет"
2653
+ # 'RubyGems.org'.downcase # => "rubygems.org"
2654
+ #
2655
+ # Some characters (and some character sets) do not have upcase and downcase
2656
+ # versions; see [Case Mapping](rdoc-ref:case_mapping.rdoc):
2641
2657
  #
2642
- # Some characters do not have upcased and downcased versions.
2658
+ # s = '1, 2, 3, ...'
2659
+ # s.downcase == s # => true
2660
+ # s = 'こんにちは'
2661
+ # s.downcase == s # => true
2643
2662
  #
2644
- # The casing may be affected by the given `mapping`; see [Case
2645
- # Mapping](rdoc-ref:case_mapping.rdoc).
2663
+ # The casing is affected by the given `mapping`, which may be `:ascii`, `:fold`,
2664
+ # or `:turkic`; see [Case Mappings](rdoc-ref:case_mapping.rdoc@Case+Mappings).
2646
2665
  #
2647
2666
  # Related: see [Converting to New
2648
2667
  # String](rdoc-ref:String@Converting+to+New+String).
@@ -2672,60 +2691,104 @@ class String
2672
2691
  # rdoc-file=string.c
2673
2692
  # - dump -> new_string
2674
2693
  # -->
2675
- # Returns a printable version of `self`, enclosed in double-quotes:
2694
+ # For an ordinary string, this method, +String#dump+, returns a printable
2695
+ # ASCII-only version of `self`, enclosed in double-quotes.
2696
+ #
2697
+ # For a dumped string, method String#undump is the inverse of +String#dump+; it
2698
+ # returns a "restored" version of `self`, where all the dumping changes have
2699
+ # been undone.
2676
2700
  #
2677
- # 'hello'.dump # => "\"hello\""
2701
+ # In the simplest case, the dumped string contains the original string, enclosed
2702
+ # in double-quotes; this example is done in `irb` (interactive Ruby), which uses
2703
+ # method `inspect` to render the results:
2678
2704
  #
2679
- # Certain special characters are rendered with escapes:
2705
+ # s = 'hello' # => "hello"
2706
+ # s.dump # => "\"hello\""
2707
+ # s.dump.undump # => "hello"
2680
2708
  #
2681
- # '"'.dump # => "\"\\\"\""
2682
- # '\\'.dump # => "\"\\\\\""
2709
+ # Keep in mind that in the second line above:
2683
2710
  #
2684
- # Non-printing characters are rendered with escapes:
2711
+ # * The outer double-quotes are put on by `inspect`, and *are* *not* part of
2712
+ # the output of #dump.
2713
+ # * The inner double-quotes *are* part of the output of `dump`, and are
2714
+ # escaped by `inspect` because they are within the outer double-quotes.
2715
+ #
2716
+ # To avoid confusion, we'll use this helper method to omit the outer
2717
+ # double-quotes:
2718
+ #
2719
+ # def dump(s)
2720
+ # print "String: ", s, "\n"
2721
+ # print "Dumped: ", s.dump, "\n"
2722
+ # print "Undumped: ", s.dump.undump, "\n"
2723
+ # end
2724
+ #
2725
+ # So that for string `'hello'`, we'll see:
2726
+ #
2727
+ # String: hello
2728
+ # Dumped: "hello"
2729
+ # Undumped: hello
2730
+ #
2731
+ # In a dump, certain special characters are escaped:
2732
+ #
2733
+ # String: "
2734
+ # Dumped: "\""
2735
+ # Undumped: "
2736
+ #
2737
+ # String: \
2738
+ # Dumped: "\\"
2739
+ # Undumped: \
2740
+ #
2741
+ # In a dump, unprintable characters are replaced by printable ones; the
2742
+ # unprintable characters are the whitespace characters (other than space
2743
+ # itself); here we see the ordinals for those characers, together with
2744
+ # explanatory text:
2745
+ #
2746
+ # h = {
2747
+ # 7 => 'Alert (BEL)',
2748
+ # 8 => 'Backspace (BS)',
2749
+ # 9 => 'Horizontal tab (HT)',
2750
+ # 10 => 'Linefeed (LF)',
2751
+ # 11 => 'Vertical tab (VT)',
2752
+ # 12 => 'Formfeed (FF)',
2753
+ # 13 => 'Carriage return (CR)'
2754
+ # }
2755
+ #
2756
+ # In this example, the dumped output is printed by method #inspect, and so
2757
+ # contains both outer double-quotes and escaped inner double-quotes:
2685
2758
  #
2686
2759
  # s = ''
2687
- # s << 7 # Alarm (bell).
2688
- # s << 8 # Back space.
2689
- # s << 9 # Horizontal tab.
2690
- # s << 10 # Line feed.
2691
- # s << 11 # Vertical tab.
2692
- # s << 12 # Form feed.
2693
- # s << 13 # Carriage return.
2694
- # s # => "\a\b\t\n\v\f\r"
2695
- # s.dump # => "\"\\a\\b\\t\\n\\v\\f\\r\""
2696
- #
2697
- # If `self` is encoded in UTF-8 and contains Unicode characters, renders Unicode
2698
- # characters in Unicode escape sequence:
2699
- #
2700
- # 'тест'.dump # => "\"\\u0442\\u0435\\u0441\\u0442\""
2701
- # 'こんにちは'.dump # => "\"\\u3053\\u3093\\u306B\\u3061\\u306F\""
2702
- #
2703
- # If the encoding of `self` is not ASCII-compatible (i.e.,
2704
- # `self.encoding.ascii_compatible?` returns `false`), renders all
2705
- # ASCII-compatible bytes as ASCII characters and all other bytes as hexadecimal.
2706
- # Appends `.dup.force_encoding(\"encoding\")`, where `<encoding>` is
2707
- # `self.encoding.name`:
2760
+ # h.keys.each {|i| s << i } # => [7, 8, 9, 10, 11, 12, 13]
2761
+ # s # => "\a\b\t\n\v\f\r"
2762
+ # s.dump # => "\"\\a\\b\\t\\n\\v\\f\\r\""
2708
2763
  #
2709
- # s = 'hello'
2710
- # s.encoding # => #<Encoding:UTF-8>
2711
- # s.dump # => "\"hello\""
2712
- # s.encode('utf-16').dump # => "\"\\xFE\\xFF\\x00h\\x00e\\x00l\\x00l\\x00o\".dup.force_encoding(\"UTF-16\")"
2713
- # s.encode('utf-16le').dump # => "\"h\\x00e\\x00l\\x00l\\x00o\\x00\".dup.force_encoding(\"UTF-16LE\")"
2764
+ # If `self` is encoded in UTF-8 and contains Unicode characters, each Unicode
2765
+ # character is dumped as a Unicode escape sequence:
2714
2766
  #
2715
- # s = 'тест'
2716
- # s.encoding # => #<Encoding:UTF-8>
2717
- # s.dump # => "\"\\u0442\\u0435\\u0441\\u0442\""
2718
- # s.encode('utf-16').dump # => "\"\\xFE\\xFF\\x04B\\x045\\x04A\\x04B\".dup.force_encoding(\"UTF-16\")"
2719
- # s.encode('utf-16le').dump # => "\"B\\x045\\x04A\\x04B\\x04\".dup.force_encoding(\"UTF-16LE\")"
2767
+ # String: тест
2768
+ # Dumped: "\u0442\u0435\u0441\u0442"
2769
+ # Undumped: тест
2720
2770
  #
2721
- # s = 'こんにちは'
2722
- # s.encoding # => #<Encoding:UTF-8>
2723
- # s.dump # => "\"\\u3053\\u3093\\u306B\\u3061\\u306F\""
2724
- # s.encode('utf-16').dump # => "\"\\xFE\\xFF0S0\\x930k0a0o\".dup.force_encoding(\"UTF-16\")"
2725
- # s.encode('utf-16le').dump # => "\"S0\\x930k0a0o0\".dup.force_encoding(\"UTF-16LE\")"
2771
+ # String: こんにちは
2772
+ # Dumped: "\u3053\u3093\u306B\u3061\u306F"
2773
+ # Undumped: こんにちは
2726
2774
  #
2727
- # Related: see [Converting to New
2728
- # String](rdoc-ref:String@Converting+to+New+String).
2775
+ # If the encoding of `self` is not ASCII-compatible (i.e., if
2776
+ # `self.encoding.ascii_compatible?` returns `false`), each ASCII-compatible byte
2777
+ # is dumped as an ASCII character, and all other bytes are dumped as
2778
+ # hexadecimal; also appends `.dup.force_encoding(\"encoding\")`, where
2779
+ # `<encoding>` is `self.encoding.name`:
2780
+ #
2781
+ # String: hello
2782
+ # Dumped: "\xFE\xFF\x00h\x00e\x00l\x00l\x00o".dup.force_encoding("UTF-16")
2783
+ # Undumped: hello
2784
+ #
2785
+ # String: тест
2786
+ # Dumped: "\xFE\xFF\x04B\x045\x04A\x04B".dup.force_encoding("UTF-16")
2787
+ # Undumped: тест
2788
+ #
2789
+ # String: こんにちは
2790
+ # Dumped: "\xFE\xFF0S0\x930k0a0o".dup.force_encoding("UTF-16")
2791
+ # Undumped: こんにちは
2729
2792
  #
2730
2793
  def dump: () -> String
2731
2794
 
@@ -3579,7 +3642,7 @@ class String
3579
3642
 
3580
3643
  # <!--
3581
3644
  # rdoc-file=string.c
3582
- # - lstrip -> new_string
3645
+ # - lstrip(*selectors) -> new_string
3583
3646
  # -->
3584
3647
  # Returns a copy of `self` with leading whitespace removed; see [Whitespace in
3585
3648
  # Strings](rdoc-ref:String@Whitespace+in+Strings):
@@ -3590,6 +3653,19 @@ class String
3590
3653
  # s.lstrip
3591
3654
  # # => "abc\u0000\t\n\v\f\r "
3592
3655
  #
3656
+ # If `selectors` are given, removes characters of `selectors` from the beginning
3657
+ # of `self`:
3658
+ #
3659
+ # s = "---abc+++"
3660
+ # s.lstrip("-") # => "abc+++"
3661
+ #
3662
+ # `selectors` must be valid character selectors (see [Character
3663
+ # Selectors](rdoc-ref:character_selectors.rdoc)), and may use any of its valid
3664
+ # forms, including negation, ranges, and escapes:
3665
+ #
3666
+ # "01234abc56789".lstrip("0-9") # "abc56789"
3667
+ # "01234abc56789".lstrip("0-9", "^4-6") # "4abc56789"
3668
+ #
3593
3669
  # Related: see [Converting to New
3594
3670
  # String](rdoc-ref:String@Converting+to+New+String).
3595
3671
  #
@@ -3597,7 +3673,7 @@ class String
3597
3673
 
3598
3674
  # <!--
3599
3675
  # rdoc-file=string.c
3600
- # - lstrip! -> self or nil
3676
+ # - lstrip!(*selectors) -> self or nil
3601
3677
  # -->
3602
3678
  # Like String#lstrip, except that:
3603
3679
  #
@@ -3856,8 +3932,8 @@ class String
3856
3932
  # `self`, not `self`.
3857
3933
  #
3858
3934
  # If `pattern` is a Regexp, performs the equivalent of `self.match(pattern)`
3859
- # (also setting [pattern-matching global
3860
- # variables](rdoc-ref:globals.md@Pattern+Matching)):
3935
+ # (also setting [matched-data
3936
+ # variables](rdoc-ref:language/globals.md@Matched+Data)):
3861
3937
  #
3862
3938
  # 'hello'.partition(/h/) # => ["", "h", "ello"]
3863
3939
  # 'hello'.partition(/l/) # => ["he", "l", "lo"]
@@ -3870,8 +3946,8 @@ class String
3870
3946
  #
3871
3947
  # If `pattern` is not a Regexp, converts it to a string (if it is not already
3872
3948
  # one), then performs the equivalent of `self.index(pattern)` (and does *not*
3873
- # set [pattern-matching global
3874
- # variables](rdoc-ref:globals.md@Pattern+Matching)):
3949
+ # set [matched-data global
3950
+ # variables](rdoc-ref:language/globals.md@Matched+Data)):
3875
3951
  #
3876
3952
  # 'hello'.partition('h') # => ["", "h", "ello"]
3877
3953
  # 'hello'.partition('l') # => ["he", "l", "lo"]
@@ -4061,8 +4137,8 @@ class String
4061
4137
  # `self`, not `self`.
4062
4138
  #
4063
4139
  # If `pattern` is a Regexp, searches for the last matching substring (also
4064
- # setting [pattern-matching global
4065
- # variables](rdoc-ref:globals.md@Pattern+Matching)):
4140
+ # setting [matched-data global
4141
+ # variables](rdoc-ref:language/globals.md@Matched+Data)):
4066
4142
  #
4067
4143
  # 'hello'.rpartition(/l/) # => ["hel", "l", "o"]
4068
4144
  # 'hello'.rpartition(/ll/) # => ["he", "ll", "o"]
@@ -4075,7 +4151,7 @@ class String
4075
4151
  #
4076
4152
  # If `pattern` is not a Regexp, converts it to a string (if it is not already
4077
4153
  # one), then searches for the last matching substring (and does *not* set
4078
- # [pattern-matching global variables](rdoc-ref:globals.md@Pattern+Matching)):
4154
+ # [matched-data global variables](rdoc-ref:language/globals.md@Matched+Data)):
4079
4155
  #
4080
4156
  # 'hello'.rpartition('l') # => ["hel", "l", "o"]
4081
4157
  # 'hello'.rpartition('ll') # => ["he", "ll", "o"]
@@ -4092,7 +4168,7 @@ class String
4092
4168
 
4093
4169
  # <!--
4094
4170
  # rdoc-file=string.c
4095
- # - rstrip -> new_string
4171
+ # - rstrip(*selectors) -> new_string
4096
4172
  # -->
4097
4173
  # Returns a copy of `self` with trailing whitespace removed; see [Whitespace in
4098
4174
  # Strings](rdoc-ref:String@Whitespace+in+Strings):
@@ -4102,6 +4178,19 @@ class String
4102
4178
  # s # => "\u0000\t\n\v\f\r abc\u0000\t\n\v\f\r "
4103
4179
  # s.rstrip # => "\u0000\t\n\v\f\r abc"
4104
4180
  #
4181
+ # If `selectors` are given, removes characters of `selectors` from the end of
4182
+ # `self`:
4183
+ #
4184
+ # s = "---abc+++"
4185
+ # s.rstrip("+") # => "---abc"
4186
+ #
4187
+ # `selectors` must be valid character selectors (see [Character
4188
+ # Selectors](rdoc-ref:character_selectors.rdoc)), and may use any of its valid
4189
+ # forms, including negation, ranges, and escapes:
4190
+ #
4191
+ # "01234abc56789".rstrip("0-9") # "01234abc"
4192
+ # "01234abc56789".rstrip("0-9", "^4-6") # "01234abc56"
4193
+ #
4105
4194
  # Related: see [Converting to New
4106
4195
  # String](rdoc-ref:String@Converting+to+New+String).
4107
4196
  #
@@ -4109,7 +4198,7 @@ class String
4109
4198
 
4110
4199
  # <!--
4111
4200
  # rdoc-file=string.c
4112
- # - rstrip! -> self or nil
4201
+ # - rstrip!(*selectors) -> self or nil
4113
4202
  # -->
4114
4203
  # Like String#rstrip, except that:
4115
4204
  #
@@ -4258,7 +4347,7 @@ class String
4258
4347
  # 'hello'[0] # => "h"
4259
4348
  # 'hello'[4] # => "o"
4260
4349
  # 'hello'[5] # => nil
4261
- # 'тест'[2] # => "с"
4350
+ # 'Привет'[2] # => "и"
4262
4351
  # 'こんにちは'[4] # => "は"
4263
4352
  #
4264
4353
  # With negative integer argument `index` given, counts backward from the end of
@@ -4339,7 +4428,7 @@ class String
4339
4428
  # 'hello'['ell'] # => "ell"
4340
4429
  # 'hello'[''] # => ""
4341
4430
  # 'hello'['nosuch'] # => nil
4342
- # 'тест'['ес'] # => "ес"
4431
+ # 'Привет'['ив'] # => "ив"
4343
4432
  # 'こんにちは'['んにち'] # => "んにち"
4344
4433
  #
4345
4434
  # Related: see [Converting to New
@@ -4564,7 +4653,7 @@ class String
4564
4653
 
4565
4654
  # <!--
4566
4655
  # rdoc-file=string.c
4567
- # - strip -> new_string
4656
+ # - strip(*selectors) -> new_string
4568
4657
  # -->
4569
4658
  # Returns a copy of `self` with leading and trailing whitespace removed; see
4570
4659
  # [Whitespace in Strings](rdoc-ref:String@Whitespace+in+Strings):
@@ -4574,6 +4663,20 @@ class String
4574
4663
  # # => "\u0000\t\n\v\f\r abc\u0000\t\n\v\f\r "
4575
4664
  # s.strip # => "abc"
4576
4665
  #
4666
+ # If `selectors` are given, removes characters of `selectors` from both ends of
4667
+ # `self`:
4668
+ #
4669
+ # s = "---abc+++"
4670
+ # s.strip("-+") # => "abc"
4671
+ # s.strip("+-") # => "abc"
4672
+ #
4673
+ # `selectors` must be valid character selectors (see [Character
4674
+ # Selectors](rdoc-ref:character_selectors.rdoc)), and may use any of its valid
4675
+ # forms, including negation, ranges, and escapes:
4676
+ #
4677
+ # "01234abc56789".strip("0-9") # "abc"
4678
+ # "01234abc56789".strip("0-9", "^4-6") # "4abc56"
4679
+ #
4577
4680
  # Related: see [Converting to New
4578
4681
  # String](rdoc-ref:String@Converting+to+New+String).
4579
4682
  #
@@ -4581,7 +4684,7 @@ class String
4581
4684
 
4582
4685
  # <!--
4583
4686
  # rdoc-file=string.c
4584
- # - strip! -> self or nil
4687
+ # - strip!(*selectors) -> self or nil
4585
4688
  # -->
4586
4689
  # Like String#strip, except that:
4587
4690
  #
@@ -4742,7 +4845,7 @@ class String
4742
4845
 
4743
4846
  # <!--
4744
4847
  # rdoc-file=string.c
4745
- # - swapcase(mapping) -> new_string
4848
+ # - swapcase(mapping = :ascii) -> new_string
4746
4849
  # -->
4747
4850
  # Returns a string containing the characters in `self`, with cases reversed:
4748
4851
  #
@@ -4751,16 +4854,28 @@ class String
4751
4854
  #
4752
4855
  # Examples:
4753
4856
  #
4754
- # 'Hello World!'.swapcase # => "hELLO wORLD!"
4755
- # 'тест'.swapcase # => "ТЕСТ"
4857
+ # 'Hello'.swapcase # => "hELLO"
4858
+ # 'Straße'.swapcase # => "sTRASSE"
4859
+ # 'Привет'.swapcase # => "пРИВЕТ"
4860
+ # 'RubyGems.org'.swapcase # => "rUBYgEMS.ORG"
4861
+ #
4862
+ # The sizes of `self` and the upcased result may differ:
4863
+ #
4864
+ # s = 'Straße'
4865
+ # s.size # => 6
4866
+ # s.swapcase # => "sTRASSE"
4867
+ # s.swapcase.size # => 7
4756
4868
  #
4757
- # Some characters (and even character sets) do not have casing:
4869
+ # Some characters (and some character sets) do not have upcase and downcase
4870
+ # versions; see [Case Mapping](rdoc-ref:case_mapping.rdoc):
4758
4871
  #
4759
- # '12345'.swapcase # => "12345"
4760
- # 'こんにちは'.swapcase # => "こんにちは"
4872
+ # s = '1, 2, 3, ...'
4873
+ # s.swapcase == s # => true
4874
+ # s = 'こんにちは'
4875
+ # s.swapcase == s # => true
4761
4876
  #
4762
- # The casing may be affected by the given `mapping`; see [Case
4763
- # Mapping](rdoc-ref:case_mapping.rdoc).
4877
+ # The casing is affected by the given `mapping`, which may be `:ascii`, `:fold`,
4878
+ # or `:turkic`; see [Case Mappings](rdoc-ref:case_mapping.rdoc@Case+Mappings).
4764
4879
  #
4765
4880
  # Related: see [Converting to New
4766
4881
  # String](rdoc-ref:String@Converting+to+New+String).
@@ -5149,16 +5264,13 @@ class String
5149
5264
 
5150
5265
  # <!--
5151
5266
  # rdoc-file=string.c
5152
- # - undump -> string
5267
+ # - undump -> new_string
5153
5268
  # -->
5154
- # Returns an unescaped version of `self`:
5269
+ # Inverse of String#dump; returns a copy of `self` with changes of the kinds
5270
+ # made by String#dump "undone."
5155
5271
  #
5156
- # s_orig = "\f\x00\xff\\\"" # => "\f\u0000\xFF\\\""
5157
- # s_dumped = s_orig.dump # => "\"\\f\\x00\\xFF\\\\\\\"\""
5158
- # s_undumped = s_dumped.undump # => "\f\u0000\xFF\\\""
5159
- # s_undumped == s_orig # => true
5160
- #
5161
- # Related: String#dump (inverse of String#undump).
5272
+ # Related: see [Converting to New
5273
+ # String](rdoc-ref:String@Converting+to+New+String).
5162
5274
  #
5163
5275
  def undump: () -> String
5164
5276
 
@@ -5179,21 +5291,22 @@ class String
5179
5291
  #
5180
5292
  # The encoding of `self` must be one of:
5181
5293
  #
5182
- # * Encoding::UTF_8
5183
- # * Encoding::UTF_16BE
5184
- # * Encoding::UTF_16LE
5185
- # * Encoding::UTF_32BE
5186
- # * Encoding::UTF_32LE
5187
- # * Encoding::GB18030
5188
- # * Encoding::UCS_2BE
5189
- # * Encoding::UCS_4BE
5294
+ # * `Encoding::UTF_8`.
5295
+ # * `Encoding::UTF_16BE`.
5296
+ # * `Encoding::UTF_16LE`.
5297
+ # * `Encoding::UTF_32BE`.
5298
+ # * `Encoding::UTF_32LE`.
5299
+ # * `Encoding::GB18030`.
5300
+ # * `Encoding::UCS_2BE`.
5301
+ # * `Encoding::UCS_4BE`.
5190
5302
  #
5191
5303
  # Examples:
5192
5304
  #
5193
- # "a\u0300".unicode_normalize # => "a"
5194
- # "\u00E0".unicode_normalize(:nfd) # => "a "
5305
+ # "a\u0300".unicode_normalize # => "à" # Lowercase 'a' with grave accens.
5306
+ # "a\u0300".unicode_normalize(:nfd) # => "à" # Same.
5195
5307
  #
5196
- # Related: String#unicode_normalize!, String#unicode_normalized?.
5308
+ # Related: see [Converting to New
5309
+ # String](rdoc-ref:String@Converting+to+New+String).
5197
5310
  #
5198
5311
  def unicode_normalize: (?:nfc | :nfd | :nfkc | :nfkd form) -> self
5199
5312
 
@@ -5239,7 +5352,7 @@ class String
5239
5352
  # - unpack(template, offset: 0) -> array
5240
5353
  # -->
5241
5354
  # Extracts data from `self` to form new objects; see [Packed
5242
- # Data](rdoc-ref:packed_data.rdoc).
5355
+ # Data](rdoc-ref:language/packed_data.rdoc).
5243
5356
  #
5244
5357
  # With a block given, calls the block with each unpacked object.
5245
5358
  #
@@ -5256,7 +5369,7 @@ class String
5256
5369
  # - unpack1(template, offset: 0) -> object
5257
5370
  # -->
5258
5371
  # Like String#unpack with no block, but unpacks and returns only the first
5259
- # extracted object. See [Packed Data](rdoc-ref:packed_data.rdoc).
5372
+ # extracted object. See [Packed Data](rdoc-ref:language/packed_data.rdoc).
5260
5373
  #
5261
5374
  # Related: see [Converting to
5262
5375
  # Non-String](rdoc-ref:String@Converting+to+Non--5CString).
@@ -5265,17 +5378,35 @@ class String
5265
5378
 
5266
5379
  # <!--
5267
5380
  # rdoc-file=string.c
5268
- # - upcase(mapping) -> string
5381
+ # - upcase(mapping = :ascii) -> new_string
5269
5382
  # -->
5270
- # Returns a string containing the upcased characters in `self`:
5383
+ # Returns a new string containing the upcased characters in `self`:
5384
+ #
5385
+ # 'hello'.upcase # => "HELLO"
5386
+ # 'straße'.upcase # => "STRASSE"
5387
+ # 'привет'.upcase # => "ПРИВЕТ"
5388
+ # 'RubyGems.org'.upcase # => "RUBYGEMS.ORG"
5271
5389
  #
5272
- # s = 'Hello World!' # => "Hello World!"
5273
- # s.upcase # => "HELLO WORLD!"
5390
+ # The sizes of `self` and the upcased result may differ:
5274
5391
  #
5275
- # The casing may be affected by the given `mapping`; see [Case
5276
- # Mapping](rdoc-ref:case_mapping.rdoc).
5392
+ # s = 'Straße'
5393
+ # s.size # => 6
5394
+ # s.upcase # => "STRASSE"
5395
+ # s.upcase.size # => 7
5277
5396
  #
5278
- # Related: String#upcase!, String#downcase, String#downcase!.
5397
+ # Some characters (and some character sets) do not have upcase and downcase
5398
+ # versions; see [Case Mapping](rdoc-ref:case_mapping.rdoc):
5399
+ #
5400
+ # s = '1, 2, 3, ...'
5401
+ # s.upcase == s # => true
5402
+ # s = 'こんにちは'
5403
+ # s.upcase == s # => true
5404
+ #
5405
+ # The casing is affected by the given `mapping`, which may be `:ascii`, `:fold`,
5406
+ # or `:turkic`; see [Case Mappings](rdoc-ref:case_mapping.rdoc@Case+Mappings).
5407
+ #
5408
+ # Related: see [Converting to New
5409
+ # String](rdoc-ref:String@Converting+to+New+String).
5279
5410
  #
5280
5411
  def upcase: () -> String
5281
5412
  | (:ascii | :lithuanian | :turkic) -> String
@@ -5286,18 +5417,12 @@ class String
5286
5417
  # rdoc-file=string.c
5287
5418
  # - upcase!(mapping) -> self or nil
5288
5419
  # -->
5289
- # Upcases the characters in `self`; returns `self` if any changes were made,
5290
- # `nil` otherwise:
5291
- #
5292
- # s = 'Hello World!' # => "Hello World!"
5293
- # s.upcase! # => "HELLO WORLD!"
5294
- # s # => "HELLO WORLD!"
5295
- # s.upcase! # => nil
5420
+ # Like String#upcase, except that:
5296
5421
  #
5297
- # The casing may be affected by the given `mapping`; see [Case
5298
- # Mapping](rdoc-ref:case_mapping.rdoc).
5422
+ # * Changes character casings in `self` (not in a copy of `self`).
5423
+ # * Returns `self` if any changes are made, `nil` otherwise.
5299
5424
  #
5300
- # Related: String#upcase, String#downcase, String#downcase!.
5425
+ # Related: See [Modifying](rdoc-ref:String@Modifying).
5301
5426
  #
5302
5427
  def upcase!: () -> self?
5303
5428
  | (:ascii | :lithuanian | :turkic) -> self?
@@ -5314,20 +5439,28 @@ class String
5314
5439
  # `self.succ`, and so on; the sequence terminates when value `other_string` is
5315
5440
  # reached; returns `self`:
5316
5441
  #
5317
- # 'a8'.upto('b6') {|s| print s, ' ' } # => "a8"
5442
+ # a = []
5443
+ # 'a'.upto('f') {|c| a.push(c) }
5444
+ # a # => ["a", "b", "c", "d", "e", "f"]
5318
5445
  #
5319
- # Output:
5446
+ # a = []
5447
+ # 'Ж'.upto('П') {|c| a.push(c) }
5448
+ # a # => ["Ж", "З", "И", "Й", "К", "Л", "М", "Н", "О", "П"]
5320
5449
  #
5321
- # a8 a9 b0 b1 b2 b3 b4 b5 b6
5450
+ # a = []
5451
+ # 'よ'.upto('ろ') {|c| a.push(c) }
5452
+ # a # => ["よ", "ら", "り", "る", "れ", "ろ"]
5453
+ #
5454
+ # a = []
5455
+ # 'a8'.upto('b6') {|c| a.push(c) }
5456
+ # a # => ["a8", "a9", "b0", "b1", "b2", "b3", "b4", "b5", "b6"]
5322
5457
  #
5323
5458
  # If argument `exclusive` is given as a truthy object, the last value is
5324
5459
  # omitted:
5325
5460
  #
5326
- # 'a8'.upto('b6', true) {|s| print s, ' ' } # => "a8"
5327
- #
5328
- # Output:
5329
- #
5330
- # a8 a9 b0 b1 b2 b3 b4 b5
5461
+ # a = []
5462
+ # 'a'.upto('f', true) {|c| a.push(c) }
5463
+ # a # => ["a", "b", "c", "d", "e"]
5331
5464
  #
5332
5465
  # If `other_string` would not be reached, does not call the block:
5333
5466
  #
@@ -5338,6 +5471,8 @@ class String
5338
5471
  #
5339
5472
  # 'a8'.upto('b6') # => #<Enumerator: "a8":upto("b6")>
5340
5473
  #
5474
+ # Related: see [Iterating](rdoc-ref:String@Iterating).
5475
+ #
5341
5476
  def upto: (string other_string, ?boolish exclusive) -> Enumerator[String, self]
5342
5477
  | (string other_string, ?boolish exclusive) { (String s) -> void } -> self
5343
5478
 
@@ -5345,11 +5480,14 @@ class String
5345
5480
  # rdoc-file=string.c
5346
5481
  # - valid_encoding? -> true or false
5347
5482
  # -->
5348
- # Returns `true` if `self` is encoded correctly, `false` otherwise:
5483
+ # Returns whether `self` is encoded correctly:
5349
5484
  #
5350
- # "\xc2\xa1".force_encoding(Encoding::UTF_8).valid_encoding? # => true
5351
- # "\xc2".force_encoding(Encoding::UTF_8).valid_encoding? # => false
5352
- # "\x80".force_encoding(Encoding::UTF_8).valid_encoding? # => false
5485
+ # s = 'Straße'
5486
+ # s.valid_encoding? # => true
5487
+ # s.encoding # => #<Encoding:UTF-8>
5488
+ # s.force_encoding(Encoding::ASCII).valid_encoding? # => false
5489
+ #
5490
+ # Related: see [Querying](rdoc-ref:String@Querying).
5353
5491
  #
5354
5492
  def valid_encoding?: () -> bool
5355
5493
  end