rbs 3.0.0.dev.2 → 3.0.0.dev.3
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 +2 -1
- data/.github/workflows/ruby.yml +4 -0
- data/Gemfile.lock +11 -11
- data/Rakefile +2 -2
- data/Steepfile +1 -1
- data/core/array.rbs +573 -423
- data/core/basic_object.rbs +11 -39
- data/core/binding.rbs +1 -1
- data/core/builtin.rbs +8 -0
- data/core/class.rbs +37 -0
- data/core/comparable.rbs +7 -18
- data/core/complex.rbs +2 -2
- data/core/data.rbs +419 -0
- data/core/dir.rbs +52 -104
- data/core/encoding.rbs +22 -181
- data/core/enumerable.rbs +212 -175
- data/core/enumerator/product.rbs +96 -0
- data/core/enumerator.rbs +57 -8
- data/core/errors.rbs +8 -2
- data/core/exception.rbs +41 -0
- data/core/fiber.rbs +95 -12
- data/core/file.rbs +840 -275
- data/core/file_test.rbs +34 -19
- data/core/float.rbs +40 -96
- data/core/gc.rbs +15 -3
- data/core/hash.rbs +113 -175
- data/core/integer.rbs +85 -145
- data/core/io/buffer.rbs +187 -60
- data/core/io/wait.rbs +28 -16
- data/core/io.rbs +1859 -1389
- data/core/kernel.rbs +525 -961
- data/core/match_data.rbs +306 -142
- data/core/math.rbs +506 -234
- data/core/method.rbs +0 -24
- data/core/module.rbs +110 -17
- data/core/nil_class.rbs +2 -0
- data/core/numeric.rbs +76 -144
- data/core/object.rbs +88 -212
- data/core/proc.rbs +17 -5
- data/core/process.rbs +22 -5
- data/core/ractor.rbs +1 -1
- data/core/random.rbs +20 -3
- data/core/range.rbs +91 -89
- data/core/rational.rbs +2 -3
- data/core/rbs/unnamed/argf.rbs +177 -120
- data/core/rbs/unnamed/env_class.rbs +89 -163
- data/core/rbs/unnamed/random.rbs +36 -12
- data/core/refinement.rbs +8 -0
- data/core/regexp.rbs +462 -272
- data/core/ruby_vm.rbs +210 -0
- data/{stdlib/set/0 → core}/set.rbs +43 -47
- data/core/string.rbs +1403 -1332
- data/core/string_io.rbs +191 -107
- data/core/struct.rbs +67 -63
- data/core/symbol.rbs +187 -201
- data/core/thread.rbs +40 -35
- data/core/time.rbs +902 -826
- data/core/trace_point.rbs +55 -6
- data/core/unbound_method.rbs +48 -24
- data/docs/collection.md +4 -0
- data/docs/syntax.md +55 -0
- data/ext/rbs_extension/parser.c +5 -6
- data/lib/rbs/cli.rb +6 -1
- data/lib/rbs/collection/cleaner.rb +8 -1
- data/lib/rbs/collection/config/lockfile.rb +3 -1
- data/lib/rbs/collection/config/lockfile_generator.rb +16 -14
- data/lib/rbs/collection/config.rb +1 -1
- data/lib/rbs/collection/sources/git.rb +9 -2
- data/lib/rbs/collection/sources/local.rb +79 -0
- data/lib/rbs/collection/sources.rb +8 -1
- data/lib/rbs/environment.rb +6 -5
- data/lib/rbs/environment_loader.rb +3 -2
- data/lib/rbs/errors.rb +18 -0
- data/lib/rbs/locator.rb +26 -7
- data/lib/rbs/sorter.rb +2 -2
- data/lib/rbs/version.rb +1 -1
- data/sig/collection/sources.rbs +32 -3
- data/sig/environment.rbs +2 -3
- data/sig/locator.rbs +14 -2
- data/sig/shims/{abstract_syntax_tree.rbs → _abstract_syntax_tree.rbs} +0 -0
- data/stdlib/bigdecimal/0/big_decimal.rbs +16 -13
- data/stdlib/cgi/0/core.rbs +16 -0
- data/stdlib/coverage/0/coverage.rbs +50 -8
- data/stdlib/csv/0/csv.rbs +1 -1
- data/stdlib/date/0/date.rbs +856 -726
- data/stdlib/date/0/date_time.rbs +83 -210
- data/stdlib/erb/0/erb.rbs +13 -36
- data/stdlib/etc/0/etc.rbs +127 -20
- data/stdlib/fileutils/0/fileutils.rbs +1290 -381
- data/stdlib/logger/0/logger.rbs +466 -316
- data/stdlib/net-http/0/net-http.rbs +2211 -534
- data/stdlib/nkf/0/nkf.rbs +5 -5
- data/stdlib/objspace/0/objspace.rbs +31 -14
- data/stdlib/openssl/0/openssl.rbs +11 -7
- data/stdlib/optparse/0/optparse.rbs +20 -17
- data/stdlib/pathname/0/pathname.rbs +21 -4
- data/stdlib/pstore/0/pstore.rbs +378 -154
- data/stdlib/pty/0/pty.rbs +24 -8
- data/stdlib/ripper/0/ripper.rbs +1650 -0
- data/stdlib/socket/0/addrinfo.rbs +9 -15
- data/stdlib/socket/0/socket.rbs +36 -3
- data/stdlib/strscan/0/string_scanner.rbs +7 -5
- data/stdlib/tempfile/0/tempfile.rbs +104 -44
- data/stdlib/time/0/time.rbs +2 -2
- data/stdlib/uri/0/file.rbs +5 -0
- data/stdlib/uri/0/generic.rbs +2 -2
- data/stdlib/yaml/0/yaml.rbs +2 -2
- data/stdlib/zlib/0/zlib.rbs +1 -1
- metadata +8 -6
- data/core/deprecated.rbs +0 -9
- data/sig/shims/ripper.rbs +0 -8
data/core/string_io.rbs
CHANGED
|
@@ -1,39 +1,52 @@
|
|
|
1
1
|
# <!-- rdoc-file=ext/stringio/stringio.c -->
|
|
2
|
-
#
|
|
2
|
+
# IO streams for strings, with access similar to [IO](rdoc-ref:IO); see
|
|
3
|
+
# [IO](rdoc-ref:IO).
|
|
3
4
|
#
|
|
4
|
-
#
|
|
5
|
+
# ### About the Examples
|
|
5
6
|
#
|
|
6
|
-
#
|
|
7
|
+
# Examples on this page assume that StringIO has been required:
|
|
7
8
|
#
|
|
8
9
|
# require 'stringio'
|
|
9
10
|
#
|
|
10
|
-
# # Writing stream emulation
|
|
11
|
-
# io = StringIO.new
|
|
12
|
-
# io.puts "Hello World"
|
|
13
|
-
# io.string #=> "Hello World\n"
|
|
14
|
-
#
|
|
15
|
-
# # Reading stream emulation
|
|
16
|
-
# io = StringIO.new "first\nsecond\nlast\n"
|
|
17
|
-
# io.getc #=> "f"
|
|
18
|
-
# io.gets #=> "irst\n"
|
|
19
|
-
# io.read #=> "second\nlast\n"
|
|
20
|
-
#
|
|
21
11
|
class StringIO
|
|
22
12
|
# <!--
|
|
23
13
|
# rdoc-file=ext/stringio/stringio.c
|
|
24
|
-
# - StringIO.new(string=
|
|
14
|
+
# - StringIO.new(string = '', mode = 'r+') -> new_stringio
|
|
25
15
|
# -->
|
|
26
|
-
#
|
|
16
|
+
# Note that `mode` defaults to `'r'` if `string` is frozen.
|
|
17
|
+
#
|
|
18
|
+
# Returns a new StringIO instance formed from `string` and `mode`; see [Access
|
|
19
|
+
# Modes](rdoc-ref:File@Access+Modes):
|
|
20
|
+
#
|
|
21
|
+
# strio = StringIO.new # => #<StringIO>
|
|
22
|
+
# strio.close
|
|
23
|
+
#
|
|
24
|
+
# The instance should be closed when no longer needed.
|
|
25
|
+
#
|
|
26
|
+
# Related: StringIO.open (accepts block; closes automatically).
|
|
27
27
|
#
|
|
28
28
|
def initialize: (?String string, ?String? mode) -> void
|
|
29
29
|
|
|
30
30
|
# <!--
|
|
31
31
|
# rdoc-file=ext/stringio/stringio.c
|
|
32
|
-
# - StringIO.open(string=
|
|
32
|
+
# - StringIO.open(string = '', mode = 'r+') {|strio| ... }
|
|
33
33
|
# -->
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
34
|
+
# Note that `mode` defaults to `'r'` if `string` is frozen.
|
|
35
|
+
#
|
|
36
|
+
# Creates a new StringIO instance formed from `string` and `mode`; see [Access
|
|
37
|
+
# Modes](rdoc-ref:File@Access+Modes).
|
|
38
|
+
#
|
|
39
|
+
# With no block, returns the new instance:
|
|
40
|
+
#
|
|
41
|
+
# strio = StringIO.open # => #<StringIO>
|
|
42
|
+
#
|
|
43
|
+
# With a block, calls the block with the new instance and returns the block's
|
|
44
|
+
# value; closes the instance on block exit.
|
|
45
|
+
#
|
|
46
|
+
# StringIO.open {|strio| p strio }
|
|
47
|
+
# # => #<StringIO>
|
|
48
|
+
#
|
|
49
|
+
# Related: StringIO.new.
|
|
37
50
|
#
|
|
38
51
|
def self.open: [U] (?String string, ?String? mode) { (StringIO arg) -> U } -> U
|
|
39
52
|
|
|
@@ -41,116 +54,134 @@ class StringIO
|
|
|
41
54
|
|
|
42
55
|
# <!--
|
|
43
56
|
# rdoc-file=ext/stringio/stringio.c
|
|
44
|
-
# -
|
|
57
|
+
# - binmode -> self
|
|
45
58
|
# -->
|
|
46
|
-
#
|
|
59
|
+
# Sets the data mode in `self` to binary mode; see [Data
|
|
60
|
+
# Mode](rdoc-ref:File@Data+Mode).
|
|
47
61
|
#
|
|
48
62
|
def binmode: () -> self
|
|
49
63
|
|
|
50
64
|
# <!--
|
|
51
65
|
# rdoc-file=ext/stringio/stringio.c
|
|
52
|
-
# -
|
|
66
|
+
# - close -> nil
|
|
53
67
|
# -->
|
|
54
|
-
# Closes
|
|
55
|
-
#
|
|
68
|
+
# Closes `self` for both reading and writing.
|
|
69
|
+
#
|
|
70
|
+
# Raises IOError if reading or writing is attempted.
|
|
71
|
+
#
|
|
72
|
+
# Related: StringIO#close_read, StringIO#close_write.
|
|
56
73
|
#
|
|
57
74
|
def close: () -> nil
|
|
58
75
|
|
|
59
76
|
# <!--
|
|
60
77
|
# rdoc-file=ext/stringio/stringio.c
|
|
61
|
-
# -
|
|
78
|
+
# - close_read -> nil
|
|
62
79
|
# -->
|
|
63
|
-
# Closes
|
|
64
|
-
#
|
|
80
|
+
# Closes `self` for reading; closed-write setting remains unchanged.
|
|
81
|
+
#
|
|
82
|
+
# Raises IOError if reading is attempted.
|
|
83
|
+
#
|
|
84
|
+
# Related: StringIO#close, StringIO#close_write.
|
|
65
85
|
#
|
|
66
86
|
def close_read: () -> nil
|
|
67
87
|
|
|
68
88
|
# <!--
|
|
69
89
|
# rdoc-file=ext/stringio/stringio.c
|
|
70
|
-
# -
|
|
90
|
+
# - close_write -> nil
|
|
71
91
|
# -->
|
|
72
|
-
# Closes
|
|
73
|
-
#
|
|
92
|
+
# Closes `self` for writing; closed-read setting remains unchanged.
|
|
93
|
+
#
|
|
94
|
+
# Raises IOError if writing is attempted.
|
|
95
|
+
#
|
|
96
|
+
# Related: StringIO#close, StringIO#close_read.
|
|
74
97
|
#
|
|
75
98
|
def close_write: () -> nil
|
|
76
99
|
|
|
77
100
|
# <!--
|
|
78
101
|
# rdoc-file=ext/stringio/stringio.c
|
|
79
|
-
# -
|
|
102
|
+
# - closed? -> true or false
|
|
80
103
|
# -->
|
|
81
|
-
# Returns `true` if
|
|
104
|
+
# Returns `true` if `self` is closed for both reading and writing, `false`
|
|
105
|
+
# otherwise.
|
|
82
106
|
#
|
|
83
107
|
def closed?: () -> bool
|
|
84
108
|
|
|
85
109
|
# <!--
|
|
86
110
|
# rdoc-file=ext/stringio/stringio.c
|
|
87
|
-
# -
|
|
111
|
+
# - closed_read? -> true or false
|
|
88
112
|
# -->
|
|
89
|
-
# Returns `true` if
|
|
113
|
+
# Returns `true` if `self` is closed for reading, `false` otherwise.
|
|
90
114
|
#
|
|
91
115
|
def closed_read?: () -> bool
|
|
92
116
|
|
|
93
117
|
# <!--
|
|
94
118
|
# rdoc-file=ext/stringio/stringio.c
|
|
95
|
-
# -
|
|
119
|
+
# - closed_write? -> true or false
|
|
96
120
|
# -->
|
|
97
|
-
# Returns `true` if
|
|
121
|
+
# Returns `true` if `self` is closed for writing, `false` otherwise.
|
|
98
122
|
#
|
|
99
123
|
def closed_write?: () -> bool
|
|
100
124
|
|
|
101
125
|
# <!--
|
|
102
126
|
# rdoc-file=ext/stringio/stringio.c
|
|
103
|
-
# -
|
|
104
|
-
# -
|
|
105
|
-
# -
|
|
106
|
-
# - strio.each(...) -> anEnumerator
|
|
107
|
-
# - strio.each_line(sep=$/, chomp: false) {|line| block } -> strio
|
|
108
|
-
# - strio.each_line(limit, chomp: false) {|line| block } -> strio
|
|
109
|
-
# - strio.each_line(sep, limit, chomp: false) {|line| block } -> strio
|
|
110
|
-
# - strio.each_line(...) -> anEnumerator
|
|
127
|
+
# - each_line(sep = $/, chomp: false) {|line| ... } -> self
|
|
128
|
+
# - each_line(limit, chomp: false) {|line| ... } -> self
|
|
129
|
+
# - each_line(sep, limit, chomp: false) {|line| ... } -> self
|
|
111
130
|
# -->
|
|
112
|
-
#
|
|
131
|
+
# Calls the block with each remaining line read from the stream; does nothing if
|
|
132
|
+
# already at end-of-file; returns `self`. See [Line IO](rdoc-ref:IO@Line+IO).
|
|
133
|
+
#
|
|
134
|
+
# StringIO#each is an alias for StringIO#each_line.
|
|
113
135
|
#
|
|
114
136
|
def each: (?String sep, ?Integer limit, ?chomp: boolish) { (String) -> untyped } -> self
|
|
115
137
|
| (?String sep, ?Integer limit, ?chomp: boolish) -> ::Enumerator[String, self]
|
|
116
138
|
|
|
117
139
|
# <!--
|
|
118
140
|
# rdoc-file=ext/stringio/stringio.c
|
|
119
|
-
# -
|
|
120
|
-
# - strio.each_byte -> anEnumerator
|
|
141
|
+
# - each_byte {|byte| ... } -> self
|
|
121
142
|
# -->
|
|
122
|
-
#
|
|
143
|
+
# With a block given, calls the block with each remaining byte in the stream;
|
|
144
|
+
# see [Byte IO](rdoc-ref:IO@Byte+IO).
|
|
145
|
+
#
|
|
146
|
+
# With no block given, returns an enumerator.
|
|
123
147
|
#
|
|
124
148
|
def each_byte: () { (Integer arg0) -> untyped } -> self
|
|
125
149
|
| () -> ::Enumerator[Integer, self]
|
|
126
150
|
|
|
127
151
|
# <!--
|
|
128
152
|
# rdoc-file=ext/stringio/stringio.c
|
|
129
|
-
# -
|
|
130
|
-
# - strio.each_char -> anEnumerator
|
|
153
|
+
# - each_char {|c| ... } -> self
|
|
131
154
|
# -->
|
|
132
|
-
#
|
|
155
|
+
# With a block given, calls the block with each remaining character in the
|
|
156
|
+
# stream; see [Character IO](rdoc-ref:IO@Character+IO).
|
|
157
|
+
#
|
|
158
|
+
# With no block given, returns an enumerator.
|
|
133
159
|
#
|
|
134
160
|
def each_char: () { (String arg0) -> untyped } -> self
|
|
135
161
|
| () -> ::Enumerator[String, self]
|
|
136
162
|
|
|
137
163
|
# <!--
|
|
138
164
|
# rdoc-file=ext/stringio/stringio.c
|
|
139
|
-
# -
|
|
140
|
-
# - strio.each_codepoint -> anEnumerator
|
|
165
|
+
# - each_codepoint {|codepoint| ... } -> self
|
|
141
166
|
# -->
|
|
142
|
-
#
|
|
167
|
+
# With a block given, calls the block with each remaining codepoint in the
|
|
168
|
+
# stream; see [Codepoint IO](rdoc-ref:IO@Codepoint+IO).
|
|
169
|
+
#
|
|
170
|
+
# With no block given, returns an enumerator.
|
|
143
171
|
#
|
|
144
172
|
def each_codepoint: () { (Integer arg0) -> untyped } -> self
|
|
145
173
|
| () -> ::Enumerator[Integer, self]
|
|
146
174
|
|
|
147
175
|
# <!--
|
|
148
176
|
# rdoc-file=ext/stringio/stringio.c
|
|
149
|
-
# -
|
|
150
|
-
# - strio.eof? -> true or false
|
|
177
|
+
# - eof? -> true or false
|
|
151
178
|
# -->
|
|
152
|
-
# Returns true if
|
|
153
|
-
#
|
|
179
|
+
# Returns `true` if positioned at end-of-stream, `false` otherwise; see
|
|
180
|
+
# [Position](rdoc-ref:File@Position).
|
|
181
|
+
#
|
|
182
|
+
# Raises IOError if the stream is not opened for reading.
|
|
183
|
+
#
|
|
184
|
+
# StreamIO#eof is an alias for StreamIO#eof?.
|
|
154
185
|
#
|
|
155
186
|
def eof: () -> bool
|
|
156
187
|
|
|
@@ -188,27 +219,30 @@ class StringIO
|
|
|
188
219
|
|
|
189
220
|
# <!--
|
|
190
221
|
# rdoc-file=ext/stringio/stringio.c
|
|
191
|
-
# -
|
|
222
|
+
# - getbyte -> byte or nil
|
|
192
223
|
# -->
|
|
193
|
-
#
|
|
224
|
+
# Reads and returns the next 8-bit byte from the stream; see [Byte
|
|
225
|
+
# IO](rdoc-ref:IO@Byte+IO).
|
|
194
226
|
#
|
|
195
227
|
def getbyte: () -> Integer?
|
|
196
228
|
|
|
197
229
|
# <!--
|
|
198
230
|
# rdoc-file=ext/stringio/stringio.c
|
|
199
|
-
# -
|
|
231
|
+
# - getc -> character or nil
|
|
200
232
|
# -->
|
|
201
|
-
#
|
|
233
|
+
# Reads and returns the next character from the stream; see [Character
|
|
234
|
+
# IO](rdoc-ref:IO@Character+IO).
|
|
202
235
|
#
|
|
203
236
|
def getc: () -> String?
|
|
204
237
|
|
|
205
238
|
# <!--
|
|
206
239
|
# rdoc-file=ext/stringio/stringio.c
|
|
207
|
-
# -
|
|
208
|
-
# -
|
|
209
|
-
# -
|
|
240
|
+
# - gets(sep = $/, chomp: false) -> string or nil
|
|
241
|
+
# - gets(limit, chomp: false) -> string or nil
|
|
242
|
+
# - gets(sep, limit, chomp: false) -> string or nil
|
|
210
243
|
# -->
|
|
211
|
-
#
|
|
244
|
+
# Reads and returns a line from the stream; assigns the return value to `$_`;
|
|
245
|
+
# see [Line IO](rdoc-ref:IO@Line+IO).
|
|
212
246
|
#
|
|
213
247
|
def gets: (?String sep, ?Integer limit, ?chomp: boolish) -> String?
|
|
214
248
|
|
|
@@ -240,21 +274,19 @@ class StringIO
|
|
|
240
274
|
|
|
241
275
|
# <!--
|
|
242
276
|
# rdoc-file=ext/stringio/stringio.c
|
|
243
|
-
# -
|
|
277
|
+
# - lineno -> current_line_number
|
|
244
278
|
# -->
|
|
245
|
-
# Returns the current line number
|
|
246
|
-
#
|
|
247
|
-
# of newlines encountered. The two values will differ if `gets` is called with
|
|
248
|
-
# a separator other than newline. See also the `$.` variable.
|
|
279
|
+
# Returns the current line number in `self`; see [Line
|
|
280
|
+
# Number](rdoc-ref:IO@Line+Number).
|
|
249
281
|
#
|
|
250
282
|
def lineno: () -> Integer
|
|
251
283
|
|
|
252
284
|
# <!--
|
|
253
285
|
# rdoc-file=ext/stringio/stringio.c
|
|
254
|
-
# -
|
|
286
|
+
# - lineno = new_line_number -> new_line_number
|
|
255
287
|
# -->
|
|
256
|
-
#
|
|
257
|
-
#
|
|
288
|
+
# Sets the current line number in `self` to the given `new_line_number`; see
|
|
289
|
+
# [Line Number](rdoc-ref:IO@Line+Number).
|
|
258
290
|
#
|
|
259
291
|
def lineno=: (Integer arg0) -> Integer
|
|
260
292
|
|
|
@@ -268,18 +300,19 @@ class StringIO
|
|
|
268
300
|
|
|
269
301
|
# <!--
|
|
270
302
|
# rdoc-file=ext/stringio/stringio.c
|
|
271
|
-
# -
|
|
272
|
-
# - strio.tell -> integer
|
|
303
|
+
# - pos -> stream_position
|
|
273
304
|
# -->
|
|
274
|
-
# Returns the current
|
|
305
|
+
# Returns the current position (in bytes); see [Position](rdoc-ref:IO@Position).
|
|
306
|
+
#
|
|
307
|
+
# StringIO#tell is an alias for StringIO#pos.
|
|
275
308
|
#
|
|
276
309
|
def pos: () -> Integer
|
|
277
310
|
|
|
278
311
|
# <!--
|
|
279
312
|
# rdoc-file=ext/stringio/stringio.c
|
|
280
|
-
# -
|
|
313
|
+
# - pos = new_position -> new_position
|
|
281
314
|
# -->
|
|
282
|
-
#
|
|
315
|
+
# Sets the current position (in bytes); see [Position](rdoc-ref:IO@Position).
|
|
283
316
|
#
|
|
284
317
|
def pos=: (Integer arg0) -> Integer
|
|
285
318
|
|
|
@@ -327,29 +360,45 @@ class StringIO
|
|
|
327
360
|
|
|
328
361
|
# <!--
|
|
329
362
|
# rdoc-file=ext/stringio/stringio.c
|
|
330
|
-
# -
|
|
331
|
-
# - strio.reopen(string, mode) -> strio
|
|
363
|
+
# - reopen(other, mode = 'r+') -> self
|
|
332
364
|
# -->
|
|
333
|
-
# Reinitializes the stream with the given
|
|
334
|
-
#
|
|
365
|
+
# Reinitializes the stream with the given `other` (string or StringIO) and
|
|
366
|
+
# `mode`; see IO.new:
|
|
367
|
+
#
|
|
368
|
+
# StringIO.open('foo') do |strio|
|
|
369
|
+
# p strio.string
|
|
370
|
+
# strio.reopen('bar')
|
|
371
|
+
# p strio.string
|
|
372
|
+
# other_strio = StringIO.new('baz')
|
|
373
|
+
# strio.reopen(other_strio)
|
|
374
|
+
# p strio.string
|
|
375
|
+
# other_strio.close
|
|
376
|
+
# end
|
|
377
|
+
#
|
|
378
|
+
# Output:
|
|
379
|
+
#
|
|
380
|
+
# "foo"
|
|
381
|
+
# "bar"
|
|
382
|
+
# "baz"
|
|
335
383
|
#
|
|
336
384
|
def reopen: (StringIO other) -> self
|
|
337
385
|
| (String other, ?String mode_str) -> self
|
|
338
386
|
|
|
339
387
|
# <!--
|
|
340
388
|
# rdoc-file=ext/stringio/stringio.c
|
|
341
|
-
# -
|
|
389
|
+
# - rewind -> 0
|
|
342
390
|
# -->
|
|
343
|
-
#
|
|
391
|
+
# Sets the current position and line number to zero; see
|
|
392
|
+
# [Position](rdoc-ref:IO@Position) and [Line Number](rdoc-ref:IO@Line+Number).
|
|
344
393
|
#
|
|
345
394
|
def rewind: () -> Integer
|
|
346
395
|
|
|
347
396
|
# <!--
|
|
348
397
|
# rdoc-file=ext/stringio/stringio.c
|
|
349
|
-
# -
|
|
398
|
+
# - seek(offset, whence = SEEK_SET) -> 0
|
|
350
399
|
# -->
|
|
351
|
-
#
|
|
352
|
-
#
|
|
400
|
+
# Sets the current position to the given integer `offset` (in bytes), with
|
|
401
|
+
# respect to a given constant `whence`; see [Position](rdoc-ref:IO@Position).
|
|
353
402
|
#
|
|
354
403
|
def seek: (Integer amount, ?Integer whence) -> Integer
|
|
355
404
|
|
|
@@ -366,17 +415,44 @@ class StringIO
|
|
|
366
415
|
|
|
367
416
|
# <!--
|
|
368
417
|
# rdoc-file=ext/stringio/stringio.c
|
|
369
|
-
# -
|
|
418
|
+
# - string -> string
|
|
370
419
|
# -->
|
|
371
|
-
# Returns underlying
|
|
420
|
+
# Returns underlying string:
|
|
421
|
+
#
|
|
422
|
+
# StringIO.open('foo') do |strio|
|
|
423
|
+
# p strio.string
|
|
424
|
+
# strio.string = 'bar'
|
|
425
|
+
# p strio.string
|
|
426
|
+
# end
|
|
427
|
+
#
|
|
428
|
+
# Output:
|
|
429
|
+
#
|
|
430
|
+
# "foo"
|
|
431
|
+
# "bar"
|
|
432
|
+
#
|
|
433
|
+
# Related: StringIO#string= (assigns the underlying string).
|
|
372
434
|
#
|
|
373
435
|
def string: () -> String
|
|
374
436
|
|
|
375
437
|
# <!--
|
|
376
438
|
# rdoc-file=ext/stringio/stringio.c
|
|
377
|
-
# -
|
|
439
|
+
# - string = other_string -> other_string
|
|
378
440
|
# -->
|
|
379
|
-
#
|
|
441
|
+
# Assigns the underlying string as `other_string`, and sets position to zero;
|
|
442
|
+
# returns `other_string`:
|
|
443
|
+
#
|
|
444
|
+
# StringIO.open('foo') do |strio|
|
|
445
|
+
# p strio.string
|
|
446
|
+
# strio.string = 'bar'
|
|
447
|
+
# p strio.string
|
|
448
|
+
# end
|
|
449
|
+
#
|
|
450
|
+
# Output:
|
|
451
|
+
#
|
|
452
|
+
# "foo"
|
|
453
|
+
# "bar"
|
|
454
|
+
#
|
|
455
|
+
# Related: StringIO#string (returns the underlying string).
|
|
380
456
|
#
|
|
381
457
|
def string=: (String str) -> String
|
|
382
458
|
|
|
@@ -391,9 +467,9 @@ class StringIO
|
|
|
391
467
|
|
|
392
468
|
# <!--
|
|
393
469
|
# rdoc-file=ext/stringio/stringio.c
|
|
394
|
-
# -
|
|
470
|
+
# - sync -> true
|
|
395
471
|
# -->
|
|
396
|
-
# Returns `true
|
|
472
|
+
# Returns `true`; implemented only for compatibility with other stream classes.
|
|
397
473
|
#
|
|
398
474
|
def sync: () -> bool
|
|
399
475
|
|
|
@@ -411,10 +487,11 @@ class StringIO
|
|
|
411
487
|
|
|
412
488
|
# <!--
|
|
413
489
|
# rdoc-file=ext/stringio/stringio.c
|
|
414
|
-
# -
|
|
415
|
-
# - strio.tell -> integer
|
|
490
|
+
# - pos -> stream_position
|
|
416
491
|
# -->
|
|
417
|
-
# Returns the current
|
|
492
|
+
# Returns the current position (in bytes); see [Position](rdoc-ref:IO@Position).
|
|
493
|
+
#
|
|
494
|
+
# StringIO#tell is an alias for StringIO#pos.
|
|
418
495
|
#
|
|
419
496
|
def tell: () -> Integer
|
|
420
497
|
|
|
@@ -425,19 +502,19 @@ class StringIO
|
|
|
425
502
|
|
|
426
503
|
# <!--
|
|
427
504
|
# rdoc-file=ext/stringio/stringio.c
|
|
428
|
-
# -
|
|
505
|
+
# - ungetbyte(byte) -> nil
|
|
429
506
|
# -->
|
|
430
|
-
#
|
|
507
|
+
# Pushes back ("unshifts") an 8-bit byte onto the stream; see [Byte
|
|
508
|
+
# IO](rdoc-ref:IO@Byte+IO).
|
|
431
509
|
#
|
|
432
510
|
def ungetbyte: (String | Integer arg0) -> nil
|
|
433
511
|
|
|
434
512
|
# <!--
|
|
435
513
|
# rdoc-file=ext/stringio/stringio.c
|
|
436
|
-
# -
|
|
514
|
+
# - ungetc(character) -> nil
|
|
437
515
|
# -->
|
|
438
|
-
# Pushes back
|
|
439
|
-
#
|
|
440
|
-
# including pushing back behind the beginning of the buffer string.
|
|
516
|
+
# Pushes back ("unshifts") a character or integer onto the stream; see
|
|
517
|
+
# [Character IO](rdoc-ref:IO@Character+IO).
|
|
441
518
|
#
|
|
442
519
|
def ungetc: (String arg0) -> nil
|
|
443
520
|
|
|
@@ -468,14 +545,21 @@ class StringIO
|
|
|
468
545
|
| () -> ::Enumerator[Integer, self]
|
|
469
546
|
|
|
470
547
|
# <!-- rdoc-file=ext/stringio/stringio.c -->
|
|
471
|
-
#
|
|
548
|
+
# Calls the block with each remaining line read from the stream; does nothing if
|
|
549
|
+
# already at end-of-file; returns `self`. See [Line IO](rdoc-ref:IO@Line+IO).
|
|
550
|
+
#
|
|
551
|
+
# StringIO#each is an alias for StringIO#each_line.
|
|
472
552
|
#
|
|
473
553
|
def each_line: (?String sep, ?Integer limit, ?chomp: boolish) { (String) -> untyped } -> self
|
|
474
554
|
| (?String sep, ?Integer limit, ?chomp: boolish) -> ::Enumerator[String, self]
|
|
475
555
|
|
|
476
556
|
# <!-- rdoc-file=ext/stringio/stringio.c -->
|
|
477
|
-
# Returns true if
|
|
478
|
-
#
|
|
557
|
+
# Returns `true` if positioned at end-of-stream, `false` otherwise; see
|
|
558
|
+
# [Position](rdoc-ref:File@Position).
|
|
559
|
+
#
|
|
560
|
+
# Raises IOError if the stream is not opened for reading.
|
|
561
|
+
#
|
|
562
|
+
# StreamIO#eof is an alias for StreamIO#eof?.
|
|
479
563
|
#
|
|
480
564
|
def eof?: () -> bool
|
|
481
565
|
|