D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
IO
/
Buffer
/
Filename :
slice-i.ri
back
Copy
U:RDoc::AnyMethod[iI" slice:ETI"IO::Buffer#slice;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"PProduce another IO::Buffer which is a slice (or view into) the current one ;TI"=starting at +offset+ bytes and going for +length+ bytes.;To:RDoc::Markup::BlankLine o; ; [I"NThe slicing happens without copying of memory, and the slice keeps being ;TI"Lassociated with the original buffer's source (string, or file), if any.;T@o; ; [I"PIf the offset is not given, it will be zero. If the offset is negative, it ;TI"!will raise an ArgumentError.;T@o; ; [I"KIf the length is not given, the slice will be as long as the original ;TI"Qbuffer minus the specified offset. If the length is negative, it will raise ;TI"an ArgumentError.;T@o; ; [I"MRaises RuntimeError if the <tt>offset+length</tt> is out of the current ;TI"buffer's bounds.;T@o:RDoc::Markup::Verbatim; [#I"string = 'test' ;TI")buffer = IO::Buffer.for(string).dup ;TI" ;TI"slice = buffer.slice ;TI" # => ;TI"0# #<IO::Buffer 0x0000000108338e68+4 SLICE> ;TI"H# 0x00000000 74 65 73 74 test ;TI" ;TI"buffer.slice(2) ;TI" # => ;TI"0# #<IO::Buffer 0x0000000108338e6a+2 SLICE> ;TI"F# 0x00000000 73 74 st ;TI" ;TI" slice = buffer.slice(1, 2) ;TI" # => ;TI"0# #<IO::Buffer 0x00007fc3d34ebc49+2 SLICE> ;TI"F# 0x00000000 65 73 es ;TI" ;TI"-# Put "o" into 0s position of the slice ;TI"slice.set_string('o', 0) ;TI"slice ;TI" # => ;TI"0# #<IO::Buffer 0x00007fc3d34ebc49+2 SLICE> ;TI"F# 0x00000000 6f 73 os ;TI" ;TI"?# it is also visible at position 1 of the original buffer ;TI"buffer ;TI" # => ;TI"3# #<IO::Buffer 0x00007fc3d31e2d80+4 INTERNAL> ;TI"G# 0x00000000 74 6f 73 74 tost;T:@format0: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I",slice([offset, [length]]) -> io_buffer ;T0[ I"(*args);T@AFI"Buffer;TcRDoc::NormalClass00