Class: Mmap
- Inherits:
-
Object
- Object
- Mmap
- Includes:
- Comparable, Enumerable
- Defined in:
- lib/mmap.rb,
ext/mmap/mmap.c
Constant Summary collapse
- VERSION =
'0.2.6'
- MS_SYNC =
INT2FIX(MS_SYNC)
- MS_ASYNC =
INT2FIX(MS_ASYNC)
- MS_INVALIDATE =
INT2FIX(MS_INVALIDATE)
- PROT_READ =
INT2FIX(PROT_READ)
- PROT_WRITE =
INT2FIX(PROT_WRITE)
- PROT_EXEC =
INT2FIX(PROT_EXEC)
- PROT_NONE =
INT2FIX(PROT_NONE)
- MAP_SHARED =
INT2FIX(MAP_SHARED)
- MAP_PRIVATE =
INT2FIX(MAP_PRIVATE)
- MADV_NORMAL =
INT2FIX(MADV_NORMAL)
- MADV_RANDOM =
INT2FIX(MADV_RANDOM)
- MADV_SEQUENTIAL =
INT2FIX(MADV_SEQUENTIAL)
- MADV_WILLNEED =
INT2FIX(MADV_WILLNEED)
- MADV_DONTNEED =
INT2FIX(MADV_DONTNEED)
- MAP_DENYWRITE =
INT2FIX(MAP_DENYWRITE)
- MAP_EXECUTABLE =
INT2FIX(MAP_EXECUTABLE)
- MAP_NORESERVE =
INT2FIX(MAP_NORESERVE)
- MAP_LOCKED =
INT2FIX(MAP_LOCKED)
- MAP_GROWSDOWN =
INT2FIX(MAP_GROWSDOWN)
- MAP_ANON =
INT2FIX(MAP_ANON)
- MAP_ANONYMOUS =
INT2FIX(MAP_ANONYMOUS)
- MAP_NOSYNC =
INT2FIX(MAP_NOSYNC)
- MCL_CURRENT =
INT2FIX(MCL_CURRENT)
- MCL_FUTURE =
INT2FIX(MCL_FUTURE)
Class Method Summary collapse
-
.lockall ⇒ Object
call-seq: lockall(flag).
-
.mlockall ⇒ Object
call-seq: lockall(flag).
-
.munlockall ⇒ Object
call-seq: unlockall.
-
.new(file, mode = "r", protection = Mmap::MAP_SHARED, options = {}) ⇒ Object
create a new Mmap object.
-
.unlockall ⇒ Object
call-seq: unlockall.
Instance Method Summary collapse
-
#<< ⇒ Object
call-seq: concat(other).
-
#<=>(other) ⇒ Object
comparison : return -1, 0, 1.
-
#== ⇒ Object
call-seq: ==.
-
#=== ⇒ Object
call-seq: ==.
-
#=~(other) ⇒ Object
return an index of the match.
-
#[] ⇒ Object
call-seq: [](args).
-
#[]=(args) ⇒ Object
Element assignement - with the following syntax.
-
#advise ⇒ Object
call-seq: madvise(advice).
-
#capitalize! ⇒ Object
change the first character to uppercase letter.
-
#casecmp(other) ⇒ Object
only with ruby >= 1.7.1.
-
#chomp!(rs = $/) ⇒ Object
chop off the line ending character, specified by rs.
-
#chop! ⇒ Object
chop off the last character.
-
#clone ⇒ Object
:nodoc:.
-
#concat ⇒ Object
call-seq: concat(other).
-
#count(o1, *args) ⇒ Object
each parameter defines a set of character to count.
-
#crypt ⇒ Object
crypt with salt.
-
#delete!(str) ⇒ Object
delete every characters included in str.
-
#downcase! ⇒ Object
change all uppercase character to lowercase character.
-
#dup ⇒ Object
:nodoc:.
-
#each ⇒ Object
call-seq: each(rs = $/, &block).
-
#each_byte(&block) ⇒ Object
iterate on each byte.
-
#each_line ⇒ Object
call-seq: each(rs = $/, &block).
-
#empty? ⇒ Boolean
return true if the file is empty.
-
#eql?(other) ⇒ Boolean
Is this eql? to
other
?. -
#extend(count) ⇒ Object
add count bytes to the file (i.e. pre-extend the file).
-
#flush ⇒ Object
call-seq: msync.
-
#freeze ⇒ Object
freeze the current file.
-
#gsub! ⇒ Object
global substitution.
-
#hash ⇒ Object
Get the hash value.
-
#include?(other) ⇒ Boolean
return true if other is found.
-
#index ⇒ Object
return the index of substr.
-
#initialize ⇒ Object
constructor
Create a new Mmap object.
-
#insert(index, str) ⇒ Object
insert str at index.
-
#ipc_key ⇒ Object
Get the ipc key.
-
#length ⇒ Object
return the size of the file.
-
#lock ⇒ Object
call-seq: mlock.
-
#lstrip! ⇒ Object
removes leading whitespace.
-
#madvise ⇒ Object
call-seq: madvise(advice).
-
#match(pattern) ⇒ Object
convert pattern to a Regexp and then call match on self.
-
#mlock ⇒ Object
call-seq: mlock.
-
#mprotect ⇒ Object
call-seq: mprotect(mode).
-
#msync ⇒ Object
call-seq: msync.
-
#munlock ⇒ Object
call-seq: unlock.
-
#munmap ⇒ Object
call-seq: munmap.
-
#protect ⇒ Object
call-seq: mprotect(mode).
-
#reverse! ⇒ Object
reverse the content of the file.
-
#rindex(sibstr, pos = nil) ⇒ Object
return the index of the last occurrence of substr.
-
#rstrip! ⇒ Object
removes trailing whitespace.
-
#scan(pattern, &block) ⇒ Object
return an array of all occurence matched by pattern.
-
#semlock ⇒ Object
Create a lock.
-
#size ⇒ Object
return the size of the file.
-
#slice ⇒ Object
call-seq: [](args).
-
#slice!(str) ⇒ Object
delete the specified portion of the file.
-
#split(sep, limit = 0) ⇒ Object
splits into a list of strings and return this array.
-
#squeeze! ⇒ Object
squeeze!(str).
- #strip! ⇒ Object
-
#sub! ⇒ Object
substitution.
-
#sum(bits = 16) ⇒ Object
return a checksum.
-
#swapcase! ⇒ Object
replaces all lowercase characters to uppercase characters, and vice-versa.
-
#sync ⇒ Object
call-seq: msync.
-
#to_str ⇒ Object
Convert object to a string.
-
#tr!(search, replace) ⇒ Object
translate the character from search to replace.
-
#tr_s!(search, replace) ⇒ Object
translate the character from search to replace, then squeeze sequence of the same characters.
-
#unlock ⇒ Object
call-seq: unlock.
-
#unmap ⇒ Object
call-seq: munmap.
-
#upcase! ⇒ Object
replaces all lowercase characters to downcase characters.
Constructor Details
#initialize ⇒ Object
Create a new Mmap object
663 664 665 |
# File 'ext/mmap/mmap.c', line 663 static VALUE mm_init(argc, argv, obj) VALUE obj, *argv; |
Class Method Details
.lockall ⇒ Object
call-seq:
lockall(flag)
disable paging of all pages mapped. flag can be Mmap::MCL_CURRENT or Mmap::MCL_FUTURE
2397 2398 2399 |
# File 'ext/mmap/mmap.c', line 2397 static VALUE mm_mlockall(obj, flag) VALUE obj, flag; |
.mlockall ⇒ Object
call-seq:
lockall(flag)
disable paging of all pages mapped. flag can be Mmap::MCL_CURRENT or Mmap::MCL_FUTURE
2397 2398 2399 |
# File 'ext/mmap/mmap.c', line 2397 static VALUE mm_mlockall(obj, flag) VALUE obj, flag; |
.munlockall ⇒ Object
call-seq: unlockall
reenable paging
2415 2416 2417 |
# File 'ext/mmap/mmap.c', line 2415 static VALUE mm_munlockall(obj) VALUE obj; |
.new(file, mode = "r", protection = Mmap::MAP_SHARED, options = {}) ⇒ Object
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)
634 635 636 |
# File 'ext/mmap/mmap.c', line 634 static VALUE mm_s_new(argc, argv, obj) int argc; |
.unlockall ⇒ Object
call-seq: unlockall
reenable paging
2415 2416 2417 |
# File 'ext/mmap/mmap.c', line 2415 static VALUE mm_munlockall(obj) VALUE obj; |
Instance Method Details
#<< ⇒ Object
call-seq: concat(other)
append the contents of other
1661 1662 1663 |
# File 'ext/mmap/mmap.c', line 1661 static VALUE mm_concat(str1, str2) VALUE str1, str2; |
#<=>(other) ⇒ Object
comparison : return -1, 0, 1
1817 1818 1819 |
# File 'ext/mmap/mmap.c', line 1817 static VALUE mm_cmp(a, b) VALUE a, b; |
#== ⇒ Object
call-seq: ==
comparison
1864 1865 1866 |
# File 'ext/mmap/mmap.c', line 1864 static VALUE mm_equal(a, b) VALUE a, b; |
#=== ⇒ Object
call-seq: ==
comparison
1864 1865 1866 |
# File 'ext/mmap/mmap.c', line 1864 static VALUE mm_equal(a, b) VALUE a, b; |
#=~(other) ⇒ Object
return an index of the match
1120 1121 1122 |
# File 'ext/mmap/mmap.c', line 1120 static VALUE mm_match(x, y) VALUE x, y; |
#[] ⇒ Object
call-seq: [](args)
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
2267 2268 2269 |
# File 'ext/mmap/mmap.c', line 2267 static VALUE mm_aref_m(argc, argv, obj) int argc; |
#[]=(args) ⇒ Object
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.
1524 1525 1526 |
# File 'ext/mmap/mmap.c', line 1524 static VALUE mm_aset_m(argc, argv, str) int argc; |
#advise ⇒ Object
call-seq: madvise(advice)
advice can have the value Mmap::MADV_NORMAL, Mmap::MADV_RANDOM, Mmap::MADV_SEQUENTIAL, Mmap::MADV_WILLNEED, Mmap::MADV_DONTNEED
1032 1033 1034 |
# File 'ext/mmap/mmap.c', line 1032 static VALUE mm_madvise(obj, a) VALUE obj, a; |
#capitalize! ⇒ Object
change the first character to uppercase letter
2084 2085 2086 |
# File 'ext/mmap/mmap.c', line 2084 static VALUE mm_capitalize_bang(a) VALUE a; |
#casecmp(other) ⇒ Object
only with ruby >= 1.7.1
1839 1840 1841 |
# File 'ext/mmap/mmap.c', line 1839 static VALUE mm_casecmp(a, b) VALUE a, b; |
#chomp!(rs = $/) ⇒ Object
chop off the line ending character, specified by rs
2132 2133 2134 |
# File 'ext/mmap/mmap.c', line 2132 static VALUE mm_chomp_bang(argc, argv, obj) int argc; |
#chop! ⇒ Object
chop off the last character
2120 2121 2122 |
# File 'ext/mmap/mmap.c', line 2120 static VALUE mm_chop_bang(a) VALUE a; |
#clone ⇒ Object
:nodoc:
15 16 17 |
# File 'lib/mmap.rb', line 15 def clone # :nodoc: raise TypeError, "can't clone instance of #{self.class}" end |
#concat ⇒ Object
call-seq: concat(other)
append the contents of other
1661 1662 1663 |
# File 'ext/mmap/mmap.c', line 1661 static VALUE mm_concat(str1, str2) VALUE str1, str2; |
#count(o1, *args) ⇒ Object
each parameter defines a set of character to count
2306 2307 2308 |
# File 'ext/mmap/mmap.c', line 2306 static VALUE mm_count(argc, argv, obj) int argc; |
#crypt ⇒ Object
crypt with salt
2202 2203 2204 |
# File 'ext/mmap/mmap.c', line 2202 static VALUE mm_crypt(a, b) VALUE a, b; |
#delete!(str) ⇒ Object
delete every characters included in str
2145 2146 2147 |
# File 'ext/mmap/mmap.c', line 2145 static VALUE mm_delete_bang(argc, argv, obj) int argc; |
#downcase! ⇒ Object
change all uppercase character to lowercase character
2072 2073 2074 |
# File 'ext/mmap/mmap.c', line 2072 static VALUE mm_downcase_bang(a) VALUE a; |
#dup ⇒ Object
:nodoc:
19 20 21 |
# File 'lib/mmap.rb', line 19 def dup # :nodoc: raise TypeError, "can't dup instance of #{self.class}" end |
#each ⇒ Object
call-seq:
each(rs = $/, &block)
iterate on each line
2352 2353 2354 |
# File 'ext/mmap/mmap.c', line 2352 static VALUE mm_each_line(argc, argv, obj) int argc; |
#each_byte(&block) ⇒ Object
iterate on each byte
2372 2373 2374 |
# File 'ext/mmap/mmap.c', line 2372 static VALUE mm_each_byte(argc, argv, obj) int argc; |
#each_line ⇒ Object
call-seq:
each(rs = $/, &block)
iterate on each line
2352 2353 2354 |
# File 'ext/mmap/mmap.c', line 2352 static VALUE mm_each_line(argc, argv, obj) int argc; |
#empty? ⇒ Boolean
return true if the file is empty
1954 1955 1956 |
# File 'ext/mmap/mmap.c', line 1954 static VALUE mm_empty(a) VALUE a; |
#eql?(other) ⇒ Boolean
Is this eql? to other
?
1892 1893 1894 |
# File 'ext/mmap/mmap.c', line 1892 static VALUE mm_eql(a, b) VALUE a, b; |
#extend(count) ⇒ Object
add count bytes to the file (i.e. pre-extend the file)
489 490 491 |
# File 'ext/mmap/mmap.c', line 489 static VALUE mm_extend(obj, a) VALUE obj, a; |
#flush ⇒ Object
call-seq: msync
flush the file
946 947 948 |
# File 'ext/mmap/mmap.c', line 946 static VALUE mm_msync(argc, argv, obj) int argc; |
#freeze ⇒ Object
freeze the current file
321 322 323 |
# File 'ext/mmap/mmap.c', line 321 static VALUE mm_freeze(obj) VALUE obj; |
#gsub!(pattern, replacement) ⇒ String? #gsub!(pattern) {|match| ... } ⇒ String?
global substitution
1378 1379 1380 |
# File 'ext/mmap/mmap.c', line 1378 static VALUE mm_gsub_bang(argc, argv, obj) int argc; |
#hash ⇒ Object
Get the hash value
1920 1921 1922 |
# File 'ext/mmap/mmap.c', line 1920 static VALUE mm_hash(a) VALUE a; |
#include?(other) ⇒ Boolean
return true if other is found
2214 2215 2216 |
# File 'ext/mmap/mmap.c', line 2214 static VALUE mm_include(a, b) VALUE a, b; |
#index ⇒ Object
return the index of substr
2226 2227 2228 |
# File 'ext/mmap/mmap.c', line 2226 static VALUE mm_index(argc, argv, obj) int argc; |
#insert(index, str) ⇒ Object
insert str at index
1562 1563 1564 |
# File 'ext/mmap/mmap.c', line 1562 static VALUE mm_insert(str, idx, str2) VALUE str, idx, str2; |
#ipc_key ⇒ Object
Get the ipc key
272 273 274 |
# File 'ext/mmap/mmap.c', line 272 static VALUE mm_ipc_key(obj) VALUE obj; |
#length ⇒ Object
return the size of the file
1939 1940 1941 |
# File 'ext/mmap/mmap.c', line 1939 static VALUE mm_size(a) VALUE a; |
#lock ⇒ Object
call-seq: mlock
disable paging
2433 2434 2435 |
# File 'ext/mmap/mmap.c', line 2433 static VALUE mm_mlock(obj) VALUE obj; |
#lstrip! ⇒ Object
removes leading whitespace
1725 1726 1727 |
# File 'ext/mmap/mmap.c', line 1725 static VALUE mm_lstrip_bang(str) VALUE str; |
#madvise ⇒ Object
call-seq: madvise(advice)
advice can have the value Mmap::MADV_NORMAL, Mmap::MADV_RANDOM, Mmap::MADV_SEQUENTIAL, Mmap::MADV_WILLNEED, Mmap::MADV_DONTNEED
1032 1033 1034 |
# File 'ext/mmap/mmap.c', line 1032 static VALUE mm_madvise(obj, a) VALUE obj, a; |
#match(pattern) ⇒ Object
convert pattern to a Regexp and then call match on self
2046 2047 2048 |
# File 'ext/mmap/mmap.c', line 2046 static VALUE mm_match_m(a, b) VALUE a, b; |
#mlock ⇒ Object
call-seq: mlock
disable paging
2433 2434 2435 |
# File 'ext/mmap/mmap.c', line 2433 static VALUE mm_mlock(obj) VALUE obj; |
#mprotect ⇒ Object
call-seq: mprotect(mode)
change the mode, value must be “r”, “w” or “rw”
977 978 979 |
# File 'ext/mmap/mmap.c', line 977 static VALUE mm_mprotect(obj, a) VALUE obj, a; |
#msync ⇒ Object
call-seq: msync
flush the file
946 947 948 |
# File 'ext/mmap/mmap.c', line 946 static VALUE mm_msync(argc, argv, obj) int argc; |
#munlock ⇒ Object
call-seq: unlock
reenable paging
2461 2462 2463 |
# File 'ext/mmap/mmap.c', line 2461 static VALUE mm_munlock(obj) VALUE obj; |
#munmap ⇒ Object
call-seq: munmap
terminate the association
293 294 295 |
# File 'ext/mmap/mmap.c', line 293 static VALUE mm_unmap(obj) VALUE obj; |
#protect ⇒ Object
call-seq: mprotect(mode)
change the mode, value must be “r”, “w” or “rw”
977 978 979 |
# File 'ext/mmap/mmap.c', line 977 static VALUE mm_mprotect(obj, a) VALUE obj, a; |
#reverse! ⇒ Object
reverse the content of the file
2108 2109 2110 |
# File 'ext/mmap/mmap.c', line 2108 static VALUE mm_reverse_bang(a) VALUE a; |
#rindex(sibstr, pos = nil) ⇒ Object
return the index of the last occurrence of substr
2239 2240 2241 |
# File 'ext/mmap/mmap.c', line 2239 static VALUE mm_rindex(argc, argv, obj) int argc; |
#rstrip! ⇒ Object
removes trailing whitespace
1758 1759 1760 |
# File 'ext/mmap/mmap.c', line 1758 static VALUE mm_rstrip_bang(str) VALUE str; |
#scan(pattern, &block) ⇒ Object
return an array of all occurence matched by pattern
2326 2327 2328 |
# File 'ext/mmap/mmap.c', line 2326 static VALUE mm_scan(obj, a) VALUE obj, a; |
#semlock ⇒ Object
Create a lock
240 241 242 |
# File 'ext/mmap/mmap.c', line 240 static VALUE mm_semlock(argc, argv, obj) int argc; |
#size ⇒ Object
return the size of the file
1939 1940 1941 |
# File 'ext/mmap/mmap.c', line 1939 static VALUE mm_size(a) VALUE a; |
#slice ⇒ Object
call-seq: [](args)
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
2267 2268 2269 |
# File 'ext/mmap/mmap.c', line 2267 static VALUE mm_aref_m(argc, argv, obj) int argc; |
#slice!(str) ⇒ Object
delete the specified portion of the file
1589 1590 1591 |
# File 'ext/mmap/mmap.c', line 1589 static VALUE mm_slice_bang(argc, argv, str) int argc; |
#split(sep, limit = 0) ⇒ Object
splits into a list of strings and return this array
2293 2294 2295 |
# File 'ext/mmap/mmap.c', line 2293 static VALUE mm_split(argc, argv, obj) int argc; |
#squeeze! ⇒ Object
squeeze!(str)
squeezes sequences of the same characters which is included in str
2158 2159 2160 |
# File 'ext/mmap/mmap.c', line 2158 static VALUE mm_squeeze_bang(argc, argv, obj) int argc; |
#strip! ⇒ Object
1786 1787 1788 |
# File 'ext/mmap/mmap.c', line 1786 static VALUE mm_strip_bang(str) VALUE str; |
#sub!(pattern, replacement) ⇒ String? #sub!(pattern) {|match| ... } ⇒ String?
substitution
1265 1266 1267 |
# File 'ext/mmap/mmap.c', line 1265 static VALUE mm_sub_bang(argc, argv, obj) int argc; |
#sum(bits = 16) ⇒ Object
return a checksum
2280 2281 2282 |
# File 'ext/mmap/mmap.c', line 2280 static VALUE mm_sum(argc, argv, obj) int argc; |
#swapcase! ⇒ Object
replaces all lowercase characters to uppercase characters, and vice-versa
2096 2097 2098 |
# File 'ext/mmap/mmap.c', line 2096 static VALUE mm_swapcase_bang(a) VALUE a; |
#sync ⇒ Object
call-seq: msync
flush the file
946 947 948 |
# File 'ext/mmap/mmap.c', line 946 static VALUE mm_msync(argc, argv, obj) int argc; |
#to_str ⇒ Object
Convert object to a string
381 382 383 |
# File 'ext/mmap/mmap.c', line 381 static VALUE mm_to_str(obj) VALUE obj; |
#tr!(search, replace) ⇒ Object
translate the character from search to replace
2171 2172 2173 |
# File 'ext/mmap/mmap.c', line 2171 static VALUE mm_tr_bang(obj, a, b) VALUE obj, a, b; |
#tr_s!(search, replace) ⇒ Object
translate the character from search to replace, then squeeze sequence of the same characters
2187 2188 2189 |
# File 'ext/mmap/mmap.c', line 2187 static VALUE mm_tr_s_bang(obj, a, b) VALUE obj, a, b; |
#unlock ⇒ Object
call-seq: unlock
reenable paging
2461 2462 2463 |
# File 'ext/mmap/mmap.c', line 2461 static VALUE mm_munlock(obj) VALUE obj; |
#unmap ⇒ Object
call-seq: munmap
terminate the association
293 294 295 |
# File 'ext/mmap/mmap.c', line 293 static VALUE mm_unmap(obj) VALUE obj; |
#upcase! ⇒ Object
replaces all lowercase characters to downcase characters
2060 2061 2062 |
# File 'ext/mmap/mmap.c', line 2060 static VALUE mm_upcase_bang(a) VALUE a; |