rewind

ios.rewind â 0 Instance Public methods Positions ios to the beginning of input, resetting lineno to zero. f = File.new("testfile") f.readline #=> "This is line one\n" f.rewind #=> 0 f.lineno #=> 0 f.readline #=> "This is line one\n" Note that it cannot be used with streams such as pipes, ttys, and sockets.

scanf

scanf(str) Instance Public methods Scans the current string until the match is exhausted, yielding each match as it is encountered in the string. A block is not necessary though, as the results will simply be aggregated into the final array. "123 456".block_scanf("%d") # => [123, 456] If a block is given, the value from that is returned from the yield is added to an output array. "123 456".block_scanf("%d) do |digit,| # the ',' unpacks the Array digit + 100 end # => [223,

seek

ios.seek(amount, whence=IO::SEEK_SET) â 0 Instance Public methods Seeks to a given offset anInteger in the stream according to the value of whence: IO::SEEK_CUR | Seeks to _amount_ plus current position --------------+---------------------------------------------------- IO::SEEK_END | Seeks to _amount_ plus end of stream (you probably | want a negative value for _amount_) --------------+---------------------------------------------------- IO::SEEK_SET | Seeks to

set_encoding

io.set_encoding(ext_enc) â ioio.set_encoding("ext_enc:int_enc") â ioio.set_encoding(ext_enc, int_enc) â ioio.set_encoding("ext_enc:int_enc", opt) â ioio.set_encoding(ext_enc, int_enc, opt) â io Instance Public methods If single argument is specified, read string from io is tagged with the encoding specified. If encoding is a colon separated two encoding names âA:Bâ, the read string is converted from encoding A (external encoding) to encoding B (internal

stat

ios.stat â stat Instance Public methods Returns status information for ios as an object of type File::Stat. f = File.new("testfile") s = f.stat "%o" % s.mode #=> "100644" s.blksize #=> 4096 s.atime #=> Wed Apr 09 08:53:54 CDT 2003

sync

ios.sync â true or false Instance Public methods Returns the current âsync mode'' of ios. When sync mode is true, all output is immediately flushed to the underlying operating system and is not buffered by Ruby internally. See also IO#fsync. f = File.new("testfile") f.sync #=> false

sync=

ios.sync = boolean â boolean Instance Public methods Sets the âsync mode'' to true or false. When sync mode is true, all output is immediately flushed to the underlying operating system and is not buffered internally. Returns the new state. See also IO#fsync. f = File.new("testfile") f.sync = true (produces no output)

sysread

ios.sysread(maxlen[, outbuf]) â string Instance Public methods Reads maxlen bytes from ios using a low-level read and returns them as a string. Do not mix with other methods that read from ios or you may get unpredictable results. If the optional outbuf argument is present, it must reference a String, which will receive the data. The outbuf will contain only the received data after the method call even if it is not empty at the beginning. Raises SystemCallError on error and EO

sysseek

ios.sysseek(offset, whence=IO::SEEK_SET) â integer Instance Public methods Seeks to a given offset in the stream according to the value of whence (see IO#seek for values of whence). Returns the new offset into the file. f = File.new("testfile") f.sysseek(-13, IO::SEEK_END) #=> 53 f.sysread(10) #=> "And so on."

syswrite

ios.syswrite(string) â integer Instance Public methods Writes the given string to ios using a low-level write. Returns the number of bytes written. Do not mix with other methods that write to ios or you may get unpredictable results. Raises SystemCallError on error. f = File.new("out", "w") f.syswrite("ABCDEF") #=> 6