steep 0.16.0 → 0.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +0 -3
- data/CHANGELOG.md +6 -0
- data/Rakefile +0 -13
- data/bin/setup +0 -2
- data/bin/smoke_runner.rb +0 -1
- data/exe/steep +0 -1
- data/lib/steep/project/file.rb +1 -1
- data/lib/steep/project/hover_content.rb +1 -1
- data/lib/steep/server/code_worker.rb +1 -1
- data/lib/steep/server/signature_worker.rb +4 -4
- data/lib/steep/type_construction.rb +10 -16
- data/lib/steep/type_inference/constant_env.rb +2 -10
- data/lib/steep/type_inference/context.rb +1 -0
- data/lib/steep/version.rb +1 -1
- data/steep.gemspec +1 -5
- metadata +17 -135
- data/exe/rbs +0 -3
- data/vendor/ruby-signature/.github/workflows/ruby.yml +0 -27
- data/vendor/ruby-signature/.gitignore +0 -12
- data/vendor/ruby-signature/.rubocop.yml +0 -15
- data/vendor/ruby-signature/BSDL +0 -22
- data/vendor/ruby-signature/COPYING +0 -56
- data/vendor/ruby-signature/Gemfile +0 -6
- data/vendor/ruby-signature/README.md +0 -93
- data/vendor/ruby-signature/Rakefile +0 -142
- data/vendor/ruby-signature/bin/annotate-with-rdoc +0 -157
- data/vendor/ruby-signature/bin/console +0 -14
- data/vendor/ruby-signature/bin/query-rdoc +0 -103
- data/vendor/ruby-signature/bin/setup +0 -10
- data/vendor/ruby-signature/bin/sort +0 -89
- data/vendor/ruby-signature/bin/test_runner.rb +0 -16
- data/vendor/ruby-signature/docs/CONTRIBUTING.md +0 -97
- data/vendor/ruby-signature/docs/sigs.md +0 -148
- data/vendor/ruby-signature/docs/stdlib.md +0 -152
- data/vendor/ruby-signature/docs/syntax.md +0 -528
- data/vendor/ruby-signature/exe/rbs +0 -7
- data/vendor/ruby-signature/lib/rbs.rb +0 -64
- data/vendor/ruby-signature/lib/rbs/ast/annotation.rb +0 -27
- data/vendor/ruby-signature/lib/rbs/ast/comment.rb +0 -27
- data/vendor/ruby-signature/lib/rbs/ast/declarations.rb +0 -395
- data/vendor/ruby-signature/lib/rbs/ast/members.rb +0 -362
- data/vendor/ruby-signature/lib/rbs/buffer.rb +0 -50
- data/vendor/ruby-signature/lib/rbs/builtin_names.rb +0 -55
- data/vendor/ruby-signature/lib/rbs/cli.rb +0 -558
- data/vendor/ruby-signature/lib/rbs/constant.rb +0 -26
- data/vendor/ruby-signature/lib/rbs/constant_table.rb +0 -150
- data/vendor/ruby-signature/lib/rbs/definition.rb +0 -170
- data/vendor/ruby-signature/lib/rbs/definition_builder.rb +0 -919
- data/vendor/ruby-signature/lib/rbs/environment.rb +0 -281
- data/vendor/ruby-signature/lib/rbs/environment_loader.rb +0 -136
- data/vendor/ruby-signature/lib/rbs/environment_walker.rb +0 -124
- data/vendor/ruby-signature/lib/rbs/errors.rb +0 -187
- data/vendor/ruby-signature/lib/rbs/location.rb +0 -102
- data/vendor/ruby-signature/lib/rbs/method_type.rb +0 -123
- data/vendor/ruby-signature/lib/rbs/namespace.rb +0 -91
- data/vendor/ruby-signature/lib/rbs/parser.y +0 -1344
- data/vendor/ruby-signature/lib/rbs/prototype/rb.rb +0 -553
- data/vendor/ruby-signature/lib/rbs/prototype/rbi.rb +0 -587
- data/vendor/ruby-signature/lib/rbs/prototype/runtime.rb +0 -381
- data/vendor/ruby-signature/lib/rbs/substitution.rb +0 -46
- data/vendor/ruby-signature/lib/rbs/test.rb +0 -26
- data/vendor/ruby-signature/lib/rbs/test/errors.rb +0 -61
- data/vendor/ruby-signature/lib/rbs/test/hook.rb +0 -294
- data/vendor/ruby-signature/lib/rbs/test/setup.rb +0 -58
- data/vendor/ruby-signature/lib/rbs/test/spy.rb +0 -325
- data/vendor/ruby-signature/lib/rbs/test/test_helper.rb +0 -183
- data/vendor/ruby-signature/lib/rbs/test/type_check.rb +0 -254
- data/vendor/ruby-signature/lib/rbs/type_name.rb +0 -70
- data/vendor/ruby-signature/lib/rbs/types.rb +0 -936
- data/vendor/ruby-signature/lib/rbs/variance_calculator.rb +0 -138
- data/vendor/ruby-signature/lib/rbs/vendorer.rb +0 -47
- data/vendor/ruby-signature/lib/rbs/version.rb +0 -3
- data/vendor/ruby-signature/lib/rbs/writer.rb +0 -269
- data/vendor/ruby-signature/lib/ruby/signature.rb +0 -7
- data/vendor/ruby-signature/rbs.gemspec +0 -46
- data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +0 -60
- data/vendor/ruby-signature/stdlib/base64/base64.rbs +0 -71
- data/vendor/ruby-signature/stdlib/benchmark/benchmark.rbs +0 -372
- data/vendor/ruby-signature/stdlib/builtin/array.rbs +0 -1997
- data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +0 -280
- data/vendor/ruby-signature/stdlib/builtin/binding.rbs +0 -177
- data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +0 -45
- data/vendor/ruby-signature/stdlib/builtin/class.rbs +0 -145
- data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +0 -116
- data/vendor/ruby-signature/stdlib/builtin/complex.rbs +0 -400
- data/vendor/ruby-signature/stdlib/builtin/constants.rbs +0 -37
- data/vendor/ruby-signature/stdlib/builtin/data.rbs +0 -5
- data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +0 -2
- data/vendor/ruby-signature/stdlib/builtin/dir.rbs +0 -413
- data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +0 -607
- data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +0 -404
- data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +0 -260
- data/vendor/ruby-signature/stdlib/builtin/errno.rbs +0 -781
- data/vendor/ruby-signature/stdlib/builtin/errors.rbs +0 -582
- data/vendor/ruby-signature/stdlib/builtin/exception.rbs +0 -194
- data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +0 -40
- data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +0 -68
- data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +0 -12
- data/vendor/ruby-signature/stdlib/builtin/file.rbs +0 -1076
- data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +0 -59
- data/vendor/ruby-signature/stdlib/builtin/float.rbs +0 -696
- data/vendor/ruby-signature/stdlib/builtin/gc.rbs +0 -243
- data/vendor/ruby-signature/stdlib/builtin/hash.rbs +0 -1029
- data/vendor/ruby-signature/stdlib/builtin/integer.rbs +0 -707
- data/vendor/ruby-signature/stdlib/builtin/io.rbs +0 -683
- data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +0 -576
- data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +0 -161
- data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +0 -271
- data/vendor/ruby-signature/stdlib/builtin/math.rbs +0 -369
- data/vendor/ruby-signature/stdlib/builtin/method.rbs +0 -185
- data/vendor/ruby-signature/stdlib/builtin/module.rbs +0 -1104
- data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +0 -82
- data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +0 -409
- data/vendor/ruby-signature/stdlib/builtin/object.rbs +0 -824
- data/vendor/ruby-signature/stdlib/builtin/proc.rbs +0 -429
- data/vendor/ruby-signature/stdlib/builtin/process.rbs +0 -1227
- data/vendor/ruby-signature/stdlib/builtin/random.rbs +0 -267
- data/vendor/ruby-signature/stdlib/builtin/range.rbs +0 -226
- data/vendor/ruby-signature/stdlib/builtin/rational.rbs +0 -424
- data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +0 -57
- data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +0 -1083
- data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +0 -14
- data/vendor/ruby-signature/stdlib/builtin/signal.rbs +0 -55
- data/vendor/ruby-signature/stdlib/builtin/string.rbs +0 -1901
- data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +0 -284
- data/vendor/ruby-signature/stdlib/builtin/struct.rbs +0 -40
- data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +0 -228
- data/vendor/ruby-signature/stdlib/builtin/thread.rbs +0 -1108
- data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +0 -23
- data/vendor/ruby-signature/stdlib/builtin/time.rbs +0 -1047
- data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +0 -290
- data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +0 -46
- data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +0 -153
- data/vendor/ruby-signature/stdlib/builtin/warning.rbs +0 -17
- data/vendor/ruby-signature/stdlib/coverage/coverage.rbs +0 -62
- data/vendor/ruby-signature/stdlib/csv/csv.rbs +0 -773
- data/vendor/ruby-signature/stdlib/erb/erb.rbs +0 -392
- data/vendor/ruby-signature/stdlib/find/find.rbs +0 -40
- data/vendor/ruby-signature/stdlib/ipaddr/ipaddr.rbs +0 -247
- data/vendor/ruby-signature/stdlib/json/json.rbs +0 -335
- data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +0 -1093
- data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +0 -23
- data/vendor/ruby-signature/stdlib/prime/prime.rbs +0 -188
- data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +0 -9
- data/vendor/ruby-signature/stdlib/set/set.rbs +0 -301
- data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +0 -53
@@ -1,707 +0,0 @@
|
|
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) -> 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
|