IO

ruby/spec describes 118 methods in core/io, and Metorex implements 117 of them. The parameters are what Method#parameters answers under Metorex.

IO#

  • IO#<<: implemented, parameters [[:req, :text]]. Writes the given object to self, which must be opened for writing (see Access Modes); returns self; if object is not a string, it is converted via method to_s:
  • **IO#advise**: implemented, parameters [[:req, :kind], [:opt, :offset], [:opt, :length]]. Invokes Posix system call posix_fadvise(2), which announces an intention to access data from the current file in a particular manner. An example calling it.
  • IO#autoclose=: implemented, parameters [[:req, :wanted]]. Sets auto-close flag.
  • IO#autoclose?: implemented, parameters []. Returns true if the underlying file descriptor of ios will be closed at its finalization or at calling #close, otherwise false.
  • IO#binmode: implemented, parameters []. Sets the stream's data mode as binary (see Data Mode). An example calling it.
  • IO#binmode?: implemented, parameters []. Returns true if the stream is on binary mode, false otherwise. An example calling it.
  • IO.binread: implemented, parameters [[:req, :name], [:rest, :rest]]. Behaves like IO.read, except that the stream is opened in binary mode with ASCII-8BIT encoding. An example calling it.
  • IO.binwrite: implemented, parameters [[:req, :name], [:req, :text], [:opt, :offset], [:rest, :extra], [:keyrest, :options]]. Behaves like IO.write, except that the stream is opened in binary mode with ASCII-8BIT encoding.
  • IO#close: implemented, parameters []. Closes the stream for both reading and writing if open for either or both; returns nil. An example calling it.
  • IO#close_on_exec=: implemented, parameters [[:req, :wanted]]. Sets a close-on-exec flag.
  • IO#close_on_exec?: implemented, parameters []. Returns true if the stream will be closed on exec, false otherwise: An example calling it.
  • IO#close_read: implemented, parameters []. Closes the stream for reading if open for reading; returns nil. An example calling it.
  • IO#close_write: implemented, parameters []. Closes the stream for writing if open for writing; returns nil. An example calling it.
  • IO#closed?: implemented, parameters []. Returns true if the stream is closed for both reading and writing, false otherwise. An example calling it.
  • IO.copy_stream: implemented, parameters [[:req, :source], [:req, :destination], [:opt, :length], [:opt, :offset]]. Copies from the given src to the given dst, returning the number of bytes copied. An example calling it.
  • IO#dup: implemented, parameters []. Produces a shallow copy of obj---the instance variables of obj are copied, but not the objects they reference. An example calling it.
  • IO#each: implemented, parameters [[:opt, :separator], [:opt, :limit], [:key, :chomp], [:block, :block]]. Calls the block with each remaining line read from the stream; returns self. An example calling it.
  • IO#each_byte: implemented, parameters []. Calls the given block with each byte (0..255) in the stream; returns self. An example calling it.
  • IO#each_char: implemented, parameters []. Calls the given block with each character in the stream; returns self. An example calling it.
  • IO#each_codepoint: implemented, parameters []. Calls the given block with each codepoint in the stream; returns self: An example calling it.
  • IO#each_line: implemented, parameters [[:opt, :separator], [:opt, :limit], [:key, :chomp], [:block, :block]]. Calls the block with each remaining line read from the stream; returns self. An example calling it.
  • IO#eof: implemented, parameters []. Returns true if the stream is positioned at its end, false otherwise; see Position:
  • IO#eof?: implemented, parameters []. Returns true if the stream is positioned at its end, false otherwise; see Position: An example calling it.
  • IO#external_encoding: implemented, parameters []. Returns the Encoding object that represents the encoding of the stream, or nil if the stream is in write mode and no encoding is specified. An example calling it.
  • IO#fcntl: implemented, parameters [[:req, :command], [:opt, :argument]]. Invokes Posix system call fcntl(2), which provides a mechanism for issuing low-level commands to control or query a file-oriented I/O stream. An example calling it.
  • IO#fdatasync: implemented, parameters []. Immediately writes to disk all data buffered in the stream, via the operating system's: fdatasync(2), if supported, otherwise via fsync(2), if supported; otherwise raises an exception.
  • IO#fileno: implemented, parameters []. Returns the integer file descriptor for the stream: An example calling it.
  • IO#flush: implemented, parameters []. Flushes data buffered in self to the operating system (but does not necessarily flush data buffered in the operating system): An example calling it.
  • IO.for_fd: implemented, parameters [[:req, :number], [:opt, :mode], [:keyrest, :options]]. Synonym for IO.new.
  • IO.foreach: implemented, parameters [[:req, :name], [:opt, :separator], [:opt, :limit], [:key, :chomp], [:keyrest, :options], [:block, :block]]. Calls the block with each successive line read from the stream. An example calling it.
  • IO#fsync: implemented, parameters []. Immediately writes to disk all data buffered in the stream, via the operating system's fsync(2).
  • IO#getbyte: implemented, parameters []. Reads and returns the next byte (in range 0..255) from the stream; returns nil if already at end-of-stream. An example calling it.
  • IO#getc: implemented, parameters []. Reads and returns the next 1-character string from the stream; returns nil if already at end-of-stream. An example calling it.
  • IO#gets: implemented, parameters [[:opt, :separator], [:opt, :limit], [:rest, :extra], [:key, :chomp]]. Reads and returns a line from the stream; assigns the return value to $_. An example calling it.
  • IO#initialize: implemented, parameters [[:req, :number], [:opt, :mode], [:rest, :extra], [:keyrest, :options]]. An example calling it.
  • IO#inspect: implemented, parameters []. Returns a string representation of self: An example calling it.
  • IO#internal_encoding: implemented, parameters []. Returns the Encoding object that represents the encoding of the internal string, if conversion is specified, or nil otherwise. An example calling it.
  • IO#ioctl: implemented, parameters [[:req, :request], [:opt, :argument]]. Invokes Posix system call ioctl(2), which issues a low-level command to an I/O device.
  • IO#isatty: implemented, parameters []. Returns true if the stream is associated with a terminal device (tty), false otherwise:
  • IO#lineno: implemented, parameters []. Returns the current line number for the stream; see Line Number. An example calling it.
  • IO#lineno=: implemented, parameters [[:req, :held]]. Sets and returns the line number for the stream; see Line Number.
  • IO.new: implemented, parameters [[:rest]]. Creates and returns a new IO object (file stream) from a file descriptor. An example calling it.
  • IO#nonblock=: implemented, parameters [[:req, :wanted]]. Enables non-blocking mode on a stream when set to true, and blocking mode when set to false.
  • IO#nonblock?: implemented, parameters []. Returns true if an IO object is in non-blocking mode. An example calling it.
  • IO.open: implemented, parameters [[:req, :number], [:opt, :mode], [:rest, :extra], [:keyrest, :options]]. Creates a new IO object, via IO.new with the given arguments. An example calling it.
  • IO#path: implemented, parameters []. Returns the path associated with the IO, or nil if there is no path associated with the IO. An example calling it.
  • IO#pid: implemented, parameters []. Returns the process ID of a child process associated with the stream, which will have been set by IO#popen, or nil if the stream was not created by IO#popen: An example calling it.
  • IO.pipe: implemented, parameters [[:opt, :external], [:opt, :internal], [:keyrest, :options]]. Creates a pair of pipe endpoints, read_io and write_io, connected to each other. An example calling it.
  • IO.popen: implemented, parameters [[:rest, :given], [:keyrest, :options], [:block, :block]]. Executes the given command cmd as a subprocess whose $stdin and $stdout are connected to a new stream io. An example calling it.
  • IO#pos: implemented, parameters []. Returns the current position (in bytes) in self (see Position): An example calling it.
  • IO#pos=: implemented, parameters [[:req, :offset]]. Seeks to the given new_position (in bytes); see Position:
  • IO#pread: implemented, parameters [[:req, :maxlen], [:req, :offset], [:opt, :buffer]]. Behaves like IO#readpartial, except that it: An example calling it.
  • IO#print: implemented, parameters [[:rest, :parts]]. Writes the given objects to the stream; returns nil. An example calling it.
  • IO#printf: implemented, parameters [[:req, :format], [:rest, :rest]]. Formats and writes objects to the stream. An example calling it.
  • IO#putc: implemented, parameters [[:req, :held]]. Writes a character to the stream. An example calling it.
  • IO#puts: implemented, parameters [[:rest, :lines]]. Writes the given objects to the stream, which must be open for writing; returns nil.\ Writes a newline after each that does not already end with a newline sequence. An example calling it.
  • IO#pwrite: implemented, parameters [[:req, :held], [:req, :offset]]. Behaves like IO#write, except that it:
  • IO#read: implemented, parameters [[:opt, :length], [:opt, :buffer]]. Reads bytes from the stream; the stream must be opened for reading (see Access Modes): An example calling it.
  • IO.read: implemented, parameters [[:req, :name], [:rest, :rest], [:keyrest, :options]]. Opens the stream, reads and returns some or all of its content, and closes the stream; returns nil if no bytes were read. An example calling it.
  • IO#read_nonblock: implemented, parameters [[:req, :length], [:opt, :buffer], [:key, :exception]]. Reads at most maxlen bytes from ios using the read(2) system call after O_NONBLOCK is set for the underlying file descriptor. An example calling it.
  • IO#readbyte: implemented, parameters []. Reads and returns the next byte (in range 0..255) from the stream; raises EOFError if already at end-of-stream. An example calling it.
  • IO#readchar: implemented, parameters []. Reads and returns the next 1-character string from the stream; raises EOFError if already at end-of-stream. An example calling it.
  • IO#readline: implemented, parameters [[:opt, :separator], [:opt, :limit], [:rest, :extra], [:key, :chomp]]. Reads a line as with IO#gets, but raises EOFError if already at end-of-stream. An example calling it.
  • IO#readlines: implemented, parameters [[:opt, :separator], [:opt, :limit], [:key, :chomp], [:keyrest, :_ignored]]. Reads and returns all remaining line from the stream; does not modify $_. An example calling it.
  • IO.readlines: implemented, parameters [[:req, :name], [:opt, :separator], [:opt, :limit], [:key, :chomp], [:keyrest, :options]]. Returns an array of all lines read from the stream. An example calling it.
  • IO#readpartial: implemented, parameters [[:opt, :length], [:opt, :buffer]]. Reads up to maxlen bytes from the stream; returns a string (either a new string or the given out_string). An example calling it.
  • IO#reopen: implemented, parameters [[:req, :target], [:opt, :mode]]. Reassociates the stream with another stream, which may be of a different class. An example calling it.
  • IO#rewind: implemented, parameters []. Repositions the stream to its beginning, setting both the position and the line number to zero; see Position and Line Number: An example calling it.
  • IO#seek: implemented, parameters [[:req, :offset], [:opt, :whence]]. Seeks to the position given by integer offset (see Position) and constant whence, which is one of: An example calling it.
  • IO.select: implemented, parameters [[:opt, :readers], [:opt, :writers], [:opt, :errored], [:opt, :timeout]]. Invokes system call select(2), which monitors multiple file descriptors, waiting until one or more of the file descriptors becomes ready for some class of I/O operation. An example calling it.
  • IO#set_encoding: implemented, parameters [[:req, :external], [:opt, :internal], [:keyrest, :options]]. See Encodings. An example calling it.
  • IO#set_encoding_by_bom: implemented, parameters []. If the stream begins with a BOM (byte order marker), consumes the BOM and sets the external encoding accordingly; returns the result encoding if found, or nil otherwise:
  • IO#stat: implemented, parameters []. Returns status information for ios as an object of type File::Stat. An example calling it.
  • IO#sync: implemented, parameters []. Returns the current sync mode of the stream. An example calling it.
  • IO#sync=: implemented, parameters [[:req, :wanted]]. Sets the sync mode for the stream to the given value; returns the given value.
  • IO.sysopen: implemented, parameters [[:req, :name], [:opt, :mode], [:opt, :permissions]]. Opens the file at the given path with the given mode and permissions; returns the integer file descriptor. An example calling it.
  • IO#sysread: implemented, parameters [[:opt, :length], [:opt, :buffer]]. Behaves like IO#readpartial, except that it uses low-level system functions. An example calling it.
  • IO#sysseek: implemented, parameters [[:req, :offset], [:opt, :whence]]. Behaves like IO#seek, except that it:
  • IO#syswrite: implemented, parameters [[:req, :text]]. Writes the given object to self, which must be opened for writing (see Modes); returns the number bytes written. An example calling it.
  • IO#tell: implemented, parameters []. Returns the current position (in bytes) in self (see Position): An example calling it.
  • IO#to_i: implemented, parameters []. Returns the integer file descriptor for the stream: An example calling it.
  • IO#to_io: implemented, parameters []. Returns self.
  • IO#to_path: implemented, parameters []. Returns the path associated with the IO, or nil if there is no path associated with the IO. An example calling it.
  • IO.try_convert: implemented, parameters [[:req, :held]]. Attempts to convert object into an IO object via method to_io; returns the new IO object if successful, or nil otherwise:
  • IO#tty?: implemented, parameters []. Returns true if the stream is associated with a terminal device (tty), false otherwise: An example calling it.
  • IO#ungetbyte: implemented, parameters [[:req, :held]]. Pushes back ("unshifts") the given data onto the stream's buffer, placing the data so that it is next to be read; returns nil. An example calling it.
  • IO#ungetc: implemented, parameters [[:req, :held]]. Pushes back ("unshifts") the given data onto the stream's buffer, placing the data so that it is next to be read; returns nil. An example calling it.
  • IO#write: implemented, parameters [[:rest, :parts]]. Writes each of the given objects to self, which must be opened for writing (see Access Modes); returns the total number bytes written; each of objects that is not a string is converted via method to_s: An example calling it.
  • IO.write: implemented, parameters [[:req, :name], [:req, :text], [:opt, :offset], [:rest, :extra], [:keyrest, :options]]. Opens the stream, writes the given data to it, and closes the stream; returns the number of bytes written. An example calling it.
  • IO#write_nonblock: implemented, parameters [[:req, :text], [:key, :exception]]. Writes the given string to ios using the write(2) system call after O_NONBLOCK is set for the underlying file descriptor. An example calling it.

IO::Buffer#

  • IO::Buffer#&: implemented, parameters [[:req, :mask]]. Generate a new buffer the same size as the source by applying the binary AND operation to the source, using the mask, repeating as necessary.
  • IO::Buffer#^: implemented, parameters [[:req, :mask]]. Generate a new buffer the same size as the source by applying the binary XOR operation to the source, using the mask, repeating as necessary.
  • IO::Buffer#and!: implemented, parameters [[:req, :mask]]. Modify the source buffer in place by applying the binary AND operation to the source, using the mask, repeating as necessary.
  • IO::Buffer#bit_count: not implemented.
  • IO::Buffer#empty?: implemented, parameters []. If the buffer has 0 size: it is created by ::new with size 0, or with ::for from an empty string. An example calling it.
  • IO::Buffer#external?: implemented, parameters []. The buffer is external if it references the memory which is not allocated or mapped by the buffer itself.
  • IO::Buffer.for: implemented, parameters [[:req, :string]]. Creates a zero-copy IO::Buffer from the given string's memory.
  • IO::Buffer#free: implemented, parameters []. If the buffer references memory, release it back to the operating system. An example calling it.
  • IO::Buffer#initialize: implemented, parameters [[:opt, :size], [:opt, :flags]]. An example calling it.
  • IO::Buffer#internal?: implemented, parameters []. If the buffer is internal, meaning it references memory allocated by the buffer itself.
  • IO::Buffer#locked: implemented, parameters []. Allows to process a buffer in exclusive way, for concurrency-safety. An example calling it.
  • IO::Buffer#locked?: implemented, parameters []. If the buffer is locked, meaning it is inside #locked block execution. An example calling it.
  • IO::Buffer.map: implemented, parameters [[:req, :file], [:opt, :size], [:opt, :offset], [:opt, :flags]]. Create an IO::Buffer for reading from file by memory-mapping the file. An example calling it.
  • IO::Buffer#mapped?: implemented, parameters []. If the buffer is mapped, meaning it references memory mapped by the buffer.
  • IO::Buffer#not!: implemented, parameters []. Modify the source buffer in place by applying the binary NOT operation to the source.
  • IO::Buffer#null?: implemented, parameters []. If the buffer was freed with #free, transferred with #transfer, or was never allocated in the first place.
  • IO::Buffer#or!: implemented, parameters [[:req, :mask]]. Modify the source buffer in place by applying the binary OR operation to the source, using the mask, repeating as necessary.
  • IO::Buffer#private?: implemented, parameters []. If the buffer is private, meaning modifications to the buffer will not be replicated to the underlying file mapping.
  • IO::Buffer#readonly?: implemented, parameters []. If the buffer is read only, meaning the buffer cannot be modified using #set_value, #set_string or #copy and similar.
  • IO::Buffer#resize: implemented, parameters [[:req, :size]]. Resizes a buffer to a new_size bytes, preserving its content. An example calling it.
  • IO::Buffer#shared?: implemented, parameters []. If the buffer is shared, meaning it references memory that can be shared with other processes (and thus might change without being modified locally).
  • IO::Buffer.string: implemented, parameters [[:req, :length]]. Creates a new string of the given length and yields a zero-copy IO::Buffer instance to the block which uses the string as a source.
  • IO::Buffer#transfer: implemented, parameters []. Transfers ownership of the underlying memory to a new buffer, causing the current buffer to become uninitialized. An example calling it.
  • IO::Buffer#valid?: implemented, parameters []. Returns whether the buffer buffer is accessible. An example calling it.
  • IO::Buffer#write: implemented, parameters [[:req, :io], [:opt, :length], [:opt, :offset]]. Write at least length bytes from the buffer starting at offset, into the io. An example calling it.
  • IO::Buffer#xor!: implemented, parameters [[:req, :mask]]. Modify the source buffer in place by applying the binary XOR operation to the source, using the mask, repeating as necessary.
  • IO::Buffer#|: implemented, parameters [[:req, :mask]]. Generate a new buffer the same size as the source by applying the binary OR operation to the source, using the mask, repeating as necessary.
  • IO::Buffer#~: implemented, parameters []. Generate a new buffer the same size as the source by applying the binary NOT operation to the source.

The method summaries are the first sentences of Ruby's own documentation for each method, read from MRI 4.0.6's ri data. Ruby's documentation is distributed under Ruby's license.