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,707 @@
1
+ # Holds Integer values. You cannot add a singleton method to an Integer object,
2
+ # any attempt to do so will raise a TypeError.
3
+ #
4
+ class Integer < Numeric
5
+ # Returns the integer square root of the non-negative integer `n`, i.e. the
6
+ # largest non-negative integer less than or equal to the square root of `n`.
7
+ #
8
+ # Integer.sqrt(0) #=> 0
9
+ # Integer.sqrt(1) #=> 1
10
+ # Integer.sqrt(24) #=> 4
11
+ # Integer.sqrt(25) #=> 5
12
+ # Integer.sqrt(10**400) #=> 10**200
13
+ #
14
+ # Equivalent to `Math.sqrt(n).floor`, except that the result of the latter code
15
+ # may differ from the true value due to the limited precision of floating point
16
+ # arithmetic.
17
+ #
18
+ # Integer.sqrt(10**46) #=> 100000000000000000000000
19
+ # Math.sqrt(10**46).floor #=> 99999999999999991611392 (!)
20
+ #
21
+ # If `n` is not an Integer, it is converted to an Integer first. If `n` is
22
+ # negative, a Math::DomainError is raised.
23
+ #
24
+ def self.sqrt: (int n) -> Integer
25
+
26
+ public
27
+
28
+ # Returns `int` modulo `other`.
29
+ #
30
+ # See Numeric#divmod for more information.
31
+ #
32
+ def %: (Float) -> Float
33
+ | (Rational) -> Rational
34
+ | (Integer) -> Integer
35
+ | (Numeric) -> Numeric
36
+
37
+ # Bitwise AND.
38
+ #
39
+ def &: (Integer) -> Integer
40
+
41
+ # Performs multiplication: the class of the resulting object depends on the
42
+ # class of `numeric`.
43
+ #
44
+ def *: (Float) -> Float
45
+ | (Rational) -> Rational
46
+ | (Complex) -> Complex
47
+ | (Integer) -> Integer
48
+
49
+ # Raises `int` to the power of `numeric`, which may be negative or fractional.
50
+ # The result may be an Integer, a Float, a Rational, or a complex number.
51
+ #
52
+ # 2 ** 3 #=> 8
53
+ # 2 ** -1 #=> (1/2)
54
+ # 2 ** 0.5 #=> 1.4142135623730951
55
+ # (-1) ** 0.5 #=> (0.0+1.0i)
56
+ #
57
+ # 123456789 ** 2 #=> 15241578750190521
58
+ # 123456789 ** 1.2 #=> 5126464716.0993185
59
+ # 123456789 ** -2 #=> (1/15241578750190521)
60
+ #
61
+ def **: (Integer) -> Numeric
62
+ | (Float) -> Numeric
63
+ | (Rational) -> Numeric
64
+ | (Complex) -> Complex
65
+
66
+ # Performs addition: the class of the resulting object depends on the class of
67
+ # `numeric`.
68
+ #
69
+ def +: (Integer) -> Integer
70
+ | (Float) -> Float
71
+ | (Rational) -> Rational
72
+ | (Complex) -> Complex
73
+
74
+ def +@: () -> Integer
75
+
76
+ # Performs subtraction: the class of the resulting object depends on the class
77
+ # of `numeric`.
78
+ #
79
+ def -: (Integer) -> Integer
80
+ | (Float) -> Float
81
+ | (Rational) -> Rational
82
+ | (Complex) -> Complex
83
+
84
+ # Returns `int`, negated.
85
+ #
86
+ def -@: () -> Integer
87
+
88
+ # Performs division: the class of the resulting object depends on the class of
89
+ # `numeric`.
90
+ #
91
+ def /: (Integer) -> Integer
92
+ | (Float) -> Float
93
+ | (Rational) -> Rational
94
+ | (Complex) -> Complex
95
+
96
+ # Returns `true` if the value of `int` is less than that of `real`.
97
+ #
98
+ def <: (Numeric) -> bool
99
+
100
+ # Returns `int` shifted left `count` positions, or right if `count` is negative.
101
+ #
102
+ def <<: (int) -> Integer
103
+
104
+ # Returns `true` if the value of `int` is less than or equal to that of `real`.
105
+ #
106
+ def <=: (Numeric) -> bool
107
+
108
+ # Comparison---Returns -1, 0, or +1 depending on whether `int` is less than,
109
+ # equal to, or greater than `numeric`.
110
+ #
111
+ # This is the basis for the tests in the Comparable module.
112
+ #
113
+ # `nil` is returned if the two values are incomparable.
114
+ #
115
+ def <=>: (Numeric) -> Integer?
116
+
117
+ # Returns `true` if `int` equals `other` numerically. Contrast this with
118
+ # Integer#eql?, which requires `other` to be an Integer.
119
+ #
120
+ # 1 == 2 #=> false
121
+ # 1 == 1.0 #=> true
122
+ #
123
+ def ==: (untyped) -> bool
124
+
125
+ # Returns `true` if `int` equals `other` numerically. Contrast this with
126
+ # Integer#eql?, which requires `other` to be an Integer.
127
+ #
128
+ # 1 == 2 #=> false
129
+ # 1 == 1.0 #=> true
130
+ #
131
+ def ===: (untyped) -> bool
132
+
133
+ # Returns `true` if the value of `int` is greater than that of `real`.
134
+ #
135
+ def >: (Numeric) -> bool
136
+
137
+ # Returns `true` if the value of `int` is greater than or equal to that of
138
+ # `real`.
139
+ #
140
+ def >=: (Numeric) -> bool
141
+
142
+ # Returns `int` shifted right `count` positions, or left if `count` is negative.
143
+ #
144
+ def >>: (int) -> Integer
145
+
146
+ # Bit Reference---Returns the `n`th bit in the binary representation of `int`,
147
+ # where `int[0]` is the least significant bit.
148
+ #
149
+ # a = 0b11001100101010
150
+ # 30.downto(0) {|n| print a[n] }
151
+ # #=> 0000000000000000011001100101010
152
+ #
153
+ # a = 9**15
154
+ # 50.downto(0) {|n| print a[n] }
155
+ # #=> 000101110110100000111000011110010100111100010111001
156
+ #
157
+ # In principle, `n[i]` is equivalent to `(n >> i) & 1`. Thus, any negative index
158
+ # always returns zero:
159
+ #
160
+ # p 255[-1] #=> 0
161
+ #
162
+ # Range operations `n[i, len]` and `n[i..j]` are naturally extended.
163
+ #
164
+ # * `n[i, len]` equals to `(n >> i) & ((1 << len) - 1)`.
165
+ # * `n[i..j]` equals to `(n >> i) & ((1 << (j - i + 1)) - 1)`.
166
+ # * `n[i...j]` equals to `(n >> i) & ((1 << (j - i)) - 1)`.
167
+ # * `n[i..]` equals to `(n >> i)`.
168
+ # * `n[..j]` is zero if `n & ((1 << (j + 1)) - 1)` is zero. Otherwise, raises
169
+ # an ArgumentError.
170
+ # * `n[...j]` is zero if `n & ((1 << j) - 1)` is zero. Otherwise, raises an
171
+ # ArgumentError.
172
+ #
173
+ #
174
+ # Note that range operation may exhaust memory. For example, `-1[0,
175
+ # 1000000000000]` will raise NoMemoryError.
176
+ #
177
+ def []: (int) -> Integer
178
+ | (int i, int len) -> Integer
179
+ | (Range[int]) -> Integer
180
+
181
+ # Bitwise EXCLUSIVE OR.
182
+ #
183
+ def ^: (Integer) -> Integer
184
+
185
+ # Returns the absolute value of `int`.
186
+ #
187
+ # (-12345).abs #=> 12345
188
+ # -12345.abs #=> 12345
189
+ # 12345.abs #=> 12345
190
+ #
191
+ # Integer#magnitude is an alias for Integer#abs.
192
+ #
193
+ def abs: () -> Integer
194
+
195
+ def abs2: () -> Integer
196
+
197
+ # Returns `true` if all bits of `int & mask` are 1.
198
+ #
199
+ def allbits?: (int mask) -> bool
200
+
201
+ def angle: () -> (Integer | Float)
202
+
203
+ # Returns `true` if any bits of `int & mask` are 1.
204
+ #
205
+ def anybits?: (int mask) -> bool
206
+
207
+ alias arg angle
208
+
209
+ # Returns the number of bits of the value of `int`.
210
+ #
211
+ # "Number of bits" means the bit position of the highest bit which is different
212
+ # from the sign bit (where the least significant bit has bit position 1). If
213
+ # there is no such bit (zero or minus one), zero is returned.
214
+ #
215
+ # I.e. this method returns *ceil(log2(int < 0 ? -int : int+1))*.
216
+ #
217
+ # (-2**1000-1).bit_length #=> 1001
218
+ # (-2**1000).bit_length #=> 1000
219
+ # (-2**1000+1).bit_length #=> 1000
220
+ # (-2**12-1).bit_length #=> 13
221
+ # (-2**12).bit_length #=> 12
222
+ # (-2**12+1).bit_length #=> 12
223
+ # -0x101.bit_length #=> 9
224
+ # -0x100.bit_length #=> 8
225
+ # -0xff.bit_length #=> 8
226
+ # -2.bit_length #=> 1
227
+ # -1.bit_length #=> 0
228
+ # 0.bit_length #=> 0
229
+ # 1.bit_length #=> 1
230
+ # 0xff.bit_length #=> 8
231
+ # 0x100.bit_length #=> 9
232
+ # (2**12-1).bit_length #=> 12
233
+ # (2**12).bit_length #=> 13
234
+ # (2**12+1).bit_length #=> 13
235
+ # (2**1000-1).bit_length #=> 1000
236
+ # (2**1000).bit_length #=> 1001
237
+ # (2**1000+1).bit_length #=> 1001
238
+ #
239
+ # This method can be used to detect overflow in Array#pack as follows:
240
+ #
241
+ # if n.bit_length < 32
242
+ # [n].pack("l") # no overflow
243
+ # else
244
+ # raise "overflow"
245
+ # end
246
+ #
247
+ def bit_length: () -> Integer
248
+
249
+ # Returns the smallest number greater than or equal to `int` with a precision of
250
+ # `ndigits` decimal digits (default: 0).
251
+ #
252
+ # When the precision is negative, the returned value is an integer with at least
253
+ # `ndigits.abs` trailing zeros.
254
+ #
255
+ # Returns `self` when `ndigits` is zero or positive.
256
+ #
257
+ # 1.ceil #=> 1
258
+ # 1.ceil(2) #=> 1
259
+ # 18.ceil(-1) #=> 20
260
+ # (-18).ceil(-1) #=> -10
261
+ #
262
+ def ceil: () -> Integer
263
+ | (int digits) -> (Integer | Float)
264
+
265
+ # Returns a string containing the character represented by the `int`'s value
266
+ # according to `encoding`.
267
+ #
268
+ # 65.chr #=> "A"
269
+ # 230.chr #=> "\xE6"
270
+ # 255.chr(Encoding::UTF_8) #=> "\u00FF"
271
+ #
272
+ def chr: (?encoding) -> String
273
+
274
+ def clone: (?freeze: bool) -> self
275
+
276
+ # Returns an array with both a `numeric` and a `big` represented as Bignum
277
+ # objects.
278
+ #
279
+ # This is achieved by converting `numeric` to a Bignum.
280
+ #
281
+ # A TypeError is raised if the `numeric` is not a Fixnum or Bignum type.
282
+ #
283
+ # (0x3FFFFFFFFFFFFFFF+1).coerce(42) #=> [42, 4611686018427387904]
284
+ #
285
+ def coerce: (Numeric) -> [Numeric, Numeric]
286
+
287
+ def conj: () -> Integer
288
+
289
+ def conjugate: () -> Integer
290
+
291
+ # Returns 1.
292
+ #
293
+ def denominator: () -> Integer
294
+
295
+ # Returns the digits of `int`'s place-value representation with radix `base`
296
+ # (default: 10). The digits are returned as an array with the least significant
297
+ # digit as the first array element.
298
+ #
299
+ # `base` must be greater than or equal to 2.
300
+ #
301
+ # 12345.digits #=> [5, 4, 3, 2, 1]
302
+ # 12345.digits(7) #=> [4, 6, 6, 0, 5]
303
+ # 12345.digits(100) #=> [45, 23, 1]
304
+ #
305
+ # -12345.digits(7) #=> Math::DomainError
306
+ #
307
+ def digits: (?int base) -> ::Array[Integer]
308
+
309
+ # Performs integer division: returns the integer result of dividing `int` by
310
+ # `numeric`.
311
+ #
312
+ def div: (Numeric) -> Integer
313
+
314
+ # See Numeric#divmod.
315
+ #
316
+ def divmod: (Integer) -> [Integer, Integer]
317
+ | (Float) -> [Float, Float]
318
+ | (Numeric) -> [Numeric, Numeric]
319
+
320
+ # Iterates the given block, passing in decreasing values from `int` down to and
321
+ # including `limit`.
322
+ #
323
+ # If no block is given, an Enumerator is returned instead.
324
+ #
325
+ # 5.downto(1) { |n| print n, ".. " }
326
+ # puts "Liftoff!"
327
+ # #=> "5.. 4.. 3.. 2.. 1.. Liftoff!"
328
+ #
329
+ def downto: (Integer limit) { (Integer) -> void } -> Integer
330
+ | (Integer limit) -> ::Enumerator[Integer, self]
331
+
332
+ def dup: () -> self
333
+
334
+ def eql?: (untyped) -> bool
335
+
336
+ # Returns `true` if `int` is an even number.
337
+ #
338
+ def even?: () -> bool
339
+
340
+ # Returns the floating point result of dividing `int` by `numeric`.
341
+ #
342
+ # 654321.fdiv(13731) #=> 47.652829364212366
343
+ # 654321.fdiv(13731.24) #=> 47.65199646936475
344
+ # -654321.fdiv(13731) #=> -47.652829364212366
345
+ #
346
+ def fdiv: (Numeric) -> Float
347
+
348
+ def finite?: () -> bool
349
+
350
+ # Returns the largest number less than or equal to `int` with a precision of
351
+ # `ndigits` decimal digits (default: 0).
352
+ #
353
+ # When the precision is negative, the returned value is an integer with at least
354
+ # `ndigits.abs` trailing zeros.
355
+ #
356
+ # Returns `self` when `ndigits` is zero or positive.
357
+ #
358
+ # 1.floor #=> 1
359
+ # 1.floor(2) #=> 1
360
+ # 18.floor(-1) #=> 10
361
+ # (-18).floor(-1) #=> -20
362
+ #
363
+ def floor: () -> Integer
364
+ | (int digits) -> (Integer | Float)
365
+
366
+ # Returns the greatest common divisor of the two integers. The result is always
367
+ # positive. 0.gcd(x) and x.gcd(0) return x.abs.
368
+ #
369
+ # 36.gcd(60) #=> 12
370
+ # 2.gcd(2) #=> 2
371
+ # 3.gcd(-7) #=> 1
372
+ # ((1<<31)-1).gcd((1<<61)-1) #=> 1
373
+ #
374
+ def gcd: (Integer) -> Integer
375
+
376
+ # Returns an array with the greatest common divisor and the least common
377
+ # multiple of the two integers, [gcd, lcm].
378
+ #
379
+ # 36.gcdlcm(60) #=> [12, 180]
380
+ # 2.gcdlcm(2) #=> [2, 2]
381
+ # 3.gcdlcm(-7) #=> [1, 21]
382
+ # ((1<<31)-1).gcdlcm((1<<61)-1) #=> [1, 4951760154835678088235319297]
383
+ #
384
+ def gcdlcm: (Integer) -> [ Integer, Integer ]
385
+
386
+ def i: () -> Complex
387
+
388
+ def imag: () -> Integer
389
+
390
+ def imaginary: () -> Integer
391
+
392
+ def infinite?: () -> Integer?
393
+
394
+ alias inspect to_s
395
+
396
+ # Since `int` is already an Integer, this always returns `true`.
397
+ #
398
+ def integer?: () -> true
399
+
400
+ # Returns the least common multiple of the two integers. The result is always
401
+ # positive. 0.lcm(x) and x.lcm(0) return zero.
402
+ #
403
+ # 36.lcm(60) #=> 180
404
+ # 2.lcm(2) #=> 2
405
+ # 3.lcm(-7) #=> 21
406
+ # ((1<<31)-1).lcm((1<<61)-1) #=> 4951760154835678088235319297
407
+ #
408
+ def lcm: (Integer) -> Integer
409
+
410
+ # Returns the absolute value of `int`.
411
+ #
412
+ # (-12345).abs #=> 12345
413
+ # -12345.abs #=> 12345
414
+ # 12345.abs #=> 12345
415
+ #
416
+ # Integer#magnitude is an alias for Integer#abs.
417
+ #
418
+ def magnitude: () -> Integer
419
+
420
+ # Returns `int` modulo `other`.
421
+ #
422
+ # See Numeric#divmod for more information.
423
+ #
424
+ alias modulo `%`
425
+
426
+ def negative?: () -> bool
427
+
428
+ # Returns the successor of `int`, i.e. the Integer equal to `int+1`.
429
+ #
430
+ # 1.next #=> 2
431
+ # (-1).next #=> 0
432
+ # 1.succ #=> 2
433
+ # (-1).succ #=> 0
434
+ #
435
+ def next: () -> Integer
436
+
437
+ # Returns `true` if no bits of `int & mask` are 1.
438
+ #
439
+ def nobits?: (int mask) -> bool
440
+
441
+ def nonzero?: () -> self?
442
+
443
+ # Returns self.
444
+ #
445
+ def numerator: () -> Integer
446
+
447
+ # Returns `true` if `int` is an odd number.
448
+ #
449
+ def odd?: () -> bool
450
+
451
+ # Returns the `int` itself.
452
+ #
453
+ # 97.ord #=> 97
454
+ #
455
+ # This method is intended for compatibility to character literals in Ruby 1.9.
456
+ #
457
+ # For example, `?a.ord` returns 97 both in 1.8 and 1.9.
458
+ #
459
+ def ord: () -> Integer
460
+
461
+ alias phase angle
462
+
463
+ def polar: () -> [ Integer, Integer | Float ]
464
+
465
+ def positive?: () -> bool
466
+
467
+ # Returns (modular) exponentiation as:
468
+ #
469
+ # a.pow(b) #=> same as a**b
470
+ # a.pow(b, m) #=> same as (a**b) % m, but avoids huge temporary values
471
+ #
472
+ def pow: (Integer other, ?Integer modulo) -> Integer
473
+ | (Float) -> Float
474
+ | (Rational) -> Rational
475
+ | (Complex) -> Complex
476
+
477
+ # Returns the predecessor of `int`, i.e. the Integer equal to `int-1`.
478
+ #
479
+ # 1.pred #=> 0
480
+ # (-1).pred #=> -2
481
+ #
482
+ def pred: () -> Integer
483
+
484
+ def quo: (Integer) -> Rational
485
+ | (Float) -> Float
486
+ | (Rational) -> Rational
487
+ | (Complex) -> Complex
488
+ | (Numeric) -> Numeric
489
+
490
+ # Returns the value as a rational. The optional argument `eps` is always
491
+ # ignored.
492
+ #
493
+ def rationalize: (?Numeric eps) -> Rational
494
+
495
+ def real: () -> self
496
+
497
+ def real?: () -> true
498
+
499
+ def rect: () -> [ Integer, Numeric ]
500
+
501
+ alias rectangular rect
502
+
503
+ # Returns the remainder after dividing `int` by `numeric`.
504
+ #
505
+ # `x.remainder(y)` means `x-y*(x/y).truncate`.
506
+ #
507
+ # 5.remainder(3) #=> 2
508
+ # -5.remainder(3) #=> -2
509
+ # 5.remainder(-3) #=> 2
510
+ # -5.remainder(-3) #=> -2
511
+ # 5.remainder(1.5) #=> 0.5
512
+ #
513
+ # See Numeric#divmod.
514
+ #
515
+ def remainder: (Integer) -> Integer
516
+ | (Float) -> Float
517
+ | (Rational) -> Rational
518
+ | (Numeric) -> Numeric
519
+
520
+ # Returns `int` rounded to the nearest value with a precision of `ndigits`
521
+ # decimal digits (default: 0).
522
+ #
523
+ # When the precision is negative, the returned value is an integer with at least
524
+ # `ndigits.abs` trailing zeros.
525
+ #
526
+ # Returns `self` when `ndigits` is zero or positive.
527
+ #
528
+ # 1.round #=> 1
529
+ # 1.round(2) #=> 1
530
+ # 15.round(-1) #=> 20
531
+ # (-15).round(-1) #=> -20
532
+ #
533
+ # The optional `half` keyword argument is available similar to Float#round.
534
+ #
535
+ # 25.round(-1, half: :up) #=> 30
536
+ # 25.round(-1, half: :down) #=> 20
537
+ # 25.round(-1, half: :even) #=> 20
538
+ # 35.round(-1, half: :up) #=> 40
539
+ # 35.round(-1, half: :down) #=> 30
540
+ # 35.round(-1, half: :even) #=> 40
541
+ # (-25).round(-1, half: :up) #=> -30
542
+ # (-25).round(-1, half: :down) #=> -20
543
+ # (-25).round(-1, half: :even) #=> -20
544
+ #
545
+ def round: (?half: :up | :down | :even) -> Integer
546
+ | (int digits, ?half: :up | :down | :even) -> (Integer | Float)
547
+
548
+ # Returns the number of bytes in the machine representation of `int` (machine
549
+ # dependent).
550
+ #
551
+ # 1.size #=> 8
552
+ # -1.size #=> 8
553
+ # 2147483647.size #=> 8
554
+ # (256**10 - 1).size #=> 10
555
+ # (256**20 - 1).size #=> 20
556
+ # (256**40 - 1).size #=> 40
557
+ #
558
+ def size: () -> Integer
559
+
560
+ def step: () { (Integer) -> void } -> void
561
+ | (Numeric limit, ?Integer step) { (Integer) -> void } -> void
562
+ | (Numeric limit, ?Numeric step) { (Numeric) -> void } -> void
563
+ | (to: Numeric, ?by: Integer) { (Integer) -> void } -> void
564
+ | (?to: Numeric, by: Numeric) { (Numeric) -> void } -> void
565
+ | () -> Enumerator[Integer, bot]
566
+ | (Numeric limit, ?Integer step) -> Enumerator[Integer, void]
567
+ | (Numeric limit, ?Numeric step) -> Enumerator[Numeric, void]
568
+ | (to: Numeric, ?by: Integer) -> Enumerator[Integer, void]
569
+ | (?to: Numeric, by: Numeric) -> Enumerator[Numeric, void]
570
+
571
+ # Returns the successor of `int`, i.e. the Integer equal to `int+1`.
572
+ #
573
+ # 1.next #=> 2
574
+ # (-1).next #=> 0
575
+ # 1.succ #=> 2
576
+ # (-1).succ #=> 0
577
+ #
578
+ def succ: () -> Integer
579
+
580
+ # Iterates the given block `int` times, passing in values from zero to `int -
581
+ # 1`.
582
+ #
583
+ # If no block is given, an Enumerator is returned instead.
584
+ #
585
+ # 5.times {|i| print i, " " } #=> 0 1 2 3 4
586
+ #
587
+ def times: () { (Integer) -> void } -> self
588
+ | () -> ::Enumerator[Integer, self]
589
+
590
+ def to_c: () -> Complex
591
+
592
+ # Converts `int` to a Float. If `int` doesn't fit in a Float, the result is
593
+ # infinity.
594
+ #
595
+ def to_f: () -> Float
596
+
597
+ # Since `int` is already an Integer, returns `self`.
598
+ #
599
+ # #to_int is an alias for #to_i.
600
+ #
601
+ def to_i: () -> Integer
602
+
603
+ # Since `int` is already an Integer, returns `self`.
604
+ #
605
+ # #to_int is an alias for #to_i.
606
+ #
607
+ alias to_int to_i
608
+
609
+ # Returns the value as a rational.
610
+ #
611
+ # 1.to_r #=> (1/1)
612
+ # (1<<64).to_r #=> (18446744073709551616/1)
613
+ #
614
+ def to_r: () -> Rational
615
+
616
+ # Returns a string containing the place-value representation of `int` with radix
617
+ # `base` (between 2 and 36).
618
+ #
619
+ # 12345.to_s #=> "12345"
620
+ # 12345.to_s(2) #=> "11000000111001"
621
+ # 12345.to_s(8) #=> "30071"
622
+ # 12345.to_s(10) #=> "12345"
623
+ # 12345.to_s(16) #=> "3039"
624
+ # 12345.to_s(36) #=> "9ix"
625
+ # 78546939656932.to_s(36) #=> "rubyrules"
626
+ #
627
+ def to_s: () -> String
628
+ | (2) -> String
629
+ | (3) -> String
630
+ | (4) -> String
631
+ | (5) -> String
632
+ | (6) -> String
633
+ | (7) -> String
634
+ | (8) -> String
635
+ | (9) -> String
636
+ | (10) -> String
637
+ | (11) -> String
638
+ | (12) -> String
639
+ | (13) -> String
640
+ | (14) -> String
641
+ | (15) -> String
642
+ | (16) -> String
643
+ | (17) -> String
644
+ | (18) -> String
645
+ | (19) -> String
646
+ | (20) -> String
647
+ | (21) -> String
648
+ | (22) -> String
649
+ | (23) -> String
650
+ | (24) -> String
651
+ | (25) -> String
652
+ | (26) -> String
653
+ | (27) -> String
654
+ | (28) -> String
655
+ | (29) -> String
656
+ | (30) -> String
657
+ | (31) -> String
658
+ | (32) -> String
659
+ | (33) -> String
660
+ | (34) -> String
661
+ | (35) -> String
662
+ | (36) -> String
663
+ | (int base) -> String
664
+
665
+ # Returns `int` truncated (toward zero) to a precision of `ndigits` decimal
666
+ # digits (default: 0).
667
+ #
668
+ # When the precision is negative, the returned value is an integer with at least
669
+ # `ndigits.abs` trailing zeros.
670
+ #
671
+ # Returns `self` when `ndigits` is zero or positive.
672
+ #
673
+ # 1.truncate #=> 1
674
+ # 1.truncate(2) #=> 1
675
+ # 18.truncate(-1) #=> 10
676
+ # (-18).truncate(-1) #=> -10
677
+ #
678
+ def truncate: () -> Integer
679
+ | (int ndigits) -> Integer
680
+
681
+ # Iterates the given block, passing in integer values from `int` up to and
682
+ # including `limit`.
683
+ #
684
+ # If no block is given, an Enumerator is returned instead.
685
+ #
686
+ # 5.upto(10) {|i| print i, " " } #=> 5 6 7 8 9 10
687
+ #
688
+ def upto: (Integer limit) { (Integer) -> void } -> Integer
689
+ | (Integer limit) -> ::Enumerator[Integer, self]
690
+
691
+ def zero?: () -> bool
692
+
693
+ # Bitwise OR.
694
+ #
695
+ def |: (Integer) -> Integer
696
+
697
+ # One's complement: returns a number where each bit is flipped.
698
+ #
699
+ # Inverts the bits in an Integer. As integers are conceptually of infinite
700
+ # length, the result acts as if it had an infinite number of one bits to the
701
+ # left. In hex representations, this is displayed as two periods to the left of
702
+ # the digits.
703
+ #
704
+ # sprintf("%X", ~0x1122334455) #=> "..FEEDDCCBBAA"
705
+ #
706
+ def ~: () -> Integer
707
+ end