steep 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (299) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +27 -0
  3. data/.gitmodules +3 -0
  4. data/CHANGELOG.md +5 -0
  5. data/README.md +48 -90
  6. data/Rakefile +10 -6
  7. data/Steepfile +1 -0
  8. data/bin/setup +1 -0
  9. data/bin/smoke_runner.rb +9 -14
  10. data/exe/rbs +3 -0
  11. data/exe/ruby-signature +3 -0
  12. data/exe/steep +1 -0
  13. data/lib/steep.rb +32 -26
  14. data/lib/steep/annotation_parser.rb +167 -0
  15. data/lib/steep/ast/annotation/collection.rb +7 -7
  16. data/lib/steep/ast/types.rb +60 -0
  17. data/lib/steep/ast/types/any.rb +1 -1
  18. data/lib/steep/ast/types/factory.rb +535 -0
  19. data/lib/steep/ast/types/name.rb +3 -3
  20. data/lib/steep/ast/types/var.rb +1 -1
  21. data/lib/steep/cli.rb +56 -240
  22. data/lib/steep/drivers/annotations.rb +36 -19
  23. data/lib/steep/drivers/check.rb +55 -91
  24. data/lib/steep/drivers/init.rb +54 -0
  25. data/lib/steep/drivers/langserver.rb +241 -150
  26. data/lib/steep/drivers/print_project.rb +56 -0
  27. data/lib/steep/drivers/signature_error_printer.rb +25 -0
  28. data/lib/steep/drivers/trace_printer.rb +25 -0
  29. data/lib/steep/drivers/utils/driver_helper.rb +26 -0
  30. data/lib/steep/drivers/validate.rb +18 -38
  31. data/lib/steep/drivers/vendor.rb +46 -0
  32. data/lib/steep/drivers/watch.rb +78 -140
  33. data/lib/steep/errors.rb +22 -13
  34. data/lib/steep/interface/interface.rb +91 -0
  35. data/lib/steep/interface/method.rb +0 -4
  36. data/lib/steep/interface/method_type.rb +362 -2
  37. data/lib/steep/interface/substitution.rb +22 -0
  38. data/lib/steep/project.rb +25 -233
  39. data/lib/steep/project/dsl.rb +132 -0
  40. data/lib/steep/project/file.rb +93 -76
  41. data/lib/steep/project/file_loader.rb +63 -0
  42. data/lib/steep/project/options.rb +7 -0
  43. data/lib/steep/project/target.rb +190 -0
  44. data/lib/steep/signature/errors.rb +25 -77
  45. data/lib/steep/signature/validator.rb +122 -0
  46. data/lib/steep/source.rb +12 -7
  47. data/lib/steep/subtyping/check.rb +357 -633
  48. data/lib/steep/subtyping/constraints.rb +2 -2
  49. data/lib/steep/subtyping/trace.rb +23 -0
  50. data/lib/steep/type_construction.rb +509 -455
  51. data/lib/steep/type_inference/constant_env.rb +16 -24
  52. data/lib/steep/type_inference/type_env.rb +26 -18
  53. data/lib/steep/version.rb +1 -1
  54. data/sample/Steepfile +6 -0
  55. data/sample/lib/conference.rb +12 -0
  56. data/sample/sig/conference.rbs +6 -0
  57. data/smoke/alias/Steepfile +4 -0
  58. data/smoke/alias/a.rb +2 -2
  59. data/smoke/alias/{a.rbi → a.rbs} +1 -1
  60. data/smoke/and/Steepfile +4 -0
  61. data/smoke/array/Steepfile +4 -0
  62. data/smoke/array/a.rb +2 -2
  63. data/smoke/array/b.rb +4 -4
  64. data/smoke/array/c.rb +2 -2
  65. data/smoke/block/Steepfile +5 -0
  66. data/smoke/block/{a.rbi → a.rbs} +1 -1
  67. data/smoke/block/{c.rbi → c.rbs} +0 -0
  68. data/smoke/block/d.rb +6 -6
  69. data/smoke/case/Steepfile +4 -0
  70. data/smoke/case/a.rb +4 -3
  71. data/smoke/class/Steepfile +4 -0
  72. data/smoke/class/a.rb +1 -4
  73. data/smoke/class/a.rbs +24 -0
  74. data/smoke/class/h.rb +6 -2
  75. data/smoke/class/{h.rbi → h.rbs} +1 -2
  76. data/smoke/class/i.rb +1 -2
  77. data/smoke/class/i.rbs +9 -0
  78. data/smoke/const/Steepfile +4 -0
  79. data/smoke/dstr/Steepfile +4 -0
  80. data/smoke/ensure/Steepfile +4 -0
  81. data/smoke/ensure/a.rb +1 -1
  82. data/smoke/enumerator/Steepfile +4 -0
  83. data/smoke/enumerator/a.rb +7 -7
  84. data/smoke/enumerator/b.rb +6 -6
  85. data/smoke/extension/Steepfile +4 -0
  86. data/smoke/extension/{a.rbi → a.rbs} +2 -2
  87. data/smoke/extension/{e.rbi → e.rbs} +2 -2
  88. data/smoke/hash/Steepfile +4 -0
  89. data/smoke/hash/{a.rbi → a.rbs} +0 -0
  90. data/smoke/hash/b.rb +2 -2
  91. data/smoke/hash/c.rb +1 -1
  92. data/smoke/hash/e.rbs +3 -0
  93. data/smoke/hash/f.rb +1 -1
  94. data/smoke/hello/Steepfile +4 -0
  95. data/smoke/hello/hello.rbs +7 -0
  96. data/smoke/if/Steepfile +4 -0
  97. data/smoke/implements/Steepfile +4 -0
  98. data/smoke/implements/a.rbs +6 -0
  99. data/smoke/initialize/Steepfile +4 -0
  100. data/smoke/initialize/a.rbs +3 -0
  101. data/smoke/integer/Steepfile +4 -0
  102. data/smoke/integer/a.rb +5 -3
  103. data/smoke/interface/Steepfile +4 -0
  104. data/smoke/interface/{a.rbi → a.rbs} +0 -0
  105. data/smoke/kwbegin/Steepfile +4 -0
  106. data/smoke/lambda/Steepfile +4 -0
  107. data/smoke/lambda/a.rb +9 -2
  108. data/smoke/literal/Steepfile +4 -0
  109. data/smoke/literal/{literal_methods.rbi → literal_methods.rbs} +0 -0
  110. data/smoke/map/Steepfile +4 -0
  111. data/smoke/map/a.rb +1 -1
  112. data/smoke/method/Steepfile +4 -0
  113. data/smoke/method/{a.rbi → a.rbs} +0 -0
  114. data/smoke/method/b.rb +1 -4
  115. data/smoke/method/d.rb +1 -0
  116. data/smoke/method/d.rbs +3 -0
  117. data/smoke/module/Steepfile +4 -0
  118. data/smoke/module/a.rb +1 -1
  119. data/smoke/module/a.rbs +16 -0
  120. data/smoke/module/c.rb +1 -1
  121. data/smoke/regexp/Steepfile +4 -0
  122. data/smoke/regexp/a.rb +2 -2
  123. data/smoke/regexp/b.rb +16 -16
  124. data/smoke/regression/Steepfile +5 -0
  125. data/smoke/regression/array.rb +2 -2
  126. data/smoke/regression/hash.rb +2 -2
  127. data/smoke/regression/poly_new.rb +2 -0
  128. data/smoke/regression/poly_new.rbs +4 -0
  129. data/smoke/regression/set_divide.rb +2 -2
  130. data/smoke/rescue/Steepfile +4 -0
  131. data/smoke/rescue/a.rb +1 -1
  132. data/smoke/self/Steepfile +4 -0
  133. data/smoke/self/a.rbs +4 -0
  134. data/smoke/skip/Steepfile +4 -0
  135. data/smoke/stdout/Steepfile +4 -0
  136. data/smoke/stdout/{a.rbi → a.rbs} +1 -1
  137. data/smoke/super/Steepfile +4 -0
  138. data/smoke/super/a.rbs +10 -0
  139. data/smoke/type_case/Steepfile +4 -0
  140. data/smoke/type_case/a.rb +1 -1
  141. data/smoke/yield/Steepfile +4 -0
  142. data/smoke/yield/a.rb +2 -2
  143. data/steep.gemspec +14 -7
  144. data/vendor/ruby-signature/.github/workflows/ruby.yml +27 -0
  145. data/vendor/ruby-signature/.gitignore +12 -0
  146. data/vendor/ruby-signature/.rubocop.yml +15 -0
  147. data/vendor/ruby-signature/BSDL +22 -0
  148. data/vendor/ruby-signature/COPYING +56 -0
  149. data/vendor/ruby-signature/Gemfile +6 -0
  150. data/vendor/ruby-signature/README.md +93 -0
  151. data/vendor/ruby-signature/Rakefile +66 -0
  152. data/vendor/ruby-signature/bin/annotate-with-rdoc +156 -0
  153. data/vendor/ruby-signature/bin/console +14 -0
  154. data/vendor/ruby-signature/bin/query-rdoc +103 -0
  155. data/vendor/ruby-signature/bin/setup +10 -0
  156. data/vendor/ruby-signature/bin/sort +88 -0
  157. data/vendor/ruby-signature/bin/test_runner.rb +17 -0
  158. data/vendor/ruby-signature/docs/CONTRIBUTING.md +97 -0
  159. data/vendor/ruby-signature/docs/sigs.md +148 -0
  160. data/vendor/ruby-signature/docs/stdlib.md +152 -0
  161. data/vendor/ruby-signature/docs/syntax.md +528 -0
  162. data/vendor/ruby-signature/exe/rbs +3 -0
  163. data/vendor/ruby-signature/exe/ruby-signature +7 -0
  164. data/vendor/ruby-signature/lib/ruby/signature.rb +64 -0
  165. data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +29 -0
  166. data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +29 -0
  167. data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +391 -0
  168. data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +364 -0
  169. data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +52 -0
  170. data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +54 -0
  171. data/vendor/ruby-signature/lib/ruby/signature/cli.rb +534 -0
  172. data/vendor/ruby-signature/lib/ruby/signature/constant.rb +28 -0
  173. data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +152 -0
  174. data/vendor/ruby-signature/lib/ruby/signature/definition.rb +172 -0
  175. data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +921 -0
  176. data/vendor/ruby-signature/lib/ruby/signature/environment.rb +283 -0
  177. data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +138 -0
  178. data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +126 -0
  179. data/vendor/ruby-signature/lib/ruby/signature/errors.rb +189 -0
  180. data/vendor/ruby-signature/lib/ruby/signature/location.rb +104 -0
  181. data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +125 -0
  182. data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +93 -0
  183. data/vendor/ruby-signature/lib/ruby/signature/parser.y +1343 -0
  184. data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +441 -0
  185. data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +579 -0
  186. data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +383 -0
  187. data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +48 -0
  188. data/vendor/ruby-signature/lib/ruby/signature/test.rb +28 -0
  189. data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +63 -0
  190. data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +290 -0
  191. data/vendor/ruby-signature/lib/ruby/signature/test/setup.rb +58 -0
  192. data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +324 -0
  193. data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +185 -0
  194. data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +256 -0
  195. data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +72 -0
  196. data/vendor/ruby-signature/lib/ruby/signature/types.rb +932 -0
  197. data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +140 -0
  198. data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +49 -0
  199. data/vendor/ruby-signature/lib/ruby/signature/version.rb +5 -0
  200. data/vendor/ruby-signature/lib/ruby/signature/writer.rb +271 -0
  201. data/vendor/ruby-signature/ruby-signature.gemspec +45 -0
  202. data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +3 -0
  203. data/vendor/ruby-signature/stdlib/base64/base64.rbs +15 -0
  204. data/vendor/ruby-signature/stdlib/builtin/array.rbs +1997 -0
  205. data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +280 -0
  206. data/vendor/ruby-signature/stdlib/builtin/binding.rbs +177 -0
  207. data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +35 -0
  208. data/vendor/ruby-signature/stdlib/builtin/class.rbs +145 -0
  209. data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +116 -0
  210. data/vendor/ruby-signature/stdlib/builtin/complex.rbs +400 -0
  211. data/vendor/ruby-signature/stdlib/builtin/constants.rbs +37 -0
  212. data/vendor/ruby-signature/stdlib/builtin/data.rbs +5 -0
  213. data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +2 -0
  214. data/vendor/ruby-signature/stdlib/builtin/dir.rbs +419 -0
  215. data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +606 -0
  216. data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +404 -0
  217. data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +260 -0
  218. data/vendor/ruby-signature/stdlib/builtin/errno.rbs +781 -0
  219. data/vendor/ruby-signature/stdlib/builtin/errors.rbs +582 -0
  220. data/vendor/ruby-signature/stdlib/builtin/exception.rbs +193 -0
  221. data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +40 -0
  222. data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +68 -0
  223. data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +12 -0
  224. data/vendor/ruby-signature/stdlib/builtin/file.rbs +476 -0
  225. data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +59 -0
  226. data/vendor/ruby-signature/stdlib/builtin/float.rbs +696 -0
  227. data/vendor/ruby-signature/stdlib/builtin/gc.rbs +121 -0
  228. data/vendor/ruby-signature/stdlib/builtin/hash.rbs +1029 -0
  229. data/vendor/ruby-signature/stdlib/builtin/integer.rbs +710 -0
  230. data/vendor/ruby-signature/stdlib/builtin/io.rbs +683 -0
  231. data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +574 -0
  232. data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +135 -0
  233. data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +141 -0
  234. data/vendor/ruby-signature/stdlib/builtin/math.rbs +66 -0
  235. data/vendor/ruby-signature/stdlib/builtin/method.rbs +182 -0
  236. data/vendor/ruby-signature/stdlib/builtin/module.rbs +248 -0
  237. data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +82 -0
  238. data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +409 -0
  239. data/vendor/ruby-signature/stdlib/builtin/object.rbs +824 -0
  240. data/vendor/ruby-signature/stdlib/builtin/proc.rbs +426 -0
  241. data/vendor/ruby-signature/stdlib/builtin/process.rbs +354 -0
  242. data/vendor/ruby-signature/stdlib/builtin/random.rbs +93 -0
  243. data/vendor/ruby-signature/stdlib/builtin/range.rbs +226 -0
  244. data/vendor/ruby-signature/stdlib/builtin/rational.rbs +424 -0
  245. data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +10 -0
  246. data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +131 -0
  247. data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +14 -0
  248. data/vendor/ruby-signature/stdlib/builtin/signal.rbs +55 -0
  249. data/vendor/ruby-signature/stdlib/builtin/string.rbs +770 -0
  250. data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +13 -0
  251. data/vendor/ruby-signature/stdlib/builtin/struct.rbs +40 -0
  252. data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +230 -0
  253. data/vendor/ruby-signature/stdlib/builtin/thread.rbs +1112 -0
  254. data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +23 -0
  255. data/vendor/ruby-signature/stdlib/builtin/time.rbs +739 -0
  256. data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +91 -0
  257. data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +46 -0
  258. data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +159 -0
  259. data/vendor/ruby-signature/stdlib/builtin/warning.rbs +17 -0
  260. data/vendor/ruby-signature/stdlib/erb/erb.rbs +18 -0
  261. data/vendor/ruby-signature/stdlib/find/find.rbs +44 -0
  262. data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +21 -0
  263. data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +23 -0
  264. data/vendor/ruby-signature/stdlib/prime/prime.rbs +188 -0
  265. data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +9 -0
  266. data/vendor/ruby-signature/stdlib/set/set.rbs +77 -0
  267. data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +53 -0
  268. metadata +244 -54
  269. data/.travis.yml +0 -7
  270. data/lib/steep/ast/signature/alias.rb +0 -19
  271. data/lib/steep/ast/signature/class.rb +0 -33
  272. data/lib/steep/ast/signature/const.rb +0 -17
  273. data/lib/steep/ast/signature/env.rb +0 -138
  274. data/lib/steep/ast/signature/extension.rb +0 -21
  275. data/lib/steep/ast/signature/gvar.rb +0 -17
  276. data/lib/steep/ast/signature/interface.rb +0 -31
  277. data/lib/steep/ast/signature/members.rb +0 -115
  278. data/lib/steep/ast/signature/module.rb +0 -21
  279. data/lib/steep/drivers/print_interface.rb +0 -94
  280. data/lib/steep/drivers/scaffold.rb +0 -321
  281. data/lib/steep/drivers/utils/each_signature.rb +0 -31
  282. data/lib/steep/interface/abstract.rb +0 -68
  283. data/lib/steep/interface/builder.rb +0 -637
  284. data/lib/steep/interface/instantiated.rb +0 -163
  285. data/lib/steep/interface/ivar_chain.rb +0 -26
  286. data/lib/steep/parser.y +0 -1278
  287. data/lib/steep/project/listener.rb +0 -53
  288. data/smoke/class/a.rbi +0 -24
  289. data/smoke/class/d.rb +0 -9
  290. data/smoke/class/e.rb +0 -12
  291. data/smoke/class/i.rbi +0 -9
  292. data/smoke/hash/e.rbi +0 -3
  293. data/smoke/hello/hello.rbi +0 -7
  294. data/smoke/implements/a.rbi +0 -6
  295. data/smoke/initialize/a.rbi +0 -3
  296. data/smoke/module/a.rbi +0 -16
  297. data/smoke/self/a.rbi +0 -4
  298. data/smoke/super/a.rbi +0 -10
  299. data/stdlib/builtin.rbi +0 -787
@@ -0,0 +1,824 @@
1
+ # Object is the default root of all Ruby objects. Object inherits from
2
+ # BasicObject which allows creating alternate object hierarchies. Methods on
3
+ # Object are available to all classes unless explicitly overridden.
4
+ #
5
+ # Object mixes in the Kernel module, making the built-in kernel functions
6
+ # globally accessible. Although the instance methods of Object are defined by
7
+ # the Kernel module, we have chosen to document them here for clarity.
8
+ #
9
+ # When referencing constants in classes inheriting from Object you do not need
10
+ # to use the full namespace. For example, referencing `File` inside `YourClass`
11
+ # will find the top-level File class.
12
+ #
13
+ # In the descriptions of Object's methods, the parameter *symbol* refers to a
14
+ # symbol, which is either a quoted string or a Symbol (such as `:name`).
15
+ #
16
+ class Object < BasicObject
17
+ include Kernel
18
+
19
+ # Returns true if two objects do not match (using the *=~* method), otherwise
20
+ # false.
21
+ #
22
+ def !~: (untyped) -> bool
23
+
24
+ # Returns 0 if `obj` and `other` are the same object or `obj == other`,
25
+ # otherwise nil.
26
+ #
27
+ # The `<=>` is used by various methods to compare objects, for example
28
+ # Enumerable#sort, Enumerable#max etc.
29
+ #
30
+ # Your implementation of `<=>` should return one of the following values: -1, 0,
31
+ # 1 or nil. -1 means self is smaller than other. 0 means self is equal to other.
32
+ # 1 means self is bigger than other. Nil means the two values could not be
33
+ # compared.
34
+ #
35
+ # When you define `<=>`, you can include Comparable to gain the methods `<=`,
36
+ # `<`, `==`, `>=`, `>` and `between?`.
37
+ #
38
+ def <=>: (untyped) -> Integer?
39
+
40
+ # Case Equality -- For class Object, effectively the same as calling `#==`, but
41
+ # typically overridden by descendants to provide meaningful semantics in `case`
42
+ # statements.
43
+ #
44
+ def ===: (untyped) -> bool
45
+
46
+ # This method is deprecated.
47
+ #
48
+ # This is not only unuseful but also troublesome because it may hide a type
49
+ # error.
50
+ #
51
+ def =~: (untyped) -> bool
52
+
53
+ # Returns the class of *obj*. This method must always be called with an explicit
54
+ # receiver, as `class` is also a reserved word in Ruby.
55
+ #
56
+ # 1.class #=> Integer
57
+ # self.class #=> Object
58
+ #
59
+ def `class`: () -> untyped
60
+
61
+ # Produces a shallow copy of *obj*---the instance variables of *obj* are copied,
62
+ # but not the objects they reference. `clone` copies the frozen (unless :freeze
63
+ # keyword argument is given with a false value) and tainted state of *obj*. See
64
+ # also the discussion under `Object#dup`.
65
+ #
66
+ # class Klass
67
+ # attr_accessor :str
68
+ # end
69
+ # s1 = Klass.new #=> #<Klass:0x401b3a38>
70
+ # s1.str = "Hello" #=> "Hello"
71
+ # s2 = s1.clone #=> #<Klass:0x401b3998 @str="Hello">
72
+ # s2.str[1,4] = "i" #=> "i"
73
+ # s1.inspect #=> "#<Klass:0x401b3a38 @str=\"Hi\">"
74
+ # s2.inspect #=> "#<Klass:0x401b3998 @str=\"Hi\">"
75
+ #
76
+ # This method may have class-specific behavior. If so, that behavior will be
77
+ # documented under the #`initialize_copy` method of the class.
78
+ #
79
+ def clone: (?freeze: bool) -> self
80
+
81
+ # Defines a singleton method in the receiver. The *method* parameter can be a
82
+ # `Proc`, a `Method` or an `UnboundMethod` object. If a block is specified, it
83
+ # is used as the method body.
84
+ #
85
+ # class A
86
+ # class << self
87
+ # def class_name
88
+ # to_s
89
+ # end
90
+ # end
91
+ # end
92
+ # A.define_singleton_method(:who_am_i) do
93
+ # "I am: #{class_name}"
94
+ # end
95
+ # A.who_am_i # ==> "I am: A"
96
+ #
97
+ # guy = "Bob"
98
+ # guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
99
+ # guy.hello #=> "Bob: Hello there!"
100
+ #
101
+ def define_singleton_method: (Symbol, Method | UnboundMethod) -> Symbol
102
+ | (Symbol) { (*untyped) -> untyped } -> Symbol
103
+
104
+ # Prints *obj* on the given port (default `$>`). Equivalent to:
105
+ #
106
+ # def display(port=$>)
107
+ # port.write self
108
+ # nil
109
+ # end
110
+ #
111
+ # For example:
112
+ #
113
+ # 1.display
114
+ # "cat".display
115
+ # [ 4, 5, 6 ].display
116
+ # puts
117
+ #
118
+ # *produces:*
119
+ #
120
+ # 1cat[4, 5, 6]
121
+ #
122
+ def display: (?_Writeable port) -> void
123
+
124
+ # Produces a shallow copy of *obj*---the instance variables of *obj* are copied,
125
+ # but not the objects they reference. `dup` copies the tainted state of *obj*.
126
+ #
127
+ # This method may have class-specific behavior. If so, that behavior will be
128
+ # documented under the #`initialize_copy` method of the class.
129
+ #
130
+ # ### on dup vs clone
131
+ #
132
+ # In general, `clone` and `dup` may have different semantics in descendant
133
+ # classes. While `clone` is used to duplicate an object, including its internal
134
+ # state, `dup` typically uses the class of the descendant object to create the
135
+ # new instance.
136
+ #
137
+ # When using #dup, any modules that the object has been extended with will not
138
+ # be copied.
139
+ #
140
+ # class Klass
141
+ # attr_accessor :str
142
+ # end
143
+ #
144
+ # module Foo
145
+ # def foo; 'foo'; end
146
+ # end
147
+ #
148
+ # s1 = Klass.new #=> #<Klass:0x401b3a38>
149
+ # s1.extend(Foo) #=> #<Klass:0x401b3a38>
150
+ # s1.foo #=> "foo"
151
+ #
152
+ # s2 = s1.clone #=> #<Klass:0x401b3a38>
153
+ # s2.foo #=> "foo"
154
+ #
155
+ # s3 = s1.dup #=> #<Klass:0x401b3a38>
156
+ # s3.foo #=> NoMethodError: undefined method `foo' for #<Klass:0x401b3a38>
157
+ #
158
+ def dup: () -> self
159
+
160
+ # Creates a new Enumerator which will enumerate by calling `method` on `obj`,
161
+ # passing `args` if any.
162
+ #
163
+ # If a block is given, it will be used to calculate the size of the enumerator
164
+ # without the need to iterate it (see Enumerator#size).
165
+ #
166
+ # ### Examples
167
+ #
168
+ # str = "xyz"
169
+ #
170
+ # enum = str.enum_for(:each_byte)
171
+ # enum.each { |b| puts b }
172
+ # # => 120
173
+ # # => 121
174
+ # # => 122
175
+ #
176
+ # # protect an array from being modified by some_method
177
+ # a = [1, 2, 3]
178
+ # some_method(a.to_enum)
179
+ #
180
+ # It is typical to call to_enum when defining methods for a generic Enumerable,
181
+ # in case no block is passed.
182
+ #
183
+ # Here is such an example, with parameter passing and a sizing block:
184
+ #
185
+ # module Enumerable
186
+ # # a generic method to repeat the values of any enumerable
187
+ # def repeat(n)
188
+ # raise ArgumentError, "#{n} is negative!" if n < 0
189
+ # unless block_given?
190
+ # return to_enum(__method__, n) do # __method__ is :repeat here
191
+ # sz = size # Call size and multiply by n...
192
+ # sz * n if sz # but return nil if size itself is nil
193
+ # end
194
+ # end
195
+ # each do |*val|
196
+ # n.times { yield *val }
197
+ # end
198
+ # end
199
+ # end
200
+ #
201
+ # %i[hello world].repeat(2) { |w| puts w }
202
+ # # => Prints 'hello', 'hello', 'world', 'world'
203
+ # enum = (1..14).repeat(3)
204
+ # # => returns an Enumerator when called without a block
205
+ # enum.first(4) # => [1, 1, 1, 2]
206
+ # enum.size # => 42
207
+ #
208
+ def enum_for: (Symbol method, *untyped args) ?{ (*untyped args) -> Integer } -> Enumerator[untyped, untyped]
209
+ | (*untyped args) ?{ (*untyped args) -> Integer } -> Enumerator[untyped, untyped]
210
+
211
+ # Creates a new Enumerator which will enumerate by calling `method` on `obj`,
212
+ # passing `args` if any.
213
+ #
214
+ # If a block is given, it will be used to calculate the size of the enumerator
215
+ # without the need to iterate it (see Enumerator#size).
216
+ #
217
+ # ### Examples
218
+ #
219
+ # str = "xyz"
220
+ #
221
+ # enum = str.enum_for(:each_byte)
222
+ # enum.each { |b| puts b }
223
+ # # => 120
224
+ # # => 121
225
+ # # => 122
226
+ #
227
+ # # protect an array from being modified by some_method
228
+ # a = [1, 2, 3]
229
+ # some_method(a.to_enum)
230
+ #
231
+ # It is typical to call to_enum when defining methods for a generic Enumerable,
232
+ # in case no block is passed.
233
+ #
234
+ # Here is such an example, with parameter passing and a sizing block:
235
+ #
236
+ # module Enumerable
237
+ # # a generic method to repeat the values of any enumerable
238
+ # def repeat(n)
239
+ # raise ArgumentError, "#{n} is negative!" if n < 0
240
+ # unless block_given?
241
+ # return to_enum(__method__, n) do # __method__ is :repeat here
242
+ # sz = size # Call size and multiply by n...
243
+ # sz * n if sz # but return nil if size itself is nil
244
+ # end
245
+ # end
246
+ # each do |*val|
247
+ # n.times { yield *val }
248
+ # end
249
+ # end
250
+ # end
251
+ #
252
+ # %i[hello world].repeat(2) { |w| puts w }
253
+ # # => Prints 'hello', 'hello', 'world', 'world'
254
+ # enum = (1..14).repeat(3)
255
+ # # => returns an Enumerator when called without a block
256
+ # enum.first(4) # => [1, 1, 1, 2]
257
+ # enum.size # => 42
258
+ #
259
+ alias to_enum enum_for
260
+
261
+ # Equality --- At the `Object` level, `==` returns `true` only if `obj` and
262
+ # `other` are the same object. Typically, this method is overridden in
263
+ # descendant classes to provide class-specific meaning.
264
+ #
265
+ # Unlike `==`, the `equal?` method should never be overridden by subclasses as
266
+ # it is used to determine object identity (that is, `a.equal?(b)` if and only if
267
+ # `a` is the same object as `b`):
268
+ #
269
+ # obj = "a"
270
+ # other = obj.dup
271
+ #
272
+ # obj == other #=> true
273
+ # obj.equal? other #=> false
274
+ # obj.equal? obj #=> true
275
+ #
276
+ # The `eql?` method returns `true` if `obj` and `other` refer to the same hash
277
+ # key. This is used by Hash to test members for equality. For objects of class
278
+ # `Object`, `eql?` is synonymous with `==`. Subclasses normally continue this
279
+ # tradition by aliasing `eql?` to their overridden `==` method, but there are
280
+ # exceptions. `Numeric` types, for example, perform type conversion across
281
+ # `==`, but not across `eql?`, so:
282
+ #
283
+ # 1 == 1.0 #=> true
284
+ # 1.eql? 1.0 #=> false
285
+ #
286
+ def eql?: (untyped) -> bool
287
+
288
+ # Adds to *obj* the instance methods from each module given as a parameter.
289
+ #
290
+ # module Mod
291
+ # def hello
292
+ # "Hello from Mod.\n"
293
+ # end
294
+ # end
295
+ #
296
+ # class Klass
297
+ # def hello
298
+ # "Hello from Klass.\n"
299
+ # end
300
+ # end
301
+ #
302
+ # k = Klass.new
303
+ # k.hello #=> "Hello from Klass.\n"
304
+ # k.extend(Mod) #=> #<Klass:0x401b3bc8>
305
+ # k.hello #=> "Hello from Mod.\n"
306
+ #
307
+ def `extend`: (*Module) -> self
308
+
309
+ # Prevents further modifications to *obj*. A `RuntimeError` will be raised if
310
+ # modification is attempted. There is no way to unfreeze a frozen object. See
311
+ # also `Object#frozen?`.
312
+ #
313
+ # This method returns self.
314
+ #
315
+ # a = [ "a", "b", "c" ]
316
+ # a.freeze
317
+ # a << "z"
318
+ #
319
+ # *produces:*
320
+ #
321
+ # prog.rb:3:in `<<': can't modify frozen Array (FrozenError)
322
+ # from prog.rb:3
323
+ #
324
+ # Objects of the following classes are always frozen: Integer, Float, Symbol.
325
+ #
326
+ def freeze: () -> self
327
+
328
+ # Returns the freeze status of *obj*.
329
+ #
330
+ # a = [ "a", "b", "c" ]
331
+ # a.freeze #=> ["a", "b", "c"]
332
+ # a.frozen? #=> true
333
+ #
334
+ def frozen?: () -> bool
335
+
336
+ def hash: () -> Integer
337
+
338
+ # Returns a string containing a human-readable representation of *obj*. The
339
+ # default `inspect` shows the object's class name, an encoding of the object id,
340
+ # and a list of the instance variables and their values (by calling #inspect on
341
+ # each of them). User defined classes should override this method to provide a
342
+ # better representation of *obj*. When overriding this method, it should return
343
+ # a string whose encoding is compatible with the default external encoding.
344
+ #
345
+ # [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]"
346
+ # Time.new.inspect #=> "2008-03-08 19:43:39 +0900"
347
+ #
348
+ # class Foo
349
+ # end
350
+ # Foo.new.inspect #=> "#<Foo:0x0300c868>"
351
+ #
352
+ # class Bar
353
+ # def initialize
354
+ # @bar = 1
355
+ # end
356
+ # end
357
+ # Bar.new.inspect #=> "#<Bar:0x0300c868 @bar=1>"
358
+ #
359
+ def inspect: () -> String
360
+
361
+ # Returns `true` if *obj* is an instance of the given class. See also
362
+ # `Object#kind_of?`.
363
+ #
364
+ # class A; end
365
+ # class B < A; end
366
+ # class C < B; end
367
+ #
368
+ # b = B.new
369
+ # b.instance_of? A #=> false
370
+ # b.instance_of? B #=> true
371
+ # b.instance_of? C #=> false
372
+ #
373
+ def instance_of?: (Module) -> bool
374
+
375
+ # Returns `true` if the given instance variable is defined in *obj*. String
376
+ # arguments are converted to symbols.
377
+ #
378
+ # class Fred
379
+ # def initialize(p1, p2)
380
+ # @a, @b = p1, p2
381
+ # end
382
+ # end
383
+ # fred = Fred.new('cat', 99)
384
+ # fred.instance_variable_defined?(:@a) #=> true
385
+ # fred.instance_variable_defined?("@b") #=> true
386
+ # fred.instance_variable_defined?("@c") #=> false
387
+ #
388
+ def instance_variable_defined?: (String | Symbol var) -> bool
389
+
390
+ # Returns the value of the given instance variable, or nil if the instance
391
+ # variable is not set. The `@` part of the variable name should be included for
392
+ # regular instance variables. Throws a `NameError` exception if the supplied
393
+ # symbol is not valid as an instance variable name. String arguments are
394
+ # converted to symbols.
395
+ #
396
+ # class Fred
397
+ # def initialize(p1, p2)
398
+ # @a, @b = p1, p2
399
+ # end
400
+ # end
401
+ # fred = Fred.new('cat', 99)
402
+ # fred.instance_variable_get(:@a) #=> "cat"
403
+ # fred.instance_variable_get("@b") #=> 99
404
+ #
405
+ def instance_variable_get: (String | Symbol var) -> untyped
406
+
407
+ # Sets the instance variable named by *symbol* to the given object, thereby
408
+ # frustrating the efforts of the class's author to attempt to provide proper
409
+ # encapsulation. The variable does not have to exist prior to this call. If the
410
+ # instance variable name is passed as a string, that string is converted to a
411
+ # symbol.
412
+ #
413
+ # class Fred
414
+ # def initialize(p1, p2)
415
+ # @a, @b = p1, p2
416
+ # end
417
+ # end
418
+ # fred = Fred.new('cat', 99)
419
+ # fred.instance_variable_set(:@a, 'dog') #=> "dog"
420
+ # fred.instance_variable_set(:@c, 'cat') #=> "cat"
421
+ # fred.inspect #=> "#<Fred:0x401b3da8 @a=\"dog\", @b=99, @c=\"cat\">"
422
+ #
423
+ def instance_variable_set: [X] (String | Symbol var, X value) -> X
424
+
425
+ # Returns an array of instance variable names for the receiver. Note that simply
426
+ # defining an accessor does not create the corresponding instance variable.
427
+ #
428
+ # class Fred
429
+ # attr_accessor :a1
430
+ # def initialize
431
+ # @iv = 3
432
+ # end
433
+ # end
434
+ # Fred.new.instance_variables #=> [:@iv]
435
+ #
436
+ def instance_variables: () -> Array[Symbol]
437
+
438
+ # Returns `true` if *class* is the class of *obj*, or if *class* is one of the
439
+ # superclasses of *obj* or modules included in *obj*.
440
+ #
441
+ # module M; end
442
+ # class A
443
+ # include M
444
+ # end
445
+ # class B < A; end
446
+ # class C < B; end
447
+ #
448
+ # b = B.new
449
+ # b.is_a? A #=> true
450
+ # b.is_a? B #=> true
451
+ # b.is_a? C #=> false
452
+ # b.is_a? M #=> true
453
+ #
454
+ # b.kind_of? A #=> true
455
+ # b.kind_of? B #=> true
456
+ # b.kind_of? C #=> false
457
+ # b.kind_of? M #=> true
458
+ #
459
+ def is_a?: (Module) -> bool
460
+
461
+ # Returns `true` if *class* is the class of *obj*, or if *class* is one of the
462
+ # superclasses of *obj* or modules included in *obj*.
463
+ #
464
+ # module M; end
465
+ # class A
466
+ # include M
467
+ # end
468
+ # class B < A; end
469
+ # class C < B; end
470
+ #
471
+ # b = B.new
472
+ # b.is_a? A #=> true
473
+ # b.is_a? B #=> true
474
+ # b.is_a? C #=> false
475
+ # b.is_a? M #=> true
476
+ #
477
+ # b.kind_of? A #=> true
478
+ # b.kind_of? B #=> true
479
+ # b.kind_of? C #=> false
480
+ # b.kind_of? M #=> true
481
+ #
482
+ alias kind_of? is_a?
483
+
484
+ # Returns the receiver.
485
+ #
486
+ # string = "my string"
487
+ # string.itself.object_id == string.object_id #=> true
488
+ #
489
+ def `itself`: () -> self
490
+
491
+ # Looks up the named method as a receiver in *obj*, returning a `Method` object
492
+ # (or raising `NameError`). The `Method` object acts as a closure in *obj*'s
493
+ # object instance, so instance variables and the value of `self` remain
494
+ # available.
495
+ #
496
+ # class Demo
497
+ # def initialize(n)
498
+ # @iv = n
499
+ # end
500
+ # def hello()
501
+ # "Hello, @iv = #{@iv}"
502
+ # end
503
+ # end
504
+ #
505
+ # k = Demo.new(99)
506
+ # m = k.method(:hello)
507
+ # m.call #=> "Hello, @iv = 99"
508
+ #
509
+ # l = Demo.new('Fred')
510
+ # m = l.method("hello")
511
+ # m.call #=> "Hello, @iv = Fred"
512
+ #
513
+ # Note that `Method` implements `to_proc` method, which means it can be used
514
+ # with iterators.
515
+ #
516
+ # [ 1, 2, 3 ].each(&method(:puts)) # => prints 3 lines to stdout
517
+ #
518
+ # out = File.open('test.txt', 'w')
519
+ # [ 1, 2, 3 ].each(&out.method(:puts)) # => prints 3 lines to file
520
+ #
521
+ # require 'date'
522
+ # %w[2017-03-01 2017-03-02].collect(&Date.method(:parse))
523
+ # #=> [#<Date: 2017-03-01 ((2457814j,0s,0n),+0s,2299161j)>, #<Date: 2017-03-02 ((2457815j,0s,0n),+0s,2299161j)>]
524
+ #
525
+ def method: (String | Symbol name) -> Method
526
+
527
+ # Returns a list of the names of public and protected methods of *obj*. This
528
+ # will include all the methods accessible in *obj*'s ancestors. If the optional
529
+ # parameter is `false`, it returns an array of *obj<i>'s public and protected
530
+ # singleton methods, the array will not include methods in modules included in
531
+ # <i>obj*.
532
+ #
533
+ # class Klass
534
+ # def klass_method()
535
+ # end
536
+ # end
537
+ # k = Klass.new
538
+ # k.methods[0..9] #=> [:klass_method, :nil?, :===,
539
+ # # :==~, :!, :eql?
540
+ # # :hash, :<=>, :class, :singleton_class]
541
+ # k.methods.length #=> 56
542
+ #
543
+ # k.methods(false) #=> []
544
+ # def k.singleton_method; end
545
+ # k.methods(false) #=> [:singleton_method]
546
+ #
547
+ # module M123; def m123; end end
548
+ # k.extend M123
549
+ # k.methods(false) #=> [:singleton_method]
550
+ #
551
+ def methods: () -> Array[Symbol]
552
+
553
+ # Only the object *nil* responds `true` to `nil?`.
554
+ #
555
+ # Object.new.nil? #=> false
556
+ # nil.nil? #=> true
557
+ #
558
+ def `nil?`: () -> bool
559
+
560
+ # Returns an integer identifier for `obj`.
561
+ #
562
+ # The same number will be returned on all calls to `object_id` for a given
563
+ # object, and no two active objects will share an id.
564
+ #
565
+ # Note: that some objects of builtin classes are reused for optimization. This
566
+ # is the case for immediate values and frozen string literals.
567
+ #
568
+ # Immediate values are not passed by reference but are passed by value: `nil`,
569
+ # `true`, `false`, Fixnums, Symbols, and some Floats.
570
+ #
571
+ # Object.new.object_id == Object.new.object_id # => false
572
+ # (21 * 2).object_id == (21 * 2).object_id # => true
573
+ # "hello".object_id == "hello".object_id # => false
574
+ # "hi".freeze.object_id == "hi".freeze.object_id # => true
575
+ #
576
+ def object_id: () -> Integer
577
+
578
+ # Returns the list of private methods accessible to *obj*. If the *all*
579
+ # parameter is set to `false`, only those methods in the receiver will be
580
+ # listed.
581
+ #
582
+ def private_methods: () -> Array[Symbol]
583
+
584
+ # Returns the list of protected methods accessible to *obj*. If the *all*
585
+ # parameter is set to `false`, only those methods in the receiver will be
586
+ # listed.
587
+ #
588
+ def protected_methods: () -> Array[Symbol]
589
+
590
+ # Similar to *method*, searches public method only.
591
+ #
592
+ def public_method: (name name) -> Method
593
+
594
+ # Invokes the method identified by *symbol*, passing it any arguments specified.
595
+ # Unlike send, public_send calls public methods only. When the method is
596
+ # identified by a string, the string is converted to a symbol.
597
+ #
598
+ # 1.public_send(:puts, "hello") # causes NoMethodError
599
+ #
600
+ def `public_send`: (name name, *untyped args) ?{ (*untyped) -> untyped } -> untyped
601
+
602
+ # Removes the named instance variable from *obj*, returning that variable's
603
+ # value. String arguments are converted to symbols.
604
+ #
605
+ # class Dummy
606
+ # attr_reader :var
607
+ # def initialize
608
+ # @var = 99
609
+ # end
610
+ # def remove
611
+ # remove_instance_variable(:@var)
612
+ # end
613
+ # end
614
+ # d = Dummy.new
615
+ # d.var #=> 99
616
+ # d.remove #=> 99
617
+ # d.var #=> nil
618
+ #
619
+ def remove_instance_variable: (name name) -> untyped
620
+
621
+ # Returns `true` if *obj* responds to the given method. Private and protected
622
+ # methods are included in the search only if the optional second parameter
623
+ # evaluates to `true`.
624
+ #
625
+ # If the method is not implemented, as Process.fork on Windows, File.lchmod on
626
+ # GNU/Linux, etc., false is returned.
627
+ #
628
+ # If the method is not defined, `respond_to_missing?` method is called and the
629
+ # result is returned.
630
+ #
631
+ # When the method name parameter is given as a string, the string is converted
632
+ # to a symbol.
633
+ #
634
+ def respond_to?: (name name, ?bool include_all) -> bool
635
+
636
+ # Invokes the method identified by *symbol*, passing it any arguments specified.
637
+ # You can use `__send__` if the name `send` clashes with an existing method in
638
+ # *obj*. When the method is identified by a string, the string is converted to a
639
+ # symbol.
640
+ #
641
+ # class Klass
642
+ # def hello(*args)
643
+ # "Hello " + args.join(' ')
644
+ # end
645
+ # end
646
+ # k = Klass.new
647
+ # k.send :hello, "gentle", "readers" #=> "Hello gentle readers"
648
+ #
649
+ def `send`: (name name, *untyped args) ?{ (*untyped) -> untyped } -> untyped
650
+
651
+ # Returns the singleton class of *obj*. This method creates a new singleton
652
+ # class if *obj* does not have one.
653
+ #
654
+ # If *obj* is `nil`, `true`, or `false`, it returns NilClass, TrueClass, or
655
+ # FalseClass, respectively. If *obj* is an Integer, a Float or a Symbol, it
656
+ # raises a TypeError.
657
+ #
658
+ # Object.new.singleton_class #=> #<Class:#<Object:0xb7ce1e24>>
659
+ # String.singleton_class #=> #<Class:String>
660
+ # nil.singleton_class #=> NilClass
661
+ #
662
+ def `singleton_class`: () -> Class
663
+
664
+ # Similar to *method*, searches singleton method only.
665
+ #
666
+ # class Demo
667
+ # def initialize(n)
668
+ # @iv = n
669
+ # end
670
+ # def hello()
671
+ # "Hello, @iv = #{@iv}"
672
+ # end
673
+ # end
674
+ #
675
+ # k = Demo.new(99)
676
+ # def k.hi
677
+ # "Hi, @iv = #{@iv}"
678
+ # end
679
+ # m = k.singleton_method(:hi)
680
+ # m.call #=> "Hi, @iv = 99"
681
+ # m = k.singleton_method(:hello) #=> NameError
682
+ #
683
+ def singleton_method: (name name) -> Method
684
+
685
+ # Returns an array of the names of singleton methods for *obj*. If the optional
686
+ # *all* parameter is true, the list will include methods in modules included in
687
+ # *obj*. Only public and protected singleton methods are returned.
688
+ #
689
+ # module Other
690
+ # def three() end
691
+ # end
692
+ #
693
+ # class Single
694
+ # def Single.four() end
695
+ # end
696
+ #
697
+ # a = Single.new
698
+ #
699
+ # def a.one()
700
+ # end
701
+ #
702
+ # class << a
703
+ # include Other
704
+ # def two()
705
+ # end
706
+ # end
707
+ #
708
+ # Single.singleton_methods #=> [:four]
709
+ # a.singleton_methods(false) #=> [:two, :one]
710
+ # a.singleton_methods #=> [:two, :one, :three]
711
+ #
712
+ def singleton_methods: () -> Array[Symbol]
713
+
714
+ # Mark the object as tainted.
715
+ #
716
+ # Objects that are marked as tainted will be restricted from various built-in
717
+ # methods. This is to prevent insecure data, such as command-line arguments or
718
+ # strings read from Kernel#gets, from inadvertently compromising the user's
719
+ # system.
720
+ #
721
+ # To check whether an object is tainted, use #tainted?.
722
+ #
723
+ # You should only untaint a tainted object if your code has inspected it and
724
+ # determined that it is safe. To do so use #untaint.
725
+ #
726
+ def taint: () -> self
727
+
728
+ # Deprecated method that is equivalent to #taint.
729
+ #
730
+ alias untrust taint
731
+
732
+ # Returns true if the object is tainted.
733
+ #
734
+ # See #taint for more information.
735
+ #
736
+ def tainted?: () -> bool
737
+
738
+ # Deprecated method that is equivalent to #tainted?.
739
+ #
740
+ alias untrusted? tainted?
741
+
742
+ # Yields self to the block, and then returns self. The primary purpose of this
743
+ # method is to "tap into" a method chain, in order to perform operations on
744
+ # intermediate results within the chain.
745
+ #
746
+ # (1..10) .tap {|x| puts "original: #{x}" }
747
+ # .to_a .tap {|x| puts "array: #{x}" }
748
+ # .select {|x| x.even? } .tap {|x| puts "evens: #{x}" }
749
+ # .map {|x| x*x } .tap {|x| puts "squares: #{x}" }
750
+ #
751
+ def tap: () { (self) -> void } -> self
752
+
753
+ # Yields self to the block and returns the result of the block.
754
+ #
755
+ # 3.next.then {|x| x**x }.to_s #=> "256"
756
+ # "my string".yield_self {|s| s.upcase } #=> "MY STRING"
757
+ #
758
+ # Good usage for `yield_self` is value piping in method chains:
759
+ #
760
+ # require 'open-uri'
761
+ # require 'json'
762
+ #
763
+ # construct_url(arguments).
764
+ # yield_self {|url| open(url).read }.
765
+ # yield_self {|response| JSON.parse(response) }
766
+ #
767
+ # When called without block, the method returns `Enumerator`, which can be used,
768
+ # for example, for conditional circuit-breaking:
769
+ #
770
+ # # meets condition, no-op
771
+ # 1.yield_self.detect(&:odd?) # => 1
772
+ # # does not meet condition, drop value
773
+ # 2.yield_self.detect(&:odd?) # => nil
774
+ #
775
+ def `yield_self`: [X] () { (self) -> X } -> X
776
+ | () -> Enumerator[self, untyped]
777
+
778
+ # Returns a string representing *obj*. The default `to_s` prints the object's
779
+ # class and an encoding of the object id. As a special case, the top-level
780
+ # object that is the initial execution context of Ruby programs returns
781
+ # ``main''.
782
+ #
783
+ def to_s: () -> String
784
+
785
+ # Removes the tainted mark from the object.
786
+ #
787
+ # See #taint for more information.
788
+ #
789
+ def untaint: () -> self
790
+
791
+ # Deprecated method that is equivalent to #untaint.
792
+ #
793
+ alias trust untaint
794
+
795
+ # Yields self to the block and returns the result of the block.
796
+ #
797
+ # 3.next.then {|x| x**x }.to_s #=> "256"
798
+ # "my string".yield_self {|s| s.upcase } #=> "MY STRING"
799
+ #
800
+ # Good usage for `yield_self` is value piping in method chains:
801
+ #
802
+ # require 'open-uri'
803
+ # require 'json'
804
+ #
805
+ # construct_url(arguments).
806
+ # yield_self {|url| open(url).read }.
807
+ # yield_self {|response| JSON.parse(response) }
808
+ #
809
+ # When called without block, the method returns `Enumerator`, which can be used,
810
+ # for example, for conditional circuit-breaking:
811
+ #
812
+ # # meets condition, no-op
813
+ # 1.yield_self.detect(&:odd?) # => 1
814
+ # # does not meet condition, drop value
815
+ # 2.yield_self.detect(&:odd?) # => nil
816
+ #
817
+ alias then yield_self
818
+ end
819
+
820
+ interface _Writeable
821
+ def write: (untyped) -> void
822
+ end
823
+
824
+ type Object::name = Symbol | String