Class | Mmap |
In: |
mmap.rb
|
Parent: | Object |
The Mmap class implement memory-mapped file objects
Most of these methods have the same syntax than the methods of String
create a new Mmap object
Pathname of the file, if nil is given an anonymous map is created Mmanp::MAP_ANON
Mode to open the file, it can be "r", "w", "rw", "a"
specify the nature of the mapping
Creates a mapping that’s shared with all other processes mapping the same areas of the file. The default value is Mmap::MAP_SHARED
Creates a private copy-on-write mapping, so changes to the contents of the mmap object will be private to this process
Hash. If one of the options length or offset is specified it will not possible to modify the size of the mapped file.
length: | maps length bytes from the file |
offset: | the mapping begin at offset |
advice: | the type of the access (see madvise) |
Element reference - with the following syntax
self[nth]
retrieve the nth character
return a substring from start to last
self[start, length]
return a substring of lenght characters from start
Element assignement - with the following syntax
self[nth] = val
change the nth character with val
self = val
change substring from start to last with val
self[start, len] = val
replace length characters from start with val.
global substitution
str.gsub!(pattern, replacement) => str or nil
str.gsub!(pattern) {|match| block } => str or nil
advice can have the value Mmap::MADV_NORMAL, Mmap::MADV_RANDOM, Mmap::MADV_SEQUENTIAL, Mmap::MADV_WILLNEED, Mmap::MADV_DONTNEED
substitution
str.sub!(pattern, replacement) => str or nil
str.sub!(pattern) {|match| block } => str or nil