{: rooto:"YARD::CodeObjects::RootObject:@childrenIC:&YARD::CodeObjects::CodeObjectList[o:$YARD::CodeObjects::ModuleObject;IC;[Jo:#YARD::CodeObjects::ClassObject;IC;[o:$YARD::CodeObjects::MethodObject:@module_functionF:@scope:
instance:@visibility:public:
@pathI"Zlib::ZStream#avail_out:EF:@parameters[ :@files[[I"ext/zlib/zlib.c;Ti:@current_file_has_commentsT:
@name:avail_out:@source_type0:
@tags[ :@docstrings{ :@docstringIC:YARD::Docstring"Returns number of bytes of free spaces in output buffer. Because the free
space is allocated automatically, this method returns 0 normally.
;T;[ :@ref_tags[ : @allI"Returns number of bytes of free spaces in output buffer. Because the free
space is allocated automatically, this method returns 0 normally.
;T:@unresolved_reference0:@object@:@hash_flagF:@line_rangeo:
Range: exclT:
begini:endi:@namespace@
:@sourceI"static VALUE
rb_zstream_avail_out(VALUE obj)
{
struct zstream *z;
TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z);
return rb_uint2inum(z->stream.avail_out);
};T:@signatureI"static VALUE;T:@explicitTo;;F;
;;;;I"Zlib::ZStream#avail_out=;F;[[I" size;T0;[[@i;T;:avail_out=;0;[ ;{ ;IC;"Allocates +size+ bytes of free space in the output buffer. If there are more
than +size+ bytes already in the buffer, the buffer is truncated. Because
free space is allocated automatically, you usually don't need to use this
method.
;T;[ ;[ ;I"Allocates +size+ bytes of free space in the output buffer. If there are more
than +size+ bytes already in the buffer, the buffer is truncated. Because
free space is allocated automatically, you usually don't need to use this
method.
;T;0; @;!F;"o;#;$T;%i;&i;'@
;(I"static VALUE
rb_zstream_set_avail_out(VALUE obj, VALUE size)
{
struct zstream *z = get_zstream(obj);
zstream_expand_buffer_into(z, FIX2INT(size));
return size;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Zlib::ZStream#avail_in;F;[ ;[[@i;T;:
avail_in;0;[ ;{ ;IC;"DReturns bytes of data in the input buffer. Normally, returns 0.
;T;[ ;[ ;I"EReturns bytes of data in the input buffer. Normally, returns 0.
;T;0; @+;!F;"o;#;$T;%i;&i;'@
;(I"static VALUE
rb_zstream_avail_in(VALUE obj)
{
struct zstream *z;
TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z);
return INT2FIX(NIL_P(z->input) ? 0 : (int)(RSTRING_LEN(z->input)));
};T;)I"static VALUE;T;*To;;F;
;;;;I"Zlib::ZStream#total_in;F;[ ;[[@i;T;:
total_in;0;[ ;{ ;IC;"DReturns the total bytes of the input data to the stream. FIXME
;T;[ ;[ ;I"EReturns the total bytes of the input data to the stream. FIXME
;T;0; @9;!F;"o;#;$T;%i;&i;'@
;(I"pstatic VALUE
rb_zstream_total_in(VALUE obj)
{
return rb_uint2inum(get_zstream(obj)->stream.total_in);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Zlib::ZStream#total_out;F;[ ;[[@i;T;:total_out;0;[ ;{ ;IC;"GReturns the total bytes of the output data from the stream. FIXME
;T;[ ;[ ;I"HReturns the total bytes of the output data from the stream. FIXME
;T;0; @G;!F;"o;#;$T;%i;&i;'@
;(I"rstatic VALUE
rb_zstream_total_out(VALUE obj)
{
return rb_uint2inum(get_zstream(obj)->stream.total_out);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Zlib::ZStream#data_type;F;[ ;[[@i;T;:data_type;0;[ ;{ ;IC;"Guesses the type of the data which have been inputed into the stream. The
returned value is either BINARY, ASCII, or
UNKNOWN.
;T;[ ;[ ;I"Guesses the type of the data which have been inputed into the stream. The
returned value is either BINARY, ASCII, or
UNKNOWN.
;T;0; @U;!F;"o;#;$T;%i;&i;'@
;(I"mstatic VALUE
rb_zstream_data_type(VALUE obj)
{
return INT2FIX(get_zstream(obj)->stream.data_type);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Zlib::ZStream#adler;F;[ ;[[@i;T;:
adler;0;[ ;{ ;IC;"#Returns the adler-32 checksum.
;T;[ ;[ ;I"$Returns the adler-32 checksum.
;T;0; @c;!F;"o;#;$T;%i;&i;'@
;(I"jstatic VALUE
rb_zstream_adler(VALUE obj)
{
return rb_uint2inum(get_zstream(obj)->stream.adler);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Zlib::ZStream#finished?;F;[ ;[[@i;T;:finished?;0;[ ;{ ;IC;",Returns true if the stream is finished.;T;[o:YARD::Tags::Tag
:@tag_nameI"return;F:
@textI" ;T;0:@types[I"Boolean;T; @q;[ ;I"-Returns true if the stream is finished.
;T;0; @q;!F;"o;#;$T;%i;&i:@ref_tag_recurse_counti ;'@
;(I"ystatic VALUE
rb_zstream_finished_p(VALUE obj)
{
return ZSTREAM_IS_FINISHED(get_zstream(obj)) ? Qtrue : Qfalse;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Zlib::ZStream#stream_end?;F;[ ;[[@i;T;:stream_end?;0;[ ;{ ;IC;",Returns true if the stream is finished.;T;[o;2
;3I"return;F;4@|;0;5[@~; @;[ ;@{;0; @;!F;"o;#;$T;%i;&i;6i ;'@
;(I"ystatic VALUE
rb_zstream_finished_p(VALUE obj)
{
return ZSTREAM_IS_FINISHED(get_zstream(obj)) ? Qtrue : Qfalse;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Zlib::ZStream#closed?;F;[ ;[[@i;T;:closed?;0;[ ;{ ;IC;"*Returns true if the stream is closed.;T;[o;2
;3I"return;F;4@|;0;5[@~; @;[ ;I"+Returns true if the stream is closed.
;T;0; @;!F;"o;#;$T;%i;&i;6i ;'@
;(I"static VALUE
rb_zstream_closed_p(VALUE obj)
{
struct zstream *z;
TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z);
return ZSTREAM_IS_READY(z) ? Qfalse : Qtrue;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Zlib::ZStream#ended?;F;[ ;[[@i;T;:ended?;0;[ ;{ ;IC;"*Returns true if the stream is closed.;T;[o;2
;3I"return;F;4@|;0;5[@~; @;[ ;@;0; @;!F;"o;#;$T;%i;&i;6i ;'@
;(I"static VALUE
rb_zstream_closed_p(VALUE obj)
{
struct zstream *z;
TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z);
return ZSTREAM_IS_READY(z) ? Qfalse : Qtrue;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Zlib::ZStream#close;F;[ ;[[@iY;T;:
close;0;[ ;{ ;IC;"TCloses the stream. All operations on the closed stream will raise an
exception.
;T;[ ;[ ;I"UCloses the stream. All operations on the closed stream will raise an
exception.
;T;0; @;!F;"o;#;$T;%iU;&iW;'@
;(I"cstatic VALUE
rb_zstream_end(VALUE obj)
{
zstream_end(get_zstream(obj));
return Qnil;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Zlib::ZStream#end;F;[ ;[[@iY;T;;&;0;[ ;{ ;IC;"TCloses the stream. All operations on the closed stream will raise an
exception.
;T;[ ;[ ;@;0; @;!F;"o;#;$T;%iU;&iW;'@
;(I"cstatic VALUE
rb_zstream_end(VALUE obj)
{
zstream_end(get_zstream(obj));
return Qnil;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Zlib::ZStream#reset;F;[ ;[[@id;T;:
reset;0;[ ;{ ;IC;"_Resets and initializes the stream. All data in both input and output buffer
are discarded.
;T;[ ;[ ;I"`Resets and initializes the stream. All data in both input and output buffer
are discarded.
;T;0; @;!F;"o;#;$T;%i`;&ib;'@
;(I"gstatic VALUE
rb_zstream_reset(VALUE obj)
{
zstream_reset(get_zstream(obj));
return Qnil;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Zlib::ZStream#finish;F;[ ;[[@it;T;:finish;0;[ ;{ ;IC;"Finishes the stream and flushes output buffer. If a block is given each
chunk is yielded to the block until the input buffer has been flushed to
the output buffer.
;T;[o:YARD::Tags::OverloadTag
;3I"
overload;F;40;;<;50;)I"finish;T;IC;" ;T; @:
@summary0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"String;T; @;[ ;I"@return [String];T;0;6i ;[ ; @o;=
;3I"
overload;F;40;;<;50;)I"finish;T;IC;" ;T; @;>0;!F;[o;2
;3I"
yield;F;4I" ;T;0;5[I"
chunk;T; @o;2
;3I"return;F;4I" ;T;0;5[I"nil;T; @;[ ;I"!@yield [chunk]
@return [nil];T;0;6i ;[ ; @;[ ;I"Finishes the stream and flushes output buffer. If a block is given each
chunk is yielded to the block until the input buffer has been flushed to
the output buffer.
@overload finish
@return [String]
@overload finish
@yield [chunk]
@return [nil];T;0; @;!F;"o;#;$T;%ik;⁢'@
;(I"static VALUE
rb_zstream_finish(VALUE obj)
{
struct zstream *z = get_zstream(obj);
zstream_run(z, (Bytef*)"", 0, Z_FINISH);
return zstream_detach_buffer(z);
};T;)I"static VALUE;T;*To;;F;
;;;;I" Zlib::ZStream#flush_next_in;F;[ ;[[@i;T;:flush_next_in;0;[ ;{ ;IC;"
;T;[o;=
;3I"
overload;F;40;;?;50;)I"flush_next_in;T;IC;" ;T; @;>0;!F;[ ;[ ;I" ;T;0;6i ;[ ; @;[ ;I"
@overload flush_next_in;T;0; @;!F;"o;#;$T;%i~;&i;'@
;(I"static VALUE
rb_zstream_flush_next_in(VALUE obj)
{
struct zstream *z;
VALUE dst;
TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z);
dst = zstream_detach_input(z);
return dst;
};T;)I"static VALUE;T;*To;;F;
;;;;I"!Zlib::ZStream#flush_next_out;F;[ ;[[@i;T;:flush_next_out;0;[ ;{ ;IC;"Flushes output buffer and returns all data in that buffer. If a block is
given each chunk is yielded to the block until the current output buffer
has been flushed.
;T;[o;=
;3I"
overload;F;40;;@;50;)I"flush_next_out;T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"String;T; @;[ ;I"@return [String];T;0;6i ;[ ; @o;=
;3I"
overload;F;40;;@;50;)I"flush_next_out;T;IC;" ;T; @;>0;!F;[o;2
;3I"
yield;F;4I" ;T;0;5[I"
chunk;T; @o;2
;3I"return;F;4I" ;T;0;5[I"nil;T; @;[ ;I"!@yield [chunk]
@return [nil];T;0;6i ;[ ; @;[ ;I"Flushes output buffer and returns all data in that buffer. If a block is
given each chunk is yielded to the block until the current output buffer
has been flushed.
@overload flush_next_out
@return [String]
@overload flush_next_out
@yield [chunk]
@return [nil];T;0; @;!F;"o;#;$T;%i;&i;'@
;(I"static VALUE
rb_zstream_flush_next_out(VALUE obj)
{
struct zstream *z;
TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z);
return zstream_detach_buffer(z);
};T;)I"static VALUE;T;*T:@owner@
:@class_mixinsIC;[ ;A@
:@instance_mixinsIC;[ ;A@
:@attributesIC:SymbolHash{:
classIC;E{ :@symbolize_valueT;IC;E{ ;GT;GT:
@aliases{ :@groups[ ;[[@i[@i/;T;:ZStream;: ruby;;;[ ;{ ;IC;": Zlib::ZStream is the abstract class for the stream which handles the
compressed data. The operations are defined in the subclasses:
Zlib::Deflate for compression, and Zlib::Inflate for decompression.
An instance of Zlib::ZStream has one stream (struct zstream in the source)
and two variable-length buffers which associated to the input (next_in) of
the stream and the output (next_out) of the stream. In this document,
"input buffer" means the buffer for input, and "output buffer" means the
buffer for output.
Data input into an instance of Zlib::ZStream are temporally stored into
the end of input buffer, and then data in input buffer are processed from
the beginning of the buffer until no more output from the stream is
produced (i.e. until avail_out > 0 after processing). During processing,
output buffer is allocated and expanded automatically to hold all output
data.
Some particular instance methods consume the data in output buffer and
return them as a String.
Here is an ascii art for describing above:
+================ an instance of Zlib::ZStream ================+
|| ||
|| +--------+ +-------+ +--------+ ||
|| +--| output |<---------|zstream|<---------| input |<--+ ||
|| | | buffer | next_out+-------+next_in | buffer | | ||
|| | +--------+ +--------+ | ||
|| | | ||
+===|======================================================|===+
| |
v |
"output data" "input data"
If an error occurs during processing input buffer, an exception which is a
subclass of Zlib::Error is raised. At that time, both input and output
buffer keep their conditions at the time when the error occurs.
== Method Catalogue
Many of the methods in this class are fairly low-level and unlikely to be
of interest to users. In fact, users are unlikely to use this class
directly; rather they will be interested in Zlib::Inflate and
Zlib::Deflate.
The higher level methods are listed below.
- #total_in
- #total_out
- #data_type
- #adler
- #reset
- #finish
- #finished?
- #close
- #closed?;T;[ ;[ ;I"<
Zlib::ZStream is the abstract class for the stream which handles the
compressed data. The operations are defined in the subclasses:
Zlib::Deflate for compression, and Zlib::Inflate for decompression.
An instance of Zlib::ZStream has one stream (struct zstream in the source)
and two variable-length buffers which associated to the input (next_in) of
the stream and the output (next_out) of the stream. In this document,
"input buffer" means the buffer for input, and "output buffer" means the
buffer for output.
Data input into an instance of Zlib::ZStream are temporally stored into
the end of input buffer, and then data in input buffer are processed from
the beginning of the buffer until no more output from the stream is
produced (i.e. until avail_out > 0 after processing). During processing,
output buffer is allocated and expanded automatically to hold all output
data.
Some particular instance methods consume the data in output buffer and
return them as a String.
Here is an ascii art for describing above:
+================ an instance of Zlib::ZStream ================+
|| ||
|| +--------+ +-------+ +--------+ ||
|| +--| output |<---------|zstream|<---------| input |<--+ ||
|| | | buffer | next_out+-------+next_in | buffer | | ||
|| | +--------+ +--------+ | ||
|| | | ||
+===|======================================================|===+
| |
v |
"output data" "input data"
If an error occurs during processing input buffer, an exception which is a
subclass of Zlib::Error is raised. At that time, both input and output
buffer keep their conditions at the time when the error occurs.
== Method Catalogue
Many of the methods in this class are fairly low-level and unlikely to be
of interest to users. In fact, users are unlikely to use this class
directly; rather they will be interested in Zlib::Inflate and
Zlib::Deflate.
The higher level methods are listed below.
- #total_in
- #total_out
- #data_type
- #adler
- #reset
- #finish
- #finished?
- #close
- #closed?
;T;0; @
;!F;"o;#;$T;%i;&iQ;6i ;'o:YARD::CodeObjects::Proxy:@orignamespace0:@origname0:
@imethod0;: Zlib;'@: @obj@:
@type0;I"Zlib::ZStream;F:@superclasso;L;M0;N0;O0;:Object;'@;Qo;
;IC;[;o;;F;
;;;;I"Object#extend;F;[[I"
*args;T0;[[I"eval.c;Ti;T;:extend;0;[ ;{ ;IC;"sAdds to _obj_ the instance methods from each module given as a
parameter.
module Mod
def hello
"Hello from Mod.\n"
end
end
class Klass
def hello
"Hello from Klass.\n"
end
end
k = Klass.new
k.hello #=> "Hello from Klass.\n"
k.extend(Mod) #=> #
k.hello #=> "Hello from Mod.\n"
;T;[o;=
;3I"
overload;F;40;;U;50;)I"extend(module, ...);T;IC;" ;T; @_;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @_;[ ;I"@return [Object];T;0;6i ;[ ; @_;[ ;I"Adds to _obj_ the instance methods from each module given as a
parameter.
module Mod
def hello
"Hello from Mod.\n"
end
end
class Klass
def hello
"Hello from Klass.\n"
end
end
k = Klass.new
k.hello #=> "Hello from Klass.\n"
k.extend(Mod) #=> #
k.hello #=> "Hello from Mod.\n"
@overload extend(module, ...)
@return [Object];T;0; @_;!F;"o;#;$T;%i;&i;'@];(I"static VALUE
rb_obj_extend(int argc, VALUE *argv, VALUE obj)
{
int i;
ID id_extend_object, id_extended;
CONST_ID(id_extend_object, "extend_object");
CONST_ID(id_extended, "extended");
rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
for (i = 0; i < argc; i++)
Check_Type(argv[i], T_MODULE);
while (argc--) {
rb_funcall(argv[argc], id_extend_object, 1, obj);
rb_funcall(argv[argc], id_extended, 1, obj);
}
return obj;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Object#respond_to?;F;[[@c0;[[I"vm_method.c;Ti
;T;:respond_to?;0;[ ;{ ;IC;"Returns +true+ if _obj_ responds to the given method. Private and
protected methods are included in the search only if the optional
second parameter evaluates to +true+.
If the method is not implemented,
as Process.fork on Windows, File.lchmod on GNU/Linux, etc.,
false is returned.
If the method is not defined, respond_to_missing?
method is called and the result is returned.
When the method name parameter is given as a string, the string is
converted to a symbol.;T;[o;=
;3I"
overload;F;40;;V;50;)I"+respond_to?(symbol, include_all=false);T;IC;" ;T; @};>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @};[ ;I"@return [Boolean];T;0;6i ;[[I"symbol;T0[I"include_all;TI"
false;T; @}o;=
;3I"
overload;F;40;;V;50;)I"+respond_to?(string, include_all=false);T;IC;" ;T; @};>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @};[ ;I"@return [Boolean];T;0;6i ;[[I"string;T0[I"include_all;TI"
false;T; @};[ ;I"pReturns +true+ if _obj_ responds to the given method. Private and
protected methods are included in the search only if the optional
second parameter evaluates to +true+.
If the method is not implemented,
as Process.fork on Windows, File.lchmod on GNU/Linux, etc.,
false is returned.
If the method is not defined, respond_to_missing?
method is called and the result is returned.
When the method name parameter is given as a string, the string is
converted to a symbol.
@overload respond_to?(symbol, include_all=false)
@return [Boolean]
@overload respond_to?(string, include_all=false)
@return [Boolean];T;0; @};!F;"o;#;$T;%i
;&i
;6i ;'@];(I"static VALUE
obj_respond_to(int argc, VALUE *argv, VALUE obj)
{
VALUE mid, priv;
ID id;
rb_execution_context_t *ec = GET_EC();
rb_scan_args(argc, argv, "11", &mid, &priv);
if (!(id = rb_check_id(&mid))) {
VALUE ret = basic_obj_respond_to_missing(ec, CLASS_OF(obj), obj,
rb_to_symbol(mid), priv);
if (ret == Qundef) ret = Qfalse;
return ret;
}
if (basic_obj_respond_to(ec, obj, id, !RTEST(priv)))
return Qtrue;
return Qfalse;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Object#respond_to_missing?;F;[[I"mid;T0[I" priv;T0;[[@i=
;T;:respond_to_missing?;0;[ ;{ ;IC;"DO NOT USE THIS DIRECTLY.
Hook method to return whether the _obj_ can respond to _id_ method
or not.
When the method name parameter is given as a string, the string is
converted to a symbol.
See #respond_to?, and the example of BasicObject.;T;[o;=
;3I"
overload;F;40;;W;50;)I"-respond_to_missing?(symbol, include_all);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @;[ ;I"@return [Boolean];T;0;6i ;[[I"symbol;T0[I"include_all;T0; @o;=
;3I"
overload;F;40;;W;50;)I"-respond_to_missing?(string, include_all);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @;[ ;I"@return [Boolean];T;0;6i ;[[I"string;T0[I"include_all;T0; @;[ ;I"DO NOT USE THIS DIRECTLY.
Hook method to return whether the _obj_ can respond to _id_ method
or not.
When the method name parameter is given as a string, the string is
converted to a symbol.
See #respond_to?, and the example of BasicObject.
@overload respond_to_missing?(symbol, include_all)
@return [Boolean]
@overload respond_to_missing?(string, include_all)
@return [Boolean];T;0; @;!F;"o;#;$T;%i.
;&i<
;6i ;'@];(I"astatic VALUE
obj_respond_to_missing(VALUE obj, VALUE mid, VALUE priv)
{
return Qfalse;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Object#to_enum;F;[[@c0;[[I"enumerator.c;Tip;T;:to_enum;0;[ ;{ ;IC;"{Creates a new Enumerator which will enumerate by calling +method+ on
+obj+, passing +args+ if any. What was _yielded_ by method becomes
values of enumerator.
If a block is given, it will be used to calculate the size of
the enumerator without the need to iterate it (see Enumerator#size).
=== Examples
str = "xyz"
enum = str.enum_for(:each_byte)
enum.each { |b| puts b }
# => 120
# => 121
# => 122
# protect an array from being modified by some_method
a = [1, 2, 3]
some_method(a.to_enum)
# String#split in block form is more memory-effective:
very_large_string.split("|") { |chunk| return chunk if chunk.include?('DATE') }
# This could be rewritten more idiomatically with to_enum:
very_large_string.to_enum(:split, "|").lazy.grep(/DATE/).first
It is typical to call to_enum when defining methods for
a generic Enumerable, in case no block is passed.
Here is such an example, with parameter passing and a sizing block:
module Enumerable
# a generic method to repeat the values of any enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
return to_enum(__method__, n) do # __method__ is :repeat here
sz = size # Call size and multiply by n...
sz * n if sz # but return nil if size itself is nil
end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => Prints 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => returns an Enumerator when called without a block
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
;T;[ o;=
;3I"
overload;F;40;;X;50;)I"#to_enum(method = :each, *args);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Enumerator;T; @;[ ;I"@return [Enumerator];T;0;6i ;[[I"method;TI"
:each;T[I"
*args;T0; @o;=
;3I"
overload;F;40;:
enum_for;50;)I"$enum_for(method = :each, *args);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Enumerator;T; @;[ ;I"@return [Enumerator];T;0;6i ;[[I"method;TI"
:each;T[I"
*args;T0; @o;=
;3I"
overload;F;40;;X;50;)I"#to_enum(method = :each, *args);T;IC;" ;T; @;>0;!F;[o;2
;3I"
yield;F;4I" ;T;0;5[I"
*args;T; @o;2
;3I"return;F;4I" ;T;0;5[I"Enumerator;T; @;[ ;I"(@yield [*args]
@return [Enumerator];T;0;6i ;[[I"method;TI"
:each;T[I"
*args;T0; @o;=
;3I"
overload;F;40;;Y;50;)I"$enum_for(method = :each, *args);T;IC;" ;T; @;>0;!F;[o;2
;3I"
yield;F;4I" ;T;0;5[I"
*args;T; @o;2
;3I"return;F;4I" ;T;0;5[I"Enumerator;T; @;[ ;I"(@yield [*args]
@return [Enumerator];T;0;6i ;[[I"method;TI"
:each;T[I"
*args;T0; @;[ ;I"Creates a new Enumerator which will enumerate by calling +method+ on
+obj+, passing +args+ if any. What was _yielded_ by method becomes
values of enumerator.
If a block is given, it will be used to calculate the size of
the enumerator without the need to iterate it (see Enumerator#size).
=== Examples
str = "xyz"
enum = str.enum_for(:each_byte)
enum.each { |b| puts b }
# => 120
# => 121
# => 122
# protect an array from being modified by some_method
a = [1, 2, 3]
some_method(a.to_enum)
# String#split in block form is more memory-effective:
very_large_string.split("|") { |chunk| return chunk if chunk.include?('DATE') }
# This could be rewritten more idiomatically with to_enum:
very_large_string.to_enum(:split, "|").lazy.grep(/DATE/).first
It is typical to call to_enum when defining methods for
a generic Enumerable, in case no block is passed.
Here is such an example, with parameter passing and a sizing block:
module Enumerable
# a generic method to repeat the values of any enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
return to_enum(__method__, n) do # __method__ is :repeat here
sz = size # Call size and multiply by n...
sz * n if sz # but return nil if size itself is nil
end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => Prints 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => returns an Enumerator when called without a block
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
@overload to_enum(method = :each, *args)
@return [Enumerator]
@overload enum_for(method = :each, *args)
@return [Enumerator]
@overload to_enum(method = :each, *args)
@yield [*args]
@return [Enumerator]
@overload enum_for(method = :each, *args)
@yield [*args]
@return [Enumerator];T;0; @;!F;"o;#;$T;%i3;&is;'@];(I"Qstatic VALUE
obj_to_enum(int argc, VALUE *argv, VALUE obj)
{
VALUE enumerator, meth = sym_each;
if (argc > 0) {
--argc;
meth = *argv++;
}
enumerator = rb_enumeratorize_with_size(obj, meth, argc, argv, 0);
if (rb_block_given_p()) {
enumerator_ptr(enumerator)->size = rb_block_proc();
}
return enumerator;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Object#enum_for;F;[[@c0;[[@ip;T;;Y;0;[ ;{ ;IC;"{Creates a new Enumerator which will enumerate by calling +method+ on
+obj+, passing +args+ if any. What was _yielded_ by method becomes
values of enumerator.
If a block is given, it will be used to calculate the size of
the enumerator without the need to iterate it (see Enumerator#size).
=== Examples
str = "xyz"
enum = str.enum_for(:each_byte)
enum.each { |b| puts b }
# => 120
# => 121
# => 122
# protect an array from being modified by some_method
a = [1, 2, 3]
some_method(a.to_enum)
# String#split in block form is more memory-effective:
very_large_string.split("|") { |chunk| return chunk if chunk.include?('DATE') }
# This could be rewritten more idiomatically with to_enum:
very_large_string.to_enum(:split, "|").lazy.grep(/DATE/).first
It is typical to call to_enum when defining methods for
a generic Enumerable, in case no block is passed.
Here is such an example, with parameter passing and a sizing block:
module Enumerable
# a generic method to repeat the values of any enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
return to_enum(__method__, n) do # __method__ is :repeat here
sz = size # Call size and multiply by n...
sz * n if sz # but return nil if size itself is nil
end
end
each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => Prints 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => returns an Enumerator when called without a block
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
;T;[ o;=
;3I"
overload;F;40;;X;50;)I"#to_enum(method = :each, *args);T;IC;" ;T; @G;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Enumerator;T; @G;[ ;I"@return [Enumerator];T;0;6i ;[[I"method;TI"
:each;T[I"
*args;T0; @Go;=
;3I"
overload;F;40;;Y;50;)I"$enum_for(method = :each, *args);T;IC;" ;T; @G;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Enumerator;T; @G;[ ;I"@return [Enumerator];T;0;6i ;[[I"method;TI"
:each;T[I"
*args;T0; @Go;=
;3I"
overload;F;40;;X;50;)I"#to_enum(method = :each, *args);T;IC;" ;T; @G;>0;!F;[o;2
;3I"
yield;F;4I" ;T;0;5[I"
*args;T; @Go;2
;3I"return;F;4I" ;T;0;5[I"Enumerator;T; @G;[ ;I"(@yield [*args]
@return [Enumerator];T;0;6i ;[[I"method;TI"
:each;T[I"
*args;T0; @Go;=
;3I"
overload;F;40;;Y;50;)I"$enum_for(method = :each, *args);T;IC;" ;T; @G;>0;!F;[o;2
;3I"
yield;F;4I" ;T;0;5[I"
*args;T; @Go;2
;3I"return;F;4I" ;T;0;5[I"Enumerator;T; @G;[ ;I"(@yield [*args]
@return [Enumerator];T;0;6i ;[[I"method;TI"
:each;T[I"
*args;T0; @G;[ ;@C;0; @G;!F;"o;#;$T;%i3;&is;'@];(I"Qstatic VALUE
obj_to_enum(int argc, VALUE *argv, VALUE obj)
{
VALUE enumerator, meth = sym_each;
if (argc > 0) {
--argc;
meth = *argv++;
}
enumerator = rb_enumeratorize_with_size(obj, meth, argc, argv, 0);
if (rb_block_given_p()) {
enumerator_ptr(enumerator)->size = rb_block_proc();
}
return enumerator;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Object#display;F;[[@c0;[[I" io.c;Tih;T;:display;0;[ ;{ ;IC;"Prints obj on the given port (default $>
).
Equivalent to:
def display(port=$>)
port.write self
nil
end
For example:
1.display
"cat".display
[ 4, 5, 6 ].display
puts
produces:
1cat[4, 5, 6]
;T;[o;=
;3I"
overload;F;40;;Z;50;)I"display(port=$>);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"nil;T; @;[ ;I"@return [nil];T;0;6i ;[[I" port;TI"$>;T; @;[ ;I"*Prints obj on the given port (default $>
).
Equivalent to:
def display(port=$>)
port.write self
nil
end
For example:
1.display
"cat".display
[ 4, 5, 6 ].display
puts
produces:
1cat[4, 5, 6]
@overload display(port=$>)
@return [nil];T;0; @;!F;"o;#;$T;%iP;&ie;'@];(I"static VALUE
rb_obj_display(int argc, VALUE *argv, VALUE self)
{
VALUE out;
out = (!rb_check_arity(argc, 0, 1) ? rb_ractor_stdout() : argv[0]);
rb_io_write(out, self);
return Qnil;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Object#nil?;F;[ ;[[I"
object.c;Ti#;T;: nil?;0;[ ;{ ;IC;"Only the object nil responds true
to nil?
.
Object.new.nil? #=> false
nil.nil? #=> true;T;[o;=
;3I"
overload;F;40;;[;50;)I" nil?;T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @;[ ;I"@return [Boolean];T;0;6i ;[ ; @;[ ;I"Only the object nil responds true
to nil?
.
Object.new.nil? #=> false
nil.nil? #=> true
@overload nil?
@return [Boolean];T;0; @;!F;"o;#;$T;%i;&i;6i ;'@];(I"HMJIT_FUNC_EXPORTED VALUE
rb_false(VALUE obj)
{
return Qfalse;
};T;)I"MJIT_FUNC_EXPORTED VALUE;T;*To;;F;
;;;;I"Object#===;F;[ ;[ ;F;:===;;K;[ ;{ ;IC;" ;T;[ ;[ ;@|;0; @;'@];*To;;F;
;;;;I"Object#=~;F;[[I" obj2;T0;[[@i4;T;:=~;0;[ ;{ ;IC;"pThis method is deprecated.
This is not only useless but also troublesome because it may hide a
type error.
;T;[o;=
;3I"
overload;F;40;;];50;)I"=~(other);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"nil;T; @;[ ;I"@return [nil];T;0;6i ;[[I"
other;T0; @;[ ;I"This method is deprecated.
This is not only useless but also troublesome because it may hide a
type error.
@overload =~(other)
@return [nil];T;0; @;!F;"o;#;$T;%i*;&i1;'@];(I"7static VALUE
rb_obj_match(VALUE obj1, VALUE obj2)
{
if (rb_warning_category_enabled_p(RB_WARN_CATEGORY_DEPRECATED)) {
rb_category_warn(RB_WARN_CATEGORY_DEPRECATED, "deprecated Object#=~ is called on %"PRIsVALUE
"; it always returns nil", rb_obj_class(obj1));
}
return Qnil;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Object#!~;F;[[I" obj2;T0;[[@iF;T;:!~;0;[ ;{ ;IC;"\Returns true if two objects do not match (using the =~
method), otherwise false.
;T;[o;=
;3I"
overload;F;40;;^;50;)I"!~(other);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @;[ ;I"@return [Boolean];T;0;6i ;[[I"
other;T0; @;[ ;I"Returns true if two objects do not match (using the =~
method), otherwise false.
@overload !~(other)
@return [Boolean];T;0; @;!F;"o;#;$T;%i>;&iC;'@];(I"static VALUE
rb_obj_not_match(VALUE obj1, VALUE obj2)
{
VALUE result = rb_funcall(obj1, id_match, 1, obj2);
return RTEST(result) ? Qfalse : Qtrue;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Object#eql?;F;[[I" obj2;T0;[[@i;T;: eql?;0;[ ;{ ;IC;"Equality --- At the Object level, #== returns true
only if +obj+ and +other+ are the same object. Typically, this
method is overridden in descendant classes to provide
class-specific meaning.
Unlike #==, the #equal? method should never be overridden by
subclasses as it is used to determine object identity (that is,
a.equal?(b)
if and only if a
is the same
object as b
):
obj = "a"
other = obj.dup
obj == other #=> true
obj.equal? other #=> false
obj.equal? obj #=> true
The #eql? method returns true
if +obj+ and +other+
refer to the same hash key. This is used by Hash to test members
for equality. For any pair of objects where #eql? returns +true+,
the #hash value of both objects must be equal. So any subclass
that overrides #eql? should also override #hash appropriately.
For objects of class Object, #eql? is synonymous
with #==. Subclasses normally continue this tradition by aliasing
#eql? to their overridden #== method, but there are exceptions.
Numeric types, for example, perform type conversion across #==,
but not across #eql?, so:
1 == 1.0 #=> true
1.eql? 1.0 #=> false;T;[o;=
;3I"
overload;F;40;:==;50;)I"==(other);T;IC;" ;T; @*;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @*;[ ;I"@return [Boolean];T;0;6i ;[[I"
other;T0; @*o;=
;3I"
overload;F;40;:equal?;50;)I"equal?(other);T;IC;" ;T; @*;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @*;[ ;I"@return [Boolean];T;0;6i ;[[I"
other;T0; @*o;=
;3I"
overload;F;40;;_;50;)I"eql?(other);T;IC;" ;T; @*;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @*;[ ;I"@return [Boolean];T;0;6i ;[[I"
other;T0; @*;[ ;I"*Equality --- At the Object level, #== returns true
only if +obj+ and +other+ are the same object. Typically, this
method is overridden in descendant classes to provide
class-specific meaning.
Unlike #==, the #equal? method should never be overridden by
subclasses as it is used to determine object identity (that is,
a.equal?(b)
if and only if a
is the same
object as b
):
obj = "a"
other = obj.dup
obj == other #=> true
obj.equal? other #=> false
obj.equal? obj #=> true
The #eql? method returns true
if +obj+ and +other+
refer to the same hash key. This is used by Hash to test members
for equality. For any pair of objects where #eql? returns +true+,
the #hash value of both objects must be equal. So any subclass
that overrides #eql? should also override #hash appropriately.
For objects of class Object, #eql? is synonymous
with #==. Subclasses normally continue this tradition by aliasing
#eql? to their overridden #== method, but there are exceptions.
Numeric types, for example, perform type conversion across #==,
but not across #eql?, so:
1 == 1.0 #=> true
1.eql? 1.0 #=> false
@overload ==(other)
@return [Boolean]
@overload equal?(other)
@return [Boolean]
@overload eql?(other)
@return [Boolean];T;0; @*;!F;"o;#;$T;%i;&i;6i ;'@];(I"}MJIT_FUNC_EXPORTED VALUE
rb_obj_equal(VALUE obj1, VALUE obj2)
{
if (obj1 == obj2) return Qtrue;
return Qfalse;
};T;)I"MJIT_FUNC_EXPORTED VALUE;T;*To;;F;
;;;;I"Object#hash;F;[ ;[[@i;T;: hash;0;[ ;{ ;IC;" ;T;[ ;[ ;@|;0; @g;'@];(I""VALUE rb_obj_hash(VALUE obj);;T;)I""VALUE rb_obj_hash(VALUE obj);;T;*To;;F;
;;;;I"Object#<=>;F;[[I" obj2;T0;[[@i`;T;:<=>;0;[ ;{ ;IC;"%Returns 0 if +obj+ and +other+ are the same object
or obj == other
, otherwise nil.
The #<=> is used by various methods to compare objects, for example
Enumerable#sort, Enumerable#max etc.
Your implementation of #<=> should return one of the following values: -1, 0,
1 or nil. -1 means self is smaller than other. 0 means self is equal to other.
1 means self is bigger than other. Nil means the two values could not be
compared.
When you define #<=>, you can include Comparable to gain the
methods #<=, #<, #==, #>=, #> and #between?.
;T;[o;=
;3I"
overload;F;40;;c;50;)I"<=>(other);T;IC;" ;T; @s;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"0;TI"nil;T; @s;[ ;I"@return [0, nil];T;0;6i ;[[I"
other;T0; @s;[ ;I"OReturns 0 if +obj+ and +other+ are the same object
or obj == other
, otherwise nil.
The #<=> is used by various methods to compare objects, for example
Enumerable#sort, Enumerable#max etc.
Your implementation of #<=> should return one of the following values: -1, 0,
1 or nil. -1 means self is smaller than other. 0 means self is equal to other.
1 means self is bigger than other. Nil means the two values could not be
compared.
When you define #<=>, you can include Comparable to gain the
methods #<=, #<, #==, #>=, #> and #between?.
@overload <=>(other)
@return [0, nil];T;0; @s;!F;"o;#;$T;%iN;&i^;'@];(I"{static VALUE
rb_obj_cmp(VALUE obj1, VALUE obj2)
{
if (rb_equal(obj1, obj2))
return INT2FIX(0);
return Qnil;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Object#singleton_class;F;[ ;[[@i=;T;:singleton_class;0;[ ;{ ;IC;"Returns the singleton class of obj. This method creates
a new singleton class if obj does not have one.
If obj is nil
, true
, or
false
, it returns NilClass, TrueClass, or FalseClass,
respectively.
If obj is an Integer, a Float or a Symbol, it raises a TypeError.
Object.new.singleton_class #=> #>
String.singleton_class #=> #
nil.singleton_class #=> NilClass
;T;[o;=
;3I"
overload;F;40;;d;50;)I"singleton_class;T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"
Class;T; @;[ ;I"@return [Class];T;0;6i ;[ ; @;[ ;I"Returns the singleton class of obj. This method creates
a new singleton class if obj does not have one.
If obj is nil
, true
, or
false
, it returns NilClass, TrueClass, or FalseClass,
respectively.
If obj is an Integer, a Float or a Symbol, it raises a TypeError.
Object.new.singleton_class #=> #>
String.singleton_class #=> #
nil.singleton_class #=> NilClass
@overload singleton_class
@return [Class];T;0; @;!F;"o;#;$T;%i,;&i:;'@];(I"[static VALUE
rb_obj_singleton_class(VALUE obj)
{
return rb_singleton_class(obj);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Object#dup;F;[ ;[[@i.;T;:dup;0;[ ;{ ;IC;"Produces a shallow copy of obj---the instance variables of
obj are copied, but not the objects they reference.
This method may have class-specific behavior. If so, that
behavior will be documented under the #+initialize_copy+ method of
the class.
=== on dup vs clone
In general, #clone and #dup may have different semantics in
descendant classes. While #clone is used to duplicate an object,
including its internal state, #dup typically uses the class of the
descendant object to create the new instance.
When using #dup, any modules that the object has been extended with will not
be copied.
class Klass
attr_accessor :str
end
module Foo
def foo; 'foo'; end
end
s1 = Klass.new #=> #
s1.extend(Foo) #=> #
s1.foo #=> "foo"
s2 = s1.clone #=> #
s2.foo #=> "foo"
s3 = s1.dup #=> #
s3.foo #=> NoMethodError: undefined method `foo' for #
;T;[o;=
;3I"
overload;F;40;;e;50;)I"dup;T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @;[ ;I"@return [Object];T;0;6i ;[ ; @;[ ;I"Produces a shallow copy of obj---the instance variables of
obj are copied, but not the objects they reference.
This method may have class-specific behavior. If so, that
behavior will be documented under the #+initialize_copy+ method of
the class.
=== on dup vs clone
In general, #clone and #dup may have different semantics in
descendant classes. While #clone is used to duplicate an object,
including its internal state, #dup typically uses the class of the
descendant object to create the new instance.
When using #dup, any modules that the object has been extended with will not
be copied.
class Klass
attr_accessor :str
end
module Foo
def foo; 'foo'; end
end
s1 = Klass.new #=> #
s1.extend(Foo) #=> #
s1.foo #=> "foo"
s2 = s1.clone #=> #
s2.foo #=> "foo"
s3 = s1.dup #=> #
s3.foo #=> NoMethodError: undefined method `foo' for #
@overload dup
@return [Object];T;0; @;!F;"o;#;$T;%i;&i*;'@];(I"VALUE
rb_obj_dup(VALUE obj)
{
VALUE dup;
if (special_object_p(obj)) {
return obj;
}
dup = rb_obj_alloc(rb_obj_class(obj));
init_copy(dup, obj);
rb_funcall(dup, id_init_dup, 1, obj);
return dup;
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#itself;F;[ ;[[@iH;T;:itself;0;[ ;{ ;IC;"mReturns the receiver.
string = "my string"
string.itself.object_id == string.object_id #=> true
;T;[o;=
;3I"
overload;F;40;;f;50;)I"itself;T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @;[ ;I"@return [Object];T;0;6i ;[ ; @;[ ;I"Returns the receiver.
string = "my string"
string.itself.object_id == string.object_id #=> true
@overload itself
@return [Object];T;0; @;!F;"o;#;$T;%i=;&iE;'@];(I">static VALUE
rb_obj_itself(VALUE obj)
{
return obj;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Object#initialize_copy;F;[[I" orig;T0;[[@ib;T;:initialize_copy;0;[ ;{ ;IC;":nodoc:
;T;[ ;[ ;I":nodoc:
;T;0; @;!F;"o;#;$T;%iZ;&i\;'@];(I"VALUE
rb_obj_init_copy(VALUE obj, VALUE orig)
{
if (obj == orig) return obj;
rb_check_frozen(obj);
if (TYPE(obj) != TYPE(orig) || rb_obj_class(obj) != rb_obj_class(orig)) {
rb_raise(rb_eTypeError, "initialize_copy should take same class object");
}
return obj;
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#initialize_dup;F;[[I" orig;T0;[[@iv;T;:initialize_dup;0;[ ;{ ;IC;"!
:nodoc:
;T;[ ;[ ;I"!
:nodoc:
;T;0; @;!F;"o;#;$T;%im;&ip;'@];(I"wVALUE
rb_obj_init_dup_clone(VALUE obj, VALUE orig)
{
rb_funcall(obj, id_init_copy, 1, orig);
return obj;
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#initialize_clone;F;[[@c0;[[@i;T;:initialize_clone;0;[ ;{ ;IC;"!
:nodoc:
;T;[ ;[ ;I"!
:nodoc:
;T;0; @;!F;"o;#;$T;%i};&i;'@];(I"static VALUE
rb_obj_init_clone(int argc, VALUE *argv, VALUE obj)
{
VALUE orig, opts;
rb_scan_args(argc, argv, "1:", &orig, &opts);
/* Ignore a freeze keyword */
if (argc == 2) (void)freeze_opt(1, &opts);
rb_funcall(obj, id_init_copy, 1, orig);
return obj;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Object#taint;F;[ ;[[@i;T;:
taint;0;[ ;{ ;IC;"OReturns object. This method is deprecated and will be removed in Ruby 3.2.
;T;[o;=
;3I"
overload;F;40;;j;50;)I"
taint;T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @;[ ;I"@return [Object];T;0;6i ;[ ; @;[ ;I"tReturns object. This method is deprecated and will be removed in Ruby 3.2.
@overload taint
@return [Object];T;0; @;!F;"o;#;$T;%i;&i;'@];(I"oVALUE
rb_obj_taint(VALUE obj)
{
rb_warn_deprecated_to_remove("Object#taint", "3.2");
return obj;
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#tainted?;F;[ ;[[@i;T;:
tainted?;0;[ ;{ ;IC;"OReturns false. This method is deprecated and will be removed in Ruby 3.2.;T;[o;=
;3I"
overload;F;40;;k;50;)I"
tainted?;T;IC;" ;T; @.;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"
false;T; @.;[ ;I"@return [false];T;0;6i ;[ ; @.;[ ;I"vReturns false. This method is deprecated and will be removed in Ruby 3.2.
@overload tainted?
@return [false];T;0; @.;!F;"o;#;$T;%i;&i;6i ;'@];(I"wVALUE
rb_obj_tainted(VALUE obj)
{
rb_warn_deprecated_to_remove("Object#tainted?", "3.2");
return Qfalse;
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#untaint;F;[ ;[[@i;T;:untaint;0;[ ;{ ;IC;"OReturns object. This method is deprecated and will be removed in Ruby 3.2.
;T;[o;=
;3I"
overload;F;40;;l;50;)I"untaint;T;IC;" ;T; @I;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @I;[ ;I"@return [Object];T;0;6i ;[ ; @I;[ ;I"vReturns object. This method is deprecated and will be removed in Ruby 3.2.
@overload untaint
@return [Object];T;0; @I;!F;"o;#;$T;%i;&i;'@];(I"sVALUE
rb_obj_untaint(VALUE obj)
{
rb_warn_deprecated_to_remove("Object#untaint", "3.2");
return obj;
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#untrust;F;[ ;[[@i;T;:untrust;0;[ ;{ ;IC;"OReturns object. This method is deprecated and will be removed in Ruby 3.2.
;T;[o;=
;3I"
overload;F;40;;m;50;)I"untrust;T;IC;" ;T; @d;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @d;[ ;I"@return [Object];T;0;6i ;[ ; @d;[ ;I"vReturns object. This method is deprecated and will be removed in Ruby 3.2.
@overload untrust
@return [Object];T;0; @d;!F;"o;#;$T;%i;&i;'@];(I"sVALUE
rb_obj_untrust(VALUE obj)
{
rb_warn_deprecated_to_remove("Object#untrust", "3.2");
return obj;
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#untrusted?;F;[ ;[[@i;T;:untrusted?;0;[ ;{ ;IC;"OReturns false. This method is deprecated and will be removed in Ruby 3.2.;T;[o;=
;3I"
overload;F;40;;n;50;)I"untrusted?;T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"
false;T; @;[ ;I"@return [false];T;0;6i ;[ ; @;[ ;I"xReturns false. This method is deprecated and will be removed in Ruby 3.2.
@overload untrusted?
@return [false];T;0; @;!F;"o;#;$T;%i;&i;6i ;'@];(I"{VALUE
rb_obj_untrusted(VALUE obj)
{
rb_warn_deprecated_to_remove("Object#untrusted?", "3.2");
return Qfalse;
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#trust;F;[ ;[[@i;T;:
trust;0;[ ;{ ;IC;"OReturns object. This method is deprecated and will be removed in Ruby 3.2.
;T;[o;=
;3I"
overload;F;40;;o;50;)I"
trust;T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @;[ ;I"@return [Object];T;0;6i ;[ ; @;[ ;I"tReturns object. This method is deprecated and will be removed in Ruby 3.2.
@overload trust
@return [Object];T;0; @;!F;"o;#;$T;%i;&i;'@];(I"oVALUE
rb_obj_trust(VALUE obj)
{
rb_warn_deprecated_to_remove("Object#trust", "3.2");
return obj;
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#freeze;F;[ ;[[@i;T;:freeze;0;[ ;{ ;IC;"Prevents further modifications to obj. A
RuntimeError will be raised if modification is attempted.
There is no way to unfreeze a frozen object. See also
Object#frozen?.
This method returns self.
a = [ "a", "b", "c" ]
a.freeze
a << "z"
produces:
prog.rb:3:in `<<': can't modify frozen Array (FrozenError)
from prog.rb:3
Objects of the following classes are always frozen: Integer,
Float, Symbol.
;T;[o;=
;3I"
overload;F;40;;p;50;)I"freeze;T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @;[ ;I"@return [Object];T;0;6i ;[ ; @;[ ;I"Prevents further modifications to obj. A
RuntimeError will be raised if modification is attempted.
There is no way to unfreeze a frozen object. See also
Object#frozen?.
This method returns self.
a = [ "a", "b", "c" ]
a.freeze
a << "z"
produces:
prog.rb:3:in `<<': can't modify frozen Array (FrozenError)
from prog.rb:3
Objects of the following classes are always frozen: Integer,
Float, Symbol.
@overload freeze
@return [Object];T;0; @;!F;"o;#;$T;%i;&i;'@];(I"VALUE
rb_obj_freeze(VALUE obj)
{
if (!OBJ_FROZEN(obj)) {
OBJ_FREEZE(obj);
if (SPECIAL_CONST_P(obj)) {
rb_bug("special consts should be frozen.");
}
}
return obj;
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#to_s;F;[ ;[[@i;T;: to_s;0;[ ;{ ;IC;"Returns a string representing obj. The default #to_s prints
the object's class and an encoding of the object id. As a special
case, the top-level object that is the initial execution context
of Ruby programs returns ``main''.
;T;[o;=
;3I"
overload;F;40;;q;50;)I" to_s;T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"String;T; @;[ ;I"@return [String];T;0;6i ;[ ; @;[ ;I"Returns a string representing obj. The default #to_s prints
the object's class and an encoding of the object id. As a special
case, the top-level object that is the initial execution context
of Ruby programs returns ``main''.
@overload to_s
@return [String];T;0; @;!F;"o;#;$T;%i;&i;'@];(I"VALUE
rb_any_to_s(VALUE obj)
{
VALUE str;
VALUE cname = rb_class_name(CLASS_OF(obj));
str = rb_sprintf("#<%"PRIsVALUE":%p>", cname, (void*)obj);
return str;
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#inspect;F;[ ;[[@i ;T;:inspect;0;[ ;{ ;IC;"7Returns a string containing a human-readable representation of obj.
The default #inspect shows the object's class name, an encoding of
its memory address, and a list of the instance variables and their
values (by calling #inspect on each of them). User defined classes
should override this method to provide a better representation of
obj. When overriding this method, it should return a string
whose encoding is compatible with the default external encoding.
[ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]"
Time.new.inspect #=> "2008-03-08 19:43:39 +0900"
class Foo
end
Foo.new.inspect #=> "#"
class Bar
def initialize
@bar = 1
end
end
Bar.new.inspect #=> "#"
;T;[o;=
;3I"
overload;F;40;;r;50;)I"inspect;T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"String;T; @;[ ;I"@return [String];T;0;6i ;[ ; @;[ ;I"^Returns a string containing a human-readable representation of obj.
The default #inspect shows the object's class name, an encoding of
its memory address, and a list of the instance variables and their
values (by calling #inspect on each of them). User defined classes
should override this method to provide a better representation of
obj. When overriding this method, it should return a string
whose encoding is compatible with the default external encoding.
[ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]"
Time.new.inspect #=> "2008-03-08 19:43:39 +0900"
class Foo
end
Foo.new.inspect #=> "#"
class Bar
def initialize
@bar = 1
end
end
Bar.new.inspect #=> "#"
@overload inspect
@return [String];T;0; @;!F;"o;#;$T;%i;&i;'@];(I"static VALUE
rb_obj_inspect(VALUE obj)
{
if (rb_ivar_count(obj) > 0) {
VALUE str;
VALUE c = rb_class_name(CLASS_OF(obj));
str = rb_sprintf("-<%"PRIsVALUE":%p", c, (void*)obj);
return rb_exec_recursive(inspect_obj, obj, str);
}
else {
return rb_any_to_s(obj);
}
};T;)I"static VALUE;T;*To;;F;
;;;;I"Object#methods;F;[[@c0;[[I"class.c;Ti;T;:methods;0;[ ;{ ;IC;",Returns a list of the names of public and protected methods of
obj. This will include all the methods accessible in
obj's ancestors.
If the optional parameter is false
, it
returns an array of obj's public and protected singleton methods,
the array will not include methods in modules included in obj.
class Klass
def klass_method()
end
end
k = Klass.new
k.methods[0..9] #=> [:klass_method, :nil?, :===,
# :==~, :!, :eql?
# :hash, :<=>, :class, :singleton_class]
k.methods.length #=> 56
k.methods(false) #=> []
def k.singleton_method; end
k.methods(false) #=> [:singleton_method]
module M123; def m123; end end
k.extend M123
k.methods(false) #=> [:singleton_method]
;T;[o;=
;3I"
overload;F;40;;s;50;)I"methods(regular=true);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"
Array;T; @;[ ;I"@return [Array];T;0;6i ;[[I"regular;TI" true;T; @;[ ;I"`Returns a list of the names of public and protected methods of
obj. This will include all the methods accessible in
obj's ancestors.
If the optional parameter is false
, it
returns an array of obj's public and protected singleton methods,
the array will not include methods in modules included in obj.
class Klass
def klass_method()
end
end
k = Klass.new
k.methods[0..9] #=> [:klass_method, :nil?, :===,
# :==~, :!, :eql?
# :hash, :<=>, :class, :singleton_class]
k.methods.length #=> 56
k.methods(false) #=> []
def k.singleton_method; end
k.methods(false) #=> [:singleton_method]
module M123; def m123; end end
k.extend M123
k.methods(false) #=> [:singleton_method]
@overload methods(regular=true)
@return [Array];T;0; @;!F;"o;#;$T;%i;&i;'@];(I"VALUE
rb_obj_methods(int argc, const VALUE *argv, VALUE obj)
{
rb_check_arity(argc, 0, 1);
if (argc > 0 && !RTEST(argv[0])) {
return rb_obj_singleton_methods(argc, argv, obj);
}
return class_instance_method_list(argc, argv, CLASS_OF(obj), 1, ins_methods_i);
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#singleton_methods;F;[[@c0;[[@ir;T;:singleton_methods;0;[ ;{ ;IC;"JReturns an array of the names of singleton methods for obj.
If the optional all parameter is true, the list will include
methods in modules included in obj.
Only public and protected singleton methods are returned.
module Other
def three() end
end
class Single
def Single.four() end
end
a = Single.new
def a.one()
end
class << a
include Other
def two()
end
end
Single.singleton_methods #=> [:four]
a.singleton_methods(false) #=> [:two, :one]
a.singleton_methods #=> [:two, :one, :three]
;T;[o;=
;3I"
overload;F;40;;t;50;)I" singleton_methods(all=true);T;IC;" ;T; @&;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"
Array;T; @&;[ ;I"@return [Array];T;0;6i ;[[I"all;TI" true;T; @&;[ ;I"Returns an array of the names of singleton methods for obj.
If the optional all parameter is true, the list will include
methods in modules included in obj.
Only public and protected singleton methods are returned.
module Other
def three() end
end
class Single
def Single.four() end
end
a = Single.new
def a.one()
end
class << a
include Other
def two()
end
end
Single.singleton_methods #=> [:four]
a.singleton_methods(false) #=> [:two, :one]
a.singleton_methods #=> [:two, :one, :three]
@overload singleton_methods(all=true)
@return [Array];T;0; @&;!F;"o;#;$T;%iQ;&io;'@];(I"(VALUE
rb_obj_singleton_methods(int argc, const VALUE *argv, VALUE obj)
{
VALUE ary, klass, origin;
struct method_entry_arg me_arg;
struct rb_id_table *mtbl;
int recur = TRUE;
if (rb_check_arity(argc, 0, 1)) recur = RTEST(argv[0]);
if (RB_TYPE_P(obj, T_CLASS) && FL_TEST(obj, FL_SINGLETON)) {
rb_singleton_class(obj);
}
klass = CLASS_OF(obj);
origin = RCLASS_ORIGIN(klass);
me_arg.list = st_init_numtable();
me_arg.recur = recur;
if (klass && FL_TEST(klass, FL_SINGLETON)) {
if ((mtbl = RCLASS_M_TBL(origin)) != 0) rb_id_table_foreach(mtbl, method_entry_i, &me_arg);
klass = RCLASS_SUPER(klass);
}
if (recur) {
while (klass && (FL_TEST(klass, FL_SINGLETON) || RB_TYPE_P(klass, T_ICLASS))) {
if (klass != origin && (mtbl = RCLASS_M_TBL(klass)) != 0) rb_id_table_foreach(mtbl, method_entry_i, &me_arg);
klass = RCLASS_SUPER(klass);
}
}
ary = rb_ary_new2(me_arg.list->num_entries);
st_foreach(me_arg.list, ins_methods_i, ary);
st_free_table(me_arg.list);
return ary;
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#protected_methods;F;[[@c0;[[@i-;T;:protected_methods;0;[ ;{ ;IC;"Returns the list of protected methods accessible to obj. If
the all parameter is set to false
, only those methods
in the receiver will be listed.
;T;[o;=
;3I"
overload;F;40;;u;50;)I" protected_methods(all=true);T;IC;" ;T; @E;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"
Array;T; @E;[ ;I"@return [Array];T;0;6i ;[[I"all;TI" true;T; @E;[ ;I"Returns the list of protected methods accessible to obj. If
the all parameter is set to false
, only those methods
in the receiver will be listed.
@overload protected_methods(all=true)
@return [Array];T;0; @E;!F;"o;#;$T;%i$;&i*;'@];(I"VALUE
rb_obj_protected_methods(int argc, const VALUE *argv, VALUE obj)
{
return class_instance_method_list(argc, argv, CLASS_OF(obj), 1, ins_methods_prot_i);
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#private_methods;F;[[@c0;[[@i<;T;:private_methods;0;[ ;{ ;IC;"Returns the list of private methods accessible to obj. If
the all parameter is set to false
, only those methods
in the receiver will be listed.
;T;[o;=
;3I"
overload;F;40;;v;50;)I"private_methods(all=true);T;IC;" ;T; @d;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"
Array;T; @d;[ ;I"@return [Array];T;0;6i ;[[I"all;TI" true;T; @d;[ ;I"Returns the list of private methods accessible to obj. If
the all parameter is set to false
, only those methods
in the receiver will be listed.
@overload private_methods(all=true)
@return [Array];T;0; @d;!F;"o;#;$T;%i3;&i9;'@];(I"VALUE
rb_obj_private_methods(int argc, const VALUE *argv, VALUE obj)
{
return class_instance_method_list(argc, argv, CLASS_OF(obj), 1, ins_methods_priv_i);
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#public_methods;F;[[@c0;[[@iK;T;:public_methods;0;[ ;{ ;IC;"Returns the list of public methods accessible to obj. If
the all parameter is set to false
, only those methods
in the receiver will be listed.
;T;[o;=
;3I"
overload;F;40;;w;50;)I"public_methods(all=true);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"
Array;T; @;[ ;I"@return [Array];T;0;6i ;[[I"all;TI" true;T; @;[ ;I"Returns the list of public methods accessible to obj. If
the all parameter is set to false
, only those methods
in the receiver will be listed.
@overload public_methods(all=true)
@return [Array];T;0; @;!F;"o;#;$T;%iB;&iH;'@];(I"VALUE
rb_obj_public_methods(int argc, const VALUE *argv, VALUE obj)
{
return class_instance_method_list(argc, argv, CLASS_OF(obj), 1, ins_methods_pub_i);
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#instance_variables;F;[ ;[[I"variable.c;Ti;T;:instance_variables;0;[ ;{ ;IC;"Returns an array of instance variable names for the receiver. Note
that simply defining an accessor does not create the corresponding
instance variable.
class Fred
attr_accessor :a1
def initialize
@iv = 3
end
end
Fred.new.instance_variables #=> [:@iv]
;T;[o;=
;3I"
overload;F;40;;x;50;)I"instance_variables;T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"
Array;T; @;[ ;I"@return [Array];T;0;6i ;[ ; @;[ ;I"NReturns an array of instance variable names for the receiver. Note
that simply defining an accessor does not create the corresponding
instance variable.
class Fred
attr_accessor :a1
def initialize
@iv = 3
end
end
Fred.new.instance_variables #=> [:@iv]
@overload instance_variables
@return [Array];T;0; @;!F;"o;#;$T;%i;&i;'@];(I"VALUE
rb_obj_instance_variables(VALUE obj)
{
VALUE ary;
ary = rb_ary_new();
rb_ivar_foreach(obj, ivar_i, ary);
return ary;
};T;)I"
VALUE;T;*To;;F;
;;;;I"!Object#instance_variable_get;F;[[I"iv;T0;[[@i6;T;:instance_variable_get;0;[ ;{ ;IC;"Returns the value of the given instance variable, or nil if the
instance variable is not set. The @
part of the
variable name should be included for regular instance
variables. Throws a NameError exception if the
supplied symbol is not valid as an instance variable name.
String arguments are converted to symbols.
class Fred
def initialize(p1, p2)
@a, @b = p1, p2
end
end
fred = Fred.new('cat', 99)
fred.instance_variable_get(:@a) #=> "cat"
fred.instance_variable_get("@b") #=> 99
;T;[o;=
;3I"
overload;F;40;;y;50;)I""instance_variable_get(symbol);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @;[ ;I"@return [Object];T;0;6i ;[[I"symbol;T0; @o;=
;3I"
overload;F;40;;y;50;)I""instance_variable_get(string);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @;[ ;I"@return [Object];T;0;6i ;[[I"string;T0; @;[ ;I"Returns the value of the given instance variable, or nil if the
instance variable is not set. The @
part of the
variable name should be included for regular instance
variables. Throws a NameError exception if the
supplied symbol is not valid as an instance variable name.
String arguments are converted to symbols.
class Fred
def initialize(p1, p2)
@a, @b = p1, p2
end
end
fred = Fred.new('cat', 99)
fred.instance_variable_get(:@a) #=> "cat"
fred.instance_variable_get("@b") #=> 99
@overload instance_variable_get(symbol)
@return [Object]
@overload instance_variable_get(string)
@return [Object];T;0; @;!F;"o;#;$T;%i ;&i4;'@];(I"static VALUE
rb_obj_ivar_get(VALUE obj, VALUE iv)
{
ID id = id_for_var(obj, iv, instance);
if (!id) {
return Qnil;
}
return rb_ivar_get(obj, id);
};T;)I"static VALUE;T;*To;;F;
;;;;I"!Object#instance_variable_set;F;[[I"iv;T0[I"val;T0;[[@iX;T;:instance_variable_set;0;[ ;{ ;IC;"Sets the instance variable named by symbol to the given
object. This may circumvent the encapsulation intended by
the author of the class, so it should be used with care.
The variable does not have to exist prior to this call.
If the instance variable name is passed as a string, that string
is converted to a symbol.
class Fred
def initialize(p1, p2)
@a, @b = p1, p2
end
end
fred = Fred.new('cat', 99)
fred.instance_variable_set(:@a, 'dog') #=> "dog"
fred.instance_variable_set(:@c, 'cat') #=> "cat"
fred.inspect #=> "#"
;T;[o;=
;3I"
overload;F;40;;z;50;)I"'instance_variable_set(symbol, obj);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @;[ ;I"@return [Object];T;0;6i ;[[I"symbol;T0[I"obj;T0; @o;=
;3I"
overload;F;40;;z;50;)I"'instance_variable_set(string, obj);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @;[ ;I"@return [Object];T;0;6i ;[[I"string;T0[I"obj;T0; @;[ ;I"Sets the instance variable named by symbol to the given
object. This may circumvent the encapsulation intended by
the author of the class, so it should be used with care.
The variable does not have to exist prior to this call.
If the instance variable name is passed as a string, that string
is converted to a symbol.
class Fred
def initialize(p1, p2)
@a, @b = p1, p2
end
end
fred = Fred.new('cat', 99)
fred.instance_variable_set(:@a, 'dog') #=> "dog"
fred.instance_variable_set(:@c, 'cat') #=> "cat"
fred.inspect #=> "#"
@overload instance_variable_set(symbol, obj)
@return [Object]
@overload instance_variable_set(string, obj)
@return [Object];T;0; @;!F;"o;#;$T;%iA;&iV;'@];(I"static VALUE
rb_obj_ivar_set(VALUE obj, VALUE iv, VALUE val)
{
ID id = id_for_var(obj, iv, instance);
if (!id) id = rb_intern_str(iv);
return rb_ivar_set(obj, id, val);
};T;)I"static VALUE;T;*To;;F;
;;;;I"&Object#instance_variable_defined?;F;[[I"iv;T0;[[@it;T;:instance_variable_defined?;0;[ ;{ ;IC;"Returns true
if the given instance variable is
defined in obj.
String arguments are converted to symbols.
class Fred
def initialize(p1, p2)
@a, @b = p1, p2
end
end
fred = Fred.new('cat', 99)
fred.instance_variable_defined?(:@a) #=> true
fred.instance_variable_defined?("@b") #=> true
fred.instance_variable_defined?("@c") #=> false;T;[o;=
;3I"
overload;F;40;;{;50;)I"'instance_variable_defined?(symbol);T;IC;" ;T; @ ;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @ ;[ ;I"@return [Boolean];T;0;6i ;[[I"symbol;T0; @ o;=
;3I"
overload;F;40;;{;50;)I"'instance_variable_defined?(string);T;IC;" ;T; @ ;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @ ;[ ;I"@return [Boolean];T;0;6i ;[[I"string;T0; @ ;[ ;I"Returns true
if the given instance variable is
defined in obj.
String arguments are converted to symbols.
class Fred
def initialize(p1, p2)
@a, @b = p1, p2
end
end
fred = Fred.new('cat', 99)
fred.instance_variable_defined?(:@a) #=> true
fred.instance_variable_defined?("@b") #=> true
fred.instance_variable_defined?("@c") #=> false
@overload instance_variable_defined?(symbol)
@return [Boolean]
@overload instance_variable_defined?(string)
@return [Boolean];T;0; @ ;!F;"o;#;$T;%i`;&ir;6i ;'@];(I"static VALUE
rb_obj_ivar_defined(VALUE obj, VALUE iv)
{
ID id = id_for_var(obj, iv, instance);
if (!id) {
return Qfalse;
}
return rb_ivar_defined(obj, id);
};T;)I"static VALUE;T;*To;;F;
;;;;I"$Object#remove_instance_variable;F;[[I" name;T0;[[@i?;T;:remove_instance_variable;0;[ ;{ ;IC;"lRemoves the named instance variable from obj, returning that
variable's value.
String arguments are converted to symbols.
class Dummy
attr_reader :var
def initialize
@var = 99
end
def remove
remove_instance_variable(:@var)
end
end
d = Dummy.new
d.var #=> 99
d.remove #=> 99
d.var #=> nil
;T;[o;=
;3I"
overload;F;40;;|;50;)I"%remove_instance_variable(symbol);T;IC;" ;T; @N;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @N;[ ;I"@return [Object];T;0;6i ;[[I"symbol;T0; @No;=
;3I"
overload;F;40;;|;50;)I"%remove_instance_variable(string);T;IC;" ;T; @N;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @N;[ ;I"@return [Object];T;0;6i ;[[I"string;T0; @N;[ ;I"Removes the named instance variable from obj, returning that
variable's value.
String arguments are converted to symbols.
class Dummy
attr_reader :var
def initialize
@var = 99
end
def remove
remove_instance_variable(:@var)
end
end
d = Dummy.new
d.var #=> 99
d.remove #=> 99
d.var #=> nil
@overload remove_instance_variable(symbol)
@return [Object]
@overload remove_instance_variable(string)
@return [Object];T;0; @N;!F;"o;#;$T;%i';&i=;'@];(I"JVALUE
rb_obj_remove_instance_variable(VALUE obj, VALUE name)
{
VALUE val = Qnil;
const ID id = id_for_var(obj, name, an, instance);
st_data_t n, v;
struct st_table *iv_index_tbl;
uint32_t index;
rb_check_frozen(obj);
if (!id) {
goto not_defined;
}
switch (BUILTIN_TYPE(obj)) {
case T_OBJECT:
iv_index_tbl = ROBJECT_IV_INDEX_TBL(obj);
if (iv_index_tbl_lookup(iv_index_tbl, id, &index) &&
index < ROBJECT_NUMIV(obj) &&
(val = ROBJECT_IVPTR(obj)[index]) != Qundef) {
ROBJECT_IVPTR(obj)[index] = Qundef;
return val;
}
break;
case T_CLASS:
case T_MODULE:
IVAR_ACCESSOR_SHOULD_BE_MAIN_RACTOR(id);
n = id;
if (RCLASS_IV_TBL(obj) && st_delete(RCLASS_IV_TBL(obj), &n, &v)) {
return (VALUE)v;
}
break;
default:
if (FL_TEST(obj, FL_EXIVAR)) {
if (generic_ivar_remove(obj, id, &val)) {
return val;
}
}
break;
}
not_defined:
rb_name_err_raise("instance variable %1$s not defined",
obj, name);
UNREACHABLE_RETURN(Qnil);
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#instance_of?;F;[[I"c;T0;[[@iA;T;:instance_of?;0;[ ;{ ;IC;"Returns true
if obj is an instance of the given
class. See also Object#kind_of?.
class A; end
class B < A; end
class C < B; end
b = B.new
b.instance_of? A #=> false
b.instance_of? B #=> true
b.instance_of? C #=> false;T;[o;=
;3I"
overload;F;40;;};50;)I"instance_of?(class);T;IC;" ;T; @|;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @|;[ ;I"@return [Boolean];T;0;6i ;[ ; @|;[ ;I"CReturns true
if obj is an instance of the given
class. See also Object#kind_of?.
class A; end
class B < A; end
class C < B; end
b = B.new
b.instance_of? A #=> false
b.instance_of? B #=> true
b.instance_of? C #=> false
@overload instance_of?(class)
@return [Boolean];T;0; @|;!F;"o;#;$T;%i);&i8;6i ;'@];(I"VALUE
rb_obj_is_instance_of(VALUE obj, VALUE c)
{
c = class_or_module_required(c);
if (rb_obj_class(obj) == c) return Qtrue;
return Qfalse;
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#kind_of?;F;[[I"c;T0;[[@im;T;:
kind_of?;0;[ ;{ ;IC;"Returns true
if class is the class of
obj, or if class is one of the superclasses of
obj or modules included in obj.
module M; end
class A
include M
end
class B < A; end
class C < B; end
b = B.new
b.is_a? A #=> true
b.is_a? B #=> true
b.is_a? C #=> false
b.is_a? M #=> true
b.kind_of? A #=> true
b.kind_of? B #=> true
b.kind_of? C #=> false
b.kind_of? M #=> true;T;[o;=
;3I"
overload;F;40;:
is_a?;50;)I"is_a?(class);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @;[ ;I"@return [Boolean];T;0;6i ;[ ; @o;=
;3I"
overload;F;40;;~;50;)I"kind_of?(class);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @;[ ;I"@return [Boolean];T;0;6i ;[ ; @;[ ;I"gReturns true
if class is the class of
obj, or if class is one of the superclasses of
obj or modules included in obj.
module M; end
class A
include M
end
class B < A; end
class C < B; end
b = B.new
b.is_a? A #=> true
b.is_a? B #=> true
b.is_a? C #=> false
b.is_a? M #=> true
b.kind_of? A #=> true
b.kind_of? B #=> true
b.kind_of? C #=> false
b.kind_of? M #=> true
@overload is_a?(class)
@return [Boolean]
@overload kind_of?(class)
@return [Boolean];T;0; @;!F;"o;#;$T;%iJ;&ie;6i ;'@];(I"VALUE
rb_obj_is_kind_of(VALUE obj, VALUE c)
{
VALUE cl = CLASS_OF(obj);
c = class_or_module_required(c);
return class_search_ancestor(cl, RCLASS_ORIGIN(c)) ? Qtrue : Qfalse;
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#is_a?;F;[[I"c;T0;[[@im;T;;;0;[ ;{ ;IC;"Returns true
if class is the class of
obj, or if class is one of the superclasses of
obj or modules included in obj.
module M; end
class A
include M
end
class B < A; end
class C < B; end
b = B.new
b.is_a? A #=> true
b.is_a? B #=> true
b.is_a? C #=> false
b.is_a? M #=> true
b.kind_of? A #=> true
b.kind_of? B #=> true
b.kind_of? C #=> false
b.kind_of? M #=> true;T;[o;=
;3I"
overload;F;40;;;50;)I"is_a?(class);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @;[ ;I"@return [Boolean];T;0;6i ;[ ; @o;=
;3I"
overload;F;40;;~;50;)I"kind_of?(class);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @;[ ;I"@return [Boolean];T;0;6i ;[ ; @;[ ;@;0; @;!F;"o;#;$T;%iJ;&ie;6i ;'@];(I"VALUE
rb_obj_is_kind_of(VALUE obj, VALUE c)
{
VALUE cl = CLASS_OF(obj);
c = class_or_module_required(c);
return class_search_ancestor(cl, RCLASS_ORIGIN(c)) ? Qtrue : Qfalse;
};T;)I"
VALUE;T;*To:&YARD::CodeObjects::ConstantObject;[[I"numeric.c;Ti;F;:Fixnum;:c;;;[ ;{ ;IC;"#An obsolete class, use Integer
;T;[ ;[ ;I"#An obsolete class, use Integer;T;0; @;!F;"o;#;$T;%i;&i;'@];I"Object::Fixnum;F:@valueI"rb_cInteger;To;;F;
;;;;I"Object#method;F;[[I"vid;T0;[[I"proc.c;Ti;T;:method;0;[ ;{ ;IC;"Looks up the named method as a receiver in obj, returning a
Method object (or raising NameError). The Method object acts as a
closure in obj's object instance, so instance variables and
the value of self
remain available.
class Demo
def initialize(n)
@iv = n
end
def hello()
"Hello, @iv = #{@iv}"
end
end
k = Demo.new(99)
m = k.method(:hello)
m.call #=> "Hello, @iv = 99"
l = Demo.new('Fred')
m = l.method("hello")
m.call #=> "Hello, @iv = Fred"
Note that Method implements to_proc
method, which
means it can be used with iterators.
[ 1, 2, 3 ].each(&method(:puts)) # => prints 3 lines to stdout
out = File.open('test.txt', 'w')
[ 1, 2, 3 ].each(&out.method(:puts)) # => prints 3 lines to file
require 'date'
%w[2017-03-01 2017-03-02].collect(&Date.method(:parse))
#=> [#, #]
;T;[o;=
;3I"
overload;F;40;;;50;)I"method(sym);T;IC;" ;T; @;>0;!F;[ ;[ ;I" ;T;0;6i ;[[I"sym;T0; @;[ ;I"Looks up the named method as a receiver in obj, returning a
Method object (or raising NameError). The Method object acts as a
closure in obj's object instance, so instance variables and
the value of self
remain available.
class Demo
def initialize(n)
@iv = n
end
def hello()
"Hello, @iv = #{@iv}"
end
end
k = Demo.new(99)
m = k.method(:hello)
m.call #=> "Hello, @iv = 99"
l = Demo.new('Fred')
m = l.method("hello")
m.call #=> "Hello, @iv = Fred"
Note that Method implements to_proc
method, which
means it can be used with iterators.
[ 1, 2, 3 ].each(&method(:puts)) # => prints 3 lines to stdout
out = File.open('test.txt', 'w')
[ 1, 2, 3 ].each(&out.method(:puts)) # => prints 3 lines to file
require 'date'
%w[2017-03-01 2017-03-02].collect(&Date.method(:parse))
#=> [#, #]
@overload method(sym);T;0; @;!F;"o;#;$T;%i;&i;'@];(I"ZVALUE
rb_obj_method(VALUE obj, VALUE vid)
{
return obj_method(obj, vid, FALSE);
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#public_method;F;[[I"vid;T0;[[@ i;T;:public_method;0;[ ;{ ;IC;"6Similar to _method_, searches public method only.
;T;[o;=
;3I"
overload;F;40;;;50;)I"public_method(sym);T;IC;" ;T; @;>0;!F;[ ;[ ;I" ;T;0;6i ;[[I"sym;T0; @;[ ;I"USimilar to _method_, searches public method only.
@overload public_method(sym);T;0; @;!F;"o;#;$T;%i;&i;'@];(I"`VALUE
rb_obj_public_method(VALUE obj, VALUE vid)
{
return obj_method(obj, vid, TRUE);
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#singleton_method;F;[[I"vid;T0;[[@ i;T;:singleton_method;0;[ ;{ ;IC;"^Similar to _method_, searches singleton method only.
class Demo
def initialize(n)
@iv = n
end
def hello()
"Hello, @iv = #{@iv}"
end
end
k = Demo.new(99)
def k.hi
"Hi, @iv = #{@iv}"
end
m = k.singleton_method(:hi)
m.call #=> "Hi, @iv = 99"
m = k.singleton_method(:hello) #=> NameError
;T;[o;=
;3I"
overload;F;40;;;50;)I"singleton_method(sym);T;IC;" ;T; @.;>0;!F;[ ;[ ;I" ;T;0;6i ;[[I"sym;T0; @.;[ ;I"Similar to _method_, searches singleton method only.
class Demo
def initialize(n)
@iv = n
end
def hello()
"Hello, @iv = #{@iv}"
end
end
k = Demo.new(99)
def k.hi
"Hi, @iv = #{@iv}"
end
m = k.singleton_method(:hi)
m.call #=> "Hi, @iv = 99"
m = k.singleton_method(:hello) #=> NameError
@overload singleton_method(sym);T;0; @.;!F;"o;#;$T;%i;&i;'@];(I"VALUE
rb_obj_singleton_method(VALUE obj, VALUE vid)
{
VALUE klass = rb_singleton_class_get(obj);
ID id = rb_check_id(&vid);
if (NIL_P(klass)) {
/* goto undef; */
}
else if (NIL_P(klass = RCLASS_ORIGIN(klass))) {
/* goto undef; */
}
else if (! id) {
VALUE m = mnew_missing_by_name(klass, obj, &vid, FALSE, rb_cMethod);
if (m) return m;
/* else goto undef; */
}
else {
const rb_method_entry_t *me = rb_method_entry_at(klass, id);
vid = ID2SYM(id);
if (UNDEFINED_METHOD_ENTRY_P(me)) {
/* goto undef; */
}
else if (UNDEFINED_REFINED_METHOD_P(me->def)) {
/* goto undef; */
}
else {
return mnew_from_me(me, klass, klass, obj, id, rb_cMethod, FALSE);
}
}
/* undef: */
rb_name_err_raise("undefined singleton method `%1$s' for `%2$s'",
obj, vid);
UNREACHABLE_RETURN(Qundef);
};T;)I"
VALUE;T;*To;;F;
;;;;I"#Object#define_singleton_method;F;[[@c0;[[@ i;T;:define_singleton_method;0;[ ;{ ;IC;"Defines a singleton method in the receiver. The _method_
parameter can be a +Proc+, a +Method+ or an +UnboundMethod+ object.
If a block is specified, it is used as the method body.
If a block or a method has parameters, they're used as method parameters.
class A
class << self
def class_name
to_s
end
end
end
A.define_singleton_method(:who_am_i) do
"I am: #{class_name}"
end
A.who_am_i # ==> "I am: A"
guy = "Bob"
guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
guy.hello #=> "Bob: Hello there!"
chris = "Chris"
chris.define_singleton_method(:greet) {|greeting| "#{greeting}, I'm Chris!" }
chris.greet("Hi") #=> "Hi, I'm Chris!"
;T;[o;=
;3I"
overload;F;40;;;50;)I",define_singleton_method(symbol, method);T;IC;" ;T; @H;>0;!F;[ ;[ ;I" ;T;0;6i ;[[I"symbol;T0[I"method;T0; @Ho;=
;3I"
overload;F;40;;;50;)I"$define_singleton_method(symbol);T;IC;" ;T; @H;>0;!F;[o;2
;3I"
yield;F;4I"[];T;0;50; @H;[ ;I"@yield [];T;0;6i ;[[I"symbol;T0; @H;[ ;I">Defines a singleton method in the receiver. The _method_
parameter can be a +Proc+, a +Method+ or an +UnboundMethod+ object.
If a block is specified, it is used as the method body.
If a block or a method has parameters, they're used as method parameters.
class A
class << self
def class_name
to_s
end
end
end
A.define_singleton_method(:who_am_i) do
"I am: #{class_name}"
end
A.who_am_i # ==> "I am: A"
guy = "Bob"
guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
guy.hello #=> "Bob: Hello there!"
chris = "Chris"
chris.define_singleton_method(:greet) {|greeting| "#{greeting}, I'm Chris!" }
chris.greet("Hi") #=> "Hi, I'm Chris!"
@overload define_singleton_method(symbol, method)
@overload define_singleton_method(symbol)
@yield [];T;0; @H;!F;"o;#;$T;%i;&i;'@];(I"static VALUE
rb_obj_define_method(int argc, VALUE *argv, VALUE obj)
{
VALUE klass = rb_singleton_class(obj);
return rb_mod_define_method(argc, argv, klass);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Object#send;F;[[@c0;[[I"vm_eval.c;Ti;T;: send;0;[ ;{ ;IC;"!Invokes the method identified by _symbol_, passing it any
arguments specified.
When the method is identified by a string, the string is converted
to a symbol.
BasicObject implements +__send__+, Kernel implements +send+.
__send__
is safer than +send+
when _obj_ has the same method name like Socket
.
See also public_send
.
class Klass
def hello(*args)
"Hello " + args.join(' ')
end
end
k = Klass.new
k.send :hello, "gentle", "readers" #=> "Hello gentle readers"
;T;[ o;=
;3I"
overload;F;40;;;50;)I"send(symbol [, args...]);T;IC;" ;T; @p;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @p;[ ;I"@return [Object];T;0;6i ;[[I"symbol[, args...];T0; @po;=
;3I"
overload;F;40;:
__send__;50;)I"!__send__(symbol [, args...]);T;IC;" ;T; @p;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @p;[ ;I"@return [Object];T;0;6i ;[[I"symbol[, args...];T0; @po;=
;3I"
overload;F;40;;;50;)I"send(string [, args...]);T;IC;" ;T; @p;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @p;[ ;I"@return [Object];T;0;6i ;[[I"string[, args...];T0; @po;=
;3I"
overload;F;40;;;50;)I"!__send__(string [, args...]);T;IC;" ;T; @p;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @p;[ ;I"@return [Object];T;0;6i ;[[I"string[, args...];T0; @p;[ ;I" Invokes the method identified by _symbol_, passing it any
arguments specified.
When the method is identified by a string, the string is converted
to a symbol.
BasicObject implements +__send__+, Kernel implements +send+.
__send__
is safer than +send+
when _obj_ has the same method name like Socket
.
See also public_send
.
class Klass
def hello(*args)
"Hello " + args.join(' ')
end
end
k = Klass.new
k.send :hello, "gentle", "readers" #=> "Hello gentle readers"
@overload send(symbol [, args...])
@return [Object]
@overload __send__(symbol [, args...])
@return [Object]
@overload send(string [, args...])
@return [Object]
@overload __send__(string [, args...])
@return [Object];T;0; @p;!F;"o;#;$T;%i;&i;'@];(I"vVALUE
rb_f_send(int argc, VALUE *argv, VALUE recv)
{
return send_internal_kw(argc, argv, recv, CALL_FCALL);
};T;)I"
VALUE;T;*To;;F;
;;;;I"Object#public_send;F;[[@c0;[[@vi";T;:public_send;0;[ ;{ ;IC;"Invokes the method identified by _symbol_, passing it any
arguments specified. Unlike send, public_send calls public
methods only.
When the method is identified by a string, the string is converted
to a symbol.
1.public_send(:puts, "hello") # causes NoMethodError
;T;[o;=
;3I"
overload;F;40;;;50;)I"$public_send(symbol [, args...]);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @;[ ;I"@return [Object];T;0;6i ;[[I"symbol[, args...];T0; @o;=
;3I"
overload;F;40;;;50;)I"$public_send(string [, args...]);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @;[ ;I"@return [Object];T;0;6i ;[[I"string[, args...];T0; @;[ ;I"Invokes the method identified by _symbol_, passing it any
arguments specified. Unlike send, public_send calls public
methods only.
When the method is identified by a string, the string is converted
to a symbol.
1.public_send(:puts, "hello") # causes NoMethodError
@overload public_send(symbol [, args...])
@return [Object]
@overload public_send(string [, args...])
@return [Object];T;0; @;!F;"o;#;$T;%i;&i ;'@];(I"static VALUE
rb_f_public_send(int argc, VALUE *argv, VALUE recv)
{
return send_internal_kw(argc, argv, recv, CALL_PUBLIC);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Object#rb_fatal;F;[[I"msg;T0;[[I" ext/-test-/fatal/rb_fatal.c;Ti;T;:
rb_fatal;0;[ ;{ ;IC;" ;T;[ ;[ ;@|;0; @;'@];(I"static VALUE
ruby_fatal(VALUE obj, VALUE msg)
{
const char *cmsg = NULL;
(void)obj;
cmsg = RSTRING_PTR(msg);
rb_fatal("%s", cmsg);
return 0; /* never reached */
};T;)I"static VALUE;T;*To;{;[[I"7ext/-test-/wait_for_single_fd/wait_for_single_fd.c;Ti[;F;:RB_WAITFD_IN;;};;;[ ;{ ;IC;" ;T;[ ;[ ;@|;0; @;'@];I"Object::RB_WAITFD_IN;F;~I"INT2NUM(RB_WAITFD_IN);To;{;[[@i\;F;:RB_WAITFD_OUT;;};;;[ ;{ ;IC;" ;T;[ ;[ ;@|;0; @;'@];I"Object::RB_WAITFD_OUT;F;~I"INT2NUM(RB_WAITFD_OUT);To;{;[[@i];F;:RB_WAITFD_PRI;;};;;[ ;{ ;IC;" ;T;[ ;[ ;@|;0; @
;'@];I"Object::RB_WAITFD_PRI;F;~I"INT2NUM(RB_WAITFD_PRI);To;;F;
;;;;I"Object#object_id;F;[ ;[[I" gc.c;Ti
;T;:object_id;0;[ ;{ ;IC;"4call-seq:
obj.__id__ -> integer
obj.object_id -> integer
Returns an integer identifier for +obj+.
The same number will be returned on all calls to +object_id+ for a given
object, and no two active objects will share an id.
Note: that some objects of builtin classes are reused for optimization.
This is the case for immediate values and frozen string literals.
BasicObject implements +__id__+, Kernel implements +object_id+.
Immediate values are not passed by reference but are passed by value:
+nil+, +true+, +false+, Fixnums, Symbols, and some Floats.
Object.new.object_id == Object.new.object_id # => false
(21 * 2).object_id == (21 * 2).object_id # => true
"hello".object_id == "hello".object_id # => false
"hi".freeze.object_id == "hi".freeze.object_id # => true
;T;[ ;[ ;I"6
call-seq:
obj.__id__ -> integer
obj.object_id -> integer
Returns an integer identifier for +obj+.
The same number will be returned on all calls to +object_id+ for a given
object, and no two active objects will share an id.
Note: that some objects of builtin classes are reused for optimization.
This is the case for immediate values and frozen string literals.
BasicObject implements +__id__+, Kernel implements +object_id+.
Immediate values are not passed by reference but are passed by value:
+nil+, +true+, +false+, Fixnums, Symbols, and some Floats.
Object.new.object_id == Object.new.object_id # => false
(21 * 2).object_id == (21 * 2).object_id # => true
"hello".object_id == "hello".object_id # => false
"hi".freeze.object_id == "hi".freeze.object_id # => true
;T;0; @;!F;"o;#;$T;%i;&i;'@];(I"VALUE
rb_obj_id(VALUE obj)
{
/*
* 32-bit VALUE space
* MSB ------------------------ LSB
* false 00000000000000000000000000000000
* true 00000000000000000000000000000010
* nil 00000000000000000000000000000100
* undef 00000000000000000000000000000110
* symbol ssssssssssssssssssssssss00001110
* object oooooooooooooooooooooooooooooo00 = 0 (mod sizeof(RVALUE))
* fixnum fffffffffffffffffffffffffffffff1
*
* object_id space
* LSB
* false 00000000000000000000000000000000
* true 00000000000000000000000000000010
* nil 00000000000000000000000000000100
* undef 00000000000000000000000000000110
* symbol 000SSSSSSSSSSSSSSSSSSSSSSSSSSS0 S...S % A = 4 (S...S = s...s * A + 4)
* object oooooooooooooooooooooooooooooo0 o...o % A = 0
* fixnum fffffffffffffffffffffffffffffff1 bignum if required
*
* where A = sizeof(RVALUE)/4
*
* sizeof(RVALUE) is
* 20 if 32-bit, double is 4-byte aligned
* 24 if 32-bit, double is 8-byte aligned
* 40 if 64-bit
*/
return rb_find_object_id(obj, cached_object_id);
};T;)I"
VALUE;T;*To;{;[[I"
bignum.c;Ti
;F;:Bignum;;};;;[ ;{ ;IC;"#An obsolete class, use Integer
;T;[ ;[ ;I"#An obsolete class, use Integer;T;0; @&;!F;"o;#;$T;%i ;&i ;'o;L;M0;N0;O0;;T;'@;Q@];R0;I"Object::Bignum;T;~I"rb_cInteger;T;A@];BIC;[ ;A@];CIC;[o; ;IC;[Do;;F;
;;;;I"Kernel#load;F;[[@c0;[[I"load.c;Ti;T;: load;0;[ ;{ ;IC;")Loads and executes the Ruby program in the file _filename_.
If the filename is an absolute path (e.g. starts with '/'), the file
will be loaded directly using the absolute path.
If the filename is an explicit relative path (e.g. starts with './' or
'../'), the file will be loaded using the relative path from the current
directory.
Otherwise, the file will be searched for in the library
directories listed in $LOAD_PATH
($:
).
If the file is found in a directory, it will attempt to load the file
relative to that directory. If the file is not found in any of the
directories in $LOAD_PATH
, the file will be loaded using
the relative path from the current directory.
If the file doesn't exist when there is an attempt to load it, a
LoadError will be raised.
If the optional _wrap_ parameter is +true+, the loaded script will
be executed under an anonymous module, protecting the calling
program's global namespace. In no circumstance will any local
variables in the loaded file be propagated to the loading
environment.
;T;[o;=
;3I"
overload;F;40;;;50;)I"load(filename, wrap=false);T;IC;" ;T; @8;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I" true;T; @8;[ ;I"@return [true];T;0;6i ;[[I"
filename;T0[I" wrap;TI"
false;T; @8;[ ;I"aLoads and executes the Ruby program in the file _filename_.
If the filename is an absolute path (e.g. starts with '/'), the file
will be loaded directly using the absolute path.
If the filename is an explicit relative path (e.g. starts with './' or
'../'), the file will be loaded using the relative path from the current
directory.
Otherwise, the file will be searched for in the library
directories listed in $LOAD_PATH
($:
).
If the file is found in a directory, it will attempt to load the file
relative to that directory. If the file is not found in any of the
directories in $LOAD_PATH
, the file will be loaded using
the relative path from the current directory.
If the file doesn't exist when there is an attempt to load it, a
LoadError will be raised.
If the optional _wrap_ parameter is +true+, the loaded script will
be executed under an anonymous module, protecting the calling
program's global namespace. In no circumstance will any local
variables in the loaded file be propagated to the loading
environment.
@overload load(filename, wrap=false)
@return [true];T;0; @8;!F;"o;#;$T;%i;&i;'@6;(I"?static VALUE
rb_f_load(int argc, VALUE *argv, VALUE _)
{
VALUE fname, wrap, path, orig_fname;
rb_scan_args(argc, argv, "11", &fname, &wrap);
orig_fname = rb_get_path_check_to_string(fname);
fname = rb_str_encode_ospath(orig_fname);
RUBY_DTRACE_HOOK(LOAD_ENTRY, RSTRING_PTR(orig_fname));
path = rb_find_file(fname);
if (!path) {
if (!rb_file_load_ok(RSTRING_PTR(fname)))
load_failed(orig_fname);
path = fname;
}
rb_load_internal(path, RTEST(wrap));
RUBY_DTRACE_HOOK(LOAD_RETURN, RSTRING_PTR(orig_fname));
return Qtrue;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#require;F;[[I"
fname;T0;[[@>io;T;:require;0;[ ;{ ;IC;"Loads the given +name+, returning +true+ if successful and +false+ if the
feature is already loaded.
If the filename neither resolves to an absolute path nor starts with
'./' or '../', the file will be searched for in the library
directories listed in $LOAD_PATH
($:
).
If the filename starts with './' or '../', resolution is based on Dir.pwd.
If the filename has the extension ".rb", it is loaded as a source file; if
the extension is ".so", ".o", or ".dll", or the default shared library
extension on the current platform, Ruby loads the shared library as a
Ruby extension. Otherwise, Ruby tries adding ".rb", ".so", and so on
to the name until found. If the file named cannot be found, a LoadError
will be raised.
For Ruby extensions the filename given may use any shared library
extension. For example, on Linux the socket extension is "socket.so" and
require 'socket.dll'
will load the socket extension.
The absolute path of the loaded file is added to
$LOADED_FEATURES
($"
). A file will not be
loaded again if its path already appears in $"
. For example,
require 'a'; require './a'
will not load a.rb
again.
require "my-library.rb"
require "db-driver"
Any constants or globals within the loaded source file will be available
in the calling program's global namespace. However, local variables will
not be propagated to the loading environment.
;T;[o;=
;3I"
overload;F;40;;;50;)I"require(name);T;IC;" ;T; @Z;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @Z;[ ;I"@return [Boolean];T;0;6i ;[[I" name;T0; @Z;[ ;I"Loads the given +name+, returning +true+ if successful and +false+ if the
feature is already loaded.
If the filename neither resolves to an absolute path nor starts with
'./' or '../', the file will be searched for in the library
directories listed in $LOAD_PATH
($:
).
If the filename starts with './' or '../', resolution is based on Dir.pwd.
If the filename has the extension ".rb", it is loaded as a source file; if
the extension is ".so", ".o", or ".dll", or the default shared library
extension on the current platform, Ruby loads the shared library as a
Ruby extension. Otherwise, Ruby tries adding ".rb", ".so", and so on
to the name until found. If the file named cannot be found, a LoadError
will be raised.
For Ruby extensions the filename given may use any shared library
extension. For example, on Linux the socket extension is "socket.so" and
require 'socket.dll'
will load the socket extension.
The absolute path of the loaded file is added to
$LOADED_FEATURES
($"
). A file will not be
loaded again if its path already appears in $"
. For example,
require 'a'; require './a'
will not load a.rb
again.
require "my-library.rb"
require "db-driver"
Any constants or globals within the loaded source file will be available
in the calling program's global namespace. However, local variables will
not be propagated to the loading environment.
@overload require(name)
@return [Boolean];T;0; @Z;!F;"o;#;$T;%iI;&il;'@6;(I"XVALUE
rb_f_require(VALUE obj, VALUE fname)
{
return rb_require_string(fname);
};T;)I"
VALUE;T;*To;;F;
;;;;I"Kernel#require_relative;F;[[I"
fname;T0;[[@>i};T;:require_relative;0;[ ;{ ;IC;"Ruby tries to load the library named _string_ relative to the requiring
file's path. If the file's path cannot be determined a LoadError is raised.
If a file is loaded +true+ is returned and false otherwise.
;T;[o;=
;3I"
overload;F;40;;;50;)I"require_relative(string);T;IC;" ;T; @y;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @y;[ ;I"@return [Boolean];T;0;6i ;[[I"string;T0; @y;[ ;I" Ruby tries to load the library named _string_ relative to the requiring
file's path. If the file's path cannot be determined a LoadError is raised.
If a file is loaded +true+ is returned and false otherwise.
@overload require_relative(string)
@return [Boolean];T;0; @y;!F;"o;#;$T;%iu;&i{;'@6;(I"VALUE
rb_f_require_relative(VALUE obj, VALUE fname)
{
VALUE base = rb_current_realfilepath();
if (NIL_P(base)) {
rb_loaderror("cannot infer basepath");
}
base = rb_file_dirname(base);
return rb_require_string(rb_file_absolute_path(fname, base));
};T;)I"
VALUE;T;*To;;F;
;;;;I"Kernel#autoload;F;[[I"sym;T0[I" file;T0;[[@>i;T;:
autoload;0;[ ;{ ;IC;"Registers _filename_ to be loaded (using Kernel::require)
the first time that _module_ (which may be a String or
a symbol) is accessed.
autoload(:MyModule, "/usr/local/lib/modules/my_module.rb")
;T;[o;=
;3I"
overload;F;40;;;50;)I"autoload(module, filename);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"nil;T; @;[ ;I"@return [nil];T;0;6i ;[ ; @;[ ;I"Registers _filename_ to be loaded (using Kernel::require)
the first time that _module_ (which may be a String or
a symbol) is accessed.
autoload(:MyModule, "/usr/local/lib/modules/my_module.rb")
@overload autoload(module, filename)
@return [nil];T;0; @;!F;"o;#;$T;%i;&i;'@6;(I"static VALUE
rb_f_autoload(VALUE obj, VALUE sym, VALUE file)
{
VALUE klass = rb_class_real(rb_vm_cbase());
if (!klass) {
rb_raise(rb_eTypeError, "Can not set autoload on singleton class");
}
return rb_mod_autoload(klass, sym, file);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#autoload?;F;[[@c0;[[@>i,;T;:autoload?;0;[ ;{ ;IC;"Returns _filename_ to be loaded if _name_ is registered as
+autoload+.
autoload(:B, "b")
autoload?(:B) #=> "b";T;[o;=
;3I"
overload;F;40;;;50;)I""autoload?(name, inherit=true);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"String;TI"nil;T; @;[ ;I"@return [String, nil];T;0;6i ;[[I" name;T0[I"inherit;TI" true;T; @;[ ;I"Returns _filename_ to be loaded if _name_ is registered as
+autoload+.
autoload(:B, "b")
autoload?(:B) #=> "b"
@overload autoload?(name, inherit=true)
@return [String, nil];T;0; @;!F;"o;#;$T;%i!;&i);6i ;'@6;(I"static VALUE
rb_f_autoload_p(int argc, VALUE *argv, VALUE obj)
{
/* use rb_vm_cbase() as same as rb_f_autoload. */
VALUE klass = rb_vm_cbase();
if (NIL_P(klass)) {
return Qnil;
}
return rb_mod_autoload_p(argc, argv, klass);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#set_trace_func;F;[[I"
trace;T0;[[I"vm_trace.c;Ti;T;:set_trace_func;0;[ ;{ ;IC;"+Establishes _proc_ as the handler for tracing, or disables
tracing if the parameter is +nil+.
*Note:* this method is obsolete, please use TracePoint instead.
_proc_ takes up to six parameters:
* an event name
* a filename
* a line number
* an object id
* a binding
* the name of a class
_proc_ is invoked whenever an event occurs.
Events are:
+c-call+:: call a C-language routine
+c-return+:: return from a C-language routine
+call+:: call a Ruby method
+class+:: start a class or module definition
+end+:: finish a class or module definition
+line+:: execute code on a new line
+raise+:: raise an exception
+return+:: return from a Ruby method
Tracing is disabled within the context of _proc_.
class Test
def test
a = 1
b = 2
end
end
set_trace_func proc { |event, file, line, id, binding, classname|
printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
}
t = Test.new
t.test
line prog.rb:11 false
c-call prog.rb:11 new Class
c-call prog.rb:11 initialize Object
c-return prog.rb:11 initialize Object
c-return prog.rb:11 new Class
line prog.rb:12 false
call prog.rb:2 test Test
line prog.rb:3 test Test
line prog.rb:4 test Test
return prog.rb:4 test Test
;T;[o;=
;3I"
overload;F;40;;;50;)I"set_trace_func(proc);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I" Proc;T; @;[ ;I"@return [Proc];T;0;6i ;[[I" proc;T0; @o;=
;3I"
overload;F;40;;;50;)I"set_trace_func(nil);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"nil;T; @;[ ;I"@return [nil];T;0;6i ;[[I"nil;T0; @;[ ;I"Establishes _proc_ as the handler for tracing, or disables
tracing if the parameter is +nil+.
*Note:* this method is obsolete, please use TracePoint instead.
_proc_ takes up to six parameters:
* an event name
* a filename
* a line number
* an object id
* a binding
* the name of a class
_proc_ is invoked whenever an event occurs.
Events are:
+c-call+:: call a C-language routine
+c-return+:: return from a C-language routine
+call+:: call a Ruby method
+class+:: start a class or module definition
+end+:: finish a class or module definition
+line+:: execute code on a new line
+raise+:: raise an exception
+return+:: return from a Ruby method
Tracing is disabled within the context of _proc_.
class Test
def test
a = 1
b = 2
end
end
set_trace_func proc { |event, file, line, id, binding, classname|
printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
}
t = Test.new
t.test
line prog.rb:11 false
c-call prog.rb:11 new Class
c-call prog.rb:11 initialize Object
c-return prog.rb:11 initialize Object
c-return prog.rb:11 new Class
line prog.rb:12 false
call prog.rb:2 test Test
line prog.rb:3 test Test
line prog.rb:4 test Test
return prog.rb:4 test Test
@overload set_trace_func(proc)
@return [Proc]
@overload set_trace_func(nil)
@return [nil];T;0; @;!F;"o;#;$T;%i;&i
;'@6;(I"Cstatic VALUE
set_trace_func(VALUE obj, VALUE trace)
{
rb_remove_event_hook(call_trace_func);
if (NIL_P(trace)) {
return Qnil;
}
if (!rb_obj_is_proc(trace)) {
rb_raise(rb_eTypeError, "trace_func needs to be Proc");
}
rb_add_event_hook(call_trace_func, RUBY_EVENT_ALL, trace);
return trace;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#raise;F;[[I"*v;T0[I"_;T0;[[@fi5;T;:
raise;0;[ ;{ ;IC;"With no arguments, raises the exception in $!
or raises
a RuntimeError if $!
is +nil+. With a single +String+
argument, raises a +RuntimeError+ with the string as a message. Otherwise,
the first parameter should be an +Exception+ class (or another
object that returns an +Exception+ object when sent an +exception+
message). The optional second parameter sets the message associated with
the exception (accessible via Exception#message), and the third parameter
is an array of callback information (accessible via Exception#backtrace).
The +cause+ of the generated exception (accessible via Exception#cause)
is automatically set to the "current" exception ($!
), if any.
An alternative value, either an +Exception+ object or +nil+, can be
specified via the +:cause+ argument.
Exceptions are caught by the +rescue+ clause of
begin...end
blocks.
raise "Failed to create socket"
raise ArgumentError, "No parameters", caller
;T;[o;=
;3I"
overload;F;40;;;50;)I"
raise;T;IC;" ;T; @ ;>0;!F;[ ;[ ;I" ;T;0;6i ;[ ; @ o;=
;3I"
overload;F;40;;;50;)I"raise(string, cause: $!);T;IC;" ;T; @ ;>0;!F;[ ;[ ;I" ;T;0;6i ;[[I"string;T0[I"cause:;TI"$!;T; @ o;=
;3I"
overload;F;40;;;50;)I"5raise(exception [, string [, array]], cause: $!);T;IC;" ;T; @ ;>0;!F;[ ;[ ;I" ;T;0;6i ;[[I""exception[, string [, array]];T0[I"cause:;TI"$!;T; @ o;=
;3I"
overload;F;40;: fail;50;)I" fail;T;IC;" ;T; @ ;>0;!F;[ ;[ ;I" ;T;0;6i ;[ ; @ o;=
;3I"
overload;F;40;;;50;)I"fail(string, cause: $!);T;IC;" ;T; @ ;>0;!F;[ ;[ ;I" ;T;0;6i ;[[I"string;T0[I"cause:;TI"$!;T; @ o;=
;3I"
overload;F;40;;;50;)I"4fail(exception [, string [, array]], cause: $!);T;IC;" ;T; @ ;>0;!F;[ ;[ ;I" ;T;0;6i ;[[I""exception[, string [, array]];T0[I"cause:;TI"$!;T; @ ;[ ;I"With no arguments, raises the exception in $!
or raises
a RuntimeError if $!
is +nil+. With a single +String+
argument, raises a +RuntimeError+ with the string as a message. Otherwise,
the first parameter should be an +Exception+ class (or another
object that returns an +Exception+ object when sent an +exception+
message). The optional second parameter sets the message associated with
the exception (accessible via Exception#message), and the third parameter
is an array of callback information (accessible via Exception#backtrace).
The +cause+ of the generated exception (accessible via Exception#cause)
is automatically set to the "current" exception ($!
), if any.
An alternative value, either an +Exception+ object or +nil+, can be
specified via the +:cause+ argument.
Exceptions are caught by the +rescue+ clause of
begin...end
blocks.
raise "Failed to create socket"
raise ArgumentError, "No parameters", caller
@overload raise
@overload raise(string, cause: $!)
@overload raise(exception [, string [, array]], cause: $!)
@overload fail
@overload fail(string, cause: $!)
@overload fail(exception [, string [, array]], cause: $!);T;0; @ ;!F;"o;#;$T;%i;&i1;'@6;(I"Tstatic VALUE
f_raise(int c, VALUE *v, VALUE _)
{
return rb_f_raise(c, v);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#fail;F;[[I"*v;T0[I"_;T0;[[@fi5;T;;;0;[ ;{ ;IC;"With no arguments, raises the exception in $!
or raises
a RuntimeError if $!
is +nil+. With a single +String+
argument, raises a +RuntimeError+ with the string as a message. Otherwise,
the first parameter should be an +Exception+ class (or another
object that returns an +Exception+ object when sent an +exception+
message). The optional second parameter sets the message associated with
the exception (accessible via Exception#message), and the third parameter
is an array of callback information (accessible via Exception#backtrace).
The +cause+ of the generated exception (accessible via Exception#cause)
is automatically set to the "current" exception ($!
), if any.
An alternative value, either an +Exception+ object or +nil+, can be
specified via the +:cause+ argument.
Exceptions are caught by the +rescue+ clause of
begin...end
blocks.
raise "Failed to create socket"
raise ArgumentError, "No parameters", caller
;T;[o;=
;3I"
overload;F;40;;;50;)I"
raise;T;IC;" ;T; @^ ;>0;!F;[ ;[ ;I" ;T;0;6i ;[ ; @^ o;=
;3I"
overload;F;40;;;50;)I"raise(string, cause: $!);T;IC;" ;T; @^ ;>0;!F;[ ;[ ;I" ;T;0;6i ;[[I"string;T0[I"cause:;TI"$!;T; @^ o;=
;3I"
overload;F;40;;;50;)I"5raise(exception [, string [, array]], cause: $!);T;IC;" ;T; @^ ;>0;!F;[ ;[ ;I" ;T;0;6i ;[[I""exception[, string [, array]];T0[I"cause:;TI"$!;T; @^ o;=
;3I"
overload;F;40;;;50;)I" fail;T;IC;" ;T; @^ ;>0;!F;[ ;[ ;I" ;T;0;6i ;[ ; @^ o;=
;3I"
overload;F;40;;;50;)I"fail(string, cause: $!);T;IC;" ;T; @^ ;>0;!F;[ ;[ ;I" ;T;0;6i ;[[I"string;T0[I"cause:;TI"$!;T; @^ o;=
;3I"
overload;F;40;;;50;)I"4fail(exception [, string [, array]], cause: $!);T;IC;" ;T; @^ ;>0;!F;[ ;[ ;I" ;T;0;6i ;[[I""exception[, string [, array]];T0[I"cause:;TI"$!;T; @^ ;[ ;@Z ;0; @^ ;!F;"o;#;$T;%i;&i1;'@6;(I"Tstatic VALUE
f_raise(int c, VALUE *v, VALUE _)
{
return rb_f_raise(c, v);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#global_variables;F;[ ;[[@fi;T;:global_variables;0;[ ;{ ;IC;"%Returns an array of the names of global variables. This includes
special regexp global variables such as $~ and $+,
but does not include the numbered regexp global variables ($1,
$2, etc.).
global_variables.grep /std/ #=> [:$stdin, :$stdout, :$stderr]
;T;[o;=
;3I"
overload;F;40;;;50;)I"global_variables;T;IC;" ;T; @ ;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"
Array;T; @ ;[ ;I"@return [Array];T;0;6i ;[ ; @ ;[ ;I"TReturns an array of the names of global variables. This includes
special regexp global variables such as $~ and $+,
but does not include the numbered regexp global variables ($1,
$2, etc.).
global_variables.grep /std/ #=> [:$stdin, :$stdout, :$stderr]
@overload global_variables
@return [Array];T;0; @ ;!F;"o;#;$T;%i;&i;'@6;(I"Ustatic VALUE
f_global_variables(VALUE _)
{
return rb_f_global_variables();
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#__method__;F;[ ;[[@fi;T;:__method__;0;[ ;{ ;IC;"Returns the name at the definition of the current method as a
Symbol.
If called outside of a method, it returns nil
.
;T;[o;=
;3I"
overload;F;40;;;50;)I"__method__;T;IC;" ;T; @ ;>0;!F;[ ;[ ;I" ;T;0;6i ;[ ; @ ;[ ;I"Returns the name at the definition of the current method as a
Symbol.
If called outside of a method, it returns nil
.
@overload __method__;T;0; @ ;!F;"o;#;$T;%i;&i;'@6;(I"static VALUE
rb_f_method_name(VALUE _)
{
ID fname = prev_frame_func(); /* need *method* ID */
if (fname) {
return ID2SYM(fname);
}
else {
return Qnil;
}
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#__callee__;F;[ ;[[@fi;T;:__callee__;0;[ ;{ ;IC;"{Returns the called name of the current method as a Symbol.
If called outside of a method, it returns nil
.
;T;[o;=
;3I"
overload;F;40;;;50;)I"__callee__;T;IC;" ;T; @ ;>0;!F;[ ;[ ;I" ;T;0;6i ;[ ; @ ;[ ;I"Returns the called name of the current method as a Symbol.
If called outside of a method, it returns nil
.
@overload __callee__;T;0; @ ;!F;"o;#;$T;%i;&i;'@6;(I"static VALUE
rb_f_callee_name(VALUE _)
{
ID fname = prev_frame_callee(); /* need *callee* ID */
if (fname) {
return ID2SYM(fname);
}
else {
return Qnil;
}
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#__dir__;F;[ ;[[@fi;T;:__dir__;0;[ ;{ ;IC;"+Returns the canonicalized absolute path of the directory of the file from
which this method is called. It means symlinks in the path is resolved.
If __FILE__
is nil
, it returns nil
.
The return value equals to File.dirname(File.realpath(__FILE__))
.
;T;[o;=
;3I"
overload;F;40;;;50;)I"__dir__;T;IC;" ;T; @ ;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"String;T; @ ;[ ;I"@return [String];T;0;6i ;[ ; @ ;[ ;I"SReturns the canonicalized absolute path of the directory of the file from
which this method is called. It means symlinks in the path is resolved.
If __FILE__
is nil
, it returns nil
.
The return value equals to File.dirname(File.realpath(__FILE__))
.
@overload __dir__
@return [String];T;0; @ ;!F;"o;#;$T;%i;&i;'@6;(I"static VALUE
f_current_dirname(VALUE _)
{
VALUE base = rb_current_realfilepath();
if (NIL_P(base)) {
return Qnil;
}
base = rb_file_dirname(base);
return base;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#trace_var;F;[[I"*a;T0[I"_;T0;[[@fi;T;:trace_var;0;[ ;{ ;IC;"Controls tracing of assignments to global variables. The parameter
+symbol+ identifies the variable (as either a string name or a
symbol identifier). _cmd_ (which may be a string or a
+Proc+ object) or block is executed whenever the variable
is assigned. The block or +Proc+ object receives the
variable's new value as a parameter. Also see
Kernel::untrace_var.
trace_var :$_, proc {|v| puts "$_ is now '#{v}'" }
$_ = "hello"
$_ = ' there'
produces:
$_ is now 'hello'
$_ is now ' there'
;T;[o;=
;3I"
overload;F;40;;;50;)I"trace_var(symbol, cmd );T;IC;" ;T; @
;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"nil;T; @
;[ ;I"@return [nil];T;0;6i ;[[I"symbol;T0[I"cmd;T0; @
o;=
;3I"
overload;F;40;;;50;)I"trace_var(symbol);T;IC;" ;T; @
;>0;!F;[o;2
;3I"
yield;F;4I" ;T;0;5[I"val;T; @
o;2
;3I"return;F;4I" ;T;0;5[I"nil;T; @
;[ ;I"@yield [val]
@return [nil];T;0;6i ;[[I"symbol;T0; @
;[ ;I"pControls tracing of assignments to global variables. The parameter
+symbol+ identifies the variable (as either a string name or a
symbol identifier). _cmd_ (which may be a string or a
+Proc+ object) or block is executed whenever the variable
is assigned. The block or +Proc+ object receives the
variable's new value as a parameter. Also see
Kernel::untrace_var.
trace_var :$_, proc {|v| puts "$_ is now '#{v}'" }
$_ = "hello"
$_ = ' there'
produces:
$_ is now 'hello'
$_ is now ' there'
@overload trace_var(symbol, cmd )
@return [nil]
@overload trace_var(symbol)
@yield [val]
@return [nil];T;0; @
;!F;"o;#;$T;%i;&i
;'@6;(I"bstatic VALUE
f_trace_var(int c, const VALUE *a, VALUE _)
{
return rb_f_trace_var(c, a);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#untrace_var;F;[[I"*a;T0[I"_;T0;[[@fi;T;:untrace_var;0;[ ;{ ;IC;"Removes tracing for the specified command on the given global
variable and returns +nil+. If no command is specified,
removes all tracing for that variable and returns an array
containing the commands actually removed.
;T;[o;=
;3I"
overload;F;40;;;50;)I"!untrace_var(symbol [, cmd] );T;IC;" ;T; @L
;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"
Array;TI"nil;T; @L
;[ ;I"@return [Array, nil];T;0;6i ;[[I"symbol[, cmd];T0; @L
;[ ;I"Removes tracing for the specified command on the given global
variable and returns +nil+. If no command is specified,
removes all tracing for that variable and returns an array
containing the commands actually removed.
@overload untrace_var(symbol [, cmd] )
@return [Array, nil];T;0; @L
;!F;"o;#;$T;%i;&i;'@6;(I"fstatic VALUE
f_untrace_var(int c, const VALUE *a, VALUE _)
{
return rb_f_untrace_var(c, a);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#Complex;F;[[@c0;[[I"complex.c;Ti%;T;:Complex;0;[ ;{ ;IC;"DReturns x+i*y;
Complex(1, 2) #=> (1+2i)
Complex('1+2i') #=> (1+2i)
Complex(nil) #=> TypeError
Complex(1, nil) #=> TypeError
Complex(1, nil, exception: false) #=> nil
Complex('1+2', exception: false) #=> nil
Syntax of string form:
string form = extra spaces , complex , extra spaces ;
complex = real part | [ sign ] , imaginary part
| real part , sign , imaginary part
| rational , "@" , rational ;
real part = rational ;
imaginary part = imaginary unit | unsigned rational , imaginary unit ;
rational = [ sign ] , unsigned rational ;
unsigned rational = numerator | numerator , "/" , denominator ;
numerator = integer part | fractional part | integer part , fractional part ;
denominator = digits ;
integer part = digits ;
fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ;
imaginary unit = "i" | "I" | "j" | "J" ;
sign = "-" | "+" ;
digits = digit , { digit | "_" , digit };
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
extra spaces = ? \s* ? ;
See String#to_c.
;T;[o;=
;3I"
overload;F;40;;;50;)I"%Complex(x[, y], exception: true);T;IC;" ;T; @n
;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Numeric;TI"nil;T; @n
;[ ;I"@return [Numeric, nil];T;0;6i ;[[I"x[, y];T0[I"exception:;TI" true;T; @n
;[ ;I"Returns x+i*y;
Complex(1, 2) #=> (1+2i)
Complex('1+2i') #=> (1+2i)
Complex(nil) #=> TypeError
Complex(1, nil) #=> TypeError
Complex(1, nil, exception: false) #=> nil
Complex('1+2', exception: false) #=> nil
Syntax of string form:
string form = extra spaces , complex , extra spaces ;
complex = real part | [ sign ] , imaginary part
| real part , sign , imaginary part
| rational , "@" , rational ;
real part = rational ;
imaginary part = imaginary unit | unsigned rational , imaginary unit ;
rational = [ sign ] , unsigned rational ;
unsigned rational = numerator | numerator , "/" , denominator ;
numerator = integer part | fractional part | integer part , fractional part ;
denominator = digits ;
integer part = digits ;
fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ;
imaginary unit = "i" | "I" | "j" | "J" ;
sign = "-" | "+" ;
digits = digit , { digit | "_" , digit };
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
extra spaces = ? \s* ? ;
See String#to_c.
@overload Complex(x[, y], exception: true)
@return [Numeric, nil];T;0; @n
;!F;"o;#;$T;%i;&i#;'@6;(I"static VALUE
nucomp_f_complex(int argc, VALUE *argv, VALUE klass)
{
VALUE a1, a2, opts = Qnil;
int raise = TRUE;
if (rb_scan_args(argc, argv, "11:", &a1, &a2, &opts) == 1) {
a2 = Qundef;
}
if (!NIL_P(opts)) {
raise = rb_opts_exception_p(opts, raise);
}
if (argc > 0 && CLASS_OF(a1) == rb_cComplex && a2 == Qundef) {
return a1;
}
return nucomp_convert(rb_cComplex, a1, a2, raise);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#Pathname;F;[[I"str;T0;[[I"ext/pathname/pathname.c;Ti*;T;:
Pathname;0;[ ;{ ;IC;"Y:call-seq:
Pathname(path) -> pathname
Creates a new Pathname object from the given string, +path+, and returns
pathname object.
In order to use this constructor, you must first require the Pathname
standard library extension.
require 'pathname'
Pathname("/home/zzak")
#=> #
See also Pathname::new for more information.
;T;[ ;[ ;I"Z:call-seq:
Pathname(path) -> pathname
Creates a new Pathname object from the given string, +path+, and returns
pathname object.
In order to use this constructor, you must first require the Pathname
standard library extension.
require 'pathname'
Pathname("/home/zzak")
#=> #
See also Pathname::new for more information.
;T;0; @
;!F;"o;#;$T;%i;&i(;'@6;(I"static VALUE
path_f_pathname(VALUE self, VALUE str)
{
if (CLASS_OF(str) == rb_cPathname)
return str;
return rb_class_new_instance(1, &str, rb_cPathname);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#Rational;F;[[@c0;[[I"rational.c;Ti%;T;:
Rational;0;[ ;{ ;IC;"Returns +x/y+ or +arg+ as a Rational.
Rational(2, 3) #=> (2/3)
Rational(5) #=> (5/1)
Rational(0.5) #=> (1/2)
Rational(0.3) #=> (5404319552844595/18014398509481984)
Rational("2/3") #=> (2/3)
Rational("0.3") #=> (3/10)
Rational("10 cents") #=> ArgumentError
Rational(nil) #=> TypeError
Rational(1, nil) #=> TypeError
Rational("10 cents", exception: false) #=> nil
Syntax of the string form:
string form = extra spaces , rational , extra spaces ;
rational = [ sign ] , unsigned rational ;
unsigned rational = numerator | numerator , "/" , denominator ;
numerator = integer part | fractional part | integer part , fractional part ;
denominator = digits ;
integer part = digits ;
fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ;
sign = "-" | "+" ;
digits = digit , { digit | "_" , digit } ;
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
extra spaces = ? \s* ? ;
See also String#to_r.
;T;[o;=
;3I"
overload;F;40;;;50;)I"$Rational(x, y, exception: true);T;IC;" ;T; @
;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"nil;T; @
;[ ;I"@return [nil];T;0;6i ;[[I"x;T0[I"y;T0[I"exception:;TI" true;T; @
o;=
;3I"
overload;F;40;;;50;)I"#Rational(arg, exception: true);T;IC;" ;T; @
;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"nil;T; @
;[ ;I"@return [nil];T;0;6i ;[[I"arg;T0[I"exception:;TI" true;T; @
;[ ;I"jReturns +x/y+ or +arg+ as a Rational.
Rational(2, 3) #=> (2/3)
Rational(5) #=> (5/1)
Rational(0.5) #=> (1/2)
Rational(0.3) #=> (5404319552844595/18014398509481984)
Rational("2/3") #=> (2/3)
Rational("0.3") #=> (3/10)
Rational("10 cents") #=> ArgumentError
Rational(nil) #=> TypeError
Rational(1, nil) #=> TypeError
Rational("10 cents", exception: false) #=> nil
Syntax of the string form:
string form = extra spaces , rational , extra spaces ;
rational = [ sign ] , unsigned rational ;
unsigned rational = numerator | numerator , "/" , denominator ;
numerator = integer part | fractional part | integer part , fractional part ;
denominator = digits ;
integer part = digits ;
fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ;
sign = "-" | "+" ;
digits = digit , { digit | "_" , digit } ;
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
extra spaces = ? \s* ? ;
See also String#to_r.
@overload Rational(x, y, exception: true)
@return [nil]
@overload Rational(arg, exception: true)
@return [nil];T;0; @
;!F;"o;#;$T;%i ;&i$;'@6;(I"^static VALUE
nurat_f_rational(int argc, VALUE *argv, VALUE klass)
{
VALUE a1, a2, opts = Qnil;
int raise = TRUE;
if (rb_scan_args(argc, argv, "11:", &a1, &a2, &opts) == 1) {
a2 = Qundef;
}
if (!NIL_P(opts)) {
raise = rb_opts_exception_p(opts, raise);
}
return nurat_convert(rb_cRational, a1, a2, raise);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#callcc;F;[ ;[[I"cont.c;Ti;T;:callcc;0;[ ;{ ;IC;"Generates a Continuation object, which it passes to
the associated block. You need to require
'continuation'
before using this method. Performing a
cont.call
will cause the #callcc
to return (as will falling through the end of the block). The
value returned by the #callcc is the value of the
block, or the value passed to cont.call
. See
class Continuation for more details. Also see
Kernel#throw for an alternative mechanism for
unwinding a call stack.
;T;[o;=
;3I"
overload;F;40;;;50;)I"callcc;T;IC;" ;T; @
;>0;!F;[o;2
;3I"
yield;F;4I" ;T;0;5[I" cont;T; @
o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @
;[ ;I"#@yield [cont]
@return [Object];T;0;6i ;[ ; @
;[ ;I"4Generates a Continuation object, which it passes to
the associated block. You need to require
'continuation'
before using this method. Performing a
cont.call
will cause the #callcc
to return (as will falling through the end of the block). The
value returned by the #callcc is the value of the
block, or the value passed to cont.call
. See
class Continuation for more details. Also see
Kernel#throw for an alternative mechanism for
unwinding a call stack.
@overload callcc
@yield [cont]
@return [Object];T;0; @
;!F;"o;#;$T;%i;&i;'@6;(I"static VALUE
rb_callcc(VALUE self)
{
volatile int called;
volatile VALUE val = cont_capture(&called);
if (called) {
return val;
}
else {
return rb_yield(val);
}
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#syscall;F;[[@c0;[[@i';T;:syscall;0;[ ;{ ;IC;"Calls the operating system function identified by _num_ and
returns the result of the function or raises SystemCallError if
it failed.
Arguments for the function can follow _num_. They must be either
+String+ objects or +Integer+ objects. A +String+ object is passed
as a pointer to the byte sequence. An +Integer+ object is passed
as an integer whose bit size is same as a pointer.
Up to nine parameters may be passed.
The function identified by _num_ is system
dependent. On some Unix systems, the numbers may be obtained from a
header file called syscall.h
.
syscall 4, 1, "hello\n", 6 # '4' is write(2) on our box
produces:
hello
Calling +syscall+ on a platform which does not have any way to
an arbitrary system function just fails with NotImplementedError.
*Note:*
+syscall+ is essentially unsafe and unportable.
Feel free to shoot your foot.
The DL (Fiddle) library is preferred for safer and a bit
more portable programming.
;T;[o;=
;3I"
overload;F;40;;;50;)I"syscall(num [, args...]);T;IC;" ;T; @
;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Integer;T; @
;[ ;I"@return [Integer];T;0;6i ;[[I"num[, args...];T0; @
;[ ;I"Calls the operating system function identified by _num_ and
returns the result of the function or raises SystemCallError if
it failed.
Arguments for the function can follow _num_. They must be either
+String+ objects or +Integer+ objects. A +String+ object is passed
as a pointer to the byte sequence. An +Integer+ object is passed
as an integer whose bit size is same as a pointer.
Up to nine parameters may be passed.
The function identified by _num_ is system
dependent. On some Unix systems, the numbers may be obtained from a
header file called syscall.h
.
syscall 4, 1, "hello\n", 6 # '4' is write(2) on our box
produces:
hello
Calling +syscall+ on a platform which does not have any way to
an arbitrary system function just fails with NotImplementedError.
*Note:*
+syscall+ is essentially unsafe and unportable.
Feel free to shoot your foot.
The DL (Fiddle) library is preferred for safer and a bit
more portable programming.
@overload syscall(num [, args...])
@return [Integer];T;0; @
;!F;"o;#;$T;%i';&i';'@6;(I"e static VALUE
rb_f_syscall(int argc, VALUE *argv, VALUE _)
{
VALUE arg[8];
#if SIZEOF_VOIDP == 8 && defined(HAVE___SYSCALL) && SIZEOF_INT != 8 /* mainly *BSD */
# define SYSCALL __syscall
# define NUM2SYSCALLID(x) NUM2LONG(x)
# define RETVAL2NUM(x) LONG2NUM(x)
# if SIZEOF_LONG == 8
long num, retval = -1;
# elif SIZEOF_LONG_LONG == 8
long long num, retval = -1;
# else
# error ---->> it is asserted that __syscall takes the first argument and returns retval in 64bit signed integer. <<----
# endif
#elif defined(__linux__)
# define SYSCALL syscall
# define NUM2SYSCALLID(x) NUM2LONG(x)
# define RETVAL2NUM(x) LONG2NUM(x)
/*
* Linux man page says, syscall(2) function prototype is below.
*
* int syscall(int number, ...);
*
* But, it's incorrect. Actual one takes and returned long. (see unistd.h)
*/
long num, retval = -1;
#else
# define SYSCALL syscall
# define NUM2SYSCALLID(x) NUM2INT(x)
# define RETVAL2NUM(x) INT2NUM(x)
int num, retval = -1;
#endif
int i;
if (RTEST(ruby_verbose)) {
rb_category_warning(RB_WARN_CATEGORY_DEPRECATED,
"We plan to remove a syscall function at future release. DL(Fiddle) provides safer alternative.");
}
if (argc == 0)
rb_raise(rb_eArgError, "too few arguments for syscall");
if (argc > numberof(arg))
rb_raise(rb_eArgError, "too many arguments for syscall");
num = NUM2SYSCALLID(argv[0]); ++argv;
for (i = argc - 1; i--; ) {
VALUE v = rb_check_string_type(argv[i]);
if (!NIL_P(v)) {
SafeStringValue(v);
rb_str_modify(v);
arg[i] = (VALUE)StringValueCStr(v);
}
else {
arg[i] = (VALUE)NUM2LONG(argv[i]);
}
}
switch (argc) {
case 1:
retval = SYSCALL(num);
break;
case 2:
retval = SYSCALL(num, arg[0]);
break;
case 3:
retval = SYSCALL(num, arg[0],arg[1]);
break;
case 4:
retval = SYSCALL(num, arg[0],arg[1],arg[2]);
break;
case 5:
retval = SYSCALL(num, arg[0],arg[1],arg[2],arg[3]);
break;
case 6:
retval = SYSCALL(num, arg[0],arg[1],arg[2],arg[3],arg[4]);
break;
case 7:
retval = SYSCALL(num, arg[0],arg[1],arg[2],arg[3],arg[4],arg[5]);
break;
case 8:
retval = SYSCALL(num, arg[0],arg[1],arg[2],arg[3],arg[4],arg[5],arg[6]);
break;
}
if (retval == -1)
rb_sys_fail(0);
return RETVAL2NUM(retval);
#undef SYSCALL
#undef NUM2SYSCALLID
#undef RETVAL2NUM
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#open;F;[[@c0;[[@i;T;: open;0;[ ;{ ;IC;" Creates an IO object connected to the given stream, file, or subprocess.
If +path+ does not start with a pipe character (|
), treat it
as the name of a file to open using the specified mode (defaulting to
"r").
The +mode+ is either a string or an integer. If it is an integer, it
must be bitwise-or of open(2) flags, such as File::RDWR or File::EXCL. If
it is a string, it is either "fmode", "fmode:ext_enc", or
"fmode:ext_enc:int_enc".
See the documentation of IO.new for full documentation of the +mode+ string
directives.
If a file is being created, its initial permissions may be set using the
+perm+ parameter. See File.new and the open(2) and chmod(2) man pages for
a description of permissions.
If a block is specified, it will be invoked with the IO object as a
parameter, and the IO will be automatically closed when the block
terminates. The call returns the value of the block.
If +path+ starts with a pipe character ("|"
), a subprocess is
created, connected to the caller by a pair of pipes. The returned IO
object may be used to write to the standard input and read from the
standard output of this subprocess.
If the command following the pipe is a single minus sign
("|-"
), Ruby forks, and this subprocess is connected to the
parent. If the command is not "-"
, the subprocess runs the
command.
When the subprocess is Ruby (opened via "|-"
), the +open+
call returns +nil+. If a block is associated with the open call, that
block will run twice --- once in the parent and once in the child.
The block parameter will be an IO object in the parent and +nil+ in the
child. The parent's +IO+ object will be connected to the child's $stdin
and $stdout. The subprocess will be terminated at the end of the block.
=== Examples
Reading from "testfile":
open("testfile") do |f|
print f.gets
end
Produces:
This is line one
Open a subprocess and read its output:
cmd = open("|date")
print cmd.gets
cmd.close
Produces:
Wed Apr 9 08:56:31 CDT 2003
Open a subprocess running the same Ruby program:
f = open("|-", "w+")
if f.nil?
puts "in Child"
exit
else
puts "Got: #{f.gets}"
end
Produces:
Got: in Child
Open a subprocess using a block to receive the IO object:
open "|-" do |f|
if f then
# parent process
puts "Got: #{f.gets}"
else
# child process
puts "in Child"
end
end
Produces:
Got: in Child
;T;[o;=
;3I"
overload;F;40;;;50;)I")open(path [, mode [, perm]] [, opt]);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"IO;TI"nil;T; @;[ ;I"@return [IO, nil];T;0;6i ;[[I"!path[, mode [, perm]][, opt];T0; @o;=
;3I"
overload;F;40;;;50;)I")open(path [, mode [, perm]] [, opt]);T;IC;" ;T; @;>0;!F;[o;2
;3I"
yield;F;4I" ;T;0;5[I"io;T; @o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @;[ ;I"!@yield [io]
@return [Object];T;0;6i ;[[I"!path[, mode [, perm]][, opt];T0; @;[ ;I"\
Creates an IO object connected to the given stream, file, or subprocess.
If +path+ does not start with a pipe character (|
), treat it
as the name of a file to open using the specified mode (defaulting to
"r").
The +mode+ is either a string or an integer. If it is an integer, it
must be bitwise-or of open(2) flags, such as File::RDWR or File::EXCL. If
it is a string, it is either "fmode", "fmode:ext_enc", or
"fmode:ext_enc:int_enc".
See the documentation of IO.new for full documentation of the +mode+ string
directives.
If a file is being created, its initial permissions may be set using the
+perm+ parameter. See File.new and the open(2) and chmod(2) man pages for
a description of permissions.
If a block is specified, it will be invoked with the IO object as a
parameter, and the IO will be automatically closed when the block
terminates. The call returns the value of the block.
If +path+ starts with a pipe character ("|"
), a subprocess is
created, connected to the caller by a pair of pipes. The returned IO
object may be used to write to the standard input and read from the
standard output of this subprocess.
If the command following the pipe is a single minus sign
("|-"
), Ruby forks, and this subprocess is connected to the
parent. If the command is not "-"
, the subprocess runs the
command.
When the subprocess is Ruby (opened via "|-"
), the +open+
call returns +nil+. If a block is associated with the open call, that
block will run twice --- once in the parent and once in the child.
The block parameter will be an IO object in the parent and +nil+ in the
child. The parent's +IO+ object will be connected to the child's $stdin
and $stdout. The subprocess will be terminated at the end of the block.
=== Examples
Reading from "testfile":
open("testfile") do |f|
print f.gets
end
Produces:
This is line one
Open a subprocess and read its output:
cmd = open("|date")
print cmd.gets
cmd.close
Produces:
Wed Apr 9 08:56:31 CDT 2003
Open a subprocess running the same Ruby program:
f = open("|-", "w+")
if f.nil?
puts "in Child"
exit
else
puts "Got: #{f.gets}"
end
Produces:
Got: in Child
Open a subprocess using a block to receive the IO object:
open "|-" do |f|
if f then
# parent process
puts "Got: #{f.gets}"
else
# child process
puts "in Child"
end
end
Produces:
Got: in Child
@overload open(path [, mode [, perm]] [, opt])
@return [IO, nil]
@overload open(path [, mode [, perm]] [, opt])
@yield [io]
@return [Object];T;0; @;!F;"o;#;$T;%iA;&i;'@6;(I"static VALUE
rb_f_open(int argc, VALUE *argv, VALUE _)
{
ID to_open = 0;
int redirect = FALSE;
if (argc >= 1) {
CONST_ID(to_open, "to_open");
if (rb_respond_to(argv[0], to_open)) {
redirect = TRUE;
}
else {
VALUE tmp = argv[0];
FilePathValue(tmp);
if (NIL_P(tmp)) {
redirect = TRUE;
}
else {
VALUE cmd = check_pipe_command(tmp);
if (!NIL_P(cmd)) {
argv[0] = cmd;
return rb_io_s_popen(argc, argv, rb_cIO);
}
}
}
}
if (redirect) {
VALUE io = rb_funcallv_kw(argv[0], to_open, argc-1, argv+1, RB_PASS_CALLED_KEYWORDS);
if (rb_block_given_p()) {
return rb_ensure(rb_yield, io, io_close, io);
}
return io;
}
return rb_io_s_open(argc, argv, rb_cFile);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#printf;F;[[@c0;[[@i;T;:printf;0;[ ;{ ;IC;"iEquivalent to:
io.write(sprintf(string, obj, ...))
or
$stdout.write(sprintf(string, obj, ...))
;T;[o;=
;3I"
overload;F;40;;;50;)I"$printf(io, string [, obj ... ]);T;IC;" ;T; @J;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"nil;T; @J;[ ;I"@return [nil];T;0;6i ;[[I"io;T0[I"string[, obj ... ];T0; @Jo;=
;3I"
overload;F;40;;;50;)I" printf(string [, obj ... ]);T;IC;" ;T; @J;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"nil;T; @J;[ ;I"@return [nil];T;0;6i ;[[I"string[, obj ... ];T0; @J;[ ;I"Equivalent to:
io.write(sprintf(string, obj, ...))
or
$stdout.write(sprintf(string, obj, ...))
@overload printf(io, string [, obj ... ])
@return [nil]
@overload printf(string [, obj ... ])
@return [nil];T;0; @J;!F;"o;#;$T;%i;&i;'@6;(I"*static VALUE
rb_f_printf(int argc, VALUE *argv, VALUE _)
{
VALUE out;
if (argc == 0) return Qnil;
if (RB_TYPE_P(argv[0], T_STRING)) {
out = rb_ractor_stdout();
}
else {
out = argv[0];
argv++;
argc--;
}
rb_io_write(out, rb_f_sprintf(argc, argv));
return Qnil;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#print;F;[[@c0;[[@iZ;T;:
print;0;[ ;{ ;IC;"Prints each object in turn to $stdout
. If the output
field separator ($,
) is not +nil+, its
contents will appear between each field. If the output record
separator ($\\
) is not +nil+, it will be
appended to the output. If no arguments are given, prints
$_
. Objects that aren't strings will be converted by
calling their to_s
method.
print "cat", [1,2,3], 99, "\n"
$, = ", "
$\ = "\n"
print "cat", [1,2,3], 99
produces:
cat12399
cat, 1, 2, 3, 99
;T;[o;=
;3I"
overload;F;40;;;50;)I"print(obj, ...);T;IC;" ;T; @y;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"nil;T; @y;[ ;I"@return [nil];T;0;6i ;[[I"obj;T0[I"...;T0; @y;[ ;I"GPrints each object in turn to $stdout
. If the output
field separator ($,
) is not +nil+, its
contents will appear between each field. If the output record
separator ($\\
) is not +nil+, it will be
appended to the output. If no arguments are given, prints
$_
. Objects that aren't strings will be converted by
calling their to_s
method.
print "cat", [1,2,3], 99, "\n"
$, = ", "
$\ = "\n"
print "cat", [1,2,3], 99
produces:
cat12399
cat, 1, 2, 3, 99
@overload print(obj, ...)
@return [nil];T;0; @y;!F;"o;#;$T;%iC;&iW;'@6;(I"static VALUE
rb_f_print(int argc, const VALUE *argv, VALUE _)
{
rb_io_print(argc, argv, rb_ractor_stdout());
return Qnil;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#putc;F;[[I"ch;T0;[[@i;T;: putc;0;[ ;{ ;IC;"Equivalent to:
$stdout.putc(int)
Refer to the documentation for IO#putc for important information regarding
multi-byte characters.
;T;[o;=
;3I"
overload;F;40;;;50;)I"putc(int);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Integer;T; @;[ ;I"@return [Integer];T;0;6i ;[[I"int;T0; @;[ ;I"Equivalent to:
$stdout.putc(int)
Refer to the documentation for IO#putc for important information regarding
multi-byte characters.
@overload putc(int)
@return [Integer];T;0; @;!F;"o;#;$T;%i;&i;'@6;(I"static VALUE
rb_f_putc(VALUE recv, VALUE ch)
{
VALUE r_stdout = rb_ractor_stdout();
if (recv == r_stdout) {
return rb_io_putc(recv, ch);
}
return rb_funcallv(r_stdout, rb_intern("putc"), 1, &ch);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#puts;F;[[@c0;[[@i ;T;: puts;0;[ ;{ ;IC;".Equivalent to
$stdout.puts(obj, ...)
;T;[o;=
;3I"
overload;F;40;;;50;)I"puts(obj, ...);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"nil;T; @;[ ;I"@return [nil];T;0;6i ;[[I"obj;T0[I"...;T0; @;[ ;I"YEquivalent to
$stdout.puts(obj, ...)
@overload puts(obj, ...)
@return [nil];T;0; @;!F;"o;#;$T;%i;&i;'@6;(I"static VALUE
rb_f_puts(int argc, VALUE *argv, VALUE recv)
{
VALUE r_stdout = rb_ractor_stdout();
if (recv == r_stdout) {
return rb_io_puts(argc, argv, recv);
}
return rb_funcallv(r_stdout, rb_intern("puts"), argc, argv);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#gets;F;[[@c0;[[@ii#;T;: gets;0;[ ;{ ;IC;"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 the first argument is an
integer, or optional second argument is given, the returning string
would not be longer than the given value in bytes. 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.
;T;[o;=
;3I"
overload;F;40;;;50;)I""gets(sep=$/ [, getline_args]);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"String;TI"nil;T; @;[ ;I"@return [String, nil];T;0;6i ;[[I"sep;TI"$/[, getline_args];T; @o;=
;3I"
overload;F;40;;;50;)I"!gets(limit [, getline_args]);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"String;TI"nil;T; @;[ ;I"@return [String, nil];T;0;6i ;[[I"limit[, getline_args];T0; @o;=
;3I"
overload;F;40;;;50;)I"&gets(sep, limit [, getline_args]);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"String;TI"nil;T; @;[ ;I"@return [String, nil];T;0;6i ;[[I"sep;T0[I"limit[, getline_args];T0; @;[ ;I"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 the first argument is an
integer, or optional second argument is given, the returning string
would not be longer than the given value in bytes. 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.
@overload gets(sep=$/ [, getline_args])
@return [String, nil]
@overload gets(limit [, getline_args])
@return [String, nil]
@overload gets(sep, limit [, getline_args])
@return [String, nil];T;0; @;!F;"o;#;$T;%iH#;&ih#;'@6;(I"static VALUE
rb_f_gets(int argc, VALUE *argv, VALUE recv)
{
if (recv == argf) {
return argf_gets(argc, argv, argf);
}
return rb_funcallv(argf, idGets, argc, argv);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#readline;F;[[@c0;[[@i#;T;:
readline;0;[ ;{ ;IC;"TEquivalent to Kernel::gets, except
+readline+ raises +EOFError+ at end of file.
;T;[o;=
;3I"
overload;F;40;;;50;)I"readline(sep=$/);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"String;T; @;[ ;I"@return [String];T;0;6i ;[[I"sep;TI"$/;T; @o;=
;3I"
overload;F;40;;;50;)I"readline(limit);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"String;T; @;[ ;I"@return [String];T;0;6i ;[[I"
limit;T0; @o;=
;3I"
overload;F;40;;;50;)I"readline(sep, limit);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"String;T; @;[ ;I"@return [String];T;0;6i ;[[I"sep;T0[I"
limit;T0; @;[ ;I"Equivalent to Kernel::gets, except
+readline+ raises +EOFError+ at end of file.
@overload readline(sep=$/)
@return [String]
@overload readline(limit)
@return [String]
@overload readline(sep, limit)
@return [String];T;0; @;!F;"o;#;$T;%i#;&i#;'@6;(I"static VALUE
rb_f_readline(int argc, VALUE *argv, VALUE recv)
{
if (recv == argf) {
return argf_readline(argc, argv, argf);
}
return rb_funcallv(argf, rb_intern("readline"), argc, argv);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#select;F;[[@c0;[[@i&;T;:select;0;[ ;{ ;IC;"Calls select(2) system call.
It monitors given arrays of IO objects, waits until one or more of
IO objects are ready for reading, are ready for writing, and have
pending exceptions respectively, and returns an array that contains
arrays of those IO objects. It will return +nil+ if optional
timeout value is given and no IO object is ready in
timeout seconds.
IO.select peeks the buffer of IO objects for testing readability.
If the IO buffer is not empty, IO.select immediately notifies
readability. This "peek" only happens for IO objects. It does not
happen for IO-like objects such as OpenSSL::SSL::SSLSocket.
The best way to use IO.select is invoking it after nonblocking
methods such as #read_nonblock, #write_nonblock, etc. The methods
raise an exception which is extended by IO::WaitReadable or
IO::WaitWritable. The modules notify how the caller should wait
with IO.select. If IO::WaitReadable is raised, the caller should
wait for reading. If IO::WaitWritable is raised, the caller should
wait for writing.
So, blocking read (#readpartial) can be emulated using
#read_nonblock and IO.select as follows:
begin
result = io_like.read_nonblock(maxlen)
rescue IO::WaitReadable
IO.select([io_like])
retry
rescue IO::WaitWritable
IO.select(nil, [io_like])
retry
end
Especially, the combination of nonblocking methods and IO.select is
preferred for IO like objects such as OpenSSL::SSL::SSLSocket. It
has #to_io method to return underlying IO object. IO.select calls
#to_io to obtain the file descriptor to wait.
This means that readability notified by IO.select doesn't mean
readability from OpenSSL::SSL::SSLSocket object.
The most likely situation is that OpenSSL::SSL::SSLSocket buffers
some data. IO.select doesn't see the buffer. So IO.select can
block when OpenSSL::SSL::SSLSocket#readpartial doesn't block.
However, several more complicated situations exist.
SSL is a protocol which is sequence of records.
The record consists of multiple bytes.
So, the remote side of SSL sends a partial record, IO.select
notifies readability but OpenSSL::SSL::SSLSocket cannot decrypt a
byte and OpenSSL::SSL::SSLSocket#readpartial will block.
Also, the remote side can request SSL renegotiation which forces
the local SSL engine to write some data.
This means OpenSSL::SSL::SSLSocket#readpartial may invoke #write
system call and it can block.
In such a situation, OpenSSL::SSL::SSLSocket#read_nonblock raises
IO::WaitWritable instead of blocking.
So, the caller should wait for ready for writability as above
example.
The combination of nonblocking methods and IO.select is also useful
for streams such as tty, pipe socket socket when multiple processes
read from a stream.
Finally, Linux kernel developers don't guarantee that
readability of select(2) means readability of following read(2) even
for a single process.
See select(2) manual on GNU/Linux system.
Invoking IO.select before IO#readpartial works well as usual.
However it is not the best way to use IO.select.
The writability notified by select(2) doesn't show
how many bytes are writable.
IO#write method blocks until given whole string is written.
So, IO#write(two or more bytes)
can block after
writability is notified by IO.select. IO#write_nonblock is required
to avoid the blocking.
Blocking write (#write) can be emulated using #write_nonblock and
IO.select as follows: IO::WaitReadable should also be rescued for
SSL renegotiation in OpenSSL::SSL::SSLSocket.
while 0 < string.bytesize
begin
written = io_like.write_nonblock(string)
rescue IO::WaitReadable
IO.select([io_like])
retry
rescue IO::WaitWritable
IO.select(nil, [io_like])
retry
end
string = string.byteslice(written..-1)
end
=== Parameters
read_array:: an array of IO objects that wait until ready for read
write_array:: an array of IO objects that wait until ready for write
error_array:: an array of IO objects that wait for exceptions
timeout:: a numeric value in second
=== Example
rp, wp = IO.pipe
mesg = "ping "
100.times {
# IO.select follows IO#read. Not the best way to use IO.select.
rs, ws, = IO.select([rp], [wp])
if r = rs[0]
ret = r.read(5)
print ret
case ret
when /ping/
mesg = "pong\n"
when /pong/
mesg = "ping "
end
end
if w = ws[0]
w.write(mesg)
end
}
produces:
ping pong
ping pong
ping pong
(snipped)
ping
;T;[o;=
;3I"
overload;F;40;;;50;)I"Cselect(read_array [, write_array [, error_array [, timeout]]]);T;IC;" ;T; @Y;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"
Array;TI"nil;T; @Y;[ ;I"@return [Array, nil];T;0;6i ;[[I":read_array[, write_array [, error_array [, timeout]]];T0; @Y;[ ;I"+Calls select(2) system call.
It monitors given arrays of IO objects, waits until one or more of
IO objects are ready for reading, are ready for writing, and have
pending exceptions respectively, and returns an array that contains
arrays of those IO objects. It will return +nil+ if optional
timeout value is given and no IO object is ready in
timeout seconds.
IO.select peeks the buffer of IO objects for testing readability.
If the IO buffer is not empty, IO.select immediately notifies
readability. This "peek" only happens for IO objects. It does not
happen for IO-like objects such as OpenSSL::SSL::SSLSocket.
The best way to use IO.select is invoking it after nonblocking
methods such as #read_nonblock, #write_nonblock, etc. The methods
raise an exception which is extended by IO::WaitReadable or
IO::WaitWritable. The modules notify how the caller should wait
with IO.select. If IO::WaitReadable is raised, the caller should
wait for reading. If IO::WaitWritable is raised, the caller should
wait for writing.
So, blocking read (#readpartial) can be emulated using
#read_nonblock and IO.select as follows:
begin
result = io_like.read_nonblock(maxlen)
rescue IO::WaitReadable
IO.select([io_like])
retry
rescue IO::WaitWritable
IO.select(nil, [io_like])
retry
end
Especially, the combination of nonblocking methods and IO.select is
preferred for IO like objects such as OpenSSL::SSL::SSLSocket. It
has #to_io method to return underlying IO object. IO.select calls
#to_io to obtain the file descriptor to wait.
This means that readability notified by IO.select doesn't mean
readability from OpenSSL::SSL::SSLSocket object.
The most likely situation is that OpenSSL::SSL::SSLSocket buffers
some data. IO.select doesn't see the buffer. So IO.select can
block when OpenSSL::SSL::SSLSocket#readpartial doesn't block.
However, several more complicated situations exist.
SSL is a protocol which is sequence of records.
The record consists of multiple bytes.
So, the remote side of SSL sends a partial record, IO.select
notifies readability but OpenSSL::SSL::SSLSocket cannot decrypt a
byte and OpenSSL::SSL::SSLSocket#readpartial will block.
Also, the remote side can request SSL renegotiation which forces
the local SSL engine to write some data.
This means OpenSSL::SSL::SSLSocket#readpartial may invoke #write
system call and it can block.
In such a situation, OpenSSL::SSL::SSLSocket#read_nonblock raises
IO::WaitWritable instead of blocking.
So, the caller should wait for ready for writability as above
example.
The combination of nonblocking methods and IO.select is also useful
for streams such as tty, pipe socket socket when multiple processes
read from a stream.
Finally, Linux kernel developers don't guarantee that
readability of select(2) means readability of following read(2) even
for a single process.
See select(2) manual on GNU/Linux system.
Invoking IO.select before IO#readpartial works well as usual.
However it is not the best way to use IO.select.
The writability notified by select(2) doesn't show
how many bytes are writable.
IO#write method blocks until given whole string is written.
So, IO#write(two or more bytes)
can block after
writability is notified by IO.select. IO#write_nonblock is required
to avoid the blocking.
Blocking write (#write) can be emulated using #write_nonblock and
IO.select as follows: IO::WaitReadable should also be rescued for
SSL renegotiation in OpenSSL::SSL::SSLSocket.
while 0 < string.bytesize
begin
written = io_like.write_nonblock(string)
rescue IO::WaitReadable
IO.select([io_like])
retry
rescue IO::WaitWritable
IO.select(nil, [io_like])
retry
end
string = string.byteslice(written..-1)
end
=== Parameters
read_array:: an array of IO objects that wait until ready for read
write_array:: an array of IO objects that wait until ready for write
error_array:: an array of IO objects that wait for exceptions
timeout:: a numeric value in second
=== Example
rp, wp = IO.pipe
mesg = "ping "
100.times {
# IO.select follows IO#read. Not the best way to use IO.select.
rs, ws, = IO.select([rp], [wp])
if r = rs[0]
ret = r.read(5)
print ret
case ret
when /ping/
mesg = "pong\n"
when /pong/
mesg = "ping "
end
end
if w = ws[0]
w.write(mesg)
end
}
produces:
ping pong
ping pong
ping pong
(snipped)
ping
@overload select(read_array [, write_array [, error_array [, timeout]]])
@return [Array, nil];T;0; @Y;!F;"o;#;$T;%i%;&i&;'@6;(I"
static VALUE
rb_f_select(int argc, VALUE *argv, VALUE obj)
{
VALUE timeout;
struct select_args args;
struct timeval timerec;
int i;
rb_scan_args(argc, argv, "13", &args.read, &args.write, &args.except, &timeout);
if (NIL_P(timeout)) {
args.timeout = 0;
}
else {
timerec = rb_time_interval(timeout);
args.timeout = &timerec;
}
for (i = 0; i < numberof(args.fdsets); ++i)
rb_fd_init(&args.fdsets[i]);
return rb_ensure(select_call, (VALUE)&args, select_end, (VALUE)&args);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Kernel#readlines;F;[[@c0;[[@i#;T;:readlines;0;[ ;{ ;IC;"zReturns an array containing the lines returned by calling
Kernel.gets(sep)
until the end of file.
;T;[o;=
;3I"
overload;F;40;;;50;)I"readlines(sep=$/);T;IC;" ;T; @x;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"
Array;T; @x;[ ;I"@return [Array];T;0;6i ;[[I"sep;TI"$/;T; @xo;=
;3I"
overload;F;40;;;50;)I"readlines(limit);T;IC;" ;T; @x;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"
Array;T; @x;[ ;I"@return [Array];T;0;6i ;[[I"
limit;T0; @xo;=
;3I"
overload;F;40;;;50;)I"readlines(sep, limit);T;IC;" ;T; @x;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"
Array;T; @x;[ ;I"@return [Array];T;0;6i ;[[I"sep;T0[I"
limit;T0; @x;[ ;I"Returns an array containing the lines returned by calling
Kernel.gets(sep)
until the end of file.
@overload readlines(sep=$/)
@return [Array]
@overload readlines(limit)
@return [Array]
@overload readlines(sep, limit)
@return [Array];T;0; @x;!F;"o;#;$T;%i#;&i#;'@6;(I"static VALUE
rb_f_readlines(int argc, VALUE *argv, VALUE recv)
{
if (recv == argf) {
return argf_readlines(argc, argv, argf);
}
return rb_funcallv(argf, rb_intern("readlines"), argc, argv);
};T;)I"static VALUE;T;*To;;F;
;;;;I"
Kernel#`;F;[[I"str;T0;[[@i*$;T;:`;0;[ ;{ ;IC;"ZReturns the standard output of running _cmd_ in a subshell.
The built-in syntax %x{...}
uses
this method. Sets $?
to the process status.
`date` #=> "Wed Apr 9 08:56:30 CDT 2003\n"
`ls testdir`.split[1] #=> "main.rb"
`echo oops && exit 99` #=> "oops\n"
$?.exitstatus #=> 99
;T;[o;=
;3I"
overload;F;40;;;50;)I"
`cmd`;T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"String;T; @;[ ;I"@return [String];T;0;6i ;[ ; @;[ ;I"Returns the standard output of running _cmd_ in a subshell.
The built-in syntax %x{...}
uses
this method. Sets $?
to the process status.
`date` #=> "Wed Apr 9 08:56:30 CDT 2003\n"
`ls testdir`.split[1] #=> "main.rb"
`echo oops && exit 99` #=> "oops\n"
$?.exitstatus #=> 99
@overload `cmd`
@return [String];T;0; @;!F;"o;#;$T;%i$;&i'$;'@6;(I"static VALUE
rb_f_backquote(VALUE obj, VALUE str)
{
VALUE port;
VALUE result;
rb_io_t *fptr;
SafeStringValue(str);
rb_last_status_clear();
port = pipe_open_s(str, "r", FMODE_READABLE|DEFAULT_TEXTMODE, NULL);
if (NIL_P(port)) return rb_str_new(0,0);
GetOpenFile(port, fptr);
result = read_all(fptr, remain_size(fptr), Qnil);
rb_io_close(port);
RFILE(port)->fptr = NULL;
rb_io_fptr_finalize(fptr);
rb_gc_force_recycle(port); /* also guards from premature GC */
return result;
};T;)I"static VALUE;T;*To;;F;
;;;;I"
Kernel#p;F;[[@c0;[[@iE;T;:p;0;[ ;{ ;IC;"For each object, directly writes _obj_.+inspect+ followed by a
newline to the program's standard output.
S = Struct.new(:name, :state)
s = S['dave', 'TX']
p s
produces:
#
;T;[o;=
;3I"
overload;F;40;;;50;)I"p(obj);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @;[ ;I"@return [Object];T;0;6i ;[[I"obj;T0; @o;=
;3I"
overload;F;40;;;50;)I"p(obj1, obj2, ...);T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"
Array;T; @;[ ;I"@return [Array];T;0;6i ;[[I" obj1;T0[I" obj2;T0[I"...;T0; @o;=
;3I"
overload;F;40;;;50;)I"p();T;IC;" ;T; @;>0;!F;[o;2
;3I"return;F;4I" ;T;0;5[I"nil;T; @;[ ;I"@return [nil];T;0;6i ;[ ; @;[ ;I"PFor each object, directly writes _obj_.+inspect+ followed by a
newline to the program's standard output.
S = Struct.new(:name, :state)
s = S['dave', 'TX']
p s
produces:
#
@overload p(obj)
@return [Object]
@overload p(obj1, obj2, ...)
@return [Array]
@overload p()
@return [nil];T;0; @;!F;"o;#;$T;%i3;&iD;'@6;(I" static VALUE
rb_f_p(int argc, VALUE *argv, VALUE self)
{
int i;
for (i=0; i