Class Mmap
In: doc/mmap.rb
Parent: Object
Mmap Comparable Enumerable dot/f_0.png

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

[Source]

    # File doc/mmap.rb, line 15
15:       def  lockall(flag)
16:       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)

[Source]

    # File doc/mmap.rb, line 57
57:       def  new(file, mode = "r", protection = Mmap::MAP_SHARED, options = {})
58:       end

reenable paging

[Source]

    # File doc/mmap.rb, line 62
62:       def  unlockall
63:       end

Public Instance methods

comparison

[Source]

     # File doc/mmap.rb, line 126
126:    def  <(other)
127:    end

append other to self

[Source]

     # File doc/mmap.rb, line 141
141:    def  <<(other)
142:    end

comparison

[Source]

     # File doc/mmap.rb, line 131
131:    def  <=(other)
132:    end

comparison

[Source]

     # File doc/mmap.rb, line 111
111:    def  ==(other) 
112:    end

used for case comparison

[Source]

     # File doc/mmap.rb, line 136
136:    def  ===(other)
137:    end

return an index of the match

[Source]

     # File doc/mmap.rb, line 146
146:    def  =~(other)
147:    end

comparison

[Source]

     # File doc/mmap.rb, line 116
116:    def  >(other)
117:    end

comparison

[Source]

     # File doc/mmap.rb, line 121
121:    def  >=(other)
122:    end

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

[Source]

     # File doc/mmap.rb, line 163
163:    def  [](args)
164:    end

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.

[Source]

     # File doc/mmap.rb, line 181
181:    def  []=(args) 
182:    end

change the first character to uppercase letter

[Source]

     # File doc/mmap.rb, line 200
200:    def  capitalize!
201:    end

only with ruby >= 1.7.1

[Source]

     # File doc/mmap.rb, line 190
190:    def  casecmp(other)
191:    end

chop off the line ending character, specified by rs

[Source]

     # File doc/mmap.rb, line 210
210:    def  chomp!(rs = $/) 
211:    end

chop off the last character

[Source]

     # File doc/mmap.rb, line 205
205:    def  chop! 
206:    end

append the contents of other

[Source]

     # File doc/mmap.rb, line 195
195:    def  concat(other) 
196:    end

each parameter defines a set of character to count

[Source]

     # File doc/mmap.rb, line 215
215:    def  count(o1 [, o2, ...])
216:    end

crypt with salt

[Source]

     # File doc/mmap.rb, line 220
220:    def  crypt(salt)
221:    end

delete every characters included in str

[Source]

     # File doc/mmap.rb, line 225
225:    def  delete!(str) 
226:    end

change all uppercase character to lowercase character

[Source]

     # File doc/mmap.rb, line 230
230:    def  downcase! 
231:    end

iterate on each line

[Source]

     # File doc/mmap.rb, line 241
241:    def  each(rs = $/)  
242:       yield line
243:    end

iterate on each byte

[Source]

     # File doc/mmap.rb, line 235
235:    def  each_byte  
236:       yield char
237:    end

same than each

[Source]

     # File doc/mmap.rb, line 245
245:    def  each_line(rs = $/)  
246:       yield line
247:    end

return true if the file is empty

[Source]

     # File doc/mmap.rb, line 251
251:    def  empty? 
252:    end

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

[Source]

    # File doc/mmap.rb, line 68
68:    def  extend(count)
69:    end

same than msync

[Source]

    # File doc/mmap.rb, line 93
93:    def  flush
94:    end

freeze the current file

[Source]

     # File doc/mmap.rb, line 256
256:    def  freeze
257:    end

return true if the file is frozen

[Source]

     # File doc/mmap.rb, line 261
261:    def  frozen 
262:    end

global substitution

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

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

[Source]

     # File doc/mmap.rb, line 270
270:    def  gsub!(pattern, replacement = nil)
271:    end

return true if other is found

[Source]

     # File doc/mmap.rb, line 275
275:    def  include?(other) 
276:    end

return the index of substr

[Source]

     # File doc/mmap.rb, line 280
280:    def  index(substr[, pos])
281:    end

insert str at index

[Source]

     # File doc/mmap.rb, line 285
285:    def  insert(index, str) >= 1.7.1
286:    end

return the size of the file

[Source]

     # File doc/mmap.rb, line 290
290:    def  length 
291:    end

removes leading whitespace

[Source]

     # File doc/mmap.rb, line 351
351:    def  lstrip! 
352:    end

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

[Source]

    # File doc/mmap.rb, line 75
75:    def  madvise(advice)
76:    end

convert pattern to a Regexp and then call match on self

[Source]

     # File doc/mmap.rb, line 295
295:    def  match(pattern)
296:    end

disable paging

[Source]

    # File doc/mmap.rb, line 85
85:    def  mlock
86:    end

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

[Source]

    # File doc/mmap.rb, line 80
80:    def  mprotect(mode)
81:    end

flush the file

[Source]

    # File doc/mmap.rb, line 90
90:    def  msync
91:    end

reenable paging

[Source]

    # File doc/mmap.rb, line 98
98:    def  munlock
99:    end

terminate the association

[Source]

     # File doc/mmap.rb, line 102
102:    def  munmap
103:    end

reverse the content of the file

[Source]

     # File doc/mmap.rb, line 300
300:    def  reverse!
301:    end

return the index of the last occurrence of substr

[Source]

     # File doc/mmap.rb, line 305
305:    def  rindex(substr[, pos]) 
306:    end

removes trailing whitespace

[Source]

     # File doc/mmap.rb, line 356
356:    def  rstrip! 
357:    end

return an array of all occurence matched by pattern

[Source]

     # File doc/mmap.rb, line 310
310:    def  scan(pattern)
311:    end

iterate through the file, matching the pattern

[Source]

     # File doc/mmap.rb, line 315
315:    def  scan(pattern)  
316:       yield str
317:    end

comparison : return -1, 0, 1

[Source]

     # File doc/mmap.rb, line 186
186:    def  self <=> other 
187:    end

return the size of the file

[Source]

     # File doc/mmap.rb, line 321
321:    def  size 
322:    end

same than []

[Source]

     # File doc/mmap.rb, line 326
326:    def  slice
327:    end

delete the specified portion of the file

[Source]

     # File doc/mmap.rb, line 331
331:    def  slice!
332:    end

splits into a list of strings and return this array

[Source]

     # File doc/mmap.rb, line 336
336:    def  split([sep[, limit]]) 
337:    end

squeezes sequences of the same characters which is included in str

[Source]

     # File doc/mmap.rb, line 341
341:    def  squeeze!([str]) 
342:    end

removes leading and trailing whitespace

[Source]

     # File doc/mmap.rb, line 346
346:    def  strip! 
347:    end

substitution

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

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

[Source]

     # File doc/mmap.rb, line 366
366:    def  sub!(pattern, replacement = nil)
367:    end

return a checksum

[Source]

     # File doc/mmap.rb, line 371
371:    def  sum(bits = 16) 
372:    end

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

[Source]

     # File doc/mmap.rb, line 376
376:    def  swapcase! 
377:    end

translate the character from search to replace

[Source]

     # File doc/mmap.rb, line 381
381:    def  tr!(search, replace)
382:    end

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

[Source]

     # File doc/mmap.rb, line 387
387:    def  tr_s!(search, replace) 
388:    end

replaces all lowercase characters to downcase characters

[Source]

     # File doc/mmap.rb, line 392
392:    def upcase! 
393:    end

[Validate]