Top Level Namespace
Defined Under Namespace
Modules: Comparable, Enumerable, Errno, FileTest, GC, Kernel, Marshal, Math, ObjectSpace, Precision, Process, Signal Classes: ArgumentError, Array, Bignum, Binding, Class, Continuation, Data, Dir, EOFError, Exception, FalseClass, File, Fixnum, Float, FloatDomainError, Hash, IO, IOError, IndexError, Integer, Interrupt, LoadError, LocalJumpError, MatchData, Method, Module, NameError, NilClass, NoMemoryError, NoMethodError, NotImplementedError, Numeric, Object, Proc, Range, RangeError, Regexp, RegexpError, RuntimeError, ScriptError, SecurityError, SignalException, StandardError, StopIteration, String, Struct, Symbol, SyntaxError, SystemCallError, SystemExit, SystemStackError, Thread, ThreadError, ThreadGroup, Time, TrueClass, TypeError, UnboundMethod, ZeroDivisionError, fatal
Class Method Summary collapse
- .binmode ⇒ Object
- .bytes ⇒ Object
- .chars ⇒ Object
- .close ⇒ Object
- .closed? ⇒ Boolean
- .each ⇒ Object
- .each_byte ⇒ Object
- .each_char ⇒ Object
- .each_line ⇒ Object
- .eof ⇒ Object
- .eof? ⇒ Boolean
- .file ⇒ Object
- .filename ⇒ Object
- .fileno ⇒ Object
- .getbyte ⇒ Object
- .getc ⇒ Object
-
.gets(separator = $/) ⇒ String?
Returns (and assigns to
$_
) the next line from the list of files inARGV
(or$*
), or from standard input if no files are present on the command line. -
.induced_from(number) ⇒ Object
Creates an instance of mod from.
- .lineno ⇒ Object
- .lineno= ⇒ Object
- .lines ⇒ Object
- .path ⇒ Object
- .pos ⇒ Object
- .pos= ⇒ Object
- .read ⇒ Object
- .readbyte ⇒ Object
- .readchar ⇒ Object
-
.readline(separator = $/) ⇒ String
Equivalent to
Kernel::gets
, exceptreadline
raisesEOFError
at end of file. -
.readlines(separator = $/) ⇒ Array
Returns an array containing the lines returned by calling
Kernel.gets(separator)
until the end of file. - .rewind ⇒ Object
- .seek ⇒ Object
- .skip ⇒ Object
- .tell ⇒ Object
-
.readlines(separator = $/) ⇒ Array
Returns an array containing the lines returned by calling
Kernel.gets(separator)
until the end of file. - .to_i ⇒ Object
- .to_io ⇒ Object
- .to_s ⇒ Object
Class Method Details
.binmode ⇒ Object
.bytes ⇒ Object
.chars ⇒ Object
.close ⇒ Object
.closed? ⇒ Boolean
.each ⇒ Object
.each_byte ⇒ Object
.each_char ⇒ Object
.each_line ⇒ Object
.eof ⇒ Object
.eof? ⇒ Boolean
.file ⇒ Object
.filename ⇒ Object
.fileno ⇒ Object
.getbyte ⇒ Object
.getc ⇒ Object
.gets(separator = $/) ⇒ String?
Returns (and assigns to $_
) the next line from the list of files in ARGV
(or $*
), or from standard input if no files are present on the command line. Returns nil
at end of file. The optional argument specifies the record separator. The separator is included with the contents of each record. A separator of nil
reads the entire contents, and a zero-length separator reads the input one paragraph at a time, where paragraphs are divided by two consecutive newlines. If multiple filenames are present in ARGV
, gets(nil) will read the contents one file at a time.
ARGV << "testfile"
print while gets
produces:
This is line one
This is line two
This is line three
And so on...
The style of programming using $_
as an implicit parameter is gradually losing favor in the Ruby community.
|
# File 'io.c'
/*
* call-seq:
* gets(separator=$/) => string or nil
*
* Returns (and assigns to <code>$_</code>) the next line from the list
* of files in +ARGV+ (or <code>$*</code>), or from standard
* input if no files are present on the command line. Returns
* +nil+ at end of file. The optional argument specifies the
* record separator. The separator is included with the contents of
* each record. A separator of +nil+ reads the entire
* contents, and a zero-length separator reads the input one paragraph
* at a time, where paragraphs are divided by two consecutive newlines.
* If multiple filenames are present in +ARGV+,
* +gets(nil)+ will read the contents one file at a time.
*
* ARGV << "testfile"
* print while gets
*
* <em>produces:</em>
*
* This is line one
* This is line two
* This is line three
* And so on...
*
* The style of programming using <code>$_</code> as an implicit
* parameter is gradually losing favor in the Ruby community.
*/
static VALUE
rb_f_gets(argc, argv)
int argc;
VALUE *argv;
{
VALUE line;
if (!next_argv()) return Qnil;
if (TYPE(current_file) != T_FILE) {
line = rb_funcall3(current_file, rb_intern("gets"), argc, argv);
}
else {
line = argf_getline(argc, argv);
}
rb_lastline_set(line);
return line;
}
|
.induced_from(number) ⇒ Object
Creates an instance of mod from. This method is overridden by concrete Numeric
classes, so that (for example)
Fixnum.induced_from(9.9) #=> 9
Note that a use of prec
in a redefinition may cause an infinite loop.
|
# File 'prec.c'
/*
* call-seq:
* Mod.induced_from(number) => a_mod
*
* Creates an instance of mod from. This method is overridden
* by concrete +Numeric+ classes, so that (for example)
*
* Fixnum.induced_from(9.9) #=> 9
*
* Note that a use of +prec+ in a redefinition may cause
* an infinite loop.
*/
static VALUE
prec_induced_from(module, x)
VALUE module, x;
{
rb_raise(rb_eTypeError, "undefined conversion from %s into %s",
rb_obj_classname(x), rb_class2name(module));
return Qnil; /* not reached */
}
|
.lineno ⇒ Object
.lineno= ⇒ Object
.lines ⇒ Object
.path ⇒ Object
.pos ⇒ Object
.pos= ⇒ Object
.read ⇒ Object
.readbyte ⇒ Object
.readchar ⇒ Object
.readline(separator = $/) ⇒ String
Equivalent to Kernel::gets
, except readline
raises EOFError
at end of file.
|
# File 'io.c'
/*
* call-seq:
* readline(separator=$/) => string
*
* Equivalent to <code>Kernel::gets</code>, except
* +readline+ raises +EOFError+ at end of file.
*/
static VALUE
rb_f_readline(argc, argv)
int argc;
VALUE *argv;
{
VALUE line;
if (!next_argv()) rb_eof_error();
ARGF_FORWARD(argc, argv);
line = rb_f_gets(argc, argv);
if (NIL_P(line)) {
rb_eof_error();
}
return line;
}
|
.readlines(separator = $/) ⇒ Array
Returns an array containing the lines returned by calling Kernel.gets(separator)
until the end of file.
|
# File 'io.c'
/*
* call-seq:
* readlines(separator=$/) => array
*
* Returns an array containing the lines returned by calling
* <code>Kernel.gets(<i>separator</i>)</code> until the end of file.
*/
static VALUE
rb_f_readlines(argc, argv)
int argc;
VALUE *argv;
{
VALUE line, ary;
NEXT_ARGF_FORWARD(argc, argv);
ary = rb_ary_new();
while (!NIL_P(line = argf_getline(argc, argv))) {
rb_ary_push(ary, line);
}
return ary;
}
|
.rewind ⇒ Object
.seek ⇒ Object
.skip ⇒ Object
.tell ⇒ Object
.readlines(separator = $/) ⇒ Array
Returns an array containing the lines returned by calling Kernel.gets(separator)
until the end of file.
|
# File 'io.c'
/*
* call-seq:
* readlines(separator=$/) => array
*
* Returns an array containing the lines returned by calling
* <code>Kernel.gets(<i>separator</i>)</code> until the end of file.
*/
static VALUE
rb_f_readlines(argc, argv)
int argc;
VALUE *argv;
{
VALUE line, ary;
NEXT_ARGF_FORWARD(argc, argv);
ary = rb_ary_new();
while (!NIL_P(line = argf_getline(argc, argv))) {
rb_ary_push(ary, line);
}
return ary;
}
|