Announce an intention to access data from the current file in a specific pattern. On platforms that do not support the posix_fadvise(2) system call, this method is a no-op.
advice is one of the following symbols:
No advice to give; the default assumption for an open file.
The data will be accessed sequentially with lower offsets read before higher ones.
The data will be accessed in random order.
The data will be accessed in the near future.
The data will not be accessed in the near future.
The data will only be accessed once.
The semantics of a piece of advice are platform-dependent. See man 2 posix_fadvise for details.
“data” means the region of the current file that begins at offset and extends for len bytes. If len is 0, the region ends at the last byte of the file. By default, both offset and len are 0, meaning that the advice applies to the entire file.
If an error occurs, one of the following exceptions will be raised:
IOErrorThe IO stream is closed.
Errno::EBADFThe file descriptor of the current file is invalid.
Errno::EINVALAn invalid value for advice was given.
Errno::ESPIPEThe file descriptor of the current file refers to a FIFO or pipe. (Linux raises Errno::EINVAL in this case).
TypeErrorEither advice was not a Symbol, or one of the other arguments was not an Integer.
RangeErrorOne of the arguments given was too big/small.
Errnoexceptions are also possible.
Provides a mechanism for issuing low-level commands to control or query I/O devices. Arguments and results are platform dependent. If arg is a number, its value is passed directly. If it is a string, it is interpreted as a binary sequence of bytes. On Unix platforms, see ioctl(2) for details. Not implemented on all platforms.
Returns true if the underlying file descriptor of ios will be closed automatically at its finalization, otherwise false.
Sets auto-close flag.
f = open("/dev/null") IO.for_fd(f.fileno) # ... f.gets # may cause IOError f = open("/dev/null") IO.for_fd(f.fileno).autoclose = true # ... f.gets # won't cause IOError
If called without a block, this is synonymous to GDBM::new. If a block is given, the new GDBM instance will be passed to the block as a parameter, and the corresponding database file will be closed after the execution of the block code has been finished.
Example for an open call with a block:
require 'gdbm' GDBM.open("fruitstore.db") do |gdbm| gdbm.each_pair do |key, value| print "#{key}: #{value}\n" end end
Closes the associated database file.
Returns true if the associated database file has been closed.
Returns a new array of all key-value pairs of the database for which block evaluates to true.
Returns true if the database is empty.
Removes all the key-value pairs within gdbm.
Returns a hash created by using gdbm’s values as keys, and the keys as values.
Returns true if the given key k exists within the database. Returns false otherwise.
Returns the first object in the range, or an array of the first n elements.
(10..20).first #=> 10 (10..20).first(3) #=> [10, 11, 12]
Returns true if obj is an element of the range, false otherwise. If begin and end are numeric, comparison is done according to the magnitude of the values.
("a".."z").include?("g") #=> true ("a".."z").include?("A") #=> false ("a".."z").include?("cc") #=> false
Returns true if obj is between the begin and end of the range.
This tests begin <= obj <= end when exclude_end? is false and begin <= obj < end when exclude_end? is true.
("a".."z").cover?("c") #=> true ("a".."z").cover?("5") #=> false ("a".."z").cover?("cc") #=> true
Returns the value of the case-insensitive flag.
/a/.casefold? #=> false /a/i.casefold? #=> true /(?i:a)/.casefold? #=> false
provides a unified clone operation, for REXML::XPathParser to use across multiple Object types
In general, to_sym returns the Symbol corresponding to an object. As sym is already a symbol, self is returned in this case.
Returns that sym is :“” or not.
Same as sym.to_s.upcase.intern.
Same as sym.to_s.downcase.intern.
Same as sym.to_s.swapcase.intern.
Callback invoked whenever a subclass of the current class is created.
Example:
class Foo def self.inherited(subclass) puts "New subclass: #{subclass}" end end class Bar < Foo end class Baz < Bar end
produces:
New subclass: Bar New subclass: Baz
Returns the superclass of class, or nil.
File.superclass #=> IO IO.superclass #=> Object Object.superclass #=> BasicObject class Foo; end class Bar < Foo; end Bar.superclass #=> Foo
Returns nil when the given class does not have a parent class:
BasicObject.superclass #=> nil