@@ -3,8 +3,8 @@ similar in some ways to [class IO][io class].
33
44You can create a \StringIO instance using:
55
6- - StringIO.new(string) : returns a new \StringIO object containing the given string.
7- - StringIO.open(string) : passes a new \StringIO object to the given block.
6+ - StringIO.new: returns a new \StringIO object containing the given string.
7+ - StringIO.open: passes a new \StringIO object to the given block.
88
99Like an \IO stream, a \StringIO stream has certain properties:
1010
@@ -310,7 +310,8 @@ strio = StringIO.new('foo', 'rt')
310310strio.external_encoding # => #<Encoding:UTF-8>
311311data = " \u 9990\u 9991\u 9992\u 9993\u 9994"
312312strio = StringIO .new (data, ' rb' )
313- strio.external_encoding # => #<Encoding:BINARY (ASCII-8BIT)>```
313+ strio.external_encoding # => #<Encoding:BINARY (ASCII-8BIT)>
314+ ```
314315
315316When the data mode is specified, the read/write mode may not be omitted:
316317
@@ -360,9 +361,9 @@ The initial position of a stream is zero.
360361
361362Each of these methods initializes (to zero) the position of a new or re-opened stream:
362363
363- - ::new (string = ' ' , mode = ' r+ ' ) : returns a new stream.
364- - ::open (string = ' ' , mode = ' r+ ' ) : passes a new stream to the block.
365- - # reopen(string = '', mode = 'r+') : re-initializes the stream.
364+ - ::new : returns a new stream.
365+ - ::open: passes a new stream to the block.
366+ - #reopen: re-initializes the stream.
366367
367368Each of these methods queries, gets, or sets the position, without otherwise changing the stream:
368369
@@ -429,9 +430,9 @@ strio.pos # => 47 ## End-of-stream.
429430Each of these methods begins writing at the current position,
430431and advances the position to the end of the written substring:
431432
432- - # putc(character) : writes a given character.
433+ - #putc: writes the given character.
433434- #write: writes the given objects as strings.
434- - [Kernel # puts][kernel#puts] writes given objects as strings, each followed by newline.
435+ - [ Kernel#puts] [ kernel#puts ] : writes given objects as strings, each followed by newline.
435436
436437Examples:
437438
@@ -456,8 +457,8 @@ strio.pos # => 11
456457Each of these methods writes _ before_ the current position, and decrements the position
457458so that the written data is next to be read:
458459
459- - # ungetbyte(byte) : unshifts the given byte.
460- - # ungetc(character) : unshifts the given character.
460+ - #ungetbyte: unshifts the given byte.
461+ - #ungetc: unshifts the given character.
461462
462463Examples:
463464
@@ -474,7 +475,7 @@ strio.string # => "xxo"
474475
475476This method does not affect the position:
476477
477- - # truncate(size) : truncates the stream's string to the given size.
478+ - #truncate: truncates the stream's string to the given size.
478479
479480Examples:
480481
@@ -545,9 +546,9 @@ see [Read/Write Mode][read/write mode].
545546
546547Each of these methods initializes the read/write mode for a new or re-opened stream:
547548
548- - ::new (string = ' ' , mode = ' r+ ' ) : returns a new stream.
549- - ::open (string = ' ' , mode = ' r+ ' ) : passes a new stream to the block.
550- - # reopen(string = '', mode = 'r+') : re-initializes the stream.
549+ - ::new : returns a new stream.
550+ - ::open: passes a new stream to the block.
551+ - #reopen: re-initializes the stream.
551552
552553Other relevant methods:
553554
@@ -624,29 +625,29 @@ This instance method is useful in a multi-threaded application:
624625
625626You can write to the stream, advancing the position, using these instance methods:
626627
627- - # putc(character) : writes a given character.
628+ - #putc: writes a given character.
628629- #write: writes the given objects as strings.
629630- [ Kernel#puts] [ kernel#puts ] writes given objects as strings, each followed by newline.
630631
631632You can "unshift" to the stream using these instance methods;
632633each writes _ before_ the current position, and decrements the position
633634so that the written data is next to be read.
634635
635- - # ungetbyte(byte) : unshifts the given byte.
636- - # ungetc(character) : unshifts the given character.
636+ - #ungetbyte: unshifts the given byte.
637+ - #ungetc: unshifts the given character.
637638
638639One more writing method:
639640
640- - # truncate(size) : truncates the stream's string to the given size.
641+ - #truncate: truncates the stream's string to the given size.
641642
642643## Line \IO
643644
644645Reading:
645646
646647- #gets: reads and returns the next line.
647- - # each_line: reads each remaining line, passing it to the block
648- - # readlines: reads the remaining data the stream and returns an array of its lines.
649648- [ Kernel#readline] [ kernel#readline ] : like #gets, but raises an exception if at end-of-stream.
649+ - #readlines: reads the remaining data the stream and returns an array of its lines.
650+ - #each_line: reads each remaining line, passing it to the block
650651
651652Writing:
652653
0 commit comments