rbs 2.0.0 → 2.2.2
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.
- checksums.yaml +4 -4
- data/.github/workflows/comments.yml +34 -0
- data/.github/workflows/ruby.yml +5 -0
- data/CHANGELOG.md +82 -0
- data/README.md +6 -1
- data/Rakefile +56 -21
- data/core/array.rbs +2866 -1086
- data/core/basic_object.rbs +150 -30
- data/core/binding.rbs +33 -0
- data/core/builtin.rbs +4 -4
- data/core/class.rbs +43 -5
- data/core/comparable.rbs +57 -0
- data/core/complex.rbs +170 -4
- data/core/constants.rbs +51 -0
- data/core/deprecated.rbs +7 -0
- data/core/dir.rbs +305 -20
- data/core/encoding.rbs +1214 -77
- data/core/enumerable.rbs +2173 -234
- data/core/enumerator.rbs +448 -182
- data/core/env.rbs +448 -1
- data/core/errno.rbs +1 -10
- data/core/errors.rbs +152 -2
- data/core/exception.rbs +201 -127
- data/core/false_class.rbs +27 -0
- data/core/fiber.rbs +118 -37
- data/core/fiber_error.rbs +8 -9
- data/core/file.rbs +1060 -142
- data/core/file_test.rbs +287 -32
- data/core/float.rbs +776 -300
- data/core/gc.rbs +185 -34
- data/core/global_variables.rbs +5 -1
- data/core/hash.rbs +1582 -649
- data/core/integer.rbs +974 -204
- data/core/io/buffer.rbs +710 -0
- data/core/io/wait.rbs +29 -8
- data/core/io.rbs +2438 -417
- data/core/kernel.rbs +2319 -318
- data/core/marshal.rbs +37 -2
- data/core/match_data.rbs +123 -6
- data/core/math.rbs +126 -6
- data/core/method.rbs +226 -102
- data/core/module.rbs +421 -45
- data/core/nil_class.rbs +64 -0
- data/core/numeric.rbs +620 -142
- data/core/object.rbs +453 -81
- data/core/object_space.rbs +92 -2
- data/core/proc.rbs +482 -285
- data/core/process.rbs +443 -34
- data/core/ractor.rbs +232 -9
- data/core/random.rbs +151 -52
- data/core/range.rbs +885 -160
- data/core/rational.rbs +122 -6
- data/core/rb_config.rbs +14 -4
- data/core/refinement.rbs +44 -0
- data/core/regexp.rbs +156 -14
- data/core/ruby_vm.rbs +42 -3
- data/core/signal.rbs +78 -39
- data/core/string.rbs +2123 -567
- data/core/string_io.rbs +204 -0
- data/core/struct.rbs +283 -28
- data/core/symbol.rbs +304 -30
- data/core/thread.rbs +1288 -688
- data/core/thread_group.rbs +66 -10
- data/core/time.rbs +643 -217
- data/core/trace_point.rbs +100 -12
- data/core/true_class.rbs +24 -0
- data/core/unbound_method.rbs +73 -7
- data/core/warning.rbs +37 -12
- data/docs/CONTRIBUTING.md +40 -34
- data/docs/stdlib.md +3 -102
- data/docs/syntax.md +54 -11
- data/ext/rbs_extension/extconf.rb +1 -0
- data/ext/rbs_extension/lexer.h +5 -0
- data/ext/rbs_extension/lexstate.c +6 -0
- data/ext/rbs_extension/parser.c +85 -10
- data/ext/rbs_extension/ruby_objs.c +4 -2
- data/ext/rbs_extension/ruby_objs.h +2 -2
- data/goodcheck.yml +0 -11
- data/lib/rbs/annotate/annotations.rb +197 -0
- data/lib/rbs/annotate/formatter.rb +80 -0
- data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
- data/lib/rbs/annotate/rdoc_source.rb +120 -0
- data/lib/rbs/annotate.rb +6 -0
- data/lib/rbs/ast/members.rb +21 -13
- data/lib/rbs/buffer.rb +17 -11
- data/lib/rbs/cli.rb +48 -1
- data/lib/rbs/definition_builder/method_builder.rb +28 -16
- data/lib/rbs/definition_builder.rb +6 -2
- data/lib/rbs/environment.rb +8 -4
- data/lib/rbs/location_aux.rb +12 -0
- data/lib/rbs/namespace.rb +1 -1
- data/lib/rbs/prototype/rb.rb +12 -0
- data/lib/rbs/type_alias_regularity.rb +6 -4
- data/lib/rbs/type_name.rb +1 -1
- data/lib/rbs/types.rb +1 -1
- data/lib/rbs/validator.rb +6 -0
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +54 -4
- data/lib/rbs.rb +0 -2
- data/schema/typeParam.json +3 -3
- data/sig/annotate/annotations.rbs +102 -0
- data/sig/annotate/formatter.rbs +24 -0
- data/sig/annotate/rdoc_annotater.rbs +82 -0
- data/sig/annotate/rdoc_source.rbs +30 -0
- data/sig/buffer.rbs +6 -2
- data/sig/cli.rbs +2 -0
- data/sig/collection/{collections.rbs → sources.rbs} +0 -0
- data/sig/location.rbs +6 -0
- data/sig/members.rbs +24 -18
- data/sig/method_builder.rbs +5 -4
- data/sig/method_types.rbs +5 -1
- data/sig/polyfill.rbs +78 -0
- data/sig/validator.rbs +3 -1
- data/sig/writer.rbs +79 -2
- data/stdlib/abbrev/0/abbrev.rbs +6 -0
- data/stdlib/abbrev/0/array.rbs +26 -0
- data/stdlib/base64/0/base64.rbs +31 -0
- data/stdlib/benchmark/0/benchmark.rbs +74 -3
- data/stdlib/bigdecimal/0/big_decimal.rbs +614 -165
- data/stdlib/bigdecimal-math/0/big_math.rbs +41 -64
- data/stdlib/cgi/0/core.rbs +649 -21
- data/stdlib/coverage/0/coverage.rbs +164 -2
- data/stdlib/csv/0/csv.rbs +2862 -398
- data/stdlib/date/0/date.rbs +483 -25
- data/stdlib/date/0/date_time.rbs +187 -12
- data/stdlib/dbm/0/dbm.rbs +152 -17
- data/stdlib/digest/0/digest.rbs +146 -0
- data/stdlib/erb/0/erb.rbs +65 -245
- data/stdlib/fiber/0/fiber.rbs +73 -91
- data/stdlib/fileutils/0/fileutils.rbs +301 -1
- data/stdlib/find/0/find.rbs +9 -0
- data/stdlib/forwardable/0/forwardable.rbs +65 -1
- data/stdlib/io-console/0/io-console.rbs +227 -15
- data/stdlib/ipaddr/0/ipaddr.rbs +161 -0
- data/stdlib/json/0/json.rbs +1147 -145
- data/stdlib/logger/0/formatter.rbs +24 -0
- data/stdlib/logger/0/log_device.rbs +64 -0
- data/stdlib/logger/0/logger.rbs +165 -13
- data/stdlib/logger/0/period.rbs +10 -0
- data/stdlib/logger/0/severity.rbs +26 -0
- data/stdlib/monitor/0/monitor.rbs +163 -0
- data/stdlib/mutex_m/0/mutex_m.rbs +35 -6
- data/stdlib/net-http/0/manifest.yaml +1 -0
- data/stdlib/net-http/0/net-http.rbs +1513 -683
- data/stdlib/nkf/0/nkf.rbs +372 -0
- data/stdlib/objspace/0/objspace.rbs +149 -90
- data/stdlib/openssl/0/openssl.rbs +8108 -71
- data/stdlib/optparse/0/optparse.rbs +487 -19
- data/stdlib/pathname/0/pathname.rbs +425 -124
- data/stdlib/prettyprint/0/prettyprint.rbs +120 -99
- data/stdlib/prime/0/integer-extension.rbs +20 -2
- data/stdlib/prime/0/prime.rbs +88 -21
- data/stdlib/pstore/0/pstore.rbs +102 -0
- data/stdlib/pty/0/pty.rbs +64 -14
- data/stdlib/resolv/0/resolv.rbs +420 -31
- data/stdlib/rubygems/0/basic_specification.rbs +4 -1
- data/stdlib/rubygems/0/config_file.rbs +33 -1
- data/stdlib/rubygems/0/dependency_installer.rbs +4 -3
- data/stdlib/rubygems/0/installer.rbs +13 -1
- data/stdlib/rubygems/0/path_support.rbs +4 -1
- data/stdlib/rubygems/0/platform.rbs +5 -1
- data/stdlib/rubygems/0/request_set.rbs +44 -2
- data/stdlib/rubygems/0/requirement.rbs +65 -2
- data/stdlib/rubygems/0/rubygems.rbs +407 -0
- data/stdlib/rubygems/0/source_list.rbs +13 -0
- data/stdlib/rubygems/0/specification.rbs +21 -1
- data/stdlib/rubygems/0/stream_ui.rbs +3 -1
- data/stdlib/rubygems/0/uninstaller.rbs +8 -1
- data/stdlib/rubygems/0/version.rbs +60 -157
- data/stdlib/securerandom/0/securerandom.rbs +44 -0
- data/stdlib/set/0/set.rbs +423 -109
- data/stdlib/shellwords/0/shellwords.rbs +55 -77
- data/stdlib/singleton/0/singleton.rbs +20 -0
- data/stdlib/socket/0/addrinfo.rbs +210 -9
- data/stdlib/socket/0/basic_socket.rbs +103 -11
- data/stdlib/socket/0/ip_socket.rbs +31 -9
- data/stdlib/socket/0/socket.rbs +586 -38
- data/stdlib/socket/0/tcp_server.rbs +22 -2
- data/stdlib/socket/0/tcp_socket.rbs +12 -1
- data/stdlib/socket/0/udp_socket.rbs +25 -2
- data/stdlib/socket/0/unix_server.rbs +22 -2
- data/stdlib/socket/0/unix_socket.rbs +45 -5
- data/stdlib/strscan/0/string_scanner.rbs +210 -9
- data/stdlib/tempfile/0/tempfile.rbs +58 -10
- data/stdlib/time/0/time.rbs +208 -116
- data/stdlib/timeout/0/timeout.rbs +10 -0
- data/stdlib/tmpdir/0/tmpdir.rbs +13 -4
- data/stdlib/tsort/0/cyclic.rbs +1 -0
- data/stdlib/tsort/0/interfaces.rbs +1 -0
- data/stdlib/tsort/0/tsort.rbs +42 -0
- data/stdlib/uri/0/common.rbs +57 -8
- data/stdlib/uri/0/file.rbs +55 -109
- data/stdlib/uri/0/ftp.rbs +6 -3
- data/stdlib/uri/0/generic.rbs +558 -329
- data/stdlib/uri/0/http.rbs +60 -114
- data/stdlib/uri/0/https.rbs +8 -102
- data/stdlib/uri/0/ldap.rbs +143 -137
- data/stdlib/uri/0/ldaps.rbs +8 -102
- data/stdlib/uri/0/mailto.rbs +3 -0
- data/stdlib/uri/0/rfc2396_parser.rbs +66 -26
- data/stdlib/uri/0/ws.rbs +6 -3
- data/stdlib/uri/0/wss.rbs +5 -3
- data/stdlib/yaml/0/dbm.rbs +151 -87
- data/stdlib/yaml/0/store.rbs +6 -0
- data/stdlib/zlib/0/zlib.rbs +90 -31
- metadata +18 -6
- data/lib/rbs/location.rb +0 -221
- data/sig/char_scanner.rbs +0 -9
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# <!-- rdoc-file=ext/strscan/strscan.c -->
|
|
1
2
|
# StringScanner provides for lexical scanning operations on a String. Here is
|
|
2
3
|
# an example of its usage:
|
|
3
4
|
#
|
|
@@ -66,7 +67,7 @@
|
|
|
66
67
|
#
|
|
67
68
|
# ### Finding Where we Are
|
|
68
69
|
#
|
|
69
|
-
# * #beginning_of_line? (
|
|
70
|
+
# * #beginning_of_line? (`#bol?`)
|
|
70
71
|
# * #eos?
|
|
71
72
|
# * #rest?
|
|
72
73
|
# * #rest_size
|
|
@@ -85,16 +86,14 @@
|
|
|
85
86
|
# * #matched
|
|
86
87
|
# * #matched?
|
|
87
88
|
# * #matched_size
|
|
88
|
-
#
|
|
89
|
-
#
|
|
90
|
-
# :
|
|
89
|
+
# * `#[]`
|
|
91
90
|
# * #pre_match
|
|
92
91
|
# * #post_match
|
|
93
92
|
#
|
|
94
93
|
#
|
|
95
94
|
# ### Miscellaneous
|
|
96
95
|
#
|
|
97
|
-
# *
|
|
96
|
+
# * `<<`
|
|
98
97
|
# * #concat
|
|
99
98
|
# * #string
|
|
100
99
|
# * #string=
|
|
@@ -102,13 +101,19 @@
|
|
|
102
101
|
#
|
|
103
102
|
#
|
|
104
103
|
# There are aliases to several of the methods.
|
|
104
|
+
#
|
|
105
105
|
class StringScanner
|
|
106
|
+
# <!--
|
|
107
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
108
|
+
# - StringScanner.must_C_version
|
|
109
|
+
# -->
|
|
106
110
|
# This method is defined for backward compatibility.
|
|
107
111
|
#
|
|
108
112
|
def self.must_C_version: () -> self
|
|
109
113
|
|
|
110
114
|
public
|
|
111
115
|
|
|
116
|
+
# <!-- rdoc-file=ext/strscan/strscan.c -->
|
|
112
117
|
# Appends `str` to the string being scanned. This method does not affect scan
|
|
113
118
|
# pointer.
|
|
114
119
|
#
|
|
@@ -120,6 +125,10 @@ class StringScanner
|
|
|
120
125
|
#
|
|
121
126
|
def <<: (String) -> self
|
|
122
127
|
|
|
128
|
+
# <!--
|
|
129
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
130
|
+
# - [](n)
|
|
131
|
+
# -->
|
|
123
132
|
# Returns the n-th subgroup in the most recent match.
|
|
124
133
|
#
|
|
125
134
|
# s = StringScanner.new("Fri Dec 12 1975 14:39")
|
|
@@ -145,7 +154,12 @@ class StringScanner
|
|
|
145
154
|
#
|
|
146
155
|
def []: (Integer) -> String?
|
|
147
156
|
|
|
148
|
-
#
|
|
157
|
+
# <!--
|
|
158
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
159
|
+
# - beginning_of_line?()
|
|
160
|
+
# -->
|
|
161
|
+
# Returns `true` if and only if the scan pointer is at the beginning of the
|
|
162
|
+
# line.
|
|
149
163
|
#
|
|
150
164
|
# s = StringScanner.new("test\ntest\n")
|
|
151
165
|
# s.bol? # => true
|
|
@@ -160,6 +174,10 @@ class StringScanner
|
|
|
160
174
|
|
|
161
175
|
alias bol? beginning_of_line?
|
|
162
176
|
|
|
177
|
+
# <!--
|
|
178
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
179
|
+
# - captures
|
|
180
|
+
# -->
|
|
163
181
|
# Returns the subgroups in the most recent match (not including the full match).
|
|
164
182
|
# If nothing was priorly matched, it returns nil.
|
|
165
183
|
#
|
|
@@ -171,6 +189,10 @@ class StringScanner
|
|
|
171
189
|
#
|
|
172
190
|
def captures: () -> Array[String]?
|
|
173
191
|
|
|
192
|
+
# <!--
|
|
193
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
194
|
+
# - charpos()
|
|
195
|
+
# -->
|
|
174
196
|
# Returns the character position of the scan pointer. In the 'reset' position,
|
|
175
197
|
# this value is zero. In the 'terminated' position (i.e. the string is
|
|
176
198
|
# exhausted), this value is the size of the string.
|
|
@@ -185,6 +207,10 @@ class StringScanner
|
|
|
185
207
|
#
|
|
186
208
|
def charpos: () -> Integer
|
|
187
209
|
|
|
210
|
+
# <!--
|
|
211
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
212
|
+
# - check(pattern)
|
|
213
|
+
# -->
|
|
188
214
|
# This returns the value that #scan would return, without advancing the scan
|
|
189
215
|
# pointer. The match register is affected, though.
|
|
190
216
|
#
|
|
@@ -199,6 +225,10 @@ class StringScanner
|
|
|
199
225
|
#
|
|
200
226
|
def check: (Regexp) -> String?
|
|
201
227
|
|
|
228
|
+
# <!--
|
|
229
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
230
|
+
# - check_until(pattern)
|
|
231
|
+
# -->
|
|
202
232
|
# This returns the value that #scan_until would return, without advancing the
|
|
203
233
|
# scan pointer. The match register is affected, though.
|
|
204
234
|
#
|
|
@@ -211,16 +241,42 @@ class StringScanner
|
|
|
211
241
|
#
|
|
212
242
|
def check_until: (Regexp) -> String
|
|
213
243
|
|
|
244
|
+
# <!--
|
|
245
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
246
|
+
# - clear()
|
|
247
|
+
# -->
|
|
214
248
|
# Equivalent to #terminate. This method is obsolete; use #terminate instead.
|
|
215
249
|
#
|
|
216
250
|
def clear: () -> void
|
|
217
251
|
|
|
252
|
+
# <!--
|
|
253
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
254
|
+
# - concat(str)
|
|
255
|
+
# - <<(str)
|
|
256
|
+
# -->
|
|
257
|
+
# Appends `str` to the string being scanned. This method does not affect scan
|
|
258
|
+
# pointer.
|
|
259
|
+
#
|
|
260
|
+
# s = StringScanner.new("Fri Dec 12 1975 14:39")
|
|
261
|
+
# s.scan(/Fri /)
|
|
262
|
+
# s << " +1000 GMT"
|
|
263
|
+
# s.string # -> "Fri Dec 12 1975 14:39 +1000 GMT"
|
|
264
|
+
# s.scan(/Dec/) # -> "Dec"
|
|
265
|
+
#
|
|
218
266
|
alias concat <<
|
|
219
267
|
|
|
268
|
+
# <!--
|
|
269
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
270
|
+
# - empty?()
|
|
271
|
+
# -->
|
|
220
272
|
# Equivalent to #eos?. This method is obsolete, use #eos? instead.
|
|
221
273
|
#
|
|
222
274
|
def empty?: () -> bool
|
|
223
275
|
|
|
276
|
+
# <!--
|
|
277
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
278
|
+
# - eos?()
|
|
279
|
+
# -->
|
|
224
280
|
# Returns `true` if the scan pointer is at the end of the string.
|
|
225
281
|
#
|
|
226
282
|
# s = StringScanner.new('test string')
|
|
@@ -232,6 +288,10 @@ class StringScanner
|
|
|
232
288
|
#
|
|
233
289
|
def eos?: () -> bool
|
|
234
290
|
|
|
291
|
+
# <!--
|
|
292
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
293
|
+
# - exist?(pattern)
|
|
294
|
+
# -->
|
|
235
295
|
# Looks *ahead* to see if the `pattern` exists *anywhere* in the string, without
|
|
236
296
|
# advancing the scan pointer. This predicates whether a #scan_until will return
|
|
237
297
|
# a value.
|
|
@@ -244,6 +304,10 @@ class StringScanner
|
|
|
244
304
|
#
|
|
245
305
|
def exist?: (Regexp) -> Integer?
|
|
246
306
|
|
|
307
|
+
# <!--
|
|
308
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
309
|
+
# - scanner.fixed_anchor? -> true or false
|
|
310
|
+
# -->
|
|
247
311
|
# Whether `scanner` uses fixed anchor mode or not.
|
|
248
312
|
#
|
|
249
313
|
# If fixed anchor mode is used, `\A` always matches the beginning of the string.
|
|
@@ -251,6 +315,10 @@ class StringScanner
|
|
|
251
315
|
#
|
|
252
316
|
def fixed_anchor?: () -> bool
|
|
253
317
|
|
|
318
|
+
# <!--
|
|
319
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
320
|
+
# - get_byte()
|
|
321
|
+
# -->
|
|
254
322
|
# Scans one byte and returns it. This method is not multibyte character
|
|
255
323
|
# sensitive. See also: #getch.
|
|
256
324
|
#
|
|
@@ -266,10 +334,18 @@ class StringScanner
|
|
|
266
334
|
#
|
|
267
335
|
def get_byte: () -> String?
|
|
268
336
|
|
|
337
|
+
# <!--
|
|
338
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
339
|
+
# - getbyte()
|
|
340
|
+
# -->
|
|
269
341
|
# Equivalent to #get_byte. This method is obsolete; use #get_byte instead.
|
|
270
342
|
#
|
|
271
343
|
def getbyte: () -> String?
|
|
272
344
|
|
|
345
|
+
# <!--
|
|
346
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
347
|
+
# - getch()
|
|
348
|
+
# -->
|
|
273
349
|
# Scans one character and returns it. This method is multibyte character
|
|
274
350
|
# sensitive.
|
|
275
351
|
#
|
|
@@ -284,6 +360,10 @@ class StringScanner
|
|
|
284
360
|
#
|
|
285
361
|
def getch: () -> String?
|
|
286
362
|
|
|
363
|
+
# <!--
|
|
364
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
365
|
+
# - inspect()
|
|
366
|
+
# -->
|
|
287
367
|
# Returns a string that represents the StringScanner object, showing:
|
|
288
368
|
# * the current position
|
|
289
369
|
# * the size of the string
|
|
@@ -296,6 +376,10 @@ class StringScanner
|
|
|
296
376
|
#
|
|
297
377
|
def inspect: () -> String
|
|
298
378
|
|
|
379
|
+
# <!--
|
|
380
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
381
|
+
# - match?(pattern)
|
|
382
|
+
# -->
|
|
299
383
|
# Tests whether the given `pattern` is matched from the current scan pointer.
|
|
300
384
|
# Returns the length of the match, or `nil`. The scan pointer is not advanced.
|
|
301
385
|
#
|
|
@@ -307,6 +391,10 @@ class StringScanner
|
|
|
307
391
|
#
|
|
308
392
|
def match?: (Regexp) -> Integer?
|
|
309
393
|
|
|
394
|
+
# <!--
|
|
395
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
396
|
+
# - matched()
|
|
397
|
+
# -->
|
|
310
398
|
# Returns the last matched string.
|
|
311
399
|
#
|
|
312
400
|
# s = StringScanner.new('test string')
|
|
@@ -315,7 +403,11 @@ class StringScanner
|
|
|
315
403
|
#
|
|
316
404
|
def matched: () -> String?
|
|
317
405
|
|
|
318
|
-
#
|
|
406
|
+
# <!--
|
|
407
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
408
|
+
# - matched?()
|
|
409
|
+
# -->
|
|
410
|
+
# Returns `true` if and only if the last match was successful.
|
|
319
411
|
#
|
|
320
412
|
# s = StringScanner.new('test string')
|
|
321
413
|
# s.match?(/\w+/) # => 4
|
|
@@ -325,6 +417,10 @@ class StringScanner
|
|
|
325
417
|
#
|
|
326
418
|
def matched?: () -> bool
|
|
327
419
|
|
|
420
|
+
# <!--
|
|
421
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
422
|
+
# - matched_size()
|
|
423
|
+
# -->
|
|
328
424
|
# Returns the size of the most recent match in bytes, or `nil` if there was no
|
|
329
425
|
# recent match. This is different than `matched.size`, which will return the
|
|
330
426
|
# size in characters.
|
|
@@ -337,6 +433,10 @@ class StringScanner
|
|
|
337
433
|
#
|
|
338
434
|
def matched_size: () -> Integer?
|
|
339
435
|
|
|
436
|
+
# <!--
|
|
437
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
438
|
+
# - peek(len)
|
|
439
|
+
# -->
|
|
340
440
|
# Extracts a string corresponding to `string[pos,len]`, without advancing the
|
|
341
441
|
# scan pointer.
|
|
342
442
|
#
|
|
@@ -346,10 +446,15 @@ class StringScanner
|
|
|
346
446
|
#
|
|
347
447
|
def peek: (Integer) -> String
|
|
348
448
|
|
|
449
|
+
# <!--
|
|
450
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
451
|
+
# - peep(p1)
|
|
452
|
+
# -->
|
|
349
453
|
# Equivalent to #peek. This method is obsolete; use #peek instead.
|
|
350
454
|
#
|
|
351
455
|
def peep: (Integer) -> String
|
|
352
456
|
|
|
457
|
+
# <!-- rdoc-file=ext/strscan/strscan.c -->
|
|
353
458
|
# Returns the byte position of the scan pointer. In the 'reset' position, this
|
|
354
459
|
# value is zero. In the 'terminated' position (i.e. the string is exhausted),
|
|
355
460
|
# this value is the bytesize of the string.
|
|
@@ -365,6 +470,7 @@ class StringScanner
|
|
|
365
470
|
#
|
|
366
471
|
def pointer: () -> Integer
|
|
367
472
|
|
|
473
|
+
# <!-- rdoc-file=ext/strscan/strscan.c -->
|
|
368
474
|
# Sets the byte position of the scan pointer.
|
|
369
475
|
#
|
|
370
476
|
# s = StringScanner.new('test string')
|
|
@@ -373,6 +479,10 @@ class StringScanner
|
|
|
373
479
|
#
|
|
374
480
|
def pointer=: (Integer) -> Integer
|
|
375
481
|
|
|
482
|
+
# <!--
|
|
483
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
484
|
+
# - pos()
|
|
485
|
+
# -->
|
|
376
486
|
# Returns the byte position of the scan pointer. In the 'reset' position, this
|
|
377
487
|
# value is zero. In the 'terminated' position (i.e. the string is exhausted),
|
|
378
488
|
# this value is the bytesize of the string.
|
|
@@ -388,6 +498,10 @@ class StringScanner
|
|
|
388
498
|
#
|
|
389
499
|
def pos: () -> Integer
|
|
390
500
|
|
|
501
|
+
# <!--
|
|
502
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
503
|
+
# - pos=(n)
|
|
504
|
+
# -->
|
|
391
505
|
# Sets the byte position of the scan pointer.
|
|
392
506
|
#
|
|
393
507
|
# s = StringScanner.new('test string')
|
|
@@ -396,6 +510,10 @@ class StringScanner
|
|
|
396
510
|
#
|
|
397
511
|
def pos=: (Integer) -> Integer
|
|
398
512
|
|
|
513
|
+
# <!--
|
|
514
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
515
|
+
# - post_match()
|
|
516
|
+
# -->
|
|
399
517
|
# Returns the ***post**-match* (in the regular expression sense) of the last
|
|
400
518
|
# scan.
|
|
401
519
|
#
|
|
@@ -407,6 +525,10 @@ class StringScanner
|
|
|
407
525
|
#
|
|
408
526
|
def post_match: () -> String
|
|
409
527
|
|
|
528
|
+
# <!--
|
|
529
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
530
|
+
# - pre_match()
|
|
531
|
+
# -->
|
|
410
532
|
# Returns the ***pre**-match* (in the regular expression sense) of the last
|
|
411
533
|
# scan.
|
|
412
534
|
#
|
|
@@ -418,17 +540,29 @@ class StringScanner
|
|
|
418
540
|
#
|
|
419
541
|
def pre_match: () -> String
|
|
420
542
|
|
|
543
|
+
# <!--
|
|
544
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
545
|
+
# - reset()
|
|
546
|
+
# -->
|
|
421
547
|
# Reset the scan pointer (index 0) and clear matching data.
|
|
422
548
|
#
|
|
423
549
|
def reset: () -> void
|
|
424
550
|
|
|
551
|
+
# <!--
|
|
552
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
553
|
+
# - rest()
|
|
554
|
+
# -->
|
|
425
555
|
# Returns the "rest" of the string (i.e. everything after the scan pointer). If
|
|
426
556
|
# there is no more data (eos? = true), it returns `""`.
|
|
427
557
|
#
|
|
428
558
|
def rest: () -> String
|
|
429
559
|
|
|
430
|
-
#
|
|
431
|
-
#
|
|
560
|
+
# <!--
|
|
561
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
562
|
+
# - rest?()
|
|
563
|
+
# -->
|
|
564
|
+
# Returns true if and only if there is more data in the string. See #eos?. This
|
|
565
|
+
# method is obsolete; use #eos? instead.
|
|
432
566
|
#
|
|
433
567
|
# s = StringScanner.new('test string')
|
|
434
568
|
# s.eos? # These two
|
|
@@ -436,15 +570,27 @@ class StringScanner
|
|
|
436
570
|
#
|
|
437
571
|
def rest?: () -> bool
|
|
438
572
|
|
|
573
|
+
# <!--
|
|
574
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
575
|
+
# - rest_size()
|
|
576
|
+
# -->
|
|
439
577
|
# `s.rest_size` is equivalent to `s.rest.size`.
|
|
440
578
|
#
|
|
441
579
|
def rest_size: () -> Integer
|
|
442
580
|
|
|
581
|
+
# <!--
|
|
582
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
583
|
+
# - restsize()
|
|
584
|
+
# -->
|
|
443
585
|
# `s.restsize` is equivalent to `s.rest_size`. This method is obsolete; use
|
|
444
586
|
# #rest_size instead.
|
|
445
587
|
#
|
|
446
588
|
def restsize: () -> Integer
|
|
447
589
|
|
|
590
|
+
# <!--
|
|
591
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
592
|
+
# - scan(pattern) => String
|
|
593
|
+
# -->
|
|
448
594
|
# Tries to match with `pattern` at the current position. If there's a match, the
|
|
449
595
|
# scanner advances the "scan pointer" and returns the matched string. Otherwise,
|
|
450
596
|
# the scanner returns `nil`.
|
|
@@ -459,6 +605,10 @@ class StringScanner
|
|
|
459
605
|
#
|
|
460
606
|
def scan: (Regexp) -> String?
|
|
461
607
|
|
|
608
|
+
# <!--
|
|
609
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
610
|
+
# - scan_full(pattern, advance_pointer_p, return_string_p)
|
|
611
|
+
# -->
|
|
462
612
|
# Tests whether the given `pattern` is matched from the current scan pointer.
|
|
463
613
|
# Advances the scan pointer if `advance_pointer_p` is true. Returns the matched
|
|
464
614
|
# string if `return_string_p` is true. The match register is affected.
|
|
@@ -467,6 +617,10 @@ class StringScanner
|
|
|
467
617
|
#
|
|
468
618
|
def scan_full: (Regexp pattern, bool advance_pointer_p, bool return_string_p) -> untyped
|
|
469
619
|
|
|
620
|
+
# <!--
|
|
621
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
622
|
+
# - scan_until(pattern)
|
|
623
|
+
# -->
|
|
470
624
|
# Scans the string *until* the `pattern` is matched. Returns the substring up
|
|
471
625
|
# to and including the end of the match, advancing the scan pointer to that
|
|
472
626
|
# location. If there is no match, `nil` is returned.
|
|
@@ -478,6 +632,10 @@ class StringScanner
|
|
|
478
632
|
#
|
|
479
633
|
def scan_until: (Regexp) -> String?
|
|
480
634
|
|
|
635
|
+
# <!--
|
|
636
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
637
|
+
# - search_full(pattern, advance_pointer_p, return_string_p)
|
|
638
|
+
# -->
|
|
481
639
|
# Scans the string *until* the `pattern` is matched. Advances the scan pointer
|
|
482
640
|
# if `advance_pointer_p`, otherwise not. Returns the matched string if
|
|
483
641
|
# `return_string_p` is true, otherwise returns the number of bytes advanced.
|
|
@@ -485,6 +643,10 @@ class StringScanner
|
|
|
485
643
|
#
|
|
486
644
|
def search_full: (Regexp pattern, bool advance_pointer_p, bool return_string_p) -> untyped
|
|
487
645
|
|
|
646
|
+
# <!--
|
|
647
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
648
|
+
# - size
|
|
649
|
+
# -->
|
|
488
650
|
# Returns the amount of subgroups in the most recent match. The full match
|
|
489
651
|
# counts as a subgroup.
|
|
490
652
|
#
|
|
@@ -494,6 +656,10 @@ class StringScanner
|
|
|
494
656
|
#
|
|
495
657
|
def size: () -> Integer
|
|
496
658
|
|
|
659
|
+
# <!--
|
|
660
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
661
|
+
# - skip(pattern)
|
|
662
|
+
# -->
|
|
497
663
|
# Attempts to skip over the given `pattern` beginning with the scan pointer. If
|
|
498
664
|
# it matches, the scan pointer is advanced to the end of the match, and the
|
|
499
665
|
# length of the match is returned. Otherwise, `nil` is returned.
|
|
@@ -510,6 +676,10 @@ class StringScanner
|
|
|
510
676
|
#
|
|
511
677
|
def skip: (Regexp) -> Integer?
|
|
512
678
|
|
|
679
|
+
# <!--
|
|
680
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
681
|
+
# - skip_until(pattern)
|
|
682
|
+
# -->
|
|
513
683
|
# Advances the scan pointer until `pattern` is matched and consumed. Returns
|
|
514
684
|
# the number of bytes advanced, or `nil` if no match was found.
|
|
515
685
|
#
|
|
@@ -525,19 +695,36 @@ class StringScanner
|
|
|
525
695
|
#
|
|
526
696
|
def skip_until: (Regexp) -> Integer?
|
|
527
697
|
|
|
698
|
+
# <!--
|
|
699
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
700
|
+
# - string()
|
|
701
|
+
# -->
|
|
528
702
|
# Returns the string being scanned.
|
|
529
703
|
#
|
|
530
704
|
def string: () -> String
|
|
531
705
|
|
|
706
|
+
# <!--
|
|
707
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
708
|
+
# - string=(str)
|
|
709
|
+
# -->
|
|
532
710
|
# Changes the string being scanned to `str` and resets the scanner. Returns
|
|
533
711
|
# `str`.
|
|
534
712
|
#
|
|
535
713
|
def string=: (String) -> String
|
|
536
714
|
|
|
715
|
+
# <!--
|
|
716
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
717
|
+
# - terminate
|
|
718
|
+
# - clear
|
|
719
|
+
# -->
|
|
537
720
|
# Sets the scan pointer to the end of the string and clear matching data.
|
|
538
721
|
#
|
|
539
722
|
def terminate: () -> void
|
|
540
723
|
|
|
724
|
+
# <!--
|
|
725
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
726
|
+
# - unscan()
|
|
727
|
+
# -->
|
|
541
728
|
# Sets the scan pointer to the previous position. Only one previous position is
|
|
542
729
|
# remembered, and it changes with each scanning operation.
|
|
543
730
|
#
|
|
@@ -550,6 +737,10 @@ class StringScanner
|
|
|
550
737
|
#
|
|
551
738
|
def unscan: () -> void
|
|
552
739
|
|
|
740
|
+
# <!--
|
|
741
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
742
|
+
# - scanner.values_at( i1, i2, ... iN ) -> an_array
|
|
743
|
+
# -->
|
|
553
744
|
# Returns the subgroups in the most recent match at the given indices. If
|
|
554
745
|
# nothing was priorly matched, it returns nil.
|
|
555
746
|
#
|
|
@@ -563,6 +754,11 @@ class StringScanner
|
|
|
563
754
|
|
|
564
755
|
private
|
|
565
756
|
|
|
757
|
+
# <!--
|
|
758
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
759
|
+
# - StringScanner.new(string, fixed_anchor: false)
|
|
760
|
+
# - StringScanner.new(string, dup = false)
|
|
761
|
+
# -->
|
|
566
762
|
# Creates a new StringScanner object to scan over the given `string`.
|
|
567
763
|
#
|
|
568
764
|
# If `fixed_anchor` is `true`, `\A` always matches the beginning of the string.
|
|
@@ -572,6 +768,11 @@ class StringScanner
|
|
|
572
768
|
#
|
|
573
769
|
def initialize: (String, ?bool dup, ?fixed_anchor: bool) -> untyped
|
|
574
770
|
|
|
771
|
+
# <!--
|
|
772
|
+
# rdoc-file=ext/strscan/strscan.c
|
|
773
|
+
# - dup
|
|
774
|
+
# - clone
|
|
775
|
+
# -->
|
|
575
776
|
# Duplicates a StringScanner object.
|
|
576
777
|
#
|
|
577
778
|
def initialize_copy: (StringScanner) -> void
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# <!-- rdoc-file=lib/tempfile.rb -->
|
|
1
2
|
# A utility class for managing temporary files. When you create a Tempfile
|
|
2
3
|
# object, it will create a temporary file with a unique filename. A Tempfile
|
|
3
4
|
# objects behaves just like a File object, and you can perform all the usual
|
|
@@ -25,12 +26,12 @@
|
|
|
25
26
|
# ### Explicit close
|
|
26
27
|
#
|
|
27
28
|
# When a Tempfile object is garbage collected, or when the Ruby interpreter
|
|
28
|
-
# exits, its associated temporary file is automatically deleted. This means
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
29
|
+
# exits, its associated temporary file is automatically deleted. This means that
|
|
30
|
+
# it's unnecessary to explicitly delete a Tempfile after use, though it's a good
|
|
31
|
+
# practice to do so: not explicitly deleting unused Tempfiles can potentially
|
|
32
|
+
# leave behind a large number of temp files on the filesystem until they're
|
|
33
|
+
# garbage collected. The existence of these temp files can make it harder to
|
|
34
|
+
# determine a new Tempfile filename.
|
|
34
35
|
#
|
|
35
36
|
# Therefore, one should always call #unlink or close in an ensure block, like
|
|
36
37
|
# this:
|
|
@@ -75,7 +76,12 @@
|
|
|
75
76
|
# Tempfile itself however may not be entirely thread-safe. If you access the
|
|
76
77
|
# same Tempfile object from multiple threads then you should protect it with a
|
|
77
78
|
# mutex.
|
|
79
|
+
#
|
|
78
80
|
class Tempfile < File
|
|
81
|
+
# <!--
|
|
82
|
+
# rdoc-file=lib/tempfile.rb
|
|
83
|
+
# - create(basename="", tmpdir=nil, mode: 0, **options) { |tmpfile| ... }
|
|
84
|
+
# -->
|
|
79
85
|
# Creates a temporary file as a usual File object (not a Tempfile). It does not
|
|
80
86
|
# use finalizer and delegation, which makes it more efficient and reliable.
|
|
81
87
|
#
|
|
@@ -95,9 +101,13 @@ class Tempfile < File
|
|
|
95
101
|
# # ... do something with f ...
|
|
96
102
|
# end
|
|
97
103
|
#
|
|
98
|
-
def self.create: (?
|
|
99
|
-
| [A] (?
|
|
104
|
+
def self.create: (?String | [ String, String ] basename, ?String? tmpdir, ?mode: Integer, **untyped) -> File
|
|
105
|
+
| [A] (?String | [ String, String ] basename, ?String? tmpdir, ?mode: Integer, **untyped) { (File) -> A } -> A
|
|
100
106
|
|
|
107
|
+
# <!--
|
|
108
|
+
# rdoc-file=lib/tempfile.rb
|
|
109
|
+
# - open(*args, **kw) { |tempfile| ... }
|
|
110
|
+
# -->
|
|
101
111
|
# Creates a new Tempfile.
|
|
102
112
|
#
|
|
103
113
|
# This method is not recommended and exists mostly for backward compatibility.
|
|
@@ -140,6 +150,10 @@ class Tempfile < File
|
|
|
140
150
|
|
|
141
151
|
public
|
|
142
152
|
|
|
153
|
+
# <!--
|
|
154
|
+
# rdoc-file=lib/tempfile.rb
|
|
155
|
+
# - close(unlink_now=false)
|
|
156
|
+
# -->
|
|
143
157
|
# Closes the file. If `unlink_now` is true, then the file will be unlinked
|
|
144
158
|
# (deleted) after closing. Of course, you can choose to later call #unlink if
|
|
145
159
|
# you do not unlink it now.
|
|
@@ -149,31 +163,61 @@ class Tempfile < File
|
|
|
149
163
|
#
|
|
150
164
|
def close: (?boolish unlink_now) -> void
|
|
151
165
|
|
|
166
|
+
# <!--
|
|
167
|
+
# rdoc-file=lib/tempfile.rb
|
|
168
|
+
# - close!()
|
|
169
|
+
# -->
|
|
152
170
|
# Closes and unlinks (deletes) the file. Has the same effect as called
|
|
153
171
|
# `close(true)`.
|
|
154
172
|
#
|
|
155
173
|
def close!: () -> void
|
|
156
174
|
|
|
175
|
+
# <!--
|
|
176
|
+
# rdoc-file=lib/tempfile.rb
|
|
177
|
+
# - delete()
|
|
178
|
+
# -->
|
|
179
|
+
#
|
|
157
180
|
alias delete unlink
|
|
158
181
|
|
|
159
182
|
def inspect: () -> String
|
|
160
183
|
|
|
184
|
+
# <!--
|
|
185
|
+
# rdoc-file=lib/tempfile.rb
|
|
186
|
+
# - length()
|
|
187
|
+
# -->
|
|
188
|
+
#
|
|
161
189
|
alias length size
|
|
162
190
|
|
|
191
|
+
# <!--
|
|
192
|
+
# rdoc-file=lib/tempfile.rb
|
|
193
|
+
# - open()
|
|
194
|
+
# -->
|
|
163
195
|
# Opens or reopens the file with mode "r+".
|
|
164
196
|
#
|
|
165
197
|
def open: () -> File
|
|
166
198
|
|
|
199
|
+
# <!--
|
|
200
|
+
# rdoc-file=lib/tempfile.rb
|
|
201
|
+
# - path()
|
|
202
|
+
# -->
|
|
167
203
|
# Returns the full path name of the temporary file. This will be nil if #unlink
|
|
168
204
|
# has been called.
|
|
169
205
|
#
|
|
170
206
|
def path: () -> String?
|
|
171
207
|
|
|
208
|
+
# <!--
|
|
209
|
+
# rdoc-file=lib/tempfile.rb
|
|
210
|
+
# - size()
|
|
211
|
+
# -->
|
|
172
212
|
# Returns the size of the temporary file. As a side effect, the IO buffer is
|
|
173
213
|
# flushed before determining the size.
|
|
174
214
|
#
|
|
175
215
|
def size: () -> Integer
|
|
176
216
|
|
|
217
|
+
# <!--
|
|
218
|
+
# rdoc-file=lib/tempfile.rb
|
|
219
|
+
# - unlink()
|
|
220
|
+
# -->
|
|
177
221
|
# Unlinks (deletes) the file from the filesystem. One should always unlink the
|
|
178
222
|
# file after using it, as is explained in the "Explicit close" good practice
|
|
179
223
|
# section in the Tempfile overview:
|
|
@@ -220,6 +264,10 @@ class Tempfile < File
|
|
|
220
264
|
def initialize: (::Tempfile tmpfile) -> void
|
|
221
265
|
end
|
|
222
266
|
|
|
267
|
+
# <!--
|
|
268
|
+
# rdoc-file=lib/tempfile.rb
|
|
269
|
+
# - new(basename="", tmpdir=nil, mode: 0, **options)
|
|
270
|
+
# -->
|
|
223
271
|
# Creates a temporary file with permissions 0600 (= only readable and writable
|
|
224
272
|
# by the owner) and opens it with mode "w+".
|
|
225
273
|
#
|
|
@@ -263,6 +311,6 @@ class Tempfile < File
|
|
|
263
311
|
# If Tempfile.new cannot find a unique filename within a limited number of
|
|
264
312
|
# tries, then it will raise an exception.
|
|
265
313
|
#
|
|
266
|
-
def self.new: (?
|
|
267
|
-
| [A] (?
|
|
314
|
+
def self.new: (?String | [ String, String ] basename, ?String? tmpdir, ?mode: Integer, **untyped) -> instance
|
|
315
|
+
| [A] (?String | [ String, String ] basename, ?String? tmpdir, ?mode: Integer, **untyped) { (instance) -> A } -> A
|
|
268
316
|
end
|