Skip to content

Commit 3562c34

Browse files
committed
[DOC] Moved non ASCII documents to separated files
C99 does not declare ways to designate the charset encoding of the source file. We can assume just US-ASCII characters will be safe.
1 parent 6628d48 commit 3562c34

File tree

5 files changed

+108
-105
lines changed

5 files changed

+108
-105
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/Gemfile.lock
44
/_yardoc/
55
/coverage/
6-
/doc/
6+
/docs/
77
/html
88
/pkg/
99
/spec/reports/

doc/stringio/each_byte.rdoc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
With a block given, calls the block with each remaining byte in the stream;
2+
positions the stream at end-of-file;
3+
returns +self+:
4+
5+
bytes = []
6+
strio = StringIO.new('hello') # Five 1-byte characters.
7+
strio.each_byte {|byte| bytes.push(byte) }
8+
strio.eof? # => true
9+
bytes # => [104, 101, 108, 108, 111]
10+
bytes = []
11+
strio = StringIO.new('тест') # Four 2-byte characters.
12+
strio.each_byte {|byte| bytes.push(byte) }
13+
bytes # => [209, 130, 208, 181, 209, 129, 209, 130]
14+
bytes = []
15+
strio = StringIO.new('こんにちは') # Five 3-byte characters.
16+
strio.each_byte {|byte| bytes.push(byte) }
17+
bytes # => [227, 129, 147, 227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
18+
19+
The position in the stream matters:
20+
21+
bytes = []
22+
strio = StringIO.new('こんにちは')
23+
strio.getc # => "こ"
24+
strio.pos # => 3 # 3-byte character was read.
25+
strio.each_byte {|byte| bytes.push(byte) }
26+
bytes # => [227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
27+
28+
If at end-of-file, does not call the block:
29+
30+
strio.eof? # => true
31+
strio.each_byte {|byte| fail 'Boo!' }
32+
strio.eof? # => true
33+
34+
With no block given, returns a new {Enumerator}[https://docs.ruby-lang.org/en/master/Enumerator.html].

doc/stringio/each_char.rdoc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
With a block given, calls the block with each remaining character in the stream;
2+
positions the stream at end-of-file;
3+
returns +self+:
4+
5+
chars = []
6+
strio = StringIO.new('hello')
7+
strio.each_char {|char| chars.push(char) }
8+
strio.eof? # => true
9+
chars # => ["h", "e", "l", "l", "o"]
10+
chars = []
11+
strio = StringIO.new('тест')
12+
strio.each_char {|char| chars.push(char) }
13+
chars # => ["т", "е", "с", "т"]
14+
chars = []
15+
strio = StringIO.new('こんにちは')
16+
strio.each_char {|char| chars.push(char) }
17+
chars # => ["こ", "ん", "に", "ち", "は"]
18+
19+
Stream position matters:
20+
21+
chars = []
22+
strio = StringIO.new('こんにちは')
23+
strio.getc # => "こ"
24+
strio.pos # => 3 # 3-byte character was read.
25+
strio.each_char {|char| chars.push(char) }
26+
chars # => ["ん", "に", "ち", "は"]
27+
28+
When at end-of-stream does not call the block:
29+
30+
strio.eof? # => true
31+
strio.each_char {|char| fail 'Boo!' }
32+
strio.eof? # => true
33+
34+
With no block given, returns a new {Enumerator}[https://docs.ruby-lang.org/en/master/Enumerator.html].

doc/stringio/each_codepoint.rdoc

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
With a block given, calls the block with each successive codepoint from self;
2+
sets the position to end-of-stream;
3+
returns +self+.
4+
5+
Each codepoint is the integer value for a character; returns self:
6+
7+
codepoints = []
8+
strio = StringIO.new('hello')
9+
strio.each_codepoint {|codepoint| codepoints.push(codepoint) }
10+
strio.eof? # => true
11+
codepoints # => [104, 101, 108, 108, 111]
12+
codepoints = []
13+
strio = StringIO.new('тест')
14+
strio.each_codepoint {|codepoint| codepoints.push(codepoint) }
15+
codepoints # => [1090, 1077, 1089, 1090]
16+
codepoints = []
17+
strio = StringIO.new('こんにちは')
18+
strio.each_codepoint {|codepoint| codepoints.push(codepoint) }
19+
codepoints # => [12371, 12435, 12395, 12385, 12399]
20+
21+
Position in the stream matters:
22+
23+
codepoints = []
24+
strio = StringIO.new('こんにちは')
25+
strio.getc # => "こ"
26+
strio.pos # => 3
27+
strio.each_codepoint {|codepoint| codepoints.push(codepoint) }
28+
codepoints # => [12435, 12395, 12385, 12399]
29+
30+
When at end-of-stream, the block is not called:
31+
32+
strio.eof? # => true
33+
strio.each_codepoint {|codepoint| fail 'Boo!' }
34+
strio.eof? # => true
35+
36+
With no block given, returns a new {Enumerator}[https://docs.ruby-lang.org/en/master/Enumerator.html].

ext/stringio/stringio.c

Lines changed: 3 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -936,40 +936,7 @@ strio_get_sync(VALUE self)
936936
* call-seq:
937937
* each_byte {|byte| ... } -> self
938938
*
939-
* With a block given, calls the block with each remaining byte in the stream;
940-
* positions the stream at end-of-file;
941-
* returns +self+:
942-
*
943-
* bytes = []
944-
* strio = StringIO.new('hello') # Five 1-byte characters.
945-
* strio.each_byte {|byte| bytes.push(byte) }
946-
* strio.eof? # => true
947-
* bytes # => [104, 101, 108, 108, 111]
948-
* bytes = []
949-
* strio = StringIO.new('тест') # Four 2-byte characters.
950-
* strio.each_byte {|byte| bytes.push(byte) }
951-
* bytes # => [209, 130, 208, 181, 209, 129, 209, 130]
952-
* bytes = []
953-
* strio = StringIO.new('こんにちは') # Five 3-byte characters.
954-
* strio.each_byte {|byte| bytes.push(byte) }
955-
* bytes # => [227, 129, 147, 227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
956-
*
957-
* The position in the stream matters:
958-
*
959-
* bytes = []
960-
* strio = StringIO.new('こんにちは')
961-
* strio.getc # => "こ"
962-
* strio.pos # => 3 # 3-byte character was read.
963-
* strio.each_byte {|byte| bytes.push(byte) }
964-
* bytes # => [227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
965-
*
966-
* If at end-of-file, does not call the block:
967-
*
968-
* strio.eof? # => true
969-
* strio.each_byte {|byte| fail 'Boo!' }
970-
* strio.eof? # => true
971-
*
972-
* With no block given, returns a new {Enumerator}[https://docs.ruby-lang.org/en/master/Enumerator.html].
939+
* :include: stringio/each_byte.rdoc
973940
*
974941
* Related: StringIO#each_char, StringIO#each_codepoint, StringIO#each_line.
975942
*/
@@ -1196,40 +1163,7 @@ strio_readbyte(VALUE self)
11961163
* call-seq:
11971164
* each_char {|char| ... } -> self
11981165
*
1199-
* With a block given, calls the block with each remaining character in the stream;
1200-
* positions the stream at end-of-file;
1201-
* returns +self+:
1202-
*
1203-
* chars = []
1204-
* strio = StringIO.new('hello')
1205-
* strio.each_char {|char| chars.push(char) }
1206-
* strio.eof? # => true
1207-
* chars # => ["h", "e", "l", "l", "o"]
1208-
* chars = []
1209-
* strio = StringIO.new('тест')
1210-
* strio.each_char {|char| chars.push(char) }
1211-
* chars # => ["т", "е", "с", "т"]
1212-
* chars = []
1213-
* strio = StringIO.new('こんにちは')
1214-
* strio.each_char {|char| chars.push(char) }
1215-
* chars # => ["こ", "ん", "に", "ち", "は"]
1216-
*
1217-
* Stream position matters:
1218-
*
1219-
* chars = []
1220-
* strio = StringIO.new('こんにちは')
1221-
* strio.getc # => "こ"
1222-
* strio.pos # => 3 # 3-byte character was read.
1223-
* strio.each_char {|char| chars.push(char) }
1224-
* chars # => ["ん", "に", "ち", "は"]
1225-
*
1226-
* When at end-of-stream does not call the block:
1227-
*
1228-
* strio.eof? # => true
1229-
* strio.each_char {|char| fail 'Boo!' }
1230-
* strio.eof? # => true
1231-
*
1232-
* With no block given, returns a new {Enumerator}[https://docs.ruby-lang.org/en/master/Enumerator.html].
1166+
* :include: stringio/each_char.rdoc
12331167
*
12341168
* Related: StringIO#each_byte, StringIO#each_codepoint, StringIO#each_line.
12351169
*/
@@ -1250,42 +1184,7 @@ strio_each_char(VALUE self)
12501184
* call-seq:
12511185
* each_codepoint {|codepoint| ... } -> self
12521186
*
1253-
* With a block given, calls the block with each successive codepoint from self;
1254-
* sets the position to end-of-stream;
1255-
* returns +self+.
1256-
*
1257-
* Each codepoint is the integer value for a character; returns self:
1258-
*
1259-
* codepoints = []
1260-
* strio = StringIO.new('hello')
1261-
* strio.each_codepoint {|codepoint| codepoints.push(codepoint) }
1262-
* strio.eof? # => true
1263-
* codepoints # => [104, 101, 108, 108, 111]
1264-
* codepoints = []
1265-
* strio = StringIO.new('тест')
1266-
* strio.each_codepoint {|codepoint| codepoints.push(codepoint) }
1267-
* codepoints # => [1090, 1077, 1089, 1090]
1268-
* codepoints = []
1269-
* strio = StringIO.new('こんにちは')
1270-
* strio.each_codepoint {|codepoint| codepoints.push(codepoint) }
1271-
* codepoints # => [12371, 12435, 12395, 12385, 12399]
1272-
*
1273-
* Position in the stream matters:
1274-
*
1275-
* codepoints = []
1276-
* strio = StringIO.new('こんにちは')
1277-
* strio.getc # => "こ"
1278-
* strio.pos # => 3
1279-
* strio.each_codepoint {|codepoint| codepoints.push(codepoint) }
1280-
* codepoints # => [12435, 12395, 12385, 12399]
1281-
*
1282-
* When at end-of-stream, the block is not called:
1283-
*
1284-
* strio.eof? # => true
1285-
* strio.each_codepoint {|codepoint| fail 'Boo!' }
1286-
* strio.eof? # => true
1287-
*
1288-
* With no block given, returns a new {Enumerator}[https://docs.ruby-lang.org/en/master/Enumerator.html].
1187+
* :include: stringio/each_codepoint.rdoc
12891188
*
12901189
* Related: StringIO#each_byte, StringIO#each_char, StringIO#each_line.
12911190
*/

0 commit comments

Comments
 (0)