rbs 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ruby.yml +28 -0
  3. data/.gitignore +12 -0
  4. data/.rubocop.yml +15 -0
  5. data/BSDL +22 -0
  6. data/CHANGELOG.md +9 -0
  7. data/COPYING +56 -0
  8. data/Gemfile +6 -0
  9. data/README.md +93 -0
  10. data/Rakefile +142 -0
  11. data/bin/annotate-with-rdoc +157 -0
  12. data/bin/console +14 -0
  13. data/bin/query-rdoc +103 -0
  14. data/bin/setup +10 -0
  15. data/bin/sort +89 -0
  16. data/bin/test_runner.rb +16 -0
  17. data/docs/CONTRIBUTING.md +97 -0
  18. data/docs/sigs.md +148 -0
  19. data/docs/stdlib.md +152 -0
  20. data/docs/syntax.md +528 -0
  21. data/exe/rbs +7 -0
  22. data/lib/rbs.rb +64 -0
  23. data/lib/rbs/ast/annotation.rb +27 -0
  24. data/lib/rbs/ast/comment.rb +27 -0
  25. data/lib/rbs/ast/declarations.rb +395 -0
  26. data/lib/rbs/ast/members.rb +362 -0
  27. data/lib/rbs/buffer.rb +50 -0
  28. data/lib/rbs/builtin_names.rb +55 -0
  29. data/lib/rbs/cli.rb +558 -0
  30. data/lib/rbs/constant.rb +26 -0
  31. data/lib/rbs/constant_table.rb +150 -0
  32. data/lib/rbs/definition.rb +170 -0
  33. data/lib/rbs/definition_builder.rb +919 -0
  34. data/lib/rbs/environment.rb +281 -0
  35. data/lib/rbs/environment_loader.rb +136 -0
  36. data/lib/rbs/environment_walker.rb +124 -0
  37. data/lib/rbs/errors.rb +187 -0
  38. data/lib/rbs/location.rb +102 -0
  39. data/lib/rbs/method_type.rb +123 -0
  40. data/lib/rbs/namespace.rb +91 -0
  41. data/lib/rbs/parser.y +1344 -0
  42. data/lib/rbs/prototype/rb.rb +553 -0
  43. data/lib/rbs/prototype/rbi.rb +587 -0
  44. data/lib/rbs/prototype/runtime.rb +381 -0
  45. data/lib/rbs/substitution.rb +46 -0
  46. data/lib/rbs/test.rb +26 -0
  47. data/lib/rbs/test/errors.rb +61 -0
  48. data/lib/rbs/test/hook.rb +294 -0
  49. data/lib/rbs/test/setup.rb +58 -0
  50. data/lib/rbs/test/spy.rb +325 -0
  51. data/lib/rbs/test/test_helper.rb +183 -0
  52. data/lib/rbs/test/type_check.rb +254 -0
  53. data/lib/rbs/type_name.rb +70 -0
  54. data/lib/rbs/types.rb +936 -0
  55. data/lib/rbs/variance_calculator.rb +138 -0
  56. data/lib/rbs/vendorer.rb +47 -0
  57. data/lib/rbs/version.rb +3 -0
  58. data/lib/rbs/writer.rb +269 -0
  59. data/lib/ruby/signature.rb +7 -0
  60. data/rbs.gemspec +46 -0
  61. data/stdlib/abbrev/abbrev.rbs +60 -0
  62. data/stdlib/base64/base64.rbs +71 -0
  63. data/stdlib/benchmark/benchmark.rbs +372 -0
  64. data/stdlib/builtin/array.rbs +1997 -0
  65. data/stdlib/builtin/basic_object.rbs +280 -0
  66. data/stdlib/builtin/binding.rbs +177 -0
  67. data/stdlib/builtin/builtin.rbs +45 -0
  68. data/stdlib/builtin/class.rbs +145 -0
  69. data/stdlib/builtin/comparable.rbs +116 -0
  70. data/stdlib/builtin/complex.rbs +400 -0
  71. data/stdlib/builtin/constants.rbs +37 -0
  72. data/stdlib/builtin/data.rbs +5 -0
  73. data/stdlib/builtin/deprecated.rbs +2 -0
  74. data/stdlib/builtin/dir.rbs +413 -0
  75. data/stdlib/builtin/encoding.rbs +607 -0
  76. data/stdlib/builtin/enumerable.rbs +404 -0
  77. data/stdlib/builtin/enumerator.rbs +260 -0
  78. data/stdlib/builtin/errno.rbs +781 -0
  79. data/stdlib/builtin/errors.rbs +582 -0
  80. data/stdlib/builtin/exception.rbs +194 -0
  81. data/stdlib/builtin/false_class.rbs +40 -0
  82. data/stdlib/builtin/fiber.rbs +68 -0
  83. data/stdlib/builtin/fiber_error.rbs +12 -0
  84. data/stdlib/builtin/file.rbs +1076 -0
  85. data/stdlib/builtin/file_test.rbs +59 -0
  86. data/stdlib/builtin/float.rbs +696 -0
  87. data/stdlib/builtin/gc.rbs +243 -0
  88. data/stdlib/builtin/hash.rbs +1029 -0
  89. data/stdlib/builtin/integer.rbs +707 -0
  90. data/stdlib/builtin/io.rbs +683 -0
  91. data/stdlib/builtin/kernel.rbs +576 -0
  92. data/stdlib/builtin/marshal.rbs +161 -0
  93. data/stdlib/builtin/match_data.rbs +271 -0
  94. data/stdlib/builtin/math.rbs +369 -0
  95. data/stdlib/builtin/method.rbs +185 -0
  96. data/stdlib/builtin/module.rbs +1104 -0
  97. data/stdlib/builtin/nil_class.rbs +82 -0
  98. data/stdlib/builtin/numeric.rbs +409 -0
  99. data/stdlib/builtin/object.rbs +824 -0
  100. data/stdlib/builtin/proc.rbs +429 -0
  101. data/stdlib/builtin/process.rbs +1227 -0
  102. data/stdlib/builtin/random.rbs +267 -0
  103. data/stdlib/builtin/range.rbs +226 -0
  104. data/stdlib/builtin/rational.rbs +424 -0
  105. data/stdlib/builtin/rb_config.rbs +57 -0
  106. data/stdlib/builtin/regexp.rbs +1083 -0
  107. data/stdlib/builtin/ruby_vm.rbs +14 -0
  108. data/stdlib/builtin/signal.rbs +55 -0
  109. data/stdlib/builtin/string.rbs +1901 -0
  110. data/stdlib/builtin/string_io.rbs +284 -0
  111. data/stdlib/builtin/struct.rbs +40 -0
  112. data/stdlib/builtin/symbol.rbs +228 -0
  113. data/stdlib/builtin/thread.rbs +1108 -0
  114. data/stdlib/builtin/thread_group.rbs +23 -0
  115. data/stdlib/builtin/time.rbs +1047 -0
  116. data/stdlib/builtin/trace_point.rbs +290 -0
  117. data/stdlib/builtin/true_class.rbs +46 -0
  118. data/stdlib/builtin/unbound_method.rbs +153 -0
  119. data/stdlib/builtin/warning.rbs +17 -0
  120. data/stdlib/coverage/coverage.rbs +62 -0
  121. data/stdlib/csv/csv.rbs +773 -0
  122. data/stdlib/erb/erb.rbs +392 -0
  123. data/stdlib/find/find.rbs +40 -0
  124. data/stdlib/ipaddr/ipaddr.rbs +247 -0
  125. data/stdlib/json/json.rbs +335 -0
  126. data/stdlib/pathname/pathname.rbs +1093 -0
  127. data/stdlib/prime/integer-extension.rbs +23 -0
  128. data/stdlib/prime/prime.rbs +188 -0
  129. data/stdlib/securerandom/securerandom.rbs +9 -0
  130. data/stdlib/set/set.rbs +301 -0
  131. data/stdlib/tmpdir/tmpdir.rbs +53 -0
  132. metadata +292 -0
@@ -0,0 +1,284 @@
1
+ # Pseudo I/O on String object, with interface corresponding to IO.
2
+ #
3
+ # Commonly used to simulate `$stdio` or `$stderr`
4
+ #
5
+ # ### Examples
6
+ #
7
+ # require 'stringio'
8
+ #
9
+ # # Writing stream emulation
10
+ # io = StringIO.new
11
+ # io.puts "Hello World"
12
+ # io.string #=> "Hello World\n"
13
+ #
14
+ # # Reading stream emulation
15
+ # io = StringIO.new "first\nsecond\nlast\n"
16
+ # io.getc #=> "f"
17
+ # io.gets #=> "irst\n"
18
+ # io.read #=> "second\nlast\n"
19
+ #
20
+ class StringIO
21
+ # Creates new StringIO instance from with *string* and *mode*.
22
+ #
23
+ def initialize: (?String string, ?String? mode) -> void
24
+
25
+ # Equivalent to StringIO.new except that when it is called with a block, it
26
+ # yields with the new instance and closes it, and returns the result which
27
+ # returned from the block.
28
+ #
29
+ def self.open: [U] (?String string, ?String? mode) { (StringIO arg) -> U } -> U
30
+
31
+ def <<: (untyped arg0) -> self
32
+
33
+ # Puts stream into binary mode. See IO#binmode.
34
+ #
35
+ def binmode: () -> self
36
+
37
+ # Closes a StringIO. The stream is unavailable for any further data operations;
38
+ # an `IOError` is raised if such an attempt is made.
39
+ #
40
+ def close: () -> nil
41
+
42
+ # Closes the read end of a StringIO. Will raise an `IOError` if the receiver is
43
+ # not readable.
44
+ #
45
+ def close_read: () -> nil
46
+
47
+ # Closes the write end of a StringIO. Will raise an `IOError` if the receiver
48
+ # is not writeable.
49
+ #
50
+ def close_write: () -> nil
51
+
52
+ # Returns `true` if the stream is completely closed, `false` otherwise.
53
+ #
54
+ def closed?: () -> bool
55
+
56
+ # Returns `true` if the stream is not readable, `false` otherwise.
57
+ #
58
+ def closed_read?: () -> bool
59
+
60
+ # Returns `true` if the stream is not writable, `false` otherwise.
61
+ #
62
+ def closed_write?: () -> bool
63
+
64
+ # See IO#each.
65
+ #
66
+ def each: (?String sep, ?Integer limit, ?chomp: bool) { (String arg0) -> untyped } -> self
67
+ | (?String sep, ?Integer limit, ?chomp: bool) -> ::Enumerator[String, self]
68
+
69
+ # See IO#each_byte.
70
+ #
71
+ def each_byte: () { (Integer arg0) -> untyped } -> self
72
+ | () -> ::Enumerator[Integer, self]
73
+
74
+ # See IO#each_char.
75
+ #
76
+ def each_char: () { (String arg0) -> untyped } -> self
77
+ | () -> ::Enumerator[String, self]
78
+
79
+ # See IO#each_codepoint.
80
+ #
81
+ def each_codepoint: () { (Integer arg0) -> untyped } -> self
82
+ | () -> ::Enumerator[Integer, self]
83
+
84
+ # Returns true if the stream is at the end of the data (underlying string). The
85
+ # stream must be opened for reading or an `IOError` will be raised.
86
+ #
87
+ def eof: () -> bool
88
+
89
+ # Raises NotImplementedError.
90
+ #
91
+ def fcntl: (Integer integer_cmd, String | Integer arg) -> Integer
92
+
93
+ # Returns `nil`. Just for compatibility to IO.
94
+ #
95
+ def fileno: () -> nil
96
+
97
+ # Returns an object itself. Just for compatibility to IO.
98
+ #
99
+ def flush: () -> self
100
+
101
+ # Returns 0. Just for compatibility to IO.
102
+ #
103
+ def fsync: () -> Integer?
104
+
105
+ # See IO#getbyte.
106
+ #
107
+ def getbyte: () -> Integer?
108
+
109
+ # See IO#getc.
110
+ #
111
+ def getc: () -> String?
112
+
113
+ # See IO#gets.
114
+ #
115
+ def gets: (?String sep, ?Integer limit, ?chomp: bool) -> String?
116
+
117
+ # Returns the Encoding of the internal string if conversion is specified.
118
+ # Otherwise returns `nil`.
119
+ #
120
+ def internal_encoding: () -> Encoding
121
+
122
+ # Returns the Encoding object that represents the encoding of the file. If the
123
+ # stream is write mode and no encoding is specified, returns `nil`.
124
+ #
125
+ def external_encoding: () -> Encoding
126
+
127
+ # Returns `false`. Just for compatibility to IO.
128
+ #
129
+ def isatty: () -> bool
130
+
131
+ # Returns the current line number. The stream must be opened for reading.
132
+ # `lineno` counts the number of times `gets` is called, rather than the number
133
+ # of newlines encountered. The two values will differ if `gets` is called with
134
+ # a separator other than newline. See also the `$.` variable.
135
+ #
136
+ def lineno: () -> Integer
137
+
138
+ # Manually sets the current line number to the given value. `$.` is updated only
139
+ # on the next read.
140
+ #
141
+ def lineno=: (Integer arg0) -> Integer
142
+
143
+ # Returns `nil`. Just for compatibility to IO.
144
+ #
145
+ def pid: () -> nil
146
+
147
+ # Returns the current offset (in bytes).
148
+ #
149
+ def pos: () -> Integer
150
+
151
+ # Seeks to the given position (in bytes).
152
+ #
153
+ def pos=: (Integer arg0) -> Integer
154
+
155
+ def print: (*untyped arg0) -> nil
156
+
157
+ def printf: (String format_string, *untyped arg0) -> nil
158
+
159
+ # See IO#putc.
160
+ #
161
+ def putc: (Numeric | String arg0) -> untyped
162
+
163
+ def puts: (*untyped arg0) -> nil
164
+
165
+ # See IO#read.
166
+ #
167
+ def read: (?Integer length, ?String outbuf) -> String?
168
+
169
+ def read_nonblock: (Integer len) -> String
170
+ | (Integer len, ?String buf) -> String
171
+
172
+ def readbyte: () -> Integer
173
+
174
+ def readchar: () -> String
175
+
176
+ def readline: (?String sep, ?Integer limit) -> String
177
+
178
+ # See IO#readlines.
179
+ #
180
+ def readlines: (?String sep, ?Integer limit, ?chomp: bool) -> ::Array[String]
181
+
182
+ def readpartial: (Integer maxlen) -> String
183
+ | (Integer maxlen, ?String outbuf) -> String
184
+
185
+ # Reinitializes the stream with the given *other_StrIO* or *string* and *mode*
186
+ # (see StringIO#new).
187
+ #
188
+ def reopen: (StringIO other) -> self
189
+ | (String other, ?String mode_str) -> self
190
+
191
+ # Positions the stream to the beginning of input, resetting `lineno` to zero.
192
+ #
193
+ def rewind: () -> Integer
194
+
195
+ # Seeks to a given offset *amount* in the stream according to the value of
196
+ # *whence* (see IO#seek).
197
+ #
198
+ def seek: (Integer amount, ?Integer whence) -> Integer
199
+
200
+ # Specify the encoding of the StringIO as *ext_enc*. Use the default external
201
+ # encoding if *ext_enc* is nil. 2nd argument *int_enc* and optional hash *opt*
202
+ # argument are ignored; they are for API compatibility to IO.
203
+ #
204
+ def set_encoding: (?String | Encoding ext_or_ext_int_enc) -> self
205
+ | (?String | Encoding ext_or_ext_int_enc, ?String | Encoding int_enc) -> self
206
+
207
+ # Returns underlying String object, the subject of IO.
208
+ #
209
+ def string: () -> String
210
+
211
+ # Changes underlying String object, the subject of IO.
212
+ #
213
+ def string=: (String str) -> String
214
+
215
+ # Returns the size of the buffer string.
216
+ #
217
+ def size: () -> Integer
218
+
219
+ # Returns `true` always.
220
+ #
221
+ def sync: () -> bool
222
+
223
+ # Returns the argument unchanged. Just for compatibility to IO.
224
+ #
225
+ def sync=: (bool arg0) -> bool
226
+
227
+ def sysread: (Integer maxlen, String outbuf) -> String
228
+
229
+ def syswrite: (String arg0) -> Integer
230
+
231
+ # Returns the current offset (in bytes).
232
+ #
233
+ def tell: () -> Integer
234
+
235
+ # Returns `false`. Just for compatibility to IO.
236
+ #
237
+ def tty?: () -> bool
238
+
239
+ # See IO#ungetbyte
240
+ #
241
+ def ungetbyte: (String | Integer arg0) -> nil
242
+
243
+ # Pushes back one character (passed as a parameter) such that a subsequent
244
+ # buffered read will return it. There is no limitation for multiple pushbacks
245
+ # including pushing back behind the beginning of the buffer string.
246
+ #
247
+ def ungetc: (String arg0) -> nil
248
+
249
+ # Appends the given string to the underlying buffer string. The stream must be
250
+ # opened for writing. If the argument is not a string, it will be converted to
251
+ # a string using `to_s`. Returns the number of bytes written. See IO#write.
252
+ #
253
+ def write: (String arg0) -> Integer
254
+
255
+ # This is a deprecated alias for #each_byte.
256
+ #
257
+ def bytes: () { (Integer arg0) -> untyped } -> self
258
+ | () -> ::Enumerator[Integer, self]
259
+
260
+ # This is a deprecated alias for #each_char.
261
+ #
262
+ def chars: () { (String arg0) -> untyped } -> self
263
+ | () -> ::Enumerator[String, self]
264
+
265
+ # This is a deprecated alias for #each_codepoint.
266
+ #
267
+ def codepoints: () { (Integer arg0) -> untyped } -> self
268
+ | () -> ::Enumerator[Integer, self]
269
+
270
+ # See IO#each.
271
+ #
272
+ def each_line: (?String sep, ?Integer limit, ?chomp: bool) { (String arg0) -> untyped } -> self
273
+ | (?String sep, ?Integer limit, ?chomp: bool) -> ::Enumerator[String, self]
274
+
275
+ # Returns true if the stream is at the end of the data (underlying string). The
276
+ # stream must be opened for reading or an `IOError` will be raised.
277
+ #
278
+ def eof?: () -> bool
279
+
280
+ # This is a deprecated alias for #each_line.
281
+ #
282
+ def lines: (?String sep, ?Integer limit) { (String arg0) -> untyped } -> self
283
+ | (?String sep, ?Integer limit) -> ::Enumerator[String, self]
284
+ end
@@ -0,0 +1,40 @@
1
+ # A [Struct](Struct) is a convenient way to bundle a
2
+ # number of attributes together, using accessor methods, without having to
3
+ # write an explicit class.
4
+ #
5
+ # The [Struct](Struct) class generates new subclasses
6
+ # that hold a set of members and their values. For each member a reader
7
+ # and writer method is created similar to
8
+ # [Module\#attr\_accessor](https://ruby-doc.org/core-2.6.3/Module.html#method-i-attr_accessor)
9
+ # .
10
+ #
11
+ # ```ruby
12
+ # Customer = Struct.new(:name, :address) do
13
+ # def greeting
14
+ # "Hello #{name}!"
15
+ # end
16
+ # end
17
+ #
18
+ # dave = Customer.new("Dave", "123 Main")
19
+ # dave.name #=> "Dave"
20
+ # dave.greeting #=> "Hello Dave!"
21
+ # ```
22
+ #
23
+ # See [::new](Struct#method-c-new) for further
24
+ # examples of creating struct subclasses and instances.
25
+ #
26
+ # In the method descriptions that follow, a "member" parameter refers to a
27
+ # struct member which is either a quoted string ( `"name"` ) or a
28
+ # [Symbol](https://ruby-doc.org/core-2.6.3/Symbol.html) ( `:name` ).
29
+ class Struct[Elem] < Object
30
+ include Enumerable[Elem, Struct[Elem]]
31
+
32
+ def initialize: (Symbol | String arg0, *Symbol | String arg1, ?keyword_init: bool keyword_init) -> void
33
+
34
+ def each: () { (Elem arg0) -> untyped } -> untyped
35
+ | () -> self
36
+
37
+ def self.members: () -> ::Array[Symbol]
38
+
39
+ def new: (*untyped args) -> Struct[untyped]
40
+ end
@@ -0,0 +1,228 @@
1
+ # Symbol objects represent names inside the Ruby interpreter. They are generated
2
+ # using the `:name` and `:"string"` literals syntax, and by the various `to_sym`
3
+ # methods. The same Symbol object will be created for a given name or string for
4
+ # the duration of a program's execution, regardless of the context or meaning of
5
+ # that name. Thus if `Fred` is a constant in one context, a method in another,
6
+ # and a class in a third, the Symbol `:Fred` will be the same object in all
7
+ # three contexts.
8
+ #
9
+ # module One
10
+ # class Fred
11
+ # end
12
+ # $f1 = :Fred
13
+ # end
14
+ # module Two
15
+ # Fred = 1
16
+ # $f2 = :Fred
17
+ # end
18
+ # def Fred()
19
+ # end
20
+ # $f3 = :Fred
21
+ # $f1.object_id #=> 2514190
22
+ # $f2.object_id #=> 2514190
23
+ # $f3.object_id #=> 2514190
24
+ #
25
+ class Symbol
26
+ include Comparable
27
+
28
+ # Returns an array of all the symbols currently in Ruby's symbol table.
29
+ #
30
+ # Symbol.all_symbols.size #=> 903
31
+ # Symbol.all_symbols[1,20] #=> [:floor, :ARGV, :Binding, :symlink,
32
+ # :chown, :EOFError, :$;, :String,
33
+ # :LOCK_SH, :"setuid?", :$<,
34
+ # :default_proc, :compact, :extend,
35
+ # :Tms, :getwd, :$=, :ThreadGroup,
36
+ # :wait2, :$>]
37
+ #
38
+ def self.all_symbols: () -> ::Array[Symbol]
39
+
40
+ public
41
+
42
+ # Compares `symbol` with `other_symbol` after calling #to_s on each of the
43
+ # symbols. Returns -1, 0, +1, or `nil` depending on whether `symbol` is less
44
+ # than, equal to, or greater than `other_symbol`.
45
+ #
46
+ # `nil` is returned if the two values are incomparable.
47
+ #
48
+ # See String#<=> for more information.
49
+ #
50
+ def <=>: (untyped other) -> Integer?
51
+
52
+ # Equality---If *sym* and *obj* are exactly the same symbol, returns `true`.
53
+ #
54
+ def ==: (untyped obj) -> bool
55
+
56
+ # Equality---If *sym* and *obj* are exactly the same symbol, returns `true`.
57
+ #
58
+ def ===: (untyped obj) -> bool
59
+
60
+ # Returns `sym.to_s =~ obj`.
61
+ #
62
+ def =~: (untyped obj) -> Integer?
63
+
64
+ # Returns `sym.to_s[]`.
65
+ #
66
+ def []: (int index) -> String?
67
+ | (int start, int length) -> String?
68
+ | (Range[Integer?] range) -> String?
69
+ | (Regexp regexp) -> String?
70
+ | (Regexp regexp, int | String capture) -> String?
71
+ | (String match_str) -> String?
72
+
73
+ # Same as `sym.to_s.capitalize.intern`.
74
+ #
75
+ def capitalize: () -> Symbol
76
+ | (:ascii | :lithuanian | :turkic) -> Symbol
77
+ | (:lithuanian, :turkic) -> Symbol
78
+ | (:turkic, :lithuanian) -> Symbol
79
+
80
+ # Case-insensitive version of Symbol#<=>. Currently, case-insensitivity only
81
+ # works on characters A-Z/a-z, not all of Unicode. This is different from
82
+ # Symbol#casecmp?.
83
+ #
84
+ # :aBcDeF.casecmp(:abcde) #=> 1
85
+ # :aBcDeF.casecmp(:abcdef) #=> 0
86
+ # :aBcDeF.casecmp(:abcdefg) #=> -1
87
+ # :abcdef.casecmp(:ABCDEF) #=> 0
88
+ #
89
+ # `nil` is returned if the two symbols have incompatible encodings, or if
90
+ # `other_symbol` is not a symbol.
91
+ #
92
+ # :foo.casecmp(2) #=> nil
93
+ # "\u{e4 f6 fc}".encode("ISO-8859-1").to_sym.casecmp(:"\u{c4 d6 dc}") #=> nil
94
+ #
95
+ def casecmp: (untyped other) -> Integer?
96
+
97
+ # Returns `true` if `sym` and `other_symbol` are equal after Unicode case
98
+ # folding, `false` if they are not equal.
99
+ #
100
+ # :aBcDeF.casecmp?(:abcde) #=> false
101
+ # :aBcDeF.casecmp?(:abcdef) #=> true
102
+ # :aBcDeF.casecmp?(:abcdefg) #=> false
103
+ # :abcdef.casecmp?(:ABCDEF) #=> true
104
+ # :"\u{e4 f6 fc}".casecmp?(:"\u{c4 d6 dc}") #=> true
105
+ #
106
+ # `nil` is returned if the two symbols have incompatible encodings, or if
107
+ # `other_symbol` is not a symbol.
108
+ #
109
+ # :foo.casecmp?(2) #=> nil
110
+ # "\u{e4 f6 fc}".encode("ISO-8859-1").to_sym.casecmp?(:"\u{c4 d6 dc}") #=> nil
111
+ #
112
+ def casecmp?: (untyped other) -> bool
113
+
114
+ # Same as `sym.to_s.downcase.intern`.
115
+ #
116
+ def downcase: () -> Symbol
117
+ | (:ascii | :fold | :lithuanian | :turkic) -> Symbol
118
+ | (:lithuanian, :turkic) -> Symbol
119
+ | (:turkic, :lithuanian) -> Symbol
120
+
121
+ # Returns whether *sym* is :"" or not.
122
+ #
123
+ def empty?: () -> bool
124
+
125
+ # Returns the Encoding object that represents the encoding of *sym*.
126
+ #
127
+ def encoding: () -> Encoding
128
+
129
+ # Returns true if `sym` ends with one of the `suffixes` given.
130
+ #
131
+ # :hello.end_with?("ello") #=> true
132
+ #
133
+ # # returns true if one of the +suffixes+ matches.
134
+ # :hello.end_with?("heaven", "ello") #=> true
135
+ # :hello.end_with?("heaven", "paradise") #=> false
136
+ #
137
+ def end_with?: (*string suffixes) -> bool
138
+
139
+ # Returns the name or string corresponding to *sym*.
140
+ #
141
+ # :fred.id2name #=> "fred"
142
+ # :ginger.to_s #=> "ginger"
143
+ #
144
+ def id2name: () -> String
145
+
146
+ # Returns the representation of *sym* as a symbol literal.
147
+ #
148
+ # :fred.inspect #=> ":fred"
149
+ #
150
+ def inspect: () -> String
151
+
152
+ # In general, `to_sym` returns the Symbol corresponding to an object. As *sym*
153
+ # is already a symbol, `self` is returned in this case.
154
+ #
155
+ def intern: () -> self
156
+
157
+ # Same as `sym.to_s.length`.
158
+ #
159
+ def length: () -> Integer
160
+
161
+ # Returns `sym.to_s.match`.
162
+ #
163
+ def match: (Regexp | string pattern, ?int pos) -> MatchData?
164
+ | (Regexp | string pattern, ?int pos) { (MatchData) -> void } -> untyped
165
+
166
+ # Returns `sym.to_s.match?`.
167
+ #
168
+ def match?: (Regexp | string pattern, ?int pos) -> bool
169
+
170
+ # Same as `sym.to_s.succ.intern`.
171
+ #
172
+ def next: () -> Symbol
173
+
174
+ # Same as `sym.to_s.length`.
175
+ #
176
+ alias size length
177
+
178
+ # Returns `sym.to_s[]`.
179
+ #
180
+ alias slice `[]`
181
+
182
+ # Returns true if `sym` starts with one of the `prefixes` given. Each of the
183
+ # `prefixes` should be a String or a Regexp.
184
+ #
185
+ # :hello.start_with?("hell") #=> true
186
+ # :hello.start_with?(/H/i) #=> true
187
+ #
188
+ # # returns true if one of the prefixes matches.
189
+ # :hello.start_with?("heaven", "hell") #=> true
190
+ # :hello.start_with?("heaven", "paradise") #=> false
191
+ def start_with?: (*string prefixes) -> bool
192
+
193
+ # Same as `sym.to_s.succ.intern`.
194
+ #
195
+ alias succ next
196
+
197
+ # Same as `sym.to_s.swapcase.intern`.
198
+ #
199
+ def swapcase: () -> Symbol
200
+ | (:ascii | :lithuanian | :turkic) -> Symbol
201
+ | (:lithuanian, :turkic) -> Symbol
202
+ | (:turkic, :lithuanian) -> Symbol
203
+
204
+ # Returns a *Proc* object which responds to the given method by *sym*.
205
+ #
206
+ # (1..3).collect(&:to_s) #=> ["1", "2", "3"]
207
+ #
208
+ def to_proc: () -> Proc
209
+
210
+ # Returns the name or string corresponding to *sym*.
211
+ #
212
+ # :fred.id2name #=> "fred"
213
+ # :ginger.to_s #=> "ginger"
214
+ #
215
+ alias to_s id2name
216
+
217
+ # In general, `to_sym` returns the Symbol corresponding to an object. As *sym*
218
+ # is already a symbol, `self` is returned in this case.
219
+ #
220
+ alias to_sym intern
221
+
222
+ # Same as `sym.to_s.upcase.intern`.
223
+ #
224
+ def upcase: () -> Symbol
225
+ | (:ascii | :lithuanian | :turkic) -> Symbol
226
+ | (:lithuanian, :turkic) -> Symbol
227
+ | (:turkic, :lithuanian) -> Symbol
228
+ end