each_byte

ios.each_byte {|byte| block } â iosios.each_byte â an_enumerator Instance Public methods Calls the given block once for each byte (0..255) in ios, passing the byte as an argument. The stream must be opened for reading or an IOError will be raised. If no block is given, an enumerator is returned instead. f = File.new("testfile") checksum = 0 f.each_byte {|x| checksum ^= x } #=> #<File:testfile> checksum #=> 12

each

ios.each(sep=$/) {|line| block } â iosios.each(limit) {|line| block } â iosios.each(sep,limit) {|line| block } â iosios.each(...) â an_enumeratorios.each_line(sep=$/) {|line| block } â iosios.each_line(limit) {|line| block } â iosios.each_line(sep,limit) {|line| block } â iosios.each_line(...) â an_enumerator Instance Public methods Executes the block for every line in ios, where lines are separated by se

cooked!

io.cooked! Instance Public methods Enables cooked mode. If the terminal mode needs to be back, use io.cooked { ⦠}. You must require 'io/console' to use this method.

cooked

io.cooked {|io| } Instance Public methods Yields self within cooked mode. STDIN.cooked(&:gets) will read and return a line with echo back and line editing. You must require 'io/console' to use this method.

codepoints

codepoints() Instance Public methods This is a deprecated alias for each_codepoint.

closed?

ios.closed? â true or false Instance Public methods Returns true if ios is completely closed (for duplex streams, both reader and writer), false otherwise. f = File.new("testfile") f.close #=> nil f.closed? #=> true f = IO.popen("/bin/sh","r+") f.close_write #=> nil f.closed? #=> false f.close_read #=> nil f.closed? #=> true

close_write

ios.close_write â nil Instance Public methods Closes the write end of a duplex I/O stream (i.e., one that contains both a read and a write stream, such as a pipe). Will raise an IOError if the stream is not duplexed. f = IO.popen("/bin/sh","r+") f.close_write f.print "nowhere" produces: prog.rb:3:in `write': not opened for writing (IOError) from prog.rb:3:in `print' from prog.rb:3

close_read

ios.close_read â nil Instance Public methods Closes the read end of a duplex I/O stream (i.e., one that contains both a read and a write stream, such as a pipe). Will raise an IOError if the stream is not duplexed. f = IO.popen("/bin/sh","r+") f.close_read f.readlines produces: prog.rb:3:in `readlines': not opened for reading (IOError) from prog.rb:3

close_on_exec?

ios.close_on_exec? â true or false Instance Public methods Returns true if ios will be closed on exec. f = open("/dev/null") f.close_on_exec? #=> false f.close_on_exec = true f.close_on_exec? #=> true f.close_on_exec = false f.close_on_exec? #=> false

close_on_exec=

ios.close_on_exec = bool â true or false Instance Public methods Sets a close-on-exec flag. f = open("/dev/null") f.close_on_exec = true system("cat", "/proc/self/fd/#{f.fileno}") # cat: /proc/self/fd/3: No such file or directory f.closed? #=> false Ruby sets close-on-exec flags of all file descriptors by default since Ruby 2.0.0. So you don't need to set by yourself. Also, unsetting a close-on-exec flag can cause file descriptor leak if another thread use fo