rbs 0.12.2 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +8 -4
  3. data/.gitignore +0 -1
  4. data/CHANGELOG.md +32 -0
  5. data/Gemfile +4 -0
  6. data/README.md +8 -2
  7. data/Rakefile +9 -2
  8. data/Steepfile +1 -1
  9. data/bin/annotate-with-rdoc +1 -1
  10. data/bin/setup +0 -2
  11. data/bin/test_runner.rb +15 -1
  12. data/{stdlib/builtin → core}/array.rbs +124 -120
  13. data/{stdlib/builtin → core}/basic_object.rbs +54 -54
  14. data/{stdlib/builtin → core}/binding.rbs +42 -42
  15. data/core/builtin.rbs +70 -0
  16. data/{stdlib/builtin → core}/class.rbs +33 -33
  17. data/{stdlib/builtin → core}/comparable.rbs +0 -0
  18. data/{stdlib/builtin → core}/complex.rbs +90 -90
  19. data/{stdlib/builtin → core}/constants.rbs +0 -0
  20. data/{stdlib/builtin → core}/data.rbs +0 -0
  21. data/{stdlib/builtin → core}/deprecated.rbs +0 -0
  22. data/{stdlib/builtin → core}/dir.rbs +0 -0
  23. data/{stdlib/builtin → core}/encoding.rbs +33 -33
  24. data/{stdlib/builtin → core}/enumerable.rbs +58 -52
  25. data/{stdlib/builtin → core}/enumerator.rbs +35 -35
  26. data/{stdlib/builtin → core}/errno.rbs +0 -0
  27. data/{stdlib/builtin → core}/errors.rbs +2 -2
  28. data/{stdlib/builtin → core}/exception.rbs +50 -50
  29. data/{stdlib/builtin → core}/false_class.rbs +6 -6
  30. data/{stdlib/builtin → core}/fiber.rbs +14 -14
  31. data/{stdlib/builtin → core}/fiber_error.rbs +1 -1
  32. data/{stdlib/builtin → core}/file.rbs +0 -0
  33. data/{stdlib/builtin → core}/file_test.rbs +0 -0
  34. data/{stdlib/builtin → core}/float.rbs +161 -161
  35. data/{stdlib/builtin → core}/gc.rbs +3 -3
  36. data/{stdlib/builtin → core}/hash.rbs +7 -7
  37. data/{stdlib/builtin → core}/integer.rbs +0 -0
  38. data/{stdlib/builtin → core}/io.rbs +88 -88
  39. data/{stdlib/builtin → core}/kernel.rbs +71 -153
  40. data/{stdlib/builtin → core}/marshal.rbs +0 -0
  41. data/{stdlib/builtin → core}/match_data.rbs +1 -1
  42. data/{stdlib/builtin → core}/math.rbs +0 -0
  43. data/{stdlib/builtin → core}/method.rbs +19 -19
  44. data/{stdlib/builtin → core}/module.rbs +13 -13
  45. data/{stdlib/builtin → core}/nil_class.rbs +20 -20
  46. data/{stdlib/builtin → core}/numeric.rbs +101 -101
  47. data/{stdlib/builtin → core}/object.rbs +173 -173
  48. data/{stdlib/builtin → core}/proc.rbs +91 -91
  49. data/{stdlib/builtin → core}/process.rbs +0 -0
  50. data/{stdlib/builtin → core}/random.rbs +1 -1
  51. data/{stdlib/builtin → core}/range.rbs +3 -5
  52. data/{stdlib/builtin → core}/rational.rbs +83 -83
  53. data/{stdlib/builtin → core}/rb_config.rbs +0 -0
  54. data/{stdlib/builtin → core}/regexp.rbs +0 -0
  55. data/{stdlib/builtin → core}/ruby_vm.rbs +0 -0
  56. data/{stdlib/builtin → core}/signal.rbs +7 -7
  57. data/{stdlib/builtin → core}/string.rbs +10 -10
  58. data/{stdlib/builtin → core}/string_io.rbs +8 -8
  59. data/{stdlib/builtin → core}/struct.rbs +1 -1
  60. data/{stdlib/builtin → core}/symbol.rbs +1 -1
  61. data/{stdlib/builtin → core}/thread.rbs +189 -189
  62. data/{stdlib/builtin → core}/thread_group.rbs +2 -2
  63. data/{stdlib/builtin → core}/time.rbs +0 -0
  64. data/{stdlib/builtin → core}/trace_point.rbs +0 -0
  65. data/{stdlib/builtin → core}/true_class.rbs +10 -10
  66. data/{stdlib/builtin → core}/unbound_method.rbs +0 -0
  67. data/{stdlib/builtin → core}/warning.rbs +1 -1
  68. data/docs/CONTRIBUTING.md +1 -0
  69. data/docs/repo.md +125 -0
  70. data/docs/syntax.md +50 -6
  71. data/goodcheck.yml +22 -5
  72. data/lib/rbs.rb +1 -0
  73. data/lib/rbs/ast/comment.rb +1 -1
  74. data/lib/rbs/cli.rb +117 -107
  75. data/lib/rbs/constant.rb +1 -1
  76. data/lib/rbs/constant_table.rb +9 -8
  77. data/lib/rbs/definition_builder.rb +6 -7
  78. data/lib/rbs/environment.rb +5 -1
  79. data/lib/rbs/environment_loader.rb +79 -105
  80. data/lib/rbs/namespace.rb +1 -1
  81. data/lib/rbs/parser.rb +3148 -0
  82. data/lib/rbs/parser.y +10 -3
  83. data/lib/rbs/prototype/rb.rb +38 -6
  84. data/lib/rbs/prototype/runtime.rb +17 -7
  85. data/lib/rbs/repository.rb +121 -0
  86. data/lib/rbs/test/hook.rb +2 -0
  87. data/lib/rbs/test/setup.rb +5 -3
  88. data/lib/rbs/test/setup_helper.rb +4 -4
  89. data/lib/rbs/test/tester.rb +4 -1
  90. data/lib/rbs/test/type_check.rb +12 -6
  91. data/lib/rbs/type_name.rb +3 -2
  92. data/lib/rbs/variance_calculator.rb +2 -2
  93. data/lib/rbs/vendorer.rb +38 -16
  94. data/lib/rbs/version.rb +1 -1
  95. data/lib/rbs/writer.rb +25 -15
  96. data/sig/cli.rbs +58 -0
  97. data/sig/constant.rbs +21 -0
  98. data/sig/constant_table.rbs +30 -0
  99. data/sig/declarations.rbs +2 -2
  100. data/sig/definition.rbs +2 -2
  101. data/sig/definition_builder.rbs +6 -5
  102. data/sig/environment_loader.rbs +100 -0
  103. data/sig/members.rbs +2 -2
  104. data/sig/method_types.rbs +1 -1
  105. data/sig/namespace.rbs +4 -4
  106. data/sig/parser.rbs +25 -0
  107. data/sig/polyfill.rbs +42 -0
  108. data/sig/rbs.rbs +8 -0
  109. data/sig/repository.rbs +79 -0
  110. data/sig/substitution.rbs +3 -3
  111. data/sig/typename.rbs +1 -1
  112. data/sig/types.rbs +1 -1
  113. data/sig/vendorer.rbs +44 -0
  114. data/sig/version.rbs +3 -0
  115. data/sig/writer.rbs +40 -0
  116. data/stdlib/abbrev/{abbrev.rbs → 0/abbrev.rbs} +0 -0
  117. data/stdlib/base64/{base64.rbs → 0/base64.rbs} +1 -1
  118. data/stdlib/benchmark/{benchmark.rbs → 0/benchmark.rbs} +2 -2
  119. data/stdlib/{bigdecimal/math → bigdecimal-math/0}/big_math.rbs +0 -0
  120. data/stdlib/bigdecimal/{big_decimal.rbs → 0/big_decimal.rbs} +0 -0
  121. data/stdlib/coverage/{coverage.rbs → 0/coverage.rbs} +2 -2
  122. data/stdlib/csv/{csv.rbs → 0/csv.rbs} +1 -1
  123. data/stdlib/date/{date.rbs → 0/date.rbs} +4 -4
  124. data/stdlib/date/{date_time.rbs → 0/date_time.rbs} +1 -1
  125. data/stdlib/dbm/0/dbm.rbs +277 -0
  126. data/stdlib/erb/{erb.rbs → 0/erb.rbs} +0 -0
  127. data/stdlib/fiber/{fiber.rbs → 0/fiber.rbs} +0 -0
  128. data/stdlib/find/{find.rbs → 0/find.rbs} +12 -12
  129. data/stdlib/forwardable/{forwardable.rbs → 0/forwardable.rbs} +0 -0
  130. data/stdlib/ipaddr/{ipaddr.rbs → 0/ipaddr.rbs} +0 -0
  131. data/stdlib/json/{json.rbs → 0/json.rbs} +0 -0
  132. data/stdlib/logger/{formatter.rbs → 0/formatter.rbs} +0 -0
  133. data/stdlib/logger/{log_device.rbs → 0/log_device.rbs} +1 -1
  134. data/stdlib/logger/{logger.rbs → 0/logger.rbs} +1 -1
  135. data/stdlib/logger/{period.rbs → 0/period.rbs} +0 -0
  136. data/stdlib/logger/{severity.rbs → 0/severity.rbs} +0 -0
  137. data/stdlib/mutex_m/{mutex_m.rbs → 0/mutex_m.rbs} +0 -0
  138. data/stdlib/pathname/{pathname.rbs → 0/pathname.rbs} +41 -39
  139. data/stdlib/prime/{integer-extension.rbs → 0/integer-extension.rbs} +0 -0
  140. data/stdlib/prime/{prime.rbs → 0/prime.rbs} +0 -0
  141. data/stdlib/pstore/0/pstore.rbs +287 -0
  142. data/stdlib/pty/{pty.rbs → 0/pty.rbs} +1 -1
  143. data/stdlib/securerandom/{securerandom.rbs → 0/securerandom.rbs} +0 -0
  144. data/stdlib/set/{set.rbs → 0/set.rbs} +0 -0
  145. data/stdlib/tmpdir/{tmpdir.rbs → 0/tmpdir.rbs} +12 -12
  146. data/stdlib/uri/{file.rbs → 0/file.rbs} +0 -0
  147. data/stdlib/uri/{generic.rbs → 0/generic.rbs} +2 -2
  148. data/stdlib/uri/0/http.rbs +158 -0
  149. data/stdlib/uri/0/https.rbs +108 -0
  150. data/stdlib/uri/0/ldap.rbs +224 -0
  151. data/stdlib/uri/0/ldaps.rbs +108 -0
  152. data/stdlib/zlib/{zlib.rbs → 0/zlib.rbs} +0 -0
  153. data/steep/Gemfile.lock +13 -17
  154. metadata +105 -89
  155. data/stdlib/builtin/builtin.rbs +0 -42
@@ -1,108 +1,108 @@
1
1
  # BasicObject is the parent class of all classes in Ruby. It's an explicit
2
2
  # blank class.
3
- #
3
+ #
4
4
  # BasicObject can be used for creating object hierarchies independent of Ruby's
5
5
  # object hierarchy, proxy objects like the Delegator class, or other uses where
6
6
  # namespace pollution from Ruby's methods and classes must be avoided.
7
- #
7
+ #
8
8
  # To avoid polluting BasicObject for other users an appropriately named subclass
9
9
  # of BasicObject should be created instead of directly modifying BasicObject:
10
- #
10
+ #
11
11
  # class MyObjectSystem < BasicObject
12
12
  # end
13
- #
13
+ #
14
14
  # BasicObject does not include Kernel (for methods like `puts`) and BasicObject
15
15
  # is outside of the namespace of the standard library so common classes will not
16
16
  # be found without using a full class path.
17
- #
17
+ #
18
18
  # A variety of strategies can be used to provide useful portions of the standard
19
19
  # library to subclasses of BasicObject. A subclass could `include Kernel` to
20
20
  # obtain `puts`, `exit`, etc. A custom Kernel-like module could be created and
21
21
  # included or delegation can be used via #method_missing:
22
- #
22
+ #
23
23
  # class MyObjectSystem < BasicObject
24
24
  # DELEGATE = [:puts, :p]
25
- #
25
+ #
26
26
  # def method_missing(name, *args, &block)
27
27
  # super unless DELEGATE.include? name
28
28
  # ::Kernel.send(name, *args, &block)
29
29
  # end
30
- #
30
+ #
31
31
  # def respond_to_missing?(name, include_private = false)
32
32
  # DELEGATE.include?(name) or super
33
33
  # end
34
34
  # end
35
- #
35
+ #
36
36
  # Access to classes and modules from the Ruby standard library can be obtained
37
37
  # in a BasicObject subclass by referencing the desired constant from the root
38
38
  # like `::File` or `::Enumerator`. Like #method_missing, #const_missing can be
39
39
  # used to delegate constant lookup to `Object`:
40
- #
40
+ #
41
41
  # class MyObjectSystem < BasicObject
42
42
  # def self.const_missing(name)
43
43
  # ::Object.const_get(name)
44
44
  # end
45
45
  # end
46
- #
46
+ #
47
47
  class BasicObject
48
48
  # Boolean negate.
49
- #
49
+ #
50
50
  def !: () -> bool
51
51
 
52
52
  # Returns true if two objects are not-equal, otherwise false.
53
- #
53
+ #
54
54
  def !=: (untyped other) -> bool
55
55
 
56
56
  # Equality --- At the `Object` level, `==` returns `true` only if `obj` and
57
57
  # `other` are the same object. Typically, this method is overridden in
58
58
  # descendant classes to provide class-specific meaning.
59
- #
59
+ #
60
60
  # Unlike `==`, the `equal?` method should never be overridden by subclasses as
61
61
  # it is used to determine object identity (that is, `a.equal?(b)` if and only if
62
62
  # `a` is the same object as `b`):
63
- #
63
+ #
64
64
  # obj = "a"
65
65
  # other = obj.dup
66
- #
66
+ #
67
67
  # obj == other #=> true
68
68
  # obj.equal? other #=> false
69
69
  # obj.equal? obj #=> true
70
- #
70
+ #
71
71
  # The `eql?` method returns `true` if `obj` and `other` refer to the same hash
72
72
  # key. This is used by Hash to test members for equality. For objects of class
73
73
  # `Object`, `eql?` is synonymous with `==`. Subclasses normally continue this
74
74
  # tradition by aliasing `eql?` to their overridden `==` method, but there are
75
75
  # exceptions. `Numeric` types, for example, perform type conversion across
76
76
  # `==`, but not across `eql?`, so:
77
- #
77
+ #
78
78
  # 1 == 1.0 #=> true
79
79
  # 1.eql? 1.0 #=> false
80
- #
80
+ #
81
81
  def ==: (untyped other) -> bool
82
82
 
83
83
  # Returns an integer identifier for `obj`.
84
- #
84
+ #
85
85
  # The same number will be returned on all calls to `object_id` for a given
86
86
  # object, and no two active objects will share an id.
87
- #
87
+ #
88
88
  # Note: that some objects of builtin classes are reused for optimization. This
89
89
  # is the case for immediate values and frozen string literals.
90
- #
90
+ #
91
91
  # Immediate values are not passed by reference but are passed by value: `nil`,
92
92
  # `true`, `false`, Fixnums, Symbols, and some Floats.
93
- #
93
+ #
94
94
  # Object.new.object_id == Object.new.object_id # => false
95
95
  # (21 * 2).object_id == (21 * 2).object_id # => true
96
96
  # "hello".object_id == "hello".object_id # => false
97
97
  # "hi".freeze.object_id == "hi".freeze.object_id # => true
98
- #
98
+ #
99
99
  def __id__: () -> Integer
100
100
 
101
101
  # Invokes the method identified by *symbol*, passing it any arguments specified.
102
102
  # You can use `__send__` if the name `send` clashes with an existing method in
103
103
  # *obj*. When the method is identified by a string, the string is converted to a
104
104
  # symbol.
105
- #
105
+ #
106
106
  # class Klass
107
107
  # def hello(*args)
108
108
  # "Hello " + args.join(' ')
@@ -110,48 +110,48 @@ class BasicObject
110
110
  # end
111
111
  # k = Klass.new
112
112
  # k.send :hello, "gentle", "readers" #=> "Hello gentle readers"
113
- #
113
+ #
114
114
  def __send__: (String | Symbol arg0, *untyped args) -> untyped
115
115
 
116
116
  # Equality --- At the `Object` level, `==` returns `true` only if `obj` and
117
117
  # `other` are the same object. Typically, this method is overridden in
118
118
  # descendant classes to provide class-specific meaning.
119
- #
119
+ #
120
120
  # Unlike `==`, the `equal?` method should never be overridden by subclasses as
121
121
  # it is used to determine object identity (that is, `a.equal?(b)` if and only if
122
122
  # `a` is the same object as `b`):
123
- #
123
+ #
124
124
  # obj = "a"
125
125
  # other = obj.dup
126
- #
126
+ #
127
127
  # obj == other #=> true
128
128
  # obj.equal? other #=> false
129
129
  # obj.equal? obj #=> true
130
- #
130
+ #
131
131
  # The `eql?` method returns `true` if `obj` and `other` refer to the same hash
132
132
  # key. This is used by Hash to test members for equality. For objects of class
133
133
  # `Object`, `eql?` is synonymous with `==`. Subclasses normally continue this
134
134
  # tradition by aliasing `eql?` to their overridden `==` method, but there are
135
135
  # exceptions. `Numeric` types, for example, perform type conversion across
136
136
  # `==`, but not across `eql?`, so:
137
- #
137
+ #
138
138
  # 1 == 1.0 #=> true
139
139
  # 1.eql? 1.0 #=> false
140
- #
140
+ #
141
141
  def equal?: (untyped other) -> bool
142
142
 
143
143
  # Evaluates a string containing Ruby source code, or the given block, within the
144
144
  # context of the receiver (*obj*). In order to set the context, the variable
145
145
  # `self` is set to *obj* while the code is executing, giving the code access to
146
146
  # *obj*'s instance variables and private methods.
147
- #
147
+ #
148
148
  # When `instance_eval` is given a block, *obj* is also passed in as the block's
149
149
  # only argument.
150
- #
150
+ #
151
151
  # When `instance_eval` is given a `String`, the optional second and third
152
152
  # parameters supply a filename and starting line number that are used when
153
153
  # reporting compilation errors.
154
- #
154
+ #
155
155
  # class KlassWithSecret
156
156
  # def initialize
157
157
  # @secret = 99
@@ -165,7 +165,7 @@ class BasicObject
165
165
  # k.instance_eval { @secret } #=> 99
166
166
  # k.instance_eval { the_secret } #=> "Ssssh! The secret is 99."
167
167
  # k.instance_eval {|obj| obj == self } #=> true
168
- #
168
+ #
169
169
  def instance_eval: (String, ?String filename, ?Integer lineno) -> untyped
170
170
  | [U] () { (self) -> U } -> U
171
171
 
@@ -173,7 +173,7 @@ class BasicObject
173
173
  # to set the context, the variable `self` is set to *obj* while the code is
174
174
  # executing, giving the code access to *obj*'s instance variables. Arguments
175
175
  # are passed as block parameters.
176
- #
176
+ #
177
177
  # class KlassWithSecret
178
178
  # def initialize
179
179
  # @secret = 99
@@ -181,11 +181,11 @@ class BasicObject
181
181
  # end
182
182
  # k = KlassWithSecret.new
183
183
  # k.instance_exec(5) {|x| @secret+x } #=> 104
184
- #
184
+ #
185
185
  def instance_exec: [U, V] (*V args) { (*V args) -> U } -> U
186
186
 
187
187
  # Not documented
188
- #
188
+ #
189
189
  def initialize: () -> void
190
190
 
191
191
  private
@@ -199,7 +199,7 @@ class BasicObject
199
199
  # method. The example below creates a class `Roman`, which responds to methods
200
200
  # with names consisting of roman numerals, returning the corresponding integer
201
201
  # values.
202
- #
202
+ #
203
203
  # class Roman
204
204
  # def roman_to_int(str)
205
205
  # # ...
@@ -209,16 +209,16 @@ class BasicObject
209
209
  # roman_to_int(str)
210
210
  # end
211
211
  # end
212
- #
212
+ #
213
213
  # r = Roman.new
214
214
  # r.iv #=> 4
215
215
  # r.xxiii #=> 23
216
216
  # r.mm #=> 2000
217
- #
217
+ #
218
218
  def method_missing: (Symbol, *untyped) -> untyped
219
219
 
220
220
  # Invoked as a callback whenever a singleton method is added to the receiver.
221
- #
221
+ #
222
222
  # module Chatty
223
223
  # def Chatty.singleton_method_added(id)
224
224
  # puts "Adding #{id.id2name}"
@@ -227,18 +227,18 @@ class BasicObject
227
227
  # def two() end
228
228
  # def Chatty.three() end
229
229
  # end
230
- #
230
+ #
231
231
  # *produces:*
232
- #
232
+ #
233
233
  # Adding singleton_method_added
234
234
  # Adding one
235
235
  # Adding three
236
- #
236
+ #
237
237
  def singleton_method_added: (Symbol) -> void
238
238
 
239
239
  # Invoked as a callback whenever a singleton method is removed from the
240
240
  # receiver.
241
- #
241
+ #
242
242
  # module Chatty
243
243
  # def Chatty.singleton_method_removed(id)
244
244
  # puts "Removing #{id.id2name}"
@@ -251,17 +251,17 @@ class BasicObject
251
251
  # remove_method :one
252
252
  # end
253
253
  # end
254
- #
254
+ #
255
255
  # *produces:*
256
- #
256
+ #
257
257
  # Removing three
258
258
  # Removing one
259
- #
259
+ #
260
260
  def singleton_method_removed: (Symbol) -> void
261
261
 
262
262
  # Invoked as a callback whenever a singleton method is undefined in the
263
263
  # receiver.
264
- #
264
+ #
265
265
  # module Chatty
266
266
  # def Chatty.singleton_method_undefined(id)
267
267
  # puts "Undefining #{id.id2name}"
@@ -271,10 +271,10 @@ class BasicObject
271
271
  # undef_method(:one)
272
272
  # end
273
273
  # end
274
- #
274
+ #
275
275
  # *produces:*
276
- #
276
+ #
277
277
  # Undefining one
278
- #
278
+ #
279
279
  def singleton_method_undefined: (Symbol) -> void
280
280
  end
@@ -4,10 +4,10 @@
4
4
  # in this context are all retained. Binding objects can be created using
5
5
  # Kernel#binding, and are made available to the callback of
6
6
  # Kernel#set_trace_func and instances of TracePoint.
7
- #
7
+ #
8
8
  # These binding objects can be passed as the second argument of the Kernel#eval
9
9
  # method, establishing an environment for the evaluation.
10
- #
10
+ #
11
11
  # class Demo
12
12
  # def initialize(n)
13
13
  # @secret = n
@@ -16,39 +16,39 @@
16
16
  # binding
17
17
  # end
18
18
  # end
19
- #
19
+ #
20
20
  # k1 = Demo.new(99)
21
21
  # b1 = k1.get_binding
22
22
  # k2 = Demo.new(-3)
23
23
  # b2 = k2.get_binding
24
- #
24
+ #
25
25
  # eval("@secret", b1) #=> 99
26
26
  # eval("@secret", b2) #=> -3
27
27
  # eval("@secret") #=> nil
28
- #
28
+ #
29
29
  # Binding objects have no class-specific methods.
30
- #
30
+ #
31
31
  class Binding
32
32
  public
33
33
 
34
34
  # Evaluates the Ruby expression(s) in *string*, in the *binding*'s context. If
35
35
  # the optional *filename* and *lineno* parameters are present, they will be used
36
36
  # when reporting syntax errors.
37
- #
37
+ #
38
38
  # def get_binding(param)
39
39
  # binding
40
40
  # end
41
41
  # b = get_binding("hello")
42
42
  # b.eval("param") #=> "hello"
43
- #
43
+ #
44
44
  def eval: (String arg0, ?String filename, ?Integer lineno) -> untyped
45
45
 
46
46
  # Opens an IRB session where `binding.irb` is called which allows for
47
47
  # interactive debugging. You can call any methods or variables available in the
48
48
  # current scope, and mutate state if you need to.
49
- #
49
+ #
50
50
  # Given a Ruby file called `potato.rb` containing the following code:
51
- #
51
+ #
52
52
  # class Potato
53
53
  # def initialize
54
54
  # @cooked = false
@@ -56,16 +56,16 @@ class Binding
56
56
  # puts "Cooked potato: #{@cooked}"
57
57
  # end
58
58
  # end
59
- #
59
+ #
60
60
  # Potato.new
61
- #
61
+ #
62
62
  # Running `ruby potato.rb` will open an IRB session where `binding.irb` is
63
63
  # called, and you will see the following:
64
- #
64
+ #
65
65
  # $ ruby potato.rb
66
- #
66
+ #
67
67
  # From: potato.rb @ line 4 :
68
- #
68
+ #
69
69
  # 1: class Potato
70
70
  # 2: def initialize
71
71
  # 3: @cooked = false
@@ -75,12 +75,12 @@ class Binding
75
75
  # 7: end
76
76
  # 8:
77
77
  # 9: Potato.new
78
- #
78
+ #
79
79
  # irb(#<Potato:0x00007feea1916670>):001:0>
80
- #
80
+ #
81
81
  # You can type any valid Ruby code and it will be evaluated in the current
82
82
  # context. This allows you to debug without having to run your code repeatedly:
83
- #
83
+ #
84
84
  # irb(#<Potato:0x00007feea1916670>):001:0> @cooked
85
85
  # => false
86
86
  # irb(#<Potato:0x00007feea1916670>):002:0> self.class
@@ -89,89 +89,89 @@ class Binding
89
89
  # => ".../2.5.1/lib/ruby/2.5.0/irb/workspace.rb:85:in `eval'"
90
90
  # irb(#<Potato:0x00007feea1916670>):004:0> @cooked = true
91
91
  # => true
92
- #
92
+ #
93
93
  # You can exit the IRB session with the `exit` command. Note that exiting will
94
94
  # resume execution where `binding.irb` had paused it, as you can see from the
95
95
  # output printed to standard output in this example:
96
- #
96
+ #
97
97
  # irb(#<Potato:0x00007feea1916670>):005:0> exit
98
98
  # Cooked potato: true
99
- #
99
+ #
100
100
  # See IRB@IRB+Usage for more information.
101
- #
101
+ #
102
102
  def irb: () -> void
103
103
 
104
104
  # Returns `true` if a local variable `symbol` exists.
105
- #
105
+ #
106
106
  # def foo
107
107
  # a = 1
108
108
  # binding.local_variable_defined?(:a) #=> true
109
109
  # binding.local_variable_defined?(:b) #=> false
110
110
  # end
111
- #
111
+ #
112
112
  # This method is the short version of the following code:
113
- #
113
+ #
114
114
  # binding.eval("defined?(#{symbol}) == 'local-variable'")
115
- #
115
+ #
116
116
  def local_variable_defined?: (String | Symbol symbol) -> bool
117
117
 
118
118
  # Returns the value of the local variable `symbol`.
119
- #
119
+ #
120
120
  # def foo
121
121
  # a = 1
122
122
  # binding.local_variable_get(:a) #=> 1
123
123
  # binding.local_variable_get(:b) #=> NameError
124
124
  # end
125
- #
125
+ #
126
126
  # This method is the short version of the following code:
127
- #
127
+ #
128
128
  # binding.eval("#{symbol}")
129
- #
129
+ #
130
130
  def local_variable_get: (String | Symbol symbol) -> untyped
131
131
 
132
132
  # Set local variable named `symbol` as `obj`.
133
- #
133
+ #
134
134
  # def foo
135
135
  # a = 1
136
136
  # bind = binding
137
137
  # bind.local_variable_set(:a, 2) # set existing local variable `a'
138
138
  # bind.local_variable_set(:b, 3) # create new local variable `b'
139
139
  # # `b' exists only in binding
140
- #
140
+ #
141
141
  # p bind.local_variable_get(:a) #=> 2
142
142
  # p bind.local_variable_get(:b) #=> 3
143
143
  # p a #=> 2
144
144
  # p b #=> NameError
145
145
  # end
146
- #
146
+ #
147
147
  # This method behaves similarly to the following code:
148
- #
148
+ #
149
149
  # binding.eval("#{symbol} = #{obj}")
150
- #
150
+ #
151
151
  # if `obj` can be dumped in Ruby code.
152
- #
152
+ #
153
153
  def local_variable_set: [U] (String | Symbol symbol, U obj) -> U
154
154
 
155
155
  # Returns the names of the binding's local variables as symbols.
156
- #
156
+ #
157
157
  # def foo
158
158
  # a = 1
159
159
  # 2.times do |n|
160
160
  # binding.local_variables #=> [:a, :n]
161
161
  # end
162
162
  # end
163
- #
163
+ #
164
164
  # This method is the short version of the following code:
165
- #
165
+ #
166
166
  # binding.eval("local_variables")
167
- #
167
+ #
168
168
  def local_variables: () -> Array[Symbol]
169
169
 
170
170
  # Returns the bound receiver of the binding object.
171
- #
171
+ #
172
172
  def receiver: () -> untyped
173
173
 
174
174
  # Returns the Ruby source filename and line number of the binding object.
175
- #
175
+ #
176
176
  def source_location: () -> [ String, Integer ]
177
177
  end