rbs 3.10.0 → 3.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/core/method.rbs CHANGED
@@ -126,7 +126,9 @@ class Method
126
126
 
127
127
  # <!--
128
128
  # rdoc-file=proc.c
129
- # - meth.call(args, ...) -> obj
129
+ # - meth.call(args, ...) -> obj
130
+ # - meth[args, ...] -> obj
131
+ # - method === obj -> result_of_method
130
132
  # -->
131
133
  # Invokes the *meth* with the specified arguments, returning the method's return
132
134
  # value.
@@ -135,23 +137,32 @@ class Method
135
137
  # m.call(3) #=> 15
136
138
  # m.call(20) #=> 32
137
139
  #
140
+ # Using Method#=== allows a method object to be the target of a `when` clause in
141
+ # a case statement.
142
+ #
143
+ # require 'prime'
144
+ #
145
+ # case 1373
146
+ # when Prime.method(:prime?)
147
+ # # ...
148
+ # end
149
+ #
138
150
  def call: (?) -> untyped
139
151
 
140
152
  # <!--
141
153
  # rdoc-file=proc.c
142
- # - meth << g -> a_proc
154
+ # - self << g -> a_proc
143
155
  # -->
144
- # Returns a proc that is the composition of this method and the given *g*. The
145
- # returned proc takes a variable number of arguments, calls *g* with them then
146
- # calls this method with the result.
156
+ # Returns a proc that is the composition of the given `g` and this method.
147
157
  #
148
- # def f(x)
149
- # x * x
150
- # end
158
+ # The returned proc takes a variable number of arguments. It first calls `g`
159
+ # with the arguments, then calls `self` with the return value of `g`.
160
+ #
161
+ # def f(ary) = ary << 'in f'
151
162
  #
152
163
  # f = self.method(:f)
153
- # g = proc {|x| x + x }
154
- # p (f << g).call(2) #=> 16
164
+ # g = proc { |ary| ary << 'in proc' }
165
+ # (f << g).call([]) # => ["in proc", "in f"]
155
166
  #
156
167
  def <<: (Proc::_Callable g) -> Proc
157
168
 
@@ -163,23 +174,32 @@ class Method
163
174
  # m.call(3) #=> 15
164
175
  # m.call(20) #=> 32
165
176
  #
177
+ # Using Method#=== allows a method object to be the target of a `when` clause in
178
+ # a case statement.
179
+ #
180
+ # require 'prime'
181
+ #
182
+ # case 1373
183
+ # when Prime.method(:prime?)
184
+ # # ...
185
+ # end
186
+ #
166
187
  alias === call
167
188
 
168
189
  # <!--
169
190
  # rdoc-file=proc.c
170
- # - meth >> g -> a_proc
191
+ # - self >> g -> a_proc
171
192
  # -->
172
- # Returns a proc that is the composition of this method and the given *g*. The
173
- # returned proc takes a variable number of arguments, calls this method with
174
- # them then calls *g* with the result.
193
+ # Returns a proc that is the composition of this method and the given `g`.
175
194
  #
176
- # def f(x)
177
- # x * x
178
- # end
195
+ # The returned proc takes a variable number of arguments. It first calls `self`
196
+ # with the arguments, then calls `g` with the return value of `self`.
197
+ #
198
+ # def f(ary) = ary << 'in f'
179
199
  #
180
200
  # f = self.method(:f)
181
- # g = proc {|x| x + x }
182
- # p (f >> g).call(2) #=> 8
201
+ # g = proc { |ary| ary << 'in proc' }
202
+ # (f >> g).call([]) # => ["in f", "in proc"]
183
203
  #
184
204
  def >>: (Proc::_Callable g) -> Proc
185
205
 
@@ -191,6 +211,16 @@ class Method
191
211
  # m.call(3) #=> 15
192
212
  # m.call(20) #=> 32
193
213
  #
214
+ # Using Method#=== allows a method object to be the target of a `when` clause in
215
+ # a case statement.
216
+ #
217
+ # require 'prime'
218
+ #
219
+ # case 1373
220
+ # when Prime.method(:prime?)
221
+ # # ...
222
+ # end
223
+ #
194
224
  alias [] call
195
225
 
196
226
  # <!--
data/core/module.rbs CHANGED
@@ -114,12 +114,15 @@ class Module < Object
114
114
 
115
115
  # <!--
116
116
  # rdoc-file=object.c
117
- # - mod < other -> true, false, or nil
117
+ # - self < other -> true, false, or nil
118
118
  # -->
119
- # Returns true if *mod* is a subclass of *other*. Returns `false` if *mod* is
120
- # the same as *other* or *mod* is an ancestor of *other*. Returns `nil` if
121
- # there's no relationship between the two. (Think of the relationship in terms
122
- # of the class definition: "class A < B" implies "A < B".)
119
+ # Returns whether `self` is a subclass of `other`, or `nil` if there is no
120
+ # relationship between the two:
121
+ #
122
+ # Float < Numeric # => true
123
+ # Numeric < Float # => false
124
+ # Float < Float # => false
125
+ # Float < Hash # => nil
123
126
  #
124
127
  def <: (Module other) -> bool?
125
128
 
@@ -135,13 +138,15 @@ class Module < Object
135
138
 
136
139
  # <!--
137
140
  # rdoc-file=object.c
138
- # - self <=> object -> -1, 0, +1, or nil
141
+ # - self <=> other -> -1, 0, 1, or nil
139
142
  # -->
143
+ # Compares `self` and `other`.
144
+ #
140
145
  # Returns:
141
146
  #
142
- # * `-1`, if `self` includes `object`, if or `self` is a subclass of `object`.
143
- # * `0`, if `self` and `object` are the same.
144
- # * `1`, if `object` includes `self`, or if `object` is a subclass of `self`.
147
+ # * `-1`, if `self` includes `other`, if or `self` is a subclass of `other`.
148
+ # * `0`, if `self` and `other` are the same.
149
+ # * `1`, if `other` includes `self`, or if `other` is a subclass of `self`.
145
150
  # * `nil`, if none of the above is true.
146
151
  #
147
152
  # Examples:
@@ -152,8 +157,10 @@ class Module < Object
152
157
  # Enumerable <=> Array # => 1
153
158
  # # Class File is a subclass of class IO.
154
159
  # File <=> IO # => -1
155
- # IO <=> File # => 1
156
160
  # File <=> File # => 0
161
+ # IO <=> File # => 1
162
+ # # Class File has no relationship to class String.
163
+ # File <=> String # => nil
157
164
  #
158
165
  def <=>: (untyped other) -> Integer?
159
166
 
@@ -1649,7 +1656,7 @@ class Module < Object
1649
1656
  # m.name #=> nil
1650
1657
  #
1651
1658
  # c = Class.new
1652
- # c.set_temporary_name("MyClass(with description)")
1659
+ # c.set_temporary_name("MyClass(with description)") # => MyClass(with description)
1653
1660
  #
1654
1661
  # c.new # => #<MyClass(with description):0x0....>
1655
1662
  #
data/core/numeric.rbs CHANGED
@@ -220,7 +220,15 @@ class Numeric
220
220
  # rdoc-file=numeric.c
221
221
  # - self <=> other -> zero or nil
222
222
  # -->
223
- # Returns zero if `self` is the same as `other`, `nil` otherwise.
223
+ # Compares `self` and `other`.
224
+ #
225
+ # Returns:
226
+ #
227
+ # * Zero, if `self` is the same as `other`.
228
+ # * `nil`, otherwise.
229
+ #
230
+ # Class Numeric includes module Comparable, each of whose methods uses
231
+ # Numeric#<=> for comparison.
224
232
  #
225
233
  # No subclass in the Ruby Core or Standard Library uses this implementation.
226
234
  #
data/core/pathname.rbs CHANGED
@@ -670,28 +670,6 @@ class Pathname
670
670
  #
671
671
  def file?: () -> bool
672
672
 
673
- # <!--
674
- # rdoc-file=lib/pathname.rb
675
- # - find(ignore_error: true) { |pathname| ... }
676
- # -->
677
- # Iterates over the directory tree in a depth first manner, yielding a Pathname
678
- # for each file under "this" directory.
679
- #
680
- # Note that you need to require 'pathname' to use this method.
681
- #
682
- # Returns an Enumerator if no block is given.
683
- #
684
- # Since it is implemented by the standard library module Find, Find.prune can be
685
- # used to control the traversal.
686
- #
687
- # If `self` is `.`, yielded pathnames begin with a filename in the current
688
- # directory, not `./`.
689
- #
690
- # See Find.find
691
- #
692
- def find: (?ignore_error: boolish) { (Pathname) -> untyped } -> nil
693
- | (?ignore_error: boolish) -> Enumerator[Pathname, nil]
694
-
695
673
  # <!--
696
674
  # rdoc-file=pathname_builtin.rb
697
675
  # - fnmatch(pattern, ...)
@@ -1017,18 +995,6 @@ class Pathname
1017
995
  #
1018
996
  def rmdir: () -> 0
1019
997
 
1020
- # <!--
1021
- # rdoc-file=lib/pathname.rb
1022
- # - rmtree(noop: nil, verbose: nil, secure: nil)
1023
- # -->
1024
- # Recursively deletes a directory, including all directories beneath it.
1025
- #
1026
- # Note that you need to require 'pathname' to use this method.
1027
- #
1028
- # See FileUtils.rm_rf
1029
- #
1030
- def rmtree: () -> self
1031
-
1032
998
  # <!--
1033
999
  # rdoc-file=pathname_builtin.rb
1034
1000
  # - root?()
data/core/proc.rbs CHANGED
@@ -380,9 +380,9 @@ class Proc
380
380
  def dup: () -> self
381
381
 
382
382
  # <!-- rdoc-file=proc.c -->
383
- # Invokes the block, setting the block's parameters to the values in *params*
384
- # using something close to method calling semantics. Returns the value of the
385
- # last expression evaluated in the block.
383
+ # Invokes the block, setting the block's parameters to the arguments using
384
+ # something close to method calling semantics. Returns the value of the last
385
+ # expression evaluated in the block.
386
386
  #
387
387
  # a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } }
388
388
  # a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]
@@ -409,9 +409,9 @@ class Proc
409
409
  alias === call
410
410
 
411
411
  # <!-- rdoc-file=proc.c -->
412
- # Invokes the block, setting the block's parameters to the values in *params*
413
- # using something close to method calling semantics. Returns the value of the
414
- # last expression evaluated in the block.
412
+ # Invokes the block, setting the block's parameters to the arguments using
413
+ # something close to method calling semantics. Returns the value of the last
414
+ # expression evaluated in the block.
415
415
  #
416
416
  # a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } }
417
417
  # a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]
@@ -592,14 +592,13 @@ class Proc
592
592
 
593
593
  # <!--
594
594
  # rdoc-file=proc.c
595
- # - prc.call(params,...) -> obj
596
- # - prc[params,...] -> obj
597
- # - prc.(params,...) -> obj
598
- # - prc.yield(params,...) -> obj
595
+ # - call(...) -> obj
596
+ # - self[...] -> obj
597
+ # - yield(...) -> obj
599
598
  # -->
600
- # Invokes the block, setting the block's parameters to the values in *params*
601
- # using something close to method calling semantics. Returns the value of the
602
- # last expression evaluated in the block.
599
+ # Invokes the block, setting the block's parameters to the arguments using
600
+ # something close to method calling semantics. Returns the value of the last
601
+ # expression evaluated in the block.
603
602
  #
604
603
  # a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } }
605
604
  # a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]
@@ -626,9 +625,9 @@ class Proc
626
625
  def call: (?) -> untyped
627
626
 
628
627
  # <!-- rdoc-file=proc.c -->
629
- # Invokes the block, setting the block's parameters to the values in *params*
630
- # using something close to method calling semantics. Returns the value of the
631
- # last expression evaluated in the block.
628
+ # Invokes the block, setting the block's parameters to the arguments using
629
+ # something close to method calling semantics. Returns the value of the last
630
+ # expression evaluated in the block.
632
631
  #
633
632
  # a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } }
634
633
  # a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]