Skip to content

Commit 3b1f8d1

Browse files
Fix fenced code blocks.
1 parent 45eaeb1 commit 3b1f8d1

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

doc/stringio/each_line.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Output:
3030
With only string argument `sep` given,
3131
reads lines using that string as the record separator:
3232

33-
```
33+
```ruby
3434
strio = StringIO.new(TEXT)
3535
strio.each_line(' ') {|line| p line }
3636
```
@@ -51,7 +51,7 @@ With only integer argument `limit` given,
5151
reads lines using the default record separator;
5252
also limits the size (in characters) of each line to the given limit:
5353

54-
```
54+
```ruby
5555
strio = StringIO.new(TEXT)
5656
strio.each_line(10) {|line| p line }
5757
```
@@ -69,12 +69,13 @@ Output:
6969
"Fifth line"
7070
"\n"
7171
```
72+
7273
**Arguments `sep` and `limit`**
7374

7475
With arguments `sep` and `limit` both given,
7576
honors both:
7677

77-
```
78+
```ruby
7879
strio = StringIO.new(TEXT)
7980
strio.each_line(' ', 10) {|line| p line }
8081
```
@@ -99,7 +100,7 @@ As stated above, method `each` _remaining_ line in the stream.
99100
In the examples above each `strio` object starts with its position at beginning-of-stream;
100101
but in other cases the position may be anywhere (see StringIO#pos):
101102

102-
```
103+
```ruby
103104
strio = StringIO.new(TEXT)
104105
strio.pos = 30 # Set stream position to character 30.
105106
strio.each_line {|line| p line }
@@ -128,6 +129,7 @@ strio.each_line {|line| p line }
128129

129130
Output:
130131

132+
```
131133
"んにちは"
132134
"\x82\x93にちは"
133135
"\x93にちは"
@@ -138,7 +140,7 @@ Output:
138140
Like some methods in class `IO`, StringIO.each honors two special record separators;
139141
see {Special Line Separators}[https://docs.ruby-lang.org/en/master/IO.html#class-IO-label-Special+Line+Separator+Values].
140142

141-
```
143+
```ruby
142144
strio = StringIO.new(TEXT)
143145
strio.each_line('') {|line| p line } # Read as paragraphs (separated by blank lines).
144146
```
@@ -150,7 +152,7 @@ Output:
150152
"Fourth line\nFifth line\n"
151153
```
152154

153-
```
155+
```ruby
154156
strio = StringIO.new(TEXT)
155157
strio.each_line(nil) {|line| p line } # "Slurp"; read it all.
156158
```
@@ -166,7 +168,7 @@ Output:
166168
With keyword argument `chomp` given as `true` (the default is `false`),
167169
removes trailing newline (if any) from each line:
168170

169-
```
171+
```ruby
170172
strio = StringIO.new(TEXT)
171173
strio.each_line(chomp: true) {|line| p line }
172174
```
@@ -183,4 +185,5 @@ Output:
183185

184186
With no block given, returns a new {Enumerator}[https://docs.ruby-lang.org/en/master/Enumerator.html].
185187

188+
186189
Related: StringIO.each_byte, StringIO.each_char, StringIO.each_codepoint.

0 commit comments

Comments
 (0)