steep 0.11.1 → 0.12.0
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/workflows/ruby.yml +27 -0
- data/.gitmodules +3 -0
- data/CHANGELOG.md +5 -0
- data/README.md +48 -90
- data/Rakefile +10 -6
- data/Steepfile +1 -0
- data/bin/setup +1 -0
- data/bin/smoke_runner.rb +9 -14
- data/exe/rbs +3 -0
- data/exe/ruby-signature +3 -0
- data/exe/steep +1 -0
- data/lib/steep.rb +32 -26
- data/lib/steep/annotation_parser.rb +167 -0
- data/lib/steep/ast/annotation/collection.rb +7 -7
- data/lib/steep/ast/types.rb +60 -0
- data/lib/steep/ast/types/any.rb +1 -1
- data/lib/steep/ast/types/factory.rb +535 -0
- data/lib/steep/ast/types/name.rb +3 -3
- data/lib/steep/ast/types/var.rb +1 -1
- data/lib/steep/cli.rb +56 -240
- data/lib/steep/drivers/annotations.rb +36 -19
- data/lib/steep/drivers/check.rb +55 -91
- data/lib/steep/drivers/init.rb +54 -0
- data/lib/steep/drivers/langserver.rb +241 -150
- data/lib/steep/drivers/print_project.rb +56 -0
- data/lib/steep/drivers/signature_error_printer.rb +25 -0
- data/lib/steep/drivers/trace_printer.rb +25 -0
- data/lib/steep/drivers/utils/driver_helper.rb +26 -0
- data/lib/steep/drivers/validate.rb +18 -38
- data/lib/steep/drivers/vendor.rb +46 -0
- data/lib/steep/drivers/watch.rb +78 -140
- data/lib/steep/errors.rb +22 -13
- data/lib/steep/interface/interface.rb +91 -0
- data/lib/steep/interface/method.rb +0 -4
- data/lib/steep/interface/method_type.rb +362 -2
- data/lib/steep/interface/substitution.rb +22 -0
- data/lib/steep/project.rb +25 -233
- data/lib/steep/project/dsl.rb +132 -0
- data/lib/steep/project/file.rb +93 -76
- data/lib/steep/project/file_loader.rb +63 -0
- data/lib/steep/project/options.rb +7 -0
- data/lib/steep/project/target.rb +190 -0
- data/lib/steep/signature/errors.rb +25 -77
- data/lib/steep/signature/validator.rb +122 -0
- data/lib/steep/source.rb +12 -7
- data/lib/steep/subtyping/check.rb +357 -633
- data/lib/steep/subtyping/constraints.rb +2 -2
- data/lib/steep/subtyping/trace.rb +23 -0
- data/lib/steep/type_construction.rb +509 -455
- data/lib/steep/type_inference/constant_env.rb +16 -24
- data/lib/steep/type_inference/type_env.rb +26 -18
- data/lib/steep/version.rb +1 -1
- data/sample/Steepfile +6 -0
- data/sample/lib/conference.rb +12 -0
- data/sample/sig/conference.rbs +6 -0
- data/smoke/alias/Steepfile +4 -0
- data/smoke/alias/a.rb +2 -2
- data/smoke/alias/{a.rbi → a.rbs} +1 -1
- data/smoke/and/Steepfile +4 -0
- data/smoke/array/Steepfile +4 -0
- data/smoke/array/a.rb +2 -2
- data/smoke/array/b.rb +4 -4
- data/smoke/array/c.rb +2 -2
- data/smoke/block/Steepfile +5 -0
- data/smoke/block/{a.rbi → a.rbs} +1 -1
- data/smoke/block/{c.rbi → c.rbs} +0 -0
- data/smoke/block/d.rb +6 -6
- data/smoke/case/Steepfile +4 -0
- data/smoke/case/a.rb +4 -3
- data/smoke/class/Steepfile +4 -0
- data/smoke/class/a.rb +1 -4
- data/smoke/class/a.rbs +24 -0
- data/smoke/class/h.rb +6 -2
- data/smoke/class/{h.rbi → h.rbs} +1 -2
- data/smoke/class/i.rb +1 -2
- data/smoke/class/i.rbs +9 -0
- data/smoke/const/Steepfile +4 -0
- data/smoke/dstr/Steepfile +4 -0
- data/smoke/ensure/Steepfile +4 -0
- data/smoke/ensure/a.rb +1 -1
- data/smoke/enumerator/Steepfile +4 -0
- data/smoke/enumerator/a.rb +7 -7
- data/smoke/enumerator/b.rb +6 -6
- data/smoke/extension/Steepfile +4 -0
- data/smoke/extension/{a.rbi → a.rbs} +2 -2
- data/smoke/extension/{e.rbi → e.rbs} +2 -2
- data/smoke/hash/Steepfile +4 -0
- data/smoke/hash/{a.rbi → a.rbs} +0 -0
- data/smoke/hash/b.rb +2 -2
- data/smoke/hash/c.rb +1 -1
- data/smoke/hash/e.rbs +3 -0
- data/smoke/hash/f.rb +1 -1
- data/smoke/hello/Steepfile +4 -0
- data/smoke/hello/hello.rbs +7 -0
- data/smoke/if/Steepfile +4 -0
- data/smoke/implements/Steepfile +4 -0
- data/smoke/implements/a.rbs +6 -0
- data/smoke/initialize/Steepfile +4 -0
- data/smoke/initialize/a.rbs +3 -0
- data/smoke/integer/Steepfile +4 -0
- data/smoke/integer/a.rb +5 -3
- data/smoke/interface/Steepfile +4 -0
- data/smoke/interface/{a.rbi → a.rbs} +0 -0
- data/smoke/kwbegin/Steepfile +4 -0
- data/smoke/lambda/Steepfile +4 -0
- data/smoke/lambda/a.rb +9 -2
- data/smoke/literal/Steepfile +4 -0
- data/smoke/literal/{literal_methods.rbi → literal_methods.rbs} +0 -0
- data/smoke/map/Steepfile +4 -0
- data/smoke/map/a.rb +1 -1
- data/smoke/method/Steepfile +4 -0
- data/smoke/method/{a.rbi → a.rbs} +0 -0
- data/smoke/method/b.rb +1 -4
- data/smoke/method/d.rb +1 -0
- data/smoke/method/d.rbs +3 -0
- data/smoke/module/Steepfile +4 -0
- data/smoke/module/a.rb +1 -1
- data/smoke/module/a.rbs +16 -0
- data/smoke/module/c.rb +1 -1
- data/smoke/regexp/Steepfile +4 -0
- data/smoke/regexp/a.rb +2 -2
- data/smoke/regexp/b.rb +16 -16
- data/smoke/regression/Steepfile +5 -0
- data/smoke/regression/array.rb +2 -2
- data/smoke/regression/hash.rb +2 -2
- data/smoke/regression/poly_new.rb +2 -0
- data/smoke/regression/poly_new.rbs +4 -0
- data/smoke/regression/set_divide.rb +2 -2
- data/smoke/rescue/Steepfile +4 -0
- data/smoke/rescue/a.rb +1 -1
- data/smoke/self/Steepfile +4 -0
- data/smoke/self/a.rbs +4 -0
- data/smoke/skip/Steepfile +4 -0
- data/smoke/stdout/Steepfile +4 -0
- data/smoke/stdout/{a.rbi → a.rbs} +1 -1
- data/smoke/super/Steepfile +4 -0
- data/smoke/super/a.rbs +10 -0
- data/smoke/type_case/Steepfile +4 -0
- data/smoke/type_case/a.rb +1 -1
- data/smoke/yield/Steepfile +4 -0
- data/smoke/yield/a.rb +2 -2
- data/steep.gemspec +14 -7
- data/vendor/ruby-signature/.github/workflows/ruby.yml +27 -0
- data/vendor/ruby-signature/.gitignore +12 -0
- data/vendor/ruby-signature/.rubocop.yml +15 -0
- data/vendor/ruby-signature/BSDL +22 -0
- data/vendor/ruby-signature/COPYING +56 -0
- data/vendor/ruby-signature/Gemfile +6 -0
- data/vendor/ruby-signature/README.md +93 -0
- data/vendor/ruby-signature/Rakefile +66 -0
- data/vendor/ruby-signature/bin/annotate-with-rdoc +156 -0
- data/vendor/ruby-signature/bin/console +14 -0
- data/vendor/ruby-signature/bin/query-rdoc +103 -0
- data/vendor/ruby-signature/bin/setup +10 -0
- data/vendor/ruby-signature/bin/sort +88 -0
- data/vendor/ruby-signature/bin/test_runner.rb +17 -0
- data/vendor/ruby-signature/docs/CONTRIBUTING.md +97 -0
- data/vendor/ruby-signature/docs/sigs.md +148 -0
- data/vendor/ruby-signature/docs/stdlib.md +152 -0
- data/vendor/ruby-signature/docs/syntax.md +528 -0
- data/vendor/ruby-signature/exe/rbs +3 -0
- data/vendor/ruby-signature/exe/ruby-signature +7 -0
- data/vendor/ruby-signature/lib/ruby/signature.rb +64 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +29 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +29 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +391 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +364 -0
- data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +52 -0
- data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +54 -0
- data/vendor/ruby-signature/lib/ruby/signature/cli.rb +534 -0
- data/vendor/ruby-signature/lib/ruby/signature/constant.rb +28 -0
- data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +152 -0
- data/vendor/ruby-signature/lib/ruby/signature/definition.rb +172 -0
- data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +921 -0
- data/vendor/ruby-signature/lib/ruby/signature/environment.rb +283 -0
- data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +138 -0
- data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +126 -0
- data/vendor/ruby-signature/lib/ruby/signature/errors.rb +189 -0
- data/vendor/ruby-signature/lib/ruby/signature/location.rb +104 -0
- data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +125 -0
- data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +93 -0
- data/vendor/ruby-signature/lib/ruby/signature/parser.y +1343 -0
- data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +441 -0
- data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +579 -0
- data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +383 -0
- data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +48 -0
- data/vendor/ruby-signature/lib/ruby/signature/test.rb +28 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +63 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +290 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/setup.rb +58 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +324 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +185 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +256 -0
- data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +72 -0
- data/vendor/ruby-signature/lib/ruby/signature/types.rb +932 -0
- data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +140 -0
- data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +49 -0
- data/vendor/ruby-signature/lib/ruby/signature/version.rb +5 -0
- data/vendor/ruby-signature/lib/ruby/signature/writer.rb +271 -0
- data/vendor/ruby-signature/ruby-signature.gemspec +45 -0
- data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +3 -0
- data/vendor/ruby-signature/stdlib/base64/base64.rbs +15 -0
- data/vendor/ruby-signature/stdlib/builtin/array.rbs +1997 -0
- data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +280 -0
- data/vendor/ruby-signature/stdlib/builtin/binding.rbs +177 -0
- data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +35 -0
- data/vendor/ruby-signature/stdlib/builtin/class.rbs +145 -0
- data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +116 -0
- data/vendor/ruby-signature/stdlib/builtin/complex.rbs +400 -0
- data/vendor/ruby-signature/stdlib/builtin/constants.rbs +37 -0
- data/vendor/ruby-signature/stdlib/builtin/data.rbs +5 -0
- data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +2 -0
- data/vendor/ruby-signature/stdlib/builtin/dir.rbs +419 -0
- data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +606 -0
- data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +404 -0
- data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +260 -0
- data/vendor/ruby-signature/stdlib/builtin/errno.rbs +781 -0
- data/vendor/ruby-signature/stdlib/builtin/errors.rbs +582 -0
- data/vendor/ruby-signature/stdlib/builtin/exception.rbs +193 -0
- data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +40 -0
- data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +68 -0
- data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +12 -0
- data/vendor/ruby-signature/stdlib/builtin/file.rbs +476 -0
- data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +59 -0
- data/vendor/ruby-signature/stdlib/builtin/float.rbs +696 -0
- data/vendor/ruby-signature/stdlib/builtin/gc.rbs +121 -0
- data/vendor/ruby-signature/stdlib/builtin/hash.rbs +1029 -0
- data/vendor/ruby-signature/stdlib/builtin/integer.rbs +710 -0
- data/vendor/ruby-signature/stdlib/builtin/io.rbs +683 -0
- data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +574 -0
- data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +135 -0
- data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +141 -0
- data/vendor/ruby-signature/stdlib/builtin/math.rbs +66 -0
- data/vendor/ruby-signature/stdlib/builtin/method.rbs +182 -0
- data/vendor/ruby-signature/stdlib/builtin/module.rbs +248 -0
- data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +82 -0
- data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +409 -0
- data/vendor/ruby-signature/stdlib/builtin/object.rbs +824 -0
- data/vendor/ruby-signature/stdlib/builtin/proc.rbs +426 -0
- data/vendor/ruby-signature/stdlib/builtin/process.rbs +354 -0
- data/vendor/ruby-signature/stdlib/builtin/random.rbs +93 -0
- data/vendor/ruby-signature/stdlib/builtin/range.rbs +226 -0
- data/vendor/ruby-signature/stdlib/builtin/rational.rbs +424 -0
- data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +10 -0
- data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +131 -0
- data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +14 -0
- data/vendor/ruby-signature/stdlib/builtin/signal.rbs +55 -0
- data/vendor/ruby-signature/stdlib/builtin/string.rbs +770 -0
- data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +13 -0
- data/vendor/ruby-signature/stdlib/builtin/struct.rbs +40 -0
- data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +230 -0
- data/vendor/ruby-signature/stdlib/builtin/thread.rbs +1112 -0
- data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +23 -0
- data/vendor/ruby-signature/stdlib/builtin/time.rbs +739 -0
- data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +91 -0
- data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +46 -0
- data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +159 -0
- data/vendor/ruby-signature/stdlib/builtin/warning.rbs +17 -0
- data/vendor/ruby-signature/stdlib/erb/erb.rbs +18 -0
- data/vendor/ruby-signature/stdlib/find/find.rbs +44 -0
- data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +21 -0
- data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +23 -0
- data/vendor/ruby-signature/stdlib/prime/prime.rbs +188 -0
- data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +9 -0
- data/vendor/ruby-signature/stdlib/set/set.rbs +77 -0
- data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +53 -0
- metadata +244 -54
- data/.travis.yml +0 -7
- data/lib/steep/ast/signature/alias.rb +0 -19
- data/lib/steep/ast/signature/class.rb +0 -33
- data/lib/steep/ast/signature/const.rb +0 -17
- data/lib/steep/ast/signature/env.rb +0 -138
- data/lib/steep/ast/signature/extension.rb +0 -21
- data/lib/steep/ast/signature/gvar.rb +0 -17
- data/lib/steep/ast/signature/interface.rb +0 -31
- data/lib/steep/ast/signature/members.rb +0 -115
- data/lib/steep/ast/signature/module.rb +0 -21
- data/lib/steep/drivers/print_interface.rb +0 -94
- data/lib/steep/drivers/scaffold.rb +0 -321
- data/lib/steep/drivers/utils/each_signature.rb +0 -31
- data/lib/steep/interface/abstract.rb +0 -68
- data/lib/steep/interface/builder.rb +0 -637
- data/lib/steep/interface/instantiated.rb +0 -163
- data/lib/steep/interface/ivar_chain.rb +0 -26
- data/lib/steep/parser.y +0 -1278
- data/lib/steep/project/listener.rb +0 -53
- data/smoke/class/a.rbi +0 -24
- data/smoke/class/d.rb +0 -9
- data/smoke/class/e.rb +0 -12
- data/smoke/class/i.rbi +0 -9
- data/smoke/hash/e.rbi +0 -3
- data/smoke/hello/hello.rbi +0 -7
- data/smoke/implements/a.rbi +0 -6
- data/smoke/initialize/a.rbi +0 -3
- data/smoke/module/a.rbi +0 -16
- data/smoke/self/a.rbi +0 -4
- data/smoke/super/a.rbi +0 -10
- data/stdlib/builtin.rbi +0 -787
@@ -0,0 +1,131 @@
|
|
1
|
+
class Regexp < Object
|
2
|
+
def self.escape: (String | Symbol arg0) -> String
|
3
|
+
|
4
|
+
def self.last_match: () -> MatchData?
|
5
|
+
| (Integer n) -> String?
|
6
|
+
| (Symbol | String n) -> String?
|
7
|
+
|
8
|
+
def self.try_convert: (untyped obj) -> Regexp?
|
9
|
+
|
10
|
+
def ==: (untyped other) -> bool
|
11
|
+
|
12
|
+
def ===: (untyped other) -> bool
|
13
|
+
|
14
|
+
def =~: (String? str) -> Integer?
|
15
|
+
|
16
|
+
# Returns the value of the case-insensitive flag.
|
17
|
+
#
|
18
|
+
# ```ruby
|
19
|
+
# /a/.casefold? #=> false
|
20
|
+
# /a/i.casefold? #=> true
|
21
|
+
# /(?i:a)/.casefold? #=> false
|
22
|
+
# ```
|
23
|
+
def casefold?: () -> bool
|
24
|
+
|
25
|
+
# Returns the [Encoding](https://ruby-doc.org/core-2.6.3/Encoding.html)
|
26
|
+
# object that represents the encoding of obj.
|
27
|
+
def encoding: () -> Encoding
|
28
|
+
|
29
|
+
def fixed_encoding?: () -> bool
|
30
|
+
|
31
|
+
# Produce a hash based on the text and options of this regular expression.
|
32
|
+
#
|
33
|
+
# See also Object\#hash.
|
34
|
+
def hash: () -> Integer
|
35
|
+
|
36
|
+
def initialize: (String arg0, ?untyped options, ?String kcode) -> Object
|
37
|
+
| (Regexp arg0) -> void
|
38
|
+
|
39
|
+
# Produce a nicely formatted string-version of *rxp* . Perhaps
|
40
|
+
# surprisingly, `#inspect` actually produces the more natural version of
|
41
|
+
# the string than `#to_s` .
|
42
|
+
#
|
43
|
+
# ```ruby
|
44
|
+
# /ab+c/ix.inspect #=> "/ab+c/ix"
|
45
|
+
# ```
|
46
|
+
def inspect: () -> String
|
47
|
+
|
48
|
+
def match: (String? | Symbol | _ToStr arg0, ?Integer arg1) -> MatchData?
|
49
|
+
| (String? | Symbol | _ToStr arg0, ?Integer arg1) { (MatchData) -> untyped } -> untyped
|
50
|
+
|
51
|
+
def match?: (String? | Symbol | _ToStr arg0, ?Integer arg1) -> bool
|
52
|
+
|
53
|
+
def named_captures: () -> ::Hash[String, ::Array[Integer]]
|
54
|
+
|
55
|
+
def names: () -> ::Array[String]
|
56
|
+
|
57
|
+
# Returns the set of bits corresponding to the options used when creating
|
58
|
+
# this [Regexp](Regexp.downloaded.ruby_doc) (see `Regexp::new` for
|
59
|
+
# details. Note that additional bits may be set in the returned options:
|
60
|
+
# these are used internally by the regular expression code. These extra
|
61
|
+
# bits are ignored if the options are passed to `Regexp::new` .
|
62
|
+
#
|
63
|
+
# ```ruby
|
64
|
+
# Regexp::IGNORECASE #=> 1
|
65
|
+
# Regexp::EXTENDED #=> 2
|
66
|
+
# Regexp::MULTILINE #=> 4
|
67
|
+
#
|
68
|
+
# /cat/.options #=> 0
|
69
|
+
# /cat/ix.options #=> 3
|
70
|
+
# Regexp.new('cat', true).options #=> 1
|
71
|
+
# /\xa1\xa2/e.options #=> 16
|
72
|
+
#
|
73
|
+
# r = /cat/ix
|
74
|
+
# Regexp.new(r.source, r.options) #=> /cat/ix
|
75
|
+
# ```
|
76
|
+
def options: () -> Integer
|
77
|
+
|
78
|
+
# Returns the original string of the pattern.
|
79
|
+
#
|
80
|
+
# ```ruby
|
81
|
+
# /ab+c/ix.source #=> "ab+c"
|
82
|
+
# ```
|
83
|
+
#
|
84
|
+
# Note that escape sequences are retained as is.
|
85
|
+
#
|
86
|
+
# ```ruby
|
87
|
+
# /\x20\+/.source #=> "\\x20\\+"
|
88
|
+
# ```
|
89
|
+
def source: () -> String
|
90
|
+
|
91
|
+
# Returns a string containing the regular expression and its options
|
92
|
+
# (using the `(?opts:source)` notation. This string can be fed back in to
|
93
|
+
# `Regexp::new` to a regular expression with the same semantics as the
|
94
|
+
# original. (However, `Regexp#==` may not return true when comparing the
|
95
|
+
# two, as the source of the regular expression itself may differ, as the
|
96
|
+
# example shows). `Regexp#inspect` produces a generally more readable
|
97
|
+
# version of *rxp* .
|
98
|
+
#
|
99
|
+
# ```ruby
|
100
|
+
# r1 = /ab+c/ix #=> /ab+c/ix
|
101
|
+
# s1 = r1.to_s #=> "(?ix-m:ab+c)"
|
102
|
+
# r2 = Regexp.new(s1) #=> /(?ix-m:ab+c)/
|
103
|
+
# r1 == r2 #=> false
|
104
|
+
# r1.source #=> "ab+c"
|
105
|
+
# r2.source #=> "(?ix-m:ab+c)"
|
106
|
+
# ```
|
107
|
+
def to_s: () -> String
|
108
|
+
|
109
|
+
def ~: () -> Integer?
|
110
|
+
|
111
|
+
def self.compile: (String arg0, ?untyped options, ?String kcode) -> Regexp
|
112
|
+
| (Regexp arg0) -> Regexp
|
113
|
+
|
114
|
+
def self.quote: (String | Symbol arg0) -> String
|
115
|
+
|
116
|
+
def self.union: () -> Regexp
|
117
|
+
| (String | Regexp arg0, *String | Regexp args) -> Regexp
|
118
|
+
| (::Array[String | Regexp]) -> Regexp
|
119
|
+
|
120
|
+
def eql?: (untyped other) -> bool
|
121
|
+
end
|
122
|
+
|
123
|
+
Regexp::EXTENDED: Integer
|
124
|
+
|
125
|
+
Regexp::FIXEDENCODING: Integer
|
126
|
+
|
127
|
+
Regexp::IGNORECASE: Integer
|
128
|
+
|
129
|
+
Regexp::MULTILINE: Integer
|
130
|
+
|
131
|
+
Regexp::NOENCODING: Integer
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# The [RubyVM](RubyVM) module provides some access to
|
2
|
+
# Ruby internals. This module is for very limited purposes, such as
|
3
|
+
# debugging, prototyping, and research. Normal users must not use it.
|
4
|
+
class RubyVM < Object
|
5
|
+
end
|
6
|
+
|
7
|
+
RubyVM::DEFAULT_PARAMS: Hash[Symbol, Integer]
|
8
|
+
|
9
|
+
RubyVM::INSTRUCTION_NAMES: Array[String]
|
10
|
+
|
11
|
+
RubyVM::OPTS: Array[String]
|
12
|
+
|
13
|
+
class RubyVM::InstructionSequence < Object
|
14
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Many operating systems allow signals to be sent to running processes.
|
2
|
+
# Some signals have a defined effect on the process, while others may be
|
3
|
+
# trapped at the code level and acted upon. For example, your process may
|
4
|
+
# trap the USR1 signal and use it to toggle debugging, and may use TERM to
|
5
|
+
# initiate a controlled shutdown.
|
6
|
+
#
|
7
|
+
# ```ruby
|
8
|
+
# pid = fork do
|
9
|
+
# Signal.trap("USR1") do
|
10
|
+
# $debug = !$debug
|
11
|
+
# puts "Debug now: #$debug"
|
12
|
+
# end
|
13
|
+
# Signal.trap("TERM") do
|
14
|
+
# puts "Terminating..."
|
15
|
+
# shutdown()
|
16
|
+
# end
|
17
|
+
# # . . . do some work . . .
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# Process.detach(pid)
|
21
|
+
#
|
22
|
+
# # Controlling program:
|
23
|
+
# Process.kill("USR1", pid)
|
24
|
+
# # ...
|
25
|
+
# Process.kill("USR1", pid)
|
26
|
+
# # ...
|
27
|
+
# Process.kill("TERM", pid)
|
28
|
+
# ```
|
29
|
+
#
|
30
|
+
# produces:
|
31
|
+
#
|
32
|
+
# ```
|
33
|
+
# Debug now: true
|
34
|
+
# Debug now: false
|
35
|
+
# Terminating...
|
36
|
+
# ```
|
37
|
+
#
|
38
|
+
# The list of available signal names and their interpretation is system
|
39
|
+
# dependent. [Signal](Signal) delivery semantics may
|
40
|
+
# also vary between systems; in particular signal delivery may not always
|
41
|
+
# be reliable.
|
42
|
+
module Signal
|
43
|
+
# Returns a list of signal names mapped to the corresponding underlying
|
44
|
+
# signal numbers.
|
45
|
+
#
|
46
|
+
# ```ruby
|
47
|
+
# Signal.list #=> {"EXIT"=>0, "HUP"=>1, "INT"=>2, "QUIT"=>3, "ILL"=>4, "TRAP"=>5, "IOT"=>6, "ABRT"=>6, "FPE"=>8, "KILL"=>9, "BUS"=>7, "SEGV"=>11, "SYS"=>31, "PIPE"=>13, "ALRM"=>14, "TERM"=>15, "URG"=>23, "STOP"=>19, "TSTP"=>20, "CONT"=>18, "CHLD"=>17, "CLD"=>17, "TTIN"=>21, "TTOU"=>22, "IO"=>29, "XCPU"=>24, "XFSZ"=>25, "VTALRM"=>26, "PROF"=>27, "WINCH"=>28, "USR1"=>10, "USR2"=>12, "PWR"=>30, "POLL"=>29}
|
48
|
+
# ```
|
49
|
+
def self.list: () -> ::Hash[String, Integer]
|
50
|
+
|
51
|
+
def self.signame: (Integer arg0) -> String?
|
52
|
+
|
53
|
+
def self.trap: (Integer | String | Symbol signal, ?untyped command) -> (String | Proc)
|
54
|
+
| (Integer | String | Symbol signal) { (Integer arg0) -> untyped } -> (String | Proc)
|
55
|
+
end
|
@@ -0,0 +1,770 @@
|
|
1
|
+
# A `String` object holds and manipulates an arbitrary sequence of bytes,
|
2
|
+
# typically representing characters. [String](String)
|
3
|
+
# objects may be created using `String::new` or as literals.
|
4
|
+
#
|
5
|
+
# Because of aliasing issues, users of strings should be aware of the
|
6
|
+
# methods that modify the contents of a `String` object. Typically,
|
7
|
+
# methods with names ending in “\!” modify their receiver, while those
|
8
|
+
# without a “\!” return a new `String` . However, there are exceptions,
|
9
|
+
# such as `String#[]=` .
|
10
|
+
class String < Object
|
11
|
+
include Comparable
|
12
|
+
|
13
|
+
def %: (Object arg0) -> String
|
14
|
+
|
15
|
+
def *: (Integer arg0) -> String
|
16
|
+
|
17
|
+
def +: (String arg0) -> String
|
18
|
+
|
19
|
+
def <<: (Object arg0) -> String
|
20
|
+
|
21
|
+
def <=>: (String other) -> Integer?
|
22
|
+
|
23
|
+
def ==: (untyped arg0) -> bool
|
24
|
+
|
25
|
+
def ===: (untyped arg0) -> bool
|
26
|
+
|
27
|
+
%a{rbs:test:skip}
|
28
|
+
def =~: (Object arg0) -> Integer?
|
29
|
+
|
30
|
+
def []: (Integer arg0, ?Integer arg1) -> String?
|
31
|
+
| (::Range[Integer] | Regexp arg0) -> String?
|
32
|
+
| (Regexp arg0, ?Integer arg1) -> String?
|
33
|
+
| (Regexp arg0, ?String arg1) -> String?
|
34
|
+
| (String arg0) -> String?
|
35
|
+
|
36
|
+
# Returns true for a string which has only ASCII characters.
|
37
|
+
#
|
38
|
+
# ```ruby
|
39
|
+
# "abc".force_encoding("UTF-8").ascii_only? #=> true
|
40
|
+
# "abc\u{6666}".force_encoding("UTF-8").ascii_only? #=> false
|
41
|
+
# ```
|
42
|
+
def ascii_only?: () -> bool
|
43
|
+
|
44
|
+
# Returns a copied string whose encoding is ASCII-8BIT.
|
45
|
+
def b: () -> String
|
46
|
+
|
47
|
+
# Returns an array of bytes in *str* . This is a shorthand for
|
48
|
+
# `str.each_byte.to_a` .
|
49
|
+
#
|
50
|
+
# If a block is given, which is a deprecated form, works the same as
|
51
|
+
# `each_byte` .
|
52
|
+
def bytes: () -> Array[String]
|
53
|
+
|
54
|
+
# Returns the length of `str` in bytes.
|
55
|
+
#
|
56
|
+
# "\x80\u3042".bytesize #=> 4
|
57
|
+
# "hello".bytesize #=> 5
|
58
|
+
def bytesize: () -> Integer
|
59
|
+
|
60
|
+
def byteslice: (Integer arg0, ?Integer arg1) -> String?
|
61
|
+
| (::Range[Integer] arg0) -> String?
|
62
|
+
|
63
|
+
# Returns a copy of *str* with the first character converted to uppercase
|
64
|
+
# and the remainder to lowercase.
|
65
|
+
#
|
66
|
+
# See [\#downcase](String.downloaded.ruby_doc#method-i-downcase) for
|
67
|
+
# meaning of `options` and use with different encodings.
|
68
|
+
#
|
69
|
+
# ```ruby
|
70
|
+
# "hello".capitalize #=> "Hello"
|
71
|
+
# "HELLO".capitalize #=> "Hello"
|
72
|
+
# "123ABC".capitalize #=> "123abc"
|
73
|
+
# ```
|
74
|
+
def capitalize: () -> String
|
75
|
+
|
76
|
+
# Modifies *str* by converting the first character to uppercase and the
|
77
|
+
# remainder to lowercase. Returns `nil` if no changes are made. There is
|
78
|
+
# an exception for modern Georgian (mkhedruli/MTAVRULI), where the result
|
79
|
+
# is the same as for
|
80
|
+
# [\#downcase](String.downloaded.ruby_doc#method-i-downcase), to avoid
|
81
|
+
# mixed case.
|
82
|
+
#
|
83
|
+
# See [\#downcase](String.downloaded.ruby_doc#method-i-downcase) for
|
84
|
+
# meaning of `options` and use with different encodings.
|
85
|
+
#
|
86
|
+
# ```ruby
|
87
|
+
# a = "hello"
|
88
|
+
# a.capitalize! #=> "Hello"
|
89
|
+
# a #=> "Hello"
|
90
|
+
# a.capitalize! #=> nil
|
91
|
+
# ```
|
92
|
+
def capitalize!: () -> String?
|
93
|
+
|
94
|
+
def casecmp: (String arg0) -> Integer?
|
95
|
+
|
96
|
+
def center: (Integer arg0, ?String arg1) -> String
|
97
|
+
|
98
|
+
# Returns an array of characters in *str* . This is a shorthand for
|
99
|
+
# `str.each_char.to_a` .
|
100
|
+
#
|
101
|
+
# If a block is given, which is a deprecated form, works the same as
|
102
|
+
# `each_char` .
|
103
|
+
def chars: () -> Array[String]
|
104
|
+
|
105
|
+
def chomp: (?String arg0) -> String
|
106
|
+
|
107
|
+
def chomp!: (?String arg0) -> String?
|
108
|
+
|
109
|
+
# Returns a new `String` with the last character removed. If the string
|
110
|
+
# ends with `\r\n`, both characters are removed. Applying `chop` to an
|
111
|
+
# empty string returns an empty string. `String#chomp` is often a safer
|
112
|
+
# alternative, as it leaves the string unchanged if it doesn’t end in a
|
113
|
+
# record separator.
|
114
|
+
#
|
115
|
+
# ```ruby
|
116
|
+
# "string\r\n".chop #=> "string"
|
117
|
+
# "string\n\r".chop #=> "string\n"
|
118
|
+
# "string\n".chop #=> "string"
|
119
|
+
# "string".chop #=> "strin"
|
120
|
+
# "x".chop.chop #=> ""
|
121
|
+
# ```
|
122
|
+
def chop: () -> String
|
123
|
+
|
124
|
+
# Processes *str* as for `String#chop`, returning *str* , or `nil` if
|
125
|
+
# *str* is the empty string. See also `String#chomp!` .
|
126
|
+
def chop!: () -> String?
|
127
|
+
|
128
|
+
# Returns a one-character string at the beginning of the string.
|
129
|
+
#
|
130
|
+
# ```ruby
|
131
|
+
# a = "abcde"
|
132
|
+
# a.chr #=> "a"
|
133
|
+
# ```
|
134
|
+
def chr: () -> String
|
135
|
+
|
136
|
+
# Makes string empty.
|
137
|
+
#
|
138
|
+
# ```ruby
|
139
|
+
# a = "abcde"
|
140
|
+
# a.clear #=> ""
|
141
|
+
# ```
|
142
|
+
def clear: () -> String
|
143
|
+
|
144
|
+
# Returns an array of the `Integer` ordinals of the characters in *str* .
|
145
|
+
# This is a shorthand for `str.each_codepoint.to_a` .
|
146
|
+
#
|
147
|
+
# If a block is given, which is a deprecated form, works the same as
|
148
|
+
# `each_codepoint` .
|
149
|
+
def codepoints: () -> ::Array[Integer]
|
150
|
+
| () { () -> untyped } -> ::Array[Integer]
|
151
|
+
|
152
|
+
def concat: (Integer | Object arg0) -> String
|
153
|
+
|
154
|
+
def count: (String arg0, *String arg1) -> Integer
|
155
|
+
|
156
|
+
def crypt: (String arg0) -> String
|
157
|
+
|
158
|
+
def delete: (String arg0, *String arg1) -> String
|
159
|
+
|
160
|
+
def delete!: (String arg0, *String arg1) -> String?
|
161
|
+
|
162
|
+
def delete_prefix: (String) -> String
|
163
|
+
|
164
|
+
def delete_prefix!: (String) -> String?
|
165
|
+
|
166
|
+
def delete_suffix: (String) -> String
|
167
|
+
|
168
|
+
def delete_suffix!: (String) -> String?
|
169
|
+
|
170
|
+
# Returns a copy of *str* with all uppercase letters replaced with their
|
171
|
+
# lowercase counterparts. Which letters exactly are replaced, and by which
|
172
|
+
# other letters, depends on the presence or absence of options, and on the
|
173
|
+
# `encoding` of the string.
|
174
|
+
#
|
175
|
+
# The meaning of the `options` is as follows:
|
176
|
+
#
|
177
|
+
# - No option
|
178
|
+
# Full Unicode case mapping, suitable for most languages (see :turkic
|
179
|
+
# and :lithuanian options below for exceptions). Context-dependent
|
180
|
+
# case mapping as described in Table 3-14 of the Unicode standard is
|
181
|
+
# currently not supported.
|
182
|
+
#
|
183
|
+
# - :ascii
|
184
|
+
# Only the ASCII region, i.e. the characters “A” to “Z” and “a” to
|
185
|
+
# “z”, are affected. This option cannot be combined with any other
|
186
|
+
# option.
|
187
|
+
#
|
188
|
+
# - :turkic
|
189
|
+
# Full Unicode case mapping, adapted for Turkic languages (Turkish,
|
190
|
+
# Azerbaijani, …). This means that upper case I is mapped to lower
|
191
|
+
# case dotless i, and so on.
|
192
|
+
#
|
193
|
+
# - :lithuanian
|
194
|
+
# Currently, just full Unicode case mapping. In the future, full
|
195
|
+
# Unicode case mapping adapted for Lithuanian (keeping the dot on the
|
196
|
+
# lower case i even if there is an accent on top).
|
197
|
+
#
|
198
|
+
# - :fold
|
199
|
+
# Only available on `downcase` and `downcase!` . Unicode case
|
200
|
+
# **folding** , which is more far-reaching than Unicode case mapping.
|
201
|
+
# This option currently cannot be combined with any other option (i.e.
|
202
|
+
# there is currently no variant for turkic languages).
|
203
|
+
#
|
204
|
+
# Please note that several assumptions that are valid for ASCII-only case
|
205
|
+
# conversions do not hold for more general case conversions. For example,
|
206
|
+
# the length of the result may not be the same as the length of the input
|
207
|
+
# (neither in characters nor in bytes), some roundtrip assumptions (e.g.
|
208
|
+
# str.downcase == str.upcase.downcase) may not apply, and Unicode
|
209
|
+
# normalization (i.e.
|
210
|
+
# [\#unicode\_normalize](String.downloaded.ruby_doc#method-i-unicode_normalize)
|
211
|
+
# ) is not necessarily maintained by case mapping operations.
|
212
|
+
#
|
213
|
+
# Non-ASCII case mapping/folding is currently supported for UTF-8,
|
214
|
+
# UTF-16BE/LE, UTF-32BE/LE, and ISO-8859-1\~16 Strings/Symbols. This
|
215
|
+
# support will be extended to other encodings.
|
216
|
+
#
|
217
|
+
# ```ruby
|
218
|
+
# "hEllO".downcase #=> "hello"
|
219
|
+
# ```
|
220
|
+
def downcase: () -> String
|
221
|
+
|
222
|
+
# Downcases the contents of *str* , returning `nil` if no changes were
|
223
|
+
# made.
|
224
|
+
#
|
225
|
+
# See [\#downcase](String.downloaded.ruby_doc#method-i-downcase) for
|
226
|
+
# meaning of `options` and use with different encodings.
|
227
|
+
def downcase!: () -> String?
|
228
|
+
|
229
|
+
# Produces a version of `str` with all non-printing characters replaced by
|
230
|
+
# `\nnn` notation and all special characters escaped.
|
231
|
+
#
|
232
|
+
# ```ruby
|
233
|
+
# "hello \n ''".dump #=> "\"hello \\n ''\""
|
234
|
+
# ```
|
235
|
+
def dump: () -> String
|
236
|
+
|
237
|
+
def each_byte: () { (Integer arg0) -> untyped } -> String
|
238
|
+
| () -> ::Enumerator[Integer, self]
|
239
|
+
|
240
|
+
def each_char: () { (String arg0) -> untyped } -> String
|
241
|
+
| () -> ::Enumerator[String, self]
|
242
|
+
|
243
|
+
def each_codepoint: () { (Integer arg0) -> untyped } -> String
|
244
|
+
| () -> ::Enumerator[Integer, self]
|
245
|
+
|
246
|
+
def each_line: (?String arg0) { (String arg0) -> untyped } -> String
|
247
|
+
| (?String arg0) -> ::Enumerator[String, self]
|
248
|
+
|
249
|
+
# Returns `true` if *str* has a length of zero.
|
250
|
+
#
|
251
|
+
# ```ruby
|
252
|
+
# "hello".empty? #=> false
|
253
|
+
# " ".empty? #=> false
|
254
|
+
# "".empty? #=> true
|
255
|
+
# ```
|
256
|
+
def empty?: () -> bool
|
257
|
+
|
258
|
+
# Returns the [Encoding](https://ruby-doc.org/core-2.6.3/Encoding.html)
|
259
|
+
# object that represents the encoding of obj.
|
260
|
+
def encoding: () -> Encoding
|
261
|
+
|
262
|
+
def end_with?: (*String arg0) -> bool
|
263
|
+
|
264
|
+
def eql?: (String arg0) -> bool
|
265
|
+
|
266
|
+
def force_encoding: (String | Encoding arg0) -> String
|
267
|
+
|
268
|
+
def getbyte: (Integer arg0) -> Integer?
|
269
|
+
|
270
|
+
def gsub: (Regexp | String arg0, ?String arg1) -> String
|
271
|
+
| (Regexp | String arg0, ?Hash[String, String] arg1) -> String
|
272
|
+
| (Regexp | String arg0) { (String arg0) -> untyped } -> String
|
273
|
+
| (Regexp | String arg0) -> ::Enumerator[String, self]
|
274
|
+
| (Regexp | String arg0) -> String
|
275
|
+
|
276
|
+
def gsub!: (Regexp | String arg0, ?String arg1) -> String?
|
277
|
+
| (Regexp | String arg0) { (String arg0) -> untyped } -> String?
|
278
|
+
| (Regexp | String arg0) -> ::Enumerator[String, self]
|
279
|
+
|
280
|
+
# Returns a hash based on the string’s length, content and encoding.
|
281
|
+
#
|
282
|
+
# See also Object\#hash.
|
283
|
+
def hash: () -> Integer
|
284
|
+
|
285
|
+
# Treats leading characters from *str* as a string of hexadecimal digits
|
286
|
+
# (with an optional sign and an optional `0x` ) and returns the
|
287
|
+
# corresponding number. Zero is returned on error.
|
288
|
+
#
|
289
|
+
# ```ruby
|
290
|
+
# "0x0a".hex #=> 10
|
291
|
+
# "-1234".hex #=> -4660
|
292
|
+
# "0".hex #=> 0
|
293
|
+
# "wombat".hex #=> 0
|
294
|
+
# ```
|
295
|
+
def hex: () -> Integer
|
296
|
+
|
297
|
+
def `include?`: (String arg0) -> bool
|
298
|
+
|
299
|
+
def index: (Regexp | String arg0, ?Integer arg1) -> Integer?
|
300
|
+
|
301
|
+
def initialize: (?String str, ?encoding: Encoding | String, ?capacity: Integer) -> void
|
302
|
+
|
303
|
+
def insert: (Integer arg0, String arg1) -> String
|
304
|
+
|
305
|
+
# Returns a printable version of *str* , surrounded by quote marks, with
|
306
|
+
# special characters escaped.
|
307
|
+
#
|
308
|
+
# ```ruby
|
309
|
+
# str = "hello"
|
310
|
+
# str[3] = "\b"
|
311
|
+
# str.inspect #=> "\"hel\\bo\""
|
312
|
+
# ```
|
313
|
+
def inspect: () -> String
|
314
|
+
|
315
|
+
# Returns the `Symbol` corresponding to *str* , creating the symbol if it
|
316
|
+
# did not previously exist. See `Symbol#id2name` .
|
317
|
+
#
|
318
|
+
# ```ruby
|
319
|
+
# "Koala".intern #=> :Koala
|
320
|
+
# s = 'cat'.to_sym #=> :cat
|
321
|
+
# s == :cat #=> true
|
322
|
+
# s = '@cat'.to_sym #=> :@cat
|
323
|
+
# s == :@cat #=> true
|
324
|
+
# ```
|
325
|
+
#
|
326
|
+
# This can also be used to create symbols that cannot be represented using
|
327
|
+
# the `:xxx` notation.
|
328
|
+
#
|
329
|
+
# ```ruby
|
330
|
+
# 'cat and dog'.to_sym #=> :"cat and dog"
|
331
|
+
# ```
|
332
|
+
def intern: () -> Symbol
|
333
|
+
|
334
|
+
# Returns the character length of *str* .
|
335
|
+
def length: () -> Integer
|
336
|
+
|
337
|
+
def lines: (?String arg0) -> ::Array[String]
|
338
|
+
|
339
|
+
def ljust: (Integer arg0, ?String arg1) -> String
|
340
|
+
|
341
|
+
# Returns a copy of the receiver with leading whitespace removed. See also
|
342
|
+
# [\#rstrip](String.downloaded.ruby_doc#method-i-rstrip) and
|
343
|
+
# [\#strip](String.downloaded.ruby_doc#method-i-strip).
|
344
|
+
#
|
345
|
+
# Refer to [\#strip](String.downloaded.ruby_doc#method-i-strip) for the
|
346
|
+
# definition of whitespace.
|
347
|
+
#
|
348
|
+
# ```ruby
|
349
|
+
# " hello ".lstrip #=> "hello "
|
350
|
+
# "hello".lstrip #=> "hello"
|
351
|
+
# ```
|
352
|
+
def lstrip: () -> String
|
353
|
+
|
354
|
+
# Removes leading whitespace from the receiver. Returns the altered
|
355
|
+
# receiver, or `nil` if no change was made. See also
|
356
|
+
# [\#rstrip\!](String.downloaded.ruby_doc#method-i-rstrip-21) and
|
357
|
+
# [\#strip\!](String.downloaded.ruby_doc#method-i-strip-21).
|
358
|
+
#
|
359
|
+
# Refer to [\#strip](String.downloaded.ruby_doc#method-i-strip) for the
|
360
|
+
# definition of whitespace.
|
361
|
+
#
|
362
|
+
# ```ruby
|
363
|
+
# " hello ".lstrip! #=> "hello "
|
364
|
+
# "hello ".lstrip! #=> nil
|
365
|
+
# "hello".lstrip! #=> nil
|
366
|
+
# ```
|
367
|
+
def lstrip!: () -> String?
|
368
|
+
|
369
|
+
def match: (Regexp | String arg0) -> MatchData?
|
370
|
+
| (Regexp | String arg0, ?Integer arg1) -> MatchData?
|
371
|
+
|
372
|
+
def match?: (Regexp | String arg0) -> bool
|
373
|
+
| (Regexp | String arg0, ?Integer arg1) -> bool
|
374
|
+
|
375
|
+
# Returns the successor to *str* . The successor is calculated by
|
376
|
+
# incrementing characters starting from the rightmost alphanumeric (or the
|
377
|
+
# rightmost character if there are no alphanumerics) in the string.
|
378
|
+
# Incrementing a digit always results in another digit, and incrementing a
|
379
|
+
# letter results in another letter of the same case. Incrementing
|
380
|
+
# nonalphanumerics uses the underlying character set’s collating sequence.
|
381
|
+
#
|
382
|
+
# If the increment generates a “carry,” the character to the left of it is
|
383
|
+
# incremented. This process repeats until there is no carry, adding an
|
384
|
+
# additional character if necessary.
|
385
|
+
#
|
386
|
+
# ```ruby
|
387
|
+
# "abcd".succ #=> "abce"
|
388
|
+
# "THX1138".succ #=> "THX1139"
|
389
|
+
# "<<koala>>".succ #=> "<<koalb>>"
|
390
|
+
# "1999zzz".succ #=> "2000aaa"
|
391
|
+
# "ZZZ9999".succ #=> "AAAA0000"
|
392
|
+
# "***".succ #=> "**+"
|
393
|
+
# ```
|
394
|
+
def next: () -> String
|
395
|
+
|
396
|
+
# Equivalent to `String#succ`, but modifies the receiver in place.
|
397
|
+
def next!: () -> String
|
398
|
+
|
399
|
+
# Treats leading characters of *str* as a string of octal digits (with an
|
400
|
+
# optional sign) and returns the corresponding number. Returns 0 if the
|
401
|
+
# conversion fails.
|
402
|
+
#
|
403
|
+
# ```ruby
|
404
|
+
# "123".oct #=> 83
|
405
|
+
# "-377".oct #=> -255
|
406
|
+
# "bad".oct #=> 0
|
407
|
+
# "0377bad".oct #=> 255
|
408
|
+
# ```
|
409
|
+
#
|
410
|
+
# If `str` starts with `0`, radix indicators are honored. See
|
411
|
+
# Kernel\#Integer.
|
412
|
+
def oct: () -> Integer
|
413
|
+
|
414
|
+
# Returns the `Integer` ordinal of a one-character string.
|
415
|
+
#
|
416
|
+
# ```ruby
|
417
|
+
# "a".ord #=> 97
|
418
|
+
# ```
|
419
|
+
def ord: () -> Integer
|
420
|
+
|
421
|
+
def partition: (Regexp | String arg0) -> [ String, String, String ]
|
422
|
+
|
423
|
+
def `prepend`: (String arg0) -> String
|
424
|
+
|
425
|
+
def replace: (String arg0) -> String
|
426
|
+
|
427
|
+
# Returns a new string with the characters from *str* in reverse order.
|
428
|
+
#
|
429
|
+
# ```ruby
|
430
|
+
# "stressed".reverse #=> "desserts"
|
431
|
+
# ```
|
432
|
+
def reverse: () -> String
|
433
|
+
|
434
|
+
def rindex: (String | Regexp arg0, ?Integer arg1) -> Integer?
|
435
|
+
|
436
|
+
def rjust: (Integer arg0, ?String arg1) -> String
|
437
|
+
|
438
|
+
def rpartition: (String | Regexp arg0) -> [ String, String, String ]
|
439
|
+
|
440
|
+
# Returns a copy of the receiver with trailing whitespace removed. See
|
441
|
+
# also [\#lstrip](String.downloaded.ruby_doc#method-i-lstrip) and
|
442
|
+
# [\#strip](String.downloaded.ruby_doc#method-i-strip).
|
443
|
+
#
|
444
|
+
# Refer to [\#strip](String.downloaded.ruby_doc#method-i-strip) for the
|
445
|
+
# definition of whitespace.
|
446
|
+
#
|
447
|
+
# ```ruby
|
448
|
+
# " hello ".rstrip #=> " hello"
|
449
|
+
# "hello".rstrip #=> "hello"
|
450
|
+
# ```
|
451
|
+
def rstrip: () -> String
|
452
|
+
|
453
|
+
# Removes trailing whitespace from the receiver. Returns the altered
|
454
|
+
# receiver, or `nil` if no change was made. See also
|
455
|
+
# [\#lstrip\!](String.downloaded.ruby_doc#method-i-lstrip-21) and
|
456
|
+
# [\#strip\!](String.downloaded.ruby_doc#method-i-strip-21).
|
457
|
+
#
|
458
|
+
# Refer to [\#strip](String.downloaded.ruby_doc#method-i-strip) for the
|
459
|
+
# definition of whitespace.
|
460
|
+
#
|
461
|
+
# ```ruby
|
462
|
+
# " hello ".rstrip! #=> " hello"
|
463
|
+
# " hello".rstrip! #=> nil
|
464
|
+
# "hello".rstrip! #=> nil
|
465
|
+
# ```
|
466
|
+
def rstrip!: () -> String
|
467
|
+
|
468
|
+
def scan: (Regexp | String arg0) -> ::Array[String | ::Array[String]]
|
469
|
+
| (Regexp | String arg0) { () -> untyped } -> ::Array[String | ::Array[String]]
|
470
|
+
|
471
|
+
def scrub: (?String arg0) -> String
|
472
|
+
| (?String arg0) { (untyped arg0) -> untyped } -> String
|
473
|
+
|
474
|
+
def scrub!: (?String arg0) -> String
|
475
|
+
| (?String arg0) { (untyped arg0) -> untyped } -> String
|
476
|
+
|
477
|
+
def setbyte: (Integer arg0, Integer arg1) -> Integer
|
478
|
+
|
479
|
+
# Returns the character length of *str* .
|
480
|
+
def size: () -> Integer
|
481
|
+
|
482
|
+
def slice!: (Integer arg0, ?Integer arg1) -> String?
|
483
|
+
| (::Range[Integer] | Regexp arg0) -> String?
|
484
|
+
| (Regexp arg0, ?Integer arg1) -> String?
|
485
|
+
| (Regexp arg0, ?String arg1) -> String?
|
486
|
+
| (String arg0) -> String?
|
487
|
+
|
488
|
+
def split: (?Regexp | String arg0, ?Integer arg1) -> ::Array[String]
|
489
|
+
| (?Integer arg0) -> ::Array[String]
|
490
|
+
|
491
|
+
def squeeze: (?String arg0) -> String
|
492
|
+
|
493
|
+
def squeeze!: (?String arg0) -> String
|
494
|
+
|
495
|
+
def start_with?: (*String arg0) -> bool
|
496
|
+
|
497
|
+
# Returns a copy of the receiver with leading and trailing whitespace
|
498
|
+
# removed.
|
499
|
+
#
|
500
|
+
# Whitespace is defined as any of the following characters: null,
|
501
|
+
# horizontal tab, line feed, vertical tab, form feed, carriage return,
|
502
|
+
# space.
|
503
|
+
#
|
504
|
+
# ```ruby
|
505
|
+
# " hello ".strip #=> "hello"
|
506
|
+
# "\tgoodbye\r\n".strip #=> "goodbye"
|
507
|
+
# "\x00\t\n\v\f\r ".strip #=> ""
|
508
|
+
# "hello".strip #=> "hello"
|
509
|
+
# ```
|
510
|
+
def strip: () -> String
|
511
|
+
|
512
|
+
# Removes leading and trailing whitespace from the receiver. Returns the
|
513
|
+
# altered receiver, or `nil` if there was no change.
|
514
|
+
#
|
515
|
+
# Refer to [\#strip](String.downloaded.ruby_doc#method-i-strip) for the
|
516
|
+
# definition of whitespace.
|
517
|
+
#
|
518
|
+
# ```ruby
|
519
|
+
# " hello ".strip! #=> "hello"
|
520
|
+
# "hello".strip! #=> nil
|
521
|
+
# ```
|
522
|
+
def strip!: () -> String
|
523
|
+
|
524
|
+
def sub: (Regexp | String arg0, ?String | Hash[String, String] arg1) -> String
|
525
|
+
| (Regexp | String arg0) { (String arg0) -> untyped } -> String
|
526
|
+
|
527
|
+
def sub!: (Regexp | String arg0, ?String arg1) -> String
|
528
|
+
| (Regexp | String arg0) { (String arg0) -> untyped } -> String
|
529
|
+
|
530
|
+
# Returns the successor to *str* . The successor is calculated by
|
531
|
+
# incrementing characters starting from the rightmost alphanumeric (or the
|
532
|
+
# rightmost character if there are no alphanumerics) in the string.
|
533
|
+
# Incrementing a digit always results in another digit, and incrementing a
|
534
|
+
# letter results in another letter of the same case. Incrementing
|
535
|
+
# nonalphanumerics uses the underlying character set’s collating sequence.
|
536
|
+
#
|
537
|
+
# If the increment generates a “carry,” the character to the left of it is
|
538
|
+
# incremented. This process repeats until there is no carry, adding an
|
539
|
+
# additional character if necessary.
|
540
|
+
#
|
541
|
+
# ```ruby
|
542
|
+
# "abcd".succ #=> "abce"
|
543
|
+
# "THX1138".succ #=> "THX1139"
|
544
|
+
# "<<koala>>".succ #=> "<<koalb>>"
|
545
|
+
# "1999zzz".succ #=> "2000aaa"
|
546
|
+
# "ZZZ9999".succ #=> "AAAA0000"
|
547
|
+
# "***".succ #=> "**+"
|
548
|
+
# ```
|
549
|
+
def succ: () -> String
|
550
|
+
|
551
|
+
def succ!: () -> String
|
552
|
+
|
553
|
+
def sum: (?Integer arg0) -> Integer
|
554
|
+
|
555
|
+
# Returns a copy of *str* with uppercase alphabetic characters converted
|
556
|
+
# to lowercase and lowercase characters converted to uppercase.
|
557
|
+
#
|
558
|
+
# See [\#downcase](String.downloaded.ruby_doc#method-i-downcase) for
|
559
|
+
# meaning of `options` and use with different encodings.
|
560
|
+
#
|
561
|
+
# ```ruby
|
562
|
+
# "Hello".swapcase #=> "hELLO"
|
563
|
+
# "cYbEr_PuNk11".swapcase #=> "CyBeR_pUnK11"
|
564
|
+
# ```
|
565
|
+
def swapcase: () -> String
|
566
|
+
|
567
|
+
# Equivalent to `String#swapcase`, but modifies the receiver in place,
|
568
|
+
# returning *str* , or `nil` if no changes were made.
|
569
|
+
#
|
570
|
+
# See [\#downcase](String.downloaded.ruby_doc#method-i-downcase) for
|
571
|
+
# meaning of `options` and use with different encodings.
|
572
|
+
def swapcase!: () -> String?
|
573
|
+
|
574
|
+
# Returns a complex which denotes the string form. The parser ignores
|
575
|
+
# leading whitespaces and trailing garbage. Any digit sequences can be
|
576
|
+
# separated by an underscore. Returns zero for null or garbage string.
|
577
|
+
#
|
578
|
+
# ```ruby
|
579
|
+
# '9'.to_c #=> (9+0i)
|
580
|
+
# '2.5'.to_c #=> (2.5+0i)
|
581
|
+
# '2.5/1'.to_c #=> ((5/2)+0i)
|
582
|
+
# '-3/2'.to_c #=> ((-3/2)+0i)
|
583
|
+
# '-i'.to_c #=> (0-1i)
|
584
|
+
# '45i'.to_c #=> (0+45i)
|
585
|
+
# '3-4i'.to_c #=> (3-4i)
|
586
|
+
# '-4e2-4e-2i'.to_c #=> (-400.0-0.04i)
|
587
|
+
# '-0.0-0.0i'.to_c #=> (-0.0-0.0i)
|
588
|
+
# '1/2+3/4i'.to_c #=> ((1/2)+(3/4)*i)
|
589
|
+
# 'ruby'.to_c #=> (0+0i)
|
590
|
+
# ```
|
591
|
+
#
|
592
|
+
# See [Kernel](https://ruby-doc.org/core-2.6.3/Kernel.html).Complex.
|
593
|
+
def to_c: () -> Complex
|
594
|
+
|
595
|
+
# Returns the result of interpreting leading characters in *str* as a
|
596
|
+
# floating point number. Extraneous characters past the end of a valid
|
597
|
+
# number are ignored. If there is not a valid number at the start of *str*
|
598
|
+
# , `0.0` is returned. This method never raises an exception.
|
599
|
+
#
|
600
|
+
# ```ruby
|
601
|
+
# "123.45e1".to_f #=> 1234.5
|
602
|
+
# "45.67 degrees".to_f #=> 45.67
|
603
|
+
# "thx1138".to_f #=> 0.0
|
604
|
+
# ```
|
605
|
+
def to_f: () -> Float
|
606
|
+
|
607
|
+
def to_i: (?Integer arg0) -> Integer
|
608
|
+
|
609
|
+
# Returns the result of interpreting leading characters in `str` as a
|
610
|
+
# rational. Leading whitespace and extraneous characters past the end of a
|
611
|
+
# valid number are ignored. Digit sequences can be separated by an
|
612
|
+
# underscore. If there is not a valid number at the start of `str`, zero
|
613
|
+
# is returned. This method never raises an exception.
|
614
|
+
#
|
615
|
+
# ```ruby
|
616
|
+
# ' 2 '.to_r #=> (2/1)
|
617
|
+
# '300/2'.to_r #=> (150/1)
|
618
|
+
# '-9.2'.to_r #=> (-46/5)
|
619
|
+
# '-9.2e2'.to_r #=> (-920/1)
|
620
|
+
# '1_234_567'.to_r #=> (1234567/1)
|
621
|
+
# '21 June 09'.to_r #=> (21/1)
|
622
|
+
# '21/06/09'.to_r #=> (7/2)
|
623
|
+
# 'BWV 1079'.to_r #=> (0/1)
|
624
|
+
# ```
|
625
|
+
#
|
626
|
+
# NOTE: “0.3”.to\_r isn’t the same as 0.3.to\_r. The former is equivalent
|
627
|
+
# to “3/10”.to\_r, but the latter isn’t so.
|
628
|
+
#
|
629
|
+
# "0.3".to_r == 3/10r #=> true
|
630
|
+
# 0.3.to_r == 3/10r #=> false
|
631
|
+
#
|
632
|
+
# See also Kernel\#Rational.
|
633
|
+
def to_r: () -> Rational
|
634
|
+
|
635
|
+
# Returns `self` .
|
636
|
+
#
|
637
|
+
# If called on a subclass of [String](String.downloaded.ruby_doc),
|
638
|
+
# converts the receiver to a [String](String.downloaded.ruby_doc) object.
|
639
|
+
def to_s: () -> String
|
640
|
+
|
641
|
+
# Returns `self` .
|
642
|
+
#
|
643
|
+
# If called on a subclass of [String](String.downloaded.ruby_doc),
|
644
|
+
# converts the receiver to a [String](String.downloaded.ruby_doc) object.
|
645
|
+
def to_str: () -> String
|
646
|
+
|
647
|
+
# Returns the `Symbol` corresponding to *str* , creating the symbol if it
|
648
|
+
# did not previously exist. See `Symbol#id2name` .
|
649
|
+
#
|
650
|
+
# ```ruby
|
651
|
+
# "Koala".intern #=> :Koala
|
652
|
+
# s = 'cat'.to_sym #=> :cat
|
653
|
+
# s == :cat #=> true
|
654
|
+
# s = '@cat'.to_sym #=> :@cat
|
655
|
+
# s == :@cat #=> true
|
656
|
+
# ```
|
657
|
+
#
|
658
|
+
# This can also be used to create symbols that cannot be represented using
|
659
|
+
# the `:xxx` notation.
|
660
|
+
#
|
661
|
+
# ```ruby
|
662
|
+
# 'cat and dog'.to_sym #=> :"cat and dog"
|
663
|
+
# ```
|
664
|
+
def to_sym: () -> Symbol
|
665
|
+
|
666
|
+
def tr: (String arg0, String arg1) -> String
|
667
|
+
|
668
|
+
def tr!: (String arg0, String arg1) -> String?
|
669
|
+
|
670
|
+
def tr_s: (String arg0, String arg1) -> String
|
671
|
+
|
672
|
+
def tr_s!: (String arg0, String arg1) -> String?
|
673
|
+
|
674
|
+
def unpack: (String arg0) -> ::Array[(Integer | Float | String)?]
|
675
|
+
|
676
|
+
# Returns a copy of *str* with all lowercase letters replaced with their
|
677
|
+
# uppercase counterparts.
|
678
|
+
#
|
679
|
+
# See [\#downcase](String.downloaded.ruby_doc#method-i-downcase) for
|
680
|
+
# meaning of `options` and use with different encodings.
|
681
|
+
#
|
682
|
+
# ```ruby
|
683
|
+
# "hEllO".upcase #=> "HELLO"
|
684
|
+
# ```
|
685
|
+
def upcase: () -> String
|
686
|
+
|
687
|
+
# Upcases the contents of *str* , returning `nil` if no changes were made.
|
688
|
+
#
|
689
|
+
# See [\#downcase](String.downloaded.ruby_doc#method-i-downcase) for
|
690
|
+
# meaning of `options` and use with different encodings.
|
691
|
+
def upcase!: () -> String?
|
692
|
+
|
693
|
+
def upto: [Bool] (String arg0, ?Bool arg1) -> ::Enumerator[String, self]
|
694
|
+
| [Bool] (String arg0, ?Bool arg1) { (String arg0) -> untyped } -> String
|
695
|
+
|
696
|
+
# Returns true for a string which is encoded correctly.
|
697
|
+
#
|
698
|
+
# ```ruby
|
699
|
+
# "\xc2\xa1".force_encoding("UTF-8").valid_encoding? #=> true
|
700
|
+
# "\xc2".force_encoding("UTF-8").valid_encoding? #=> false
|
701
|
+
# "\x80".force_encoding("UTF-8").valid_encoding? #=> false
|
702
|
+
# ```
|
703
|
+
def valid_encoding?: () -> bool
|
704
|
+
|
705
|
+
def self.try_convert: (Object obj) -> String?
|
706
|
+
|
707
|
+
def slice: (Integer arg0, ?Integer arg1) -> String?
|
708
|
+
| (::Range[Integer] | Regexp arg0) -> String?
|
709
|
+
| (Regexp arg0, ?Integer arg1) -> String?
|
710
|
+
| (Regexp arg0, ?String arg1) -> String?
|
711
|
+
| (String arg0) -> String?
|
712
|
+
|
713
|
+
def encode: (
|
714
|
+
?(Encoding | String) encoding,
|
715
|
+
?(Encoding | String) from_encoding,
|
716
|
+
?invalid: :replace ?,
|
717
|
+
?undef: :replace ?,
|
718
|
+
?replace: String,
|
719
|
+
?fallback: Hash[String, String] | Proc | Method,
|
720
|
+
?xml: :text | :attr,
|
721
|
+
?universal_newline: TrueClass,
|
722
|
+
?cr_newline: TrueClass,
|
723
|
+
?crlf_newline: TrueClass
|
724
|
+
) -> String
|
725
|
+
|
726
|
+
def encode!: (
|
727
|
+
?(Encoding | String) encoding,
|
728
|
+
?(Encoding | String) from_encoding,
|
729
|
+
?invalid: :replace ?,
|
730
|
+
?undef: :replace ?,
|
731
|
+
?replace: String,
|
732
|
+
?fallback: Hash[String, String] | Proc | Method,
|
733
|
+
?xml: :text | :attr,
|
734
|
+
?universal_newline: TrueClass,
|
735
|
+
?cr_newline: TrueClass,
|
736
|
+
?crlf_newline: TrueClass
|
737
|
+
) -> self
|
738
|
+
|
739
|
+
def +@: () -> String
|
740
|
+
|
741
|
+
def -@: () -> String
|
742
|
+
|
743
|
+
def unicode_normalize: (?(:nfc | :nfd | :nfkc | :nfkd)) -> String
|
744
|
+
|
745
|
+
def unicode_normalize!: (?(:nfc | :nfd | :nfkc | :nfkd)) -> String
|
746
|
+
|
747
|
+
def casecmp?: (String other) -> bool
|
748
|
+
| (untyped other) -> nil
|
749
|
+
|
750
|
+
def []=: (Integer pos, String new_str) -> String
|
751
|
+
| (Integer begin_pos, Integer end_pos, String new_str) -> String
|
752
|
+
| (::Range[Integer] range, String new_str) -> String
|
753
|
+
| (Regexp regexp, String new_str) -> String
|
754
|
+
| (Regexp regexp, Integer capture, String new_str) -> String
|
755
|
+
| (Regexp regexp, String name, String new_str) -> String
|
756
|
+
| (String other_str, String new_str) -> String
|
757
|
+
|
758
|
+
def undump: () -> String
|
759
|
+
|
760
|
+
def grapheme_clusters: () -> ::Array[::String]
|
761
|
+
|
762
|
+
def reverse!: () -> String
|
763
|
+
|
764
|
+
def each_grapheme_cluster: () { (String grapheme) -> untyped } -> self
|
765
|
+
| () -> ::Enumerator[String, self]
|
766
|
+
|
767
|
+
def unpack1: (String format) -> (Integer | Float | String | nil)
|
768
|
+
|
769
|
+
def unicode_normalized?: (?(:nfc | :nfd | :nfkc | :nfkd)) -> bool
|
770
|
+
end
|