Similar to IO::Memory
, but optimized for building a single string.
You should never have to deal with this class. Instead, use String.build
.
Moves the write pointer, and the resulting string bytesize, by the given amount.
Chomps the last byte from the string buffer.
Reads at most slice.size bytes from this IO
into slice.
Returns a string representation of this object.
Writes the contents of slice into this IO
.
Writes a single byte into this IO
.
IO
IO
Reference
Reference
Object
Object
Moves the write pointer, and the resulting string bytesize, by the given amount.
Chomps the last byte from the string buffer. If the byte is '\n'
and there's a '\r'
before it, it is also removed.
Reads at most slice.size bytes from this IO
into slice. Returns the number of bytes read, which is 0 if and only if there is no more data to read (so checking for 0 is the way to detect end of file).
io = IO::Memory.new "hello" slice = Bytes.new(4) io.read(slice) # => 4 slice # => Bytes[104, 101, 108, 108] io.read(slice) # => 1 slice # => Bytes[111, 101, 108, 108] io.read(slice) # => 0
Returns a string representation of this object.
Descendants must usually not override this method. Instead, they must override to_s(io)
, which must append to the given IO object.
© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/String/Builder.html