# The Mmap class implement memory-mapped file objects # # Most of these methods have the same syntax than the methods of String # # === WARNING # === The variables $' and $` are not available with gsub! and sub! class Mmap include Comparable include Enumerable class << self #disable paging of all pages mapped. flag can be #Mmap::MCL_CURRENT or Mmap::MCL_FUTURE # def lockall(flag) end #create a new Mmap object # #* file # # Pathname of the file, if nil is given an anonymous map # is created Mmanp::MAP_ANON # #* mode # # Mode to open the file, it can be "r", "w", "rw", "a" # #* protection # # specify the nature of the mapping # # * Mmap::MAP_SHARED # # Creates a mapping that's shared with all other processes # mapping the same areas of the file. # The default value is Mmap::MAP_SHARED # # * Mmap::MAP_PRIVATE # # Creates a private copy-on-write mapping, so changes to the # contents of the mmap object will be private to this process # #* options # # 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) # # def new(file, mode = "r", protection = Mmap::MAP_SHARED, options = {}) end #reenable paging # def unlockall end end #add count bytes to the file (i.e. pre-extend the file) # def extend(count) end #advice can have the value Mmap::MADV_NORMAL, #Mmap::MADV_RANDOM, Mmap::MADV_SEQUENTIAL, #Mmap::MADV_WILLNEED, Mmap::MADV_DONTNEED # def madvise(advice) end #change the mode, value must be "r", "w" or "rw" # def mprotect(mode) end #disable paging # def mlock end #flush the file # def msync end #same than msync def flush end #reenable paging # def munlock end #terminate the association def munmap end # #=== Other methods with the same syntax than for the class String # # #comparison # def ==(other) end #comparison # def >(other) end #comparison # def >=(other) end #comparison # def <(other) end #comparison # def <=(other) end #used for case comparison # def ===(other) end #append other to self # def <<(other) end #return an index of the match # def =~(other) end #Element reference - with the following syntax # #self[nth] # #retrieve the nth character # #self[start..last] # #return a substring from start to last # #self[start, length] # #return a substring of lenght characters from start # def [](args) end # Element assignement - with the following syntax # # self[nth] = val # # change the nth character with val # # self[start..last] = val # # change substring from start to last with val # # self[start, len] = val # # replace length characters from start with val. # def []=(args) end #comparison : return -1, 0, 1 # def self <=> other end # only with ruby >= 1.7.1 def casecmp(other) end #append the contents of other # def concat(other) end #change the first character to uppercase letter # def capitalize! end #chop off the last character # def chop! end #chop off the line ending character, specified by rs # def chomp!(rs = $/) end #each parameter defines a set of character to count # def count(o1 [, o2, ...]) end #crypt with salt # def crypt(salt) end #delete every characters included in str # def delete!(str) end #change all uppercase character to lowercase character # def downcase! end #iterate on each byte # def each_byte yield char end #iterate on each line # def each(rs = $/) yield line end #same than each def each_line(rs = $/) yield line end #return true if the file is empty # def empty? end #freeze the current file # def freeze end #return true if the file is frozen # def frozen end #global substitution # #str.gsub!(pattern, replacement) => str or nil # #str.gsub!(pattern) {|match| block } => str or nil # def gsub!(pattern, replacement = nil) end #return true if other is found # def include?(other) end #return the index of substr # def index(substr[, pos]) end #insert str at index # def insert(index, str) >= 1.7.1 end #return the size of the file # def length end #convert pattern to a Regexp and then call #match on self def match(pattern) end #reverse the content of the file # def reverse! end #return the index of the last occurrence of substr # def rindex(substr[, pos]) end #return an array of all occurence matched by pattern # def scan(pattern) end #iterate through the file, matching the pattern # def scan(pattern) yield str end #return the size of the file # def size end #same than [] # def slice end #delete the specified portion of the file # def slice! end #splits into a list of strings and return this array # def split([sep[, limit]]) end #squeezes sequences of the same characters which is included in str # def squeeze!([str]) end #removes leading and trailing whitespace # def strip! end #removes leading whitespace # def lstrip! end #removes trailing whitespace # def rstrip! end #substitution # #str.sub!(pattern, replacement) => str or nil # #str.sub!(pattern) {|match| block } => str or nil # # def sub!(pattern, replacement = nil) end #return a checksum # def sum(bits = 16) end #replaces all lowercase characters to uppercase characters, and vice-versa # def swapcase! end #translate the character from search to replace # def tr!(search, replace) end #translate the character from search to replace, then #squeeze sequence of the same characters # def tr_s!(search, replace) end #replaces all lowercase characters to downcase characters # def upcase! end end