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

WARNING

The variables $’ and $` are not available with gsub! and sub!

Methods

<   <<   <=   ==   ===   =~   >   >=   []   []=   capitalize!   casecmp   chomp!   chop!   concat   count   crypt   delete!   downcase!   each   each_byte   each_line   empty?   extend   flush   freeze   frozen   gsub!   include?   index   insert   length   lockall   lstrip!   madvise   match   mlock   mprotect   msync   munlock   munmap   new   reverse!   rindex   rstrip!   scan   scan   self   size   slice   slice!   split   squeeze!   strip!   sub!   sum   swapcase!   tr!   tr_s!   unlockall   upcase!  

Included Modules

Comparable Enumerable

Public Class methods

disable paging of all pages mapped. flag can be Mmap::MCL_CURRENT or Mmap::MCL_FUTURE

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)

reenable paging

Public Instance methods

comparison

append other to self

comparison

comparison

used for case comparison

return an index of the match

comparison

comparison

Element reference - with the following syntax

self[nth]

retrieve the nth character

self

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.

change the first character to uppercase letter

only with ruby >= 1.7.1

chop off the line ending character, specified by rs

chop off the last character

append the contents of other

each parameter defines a set of character to count

crypt with salt

delete every characters included in str

change all uppercase character to lowercase character

iterate on each line

iterate on each byte

return true if the file is empty

add count bytes to the file (i.e. pre-extend the file)

same than msync

freeze the current file

return true if the file is frozen

global substitution

str.gsub!(pattern, replacement) => str or nil

str.gsub!(pattern) {|match| block } => str or nil

return true if other is found

return the index of substr

insert str at index

return the size of the file

removes leading whitespace

advice can have the value Mmap::MADV_NORMAL, Mmap::MADV_RANDOM, Mmap::MADV_SEQUENTIAL, Mmap::MADV_WILLNEED, Mmap::MADV_DONTNEED

convert pattern to a Regexp and then call match on self

disable paging

change the mode, value must be "r", "w" or "rw"

flush the file

reenable paging

terminate the association

reverse the content of the file

return the index of the last occurrence of substr

removes trailing whitespace

return an array of all occurence matched by pattern

iterate through the file, matching the pattern

comparison : return -1, 0, 1

return the size of the file

same than []

delete the specified portion of the file

splits into a list of strings and return this array

squeezes sequences of the same characters which is included in str

removes leading and trailing whitespace

substitution

str.sub!(pattern, replacement) => str or nil

str.sub!(pattern) {|match| block } => str or nil

return a checksum

replaces all lowercase characters to uppercase characters, and vice-versa

translate the character from search to replace

translate the character from search to replace, then squeeze sequence of the same characters

replaces all lowercase characters to downcase characters

[Validate]