{E: rooto:"YARD::CodeObjects::RootObject:@childrenIC:&YARD::CodeObjects::CodeObjectList[o:$YARD::CodeObjects::ModuleObject;IC;[Io:#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;TiE:@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:
beginiA:endiC:@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;[[@iS;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;%iM;&iQ;'@
;(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;[ ;[[@ij;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;%ig;&ih;'@
;(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;[ ;[[@is;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;%ip;&iq;'@
;(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;%iy;&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;[ ;[[@i;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;%i;&i;'@
;(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;[ ;[[@i;T;;&;0;[ ;{ ;IC;"TCloses the stream. All operations on the closed stream will raise an
exception.
;T;[ ;[ ;@;0; @;!F;"o;#;$T;%i;&i;'@
;(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;[ ;[[@i;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;&i;'@
;(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;[ ;[[@i;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;[o;2
;3I"return;F;4I" ;T;0;5[I"String;T; @;[ ;I"@return [String];T;0; @;!F;6i :
@summary0;[ ; @o;=
;3I"
overload;F;40;;<;50;)I"finish;T;IC;" ;T;[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; @;!F;6i ;>0;[ ; @;[ ;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;%i
;&i;'@
;(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;[ ;[ ;I" ;T;0; @;!F;6i ;>0;[ ; @;[ ;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);
OBJ_INFECT(dst, obj);
return dst;
};T;)I"static VALUE;T;*To;;F;
;;;;I"!Zlib::ZStream#flush_next_out;F;[ ;[[@i7;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;[o;2
;3I"return;F;4I" ;T;0;5[I"String;T; @;[ ;I"@return [String];T;0; @;!F;6i ;>0;[ ; @o;=
;3I"
overload;F;40;;@;50;)I"flush_next_out;T;IC;" ;T;[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; @;!F;6i ;>0;[ ; @;[ ;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.;&i7;'@
;(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;&i;6i ;'o:YARD::CodeObjects::Proxy:@orignamespace0:@origname0:
@imethod0;: Zlib;'@: @obj@:
@type0;I"Zlib::ZStream;F:@superclasso;L;M0;N0;O0;:Object;'@;Qo;
;IC;[Do;;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;[o;2
;3I"return;F;4I" ;T;0;5[I"Object;T; @_;[ ;I"@return [Object];T;0; @_;!F;6i ;>0;[ ; @_;[ ;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;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @};[ ;I"@return [Boolean];T;0; @};!F;6i ;>0;[[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;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @};[ ;I"@return [Boolean];T;0; @};!F;6i ;>0;[[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;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @;[ ;I"@return [Boolean];T;0; @;!F;6i ;>0;[[I"symbol;T0[I"include_all;T0; @o;=
;3I"
overload;F;40;;W;50;)I"-respond_to_missing?(string, include_all);T;IC;" ;T;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @;[ ;I"@return [Boolean];T;0; @;!F;6i ;>0;[[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;Ti8;T;:to_enum;0;[ ;{ ;IC;"6Creates a new Enumerator which will enumerate by calling +method+ on
+obj+, passing +args+ if any.
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)
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;[o;2
;3I"return;F;4I" ;T;0;5[I"Enumerator;T; @;[ ;I"@return [Enumerator];T;0; @;!F;6i ;>0;[[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;[o;2
;3I"return;F;4I" ;T;0;5[I"Enumerator;T; @;[ ;I"@return [Enumerator];T;0; @;!F;6i ;>0;[[I"method;TI"
:each;T[I"
*args;T0; @o;=
;3I"
overload;F;40;;X;50;)I"#to_enum(method = :each, *args);T;IC;" ;T;[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; @;!F;6i ;>0;[[I"method;TI"
:each;T[I"
*args;T0; @o;=
;3I"
overload;F;40;;Y;50;)I"$enum_for(method = :each, *args);T;IC;" ;T;[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; @;!F;6i ;>0;[[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.
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)
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;%i;&i;;'@];(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;[[@i8;T;;Y;0;[ ;{ ;IC;"6Creates a new Enumerator which will enumerate by calling +method+ on
+obj+, passing +args+ if any.
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)
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;[o;2
;3I"return;F;4I" ;T;0;5[I"Enumerator;T; @G;[ ;I"@return [Enumerator];T;0; @G;!F;6i ;>0;[[I"method;TI"
:each;T[I"
*args;T0; @Go;=
;3I"
overload;F;40;;Y;50;)I"$enum_for(method = :each, *args);T;IC;" ;T;[o;2
;3I"return;F;4I" ;T;0;5[I"Enumerator;T; @G;[ ;I"@return [Enumerator];T;0; @G;!F;6i ;>0;[[I"method;TI"
:each;T[I"
*args;T0; @Go;=
;3I"
overload;F;40;;X;50;)I"#to_enum(method = :each, *args);T;IC;" ;T;[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; @G;!F;6i ;>0;[[I"method;TI"
:each;T[I"
*args;T0; @Go;=
;3I"
overload;F;40;;Y;50;)I"$enum_for(method = :each, *args);T;IC;" ;T;[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; @G;!F;6i ;>0;[[I"method;TI"
:each;T[I"
*args;T0; @G;[ ;@C;0; @G;!F;"o;#;$T;%i;&i;;'@];(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;Ti;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;[o;2
;3I"return;F;4I" ;T;0;5[I"nil;T; @;[ ;I"@return [nil];T;0; @;!F;6i ;>0;[[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;%i;&i;'@];(I"static VALUE
rb_obj_display(int argc, VALUE *argv, VALUE self)
{
VALUE out;
out = (!rb_check_arity(argc, 0, 1) ? rb_stdout : argv[0]);
rb_io_write(out, self);
return Qnil;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Object#assert_Qundef;F;[[I"obj;T0[I"msg;T0;[[I"parse.c;TiSE[I"ext/ripper/ripper.c;TitE;T;:assert_Qundef;0;[ ;{ ;IC;":nodoc:
;T;[ ;[ ;I":nodoc:;T;0; @;!F;"o;#;$T;%isE;&isE;'@];(I"static VALUE
ripper_assert_Qundef(VALUE self, VALUE obj, VALUE msg)
{
StringValue(msg);
if (obj == Qundef) {
rb_raise(rb_eArgError, "%"PRIsVALUE, msg);
}
return Qnil;
};T;)I"static VALUE;T;*To;;F;
;;;;I"Object#rawVALUE;F;[[I"obj;T0;[[@i^E[@iE;T;:
rawVALUE;0;[ ;{ ;IC;":nodoc:
;T;[ ;[ ;I":nodoc:;T;0; @;!F;"o;#;$T;%i~E;&i~E;'@];(I"Tstatic VALUE
ripper_value(VALUE self, VALUE obj)
{
return ULONG2NUM(obj);
};T;)I"static VALUE;T;*To;;F;
;;;;I"Object#validate_object;F;[[I"x;T0;[[@iC[@iD;T;:validate_object;0;[ ;{ ;IC;":nodoc:
;T;[ ;[ ;I":nodoc:;T;0; @;!F;"o;#;$T;%iD;&iD;'@];(I"Ustatic VALUE
ripper_validate_object(VALUE self, VALUE x)
{
if (x == Qfalse) return x;
if (x == Qtrue) return x;
if (x == Qnil) return x;
if (x == Qundef)
rb_raise(rb_eArgError, "Qundef given");
if (FIXNUM_P(x)) return x;
if (SYMBOL_P(x)) return x;
if (!rb_is_pointer_to_heap(x))
rb_raise(rb_eArgError, "invalid pointer: %p", x);
switch (BUILTIN_TYPE(x)) {
case T_STRING:
case T_OBJECT:
case T_ARRAY:
case T_BIGNUM:
case T_FLOAT:
case T_COMPLEX:
case T_RATIONAL:
return x;
case T_NODE:
if (nd_type(x) != NODE_RIPPER) {
rb_raise(rb_eArgError, "NODE given: %p", x);
}
return ((NODE *)x)->nd_rval;
default:
rb_raise(rb_eArgError, "wrong type of ruby object: %p (%s)",
x, rb_obj_classname(x));
}
return x;
};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;[o;2
;3I"return;F;4I" ;T;0;5[I"Boolean;T; @;[ ;I"@return [Boolean];T;0; @;!F;6i ;>0;[ ; @;[ ;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"