This is a Ruby tree! It shows every object from the Ruby Programming Language in a tree format.
# IO::Buffer.copy (from ruby core) ### Implementation from Buffer --- copy(source, [offset, [length, [source_offset]]]) -> size --- Efficiently copy data from a source IO::Buffer into the buffer, at `offset` using `memcpy`. For copying String instances, see #set_string. buffer = IO::Buffer.new(32) # => # #<IO::Buffer 0x0000555f5ca22520+32 INTERNAL> # 0x00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ # 0x00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ * buffer.copy(IO::Buffer.for("test"), 8) # => 4 -- size of data copied buffer # => # #<IO::Buffer 0x0000555f5cf8fe40+32 INTERNAL> # 0x00000000 00 00 00 00 00 00 00 00 74 65 73 74 00 00 00 00 ........test.... # 0x00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ * #copy can be used to put data into strings associated with buffer: string= "data: " # => "data: " buffer = IO::Buffer.for(str) buffer.copy(IO::Buffer.for("test"), 5) # => 4 string # => "data:test" Attempt to copy into a read-only buffer will fail: File.write('test.txt', 'test') buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY) buffer.copy(IO::Buffer.for("test"), 8) # in `copy': Buffer is not writable! (IO::Buffer::AccessError) See ::map for details of creation of mutable file mappings, this will work: buffer = IO::Buffer.map(File.open('test.txt', 'r+')) buffer.copy("boom", 0) # => 4 File.read('test.txt') # => "boom" Attempt to copy the data which will need place outside of buffer's bounds will fail: buffer = IO::Buffer.new(2) buffer.copy('test', 0) # in `copy': Specified offset+length exceeds source size! (ArgumentError)
This is MURDOC! A Ruby documentation browser inspired by Smalltalk-80. It allows you to learn about Ruby by browsing through its class hierarchies, and see any of its methods.