advise

ios.advise(advice, offset=0, len=0) รข nil
Instance Public methods
Announce an intention to access data from the current file in a
specific pattern. On platforms that do not support the
<em>posix_fadvise(2)</em> system call, this method is a no-op.

advice is one of the following symbols:

* :normal - No advice to give; the default assumption for an open file.
* :sequential - The data will be accessed sequentially:
   with lower offsets read before higher ones.
* :random - The data will be accessed in random order.
* :willneed - The data will be accessed in the near future.
* :dontneed - The data will not be accessed in the near future.
* :noreuse - 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:

* <code>IOError</code> - The <code>IO</code> stream is closed.
* <code>Errno::EBADF</code> - The file descriptor of the current file is
  invalid.
* <code>Errno::EINVAL</code> - An invalid value for _advice_ was given.
* <code>Errno::ESPIPE</code> - The file descriptor of the current
* file refers to a FIFO or pipe. (Linux raises <code>Errno::EINVAL</code>
* in this case).
* <code>TypeError</code> - Either _advice_ was not a Symbol, or one of the
  other arguments was not an <code>Integer</code>.
* <code>RangeError</code> - One of the arguments given was too big/small.
This list is not exhaustive; other Errno

exceptions are also possible.

doc_ruby_on_rails
2015-04-13 09:56:15
Comments
Leave a Comment

Please login to continue.