Class: Mmap
- Inherits:
-
Object
- Object
- Mmap
- Includes:
- Comparable, Enumerable
- Defined in:
- lib/mmap/version.rb,
lib/mmap.rb,
ext/mmap/mmap.c
Overview
Version of mmap2.
Constant Summary collapse
- VERSION =
'2.2.9'
- 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.
-
#[](*args) ⇒ 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.
-
#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(*args) ⇒ 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
rb_define_method(mm_cMap, “gsub!”, mm_gsub_bang, -1);.
-
#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
620 |
# File 'ext/mmap/mmap.c', line 620
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
2177 |
# File 'ext/mmap/mmap.c', line 2177
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
2177 |
# File 'ext/mmap/mmap.c', line 2177
static VALUE mm_mlockall(obj, flag) VALUE obj, flag;
|
.munlockall ⇒ Object
call-seq: unlockall
reenable paging
2193 |
# File 'ext/mmap/mmap.c', line 2193
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)
595 |
# File 'ext/mmap/mmap.c', line 595
static VALUE mm_s_new(argc, argv, obj) int argc;
|
.unlockall ⇒ Object
call-seq: unlockall
reenable paging
2193 |
# File 'ext/mmap/mmap.c', line 2193
static VALUE mm_munlockall(obj) VALUE obj;
|
Instance Method Details
#<< ⇒ Object
call-seq: concat(other)
append the contents of other
1564 |
# File 'ext/mmap/mmap.c', line 1564
static VALUE mm_concat(str1, str2) VALUE str1, str2;
|
#<=>(other) ⇒ Object
comparison : return -1, 0, 1
1706 |
# File 'ext/mmap/mmap.c', line 1706
static VALUE mm_cmp(a, b) VALUE a, b;
|
#== ⇒ Object
call-seq: ==
comparison
1749 |
# File 'ext/mmap/mmap.c', line 1749
static VALUE mm_equal(a, b) VALUE a, b;
|
#=== ⇒ Object
call-seq: ==
comparison
1749 |
# File 'ext/mmap/mmap.c', line 1749
static VALUE mm_equal(a, b) VALUE a, b;
|
#=~(other) ⇒ Object
return an index of the match
1055 |
# File 'ext/mmap/mmap.c', line 1055
static VALUE mm_match(x, y) VALUE x, y;
|
#[](*args) ⇒ 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
2073 2074 2075 |
# File 'ext/mmap/mmap.c', line 2073
static VALUE mm_aref_m(int argc, VALUE *argv, VALUE obj) {
return mm_bang_i(obj, MM_ORIGIN, rb_intern("[]"), argc, argv);
}
|
#[]=(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.
1440 |
# File 'ext/mmap/mmap.c', line 1440
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
973 |
# File 'ext/mmap/mmap.c', line 973
static VALUE mm_madvise(obj, a) VALUE obj, a;
|
#capitalize! ⇒ Object
change the first character to uppercase letter
1929 |
# File 'ext/mmap/mmap.c', line 1929
static VALUE mm_capitalize_bang(a) VALUE a;
|
#casecmp(other) ⇒ Object
only with ruby >= 1.7.1
1726 |
# File 'ext/mmap/mmap.c', line 1726
static VALUE mm_casecmp(a, b) VALUE a, b;
|
#chomp!(rs = $/) ⇒ Object
chop off the line ending character, specified by rs
1961 |
# File 'ext/mmap/mmap.c', line 1961
static VALUE mm_chomp_bang(argc, argv, obj) int argc;
|
#chop! ⇒ Object
chop off the last character
1953 |
# File 'ext/mmap/mmap.c', line 1953
static VALUE mm_chop_bang(a) VALUE a;
|
#clone ⇒ Object
:nodoc:
14 15 16 |
# File 'lib/mmap.rb', line 14 def clone # :nodoc: raise TypeError, "can't clone instance of #{self.class}" end |
#concat ⇒ Object
call-seq: concat(other)
append the contents of other
1564 |
# File 'ext/mmap/mmap.c', line 1564
static VALUE mm_concat(str1, str2) VALUE str1, str2;
|
#count(o1, *args) ⇒ Object
each parameter defines a set of character to count
2100 |
# File 'ext/mmap/mmap.c', line 2100
static VALUE mm_count(argc, argv, obj) int argc;
|
#crypt ⇒ Object
crypt with salt
2024 |
# File 'ext/mmap/mmap.c', line 2024
static VALUE mm_crypt(a, b) VALUE a, b;
|
#delete!(str) ⇒ Object
delete every characters included in str
1973 |
# File 'ext/mmap/mmap.c', line 1973
static VALUE mm_delete_bang(argc, argv, obj) int argc;
|
#downcase! ⇒ Object
change all uppercase character to lowercase character
1921 |
# File 'ext/mmap/mmap.c', line 1921
static VALUE mm_downcase_bang(a) VALUE a;
|
#dup ⇒ Object
:nodoc:
18 19 20 |
# File 'lib/mmap.rb', line 18 def dup # :nodoc: raise TypeError, "can't dup instance of #{self.class}" end |
#each ⇒ Object
call-seq:
each(rs = $/, &block)
iterate on each line
2136 |
# File 'ext/mmap/mmap.c', line 2136
static VALUE mm_each_line(argc, argv, obj) int argc;
|
#each_byte(&block) ⇒ Object
iterate on each byte
2154 |
# File 'ext/mmap/mmap.c', line 2154
static VALUE mm_each_byte(argc, argv, obj) int argc;
|
#each_line ⇒ Object
call-seq:
each(rs = $/, &block)
iterate on each line
2136 |
# File 'ext/mmap/mmap.c', line 2136
static VALUE mm_each_line(argc, argv, obj) int argc;
|
#empty? ⇒ Boolean
return true if the file is empty
1829 |
# File 'ext/mmap/mmap.c', line 1829
static VALUE mm_empty(a) VALUE a;
|
#eql?(other) ⇒ Boolean
Is this eql? to other
?
1774 |
# File 'ext/mmap/mmap.c', line 1774
static VALUE mm_eql(a, b) VALUE a, b;
|
#extend(count) ⇒ Object
add count bytes to the file (i.e. pre-extend the file)
461 |
# File 'ext/mmap/mmap.c', line 461
static VALUE mm_extend(obj, a) VALUE obj, a;
|
#flush ⇒ Object
call-seq: msync
flush the file
890 |
# File 'ext/mmap/mmap.c', line 890
static VALUE mm_msync(argc, argv, obj) int argc;
|
#freeze ⇒ Object
freeze the current file
313 |
# File 'ext/mmap/mmap.c', line 313
static VALUE mm_freeze(obj) VALUE obj;
|
#hash ⇒ Object
Get the hash value
1799 |
# File 'ext/mmap/mmap.c', line 1799
static VALUE mm_hash(a) VALUE a;
|
#include?(other) ⇒ Boolean
return true if other is found
2032 |
# File 'ext/mmap/mmap.c', line 2032
static VALUE mm_include(a, b) VALUE a, b;
|
#index ⇒ Object
return the index of substr
2040 2041 2042 |
# File 'ext/mmap/mmap.c', line 2040
static VALUE mm_index(int argc, VALUE *argv, VALUE obj) {
return mm_bang_i(obj, MM_ORIGIN, rb_intern("index"), argc, argv);
}
|
#insert(index, str) ⇒ Object
insert str at index
1475 |
# File 'ext/mmap/mmap.c', line 1475
static VALUE mm_insert(str, idx, str2) VALUE str, idx, str2;
|
#ipc_key ⇒ Object
Get the ipc key
267 |
# File 'ext/mmap/mmap.c', line 267
static VALUE mm_ipc_key(obj) VALUE obj;
|
#length ⇒ Object
return the size of the file
1816 |
# File 'ext/mmap/mmap.c', line 1816
static VALUE mm_size(a) VALUE a;
|
#lock ⇒ Object
call-seq: mlock
disable paging
2209 |
# File 'ext/mmap/mmap.c', line 2209
static VALUE mm_mlock(obj) VALUE obj;
|
#lstrip! ⇒ Object
removes leading whitespace
1622 |
# File 'ext/mmap/mmap.c', line 1622
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
973 |
# File 'ext/mmap/mmap.c', line 973
static VALUE mm_madvise(obj, a) VALUE obj, a;
|
#match(pattern) ⇒ Object
convert pattern to a Regexp and then call match on self
1903 |
# File 'ext/mmap/mmap.c', line 1903
static VALUE mm_match_m(a, b) VALUE a, b;
|
#mlock ⇒ Object
call-seq: mlock
disable paging
2209 |
# File 'ext/mmap/mmap.c', line 2209
static VALUE mm_mlock(obj) VALUE obj;
|
#mprotect ⇒ Object
call-seq: mprotect(mode)
change the mode, value must be “r”, “w” or “rw”
919 |
# File 'ext/mmap/mmap.c', line 919
static VALUE mm_mprotect(obj, a) VALUE obj, a;
|
#msync ⇒ Object
call-seq: msync
flush the file
890 |
# File 'ext/mmap/mmap.c', line 890
static VALUE mm_msync(argc, argv, obj) int argc;
|
#munlock ⇒ Object
call-seq: unlock
reenable paging
2235 |
# File 'ext/mmap/mmap.c', line 2235
static VALUE mm_munlock(obj) VALUE obj;
|
#munmap ⇒ Object
call-seq: munmap
terminate the association
286 |
# File 'ext/mmap/mmap.c', line 286
static VALUE mm_unmap(obj) VALUE obj;
|
#protect ⇒ Object
call-seq: mprotect(mode)
change the mode, value must be “r”, “w” or “rw”
919 |
# File 'ext/mmap/mmap.c', line 919
static VALUE mm_mprotect(obj, a) VALUE obj, a;
|
#reverse! ⇒ Object
reverse the content of the file
1945 |
# File 'ext/mmap/mmap.c', line 1945
static VALUE mm_reverse_bang(a) VALUE a;
|
#rindex(sibstr, pos = nil) ⇒ Object
return the index of the last occurrence of substr
2049 |
# File 'ext/mmap/mmap.c', line 2049
static VALUE mm_rindex(argc, argv, obj) int argc;
|
#rstrip! ⇒ Object
removes trailing whitespace
1653 |
# File 'ext/mmap/mmap.c', line 1653
static VALUE mm_rstrip_bang(str) VALUE str;
|
#scan(pattern, &block) ⇒ Object
return an array of all occurence matched by pattern
2112 |
# File 'ext/mmap/mmap.c', line 2112
static VALUE mm_scan(obj, a) VALUE obj, a;
|
#semlock ⇒ Object
Create a lock
238 |
# File 'ext/mmap/mmap.c', line 238
static VALUE mm_semlock(argc, argv, obj) int argc;
|
#size ⇒ Object
return the size of the file
1816 |
# File 'ext/mmap/mmap.c', line 1816
static VALUE mm_size(a) VALUE a;
|
#slice(*args) ⇒ 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
2073 2074 2075 |
# File 'ext/mmap/mmap.c', line 2073
static VALUE mm_aref_m(int argc, VALUE *argv, VALUE obj) {
return mm_bang_i(obj, MM_ORIGIN, rb_intern("[]"), argc, argv);
}
|
#slice!(str) ⇒ Object
delete the specified portion of the file
1499 |
# File 'ext/mmap/mmap.c', line 1499
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
2091 |
# File 'ext/mmap/mmap.c', line 2091
static VALUE mm_split(argc, argv, obj) int argc;
|
#squeeze! ⇒ Object
squeeze!(str)
squeezes sequences of the same characters which is included in str
1985 |
# File 'ext/mmap/mmap.c', line 1985
static VALUE mm_squeeze_bang(argc, argv, obj) int argc;
|
#strip! ⇒ Object
rb_define_method(mm_cMap, “gsub!”, mm_gsub_bang, -1);
1679 |
# File 'ext/mmap/mmap.c', line 1679
static VALUE mm_strip_bang(str) VALUE str;
|
#sub!(pattern, replacement) ⇒ String? #sub!(pattern) {|match| ... } ⇒ String?
substitution
1195 |
# File 'ext/mmap/mmap.c', line 1195
static VALUE mm_sub_bang(argc, argv, obj) int argc;
|
#sum(bits = 16) ⇒ Object
return a checksum
2082 |
# File 'ext/mmap/mmap.c', line 2082
static VALUE mm_sum(argc, argv, obj) int argc;
|
#swapcase! ⇒ Object
replaces all lowercase characters to uppercase characters, and vice-versa
1937 |
# File 'ext/mmap/mmap.c', line 1937
static VALUE mm_swapcase_bang(a) VALUE a;
|
#sync ⇒ Object
call-seq: msync
flush the file
890 |
# File 'ext/mmap/mmap.c', line 890
static VALUE mm_msync(argc, argv, obj) int argc;
|
#to_str ⇒ Object
Convert object to a string
362 |
# File 'ext/mmap/mmap.c', line 362
static VALUE mm_to_str(obj) VALUE obj;
|
#tr!(search, replace) ⇒ Object
translate the character from search to replace
1997 |
# File 'ext/mmap/mmap.c', line 1997
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
2011 |
# File 'ext/mmap/mmap.c', line 2011
static VALUE mm_tr_s_bang(obj, a, b) VALUE obj, a, b;
|
#unlock ⇒ Object
call-seq: unlock
reenable paging
2235 |
# File 'ext/mmap/mmap.c', line 2235
static VALUE mm_munlock(obj) VALUE obj;
|
#unmap ⇒ Object
call-seq: munmap
terminate the association
286 |
# File 'ext/mmap/mmap.c', line 286
static VALUE mm_unmap(obj) VALUE obj;
|
#upcase! ⇒ Object
replaces all lowercase characters to downcase characters
1913 |
# File 'ext/mmap/mmap.c', line 1913
static VALUE mm_upcase_bang(a) VALUE a;
|