inspect

inspect() Instance Public methods Alias for: to_s

inplace_mode=

ARGF.inplace_mode = ext â ARGF Instance Public methods Sets the filename extension for inplace editing mode to the given String. Each file being edited has this value appended to its filename. The modified file is saved under this new name. For example: $ ruby argf.rb file.txt ARGF.inplace_mode = '.bak' ARGF.lines do |line| print line.sub("foo","bar") end Each line of file.txt has the first occurrence of âfooâ replaced with âbarâ, then the new line is wri

inplace_mode

ARGF.inplace_mode â String Instance Public methods Returns the file extension appended to the names of modified files under inplace-edit mode. This value can be set using ARGF.inplace_mode= or passing the -i switch to the Ruby binary.

gets

ARGF.gets(sep=$/) â stringARGF.gets(limit) â stringARGF.gets(sep, limit) â string Instance Public methods Returns the next line from the current file in ARGF. By default lines are assumed to be separated by +$/+; to use a different character as a separator, supply it as a String for the sep argument. The optional limit argument specifies how many characters of each line to return. By default all characters are returned.

getc

ARGF.getc â String or nil Instance Public methods Reads the next character from ARGF and returns it as a String. Returns nil at the end of the stream. ARGF treats the files named on the command line as a single file created by concatenating their contents. After returning the last character of the first file, it returns the first character of the second file, and so on. For example: $ echo "foo" > file $ ruby argf.rb file ARGF.getc #=> "f" ARGF.getc #=> "o" ARGF.getc

getbyte

ARGF.getbyte â Fixnum or nil Instance Public methods Gets the next 8-bit byte (0..255) from ARGF. Returns nil if called at the end of the stream. For example: $ echo "foo" > file $ ruby argf.rb file ARGF.getbyte #=> 102 ARGF.getbyte #=> 111 ARGF.getbyte #=> 111 ARGF.getbyte #=> 10 ARGF.getbyte #=> nil

fileno

ARGF.fileno â fixnum Instance Public methods Returns an integer representing the numeric file descriptor for the current file. Raises an ArgumentError if there isn't a current file. ARGF.fileno #=> 3

filename

ARGF.filename â String Instance Public methods Returns the current filename. â-â is returned when the current file is STDIN. For example: $ echo "foo" > foo $ echo "bar" > bar $ echo "glark" > glark $ ruby argf.rb foo bar glark ARGF.filename #=> "foo" ARGF.read(5) #=> "foo\nb" ARGF.filename #=> "bar" ARGF.skip ARGF.filename #=> "glark"

file

ARGF.file â IO or File object Instance Public methods Returns the current file as an IO or File object. #<IO:<STDIN>> is returned when the current file is STDIN. For example: $ echo "foo" > foo $ echo "bar" > bar $ ruby argf.rb foo bar ARGF.file #=> #<File:foo> ARGF.read(5) #=> "foo\nb" ARGF.file #=> #<File:bar>

external_encoding

ARGF.external_encoding â encoding Instance Public methods Returns the external encoding for files read from +ARGF+ as an +Encoding+ object. The external encoding is the encoding of the text as stored in a file. Contrast with +ARGF.internal_encoding+, which is the encoding used to represent this text within Ruby. To set the external encoding use +ARGF.set_encoding+. For example: ARGF.external_encoding #=> #<Encoding:UTF-8>