D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
IO
/
Buffer
/
Filename :
for-c.ri
back
Copy
U:RDoc::AnyMethod[iI"for:ETI"IO::Buffer::for;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [ I"NCreates a zero-copy IO::Buffer from the given string's memory. Without a ;TI"Pblock a frozen internal copy of the string is created efficiently and used ;TI"Nas the buffer source. When a block is provided, the buffer is associated ;TI"Mdirectly with the string's internal buffer and updating the buffer will ;TI"update the string.;To:RDoc::Markup::BlankLine o; ; [I"PUntil #free is invoked on the buffer, either explicitly or via the garbage ;TI"Hcollector, the source string will be locked and cannot be modified.;T@o; ; [I"PIf the string is frozen, it will create a read-only buffer which cannot be ;TI"Lmodified. If the string is shared, it may trigger a copy-on-write when ;TI"using the block form.;T@o:RDoc::Markup::Verbatim; [I"string = 'test' ;TI"%buffer = IO::Buffer.for(string) ;TI"buffer.external? #=> true ;TI" ;TI"buffer.get_string(0, 1) ;TI"# => "t" ;TI"string ;TI"# => "best" ;TI" ;TI"buffer.resize(100) ;TI"M# in `resize': Cannot resize external buffer! (IO::Buffer::AccessError) ;TI" ;TI"(IO::Buffer.for(string) do |buffer| ;TI" buffer.set_string("T") ;TI" string ;TI" # => "Test" ;TI"end;T:@format0: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"tIO::Buffer.for(string) -> readonly io_buffer IO::Buffer.for(string) {|io_buffer| ... read/write io_buffer ...} ;T0[ I" (p1);T@/FI"Buffer;TcRDoc::NormalClass00