{z: rooto:"YARD::CodeObjects::RootObject:@childrenIC:&YARD::CodeObjects::CodeObjectList[o:#YARD::CodeObjects::ClassObject;IC;[7o; ;IC;[: @owner@ :@class_mixinsIC;[; @ :@instance_mixinsIC;[; @ :@attributesIC:SymbolHash{: classIC;{:@symbolize_valueT: instanceIC;{;T;T: @aliases{: @groups[: @files[[I"ext/strscan/strscan.c:ETi.:@current_file_has_commentsF: @name: Error:@source_type: ruby:@visibility: public: @tags[:@docstrings{:@docstringIC:YARD::Docstring" ;T;[:@ref_tags[: @allI";T:@unresolved_reference0: @object@ :@namespace@: @pathI"StringScanner::Error;F:@superclasso:YARD::CodeObjects::Proxy :@orignamespace0:@origname0: @imethod0;:StandardError;%@: @objo; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[I" error.c;Ti| [@)iR ;T;;,;;;;;[;{;IC; "The most standard error types are subclasses of StandardError. A rescue clause without an explicit Exception class will rescue all StandardErrors (and only those). def foo raise "Oups" end foo rescue "Hello" #=> "Hello" On the other hand: require 'does/not/exist' rescue "Hi" raises the exception: LoadError: no such file to load -- does/not/exist ;T;[;![;"I" The most standard error types are subclasses of StandardError. A rescue clause without an explicit Exception class will rescue all StandardErrors (and only those). def foo raise "Oups" end foo rescue "Hello" #=> "Hello" On the other hand: require 'does/not/exist' rescue "Hi" raises the exception: LoadError: no such file to load -- does/not/exist ;T;#0;$@:@hash_flagF:@line_rangeo: Range: exclT: begini| :endi ;%@;&I"StandardError;F;'o; ;IC;[o:$YARD::CodeObjects::MethodObject:@module_functionF: @scope;;;;&I"Exception.exception;F:@parameters[[I" *args;T0;[[I" object.c;Ti;T;:exception;0;[;{;IC; "call-seq: exc.exception([string]) -> an_exception or exc With no argument, or if the argument is the same as the receiver, return the receiver. Otherwise, create a new exception object of the same class as the receiver, but with a message equal to string.to_str. ;T;[;![;"I" call-seq: exc.exception([string]) -> an_exception or exc With no argument, or if the argument is the same as the receiver, return the receiver. Otherwise, create a new exception object of the same class as the receiver, but with a message equal to string.to_str. ;T;#0;$@5;.F;/o;0;1T;2i;3i;%@3: @sourceI"VALUE rb_class_new_instance(int argc, const VALUE *argv, VALUE klass) { VALUE obj; Check_Type(klass, T_CLASS); obj = rb_class_alloc(klass); rb_obj_call_init_kw(obj, argc, argv, RB_NO_KEYWORDS); return obj; };T:@signatureI" VALUE;T:@explicitTo;4;5F;6;;;;&I"Exception.to_tty?;F;7[;[[@)i;T;: to_tty?;0;[;{;IC; "@Returns +true+ if exception messages will be sent to a tty.;T;[o:YARD::Tags::OverloadTag :@tag_nameI" overload;F: @text0;;<: @types0;:I" to_tty?;T;IC; ";T;[o:YARD::Tags::Tag ;>I" return;F;?I";T;0;@[I" Boolean;T;$@F;![;"I"@return [Boolean];T;#0;$@F;.F:@ref_tag_recurse_counti: @summary0;7[;$@F;![;"I"hReturns +true+ if exception messages will be sent to a tty. @overload to_tty? @return [Boolean];T;#0;$@F;.F;/o;0;1T;2i;3i;Bi;%@3;9I"Ustatic VALUE exc_s_to_tty_p(VALUE self) { return RBOOL(rb_stderr_tty_p()); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Exception#exception;F;7[[@90;[[@)i;T;;8;0;[;{;IC; "call-seq: exc.exception([string]) -> an_exception or exc With no argument, or if the argument is the same as the receiver, return the receiver. Otherwise, create a new exception object of the same class as the receiver, but with a message equal to string.to_str. ;T;[;![;"@B;#0;$@a;.F;/o;0;1T;2i;3i;%@3;9I"!static VALUE exc_exception(int argc, VALUE *argv, VALUE self) { VALUE exc; argc = rb_check_arity(argc, 0, 1); if (argc == 0) return self; if (argc == 1 && self == argv[0]) return self; exc = rb_obj_clone(self); rb_ivar_set(exc, id_mesg, argv[0]); return exc; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Exception#initialize;F;7[[@90;[[@)i;T;:initialize;0;[;{;IC; "HConstruct a new Exception object, optionally passing in a message. ;T;[o;= ;>I" overload;F;?0;:new;@0;:I"new(msg = nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Exception;T;$@o;![;"I"@return [Exception];T;#0;$@o;.F;Bi;C0;7[[I"msg;TI"nil;T;$@oo;= ;>I" overload;F;?0;;8;@0;:I"exception(msg = nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Exception;T;$@o;![;"I"@return [Exception];T;#0;$@o;.F;Bi;C0;7[[I"msg;TI"nil;T;$@o;![;"I" Construct a new Exception object, optionally passing in a message. @overload new(msg = nil) @return [Exception] @overload exception(msg = nil) @return [Exception];T;#0;$@o;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE exc_initialize(int argc, VALUE *argv, VALUE exc) { VALUE arg; arg = (!rb_check_arity(argc, 0, 1) ? Qnil : argv[0]); return exc_init(exc, arg); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Exception#==;F;7[[I"obj;T0;[[@)i;T;:==;0;[;{;IC; "Equality---If obj is not an Exception, returns false. Otherwise, returns true if exc and obj share same class, messages, and backtrace. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I" ==(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"obj;T0;$@;![;"I"Equality---If obj is not an Exception, returns false. Otherwise, returns true if exc and obj share same class, messages, and backtrace. @overload ==(obj) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE exc_equal(VALUE exc, VALUE obj) { VALUE mesg, backtrace; if (exc == obj) return Qtrue; if (rb_obj_class(exc) != rb_obj_class(obj)) { int state; obj = rb_protect(try_convert_to_exception, obj, &state); if (state || obj == Qundef) { rb_set_errinfo(Qnil); return Qfalse; } if (rb_obj_class(exc) != rb_obj_class(obj)) return Qfalse; mesg = rb_check_funcall(obj, id_message, 0, 0); if (mesg == Qundef) return Qfalse; backtrace = rb_check_funcall(obj, id_backtrace, 0, 0); if (backtrace == Qundef) return Qfalse; } else { mesg = rb_attr_get(obj, id_mesg); backtrace = exc_backtrace(obj); } if (!rb_equal(rb_attr_get(exc, id_mesg), mesg)) return Qfalse; return rb_equal(exc_backtrace(exc), backtrace); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Exception#to_s;F;7[;[[@)i;T;: to_s;0;[;{;IC; "UReturns exception's message (or the name of the exception if no message is set). ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"yReturns exception's message (or the name of the exception if no message is set). @overload to_s @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE exc_to_s(VALUE exc) { VALUE mesg = rb_attr_get(exc, idMesg); if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc)); return rb_String(mesg); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Exception#message;F;7[;[[@)i(;T;: message;0;[;{;IC; "wReturns the result of invoking exception.to_s. Normally this returns the exception's message or name. ;T;[o;= ;>I" overload;F;?0;;H;@0;:I" message;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the result of invoking exception.to_s. Normally this returns the exception's message or name. @overload message @return [String];T;#0;$@;.F;/o;0;1T;2i ;3i%;%@3;9I"Wstatic VALUE exc_message(VALUE exc) { return rb_funcallv(exc, idTo_s, 0, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Exception#full_message;F;7[[@90;[[@)i;T;:full_message;0;[;{;IC; "Returns formatted string of _exception_. The returned string is formatted using the same format that Ruby uses when printing an uncaught exceptions to stderr. If _highlight_ is +true+ the default error handler will send the messages to a tty. _order_ must be either of +:top+ or +:bottom+, and places the error message and the innermost backtrace come at the top or the bottom. The default values of these options depend on $stderr and its +tty?+ at the timing of a call. ;T;[o;= ;>I" overload;F;?0;;I;@0;:I"I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I"highlight:;TI" bool;T[I" order:;TI" [:top;T;$@;![;"I">Returns formatted string of _exception_. The returned string is formatted using the same format that Ruby uses when printing an uncaught exceptions to stderr. If _highlight_ is +true+ the default error handler will send the messages to a tty. _order_ must be either of +:top+ or +:bottom+, and places the error message and the innermost backtrace come at the top or the bottom. The default values of these options depend on $stderr and its +tty?+ at the timing of a call. @overload full_message(highlight: bool, order: [:top or :bottom]) @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE exc_full_message(int argc, VALUE *argv, VALUE exc) { VALUE opt, str, emesg, errat; enum {kw_highlight, kw_order, kw_max_}; static ID kw[kw_max_]; VALUE args[kw_max_] = {Qnil, Qnil}; rb_scan_args(argc, argv, "0:", &opt); if (!NIL_P(opt)) { if (!kw[0]) { #define INIT_KW(n) kw[kw_##n] = rb_intern_const(#n) INIT_KW(highlight); INIT_KW(order); #undef INIT_KW } rb_get_kwargs(opt, kw, 0, kw_max_, args); switch (args[kw_highlight]) { default: rb_bool_expected(args[kw_highlight], "highlight"); UNREACHABLE; case Qundef: args[kw_highlight] = Qnil; break; case Qtrue: case Qfalse: case Qnil: break; } if (args[kw_order] == Qundef) { args[kw_order] = Qnil; } else { ID id = rb_check_id(&args[kw_order]); if (id == id_bottom) args[kw_order] = Qtrue; else if (id == id_top) args[kw_order] = Qfalse; else { rb_raise(rb_eArgError, "expected :top or :bottom as " "order: %+"PRIsVALUE, args[kw_order]); } } } str = rb_str_new2(""); errat = rb_get_backtrace(exc); emesg = rb_get_message(exc); rb_error_write(exc, emesg, errat, str, args[kw_highlight], args[kw_order]); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Exception#inspect;F;7[;[[@)i5;T;: inspect;0;[;{;IC; "4Return this exception's class name and message. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"[Return this exception's class name and message. @overload inspect @return [String];T;#0;$@;.F;/o;0;1T;2i.;3i2;%@3;9I"static VALUE exc_inspect(VALUE exc) { VALUE str, klass; klass = CLASS_OF(exc); exc = rb_obj_as_string(exc); if (RSTRING_LEN(exc) == 0) { return rb_class_name(klass); } str = rb_str_buf_new2("#<"); klass = rb_class_name(klass); rb_str_buf_append(str, klass); rb_str_buf_cat(str, ": ", 2); rb_str_buf_append(str, exc); rb_str_buf_cat(str, ">", 1); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Exception#backtrace;F;7[;[[@)im;T;:backtrace;0;[;{;IC; "Returns any backtrace associated with the exception. The backtrace is an array of strings, each containing either ``filename:lineNo: in `method''' or ``filename:lineNo.'' def a raise "boom" end def b a() end begin b() rescue => detail print detail.backtrace.join("\n") end produces: prog.rb:2:in `a' prog.rb:6:in `b' prog.rb:10 In the case no backtrace has been set, +nil+ is returned ex = StandardError.new ex.backtrace #=> nil ;T;[o;= ;>I" overload;F;?0;;K;@0;:I"backtrace;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;TI"nil;T;$@+;![;"I"@return [Array, nil];T;#0;$@+;.F;Bi;C0;7[;$@+;![;"I"!Returns any backtrace associated with the exception. The backtrace is an array of strings, each containing either ``filename:lineNo: in `method''' or ``filename:lineNo.'' def a raise "boom" end def b a() end begin b() rescue => detail print detail.backtrace.join("\n") end produces: prog.rb:2:in `a' prog.rb:6:in `b' prog.rb:10 In the case no backtrace has been set, +nil+ is returned ex = StandardError.new ex.backtrace #=> nil @overload backtrace @return [Array, nil];T;#0;$@+;.F;/o;0;1T;2iJ;3ij;%@3;9I"static VALUE exc_backtrace(VALUE exc) { VALUE obj; obj = rb_attr_get(exc, id_bt); if (rb_backtrace_p(obj)) { obj = rb_backtrace_to_str_ary(obj); /* rb_ivar_set(exc, id_bt, obj); */ } return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""Exception#backtrace_locations;F;7[;[[@)i;T;:backtrace_locations;0;[;{;IC; "Returns any backtrace associated with the exception. This method is similar to Exception#backtrace, but the backtrace is an array of Thread::Backtrace::Location. This method is not affected by Exception#set_backtrace(). ;T;[o;= ;>I" overload;F;?0;;L;@0;:I"backtrace_locations;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;TI"nil;T;$@G;![;"I"@return [Array, nil];T;#0;$@G;.F;Bi;C0;7[;$@G;![;"I"Returns any backtrace associated with the exception. This method is similar to Exception#backtrace, but the backtrace is an array of Thread::Backtrace::Location. This method is not affected by Exception#set_backtrace(). @overload backtrace_locations @return [Array, nil];T;#0;$@G;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE exc_backtrace_locations(VALUE exc) { VALUE obj; obj = rb_attr_get(exc, id_bt_locations); if (!NIL_P(obj)) { obj = rb_backtrace_to_location_ary(obj); } return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Exception#set_backtrace;F;7[[I"bt;T0;[[@)i;T;:set_backtrace;0;[;{;IC; "Sets the backtrace information associated with +exc+. The +backtrace+ must be an array of String objects or a single String in the format described in Exception#backtrace. ;T;[o;= ;>I" overload;F;?0;;M;@0;:I"set_backtrace(backtrace);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@c;![;"I"@return [Array];T;#0;$@c;.F;Bi;C0;7[[I"backtrace;T0;$@c;![;"I"Sets the backtrace information associated with +exc+. The +backtrace+ must be an array of String objects or a single String in the format described in Exception#backtrace. @overload set_backtrace(backtrace) @return [Array];T;#0;$@c;.F;/o;0;1T;2i;3i;%@3;9I"xstatic VALUE exc_set_backtrace(VALUE exc, VALUE bt) { return rb_ivar_set(exc, id_bt, rb_check_backtrace(bt)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Exception#cause;F;7[;[[@)i;T;: cause;0;[;{;IC; "Returns the previous exception ($!) at the time this exception was raised. This is useful for wrapping exceptions and retaining the original exception information. ;T;[o;= ;>I" overload;F;?0;;N;@0;:I" cause;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Exception;TI"nil;T;$@;![;"I"@return [Exception, nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the previous exception ($!) at the time this exception was raised. This is useful for wrapping exceptions and retaining the original exception information. @overload cause @return [Exception, nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@3;9I"Qstatic VALUE exc_cause(VALUE exc) { return rb_attr_get(exc, id_cause); };T;:I"static VALUE;T;;T; @3; IC;[; @3; IC;[; @3; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i [@)i8 ;T;:Exception;;;;;[;{;IC; "\Class Exception and its subclasses are used to communicate between Kernel#raise and +rescue+ statements in begin ... end blocks. An Exception object carries information about an exception: - Its type (the exception's class). - An optional descriptive message. - Optional backtrace information. Some built-in subclasses of Exception have additional methods: e.g., NameError#name. == Defaults Two Ruby statements have default exception classes: - +raise+: defaults to RuntimeError. - +rescue+: defaults to StandardError. == Global Variables When an exception has been raised but not yet handled (in +rescue+, +ensure+, +at_exit+ and +END+ blocks), two global variables are set: - $! contains the current exception. - $@ contains its backtrace. == Custom Exceptions To provide additional or alternate information, a program may create custom exception classes that derive from the built-in exception classes. A good practice is for a library to create a single "generic" exception class (typically a subclass of StandardError or RuntimeError) and have its other exception classes derive from that class. This allows the user to rescue the generic exception, thus catching all exceptions the library may raise even if future versions of the library add new exception subclasses. For example: class MyLibrary class Error < ::StandardError end class WidgetError < Error end class FrobError < Error end end To handle both MyLibrary::WidgetError and MyLibrary::FrobError the library user can rescue MyLibrary::Error. == Built-In Exception Classes The built-in subclasses of Exception are: * NoMemoryError * ScriptError * LoadError * NotImplementedError * SyntaxError * SecurityError * SignalException * Interrupt * StandardError * ArgumentError * UncaughtThrowError * EncodingError * FiberError * IOError * EOFError * IndexError * KeyError * StopIteration * ClosedQueueError * LocalJumpError * NameError * NoMethodError * RangeError * FloatDomainError * RegexpError * RuntimeError * FrozenError * SystemCallError * Errno::* * ThreadError * TypeError * ZeroDivisionError * SystemExit * SystemStackError * fatal;T;[;![;"I" \Class Exception and its subclasses are used to communicate between Kernel#raise and +rescue+ statements in begin ... end blocks. An Exception object carries information about an exception: - Its type (the exception's class). - An optional descriptive message. - Optional backtrace information. Some built-in subclasses of Exception have additional methods: e.g., NameError#name. == Defaults Two Ruby statements have default exception classes: - +raise+: defaults to RuntimeError. - +rescue+: defaults to StandardError. == Global Variables When an exception has been raised but not yet handled (in +rescue+, +ensure+, +at_exit+ and +END+ blocks), two global variables are set: - $! contains the current exception. - $@ contains its backtrace. == Custom Exceptions To provide additional or alternate information, a program may create custom exception classes that derive from the built-in exception classes. A good practice is for a library to create a single "generic" exception class (typically a subclass of StandardError or RuntimeError) and have its other exception classes derive from that class. This allows the user to rescue the generic exception, thus catching all exceptions the library may raise even if future versions of the library add new exception subclasses. For example: class MyLibrary class Error < ::StandardError end class WidgetError < Error end class FrobError < Error end end To handle both MyLibrary::WidgetError and MyLibrary::FrobError the library user can rescue MyLibrary::Error. == Built-In Exception Classes The built-in subclasses of Exception are: * NoMemoryError * ScriptError * LoadError * NotImplementedError * SyntaxError * SecurityError * SignalException * Interrupt * StandardError * ArgumentError * UncaughtThrowError * EncodingError * FiberError * IOError * EOFError * IndexError * KeyError * StopIteration * ClosedQueueError * LocalJumpError * NameError * NoMethodError * RangeError * FloatDomainError * RegexpError * RuntimeError * FrozenError * SystemCallError * Errno::* * ThreadError * TypeError * ZeroDivisionError * SystemExit * SystemStackError * fatal ;T;#0;$@3;.F;/o;0;1T;2i ;3i ;Bi;%@;&I"Exception;F;'o; ;IC;[7o;4;5F;6;;;;&I"Object#respond_to?;F;7[[@90;[[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;= ;>I" overload;F;?0;;P;@0;:I"+respond_to?(symbol, include_all=false);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" symbol;T0[I"include_all;TI" false;T;$@o;= ;>I" overload;F;?0;;P;@0;:I"+respond_to?(string, include_all=false);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[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;0;1T;2i ;3i ;Bi;%@;9I"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; } return RBOOL(basic_obj_respond_to(ec, obj, id, !RTEST(priv))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Object#respond_to_missing?;F;7[[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;= ;>I" overload;F;?0;;Q;@0;:I"-respond_to_missing?(symbol, include_all);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" symbol;T0[I"include_all;T0;$@o;= ;>I" overload;F;?0;;Q;@0;:I"-respond_to_missing?(string, include_all);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[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;0;1T;2i ;3i ;Bi;%@;9I"astatic VALUE obj_respond_to_missing(VALUE obj, VALUE mid, VALUE priv) { return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Object#nil?;F;7[;[[@nil responds true to nil?. Object.new.nil? #=> false nil.nil? #=> true;T;[o;= ;>I" overload;F;?0;;R;@0;:I" nil?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Only the object nil responds true to nil?. Object.new.nil? #=> false nil.nil? #=> true @overload nil? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"HMJIT_FUNC_EXPORTED VALUE rb_false(VALUE obj) { return Qfalse; };T;:I"MJIT_FUNC_EXPORTED VALUE;T;;To;4;5F;6;;;;&I"Object#===;F;7[;[;F;:===;;;[;{;IC; " ;T;[;![;"@;#0;$@5;%@;;To;4;5F;6;;;;&I"Object#=~;F;7[[I" obj2;T0;[[@I" overload;F;?0;;T;@0;:I"=~(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@>;![;"I"@return [nil];T;#0;$@>;.F;Bi;C0;7[[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;0;1T;2i;3i;%@;9I"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;4;5F;6;;;;&I"Object#!~;F;7[[I" obj2;T0;[[@=~ method), otherwise false. ;T;[o;= ;>I" overload;F;?0;;U;@0;:I"!~(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@];![;"I"@return [Boolean];T;#0;$@];.F;Bi;C0;7[[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;0;1T;2i;3i;%@;9I"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;4;5F;6;;;;&I"Object#eql?;F;7[[I" obj2;T0;[[@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;= ;>I" overload;F;?0;;F;@0;:I"==(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@|;![;"I"@return [Boolean];T;#0;$@|;.F;Bi;C0;7[[I" other;T0;$@|o;= ;>I" overload;F;?0;: equal?;@0;:I"equal?(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@|;![;"I"@return [Boolean];T;#0;$@|;.F;Bi;C0;7[[I" other;T0;$@|o;= ;>I" overload;F;?0;;V;@0;:I"eql?(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@|;![;"I"@return [Boolean];T;#0;$@|;.F;Bi;C0;7[[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;0;1T;2i;3i;Bi;%@;9I"fMJIT_FUNC_EXPORTED VALUE rb_obj_equal(VALUE obj1, VALUE obj2) { return RBOOL(obj1 == obj2); };T;:I"MJIT_FUNC_EXPORTED VALUE;T;;To;4;5F;6;;;;&I"Object#hash;F;7[;[[I" hash.c;Ti6;T;: hash;0;[;{;IC; "Generates an Integer hash value for this object. This function must have the property that a.eql?(b) implies a.hash == b.hash. The hash value is used along with #eql? by the Hash class to determine if two objects reference the same hash key. Any hash value that exceeds the capacity of an Integer will be truncated before being used. The hash value for an object may not be identical across invocations or implementations of Ruby. If you need a stable identifier across Ruby invocations and implementations you will need to generate one with a custom method. Certain core classes such as Integer use built-in hash calculations and do not call the #hash method when used as a hash key. ;T;[o;= ;>I" overload;F;?0;;X;@0;:I" hash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Generates an Integer hash value for this object. This function must have the property that a.eql?(b) implies a.hash == b.hash. The hash value is used along with #eql? by the Hash class to determine if two objects reference the same hash key. Any hash value that exceeds the capacity of an Integer will be truncated before being used. The hash value for an object may not be identical across invocations or implementations of Ruby. If you need a stable identifier across Ruby invocations and implementations you will need to generate one with a custom method. Certain core classes such as Integer use built-in hash calculations and do not call the #hash method when used as a hash key. @overload hash @return [Integer];T;#0;$@;.F;/o;0;1T;2i ;3i2;%@;9I"iVALUE rb_obj_hash(VALUE obj) { long hnum = any_hash(obj, objid_hash); return ST2FIX(hnum); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Object#<=>;F;7[[I" obj2;T0;[[@;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;= ;>I" overload;F;?0;;Y;@0;:I"<=>(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI"nil;T;$@;![;"I"@return [0, nil];T;#0;$@;.F;Bi;C0;7[[I" other;T0;$@;![;"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;$@;.F;/o;0;1T;2i;3i;%@;9I"{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;4;5F;6;;;;&I"Object#singleton_class;F;7[;[[@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;= ;>I" overload;F;?0;;Z;@0;:I"singleton_class;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Class;T;$@;![;"I"@return [Class];T;#0;$@;.F;Bi;C0;7[;$@;![;"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;0;1T;2i;3i;%@;9I"[static VALUE rb_obj_singleton_class(VALUE obj) { return rb_singleton_class(obj); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Object#dup;F;7[;[[@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;= ;>I" overload;F;?0;;[;@0;:I"dup;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[;$@;![;"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;0;1T;2i;3i;%@;9I"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;4;5F;6;;;;&I"Object#itself;F;7[;[[@ true ;T;[o;= ;>I" overload;F;?0;;\;@0;:I" itself;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@+;![;"I"@return [Object];T;#0;$@+;.F;Bi;C0;7[;$@+;![;"I"Returns the receiver. string = "my string" string.itself.object_id == string.object_id #=> true @overload itself @return [Object];T;#0;$@+;.F;/o;0;1T;2i;3i ;%@;9I">static VALUE rb_obj_itself(VALUE obj) { return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Object#initialize_copy;F;7[[I" orig;T0;[[@I" overload;F;?0;;`;@0;:I" taint;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@u;![;"I"@return [Object];T;#0;$@u;.F;Bi;C0;7[;$@u;![;"I"tReturns object. This method is deprecated and will be removed in Ruby 3.2. @overload taint @return [Object];T;#0;$@u;.F;/o;0;1T;2i];3ia;%@;9I"vVALUE rb_obj_taint(VALUE obj) { rb_warn_deprecated_to_remove_at(3.2, "Object#taint", NULL); return obj; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Object#tainted?;F;7[;[[@I" overload;F;?0;;a;@0;:I" tainted?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" false;T;$@;![;"I"@return [false];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"vReturns false. This method is deprecated and will be removed in Ruby 3.2. @overload tainted? @return [false];T;#0;$@;.F;/o;0;1T;2iO;3iS;Bi;%@;9I"~VALUE rb_obj_tainted(VALUE obj) { rb_warn_deprecated_to_remove_at(3.2, "Object#tainted?", NULL); return Qfalse; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Object#untaint;F;7[;[[@I" overload;F;?0;;b;@0;:I" untaint;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"vReturns object. This method is deprecated and will be removed in Ruby 3.2. @overload untaint @return [Object];T;#0;$@;.F;/o;0;1T;2il;3ip;%@;9I"zVALUE rb_obj_untaint(VALUE obj) { rb_warn_deprecated_to_remove_at(3.2, "Object#untaint", NULL); return obj; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Object#untrust;F;7[;[[@I" overload;F;?0;;c;@0;:I" untrust;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"vReturns object. This method is deprecated and will be removed in Ruby 3.2. @overload untrust @return [Object];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"zVALUE rb_obj_untrust(VALUE obj) { rb_warn_deprecated_to_remove_at(3.2, "Object#untrust", NULL); return obj; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Object#untrusted?;F;7[;[[@I" overload;F;?0;;d;@0;:I"untrusted?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" false;T;$@;![;"I"@return [false];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"xReturns false. This method is deprecated and will be removed in Ruby 3.2. @overload untrusted? @return [false];T;#0;$@;.F;/o;0;1T;2iz;3i~;Bi;%@;9I"}VALUE rb_obj_untrusted(VALUE obj) { rb_warn_deprecated_to_remove_at(3.2, "Object#untrusted?", NULL); return Qfalse; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Object#trust;F;7[;[[@I" overload;F;?0;;e;@0;:I" trust;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"tReturns object. This method is deprecated and will be removed in Ruby 3.2. @overload trust @return [Object];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"vVALUE rb_obj_trust(VALUE obj) { rb_warn_deprecated_to_remove_at(3.2, "Object#trust", NULL); return obj; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Object#freeze;F;7[;[[@obj. A FrozenError 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;= ;>I" overload;F;?0;;f;@0;:I" freeze;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Prevents further modifications to obj. A FrozenError 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;0;1T;2i;3i;%@;9I"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;4;5F;6;;;;&I"Object#to_s;F;7[;[[@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;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@2;![;"I"@return [String];T;#0;$@2;.F;Bi;C0;7[;$@2;![;"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;$@2;.F;/o;0;1T;2iY;3ia;%@;9I"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;4;5F;6;;;;&I"Object#inspect;F;7[;[[@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;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@M;![;"I"@return [String];T;#0;$@M;.F;Bi;C0;7[;$@M;![;"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;$@M;.F;/o;0;1T;2i;3i;%@;9I"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;4;5F;6;;;;&I"Object#methods;F;7[[@90;[[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;= ;>I" overload;F;?0;;g;@0;:I"methods(regular=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@h;![;"I"@return [Array];T;#0;$@h;.F;Bi;C0;7[[I" regular;TI" true;T;$@h;![;"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;$@h;.F;/o;0;1T;2i;3i;%@;9I"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;4;5F;6;;;;&I"Object#singleton_methods;F;7[[@90;[[@ni8;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;= ;>I" overload;F;?0;;h;@0;:I" singleton_methods(all=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[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;0;1T;2i;3i5;%@;9I"(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;4;5F;6;;;;&I"Object#protected_methods;F;7[[@90;[[@ni;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;= ;>I" overload;F;?0;;i;@0;:I" protected_methods(all=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"all;TI" true;T;$@;![;"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;$@;.F;/o;0;1T;2i;3i;%@;9I"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;4;5F;6;;;;&I"Object#private_methods;F;7[[@90;[[@ni;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;= ;>I" overload;F;?0;;j;@0;:I"private_methods(all=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"all;TI" true;T;$@;![;"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;$@;.F;/o;0;1T;2i;3i;%@;9I"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;4;5F;6;;;;&I"Object#public_methods;F;7[[@90;[[@ni;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;= ;>I" overload;F;?0;;k;@0;:I"public_methods(all=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[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;0;1T;2i;3i;%@;9I"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;4;5F;6;;;;&I"Object#instance_variables;F;7[;[[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;= ;>I" overload;F;?0;;l;@0;:I"instance_variables;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"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;0;1T;2iL;3iZ;%@;9I"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;4;5F;6;;;;&I"!Object#instance_variable_get;F;7[[I"iv;T0;[[@@ 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;= ;>I" overload;F;?0;;m;@0;:I""instance_variable_get(symbol);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@ ;![;"I"@return [Object];T;#0;$@ ;.F;Bi;C0;7[[I" symbol;T0;$@ o;= ;>I" overload;F;?0;;m;@0;:I""instance_variable_get(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@ ;![;"I"@return [Object];T;#0;$@ ;.F;Bi;C0;7[[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;0;1T;2i ;3i ;%@;9I"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;4;5F;6;;;;&I"!Object#instance_variable_set;F;7[[I"iv;T0[I"val;T0;[[@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;= ;>I" overload;F;?0;;n;@0;:I"'instance_variable_set(symbol, obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@N;![;"I"@return [Object];T;#0;$@N;.F;Bi;C0;7[[I" symbol;T0[I"obj;T0;$@No;= ;>I" overload;F;?0;;n;@0;:I"'instance_variable_set(string, obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@N;![;"I"@return [Object];T;#0;$@N;.F;Bi;C0;7[[I" string;T0[I"obj;T0;$@N;![;"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;$@N;.F;/o;0;1T;2i ;3i ;%@;9I"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;4;5F;6;;;;&I"&Object#instance_variable_defined?;F;7[[I"iv;T0;[[@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;= ;>I" overload;F;?0;;o;@0;:I"'instance_variable_defined?(symbol);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" symbol;T0;$@o;= ;>I" overload;F;?0;;o;@0;:I"'instance_variable_defined?(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[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;0;1T;2i ;3i ;Bi;%@;9I"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;4;5F;6;;;;&I"$Object#remove_instance_variable;F;7[[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;= ;>I" overload;F;?0;;p;@0;:I"%remove_instance_variable(symbol);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I" symbol;T0;$@o;= ;>I" overload;F;?0;;p;@0;:I"%remove_instance_variable(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I" string;T0;$@;![;"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;$@;.F;/o;0;1T;2i|;3i;%@;9I"OVALUE 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) && lock_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;4;5F;6;;;;&I"Object#instance_of?;F;7[[I"c;T0;[[@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;= ;>I" overload;F;?0;;q;@0;:I"instance_of?(class);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"BReturns 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;0;1T;2i;3i;Bi;%@;9I"VALUE rb_obj_is_instance_of(VALUE obj, VALUE c) { c = class_or_module_required(c); return RBOOL(rb_obj_class(obj) == c); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Object#kind_of?;F;7[[I"c;T0;[[@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;= ;>I" overload;F;?0;: is_a?;@0;:I"is_a?(class);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;r;@0;:I"kind_of?(class);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"fReturns 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;0;1T;2i;3i;Bi;%@;9I""VALUE rb_obj_is_kind_of(VALUE obj, VALUE c) { VALUE cl = CLASS_OF(obj); // Note: YJIT needs this function to never allocate and never raise when // `c` is a class or a module. c = class_or_module_required(c); return RBOOL(class_search_ancestor(cl, RCLASS_ORIGIN(c))); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Object#is_a?;F;7[[I"c;T0;[[@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;= ;>I" overload;F;?0;;s;@0;:I"is_a?(class);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@%;![;"I"@return [Boolean];T;#0;$@%;.F;Bi;C0;7[;$@%o;= ;>I" overload;F;?0;;r;@0;:I"kind_of?(class);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@%;![;"I"@return [Boolean];T;#0;$@%;.F;Bi;C0;7[;$@%;![;"@!;#0;$@%;.F;/o;0;1T;2i;3i;Bi;%@;9I""VALUE rb_obj_is_kind_of(VALUE obj, VALUE c) { VALUE cl = CLASS_OF(obj); // Note: YJIT needs this function to never allocate and never raise when // `c` is a class or a module. c = class_or_module_required(c); return RBOOL(class_search_ancestor(cl, RCLASS_ORIGIN(c))); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Object#display;F;7[[@90;[[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;= ;>I" overload;F;?0;;t;@0;:I"display(port=$>);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@N;![;"I"@return [nil];T;#0;$@N;.F;Bi;C0;7[[I" port;TI"$>;T;$@N;![;"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;$@N;.F;/o;0;1T;2i ;3i ;%@;9I"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:&YARD::CodeObjects::ConstantObject;[[I" bignum.c;Ti;F;: Bignum;:c;;;[;{;IC; "#An obsolete class, use Integer ;T;[;![;"I"#An obsolete class, use Integer;T;#0;$@n;.F;/o;0;1T;2i;3i;%@;&I"Object::Bignum;F: @valueI"rb_cInteger;To;4;5F;6;;;;&I"Object#to_enum;F;7[[@90;[[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;= ;>I" overload;F;?0;;y;@0;:I"#to_enum(method = :each, *args);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@{;![;"I"@return [Enumerator];T;#0;$@{;.F;Bi;C0;7[[I" method;TI" :each;T[I" *args;T0;$@{o;= ;>I" overload;F;?0;: enum_for;@0;:I"$enum_for(method = :each, *args);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@{;![;"I"@return [Enumerator];T;#0;$@{;.F;Bi;C0;7[[I" method;TI" :each;T[I" *args;T0;$@{o;= ;>I" overload;F;?0;;y;@0;:I"#to_enum(method = :each, *args);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" *args;T;$@{o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@{;![;"I"(@yield [*args] @return [Enumerator];T;#0;$@{;.F;Bi;C0;7[[I" method;TI" :each;T[I" *args;T0;$@{o;= ;>I" overload;F;?0;;z;@0;:I"$enum_for(method = :each, *args);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" *args;T;$@{o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@{;![;"I"(@yield [*args] @return [Enumerator];T;#0;$@{;.F;Bi;C0;7[[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;0;1T;2i3;3is;%@;9I"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;4;5F;6;;;;&I"Object#enum_for;F;7[[@90;[[@ip;T;;z;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;= ;>I" overload;F;?0;;y;@0;:I"#to_enum(method = :each, *args);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@;![;"I"@return [Enumerator];T;#0;$@;.F;Bi;C0;7[[I" method;TI" :each;T[I" *args;T0;$@o;= ;>I" overload;F;?0;;z;@0;:I"$enum_for(method = :each, *args);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@;![;"I"@return [Enumerator];T;#0;$@;.F;Bi;C0;7[[I" method;TI" :each;T[I" *args;T0;$@o;= ;>I" overload;F;?0;;y;@0;:I"#to_enum(method = :each, *args);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" *args;T;$@o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@;![;"I"(@yield [*args] @return [Enumerator];T;#0;$@;.F;Bi;C0;7[[I" method;TI" :each;T[I" *args;T0;$@o;= ;>I" overload;F;?0;;z;@0;:I"$enum_for(method = :each, *args);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" *args;T;$@o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@;![;"I"(@yield [*args] @return [Enumerator];T;#0;$@;.F;Bi;C0;7[[I" method;TI" :each;T[I" *args;T0;$@;![;"@;#0;$@;.F;/o;0;1T;2i3;3is;%@;9I"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;4;5F;6;;;;&I"Object#send;F;7[[@90;[[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;= ;>I" overload;F;?0;;{;@0;:I"send(symbol [, args...]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@=;![;"I"@return [Object];T;#0;$@=;.F;Bi;C0;7[[I"symbol[, args...];T0;$@=o;= ;>I" overload;F;?0;: __send__;@0;:I"!__send__(symbol [, args...]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@=;![;"I"@return [Object];T;#0;$@=;.F;Bi;C0;7[[I"symbol[, args...];T0;$@=o;= ;>I" overload;F;?0;;{;@0;:I"send(string [, args...]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@=;![;"I"@return [Object];T;#0;$@=;.F;Bi;C0;7[[I"string[, args...];T0;$@=o;= ;>I" overload;F;?0;;|;@0;:I"!__send__(string [, args...]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@=;![;"I"@return [Object];T;#0;$@=;.F;Bi;C0;7[[I"string[, args...];T0;$@=;![;"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;$@=;.F;/o;0;1T;2i;3i;%@;9I"vVALUE rb_f_send(int argc, VALUE *argv, VALUE recv) { return send_internal_kw(argc, argv, recv, CALL_FCALL); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Object#public_send;F;7[[@90;[[@Ci2;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;= ;>I" overload;F;?0;;};@0;:I"$public_send(symbol [, args...]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I"symbol[, args...];T0;$@o;= ;>I" overload;F;?0;;};@0;:I"$public_send(string [, args...]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[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;0;1T;2i$;3i0;%@;9I"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;u;[[I"numeric.c;Ti;F;: Fixnum;;w;;;[;{;IC; "#An obsolete class, use Integer ;T;[;![;"I"#An obsolete class, use Integer;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Object::Fixnum;F;xI"rb_cInteger;To;4;5F;6;;;;&I"Object#method;F;7[[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;= ;>I" overload;F;?0;;;@0;:I"method(sym);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[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;0;1T;2i;3i;%@;9I"ZVALUE rb_obj_method(VALUE obj, VALUE vid) { return obj_method(obj, vid, FALSE); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Object#public_method;F;7[[I"vid;T0;[[@i;T;:public_method;0;[;{;IC; "6Similar to _method_, searches public method only. ;T;[o;= ;>I" overload;F;?0;;{;@0;:I"public_method(sym);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"sym;T0;$@;![;"I"USimilar to _method_, searches public method only. @overload public_method(sym);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"`VALUE rb_obj_public_method(VALUE obj, VALUE vid) { return obj_method(obj, vid, TRUE); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Object#singleton_method;F;7[[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;= ;>I" overload;F;?0;;|;@0;:I"singleton_method(sym);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[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;0;1T;2i;3i;%@;9I"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;4;5F;6;;;;&I"#Object#define_singleton_method;F;7[[@90;[[@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;= ;>I" overload;F;?0;;};@0;:I",define_singleton_method(symbol, method);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" symbol;T0[I" method;T0;$@o;= ;>I" overload;F;?0;;};@0;:I"$define_singleton_method(symbol);T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@;![;"I"@yield [];T;#0;$@;.F;Bi;C0;7[[I" symbol;T0;$@;![;"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;$@;.F;/o;0;1T;2i;3i;%@;9I"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;4;5F;6;;;;&I"Object#object_id;F;7[;[[I" gc.c;TiU;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;0;1T;2i:;3iP;%@;9I"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;4;5F;6;;;;&I"Object#extend;F;7[[@90;[[I" eval.c;Tik;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;= ;>I" overload;F;?0;;;@0;:I"extend(module, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@I;![;"I"@return [Object];T;#0;$@I;.F;Bi;C0;7[;$@I;![;"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;$@I;.F;/o;0;1T;2iR;3ih;%@;9I"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;;T; @; IC;[; @; IC;[o:$YARD::CodeObjects::ModuleObject;IC;[Do;4;5F;6;;;;&I"Kernel#raise;F;7[[I"*v;T0[I"_;T0;[[@Oi;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;= ;>I" overload;F;?0;;;@0;:I" raise;T;IC; ";T;[;![;"I";T;#0;$@j;.F;Bi;C0;7[;$@jo;= ;>I" overload;F;?0;;;@0;:I"raise(string, cause: $!);T;IC; ";T;[;![;"I";T;#0;$@j;.F;Bi;C0;7[[I" string;T0[I" cause:;TI"$!;T;$@jo;= ;>I" overload;F;?0;;;@0;:I"5raise(exception [, string [, array]], cause: $!);T;IC; ";T;[;![;"I";T;#0;$@j;.F;Bi;C0;7[[I""exception[, string [, array]];T0[I" cause:;TI"$!;T;$@jo;= ;>I" overload;F;?0;: fail;@0;:I" fail;T;IC; ";T;[;![;"I";T;#0;$@j;.F;Bi;C0;7[;$@jo;= ;>I" overload;F;?0;;;@0;:I"fail(string, cause: $!);T;IC; ";T;[;![;"I";T;#0;$@j;.F;Bi;C0;7[[I" string;T0[I" cause:;TI"$!;T;$@jo;= ;>I" overload;F;?0;;;@0;:I"4fail(exception [, string [, array]], cause: $!);T;IC; ";T;[;![;"I";T;#0;$@j;.F;Bi;C0;7[[I""exception[, string [, array]];T0[I" cause:;TI"$!;T;$@j;![;"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;$@j;.F;/o;0;1T;2i;3i;%@h;9I"Tstatic VALUE f_raise(int c, VALUE *v, VALUE _) { return rb_f_raise(c, v); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#fail;F;7[[I"*v;T0[I"_;T0;[[@Oi;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;= ;>I" overload;F;?0;;;@0;:I" raise;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"raise(string, cause: $!);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;T0[I" cause:;TI"$!;T;$@o;= ;>I" overload;F;?0;;;@0;:I"5raise(exception [, string [, array]], cause: $!);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I""exception[, string [, array]];T0[I" cause:;TI"$!;T;$@o;= ;>I" overload;F;?0;;;@0;:I" fail;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"fail(string, cause: $!);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;T0[I" cause:;TI"$!;T;$@o;= ;>I" overload;F;?0;;;@0;:I"4fail(exception [, string [, array]], cause: $!);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I""exception[, string [, array]];T0[I" cause:;TI"$!;T;$@;![;"@;#0;$@;.F;/o;0;1T;2i;3i;%@h;9I"Tstatic VALUE f_raise(int c, VALUE *v, VALUE _) { return rb_f_raise(c, v); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#global_variables;F;7[;[[@OiL;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;= ;>I" overload;F;?0;;;@0;:I"global_variables;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@ ;![;"I"@return [Array];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"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;0;1T;2i@;3iI;%@h;9I"Ustatic VALUE f_global_variables(VALUE _) { return rb_f_global_variables(); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#__method__;F;7[;[[@Oi;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;= ;>I" overload;F;?0;;;@0;:I"__method__;T;IC; ";T;[;![;"I";T;#0;$@0 ;.F;Bi;C0;7[;$@0 ;![;"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;$@0 ;.F;/o;0;1T;2i;3i;%@h;9I"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;4;5F;6;;;;&I"Kernel#__callee__;F;7[;[[@Oi;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;= ;>I" overload;F;?0;;;@0;:I"__callee__;T;IC; ";T;[;![;"I";T;#0;$@F ;.F;Bi;C0;7[;$@F ;![;"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 ;.F;/o;0;1T;2i;3i;%@h;9I"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;4;5F;6;;;;&I"Kernel#__dir__;F;7[;[[@Oi5;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;= ;>I" overload;F;?0;;;@0;:I" __dir__;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@\ ;![;"I"@return [String];T;#0;$@\ ;.F;Bi;C0;7[;$@\ ;![;"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;0;1T;2i+;3i3;%@h;9I"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;4;5F;6;;;;&I"Kernel#exec;F;7[[I"*a;T0[I"_;T0;[[I"process.c;Ti~ ;T;: exec;0;[;{;IC; " Replaces the current process by running the given external _command_, which can take one of the following forms: [exec(commandline)] command line string which is passed to the standard shell [exec(cmdname, arg1, ...)] command name and one or more arguments (no shell) [exec([cmdname, argv0], arg1, ...)] command name, argv[0] and zero or more arguments (no shell) In the first form, the string is taken as a command line that is subject to shell expansion before being executed. The standard shell always means "/bin/sh" on Unix-like systems, otherwise, ENV["RUBYSHELL"] or ENV["COMSPEC"] on Windows and similar. The command is passed as an argument to the "-c" switch to the shell, except in the case of +COMSPEC+. If the string from the first form (exec("command")) follows these simple rules: * no meta characters * not starting with shell reserved word or special built-in * Ruby invokes the command directly without shell You can force shell invocation by adding ";" to the string (because ";" is a meta character). Note that this behavior is observable by pid obtained (return value of spawn() and IO#pid for IO.popen) is the pid of the invoked command, not shell. In the second form (exec("command1", "arg1", ...)), the first is taken as a command name and the rest are passed as parameters to command with no shell expansion. In the third form (exec(["command", "argv0"], "arg1", ...)), starting a two-element array at the beginning of the command, the first element is the command to be executed, and the second argument is used as the argv[0] value, which may show up in process listings. In order to execute the command, one of the exec(2) system calls are used, so the running command may inherit some of the environment of the original program (including open file descriptors). This behavior is modified by the given +env+ and +options+ parameters. See ::spawn for details. If the command fails to execute (typically Errno::ENOENT when it was not found) a SystemCallError exception is raised. This method modifies process attributes according to given +options+ before exec(2) system call. See ::spawn for more details about the given +options+. The modified attributes may be retained when exec(2) system call fails. For example, hard resource limits are not restorable. Consider to create a child process using ::spawn or Kernel#system if this is not acceptable. exec "echo *" # echoes list of files in current directory # never get here exec "echo", "*" # echoes an asterisk # never get here ;T;[o;= ;>I" overload;F;?0;;;@0;:I"'exec([env,] command... [,options]);T;IC; ";T;[;![;"I";T;#0;$@w ;.F;Bi;C0;7[[I"[env,][,options];T0;$@w ;![;"I" Replaces the current process by running the given external _command_, which can take one of the following forms: [exec(commandline)] command line string which is passed to the standard shell [exec(cmdname, arg1, ...)] command name and one or more arguments (no shell) [exec([cmdname, argv0], arg1, ...)] command name, argv[0] and zero or more arguments (no shell) In the first form, the string is taken as a command line that is subject to shell expansion before being executed. The standard shell always means "/bin/sh" on Unix-like systems, otherwise, ENV["RUBYSHELL"] or ENV["COMSPEC"] on Windows and similar. The command is passed as an argument to the "-c" switch to the shell, except in the case of +COMSPEC+. If the string from the first form (exec("command")) follows these simple rules: * no meta characters * not starting with shell reserved word or special built-in * Ruby invokes the command directly without shell You can force shell invocation by adding ";" to the string (because ";" is a meta character). Note that this behavior is observable by pid obtained (return value of spawn() and IO#pid for IO.popen) is the pid of the invoked command, not shell. In the second form (exec("command1", "arg1", ...)), the first is taken as a command name and the rest are passed as parameters to command with no shell expansion. In the third form (exec(["command", "argv0"], "arg1", ...)), starting a two-element array at the beginning of the command, the first element is the command to be executed, and the second argument is used as the argv[0] value, which may show up in process listings. In order to execute the command, one of the exec(2) system calls are used, so the running command may inherit some of the environment of the original program (including open file descriptors). This behavior is modified by the given +env+ and +options+ parameters. See ::spawn for details. If the command fails to execute (typically Errno::ENOENT when it was not found) a SystemCallError exception is raised. This method modifies process attributes according to given +options+ before exec(2) system call. See ::spawn for more details about the given +options+. The modified attributes may be retained when exec(2) system call fails. For example, hard resource limits are not restorable. Consider to create a child process using ::spawn or Kernel#system if this is not acceptable. exec "echo *" # echoes list of files in current directory # never get here exec "echo", "*" # echoes an asterisk # never get here @overload exec([env,] command... [,options]);T;#0;$@w ;.F;/o;0;1T;2i4 ;3iz ;%@h;9I"ostatic VALUE f_exec(int c, const VALUE *a, VALUE _) { rb_f_exec(c, a); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#fork;F;7[;[[@ i,;T;: fork;0;[;{;IC; "Creates a subprocess. If a block is specified, that block is run in the subprocess, and the subprocess terminates with a status of zero. Otherwise, the +fork+ call returns twice, once in the parent, returning the process ID of the child, and once in the child, returning _nil_. The child process can exit using Kernel.exit! to avoid running any at_exit functions. The parent process should use Process.wait to collect the termination statuses of its children or use Process.detach to register disinterest in their status; otherwise, the operating system may accumulate zombie processes. The thread calling fork is the only thread in the created child process. fork doesn't copy other threads. If fork is not usable, Process.respond_to?(:fork) returns false. Note that fork(2) is not available on some platforms like Windows and NetBSD 4. Therefore you should use spawn() instead of fork(). ;T;[o;= ;>I" overload;F;?0;;;@0;:I" fork;T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@ o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@ ;![;"I"%@yield [] @return [Integer, nil];T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;;;@0;:I" fork;T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@ o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@ ;![;"I"%@yield [] @return [Integer, nil];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Creates a subprocess. If a block is specified, that block is run in the subprocess, and the subprocess terminates with a status of zero. Otherwise, the +fork+ call returns twice, once in the parent, returning the process ID of the child, and once in the child, returning _nil_. The child process can exit using Kernel.exit! to avoid running any at_exit functions. The parent process should use Process.wait to collect the termination statuses of its children or use Process.detach to register disinterest in their status; otherwise, the operating system may accumulate zombie processes. The thread calling fork is the only thread in the created child process. fork doesn't copy other threads. If fork is not usable, Process.respond_to?(:fork) returns false. Note that fork(2) is not available on some platforms like Windows and NetBSD 4. Therefore you should use spawn() instead of fork(). @overload fork @yield [] @return [Integer, nil] @overload fork @yield [] @return [Integer, nil];T;#0;$@ ;.F;/o;0;1T;2i;3i,;%@h;9I"static VALUE rb_f_fork(VALUE obj) { rb_pid_t pid; pid = rb_call_proc__fork(); if (pid == 0) { if (rb_block_given_p()) { int status; rb_protect(rb_yield, Qundef, &status); ruby_stop(status); } return Qnil; } return PIDT2NUM(pid); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#exit!;F;7[[@90;[[@ if;T;: exit!;0;[;{;IC; "Exits the process immediately. No exit handlers are run. status is returned to the underlying system as the exit status. Process.exit!(true) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"exit!(status=false);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I" status;TI" false;T;$@ ;![;"I"Exits the process immediately. No exit handlers are run. status is returned to the underlying system as the exit status. Process.exit!(true) @overload exit!(status=false);T;#0;$@ ;.F;/o;0;1T;2i[;3ib;%@h;9I"static VALUE rb_f_exit_bang(int argc, VALUE *argv, VALUE obj) { int istatus; if (rb_check_arity(argc, 0, 1) == 1) { istatus = exit_status_code(argv[0]); } else { istatus = EXIT_FAILURE; } _exit(istatus); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#system;F;7[[@90;[[@ i;T;: system;0;[;{;IC; "Executes _command..._ in a subshell. _command..._ is one of following forms. [commandline] command line string which is passed to the standard shell [cmdname, arg1, ...] command name and one or more arguments (no shell) [[cmdname, argv0], arg1, ...] command name, argv[0] and zero or more arguments (no shell) system returns +true+ if the command gives zero exit status, +false+ for non zero exit status. Returns +nil+ if command execution fails. An error status is available in $?. If the exception: true argument is passed, the method raises an exception instead of returning +false+ or +nil+. The arguments are processed in the same way as for Kernel#spawn. The hash arguments, env and options, are same as #exec and #spawn. See Kernel#spawn for details. system("echo *") system("echo", "*") produces: config.h main.rb * Error handling: system("cat nonexistent.txt") # => false system("catt nonexistent.txt") # => nil system("cat nonexistent.txt", exception: true) # RuntimeError (Command failed with exit 1: cat) system("catt nonexistent.txt", exception: true) # Errno::ENOENT (No such file or directory - catt) See Kernel#exec for the standard shell. ;T;[o;= ;>I" overload;F;?0;;;@0;:I";system([env,] command... [,options], exception: false);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;TI" false;TI"nil;T;$@ ;![;"I"@return [true, false, nil];T;#0;$@ ;.F;Bi;C0;7[[I"[env,][,options];T0[I"exception:;TI" false;T;$@ ;![;"I"pExecutes _command..._ in a subshell. _command..._ is one of following forms. [commandline] command line string which is passed to the standard shell [cmdname, arg1, ...] command name and one or more arguments (no shell) [[cmdname, argv0], arg1, ...] command name, argv[0] and zero or more arguments (no shell) system returns +true+ if the command gives zero exit status, +false+ for non zero exit status. Returns +nil+ if command execution fails. An error status is available in $?. If the exception: true argument is passed, the method raises an exception instead of returning +false+ or +nil+. The arguments are processed in the same way as for Kernel#spawn. The hash arguments, env and options, are same as #exec and #spawn. See Kernel#spawn for details. system("echo *") system("echo", "*") produces: config.h main.rb * Error handling: system("cat nonexistent.txt") # => false system("catt nonexistent.txt") # => nil system("cat nonexistent.txt", exception: true) # RuntimeError (Command failed with exit 1: cat) system("catt nonexistent.txt", exception: true) # Errno::ENOENT (No such file or directory - catt) See Kernel#exec for the standard shell. @overload system([env,] command... [,options], exception: false) @return [true, false, nil];T;#0;$@ ;.F;/o;0;1T;2i;3i;%@h;9I"static VALUE rb_f_system(int argc, VALUE *argv, VALUE _) { VALUE execarg_obj = rb_execarg_new(argc, argv, TRUE, TRUE); struct rb_execarg *eargp = rb_execarg_get(execarg_obj); struct rb_process_status status = {0}; eargp->status = &status; rb_last_status_clear(); // This function can set the thread's last status. // May be different from waitpid_state.pid on exec failure. rb_pid_t pid = rb_execarg_spawn(execarg_obj, 0, 0); if (pid > 0) { VALUE status = rb_process_status_wait(pid, 0); struct rb_process_status *data = RTYPEDDATA_DATA(status); // Set the last status: rb_obj_freeze(status); GET_THREAD()->last_status = status; if (data->status == EXIT_SUCCESS) { return Qtrue; } if (data->error != 0) { if (eargp->exception) { VALUE command = eargp->invoke.sh.shell_script; RB_GC_GUARD(execarg_obj); rb_syserr_fail_str(data->error, command); } else { return Qnil; } } else if (eargp->exception) { VALUE command = eargp->invoke.sh.shell_script; VALUE str = rb_str_new_cstr("Command failed with"); rb_str_cat_cstr(pst_message_status(str, data->status), ": "); rb_str_append(str, command); RB_GC_GUARD(execarg_obj); rb_exc_raise(rb_exc_new_str(rb_eRuntimeError, str)); } else { return Qfalse; } RB_GC_GUARD(status); } if (eargp->exception) { VALUE command = eargp->invoke.sh.shell_script; RB_GC_GUARD(execarg_obj); rb_syserr_fail_str(errno, command); } else { return Qnil; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#spawn;F;7[[@90;[[@ i;T;: spawn;0;[;{;IC; "7*spawn executes specified command and return its pid. pid = spawn("tar xf ruby-2.0.0-p195.tar.bz2") Process.wait pid pid = spawn(RbConfig.ruby, "-eputs'Hello, world!'") Process.wait pid This method is similar to Kernel#system but it doesn't wait for the command to finish. The parent process should use Process.wait to collect the termination status of its child or use Process.detach to register disinterest in their status; otherwise, the operating system may accumulate zombie processes. spawn has bunch of options to specify process attributes: env: hash name => val : set the environment variable name => nil : unset the environment variable the keys and the values except for +nil+ must be strings. command...: commandline : command line string which is passed to the standard shell cmdname, arg1, ... : command name and one or more arguments (This form does not use the shell. See below for caveats.) [cmdname, argv0], arg1, ... : command name, argv[0] and zero or more arguments (no shell) options: hash clearing environment variables: :unsetenv_others => true : clear environment variables except specified by env :unsetenv_others => false : don't clear (default) process group: :pgroup => true or 0 : make a new process group :pgroup => pgid : join the specified process group :pgroup => nil : don't change the process group (default) create new process group: Windows only :new_pgroup => true : the new process is the root process of a new process group :new_pgroup => false : don't create a new process group (default) resource limit: resourcename is core, cpu, data, etc. See Process.setrlimit. :rlimit_resourcename => limit :rlimit_resourcename => [cur_limit, max_limit] umask: :umask => int redirection: key: FD : single file descriptor in child process [FD, FD, ...] : multiple file descriptor in child process value: FD : redirect to the file descriptor in parent process string : redirect to file with open(string, "r" or "w") [string] : redirect to file with open(string, File::RDONLY) [string, open_mode] : redirect to file with open(string, open_mode, 0644) [string, open_mode, perm] : redirect to file with open(string, open_mode, perm) [:child, FD] : redirect to the redirected file descriptor :close : close the file descriptor in child process FD is one of follows :in : the file descriptor 0 which is the standard input :out : the file descriptor 1 which is the standard output :err : the file descriptor 2 which is the standard error integer : the file descriptor of specified the integer io : the file descriptor specified as io.fileno file descriptor inheritance: close non-redirected non-standard fds (3, 4, 5, ...) or not :close_others => false : inherit current directory: :chdir => str The cmdname, arg1, ... form does not use the shell. However, on different OSes, different things are provided as built-in commands. An example of this is +'echo'+, which is a built-in on Windows, but is a normal program on Linux and Mac OS X. This means that Process.spawn 'echo', '%Path%' will display the contents of the %Path% environment variable on Windows, but Process.spawn 'echo', '$PATH' prints the literal $PATH. If a hash is given as +env+, the environment is updated by +env+ before exec(2) in the child process. If a pair in +env+ has nil as the value, the variable is deleted. # set FOO as BAR and unset BAZ. pid = spawn({"FOO"=>"BAR", "BAZ"=>nil}, command) If a hash is given as +options+, it specifies process group, create new process group, resource limit, current directory, umask and redirects for the child process. Also, it can be specified to clear environment variables. The :unsetenv_others key in +options+ specifies to clear environment variables, other than specified by +env+. pid = spawn(command, :unsetenv_others=>true) # no environment variable pid = spawn({"FOO"=>"BAR"}, command, :unsetenv_others=>true) # FOO only The :pgroup key in +options+ specifies a process group. The corresponding value should be true, zero, a positive integer, or nil. true and zero cause the process to be a process leader of a new process group. A non-zero positive integer causes the process to join the provided process group. The default value, nil, causes the process to remain in the same process group. pid = spawn(command, :pgroup=>true) # process leader pid = spawn(command, :pgroup=>10) # belongs to the process group 10 The :new_pgroup key in +options+ specifies to pass +CREATE_NEW_PROCESS_GROUP+ flag to CreateProcessW() that is Windows API. This option is only for Windows. true means the new process is the root process of the new process group. The new process has CTRL+C disabled. This flag is necessary for Process.kill(:SIGINT, pid) on the subprocess. :new_pgroup is false by default. pid = spawn(command, :new_pgroup=>true) # new process group pid = spawn(command, :new_pgroup=>false) # same process group The :rlimit_foo key specifies a resource limit. foo should be one of resource types such as core. The corresponding value should be an integer or an array which have one or two integers: same as cur_limit and max_limit arguments for Process.setrlimit. cur, max = Process.getrlimit(:CORE) pid = spawn(command, :rlimit_core=>[0,max]) # disable core temporary. pid = spawn(command, :rlimit_core=>max) # enable core dump pid = spawn(command, :rlimit_core=>0) # never dump core. The :umask key in +options+ specifies the umask. pid = spawn(command, :umask=>077) The :in, :out, :err, an integer, an IO and an array key specifies a redirection. The redirection maps a file descriptor in the child process. For example, stderr can be merged into stdout as follows: pid = spawn(command, :err=>:out) pid = spawn(command, 2=>1) pid = spawn(command, STDERR=>:out) pid = spawn(command, STDERR=>STDOUT) The hash keys specifies a file descriptor in the child process started by #spawn. :err, 2 and STDERR specifies the standard error stream (stderr). The hash values specifies a file descriptor in the parent process which invokes #spawn. :out, 1 and STDOUT specifies the standard output stream (stdout). In the above example, the standard output in the child process is not specified. So it is inherited from the parent process. The standard input stream (stdin) can be specified by :in, 0 and STDIN. A filename can be specified as a hash value. pid = spawn(command, :in=>"/dev/null") # read mode pid = spawn(command, :out=>"/dev/null") # write mode pid = spawn(command, :err=>"log") # write mode pid = spawn(command, [:out, :err]=>"/dev/null") # write mode pid = spawn(command, 3=>"/dev/null") # read mode For stdout and stderr (and combination of them), it is opened in write mode. Otherwise read mode is used. For specifying flags and permission of file creation explicitly, an array is used instead. pid = spawn(command, :in=>["file"]) # read mode is assumed pid = spawn(command, :in=>["file", "r"]) pid = spawn(command, :out=>["log", "w"]) # 0644 assumed pid = spawn(command, :out=>["log", "w", 0600]) pid = spawn(command, :out=>["log", File::WRONLY|File::EXCL|File::CREAT, 0600]) The array specifies a filename, flags and permission. The flags can be a string or an integer. If the flags is omitted or nil, File::RDONLY is assumed. The permission should be an integer. If the permission is omitted or nil, 0644 is assumed. If an array of IOs and integers are specified as a hash key, all the elements are redirected. # stdout and stderr is redirected to log file. # The file "log" is opened just once. pid = spawn(command, [:out, :err]=>["log", "w"]) Another way to merge multiple file descriptors is [:child, fd]. \[:child, fd] means the file descriptor in the child process. This is different from fd. For example, :err=>:out means redirecting child stderr to parent stdout. But :err=>[:child, :out] means redirecting child stderr to child stdout. They differ if stdout is redirected in the child process as follows. # stdout and stderr is redirected to log file. # The file "log" is opened just once. pid = spawn(command, :out=>["log", "w"], :err=>[:child, :out]) \[:child, :out] can be used to merge stderr into stdout in IO.popen. In this case, IO.popen redirects stdout to a pipe in the child process and [:child, :out] refers the redirected stdout. io = IO.popen(["sh", "-c", "echo out; echo err >&2", :err=>[:child, :out]]) p io.read #=> "out\nerr\n" The :chdir key in +options+ specifies the current directory. pid = spawn(command, :chdir=>"/var/tmp") spawn closes all non-standard unspecified descriptors by default. The "standard" descriptors are 0, 1 and 2. This behavior is specified by :close_others option. :close_others doesn't affect the standard descriptors which are closed only if :close is specified explicitly. pid = spawn(command, :close_others=>true) # close 3,4,5,... (default) pid = spawn(command, :close_others=>false) # don't close 3,4,5,... :close_others is false by default for spawn and IO.popen. Note that fds which close-on-exec flag is already set are closed regardless of :close_others option. So IO.pipe and spawn can be used as IO.popen. # similar to r = IO.popen(command) r, w = IO.pipe pid = spawn(command, :out=>w) # r, w is closed in the child process. w.close :close is specified as a hash value to close a fd individually. f = open(foo) system(command, f=>:close) # don't inherit f. If a file descriptor need to be inherited, io=>io can be used. # valgrind has --log-fd option for log destination. # log_w=>log_w indicates log_w.fileno inherits to child process. log_r, log_w = IO.pipe pid = spawn("valgrind", "--log-fd=#{log_w.fileno}", "echo", "a", log_w=>log_w) log_w.close p log_r.read It is also possible to exchange file descriptors. pid = spawn(command, :out=>:err, :err=>:out) The hash keys specify file descriptors in the child process. The hash values specifies file descriptors in the parent process. So the above specifies exchanging stdout and stderr. Internally, +spawn+ uses an extra file descriptor to resolve such cyclic file descriptor mapping. See Kernel.exec for the standard shell. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"(spawn([env,] command... [,options]);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I"[env,][,options];T0;$@ o;= ;>I" overload;F;?0;;;@0;:I"(spawn([env,] command... [,options]);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I"[env,][,options];T0;$@ ;![;"I"*spawn executes specified command and return its pid. pid = spawn("tar xf ruby-2.0.0-p195.tar.bz2") Process.wait pid pid = spawn(RbConfig.ruby, "-eputs'Hello, world!'") Process.wait pid This method is similar to Kernel#system but it doesn't wait for the command to finish. The parent process should use Process.wait to collect the termination status of its child or use Process.detach to register disinterest in their status; otherwise, the operating system may accumulate zombie processes. spawn has bunch of options to specify process attributes: env: hash name => val : set the environment variable name => nil : unset the environment variable the keys and the values except for +nil+ must be strings. command...: commandline : command line string which is passed to the standard shell cmdname, arg1, ... : command name and one or more arguments (This form does not use the shell. See below for caveats.) [cmdname, argv0], arg1, ... : command name, argv[0] and zero or more arguments (no shell) options: hash clearing environment variables: :unsetenv_others => true : clear environment variables except specified by env :unsetenv_others => false : don't clear (default) process group: :pgroup => true or 0 : make a new process group :pgroup => pgid : join the specified process group :pgroup => nil : don't change the process group (default) create new process group: Windows only :new_pgroup => true : the new process is the root process of a new process group :new_pgroup => false : don't create a new process group (default) resource limit: resourcename is core, cpu, data, etc. See Process.setrlimit. :rlimit_resourcename => limit :rlimit_resourcename => [cur_limit, max_limit] umask: :umask => int redirection: key: FD : single file descriptor in child process [FD, FD, ...] : multiple file descriptor in child process value: FD : redirect to the file descriptor in parent process string : redirect to file with open(string, "r" or "w") [string] : redirect to file with open(string, File::RDONLY) [string, open_mode] : redirect to file with open(string, open_mode, 0644) [string, open_mode, perm] : redirect to file with open(string, open_mode, perm) [:child, FD] : redirect to the redirected file descriptor :close : close the file descriptor in child process FD is one of follows :in : the file descriptor 0 which is the standard input :out : the file descriptor 1 which is the standard output :err : the file descriptor 2 which is the standard error integer : the file descriptor of specified the integer io : the file descriptor specified as io.fileno file descriptor inheritance: close non-redirected non-standard fds (3, 4, 5, ...) or not :close_others => false : inherit current directory: :chdir => str The cmdname, arg1, ... form does not use the shell. However, on different OSes, different things are provided as built-in commands. An example of this is +'echo'+, which is a built-in on Windows, but is a normal program on Linux and Mac OS X. This means that Process.spawn 'echo', '%Path%' will display the contents of the %Path% environment variable on Windows, but Process.spawn 'echo', '$PATH' prints the literal $PATH. If a hash is given as +env+, the environment is updated by +env+ before exec(2) in the child process. If a pair in +env+ has nil as the value, the variable is deleted. # set FOO as BAR and unset BAZ. pid = spawn({"FOO"=>"BAR", "BAZ"=>nil}, command) If a hash is given as +options+, it specifies process group, create new process group, resource limit, current directory, umask and redirects for the child process. Also, it can be specified to clear environment variables. The :unsetenv_others key in +options+ specifies to clear environment variables, other than specified by +env+. pid = spawn(command, :unsetenv_others=>true) # no environment variable pid = spawn({"FOO"=>"BAR"}, command, :unsetenv_others=>true) # FOO only The :pgroup key in +options+ specifies a process group. The corresponding value should be true, zero, a positive integer, or nil. true and zero cause the process to be a process leader of a new process group. A non-zero positive integer causes the process to join the provided process group. The default value, nil, causes the process to remain in the same process group. pid = spawn(command, :pgroup=>true) # process leader pid = spawn(command, :pgroup=>10) # belongs to the process group 10 The :new_pgroup key in +options+ specifies to pass +CREATE_NEW_PROCESS_GROUP+ flag to CreateProcessW() that is Windows API. This option is only for Windows. true means the new process is the root process of the new process group. The new process has CTRL+C disabled. This flag is necessary for Process.kill(:SIGINT, pid) on the subprocess. :new_pgroup is false by default. pid = spawn(command, :new_pgroup=>true) # new process group pid = spawn(command, :new_pgroup=>false) # same process group The :rlimit_foo key specifies a resource limit. foo should be one of resource types such as core. The corresponding value should be an integer or an array which have one or two integers: same as cur_limit and max_limit arguments for Process.setrlimit. cur, max = Process.getrlimit(:CORE) pid = spawn(command, :rlimit_core=>[0,max]) # disable core temporary. pid = spawn(command, :rlimit_core=>max) # enable core dump pid = spawn(command, :rlimit_core=>0) # never dump core. The :umask key in +options+ specifies the umask. pid = spawn(command, :umask=>077) The :in, :out, :err, an integer, an IO and an array key specifies a redirection. The redirection maps a file descriptor in the child process. For example, stderr can be merged into stdout as follows: pid = spawn(command, :err=>:out) pid = spawn(command, 2=>1) pid = spawn(command, STDERR=>:out) pid = spawn(command, STDERR=>STDOUT) The hash keys specifies a file descriptor in the child process started by #spawn. :err, 2 and STDERR specifies the standard error stream (stderr). The hash values specifies a file descriptor in the parent process which invokes #spawn. :out, 1 and STDOUT specifies the standard output stream (stdout). In the above example, the standard output in the child process is not specified. So it is inherited from the parent process. The standard input stream (stdin) can be specified by :in, 0 and STDIN. A filename can be specified as a hash value. pid = spawn(command, :in=>"/dev/null") # read mode pid = spawn(command, :out=>"/dev/null") # write mode pid = spawn(command, :err=>"log") # write mode pid = spawn(command, [:out, :err]=>"/dev/null") # write mode pid = spawn(command, 3=>"/dev/null") # read mode For stdout and stderr (and combination of them), it is opened in write mode. Otherwise read mode is used. For specifying flags and permission of file creation explicitly, an array is used instead. pid = spawn(command, :in=>["file"]) # read mode is assumed pid = spawn(command, :in=>["file", "r"]) pid = spawn(command, :out=>["log", "w"]) # 0644 assumed pid = spawn(command, :out=>["log", "w", 0600]) pid = spawn(command, :out=>["log", File::WRONLY|File::EXCL|File::CREAT, 0600]) The array specifies a filename, flags and permission. The flags can be a string or an integer. If the flags is omitted or nil, File::RDONLY is assumed. The permission should be an integer. If the permission is omitted or nil, 0644 is assumed. If an array of IOs and integers are specified as a hash key, all the elements are redirected. # stdout and stderr is redirected to log file. # The file "log" is opened just once. pid = spawn(command, [:out, :err]=>["log", "w"]) Another way to merge multiple file descriptors is [:child, fd]. \[:child, fd] means the file descriptor in the child process. This is different from fd. For example, :err=>:out means redirecting child stderr to parent stdout. But :err=>[:child, :out] means redirecting child stderr to child stdout. They differ if stdout is redirected in the child process as follows. # stdout and stderr is redirected to log file. # The file "log" is opened just once. pid = spawn(command, :out=>["log", "w"], :err=>[:child, :out]) \[:child, :out] can be used to merge stderr into stdout in IO.popen. In this case, IO.popen redirects stdout to a pipe in the child process and [:child, :out] refers the redirected stdout. io = IO.popen(["sh", "-c", "echo out; echo err >&2", :err=>[:child, :out]]) p io.read #=> "out\nerr\n" The :chdir key in +options+ specifies the current directory. pid = spawn(command, :chdir=>"/var/tmp") spawn closes all non-standard unspecified descriptors by default. The "standard" descriptors are 0, 1 and 2. This behavior is specified by :close_others option. :close_others doesn't affect the standard descriptors which are closed only if :close is specified explicitly. pid = spawn(command, :close_others=>true) # close 3,4,5,... (default) pid = spawn(command, :close_others=>false) # don't close 3,4,5,... :close_others is false by default for spawn and IO.popen. Note that fds which close-on-exec flag is already set are closed regardless of :close_others option. So IO.pipe and spawn can be used as IO.popen. # similar to r = IO.popen(command) r, w = IO.pipe pid = spawn(command, :out=>w) # r, w is closed in the child process. w.close :close is specified as a hash value to close a fd individually. f = open(foo) system(command, f=>:close) # don't inherit f. If a file descriptor need to be inherited, io=>io can be used. # valgrind has --log-fd option for log destination. # log_w=>log_w indicates log_w.fileno inherits to child process. log_r, log_w = IO.pipe pid = spawn("valgrind", "--log-fd=#{log_w.fileno}", "echo", "a", log_w=>log_w) log_w.close p log_r.read It is also possible to exchange file descriptors. pid = spawn(command, :out=>:err, :err=>:out) The hash keys specify file descriptors in the child process. The hash values specifies file descriptors in the parent process. So the above specifies exchanging stdout and stderr. Internally, +spawn+ uses an extra file descriptor to resolve such cyclic file descriptor mapping. See Kernel.exec for the standard shell. @overload spawn([env,] command... [,options]) @overload spawn([env,] command... [,options]);T;#0;$@ ;.F;/o;0;1T;2i;3i;%@h;9I"static VALUE rb_f_spawn(int argc, VALUE *argv, VALUE _) { rb_pid_t pid; char errmsg[CHILD_ERRMSG_BUFLEN] = { '\0' }; VALUE execarg_obj, fail_str; struct rb_execarg *eargp; execarg_obj = rb_execarg_new(argc, argv, TRUE, FALSE); eargp = rb_execarg_get(execarg_obj); fail_str = eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name; pid = rb_execarg_spawn(execarg_obj, errmsg, sizeof(errmsg)); if (pid == -1) { int err = errno; rb_exec_fail(eargp, err, errmsg); RB_GC_GUARD(execarg_obj); rb_syserr_fail_str(err, fail_str); } #if defined(HAVE_WORKING_FORK) || defined(HAVE_SPAWNV) return PIDT2NUM(pid); #else return Qnil; #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#sleep;F;7[[@90;[[@ i*;T;: sleep;0;[;{;IC; "Suspends the current thread for _duration_ seconds (which may be any number, including a +Float+ with fractional seconds). Returns the actual number of seconds slept (rounded), which may be less than that asked for if another thread calls Thread#run. Called without an argument, sleep() will sleep forever. Time.new #=> 2008-03-08 19:56:19 +0900 sleep 1.2 #=> 1 Time.new #=> 2008-03-08 19:56:20 +0900 sleep 1.9 #=> 2 Time.new #=> 2008-03-08 19:56:22 +0900 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"sleep([duration]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@$ ;![;"I"@return [Integer];T;#0;$@$ ;.F;Bi;C0;7[[I"[duration];T0;$@$ ;![;"I"Suspends the current thread for _duration_ seconds (which may be any number, including a +Float+ with fractional seconds). Returns the actual number of seconds slept (rounded), which may be less than that asked for if another thread calls Thread#run. Called without an argument, sleep() will sleep forever. Time.new #=> 2008-03-08 19:56:19 +0900 sleep 1.2 #=> 1 Time.new #=> 2008-03-08 19:56:20 +0900 sleep 1.9 #=> 2 Time.new #=> 2008-03-08 19:56:22 +0900 @overload sleep([duration]) @return [Integer];T;#0;$@$ ;.F;/o;0;1T;2i;3i';%@h;9I"static VALUE rb_f_sleep(int argc, VALUE *argv, VALUE _) { time_t beg = time(0); VALUE scheduler = rb_fiber_scheduler_current(); if (scheduler != Qnil) { rb_fiber_scheduler_kernel_sleepv(scheduler, argc, argv); } else { if (argc == 0) { rb_thread_sleep_forever(); } else { rb_check_arity(argc, 0, 1); rb_thread_wait_for(rb_time_interval(argv[0])); } } time_t end = time(0) - beg; return TIMET2NUM(end); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#exit;F;7[[I"*a;T0[I"_;T0;[[@ i;T;: exit;0;[;{;IC; "Initiates the termination of the Ruby script by raising the SystemExit exception. This exception may be caught. The optional parameter is used to return a status code to the invoking environment. +true+ and +FALSE+ of _status_ means success and failure respectively. The interpretation of other integer values are system dependent. begin exit puts "never get here" rescue SystemExit puts "rescued a SystemExit exception" end puts "after begin block" produces: rescued a SystemExit exception after begin block Just prior to termination, Ruby executes any at_exit functions (see Kernel::at_exit) and runs any object finalizers (see ObjectSpace::define_finalizer). at_exit { puts "at_exit function" } ObjectSpace.define_finalizer("string", proc { puts "in finalizer" }) exit produces: at_exit function in finalizer ;T;[o;= ;>I" overload;F;?0;;;@0;:I"exit(status=true);T;IC; ";T;[;![;"I";T;#0;$@B ;.F;Bi;C0;7[[I" status;TI" true;T;$@B o;= ;>I" overload;F;?0;:Kernel::exit;@0;:I"Kernel::exit(status=true);T;IC; ";T;[;![;"I";T;#0;$@B ;.F;Bi;C0;7[[I" status;TI" true;T;$@B o;= ;>I" overload;F;?0;:Process::exit;@0;:I"Process::exit(status=true);T;IC; ";T;[;![;"I";T;#0;$@B ;.F;Bi;C0;7[[I" status;TI" true;T;$@B ;![;"I"Initiates the termination of the Ruby script by raising the SystemExit exception. This exception may be caught. The optional parameter is used to return a status code to the invoking environment. +true+ and +FALSE+ of _status_ means success and failure respectively. The interpretation of other integer values are system dependent. begin exit puts "never get here" rescue SystemExit puts "rescued a SystemExit exception" end puts "after begin block" produces: rescued a SystemExit exception after begin block Just prior to termination, Ruby executes any at_exit functions (see Kernel::at_exit) and runs any object finalizers (see ObjectSpace::define_finalizer). at_exit { puts "at_exit function" } ObjectSpace.define_finalizer("string", proc { puts "in finalizer" }) exit produces: at_exit function in finalizer @overload exit(status=true) @overload Kernel::exit(status=true) @overload Process::exit(status=true);T;#0;$@B ;.F;/o;0;1T;2i;3i;%@h;9I"ostatic VALUE f_exit(int c, const VALUE *a, VALUE _) { rb_f_exit(c, a); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#abort;F;7[[I"*a;T0[I"_;T0;[[@ i;T;: abort;0;[;{;IC; "Terminate execution immediately, effectively by calling Kernel.exit(false). If _msg_ is given, it is written to STDERR prior to terminating. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" abort;T;IC; ";T;[;![;"I";T;#0;$@u ;.F;Bi;C0;7[;$@u o;= ;>I" overload;F;?0;:Kernel::abort;@0;:I"Kernel::abort([msg]);T;IC; ";T;[;![;"I";T;#0;$@u ;.F;Bi;C0;7[[I" [msg];T0;$@u o;= ;>I" overload;F;?0;;;@0;:I"abort([msg]);T;IC; ";T;[;![;"I";T;#0;$@u ;.F;Bi;C0;7[[I" [msg];T0;$@u ;![;"I"Terminate execution immediately, effectively by calling Kernel.exit(false). If _msg_ is given, it is written to STDERR prior to terminating. @overload abort @overload Kernel::abort([msg]) @overload abort([msg]);T;#0;$@u ;.F;/o;0;1T;2i;3i;%@h;9I"qstatic VALUE f_abort(int c, const VALUE *a, VALUE _) { rb_f_abort(c, a); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#sprintf;F;7[[I"*v;T0[I"_;T0;[[@format_string to any additional arguments. Within the format string, any characters other than format sequences are copied to the result. The syntax of a format sequence is as follows. %[flags][width][.precision]type A format sequence consists of a percent sign, followed by optional flags, width, and precision indicators, then terminated with a field type character. The field type controls how the corresponding sprintf argument is to be interpreted, while the flags modify that interpretation. The field type characters are: Field | Integer Format ------+-------------------------------------------------------------- b | Convert argument as a binary number. | Negative numbers will be displayed as a two's complement | prefixed with `..1'. B | Equivalent to `b', but uses an uppercase 0B for prefix | in the alternative format by #. d | Convert argument as a decimal number. i | Identical to `d'. o | Convert argument as an octal number. | Negative numbers will be displayed as a two's complement | prefixed with `..7'. u | Identical to `d'. x | Convert argument as a hexadecimal number. | Negative numbers will be displayed as a two's complement | prefixed with `..f' (representing an infinite string of | leading 'ff's). X | Equivalent to `x', but uses uppercase letters. Field | Float Format ------+-------------------------------------------------------------- e | Convert floating point argument into exponential notation | with one digit before the decimal point as [-]d.dddddde[+-]dd. | The precision specifies the number of digits after the decimal | point (defaulting to six). E | Equivalent to `e', but uses an uppercase E to indicate | the exponent. f | Convert floating point argument as [-]ddd.dddddd, | where the precision specifies the number of digits after | the decimal point. g | Convert a floating point number using exponential form | if the exponent is less than -4 or greater than or | equal to the precision, or in dd.dddd form otherwise. | The precision specifies the number of significant digits. G | Equivalent to `g', but use an uppercase `E' in exponent form. a | Convert floating point argument as [-]0xh.hhhhp[+-]dd, | which is consisted from optional sign, "0x", fraction part | as hexadecimal, "p", and exponential part as decimal. A | Equivalent to `a', but use uppercase `X' and `P'. Field | Other Format ------+-------------------------------------------------------------- c | Argument is the numeric code for a single character or | a single character string itself. p | The valuing of argument.inspect. s | Argument is a string to be substituted. If the format | sequence contains a precision, at most that many characters | will be copied. % | A percent sign itself will be displayed. No argument taken. The flags modifies the behavior of the formats. The flag characters are: Flag | Applies to | Meaning ---------+---------------+----------------------------------------- space | bBdiouxX | Leave a space at the start of | aAeEfgG | non-negative numbers. | (numeric fmt) | For `o', `x', `X', `b' and `B', use | | a minus sign with absolute value for | | negative values. ---------+---------------+----------------------------------------- (digit)$ | all | Specifies the absolute argument number | | for this field. Absolute and relative | | argument numbers cannot be mixed in a | | sprintf string. ---------+---------------+----------------------------------------- # | bBoxX | Use an alternative format. | aAeEfgG | For the conversions `o', increase the precision | | until the first digit will be `0' if | | it is not formatted as complements. | | For the conversions `x', `X', `b' and `B' | | on non-zero, prefix the result with ``0x'', | | ``0X'', ``0b'' and ``0B'', respectively. | | For `a', `A', `e', `E', `f', `g', and 'G', | | force a decimal point to be added, | | even if no digits follow. | | For `g' and 'G', do not remove trailing zeros. ---------+---------------+----------------------------------------- + | bBdiouxX | Add a leading plus sign to non-negative | aAeEfgG | numbers. | (numeric fmt) | For `o', `x', `X', `b' and `B', use | | a minus sign with absolute value for | | negative values. ---------+---------------+----------------------------------------- - | all | Left-justify the result of this conversion. ---------+---------------+----------------------------------------- 0 (zero) | bBdiouxX | Pad with zeros, not spaces. | aAeEfgG | For `o', `x', `X', `b' and `B', radix-1 | (numeric fmt) | is used for negative numbers formatted as | | complements. ---------+---------------+----------------------------------------- * | all | Use the next argument as the field width. | | If negative, left-justify the result. If the | | asterisk is followed by a number and a dollar | | sign, use the indicated argument as the width. Examples of flags: # `+' and space flag specifies the sign of non-negative numbers. sprintf("%d", 123) #=> "123" sprintf("%+d", 123) #=> "+123" sprintf("% d", 123) #=> " 123" # `#' flag for `o' increases number of digits to show `0'. # `+' and space flag changes format of negative numbers. sprintf("%o", 123) #=> "173" sprintf("%#o", 123) #=> "0173" sprintf("%+o", -123) #=> "-173" sprintf("%o", -123) #=> "..7605" sprintf("%#o", -123) #=> "..7605" # `#' flag for `x' add a prefix `0x' for non-zero numbers. # `+' and space flag disables complements for negative numbers. sprintf("%x", 123) #=> "7b" sprintf("%#x", 123) #=> "0x7b" sprintf("%+x", -123) #=> "-7b" sprintf("%x", -123) #=> "..f85" sprintf("%#x", -123) #=> "0x..f85" sprintf("%#x", 0) #=> "0" # `#' for `X' uses the prefix `0X'. sprintf("%X", 123) #=> "7B" sprintf("%#X", 123) #=> "0X7B" # `#' flag for `b' add a prefix `0b' for non-zero numbers. # `+' and space flag disables complements for negative numbers. sprintf("%b", 123) #=> "1111011" sprintf("%#b", 123) #=> "0b1111011" sprintf("%+b", -123) #=> "-1111011" sprintf("%b", -123) #=> "..10000101" sprintf("%#b", -123) #=> "0b..10000101" sprintf("%#b", 0) #=> "0" # `#' for `B' uses the prefix `0B'. sprintf("%B", 123) #=> "1111011" sprintf("%#B", 123) #=> "0B1111011" # `#' for `e' forces to show the decimal point. sprintf("%.0e", 1) #=> "1e+00" sprintf("%#.0e", 1) #=> "1.e+00" # `#' for `f' forces to show the decimal point. sprintf("%.0f", 1234) #=> "1234" sprintf("%#.0f", 1234) #=> "1234." # `#' for `g' forces to show the decimal point. # It also disables stripping lowest zeros. sprintf("%g", 123.4) #=> "123.4" sprintf("%#g", 123.4) #=> "123.400" sprintf("%g", 123456) #=> "123456" sprintf("%#g", 123456) #=> "123456." The field width is an optional integer, followed optionally by a period and a precision. The width specifies the minimum number of characters that will be written to the result for this field. Examples of width: # padding is done by spaces, width=20 # 0 or radix-1. <------------------> sprintf("%20d", 123) #=> " 123" sprintf("%+20d", 123) #=> " +123" sprintf("%020d", 123) #=> "00000000000000000123" sprintf("%+020d", 123) #=> "+0000000000000000123" sprintf("% 020d", 123) #=> " 0000000000000000123" sprintf("%-20d", 123) #=> "123 " sprintf("%-+20d", 123) #=> "+123 " sprintf("%- 20d", 123) #=> " 123 " sprintf("%020x", -123) #=> "..ffffffffffffffff85" For numeric fields, the precision controls the number of decimal places displayed. For string fields, the precision determines the maximum number of characters to be copied from the string. (Thus, the format sequence %10.10s will always contribute exactly ten characters to the result.) Examples of precisions: # precision for `d', 'o', 'x' and 'b' is # minimum number of digits <------> sprintf("%20.8d", 123) #=> " 00000123" sprintf("%20.8o", 123) #=> " 00000173" sprintf("%20.8x", 123) #=> " 0000007b" sprintf("%20.8b", 123) #=> " 01111011" sprintf("%20.8d", -123) #=> " -00000123" sprintf("%20.8o", -123) #=> " ..777605" sprintf("%20.8x", -123) #=> " ..ffff85" sprintf("%20.8b", -11) #=> " ..110101" # "0x" and "0b" for `#x' and `#b' is not counted for # precision but "0" for `#o' is counted. <------> sprintf("%#20.8d", 123) #=> " 00000123" sprintf("%#20.8o", 123) #=> " 00000173" sprintf("%#20.8x", 123) #=> " 0x0000007b" sprintf("%#20.8b", 123) #=> " 0b01111011" sprintf("%#20.8d", -123) #=> " -00000123" sprintf("%#20.8o", -123) #=> " ..777605" sprintf("%#20.8x", -123) #=> " 0x..ffff85" sprintf("%#20.8b", -11) #=> " 0b..110101" # precision for `e' is number of # digits after the decimal point <------> sprintf("%20.8e", 1234.56789) #=> " 1.23456789e+03" # precision for `f' is number of # digits after the decimal point <------> sprintf("%20.8f", 1234.56789) #=> " 1234.56789000" # precision for `g' is number of # significant digits <-------> sprintf("%20.8g", 1234.56789) #=> " 1234.5679" # <-------> sprintf("%20.8g", 123456789) #=> " 1.2345679e+08" # precision for `s' is # maximum number of characters <------> sprintf("%20.8s", "string test") #=> " string t" Examples: sprintf("%d %04x", 123, 123) #=> "123 007b" sprintf("%08b '%4s'", 123, 123) #=> "01111011 ' 123'" sprintf("%1$*2$s %2$d %1$s", "hello", 8) #=> " hello 8 hello" sprintf("%1$*2$s %2$d", "hello", -8) #=> "hello -8" sprintf("%+g:% g:%-g", 1.23, 1.23, 1.23) #=> "+1.23: 1.23:1.23" sprintf("%u", -123) #=> "-123" For more complex formatting, Ruby supports a reference by name. %s style uses format style, but %{name} style doesn't. Examples: sprintf("%d : %f", { :foo => 1, :bar => 2 }) #=> 1 : 2.000000 sprintf("%{foo}f", { :foo => 1 }) # => "1f" ;T;[o;= ;>I" overload;F;?0;: format;@0;:I",format(format_string [, arguments...] );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[[I""format_string[, arguments...];T0;$@ o;= ;>I" overload;F;?0;;;@0;:I"-sprintf(format_string [, arguments...] );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[[I""format_string[, arguments...];T0;$@ ;![;"I",Returns the string resulting from applying format_string to any additional arguments. Within the format string, any characters other than format sequences are copied to the result. The syntax of a format sequence is as follows. %[flags][width][.precision]type A format sequence consists of a percent sign, followed by optional flags, width, and precision indicators, then terminated with a field type character. The field type controls how the corresponding sprintf argument is to be interpreted, while the flags modify that interpretation. The field type characters are: Field | Integer Format ------+-------------------------------------------------------------- b | Convert argument as a binary number. | Negative numbers will be displayed as a two's complement | prefixed with `..1'. B | Equivalent to `b', but uses an uppercase 0B for prefix | in the alternative format by #. d | Convert argument as a decimal number. i | Identical to `d'. o | Convert argument as an octal number. | Negative numbers will be displayed as a two's complement | prefixed with `..7'. u | Identical to `d'. x | Convert argument as a hexadecimal number. | Negative numbers will be displayed as a two's complement | prefixed with `..f' (representing an infinite string of | leading 'ff's). X | Equivalent to `x', but uses uppercase letters. Field | Float Format ------+-------------------------------------------------------------- e | Convert floating point argument into exponential notation | with one digit before the decimal point as [-]d.dddddde[+-]dd. | The precision specifies the number of digits after the decimal | point (defaulting to six). E | Equivalent to `e', but uses an uppercase E to indicate | the exponent. f | Convert floating point argument as [-]ddd.dddddd, | where the precision specifies the number of digits after | the decimal point. g | Convert a floating point number using exponential form | if the exponent is less than -4 or greater than or | equal to the precision, or in dd.dddd form otherwise. | The precision specifies the number of significant digits. G | Equivalent to `g', but use an uppercase `E' in exponent form. a | Convert floating point argument as [-]0xh.hhhhp[+-]dd, | which is consisted from optional sign, "0x", fraction part | as hexadecimal, "p", and exponential part as decimal. A | Equivalent to `a', but use uppercase `X' and `P'. Field | Other Format ------+-------------------------------------------------------------- c | Argument is the numeric code for a single character or | a single character string itself. p | The valuing of argument.inspect. s | Argument is a string to be substituted. If the format | sequence contains a precision, at most that many characters | will be copied. % | A percent sign itself will be displayed. No argument taken. The flags modifies the behavior of the formats. The flag characters are: Flag | Applies to | Meaning ---------+---------------+----------------------------------------- space | bBdiouxX | Leave a space at the start of | aAeEfgG | non-negative numbers. | (numeric fmt) | For `o', `x', `X', `b' and `B', use | | a minus sign with absolute value for | | negative values. ---------+---------------+----------------------------------------- (digit)$ | all | Specifies the absolute argument number | | for this field. Absolute and relative | | argument numbers cannot be mixed in a | | sprintf string. ---------+---------------+----------------------------------------- # | bBoxX | Use an alternative format. | aAeEfgG | For the conversions `o', increase the precision | | until the first digit will be `0' if | | it is not formatted as complements. | | For the conversions `x', `X', `b' and `B' | | on non-zero, prefix the result with ``0x'', | | ``0X'', ``0b'' and ``0B'', respectively. | | For `a', `A', `e', `E', `f', `g', and 'G', | | force a decimal point to be added, | | even if no digits follow. | | For `g' and 'G', do not remove trailing zeros. ---------+---------------+----------------------------------------- + | bBdiouxX | Add a leading plus sign to non-negative | aAeEfgG | numbers. | (numeric fmt) | For `o', `x', `X', `b' and `B', use | | a minus sign with absolute value for | | negative values. ---------+---------------+----------------------------------------- - | all | Left-justify the result of this conversion. ---------+---------------+----------------------------------------- 0 (zero) | bBdiouxX | Pad with zeros, not spaces. | aAeEfgG | For `o', `x', `X', `b' and `B', radix-1 | (numeric fmt) | is used for negative numbers formatted as | | complements. ---------+---------------+----------------------------------------- * | all | Use the next argument as the field width. | | If negative, left-justify the result. If the | | asterisk is followed by a number and a dollar | | sign, use the indicated argument as the width. Examples of flags: # `+' and space flag specifies the sign of non-negative numbers. sprintf("%d", 123) #=> "123" sprintf("%+d", 123) #=> "+123" sprintf("% d", 123) #=> " 123" # `#' flag for `o' increases number of digits to show `0'. # `+' and space flag changes format of negative numbers. sprintf("%o", 123) #=> "173" sprintf("%#o", 123) #=> "0173" sprintf("%+o", -123) #=> "-173" sprintf("%o", -123) #=> "..7605" sprintf("%#o", -123) #=> "..7605" # `#' flag for `x' add a prefix `0x' for non-zero numbers. # `+' and space flag disables complements for negative numbers. sprintf("%x", 123) #=> "7b" sprintf("%#x", 123) #=> "0x7b" sprintf("%+x", -123) #=> "-7b" sprintf("%x", -123) #=> "..f85" sprintf("%#x", -123) #=> "0x..f85" sprintf("%#x", 0) #=> "0" # `#' for `X' uses the prefix `0X'. sprintf("%X", 123) #=> "7B" sprintf("%#X", 123) #=> "0X7B" # `#' flag for `b' add a prefix `0b' for non-zero numbers. # `+' and space flag disables complements for negative numbers. sprintf("%b", 123) #=> "1111011" sprintf("%#b", 123) #=> "0b1111011" sprintf("%+b", -123) #=> "-1111011" sprintf("%b", -123) #=> "..10000101" sprintf("%#b", -123) #=> "0b..10000101" sprintf("%#b", 0) #=> "0" # `#' for `B' uses the prefix `0B'. sprintf("%B", 123) #=> "1111011" sprintf("%#B", 123) #=> "0B1111011" # `#' for `e' forces to show the decimal point. sprintf("%.0e", 1) #=> "1e+00" sprintf("%#.0e", 1) #=> "1.e+00" # `#' for `f' forces to show the decimal point. sprintf("%.0f", 1234) #=> "1234" sprintf("%#.0f", 1234) #=> "1234." # `#' for `g' forces to show the decimal point. # It also disables stripping lowest zeros. sprintf("%g", 123.4) #=> "123.4" sprintf("%#g", 123.4) #=> "123.400" sprintf("%g", 123456) #=> "123456" sprintf("%#g", 123456) #=> "123456." The field width is an optional integer, followed optionally by a period and a precision. The width specifies the minimum number of characters that will be written to the result for this field. Examples of width: # padding is done by spaces, width=20 # 0 or radix-1. <------------------> sprintf("%20d", 123) #=> " 123" sprintf("%+20d", 123) #=> " +123" sprintf("%020d", 123) #=> "00000000000000000123" sprintf("%+020d", 123) #=> "+0000000000000000123" sprintf("% 020d", 123) #=> " 0000000000000000123" sprintf("%-20d", 123) #=> "123 " sprintf("%-+20d", 123) #=> "+123 " sprintf("%- 20d", 123) #=> " 123 " sprintf("%020x", -123) #=> "..ffffffffffffffff85" For numeric fields, the precision controls the number of decimal places displayed. For string fields, the precision determines the maximum number of characters to be copied from the string. (Thus, the format sequence %10.10s will always contribute exactly ten characters to the result.) Examples of precisions: # precision for `d', 'o', 'x' and 'b' is # minimum number of digits <------> sprintf("%20.8d", 123) #=> " 00000123" sprintf("%20.8o", 123) #=> " 00000173" sprintf("%20.8x", 123) #=> " 0000007b" sprintf("%20.8b", 123) #=> " 01111011" sprintf("%20.8d", -123) #=> " -00000123" sprintf("%20.8o", -123) #=> " ..777605" sprintf("%20.8x", -123) #=> " ..ffff85" sprintf("%20.8b", -11) #=> " ..110101" # "0x" and "0b" for `#x' and `#b' is not counted for # precision but "0" for `#o' is counted. <------> sprintf("%#20.8d", 123) #=> " 00000123" sprintf("%#20.8o", 123) #=> " 00000173" sprintf("%#20.8x", 123) #=> " 0x0000007b" sprintf("%#20.8b", 123) #=> " 0b01111011" sprintf("%#20.8d", -123) #=> " -00000123" sprintf("%#20.8o", -123) #=> " ..777605" sprintf("%#20.8x", -123) #=> " 0x..ffff85" sprintf("%#20.8b", -11) #=> " 0b..110101" # precision for `e' is number of # digits after the decimal point <------> sprintf("%20.8e", 1234.56789) #=> " 1.23456789e+03" # precision for `f' is number of # digits after the decimal point <------> sprintf("%20.8f", 1234.56789) #=> " 1234.56789000" # precision for `g' is number of # significant digits <-------> sprintf("%20.8g", 1234.56789) #=> " 1234.5679" # <-------> sprintf("%20.8g", 123456789) #=> " 1.2345679e+08" # precision for `s' is # maximum number of characters <------> sprintf("%20.8s", "string test") #=> " string t" Examples: sprintf("%d %04x", 123, 123) #=> "123 007b" sprintf("%08b '%4s'", 123, 123) #=> "01111011 ' 123'" sprintf("%1$*2$s %2$d %1$s", "hello", 8) #=> " hello 8 hello" sprintf("%1$*2$s %2$d", "hello", -8) #=> "hello -8" sprintf("%+g:% g:%-g", 1.23, 1.23, 1.23) #=> "+1.23: 1.23:1.23" sprintf("%u", -123) #=> "-123" For more complex formatting, Ruby supports a reference by name. %s style uses format style, but %{name} style doesn't. Examples: sprintf("%d : %f", { :foo => 1, :bar => 2 }) #=> 1 : 2.000000 sprintf("%{foo}f", { :foo => 1 }) # => "1f" @overload format(format_string [, arguments...] ) @return [String] @overload sprintf(format_string [, arguments...] ) @return [String];T;#0;$@ ;.F;/o;0;1T;2i;3i;%@h;9I"^static VALUE f_sprintf(int c, const VALUE *v, VALUE _) { return rb_f_sprintf(c, v); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#format;F;7[[I"*v;T0[I"_;T0;[[@format_string to any additional arguments. Within the format string, any characters other than format sequences are copied to the result. The syntax of a format sequence is as follows. %[flags][width][.precision]type A format sequence consists of a percent sign, followed by optional flags, width, and precision indicators, then terminated with a field type character. The field type controls how the corresponding sprintf argument is to be interpreted, while the flags modify that interpretation. The field type characters are: Field | Integer Format ------+-------------------------------------------------------------- b | Convert argument as a binary number. | Negative numbers will be displayed as a two's complement | prefixed with `..1'. B | Equivalent to `b', but uses an uppercase 0B for prefix | in the alternative format by #. d | Convert argument as a decimal number. i | Identical to `d'. o | Convert argument as an octal number. | Negative numbers will be displayed as a two's complement | prefixed with `..7'. u | Identical to `d'. x | Convert argument as a hexadecimal number. | Negative numbers will be displayed as a two's complement | prefixed with `..f' (representing an infinite string of | leading 'ff's). X | Equivalent to `x', but uses uppercase letters. Field | Float Format ------+-------------------------------------------------------------- e | Convert floating point argument into exponential notation | with one digit before the decimal point as [-]d.dddddde[+-]dd. | The precision specifies the number of digits after the decimal | point (defaulting to six). E | Equivalent to `e', but uses an uppercase E to indicate | the exponent. f | Convert floating point argument as [-]ddd.dddddd, | where the precision specifies the number of digits after | the decimal point. g | Convert a floating point number using exponential form | if the exponent is less than -4 or greater than or | equal to the precision, or in dd.dddd form otherwise. | The precision specifies the number of significant digits. G | Equivalent to `g', but use an uppercase `E' in exponent form. a | Convert floating point argument as [-]0xh.hhhhp[+-]dd, | which is consisted from optional sign, "0x", fraction part | as hexadecimal, "p", and exponential part as decimal. A | Equivalent to `a', but use uppercase `X' and `P'. Field | Other Format ------+-------------------------------------------------------------- c | Argument is the numeric code for a single character or | a single character string itself. p | The valuing of argument.inspect. s | Argument is a string to be substituted. If the format | sequence contains a precision, at most that many characters | will be copied. % | A percent sign itself will be displayed. No argument taken. The flags modifies the behavior of the formats. The flag characters are: Flag | Applies to | Meaning ---------+---------------+----------------------------------------- space | bBdiouxX | Leave a space at the start of | aAeEfgG | non-negative numbers. | (numeric fmt) | For `o', `x', `X', `b' and `B', use | | a minus sign with absolute value for | | negative values. ---------+---------------+----------------------------------------- (digit)$ | all | Specifies the absolute argument number | | for this field. Absolute and relative | | argument numbers cannot be mixed in a | | sprintf string. ---------+---------------+----------------------------------------- # | bBoxX | Use an alternative format. | aAeEfgG | For the conversions `o', increase the precision | | until the first digit will be `0' if | | it is not formatted as complements. | | For the conversions `x', `X', `b' and `B' | | on non-zero, prefix the result with ``0x'', | | ``0X'', ``0b'' and ``0B'', respectively. | | For `a', `A', `e', `E', `f', `g', and 'G', | | force a decimal point to be added, | | even if no digits follow. | | For `g' and 'G', do not remove trailing zeros. ---------+---------------+----------------------------------------- + | bBdiouxX | Add a leading plus sign to non-negative | aAeEfgG | numbers. | (numeric fmt) | For `o', `x', `X', `b' and `B', use | | a minus sign with absolute value for | | negative values. ---------+---------------+----------------------------------------- - | all | Left-justify the result of this conversion. ---------+---------------+----------------------------------------- 0 (zero) | bBdiouxX | Pad with zeros, not spaces. | aAeEfgG | For `o', `x', `X', `b' and `B', radix-1 | (numeric fmt) | is used for negative numbers formatted as | | complements. ---------+---------------+----------------------------------------- * | all | Use the next argument as the field width. | | If negative, left-justify the result. If the | | asterisk is followed by a number and a dollar | | sign, use the indicated argument as the width. Examples of flags: # `+' and space flag specifies the sign of non-negative numbers. sprintf("%d", 123) #=> "123" sprintf("%+d", 123) #=> "+123" sprintf("% d", 123) #=> " 123" # `#' flag for `o' increases number of digits to show `0'. # `+' and space flag changes format of negative numbers. sprintf("%o", 123) #=> "173" sprintf("%#o", 123) #=> "0173" sprintf("%+o", -123) #=> "-173" sprintf("%o", -123) #=> "..7605" sprintf("%#o", -123) #=> "..7605" # `#' flag for `x' add a prefix `0x' for non-zero numbers. # `+' and space flag disables complements for negative numbers. sprintf("%x", 123) #=> "7b" sprintf("%#x", 123) #=> "0x7b" sprintf("%+x", -123) #=> "-7b" sprintf("%x", -123) #=> "..f85" sprintf("%#x", -123) #=> "0x..f85" sprintf("%#x", 0) #=> "0" # `#' for `X' uses the prefix `0X'. sprintf("%X", 123) #=> "7B" sprintf("%#X", 123) #=> "0X7B" # `#' flag for `b' add a prefix `0b' for non-zero numbers. # `+' and space flag disables complements for negative numbers. sprintf("%b", 123) #=> "1111011" sprintf("%#b", 123) #=> "0b1111011" sprintf("%+b", -123) #=> "-1111011" sprintf("%b", -123) #=> "..10000101" sprintf("%#b", -123) #=> "0b..10000101" sprintf("%#b", 0) #=> "0" # `#' for `B' uses the prefix `0B'. sprintf("%B", 123) #=> "1111011" sprintf("%#B", 123) #=> "0B1111011" # `#' for `e' forces to show the decimal point. sprintf("%.0e", 1) #=> "1e+00" sprintf("%#.0e", 1) #=> "1.e+00" # `#' for `f' forces to show the decimal point. sprintf("%.0f", 1234) #=> "1234" sprintf("%#.0f", 1234) #=> "1234." # `#' for `g' forces to show the decimal point. # It also disables stripping lowest zeros. sprintf("%g", 123.4) #=> "123.4" sprintf("%#g", 123.4) #=> "123.400" sprintf("%g", 123456) #=> "123456" sprintf("%#g", 123456) #=> "123456." The field width is an optional integer, followed optionally by a period and a precision. The width specifies the minimum number of characters that will be written to the result for this field. Examples of width: # padding is done by spaces, width=20 # 0 or radix-1. <------------------> sprintf("%20d", 123) #=> " 123" sprintf("%+20d", 123) #=> " +123" sprintf("%020d", 123) #=> "00000000000000000123" sprintf("%+020d", 123) #=> "+0000000000000000123" sprintf("% 020d", 123) #=> " 0000000000000000123" sprintf("%-20d", 123) #=> "123 " sprintf("%-+20d", 123) #=> "+123 " sprintf("%- 20d", 123) #=> " 123 " sprintf("%020x", -123) #=> "..ffffffffffffffff85" For numeric fields, the precision controls the number of decimal places displayed. For string fields, the precision determines the maximum number of characters to be copied from the string. (Thus, the format sequence %10.10s will always contribute exactly ten characters to the result.) Examples of precisions: # precision for `d', 'o', 'x' and 'b' is # minimum number of digits <------> sprintf("%20.8d", 123) #=> " 00000123" sprintf("%20.8o", 123) #=> " 00000173" sprintf("%20.8x", 123) #=> " 0000007b" sprintf("%20.8b", 123) #=> " 01111011" sprintf("%20.8d", -123) #=> " -00000123" sprintf("%20.8o", -123) #=> " ..777605" sprintf("%20.8x", -123) #=> " ..ffff85" sprintf("%20.8b", -11) #=> " ..110101" # "0x" and "0b" for `#x' and `#b' is not counted for # precision but "0" for `#o' is counted. <------> sprintf("%#20.8d", 123) #=> " 00000123" sprintf("%#20.8o", 123) #=> " 00000173" sprintf("%#20.8x", 123) #=> " 0x0000007b" sprintf("%#20.8b", 123) #=> " 0b01111011" sprintf("%#20.8d", -123) #=> " -00000123" sprintf("%#20.8o", -123) #=> " ..777605" sprintf("%#20.8x", -123) #=> " 0x..ffff85" sprintf("%#20.8b", -11) #=> " 0b..110101" # precision for `e' is number of # digits after the decimal point <------> sprintf("%20.8e", 1234.56789) #=> " 1.23456789e+03" # precision for `f' is number of # digits after the decimal point <------> sprintf("%20.8f", 1234.56789) #=> " 1234.56789000" # precision for `g' is number of # significant digits <-------> sprintf("%20.8g", 1234.56789) #=> " 1234.5679" # <-------> sprintf("%20.8g", 123456789) #=> " 1.2345679e+08" # precision for `s' is # maximum number of characters <------> sprintf("%20.8s", "string test") #=> " string t" Examples: sprintf("%d %04x", 123, 123) #=> "123 007b" sprintf("%08b '%4s'", 123, 123) #=> "01111011 ' 123'" sprintf("%1$*2$s %2$d %1$s", "hello", 8) #=> " hello 8 hello" sprintf("%1$*2$s %2$d", "hello", -8) #=> "hello -8" sprintf("%+g:% g:%-g", 1.23, 1.23, 1.23) #=> "+1.23: 1.23:1.23" sprintf("%u", -123) #=> "-123" For more complex formatting, Ruby supports a reference by name. %s style uses format style, but %{name} style doesn't. Examples: sprintf("%d : %f", { :foo => 1, :bar => 2 }) #=> 1 : 2.000000 sprintf("%{foo}f", { :foo => 1 }) # => "1f" ;T;[o;= ;>I" overload;F;?0;;;@0;:I",format(format_string [, arguments...] );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[[I""format_string[, arguments...];T0;$@ o;= ;>I" overload;F;?0;;;@0;:I"-sprintf(format_string [, arguments...] );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[[I""format_string[, arguments...];T0;$@ ;![;"@ ;#0;$@ ;.F;/o;0;1T;2i;3i;%@h;9I"^static VALUE f_sprintf(int c, const VALUE *v, VALUE _) { return rb_f_sprintf(c, v); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#Integer;F;7[[@90;[[@arg to an Integer. Numeric types are converted directly (with floating point numbers being truncated). base (0, or between 2 and 36) is a base for integer string representation. If arg is a String, when base is omitted or equals zero, radix indicators (0, 0b, and 0x) are honored. In any case, strings should consist only of one or more digits, except for that a sign, one underscore between two digits, and leading/trailing spaces are optional. This behavior is different from that of String#to_i. Non string values will be converted by first trying to_int, then to_i. Passing nil raises a TypeError, while passing a String that does not conform with numeric representation raises an ArgumentError. This behavior can be altered by passing exception: false, in this case a not convertible value will return nil. Integer(123.999) #=> 123 Integer("0x1a") #=> 26 Integer(Time.new) #=> 1204973019 Integer("0930", 10) #=> 930 Integer("111", 2) #=> 7 Integer(" +1_0 ") #=> 10 Integer(nil) #=> TypeError: can't convert nil into Integer Integer("x") #=> ArgumentError: invalid value for Integer(): "x" Integer("x", exception: false) #=> nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I"*Integer(arg, base=0, exception: true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@ ;![;"I"@return [Integer, nil];T;#0;$@ ;.F;Bi;C0;7[[I"arg;T0[I" base;TI"0;T[I"exception:;TI" true;T;$@ ;![;"I"Converts arg to an Integer. Numeric types are converted directly (with floating point numbers being truncated). base (0, or between 2 and 36) is a base for integer string representation. If arg is a String, when base is omitted or equals zero, radix indicators (0, 0b, and 0x) are honored. In any case, strings should consist only of one or more digits, except for that a sign, one underscore between two digits, and leading/trailing spaces are optional. This behavior is different from that of String#to_i. Non string values will be converted by first trying to_int, then to_i. Passing nil raises a TypeError, while passing a String that does not conform with numeric representation raises an ArgumentError. This behavior can be altered by passing exception: false, in this case a not convertible value will return nil. Integer(123.999) #=> 123 Integer("0x1a") #=> 26 Integer(Time.new) #=> 1204973019 Integer("0930", 10) #=> 930 Integer("111", 2) #=> 7 Integer(" +1_0 ") #=> 10 Integer(nil) #=> TypeError: can't convert nil into Integer Integer("x") #=> ArgumentError: invalid value for Integer(): "x" Integer("x", exception: false) #=> nil @overload Integer(arg, base=0, exception: true) @return [Integer, nil];T;#0;$@ ;.F;/o;0;1T;2i{ ;3i ;%@h;9I"static VALUE rb_f_integer(int argc, VALUE *argv, VALUE obj) { VALUE arg = Qnil, opts = Qnil; int base = 0; if (argc > 1) { int narg = 1; VALUE vbase = rb_check_to_int(argv[1]); if (!NIL_P(vbase)) { base = NUM2INT(vbase); narg = 2; } if (argc > narg) { VALUE hash = rb_check_hash_type(argv[argc-1]); if (!NIL_P(hash)) { opts = rb_extract_keywords(&hash); if (!hash) --argc; } } } rb_check_arity(argc, 1, 2); arg = argv[0]; return rb_convert_to_integer(arg, base, opts_exception_p(opts)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#String;F;7[[I"arg;T0;[[@arg as a String. First tries to call its to_str method, then its to_s method. String(self) #=> "main" String(self.class) #=> "Object" String(123456) #=> "123456" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"String(arg);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@' ;![;"I"@return [String];T;#0;$@' ;.F;Bi;C0;7[[I"arg;T0;$@' ;![;"I" Returns arg as a String. First tries to call its to_str method, then its to_s method. String(self) #=> "main" String(self.class) #=> "Object" String(123456) #=> "123456" @overload String(arg) @return [String];T;#0;$@' ;.F;/o;0;1T;2iN;3iX;%@h;9I"Rstatic VALUE rb_f_string(VALUE obj, VALUE arg) { return rb_String(arg); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#Array;F;7[[I"arg;T0;[[@to_ary on +arg+, then to_a. If +arg+ does not respond to to_ary or to_a, returns an Array of length 1 containing +arg+. If to_ary or to_a returns something other than an Array, raises a TypeError. Array(["a", "b"]) #=> ["a", "b"] Array(1..5) #=> [1, 2, 3, 4, 5] Array(key: :value) #=> [[:key, :value]] Array(nil) #=> [] Array(1) #=> [1] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"Array(arg);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@F ;![;"I"@return [Array];T;#0;$@F ;.F;Bi;C0;7[[I"arg;T0;$@F ;![;"I""Returns +arg+ as an Array. First tries to call to_ary on +arg+, then to_a. If +arg+ does not respond to to_ary or to_a, returns an Array of length 1 containing +arg+. If to_ary or to_a returns something other than an Array, raises a TypeError. Array(["a", "b"]) #=> ["a", "b"] Array(1..5) #=> [1, 2, 3, 4, 5] Array(key: :value) #=> [[:key, :value]] Array(nil) #=> [] Array(1) #=> [1] @overload Array(arg) @return [Array];T;#0;$@F ;.F;/o;0;1T;2io;3i;%@h;9I"Pstatic VALUE rb_f_array(VALUE obj, VALUE arg) { return rb_Array(arg); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#Hash;F;7[[I"arg;T0;[[@arg to a Hash by calling arg.to_hash. Returns an empty Hash when arg is nil or []. Hash([]) #=> {} Hash(nil) #=> {} Hash(key: :value) #=> {:key => :value} Hash([1, 2, 3]) #=> TypeError ;T;[o;= ;>I" overload;F;?0;;;@0;:I"Hash(arg);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@e ;![;"I"@return [Hash];T;#0;$@e ;.F;Bi;C0;7[[I"arg;T0;$@e ;![;"I"<Converts arg to a Hash by calling arg.to_hash. Returns an empty Hash when arg is nil or []. Hash([]) #=> {} Hash(nil) #=> {} Hash(key: :value) #=> {:key => :value} Hash([1, 2, 3]) #=> TypeError @overload Hash(arg) @return [Hash];T;#0;$@e ;.F;/o;0;1T;2i;3i;%@h;9I"Nstatic VALUE rb_f_hash(VALUE obj, VALUE arg) { return rb_Hash(arg); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#syscall;F;7[[@90;[[@Ti");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 the 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;= ;>I" overload;F;?0;;;@0;:I"syscall(num [, args...]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[[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 the 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;0;1T;2i);3i);%@h;9I"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;4;5F;6;;;;&I"Kernel#open;F;7[[@90;[[@Ti;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. Note that the command may be processed by shell if it contains shell metacharacters. 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;= ;>I" overload;F;?0;;;@0;:I")open(path [, mode [, perm]] [, opt]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"IO;TI"nil;T;$@ ;![;"I"@return [IO, nil];T;#0;$@ ;.F;Bi;C0;7[[I"!path[, mode [, perm]][, opt];T0;$@ o;= ;>I" overload;F;?0;;;@0;:I")open(path [, mode [, perm]] [, opt]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"io;T;$@ o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@ ;![;"I"!@yield [io] @return [Object];T;#0;$@ ;.F;Bi;C0;7[[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. Note that the command may be processed by shell if it contains shell metacharacters. 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;0;1T;2iv;3i;%@h;9I" 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;4;5F;6;;;;&I"Kernel#printf;F;7[[@90;[[@Ti(;T;: printf;0;[;{;IC; "iEquivalent to: io.write(sprintf(string, obj, ...)) or $stdout.write(sprintf(string, obj, ...)) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"$printf(io, string [, obj ... ]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@ ;![;"I"@return [nil];T;#0;$@ ;.F;Bi;C0;7[[I"io;T0[I"string[, obj ... ];T0;$@ o;= ;>I" overload;F;?0;;;@0;:I" printf(string [, obj ... ]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@ ;![;"I"@return [nil];T;#0;$@ ;.F;Bi;C0;7[[I"string[, obj ... ];T0;$@ ;![;"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;$@ ;.F;/o;0;1T;2i;3i&;%@h;9I"*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;4;5F;6;;;;&I"Kernel#print;F;7[[@90;[[@Ti;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;= ;>I" overload;F;?0;;;@0;:I"print(obj, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@ ;![;"I"@return [nil];T;#0;$@ ;.F;Bi;C0;7[[I"obj;T0[I"...;T0;$@ ;![;"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;$@ ;.F;/o;0;1T;2iy;3i;%@h;9I"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;4;5F;6;;;;&I"Kernel#putc;F;7[[I"ch;T0;[[@Ti;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;= ;>I" overload;F;?0;;;@0;:I"putc(int);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@$ ;![;"I"@return [Integer];T;#0;$@$ ;.F;Bi;C0;7[[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;0;1T;2i;3i;%@h;9I"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 forward(r_stdout, rb_intern("putc"), 1, &ch); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#puts;F;7[[@90;[[@Ti= ;T;: puts;0;[;{;IC; ".Equivalent to $stdout.puts(obj, ...) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"puts(obj, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@C ;![;"I"@return [nil];T;#0;$@C ;.F;Bi;C0;7[[I"obj;T0[I"...;T0;$@C ;![;"I"YEquivalent to $stdout.puts(obj, ...) @overload puts(obj, ...) @return [nil];T;#0;$@C ;.F;/o;0;1T;2i4 ;3i: ;%@h;9I"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 forward(r_stdout, rb_intern("puts"), argc, argv); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#gets;F;7[[@90;[[@Ti$;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;= ;>I" overload;F;?0;;;@0;:I""gets(sep=$/ [, getline_args]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@c ;![;"I"@return [String, nil];T;#0;$@c ;.F;Bi;C0;7[[I"sep;TI"$/[, getline_args];T;$@c o;= ;>I" overload;F;?0;;;@0;:I"!gets(limit [, getline_args]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@c ;![;"I"@return [String, nil];T;#0;$@c ;.F;Bi;C0;7[[I"limit[, getline_args];T0;$@c o;= ;>I" overload;F;?0;;;@0;:I"&gets(sep, limit [, getline_args]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@c ;![;"I"@return [String, nil];T;#0;$@c ;.F;Bi;C0;7[[I"sep;T0[I"limit[, getline_args];T0;$@c ;![;"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;$@c ;.F;/o;0;1T;2i$;3i$;%@h;9I"static VALUE rb_f_gets(int argc, VALUE *argv, VALUE recv) { if (recv == argf) { return argf_gets(argc, argv, argf); } return forward(argf, idGets, argc, argv); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#readline;F;7[[@90;[[@Ti$;T;: readline;0;[;{;IC; "TEquivalent to Kernel::gets, except +readline+ raises +EOFError+ at end of file. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"readline(sep=$/);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[[I"sep;TI"$/;T;$@ o;= ;>I" overload;F;?0;;;@0;:I"readline(limit);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[[I" limit;T0;$@ o;= ;>I" overload;F;?0;;;@0;:I"readline(sep, limit);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[[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;0;1T;2i$;3i$;%@h;9I"static VALUE rb_f_readline(int argc, VALUE *argv, VALUE recv) { if (recv == argf) { return argf_readline(argc, argv, argf); } return forward(argf, rb_intern("readline"), argc, argv); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#select;F;7[[@90;[[@TiS';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;= ;>I" overload;F;?0;;;@0;:I"Cselect(read_array [, write_array [, error_array [, timeout]]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;TI"nil;T;$@ ;![;"I"@return [Array, nil];T;#0;$@ ;.F;Bi;C0;7[[I":read_array[, write_array [, error_array [, timeout]]];T0;$@ ;![;"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;$@ ;.F;/o;0;1T;2i&;3iP';%@h;9I" 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;4;5F;6;;;;&I"Kernel#readlines;F;7[[@90;[[@Ti*%;T;:readlines;0;[;{;IC; "zReturns an array containing the lines returned by calling Kernel.gets(sep) until the end of file. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"readlines(sep=$/);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@ ;![;"I"@return [Array];T;#0;$@ ;.F;Bi;C0;7[[I"sep;TI"$/;T;$@ o;= ;>I" overload;F;?0;;;@0;:I"readlines(limit);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@ ;![;"I"@return [Array];T;#0;$@ ;.F;Bi;C0;7[[I" limit;T0;$@ o;= ;>I" overload;F;?0;;;@0;:I"readlines(sep, limit);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@ ;![;"I"@return [Array];T;#0;$@ ;.F;Bi;C0;7[[I"sep;T0[I" limit;T0;$@ ;![;"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;$@ ;.F;/o;0;1T;2i %;3i)%;%@h;9I"static VALUE rb_f_readlines(int argc, VALUE *argv, VALUE recv) { if (recv == argf) { return argf_readlines(argc, argv, argf); } return forward(argf, rb_intern("readlines"), argc, argv); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Kernel#`;F;7[[I"str;T0;[[@Tii%;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;= ;>I" overload;F;?0;;;@0;:I" `cmd`;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@B ;![;"I"@return [String];T;#0;$@B ;.F;Bi;C0;7[;$@B ;![;"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;$@B ;.F;/o;0;1T;2i[%;3if%;%@h;9I"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_GUARD(port); return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Kernel#p;F;7[[@90;[[@Ti ;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;= ;>I" overload;F;?0;;;@0;:I" p(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@_ ;![;"I"@return [Object];T;#0;$@_ ;.F;Bi;C0;7[[I"obj;T0;$@_ o;= ;>I" overload;F;?0;;;@0;:I"p(obj1, obj2, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@_ ;![;"I"@return [Array];T;#0;$@_ ;.F;Bi;C0;7[[I" obj1;T0[I" obj2;T0[I"...;T0;$@_ o;= ;>I" overload;F;?0;;;@0;:I"p();T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@_ ;![;"I"@return [nil];T;#0;$@_ ;.F;Bi;C0;7[;$@_ ;![;"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;0;1T;2ip ;3i ;%@h;9I"static VALUE rb_f_p(int argc, VALUE *argv, VALUE self) { int i; for (i=0; i 268519324636777531569100071560086917274 [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319] [ rand(10), rand(1000) ] # => [4, 664] srand 1234 # => 1234 [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"$srand(number = Random.new_seed);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I" number;TI"Random.new_seed;T;$@ ;![;"I"Seeds the system pseudo-random number generator, with +number+. The previous seed value is returned. If +number+ is omitted, seeds the generator using a source of entropy provided by the operating system, if available (/dev/urandom on Unix systems or the RSA cryptographic provider on Windows), which is then combined with the time, the process id, and a sequence number. srand may be used to ensure repeatable sequences of pseudo-random numbers between different runs of the program. By setting the seed to a known value, programs can be made deterministic during testing. srand 1234 # => 268519324636777531569100071560086917274 [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319] [ rand(10), rand(1000) ] # => [4, 664] srand 1234 # => 1234 [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319] @overload srand(number = Random.new_seed);T;#0;$@ ;.F;/o;0;1T;2i;3i;%@h;9I"ystatic VALUE rb_f_srand(int argc, VALUE *argv, VALUE obj) { VALUE seed, old; rb_random_mt_t *r = rand_mt_start(default_rand()); if (rb_check_arity(argc, 0, 1) == 0) { seed = random_seed(obj); } else { seed = rb_to_int(argv[0]); } old = r->base.seed; rand_init(&random_mt_if, &r->base, seed); r->base.seed = seed; return old; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#rand;F;7[[@90;[[@ ih;T;: rand;0;[;{;IC; "0If called without an argument, or if max.to_i.abs == 0, rand returns a pseudo-random floating point number between 0.0 and 1.0, including 0.0 and excluding 1.0. rand #=> 0.2725926052826416 When +max.abs+ is greater than or equal to 1, +rand+ returns a pseudo-random integer greater than or equal to 0 and less than +max.to_i.abs+. rand(100) #=> 12 When +max+ is a Range, +rand+ returns a random number where range.member?(number) == true. Negative or floating point values for +max+ are allowed, but may give surprising results. rand(-100) # => 87 rand(-0.5) # => 0.8130921818028143 rand(1.9) # equivalent to rand(1), which is always 0 Kernel.srand may be used to ensure that sequences of random numbers are reproducible between different runs of a program. See also Random.rand. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"rand(max=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@ ;![;"I"@return [Numeric];T;#0;$@ ;.F;Bi;C0;7[[I"max;TI"0;T;$@ ;![;"I"\If called without an argument, or if max.to_i.abs == 0, rand returns a pseudo-random floating point number between 0.0 and 1.0, including 0.0 and excluding 1.0. rand #=> 0.2725926052826416 When +max.abs+ is greater than or equal to 1, +rand+ returns a pseudo-random integer greater than or equal to 0 and less than +max.to_i.abs+. rand(100) #=> 12 When +max+ is a Range, +rand+ returns a random number where range.member?(number) == true. Negative or floating point values for +max+ are allowed, but may give surprising results. rand(-100) # => 87 rand(-0.5) # => 0.8130921818028143 rand(1.9) # equivalent to rand(1), which is always 0 Kernel.srand may be used to ensure that sequences of random numbers are reproducible between different runs of a program. See also Random.rand. @overload rand(max=0) @return [Numeric];T;#0;$@ ;.F;/o;0;1T;2iI;3ie;%@h;9I"static VALUE rb_f_rand(int argc, VALUE *argv, VALUE obj) { VALUE vmax; rb_random_t *rnd = rand_start(default_rand()); if (rb_check_arity(argc, 0, 1) && !NIL_P(vmax = argv[0])) { VALUE v = rand_range(obj, rnd, vmax); if (v != Qfalse) return v; vmax = rb_to_int(vmax); if (vmax != INT2FIX(0)) { v = rand_int(obj, rnd, vmax, 0); if (!NIL_P(v)) return v; } } return DBL2NUM(random_real(obj, rnd, TRUE)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#Complex;F;7[[@90;[[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;= ;>I" overload;F;?0;;;@0;:I"%Complex(x[, y], exception: true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;TI"nil;T;$@ ;![;"I"@return [Numeric, nil];T;#0;$@ ;.F;Bi;C0;7[[I" x[, y];T0[I"exception:;TI" true;T;$@ ;![;"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;$@ ;.F;/o;0;1T;2i;3i;%@h;9I"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;4;5F;6;;;;&I"Kernel#BigDecimal;F;7[[@90;[[I" ext/bigdecimal/bigdecimal.c;Ti ;T;:BigDecimal;0;[;{;IC; "Returns the \BigDecimal converted from +value+ with a precision of +ndigits+ decimal digits. When +ndigits+ is less than the number of significant digits in the value, the result is rounded to that number of digits, according to the current rounding mode; see BigDecimal.mode. Returns +value+ converted to a \BigDecimal, depending on the type of +value+: - Integer, Float, Rational, Complex, or BigDecimal: converted directly: # Integer, Complex, or BigDecimal value does not require ndigits; ignored if given. BigDecimal(2) # => 0.2e1 BigDecimal(Complex(2, 0)) # => 0.2e1 BigDecimal(BigDecimal(2)) # => 0.2e1 # Float or Rational value requires ndigits. BigDecimal(2.0, 0) # => 0.2e1 BigDecimal(Rational(2, 1), 0) # => 0.2e1 - String: converted by parsing if it contains an integer or floating-point literal; leading and trailing whitespace is ignored: # String does not require ndigits; ignored if given. BigDecimal('2') # => 0.2e1 BigDecimal('2.0') # => 0.2e1 BigDecimal('0.2e1') # => 0.2e1 BigDecimal(' 2.0 ') # => 0.2e1 - Other type that responds to method :to_str: first converted to a string, then converted to a \BigDecimal, as above. - Other type: - Raises an exception if keyword argument +exception+ is +true+. - Returns +nil+ if keyword argument +exception+ is +true+. Raises an exception if +value+ evaluates to a Float and +digits+ is larger than Float::DIG + 1. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"'BigDecimal(value, exception: true);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I" value;T0[I"exception:;TI" true;T;$@ o;= ;>I" overload;F;?0;;;@0;:I"0BigDecimal(value, ndigits, exception: true);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I" value;T0[I" ndigits;T0[I"exception:;TI" true;T;$@ ;![;"I"R Returns the \BigDecimal converted from +value+ with a precision of +ndigits+ decimal digits. When +ndigits+ is less than the number of significant digits in the value, the result is rounded to that number of digits, according to the current rounding mode; see BigDecimal.mode. Returns +value+ converted to a \BigDecimal, depending on the type of +value+: - Integer, Float, Rational, Complex, or BigDecimal: converted directly: # Integer, Complex, or BigDecimal value does not require ndigits; ignored if given. BigDecimal(2) # => 0.2e1 BigDecimal(Complex(2, 0)) # => 0.2e1 BigDecimal(BigDecimal(2)) # => 0.2e1 # Float or Rational value requires ndigits. BigDecimal(2.0, 0) # => 0.2e1 BigDecimal(Rational(2, 1), 0) # => 0.2e1 - String: converted by parsing if it contains an integer or floating-point literal; leading and trailing whitespace is ignored: # String does not require ndigits; ignored if given. BigDecimal('2') # => 0.2e1 BigDecimal('2.0') # => 0.2e1 BigDecimal('0.2e1') # => 0.2e1 BigDecimal(' 2.0 ') # => 0.2e1 - Other type that responds to method :to_str: first converted to a string, then converted to a \BigDecimal, as above. - Other type: - Raises an exception if keyword argument +exception+ is +true+. - Returns +nil+ if keyword argument +exception+ is +true+. Raises an exception if +value+ evaluates to a Float and +digits+ is larger than Float::DIG + 1. @overload BigDecimal(value, exception: true) @overload BigDecimal(value, ndigits, exception: true);T;#0;$@ ;.F;/o;0;1T;2i ;3i ;%@h;9I"Kstatic VALUE f_BigDecimal(int argc, VALUE *argv, VALUE self) { VALUE val, digs_v, opts = Qnil; argc = rb_scan_args(argc, argv, "11:", &val, &digs_v, &opts); int exception = opts_exception_p(opts); size_t digs = SIZE_MAX; /* this means digs is omitted */ if (argc > 1) { digs_v = rb_to_int(digs_v); if (FIXNUM_P(digs_v)) { long n = FIX2LONG(digs_v); if (n < 0) goto negative_digs; digs = (size_t)n; } else { if (RBIGNUM_NEGATIVE_P(digs_v)) { negative_digs: if (!exception) return Qnil; rb_raise(rb_eArgError, "negative precision"); } digs = NUM2SIZET(digs_v); } } return rb_convert_to_BigDecimal(val, digs, exception); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#at_exit;F;7[;[[I"eval_jump.c;Ti*;T;: at_exit;0;[;{;IC; "Converts _block_ to a +Proc+ object (and therefore binds it at the point of call) and registers it for execution when the program exits. If multiple handlers are registered, they are executed in reverse order of registration. def do_at_exit(str1) at_exit { print str1 } end at_exit { puts "cruel world" } do_at_exit("goodbye ") exit produces: goodbye cruel world ;T;[o;= ;>I" overload;F;?0;;;@0;:I" at_exit;T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@&o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@&;![;"I"@yield [] @return [Proc];T;#0;$@&;.F;Bi;C0;7[;$@&;![;"I"Converts _block_ to a +Proc+ object (and therefore binds it at the point of call) and registers it for execution when the program exits. If multiple handlers are registered, they are executed in reverse order of registration. def do_at_exit(str1) at_exit { print str1 } end at_exit { puts "cruel world" } do_at_exit("goodbye ") exit produces: goodbye cruel world @overload at_exit @yield [] @return [Proc];T;#0;$@&;.F;/o;0;1T;2i;3i(;%@h;9I"static VALUE rb_f_at_exit(VALUE _) { VALUE proc; if (!rb_block_given_p()) { rb_raise(rb_eArgError, "called without a block"); } proc = rb_block_proc(); rb_set_end_proc(rb_call_end_proc, proc); return proc; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#caller;F;7[[@90;[[I"vm_backtrace.c;Ti;T;: caller;0;[;{;IC; "Returns the current execution stack---an array containing strings in the form file:line or file:line: in `method'. The optional _start_ parameter determines the number of initial stack entries to omit from the top of the stack. A second optional +length+ parameter can be used to limit how many entries are returned from the stack. Returns +nil+ if _start_ is greater than the size of current execution stack. Optionally you can pass a range, which will return an array containing the entries within the specified range. def a(skip) caller(skip) end def b(skip) a(skip) end def c(skip) b(skip) end c(0) #=> ["prog:2:in `a'", "prog:5:in `b'", "prog:8:in `c'", "prog:10:in `
'"] c(1) #=> ["prog:5:in `b'", "prog:8:in `c'", "prog:11:in `
'"] c(2) #=> ["prog:8:in `c'", "prog:12:in `
'"] c(3) #=> ["prog:13:in `
'"] c(4) #=> [] c(5) #=> nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I" caller(start=1, length=nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;TI"nil;T;$@E;![;"I"@return [Array, nil];T;#0;$@E;.F;Bi;C0;7[[I" start;TI"1;T[I" length;TI"nil;T;$@Eo;= ;>I" overload;F;?0;;;@0;:I"caller(range);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;TI"nil;T;$@E;![;"I"@return [Array, nil];T;#0;$@E;.F;Bi;C0;7[[I" range;T0;$@E;![;"I"$Returns the current execution stack---an array containing strings in the form file:line or file:line: in `method'. The optional _start_ parameter determines the number of initial stack entries to omit from the top of the stack. A second optional +length+ parameter can be used to limit how many entries are returned from the stack. Returns +nil+ if _start_ is greater than the size of current execution stack. Optionally you can pass a range, which will return an array containing the entries within the specified range. def a(skip) caller(skip) end def b(skip) a(skip) end def c(skip) b(skip) end c(0) #=> ["prog:2:in `a'", "prog:5:in `b'", "prog:8:in `c'", "prog:10:in `
'"] c(1) #=> ["prog:5:in `b'", "prog:8:in `c'", "prog:11:in `
'"] c(2) #=> ["prog:8:in `c'", "prog:12:in `
'"] c(3) #=> ["prog:13:in `
'"] c(4) #=> [] c(5) #=> nil @overload caller(start=1, length=nil) @return [Array, nil] @overload caller(range) @return [Array, nil];T;#0;$@E;.F;/o;0;1T;2i;3i;%@h;9I"{static VALUE rb_f_caller(int argc, VALUE *argv, VALUE _) { return ec_backtrace_to_ary(GET_EC(), argc, argv, 1, 1, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#caller_locations;F;7[[@90;[[@Ki;T;:caller_locations;0;[;{;IC; "&Returns the current execution stack---an array containing backtrace location objects. See Thread::Backtrace::Location for more information. The optional _start_ parameter determines the number of initial stack entries to omit from the top of the stack. A second optional +length+ parameter can be used to limit how many entries are returned from the stack. Returns +nil+ if _start_ is greater than the size of current execution stack. Optionally you can pass a range, which will return an array containing the entries within the specified range. ;T;[o;= ;>I" overload;F;?0;;;@0;:I":caller_locations(start=1, length=nil) -> array or nil;T;IC; ";T;[;![;"I";T;#0;$@y;.F;Bi;C0;7[[I" start;TI"1;T[I" length;TI"nil;T;$@yo;= ;>I" overload;F;?0;;;@0;:I".caller_locations(range) -> array or nil;T;IC; ";T;[;![;"I";T;#0;$@y;.F;Bi;C0;7[[I" range;T0;$@y;![;"I"Returns the current execution stack---an array containing backtrace location objects. See Thread::Backtrace::Location for more information. The optional _start_ parameter determines the number of initial stack entries to omit from the top of the stack. A second optional +length+ parameter can be used to limit how many entries are returned from the stack. Returns +nil+ if _start_ is greater than the size of current execution stack. Optionally you can pass a range, which will return an array containing the entries within the specified range. @overload caller_locations(start=1, length=nil) -> array or nil @overload caller_locations(range) -> array or nil;T;#0;$@y;.F;/o;0;1T;2i;3i;%@h;9I"static VALUE rb_f_caller_locations(int argc, VALUE *argv, VALUE _) { return ec_backtrace_to_ary(GET_EC(), argc, argv, 1, 1, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#eval;F;7[[@90;[[@Ci ;T;: eval;0;[;{;IC; "Evaluates the Ruby expression(s) in string. If binding is given, which must be a Binding object, the evaluation is performed in its context. If the optional filename and lineno parameters are present, they will be used when reporting syntax errors. def get_binding(str) return binding end str = "hello" eval "str + ' Fred'" #=> "hello Fred" eval "str + ' Fred'", get_binding("bye") #=> "bye Fred" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"4eval(string [, binding [, filename [,lineno]]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I"-string[, binding [, filename [,lineno]]];T0;$@;![;"I"*Evaluates the Ruby expression(s) in string. If binding is given, which must be a Binding object, the evaluation is performed in its context. If the optional filename and lineno parameters are present, they will be used when reporting syntax errors. def get_binding(str) return binding end str = "hello" eval "str + ' Fred'" #=> "hello Fred" eval "str + ' Fred'", get_binding("bye") #=> "bye Fred" @overload eval(string [, binding [, filename [,lineno]]]) @return [Object];T;#0;$@;.F;/o;0;1T;2i;3i;%@h;9I"VALUE rb_f_eval(int argc, const VALUE *argv, VALUE self) { VALUE src, scope, vfile, vline; VALUE file = Qundef; int line = 1; rb_scan_args(argc, argv, "13", &src, &scope, &vfile, &vline); SafeStringValue(src); if (argc >= 3) { StringValue(vfile); } if (argc >= 4) { line = NUM2INT(vline); } if (!NIL_P(vfile)) file = vfile; if (NIL_P(scope)) return eval_string_with_cref(self, src, NULL, file, line); else return eval_string_with_scope(scope, src, file, line); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Kernel#local_variables;F;7[;[[@Ci ;T;:local_variables;0;[;{;IC; "Returns the names of the current local variables. fred = 1 for i in 1..10 # ... end local_variables #=> [:fred, :i] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"local_variables;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the names of the current local variables. fred = 1 for i in 1..10 # ... end local_variables #=> [:fred, :i] @overload local_variables @return [Array];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@h;9I"static VALUE rb_f_local_variables(VALUE _) { struct local_var_list vars; rb_execution_context_t *ec = GET_EC(); rb_control_frame_t *cfp = vm_get_ruby_level_caller_cfp(ec, RUBY_VM_PREVIOUS_CONTROL_FRAME(ec->cfp)); unsigned int i; local_var_list_init(&vars); while (cfp) { if (cfp->iseq) { for (i = 0; i < cfp->iseq->body->local_table_size; i++) { local_var_list_add(&vars, cfp->iseq->body->local_table[i]); } } if (!VM_ENV_LOCAL_P(cfp->ep)) { /* block */ const VALUE *ep = VM_CF_PREV_EP(cfp); if (vm_collect_local_variables_in_heap(ep, &vars)) { break; } else { while (cfp->ep != ep) { cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); } } } else { break; } } return local_var_list_finish(&vars); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#iterator?;F;7[;[[@Ci ;T;:iterator?;0;[;{;IC; "+Deprecated. Use block_given? instead.;T;[o;= ;>I" overload;F;?0;;;@0;:I"iterator?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"UDeprecated. Use block_given? instead. @overload iterator? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i ;3i ;Bi;%@h;9I"static VALUE rb_f_iterator_p(VALUE self) { rb_warn_deprecated("iterator?", "block_given?"); return rb_f_block_given_p(self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#block_given?;F;7[;[[@Ci ;T;:block_given?;0;[;{;IC; "\Returns true if yield would execute a block in the current context. The iterator? form is mildly deprecated. def try if block_given? yield else "no block" end end try #=> "no block" try { "hello" } #=> "hello" try do "hello" end #=> "hello";T;[o;= ;>I" overload;F;?0;;;@0;:I"block_given?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns true if yield would execute a block in the current context. The iterator? form is mildly deprecated. def try if block_given? yield else "no block" end end try #=> "no block" try { "hello" } #=> "hello" try do "hello" end #=> "hello" @overload block_given? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i ;3i ;Bi;%@h;9I"$static VALUE rb_f_block_given_p(VALUE _) { rb_execution_context_t *ec = GET_EC(); rb_control_frame_t *cfp = ec->cfp; cfp = vm_get_ruby_level_caller_cfp(ec, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)); return RBOOL(cfp != NULL && VM_CF_BLOCK_HANDLER(cfp) != VM_BLOCK_HANDLER_NONE); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#catch;F;7[[@90;[[@Ci/ ;T;: catch;0;[;{;IC; "+catch+ executes its block. If +throw+ is not called, the block executes normally, and +catch+ returns the value of the last expression evaluated. catch(1) { 123 } # => 123 If throw(tag2, val) is called, Ruby searches up its stack for a +catch+ block whose +tag+ has the same +object_id+ as _tag2_. When found, the block stops executing and returns _val_ (or +nil+ if no second argument was given to +throw+). catch(1) { throw(1, 456) } # => 456 catch(1) { throw(1) } # => nil When +tag+ is passed as the first argument, +catch+ yields it as the parameter of the block. catch(1) {|x| x + 2 } # => 3 When no +tag+ is given, +catch+ yields a new unique object (as from +Object.new+) as the block parameter. This object can then be used as the argument to +throw+, and will match the correct +catch+ block. catch do |obj_A| catch do |obj_B| throw(obj_B, 123) puts "This puts is not reached" end puts "This puts is displayed" 456 end # => 456 catch do |obj_A| catch do |obj_B| throw(obj_A, 123) puts "This puts is still not reached" end puts "Now this puts is also not reached" 456 end # => 123 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"catch([tag]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"tag;T;$@o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I""@yield [tag] @return [Object];T;#0;$@;.F;Bi;C0;7[[I" [tag];T0;$@;![;"I"+catch+ executes its block. If +throw+ is not called, the block executes normally, and +catch+ returns the value of the last expression evaluated. catch(1) { 123 } # => 123 If throw(tag2, val) is called, Ruby searches up its stack for a +catch+ block whose +tag+ has the same +object_id+ as _tag2_. When found, the block stops executing and returns _val_ (or +nil+ if no second argument was given to +throw+). catch(1) { throw(1, 456) } # => 456 catch(1) { throw(1) } # => nil When +tag+ is passed as the first argument, +catch+ yields it as the parameter of the block. catch(1) {|x| x + 2 } # => 3 When no +tag+ is given, +catch+ yields a new unique object (as from +Object.new+) as the block parameter. This object can then be used as the argument to +throw+, and will match the correct +catch+ block. catch do |obj_A| catch do |obj_B| throw(obj_B, 123) puts "This puts is not reached" end puts "This puts is displayed" 456 end # => 456 catch do |obj_A| catch do |obj_B| throw(obj_A, 123) puts "This puts is still not reached" end puts "Now this puts is also not reached" 456 end # => 123 @overload catch([tag]) @yield [tag] @return [Object];T;#0;$@;.F;/o;0;1T;2i;3i- ;%@h;9I"static VALUE rb_f_catch(int argc, VALUE *argv, VALUE self) { VALUE tag = rb_check_arity(argc, 0, 1) ? argv[0] : rb_obj_alloc(rb_cObject); return rb_catch_obj(tag, catch_i, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#throw;F;7[[@90;[[@Ci;T;: throw;0;[;{;IC; "$Transfers control to the end of the active +catch+ block waiting for _tag_. Raises +UncaughtThrowError+ if there is no +catch+ block for the _tag_. The optional second parameter supplies a return value for the +catch+ block, which otherwise defaults to +nil+. For examples, see Kernel::catch. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"throw(tag [, obj]);T;IC; ";T;[;![;"I";T;#0;$@2;.F;Bi;C0;7[[I"tag[, obj];T0;$@2;![;"I"CTransfers control to the end of the active +catch+ block waiting for _tag_. Raises +UncaughtThrowError+ if there is no +catch+ block for the _tag_. The optional second parameter supplies a return value for the +catch+ block, which otherwise defaults to +nil+. For examples, see Kernel::catch. @overload throw(tag [, obj]);T;#0;$@2;.F;/o;0;1T;2i;3i;%@h;9I"static VALUE rb_f_throw(int argc, VALUE *argv, VALUE _) { VALUE tag, value; rb_scan_args(argc, argv, "11", &tag, &value); rb_throw_obj(tag, value); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#loop;F;7[;[[@Ci;T;: loop;0;[;{;IC; "Repeatedly executes the block. If no block is given, an enumerator is returned instead. loop do print "Input: " line = gets break if !line or line =~ /^qQ/ # ... end StopIteration raised in the block breaks the loop. In this case, loop returns the "result" value stored in the exception. enum = Enumerator.new { |y| y << "one" y << "two" :ok } result = loop { puts enum.next } #=> :ok ;T;[o;= ;>I" overload;F;?0;;;@0;:I" loop;T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@K;![;"I"@yield [];T;#0;$@K;.F;Bi;C0;7[;$@Ko;= ;>I" overload;F;?0;;;@0;:I" loop;T;IC; ";T;[;![;"I";T;#0;$@K;.F;Bi;C0;7[;$@K;![;"I"Repeatedly executes the block. If no block is given, an enumerator is returned instead. loop do print "Input: " line = gets break if !line or line =~ /^qQ/ # ... end StopIteration raised in the block breaks the loop. In this case, loop returns the "result" value stored in the exception. enum = Enumerator.new { |y| y << "one" y << "two" :ok } result = loop { puts enum.next } #=> :ok @overload loop @yield [] @overload loop;T;#0;$@K;.F;/o;0;1T;2i;3i;%@h;9I"static VALUE rb_f_loop(VALUE self) { RETURN_SIZED_ENUMERATOR(self, 0, 0, rb_f_loop_size); return rb_rescue2(loop_i, (VALUE)0, loop_stop, (VALUE)0, rb_eStopIteration, (VALUE)0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#Rational;F;7[[@90;[[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;= ;>I" overload;F;?0;;;@0;:I"$Rational(x, y, exception: true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@l;![;"I"@return [nil];T;#0;$@l;.F;Bi;C0;7[[I"x;T0[I"y;T0[I"exception:;TI" true;T;$@lo;= ;>I" overload;F;?0;;;@0;:I"#Rational(arg, exception: true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@l;![;"I"@return [nil];T;#0;$@l;.F;Bi;C0;7[[I"arg;T0[I"exception:;TI" true;T;$@l;![;"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;$@l;.F;/o;0;1T;2i;3i!;%@h;9I"^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;4;5F;6;;;;&I"Kernel#proc;F;7[;[[@iX;T;: proc;0;[;{;IC; "Equivalent to Proc.new. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" proc;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"...;T;$@o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@;![;"I" @yield [...] @return [Proc];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"MEquivalent to Proc.new. @overload proc @yield [...] @return [Proc];T;#0;$@;.F;/o;0;1T;2iQ;3iV;%@h;9I"Qstatic VALUE f_proc(VALUE _) { return proc_new(rb_cProc, FALSE, TRUE); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#lambda;F;7[;[[@i;T;: lambda;0;[;{;IC; "qEquivalent to Proc.new, except the resulting Proc objects check the number of parameters passed when called. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" lambda;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"...;T;$@o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@;![;"I" @yield [...] @return [Proc];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Equivalent to Proc.new, except the resulting Proc objects check the number of parameters passed when called. @overload lambda @yield [...] @return [Proc];T;#0;$@;.F;/o;0;1T;2i;3i;%@h;9I"Zstatic VALUE f_lambda(VALUE _) { f_lambda_warn(); return rb_block_lambda(); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#binding;F;7[;[[@i;T;: binding;0;[;{;IC; "YReturns a +Binding+ object, describing the variable and method bindings at the point of call. This object can be used when calling +eval+ to execute the evaluated command in this environment. See also the description of class +Binding+. def get_binding(param) binding end b = get_binding("hello") eval("param", b) #=> "hello" ;T;[o;= ;>I" overload;F;?0;;;@0;:I" binding;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Binding;T;$@;![;"I"@return [Binding];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a +Binding+ object, describing the variable and method bindings at the point of call. This object can be used when calling +eval+ to execute the evaluated command in this environment. See also the description of class +Binding+. def get_binding(param) binding end b = get_binding("hello") eval("param", b) #=> "hello" @overload binding @return [Binding];T;#0;$@;.F;/o;0;1T;2i;3i;%@h;9I"Kstatic VALUE rb_f_binding(VALUE self) { return rb_binding_new(); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#trap;F;7[[@90;[[I" signal.c;Tio;T;: trap;0;[;{;IC; "Specifies the handling of signals. The first parameter is a signal name (a string such as ``SIGALRM'', ``SIGUSR1'', and so on) or a signal number. The characters ``SIG'' may be omitted from the signal name. The command or block specifies code to be run when the signal is raised. If the command is the string ``IGNORE'' or ``SIG_IGN'', the signal will be ignored. If the command is ``DEFAULT'' or ``SIG_DFL'', the Ruby's default handler will be invoked. If the command is ``EXIT'', the script will be terminated by the signal. If the command is ``SYSTEM_DEFAULT'', the operating system's default handler will be invoked. Otherwise, the given command or block will be run. The special signal name ``EXIT'' or signal number zero will be invoked just prior to program termination. trap returns the previous handler for the given signal. Signal.trap(0, proc { puts "Terminating: #{$$}" }) Signal.trap("CLD") { puts "Child died" } fork && Process.wait produces: Terminating: 27461 Child died Terminating: 27460 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"trap( signal, command );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I" signal;T0[I" command;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"trap( signal );T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I";T;$@o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I" @yield [ ] @return [Object];T;#0;$@;.F;Bi;C0;7[[I" signal;T0;$@;![;"I"xSpecifies the handling of signals. The first parameter is a signal name (a string such as ``SIGALRM'', ``SIGUSR1'', and so on) or a signal number. The characters ``SIG'' may be omitted from the signal name. The command or block specifies code to be run when the signal is raised. If the command is the string ``IGNORE'' or ``SIG_IGN'', the signal will be ignored. If the command is ``DEFAULT'' or ``SIG_DFL'', the Ruby's default handler will be invoked. If the command is ``EXIT'', the script will be terminated by the signal. If the command is ``SYSTEM_DEFAULT'', the operating system's default handler will be invoked. Otherwise, the given command or block will be run. The special signal name ``EXIT'' or signal number zero will be invoked just prior to program termination. trap returns the previous handler for the given signal. Signal.trap(0, proc { puts "Terminating: #{$$}" }) Signal.trap("CLD") { puts "Child died" } fork && Process.wait produces: Terminating: 27461 Child died Terminating: 27460 @overload trap( signal, command ) @return [Object] @overload trap( signal ) @yield [ ] @return [Object];T;#0;$@;.F;/o;0;1T;2iP;3io;%@h;9I"static VALUE sig_trap(int argc, VALUE *argv, VALUE _) { int sig; sighandler_t func; VALUE cmd; rb_check_arity(argc, 1, 2); sig = trap_signm(argv[0]); if (reserved_signal_p(sig)) { const char *name = signo2signm(sig); if (name) rb_raise(rb_eArgError, "can't trap reserved signal: SIG%s", name); else rb_raise(rb_eArgError, "can't trap reserved signal: %d", sig); } if (argc == 1) { cmd = rb_block_proc(); func = sighandler; } else { cmd = argv[1]; func = trap_handler(&cmd, sig); } if (rb_obj_is_proc(cmd) && !rb_ractor_main_p() && !rb_ractor_shareable_p(cmd)) { cmd = rb_proc_isolate(cmd); } return trap(sig, func, cmd); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#test;F;7[[@90;[[I" file.c;Ti ;T;: test;0;[;{;IC; " Uses the character +cmd+ to perform various tests on +file1+ (first table below) or on +file1+ and +file2+ (second table). File tests on a single file: Cmd Returns Meaning "A" | Time | Last access time for file1 "b" | boolean | True if file1 is a block device "c" | boolean | True if file1 is a character device "C" | Time | Last change time for file1 "d" | boolean | True if file1 exists and is a directory "e" | boolean | True if file1 exists "f" | boolean | True if file1 exists and is a regular file "g" | boolean | True if file1 has the \CF{setgid} bit | | set (false under NT) "G" | boolean | True if file1 exists and has a group | | ownership equal to the caller's group "k" | boolean | True if file1 exists and has the sticky bit set "l" | boolean | True if file1 exists and is a symbolic link "M" | Time | Last modification time for file1 "o" | boolean | True if file1 exists and is owned by | | the caller's effective uid "O" | boolean | True if file1 exists and is owned by | | the caller's real uid "p" | boolean | True if file1 exists and is a fifo "r" | boolean | True if file1 is readable by the effective | | uid/gid of the caller "R" | boolean | True if file is readable by the real | | uid/gid of the caller "s" | int/nil | If file1 has nonzero size, return the size, | | otherwise return nil "S" | boolean | True if file1 exists and is a socket "u" | boolean | True if file1 has the setuid bit set "w" | boolean | True if file1 exists and is writable by | | the effective uid/gid "W" | boolean | True if file1 exists and is writable by | | the real uid/gid "x" | boolean | True if file1 exists and is executable by | | the effective uid/gid "X" | boolean | True if file1 exists and is executable by | | the real uid/gid "z" | boolean | True if file1 exists and has a zero length Tests that take two files: "-" | boolean | True if file1 and file2 are identical "=" | boolean | True if the modification times of file1 | | and file2 are equal "<" | boolean | True if the modification time of file1 | | is prior to that of file2 ">" | boolean | True if the modification time of file1 | | is after that of file2 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" test(cmd, file1 [, file2] );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@2;![;"I"@return [Object];T;#0;$@2;.F;Bi;C0;7[[I"cmd;T0[I"file1[, file2];T0;$@2;![;"I" Uses the character +cmd+ to perform various tests on +file1+ (first table below) or on +file1+ and +file2+ (second table). File tests on a single file: Cmd Returns Meaning "A" | Time | Last access time for file1 "b" | boolean | True if file1 is a block device "c" | boolean | True if file1 is a character device "C" | Time | Last change time for file1 "d" | boolean | True if file1 exists and is a directory "e" | boolean | True if file1 exists "f" | boolean | True if file1 exists and is a regular file "g" | boolean | True if file1 has the \CF{setgid} bit | | set (false under NT) "G" | boolean | True if file1 exists and has a group | | ownership equal to the caller's group "k" | boolean | True if file1 exists and has the sticky bit set "l" | boolean | True if file1 exists and is a symbolic link "M" | Time | Last modification time for file1 "o" | boolean | True if file1 exists and is owned by | | the caller's effective uid "O" | boolean | True if file1 exists and is owned by | | the caller's real uid "p" | boolean | True if file1 exists and is a fifo "r" | boolean | True if file1 is readable by the effective | | uid/gid of the caller "R" | boolean | True if file is readable by the real | | uid/gid of the caller "s" | int/nil | If file1 has nonzero size, return the size, | | otherwise return nil "S" | boolean | True if file1 exists and is a socket "u" | boolean | True if file1 has the setuid bit set "w" | boolean | True if file1 exists and is writable by | | the effective uid/gid "W" | boolean | True if file1 exists and is writable by | | the real uid/gid "x" | boolean | True if file1 exists and is executable by | | the effective uid/gid "X" | boolean | True if file1 exists and is executable by | | the real uid/gid "z" | boolean | True if file1 exists and has a zero length Tests that take two files: "-" | boolean | True if file1 and file2 are identical "=" | boolean | True if the modification times of file1 | | and file2 are equal "<" | boolean | True if the modification time of file1 | | is prior to that of file2 ">" | boolean | True if the modification time of file1 | | is after that of file2 @overload test(cmd, file1 [, file2] ) @return [Object];T;#0;$@2;.F;/o;0;1T;2i;3i;%@h;9I" static VALUE rb_f_test(int argc, VALUE *argv, VALUE _) { int cmd; if (argc == 0) rb_check_arity(argc, 2, 3); cmd = NUM2CHR(argv[0]); if (cmd == 0) { goto unknown; } if (strchr("bcdefgGkloOprRsSuwWxXz", cmd)) { CHECK(1); switch (cmd) { case 'b': return rb_file_blockdev_p(0, argv[1]); case 'c': return rb_file_chardev_p(0, argv[1]); case 'd': return rb_file_directory_p(0, argv[1]); case 'e': return rb_file_exist_p(0, argv[1]); case 'f': return rb_file_file_p(0, argv[1]); case 'g': return rb_file_sgid_p(0, argv[1]); case 'G': return rb_file_grpowned_p(0, argv[1]); case 'k': return rb_file_sticky_p(0, argv[1]); case 'l': return rb_file_symlink_p(0, argv[1]); case 'o': return rb_file_owned_p(0, argv[1]); case 'O': return rb_file_rowned_p(0, argv[1]); case 'p': return rb_file_pipe_p(0, argv[1]); case 'r': return rb_file_readable_p(0, argv[1]); case 'R': return rb_file_readable_real_p(0, argv[1]); case 's': return rb_file_size_p(0, argv[1]); case 'S': return rb_file_socket_p(0, argv[1]); case 'u': return rb_file_suid_p(0, argv[1]); case 'w': return rb_file_writable_p(0, argv[1]); case 'W': return rb_file_writable_real_p(0, argv[1]); case 'x': return rb_file_executable_p(0, argv[1]); case 'X': return rb_file_executable_real_p(0, argv[1]); case 'z': return rb_file_zero_p(0, argv[1]); } } if (strchr("MAC", cmd)) { struct stat st; VALUE fname = argv[1]; CHECK(1); if (rb_stat(fname, &st) == -1) { int e = errno; FilePathValue(fname); rb_syserr_fail_path(e, fname); } switch (cmd) { case 'A': return stat_atime(&st); case 'M': return stat_mtime(&st); case 'C': return stat_ctime(&st); } } if (cmd == '-') { CHECK(2); return rb_file_identical_p(0, argv[1], argv[2]); } if (strchr("=<>", cmd)) { struct stat st1, st2; struct timespec t1, t2; CHECK(2); if (rb_stat(argv[1], &st1) < 0) return Qfalse; if (rb_stat(argv[2], &st2) < 0) return Qfalse; t1 = stat_mtimespec(&st1); t2 = stat_mtimespec(&st2); switch (cmd) { case '=': if (t1.tv_sec == t2.tv_sec && t1.tv_nsec == t2.tv_nsec) return Qtrue; return Qfalse; case '>': if (t1.tv_sec > t2.tv_sec) return Qtrue; if (t1.tv_sec == t2.tv_sec && t1.tv_nsec > t2.tv_nsec) return Qtrue; return Qfalse; case '<': if (t1.tv_sec < t2.tv_sec) return Qtrue; if (t1.tv_sec == t2.tv_sec && t1.tv_nsec < t2.tv_nsec) return Qtrue; return Qfalse; } } unknown: /* unknown command */ if (ISPRINT(cmd)) { rb_raise(rb_eArgError, "unknown command '%s%c'", cmd == '\'' || cmd == '\\' ? "\\" : "", cmd); } else { rb_raise(rb_eArgError, "unknown command \"\\x%02X\"", cmd); } UNREACHABLE_RETURN(Qundef); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#load;F;7[[@90;[[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. If the optional _wrap_ parameter is a module, the loaded script will be executed under the given module. In no circumstance will any local variables in the loaded file be propagated to the loading environment. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"load(filename, wrap=false);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;T;$@S;![;"I"@return [true];T;#0;$@S;.F;Bi;C0;7[[I" filename;T0[I" wrap;TI" false;T;$@S;![;"I"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. If the optional _wrap_ parameter is a module, the loaded script will be executed under the given module. 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;$@S;.F;/o;0;1T;2i;3i;%@h;9I"8static 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, wrap); RUBY_DTRACE_HOOK(LOAD_RETURN, RSTRING_PTR(orig_fname)); return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#require;F;7[[I" fname;T0;[[@Yi;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;= ;>I" overload;F;?0;;;@0;:I"require(name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@u;![;"I"@return [Boolean];T;#0;$@u;.F;Bi;C0;7[[I" name;T0;$@u;![;"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;$@u;.F;/o;0;1T;2i_;3i;%@h;9I"XVALUE rb_f_require(VALUE obj, VALUE fname) { return rb_require_string(fname); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Kernel#require_relative;F;7[[I" fname;T0;[[@Yi;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;= ;>I" overload;F;?0;;;@0;:I"require_relative(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" string;T0;$@;![;"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;$@;.F;/o;0;1T;2i;3i;%@h;9I" 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;4;5F;6;;;;&I"Kernel#autoload;F;7[[I"sym;T0[I" file;T0;[[@Yi=;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;= ;>I" overload;F;?0;;;@0;:I"autoload(module, filename);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"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;0;1T;2i2;3i:;%@h;9I"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;4;5F;6;;;;&I"Kernel#autoload?;F;7[[@90;[[@YiR;T;:autoload?;0;[;{;IC; "Returns _filename_ to be loaded if _name_ is registered as +autoload+. autoload(:B, "b") autoload?(:B) #=> "b";T;[o;= ;>I" overload;F;?0;;;@0;:I""autoload?(name, inherit=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@;![;"I"@return [String, nil];T;#0;$@;.F;Bi;C0;7[[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;0;1T;2iG;3iO;Bi;%@h;9I"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;4;5F;6;;;;&I"Kernel#set_trace_func;F;7[[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 Note that for +c-call+ and +c-return+ events, the binding returned is the binding of the nearest Ruby method calling the C method, since C methods themselves do not have bindings. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"set_trace_func(proc);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@;![;"I"@return [Proc];T;#0;$@;.F;Bi;C0;7[[I" proc;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"set_trace_func(nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[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 Note that for +c-call+ and +c-return+ events, the binding returned is the binding of the nearest Ruby method calling the C method, since C methods themselves do not have bindings. @overload set_trace_func(proc) @return [Proc] @overload set_trace_func(nil) @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i);%@h;9I"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;4;5F;6;;;;&I"Kernel#callcc;F;7[;[[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;= ;>I" overload;F;?0;;;@0;:I" callcc;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" cont;T;$@#o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@#;![;"I"#@yield [cont] @return [Object];T;#0;$@#;.F;Bi;C0;7[;$@#;![;"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;0;1T;2i;3i;%@h;9I"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;4;5F;6;;;;&I"(Kernel#register_sample_bug_reporter;F;7[[I"obj;T0;[[I"+ext/-test-/bug_reporter/bug_reporter.c;Ti;T;:!register_sample_bug_reporter;0;[;{;IC; " ;T;[;![;"@;#0;$@D;%@h;9I"static VALUE register_sample_bug_reporter(VALUE self, VALUE obj) { rb_bug_reporter_add(sample_bug_reporter, (void *)(uintptr_t)NUM2INT(obj)); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#Pathname;F;7[[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;$@S;.F;/o;0;1T;2i;3i(;%@h;9I"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;4;5F;6;;;;&I"Kernel#trace_var;F;7[[I"*a;T0[I"_;T0;[[@Oii;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;= ;>I" overload;F;?0;;;@0;:I"trace_var(symbol, cmd );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@d;![;"I"@return [nil];T;#0;$@d;.F;Bi;C0;7[[I" symbol;T0[I"cmd;T0;$@do;= ;>I" overload;F;?0;;;@0;:I"trace_var(symbol);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"val;T;$@do;A ;>I" return;F;?I";T;0;@[I"nil;T;$@d;![;"I"@yield [val] @return [nil];T;#0;$@d;.F;Bi;C0;7[[I" symbol;T0;$@d;![;"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;$@d;.F;/o;0;1T;2iR;3ih;%@h;9I"bstatic VALUE f_trace_var(int c, const VALUE *a, VALUE _) { return rb_f_trace_var(c, a); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Kernel#untrace_var;F;7[[I"*a;T0[I"_;T0;[[@Oiy;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;= ;>I" overload;F;?0;;;@0;:I"!untrace_var(symbol [, cmd] );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;TI"nil;T;$@;![;"I"@return [Array, nil];T;#0;$@;.F;Bi;C0;7[[I"symbol[, cmd];T0;$@;![;"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;$@;.F;/o;0;1T;2io;3iv;%@h;9I"fstatic VALUE f_untrace_var(int c, const VALUE *a, VALUE _) { return rb_f_untrace_var(c, a); };T;:I"static VALUE;T;;T; @h; IC;[; @h; IC;[; @h; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ "1.2" == What's Here \Module \Kernel provides methods that are useful for: - {Converting}[#module-Kernel-label-Converting] - {Querying}[#module-Kernel-label-Querying] - {Exiting}[#module-Kernel-label-Exiting] - {Exceptions}[#module-Kernel-label-Exceptions] - {IO}[#module-Kernel-label-IO] - {Procs}[#module-Kernel-label-Procs] - {Tracing}[#module-Kernel-label-Tracing] - {Subprocesses}[#module-Kernel-label-Subprocesses] - {Loading}[#module-Kernel-label-Loading] - {Yielding}[#module-Kernel-label-Yielding] - {Random Values}[#module-Kernel-label-Random+Values] - {Other}[#module-Kernel-label-Other] === Converting - {#Array}[#method-i-Array]:: Returns an Array based on the given argument. - {#Complex}[#method-i-Complex]:: Returns a Complex based on the given arguments. - {#Float}[#method-i-Float]:: Returns a Float based on the given arguments. - {#Hash}[#method-i-Hash]:: Returns a Hash based on the given argument. - {#Integer}[#method-i-Integer]:: Returns an Integer based on the given arguments. - {#Rational}[#method-i-Rational]:: Returns a Rational based on the given arguments. - {#String}[#method-i-String]:: Returns a String based on the given argument. === Querying - {#__callee__}[#method-i-__callee__]:: Returns the called name of the current method as a symbol. - {#__dir__}[#method-i-__dir__]:: Returns the path to the directory from which the current method is called. - {#__method__}[#method-i-__method__]:: Returns the name of the current method as a symbol. - #autoload?:: Returns the file to be loaded when the given module is referenced. - #binding:: Returns a Binding for the context at the point of call. - #block_given?:: Returns +true+ if a block was passed to the calling method. - #caller:: Returns the current execution stack as an array of strings. - #caller_locations:: Returns the current execution stack as an array of Thread::Backtrace::Location objects. - #class:: Returns the class of +self+. - #frozen?:: Returns whether +self+ is frozen. - #global_variables:: Returns an array of global variables as symbols. - #local_variables:: Returns an array of local variables as symbols. - #test:: Performs specified tests on the given single file or pair of files. === Exiting - #abort:: Exits the current process after printing the given arguments. - #at_exit:: Executes the given block when the process exits. - #exit:: Exits the current process after calling any registered +at_exit+ handlers. - #exit!:: Exits the current process without calling any registered +at_exit+ handlers. === Exceptions - #catch:: Executes the given block, possibly catching a thrown object. - #raise (aliased as #fail):: Raises an exception based on the given arguments. - #throw:: Returns from the active catch block waiting for the given tag. === \IO - #gets:: Returns and assigns to $_ the next line from the current input. - #open:: Creates an IO object connected to the given stream, file, or subprocess. - #p:: Prints the given objects' inspect output to the standard output. - #pp:: Prints the given objects in pretty form. - #print:: Prints the given objects to standard output without a newline. - #printf:: Prints the string resulting from applying the given format string to any additional arguments. - #putc:: Equivalent to for the given object. - #puts:: Equivalent to $stdout.puts(*objects) for the given objects. - #readline:: Similar to #gets, but raises an exception at the end of file. - #readlines:: Returns an array of the remaining lines from the current input. - #select:: Same as IO.select. === Procs - #lambda:: Returns a lambda proc for the given block. - #proc:: Returns a new Proc; equivalent to Proc.new. === Tracing - #set_trace_func:: Sets the given proc as the handler for tracing, or disables tracing if given +nil+. - #trace_var:: Starts tracing assignments to the given global variable. - #untrace_var:: Disables tracing of assignments to the given global variable. === Subprocesses - #`cmd`:: Returns the standard output of running +cmd+ in a subshell. - #exec:: Replaces current process with a new process. - #fork:: Forks the current process into two processes. - #spawn:: Executes the given command and returns its pid without waiting for completion. - #system:: Executes the given command in a subshell. === Loading - #autoload:: Registers the given file to be loaded when the given constant is first referenced. - #load:: Loads the given Ruby file. - #require:: Loads the given Ruby file unless it has already been loaded. - #require_relative:: Loads the Ruby file path relative to the calling file, unless it has already been loaded. === Yielding - #tap:: Yields +self+ to the given block; returns +self+. - #then (aliased as #yield_self):: Yields +self+ to the block and returns the result of the block. === \Random Values - #rand:: Returns a pseudo-random floating point number strictly between 0.0 and 1.0. - #srand:: Seeds the pseudo-random number generator with the given number. === Other - #eval:: Evaluates the given string as Ruby code. - #loop:: Repeatedly executes the given block. - #sleep:: Suspends the current thread for the given number of seconds. - #sprintf (aliased as #format):: Returns the string resulting from applying the given format string to any additional arguments. - #syscall:: Runs an operating system call. - #trap:: Specifies the handling of system signals. - #warn:: Issue a warning based on the given messages and options.;T;[;![;"I"3 The Kernel module is included by class Object, so its methods are available in every Ruby object. The Kernel instance methods are documented in class Object while the module methods are documented here. These methods are called without a receiver and thus can be called in functional form: sprintf "%.1f", 1.234 #=> "1.2" == What's Here \Module \Kernel provides methods that are useful for: - {Converting}[#module-Kernel-label-Converting] - {Querying}[#module-Kernel-label-Querying] - {Exiting}[#module-Kernel-label-Exiting] - {Exceptions}[#module-Kernel-label-Exceptions] - {IO}[#module-Kernel-label-IO] - {Procs}[#module-Kernel-label-Procs] - {Tracing}[#module-Kernel-label-Tracing] - {Subprocesses}[#module-Kernel-label-Subprocesses] - {Loading}[#module-Kernel-label-Loading] - {Yielding}[#module-Kernel-label-Yielding] - {Random Values}[#module-Kernel-label-Random+Values] - {Other}[#module-Kernel-label-Other] === Converting - {#Array}[#method-i-Array]:: Returns an Array based on the given argument. - {#Complex}[#method-i-Complex]:: Returns a Complex based on the given arguments. - {#Float}[#method-i-Float]:: Returns a Float based on the given arguments. - {#Hash}[#method-i-Hash]:: Returns a Hash based on the given argument. - {#Integer}[#method-i-Integer]:: Returns an Integer based on the given arguments. - {#Rational}[#method-i-Rational]:: Returns a Rational based on the given arguments. - {#String}[#method-i-String]:: Returns a String based on the given argument. === Querying - {#__callee__}[#method-i-__callee__]:: Returns the called name of the current method as a symbol. - {#__dir__}[#method-i-__dir__]:: Returns the path to the directory from which the current method is called. - {#__method__}[#method-i-__method__]:: Returns the name of the current method as a symbol. - #autoload?:: Returns the file to be loaded when the given module is referenced. - #binding:: Returns a Binding for the context at the point of call. - #block_given?:: Returns +true+ if a block was passed to the calling method. - #caller:: Returns the current execution stack as an array of strings. - #caller_locations:: Returns the current execution stack as an array of Thread::Backtrace::Location objects. - #class:: Returns the class of +self+. - #frozen?:: Returns whether +self+ is frozen. - #global_variables:: Returns an array of global variables as symbols. - #local_variables:: Returns an array of local variables as symbols. - #test:: Performs specified tests on the given single file or pair of files. === Exiting - #abort:: Exits the current process after printing the given arguments. - #at_exit:: Executes the given block when the process exits. - #exit:: Exits the current process after calling any registered +at_exit+ handlers. - #exit!:: Exits the current process without calling any registered +at_exit+ handlers. === Exceptions - #catch:: Executes the given block, possibly catching a thrown object. - #raise (aliased as #fail):: Raises an exception based on the given arguments. - #throw:: Returns from the active catch block waiting for the given tag. === \IO - #gets:: Returns and assigns to $_ the next line from the current input. - #open:: Creates an IO object connected to the given stream, file, or subprocess. - #p:: Prints the given objects' inspect output to the standard output. - #pp:: Prints the given objects in pretty form. - #print:: Prints the given objects to standard output without a newline. - #printf:: Prints the string resulting from applying the given format string to any additional arguments. - #putc:: Equivalent to for the given object. - #puts:: Equivalent to $stdout.puts(*objects) for the given objects. - #readline:: Similar to #gets, but raises an exception at the end of file. - #readlines:: Returns an array of the remaining lines from the current input. - #select:: Same as IO.select. === Procs - #lambda:: Returns a lambda proc for the given block. - #proc:: Returns a new Proc; equivalent to Proc.new. === Tracing - #set_trace_func:: Sets the given proc as the handler for tracing, or disables tracing if given +nil+. - #trace_var:: Starts tracing assignments to the given global variable. - #untrace_var:: Disables tracing of assignments to the given global variable. === Subprocesses - #`cmd`:: Returns the standard output of running +cmd+ in a subshell. - #exec:: Replaces current process with a new process. - #fork:: Forks the current process into two processes. - #spawn:: Executes the given command and returns its pid without waiting for completion. - #system:: Executes the given command in a subshell. === Loading - #autoload:: Registers the given file to be loaded when the given constant is first referenced. - #load:: Loads the given Ruby file. - #require:: Loads the given Ruby file unless it has already been loaded. - #require_relative:: Loads the Ruby file path relative to the calling file, unless it has already been loaded. === Yielding - #tap:: Yields +self+ to the given block; returns +self+. - #then (aliased as #yield_self):: Yields +self+ to the block and returns the result of the block. === \Random Values - #rand:: Returns a pseudo-random floating point number strictly between 0.0 and 1.0. - #srand:: Seeds the pseudo-random number generator with the given number. === Other - #eval:: Evaluates the given string as Ruby code. - #loop:: Repeatedly executes the given block. - #sleep:: Suspends the current thread for the given number of seconds. - #sprintf (aliased as #format):: Returns the string resulting from applying the given format string to any additional arguments. - #syscall:: Runs an operating system call. - #trap:: Specifies the handling of system signals. - #warn:: Issue a warning based on the given messages and options. ;T;#0;$@h;.F;/o;0;1T;2i;3i;Bi;%@;&I" Kernel;F; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@symbol refers to a symbol, which is either a quoted string or a Symbol (such as :name). == What's Here First, what's elsewhere. \Class \Object: - Inherits from {class BasicObject}[BasicObject.html#class-BasicObject-label-What-27s+Here]. - Includes {module Kernel}[Kernel.html#module-Kernel-label-What-27s+Here]. Here, class \Object provides methods for: - {Querying}[#class-Object-label-Querying] - {Instance Variables}[#class-Object-label-Instance+Variables] - {Other}[#class-Object-label-Other] === Querying - {!~}[#method-i-21~]:: Returns +true+ if +self+ does not match the given object, otherwise +false+. - {<=>}[#method-i-3C-3D-3E]:: Returns 0 if +self+ and the given object +object+ are the same object, or if self == object; otherwise returns +nil+. - #===:: Implements case equality, effectively the same as calling #==. - #eql?:: Implements hash equality, effectively the same as calling #==. - #kind_of? (aliased as #is_a?):: Returns whether given argument is an ancestor of the singleton class of +self+. - #instance_of?:: Returns whether +self+ is an instance of the given class. - #instance_variable_defined?:: Returns whether the given instance variable is defined in +self+. - #method:: Returns the Method object for the given method in +self+. - #methods:: Returns an array of symbol names of public and protected methods in +self+. - #nil?:: Returns +false+. (Only +nil+ responds +true+ to method nil?.) - #object_id:: Returns an integer corresponding to +self+ that is unique for the current process - #private_methods:: Returns an array of the symbol names of the private methods in +self+. - #protected_methods:: Returns an array of the symbol names of the protected methods in +self+. - #public_method:: Returns the Method object for the given public method in +self+. - #public_methods:: Returns an array of the symbol names of the public methods in +self+. - #respond_to?:: Returns whether +self+ responds to the given method. - #singleton_class:: Returns the singleton class of +self+. - #singleton_method:: Returns the Method object for the given singleton method in +self+. - #singleton_methods:: Returns an array of the symbol names of the singleton methods in +self+. - #define_singleton_method:: Defines a singleton method in +self+ for the given symbol method-name and block or proc. - #extend:: Includes the given modules in the singleton class of +self+. - #public_send:: Calls the given public method in +self+ with the given argument. - #send:: Calls the given method in +self+ with the given argument. === Instance Variables - #instance_variable_get:: Returns the value of the given instance variable in +self+, or +nil+ if the instance variable is not set. - #instance_variable_set:: Sets the value of the given instance variable in +self+ to the given object. - #instance_variables:: Returns an array of the symbol names of the instance variables in +self+. - #remove_instance_variable:: Removes the named instance variable from +self+. === Other - #clone:: Returns a shallow copy of +self+, including singleton class and frozen state. - #define_singleton_method:: Defines a singleton method in +self+ for the given symbol method-name and block or proc. - #display:: Prints +self+ to the given \IO stream or $stdout. - #dup:: Returns a shallow unfrozen copy of +self+. - #enum_for (aliased as #to_enum):: Returns an Enumerator for +self+ using the using the given method, arguments, and block. - #extend:: Includes the given modules in the singleton class of +self+. - #freeze:: Prevents further modifications to +self+. - #hash:: Returns the integer hash value for +self+. - #inspect:: Returns a human-readable string representation of +self+. - #itself:: Returns +self+. - #public_send:: Calls the given public method in +self+ with the given argument. - #send:: Calls the given method in +self+ with the given argument. - #to_s:: Returns a string representation of +self+.;T;[;![;"I"- Object is the default root of all Ruby objects. Object inherits from BasicObject which allows creating alternate object hierarchies. Methods on Object are available to all classes unless explicitly overridden. Object mixes in the Kernel module, making the built-in kernel functions globally accessible. Although the instance methods of Object are defined by the Kernel module, we have chosen to document them here for clarity. When referencing constants in classes inheriting from Object you do not need to use the full namespace. For example, referencing +File+ inside +YourClass+ will find the top-level File class. In the descriptions of Object's methods, the parameter symbol refers to a symbol, which is either a quoted string or a Symbol (such as :name). == What's Here First, what's elsewhere. \Class \Object: - Inherits from {class BasicObject}[BasicObject.html#class-BasicObject-label-What-27s+Here]. - Includes {module Kernel}[Kernel.html#module-Kernel-label-What-27s+Here]. Here, class \Object provides methods for: - {Querying}[#class-Object-label-Querying] - {Instance Variables}[#class-Object-label-Instance+Variables] - {Other}[#class-Object-label-Other] === Querying - {!~}[#method-i-21~]:: Returns +true+ if +self+ does not match the given object, otherwise +false+. - {<=>}[#method-i-3C-3D-3E]:: Returns 0 if +self+ and the given object +object+ are the same object, or if self == object; otherwise returns +nil+. - #===:: Implements case equality, effectively the same as calling #==. - #eql?:: Implements hash equality, effectively the same as calling #==. - #kind_of? (aliased as #is_a?):: Returns whether given argument is an ancestor of the singleton class of +self+. - #instance_of?:: Returns whether +self+ is an instance of the given class. - #instance_variable_defined?:: Returns whether the given instance variable is defined in +self+. - #method:: Returns the Method object for the given method in +self+. - #methods:: Returns an array of symbol names of public and protected methods in +self+. - #nil?:: Returns +false+. (Only +nil+ responds +true+ to method nil?.) - #object_id:: Returns an integer corresponding to +self+ that is unique for the current process - #private_methods:: Returns an array of the symbol names of the private methods in +self+. - #protected_methods:: Returns an array of the symbol names of the protected methods in +self+. - #public_method:: Returns the Method object for the given public method in +self+. - #public_methods:: Returns an array of the symbol names of the public methods in +self+. - #respond_to?:: Returns whether +self+ responds to the given method. - #singleton_class:: Returns the singleton class of +self+. - #singleton_method:: Returns the Method object for the given singleton method in +self+. - #singleton_methods:: Returns an array of the symbol names of the singleton methods in +self+. - #define_singleton_method:: Defines a singleton method in +self+ for the given symbol method-name and block or proc. - #extend:: Includes the given modules in the singleton class of +self+. - #public_send:: Calls the given public method in +self+ with the given argument. - #send:: Calls the given method in +self+ with the given argument. === Instance Variables - #instance_variable_get:: Returns the value of the given instance variable in +self+, or +nil+ if the instance variable is not set. - #instance_variable_set:: Sets the value of the given instance variable in +self+ to the given object. - #instance_variables:: Returns an array of the symbol names of the instance variables in +self+. - #remove_instance_variable:: Removes the named instance variable from +self+. === Other - #clone:: Returns a shallow copy of +self+, including singleton class and frozen state. - #define_singleton_method:: Defines a singleton method in +self+ for the given symbol method-name and block or proc. - #display:: Prints +self+ to the given \IO stream or $stdout. - #dup:: Returns a shallow unfrozen copy of +self+. - #enum_for (aliased as #to_enum):: Returns an Enumerator for +self+ using the using the given method, arguments, and block. - #extend:: Includes the given modules in the singleton class of +self+. - #freeze:: Prevents further modifications to +self+. - #hash:: Returns the integer hash value for +self+. - #inspect:: Returns a human-readable string representation of +self+. - #itself:: Returns +self+. - #public_send:: Calls the given public method in +self+ with the given argument. - #send:: Calls the given method in +self+ with the given argument. - #to_s:: Returns a string representation of +self+. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;&I" Object;F;'o; ;IC;[o;4;5F;6;;: private;&I"BasicObject#initialize;F;7[;[;F;;D;;;[;{;IC; "=call-seq: BasicObject.new Returns a new BasicObject. ;T;[;![;"I"? call-seq: BasicObject.new Returns a new BasicObject. ;T;#0;$@;.F;/o;0;1T;2i/;3i4;%@;;To;4;5F;6;;;;&I"BasicObject#==;F;7[[I" obj2;T0;[[@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;= ;>I" overload;F;?0;;F;@0;:I"==(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" other;T0;$@o;= ;>I" overload;F;?0;;W;@0;:I"equal?(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" other;T0;$@o;= ;>I" overload;F;?0;;V;@0;:I"eql?(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" other;T0;$@;![;"@;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"fMJIT_FUNC_EXPORTED VALUE rb_obj_equal(VALUE obj1, VALUE obj2) { return RBOOL(obj1 == obj2); };T;:I"MJIT_FUNC_EXPORTED VALUE;T;;To;4;5F;6;;;;&I"BasicObject#equal?;F;7[[I" obj2;T0;[[@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;= ;>I" overload;F;?0;;F;@0;:I"==(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@);![;"I"@return [Boolean];T;#0;$@);.F;Bi;C0;7[[I" other;T0;$@)o;= ;>I" overload;F;?0;;W;@0;:I"equal?(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@);![;"I"@return [Boolean];T;#0;$@);.F;Bi;C0;7[[I" other;T0;$@)o;= ;>I" overload;F;?0;;V;@0;:I"eql?(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@);![;"I"@return [Boolean];T;#0;$@);.F;Bi;C0;7[[I" other;T0;$@);![;"@;#0;$@);.F;/o;0;1T;2i;3i;Bi;%@;9I"fMJIT_FUNC_EXPORTED VALUE rb_obj_equal(VALUE obj1, VALUE obj2) { return RBOOL(obj1 == obj2); };T;:I"MJIT_FUNC_EXPORTED VALUE;T;;To;4;5F;6;;;;&I"BasicObject#!;F;7[;[[@I" overload;F;?0;;;@0;:I" !obj;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@e;![;"I"@return [Boolean];T;#0;$@e;.F;Bi;C0;7[;$@e;![;"I":Boolean negate. @overload !obj @return [Boolean];T;#0;$@e;.F;/o;0;1T;2i;3i;%@;9I"_MJIT_FUNC_EXPORTED VALUE rb_obj_not(VALUE obj) { return RTEST(obj) ? Qfalse : Qtrue; };T;:I"MJIT_FUNC_EXPORTED VALUE;T;;To;4;5F;6;;;;&I"BasicObject#!=;F;7[[I" obj2;T0;[[@I" overload;F;?0;;;@0;:I"!=(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" other;T0;$@;![;"I"kReturns true if two objects are not-equal, otherwise false. @overload !=(other) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"MJIT_FUNC_EXPORTED VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2) { VALUE result = rb_funcall(obj1, id_eq, 1, obj2); return RTEST(result) ? Qfalse : Qtrue; };T;:I"MJIT_FUNC_EXPORTED VALUE;T;;To;4;5F;6;;;;&I"'BasicObject#singleton_method_added;F;7[;[;F;:singleton_method_added;;;[;{;IC; "call-seq: singleton_method_added(symbol) Invoked as a callback whenever a singleton method is added to the receiver. module Chatty def Chatty.singleton_method_added(id) puts "Adding #{id.id2name}" end def self.one() end def two() end def Chatty.three() end end produces: Adding singleton_method_added Adding one Adding three ;T;[;![;"I" call-seq: singleton_method_added(symbol) Invoked as a callback whenever a singleton method is added to the receiver. module Chatty def Chatty.singleton_method_added(id) puts "Adding #{id.id2name}" end def self.one() end def two() end def Chatty.three() end end produces: Adding singleton_method_added Adding one Adding three ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I")BasicObject#singleton_method_removed;F;7[;[;F;:singleton_method_removed;;;[;{;IC; "call-seq: singleton_method_removed(symbol) Invoked as a callback whenever a singleton method is removed from the receiver. module Chatty def Chatty.singleton_method_removed(id) puts "Removing #{id.id2name}" end def self.one() end def two() end def Chatty.three() end class << self remove_method :three remove_method :one end end produces: Removing three Removing one ;T;[;![;"I" call-seq: singleton_method_removed(symbol) Invoked as a callback whenever a singleton method is removed from the receiver. module Chatty def Chatty.singleton_method_removed(id) puts "Removing #{id.id2name}" end def self.one() end def two() end def Chatty.three() end class << self remove_method :three remove_method :one end end produces: Removing three Removing one ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"+BasicObject#singleton_method_undefined;F;7[;[;F;:singleton_method_undefined;;;[;{;IC; "call-seq: singleton_method_undefined(symbol) Invoked as a callback whenever a singleton method is undefined in the receiver. module Chatty def Chatty.singleton_method_undefined(id) puts "Undefining #{id.id2name}" end def Chatty.one() end class << self undef_method(:one) end end produces: Undefining one ;T;[;![;"I" call-seq: singleton_method_undefined(symbol) Invoked as a callback whenever a singleton method is undefined in the receiver. module Chatty def Chatty.singleton_method_undefined(id) puts "Undefining #{id.id2name}" end def Chatty.one() end class << self undef_method(:one) end end produces: Undefining one ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"BasicObject#instance_eval;F;7[[@90;[[@Ci;T;:instance_eval;0;[;{;IC; "Evaluates a string containing Ruby source code, or the given block, within the context of the receiver (_obj_). In order to set the context, the variable +self+ is set to _obj_ while the code is executing, giving the code access to _obj_'s instance variables and private methods. When instance_eval is given a block, _obj_ is also passed in as the block's only argument. When instance_eval is given a +String+, the optional second and third parameters supply a filename and starting line number that are used when reporting compilation errors. class KlassWithSecret def initialize @secret = 99 end private def the_secret "Ssssh! The secret is #{@secret}." end end k = KlassWithSecret.new k.instance_eval { @secret } #=> 99 k.instance_eval { the_secret } #=> "Ssssh! The secret is 99." k.instance_eval {|obj| obj == self } #=> true ;T;[o;= ;>I" overload;F;?0;;;@0;:I"3instance_eval(string [, filename [, lineno]] );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I""string[, filename [, lineno]];T0;$@o;= ;>I" overload;F;?0;;;@0;:I"instance_eval;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I""@yield [obj] @return [Object];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"+Evaluates a string containing Ruby source code, or the given block, within the context of the receiver (_obj_). In order to set the context, the variable +self+ is set to _obj_ while the code is executing, giving the code access to _obj_'s instance variables and private methods. When instance_eval is given a block, _obj_ is also passed in as the block's only argument. When instance_eval is given a +String+, the optional second and third parameters supply a filename and starting line number that are used when reporting compilation errors. class KlassWithSecret def initialize @secret = 99 end private def the_secret "Ssssh! The secret is #{@secret}." end end k = KlassWithSecret.new k.instance_eval { @secret } #=> 99 k.instance_eval { the_secret } #=> "Ssssh! The secret is 99." k.instance_eval {|obj| obj == self } #=> true @overload instance_eval(string [, filename [, lineno]] ) @return [Object] @overload instance_eval @yield [obj] @return [Object];T;#0;$@;.F;/o;0;1T;2i;3i ;%@;9I"static VALUE rb_obj_instance_eval_internal(int argc, const VALUE *argv, VALUE self) { return specific_eval(argc, argv, self, TRUE, RB_PASS_CALLED_KEYWORDS); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BasicObject#instance_exec;F;7[[@90;[[@Ci,;T;:instance_exec;0;[;{;IC; "Executes the given block within the context of the receiver (_obj_). In order to set the context, the variable +self+ is set to _obj_ while the code is executing, giving the code access to _obj_'s instance variables. Arguments are passed as block parameters. class KlassWithSecret def initialize @secret = 99 end end k = KlassWithSecret.new k.instance_exec(5) {|x| @secret+x } #=> 104 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"instance_exec(arg...);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" var...;T;$@o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"%@yield [var...] @return [Object];T;#0;$@;.F;Bi;C0;7[[I" arg...;T0;$@;![;"I"Executes the given block within the context of the receiver (_obj_). In order to set the context, the variable +self+ is set to _obj_ while the code is executing, giving the code access to _obj_'s instance variables. Arguments are passed as block parameters. class KlassWithSecret def initialize @secret = 99 end end k = KlassWithSecret.new k.instance_exec(5) {|x| @secret+x } #=> 104 @overload instance_exec(arg...) @yield [var...] @return [Object];T;#0;$@;.F;/o;0;1T;2i;3i*;%@;9I"static VALUE rb_obj_instance_exec_internal(int argc, const VALUE *argv, VALUE self) { return yield_under(self, TRUE, argc, argv, RB_PASS_CALLED_KEYWORDS); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BasicObject#method_missing;F;7[[@90;[[@Ci;T;:method_missing;0;[;{;IC; "Invoked by Ruby when obj is sent a message it cannot handle. symbol is the symbol for the method called, and args are any arguments that were passed to it. By default, the interpreter raises an error when this method is called. However, it is possible to override the method to provide more dynamic behavior. If it is decided that a particular method should not be handled, then super should be called, so that ancestors can pick up the missing method. The example below creates a class Roman, which responds to methods with names consisting of roman numerals, returning the corresponding integer values. class Roman def roman_to_int(str) # ... end def method_missing(symbol, *args) str = symbol.id2name begin roman_to_int(str) rescue super(symbol, *args) end end end r = Roman.new r.iv #=> 4 r.xxiii #=> 23 r.mm #=> 2000 r.foo #=> NoMethodError ;T;[o;= ;>I" overload;F;?0;;;@0;:I"&method_missing(symbol [, *args] );T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"symbol[, *args];T0;$@;![;"I"Invoked by Ruby when obj is sent a message it cannot handle. symbol is the symbol for the method called, and args are any arguments that were passed to it. By default, the interpreter raises an error when this method is called. However, it is possible to override the method to provide more dynamic behavior. If it is decided that a particular method should not be handled, then super should be called, so that ancestors can pick up the missing method. The example below creates a class Roman, which responds to methods with names consisting of roman numerals, returning the corresponding integer values. class Roman def roman_to_int(str) # ... end def method_missing(symbol, *args) str = symbol.id2name begin roman_to_int(str) rescue super(symbol, *args) end end end r = Roman.new r.iv #=> 4 r.xxiii #=> 23 r.mm #=> 2000 r.foo #=> NoMethodError @overload method_missing(symbol [, *args] );T;#0;$@;.F;/o;0;1T;2ir;3i;%@;9I"static VALUE rb_method_missing(int argc, const VALUE *argv, VALUE obj) { rb_execution_context_t *ec = GET_EC(); raise_method_missing(ec, argc, argv, obj, ec->method_missing_reason); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BasicObject#__send__;F;7[[@90;[[@Ci;T;;|;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;= ;>I" overload;F;?0;;{;@0;:I"send(symbol [, args...]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@,;![;"I"@return [Object];T;#0;$@,;.F;Bi;C0;7[[I"symbol[, args...];T0;$@,o;= ;>I" overload;F;?0;;|;@0;:I"!__send__(symbol [, args...]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@,;![;"I"@return [Object];T;#0;$@,;.F;Bi;C0;7[[I"symbol[, args...];T0;$@,o;= ;>I" overload;F;?0;;{;@0;:I"send(string [, args...]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@,;![;"I"@return [Object];T;#0;$@,;.F;Bi;C0;7[[I"string[, args...];T0;$@,o;= ;>I" overload;F;?0;;|;@0;:I"!__send__(string [, args...]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@,;![;"I"@return [Object];T;#0;$@,;.F;Bi;C0;7[[I"string[, args...];T0;$@,;![;"@;#0;$@,;.F;/o;0;1T;2i;3i;%@;9I"vVALUE rb_f_send(int argc, VALUE *argv, VALUE recv) { return send_internal_kw(argc, argv, recv, CALL_FCALL); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"BasicObject#__id__;F;7[;[[@?iU;T;: __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;[;![;"@E;#0;$@v;.F;/o;0;1T;2i:;3iP;%@;9I"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;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@include Kernel to obtain +puts+, +exit+, etc. A custom Kernel-like module could be created and included or delegation can be used via #method_missing: class MyObjectSystem < BasicObject DELEGATE = [:puts, :p] def method_missing(name, *args, &block) return super unless DELEGATE.include? name ::Kernel.send(name, *args, &block) end def respond_to_missing?(name, include_private = false) DELEGATE.include?(name) or super end end Access to classes and modules from the Ruby standard library can be obtained in a BasicObject subclass by referencing the desired constant from the root like ::File or ::Enumerator. Like #method_missing, #const_missing can be used to delegate constant lookup to +Object+: class MyObjectSystem < BasicObject def self.const_missing(name) ::Object.const_get(name) end end === What's Here These are the methods defined for \BasicObject: - ::new:: Returns a new \BasicObject instance. - {!}[#method-i-21]:: Returns the boolean negation of +self+: +true+ or +false+. - {!=}[#method-i-21-3D]:: Returns whether +self+ and the given object are _not_ equal. - {==}[#method-i-3D-3D]:: Returns whether +self+ and the given object are equivalent. - {__id__}[#method-i-__id__]:: Returns the integer object identifier for +self+. - {__send__}[#method-i-__send__]:: Calls the method identified by the given symbol. - #equal?:: Returns whether +self+ and the given object are the same object. - #instance_eval:: Evaluates the given string or block in the context of +self+. - #instance_exec:: Executes the given block in the context of +self+, passing the given arguments. - #method_missing:: Method called when an undefined method is called on +self+. - #singleton_method_added:: Method called when a singleton method is added to +self+. - #singleton_method_removed:: Method called when a singleton method is added removed from +self+. - #singleton_method_undefined:: Method called when a singleton method is undefined in +self+.;T;[;![;"I" BasicObject is the parent class of all classes in Ruby. It's an explicit blank class. BasicObject can be used for creating object hierarchies independent of Ruby's object hierarchy, proxy objects like the Delegator class, or other uses where namespace pollution from Ruby's methods and classes must be avoided. To avoid polluting BasicObject for other users an appropriately named subclass of BasicObject should be created instead of directly modifying BasicObject: class MyObjectSystem < BasicObject end BasicObject does not include Kernel (for methods like +puts+) and BasicObject is outside of the namespace of the standard library so common classes will not be found without using a full class path. A variety of strategies can be used to provide useful portions of the standard library to subclasses of BasicObject. A subclass could include Kernel to obtain +puts+, +exit+, etc. A custom Kernel-like module could be created and included or delegation can be used via #method_missing: class MyObjectSystem < BasicObject DELEGATE = [:puts, :p] def method_missing(name, *args, &block) return super unless DELEGATE.include? name ::Kernel.send(name, *args, &block) end def respond_to_missing?(name, include_private = false) DELEGATE.include?(name) or super end end Access to classes and modules from the Ruby standard library can be obtained in a BasicObject subclass by referencing the desired constant from the root like ::File or ::Enumerator. Like #method_missing, #const_missing can be used to delegate constant lookup to +Object+: class MyObjectSystem < BasicObject def self.const_missing(name) ::Object.const_get(name) end end === What's Here These are the methods defined for \BasicObject: - ::new:: Returns a new \BasicObject instance. - {!}[#method-i-21]:: Returns the boolean negation of +self+: +true+ or +false+. - {!=}[#method-i-21-3D]:: Returns whether +self+ and the given object are _not_ equal. - {==}[#method-i-3D-3D]:: Returns whether +self+ and the given object are equivalent. - {__id__}[#method-i-__id__]:: Returns the integer object identifier for +self+. - {__send__}[#method-i-__send__]:: Calls the method identified by the given symbol. - #equal?:: Returns whether +self+ and the given object are the same object. - #instance_eval:: Evaluates the given string or block in the context of +self+. - #instance_exec:: Executes the given block in the context of +self+, passing the given arguments. - #method_missing:: Method called when an undefined method is called on +self+. - #singleton_method_added:: Method called when a singleton method is added to +self+. - #singleton_method_removed:: Method called when a singleton method is added removed from +self+. - #singleton_method_undefined:: Method called when a singleton method is undefined in +self+. ;T;#0;$@;.F;/o;0;1T;2i;;3i;Bi;%@;&I"BasicObject;F;'o;( ;)0;*0;+0;: Qnil;%@;-0: @type;;;o;4;5F;6;;;;&I"StringScanner#initialize;F;7[[@90;[[@i;T;;D;0;[;{;IC; "Creates a new StringScanner object to scan over the given +string+. If +fixed_anchor+ is +true+, +\A+ always matches the beginning of the string. Otherwise, +\A+ always matches the current position. +dup+ argument is obsolete and not used now. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"%new(string, fixed_anchor: false);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;T0[I"fixed_anchor:;TI" false;T;$@o;= ;>I" overload;F;?0;;E;@0;:I"new(string, dup = false);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;T0[I"dup;TI" false;T;$@;![;"I"ECreates a new StringScanner object to scan over the given +string+. If +fixed_anchor+ is +true+, +\A+ always matches the beginning of the string. Otherwise, +\A+ always matches the current position. +dup+ argument is obsolete and not used now. @overload new(string, fixed_anchor: false) @overload new(string, dup = false);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strscan_initialize(int argc, VALUE *argv, VALUE self) { struct strscanner *p; VALUE str, options; p = check_strscan(self); rb_scan_args(argc, argv, "11", &str, &options); options = rb_check_hash_type(options); if (!NIL_P(options)) { VALUE fixed_anchor; ID keyword_ids[1]; keyword_ids[0] = rb_intern("fixed_anchor"); rb_get_kwargs(options, keyword_ids, 0, 1, &fixed_anchor); if (fixed_anchor == Qundef) { p->fixed_anchor_p = false; } else { p->fixed_anchor_p = RTEST(fixed_anchor); } } else { p->fixed_anchor_p = false; } StringValue(str); p->str = str; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""StringScanner#initialize_copy;F;7[[I" vorig;T0;[[@i;T;;];0;[;{;IC; "'Duplicates a StringScanner object. ;T;[o;= ;>I" overload;F;?0;;[;@0;:I"dup;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;: clone;@0;:I" clone;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"GDuplicates a StringScanner object. @overload dup @overload clone;T;#0;$@;.F;/o;0;1T;2i ;3i;%@;9I"static VALUE strscan_init_copy(VALUE vself, VALUE vorig) { struct strscanner *self, *orig; self = check_strscan(vself); orig = check_strscan(vorig); if (self != orig) { self->flags = orig->flags; self->str = orig->str; self->prev = orig->prev; self->curr = orig->curr; if (rb_reg_region_copy(&self->regs, &orig->regs)) rb_memerror(); RB_GC_GUARD(vorig); } return vself; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!StringScanner.must_C_version;F;7[;[[@i0;T;:must_C_version;0;[;{;IC; "7This method is defined for backward compatibility. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"must_C_version;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"RThis method is defined for backward compatibility. @overload must_C_version;T;#0;$@;.F;/o;0;1T;2i+;3i.;%@;9I"Bstatic VALUE strscan_s_mustc(VALUE self) { return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#reset;F;7[;[[@i9;T;: reset;0;[;{;IC; ">Reset the scan pointer (index 0) and clear matching data. ;T;[;![;"I"?Reset the scan pointer (index 0) and clear matching data. ;T;#0;$@;.F;/o;0;1T;2i6;3i7;%@;9I"static VALUE strscan_reset(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); p->curr = 0; CLEAR_MATCH_STATUS(p); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#terminate;F;7[;[[@iK;T;:terminate;0;[;{;IC; "LSets the scan pointer to the end of the string and clear matching data. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"terminate;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;: clear;@0;:I" clear;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"rSets the scan pointer to the end of the string and clear matching data. @overload terminate @overload clear;T;#0;$@;.F;/o;0;1T;2iD;3iH;%@;9I"static VALUE strscan_terminate(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); p->curr = S_LEN(p); CLEAR_MATCH_STATUS(p); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#clear;F;7[;[[@iZ;T;;;0;[;{;IC; "OEquivalent to #terminate. This method is obsolete; use #terminate instead. ;T;[;![;"I"PEquivalent to #terminate. This method is obsolete; use #terminate instead. ;T;#0;$@";.F;/o;0;1T;2iV;3iX;%@;9I"static VALUE strscan_clear(VALUE self) { rb_warning("StringScanner#clear is obsolete; use #terminate instead"); return strscan_terminate(self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#string;F;7[;[[@id;T;: string;0;[;{;IC; "&Returns the string being scanned. ;T;[;![;"I"'Returns the string being scanned. ;T;#0;$@0;.F;/o;0;1T;2ia;3ib;%@;9I"|static VALUE strscan_get_string(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); return p->str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#string=;F;7[[I"str;T0;[[@is;T;: string=;0;[;{;IC; "UChanges the string being scanned to +str+ and resets the scanner. Returns +str+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"string=(str);T;IC; ";T;[;![;"I";T;#0;$@>;.F;Bi;C0;7[[I"str;T0;$@>;![;"I"nChanges the string being scanned to +str+ and resets the scanner. Returns +str+. @overload string=(str);T;#0;$@>;.F;/o;0;1T;2im;3iq;%@;9I"static VALUE strscan_set_string(VALUE self, VALUE str) { struct strscanner *p = check_strscan(self); StringValue(str); p->str = str; p->curr = 0; CLEAR_MATCH_STATUS(p); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#concat;F;7[[I"str;T0;[[@i;T;: concat;0;[;{;IC; " Appends +str+ to the string being scanned. This method does not affect scan pointer. s = StringScanner.new("Fri Dec 12 1975 14:39") s.scan(/Fri /) s << " +1000 GMT" s.string # -> "Fri Dec 12 1975 14:39 +1000 GMT" s.scan(/Dec/) # -> "Dec" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"concat(str);T;IC; ";T;[;![;"I";T;#0;$@X;.F;Bi;C0;7[[I"str;T0;$@Xo;= ;>I" overload;F;?0;:<<;@0;:I" <<(str);T;IC; ";T;[;![;"I";T;#0;$@X;.F;Bi;C0;7[[I"str;T0;$@X;![;"I"3Appends +str+ to the string being scanned. This method does not affect scan pointer. s = StringScanner.new("Fri Dec 12 1975 14:39") s.scan(/Fri /) s << " +1000 GMT" s.string # -> "Fri Dec 12 1975 14:39 +1000 GMT" s.scan(/Dec/) # -> "Dec" @overload concat(str) @overload <<(str);T;#0;$@X;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strscan_concat(VALUE self, VALUE str) { struct strscanner *p; GET_SCANNER(self, p); StringValue(str); rb_str_append(p->str, str); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#<<;F;7[[I"str;T0;[[@i;T;;;0;[;{;IC; " Appends +str+ to the string being scanned. This method does not affect scan pointer. s = StringScanner.new("Fri Dec 12 1975 14:39") s.scan(/Fri /) s << " +1000 GMT" s.string # -> "Fri Dec 12 1975 14:39 +1000 GMT" s.scan(/Dec/) # -> "Dec" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"concat(str);T;IC; ";T;[;![;"I";T;#0;$@|;.F;Bi;C0;7[[I"str;T0;$@|o;= ;>I" overload;F;?0;;;@0;:I" <<(str);T;IC; ";T;[;![;"I";T;#0;$@|;.F;Bi;C0;7[[I"str;T0;$@|;![;"@x;#0;$@|;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strscan_concat(VALUE self, VALUE str) { struct strscanner *p; GET_SCANNER(self, p); StringValue(str); rb_str_append(p->str, str); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#pos;F;7[;[[@i;T;:pos;0;[;{;IC; "Returns the byte position of the scan pointer. In the 'reset' position, this value is zero. In the 'terminated' position (i.e. the string is exhausted), this value is the bytesize of the string. In short, it's a 0-based index into bytes of the string. s = StringScanner.new('test string') s.pos # -> 0 s.scan_until /str/ # -> "test str" s.pos # -> 8 s.terminate # -> # s.pos # -> 11 ;T;[;![;"I"Returns the byte position of the scan pointer. In the 'reset' position, this value is zero. In the 'terminated' position (i.e. the string is exhausted), this value is the bytesize of the string. In short, it's a 0-based index into bytes of the string. s = StringScanner.new('test string') s.pos # -> 0 s.scan_until /str/ # -> "test str" s.pos # -> 8 s.terminate # -> # s.pos # -> 11 ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"~static VALUE strscan_get_pos(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); return INT2FIX(p->curr); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#pos=;F;7[[I"v;T0;[[@i;T;: pos=;0;[;{;IC; "Sets the byte position of the scan pointer. s = StringScanner.new('test string') s.pos = 7 # -> 7 s.rest # -> "ring" ;T;[o;= ;>I" overload;F;?0;;;@0;:I" pos=(n);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"n;T0;$@;![;"I"Sets the byte position of the scan pointer. s = StringScanner.new('test string') s.pos = 7 # -> 7 s.rest # -> "ring" @overload pos=(n);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"Vstatic VALUE strscan_set_pos(VALUE self, VALUE v) { struct strscanner *p; long i; GET_SCANNER(self, p); i = NUM2INT(v); if (i < 0) i += S_LEN(p); if (i < 0) rb_raise(rb_eRangeError, "index out of range"); if (i > S_LEN(p)) rb_raise(rb_eRangeError, "index out of range"); p->curr = i; return LONG2NUM(i); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#charpos;F;7[;[[@i;T;: charpos;0;[;{;IC; "Returns the character position of the scan pointer. In the 'reset' position, this value is zero. In the 'terminated' position (i.e. the string is exhausted), this value is the size of the string. In short, it's a 0-based index into the string. s = StringScanner.new("abcädeföghi") s.charpos # -> 0 s.scan_until(/ä/) # -> "abcä" s.pos # -> 5 s.charpos # -> 4 ;T;[;![;"I"Returns the character position of the scan pointer. In the 'reset' position, this value is zero. In the 'terminated' position (i.e. the string is exhausted), this value is the size of the string. In short, it's a 0-based index into the string. s = StringScanner.new("abcädeföghi") s.charpos # -> 0 s.scan_until(/ä/) # -> "abcä" s.pos # -> 5 s.charpos # -> 4 ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strscan_get_charpos(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); return LONG2NUM(rb_enc_strlen(S_PBEG(p), CURPTR(p), rb_enc_get(p->str))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#pointer;F;7[;[[@i;T;: pointer;0;[;{;IC; "Returns the byte position of the scan pointer. In the 'reset' position, this value is zero. In the 'terminated' position (i.e. the string is exhausted), this value is the bytesize of the string. In short, it's a 0-based index into bytes of the string. s = StringScanner.new('test string') s.pos # -> 0 s.scan_until /str/ # -> "test str" s.pos # -> 8 s.terminate # -> # s.pos # -> 11 ;T;[;![;"@;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"~static VALUE strscan_get_pos(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); return INT2FIX(p->curr); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#pointer=;F;7[[I"v;T0;[[@i;T;: pointer=;0;[;{;IC; "Sets the byte position of the scan pointer. s = StringScanner.new('test string') s.pos = 7 # -> 7 s.rest # -> "ring" ;T;[o;= ;>I" overload;F;?0;;;@0;:I" pos=(n);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"n;T0;$@;![;"@;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"Vstatic VALUE strscan_set_pos(VALUE self, VALUE v) { struct strscanner *p; long i; GET_SCANNER(self, p); i = NUM2INT(v); if (i < 0) i += S_LEN(p); if (i < 0) rb_raise(rb_eRangeError, "index out of range"); if (i > S_LEN(p)) rb_raise(rb_eRangeError, "index out of range"); p->curr = i; return LONG2NUM(i); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#scan;F;7[[I"re;T0;[[@i;T;: scan;0;[;{;IC; "Tries to match with +pattern+ at the current position. If there's a match, the scanner advances the "scan pointer" and returns the matched string. Otherwise, the scanner returns +nil+. s = StringScanner.new('test string') p s.scan(/\w+/) # -> "test" p s.scan(/\w+/) # -> nil p s.scan(/\s+/) # -> " " p s.scan("str") # -> "str" p s.scan(/\w+/) # -> "ing" p s.scan(/./) # -> nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I"scan(pattern);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I" pattern;T0;$@;![;"I"Tries to match with +pattern+ at the current position. If there's a match, the scanner advances the "scan pointer" and returns the matched string. Otherwise, the scanner returns +nil+. s = StringScanner.new('test string') p s.scan(/\w+/) # -> "test" p s.scan(/\w+/) # -> nil p s.scan(/\s+/) # -> " " p s.scan("str") # -> "str" p s.scan(/\w+/) # -> "ing" p s.scan(/./) # -> nil @overload scan(pattern) @return [String];T;#0;$@;.F;/o;0;1T;2i{;3i;%@;9I"gstatic VALUE strscan_scan(VALUE self, VALUE re) { return strscan_do_scan(self, re, 1, 1, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#skip;F;7[[I"re;T0;[[@i;T;: skip;0;[;{;IC; "Attempts to skip over the given +pattern+ beginning with the scan pointer. If it matches, the scan pointer is advanced to the end of the match, and the length of the match is returned. Otherwise, +nil+ is returned. It's similar to #scan, but without returning the matched string. s = StringScanner.new('test string') p s.skip(/\w+/) # -> 4 p s.skip(/\w+/) # -> nil p s.skip(/\s+/) # -> 1 p s.skip("st") # -> 2 p s.skip(/\w+/) # -> 4 p s.skip(/./) # -> nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I"skip(pattern);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" pattern;T0;$@;![;"I"Attempts to skip over the given +pattern+ beginning with the scan pointer. If it matches, the scan pointer is advanced to the end of the match, and the length of the match is returned. Otherwise, +nil+ is returned. It's similar to #scan, but without returning the matched string. s = StringScanner.new('test string') p s.skip(/\w+/) # -> 4 p s.skip(/\w+/) # -> nil p s.skip(/\s+/) # -> 1 p s.skip("st") # -> 2 p s.skip(/\w+/) # -> 4 p s.skip(/./) # -> nil @overload skip(pattern);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"gstatic VALUE strscan_skip(VALUE self, VALUE re) { return strscan_do_scan(self, re, 1, 0, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#match?;F;7[[I"re;T0;[[@i;T;: match?;0;[;{;IC; "7Tests whether the given +pattern+ is matched from the current scan pointer. Returns the length of the match, or +nil+. The scan pointer is not advanced. s = StringScanner.new('test string') p s.match?(/\w+/) # -> 4 p s.match?(/\w+/) # -> 4 p s.match?("test") # -> 4 p s.match?(/\s+/) # -> nil;T;[o;= ;>I" overload;F;?0;;;@0;:I"match?(pattern);T;IC; ";T;[;![;"I";T;#0;$@4;.F;Bi;C0;7[[I" pattern;T0;$@4o;A ;>I" return;F;?@;0;@[I" Boolean;T;$@4;![;"I"STests whether the given +pattern+ is matched from the current scan pointer. Returns the length of the match, or +nil+. The scan pointer is not advanced. s = StringScanner.new('test string') p s.match?(/\w+/) # -> 4 p s.match?(/\w+/) # -> 4 p s.match?("test") # -> 4 p s.match?(/\s+/) # -> nil @overload match?(pattern);T;#0;$@4;.F;/o;0;1T;2i;3i;Bi;%@;9I"jstatic VALUE strscan_match_p(VALUE self, VALUE re) { return strscan_do_scan(self, re, 0, 0, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#check;F;7[[I"re;T0;[[@i;T;: check;0;[;{;IC; "This returns the value that #scan would return, without advancing the scan pointer. The match register is affected, though. s = StringScanner.new("Fri Dec 12 1975 14:39") s.check /Fri/ # -> "Fri" s.pos # -> 0 s.matched # -> "Fri" s.check /12/ # -> nil s.matched # -> nil Mnemonic: it "checks" to see whether a #scan will return a value. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"check(pattern);T;IC; ";T;[;![;"I";T;#0;$@R;.F;Bi;C0;7[[I" pattern;T0;$@R;![;"I"This returns the value that #scan would return, without advancing the scan pointer. The match register is affected, though. s = StringScanner.new("Fri Dec 12 1975 14:39") s.check /Fri/ # -> "Fri" s.pos # -> 0 s.matched # -> "Fri" s.check /12/ # -> nil s.matched # -> nil Mnemonic: it "checks" to see whether a #scan will return a value. @overload check(pattern);T;#0;$@R;.F;/o;0;1T;2i;3i;%@;9I"hstatic VALUE strscan_check(VALUE self, VALUE re) { return strscan_do_scan(self, re, 0, 1, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#scan_full;F;7[[I"re;T0[I"s;T0[I"f;T0;[[@i;T;:scan_full;0;[;{;IC; " Tests whether the given +pattern+ is matched from the current scan pointer. Advances the scan pointer if +advance_pointer_p+ is true. Returns the matched string if +return_string_p+ is true. The match register is affected. "full" means "#scan with full parameters". ;T;[o;= ;>I" overload;F;?0;;;@0;:I";scan_full(pattern, advance_pointer_p, return_string_p);T;IC; ";T;[;![;"I";T;#0;$@l;.F;Bi;C0;7[[I" pattern;T0[I"advance_pointer_p;T0[I"return_string_p;T0;$@l;![;"I"MTests whether the given +pattern+ is matched from the current scan pointer. Advances the scan pointer if +advance_pointer_p+ is true. Returns the matched string if +return_string_p+ is true. The match register is affected. "full" means "#scan with full parameters". @overload scan_full(pattern, advance_pointer_p, return_string_p);T;#0;$@l;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strscan_scan_full(VALUE self, VALUE re, VALUE s, VALUE f) { return strscan_do_scan(self, re, RTEST(s), RTEST(f), 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#scan_until;F;7[[I"re;T0;[[@i;T;:scan_until;0;[;{;IC; "vScans the string _until_ the +pattern+ is matched. Returns the substring up to and including the end of the match, advancing the scan pointer to that location. If there is no match, +nil+ is returned. s = StringScanner.new("Fri Dec 12 1975 14:39") s.scan_until(/1/) # -> "Fri Dec 1" s.pre_match # -> "Fri Dec " s.scan_until(/XYZ/) # -> nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I"scan_until(pattern);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" pattern;T0;$@;![;"I"Scans the string _until_ the +pattern+ is matched. Returns the substring up to and including the end of the match, advancing the scan pointer to that location. If there is no match, +nil+ is returned. s = StringScanner.new("Fri Dec 12 1975 14:39") s.scan_until(/1/) # -> "Fri Dec 1" s.pre_match # -> "Fri Dec " s.scan_until(/XYZ/) # -> nil @overload scan_until(pattern);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"mstatic VALUE strscan_scan_until(VALUE self, VALUE re) { return strscan_do_scan(self, re, 1, 1, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#skip_until;F;7[[I"re;T0;[[@i;T;:skip_until;0;[;{;IC; "Advances the scan pointer until +pattern+ is matched and consumed. Returns the number of bytes advanced, or +nil+ if no match was found. Look ahead to match +pattern+, and advance the scan pointer to the _end_ of the match. Return the number of characters advanced, or +nil+ if the match was unsuccessful. It's similar to #scan_until, but without returning the intervening string. s = StringScanner.new("Fri Dec 12 1975 14:39") s.skip_until /12/ # -> 10 s # ;T;[o;= ;>I" overload;F;?0;;;@0;:I"skip_until(pattern);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" pattern;T0;$@;![;"I"Advances the scan pointer until +pattern+ is matched and consumed. Returns the number of bytes advanced, or +nil+ if no match was found. Look ahead to match +pattern+, and advance the scan pointer to the _end_ of the match. Return the number of characters advanced, or +nil+ if the match was unsuccessful. It's similar to #scan_until, but without returning the intervening string. s = StringScanner.new("Fri Dec 12 1975 14:39") s.skip_until /12/ # -> 10 s # @overload skip_until(pattern);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"mstatic VALUE strscan_skip_until(VALUE self, VALUE re) { return strscan_do_scan(self, re, 1, 0, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#exist?;F;7[[I"re;T0;[[@i;T;: exist?;0;[;{;IC; "YLooks _ahead_ to see if the +pattern+ exists _anywhere_ in the string, without advancing the scan pointer. This predicates whether a #scan_until will return a value. s = StringScanner.new('test string') s.exist? /s/ # -> 3 s.scan /test/ # -> "test" s.exist? /s/ # -> 2 s.exist? /e/ # -> nil;T;[o;= ;>I" overload;F;?0;;;@0;:I"exist?(pattern);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" pattern;T0;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"uLooks _ahead_ to see if the +pattern+ exists _anywhere_ in the string, without advancing the scan pointer. This predicates whether a #scan_until will return a value. s = StringScanner.new('test string') s.exist? /s/ # -> 3 s.scan /test/ # -> "test" s.exist? /s/ # -> 2 s.exist? /e/ # -> nil @overload exist?(pattern);T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"jstatic VALUE strscan_exist_p(VALUE self, VALUE re) { return strscan_do_scan(self, re, 0, 0, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#check_until;F;7[[I"re;T0;[[@i(;T;:check_until;0;[;{;IC; "xThis returns the value that #scan_until would return, without advancing the scan pointer. The match register is affected, though. s = StringScanner.new("Fri Dec 12 1975 14:39") s.check_until /12/ # -> "Fri Dec 12" s.pos # -> 0 s.matched # -> 12 Mnemonic: it "checks" to see whether a #scan_until will return a value. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"check_until(pattern);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" pattern;T0;$@;![;"I"This returns the value that #scan_until would return, without advancing the scan pointer. The match register is affected, though. s = StringScanner.new("Fri Dec 12 1975 14:39") s.check_until /12/ # -> "Fri Dec 12" s.pos # -> 0 s.matched # -> 12 Mnemonic: it "checks" to see whether a #scan_until will return a value. @overload check_until(pattern);T;#0;$@;.F;/o;0;1T;2i;3i&;%@;9I"nstatic VALUE strscan_check_until(VALUE self, VALUE re) { return strscan_do_scan(self, re, 0, 1, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#search_full;F;7[[I"re;T0[I"s;T0[I"f;T0;[[@i7;T;:search_full;0;[;{;IC; "Scans the string _until_ the +pattern+ is matched. Advances the scan pointer if +advance_pointer_p+, otherwise not. Returns the matched string if +return_string_p+ is true, otherwise returns the number of bytes advanced. This method does affect the match register. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"=search_full(pattern, advance_pointer_p, return_string_p);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" pattern;T0[I"advance_pointer_p;T0[I"return_string_p;T0;$@;![;"I"MScans the string _until_ the +pattern+ is matched. Advances the scan pointer if +advance_pointer_p+, otherwise not. Returns the matched string if +return_string_p+ is true, otherwise returns the number of bytes advanced. This method does affect the match register. @overload search_full(pattern, advance_pointer_p, return_string_p);T;#0;$@;.F;/o;0;1T;2i.;3i5;%@;9I"static VALUE strscan_search_full(VALUE self, VALUE re, VALUE s, VALUE f) { return strscan_do_scan(self, re, RTEST(s), RTEST(f), 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#getch;F;7[;[[@iV;T;: getch;0;[;{;IC; "kScans one character and returns it. This method is multibyte character sensitive. s = StringScanner.new("ab") s.getch # => "a" s.getch # => "b" s.getch # => nil s = StringScanner.new("\244\242".force_encoding("euc-jp")) s.getch # => "\x{A4A2}" # Japanese hira-kana "A" in EUC-JP s.getch # => nil ;T;[;![;"I"lScans one character and returns it. This method is multibyte character sensitive. s = StringScanner.new("ab") s.getch # => "a" s.getch # => "b" s.getch # => nil s = StringScanner.new("\244\242".force_encoding("euc-jp")) s.getch # => "\x{A4A2}" # Japanese hira-kana "A" in EUC-JP s.getch # => nil ;T;#0;$@;.F;/o;0;1T;2iI;3iT;%@;9I"static VALUE strscan_getch(VALUE self) { struct strscanner *p; long len; GET_SCANNER(self, p); CLEAR_MATCH_STATUS(p); if (EOS_P(p)) return Qnil; len = rb_enc_mbclen(CURPTR(p), S_PEND(p), rb_enc_get(p->str)); len = minl(len, S_RESTLEN(p)); p->prev = p->curr; p->curr += len; MATCHED(p); adjust_registers_to_matched(p); return extract_range(p, adjust_register_position(p, p->regs.beg[0]), adjust_register_position(p, p->regs.end[0])); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#get_byte;F;7[;[[@i{;T;: get_byte;0;[;{;IC; "yScans one byte and returns it. This method is not multibyte character sensitive. See also: #getch. s = StringScanner.new('ab') s.get_byte # => "a" s.get_byte # => "b" s.get_byte # => nil s = StringScanner.new("\244\242".force_encoding("euc-jp")) s.get_byte # => "\xA4" s.get_byte # => "\xA2" s.get_byte # => nil ;T;[;![;"I"zScans one byte and returns it. This method is not multibyte character sensitive. See also: #getch. s = StringScanner.new('ab') s.get_byte # => "a" s.get_byte # => "b" s.get_byte # => nil s = StringScanner.new("\244\242".force_encoding("euc-jp")) s.get_byte # => "\xA4" s.get_byte # => "\xA2" s.get_byte # => nil ;T;#0;$@);.F;/o;0;1T;2il;3iy;%@;9I"static VALUE strscan_get_byte(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); CLEAR_MATCH_STATUS(p); if (EOS_P(p)) return Qnil; p->prev = p->curr; p->curr++; MATCHED(p); adjust_registers_to_matched(p); return extract_range(p, adjust_register_position(p, p->regs.beg[0]), adjust_register_position(p, p->regs.end[0])); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#getbyte;F;7[;[[@i;T;: getbyte;0;[;{;IC; "MEquivalent to #get_byte. This method is obsolete; use #get_byte instead. ;T;[;![;"I"NEquivalent to #get_byte. This method is obsolete; use #get_byte instead. ;T;#0;$@7;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strscan_getbyte(VALUE self) { rb_warning("StringScanner#getbyte is obsolete; use #get_byte instead"); return strscan_get_byte(self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#peek;F;7[[I" vlen;T0;[[@i;T;: peek;0;[;{;IC; "Extracts a string corresponding to string[pos,len], without advancing the scan pointer. s = StringScanner.new('test string') s.peek(7) # => "test st" s.peek(7) # => "test st" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"peek(len);T;IC; ";T;[;![;"I";T;#0;$@E;.F;Bi;C0;7[[I"len;T0;$@E;![;"I"Extracts a string corresponding to string[pos,len], without advancing the scan pointer. s = StringScanner.new('test string') s.peek(7) # => "test st" s.peek(7) # => "test st" @overload peek(len);T;#0;$@E;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strscan_peek(VALUE self, VALUE vlen) { struct strscanner *p; long len; GET_SCANNER(self, p); len = NUM2LONG(vlen); if (EOS_P(p)) return str_new(p, "", 0); len = minl(len, S_RESTLEN(p)); return extract_beg_len(p, p->curr, len); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#peep;F;7[[I" vlen;T0;[[@i;T;: peep;0;[;{;IC; "EEquivalent to #peek. This method is obsolete; use #peek instead. ;T;[;![;"I"FEquivalent to #peek. This method is obsolete; use #peek instead. ;T;#0;$@_;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strscan_peep(VALUE self, VALUE vlen) { rb_warning("StringScanner#peep is obsolete; use #peek instead"); return strscan_peek(self, vlen); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#unscan;F;7[;[[@i;T;: unscan;0;[;{;IC; "qSets the scan pointer to the previous position. Only one previous position is remembered, and it changes with each scanning operation. s = StringScanner.new('test string') s.scan(/\w+/) # => "test" s.unscan s.scan(/../) # => "te" s.scan(/\d/) # => nil s.unscan # ScanError: unscan failed: previous match record not exist ;T;[;![;"I"rSets the scan pointer to the previous position. Only one previous position is remembered, and it changes with each scanning operation. s = StringScanner.new('test string') s.scan(/\w+/) # => "test" s.unscan s.scan(/../) # => "te" s.scan(/\d/) # => nil s.unscan # ScanError: unscan failed: previous match record not exist ;T;#0;$@o;.F;/o;0;1T;2i;3i;%@;9I" static VALUE strscan_unscan(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); if (! MATCHED_P(p)) rb_raise(ScanError, "unscan failed: previous match record not exist"); p->curr = p->prev; CLEAR_MATCH_STATUS(p); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%StringScanner#beginning_of_line?;F;7[;[[@i;T;:beginning_of_line?;0;[;{;IC; "Returns +true+ if and only if the scan pointer is at the beginning of the line. s = StringScanner.new("test\ntest\n") s.bol? # => true s.scan(/te/) s.bol? # => false s.scan(/st\n/) s.bol? # => true s.terminate s.bol? # => true;T;[o;A ;>I" return;F;?@;0;@[@L;$@};![;"I"Returns +true+ if and only if the scan pointer is at the beginning of the line. s = StringScanner.new("test\ntest\n") s.bol? # => true s.scan(/te/) s.bol? # => false s.scan(/st\n/) s.bol? # => true s.terminate s.bol? # => true ;T;#0;$@};.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE strscan_bol_p(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); if (CURPTR(p) > S_PEND(p)) return Qnil; if (p->curr == 0) return Qtrue; return (*(CURPTR(p) - 1) == '\n') ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#eos?;F;7[;[[@i;T;: eos?;0;[;{;IC; "Returns +true+ if the scan pointer is at the end of the string. s = StringScanner.new('test string') p s.eos? # => false s.scan(/test/) p s.eos? # => false s.terminate p s.eos? # => true;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"Returns +true+ if the scan pointer is at the end of the string. s = StringScanner.new('test string') p s.eos? # => false s.scan(/test/) p s.eos? # => false s.terminate p s.eos? # => true ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE strscan_eos_p(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); return EOS_P(p) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#empty?;F;7[;[[@i;T;: empty?;0;[;{;IC; "EEquivalent to #eos?. This method is obsolete, use #eos? instead.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"FEquivalent to #eos?. This method is obsolete, use #eos? instead. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE strscan_empty_p(VALUE self) { rb_warning("StringScanner#empty? is obsolete; use #eos? instead"); return strscan_eos_p(self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#rest?;F;7[;[[@i;T;: rest?;0;[;{;IC; "Returns true if and only if there is more data in the string. See #eos?. This method is obsolete; use #eos? instead. s = StringScanner.new('test string') s.eos? # These two s.rest? # are opposites.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"Returns true if and only if there is more data in the string. See #eos?. This method is obsolete; use #eos? instead. s = StringScanner.new('test string') s.eos? # These two s.rest? # are opposites. ;T;#0;$@;.F;/o;0;1T;2i ;3i;Bi;%@;9I"static VALUE strscan_rest_p(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); return EOS_P(p) ? Qfalse : Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#matched?;F;7[;[[@i&;T;: matched?;0;[;{;IC; "Returns +true+ if and only if the last match was successful. s = StringScanner.new('test string') s.match?(/\w+/) # => 4 s.matched? # => true s.match?(/\d+/) # => nil s.matched? # => false;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"Returns +true+ if and only if the last match was successful. s = StringScanner.new('test string') s.match?(/\w+/) # => 4 s.matched? # => true s.match?(/\d+/) # => nil s.matched? # => false ;T;#0;$@;.F;/o;0;1T;2i;3i$;Bi;%@;9I"static VALUE strscan_matched_p(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); return MATCHED_P(p) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#matched;F;7[;[[@i6;T;: matched;0;[;{;IC; "Returns the last matched string. s = StringScanner.new('test string') s.match?(/\w+/) # -> 4 s.matched # -> "test" ;T;[;![;"I"Returns the last matched string. s = StringScanner.new('test string') s.match?(/\w+/) # -> 4 s.matched # -> "test" ;T;#0;$@;.F;/o;0;1T;2i/;3i4;%@;9I"/static VALUE strscan_matched(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); if (! MATCHED_P(p)) return Qnil; return extract_range(p, adjust_register_position(p, p->regs.beg[0]), adjust_register_position(p, p->regs.end[0])); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#matched_size;F;7[;[[@iM;T;:matched_size;0;[;{;IC; "hReturns the size of the most recent match in bytes, or +nil+ if there was no recent match. This is different than matched.size, which will return the size in characters. s = StringScanner.new('test string') s.check /\w+/ # -> "test" s.matched_size # -> 4 s.check /\d+/ # -> nil s.matched_size # -> nil ;T;[;![;"I"iReturns the size of the most recent match in bytes, or +nil+ if there was no recent match. This is different than matched.size, which will return the size in characters. s = StringScanner.new('test string') s.check /\w+/ # -> "test" s.matched_size # -> 4 s.check /\d+/ # -> nil s.matched_size # -> nil ;T;#0;$@;.F;/o;0;1T;2iB;3iK;%@;9I"static VALUE strscan_matched_size(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); if (! MATCHED_P(p)) return Qnil; return LONG2NUM(p->regs.end[0] - p->regs.beg[0]); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#[];F;7[[I"idx;T0;[[@i;T;:[];0;[;{;IC; "Returns the n-th subgroup in the most recent match. s = StringScanner.new("Fri Dec 12 1975 14:39") s.scan(/(\w+) (\w+) (\d+) /) # -> "Fri Dec 12 " s[0] # -> "Fri Dec 12 " s[1] # -> "Fri" s[2] # -> "Dec" s[3] # -> "12" s.post_match # -> "1975 14:39" s.pre_match # -> "" s.reset s.scan(/(?\w+) (?\w+) (?\d+) /) # -> "Fri Dec 12 " s[0] # -> "Fri Dec 12 " s[1] # -> "Fri" s[2] # -> "Dec" s[3] # -> "12" s[:wday] # -> "Fri" s[:month] # -> "Dec" s[:day] # -> "12" s.post_match # -> "1975 14:39" s.pre_match # -> "" ;T;[o;= ;>I" overload;F;?0;;;@0;:I" [](n);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"n;T0;$@;![;"I"Returns the n-th subgroup in the most recent match. s = StringScanner.new("Fri Dec 12 1975 14:39") s.scan(/(\w+) (\w+) (\d+) /) # -> "Fri Dec 12 " s[0] # -> "Fri Dec 12 " s[1] # -> "Fri" s[2] # -> "Dec" s[3] # -> "12" s.post_match # -> "1975 14:39" s.pre_match # -> "" s.reset s.scan(/(?\w+) (?\w+) (?\d+) /) # -> "Fri Dec 12 " s[0] # -> "Fri Dec 12 " s[1] # -> "Fri" s[2] # -> "Dec" s[3] # -> "12" s[:wday] # -> "Fri" s[:month] # -> "Dec" s[:day] # -> "12" s.post_match # -> "1975 14:39" s.pre_match # -> "" @overload [](n);T;#0;$@;.F;/o;0;1T;2ii;3i;%@;9I"static VALUE strscan_aref(VALUE self, VALUE idx) { const char *name; struct strscanner *p; long i; GET_SCANNER(self, p); if (! MATCHED_P(p)) return Qnil; switch (TYPE(idx)) { case T_SYMBOL: idx = rb_sym2str(idx); /* fall through */ case T_STRING: if (!RTEST(p->regex)) return Qnil; RSTRING_GETMEM(idx, name, i); i = name_to_backref_number(&(p->regs), p->regex, name, name + i, rb_enc_get(idx)); break; default: i = NUM2LONG(idx); } if (i < 0) i += p->regs.num_regs; if (i < 0) return Qnil; if (i >= p->regs.num_regs) return Qnil; if (p->regs.beg[i] == -1) return Qnil; return extract_range(p, adjust_register_position(p, p->regs.beg[i]), adjust_register_position(p, p->regs.end[i])); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#pre_match;F;7[;[[@i;T;:pre_match;0;[;{;IC; "Returns the pre-match (in the regular expression sense) of the last scan. s = StringScanner.new('test string') s.scan(/\w+/) # -> "test" s.scan(/\s+/) # -> " " s.pre_match # -> "test" s.post_match # -> "string" ;T;[;![;"I"Returns the pre-match (in the regular expression sense) of the last scan. s = StringScanner.new('test string') s.scan(/\w+/) # -> "test" s.scan(/\s+/) # -> " " s.pre_match # -> "test" s.post_match # -> "string" ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strscan_pre_match(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); if (! MATCHED_P(p)) return Qnil; return extract_range(p, 0, adjust_register_position(p, p->regs.beg[0])); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#post_match;F;7[;[[@i;T;:post_match;0;[;{;IC; "Returns the post-match (in the regular expression sense) of the last scan. s = StringScanner.new('test string') s.scan(/\w+/) # -> "test" s.scan(/\s+/) # -> " " s.pre_match # -> "test" s.post_match # -> "string" ;T;[;![;"I"Returns the post-match (in the regular expression sense) of the last scan. s = StringScanner.new('test string') s.scan(/\w+/) # -> "test" s.scan(/\s+/) # -> " " s.pre_match # -> "test" s.post_match # -> "string" ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strscan_post_match(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); if (! MATCHED_P(p)) return Qnil; return extract_range(p, adjust_register_position(p, p->regs.end[0]), S_LEN(p)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#size;F;7[;[[@i;T;: size;0;[;{;IC; "Returns the amount of subgroups in the most recent match. The full match counts as a subgroup. s = StringScanner.new("Fri Dec 12 1975 14:39") s.scan(/(\w+) (\w+) (\d+) /) # -> "Fri Dec 12 " s.size # -> 4 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[;![;"I";T;#0;$@$;.F;Bi;C0;7[;$@$;![;"I"Returns the amount of subgroups in the most recent match. The full match counts as a subgroup. s = StringScanner.new("Fri Dec 12 1975 14:39") s.scan(/(\w+) (\w+) (\d+) /) # -> "Fri Dec 12 " s.size # -> 4 @overload size;T;#0;$@$;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strscan_size(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); if (! MATCHED_P(p)) return Qnil; return INT2FIX(p->regs.num_regs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#captures;F;7[;[[@i;T;: captures;0;[;{;IC; "Returns the subgroups in the most recent match (not including the full match). If nothing was priorly matched, it returns nil. s = StringScanner.new("Fri Dec 12 1975 14:39") s.scan(/(\w+) (\w+) (\d+) /) # -> "Fri Dec 12 " s.captures # -> ["Fri", "Dec", "12"] s.scan(/(\w+) (\w+) (\d+) /) # -> nil s.captures # -> nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I" captures;T;IC; ";T;[;![;"I";T;#0;$@:;.F;Bi;C0;7[;$@:;![;"I"Returns the subgroups in the most recent match (not including the full match). If nothing was priorly matched, it returns nil. s = StringScanner.new("Fri Dec 12 1975 14:39") s.scan(/(\w+) (\w+) (\d+) /) # -> "Fri Dec 12 " s.captures # -> ["Fri", "Dec", "12"] s.scan(/(\w+) (\w+) (\d+) /) # -> nil s.captures # -> nil @overload captures;T;#0;$@:;.F;/o;0;1T;2i;3i;%@;9I"(static VALUE strscan_captures(VALUE self) { struct strscanner *p; int i, num_regs; VALUE new_ary; GET_SCANNER(self, p); if (! MATCHED_P(p)) return Qnil; num_regs = p->regs.num_regs; new_ary = rb_ary_new2(num_regs); for (i = 1; i < num_regs; i++) { VALUE str = extract_range(p, adjust_register_position(p, p->regs.beg[i]), adjust_register_position(p, p->regs.end[i])); rb_ary_push(new_ary, str); } return new_ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#values_at;F;7[[@90;[[@i;T;:values_at;0;[;{;IC; "Returns the subgroups in the most recent match at the given indices. If nothing was priorly matched, it returns nil. s = StringScanner.new("Fri Dec 12 1975 14:39") s.scan(/(\w+) (\w+) (\d+) /) # -> "Fri Dec 12 " s.values_at 0, -1, 5, 2 # -> ["Fri Dec 12 ", "12", nil, "Dec"] s.scan(/(\w+) (\w+) (\d+) /) # -> nil s.values_at 0, -1, 5, 2 # -> nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I" values_at( i1, i2, ... iN );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@P;![;"I"@return [Array];T;#0;$@P;.F;Bi;C0;7[[I"i1;T0[I"i2;T0[I" ...iN;T0;$@P;![;"I"Returns the subgroups in the most recent match at the given indices. If nothing was priorly matched, it returns nil. s = StringScanner.new("Fri Dec 12 1975 14:39") s.scan(/(\w+) (\w+) (\d+) /) # -> "Fri Dec 12 " s.values_at 0, -1, 5, 2 # -> ["Fri Dec 12 ", "12", nil, "Dec"] s.scan(/(\w+) (\w+) (\d+) /) # -> nil s.values_at 0, -1, 5, 2 # -> nil @overload values_at( i1, i2, ... iN ) @return [Array];T;#0;$@P;.F;/o;0;1T;2i;3i;%@;9I"\static VALUE strscan_values_at(int argc, VALUE *argv, VALUE self) { struct strscanner *p; long i; VALUE new_ary; GET_SCANNER(self, p); if (! MATCHED_P(p)) return Qnil; new_ary = rb_ary_new2(argc); for (i = 0; i"". ;T;[;![;"I"Returns the "rest" of the string (i.e. everything after the scan pointer). If there is no more data (eos? = true), it returns "". ;T;#0;$@r;.F;/o;0;1T;2i&;3i(;%@;9I"static VALUE strscan_rest(VALUE self) { struct strscanner *p; GET_SCANNER(self, p); if (EOS_P(p)) { return str_new(p, "", 0); } return extract_range(p, p->curr, S_LEN(p)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#rest_size;F;7[;[[@i9;T;:rest_size;0;[;{;IC; "@s.rest_size is equivalent to s.rest.size. ;T;[;![;"I"As.rest_size is equivalent to s.rest.size. ;T;#0;$@;.F;/o;0;1T;2i6;3i7;%@;9I"static VALUE strscan_rest_size(VALUE self) { struct strscanner *p; long i; GET_SCANNER(self, p); if (EOS_P(p)) { return INT2FIX(0); } i = S_RESTLEN(p); return INT2FIX(i); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#restsize;F;7[;[[@iK;T;: restsize;0;[;{;IC; "ps.restsize is equivalent to s.rest_size. This method is obsolete; use #rest_size instead. ;T;[;![;"I"qs.restsize is equivalent to s.rest_size. This method is obsolete; use #rest_size instead. ;T;#0;$@;.F;/o;0;1T;2iG;3iI;%@;9I"static VALUE strscan_restsize(VALUE self) { rb_warning("StringScanner#restsize is obsolete; use #rest_size instead"); return strscan_rest_size(self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringScanner#inspect;F;7[;[[@i_;T;;J;0;[;{;IC; "Returns a string that represents the StringScanner object, showing: - the current position - the size of the string - the characters surrounding the scan pointer s = StringScanner.new("Fri Dec 12 1975 14:39") s.inspect # -> '#' s.scan_until /12/ # -> "Fri Dec 12" s.inspect # -> '#' ;T;[;![;"I"Returns a string that represents the StringScanner object, showing: - the current position - the size of the string - the characters surrounding the scan pointer s = StringScanner.new("Fri Dec 12 1975 14:39") s.inspect # -> '#' s.scan_until /12/ # -> "Fri Dec 12" s.inspect # -> '#' ;T;#0;$@;.F;/o;0;1T;2iT;3i];%@;9I"static VALUE strscan_inspect(VALUE self) { struct strscanner *p; VALUE a, b; p = check_strscan(self); if (NIL_P(p->str)) { a = rb_sprintf("#<%"PRIsVALUE" (uninitialized)>", rb_obj_class(self)); return a; } if (EOS_P(p)) { a = rb_sprintf("#<%"PRIsVALUE" fin>", rb_obj_class(self)); return a; } if (p->curr == 0) { b = inspect2(p); a = rb_sprintf("#<%"PRIsVALUE" %ld/%ld @ %"PRIsVALUE">", rb_obj_class(self), p->curr, S_LEN(p), b); return a; } a = inspect1(p); b = inspect2(p); a = rb_sprintf("#<%"PRIsVALUE" %ld/%ld %"PRIsVALUE" @ %"PRIsVALUE">", rb_obj_class(self), p->curr, S_LEN(p), a, b); return a; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" StringScanner#fixed_anchor?;F;7[;[[@i;T;:fixed_anchor?;0;[;{;IC; "Whether +scanner+ uses fixed anchor mode or not. If fixed anchor mode is used, +\A+ always matches the beginning of the string. Otherwise, +\A+ always matches the current position.;T;[o;= ;>I" overload;F;?0;;;@0;:I"fixed_anchor?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Whether +scanner+ uses fixed anchor mode or not. If fixed anchor mode is used, +\A+ always matches the beginning of the string. Otherwise, +\A+ always matches the current position. @overload fixed_anchor? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE strscan_fixed_anchor_p(VALUE self) { struct strscanner *p; p = check_strscan(self); return p->fixed_anchor_p ? Qtrue : Qfalse; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i-;T;:StringScanner;;;;;[;{;IC; ") StringScanner provides for lexical scanning operations on a String. Here is an example of its usage: s = StringScanner.new('This is an example string') s.eos? # -> false p s.scan(/\w+/) # -> "This" p s.scan(/\w+/) # -> nil p s.scan(/\s+/) # -> " " p s.scan(/\s+/) # -> nil p s.scan(/\w+/) # -> "is" s.eos? # -> false p s.scan(/\s+/) # -> " " p s.scan(/\w+/) # -> "an" p s.scan(/\s+/) # -> " " p s.scan(/\w+/) # -> "example" p s.scan(/\s+/) # -> " " p s.scan(/\w+/) # -> "string" s.eos? # -> true p s.scan(/\s+/) # -> nil p s.scan(/\w+/) # -> nil Scanning a string means remembering the position of a scan pointer, which is just an index. The point of scanning is to move forward a bit at a time, so matches are sought after the scan pointer; usually immediately after it. Given the string "test string", here are the pertinent scan pointer positions: t e s t s t r i n g 0 1 2 ... 1 0 When you #scan for a pattern (a regular expression), the match must occur at the character after the scan pointer. If you use #scan_until, then the match can occur anywhere after the scan pointer. In both cases, the scan pointer moves just beyond the last character of the match, ready to scan again from the next character onwards. This is demonstrated by the example above. == Method Categories There are other methods besides the plain scanners. You can look ahead in the string without actually scanning. You can access the most recent match. You can modify the string being scanned, reset or terminate the scanner, find out or change the position of the scan pointer, skip ahead, and so on. === Advancing the Scan Pointer - #getch - #get_byte - #scan - #scan_until - #skip - #skip_until === Looking Ahead - #check - #check_until - #exist? - #match? - #peek === Finding Where we Are - #beginning_of_line? (#bol?) - #eos? - #rest? - #rest_size - #pos === Setting Where we Are - #reset - #terminate - #pos= === Match Data - #matched - #matched? - #matched_size - #[] - #pre_match - #post_match === Miscellaneous - << - #concat - #string - #string= - #unscan There are aliases to several of the methods.;T;[;![;"I"+ StringScanner provides for lexical scanning operations on a String. Here is an example of its usage: s = StringScanner.new('This is an example string') s.eos? # -> false p s.scan(/\w+/) # -> "This" p s.scan(/\w+/) # -> nil p s.scan(/\s+/) # -> " " p s.scan(/\s+/) # -> nil p s.scan(/\w+/) # -> "is" s.eos? # -> false p s.scan(/\s+/) # -> " " p s.scan(/\w+/) # -> "an" p s.scan(/\s+/) # -> " " p s.scan(/\w+/) # -> "example" p s.scan(/\s+/) # -> " " p s.scan(/\w+/) # -> "string" s.eos? # -> true p s.scan(/\s+/) # -> nil p s.scan(/\w+/) # -> nil Scanning a string means remembering the position of a scan pointer, which is just an index. The point of scanning is to move forward a bit at a time, so matches are sought after the scan pointer; usually immediately after it. Given the string "test string", here are the pertinent scan pointer positions: t e s t s t r i n g 0 1 2 ... 1 0 When you #scan for a pattern (a regular expression), the match must occur at the character after the scan pointer. If you use #scan_until, then the match can occur anywhere after the scan pointer. In both cases, the scan pointer moves just beyond the last character of the match, ready to scan again from the next character onwards. This is demonstrated by the example above. == Method Categories There are other methods besides the plain scanners. You can look ahead in the string without actually scanning. You can access the most recent match. You can modify the string being scanned, reset or terminate the scanner, find out or change the position of the scan pointer, skip ahead, and so on. === Advancing the Scan Pointer - #getch - #get_byte - #scan - #scan_until - #skip - #skip_until === Looking Ahead - #check - #check_until - #exist? - #match? - #peek === Finding Where we Are - #beginning_of_line? (#bol?) - #eos? - #rest? - #rest_size - #pos === Setting Where we Are - #reset - #terminate - #pos= === Match Data - #matched - #matched? - #matched_size - #[] - #pre_match - #post_match === Miscellaneous - << - #concat - #string - #string= - #unscan There are aliases to several of the methods. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;&I"StringScanner;F;'o;( ;)0;*0;+0;;;%@;-@;;o; ;IC;[ o;4;5F;6;;;;&I"Monitor#try_enter;F;7[;[[I"ext/monitor/monitor.c;Ti@;T;:try_enter;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"Rstatic VALUE monitor_try_enter(VALUE monitor) { struct rb_monitor *mc = monitor_ptr(monitor); if (!mc_owner_p(mc)) { if (!rb_mutex_trylock(mc->mutex)) { return Qfalse; } RB_OBJ_WRITE(monitor, &mc->owner, rb_fiber_current()); mc->count = 0; } mc->count += 1; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Monitor#enter;F;7[;[[@iP;T;: enter;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE monitor_enter(VALUE monitor) { struct rb_monitor *mc = monitor_ptr(monitor); if (!mc_owner_p(mc)) { rb_mutex_lock(mc->mutex); RB_OBJ_WRITE(monitor, &mc->owner, rb_fiber_current()); mc->count = 0; } mc->count++; return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Monitor#exit;F;7[;[[@ig;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"fstatic VALUE monitor_exit(VALUE monitor) { monitor_check_owner(monitor); struct rb_monitor *mc = monitor_ptr(monitor); if (mc->count <= 0) rb_bug("monitor_exit: count:%d\n", (int)mc->count); mc->count--; if (mc->count == 0) { RB_OBJ_WRITE(monitor, &mc->owner, Qnil); rb_mutex_unlock(mc->mutex); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Monitor#synchronize;F;7[;[[@i;T;:synchronize;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE monitor_synchronize(VALUE monitor) { monitor_enter(monitor); return rb_ensure(monitor_sync_body, monitor, monitor_sync_ensure, monitor); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Monitor#mon_locked?;F;7[;[[@ix;T;:mon_locked?;0;[;{;IC; "&internal methods for MonitorMixin;T;[o;A ;>I" return;F;?@;0;@[@L;$@ ;![;"I"&internal methods for MonitorMixin;T;#0;$@ ;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE monitor_locked_p(VALUE monitor) { struct rb_monitor *mc = monitor_ptr(monitor); return rb_mutex_locked_p(mc->mutex); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Monitor#mon_check_owner;F;7[;[[@i];T;:mon_check_owner;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE monitor_check_owner(VALUE monitor) { struct rb_monitor *mc = monitor_ptr(monitor); if (!mc_owner_p(mc)) { rb_raise(rb_eThreadError, "current fiber not owner"); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Monitor#mon_owned?;F;7[;[[@i;T;:mon_owned?;0;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@(;![;"@;#0;$@(;Bi;%@;9I"static VALUE monitor_owned_p(VALUE monitor) { struct rb_monitor *mc = monitor_ptr(monitor); return (rb_mutex_locked_p(mc->mutex) && mc_owner_p(mc)) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Monitor#wait_for_cond;F;7[[I" cond;T0[I" timeout;T0;[[@i;T;:wait_for_cond;0;[;{;IC; "9internal methods for MonitorMixin::ConditionVariable ;T;[;![;"I"9internal methods for MonitorMixin::ConditionVariable;T;#0;$@7;.F;/o;0;1T;2i;3i;%@;9I"kstatic VALUE monitor_wait_for_cond(VALUE monitor, VALUE cond, VALUE timeout) { VALUE count = monitor_exit_for_cond(monitor); struct wait_for_cond_data data = { monitor, cond, timeout, count, }; return rb_ensure(monitor_wait_for_cond_body, (VALUE)&data, monitor_enter_for_cond, (VALUE)&data); };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i;F;: Monitor;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I" Monitor;F;'o;( ;)0;*0;+0;;;%@;-@;;o;;IC;[#o;;IC;[o;4;5F;6;;;;&I"Syslog::Constants.included;F;7[[I" target;T0;[[I"ext/syslog/syslog.c;Ti;T;: included;0;[;{;IC; " ;T;[;![;"@;#0;$@];%@[;9I"}static VALUE mSyslogMacros_included(VALUE mod, VALUE target) { rb_extend_object(target, mSyslogMacros); return mod; };T;:I"Astatic VALUE mSyslogMacros_included(VALUE mod, VALUE target);T;;T; @[; IC;[; @[; IC;[o;;IC;[; @n; IC;[; @n; IC;[; @n; IC;{;IC;{;T;IC;{;T;T;{;[;[[@di;F;: Option;;;;;[;{;IC; " ;T;[;![;"@;#0;$@n;%@Y;&I"Syslog::Option;Fo;;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@di;F;: Facility;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@Y;&I"Syslog::Facility;Fo;;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@di;F;: Level;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@Y;&I"Syslog::Level;F; @[; IC;{;IC;{;T;IC;{;T;T;{;[;[[@di;F;:Constants;;;;;[;{;IC; " ;T;[;![;"@;#0;$@[;%@Y;&I"Syslog::Constants;F@n@@o;;IC;[o;4;5F;6;;;;&I"Syslog::Macros#LOG_MASK;F;7[;[;F;: LOG_MASK;;;[;{;IC; "Syslog macros ;T;[;![;"I"Syslog macros;T;#0;$@;.F;/o;0;1T;2i?;3i?;%@;;To;4;5F;6;;;;&I"Syslog::Macros#LOG_UPTO;F;7[[I"pri;T0;[[@di;T;: LOG_UPTO;0;[;{;IC; "[Generates a mask value for priority levels at or below the level specified. See #mask= ;T;[o;= ;>I" overload;F;?0;;;@0;:I"LOG_UPTO(priority_level);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"priority_level;T0;$@;![;"I"{Generates a mask value for priority levels at or below the level specified. See #mask= @overload LOG_UPTO(priority_level);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"nstatic VALUE mSyslogMacros_LOG_UPTO(VALUE mod, VALUE pri) { return INT2FIX(LOG_UPTO(NUM2INT(pri))); };T;:I">static VALUE mSyslogMacros_LOG_UPTO(VALUE mod, VALUE pri);T;;To;4;5F;6;;;;&I"Syslog::Macros.included;F;7[[I" target;T0;[[@di;T;; ;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"}static VALUE mSyslogMacros_included(VALUE mod, VALUE target) { rb_extend_object(target, mSyslogMacros); return mod; };T;:I"Astatic VALUE mSyslogMacros_included(VALUE mod, VALUE target);T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@di;F;: Macros;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@Y;&I"Syslog::Macros;Fo;4;5F;6;;;;&I"Syslog#open;F;7[[@90;[[@di;T;;;0;[;{;IC; "t:yields: syslog Open the syslog facility. Raises a runtime exception if it is already open. Can be called with or without a code block. If called with a block, the Syslog object created is passed to the block. If the syslog is already open, raises a RuntimeError. +ident+ is a String which identifies the calling program. +options+ is the logical OR of any of the following: LOG_CONS:: If there is an error while sending to the system logger, write directly to the console instead. LOG_NDELAY:: Open the connection now, rather than waiting for the first message to be written. LOG_NOWAIT:: Don't wait for any child processes created while logging messages. (Has no effect on Linux.) LOG_ODELAY:: Opposite of LOG_NDELAY; wait until a message is sent before opening the connection. (This is the default.) LOG_PERROR:: Print the message to stderr as well as sending it to syslog. (Not in POSIX.1-2001.) LOG_PID:: Include the current process ID with each message. +facility+ describes the type of program opening the syslog, and is the logical OR of any of the following which are defined for the host OS: LOG_AUTH:: Security or authorization. Deprecated, use LOG_AUTHPRIV instead. LOG_AUTHPRIV:: Security or authorization messages which should be kept private. LOG_CONSOLE:: System console message. LOG_CRON:: System task scheduler (cron or at). LOG_DAEMON:: A system daemon which has no facility value of its own. LOG_FTP:: An FTP server. LOG_KERN:: A kernel message (not sendable by user processes, so not of much use to Ruby, but listed here for completeness). LOG_LPR:: Line printer subsystem. LOG_MAIL:: Mail delivery or transport subsystem. LOG_NEWS:: Usenet news system. LOG_NTP:: Network Time Protocol server. LOG_SECURITY:: General security message. LOG_SYSLOG:: Messages generated internally by syslog. LOG_USER:: Generic user-level message. LOG_UUCP:: UUCP subsystem. LOG_LOCAL0 to LOG_LOCAL7:: Locally-defined facilities. Example: Syslog.open("webrick", Syslog::LOG_PID, Syslog::LOG_DAEMON | Syslog::LOG_LOCAL3) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"#open(ident, options, facility);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" ident;T0[I" options;T0[I" facility;T0;$@;![;"I":yields: syslog Open the syslog facility. Raises a runtime exception if it is already open. Can be called with or without a code block. If called with a block, the Syslog object created is passed to the block. If the syslog is already open, raises a RuntimeError. +ident+ is a String which identifies the calling program. +options+ is the logical OR of any of the following: LOG_CONS:: If there is an error while sending to the system logger, write directly to the console instead. LOG_NDELAY:: Open the connection now, rather than waiting for the first message to be written. LOG_NOWAIT:: Don't wait for any child processes created while logging messages. (Has no effect on Linux.) LOG_ODELAY:: Opposite of LOG_NDELAY; wait until a message is sent before opening the connection. (This is the default.) LOG_PERROR:: Print the message to stderr as well as sending it to syslog. (Not in POSIX.1-2001.) LOG_PID:: Include the current process ID with each message. +facility+ describes the type of program opening the syslog, and is the logical OR of any of the following which are defined for the host OS: LOG_AUTH:: Security or authorization. Deprecated, use LOG_AUTHPRIV instead. LOG_AUTHPRIV:: Security or authorization messages which should be kept private. LOG_CONSOLE:: System console message. LOG_CRON:: System task scheduler (cron or at). LOG_DAEMON:: A system daemon which has no facility value of its own. LOG_FTP:: An FTP server. LOG_KERN:: A kernel message (not sendable by user processes, so not of much use to Ruby, but listed here for completeness). LOG_LPR:: Line printer subsystem. LOG_MAIL:: Mail delivery or transport subsystem. LOG_NEWS:: Usenet news system. LOG_NTP:: Network Time Protocol server. LOG_SECURITY:: General security message. LOG_SYSLOG:: Messages generated internally by syslog. LOG_USER:: Generic user-level message. LOG_UUCP:: UUCP subsystem. LOG_LOCAL0 to LOG_LOCAL7:: Locally-defined facilities. Example: Syslog.open("webrick", Syslog::LOG_PID, Syslog::LOG_DAEMON | Syslog::LOG_LOCAL3) @overload open(ident, options, facility) ;T;#0;$@;.F;C0;%@Y;9I"static VALUE mSyslog_open(int argc, VALUE *argv, VALUE self) { VALUE ident, opt, fac; const char *ident_ptr; if (syslog_opened) { rb_raise(rb_eRuntimeError, "syslog already open"); } rb_scan_args(argc, argv, "03", &ident, &opt, &fac); if (NIL_P(ident)) { ident = rb_gv_get("$0"); } ident_ptr = StringValueCStr(ident); syslog_ident = strdup(ident_ptr); if (NIL_P(opt)) { syslog_options = LOG_PID | LOG_CONS; } else { syslog_options = NUM2INT(opt); } if (NIL_P(fac)) { syslog_facility = LOG_USER; } else { syslog_facility = NUM2INT(fac); } openlog(syslog_ident, syslog_options, syslog_facility); syslog_opened = 1; setlogmask(syslog_mask = setlogmask(0)); /* be like File.new.open {...} */ if (rb_block_given_p()) { rb_ensure(rb_yield, self, mSyslog_close, self); } return self; };T;:I"Astatic VALUE mSyslog_open(int argc, VALUE *argv, VALUE self);T;;To;4;5T;6;;;;&I"Syslog.open;F;7@;@;T;;;0;@;{;IC; "t:yields: syslog Open the syslog facility. Raises a runtime exception if it is already open. Can be called with or without a code block. If called with a block, the Syslog object created is passed to the block. If the syslog is already open, raises a RuntimeError. +ident+ is a String which identifies the calling program. +options+ is the logical OR of any of the following: LOG_CONS:: If there is an error while sending to the system logger, write directly to the console instead. LOG_NDELAY:: Open the connection now, rather than waiting for the first message to be written. LOG_NOWAIT:: Don't wait for any child processes created while logging messages. (Has no effect on Linux.) LOG_ODELAY:: Opposite of LOG_NDELAY; wait until a message is sent before opening the connection. (This is the default.) LOG_PERROR:: Print the message to stderr as well as sending it to syslog. (Not in POSIX.1-2001.) LOG_PID:: Include the current process ID with each message. +facility+ describes the type of program opening the syslog, and is the logical OR of any of the following which are defined for the host OS: LOG_AUTH:: Security or authorization. Deprecated, use LOG_AUTHPRIV instead. LOG_AUTHPRIV:: Security or authorization messages which should be kept private. LOG_CONSOLE:: System console message. LOG_CRON:: System task scheduler (cron or at). LOG_DAEMON:: A system daemon which has no facility value of its own. LOG_FTP:: An FTP server. LOG_KERN:: A kernel message (not sendable by user processes, so not of much use to Ruby, but listed here for completeness). LOG_LPR:: Line printer subsystem. LOG_MAIL:: Mail delivery or transport subsystem. LOG_NEWS:: Usenet news system. LOG_NTP:: Network Time Protocol server. LOG_SECURITY:: General security message. LOG_SYSLOG:: Messages generated internally by syslog. LOG_USER:: Generic user-level message. LOG_UUCP:: UUCP subsystem. LOG_LOCAL0 to LOG_LOCAL7:: Locally-defined facilities. Example: Syslog.open("webrick", Syslog::LOG_PID, Syslog::LOG_DAEMON | Syslog::LOG_LOCAL3);T;[o;= ;>I" overload;F;?0;;;@0;:I"#open(ident, options, facility);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" ident;T0[I" options;T0[I" facility;T0;$@;![;"I":yields: syslog Open the syslog facility. Raises a runtime exception if it is already open. Can be called with or without a code block. If called with a block, the Syslog object created is passed to the block. If the syslog is already open, raises a RuntimeError. +ident+ is a String which identifies the calling program. +options+ is the logical OR of any of the following: LOG_CONS:: If there is an error while sending to the system logger, write directly to the console instead. LOG_NDELAY:: Open the connection now, rather than waiting for the first message to be written. LOG_NOWAIT:: Don't wait for any child processes created while logging messages. (Has no effect on Linux.) LOG_ODELAY:: Opposite of LOG_NDELAY; wait until a message is sent before opening the connection. (This is the default.) LOG_PERROR:: Print the message to stderr as well as sending it to syslog. (Not in POSIX.1-2001.) LOG_PID:: Include the current process ID with each message. +facility+ describes the type of program opening the syslog, and is the logical OR of any of the following which are defined for the host OS: LOG_AUTH:: Security or authorization. Deprecated, use LOG_AUTHPRIV instead. LOG_AUTHPRIV:: Security or authorization messages which should be kept private. LOG_CONSOLE:: System console message. LOG_CRON:: System task scheduler (cron or at). LOG_DAEMON:: A system daemon which has no facility value of its own. LOG_FTP:: An FTP server. LOG_KERN:: A kernel message (not sendable by user processes, so not of much use to Ruby, but listed here for completeness). LOG_LPR:: Line printer subsystem. LOG_MAIL:: Mail delivery or transport subsystem. LOG_NEWS:: Usenet news system. LOG_NTP:: Network Time Protocol server. LOG_SECURITY:: General security message. LOG_SYSLOG:: Messages generated internally by syslog. LOG_USER:: Generic user-level message. LOG_UUCP:: UUCP subsystem. LOG_LOCAL0 to LOG_LOCAL7:: Locally-defined facilities. Example: Syslog.open("webrick", Syslog::LOG_PID, Syslog::LOG_DAEMON | Syslog::LOG_LOCAL3) @overload open(ident, options, facility);T;#0;$@;.F;/o;0;1T;2iM;3i;Bi;%@Y;9@ ;:@ ;;To;4;5F;6;;;;&I"Syslog#reopen;F;7[[@90;[[@di;T;: reopen;0;[;{;IC; "`:yields: syslog Closes and then reopens the syslog. Arguments are the same as for open(). ;T;[o;= ;>I" overload;F;?0;;;@0;:I"%reopen(ident, options, facility);T;IC; ";T;[;![;"I";T;#0;$@$;.F;Bi;C0;7[[I" ident;T0[I" options;T0[I" facility;T0;$@$;![;"I":yields: syslog Closes and then reopens the syslog. Arguments are the same as for open(). @overload reopen(ident, options, facility) ;T;#0;$@$;.F;C0;%@Y;9I"static VALUE mSyslog_reopen(int argc, VALUE *argv, VALUE self) { mSyslog_close(self); return mSyslog_open(argc, argv, self); };T;:I"Cstatic VALUE mSyslog_reopen(int argc, VALUE *argv, VALUE self);T;;To;4;5T;6;;;;&I"Syslog.reopen;F;7@&;@(;T;;;0;@*;{;IC; "`:yields: syslog Closes and then reopens the syslog. Arguments are the same as for open().;T;[o;= ;>I" overload;F;?0;;;@0;:I"%reopen(ident, options, facility);T;IC; ";T;[;![;"I";T;#0;$@@;.F;Bi;C0;7[[I" ident;T0[I" options;T0[I" facility;T0;$@@;![;"I":yields: syslog Closes and then reopens the syslog. Arguments are the same as for open(). @overload reopen(ident, options, facility);T;#0;$@@;.F;/o;0;1T;2i;3i;Bi;%@Y;9@>;:@?;;To;4;5F;6;;;;&I"Syslog#open!;F;7[[@90;[[@di;T;: open!;0;[;{;IC; "`:yields: syslog Closes and then reopens the syslog. Arguments are the same as for open(). ;T;[o;= ;>I" overload;F;?0;;;@0;:I"%reopen(ident, options, facility);T;IC; ";T;[;![;"I";T;#0;$@V;.F;Bi;C0;7[[I" ident;T0[I" options;T0[I" facility;T0;$@V;![;"I":yields: syslog Closes and then reopens the syslog. Arguments are the same as for open(). @overload reopen(ident, options, facility) ;T;#0;$@V;.F;C0;%@Y;9I"static VALUE mSyslog_reopen(int argc, VALUE *argv, VALUE self) { mSyslog_close(self); return mSyslog_open(argc, argv, self); };T;:I"Cstatic VALUE mSyslog_reopen(int argc, VALUE *argv, VALUE self);T;;To;4;5T;6;;;;&I"Syslog.open!;F;7@X;@Z;T;;;0;@\;{;IC; "`:yields: syslog Closes and then reopens the syslog. Arguments are the same as for open().;T;[o;= ;>I" overload;F;?0;;;@0;:I"%reopen(ident, options, facility);T;IC; ";T;[;![;"I";T;#0;$@r;.F;Bi;C0;7[[I" ident;T0[I" options;T0[I" facility;T0;$@r;![;"@T;#0;$@r;.F;/o;0;1T;2i;3i;Bi;%@Y;9@p;:@q;;To;4;5F;6;;;;&I"Syslog#opened?;F;7[;[[@di;T;: opened?;0;[;{;IC; "(Returns true if the syslog is open. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" opened?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"NReturns true if the syslog is open. @overload opened? @return [Boolean] ;T;#0;$@;.F;C0;%@Y;9I"[static VALUE mSyslog_isopen(VALUE self) { return syslog_opened ? Qtrue : Qfalse; };T;:I",static VALUE mSyslog_isopen(VALUE self);T;;To;4;5T;6;;;;&I"Syslog.opened?;F;7@;@;T;;;0;@;{;IC; "(Returns true if the syslog is open.;T;[o;= ;>I" overload;F;?0;;;@0;:I" opened?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"I" overload;F;?0;;;@0;:I"/log(priority, format_string, *format_args);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" priority;T0[I"format_string;T0[I"*format_args;T0;$@;![;"I"SLog a message with the specified priority. Example: Syslog.log(Syslog::LOG_CRIT, "Out of disk space") Syslog.log(Syslog::LOG_CRIT, "User %s logged in", ENV['USER']) The priority levels, in descending order, are: LOG_EMERG:: System is unusable LOG_ALERT:: Action needs to be taken immediately LOG_CRIT:: A critical condition has occurred LOG_ERR:: An error occurred LOG_WARNING:: Warning of a possible problem LOG_NOTICE:: A normal but significant condition occurred LOG_INFO:: Informational message LOG_DEBUG:: Debugging information Each priority level also has a shortcut method that logs with it's named priority. As an example, the two following statements would produce the same result: Syslog.log(Syslog::LOG_ALERT, "Out of memory") Syslog.alert("Out of memory") @overload log(priority, format_string, *format_args) ;T;#0;$@;.F;C0;%@Y;9I"Sstatic VALUE mSyslog_log(int argc, VALUE *argv, VALUE self) { VALUE pri; rb_check_arity(argc, 2, UNLIMITED_ARGUMENTS); argc--; pri = *argv++; if (!FIXNUM_P(pri)) { rb_raise(rb_eTypeError, "type mismatch: %"PRIsVALUE" given", rb_obj_class(pri)); } syslog_write(FIX2INT(pri), argc, argv); return self; };T;:I"@static VALUE mSyslog_log(int argc, VALUE *argv, VALUE self);T;;To;4;5T;6;;;;&I"Syslog.log;F;7@;@;T;;;0;@;{;IC; "Log a message with the specified priority. Example: Syslog.log(Syslog::LOG_CRIT, "Out of disk space") Syslog.log(Syslog::LOG_CRIT, "User %s logged in", ENV['USER']) The priority levels, in descending order, are: LOG_EMERG:: System is unusable LOG_ALERT:: Action needs to be taken immediately LOG_CRIT:: A critical condition has occurred LOG_ERR:: An error occurred LOG_WARNING:: Warning of a possible problem LOG_NOTICE:: A normal but significant condition occurred LOG_INFO:: Informational message LOG_DEBUG:: Debugging information Each priority level also has a shortcut method that logs with it's named priority. As an example, the two following statements would produce the same result: Syslog.log(Syslog::LOG_ALERT, "Out of memory") Syslog.alert("Out of memory");T;[o;= ;>I" overload;F;?0;;;@0;:I"/log(priority, format_string, *format_args);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" priority;T0[I"format_string;T0[I"*format_args;T0;$@;![;"I"ULog a message with the specified priority. Example: Syslog.log(Syslog::LOG_CRIT, "Out of disk space") Syslog.log(Syslog::LOG_CRIT, "User %s logged in", ENV['USER']) The priority levels, in descending order, are: LOG_EMERG:: System is unusable LOG_ALERT:: Action needs to be taken immediately LOG_CRIT:: A critical condition has occurred LOG_ERR:: An error occurred LOG_WARNING:: Warning of a possible problem LOG_NOTICE:: A normal but significant condition occurred LOG_INFO:: Informational message LOG_DEBUG:: Debugging information Each priority level also has a shortcut method that logs with it's named priority. As an example, the two following statements would produce the same result: Syslog.log(Syslog::LOG_ALERT, "Out of memory") Syslog.alert("Out of memory") @overload log(priority, format_string, *format_args);T;#0;$@;.F;/o;0;1T;2i;3i*;Bi;%@Y;9@ ;:@;;To;4;5F;6;;;;&I"Syslog#close;F;7[;[[@di=;T;: close;0;[;{;IC; "NCloses the syslog facility. Raises a runtime exception if it is not open. ;T;[;![;"I"NCloses the syslog facility. Raises a runtime exception if it is not open.;T;#0;$@%;.F;C0;%@Y;9I"1static VALUE mSyslog_close(VALUE self) { if (!syslog_opened) { rb_raise(rb_eRuntimeError, "syslog not opened"); } closelog(); xfree((void *)syslog_ident); syslog_ident = NULL; syslog_options = syslog_facility = syslog_mask = -1; syslog_opened = 0; return Qnil; };T;:I"+static VALUE mSyslog_close(VALUE self);T;;To;4;5T;6;;;;&I"Syslog.close;F;7@';@(;T;;;0;@*;{;IC; "NCloses the syslog facility. Raises a runtime exception if it is not open.;T;[;![;"I"OCloses the syslog facility. Raises a runtime exception if it is not open. ;T;#0;$@2;.F;/o;0;1T;2i:;3i<;Bi;%@Y;9@0;:@1;;To;4;5F;6;;;;&I"Syslog#mask;F;7[;[[@di;T;: mask;0;[;{;IC; "aReturns the log priority mask in effect. The mask is not reset by opening or closing syslog. ;T;[;![;"I"aReturns the log priority mask in effect. The mask is not reset by opening or closing syslog.;T;#0;$@:;.F;C0;%@Y;9I"jstatic VALUE mSyslog_get_mask(VALUE self) { return syslog_opened ? INT2NUM(syslog_mask) : Qnil; };T;:I".static VALUE mSyslog_get_mask(VALUE self);T;;To;4;5T;6;;;;&I"Syslog.mask;F;7@<;@=;T;;;0;@?;{;IC; "aReturns the log priority mask in effect. The mask is not reset by opening or closing syslog.;T;[;![;"I"bReturns the log priority mask in effect. The mask is not reset by opening or closing syslog. ;T;#0;$@G;.F;/o;0;1T;2i;3i;Bi;%@Y;9@E;:@F;;To;4;5F;6;;;;&I"Syslog#mask=;F;7[[I" mask;T0;[[@di;T;: mask=;0;[;{;IC; "Sets the log priority mask. A method LOG_UPTO is defined to make it easier to set mask values. Example: Syslog.mask = Syslog::LOG_UPTO(Syslog::LOG_ERR) Alternatively, specific priorities can be selected and added together using binary OR. Example: Syslog.mask = Syslog::LOG_MASK(Syslog::LOG_ERR) | Syslog::LOG_MASK(Syslog::LOG_CRIT) The priority mask persists through calls to open() and close(). ;T;[o;= ;>I" overload;F;?0;;;@0;:I"mask=(priority_mask);T;IC; ";T;[;![;"I";T;#0;$@O;.F;Bi;C0;7[[I"priority_mask;T0;$@O;![;"I"Sets the log priority mask. A method LOG_UPTO is defined to make it easier to set mask values. Example: Syslog.mask = Syslog::LOG_UPTO(Syslog::LOG_ERR) Alternatively, specific priorities can be selected and added together using binary OR. Example: Syslog.mask = Syslog::LOG_MASK(Syslog::LOG_ERR) | Syslog::LOG_MASK(Syslog::LOG_CRIT) The priority mask persists through calls to open() and close(). @overload mask=(priority_mask) ;T;#0;$@O;.F;C0;%@Y;9I"static VALUE mSyslog_set_mask(VALUE self, VALUE mask) { if (!syslog_opened) { rb_raise(rb_eRuntimeError, "must open syslog before setting log mask"); } setlogmask(syslog_mask = NUM2INT(mask)); return mask; };T;:I":static VALUE mSyslog_set_mask(VALUE self, VALUE mask);T;;To;4;5T;6;;;;&I"Syslog.mask=;F;7@Q;@T;T;;;0;@V;{;IC; "Sets the log priority mask. A method LOG_UPTO is defined to make it easier to set mask values. Example: Syslog.mask = Syslog::LOG_UPTO(Syslog::LOG_ERR) Alternatively, specific priorities can be selected and added together using binary OR. Example: Syslog.mask = Syslog::LOG_MASK(Syslog::LOG_ERR) | Syslog::LOG_MASK(Syslog::LOG_CRIT) The priority mask persists through calls to open() and close().;T;[o;= ;>I" overload;F;?0;;;@0;:I"mask=(priority_mask);T;IC; ";T;[;![;"I";T;#0;$@h;.F;Bi;C0;7[[I"priority_mask;T0;$@h;![;"I"Sets the log priority mask. A method LOG_UPTO is defined to make it easier to set mask values. Example: Syslog.mask = Syslog::LOG_UPTO(Syslog::LOG_ERR) Alternatively, specific priorities can be selected and added together using binary OR. Example: Syslog.mask = Syslog::LOG_MASK(Syslog::LOG_ERR) | Syslog::LOG_MASK(Syslog::LOG_CRIT) The priority mask persists through calls to open() and close(). @overload mask=(priority_mask);T;#0;$@h;.F;/o;0;1T;2i;3i;Bi;%@Y;9@f;:@g;;To;4;5F;6;;;;&I"Syslog.inspect;F;7[;[[@di@;T;;J;0;[;{;IC; ">Returns an inspect() string summarizing the object state. ;T;[;![;"I"?Returns an inspect() string summarizing the object state. ;T;#0;$@z;.F;/o;0;1T;2i>;3i?;%@Y;9I"rstatic VALUE mSyslog_inspect(VALUE self) { Check_Type(self, T_MODULE); if (!syslog_opened) return rb_sprintf("<#%"PRIsVALUE": opened=false>", self); return rb_sprintf("<#%"PRIsVALUE": opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>", self, syslog_ident, syslog_options, syslog_facility, syslog_mask); };T;:I"-static VALUE mSyslog_inspect(VALUE self);T;;To;4;5F;6;;;;&I"Syslog#instance;F;7[;[[@diQ;T;;;0;[;{;IC; ".Returns self, for backward compatibility. ;T;[;![;"I".Returns self, for backward compatibility.;T;#0;$@;.F;C0;%@Y;9I"Cstatic VALUE mSyslog_instance(VALUE self) { return self; };T;:I".static VALUE mSyslog_instance(VALUE self);T;;To;4;5T;6;;;;&I"Syslog.instance;F;7@;@;T;;;0;@;{;IC; ".Returns self, for backward compatibility.;T;[;![;"I"/Returns self, for backward compatibility. ;T;#0;$@;.F;/o;0;1T;2iO;3iP;Bi;%@Y;9@;:@;;T; @Y; IC;[; @Y; IC;[; @Y; IC;{;IC;{;T;IC;{;T;T;{;[;[[@di;F;: Syslog;;;;;[;{;IC; " ;T;[;![;"@;#0;$@Y;Bi;%@;&I" Syslog;Fo; ;IC;[ o;4;5F;6;;;;&I"ThreadGroup#list;F;7[;[[I" thread.c;Ti;T;: list;0;[;{;IC; "Returns an array of all existing Thread objects that belong to this group. ThreadGroup::Default.list #=> [#] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" list;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns an array of all existing Thread objects that belong to this group. ThreadGroup::Default.list #=> [#] @overload list @return [Array];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE thgroup_list(VALUE group) { VALUE ary = rb_ary_new(); rb_thread_t *th = 0; rb_ractor_t *r = GET_RACTOR(); list_for_each(&r->threads.set, th, lt_node) { if (th->thgroup == group) { rb_ary_push(ary, th->self); } } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ThreadGroup#enclose;F;7[;[[@i;T;: enclose;0;[;{;IC; "Prevents threads from being added to or removed from the receiving ThreadGroup. New threads can still be started in an enclosed ThreadGroup. ThreadGroup::Default.enclose #=> # thr = Thread.new { Thread.stop } #=> # tg = ThreadGroup.new #=> # tg.add thr #=> ThreadError: can't move from the enclosed thread group ;T;[o;= ;>I" overload;F;?0;;;@0;:I" enclose;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Prevents threads from being added to or removed from the receiving ThreadGroup. New threads can still be started in an enclosed ThreadGroup. ThreadGroup::Default.enclose #=> # thr = Thread.new { Thread.stop } #=> # tg = ThreadGroup.new #=> # tg.add thr #=> ThreadError: can't move from the enclosed thread group @overload enclose;T;#0;$@;.F;/o;0;1T;2i ;3i;%@;9I"static VALUE thgroup_enclose(VALUE group) { struct thgroup *data; TypedData_Get_Struct(group, struct thgroup, &thgroup_data_type, data); data->enclosed = 1; return group; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ThreadGroup#enclosed?;F;7[;[[@i,;T;:enclosed?;0;[;{;IC; "MReturns +true+ if the +thgrp+ is enclosed. See also ThreadGroup#enclose.;T;[o;= ;>I" overload;F;?0;;;@0;:I"enclosed?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"wReturns +true+ if the +thgrp+ is enclosed. See also ThreadGroup#enclose. @overload enclosed? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i%;3i);Bi;%@;9I"static VALUE thgroup_enclosed_p(VALUE group) { struct thgroup *data; TypedData_Get_Struct(group, struct thgroup, &thgroup_data_type, data); return RBOOL(data->enclosed); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ThreadGroup#add;F;7[[I" thread;T0;[[@iP;T;:add;0;[;{;IC; "sAdds the given +thread+ to this group, removing it from any other group to which it may have previously been a member. puts "Initial group is #{ThreadGroup::Default.list}" tg = ThreadGroup.new t1 = Thread.new { sleep } t2 = Thread.new { sleep } puts "t1 is #{t1}" puts "t2 is #{t2}" tg.add(t1) puts "Initial group now #{ThreadGroup::Default.list}" puts "tg group now #{tg.list}" This will produce: Initial group is # t1 is # t2 is # Initial group now ## tg group now # ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"add(thread);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" thread;T0;$@;![;"I"Adds the given +thread+ to this group, removing it from any other group to which it may have previously been a member. puts "Initial group is #{ThreadGroup::Default.list}" tg = ThreadGroup.new t1 = Thread.new { sleep } t2 = Thread.new { sleep } puts "t1 is #{t1}" puts "t2 is #{t2}" tg.add(t1) puts "Initial group now #{ThreadGroup::Default.list}" puts "tg group now #{tg.list}" This will produce: Initial group is # t1 is # t2 is # Initial group now ## tg group now # @overload add(thread);T;#0;$@;.F;/o;0;1T;2i6;3iL;%@;9I"static VALUE thgroup_add(VALUE group, VALUE thread) { rb_thread_t *target_th = rb_thread_ptr(thread); struct thgroup *data; if (OBJ_FROZEN(group)) { rb_raise(rb_eThreadError, "can't move to the frozen thread group"); } TypedData_Get_Struct(group, struct thgroup, &thgroup_data_type, data); if (data->enclosed) { rb_raise(rb_eThreadError, "can't move to the enclosed thread group"); } if (OBJ_FROZEN(target_th->thgroup)) { rb_raise(rb_eThreadError, "can't move from the frozen thread group"); } TypedData_Get_Struct(target_th->thgroup, struct thgroup, &thgroup_data_type, data); if (data->enclosed) { rb_raise(rb_eThreadError, "can't move from the enclosed thread group"); } target_th->thgroup = group; return group; };T;:I"static VALUE;T;;To;u;[[@it;F;: Default;;w;;;[;{;IC; "\The default ThreadGroup created when Ruby starts; all Threads belong to it by default. ;T;[;![;"I"_ The default ThreadGroup created when Ruby starts; all Threads belong to it by default. ;T;#0;$@;%@;&I"ThreadGroup::Default;F;xI"th->thgroup;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@ik;T;:ThreadGroup;;;;;[;{;IC; "=ThreadGroup provides a means of keeping track of a number of threads as a group. A given Thread object can only belong to one ThreadGroup at a time; adding a thread to a new group will remove it from any previous group. Newly created threads belong to the same group as the thread from which they were created.;T;[;![;"I"@ ThreadGroup provides a means of keeping track of a number of threads as a group. A given Thread object can only belong to one ThreadGroup at a time; adding a thread to a new group will remove it from any previous group. Newly created threads belong to the same group as the thread from which they were created. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;&I"ThreadGroup;F;'o;( ;)0;*0;+0;;;%@;-@;;o; ;IC;[; @3; IC;[; @3; IC;[; @3; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@iw;T;:ThreadError;;;;;[;{;IC; "Raised when an invalid operation is attempted on a thread. For example, when no other thread has been started: Thread.stop This will raises the following exception: ThreadError: stopping only thread note: use sleep to stop forever ;T;[;![;"I" Raised when an invalid operation is attempted on a thread. For example, when no other thread has been started: Thread.stop This will raises the following exception: ThreadError: stopping only thread note: use sleep to stop forever ;T;#0;$@3;.F;/o;0;1T;2i;3i;%@;&I"ThreadError;F;'o;( ;)0;*0;+0;;,;%@;-@;;o; ;IC;[Eo;4;5F;6;;;;&I"Thread.new;F;7[[@90;[[@i;T;;E;0;[;{;IC; "Thread.new(*args, &proc) -> thread Thread.new(*args) { |args| ... } -> thread Creates a new thread executing the given block. Any +args+ given to ::new will be passed to the block: arr = [] a, b, c = 1, 2, 3 Thread.new(a,b,c) { |d,e,f| arr << d << e << f }.join arr #=> [1, 2, 3] A ThreadError exception is raised if ::new is called without a block. If you're going to subclass Thread, be sure to call super in your +initialize+ method, otherwise a ThreadError will be raised. ;T;[;![;"I" Thread.new(*args, &proc) -> thread Thread.new(*args) { |args| ... } -> thread Creates a new thread executing the given block. Any +args+ given to ::new will be passed to the block: arr = [] a, b, c = 1, 2, 3 Thread.new(a,b,c) { |d,e,f| arr << d << e << f }.join arr #=> [1, 2, 3] A ThreadError exception is raised if ::new is called without a block. If you're going to subclass Thread, be sure to call super in your +initialize+ method, otherwise a ThreadError will be raised. ;T;#0;$@J;.F;/o;0;1T;2i;3i;%@H;9I"static VALUE thread_s_new(int argc, VALUE *argv, VALUE klass) { rb_thread_t *th; VALUE thread = rb_thread_alloc(klass); if (GET_RACTOR()->threads.main->status == THREAD_KILLED) { rb_raise(rb_eThreadError, "can't alloc thread"); } rb_obj_call_init_kw(thread, argc, argv, RB_PASS_CALLED_KEYWORDS); th = rb_thread_ptr(thread); if (!threadptr_initialized(th)) { rb_raise(rb_eThreadError, "uninitialized thread - check `%"PRIsVALUE"#initialize'", klass); } return thread; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread.start;F;7[[I" args;T0;[[@i";T;: start;0;[;{;IC; "Basically the same as ::new. However, if class Thread is subclassed, then calling +start+ in that subclass will not invoke the subclass's +initialize+ method. ;T;[o;= ;>I" overload;F;?0;;$;@0;:I"start([args]*);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" args;T;$@Y;![;"I"@yield [args];T;#0;$@Y;.F;Bi;C0;7[[I" [args];T0;$@Yo;= ;>I" overload;F;?0;;;@0;:I"fork([args]*);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" args;T;$@Y;![;"I"@yield [args];T;#0;$@Y;.F;Bi;C0;7[[I" [args];T0;$@Y;![;"I"Basically the same as ::new. However, if class Thread is subclassed, then calling +start+ in that subclass will not invoke the subclass's +initialize+ method. @overload start([args]*) @yield [args] @overload fork([args]*) @yield [args];T;#0;$@Y;.F;/o;0;1T;2i;3i ;%@H;9I"static VALUE thread_start(VALUE klass, VALUE args) { struct thread_create_params params = { .type = thread_invoke_type_proc, .args = args, .proc = rb_block_proc(), }; return thread_create_core(rb_thread_alloc(klass), ¶ms); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread.fork;F;7[[I" args;T0;[[@i";T;;;0;[;{;IC; "Basically the same as ::new. However, if class Thread is subclassed, then calling +start+ in that subclass will not invoke the subclass's +initialize+ method. ;T;[o;= ;>I" overload;F;?0;;$;@0;:I"start([args]*);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" args;T;$@;![;"I"@yield [args];T;#0;$@;.F;Bi;C0;7[[I" [args];T0;$@o;= ;>I" overload;F;?0;;;@0;:I"fork([args]*);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" args;T;$@;![;"I"@yield [args];T;#0;$@;.F;Bi;C0;7[[I" [args];T0;$@;![;"@;#0;$@;.F;/o;0;1T;2i;3i ;%@H;9I"static VALUE thread_start(VALUE klass, VALUE args) { struct thread_create_params params = { .type = thread_invoke_type_proc, .args = args, .proc = rb_block_proc(), }; return thread_create_core(rb_thread_alloc(klass), ¶ms); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread.main;F;7[;[[@ir ;T;: main;0;[;{;IC; "Returns the main thread. ;T;[o;= ;>I" overload;F;?0;;%;@0;:I" main;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I".Returns the main thread. @overload main;T;#0;$@;.F;/o;0;1T;2ik ;3in ;%@H;9I"Pstatic VALUE rb_thread_s_main(VALUE klass) { return rb_thread_main(); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread.current;F;7[;[[@i_ ;T;: current;0;[;{;IC; "^Returns the currently executing thread. Thread.current #=> # ;T;[o;= ;>I" overload;F;?0;;&;@0;:I" current;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"rReturns the currently executing thread. Thread.current #=> # @overload current;T;#0;$@;.F;/o;0;1T;2iV ;3i[ ;%@H;9I"Sstatic VALUE thread_s_current(VALUE klass) { return rb_thread_current(); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread.stop;F;7[;[[@i' ;T;: stop;0;[;{;IC; "Stops execution of the current thread, putting it into a ``sleep'' state, and schedules execution of another thread. a = Thread.new { print "a"; Thread.stop; print "c" } sleep 0.1 while a.status!='sleep' print "b" a.run a.join #=> "abc" ;T;[o;= ;>I" overload;F;?0;;';@0;:I" stop;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I" Stops execution of the current thread, putting it into a ``sleep'' state, and schedules execution of another thread. a = Thread.new { print "a"; Thread.stop; print "c" } sleep 0.1 while a.status!='sleep' print "b" a.run a.join #=> "abc" @overload stop @return [nil];T;#0;$@;.F;/o;0;1T;2i ;3i$ ;%@H;9I"Gstatic VALUE thread_stop(VALUE _) { return rb_thread_stop(); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread.kill;F;7[[I"th;T0;[[@i ;T;: kill;0;[;{;IC; "Causes the given +thread+ to exit, see also Thread::exit. count = 0 a = Thread.new { loop { count += 1 } } sleep(0.1) #=> 0 Thread.kill(a) #=> # count #=> 93947 a.alive? #=> false ;T;[o;= ;>I" overload;F;?0;;(;@0;:I"kill(thread);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" thread;T0;$@;![;"I"Causes the given +thread+ to exit, see also Thread::exit. count = 0 a = Thread.new { loop { count += 1 } } sleep(0.1) #=> 0 Thread.kill(a) #=> # count #=> 93947 a.alive? #=> false @overload kill(thread);T;#0;$@;.F;/o;0;1T;2i ;3i ;%@H;9I"Zstatic VALUE rb_thread_s_kill(VALUE obj, VALUE th) { return rb_thread_kill(th); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread.exit;F;7[;[[@i ;T;;;0;[;{;IC; "Terminates the currently running thread and schedules another thread to be run. If this thread is already marked to be killed, ::exit returns the Thread. If this is the main thread, or the last thread, exit the process. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" exit;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Terminates the currently running thread and schedules another thread to be run. If this thread is already marked to be killed, ::exit returns the Thread. If this is the main thread, or the last thread, exit the process. @overload exit;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@H;9I"vstatic VALUE rb_thread_exit(VALUE _) { rb_thread_t *th = GET_THREAD(); return rb_thread_kill(th->self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread.pass;F;7[;[[@i;T;: pass;0;[;{;IC; "Give the thread scheduler a hint to pass execution to another thread. A running thread may or may not switch, it depends on OS and processor. ;T;[o;= ;>I" overload;F;?0;;);@0;:I" pass;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@+;![;"I"@return [nil];T;#0;$@+;.F;Bi;C0;7[;$@+;![;"I"Give the thread scheduler a hint to pass execution to another thread. A running thread may or may not switch, it depends on OS and processor. @overload pass @return [nil];T;#0;$@+;.F;/o;0;1T;2i;3i;%@H;9I"[static VALUE thread_s_pass(VALUE klass) { rb_thread_schedule(); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread.list;F;7[;[[@iJ ;T;;;0;[;{;IC; "eReturns an array of Thread objects for all threads that are either runnable or stopped. Thread.new { sleep(200) } Thread.new { 1000000.times {|i| i*i } } Thread.new { Thread.stop } Thread.list.each {|t| p t} This will produce: # # # # ;T;[o;= ;>I" overload;F;?0;;;@0;:I" list;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@F;![;"I"@return [Array];T;#0;$@F;.F;Bi;C0;7[;$@F;![;"I"Returns an array of Thread objects for all threads that are either runnable or stopped. Thread.new { sleep(200) } Thread.new { 1000000.times {|i| i*i } } Thread.new { Thread.stop } Thread.list.each {|t| p t} This will produce: # # # # @overload list @return [Array];T;#0;$@F;.F;/o;0;1T;2i6 ;3iG ;%@H;9I"Gstatic VALUE thread_list(VALUE _) { return rb_thread_list(); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread.abort_on_exception;F;7[;[[@i ;T;:abort_on_exception;0;[;{;IC; "Returns the status of the global ``abort on exception'' condition. The default is +false+. When set to +true+, if any thread is aborted by an exception, the raised exception will be re-raised in the main thread. Can also be specified by the global $DEBUG flag or command line option +-d+. See also ::abort_on_exception=. There is also an instance level method to set this for a specific thread, see #abort_on_exception. ;T;[o;= ;>I" overload;F;?0;;*;@0;:I"abort_on_exception;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@a;![;"I"@return [Boolean];T;#0;$@a;.F;Bi;C0;7[;$@a;![;"I"Returns the status of the global ``abort on exception'' condition. The default is +false+. When set to +true+, if any thread is aborted by an exception, the raised exception will be re-raised in the main thread. Can also be specified by the global $DEBUG flag or command line option +-d+. See also ::abort_on_exception=. There is also an instance level method to set this for a specific thread, see #abort_on_exception. @overload abort_on_exception @return [Boolean];T;#0;$@a;.F;/o;0;1T;2iy ;3i ;%@H;9I"sstatic VALUE rb_thread_s_abort_exc(VALUE _) { return RBOOL(GET_THREAD()->vm->thread_abort_on_exception); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread.abort_on_exception=;F;7[[I"val;T0;[[@i ;T;:abort_on_exception=;0;[;{;IC; "aWhen set to +true+, if any thread is aborted by an exception, the raised exception will be re-raised in the main thread. Returns the new state. Thread.abort_on_exception = true t1 = Thread.new do puts "In new thread" raise "Exception from thread" end sleep(1) puts "not reached" This will produce: In new thread prog.rb:4: Exception from thread (RuntimeError) from prog.rb:2:in `initialize' from prog.rb:2:in `new' from prog.rb:2 See also ::abort_on_exception. There is also an instance level method to set this for a specific thread, see #abort_on_exception=. ;T;[o;= ;>I" overload;F;?0;;+;@0;:I"!abort_on_exception=(boolean);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@|;![;"I"@return [Boolean];T;#0;$@|;.F;Bi;C0;7[[I" boolean;T0;$@|;![;"I"When set to +true+, if any thread is aborted by an exception, the raised exception will be re-raised in the main thread. Returns the new state. Thread.abort_on_exception = true t1 = Thread.new do puts "In new thread" raise "Exception from thread" end sleep(1) puts "not reached" This will produce: In new thread prog.rb:4: Exception from thread (RuntimeError) from prog.rb:2:in `initialize' from prog.rb:2:in `new' from prog.rb:2 See also ::abort_on_exception. There is also an instance level method to set this for a specific thread, see #abort_on_exception=. @overload abort_on_exception=(boolean) @return [Boolean];T;#0;$@|;.F;/o;0;1T;2i ;3i ;%@H;9I"static VALUE rb_thread_s_abort_exc_set(VALUE self, VALUE val) { GET_THREAD()->vm->thread_abort_on_exception = RTEST(val); return val; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread.report_on_exception;F;7[;[[@i ;T;:report_on_exception;0;[;{;IC; "^Returns the status of the global ``report on exception'' condition. The default is +true+ since Ruby 2.5. All threads created when this flag is true will report a message on $stderr if an exception kills the thread. Thread.new { 1.times { raise } } will produce this output on $stderr: # terminated with exception (report_on_exception is true): Traceback (most recent call last): 2: from -e:1:in `block in
' 1: from -e:1:in `times' This is done to catch errors in threads early. In some cases, you might not want this output. There are multiple ways to avoid the extra output: * If the exception is not intended, the best is to fix the cause of the exception so it does not happen anymore. * If the exception is intended, it might be better to rescue it closer to where it is raised rather then let it kill the Thread. * If it is guaranteed the Thread will be joined with Thread#join or Thread#value, then it is safe to disable this report with Thread.current.report_on_exception = false when starting the Thread. However, this might handle the exception much later, or not at all if the Thread is never joined due to the parent thread being blocked, etc. See also ::report_on_exception=. There is also an instance level method to set this for a specific thread, see #report_on_exception=. ;T;[o;= ;>I" overload;F;?0;;,;@0;:I"report_on_exception;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the status of the global ``report on exception'' condition. The default is +true+ since Ruby 2.5. All threads created when this flag is true will report a message on $stderr if an exception kills the thread. Thread.new { 1.times { raise } } will produce this output on $stderr: # terminated with exception (report_on_exception is true): Traceback (most recent call last): 2: from -e:1:in `block in
' 1: from -e:1:in `times' This is done to catch errors in threads early. In some cases, you might not want this output. There are multiple ways to avoid the extra output: * If the exception is not intended, the best is to fix the cause of the exception so it does not happen anymore. * If the exception is intended, it might be better to rescue it closer to where it is raised rather then let it kill the Thread. * If it is guaranteed the Thread will be joined with Thread#join or Thread#value, then it is safe to disable this report with Thread.current.report_on_exception = false when starting the Thread. However, this might handle the exception much later, or not at all if the Thread is never joined due to the parent thread being blocked, etc. See also ::report_on_exception=. There is also an instance level method to set this for a specific thread, see #report_on_exception=. @overload report_on_exception @return [Boolean];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@H;9I"ustatic VALUE rb_thread_s_report_exc(VALUE _) { return RBOOL(GET_THREAD()->vm->thread_report_on_exception); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Thread.report_on_exception=;F;7[[I"val;T0;[[@i4 ;T;:report_on_exception=;0;[;{;IC; "Returns the new state. When set to +true+, all threads created afterwards will inherit the condition and report a message on $stderr if an exception kills a thread: Thread.report_on_exception = true t1 = Thread.new do puts "In new thread" raise "Exception from thread" end sleep(1) puts "In the main thread" This will produce: In new thread # terminated with exception (report_on_exception is true): Traceback (most recent call last): prog.rb:4:in `block in
': Exception from thread (RuntimeError) In the main thread See also ::report_on_exception. There is also an instance level method to set this for a specific thread, see #report_on_exception=. ;T;[o;= ;>I" overload;F;?0;;-;@0;:I""report_on_exception=(boolean);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" boolean;T0;$@;![;"I"Returns the new state. When set to +true+, all threads created afterwards will inherit the condition and report a message on $stderr if an exception kills a thread: Thread.report_on_exception = true t1 = Thread.new do puts "In new thread" raise "Exception from thread" end sleep(1) puts "In the main thread" This will produce: In new thread # terminated with exception (report_on_exception is true): Traceback (most recent call last): prog.rb:4:in `block in
': Exception from thread (RuntimeError) In the main thread See also ::report_on_exception. There is also an instance level method to set this for a specific thread, see #report_on_exception=. @overload report_on_exception=(boolean) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i ;3i1 ;%@H;9I"static VALUE rb_thread_s_report_exc_set(VALUE self, VALUE val) { GET_THREAD()->vm->thread_report_on_exception = RTEST(val); return val; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread.ignore_deadlock;F;7[;[[@iG ;T;:ignore_deadlock;0;[;{;IC; "Returns the status of the global ``ignore deadlock'' condition. The default is +false+, so that deadlock conditions are not ignored. See also ::ignore_deadlock=. ;T;[o;= ;>I" overload;F;?0;;.;@0;:I"ignore_deadlock;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the status of the global ``ignore deadlock'' condition. The default is +false+, so that deadlock conditions are not ignored. See also ::ignore_deadlock=. @overload ignore_deadlock @return [Boolean];T;#0;$@;.F;/o;0;1T;2i< ;3iD ;%@H;9I"vstatic VALUE rb_thread_s_ignore_deadlock(VALUE _) { return RBOOL(GET_THREAD()->vm->thread_ignore_deadlock); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread.ignore_deadlock=;F;7[[I"val;T0;[[@ib ;T;:ignore_deadlock=;0;[;{;IC; "Returns the new state. When set to +true+, the VM will not check for deadlock conditions. It is only useful to set this if your application can break a deadlock condition via some other means, such as a signal. Thread.ignore_deadlock = true queue = Thread::Queue.new trap(:SIGUSR1){queue.push "Received signal"} # raises fatal error unless ignoring deadlock puts queue.pop See also ::ignore_deadlock. ;T;[o;= ;>I" overload;F;?0;;/;@0;:I"ignore_deadlock=(boolean);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" boolean;T0;$@;![;"I"Returns the new state. When set to +true+, the VM will not check for deadlock conditions. It is only useful to set this if your application can break a deadlock condition via some other means, such as a signal. Thread.ignore_deadlock = true queue = Thread::Queue.new trap(:SIGUSR1){queue.push "Received signal"} # raises fatal error unless ignoring deadlock puts queue.pop See also ::ignore_deadlock. @overload ignore_deadlock=(boolean) @return [Boolean];T;#0;$@;.F;/o;0;1T;2iN ;3i_ ;%@H;9I"static VALUE rb_thread_s_ignore_deadlock_set(VALUE self, VALUE val) { GET_THREAD()->vm->thread_ignore_deadlock = RTEST(val); return val; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread.DEBUG;F;7[;[[@i5;T;: DEBUG;0;[;{;IC; "VReturns the thread debug level. Available only if compiled with THREAD_DEBUG=-1. ;T;[o;= ;>I" overload;F;?0;;0;@0;:I" DEBUG;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@;![;"I"@return [Numeric];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"|Returns the thread debug level. Available only if compiled with THREAD_DEBUG=-1. @overload DEBUG @return [Numeric];T;#0;$@;.F;/o;0;1T;2i-;3i2;%@H;9I"]static VALUE rb_thread_s_debug(VALUE _) { return INT2NUM(rb_thread_debug_enabled); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread.DEBUG=;F;7[[I"val;T0;[[@iC;T;: DEBUG=;0;[;{;IC; "SSets the thread debug level. Available only if compiled with THREAD_DEBUG=-1. ;T;[o;= ;>I" overload;F;?0;;1;@0;:I"DEBUG=(num);T;IC; ";T;[;![;"I";T;#0;$@*;.F;Bi;C0;7[[I"num;T0;$@*;![;"I"kSets the thread debug level. Available only if compiled with THREAD_DEBUG=-1. @overload DEBUG=(num);T;#0;$@*;.F;/o;0;1T;2i;;3i?;%@H;9I"static VALUE rb_thread_s_debug_set(VALUE self, VALUE val) { rb_thread_debug_enabled = RTEST(val) ? NUM2INT(val) : 0; return val; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread.handle_interrupt;F;7[[I" mask_arg;T0;[[@i;T;:handle_interrupt;0;[;{;IC; " Changes asynchronous interrupt timing. _interrupt_ means asynchronous event and corresponding procedure by Thread#raise, Thread#kill, signal trap (not supported yet) and main thread termination (if main thread terminates, then all other thread will be killed). The given +hash+ has pairs like ExceptionClass => :TimingSymbol. Where the ExceptionClass is the interrupt handled by the given block. The TimingSymbol can be one of the following symbols: [+:immediate+] Invoke interrupts immediately. [+:on_blocking+] Invoke interrupts while _BlockingOperation_. [+:never+] Never invoke all interrupts. _BlockingOperation_ means that the operation will block the calling thread, such as read and write. On CRuby implementation, _BlockingOperation_ is any operation executed without GVL. Masked asynchronous interrupts are delayed until they are enabled. This method is similar to sigprocmask(3). === NOTE Asynchronous interrupts are difficult to use. If you need to communicate between threads, please consider to use another way such as Queue. Or use them with deep understanding about this method. === Usage In this example, we can guard from Thread#raise exceptions. Using the +:never+ TimingSymbol the RuntimeError exception will always be ignored in the first block of the main thread. In the second ::handle_interrupt block we can purposefully handle RuntimeError exceptions. th = Thread.new do Thread.handle_interrupt(RuntimeError => :never) { begin # You can write resource allocation code safely. Thread.handle_interrupt(RuntimeError => :immediate) { # ... } ensure # You can write resource deallocation code safely. end } end Thread.pass # ... th.raise "stop" While we are ignoring the RuntimeError exception, it's safe to write our resource allocation code. Then, the ensure block is where we can safely deallocate your resources. ==== Guarding from Timeout::Error In the next example, we will guard from the Timeout::Error exception. This will help prevent from leaking resources when Timeout::Error exceptions occur during normal ensure clause. For this example we use the help of the standard library Timeout, from lib/timeout.rb require 'timeout' Thread.handle_interrupt(Timeout::Error => :never) { timeout(10){ # Timeout::Error doesn't occur here Thread.handle_interrupt(Timeout::Error => :on_blocking) { # possible to be killed by Timeout::Error # while blocking operation } # Timeout::Error doesn't occur here } } In the first part of the +timeout+ block, we can rely on Timeout::Error being ignored. Then in the Timeout::Error => :on_blocking block, any operation that will block the calling thread is susceptible to a Timeout::Error exception being raised. ==== Stack control settings It's possible to stack multiple levels of ::handle_interrupt blocks in order to control more than one ExceptionClass and TimingSymbol at a time. Thread.handle_interrupt(FooError => :never) { Thread.handle_interrupt(BarError => :never) { # FooError and BarError are prohibited. } } ==== Inheritance with ExceptionClass All exceptions inherited from the ExceptionClass parameter will be considered. Thread.handle_interrupt(Exception => :never) { # all exceptions inherited from Exception are prohibited. } For handling all interrupts, use +Object+ and not +Exception+ as the ExceptionClass, as kill/terminate interrupts are not handled by +Exception+. ;T;[o;= ;>I" overload;F;?0;;2;@0;:I"handle_interrupt(hash);T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@D;![;"I"@yield [];T;#0;$@D;.F;Bi;C0;7[[I" hash;T0;$@D;![;"I"Changes asynchronous interrupt timing. _interrupt_ means asynchronous event and corresponding procedure by Thread#raise, Thread#kill, signal trap (not supported yet) and main thread termination (if main thread terminates, then all other thread will be killed). The given +hash+ has pairs like ExceptionClass => :TimingSymbol. Where the ExceptionClass is the interrupt handled by the given block. The TimingSymbol can be one of the following symbols: [+:immediate+] Invoke interrupts immediately. [+:on_blocking+] Invoke interrupts while _BlockingOperation_. [+:never+] Never invoke all interrupts. _BlockingOperation_ means that the operation will block the calling thread, such as read and write. On CRuby implementation, _BlockingOperation_ is any operation executed without GVL. Masked asynchronous interrupts are delayed until they are enabled. This method is similar to sigprocmask(3). === NOTE Asynchronous interrupts are difficult to use. If you need to communicate between threads, please consider to use another way such as Queue. Or use them with deep understanding about this method. === Usage In this example, we can guard from Thread#raise exceptions. Using the +:never+ TimingSymbol the RuntimeError exception will always be ignored in the first block of the main thread. In the second ::handle_interrupt block we can purposefully handle RuntimeError exceptions. th = Thread.new do Thread.handle_interrupt(RuntimeError => :never) { begin # You can write resource allocation code safely. Thread.handle_interrupt(RuntimeError => :immediate) { # ... } ensure # You can write resource deallocation code safely. end } end Thread.pass # ... th.raise "stop" While we are ignoring the RuntimeError exception, it's safe to write our resource allocation code. Then, the ensure block is where we can safely deallocate your resources. ==== Guarding from Timeout::Error In the next example, we will guard from the Timeout::Error exception. This will help prevent from leaking resources when Timeout::Error exceptions occur during normal ensure clause. For this example we use the help of the standard library Timeout, from lib/timeout.rb require 'timeout' Thread.handle_interrupt(Timeout::Error => :never) { timeout(10){ # Timeout::Error doesn't occur here Thread.handle_interrupt(Timeout::Error => :on_blocking) { # possible to be killed by Timeout::Error # while blocking operation } # Timeout::Error doesn't occur here } } In the first part of the +timeout+ block, we can rely on Timeout::Error being ignored. Then in the Timeout::Error => :on_blocking block, any operation that will block the calling thread is susceptible to a Timeout::Error exception being raised. ==== Stack control settings It's possible to stack multiple levels of ::handle_interrupt blocks in order to control more than one ExceptionClass and TimingSymbol at a time. Thread.handle_interrupt(FooError => :never) { Thread.handle_interrupt(BarError => :never) { # FooError and BarError are prohibited. } } ==== Inheritance with ExceptionClass All exceptions inherited from the ExceptionClass parameter will be considered. Thread.handle_interrupt(Exception => :never) { # all exceptions inherited from Exception are prohibited. } For handling all interrupts, use +Object+ and not +Exception+ as the ExceptionClass, as kill/terminate interrupts are not handled by +Exception+. @overload handle_interrupt(hash) @yield [];T;#0;$@D;.F;/o;0;1T;2iT;3i;%@H;9I"tstatic VALUE rb_thread_s_handle_interrupt(VALUE self, VALUE mask_arg) { VALUE mask; rb_execution_context_t * volatile ec = GET_EC(); rb_thread_t * volatile th = rb_ec_thread_ptr(ec); volatile VALUE r = Qnil; enum ruby_tag_type state; if (!rb_block_given_p()) { rb_raise(rb_eArgError, "block is needed."); } mask = 0; mask_arg = rb_to_hash_type(mask_arg); rb_hash_foreach(mask_arg, handle_interrupt_arg_check_i, (VALUE)&mask); if (!mask) { return rb_yield(Qnil); } OBJ_FREEZE_RAW(mask); rb_ary_push(th->pending_interrupt_mask_stack, mask); if (!rb_threadptr_pending_interrupt_empty_p(th)) { th->pending_interrupt_queue_checked = 0; RUBY_VM_SET_INTERRUPT(th->ec); } EC_PUSH_TAG(th->ec); if ((state = EC_EXEC_TAG()) == TAG_NONE) { r = rb_yield(Qnil); } EC_POP_TAG(); rb_ary_pop(th->pending_interrupt_mask_stack); if (!rb_threadptr_pending_interrupt_empty_p(th)) { th->pending_interrupt_queue_checked = 0; RUBY_VM_SET_INTERRUPT(th->ec); } RUBY_VM_CHECK_INTS(th->ec); if (state) { EC_JUMP_TAG(th->ec, state); } return r; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread.pending_interrupt?;F;7[[@90;[[@iI ;T;:pending_interrupt?;0;[;{;IC; "Returns whether or not the asynchronous queue is empty. Since Thread::handle_interrupt can be used to defer asynchronous events, this method can be used to determine if there are any deferred events. If you find this method returns true, then you may finish +:never+ blocks. For example, the following method processes deferred asynchronous events immediately. def Thread.kick_interrupt_immediately Thread.handle_interrupt(Object => :immediate) { Thread.pass } end If +error+ is given, then check only for +error+ type deferred events. === Usage th = Thread.new{ Thread.handle_interrupt(RuntimeError => :on_blocking){ while true ... # reach safe point to invoke interrupt if Thread.pending_interrupt? Thread.handle_interrupt(Object => :immediate){} end ... end } } ... th.raise # stop thread This example can also be written as the following, which you should use to avoid asynchronous interrupts. flag = true th = Thread.new{ Thread.handle_interrupt(RuntimeError => :on_blocking){ while true ... # reach safe point to invoke interrupt break if flag == false ... end } } ... flag = false # stop thread;T;[o;= ;>I" overload;F;?0;;3;@0;:I"$pending_interrupt?(error = nil);T;IC; ";T;[;![;"I";T;#0;$@a;.F;Bi;C0;7[[I" error;TI"nil;T;$@ao;A ;>I" return;F;?@;0;@[@L;$@a;![;"I" Returns whether or not the asynchronous queue is empty. Since Thread::handle_interrupt can be used to defer asynchronous events, this method can be used to determine if there are any deferred events. If you find this method returns true, then you may finish +:never+ blocks. For example, the following method processes deferred asynchronous events immediately. def Thread.kick_interrupt_immediately Thread.handle_interrupt(Object => :immediate) { Thread.pass } end If +error+ is given, then check only for +error+ type deferred events. === Usage th = Thread.new{ Thread.handle_interrupt(RuntimeError => :on_blocking){ while true ... # reach safe point to invoke interrupt if Thread.pending_interrupt? Thread.handle_interrupt(Object => :immediate){} end ... end } } ... th.raise # stop thread This example can also be written as the following, which you should use to avoid asynchronous interrupts. flag = true th = Thread.new{ Thread.handle_interrupt(RuntimeError => :on_blocking){ while true ... # reach safe point to invoke interrupt break if flag == false ... end } } ... flag = false # stop thread @overload pending_interrupt?(error = nil);T;#0;$@a;.F;/o;0;1T;2i ;3iE ;Bi;%@H;9I"static VALUE rb_thread_s_pending_interrupt_p(int argc, VALUE *argv, VALUE self) { return rb_thread_pending_interrupt_p(argc, argv, GET_THREAD()->self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#pending_interrupt?;F;7[[@90;[[@i;T;;3;0;[;{;IC; "Returns whether or not the asynchronous queue is empty for the target thread. If +error+ is given, then check only for +error+ type deferred events. See ::pending_interrupt? for more information.;T;[o;= ;>I" overload;F;?0;;3;@0;:I"$pending_interrupt?(error = nil);T;IC; ";T;[;![;"I";T;#0;$@~;.F;Bi;C0;7[[I" error;TI"nil;T;$@~o;A ;>I" return;F;?@;0;@[@L;$@~;![;"I"Returns whether or not the asynchronous queue is empty for the target thread. If +error+ is given, then check only for +error+ type deferred events. See ::pending_interrupt? for more information. @overload pending_interrupt?(error = nil);T;#0;$@~;.F;/o;0;1T;2i;3i;Bi;%@H;9I"wstatic VALUE rb_thread_pending_interrupt_p(int argc, VALUE *argv, VALUE target_thread) { rb_thread_t *target_th = rb_thread_ptr(target_thread); if (!target_th->pending_interrupt_queue) { return Qfalse; } if (rb_threadptr_pending_interrupt_empty_p(target_th)) { return Qfalse; } if (rb_check_arity(argc, 0, 1)) { VALUE err = argv[0]; if (!rb_obj_is_kind_of(err, rb_cModule)) { rb_raise(rb_eTypeError, "class or module required for rescue clause"); } return RBOOL(rb_threadptr_pending_interrupt_include_p(target_th, err)); } else { return Qtrue; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#initialize;F;7[[I" args;T0;[[@i9;T;;D;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2i8;3i8;%@H;9I"kstatic VALUE thread_initialize(VALUE thread, VALUE args) { rb_thread_t *th = rb_thread_ptr(thread); if (!rb_block_given_p()) { rb_raise(rb_eThreadError, "must be called with a block"); } else if (th->invoke_type != thread_invoke_type_none) { VALUE loc = threadptr_invoke_proc_location(th); if (!NIL_P(loc)) { rb_raise(rb_eThreadError, "already initialized thread - %"PRIsVALUE":%"PRIsVALUE, RARRAY_AREF(loc, 0), RARRAY_AREF(loc, 1)); } else { rb_raise(rb_eThreadError, "already initialized thread"); } } else { struct thread_create_params params = { .type = thread_invoke_type_proc, .args = args, .proc = rb_block_proc(), }; return thread_create_core(thread, ¶ms); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#raise;F;7[[@90;[[@i[ ;T;;;0;[;{;IC; "]Raises an exception from the given thread. The caller does not have to be +thr+. See Kernel#raise for more information. Thread.abort_on_exception = true a = Thread.new { sleep(200) } a.raise("Gotcha") This will produce: prog.rb:3: Gotcha (RuntimeError) from prog.rb:2:in `initialize' from prog.rb:2:in `new' from prog.rb:2 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" raise;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"raise(string);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"*raise(exception [, string [, array]]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I""exception[, string [, array]];T0;$@;![;"I"Raises an exception from the given thread. The caller does not have to be +thr+. See Kernel#raise for more information. Thread.abort_on_exception = true a = Thread.new { sleep(200) } a.raise("Gotcha") This will produce: prog.rb:3: Gotcha (RuntimeError) from prog.rb:2:in `initialize' from prog.rb:2:in `new' from prog.rb:2 @overload raise @overload raise(string) @overload raise(exception [, string [, array]]);T;#0;$@;.F;/o;0;1T;2iF ;3iW ;%@H;9I"static VALUE thread_raise_m(int argc, VALUE *argv, VALUE self) { rb_thread_t *target_th = rb_thread_ptr(self); const rb_thread_t *current_th = GET_THREAD(); threadptr_check_pending_interrupt_queue(target_th); rb_threadptr_raise(target_th, argc, argv); /* To perform Thread.current.raise as Kernel.raise */ if (current_th == target_th) { RUBY_VM_CHECK_INTS(target_th->ec); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#join;F;7[[@90;[[@i$;T;: join;0;[;{;IC; "The calling thread will suspend execution and run this +thr+. Does not return until +thr+ exits or until the given +limit+ seconds have passed. If the time limit expires, +nil+ will be returned, otherwise +thr+ is returned. Any threads not joined will be killed when the main program exits. If +thr+ had previously raised an exception and the ::abort_on_exception or $DEBUG flags are not set, (so the exception has not yet been processed), it will be processed at this time. a = Thread.new { print "a"; sleep(10); print "b"; print "c" } x = Thread.new { print "x"; Thread.pass; print "y"; print "z" } x.join # Let thread x finish, thread a will be killed on exit. #=> "axyz" The following example illustrates the +limit+ parameter. y = Thread.new { 4.times { sleep 0.1; puts 'tick... ' }} puts "Waiting" until y.join(0.15) This will produce: tick... Waiting tick... Waiting tick... tick... ;T;[o;= ;>I" overload;F;?0;;4;@0;:I" join;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;4;@0;:I"join(limit);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" limit;T0;$@;![;"I"The calling thread will suspend execution and run this +thr+. Does not return until +thr+ exits or until the given +limit+ seconds have passed. If the time limit expires, +nil+ will be returned, otherwise +thr+ is returned. Any threads not joined will be killed when the main program exits. If +thr+ had previously raised an exception and the ::abort_on_exception or $DEBUG flags are not set, (so the exception has not yet been processed), it will be processed at this time. a = Thread.new { print "a"; sleep(10); print "b"; print "c" } x = Thread.new { print "x"; Thread.pass; print "y"; print "z" } x.join # Let thread x finish, thread a will be killed on exit. #=> "axyz" The following example illustrates the +limit+ parameter. y = Thread.new { 4.times { sleep 0.1; puts 'tick... ' }} puts "Waiting" until y.join(0.15) This will produce: tick... Waiting tick... Waiting tick... tick... @overload join @overload join(limit);T;#0;$@;.F;/o;0;1T;2i;3i ;%@H;9I"static VALUE thread_join_m(int argc, VALUE *argv, VALUE self) { VALUE timeout = Qnil; rb_hrtime_t rel = 0, *limit = 0; if (rb_check_arity(argc, 0, 1)) { timeout = argv[0]; } // Convert the timeout eagerly, so it's always converted and deterministic /* * This supports INFINITY and negative values, so we can't use * rb_time_interval right now... */ if (NIL_P(timeout)) { /* unlimited */ } else if (FIXNUM_P(timeout)) { rel = rb_sec2hrtime(NUM2TIMET(timeout)); limit = &rel; } else { limit = double2hrtime(&rel, rb_num2dbl(timeout)); } return thread_join(rb_thread_ptr(self), timeout, limit); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#value;F;7[;[[@iO;T;: value;0;[;{;IC; " Waits for +thr+ to complete, using #join, and returns its value or raises the exception which terminated the thread. a = Thread.new { 2 + 2 } a.value #=> 4 b = Thread.new { raise 'something went wrong' } b.value #=> RuntimeError: something went wrong ;T;[o;= ;>I" overload;F;?0;;5;@0;:I" value;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"1Waits for +thr+ to complete, using #join, and returns its value or raises the exception which terminated the thread. a = Thread.new { 2 + 2 } a.value #=> 4 b = Thread.new { raise 'something went wrong' } b.value #=> RuntimeError: something went wrong @overload value @return [Object];T;#0;$@;.F;/o;0;1T;2iA;3iL;%@H;9I"static VALUE thread_value(VALUE self) { rb_thread_t *th = rb_thread_ptr(self); thread_join(th, Qnil, 0); return th->value; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#kill;F;7[;[[@iw ;T;;(;0;[;{;IC; "Terminates +thr+ and schedules another thread to be run, returning the terminated Thread. If this is the main thread, or the last thread, exits the process. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" exit;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;(;@0;:I" kill;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"terminate;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Terminates +thr+ and schedules another thread to be run, returning the terminated Thread. If this is the main thread, or the last thread, exits the process. @overload exit @overload kill @overload terminate;T;#0;$@;.F;/o;0;1T;2il ;3is ;%@H;9I"MVALUE rb_thread_kill(VALUE thread) { rb_thread_t *th = rb_thread_ptr(thread); if (th->to_kill || th->status == THREAD_KILLED) { return thread; } if (th == th->vm->ractor.main_thread) { rb_exit(EXIT_SUCCESS); } thread_debug("rb_thread_kill: %p (%"PRI_THREAD_ID")\n", (void *)th, thread_id_str(th)); if (th == GET_THREAD()) { /* kill myself immediately */ rb_threadptr_to_kill(th); } else { threadptr_check_pending_interrupt_queue(th); rb_threadptr_pending_interrupt_enque(th, eKillSignal); rb_threadptr_interrupt(th); } return thread; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Thread#terminate;F;7[;[[@iw ;T;;;0;[;{;IC; "Terminates +thr+ and schedules another thread to be run, returning the terminated Thread. If this is the main thread, or the last thread, exits the process. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" exit;T;IC; ";T;[;![;"I";T;#0;$@8;.F;Bi;C0;7[;$@8o;= ;>I" overload;F;?0;;(;@0;:I" kill;T;IC; ";T;[;![;"I";T;#0;$@8;.F;Bi;C0;7[;$@8o;= ;>I" overload;F;?0;;;@0;:I"terminate;T;IC; ";T;[;![;"I";T;#0;$@8;.F;Bi;C0;7[;$@8;![;"@4;#0;$@8;.F;/o;0;1T;2il ;3is ;%@H;9I"MVALUE rb_thread_kill(VALUE thread) { rb_thread_t *th = rb_thread_ptr(thread); if (th->to_kill || th->status == THREAD_KILLED) { return thread; } if (th == th->vm->ractor.main_thread) { rb_exit(EXIT_SUCCESS); } thread_debug("rb_thread_kill: %p (%"PRI_THREAD_ID")\n", (void *)th, thread_id_str(th)); if (th == GET_THREAD()) { /* kill myself immediately */ rb_threadptr_to_kill(th); } else { threadptr_check_pending_interrupt_queue(th); rb_threadptr_pending_interrupt_enque(th, eKillSignal); rb_threadptr_interrupt(th); } return thread; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Thread#exit;F;7[;[[@iw ;T;;;0;[;{;IC; "Terminates +thr+ and schedules another thread to be run, returning the terminated Thread. If this is the main thread, or the last thread, exits the process. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" exit;T;IC; ";T;[;![;"I";T;#0;$@];.F;Bi;C0;7[;$@]o;= ;>I" overload;F;?0;;(;@0;:I" kill;T;IC; ";T;[;![;"I";T;#0;$@];.F;Bi;C0;7[;$@]o;= ;>I" overload;F;?0;;;@0;:I"terminate;T;IC; ";T;[;![;"I";T;#0;$@];.F;Bi;C0;7[;$@];![;"@4;#0;$@];.F;/o;0;1T;2il ;3is ;%@H;9I"MVALUE rb_thread_kill(VALUE thread) { rb_thread_t *th = rb_thread_ptr(thread); if (th->to_kill || th->status == THREAD_KILLED) { return thread; } if (th == th->vm->ractor.main_thread) { rb_exit(EXIT_SUCCESS); } thread_debug("rb_thread_kill: %p (%"PRI_THREAD_ID")\n", (void *)th, thread_id_str(th)); if (th == GET_THREAD()) { /* kill myself immediately */ rb_threadptr_to_kill(th); } else { threadptr_check_pending_interrupt_queue(th); rb_threadptr_pending_interrupt_enque(th, eKillSignal); rb_threadptr_interrupt(th); } return thread; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Thread#run;F;7[;[[@i ;T;:run;0;[;{;IC; "Wakes up +thr+, making it eligible for scheduling. a = Thread.new { puts "a"; Thread.stop; puts "c" } sleep 0.1 while a.status!='sleep' puts "Got here" a.run a.join This will produce: a Got here c See also the instance method #wakeup. ;T;[o;= ;>I" overload;F;?0;;6;@0;:I"run;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Wakes up +thr+, making it eligible for scheduling. a = Thread.new { puts "a"; Thread.stop; puts "c" } sleep 0.1 while a.status!='sleep' puts "Got here" a.run a.join This will produce: a Got here c See also the instance method #wakeup. @overload run;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@H;9I"uVALUE rb_thread_run(VALUE thread) { rb_thread_wakeup(thread); rb_thread_schedule(); return thread; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Thread#wakeup;F;7[;[[@i ;T;: wakeup;0;[;{;IC; "!Marks a given thread as eligible for scheduling, however it may still remain blocked on I/O. *Note:* This does not invoke the scheduler, see #run for more information. c = Thread.new { Thread.stop; puts "hey!" } sleep 0.1 while c.status!='sleep' c.wakeup c.join #=> "hey!" ;T;[o;= ;>I" overload;F;?0;;7;@0;:I" wakeup;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"4Marks a given thread as eligible for scheduling, however it may still remain blocked on I/O. *Note:* This does not invoke the scheduler, see #run for more information. c = Thread.new { Thread.stop; puts "hey!" } sleep 0.1 while c.status!='sleep' c.wakeup c.join #=> "hey!" @overload wakeup;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@H;9I"VALUE rb_thread_wakeup(VALUE thread) { if (!RTEST(rb_thread_wakeup_alive(thread))) { rb_raise(rb_eThreadError, "killed thread"); } return thread; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Thread#[];F;7[[I"key;T0;[[@i ;T;;;0;[;{;IC; "Attribute Reference---Returns the value of a fiber-local variable (current thread's root fiber if not explicitly inside a Fiber), using either a symbol or a string name. If the specified variable does not exist, returns +nil+. [ Thread.new { Thread.current["name"] = "A" }, Thread.new { Thread.current[:name] = "B" }, Thread.new { Thread.current["name"] = "C" } ].each do |th| th.join puts "#{th.inspect}: #{th[:name]}" end This will produce: #: A #: B #: C Thread#[] and Thread#[]= are not thread-local but fiber-local. This confusion did not exist in Ruby 1.8 because fibers are only available since Ruby 1.9. Ruby 1.9 chooses that the methods behaves fiber-local to save following idiom for dynamic scope. def meth(newvalue) begin oldvalue = Thread.current[:name] Thread.current[:name] = newvalue yield ensure Thread.current[:name] = oldvalue end end The idiom may not work as dynamic scope if the methods are thread-local and a given block switches fiber. f = Fiber.new { meth(1) { Fiber.yield } } meth(2) { f.resume } f.resume p Thread.current[:name] #=> nil if fiber-local #=> 2 if thread-local (The value 2 is leaked to outside of meth method.) For thread-local variables, please see #thread_variable_get and #thread_variable_set. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" [](sym);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@;![;"I"@return [Object, nil];T;#0;$@;.F;Bi;C0;7[[I"sym;T0;$@;![;"I"Attribute Reference---Returns the value of a fiber-local variable (current thread's root fiber if not explicitly inside a Fiber), using either a symbol or a string name. If the specified variable does not exist, returns +nil+. [ Thread.new { Thread.current["name"] = "A" }, Thread.new { Thread.current[:name] = "B" }, Thread.new { Thread.current["name"] = "C" } ].each do |th| th.join puts "#{th.inspect}: #{th[:name]}" end This will produce: #: A #: B #: C Thread#[] and Thread#[]= are not thread-local but fiber-local. This confusion did not exist in Ruby 1.8 because fibers are only available since Ruby 1.9. Ruby 1.9 chooses that the methods behaves fiber-local to save following idiom for dynamic scope. def meth(newvalue) begin oldvalue = Thread.current[:name] Thread.current[:name] = newvalue yield ensure Thread.current[:name] = oldvalue end end The idiom may not work as dynamic scope if the methods are thread-local and a given block switches fiber. f = Fiber.new { meth(1) { Fiber.yield } } meth(2) { f.resume } f.resume p Thread.current[:name] #=> nil if fiber-local #=> 2 if thread-local (The value 2 is leaked to outside of meth method.) For thread-local variables, please see #thread_variable_get and #thread_variable_set. @overload [](sym) @return [Object, nil];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@H;9I"static VALUE rb_thread_aref(VALUE thread, VALUE key) { ID id = rb_check_id(&key); if (!id) return Qnil; return rb_thread_local_aref(thread, id); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#[]=;F;7[[I"id;T0[I"val;T0;[[@iH;T;:[]=;0;[;{;IC; "Attribute Assignment---Sets or creates the value of a fiber-local variable, using either a symbol or a string. See also Thread#[]. For thread-local variables, please see #thread_variable_set and #thread_variable_get. ;T;[o;= ;>I" overload;F;?0;;8;@0;:I" []=(sym);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I"sym;T0;$@;![;"I"Attribute Assignment---Sets or creates the value of a fiber-local variable, using either a symbol or a string. See also Thread#[]. For thread-local variables, please see #thread_variable_set and #thread_variable_get. @overload []=(sym) @return [Object];T;#0;$@;.F;/o;0;1T;2i;;3iE;%@H;9I"static VALUE rb_thread_aset(VALUE self, VALUE id, VALUE val) { return rb_thread_local_aset(self, rb_to_id(id), val); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#fetch;F;7[[@90;[[@i ;T;: fetch;0;[;{;IC; "JReturns a fiber-local for the given key. If the key can't be found, there are several options: With no other arguments, it will raise a KeyError exception; if default is given, then that will be returned; if the optional code block is specified, then that will be run and its result returned. See Thread#[] and Hash#fetch. ;T;[o;= ;>I" overload;F;?0;;9;@0;:I"fetch(sym);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I"sym;T0;$@o;= ;>I" overload;F;?0;;9;@0;:I"fetch(sym);T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@yield [] @return [Object];T;#0;$@;.F;Bi;C0;7[[I"sym;T0;$@o;= ;>I" overload;F;?0;;9;@0;:I"fetch(sym, default);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I"sym;T0[I" default;T0;$@;![;"I"Returns a fiber-local for the given key. If the key can't be found, there are several options: With no other arguments, it will raise a KeyError exception; if default is given, then that will be returned; if the optional code block is specified, then that will be run and its result returned. See Thread#[] and Hash#fetch. @overload fetch(sym) @return [Object] @overload fetch(sym) @yield [] @return [Object] @overload fetch(sym, default) @return [Object];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@H;9I"-static VALUE rb_thread_fetch(int argc, VALUE *argv, VALUE self) { VALUE key, val; ID id; rb_thread_t *target_th = rb_thread_ptr(self); int block_given; rb_check_arity(argc, 1, 2); key = argv[0]; block_given = rb_block_given_p(); if (block_given && argc == 2) { rb_warn("block supersedes default value argument"); } id = rb_check_id(&key); if (id == recursive_key) { return target_th->ec->local_storage_recursive_hash; } else if (id && target_th->ec->local_storage && rb_id_table_lookup(target_th->ec->local_storage, id, &val)) { return val; } else if (block_given) { return rb_yield(key); } else if (argc == 1) { rb_key_err_raise(rb_sprintf("key not found: %+"PRIsVALUE, key), self, key); } else { return argv[1]; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#key?;F;7[[I"key;T0;[[@i;T;: key?;0;[;{;IC; "Returns +true+ if the given string (or symbol) exists as a fiber-local variable. me = Thread.current me[:oliver] = "a" me.key?(:oliver) #=> true me.key?(:stanley) #=> false;T;[o;= ;>I" overload;F;?0;;:;@0;:I"key?(sym);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@0;![;"I"@return [Boolean];T;#0;$@0;.F;Bi;C0;7[[I"sym;T0;$@0;![;"I"Returns +true+ if the given string (or symbol) exists as a fiber-local variable. me = Thread.current me[:oliver] = "a" me.key?(:oliver) #=> true me.key?(:stanley) #=> false @overload key?(sym) @return [Boolean];T;#0;$@0;.F;/o;0;1T;2i;3i;Bi;%@H;9I"3static VALUE rb_thread_key_p(VALUE self, VALUE key) { VALUE val; ID id = rb_check_id(&key); struct rb_id_table *local_storage = rb_thread_ptr(self)->ec->local_storage; if (!id || local_storage == NULL) { return Qfalse; } return RBOOL(rb_id_table_lookup(local_storage, id, &val)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#keys;F;7[;[[@i;T;: keys;0;[;{;IC; "Returns an array of the names of the fiber-local variables (as Symbols). thr = Thread.new do Thread.current[:cat] = 'meow' Thread.current["dog"] = 'woof' end thr.join #=> # thr.keys #=> [:dog, :cat] ;T;[o;= ;>I" overload;F;?0;;;;@0;:I" keys;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@O;![;"I"@return [Array];T;#0;$@O;.F;Bi;C0;7[;$@O;![;"I"Returns an array of the names of the fiber-local variables (as Symbols). thr = Thread.new do Thread.current[:cat] = 'meow' Thread.current["dog"] = 'woof' end thr.join #=> # thr.keys #=> [:dog, :cat] @overload keys @return [Array];T;#0;$@O;.F;/o;0;1T;2i;3i;%@H;9I" static VALUE rb_thread_keys(VALUE self) { struct rb_id_table *local_storage = rb_thread_ptr(self)->ec->local_storage; VALUE ary = rb_ary_new(); if (local_storage) { rb_id_table_foreach(local_storage, thread_keys_i, (void *)ary); } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#priority;F;7[;[[@i";T;: priority;0;[;{;IC; "Returns the priority of thr. Default is inherited from the current thread which creating the new thread, or zero for the initial main thread; higher-priority thread will run more frequently than lower-priority threads (but lower-priority threads can also run). This is just hint for Ruby thread scheduler. It may be ignored on some platform. Thread.current.priority #=> 0 ;T;[o;= ;>I" overload;F;?0;;<;@0;:I" priority;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@j;![;"I"@return [Integer];T;#0;$@j;.F;Bi;C0;7[;$@j;![;"I"Returns the priority of thr. Default is inherited from the current thread which creating the new thread, or zero for the initial main thread; higher-priority thread will run more frequently than lower-priority threads (but lower-priority threads can also run). This is just hint for Ruby thread scheduler. It may be ignored on some platform. Thread.current.priority #=> 0 @overload priority @return [Integer];T;#0;$@j;.F;/o;0;1T;2i;3i;%@H;9I"kstatic VALUE rb_thread_priority(VALUE thread) { return INT2NUM(rb_thread_ptr(thread)->priority); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#priority=;F;7[[I" prio;T0;[[@iC;T;:priority=;0;[;{;IC; "Sets the priority of thr to integer. Higher-priority threads will run more frequently than lower-priority threads (but lower-priority threads can also run). This is just hint for Ruby thread scheduler. It may be ignored on some platform. count1 = count2 = 0 a = Thread.new do loop { count1 += 1 } end a.priority = -1 b = Thread.new do loop { count2 += 1 } end b.priority = -2 sleep 1 #=> 1 count1 #=> 622504 count2 #=> 5832 ;T;[o;= ;>I" overload;F;?0;;=;@0;:I"priority=(integer);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" integer;T0;$@;![;"I"Sets the priority of thr to integer. Higher-priority threads will run more frequently than lower-priority threads (but lower-priority threads can also run). This is just hint for Ruby thread scheduler. It may be ignored on some platform. count1 = count2 = 0 a = Thread.new do loop { count1 += 1 } end a.priority = -1 b = Thread.new do loop { count2 += 1 } end b.priority = -2 sleep 1 #=> 1 count1 #=> 622504 count2 #=> 5832 @overload priority=(integer);T;#0;$@;.F;/o;0;1T;2i);3i?;%@H;9I"1static VALUE rb_thread_priority_set(VALUE thread, VALUE prio) { rb_thread_t *target_th = rb_thread_ptr(thread); int priority; #if USE_NATIVE_THREAD_PRIORITY target_th->priority = NUM2INT(prio); native_thread_apply_priority(th); #else priority = NUM2INT(prio); if (priority > RUBY_THREAD_PRIORITY_MAX) { priority = RUBY_THREAD_PRIORITY_MAX; } else if (priority < RUBY_THREAD_PRIORITY_MIN) { priority = RUBY_THREAD_PRIORITY_MIN; } target_th->priority = (int8_t)priority; #endif return INT2NUM(target_th->priority); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#status;F;7[;[[@i ;T;: status;0;[;{;IC; "Returns the status of +thr+. ["sleep"] Returned if this thread is sleeping or waiting on I/O ["run"] When this thread is executing ["aborting"] If this thread is aborting [+false+] When this thread is terminated normally [+nil+] If terminated with an exception. a = Thread.new { raise("die now") } b = Thread.new { Thread.stop } c = Thread.new { Thread.exit } d = Thread.new { sleep } d.kill #=> # a.status #=> nil b.status #=> "sleep" c.status #=> false d.status #=> "aborting" Thread.current.status #=> "run" See also the instance methods #alive? and #stop? ;T;[o;= ;>I" overload;F;?0;;>;@0;:I" status;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI" false;TI"nil;T;$@;![;"I"!@return [String, false, nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the status of +thr+. ["sleep"] Returned if this thread is sleeping or waiting on I/O ["run"] When this thread is executing ["aborting"] If this thread is aborting [+false+] When this thread is terminated normally [+nil+] If terminated with an exception. a = Thread.new { raise("die now") } b = Thread.new { Thread.stop } c = Thread.new { Thread.exit } d = Thread.new { sleep } d.kill #=> # a.status #=> nil b.status #=> "sleep" c.status #=> false d.status #=> "aborting" Thread.current.status #=> "run" See also the instance methods #alive? and #stop? @overload status @return [String, false, nil];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@H;9I"cstatic VALUE rb_thread_status(VALUE thread) { rb_thread_t *target_th = rb_thread_ptr(thread); if (rb_threadptr_dead(target_th)) { if (!NIL_P(target_th->ec->errinfo) && !FIXNUM_P(target_th->ec->errinfo)) { return Qnil; } else { return Qfalse; } } else { return rb_str_new2(thread_status_name(target_th, FALSE)); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#thread_variable_get;F;7[[I"key;T0;[[@ij;T;:thread_variable_get;0;[;{;IC; "WReturns the value of a thread local variable that has been set. Note that these are different than fiber local values. For fiber local values, please see Thread#[] and Thread#[]=. Thread local values are carried along with threads, and do not respect fibers. For example: Thread.new { Thread.current.thread_variable_set("foo", "bar") # set a thread local Thread.current["foo"] = "bar" # set a fiber local Fiber.new { Fiber.yield [ Thread.current.thread_variable_get("foo"), # get the thread local Thread.current["foo"], # get the fiber local ] }.resume }.join.value # => ['bar', nil] The value "bar" is returned for the thread local, where nil is returned for the fiber local. The fiber is executed in the same thread, so the thread local values are available. ;T;[o;= ;>I" overload;F;?0;;?;@0;:I"thread_variable_get(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@;![;"I"@return [Object, nil];T;#0;$@;.F;Bi;C0;7[[I"key;T0;$@;![;"I"Returns the value of a thread local variable that has been set. Note that these are different than fiber local values. For fiber local values, please see Thread#[] and Thread#[]=. Thread local values are carried along with threads, and do not respect fibers. For example: Thread.new { Thread.current.thread_variable_set("foo", "bar") # set a thread local Thread.current["foo"] = "bar" # set a fiber local Fiber.new { Fiber.yield [ Thread.current.thread_variable_get("foo"), # get the thread local Thread.current["foo"], # get the fiber local ] }.resume }.join.value # => ['bar', nil] The value "bar" is returned for the thread local, where nil is returned for the fiber local. The fiber is executed in the same thread, so the thread local values are available. @overload thread_variable_get(key) @return [Object, nil];T;#0;$@;.F;/o;0;1T;2iN;3ig;%@H;9I"static VALUE rb_thread_variable_get(VALUE thread, VALUE key) { VALUE locals; if (LIKELY(!THREAD_LOCAL_STORAGE_INITIALISED_P(thread))) { return Qnil; } locals = rb_thread_local_storage(thread); return rb_hash_aref(locals, rb_to_symbol(key)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#thread_variable_set;F;7[[I"key;T0[I"val;T0;[[@i;T;:thread_variable_set;0;[;{;IC; "Sets a thread local with +key+ to +value+. Note that these are local to threads, and not to fibers. Please see Thread#thread_variable_get and Thread#[] for more information. ;T;[o;= ;>I" overload;F;?0;;@;@0;:I"$thread_variable_set(key, value);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"key;T0[I" value;T0;$@;![;"I"Sets a thread local with +key+ to +value+. Note that these are local to threads, and not to fibers. Please see Thread#thread_variable_get and Thread#[] for more information. @overload thread_variable_set(key, value);T;#0;$@;.F;/o;0;1T;2iv;3i{;%@H;9I"6static VALUE rb_thread_variable_set(VALUE thread, VALUE key, VALUE val) { VALUE locals; if (OBJ_FROZEN(thread)) { rb_frozen_error_raise(thread, "can't modify frozen thread locals"); } locals = rb_thread_local_storage(thread); return rb_hash_aset(locals, rb_to_symbol(key), val); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#thread_variables;F;7[;[[@i;T;:thread_variables;0;[;{;IC; "Returns an array of the names of the thread-local variables (as Symbols). thr = Thread.new do Thread.current.thread_variable_set(:cat, 'meow') Thread.current.thread_variable_set("dog", 'woof') end thr.join #=> # thr.thread_variables #=> [:dog, :cat] Note that these are not fiber local variables. Please see Thread#[] and Thread#thread_variable_get for more details. ;T;[o;= ;>I" overload;F;?0;;A;@0;:I"thread_variables;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns an array of the names of the thread-local variables (as Symbols). thr = Thread.new do Thread.current.thread_variable_set(:cat, 'meow') Thread.current.thread_variable_set("dog", 'woof') end thr.join #=> # thr.thread_variables #=> [:dog, :cat] Note that these are not fiber local variables. Please see Thread#[] and Thread#thread_variable_get for more details. @overload thread_variables @return [Array];T;#0;$@;.F;/o;0;1T;2i;3i;%@H;9I".static VALUE rb_thread_variables(VALUE thread) { VALUE locals; VALUE ary; ary = rb_ary_new(); if (LIKELY(!THREAD_LOCAL_STORAGE_INITIALISED_P(thread))) { return ary; } locals = rb_thread_local_storage(thread); rb_hash_foreach(locals, keys_i, ary); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#thread_variable?;F;7[[I"key;T0;[[@i;T;:thread_variable?;0;[;{;IC; "aReturns +true+ if the given string (or symbol) exists as a thread-local variable. me = Thread.current me.thread_variable_set(:oliver, "a") me.thread_variable?(:oliver) #=> true me.thread_variable?(:stanley) #=> false Note that these are not fiber local variables. Please see Thread#[] and Thread#thread_variable_get for more details.;T;[o;= ;>I" overload;F;?0;;B;@0;:I"thread_variable?(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ ;![;"I"@return [Boolean];T;#0;$@ ;.F;Bi;C0;7[[I"key;T0;$@ ;![;"I"Returns +true+ if the given string (or symbol) exists as a thread-local variable. me = Thread.current me.thread_variable_set(:oliver, "a") me.thread_variable?(:oliver) #=> true me.thread_variable?(:stanley) #=> false Note that these are not fiber local variables. Please see Thread#[] and Thread#thread_variable_get for more details. @overload thread_variable?(key) @return [Boolean];T;#0;$@ ;.F;/o;0;1T;2i;3i;Bi;%@H;9I"!static VALUE rb_thread_variable_p(VALUE thread, VALUE key) { VALUE locals; if (LIKELY(!THREAD_LOCAL_STORAGE_INITIALISED_P(thread))) { return Qfalse; } locals = rb_thread_local_storage(thread); return RBOOL(rb_hash_lookup(locals, rb_to_symbol(key)) != Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#alive?;F;7[;[[@i ;T;: alive?;0;[;{;IC; "Returns +true+ if +thr+ is running or sleeping. thr = Thread.new { } thr.join #=> # Thread.current.alive? #=> true thr.alive? #=> false See also #stop? and #status.;T;[o;= ;>I" overload;F;?0;;C;@0;:I" alive?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@4 ;![;"I"@return [Boolean];T;#0;$@4 ;.F;Bi;C0;7[;$@4 ;![;"I"Returns +true+ if +thr+ is running or sleeping. thr = Thread.new { } thr.join #=> # Thread.current.alive? #=> true thr.alive? #=> false See also #stop? and #status. @overload alive? @return [Boolean];T;#0;$@4 ;.F;/o;0;1T;2i ;3i ;Bi;%@H;9I"pstatic VALUE rb_thread_alive_p(VALUE thread) { return RBOOL(!thread_finished(rb_thread_ptr(thread))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#stop?;F;7[;[[@i ;T;: stop?;0;[;{;IC; "Returns +true+ if +thr+ is dead or sleeping. a = Thread.new { Thread.stop } b = Thread.current a.stop? #=> true b.stop? #=> false See also #alive? and #status.;T;[o;= ;>I" overload;F;?0;;D;@0;:I" stop?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@O ;![;"I"@return [Boolean];T;#0;$@O ;.F;Bi;C0;7[;$@O ;![;"I"Returns +true+ if +thr+ is dead or sleeping. a = Thread.new { Thread.stop } b = Thread.current a.stop? #=> true b.stop? #=> false See also #alive? and #status. @overload stop? @return [Boolean];T;#0;$@O ;.F;/o;0;1T;2i ;3i ;Bi;%@H;9I"static VALUE rb_thread_stop_p(VALUE thread) { rb_thread_t *th = rb_thread_ptr(thread); if (rb_threadptr_dead(th)) { return Qtrue; } return RBOOL(th->status == THREAD_STOPPED || th->status == THREAD_STOPPED_FOREVER); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#abort_on_exception;F;7[;[[@i ;T;;*;0;[;{;IC; "Returns the status of the thread-local ``abort on exception'' condition for this +thr+. The default is +false+. See also #abort_on_exception=. There is also a class level method to set this for all threads, see ::abort_on_exception. ;T;[o;= ;>I" overload;F;?0;;*;@0;:I"abort_on_exception;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@j ;![;"I"@return [Boolean];T;#0;$@j ;.F;Bi;C0;7[;$@j ;![;"I"Returns the status of the thread-local ``abort on exception'' condition for this +thr+. The default is +false+. See also #abort_on_exception=. There is also a class level method to set this for all threads, see ::abort_on_exception. @overload abort_on_exception @return [Boolean];T;#0;$@j ;.F;/o;0;1T;2i ;3i ;%@H;9I"tstatic VALUE rb_thread_abort_exc(VALUE thread) { return RBOOL(rb_thread_ptr(thread)->abort_on_exception); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#abort_on_exception=;F;7[[I"val;T0;[[@i ;T;;+;0;[;{;IC; "When set to +true+, if this +thr+ is aborted by an exception, the raised exception will be re-raised in the main thread. See also #abort_on_exception. There is also a class level method to set this for all threads, see ::abort_on_exception=. ;T;[o;= ;>I" overload;F;?0;;+;@0;:I"!abort_on_exception=(boolean);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ ;![;"I"@return [Boolean];T;#0;$@ ;.F;Bi;C0;7[[I" boolean;T0;$@ ;![;"I"0When set to +true+, if this +thr+ is aborted by an exception, the raised exception will be re-raised in the main thread. See also #abort_on_exception. There is also a class level method to set this for all threads, see ::abort_on_exception=. @overload abort_on_exception=(boolean) @return [Boolean];T;#0;$@ ;.F;/o;0;1T;2i ;3i ;%@H;9I"static VALUE rb_thread_abort_exc_set(VALUE thread, VALUE val) { rb_thread_ptr(thread)->abort_on_exception = RTEST(val); return val; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#report_on_exception;F;7[;[[@iz ;T;;,;0;[;{;IC; "@Returns the status of the thread-local ``report on exception'' condition for this +thr+. The default value when creating a Thread is the value of the global flag Thread.report_on_exception. See also #report_on_exception=. There is also a class level method to set this for all new threads, see ::report_on_exception=. ;T;[o;= ;>I" overload;F;?0;;,;@0;:I"report_on_exception;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ ;![;"I"@return [Boolean];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"tReturns the status of the thread-local ``report on exception'' condition for this +thr+. The default value when creating a Thread is the value of the global flag Thread.report_on_exception. See also #report_on_exception=. There is also a class level method to set this for all new threads, see ::report_on_exception=. @overload report_on_exception @return [Boolean];T;#0;$@ ;.F;/o;0;1T;2ij ;3iw ;%@H;9I"vstatic VALUE rb_thread_report_exc(VALUE thread) { return RBOOL(rb_thread_ptr(thread)->report_on_exception); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Thread#report_on_exception=;F;7[[I"val;T0;[[@i ;T;;-;0;[;{;IC; "When set to +true+, a message is printed on $stderr if an exception kills this +thr+. See ::report_on_exception for details. See also #report_on_exception. There is also a class level method to set this for all new threads, see ::report_on_exception=. ;T;[o;= ;>I" overload;F;?0;;-;@0;:I""report_on_exception=(boolean);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ ;![;"I"@return [Boolean];T;#0;$@ ;.F;Bi;C0;7[[I" boolean;T0;$@ ;![;"I"<When set to +true+, a message is printed on $stderr if an exception kills this +thr+. See ::report_on_exception for details. See also #report_on_exception. There is also a class level method to set this for all new threads, see ::report_on_exception=. @overload report_on_exception=(boolean) @return [Boolean];T;#0;$@ ;.F;/o;0;1T;2i ;3i ;%@H;9I"static VALUE rb_thread_report_exc_set(VALUE thread, VALUE val) { rb_thread_ptr(thread)->report_on_exception = RTEST(val); return val; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#group;F;7[;[[@i ;T;: group;0;[;{;IC; "sReturns the ThreadGroup which contains the given thread. Thread.main.group #=> # ;T;[o;= ;>I" overload;F;?0;;E;@0;:I" group;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@ ;![;"I"@return [nil];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Returns the ThreadGroup which contains the given thread. Thread.main.group #=> # @overload group @return [nil];T;#0;$@ ;.F;/o;0;1T;2i ;3i ;%@H;9I"WVALUE rb_thread_group(VALUE thread) { return rb_thread_ptr(thread)->thgroup; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Thread#backtrace;F;7[[@90;[[@i;T;;K;0;[;{;IC; "8Returns the current backtrace of the target thread. ;T;[o;= ;>I" overload;F;?0;;K;@0;:I"backtrace;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;TI"nil;T;$@ ;![;"I"@return [Array, nil];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"fReturns the current backtrace of the target thread. @overload backtrace @return [Array, nil];T;#0;$@ ;.F;/o;0;1T;2i;3i;%@H;9I"static VALUE rb_thread_backtrace_m(int argc, VALUE *argv, VALUE thval) { return rb_vm_thread_backtrace(argc, argv, thval); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#backtrace_locations;F;7[[@90;[[@i;T;;L;0;[;{;IC; "Returns the execution stack for the target thread---an array containing backtrace location objects. See Thread::Backtrace::Location for more information. This method behaves similarly to Kernel#caller_locations except it applies to a specific thread. ;T;[o;= ;>I" overload;F;?0;;L;@0;:I"/backtrace_locations(*args) -> array or nil;T;IC; ";T;[;![;"I";T;#0;$@!;.F;Bi;C0;7[[I" *args;T0;$@!;![;"I"3Returns the execution stack for the target thread---an array containing backtrace location objects. See Thread::Backtrace::Location for more information. This method behaves similarly to Kernel#caller_locations except it applies to a specific thread. @overload backtrace_locations(*args) -> array or nil;T;#0;$@!;.F;/o;0;1T;2i;3i;%@H;9I"static VALUE rb_thread_backtrace_locations_m(int argc, VALUE *argv, VALUE thval) { return rb_vm_thread_backtrace_locations(argc, argv, thval); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#name;F;7[;[[@i$ ;T;: name;0;[;{;IC; "!show the name of the thread. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I" name;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@/!;![;"I"@return [String];T;#0;$@/!;.F;Bi;C0;7[;$@/!;![;"I"Eshow the name of the thread. @overload name @return [String];T;#0;$@/!;.F;/o;0;1T;2i ;3i! ;%@H;9I"]static VALUE rb_thread_getname(VALUE thread) { return rb_thread_ptr(thread)->name; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#name=;F;7[[I" name;T0;[[@i2 ;T;: name=;0;[;{;IC; "gset given name to the ruby thread. On some platform, it may set the name to pthread and/or kernel. ;T;[o;= ;>I" overload;F;?0;;G;@0;:I"name=(name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@J!;![;"I"@return [String];T;#0;$@J!;.F;Bi;C0;7[[I" name;T0;$@J!;![;"I"set given name to the ruby thread. On some platform, it may set the name to pthread and/or kernel. @overload name=(name) @return [String];T;#0;$@J!;.F;/o;0;1T;2i* ;3i/ ;%@H;9I"static VALUE rb_thread_setname(VALUE thread, VALUE name) { rb_thread_t *target_th = rb_thread_ptr(thread); if (!NIL_P(name)) { rb_encoding *enc; StringValueCStr(name); enc = rb_enc_get(name); if (!rb_enc_asciicompat(enc)) { rb_raise(rb_eArgError, "ASCII incompatible encoding (%s)", rb_enc_name(enc)); } name = rb_str_new_frozen(name); } target_th->name = name; if (threadptr_initialized(target_th)) { native_set_another_thread_name(target_th->thread_id, name); } return name; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#native_thread_id;F;7[;[[@i_ ;T;:native_thread_id;0;[;{;IC; "Return the native thread ID which is used by the Ruby thread. The ID depends on the OS. (not POSIX thread ID returned by pthread_self(3)) * On Linux it is TID returned by gettid(2). * On macOS it is the system-wide unique integral ID of thread returned by pthread_threadid_np(3). * On FreeBSD it is the unique integral ID of the thread returned by pthread_getthreadid_np(3). * On Windows it is the thread identifier returned by GetThreadId(). * On other platforms, it raises NotImplementedError. NOTE: If the thread is not associated yet or already deassociated with a native thread, it returns _nil_. If the Ruby implementation uses M:N thread model, the ID may change depending on the timing. ;T;[o;= ;>I" overload;F;?0;;H;@0;:I"native_thread_id;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@i!;![;"I"@return [Integer];T;#0;$@i!;.F;Bi;C0;7[;$@i!;![;"I"Return the native thread ID which is used by the Ruby thread. The ID depends on the OS. (not POSIX thread ID returned by pthread_self(3)) * On Linux it is TID returned by gettid(2). * On macOS it is the system-wide unique integral ID of thread returned by pthread_threadid_np(3). * On FreeBSD it is the unique integral ID of the thread returned by pthread_getthreadid_np(3). * On Windows it is the thread identifier returned by GetThreadId(). * On other platforms, it raises NotImplementedError. NOTE: If the thread is not associated yet or already deassociated with a native thread, it returns _nil_. If the Ruby implementation uses M:N thread model, the ID may change depending on the timing. @overload native_thread_id @return [Integer];T;#0;$@i!;.F;/o;0;1T;2iI ;3i\ ;%@H;9I"static VALUE rb_thread_native_thread_id(VALUE thread) { rb_thread_t *target_th = rb_thread_ptr(thread); if (rb_threadptr_dead(target_th)) return Qnil; return native_thread_native_thread_id(target_th); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#to_s;F;7[;[[@iq ;T;;G;0;[;{;IC; "8Dump the name, id, and status of _thr_ to a string. ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@!;![;"I"@return [String];T;#0;$@!;.F;Bi;C0;7[;$@!;![;"I"\Dump the name, id, and status of _thr_ to a string. @overload to_s @return [String];T;#0;$o;4;5F;6;;;;&I"Thread#inspect;F;7[;[[@if;F;;J;;;[;{;@!;%@H;9I"static VALUE rb_thread_to_s(VALUE thread) { VALUE cname = rb_class_path(rb_obj_class(thread)); rb_thread_t *target_th = rb_thread_ptr(thread); const char *status; VALUE str, loc; status = thread_status_name(target_th, TRUE); str = rb_sprintf("#<%"PRIsVALUE":%p", cname, (void *)thread); if (!NIL_P(target_th->name)) { rb_str_catf(str, "@%"PRIsVALUE, target_th->name); } if ((loc = threadptr_invoke_proc_location(target_th)) != Qnil) { rb_str_catf(str, " %"PRIsVALUE":%"PRIsVALUE, RARRAY_AREF(loc, 0), RARRAY_AREF(loc, 1)); } rb_str_catf(str, " %s>", status); return str; };T;:I"static VALUE;T;.F;/o;0;1T;2ij ;3in ;%@H;9I"static VALUE rb_thread_to_s(VALUE thread) { VALUE cname = rb_class_path(rb_obj_class(thread)); rb_thread_t *target_th = rb_thread_ptr(thread); const char *status; VALUE str, loc; status = thread_status_name(target_th, TRUE); str = rb_sprintf("#<%"PRIsVALUE":%p", cname, (void *)thread); if (!NIL_P(target_th->name)) { rb_str_catf(str, "@%"PRIsVALUE, target_th->name); } if ((loc = threadptr_invoke_proc_location(target_th)) != Qnil) { rb_str_catf(str, " %"PRIsVALUE":%"PRIsVALUE, RARRAY_AREF(loc, 0), RARRAY_AREF(loc, 1)); } rb_str_catf(str, " %s>", status); return str; };T;:@!;;T@!o;4;5F;6;;;;&I"#Thread#__infinite_loop_dlsym__;F;7[[I" name;T0;[[I"4ext/-test-/popen_deadlock/infinite_loop_dlsym.c;Ti%;T;:__infinite_loop_dlsym__;0;[;{;IC; " ;T;[;![;"@;#0;$@!;%@H;9I" static VALUE loop_dlsym(VALUE self, VALUE name) { struct data_for_loop_dlsym d; d.stop = 0; d.name = StringValuePtr(name); rb_thread_call_without_gvl(native_loop_dlsym, &d, ubf_for_loop_dlsym, &d); return self; };T;:I"static VALUE;T;;To; ;IC;[o;4;5F;6;;;;&I"Thread::Backtrace.limit;F;7[;[[@KiC;T;: limit;0;[;{;IC; " Returns maximum backtrace length set by --backtrace-limit command-line option. The defalt is -1 which means unlimited backtraces. If the value is zero or positive, the error backtraces, produced by Exception#full_message, are abbreviated and the extra lines are replaced by ... 3 levels... $ ruby -r net/http -e "p Thread::Backtrace.limit; Net::HTTP.get(URI('http://wrong.address'))" - 1 .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': Failed to open TCP connection to wrong.address:80 (getaddrinfo: Name or service not known) (SocketError) from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' from .../lib/ruby/3.1.0/net/http.rb:998:in `connect' from .../lib/ruby/3.1.0/net/http.rb:976:in `do_start' from .../lib/ruby/3.1.0/net/http.rb:965:in `start' from .../lib/ruby/3.1.0/net/http.rb:627:in `start' from .../lib/ruby/3.1.0/net/http.rb:503:in `get_response' from .../lib/ruby/3.1.0/net/http.rb:474:in `get' .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError) from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' from .../lib/ruby/3.1.0/net/http.rb:998:in `connect' from .../lib/ruby/3.1.0/net/http.rb:976:in `do_start' from .../lib/ruby/3.1.0/net/http.rb:965:in `start' from .../lib/ruby/3.1.0/net/http.rb:627:in `start' from .../lib/ruby/3.1.0/net/http.rb:503:in `get_response' from .../lib/ruby/3.1.0/net/http.rb:474:in `get' from -e:1:in `
' $ ruby --backtrace-limit 2 -r net/http -e "p Thread::Backtrace.limit; Net::HTTP.get(URI('http://wrong.address'))" 2 .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': Failed to open TCP connection to wrong.address:80 (getaddrinfo: Name or service not known) (SocketError) from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' ... 7 levels... .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError) from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' ... 7 levels... $ ruby --backtrace-limit 0 -r net/http -e "p Thread::Backtrace.limit; Net::HTTP.get(URI('http://wrong.address'))" 0 .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': Failed to open TCP connection to wrong.address:80 (getaddrinfo: Name or service not known) (SocketError) ... 9 levels... .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError) ... 9 levels... ;T;[o;= ;>I" overload;F;?0;:Threade::Backtrace::limit;@0;:I"Threade::Backtrace::limit;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@!;![;"I"@return [Integer];T;#0;$@!;.F;Bi;C0;7[;$@!;![;"I" Returns maximum backtrace length set by --backtrace-limit command-line option. The defalt is -1 which means unlimited backtraces. If the value is zero or positive, the error backtraces, produced by Exception#full_message, are abbreviated and the extra lines are replaced by ... 3 levels... $ ruby -r net/http -e "p Thread::Backtrace.limit; Net::HTTP.get(URI('http://wrong.address'))" - 1 .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': Failed to open TCP connection to wrong.address:80 (getaddrinfo: Name or service not known) (SocketError) from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' from .../lib/ruby/3.1.0/net/http.rb:998:in `connect' from .../lib/ruby/3.1.0/net/http.rb:976:in `do_start' from .../lib/ruby/3.1.0/net/http.rb:965:in `start' from .../lib/ruby/3.1.0/net/http.rb:627:in `start' from .../lib/ruby/3.1.0/net/http.rb:503:in `get_response' from .../lib/ruby/3.1.0/net/http.rb:474:in `get' .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError) from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' from .../lib/ruby/3.1.0/net/http.rb:998:in `connect' from .../lib/ruby/3.1.0/net/http.rb:976:in `do_start' from .../lib/ruby/3.1.0/net/http.rb:965:in `start' from .../lib/ruby/3.1.0/net/http.rb:627:in `start' from .../lib/ruby/3.1.0/net/http.rb:503:in `get_response' from .../lib/ruby/3.1.0/net/http.rb:474:in `get' from -e:1:in `
' $ ruby --backtrace-limit 2 -r net/http -e "p Thread::Backtrace.limit; Net::HTTP.get(URI('http://wrong.address'))" 2 .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': Failed to open TCP connection to wrong.address:80 (getaddrinfo: Name or service not known) (SocketError) from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' ... 7 levels... .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError) from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' ... 7 levels... $ ruby --backtrace-limit 0 -r net/http -e "p Thread::Backtrace.limit; Net::HTTP.get(URI('http://wrong.address'))" 0 .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': Failed to open TCP connection to wrong.address:80 (getaddrinfo: Name or service not known) (SocketError) ... 9 levels... .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError) ... 9 levels... @overload Threade::Backtrace::limit @return [Integer];T;#0;$@!;.F;/o;0;1T;2i;3iB;%@!;9I"astatic VALUE backtrace_limit(VALUE self) { return LONG2NUM(rb_backtrace_length_limit); };T;:I"static VALUE;T;;To; ;IC;[ o;4;5F;6;;;;&I"'Thread::Backtrace::Location#lineno;F;7[;[[@Ki;T;: lineno;0;[;{;IC; "Returns the line number of this frame. For example, using +caller_locations.rb+ from Thread::Backtrace::Location loc = c(0..1).first loc.lineno #=> 2 ;T;[;![;"I"Returns the line number of this frame. For example, using +caller_locations.rb+ from Thread::Backtrace::Location loc = c(0..1).first loc.lineno #=> 2 ;T;#0;$@!;.F;/o;0;1T;2i;3i;%@!;9I"lstatic VALUE location_lineno_m(VALUE self) { return INT2FIX(location_lineno(location_ptr(self))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&Thread::Backtrace::Location#label;F;7[;[[@Ki;T;: label;0;[;{;IC; "Returns the label of this frame. Usually consists of method, class, module, etc names with decoration. Consider the following example: def foo puts caller_locations(0).first.label 1.times do puts caller_locations(0).first.label 1.times do puts caller_locations(0).first.label end end end The result of calling +foo+ is this: label: foo label: block in foo label: block (2 levels) in foo ;T;[;![;"I"Returns the label of this frame. Usually consists of method, class, module, etc names with decoration. Consider the following example: def foo puts caller_locations(0).first.label 1.times do puts caller_locations(0).first.label 1.times do puts caller_locations(0).first.label end end end The result of calling +foo+ is this: label: foo label: block in foo label: block (2 levels) in foo ;T;#0;$@!;.F;/o;0;1T;2i;3i;%@!;9I"astatic VALUE location_label_m(VALUE self) { return location_label(location_ptr(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+Thread::Backtrace::Location#base_label;F;7[;[[@Ki;T;:base_label;0;[;{;IC; "WReturns the base label of this frame. Usually same as #label, without decoration. ;T;[;![;"I"XReturns the base label of this frame. Usually same as #label, without decoration. ;T;#0;$@!;.F;/o;0;1T;2i;3i;%@!;9I"kstatic VALUE location_base_label_m(VALUE self) { return location_base_label(location_ptr(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%Thread::Backtrace::Location#path;F;7[;[[@Ki6;T;: path;0;[;{;IC; "?Returns the file name of this frame. This will generally be an absolute path, unless the frame is in the main script, in which case it will be the script location passed on the command line. For example, using +caller_locations.rb+ from Thread::Backtrace::Location loc = c(0..1).first loc.path #=> caller_locations.rb ;T;[;![;"I"@Returns the file name of this frame. This will generally be an absolute path, unless the frame is in the main script, in which case it will be the script location passed on the command line. For example, using +caller_locations.rb+ from Thread::Backtrace::Location loc = c(0..1).first loc.path #=> caller_locations.rb ;T;#0;$@!;.F;/o;0;1T;2i,;3i4;%@!;9I"static VALUE location_path_m(VALUE self) { const rb_iseq_t *iseq = location_iseq(location_ptr(self)); return iseq ? rb_iseq_path(iseq) : Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I".Thread::Backtrace::Location#absolute_path;F;7[;[[@Kiz;T;:absolute_path;0;[;{;IC; "Returns the full file path of this frame. Same as #path, except that it will return absolute path even if the frame is in the main script. ;T;[;![;"I"Returns the full file path of this frame. Same as #path, except that it will return absolute path even if the frame is in the main script. ;T;#0;$@ ";.F;/o;0;1T;2it;3ix;%@!;9I"lstatic VALUE location_absolute_path_m(VALUE self) { return location_realpath(location_ptr(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%Thread::Backtrace::Location#to_s;F;7[;[[@Ki;T;;G;0;[;{;IC; "BReturns a Kernel#caller style string representing this frame. ;T;[;![;"I"CReturns a Kernel#caller style string representing this frame. ;T;#0;$@";.F;/o;0;1T;2i;3i;%@!;9I"cstatic VALUE location_to_str_m(VALUE self) { return location_to_str(location_ptr(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(Thread::Backtrace::Location#inspect;F;7[;[[@Ki;T;;J;0;[;{;IC; "RReturns the same as calling +inspect+ on the string representation of #to_str ;T;[;![;"I"SReturns the same as calling +inspect+ on the string representation of #to_str ;T;#0;$@)";.F;/o;0;1T;2i;3i;%@!;9I"tstatic VALUE location_inspect_m(VALUE self) { return rb_str_inspect(location_to_str(location_ptr(self))); };T;:I"static VALUE;T;;T; @!; IC;[; @!; IC;[; @!; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Ki;F;: Location;;;;;[;{;IC; " ;T;[;![;"@;#0;$@!;Bi;%@!;&I" Thread::Backtrace::Location;F;'@; @!; IC;[; @!; IC;[; @!; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Ki;F;:Backtrace;;;;;[;{;IC; " ;T;[;![;"@;#0;$@!;Bi;%@H;&I"Thread::Backtrace;F;'@o; ;IC;[ o;4;5F;6;;;;&I"Thread::Mutex#initialize;F;7[;[[I"thread_sync.c;Ti;T;;D;0;[;{;IC; "Creates a new Mutex ;T;[o;= ;>I" overload;F;?0;:Thread::Mutex.new;@0;:I"Thread::Mutex.new;T;IC; ";T;[;![;"I";T;#0;$@W";.F;Bi;C0;7[;$@W";![;"I"6Creates a new Mutex @overload Thread::Mutex.new;T;#0;$@W";.F;/o;0;1T;2i;3i;%@U";9I"Cstatic VALUE mutex_initialize(VALUE self) { return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread::Mutex#locked?;F;7[;[[@\"i;T;: locked?;0;[;{;IC; "BReturns +true+ if this lock is currently held by some thread.;T;[o;= ;>I" overload;F;?0;;T;@0;:I" locked?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@n";![;"I"@return [Boolean];T;#0;$@n";.F;Bi;C0;7[;$@n";![;"I"jReturns +true+ if this lock is currently held by some thread. @overload locked? @return [Boolean];T;#0;$@n";.F;/o;0;1T;2i;3i;Bi;%@U";9I"vVALUE rb_mutex_locked_p(VALUE self) { rb_mutex_t *mutex = mutex_ptr(self); return RBOOL(mutex->fiber); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Thread::Mutex#try_lock;F;7[;[[@\"i;T;: try_lock;0;[;{;IC; "aAttempts to obtain the lock and returns immediately. Returns +true+ if the lock was granted. ;T;[o;= ;>I" overload;F;?0;;U;@0;:I" try_lock;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@";![;"I"@return [Boolean];T;#0;$@";.F;Bi;C0;7[;$@";![;"I"Attempts to obtain the lock and returns immediately. Returns +true+ if the lock was granted. @overload try_lock @return [Boolean];T;#0;$@";.F;/o;0;1T;2i;3i;%@U";9I"VALUE rb_mutex_trylock(VALUE self) { rb_mutex_t *mutex = mutex_ptr(self); if (mutex->fiber == 0) { rb_fiber_t *fiber = GET_EC()->fiber_ptr; rb_thread_t *th = GET_THREAD(); mutex->fiber = fiber; mutex_locked(th, self); return Qtrue; } return Qfalse; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Thread::Mutex#lock;F;7[;[[@\"i;T;: lock;0;[;{;IC; "|Attempts to grab the lock and waits if it isn't available. Raises +ThreadError+ if +mutex+ was locked by the current thread. ;T;[o;= ;>I" overload;F;?0;;V;@0;:I" lock;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@";![;"I"@return [self];T;#0;$@";.F;Bi;C0;7[;$@";![;"I"Attempts to grab the lock and waits if it isn't available. Raises +ThreadError+ if +mutex+ was locked by the current thread. @overload lock @return [self];T;#0;$@";.F;/o;0;1T;2i;3i;%@U";9I"KVALUE rb_mutex_lock(VALUE self) { return do_mutex_lock(self, 1); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Thread::Mutex#unlock;F;7[;[[@\"i;T;: unlock;0;[;{;IC; "\Releases the lock. Raises +ThreadError+ if +mutex+ wasn't locked by the current thread. ;T;[o;= ;>I" overload;F;?0;;W;@0;:I" unlock;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@";![;"I"@return [self];T;#0;$@";.F;Bi;C0;7[;$@";![;"I"{Releases the lock. Raises +ThreadError+ if +mutex+ wasn't locked by the current thread. @overload unlock @return [self];T;#0;$@";.F;/o;0;1T;2i;3i;%@U";9I" VALUE rb_mutex_unlock(VALUE self) { const char *err; rb_mutex_t *mutex = mutex_ptr(self); rb_thread_t *th = GET_THREAD(); err = rb_mutex_unlock_th(mutex, th, GET_EC()->fiber_ptr); if (err) rb_raise(rb_eThreadError, "%s", err); return self; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Thread::Mutex#sleep;F;7[[@90;[[@\"iC;T;;;0;[;{;IC; "Releases the lock and sleeps +timeout+ seconds if it is given and non-nil or forever. Raises +ThreadError+ if +mutex+ wasn't locked by the current thread. When the thread is next woken up, it will attempt to reacquire the lock. Note that this method can wakeup without explicit Thread#wakeup call. For example, receiving signal and so on. Returns the slept time in seconds if woken up, or +nil+ if timed out. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"sleep(timeout = nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;TI"nil;T;$@";![;"I"@return [Numeric, nil];T;#0;$@";.F;Bi;C0;7[[I" timeout;TI"nil;T;$@";![;"I"Releases the lock and sleeps +timeout+ seconds if it is given and non-nil or forever. Raises +ThreadError+ if +mutex+ wasn't locked by the current thread. When the thread is next woken up, it will attempt to reacquire the lock. Note that this method can wakeup without explicit Thread#wakeup call. For example, receiving signal and so on. Returns the slept time in seconds if woken up, or +nil+ if timed out. @overload sleep(timeout = nil) @return [Numeric, nil];T;#0;$@";.F;/o;0;1T;2i3;3iA;%@U";9I"static VALUE mutex_sleep(int argc, VALUE *argv, VALUE self) { VALUE timeout; timeout = rb_check_arity(argc, 0, 1) ? argv[0] : Qnil; return rb_mutex_sleep(self, timeout); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread::Mutex#synchronize;F;7[;[[@\"ib;T;;;0;[;{;IC; "zObtains a lock, runs the block, and releases the lock when the block completes. See the example under Thread::Mutex. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"synchronize;T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@";![;"I"@yield [];T;#0;$@";.F;Bi;C0;7[;$@";![;"I"Obtains a lock, runs the block, and releases the lock when the block completes. See the example under Thread::Mutex. @overload synchronize @yield [];T;#0;$@";.F;/o;0;1T;2i[;3i`;%@U";9I"static VALUE rb_mutex_synchronize_m(VALUE self) { if (!rb_block_given_p()) { rb_raise(rb_eThreadError, "must be called with a block"); } return rb_mutex_synchronize(self, rb_yield, Qundef); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread::Mutex#owned?;F;7[;[[@\"i;T;: owned?;0;[;{;IC; "EReturns +true+ if this lock is currently held by current thread.;T;[o;= ;>I" overload;F;?0;;X;@0;:I" owned?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@#;![;"I"@return [Boolean];T;#0;$@#;.F;Bi;C0;7[;$@#;![;"I"lReturns +true+ if this lock is currently held by current thread. @overload owned? @return [Boolean];T;#0;$@#;.F;/o;0;1T;2i;3i;Bi;%@U";9I"VALUE rb_mutex_owned_p(VALUE self) { rb_fiber_t *fiber = GET_EC()->fiber_ptr; rb_mutex_t *mutex = mutex_ptr(self); return mutex_owned_p(fiber, mutex); };T;:I" VALUE;T;;T; @U"; IC;[; @U"; IC;[; @U"; IC;{;IC;{;T;IC;{;T;T;{;[;[[@\"iG[@\"i;T;: Mutex;;;;;[;{;IC; "_Thread::Mutex implements a simple semaphore that can be used to coordinate access to shared data from multiple concurrent threads. Example: semaphore = Thread::Mutex.new a = Thread.new { semaphore.synchronize { # access shared resource } } b = Thread.new { semaphore.synchronize { # access shared resource } };T;[;![;"I"b Thread::Mutex implements a simple semaphore that can be used to coordinate access to shared data from multiple concurrent threads. Example: semaphore = Thread::Mutex.new a = Thread.new { semaphore.synchronize { # access shared resource } } b = Thread.new { semaphore.synchronize { # access shared resource } } ;T;#0;$@U";.F;/o;0;1T;2iG;3i[;Bi;%o;( ;)0;*0;+0;: Thread;%@;-@H;0;&I"Thread::Mutex;F;'@o; ;IC;[o;4;5F;6;;;;&I"Thread::Queue#initialize;F;7[[@90;[[@\"i_;T;;D;0;[;{;IC; "call-seq: Thread::Queue.new -> empty_queue Thread::Queue.new(enumerable) -> queue Creates a new queue instance, optionally using the contents of an +enumerable+ for its initial state. Example: q = Thread::Queue.new #=> # q.empty? #=> true q = Thread::Queue.new([1, 2, 3]) #=> # q.empty? #=> false q.pop #=> 1 ;T;[;![;"I" call-seq: Thread::Queue.new -> empty_queue Thread::Queue.new(enumerable) -> queue Creates a new queue instance, optionally using the contents of an +enumerable+ for its initial state. Example: q = Thread::Queue.new #=> # q.empty? #=> true q = Thread::Queue.new([1, 2, 3]) #=> # q.empty? #=> false q.pop #=> 1 ;T;#0;$@C#;.F;/o;0;1T;2iF;3i[;%@A#;9I"static VALUE rb_queue_initialize(int argc, VALUE *argv, VALUE self) { VALUE initial; struct rb_queue *q = queue_ptr(self); if ((argc = rb_scan_args(argc, argv, "01", &initial)) == 1) { initial = rb_to_array(initial); } RB_OBJ_WRITE(self, &q->que, ary_buf_new()); list_head_init(queue_waitq(q)); if (argc == 1) { rb_ary_concat(q->que, initial); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread::Queue#marshal_dump;F;7[;[[@\"i ;T;:marshal_dump;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@R#;.F;/o;0;1T;2i ;3i ;%@A#;9I"static VALUE undumpable(VALUE obj) { rb_raise(rb_eTypeError, "can't dump %"PRIsVALUE, rb_obj_class(obj)); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread::Queue#close;F;7[;[[@\"i;T;;;0;[;{;IC; "Closes the queue. A closed queue cannot be re-opened. After the call to close completes, the following are true: - +closed?+ will return true - +close+ will be ignored. - calling enq/push/<< will raise a +ClosedQueueError+. - when +empty?+ is false, calling deq/pop/shift will return an object from the queue as usual. - when +empty?+ is true, deq(false) will not suspend the thread and will return nil. deq(true) will raise a +ThreadError+. ClosedQueueError is inherited from StopIteration, so that you can break loop block. Example: q = Thread::Queue.new Thread.new{ while e = q.deq # wait for nil to break loop # ... end } q.close ;T;[o;= ;>I" overload;F;?0;;;@0;:I" close;T;IC; ";T;[;![;"I";T;#0;$@`#;.F;Bi;C0;7[;$@`#;![;"I"Closes the queue. A closed queue cannot be re-opened. After the call to close completes, the following are true: - +closed?+ will return true - +close+ will be ignored. - calling enq/push/<< will raise a +ClosedQueueError+. - when +empty?+ is false, calling deq/pop/shift will return an object from the queue as usual. - when +empty?+ is true, deq(false) will not suspend the thread and will return nil. deq(true) will raise a +ThreadError+. ClosedQueueError is inherited from StopIteration, so that you can break loop block. Example: q = Thread::Queue.new Thread.new{ while e = q.deq # wait for nil to break loop # ... end } q.close @overload close;T;#0;$@`#;.F;/o;0;1T;2iz;3i;%@A#;9I"static VALUE rb_queue_close(VALUE self) { struct rb_queue *q = queue_ptr(self); if (!queue_closed_p(self)) { FL_SET(self, QUEUE_CLOSED); wakeup_all(queue_waitq(q)); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread::Queue#closed?;F;7[;[[@\"i;T;: closed?;0;[;{;IC; "+Returns +true+ if the queue is closed.;T;[o;= ;>I" overload;F;?0;;\;@0;:I" closed?;T;IC; ";T;[;![;"I";T;#0;$@v#;.F;Bi;C0;7[;$@v#o;A ;>I" return;F;?@;0;@[@L;$@v#;![;"I"?Returns +true+ if the queue is closed. @overload closed?;T;#0;$@v#;.F;/o;0;1T;2i;3i;Bi;%@A#;9I"[static VALUE rb_queue_closed_p(VALUE self) { return RBOOL(queue_closed_p(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread::Queue#push;F;7[[I"obj;T0;[[@\"i;T;: push;0;[;{;IC; ",Pushes the given +object+ to the queue. ;T;[o;= ;>I" overload;F;?0;;];@0;:I"push(object);T;IC; ";T;[;![;"I";T;#0;$@#;.F;Bi;C0;7[[I" object;T0;$@#o;= ;>I" overload;F;?0;:enq;@0;:I"enq(object);T;IC; ";T;[;![;"I";T;#0;$@#;.F;Bi;C0;7[[I" object;T0;$@#o;= ;>I" overload;F;?0;;;@0;:I"<<(object);T;IC; ";T;[;![;"I";T;#0;$@#;.F;Bi;C0;7[[I" object;T0;$@#;![;"I"pPushes the given +object+ to the queue. @overload push(object) @overload enq(object) @overload <<(object);T;#0;$o;4;5F;6;;;;&I"Thread::Queue#<<;F;7[;[[@\"iG;F;;;;;[;{;@#;%@A#;9I"pstatic VALUE rb_queue_push(VALUE self, VALUE obj) { return queue_do_push(self, queue_ptr(self), obj); };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@A#;9I"pstatic VALUE rb_queue_push(VALUE self, VALUE obj) { return queue_do_push(self, queue_ptr(self), obj); };T;:@#;;To;4;5F;6;;;;&I"Thread::Queue#pop;F;7[[@90;[[@\"i';T;:pop;0;[;{;IC; "Retrieves data from the queue. If the queue is empty, the calling thread is suspended until data is pushed onto the queue. If +non_block+ is true, the thread isn't suspended, and +ThreadError+ is raised. ;T;[o;= ;>I" overload;F;?0;;_;@0;:I"pop(non_block=false);T;IC; ";T;[;![;"I";T;#0;$@#;.F;Bi;C0;7[[I"non_block;TI" false;T;$@#o;= ;>I" overload;F;?0;:deq;@0;:I"deq(non_block=false);T;IC; ";T;[;![;"I";T;#0;$@#;.F;Bi;C0;7[[I"non_block;TI" false;T;$@#o;= ;>I" overload;F;?0;: shift;@0;:I"shift(non_block=false);T;IC; ";T;[;![;"I";T;#0;$@#;.F;Bi;C0;7[[I"non_block;TI" false;T;$@#;![;"I"-Retrieves data from the queue. If the queue is empty, the calling thread is suspended until data is pushed onto the queue. If +non_block+ is true, the thread isn't suspended, and +ThreadError+ is raised. @overload pop(non_block=false) @overload deq(non_block=false) @overload shift(non_block=false);T;#0;$o;4;5F;6;;;;&I"Thread::Queue#shift;F;7[;[[@\"iI;F;;a;;;[;{;@#;%@A#;9I"static VALUE rb_queue_pop(int argc, VALUE *argv, VALUE self) { int should_block = queue_pop_should_block(argc, argv); return queue_do_pop(self, queue_ptr(self), should_block); };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i";%@A#;9I"static VALUE rb_queue_pop(int argc, VALUE *argv, VALUE self) { int should_block = queue_pop_should_block(argc, argv); return queue_do_pop(self, queue_ptr(self), should_block); };T;:@#;;To;4;5F;6;;;;&I"Thread::Queue#empty?;F;7[;[[@\"i5;T;;;0;[;{;IC; "*Returns +true+ if the queue is empty.;T;[o;= ;>I" overload;F;?0;;;@0;:I" empty?;T;IC; ";T;[;![;"I";T;#0;$@#;.F;Bi;C0;7[;$@#o;A ;>I" return;F;?@;0;@[@L;$@#;![;"I"=Returns +true+ if the queue is empty. @overload empty?;T;#0;$@#;.F;/o;0;1T;2i.;3i1;Bi;%@A#;9I"nstatic VALUE rb_queue_empty_p(VALUE self) { return RBOOL(queue_length(self, queue_ptr(self)) == 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread::Queue#clear;F;7[;[[@\"iA;T;;;0;[;{;IC; "(Removes all objects from the queue. ;T;[;![;"I"* Removes all objects from the queue. ;T;#0;$@$;.F;/o;0;1T;2i;;3i=;%@A#;9I"static VALUE rb_queue_clear(VALUE self) { struct rb_queue *q = queue_ptr(self); rb_ary_clear(check_array(self, q->que)); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread::Queue#length;F;7[;[[@\"iS;T;: length;0;[;{;IC; "%Returns the length of the queue. ;T;[o;= ;>I" overload;F;?0;;b;@0;:I" length;T;IC; ";T;[;![;"I";T;#0;$@$$;.F;Bi;C0;7[;$@$$o;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[;![;"I";T;#0;$@$$;.F;Bi;C0;7[;$@$$;![;"I"GReturns the length of the queue. @overload length @overload size;T;#0;$o;4;5F;6;;;;&I"Thread::Queue#size;F;7[;[[@\"iJ;F;;;;;[;{;@+$;%@A#;9I"kstatic VALUE rb_queue_length(VALUE self) { return LONG2NUM(queue_length(self, queue_ptr(self))); };T;:I"static VALUE;T;.F;/o;0;1T;2iJ;3iN;%@A#;9I"kstatic VALUE rb_queue_length(VALUE self) { return LONG2NUM(queue_length(self, queue_ptr(self))); };T;:@G$;;To;4;5F;6;;;;&I"Thread::Queue#num_waiting;F;7[;[[@\"i_;T;:num_waiting;0;[;{;IC; "8Returns the number of threads waiting on the queue. ;T;[;![;"I": Returns the number of threads waiting on the queue. ;T;#0;$@J$;.F;/o;0;1T;2iY;3i[;%@A#;9I"static VALUE rb_queue_num_waiting(VALUE self) { struct rb_queue *q = queue_ptr(self); return INT2NUM(q->num_waiting); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread::Queue#enq;F;7[;[[@\"iF;F;;^;;;[;{;@#;%@A#;9I"pstatic VALUE rb_queue_push(VALUE self, VALUE obj) { return queue_do_push(self, queue_ptr(self), obj); };T;:@#@#o;4;5F;6;;;;&I"Thread::Queue#deq;F;7[;[[@\"iH;F;;`;;;[;{;@#;%@A#;9I"static VALUE rb_queue_pop(int argc, VALUE *argv, VALUE self) { int should_block = queue_pop_should_block(argc, argv); return queue_do_pop(self, queue_ptr(self), should_block); };T;:@#@#@?$; @A#; IC;[; @A#; IC;[; @A#; IC;{;IC;{;T;IC;{;T;T;{ @X$;]@#;]@`$;_@#;_@?$;b;[;[[@\"i#[@\"i!;T;: Queue;;;;;[;{;IC; "The Thread::Queue class implements multi-producer, multi-consumer queues. It is especially useful in threaded programming when information must be exchanged safely between multiple threads. The Thread::Queue class implements all the required locking semantics. The class implements FIFO type of queue. In a FIFO queue, the first tasks added are the first retrieved. Example: queue = Thread::Queue.new producer = Thread.new do 5.times do |i| sleep rand(i) # simulate expense queue << i puts "#{i} produced" end end consumer = Thread.new do 5.times do |i| value = queue.pop sleep rand(i/2) # simulate expense puts "consumed #{value}" end end consumer.join;T;[;![;"I" The Thread::Queue class implements multi-producer, multi-consumer queues. It is especially useful in threaded programming when information must be exchanged safely between multiple threads. The Thread::Queue class implements all the required locking semantics. The class implements FIFO type of queue. In a FIFO queue, the first tasks added are the first retrieved. Example: queue = Thread::Queue.new producer = Thread.new do 5.times do |i| sleep rand(i) # simulate expense queue << i puts "#{i} produced" end end consumer = Thread.new do 5.times do |i| value = queue.pop sleep rand(i/2) # simulate expense puts "consumed #{value}" end end consumer.join ;T;#0;$@A#;.F;/o;0;1T;2i#;3iB;Bi;%o;( ;)0;*0;+0;;Z;%@;-@H;0;&I"Thread::Queue;F;'@o; ;IC;[o;4;5F;6;;;;&I""Thread::SizedQueue#initialize;F;7[[I" vmax;T0;[[@\"iw;T;;D;0;[;{;IC; "?Creates a fixed-length queue with a maximum size of +max+. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I" new(max);T;IC; ";T;[;![;"I";T;#0;$@}$;.F;Bi;C0;7[[I"max;T0;$@}$;![;"I"TCreates a fixed-length queue with a maximum size of +max+. @overload new(max);T;#0;$@}$;.F;/o;0;1T;2ip;3is;%@{$;9I"static VALUE rb_szqueue_initialize(VALUE self, VALUE vmax) { long max; struct rb_szqueue *sq = szqueue_ptr(self); max = NUM2LONG(vmax); if (max <= 0) { rb_raise(rb_eArgError, "queue size must be positive"); } RB_OBJ_WRITE(self, &sq->q.que, ary_buf_new()); list_head_init(szqueue_waitq(sq)); list_head_init(szqueue_pushq(sq)); sq->max = max; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread::SizedQueue#close;F;7[;[[@\"i;T;;;0;[;{;IC; "Similar to Thread::Queue#close. The difference is behavior with waiting enqueuing threads. If there are waiting enqueuing threads, they are interrupted by raising ClosedQueueError('queue closed'). ;T;[o;= ;>I" overload;F;?0;;;@0;:I" close;T;IC; ";T;[;![;"I";T;#0;$@$;.F;Bi;C0;7[;$@$;![;"I"Similar to Thread::Queue#close. The difference is behavior with waiting enqueuing threads. If there are waiting enqueuing threads, they are interrupted by raising ClosedQueueError('queue closed'). @overload close;T;#0;$@$;.F;/o;0;1T;2i;3i;%@{$;9I"static VALUE rb_szqueue_close(VALUE self) { if (!queue_closed_p(self)) { struct rb_szqueue *sq = szqueue_ptr(self); FL_SET(self, QUEUE_CLOSED); wakeup_all(szqueue_waitq(sq)); wakeup_all(szqueue_pushq(sq)); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread::SizedQueue#max;F;7[;[[@\"i;T;:max;0;[;{;IC; "+Returns the maximum size of the queue. ;T;[;![;"I"- Returns the maximum size of the queue. ;T;#0;$@$;.F;/o;0;1T;2i;3i;%@{$;9I"astatic VALUE rb_szqueue_max_get(VALUE self) { return LONG2NUM(szqueue_ptr(self)->max); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread::SizedQueue#max=;F;7[[I" vmax;T0;[[@\"i;T;: max=;0;[;{;IC; ">Sets the maximum size of the queue to the given +number+. ;T;[o;= ;>I" overload;F;?0;;f;@0;:I"max=(number);T;IC; ";T;[;![;"I";T;#0;$@$;.F;Bi;C0;7[[I" number;T0;$@$;![;"I"WSets the maximum size of the queue to the given +number+. @overload max=(number);T;#0;$@$;.F;/o;0;1T;2i;3i;%@{$;9I"sstatic VALUE rb_szqueue_max_set(VALUE self, VALUE vmax) { long max = NUM2LONG(vmax); long diff = 0; struct rb_szqueue *sq = szqueue_ptr(self); if (max <= 0) { rb_raise(rb_eArgError, "queue size must be positive"); } if (max > sq->max) { diff = max - sq->max; } sq->max = max; sync_wakeup(szqueue_pushq(sq), diff); return vmax; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread::SizedQueue#push;F;7[[@90;[[@\"i;T;;];0;[;{;IC; "Pushes +object+ to the queue. If there is no space left in the queue, waits until space becomes available, unless +non_block+ is true. If +non_block+ is true, the thread isn't suspended, and +ThreadError+ is raised. ;T;[o;= ;>I" overload;F;?0;;];@0;:I""push(object, non_block=false);T;IC; ";T;[;![;"I";T;#0;$@$;.F;Bi;C0;7[[I" object;T0[I"non_block;TI" false;T;$@$o;= ;>I" overload;F;?0;;^;@0;:I"!enq(object, non_block=false);T;IC; ";T;[;![;"I";T;#0;$@$;.F;Bi;C0;7[[I" object;T0[I"non_block;TI" false;T;$@$o;= ;>I" overload;F;?0;;;@0;:I"<<(object);T;IC; ";T;[;![;"I";T;#0;$@$;.F;Bi;C0;7[[I" object;T0;$@$;![;"I"?Pushes +object+ to the queue. If there is no space left in the queue, waits until space becomes available, unless +non_block+ is true. If +non_block+ is true, the thread isn't suspended, and +ThreadError+ is raised. @overload push(object, non_block=false) @overload enq(object, non_block=false) @overload <<(object);T;#0;$o;4;5F;6;;;;&I"Thread::SizedQueue#<<;F;7[;[[@\"i[;F;;;;;[;{;@$;%@{$;9I"static VALUE rb_szqueue_push(int argc, VALUE *argv, VALUE self) { struct rb_szqueue *sq = szqueue_ptr(self); int should_block = szqueue_push_should_block(argc, argv); while (queue_length(self, &sq->q) >= sq->max) { if (!should_block) { rb_raise(rb_eThreadError, "queue full"); } else if (queue_closed_p(self)) { break; } else { rb_execution_context_t *ec = GET_EC(); struct queue_waiter queue_waiter = { .w = {.self = self, .th = ec->thread_ptr, .fiber = ec->fiber_ptr}, .as = {.sq = sq} }; struct list_head *pushq = szqueue_pushq(sq); list_add_tail(pushq, &queue_waiter.w.node); sq->num_waiting_push++; rb_ensure(queue_sleep, self, szqueue_sleep_done, (VALUE)&queue_waiter); } } if (queue_closed_p(self)) { raise_closed_queue_error(self); } return queue_do_push(self, &sq->q, argv[0]); };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@{$;9I"static VALUE rb_szqueue_push(int argc, VALUE *argv, VALUE self) { struct rb_szqueue *sq = szqueue_ptr(self); int should_block = szqueue_push_should_block(argc, argv); while (queue_length(self, &sq->q) >= sq->max) { if (!should_block) { rb_raise(rb_eThreadError, "queue full"); } else if (queue_closed_p(self)) { break; } else { rb_execution_context_t *ec = GET_EC(); struct queue_waiter queue_waiter = { .w = {.self = self, .th = ec->thread_ptr, .fiber = ec->fiber_ptr}, .as = {.sq = sq} }; struct list_head *pushq = szqueue_pushq(sq); list_add_tail(pushq, &queue_waiter.w.node); sq->num_waiting_push++; rb_ensure(queue_sleep, self, szqueue_sleep_done, (VALUE)&queue_waiter); } } if (queue_closed_p(self)) { raise_closed_queue_error(self); } return queue_do_push(self, &sq->q, argv[0]); };T;:@ %;;To;4;5F;6;;;;&I"Thread::SizedQueue#pop;F;7[[@90;[[@\"i ;T;;_;0;[;{;IC; "Retrieves data from the queue. If the queue is empty, the calling thread is suspended until data is pushed onto the queue. If +non_block+ is true, the thread isn't suspended, and +ThreadError+ is raised. ;T;[o;= ;>I" overload;F;?0;;_;@0;:I"pop(non_block=false);T;IC; ";T;[;![;"I";T;#0;$@%;.F;Bi;C0;7[[I"non_block;TI" false;T;$@%o;= ;>I" overload;F;?0;;`;@0;:I"deq(non_block=false);T;IC; ";T;[;![;"I";T;#0;$@%;.F;Bi;C0;7[[I"non_block;TI" false;T;$@%o;= ;>I" overload;F;?0;;a;@0;:I"shift(non_block=false);T;IC; ";T;[;![;"I";T;#0;$@%;.F;Bi;C0;7[[I"non_block;TI" false;T;$@%;![;"I"-Retrieves data from the queue. If the queue is empty, the calling thread is suspended until data is pushed onto the queue. If +non_block+ is true, the thread isn't suspended, and +ThreadError+ is raised. @overload pop(non_block=false) @overload deq(non_block=false) @overload shift(non_block=false);T;#0;$o;4;5F;6;;;;&I"Thread::SizedQueue#shift;F;7[;[[@\"i];F;;a;;;[;{;@%;%@{$;9I"static VALUE rb_szqueue_pop(int argc, VALUE *argv, VALUE self) { int should_block = queue_pop_should_block(argc, argv); return szqueue_do_pop(self, should_block); };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@{$;9I"static VALUE rb_szqueue_pop(int argc, VALUE *argv, VALUE self) { int should_block = queue_pop_should_block(argc, argv); return szqueue_do_pop(self, should_block); };T;:@E%;;To;4;5F;6;;;;&I"Thread::SizedQueue#empty?;F;7[;[[@\"i];T;;;0;[;{;IC; "*Returns +true+ if the queue is empty.;T;[o;= ;>I" overload;F;?0;;;@0;:I" empty?;T;IC; ";T;[;![;"I";T;#0;$@H%;.F;Bi;C0;7[;$@H%o;A ;>I" return;F;?@;0;@[@L;$@H%;![;"I"=Returns +true+ if the queue is empty. @overload empty?;T;#0;$@H%;.F;/o;0;1T;2iV;3iY;Bi;%@{$;9I"static VALUE rb_szqueue_empty_p(VALUE self) { struct rb_szqueue *sq = szqueue_ptr(self); return RBOOL(queue_length(self, &sq->q) == 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread::SizedQueue#clear;F;7[;[[@\"i-;T;;;0;[;{;IC; "(Removes all objects from the queue. ;T;[;![;"I"* Removes all objects from the queue. ;T;#0;$@a%;.F;/o;0;1T;2i';3i);%@{$;9I"static VALUE rb_szqueue_clear(VALUE self) { struct rb_szqueue *sq = szqueue_ptr(self); rb_ary_clear(check_array(self, sq->q.que)); wakeup_all(szqueue_pushq(sq)); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread::SizedQueue#length;F;7[;[[@\"i@;T;;b;0;[;{;IC; "%Returns the length of the queue. ;T;[o;= ;>I" overload;F;?0;;b;@0;:I" length;T;IC; ";T;[;![;"I";T;#0;$@o%;.F;Bi;C0;7[;$@o%o;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[;![;"I";T;#0;$@o%;.F;Bi;C0;7[;$@o%;![;"I"GReturns the length of the queue. @overload length @overload size;T;#0;$o;4;5F;6;;;;&I"Thread::SizedQueue#size;F;7[;[[@\"i^;F;;;;;[;{;@v%;%@{$;9I"static VALUE rb_szqueue_length(VALUE self) { struct rb_szqueue *sq = szqueue_ptr(self); return LONG2NUM(queue_length(self, &sq->q)); };T;:I"static VALUE;T;.F;/o;0;1T;2i7;3i;;%@{$;9I"static VALUE rb_szqueue_length(VALUE self) { struct rb_szqueue *sq = szqueue_ptr(self); return LONG2NUM(queue_length(self, &sq->q)); };T;:@%;;To;4;5F;6;;;;&I"#Thread::SizedQueue#num_waiting;F;7[;[[@\"iN;T;;c;0;[;{;IC; "8Returns the number of threads waiting on the queue. ;T;[;![;"I": Returns the number of threads waiting on the queue. ;T;#0;$@%;.F;/o;0;1T;2iH;3iJ;%@{$;9I"static VALUE rb_szqueue_num_waiting(VALUE self) { struct rb_szqueue *sq = szqueue_ptr(self); return INT2NUM(sq->q.num_waiting + sq->num_waiting_push); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread::SizedQueue#enq;F;7[;[[@\"iZ;F;;^;;;[;{;@$;%@{$;9I"static VALUE rb_szqueue_push(int argc, VALUE *argv, VALUE self) { struct rb_szqueue *sq = szqueue_ptr(self); int should_block = szqueue_push_should_block(argc, argv); while (queue_length(self, &sq->q) >= sq->max) { if (!should_block) { rb_raise(rb_eThreadError, "queue full"); } else if (queue_closed_p(self)) { break; } else { rb_execution_context_t *ec = GET_EC(); struct queue_waiter queue_waiter = { .w = {.self = self, .th = ec->thread_ptr, .fiber = ec->fiber_ptr}, .as = {.sq = sq} }; struct list_head *pushq = szqueue_pushq(sq); list_add_tail(pushq, &queue_waiter.w.node); sq->num_waiting_push++; rb_ensure(queue_sleep, self, szqueue_sleep_done, (VALUE)&queue_waiter); } } if (queue_closed_p(self)) { raise_closed_queue_error(self); } return queue_do_push(self, &sq->q, argv[0]); };T;:@ %@%o;4;5F;6;;;;&I"Thread::SizedQueue#deq;F;7[;[[@\"i\;F;;`;;;[;{;@%;%@{$;9I"static VALUE rb_szqueue_pop(int argc, VALUE *argv, VALUE self) { int should_block = queue_pop_should_block(argc, argv); return szqueue_do_pop(self, should_block); };T;:@E%@=%@%; @{$; IC;[; @{$; IC;[; @{$; IC;{;IC;{;T;IC;{;T;T;{ @%;]@%;]@%;_@=%;_@%;b;[;[[@\"ig[@\"i";T;:SizedQueue;;;;;[;{;IC; "This class represents queues of specified size capacity. The push operation may be blocked if the capacity is full. See Thread::Queue for an example of how a Thread::SizedQueue works.;T;[;![;"I" This class represents queues of specified size capacity. The push operation may be blocked if the capacity is full. See Thread::Queue for an example of how a Thread::SizedQueue works. ;T;#0;$@{$;.F;/o;0;1T;2ig;3il;Bi;%o;( ;)0;*0;+0;;Z;%@;-@H;0;&I"Thread::SizedQueue;F;'@o; ;IC;[ o;4;5F;6;;;;&I")Thread::ConditionVariable#initialize;F;7[;[[@\"i;T;;D;0;[;{;IC; "/Creates a new condition variable instance. ;T;[;![;"I"1 Creates a new condition variable instance. ;T;#0;$@%;.F;/o;0;1T;2i;3i;%@%;9I"static VALUE rb_condvar_initialize(VALUE self) { struct rb_condvar *cv = condvar_ptr(self); list_head_init(&cv->waitq); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+Thread::ConditionVariable#marshal_dump;F;7[;[[@\"i ;T;;[;0;[;{;IC; " :nodoc: ;T;[;![;"@\#;#0;$@%;.F;/o;0;1T;2i ;3i ;%@%;9I"static VALUE undumpable(VALUE obj) { rb_raise(rb_eTypeError, "can't dump %"PRIsVALUE, rb_obj_class(obj)); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#Thread::ConditionVariable#wait;F;7[[@90;[[@\"i;T;: wait;0;[;{;IC; "Releases the lock held in +mutex+ and waits; reacquires the lock on wakeup. If +timeout+ is given, this method returns after +timeout+ seconds passed, even if no other thread doesn't signal. Returns the slept result on +mutex+. ;T;[o;= ;>I" overload;F;?0;;h;@0;:I"wait(mutex, timeout=nil);T;IC; ";T;[;![;"I";T;#0;$@%;.F;Bi;C0;7[[I" mutex;T0[I" timeout;TI"nil;T;$@%;![;"I" Releases the lock held in +mutex+ and waits; reacquires the lock on wakeup. If +timeout+ is given, this method returns after +timeout+ seconds passed, even if no other thread doesn't signal. Returns the slept result on +mutex+. @overload wait(mutex, timeout=nil);T;#0;$@%;.F;/o;0;1T;2i;3i;%@%;9I" static VALUE rb_condvar_wait(int argc, VALUE *argv, VALUE self) { rb_execution_context_t *ec = GET_EC(); struct rb_condvar *cv = condvar_ptr(self); struct sleep_call args; rb_scan_args(argc, argv, "11", &args.mutex, &args.timeout); struct sync_waiter sync_waiter = { .self = args.mutex, .th = ec->thread_ptr, .fiber = ec->fiber_ptr }; list_add_tail(&cv->waitq, &sync_waiter.node); return rb_ensure(do_sleep, (VALUE)&args, delete_from_waitq, (VALUE)&sync_waiter); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%Thread::ConditionVariable#signal;F;7[;[[@\"i;T;: signal;0;[;{;IC; "=Wakes up the first thread in line waiting for this lock. ;T;[;![;"I"? Wakes up the first thread in line waiting for this lock. ;T;#0;$@%;.F;/o;0;1T;2i;3i;%@%;9I"static VALUE rb_condvar_signal(VALUE self) { struct rb_condvar *cv = condvar_ptr(self); wakeup_one(&cv->waitq); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(Thread::ConditionVariable#broadcast;F;7[;[[@\"i;T;:broadcast;0;[;{;IC; "0Wakes up all threads waiting for this lock. ;T;[;![;"I"2 Wakes up all threads waiting for this lock. ;T;#0;$@ &;.F;/o;0;1T;2i;3i;%@%;9I"static VALUE rb_condvar_broadcast(VALUE self) { struct rb_condvar *cv = condvar_ptr(self); wakeup_all(&cv->waitq); return self; };T;:I"static VALUE;T;;T; @%; IC;[; @%; IC;[; @%; IC;{;IC;{;T;IC;{;T;T;{;[;[[@\"il[@\"i ;T;:ConditionVariable;;;;;[;{;IC; "ConditionVariable objects augment class Mutex. Using condition variables, it is possible to suspend while in the middle of a critical section until a resource becomes available. Example: mutex = Thread::Mutex.new resource = Thread::ConditionVariable.new a = Thread.new { mutex.synchronize { # Thread 'a' now needs the resource resource.wait(mutex) # 'a' can now have the resource } } b = Thread.new { mutex.synchronize { # Thread 'b' has finished using the resource resource.signal } };T;[;![;"I" ConditionVariable objects augment class Mutex. Using condition variables, it is possible to suspend while in the middle of a critical section until a resource becomes available. Example: mutex = Thread::Mutex.new resource = Thread::ConditionVariable.new a = Thread.new { mutex.synchronize { # Thread 'a' now needs the resource resource.wait(mutex) # 'a' can now have the resource } } b = Thread.new { mutex.synchronize { # Thread 'b' has finished using the resource resource.signal } } ;T;#0;$@%;.F;/o;0;1T;2il;3i;Bi;%o;( ;)0;*0;+0;;Z;%@;-@H;0;&I"Thread::ConditionVariable;F;'@o;4;5F;6;;;;&I"Thread#set_trace_func;F;7[[I" trace;T0;[[@ia;T;;;0;[;{;IC; "Establishes _proc_ on _thr_ as the handler for tracing, or disables tracing if the parameter is +nil+. See Kernel#set_trace_func. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"set_trace_func(proc);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@.&;![;"I"@return [Proc];T;#0;$@.&;.F;Bi;C0;7[[I" proc;T0;$@.&o;= ;>I" overload;F;?0;;;@0;:I"set_trace_func(nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@.&;![;"I"@return [nil];T;#0;$@.&;.F;Bi;C0;7[[I"nil;T0;$@.&;![;"I"Establishes _proc_ on _thr_ as the handler for tracing, or disables tracing if the parameter is +nil+. See Kernel#set_trace_func. @overload set_trace_func(proc) @return [Proc] @overload set_trace_func(nil) @return [nil];T;#0;$@.&;.F;/o;0;1T;2iV;3i_;%@H;9I"xstatic VALUE thread_set_trace_func_m(VALUE target_thread, VALUE trace) { rb_execution_context_t *ec = GET_EC(); rb_thread_t *target_th = rb_thread_ptr(target_thread); rb_threadptr_remove_event_hook(ec, target_th, call_trace_func, Qundef); if (NIL_P(trace)) { return Qnil; } else { thread_add_trace_func(ec, target_th, trace); return trace; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Thread#add_trace_func;F;7[[I" trace;T0;[[@iO;T;:add_trace_func;0;[;{;IC; "`Adds _proc_ as a handler for tracing. See Thread#set_trace_func and Kernel#set_trace_func. ;T;[o;= ;>I" overload;F;?0;;l;@0;:I"add_trace_func(proc);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@\&;![;"I"@return [Proc];T;#0;$@\&;.F;Bi;C0;7[[I" proc;T0;$@\&;![;"I"Adds _proc_ as a handler for tracing. See Thread#set_trace_func and Kernel#set_trace_func. @overload add_trace_func(proc) @return [Proc];T;#0;$@\&;.F;/o;0;1T;2iF;3iL;%@H;9I"static VALUE thread_add_trace_func_m(VALUE obj, VALUE trace) { thread_add_trace_func(GET_EC(), rb_thread_ptr(obj), trace); return trace; };T;:I"static VALUE;T;;T; @H; IC;[; @H; IC;[; @H; IC;{;IC;{;T;IC;{;T;T;{@!;G;[;[[I" vm.c;Ti [@&iC;T;;Z;;;;;[;{;IC; "Threads are the Ruby implementation for a concurrent programming model. Programs that require multiple threads of execution are a perfect candidate for Ruby's Thread class. For example, we can create a new thread separate from the main thread's execution using ::new. thr = Thread.new { puts "What's the big deal" } Then we are able to pause the execution of the main thread and allow our new thread to finish, using #join: thr.join #=> "What's the big deal" If we don't call +thr.join+ before the main thread terminates, then all other threads including +thr+ will be killed. Alternatively, you can use an array for handling multiple threads at once, like in the following example: threads = [] threads << Thread.new { puts "What's the big deal" } threads << Thread.new { 3.times { puts "Threads are fun!" } } After creating a few threads we wait for them all to finish consecutively. threads.each { |thr| thr.join } To retrieve the last value of a thread, use #value thr = Thread.new { sleep 1; "Useful value" } thr.value #=> "Useful value" === Thread initialization In order to create new threads, Ruby provides ::new, ::start, and ::fork. A block must be provided with each of these methods, otherwise a ThreadError will be raised. When subclassing the Thread class, the +initialize+ method of your subclass will be ignored by ::start and ::fork. Otherwise, be sure to call super in your +initialize+ method. === Thread termination For terminating threads, Ruby provides a variety of ways to do this. The class method ::kill, is meant to exit a given thread: thr = Thread.new { sleep } Thread.kill(thr) # sends exit() to thr Alternatively, you can use the instance method #exit, or any of its aliases #kill or #terminate. thr.exit === Thread status Ruby provides a few instance methods for querying the state of a given thread. To get a string with the current thread's state use #status thr = Thread.new { sleep } thr.status # => "sleep" thr.exit thr.status # => false You can also use #alive? to tell if the thread is running or sleeping, and #stop? if the thread is dead or sleeping. === Thread variables and scope Since threads are created with blocks, the same rules apply to other Ruby blocks for variable scope. Any local variables created within this block are accessible to only this thread. ==== Fiber-local vs. Thread-local Each fiber has its own bucket for Thread#[] storage. When you set a new fiber-local it is only accessible within this Fiber. To illustrate: Thread.new { Thread.current[:foo] = "bar" Fiber.new { p Thread.current[:foo] # => nil }.resume }.join This example uses #[] for getting and #[]= for setting fiber-locals, you can also use #keys to list the fiber-locals for a given thread and #key? to check if a fiber-local exists. When it comes to thread-locals, they are accessible within the entire scope of the thread. Given the following example: Thread.new{ Thread.current.thread_variable_set(:foo, 1) p Thread.current.thread_variable_get(:foo) # => 1 Fiber.new{ Thread.current.thread_variable_set(:foo, 2) p Thread.current.thread_variable_get(:foo) # => 2 }.resume p Thread.current.thread_variable_get(:foo) # => 2 }.join You can see that the thread-local +:foo+ carried over into the fiber and was changed to +2+ by the end of the thread. This example makes use of #thread_variable_set to create new thread-locals, and #thread_variable_get to reference them. There is also #thread_variables to list all thread-locals, and #thread_variable? to check if a given thread-local exists. === Exception handling When an unhandled exception is raised inside a thread, it will terminate. By default, this exception will not propagate to other threads. The exception is stored and when another thread calls #value or #join, the exception will be re-raised in that thread. t = Thread.new{ raise 'something went wrong' } t.value #=> RuntimeError: something went wrong An exception can be raised from outside the thread using the Thread#raise instance method, which takes the same parameters as Kernel#raise. Setting Thread.abort_on_exception = true, Thread#abort_on_exception = true, or $DEBUG = true will cause a subsequent unhandled exception raised in a thread to be automatically re-raised in the main thread. With the addition of the class method ::handle_interrupt, you can now handle exceptions asynchronously with threads. === Scheduling Ruby provides a few ways to support scheduling threads in your program. The first way is by using the class method ::stop, to put the current running thread to sleep and schedule the execution of another thread. Once a thread is asleep, you can use the instance method #wakeup to mark your thread as eligible for scheduling. You can also try ::pass, which attempts to pass execution to another thread but is dependent on the OS whether a running thread will switch or not. The same goes for #priority, which lets you hint to the thread scheduler which threads you want to take precedence when passing execution. This method is also dependent on the OS and may be ignored on some platforms.;T;[;![;"I" Threads are the Ruby implementation for a concurrent programming model. Programs that require multiple threads of execution are a perfect candidate for Ruby's Thread class. For example, we can create a new thread separate from the main thread's execution using ::new. thr = Thread.new { puts "What's the big deal" } Then we are able to pause the execution of the main thread and allow our new thread to finish, using #join: thr.join #=> "What's the big deal" If we don't call +thr.join+ before the main thread terminates, then all other threads including +thr+ will be killed. Alternatively, you can use an array for handling multiple threads at once, like in the following example: threads = [] threads << Thread.new { puts "What's the big deal" } threads << Thread.new { 3.times { puts "Threads are fun!" } } After creating a few threads we wait for them all to finish consecutively. threads.each { |thr| thr.join } To retrieve the last value of a thread, use #value thr = Thread.new { sleep 1; "Useful value" } thr.value #=> "Useful value" === Thread initialization In order to create new threads, Ruby provides ::new, ::start, and ::fork. A block must be provided with each of these methods, otherwise a ThreadError will be raised. When subclassing the Thread class, the +initialize+ method of your subclass will be ignored by ::start and ::fork. Otherwise, be sure to call super in your +initialize+ method. === Thread termination For terminating threads, Ruby provides a variety of ways to do this. The class method ::kill, is meant to exit a given thread: thr = Thread.new { sleep } Thread.kill(thr) # sends exit() to thr Alternatively, you can use the instance method #exit, or any of its aliases #kill or #terminate. thr.exit === Thread status Ruby provides a few instance methods for querying the state of a given thread. To get a string with the current thread's state use #status thr = Thread.new { sleep } thr.status # => "sleep" thr.exit thr.status # => false You can also use #alive? to tell if the thread is running or sleeping, and #stop? if the thread is dead or sleeping. === Thread variables and scope Since threads are created with blocks, the same rules apply to other Ruby blocks for variable scope. Any local variables created within this block are accessible to only this thread. ==== Fiber-local vs. Thread-local Each fiber has its own bucket for Thread#[] storage. When you set a new fiber-local it is only accessible within this Fiber. To illustrate: Thread.new { Thread.current[:foo] = "bar" Fiber.new { p Thread.current[:foo] # => nil }.resume }.join This example uses #[] for getting and #[]= for setting fiber-locals, you can also use #keys to list the fiber-locals for a given thread and #key? to check if a fiber-local exists. When it comes to thread-locals, they are accessible within the entire scope of the thread. Given the following example: Thread.new{ Thread.current.thread_variable_set(:foo, 1) p Thread.current.thread_variable_get(:foo) # => 1 Fiber.new{ Thread.current.thread_variable_set(:foo, 2) p Thread.current.thread_variable_get(:foo) # => 2 }.resume p Thread.current.thread_variable_get(:foo) # => 2 }.join You can see that the thread-local +:foo+ carried over into the fiber and was changed to +2+ by the end of the thread. This example makes use of #thread_variable_set to create new thread-locals, and #thread_variable_get to reference them. There is also #thread_variables to list all thread-locals, and #thread_variable? to check if a given thread-local exists. === Exception handling When an unhandled exception is raised inside a thread, it will terminate. By default, this exception will not propagate to other threads. The exception is stored and when another thread calls #value or #join, the exception will be re-raised in that thread. t = Thread.new{ raise 'something went wrong' } t.value #=> RuntimeError: something went wrong An exception can be raised from outside the thread using the Thread#raise instance method, which takes the same parameters as Kernel#raise. Setting Thread.abort_on_exception = true, Thread#abort_on_exception = true, or $DEBUG = true will cause a subsequent unhandled exception raised in a thread to be automatically re-raised in the main thread. With the addition of the class method ::handle_interrupt, you can now handle exceptions asynchronously with threads. === Scheduling Ruby provides a few ways to support scheduling threads in your program. The first way is by using the class method ::stop, to put the current running thread to sleep and schedule the execution of another thread. Once a thread is asleep, you can use the instance method #wakeup to mark your thread as eligible for scheduling. You can also try ::pass, which attempts to pass execution to another thread but is dependent on the OS whether a running thread will switch or not. The same goes for #priority, which lets you hint to the thread scheduler which threads you want to take precedence when passing execution. This method is also dependent on the OS and may be ignored on some platforms. ;T;#0;$@H;.F;/o;0;1T;2i ;3i@;Bi;%@;&I" Thread;F;'@o;;IC;[?o;4;5F;6;;;;&I")ObjectSpace#trace_object_allocations;F;7[;[[I""ext/objspace/object_tracing.c;Tic;T;:trace_object_allocations;0;[;{;IC; "7Starts tracing object allocations from the ObjectSpace extension module. For example: require 'objspace' class C include ObjectSpace def foo trace_object_allocations do obj = Object.new p "#{allocation_sourcefile(obj)}:#{allocation_sourceline(obj)}" end end end C.new.foo #=> "objtrace.rb:8" This example has included the ObjectSpace module to make it easier to read, but you can also use the ::trace_object_allocations notation (recommended). Note that this feature introduces a huge performance decrease and huge memory consumption. ;T;[o;= ;>I" overload;F;?0;;m;@0;:I"trace_object_allocations;T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@&;![;"I"@yield [];T;#0;$@&;.F;Bi;C0;7[;$@&;![;"I"gStarts tracing object allocations from the ObjectSpace extension module. For example: require 'objspace' class C include ObjectSpace def foo trace_object_allocations do obj = Object.new p "#{allocation_sourcefile(obj)}:#{allocation_sourceline(obj)}" end end end C.new.foo #=> "objtrace.rb:8" This example has included the ObjectSpace module to make it easier to read, but you can also use the ::trace_object_allocations notation (recommended). Note that this feature introduces a huge performance decrease and huge memory consumption. @overload trace_object_allocations @yield [];T;#0;$@&;.F;C0;%@&;9I"static VALUE trace_object_allocations(VALUE self) { trace_object_allocations_start(self); return rb_ensure(rb_yield, Qnil, trace_object_allocations_stop, self); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I")ObjectSpace.trace_object_allocations;F;7@&;@&;T;;m;0;@&;{;IC; "7Starts tracing object allocations from the ObjectSpace extension module. For example: require 'objspace' class C include ObjectSpace def foo trace_object_allocations do obj = Object.new p "#{allocation_sourcefile(obj)}:#{allocation_sourceline(obj)}" end end end C.new.foo #=> "objtrace.rb:8" This example has included the ObjectSpace module to make it easier to read, but you can also use the ::trace_object_allocations notation (recommended). Note that this feature introduces a huge performance decrease and huge memory consumption.;T;[o;= ;>I" overload;F;?0;;m;@0;:I"trace_object_allocations;T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@&;![;"I"@yield [];T;#0;$@&;.F;Bi;C0;7[;$@&;![;"I"hStarts tracing object allocations from the ObjectSpace extension module. For example: require 'objspace' class C include ObjectSpace def foo trace_object_allocations do obj = Object.new p "#{allocation_sourcefile(obj)}:#{allocation_sourceline(obj)}" end end end C.new.foo #=> "objtrace.rb:8" This example has included the ObjectSpace module to make it easier to read, but you can also use the ::trace_object_allocations notation (recommended). Note that this feature introduces a huge performance decrease and huge memory consumption. @overload trace_object_allocations @yield [];T;#0;$@&;.F;/o;0;1T;2iG;3ib;Bi;%@&;9@&;:@&;;To;4;5F;6;;;;&I"/ObjectSpace#trace_object_allocations_start;F;7[;[[@&i;T;:#trace_object_allocations_start;0;[;{;IC; "'Starts tracing object allocations. ;T;[o;= ;>I" overload;F;?0;;n;@0;:I"#trace_object_allocations_start;T;IC; ";T;[;![;"I";T;#0;$@&;.F;Bi;C0;7[;$@&;![;"I"QStarts tracing object allocations. @overload trace_object_allocations_start ;T;#0;$@&;.F;C0;%@&;9I"static VALUE trace_object_allocations_start(VALUE self) { struct traceobj_arg *arg = get_traceobj_arg(); if (arg->running++ > 0) { /* do nothing */ } else { if (arg->newobj_trace == 0) { arg->newobj_trace = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_NEWOBJ, newobj_i, arg); arg->freeobj_trace = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_FREEOBJ, freeobj_i, arg); } rb_tracepoint_enable(arg->newobj_trace); rb_tracepoint_enable(arg->freeobj_trace); } return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"/ObjectSpace.trace_object_allocations_start;F;7@&;@&;T;;n;0;@&;{;IC; "'Starts tracing object allocations.;T;[o;= ;>I" overload;F;?0;;n;@0;:I"#trace_object_allocations_start;T;IC; ";T;[;![;"I";T;#0;$@&;.F;Bi;C0;7[;$@&;![;"I"SStarts tracing object allocations. @overload trace_object_allocations_start;T;#0;$@&;.F;/o;0;1T;2i;3i;Bi;%@&;9@&;:@&;;To;4;5F;6;;;;&I".ObjectSpace#trace_object_allocations_stop;F;7[;[[@&i;T;:"trace_object_allocations_stop;0;[;{;IC; "Stop tracing object allocations. Note that if ::trace_object_allocations_start is called n-times, then tracing will stop after calling ::trace_object_allocations_stop n-times. ;T;[o;= ;>I" overload;F;?0;;o;@0;:I""trace_object_allocations_stop;T;IC; ";T;[;![;"I";T;#0;$@&;.F;Bi;C0;7[;$@&;![;"I"Stop tracing object allocations. Note that if ::trace_object_allocations_start is called n-times, then tracing will stop after calling ::trace_object_allocations_stop n-times. @overload trace_object_allocations_stop ;T;#0;$@&;.F;C0;%@&;9I"static VALUE trace_object_allocations_stop(VALUE self) { struct traceobj_arg *arg = get_traceobj_arg(); if (arg->running > 0) { arg->running--; } if (arg->running == 0) { if (arg->newobj_trace != 0) { rb_tracepoint_disable(arg->newobj_trace); } if (arg->freeobj_trace != 0) { rb_tracepoint_disable(arg->freeobj_trace); } } return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I".ObjectSpace.trace_object_allocations_stop;F;7@&;@&;T;;o;0;@&;{;IC; "Stop tracing object allocations. Note that if ::trace_object_allocations_start is called n-times, then tracing will stop after calling ::trace_object_allocations_stop n-times.;T;[o;= ;>I" overload;F;?0;;o;@0;:I""trace_object_allocations_stop;T;IC; ";T;[;![;"I";T;#0;$@&;.F;Bi;C0;7[;$@&;![;"I"Stop tracing object allocations. Note that if ::trace_object_allocations_start is called n-times, then tracing will stop after calling ::trace_object_allocations_stop n-times. @overload trace_object_allocations_stop;T;#0;$@&;.F;/o;0;1T;2i;3i;Bi;%@&;9@&;:@&;;To;4;5F;6;;;;&I"/ObjectSpace#trace_object_allocations_clear;F;7[;[[@&i7;T;:#trace_object_allocations_clear;0;[;{;IC; "(Clear recorded tracing information. ;T;[o;= ;>I" overload;F;?0;;p;@0;:I"#trace_object_allocations_clear;T;IC; ";T;[;![;"I";T;#0;$@';.F;Bi;C0;7[;$@';![;"I"RClear recorded tracing information. @overload trace_object_allocations_clear ;T;#0;$@';.F;C0;%@&;9I"`static VALUE trace_object_allocations_clear(VALUE self) { struct traceobj_arg *arg = get_traceobj_arg(); /* clear tables */ st_foreach(arg->object_table, free_values_i, 0); st_clear(arg->object_table); st_foreach(arg->str_table, free_keys_i, 0); st_clear(arg->str_table); /* do not touch TracePoints */ return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"/ObjectSpace.trace_object_allocations_clear;F;7@';@ ';T;;p;0;@ ';{;IC; "(Clear recorded tracing information.;T;[o;= ;>I" overload;F;?0;;p;@0;:I"#trace_object_allocations_clear;T;IC; ";T;[;![;"I";T;#0;$@';.F;Bi;C0;7[;$@';![;"I"TClear recorded tracing information. @overload trace_object_allocations_clear;T;#0;$@';.F;/o;0;1T;2i1;3i5;Bi;%@&;9@';:@';;To;4;5F;6;;;;&I"5ObjectSpace#trace_object_allocations_debug_start;F;7[;[[@&i;T;:)trace_object_allocations_debug_start;0;[;{;IC; " ;T;[;![;"I";F;#0;$@+';.F;C0;%@&;9I"-static VALUE trace_object_allocations_debug_start(VALUE self) { tmp_keep_remains = 1; if (object_allocations_reporter_registered == 0) { object_allocations_reporter_registered = 1; rb_bug_reporter_add(object_allocations_reporter, 0); } return trace_object_allocations_start(self); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"5ObjectSpace.trace_object_allocations_debug_start;F;7@-';@.';T;;q;0;@0';{;IC; " ;T;[;![;"@;#0;$@8';Bi;%@&;9@6';:@7';;To;4;5F;6;;;;&I"&ObjectSpace#allocation_sourcefile;F;7[[I"obj;T0;[[@&i;T;:allocation_sourcefile;0;[;{;IC; "Returns the source file origin from the given +object+. See ::trace_object_allocations for more information and examples. ;T;[o;= ;>I" overload;F;?0;;r;@0;:I""allocation_sourcefile(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@>';![;"I"@return [String];T;#0;$@>';.F;Bi;C0;7[[I" object;T0;$@>';![;"I"Returns the source file origin from the given +object+. See ::trace_object_allocations for more information and examples. @overload allocation_sourcefile(object) @return [String];T;#0;$@>';.F;C0;%@&;9I"static VALUE allocation_sourcefile(VALUE self, VALUE obj) { struct allocation_info *info = lookup_allocation_info(obj); if (info && info->path) { return rb_str_new2(info->path); } else { return Qnil; } };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"&ObjectSpace.allocation_sourcefile;F;7@@';@C';T;;r;0;@E';{;IC; "Returns the source file origin from the given +object+. See ::trace_object_allocations for more information and examples.;T;[o;= ;>I" overload;F;?0;;r;@0;:I""allocation_sourcefile(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@\';![;"I"@return [String];T;#0;$@\';.F;Bi;C0;7[[I" object;T0;$@\';![;"I"Returns the source file origin from the given +object+. See ::trace_object_allocations for more information and examples. @overload allocation_sourcefile(object) @return [String];T;#0;$@\';.F;/o;0;1T;2i;3i;Bi;%@&;9@Z';:@[';;To;4;5F;6;;;;&I"&ObjectSpace#allocation_sourceline;F;7[[I"obj;T0;[[@&i;T;:allocation_sourceline;0;[;{;IC; "Returns the original line from source for from the given +object+. See ::trace_object_allocations for more information and examples. ;T;[o;= ;>I" overload;F;?0;;s;@0;:I""allocation_sourceline(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@s';![;"I"@return [Integer];T;#0;$@s';.F;Bi;C0;7[[I" object;T0;$@s';![;"I"Returns the original line from source for from the given +object+. See ::trace_object_allocations for more information and examples. @overload allocation_sourceline(object) @return [Integer];T;#0;$@s';.F;C0;%@&;9I"static VALUE allocation_sourceline(VALUE self, VALUE obj) { struct allocation_info *info = lookup_allocation_info(obj); if (info) { return INT2FIX(info->line); } else { return Qnil; } };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"&ObjectSpace.allocation_sourceline;F;7@u';@x';T;;s;0;@z';{;IC; "Returns the original line from source for from the given +object+. See ::trace_object_allocations for more information and examples.;T;[o;= ;>I" overload;F;?0;;s;@0;:I""allocation_sourceline(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@';![;"I"@return [Integer];T;#0;$@';.F;Bi;C0;7[[I" object;T0;$@';![;"I"Returns the original line from source for from the given +object+. See ::trace_object_allocations for more information and examples. @overload allocation_sourceline(object) @return [Integer];T;#0;$@';.F;/o;0;1T;2i;3i;Bi;%@&;9@';:@';;To;4;5F;6;;;;&I"&ObjectSpace#allocation_class_path;F;7[[I"obj;T0;[[@&i;T;:allocation_class_path;0;[;{;IC; "!Returns the class for the given +object+. class A def foo ObjectSpace::trace_object_allocations do obj = Object.new p "#{ObjectSpace::allocation_class_path(obj)}" end end end A.new.foo #=> "Class" See ::trace_object_allocations for more information and examples. ;T;[o;= ;>I" overload;F;?0;;t;@0;:I""allocation_class_path(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@';![;"I"@return [String];T;#0;$@';.F;Bi;C0;7[[I" object;T0;$@';![;"I"]Returns the class for the given +object+. class A def foo ObjectSpace::trace_object_allocations do obj = Object.new p "#{ObjectSpace::allocation_class_path(obj)}" end end end A.new.foo #=> "Class" See ::trace_object_allocations for more information and examples. @overload allocation_class_path(object) @return [String];T;#0;$@';.F;C0;%@&;9I"static VALUE allocation_class_path(VALUE self, VALUE obj) { struct allocation_info *info = lookup_allocation_info(obj); if (info && info->class_path) { return rb_str_new2(info->class_path); } else { return Qnil; } };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"&ObjectSpace.allocation_class_path;F;7@';@';T;;t;0;@';{;IC; "!Returns the class for the given +object+. class A def foo ObjectSpace::trace_object_allocations do obj = Object.new p "#{ObjectSpace::allocation_class_path(obj)}" end end end A.new.foo #=> "Class" See ::trace_object_allocations for more information and examples.;T;[o;= ;>I" overload;F;?0;;t;@0;:I""allocation_class_path(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@';![;"I"@return [String];T;#0;$@';.F;Bi;C0;7[[I" object;T0;$@';![;"I"^Returns the class for the given +object+. class A def foo ObjectSpace::trace_object_allocations do obj = Object.new p "#{ObjectSpace::allocation_class_path(obj)}" end end end A.new.foo #=> "Class" See ::trace_object_allocations for more information and examples. @overload allocation_class_path(object) @return [String];T;#0;$@';.F;/o;0;1T;2i;3i;Bi;%@&;9@';:@';;To;4;5F;6;;;;&I"%ObjectSpace#allocation_method_id;F;7[[I"obj;T0;[[@&i;T;:allocation_method_id;0;[;{;IC; "KReturns the method identifier for the given +object+. class A include ObjectSpace def foo trace_object_allocations do obj = Object.new p "#{allocation_class_path(obj)}##{allocation_method_id(obj)}" end end end A.new.foo #=> "Class#new" See ::trace_object_allocations for more information and examples. ;T;[o;= ;>I" overload;F;?0;;u;@0;:I"!allocation_method_id(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@';![;"I"@return [String];T;#0;$@';.F;Bi;C0;7[[I" object;T0;$@';![;"I"Returns the method identifier for the given +object+. class A include ObjectSpace def foo trace_object_allocations do obj = Object.new p "#{allocation_class_path(obj)}##{allocation_method_id(obj)}" end end end A.new.foo #=> "Class#new" See ::trace_object_allocations for more information and examples. @overload allocation_method_id(object) @return [String];T;#0;$@';.F;C0;%@&;9I"static VALUE allocation_method_id(VALUE self, VALUE obj) { struct allocation_info *info = lookup_allocation_info(obj); if (info) { return info->mid; } else { return Qnil; } };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"%ObjectSpace.allocation_method_id;F;7@';@';T;;u;0;@';{;IC; "KReturns the method identifier for the given +object+. class A include ObjectSpace def foo trace_object_allocations do obj = Object.new p "#{allocation_class_path(obj)}##{allocation_method_id(obj)}" end end end A.new.foo #=> "Class#new" See ::trace_object_allocations for more information and examples.;T;[o;= ;>I" overload;F;?0;;u;@0;:I"!allocation_method_id(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@';![;"I"@return [String];T;#0;$@';.F;Bi;C0;7[[I" object;T0;$@';![;"I"Returns the method identifier for the given +object+. class A include ObjectSpace def foo trace_object_allocations do obj = Object.new p "#{allocation_class_path(obj)}##{allocation_method_id(obj)}" end end end A.new.foo #=> "Class#new" See ::trace_object_allocations for more information and examples. @overload allocation_method_id(object) @return [String];T;#0;$@';.F;/o;0;1T;2i;3i;Bi;%@&;9@';:@';;To;4;5F;6;;;;&I"&ObjectSpace#allocation_generation;F;7[[I"obj;T0;[[@&i$;T;:allocation_generation;0;[;{;IC; "IReturns garbage collector generation for the given +object+. class B include ObjectSpace def foo trace_object_allocations do obj = Object.new p "Generation is #{allocation_generation(obj)}" end end end B.new.foo #=> "Generation is 3" See ::trace_object_allocations for more information and examples. ;T;[o;= ;>I" overload;F;?0;;v;@0;:I""allocation_generation(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@(;![;"I"@return [Integer, nil];T;#0;$@(;.F;Bi;C0;7[[I" object;T0;$@(;![;"I"Returns garbage collector generation for the given +object+. class B include ObjectSpace def foo trace_object_allocations do obj = Object.new p "Generation is #{allocation_generation(obj)}" end end end B.new.foo #=> "Generation is 3" See ::trace_object_allocations for more information and examples. @overload allocation_generation(object) @return [Integer, nil];T;#0;$@(;.F;C0;%@&;9I"static VALUE allocation_generation(VALUE self, VALUE obj) { struct allocation_info *info = lookup_allocation_info(obj); if (info) { return SIZET2NUM(info->generation); } else { return Qnil; } };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"&ObjectSpace.allocation_generation;F;7@(;@(;T;;v;0;@(;{;IC; "IReturns garbage collector generation for the given +object+. class B include ObjectSpace def foo trace_object_allocations do obj = Object.new p "Generation is #{allocation_generation(obj)}" end end end B.new.foo #=> "Generation is 3" See ::trace_object_allocations for more information and examples.;T;[o;= ;>I" overload;F;?0;;v;@0;:I""allocation_generation(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@1(;![;"I"@return [Integer, nil];T;#0;$@1(;.F;Bi;C0;7[[I" object;T0;$@1(;![;"I"Returns garbage collector generation for the given +object+. class B include ObjectSpace def foo trace_object_allocations do obj = Object.new p "Generation is #{allocation_generation(obj)}" end end end B.new.foo #=> "Generation is 3" See ::trace_object_allocations for more information and examples. @overload allocation_generation(object) @return [Integer, nil];T;#0;$@1(;.F;/o;0;1T;2i;3i#;Bi;%@&;9@/(;:@0(;;To;4;5F;6;;;;&I"ObjectSpace#memsize_of;F;7[[I"obj;T0;[[I"ext/objspace/objspace.c;Ti5;T;:memsize_of;0;[;{;IC; "HReturn consuming memory size of obj in bytes. Note that the return size is incomplete. You need to deal with this information as only a *HINT*. Especially, the size of +T_DATA+ may not be correct. This method is only expected to work with C Ruby. From Ruby 2.2, memsize_of(obj) returns a memory size includes sizeof(RVALUE). ;T;[o;= ;>I" overload;F;?0;;w;@0;:I"memsize_of(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@I(;![;"I"@return [Integer];T;#0;$@I(;.F;Bi;C0;7[[I"obj;T0;$@I(;![;"I"wReturn consuming memory size of obj in bytes. Note that the return size is incomplete. You need to deal with this information as only a *HINT*. Especially, the size of +T_DATA+ may not be correct. This method is only expected to work with C Ruby. From Ruby 2.2, memsize_of(obj) returns a memory size includes sizeof(RVALUE). @overload memsize_of(obj) @return [Integer];T;#0;$@I(;.F;C0;%@&;9I"gstatic VALUE memsize_of_m(VALUE self, VALUE obj) { return SIZET2NUM(rb_obj_memsize_of(obj)); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"ObjectSpace.memsize_of;F;7@K(;@N(;T;;w;0;@Q(;{;IC; "HReturn consuming memory size of obj in bytes. Note that the return size is incomplete. You need to deal with this information as only a *HINT*. Especially, the size of +T_DATA+ may not be correct. This method is only expected to work with C Ruby. From Ruby 2.2, memsize_of(obj) returns a memory size includes sizeof(RVALUE).;T;[o;= ;>I" overload;F;?0;;w;@0;:I"memsize_of(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@h(;![;"I"@return [Integer];T;#0;$@h(;.F;Bi;C0;7[[I"obj;T0;$@h(;![;"I"xReturn consuming memory size of obj in bytes. Note that the return size is incomplete. You need to deal with this information as only a *HINT*. Especially, the size of +T_DATA+ may not be correct. This method is only expected to work with C Ruby. From Ruby 2.2, memsize_of(obj) returns a memory size includes sizeof(RVALUE). @overload memsize_of(obj) @return [Integer];T;#0;$@h(;.F;/o;0;1T;2i%;3i2;Bi;%@&;9@f(;:@g(;;To;4;5F;6;;;;&I"ObjectSpace#memsize_of_all;F;7[[@90;[[@P(i;T;:memsize_of_all;0;[;{;IC; "Return consuming memory size of all living objects in bytes. If +klass+ (should be Class object) is given, return the total memory size of instances of the given class. Note that the returned size is incomplete. You need to deal with this information as only a *HINT*. Especially, the size of +T_DATA+ may not be correct. Note that this method does *NOT* return total malloc'ed memory size. This method can be defined by the following Ruby code: def memsize_of_all klass = false total = 0 ObjectSpace.each_object{|e| total += ObjectSpace.memsize_of(e) if klass == false || e.kind_of?(klass) } total end This method is only expected to work with C Ruby. ;T;[o;= ;>I" overload;F;?0;;x;@0;:I"memsize_of_all([klass]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@(;![;"I"@return [Integer];T;#0;$@(;.F;Bi;C0;7[[I" [klass];T0;$@(;![;"I"Return consuming memory size of all living objects in bytes. If +klass+ (should be Class object) is given, return the total memory size of instances of the given class. Note that the returned size is incomplete. You need to deal with this information as only a *HINT*. Especially, the size of +T_DATA+ may not be correct. Note that this method does *NOT* return total malloc'ed memory size. This method can be defined by the following Ruby code: def memsize_of_all klass = false total = 0 ObjectSpace.each_object{|e| total += ObjectSpace.memsize_of(e) if klass == false || e.kind_of?(klass) } total end This method is only expected to work with C Ruby. @overload memsize_of_all([klass]) @return [Integer];T;#0;$@(;.F;C0;%@&;9I"static VALUE memsize_of_all_m(int argc, VALUE *argv, VALUE self) { struct total_data data = {0, 0}; if (argc > 0) { rb_scan_args(argc, argv, "01", &data.klass); } each_object_with_flags(total_i, &data); return SIZET2NUM(data.total); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"ObjectSpace.memsize_of_all;F;7@(;@(;T;;x;0;@(;{;IC; "Return consuming memory size of all living objects in bytes. If +klass+ (should be Class object) is given, return the total memory size of instances of the given class. Note that the returned size is incomplete. You need to deal with this information as only a *HINT*. Especially, the size of +T_DATA+ may not be correct. Note that this method does *NOT* return total malloc'ed memory size. This method can be defined by the following Ruby code: def memsize_of_all klass = false total = 0 ObjectSpace.each_object{|e| total += ObjectSpace.memsize_of(e) if klass == false || e.kind_of?(klass) } total end This method is only expected to work with C Ruby.;T;[o;= ;>I" overload;F;?0;;x;@0;:I"memsize_of_all([klass]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@(;![;"I"@return [Integer];T;#0;$@(;.F;Bi;C0;7[[I" [klass];T0;$@(;![;"I"Return consuming memory size of all living objects in bytes. If +klass+ (should be Class object) is given, return the total memory size of instances of the given class. Note that the returned size is incomplete. You need to deal with this information as only a *HINT*. Especially, the size of +T_DATA+ may not be correct. Note that this method does *NOT* return total malloc'ed memory size. This method can be defined by the following Ruby code: def memsize_of_all klass = false total = 0 ObjectSpace.each_object{|e| total += ObjectSpace.memsize_of(e) if klass == false || e.kind_of?(klass) } total end This method is only expected to work with C Ruby. @overload memsize_of_all([klass]) @return [Integer];T;#0;$@(;.F;/o;0;1T;2iy;3i;Bi;%@&;9@(;:@(;;To;4;5F;6;;;;&I"#ObjectSpace#count_objects_size;F;7[[@90;[[@P(i;T;:count_objects_size;0;[;{;IC; "1Counts objects size (in bytes) for each type. Note that this information is incomplete. You need to deal with this information as only a *HINT*. Especially, total size of T_DATA may be wrong. It returns a hash as: {:TOTAL=>1461154, :T_CLASS=>158280, :T_MODULE=>20672, :T_STRING=>527249, ...} If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. The contents of the returned hash is implementation defined. It may be changed in future. This method is only expected to work with C Ruby. ;T;[o;= ;>I" overload;F;?0;;y;@0;:I"&count_objects_size([result_hash]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@(;![;"I"@return [Hash];T;#0;$@(;.F;Bi;C0;7[[I"[result_hash];T0;$@(;![;"I"oCounts objects size (in bytes) for each type. Note that this information is incomplete. You need to deal with this information as only a *HINT*. Especially, total size of T_DATA may be wrong. It returns a hash as: {:TOTAL=>1461154, :T_CLASS=>158280, :T_MODULE=>20672, :T_STRING=>527249, ...} If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. The contents of the returned hash is implementation defined. It may be changed in future. This method is only expected to work with C Ruby. @overload count_objects_size([result_hash]) @return [Hash];T;#0;$@(;.F;C0;%@&;9I"+static VALUE count_objects_size(int argc, VALUE *argv, VALUE os) { size_t counts[T_MASK+1]; size_t total = 0; enum ruby_value_type i; VALUE hash = setup_hash(argc, argv); for (i = 0; i <= T_MASK; i++) { counts[i] = 0; } each_object_with_flags(cos_i, &counts[0]); for (i = 0; i <= T_MASK; i++) { if (counts[i]) { VALUE type = type2sym(i); total += counts[i]; rb_hash_aset(hash, type, SIZET2NUM(counts[i])); } } rb_hash_aset(hash, ID2SYM(rb_intern("TOTAL")), SIZET2NUM(total)); return hash; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"#ObjectSpace.count_objects_size;F;7@(;@(;T;;y;0;@(;{;IC; "1Counts objects size (in bytes) for each type. Note that this information is incomplete. You need to deal with this information as only a *HINT*. Especially, total size of T_DATA may be wrong. It returns a hash as: {:TOTAL=>1461154, :T_CLASS=>158280, :T_MODULE=>20672, :T_STRING=>527249, ...} If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. The contents of the returned hash is implementation defined. It may be changed in future. This method is only expected to work with C Ruby.;T;[o;= ;>I" overload;F;?0;;y;@0;:I"&count_objects_size([result_hash]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@(;![;"I"@return [Hash];T;#0;$@(;.F;Bi;C0;7[[I"[result_hash];T0;$@(;![;"I"pCounts objects size (in bytes) for each type. Note that this information is incomplete. You need to deal with this information as only a *HINT*. Especially, total size of T_DATA may be wrong. It returns a hash as: {:TOTAL=>1461154, :T_CLASS=>158280, :T_MODULE=>20672, :T_STRING=>527249, ...} If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. The contents of the returned hash is implementation defined. It may be changed in future. This method is only expected to work with C Ruby. @overload count_objects_size([result_hash]) @return [Hash];T;#0;$@(;.F;/o;0;1T;2i;3i;Bi;%@&;9@(;:@(;;To;4;5F;6;;;;&I"ObjectSpace#count_symbols;F;7[[@90;[[@P(iJ;T;:count_symbols;0;[;{;IC; "'Counts symbols for each Symbol type. This method is only for MRI developers interested in performance and memory usage of Ruby programs. If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. Note: The contents of the returned hash is implementation defined. It may be changed in future. This method is only expected to work with C Ruby. On this version of MRI, they have 3 types of Symbols (and 1 total counts). * mortal_dynamic_symbol: GC target symbols (collected by GC) * immortal_dynamic_symbol: Immortal symbols promoted from dynamic symbols (do not collected by GC) * immortal_static_symbol: Immortal symbols (do not collected by GC) * immortal_symbol: total immortal symbols (immortal_dynamic_symbol+immortal_static_symbol) ;T;[o;= ;>I" overload;F;?0;;z;@0;:I"!count_symbols([result_hash]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@(;![;"I"@return [Hash];T;#0;$@(;.F;Bi;C0;7[[I"[result_hash];T0;$@(;![;"I"`Counts symbols for each Symbol type. This method is only for MRI developers interested in performance and memory usage of Ruby programs. If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. Note: The contents of the returned hash is implementation defined. It may be changed in future. This method is only expected to work with C Ruby. On this version of MRI, they have 3 types of Symbols (and 1 total counts). * mortal_dynamic_symbol: GC target symbols (collected by GC) * immortal_dynamic_symbol: Immortal symbols promoted from dynamic symbols (do not collected by GC) * immortal_static_symbol: Immortal symbols (do not collected by GC) * immortal_symbol: total immortal symbols (immortal_dynamic_symbol+immortal_static_symbol) @overload count_symbols([result_hash]) @return [Hash];T;#0;$@(;.F;C0;%@&;9I"static VALUE count_symbols(int argc, VALUE *argv, VALUE os) { struct dynamic_symbol_counts dynamic_counts = {0, 0}; VALUE hash = setup_hash(argc, argv); size_t immortal_symbols = rb_sym_immortal_count(); each_object_with_flags(cs_i, &dynamic_counts); rb_hash_aset(hash, ID2SYM(rb_intern("mortal_dynamic_symbol")), SIZET2NUM(dynamic_counts.mortal)); rb_hash_aset(hash, ID2SYM(rb_intern("immortal_dynamic_symbol")), SIZET2NUM(dynamic_counts.immortal)); rb_hash_aset(hash, ID2SYM(rb_intern("immortal_static_symbol")), SIZET2NUM(immortal_symbols - dynamic_counts.immortal)); rb_hash_aset(hash, ID2SYM(rb_intern("immortal_symbol")), SIZET2NUM(immortal_symbols)); return hash; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"ObjectSpace.count_symbols;F;7@(;@(;T;;z;0;@(;{;IC; "'Counts symbols for each Symbol type. This method is only for MRI developers interested in performance and memory usage of Ruby programs. If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. Note: The contents of the returned hash is implementation defined. It may be changed in future. This method is only expected to work with C Ruby. On this version of MRI, they have 3 types of Symbols (and 1 total counts). * mortal_dynamic_symbol: GC target symbols (collected by GC) * immortal_dynamic_symbol: Immortal symbols promoted from dynamic symbols (do not collected by GC) * immortal_static_symbol: Immortal symbols (do not collected by GC) * immortal_symbol: total immortal symbols (immortal_dynamic_symbol+immortal_static_symbol);T;[o;= ;>I" overload;F;?0;;z;@0;:I"!count_symbols([result_hash]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@);![;"I"@return [Hash];T;#0;$@);.F;Bi;C0;7[[I"[result_hash];T0;$@);![;"I"aCounts symbols for each Symbol type. This method is only for MRI developers interested in performance and memory usage of Ruby programs. If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. Note: The contents of the returned hash is implementation defined. It may be changed in future. This method is only expected to work with C Ruby. On this version of MRI, they have 3 types of Symbols (and 1 total counts). * mortal_dynamic_symbol: GC target symbols (collected by GC) * immortal_dynamic_symbol: Immortal symbols promoted from dynamic symbols (do not collected by GC) * immortal_static_symbol: Immortal symbols (do not collected by GC) * immortal_symbol: total immortal symbols (immortal_dynamic_symbol+immortal_static_symbol) @overload count_symbols([result_hash]) @return [Hash];T;#0;$@);.F;/o;0;1T;2i0;3iG;Bi;%@&;9@);:@);;To;4;5F;6;;;;&I"ObjectSpace#count_nodes;F;7[[@90;[[@P(i};T;:count_nodes;0;[;{;IC; "Counts nodes for each node type. This method is only for MRI developers interested in performance and memory usage of Ruby programs. It returns a hash as: {:NODE_METHOD=>2027, :NODE_FBODY=>1927, :NODE_CFUNC=>1798, ...} If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. Note: The contents of the returned hash is implementation defined. It may be changed in future. This method is only expected to work with C Ruby. ;T;[o;= ;>I" overload;F;?0;;{;@0;:I"count_nodes([result_hash]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@);![;"I"@return [Hash];T;#0;$@);.F;Bi;C0;7[[I"[result_hash];T0;$@);![;"I""Counts nodes for each node type. This method is only for MRI developers interested in performance and memory usage of Ruby programs. It returns a hash as: {:NODE_METHOD=>2027, :NODE_FBODY=>1927, :NODE_CFUNC=>1798, ...} If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. Note: The contents of the returned hash is implementation defined. It may be changed in future. This method is only expected to work with C Ruby. @overload count_nodes([result_hash]) @return [Hash];T;#0;$@);.F;C0;%@&;9I" static VALUE count_nodes(int argc, VALUE *argv, VALUE os) { size_t nodes[NODE_LAST+1]; enum node_type i; VALUE hash = setup_hash(argc, argv); for (i = 0; i <= NODE_LAST; i++) { nodes[i] = 0; } each_object_with_flags(cn_i, &nodes[0]); for (i=0; i2027, :NODE_FBODY=>1927, :NODE_CFUNC=>1798, ...} If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. Note: The contents of the returned hash is implementation defined. It may be changed in future. This method is only expected to work with C Ruby.;T;[o;= ;>I" overload;F;?0;;{;@0;:I"count_nodes([result_hash]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@8);![;"I"@return [Hash];T;#0;$@8);.F;Bi;C0;7[[I"[result_hash];T0;$@8);![;"I"#Counts nodes for each node type. This method is only for MRI developers interested in performance and memory usage of Ruby programs. It returns a hash as: {:NODE_METHOD=>2027, :NODE_FBODY=>1927, :NODE_CFUNC=>1798, ...} If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. Note: The contents of the returned hash is implementation defined. It may be changed in future. This method is only expected to work with C Ruby. @overload count_nodes([result_hash]) @return [Hash];T;#0;$@8);.F;/o;0;1T;2if;3iz;Bi;%@&;9@6);:@7);;To;4;5F;6;;;;&I"$ObjectSpace#count_tdata_objects;F;7[[@90;[[@P(i=;T;:count_tdata_objects;0;[;{;IC; "Counts objects for each +T_DATA+ type. This method is only for MRI developers interested in performance and memory usage of Ruby programs. It returns a hash as: {RubyVM::InstructionSequence=>504, :parser=>5, :barrier=>6, :mutex=>6, Proc=>60, RubyVM::Env=>57, Mutex=>1, Encoding=>99, ThreadGroup=>1, Binding=>1, Thread=>1, RubyVM=>1, :iseq=>1, Random=>1, ARGF.class=>1, Data=>1, :autoload=>3, Time=>2} # T_DATA objects existing at startup on r32276. If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. The contents of the returned hash is implementation specific and may change in the future. In this version, keys are Class object or Symbol object. If object is kind of normal (accessible) object, the key is Class object. If object is not a kind of normal (internal) object, the key is symbol name, registered by rb_data_type_struct. This method is only expected to work with C Ruby. ;T;[o;= ;>I" overload;F;?0;;|;@0;:I"'count_tdata_objects([result_hash]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@O);![;"I"@return [Hash];T;#0;$@O);.F;Bi;C0;7[[I"[result_hash];T0;$@O);![;"I"Counts objects for each +T_DATA+ type. This method is only for MRI developers interested in performance and memory usage of Ruby programs. It returns a hash as: {RubyVM::InstructionSequence=>504, :parser=>5, :barrier=>6, :mutex=>6, Proc=>60, RubyVM::Env=>57, Mutex=>1, Encoding=>99, ThreadGroup=>1, Binding=>1, Thread=>1, RubyVM=>1, :iseq=>1, Random=>1, ARGF.class=>1, Data=>1, :autoload=>3, Time=>2} # T_DATA objects existing at startup on r32276. If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. The contents of the returned hash is implementation specific and may change in the future. In this version, keys are Class object or Symbol object. If object is kind of normal (accessible) object, the key is Class object. If object is not a kind of normal (internal) object, the key is symbol name, registered by rb_data_type_struct. This method is only expected to work with C Ruby. @overload count_tdata_objects([result_hash]) @return [Hash];T;#0;$@O);.F;C0;%@&;9I"static VALUE count_tdata_objects(int argc, VALUE *argv, VALUE self) { VALUE hash = setup_hash(argc, argv); each_object_with_flags(cto_i, (void *)hash); return hash; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"$ObjectSpace.count_tdata_objects;F;7@Q);@S);T;;|;0;@U);{;IC; "Counts objects for each +T_DATA+ type. This method is only for MRI developers interested in performance and memory usage of Ruby programs. It returns a hash as: {RubyVM::InstructionSequence=>504, :parser=>5, :barrier=>6, :mutex=>6, Proc=>60, RubyVM::Env=>57, Mutex=>1, Encoding=>99, ThreadGroup=>1, Binding=>1, Thread=>1, RubyVM=>1, :iseq=>1, Random=>1, ARGF.class=>1, Data=>1, :autoload=>3, Time=>2} # T_DATA objects existing at startup on r32276. If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. The contents of the returned hash is implementation specific and may change in the future. In this version, keys are Class object or Symbol object. If object is kind of normal (accessible) object, the key is Class object. If object is not a kind of normal (internal) object, the key is symbol name, registered by rb_data_type_struct. This method is only expected to work with C Ruby.;T;[o;= ;>I" overload;F;?0;;|;@0;:I"'count_tdata_objects([result_hash]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@l);![;"I"@return [Hash];T;#0;$@l);.F;Bi;C0;7[[I"[result_hash];T0;$@l);![;"I"Counts objects for each +T_DATA+ type. This method is only for MRI developers interested in performance and memory usage of Ruby programs. It returns a hash as: {RubyVM::InstructionSequence=>504, :parser=>5, :barrier=>6, :mutex=>6, Proc=>60, RubyVM::Env=>57, Mutex=>1, Encoding=>99, ThreadGroup=>1, Binding=>1, Thread=>1, RubyVM=>1, :iseq=>1, Random=>1, ARGF.class=>1, Data=>1, :autoload=>3, Time=>2} # T_DATA objects existing at startup on r32276. If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. The contents of the returned hash is implementation specific and may change in the future. In this version, keys are Class object or Symbol object. If object is kind of normal (accessible) object, the key is Class object. If object is not a kind of normal (internal) object, the key is symbol name, registered by rb_data_type_struct. This method is only expected to work with C Ruby. @overload count_tdata_objects([result_hash]) @return [Hash];T;#0;$@l);.F;/o;0;1T;2i;3i:;Bi;%@&;9@j);:@k);;To;4;5F;6;;;;&I"$ObjectSpace#count_imemo_objects;F;7[[@90;[[@P(iy;T;:count_imemo_objects;0;[;{;IC; "OCounts objects for each +T_IMEMO+ type. This method is only for MRI developers interested in performance and memory usage of Ruby programs. It returns a hash as: {:imemo_ifunc=>8, :imemo_svar=>7, :imemo_cref=>509, :imemo_memo=>1, :imemo_throw_data=>1} If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. The contents of the returned hash is implementation specific and may change in the future. In this version, keys are symbol objects. This method is only expected to work with C Ruby. ;T;[o;= ;>I" overload;F;?0;;};@0;:I"'count_imemo_objects([result_hash]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@);![;"I"@return [Hash];T;#0;$@);.F;Bi;C0;7[[I"[result_hash];T0;$@);![;"I"Counts objects for each +T_IMEMO+ type. This method is only for MRI developers interested in performance and memory usage of Ruby programs. It returns a hash as: {:imemo_ifunc=>8, :imemo_svar=>7, :imemo_cref=>509, :imemo_memo=>1, :imemo_throw_data=>1} If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. The contents of the returned hash is implementation specific and may change in the future. In this version, keys are symbol objects. This method is only expected to work with C Ruby. @overload count_imemo_objects([result_hash]) @return [Hash];T;#0;$@);.F;C0;%@&;9I"static VALUE count_imemo_objects(int argc, VALUE *argv, VALUE self) { VALUE hash = setup_hash(argc, argv); if (imemo_type_ids[0] == 0) { imemo_type_ids[0] = rb_intern("imemo_env"); imemo_type_ids[1] = rb_intern("imemo_cref"); imemo_type_ids[2] = rb_intern("imemo_svar"); imemo_type_ids[3] = rb_intern("imemo_throw_data"); imemo_type_ids[4] = rb_intern("imemo_ifunc"); imemo_type_ids[5] = rb_intern("imemo_memo"); imemo_type_ids[6] = rb_intern("imemo_ment"); imemo_type_ids[7] = rb_intern("imemo_iseq"); imemo_type_ids[8] = rb_intern("imemo_tmpbuf"); imemo_type_ids[9] = rb_intern("imemo_ast"); imemo_type_ids[10] = rb_intern("imemo_parser_strterm"); imemo_type_ids[11] = rb_intern("imemo_callinfo"); imemo_type_ids[12] = rb_intern("imemo_callcache"); imemo_type_ids[13] = rb_intern("imemo_constcache"); } each_object_with_flags(count_imemo_objects_i, (void *)hash); return hash; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"$ObjectSpace.count_imemo_objects;F;7@);@);T;;};0;@);{;IC; "OCounts objects for each +T_IMEMO+ type. This method is only for MRI developers interested in performance and memory usage of Ruby programs. It returns a hash as: {:imemo_ifunc=>8, :imemo_svar=>7, :imemo_cref=>509, :imemo_memo=>1, :imemo_throw_data=>1} If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. The contents of the returned hash is implementation specific and may change in the future. In this version, keys are symbol objects. This method is only expected to work with C Ruby.;T;[o;= ;>I" overload;F;?0;;};@0;:I"'count_imemo_objects([result_hash]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@);![;"I"@return [Hash];T;#0;$@);.F;Bi;C0;7[[I"[result_hash];T0;$@);![;"I"Counts objects for each +T_IMEMO+ type. This method is only for MRI developers interested in performance and memory usage of Ruby programs. It returns a hash as: {:imemo_ifunc=>8, :imemo_svar=>7, :imemo_cref=>509, :imemo_memo=>1, :imemo_throw_data=>1} If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect. The contents of the returned hash is implementation specific and may change in the future. In this version, keys are symbol objects. This method is only expected to work with C Ruby. @overload count_imemo_objects([result_hash]) @return [Hash];T;#0;$@);.F;/o;0;1T;2i];3iv;Bi;%@&;9@);:@);;To;4;5F;6;;;;&I"'ObjectSpace#reachable_objects_from;F;7[[I"obj;T0;[[@P(i;T;:reachable_objects_from;0;[;{;IC; "[MRI specific feature] Return all reachable objects from `obj'. This method returns all reachable objects from `obj'. If `obj' has two or more references to the same object `x', then returned array only includes one `x' object. If `obj' is a non-markable (non-heap management) object such as true, false, nil, symbols and Fixnums (and Flonum) then it simply returns nil. If `obj' has references to an internal object, then it returns instances of ObjectSpace::InternalObjectWrapper class. This object contains a reference to an internal object and you can check the type of internal object with `type' method. If `obj' is instance of ObjectSpace::InternalObjectWrapper class, then this method returns all reachable object from an internal object, which is pointed by `obj'. With this method, you can find memory leaks. This method is only expected to work except with C Ruby. Example: ObjectSpace.reachable_objects_from(['a', 'b', 'c']) #=> [Array, 'a', 'b', 'c'] ObjectSpace.reachable_objects_from(['a', 'a', 'a']) #=> [Array, 'a', 'a', 'a'] # all 'a' strings have different object id ObjectSpace.reachable_objects_from([v = 'a', v, v]) #=> [Array, 'a'] ObjectSpace.reachable_objects_from(1) #=> nil # 1 is not markable (heap managed) object ;T;[o;= ;>I" overload;F;?0;;~;@0;:I" reachable_objects_from(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;TI"nil;T;$@);![;"I"@return [Array, nil];T;#0;$@);.F;Bi;C0;7[[I"obj;T0;$@);![;"I"3[MRI specific feature] Return all reachable objects from `obj'. This method returns all reachable objects from `obj'. If `obj' has two or more references to the same object `x', then returned array only includes one `x' object. If `obj' is a non-markable (non-heap management) object such as true, false, nil, symbols and Fixnums (and Flonum) then it simply returns nil. If `obj' has references to an internal object, then it returns instances of ObjectSpace::InternalObjectWrapper class. This object contains a reference to an internal object and you can check the type of internal object with `type' method. If `obj' is instance of ObjectSpace::InternalObjectWrapper class, then this method returns all reachable object from an internal object, which is pointed by `obj'. With this method, you can find memory leaks. This method is only expected to work except with C Ruby. Example: ObjectSpace.reachable_objects_from(['a', 'b', 'c']) #=> [Array, 'a', 'b', 'c'] ObjectSpace.reachable_objects_from(['a', 'a', 'a']) #=> [Array, 'a', 'a', 'a'] # all 'a' strings have different object id ObjectSpace.reachable_objects_from([v = 'a', v, v]) #=> [Array, 'a'] ObjectSpace.reachable_objects_from(1) #=> nil # 1 is not markable (heap managed) object @overload reachable_objects_from(obj) @return [Array, nil];T;#0;$@);.F;C0;%@&;9I"static VALUE reachable_objects_from(VALUE self, VALUE obj) { if (rb_objspace_markable_object_p(obj)) { struct rof_data data; if (rb_typeddata_is_kind_of(obj, &iow_data_type)) { obj = (VALUE)DATA_PTR(obj); } data.refs = rb_ident_hash_new(); data.internals = rb_ary_new(); rb_objspace_reachable_objects_from(obj, reachable_object_from_i, &data); return rb_funcall(data.refs, rb_intern("values"), 0); } else { return Qnil; } };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"'ObjectSpace.reachable_objects_from;F;7@);@);T;;~;0;@);{;IC; "[MRI specific feature] Return all reachable objects from `obj'. This method returns all reachable objects from `obj'. If `obj' has two or more references to the same object `x', then returned array only includes one `x' object. If `obj' is a non-markable (non-heap management) object such as true, false, nil, symbols and Fixnums (and Flonum) then it simply returns nil. If `obj' has references to an internal object, then it returns instances of ObjectSpace::InternalObjectWrapper class. This object contains a reference to an internal object and you can check the type of internal object with `type' method. If `obj' is instance of ObjectSpace::InternalObjectWrapper class, then this method returns all reachable object from an internal object, which is pointed by `obj'. With this method, you can find memory leaks. This method is only expected to work except with C Ruby. Example: ObjectSpace.reachable_objects_from(['a', 'b', 'c']) #=> [Array, 'a', 'b', 'c'] ObjectSpace.reachable_objects_from(['a', 'a', 'a']) #=> [Array, 'a', 'a', 'a'] # all 'a' strings have different object id ObjectSpace.reachable_objects_from([v = 'a', v, v]) #=> [Array, 'a'] ObjectSpace.reachable_objects_from(1) #=> nil # 1 is not markable (heap managed) object;T;[o;= ;>I" overload;F;?0;;~;@0;:I" reachable_objects_from(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;TI"nil;T;$@);![;"I"@return [Array, nil];T;#0;$@);.F;Bi;C0;7[[I"obj;T0;$@);![;"I"5[MRI specific feature] Return all reachable objects from `obj'. This method returns all reachable objects from `obj'. If `obj' has two or more references to the same object `x', then returned array only includes one `x' object. If `obj' is a non-markable (non-heap management) object such as true, false, nil, symbols and Fixnums (and Flonum) then it simply returns nil. If `obj' has references to an internal object, then it returns instances of ObjectSpace::InternalObjectWrapper class. This object contains a reference to an internal object and you can check the type of internal object with `type' method. If `obj' is instance of ObjectSpace::InternalObjectWrapper class, then this method returns all reachable object from an internal object, which is pointed by `obj'. With this method, you can find memory leaks. This method is only expected to work except with C Ruby. Example: ObjectSpace.reachable_objects_from(['a', 'b', 'c']) #=> [Array, 'a', 'b', 'c'] ObjectSpace.reachable_objects_from(['a', 'a', 'a']) #=> [Array, 'a', 'a', 'a'] # all 'a' strings have different object id ObjectSpace.reachable_objects_from([v = 'a', v, v]) #=> [Array, 'a'] ObjectSpace.reachable_objects_from(1) #=> nil # 1 is not markable (heap managed) object @overload reachable_objects_from(obj) @return [Array, nil];T;#0;$@);.F;/o;0;1T;2i;3i ;Bi;%@&;9@);:@);;To;4;5F;6;;;;&I",ObjectSpace#reachable_objects_from_root;F;7[;[[@P(i[;T;: reachable_objects_from_root;0;[;{;IC; "C[MRI specific feature] Return all reachable objects from root. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" reachable_objects_from_root;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@);![;"I"@return [Hash];T;#0;$@);.F;Bi;C0;7[;$@);![;"I"{[MRI specific feature] Return all reachable objects from root. @overload reachable_objects_from_root @return [Hash];T;#0;$@);.F;C0;%@&;9I"Gstatic VALUE reachable_objects_from_root(VALUE self) { struct rofr_data data; VALUE hash = data.categories = rb_ident_hash_new(); data.last_category = 0; rb_objspace_reachable_objects_from_root(reachable_object_from_root_i, &data); rb_hash_foreach(hash, collect_values_of_values, hash); return hash; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I",ObjectSpace.reachable_objects_from_root;F;7@);@);T;;;0;@);{;IC; "C[MRI specific feature] Return all reachable objects from root.;T;[o;= ;>I" overload;F;?0;;;@0;:I" reachable_objects_from_root;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@*;![;"I"@return [Hash];T;#0;$@*;.F;Bi;C0;7[;$@*;![;"I"|[MRI specific feature] Return all reachable objects from root. @overload reachable_objects_from_root @return [Hash];T;#0;$@*;.F;/o;0;1T;2iU;3iY;Bi;%@&;9@*;:@*;;To;4;5F;6;;;;&I""ObjectSpace#internal_class_of;F;7[[I"obj;T0;[[@P(i;T;:internal_class_of;0;[;{;IC; "[MRI specific feature] Return internal class of obj. obj can be an instance of InternalObjectWrapper. Note that you should not use this method in your application. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"internal_class_of(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Class;TI" Module;T;$@*;![;"I"@return [Class, Module];T;#0;$@*;.F;Bi;C0;7[[I"obj;T0;$@*;![;"I"[MRI specific feature] Return internal class of obj. obj can be an instance of InternalObjectWrapper. Note that you should not use this method in your application. @overload internal_class_of(obj) @return [Class, Module];T;#0;$@*;.F;C0;%@&;9I"Dstatic VALUE objspace_internal_class_of(VALUE self, VALUE obj) { VALUE klass; if (rb_typeddata_is_kind_of(obj, &iow_data_type)) { obj = (VALUE)DATA_PTR(obj); } if (RB_TYPE_P(obj, T_IMEMO)) { return Qnil; } else { klass = CLASS_OF(obj); return wrap_klass_iow(klass); } };T;:I"static VALUE;T;;To;4;5T;6;;;;&I""ObjectSpace.internal_class_of;F;7@*;@"*;T;;;0;@$*;{;IC; "[MRI specific feature] Return internal class of obj. obj can be an instance of InternalObjectWrapper. Note that you should not use this method in your application.;T;[o;= ;>I" overload;F;?0;;;@0;:I"internal_class_of(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Class;TI" Module;T;$@<*;![;"I"@return [Class, Module];T;#0;$@<*;.F;Bi;C0;7[[I"obj;T0;$@<*;![;"I"[MRI specific feature] Return internal class of obj. obj can be an instance of InternalObjectWrapper. Note that you should not use this method in your application. @overload internal_class_of(obj) @return [Class, Module];T;#0;$@<*;.F;/o;0;1T;2iw;3i~;Bi;%@&;9@:*;:@;*;;To;4;5F;6;;;;&I""ObjectSpace#internal_super_of;F;7[[I"obj;T0;[[@P(i;T;:internal_super_of;0;[;{;IC; "[MRI specific feature] Return internal super class of cls (Class or Module). obj can be an instance of InternalObjectWrapper. Note that you should not use this method in your application. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"internal_super_of(cls);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Class;TI" Module;T;$@T*;![;"I"@return [Class, Module];T;#0;$@T*;.F;Bi;C0;7[[I"cls;T0;$@T*;![;"I"[MRI specific feature] Return internal super class of cls (Class or Module). obj can be an instance of InternalObjectWrapper. Note that you should not use this method in your application. @overload internal_super_of(cls) @return [Class, Module];T;#0;$@T*;.F;C0;%@&;9I"static VALUE objspace_internal_super_of(VALUE self, VALUE obj) { VALUE super; if (rb_typeddata_is_kind_of(obj, &iow_data_type)) { obj = (VALUE)DATA_PTR(obj); } switch (OBJ_BUILTIN_TYPE(obj)) { case T_MODULE: case T_CLASS: case T_ICLASS: super = RCLASS_SUPER(obj); break; default: rb_raise(rb_eArgError, "class or module is expected"); } return wrap_klass_iow(super); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I""ObjectSpace.internal_super_of;F;7@V*;@Y*;T;;;0;@[*;{;IC; "[MRI specific feature] Return internal super class of cls (Class or Module). obj can be an instance of InternalObjectWrapper. Note that you should not use this method in your application.;T;[o;= ;>I" overload;F;?0;;;@0;:I"internal_super_of(cls);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Class;TI" Module;T;$@s*;![;"I"@return [Class, Module];T;#0;$@s*;.F;Bi;C0;7[[I"cls;T0;$@s*;![;"I"[MRI specific feature] Return internal super class of cls (Class or Module). obj can be an instance of InternalObjectWrapper. Note that you should not use this method in your application. @overload internal_super_of(cls) @return [Class, Module];T;#0;$@s*;.F;/o;0;1T;2i;3i;Bi;%@&;9@q*;:@r*;;To; ;IC;[o;4;5F;6;;;;&I",ObjectSpace::InternalObjectWrapper#type;F;7[;[[@P(i;T;: type;0;[;{;IC; "-Returns the type of the internal object. ;T;[;![;"I"-Returns the type of the internal object.;T;#0;$@*;.F;/o;0;1T;2i;3i;%@*;9I"ystatic VALUE iow_type(VALUE self) { VALUE obj = (VALUE)DATA_PTR(self); return type2sym(BUILTIN_TYPE(obj)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"/ObjectSpace::InternalObjectWrapper#inspect;F;7[;[[@P(i;T;;J;0;[;{;IC; "See Object#inspect. ;T;[;![;"I"See Object#inspect.;T;#0;$@*;.F;/o;0;1T;2i;3i;%@*;9I"static VALUE iow_inspect(VALUE self) { VALUE obj = (VALUE)DATA_PTR(self); VALUE type = type2sym(BUILTIN_TYPE(obj)); return rb_sprintf("#", (void *)obj, rb_sym2str(type)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I":ObjectSpace::InternalObjectWrapper#internal_object_id;F;7[;[[@P(i;T;:internal_object_id;0;[;{;IC; "9Returns the Object#object_id of the internal object. ;T;[;![;"I"9Returns the Object#object_id of the internal object.;T;#0;$@*;.F;/o;0;1T;2i;3i;%@*;9I"zstatic VALUE iow_internal_object_id(VALUE self) { VALUE obj = (VALUE)DATA_PTR(self); return rb_obj_id(obj); };T;:I"static VALUE;T;;T; @*; IC;[; @*; IC;[; @*; IC;{;IC;{;T;IC;{;T;T;{;[;[[@P(i;F;:InternalObjectWrapper;;;;;[;{;IC; " ;T;[;![;"@;#0;$@*;Bi;%@&;&I"'ObjectSpace::InternalObjectWrapper;F;'o;( ;)0;*0;+0;;;%@;-@;;o;4;5F;6;;;;&I"ObjectSpace#_dump;F;7[[I"obj;T0[I" output;T0;[[I"!ext/objspace/objspace_dump.c;Tig;T;: _dump;0;[;{;IC; " ;T;[;![;"I";F;#0;$@*;.F;C0;%@&;9I"static VALUE objspace_dump(VALUE os, VALUE obj, VALUE output) { struct dump_config dc = {0,}; dump_output(&dc, output, Qnil, Qnil); dump_object(obj, &dc); return dump_result(&dc); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"ObjectSpace._dump;F;7@*;@*;T;;;0;@*;{;IC; " ;T;[;![;"@;#0;$@*;Bi;%@&;9@*;:@*;;To;4;5F;6;;;;&I"ObjectSpace#_dump_all;F;7[[I" output;T0[I" full;T0[I" since;T0;[[@*ir;T;:_dump_all;0;[;{;IC; " ;T;[;![;"I";F;#0;$@*;.F;C0;%@&;9I"static VALUE objspace_dump_all(VALUE os, VALUE output, VALUE full, VALUE since) { struct dump_config dc = {0,}; dump_output(&dc, output, full, since); if (!dc.partial_dump || dc.since == 0) { /* dump roots */ rb_objspace_reachable_objects_from_root(root_obj_i, &dc); if (dc.roots) dump_append(&dc, "]}\n"); } /* dump all objects */ rb_objspace_each_objects(heap_i, &dc); return dump_result(&dc); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"ObjectSpace._dump_all;F;7@*;@*;T;;;0;@*;{;IC; " ;T;[;![;"@;#0;$@*;Bi;%@&;9@*;:@*;;To;4;5F;6;;;;&I"ObjectSpace#each_object;F;7[[@90;[[@?i;T;:each_object;0;[;{;IC; "Calls the block once for each living, nonimmediate object in this Ruby process. If module is specified, calls the block for only those classes or modules that match (or are a subclass of) module. Returns the number of objects found. Immediate objects (Fixnums, Symbols true, false, and nil) are never returned. In the example below, #each_object returns both the numbers we defined and several constants defined in the Math module. If no block is given, an enumerator is returned instead. a = 102.7 b = 95 # Won't be returned c = 12345678987654321 count = ObjectSpace.each_object(Numeric) {|x| p x } puts "Total count: #{count}" produces: 12345678987654321 102.7 2.71828182845905 3.14159265358979 2.22044604925031e-16 1.7976931348623157e+308 2.2250738585072e-308 Total count: 7 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"each_object([module]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@*o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@*;![;"I"#@yield [obj] @return [Integer];T;#0;$@*;.F;Bi;C0;7[[I"[;T0;$@*o;= ;>I" overload;F;?0;;;@0;:I"each_object([module]);T;IC; ";T;[;![;"I";T;#0;$@*;.F;Bi;C0;7[[I"[;T0;$@*;![;"I"Calls the block once for each living, nonimmediate object in this Ruby process. If module is specified, calls the block for only those classes or modules that match (or are a subclass of) module. Returns the number of objects found. Immediate objects (Fixnums, Symbols true, false, and nil) are never returned. In the example below, #each_object returns both the numbers we defined and several constants defined in the Math module. If no block is given, an enumerator is returned instead. a = 102.7 b = 95 # Won't be returned c = 12345678987654321 count = ObjectSpace.each_object(Numeric) {|x| p x } puts "Total count: #{count}" produces: 12345678987654321 102.7 2.71828182845905 3.14159265358979 2.22044604925031e-16 1.7976931348623157e+308 2.2250738585072e-308 Total count: 7 @overload each_object([module]) @yield [obj] @return [Integer] @overload each_object([module]) ;T;#0;$@*;.F;C0;%@&;9I"static VALUE os_each_obj(int argc, VALUE *argv, VALUE os) { VALUE of; of = (!rb_check_arity(argc, 0, 1) ? 0 : argv[0]); RETURN_ENUMERATOR(os, 1, &of); return os_obj_of(of); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"ObjectSpace.each_object;F;7@*;@*;T;;;0;@*;{;IC; "Calls the block once for each living, nonimmediate object in this Ruby process. If module is specified, calls the block for only those classes or modules that match (or are a subclass of) module. Returns the number of objects found. Immediate objects (Fixnums, Symbols true, false, and nil) are never returned. In the example below, #each_object returns both the numbers we defined and several constants defined in the Math module. If no block is given, an enumerator is returned instead. a = 102.7 b = 95 # Won't be returned c = 12345678987654321 count = ObjectSpace.each_object(Numeric) {|x| p x } puts "Total count: #{count}" produces: 12345678987654321 102.7 2.71828182845905 3.14159265358979 2.22044604925031e-16 1.7976931348623157e+308 2.2250738585072e-308 Total count: 7;T;[o;= ;>I" overload;F;?0;;;@0;:I"each_object([module]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@$+o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@$+;![;"I"#@yield [obj] @return [Integer];T;#0;$@$+;.F;Bi;C0;7[[I"[;T0;$@$+o;= ;>I" overload;F;?0;;;@0;:I"each_object([module]);T;IC; ";T;[;![;"I";T;#0;$@$+;.F;Bi;C0;7[[I"[;T0;$@$+;![;"I"Calls the block once for each living, nonimmediate object in this Ruby process. If module is specified, calls the block for only those classes or modules that match (or are a subclass of) module. Returns the number of objects found. Immediate objects (Fixnums, Symbols true, false, and nil) are never returned. In the example below, #each_object returns both the numbers we defined and several constants defined in the Math module. If no block is given, an enumerator is returned instead. a = 102.7 b = 95 # Won't be returned c = 12345678987654321 count = ObjectSpace.each_object(Numeric) {|x| p x } puts "Total count: #{count}" produces: 12345678987654321 102.7 2.71828182845905 3.14159265358979 2.22044604925031e-16 1.7976931348623157e+308 2.2250738585072e-308 Total count: 7 @overload each_object([module]) @yield [obj] @return [Integer] @overload each_object([module]);T;#0;$@$+;.F;/o;0;1T;2i;3i;Bi;%@&;9@"+;:@#+;;To;4;5F;6;;;;&I"!ObjectSpace#define_finalizer;F;7[[@90;[[@?i;T;:define_finalizer;0;[;{;IC; "KAdds aProc as a finalizer, to be called after obj was destroyed. The object ID of the obj will be passed as an argument to aProc. If aProc is a lambda or method, make sure it can be called with a single argument. The return value is an array [0, aProc]. The two recommended patterns are to either create the finaliser proc in a non-instance method where it can safely capture the needed state, or to use a custom callable object that stores the needed state explicitly as instance variables. class Foo def initialize(data_needed_for_finalization) ObjectSpace.define_finalizer(self, self.class.create_finalizer(data_needed_for_finalization)) end def self.create_finalizer(data_needed_for_finalization) proc { puts "finalizing #{data_needed_for_finalization}" } end end class Bar class Remover def initialize(data_needed_for_finalization) @data_needed_for_finalization = data_needed_for_finalization end def call(id) puts "finalizing #{@data_needed_for_finalization}" end end def initialize(data_needed_for_finalization) ObjectSpace.define_finalizer(self, Remover.new(data_needed_for_finalization)) end end Note that if your finalizer references the object to be finalized it will never be run on GC, although it will still be run at exit. You will get a warning if you capture the object to be finalized as the receiver of the finalizer. class CapturesSelf def initialize(name) ObjectSpace.define_finalizer(self, proc { # this finalizer will only be run on exit puts "finalizing #{name}" }) end end Also note that finalization can be unpredictable and is never guaranteed to be run except on exit. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"(define_finalizer(obj, aProc=proc());T;IC; ";T;[;![;"I";T;#0;$@J+;.F;Bi;C0;7[[I"obj;T0[I" aProc;TI" proc();T;$@J+;![;"I"zAdds aProc as a finalizer, to be called after obj was destroyed. The object ID of the obj will be passed as an argument to aProc. If aProc is a lambda or method, make sure it can be called with a single argument. The return value is an array [0, aProc]. The two recommended patterns are to either create the finaliser proc in a non-instance method where it can safely capture the needed state, or to use a custom callable object that stores the needed state explicitly as instance variables. class Foo def initialize(data_needed_for_finalization) ObjectSpace.define_finalizer(self, self.class.create_finalizer(data_needed_for_finalization)) end def self.create_finalizer(data_needed_for_finalization) proc { puts "finalizing #{data_needed_for_finalization}" } end end class Bar class Remover def initialize(data_needed_for_finalization) @data_needed_for_finalization = data_needed_for_finalization end def call(id) puts "finalizing #{@data_needed_for_finalization}" end end def initialize(data_needed_for_finalization) ObjectSpace.define_finalizer(self, Remover.new(data_needed_for_finalization)) end end Note that if your finalizer references the object to be finalized it will never be run on GC, although it will still be run at exit. You will get a warning if you capture the object to be finalized as the receiver of the finalizer. class CapturesSelf def initialize(name) ObjectSpace.define_finalizer(self, proc { # this finalizer will only be run on exit puts "finalizing #{name}" }) end end Also note that finalization can be unpredictable and is never guaranteed to be run except on exit. @overload define_finalizer(obj, aProc=proc()) ;T;#0;$@J+;.F;C0;%@&;9I"static VALUE define_final(int argc, VALUE *argv, VALUE os) { VALUE obj, block; rb_scan_args(argc, argv, "11", &obj, &block); should_be_finalizable(obj); if (argc == 1) { block = rb_block_proc(); } else { should_be_callable(block); } if (rb_callable_receiver(block) == obj) { rb_warn("finalizer references object to be finalized"); } return define_final0(obj, block); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"!ObjectSpace.define_finalizer;F;7@L+;@N+;T;;;0;@P+;{;IC; "KAdds aProc as a finalizer, to be called after obj was destroyed. The object ID of the obj will be passed as an argument to aProc. If aProc is a lambda or method, make sure it can be called with a single argument. The return value is an array [0, aProc]. The two recommended patterns are to either create the finaliser proc in a non-instance method where it can safely capture the needed state, or to use a custom callable object that stores the needed state explicitly as instance variables. class Foo def initialize(data_needed_for_finalization) ObjectSpace.define_finalizer(self, self.class.create_finalizer(data_needed_for_finalization)) end def self.create_finalizer(data_needed_for_finalization) proc { puts "finalizing #{data_needed_for_finalization}" } end end class Bar class Remover def initialize(data_needed_for_finalization) @data_needed_for_finalization = data_needed_for_finalization end def call(id) puts "finalizing #{@data_needed_for_finalization}" end end def initialize(data_needed_for_finalization) ObjectSpace.define_finalizer(self, Remover.new(data_needed_for_finalization)) end end Note that if your finalizer references the object to be finalized it will never be run on GC, although it will still be run at exit. You will get a warning if you capture the object to be finalized as the receiver of the finalizer. class CapturesSelf def initialize(name) ObjectSpace.define_finalizer(self, proc { # this finalizer will only be run on exit puts "finalizing #{name}" }) end end Also note that finalization can be unpredictable and is never guaranteed to be run except on exit.;T;[o;= ;>I" overload;F;?0;;;@0;:I"(define_finalizer(obj, aProc=proc());T;IC; ";T;[;![;"I";T;#0;$@e+;.F;Bi;C0;7[[I"obj;T0[I" aProc;TI" proc();T;$@e+;![;"I"{Adds aProc as a finalizer, to be called after obj was destroyed. The object ID of the obj will be passed as an argument to aProc. If aProc is a lambda or method, make sure it can be called with a single argument. The return value is an array [0, aProc]. The two recommended patterns are to either create the finaliser proc in a non-instance method where it can safely capture the needed state, or to use a custom callable object that stores the needed state explicitly as instance variables. class Foo def initialize(data_needed_for_finalization) ObjectSpace.define_finalizer(self, self.class.create_finalizer(data_needed_for_finalization)) end def self.create_finalizer(data_needed_for_finalization) proc { puts "finalizing #{data_needed_for_finalization}" } end end class Bar class Remover def initialize(data_needed_for_finalization) @data_needed_for_finalization = data_needed_for_finalization end def call(id) puts "finalizing #{@data_needed_for_finalization}" end end def initialize(data_needed_for_finalization) ObjectSpace.define_finalizer(self, Remover.new(data_needed_for_finalization)) end end Note that if your finalizer references the object to be finalized it will never be run on GC, although it will still be run at exit. You will get a warning if you capture the object to be finalized as the receiver of the finalizer. class CapturesSelf def initialize(name) ObjectSpace.define_finalizer(self, proc { # this finalizer will only be run on exit puts "finalizing #{name}" }) end end Also note that finalization can be unpredictable and is never guaranteed to be run except on exit. @overload define_finalizer(obj, aProc=proc());T;#0;$@e+;.F;/o;0;1T;2i;3i;Bi;%@&;9@c+;:@d+;;To;4;5F;6;;;;&I"#ObjectSpace#undefine_finalizer;F;7[[I"obj;T0;[[@?i;T;:undefine_finalizer;0;[;{;IC; "+Removes all finalizers for obj. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"undefine_finalizer(obj);T;IC; ";T;[;![;"I";T;#0;$@z+;.F;Bi;C0;7[[I"obj;T0;$@z+;![;"I"NRemoves all finalizers for obj. @overload undefine_finalizer(obj) ;T;#0;$@z+;.F;C0;%@&;9I"`static VALUE undefine_final(VALUE os, VALUE obj) { return rb_undefine_finalizer(obj); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"#ObjectSpace.undefine_finalizer;F;7@|+;@+;T;;;0;@+;{;IC; "+Removes all finalizers for obj.;T;[o;= ;>I" overload;F;?0;;;@0;:I"undefine_finalizer(obj);T;IC; ";T;[;![;"I";T;#0;$@+;.F;Bi;C0;7[[I"obj;T0;$@+;![;"I"PRemoves all finalizers for obj. @overload undefine_finalizer(obj);T;#0;$@+;.F;/o;0;1T;2i;3i;Bi;%@&;9@+;:@+;;To;4;5F;6;;;;&I"ObjectSpace#_id2ref;F;7[[I" objid;T0;[[@?i;T;: _id2ref;0;[;{;IC; " ;T;[;![;"I";F;#0;$@+;.F;C0;%@&;9I"Pstatic VALUE os_id2ref(VALUE os, VALUE objid) { return id2ref(objid); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"ObjectSpace._id2ref;F;7@+;@+;T;;;0;@+;{;IC; " ;T;[;![;"@;#0;$@+;Bi;%@&;9@+;:@+;;To;4;5F;6;;;;&I"ObjectSpace#count_objects;F;7[[@90;[[@?ik;T;:count_objects;0;[;{;IC; "Counts all objects grouped by type. It returns a hash, such as: { :TOTAL=>10000, :FREE=>3011, :T_OBJECT=>6, :T_CLASS=>404, # ... } The contents of the returned hash are implementation specific. It may be changed in future. The keys starting with +:T_+ means live objects. For example, +:T_ARRAY+ is the number of arrays. +:FREE+ means object slots which is not used now. +:TOTAL+ means sum of above. If the optional argument +result_hash+ is given, it is overwritten and returned. This is intended to avoid probe effect. h = {} ObjectSpace.count_objects(h) puts h # => { :TOTAL=>10000, :T_CLASS=>158280, :T_MODULE=>20672, :T_STRING=>527249 } This method is only expected to work on C Ruby. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"!count_objects([result_hash]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@+;![;"I"@return [Hash];T;#0;$@+;.F;Bi;C0;7[[I"[result_hash];T0;$@+;![;"I"Counts all objects grouped by type. It returns a hash, such as: { :TOTAL=>10000, :FREE=>3011, :T_OBJECT=>6, :T_CLASS=>404, # ... } The contents of the returned hash are implementation specific. It may be changed in future. The keys starting with +:T_+ means live objects. For example, +:T_ARRAY+ is the number of arrays. +:FREE+ means object slots which is not used now. +:TOTAL+ means sum of above. If the optional argument +result_hash+ is given, it is overwritten and returned. This is intended to avoid probe effect. h = {} ObjectSpace.count_objects(h) puts h # => { :TOTAL=>10000, :T_CLASS=>158280, :T_MODULE=>20672, :T_STRING=>527249 } This method is only expected to work on C Ruby. @overload count_objects([result_hash]) @return [Hash];T;#0;$@+;.F;C0;%@&;9I"static VALUE count_objects(int argc, VALUE *argv, VALUE os) { rb_objspace_t *objspace = &rb_objspace; size_t counts[T_MASK+1]; size_t freed = 0; size_t total = 0; size_t i; VALUE hash = Qnil; if (rb_check_arity(argc, 0, 1) == 1) { hash = argv[0]; if (!RB_TYPE_P(hash, T_HASH)) rb_raise(rb_eTypeError, "non-hash given"); } for (i = 0; i <= T_MASK; i++) { counts[i] = 0; } for (i = 0; i < heap_allocated_pages; i++) { struct heap_page *page = heap_pages_sorted[i]; short stride = page->slot_size; uintptr_t p = (uintptr_t)page->start; uintptr_t pend = p + page->total_slots * stride; for (;p < pend; p += stride) { VALUE vp = (VALUE)p; GC_ASSERT((NUM_IN_PAGE(vp) * sizeof(RVALUE)) % page->slot_size == 0); void *poisoned = asan_poisoned_object_p(vp); asan_unpoison_object(vp, false); if (RANY(p)->as.basic.flags) { counts[BUILTIN_TYPE(vp)]++; } else { freed++; } if (poisoned) { GC_ASSERT(BUILTIN_TYPE(vp) == T_NONE); asan_poison_object(vp); } } total += page->total_slots; } if (NIL_P(hash)) { hash = rb_hash_new(); } else if (!RHASH_EMPTY_P(hash)) { rb_hash_stlike_foreach(hash, set_zero, hash); } rb_hash_aset(hash, ID2SYM(rb_intern("TOTAL")), SIZET2NUM(total)); rb_hash_aset(hash, ID2SYM(rb_intern("FREE")), SIZET2NUM(freed)); for (i = 0; i <= T_MASK; i++) { VALUE type = type_sym(i); if (counts[i]) rb_hash_aset(hash, type, SIZET2NUM(counts[i])); } return hash; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"ObjectSpace.count_objects;F;7@+;@+;T;;;0;@+;{;IC; "Counts all objects grouped by type. It returns a hash, such as: { :TOTAL=>10000, :FREE=>3011, :T_OBJECT=>6, :T_CLASS=>404, # ... } The contents of the returned hash are implementation specific. It may be changed in future. The keys starting with +:T_+ means live objects. For example, +:T_ARRAY+ is the number of arrays. +:FREE+ means object slots which is not used now. +:TOTAL+ means sum of above. If the optional argument +result_hash+ is given, it is overwritten and returned. This is intended to avoid probe effect. h = {} ObjectSpace.count_objects(h) puts h # => { :TOTAL=>10000, :T_CLASS=>158280, :T_MODULE=>20672, :T_STRING=>527249 } This method is only expected to work on C Ruby.;T;[o;= ;>I" overload;F;?0;;;@0;:I"!count_objects([result_hash]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@+;![;"I"@return [Hash];T;#0;$@+;.F;Bi;C0;7[[I"[result_hash];T0;$@+;![;"I"Counts all objects grouped by type. It returns a hash, such as: { :TOTAL=>10000, :FREE=>3011, :T_OBJECT=>6, :T_CLASS=>404, # ... } The contents of the returned hash are implementation specific. It may be changed in future. The keys starting with +:T_+ means live objects. For example, +:T_ARRAY+ is the number of arrays. +:FREE+ means object slots which is not used now. +:TOTAL+ means sum of above. If the optional argument +result_hash+ is given, it is overwritten and returned. This is intended to avoid probe effect. h = {} ObjectSpace.count_objects(h) puts h # => { :TOTAL=>10000, :T_CLASS=>158280, :T_MODULE=>20672, :T_STRING=>527249 } This method is only expected to work on C Ruby. @overload count_objects([result_hash]) @return [Hash];T;#0;$@+;.F;/o;0;1T;2iH;3ih;Bi;%@&;9@+;:@+;;To; ;IC;[o;4;5F;6;;;;&I"ObjectSpace::WeakMap#[]=;F;7[;[;F;;8;;;[;{;IC; " ;T;[;![;"@;#0;$@+;%@+;;To;4;5F;6;;;;&I"ObjectSpace::WeakMap#[];F;7[;[;F;;;;;[;{;IC; " ;T;[;![;"@;#0;$@+;%@+;;To;4;5F;6;;;;&I""ObjectSpace::WeakMap#include?;F;7[;[;F;: include?;;;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@,;![;"@;#0;$@,;Bi;%@+;;To;4;5F;6;;;;&I"!ObjectSpace::WeakMap#member?;F;7[;[;F;: member?;;;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@,;![;"@;#0;$@,;Bi;%@+;;To;4;5F;6;;;;&I"ObjectSpace::WeakMap#key?;F;7[;[;F;;:;;;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@,;![;"@;#0;$@,;Bi;%@+;;To;4;5F;6;;;;&I"!ObjectSpace::WeakMap#inspect;F;7[;[;F;;J;;;[;{;IC; " ;T;[;![;"@;#0;$@&,;%@+;;To;4;5F;6;;;;&I"ObjectSpace::WeakMap#each;F;7[;[;F;: each;;;[;{;IC; " ;T;[;![;"@;#0;$@/,;%@+;;To;4;5F;6;;;;&I"#ObjectSpace::WeakMap#each_pair;F;7[;[;F;:each_pair;;;[;{;IC; " ;T;[;![;"@;#0;$@8,;%@+;;To;4;5F;6;;;;&I""ObjectSpace::WeakMap#each_key;F;7[;[;F;: each_key;;;[;{;IC; " ;T;[;![;"@;#0;$@A,;%@+;;To;4;5F;6;;;;&I"$ObjectSpace::WeakMap#each_value;F;7[;[;F;:each_value;;;[;{;IC; " ;T;[;![;"@;#0;$@J,;%@+;;To;4;5F;6;;;;&I"ObjectSpace::WeakMap#keys;F;7[;[;F;;;;;;[;{;IC; " ;T;[;![;"@;#0;$@S,;%@+;;To;4;5F;6;;;;&I" ObjectSpace::WeakMap#values;F;7[;[;F;: values;;;[;{;IC; " ;T;[;![;"@;#0;$@\,;%@+;;To;4;5F;6;;;;&I"ObjectSpace::WeakMap#size;F;7[;[;F;;;;;[;{;IC; " ;T;[;![;"@;#0;$@e,;%@+;;To;4;5F;6;;;;&I" ObjectSpace::WeakMap#length;F;7[;[;F;;b;;;[;{;IC; " ;T;[;![;"@;#0;$@n,;%@+;;T; @+; IC;[; @+; IC;[o;;IC;[Ao;4;5F;6;;;;&I"Enumerable#chain;F;7[[@90;[[@i ;T;: chain;0;[;{;IC; "Returns an enumerator object generated from this enumerator and given enumerables. e = (1..3).chain([4, 5]) e.to_a #=> [1, 2, 3, 4, 5] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"chain(*enums);T;IC; ";T;[;![;"I";T;#0;$@{,;.F;Bi;C0;7[[I" *enums;T0;$@{,;![;"I"Returns an enumerator object generated from this enumerator and given enumerables. e = (1..3).chain([4, 5]) e.to_a #=> [1, 2, 3, 4, 5] @overload chain(*enums);T;#0;$@{,;.F;/o;0;1T;2i ;3i ;%@y,;9I"static VALUE enum_chain(int argc, VALUE *argv, VALUE obj) { VALUE enums = rb_ary_new_from_values(1, &obj); rb_ary_cat(enums, argv, argc); return new_enum_chain(enums); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#lazy;F;7[;[[@id;T;: lazy;0;[;{;IC; "Returns an Enumerator::Lazy, which redefines most Enumerable methods to postpone enumeration and enumerate values only on an as-needed basis. === Example The following program finds pythagorean triples: def pythagorean_triples (1..Float::INFINITY).lazy.flat_map {|z| (1..z).flat_map {|x| (x..z).select {|y| x**2 + y**2 == z**2 }.map {|y| [x, y, z] } } } end # show first ten pythagorean triples p pythagorean_triples.take(10).force # take is lazy, so force is needed p pythagorean_triples.first(10) # first is eager # show pythagorean triples less than 100 p pythagorean_triples.take_while { |*, z| z < 100 }.force ;T;[o;= ;>I" overload;F;?0;;;@0;:I" lazy;T;IC; ";T;[;![;"I";T;#0;$@,;.F;Bi;C0;7[;$@,;![;"I"Returns an Enumerator::Lazy, which redefines most Enumerable methods to postpone enumeration and enumerate values only on an as-needed basis. === Example The following program finds pythagorean triples: def pythagorean_triples (1..Float::INFINITY).lazy.flat_map {|z| (1..z).flat_map {|x| (x..z).select {|y| x**2 + y**2 == z**2 }.map {|y| [x, y, z] } } } end # show first ten pythagorean triples p pythagorean_triples.take(10).force # take is lazy, so force is needed p pythagorean_triples.first(10) # first is eager # show pythagorean triples less than 100 p pythagorean_triples.take_while { |*, z| z < 100 }.force @overload lazy;T;#0;$@,;.F;/o;0;1T;2iG;3ia;%@y,;9I"static VALUE enumerable_lazy(VALUE obj) { VALUE result = lazy_to_enum_i(obj, sym_each, 0, 0, lazyenum_size, rb_keyword_given_p()); /* Qfalse indicates that the Enumerator::Lazy has no method name */ rb_ivar_set(result, id_method, Qfalse); return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#to_a;F;7[[@90;[[I" enum.c;Ti;T;: to_a;0;[;{;IC; "Returns an array containing the items in +self+: (0..4).to_a # => [0, 1, 2, 3, 4] Enumerable#entries is an alias for Enumerable#to_a. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_a;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@,;![;"I"@return [Array];T;#0;$@,;.F;Bi;C0;7[;$@,;![;"I"Returns an array containing the items in +self+: (0..4).to_a # => [0, 1, 2, 3, 4] Enumerable#entries is an alias for Enumerable#to_a. @overload to_a @return [Array];T;#0;$@,;.F;/o;0;1T;2i;3i;%@y,;9I"static VALUE enum_to_a(int argc, VALUE *argv, VALUE obj) { VALUE ary = rb_ary_new(); rb_block_call_kw(obj, id_each, argc, argv, collect_all, ary, RB_PASS_CALLED_KEYWORDS); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#entries;F;7[[@90;[[@,i;T;: entries;0;[;{;IC; "Returns an array containing the items in +self+: (0..4).to_a # => [0, 1, 2, 3, 4] Enumerable#entries is an alias for Enumerable#to_a. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_a;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@,;![;"I"@return [Array];T;#0;$@,;.F;Bi;C0;7[;$@,;![;"@,;#0;$@,;.F;/o;0;1T;2i;3i;%@y,;9I"static VALUE enum_to_a(int argc, VALUE *argv, VALUE obj) { VALUE ary = rb_ary_new(); rb_block_call_kw(obj, id_each, argc, argv, collect_all, ary, RB_PASS_CALLED_KEYWORDS); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#to_h;F;7[[@90;[[@,i;T;: to_h;0;[;{;IC; "When +self+ consists of 2-element arrays, returns a hash each of whose entries is the key-value pair formed from one of those arrays: [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} When a block is given, the block is called with each element of +self+; the block should return a 2-element array which becomes a key-value pair in the returned hash: (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} Raises an exception if an element of +self+ is not a 2-element array, and a block is not passed. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_h;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@,;![;"I"@return [Hash];T;#0;$@,;.F;Bi;C0;7[;$@,o;= ;>I" overload;F;?0;;;@0;:I" to_h;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@,o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@,;![;"I"$@yield [element] @return [Hash];T;#0;$@,;.F;Bi;C0;7[;$@,;![;"I"nWhen +self+ consists of 2-element arrays, returns a hash each of whose entries is the key-value pair formed from one of those arrays: [[:foo, 0], [:bar, 1], [:baz, 2]].to_h # => {:foo=>0, :bar=>1, :baz=>2} When a block is given, the block is called with each element of +self+; the block should return a 2-element array which becomes a key-value pair in the returned hash: (0..3).to_h {|i| [i, i ** 2]} # => {0=>0, 1=>1, 2=>4, 3=>9} Raises an exception if an element of +self+ is not a 2-element array, and a block is not passed. @overload to_h @return [Hash] @overload to_h @yield [element] @return [Hash];T;#0;$@,;.F;/o;0;1T;2i;3i;%@y,;9I"static VALUE enum_to_h(int argc, VALUE *argv, VALUE obj) { rb_block_call_func *iter = rb_block_given_p() ? enum_to_h_ii : enum_to_h_i; return enum_hashify(obj, argc, argv, iter); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#sort;F;7[;[[@,i,;T;: sort;0;[;{;IC; "Returns an array containing the sorted elements of +self+. The ordering of equal elements is indeterminate and may be unstable. With no block given, the sort compares using the elements' own method <=>: %w[b c a d].sort # => ["a", "b", "c", "d"] {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] With a block given, comparisons in the block determine the ordering. The block is called with two elements +a+ and +b+, and must return: - A negative integer if a < b. - Zero if a == b. - A positive integer if a > b. Examples: a = %w[b c a d] a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] h = {foo: 0, bar: 1, baz: 2} h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] See also #sort_by. It implements a Schwartzian transform which is useful when key computation or comparison is expensive. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" sort;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@-;![;"I"@return [Array];T;#0;$@-;.F;Bi;C0;7[;$@-o;= ;>I" overload;F;?0;;;@0;:I" sort;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"a;TI"b;T;$@-o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@-;![;"I""@yield [a, b] @return [Array];T;#0;$@-;.F;Bi;C0;7[;$@-;![;"I"Returns an array containing the sorted elements of +self+. The ordering of equal elements is indeterminate and may be unstable. With no block given, the sort compares using the elements' own method <=>: %w[b c a d].sort # => ["a", "b", "c", "d"] {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]] With a block given, comparisons in the block determine the ordering. The block is called with two elements +a+ and +b+, and must return: - A negative integer if a < b. - Zero if a == b. - A positive integer if a > b. Examples: a = %w[b c a d] a.sort {|a, b| b <=> a } # => ["d", "c", "b", "a"] h = {foo: 0, bar: 1, baz: 2} h.sort {|a, b| b <=> a } # => [[:foo, 0], [:baz, 2], [:bar, 1]] See also #sort_by. It implements a Schwartzian transform which is useful when key computation or comparison is expensive. @overload sort @return [Array] @overload sort @yield [a, b] @return [Array];T;#0;$@-;.F;/o;0;1T;2i ;3i+;%@y,;9I"]static VALUE enum_sort(VALUE obj) { return rb_ary_sort_bang(enum_to_a(0, 0, obj)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#sort_by;F;7[;[[@,i;T;: sort_by;0;[;{;IC; "( With a block given, returns an array of elements of +self+, sorted according to the value returned by the block for each element. The ordering of equal elements is indeterminate and may be unstable. Examples: a = %w[xx xxx x xxxx] a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] h = {foo: 2, bar: 1, baz: 0} h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] With no block given, returns an Enumerator. The current implementation of #sort_by generates an array of tuples containing the original collection element and the mapped value. This makes #sort_by fairly expensive when the keysets are simple. require 'benchmark' a = (1..100000).map { rand(100000) } Benchmark.bm(10) do |b| b.report("Sort") { a.sort } b.report("Sort by") { a.sort_by { |a| a } } end produces: user system total real Sort 0.180000 0.000000 0.180000 ( 0.175469) Sort by 1.980000 0.040000 2.020000 ( 2.013586) However, consider the case where comparing the keys is a non-trivial operation. The following code sorts some files on modification time using the basic #sort method. files = Dir["*"] sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } sorted #=> ["mon", "tues", "wed", "thurs"] This sort is inefficient: it generates two new File objects during every comparison. A slightly better technique is to use the Kernel#test method to generate the modification times directly. files = Dir["*"] sorted = files.sort { |a, b| test(?M, a) <=> test(?M, b) } sorted #=> ["mon", "tues", "wed", "thurs"] This still generates many unnecessary Time objects. A more efficient technique is to cache the sort keys (modification times in this case) before the sort. Perl users often call this approach a Schwartzian transform, after Randal Schwartz. We construct a temporary array, where each element is an array containing our sort key along with the filename. We sort this array, and then extract the filename from the result. sorted = Dir["*"].collect { |f| [test(?M, f), f] }.sort.collect { |f| f[1] } sorted #=> ["mon", "tues", "wed", "thurs"] This is exactly what #sort_by does internally. sorted = Dir["*"].sort_by { |f| test(?M, f) } sorted #=> ["mon", "tues", "wed", "thurs"] To produce the reverse of a specific order, the following can be used: ary.sort_by { ... }.reverse! ;T;[o;= ;>I" overload;F;?0;;;@0;:I" sort_by;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@>-o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@>-;![;"I"%@yield [element] @return [Array];T;#0;$@>-;.F;Bi;C0;7[;$@>-o;= ;>I" overload;F;?0;;;@0;:I" sort_by;T;IC; ";T;[;![;"I";T;#0;$@>-;.F;Bi;C0;7[;$@>-;![;"I"s With a block given, returns an array of elements of +self+, sorted according to the value returned by the block for each element. The ordering of equal elements is indeterminate and may be unstable. Examples: a = %w[xx xxx x xxxx] a.sort_by {|s| s.size } # => ["x", "xx", "xxx", "xxxx"] a.sort_by {|s| -s.size } # => ["xxxx", "xxx", "xx", "x"] h = {foo: 2, bar: 1, baz: 0} h.sort_by{|key, value| value } # => [[:baz, 0], [:bar, 1], [:foo, 2]] h.sort_by{|key, value| key } # => [[:bar, 1], [:baz, 0], [:foo, 2]] With no block given, returns an Enumerator. The current implementation of #sort_by generates an array of tuples containing the original collection element and the mapped value. This makes #sort_by fairly expensive when the keysets are simple. require 'benchmark' a = (1..100000).map { rand(100000) } Benchmark.bm(10) do |b| b.report("Sort") { a.sort } b.report("Sort by") { a.sort_by { |a| a } } end produces: user system total real Sort 0.180000 0.000000 0.180000 ( 0.175469) Sort by 1.980000 0.040000 2.020000 ( 2.013586) However, consider the case where comparing the keys is a non-trivial operation. The following code sorts some files on modification time using the basic #sort method. files = Dir["*"] sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime } sorted #=> ["mon", "tues", "wed", "thurs"] This sort is inefficient: it generates two new File objects during every comparison. A slightly better technique is to use the Kernel#test method to generate the modification times directly. files = Dir["*"] sorted = files.sort { |a, b| test(?M, a) <=> test(?M, b) } sorted #=> ["mon", "tues", "wed", "thurs"] This still generates many unnecessary Time objects. A more efficient technique is to cache the sort keys (modification times in this case) before the sort. Perl users often call this approach a Schwartzian transform, after Randal Schwartz. We construct a temporary array, where each element is an array containing our sort key along with the filename. We sort this array, and then extract the filename from the result. sorted = Dir["*"].collect { |f| [test(?M, f), f] }.sort.collect { |f| f[1] } sorted #=> ["mon", "tues", "wed", "thurs"] This is exactly what #sort_by does internally. sorted = Dir["*"].sort_by { |f| test(?M, f) } sorted #=> ["mon", "tues", "wed", "thurs"] To produce the reverse of a specific order, the following can be used: ary.sort_by { ... }.reverse! @overload sort_by @yield [element] @return [Array] @overload sort_by;T;#0;$@>-;.F;/o;0;1T;2ig;3i;%@y,;9I"static VALUE enum_sort_by(VALUE obj) { VALUE ary, buf; struct MEMO *memo; long i; struct sort_by_data *data; RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size); if (RB_TYPE_P(obj, T_ARRAY) && RARRAY_LEN(obj) <= LONG_MAX/2) { ary = rb_ary_new2(RARRAY_LEN(obj)*2); } else { ary = rb_ary_new(); } RBASIC_CLEAR_CLASS(ary); buf = rb_ary_tmp_new(SORT_BY_BUFSIZE*2); rb_ary_store(buf, SORT_BY_BUFSIZE*2-1, Qnil); memo = MEMO_NEW(0, 0, 0); data = (struct sort_by_data *)&memo->v1; RB_OBJ_WRITE(memo, &data->ary, ary); RB_OBJ_WRITE(memo, &data->buf, buf); data->n = 0; rb_block_call(obj, id_each, 0, 0, sort_by_i, (VALUE)memo); ary = data->ary; buf = data->buf; if (data->n) { rb_ary_resize(buf, data->n*2); rb_ary_concat(ary, buf); } if (RARRAY_LEN(ary) > 2) { RARRAY_PTR_USE(ary, ptr, ruby_qsort(ptr, RARRAY_LEN(ary)/2, 2*sizeof(VALUE), sort_by_cmp, (void *)ary)); } if (RBASIC(ary)->klass) { rb_raise(rb_eRuntimeError, "sort_by reentered"); } for (i=1; ipattern === element is +true+: a = ['foo', 'bar', 'car', 'moo'] a.grep(/ar/) # => ["bar", "car"] (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] ['a', 'b', 0, 1].grep(Integer) # => [0, 1] With a block given, calls the block with each matching element and returns an array containing each object returned by the block: a = ['foo', 'bar', 'car', 'moo'] a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] Related: #grep_v. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"grep(pattern);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@f-;![;"I"@return [Array];T;#0;$@f-;.F;Bi;C0;7[[I" pattern;T0;$@f-o;= ;>I" overload;F;?0;;;@0;:I"grep(pattern);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@f-o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@f-;![;"I"%@yield [element] @return [Array];T;#0;$@f-;.F;Bi;C0;7[[I" pattern;T0;$@f-;![;"I"Returns an array of objects based elements of +self+ that match the given pattern. With no block given, returns an array containing each element for which pattern === element is +true+: a = ['foo', 'bar', 'car', 'moo'] a.grep(/ar/) # => ["bar", "car"] (1..10).grep(3..8) # => [3, 4, 5, 6, 7, 8] ['a', 'b', 0, 1].grep(Integer) # => [0, 1] With a block given, calls the block with each matching element and returns an array containing each object returned by the block: a = ['foo', 'bar', 'car', 'moo'] a.grep(/ar/) {|element| element.upcase } # => ["BAR", "CAR"] Related: #grep_v. @overload grep(pattern) @return [Array] @overload grep(pattern) @yield [element] @return [Array];T;#0;$@f-;.F;/o;0;1T;2i;3i;%@y,;9I"]static VALUE enum_grep(VALUE obj, VALUE pat) { return enum_grep0(obj, pat, Qtrue); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#grep_v;F;7[[I"pat;T0;[[@,i;T;: grep_v;0;[;{;IC; "Returns an array of objects based on elements of +self+ that don't match the given pattern. With no block given, returns an array containing each element for which pattern === element is +false+: a = ['foo', 'bar', 'car', 'moo'] a.grep_v(/ar/) # => ["foo", "moo"] (1..10).grep_v(3..8) # => [1, 2, 9, 10] ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] With a block given, calls the block with each non-matching element and returns an array containing each object returned by the block: a = ['foo', 'bar', 'car', 'moo'] a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] Related: #grep. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"grep_v(pattern);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@-;![;"I"@return [Array];T;#0;$@-;.F;Bi;C0;7[[I" pattern;T0;$@-o;= ;>I" overload;F;?0;;;@0;:I"grep_v(pattern);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@-o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@-;![;"I"%@yield [element] @return [Array];T;#0;$@-;.F;Bi;C0;7[[I" pattern;T0;$@-;![;"I"Returns an array of objects based on elements of +self+ that don't match the given pattern. With no block given, returns an array containing each element for which pattern === element is +false+: a = ['foo', 'bar', 'car', 'moo'] a.grep_v(/ar/) # => ["foo", "moo"] (1..10).grep_v(3..8) # => [1, 2, 9, 10] ['a', 'b', 0, 1].grep_v(Integer) # => ["a", "b"] With a block given, calls the block with each non-matching element and returns an array containing each object returned by the block: a = ['foo', 'bar', 'car', 'moo'] a.grep_v(/ar/) {|element| element.upcase } # => ["FOO", "MOO"] Related: #grep. @overload grep_v(pattern) @return [Array] @overload grep_v(pattern) @yield [element] @return [Array];T;#0;$@-;.F;/o;0;1T;2i;3i;%@y,;9I"`static VALUE enum_grep_v(VALUE obj, VALUE pat) { return enum_grep0(obj, pat, Qfalse); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#count;F;7[[@90;[[@,i);T;: count;0;[;{;IC; "{Returns the count of elements, based on an argument or block criterion, if given. With no argument and no block given, returns the number of elements: [0, 1, 2].count # => 3 {foo: 0, bar: 1, baz: 2}.count # => 3 With argument +object+ given, returns the number of elements that are == to +object+: [0, 1, 2, 1].count(1) # => 2 With a block given, calls the block with each element and returns the number of elements for which the block returns a truthy value: [0, 1, 2, 3].count {|element| element < 2} # => 2 {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" count;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@-;![;"I"@return [Integer];T;#0;$@-;.F;Bi;C0;7[;$@-o;= ;>I" overload;F;?0;;;@0;:I"count(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@-;![;"I"@return [Integer];T;#0;$@-;.F;Bi;C0;7[[I" object;T0;$@-o;= ;>I" overload;F;?0;;;@0;:I" count;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@-o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@-;![;"I"'@yield [element] @return [Integer];T;#0;$@-;.F;Bi;C0;7[;$@-;![;"I"Returns the count of elements, based on an argument or block criterion, if given. With no argument and no block given, returns the number of elements: [0, 1, 2].count # => 3 {foo: 0, bar: 1, baz: 2}.count # => 3 With argument +object+ given, returns the number of elements that are == to +object+: [0, 1, 2, 1].count(1) # => 2 With a block given, calls the block with each element and returns the number of elements for which the block returns a truthy value: [0, 1, 2, 3].count {|element| element < 2} # => 2 {foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2 @overload count @return [Integer] @overload count(object) @return [Integer] @overload count @yield [element] @return [Integer];T;#0;$@-;.F;/o;0;1T;2i;3i);%@y,;9I"static VALUE enum_count(int argc, VALUE *argv, VALUE obj) { VALUE item = Qnil; struct MEMO *memo; rb_block_call_func *func; if (argc == 0) { if (rb_block_given_p()) { func = count_iter_i; } else { func = count_all_i; } } else { rb_scan_args(argc, argv, "1", &item); if (rb_block_given_p()) { rb_warn("given block not used"); } func = count_i; } memo = MEMO_NEW(item, 0, 0); rb_block_call(obj, id_each, 0, 0, func, (VALUE)memo); return imemo_count_value(memo); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#find;F;7[[@90;[[@,ih;T;: find;0;[;{;IC; "Returns the first element for which the block returns a truthy value. With a block given, calls the block with successive elements of the collection; returns the first element for which the block returns a truthy value: (0..9).find {|element| element > 2} # => 3 If no such element is found, calls +if_none_proc+ and returns its return value. (0..9).find(proc {false}) {|element| element > 12} # => false {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] With no block given, returns an \Enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"find(if_none_proc = nil);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@ .o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@ .;![;"I"+@yield [element] @return [Object, nil];T;#0;$@ .;.F;Bi;C0;7[[I"if_none_proc;TI"nil;T;$@ .o;= ;>I" overload;F;?0;;;@0;:I"find(if_none_proc = nil);T;IC; ";T;[;![;"I";T;#0;$@ .;.F;Bi;C0;7[[I"if_none_proc;TI"nil;T;$@ .;![;"I"Returns the first element for which the block returns a truthy value. With a block given, calls the block with successive elements of the collection; returns the first element for which the block returns a truthy value: (0..9).find {|element| element > 2} # => 3 If no such element is found, calls +if_none_proc+ and returns its return value. (0..9).find(proc {false}) {|element| element > 12} # => false {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] With no block given, returns an \Enumerator. @overload find(if_none_proc = nil) @yield [element] @return [Object, nil] @overload find(if_none_proc = nil);T;#0;$@ .;.F;/o;0;1T;2iS;3ig;%@y,;9I"static VALUE enum_find(int argc, VALUE *argv, VALUE obj) { struct MEMO *memo; VALUE if_none; if_none = rb_check_arity(argc, 0, 1) ? argv[0] : Qnil; RETURN_ENUMERATOR(obj, argc, argv); memo = MEMO_NEW(Qundef, 0, 0); rb_block_call(obj, id_each, 0, 0, find_i, (VALUE)memo); if (memo->u3.cnt) { return memo->v1; } if (!NIL_P(if_none)) { return rb_funcallv(if_none, id_call, 0, 0); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#detect;F;7[[@90;[[@,ih;T;: detect;0;[;{;IC; "Returns the first element for which the block returns a truthy value. With a block given, calls the block with successive elements of the collection; returns the first element for which the block returns a truthy value: (0..9).find {|element| element > 2} # => 3 If no such element is found, calls +if_none_proc+ and returns its return value. (0..9).find(proc {false}) {|element| element > 12} # => false {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] With no block given, returns an \Enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"find(if_none_proc = nil);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@9.o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@9.;![;"I"+@yield [element] @return [Object, nil];T;#0;$@9.;.F;Bi;C0;7[[I"if_none_proc;TI"nil;T;$@9.o;= ;>I" overload;F;?0;;;@0;:I"find(if_none_proc = nil);T;IC; ";T;[;![;"I";T;#0;$@9.;.F;Bi;C0;7[[I"if_none_proc;TI"nil;T;$@9.;![;"@5.;#0;$@9.;.F;/o;0;1T;2iS;3ig;%@y,;9I"static VALUE enum_find(int argc, VALUE *argv, VALUE obj) { struct MEMO *memo; VALUE if_none; if_none = rb_check_arity(argc, 0, 1) ? argv[0] : Qnil; RETURN_ENUMERATOR(obj, argc, argv); memo = MEMO_NEW(Qundef, 0, 0); rb_block_call(obj, id_each, 0, 0, find_i, (VALUE)memo); if (memo->u3.cnt) { return memo->v1; } if (!NIL_P(if_none)) { return rb_funcallv(if_none, id_call, 0, 0); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#find_index;F;7[[@90;[[@,i;T;:find_index;0;[;{;IC; "cReturns the index of the first element that meets a specified criterion, or +nil+ if no such element is found. With argument +object+ given, returns the index of the first element that is == +object+: ['a', 'b', 'c', 'b'].find_index('b') # => 1 With a block given, calls the block with successive elements; returns the first element for which the block returns a truthy value: ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 With no argument and no block given, returns an \Enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"find_index(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@h.;![;"I"@return [Integer, nil];T;#0;$@h.;.F;Bi;C0;7[[I" object;T0;$@h.o;= ;>I" overload;F;?0;;;@0;:I"find_index;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@h.o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@h.;![;"I",@yield [element] @return [Integer, nil];T;#0;$@h.;.F;Bi;C0;7[;$@h.o;= ;>I" overload;F;?0;;;@0;:I"find_index;T;IC; ";T;[;![;"I";T;#0;$@h.;.F;Bi;C0;7[;$@h.;![;"I"Returns the index of the first element that meets a specified criterion, or +nil+ if no such element is found. With argument +object+ given, returns the index of the first element that is == +object+: ['a', 'b', 'c', 'b'].find_index('b') # => 1 With a block given, calls the block with successive elements; returns the first element for which the block returns a truthy value: ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1 {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2 With no argument and no block given, returns an \Enumerator. @overload find_index(object) @return [Integer, nil] @overload find_index @yield [element] @return [Integer, nil] @overload find_index;T;#0;$@h.;.F;/o;0;1T;2i;3i;%@y,;9I"Fstatic VALUE enum_find_index(int argc, VALUE *argv, VALUE obj) { struct MEMO *memo; /* [return value, current index, ] */ VALUE condition_value = Qnil; rb_block_call_func *func; if (argc == 0) { RETURN_ENUMERATOR(obj, 0, 0); func = find_index_iter_i; } else { rb_scan_args(argc, argv, "1", &condition_value); if (rb_block_given_p()) { rb_warn("given block not used"); } func = find_index_i; } memo = MEMO_NEW(Qnil, condition_value, 0); rb_block_call(obj, id_each, 0, 0, func, (VALUE)memo); return memo->v1; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#find_all;F;7[;[[@,i;T;: find_all;0;[;{;IC; "Returns an array containing elements selected by the block. With a block given, calls the block with successive elements; returns an array of those elements for which the block returns a truthy value: (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } a # => {:bar=>1, :baz=>2} With no block given, returns an \Enumerator. Related: #reject. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@.o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@.;![;"I"%@yield [element] @return [Array];T;#0;$@.;.F;Bi;C0;7[;$@.o;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[;![;"I";T;#0;$@.;.F;Bi;C0;7[;$@.;![;"I"Returns an array containing elements selected by the block. With a block given, calls the block with successive elements; returns an array of those elements for which the block returns a truthy value: (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } a # => {:bar=>1, :baz=>2} With no block given, returns an \Enumerator. Related: #reject. @overload select @yield [element] @return [Array] @overload select;T;#0;$@.;.F;/o;0;1T;2i;3i;%@y,;9I"static VALUE enum_find_all(VALUE obj) { VALUE ary; RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size); ary = rb_ary_new(); rb_block_call(obj, id_each, 0, 0, find_all_i, ary); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#select;F;7[;[[@,i;T;;;0;[;{;IC; "Returns an array containing elements selected by the block. With a block given, calls the block with successive elements; returns an array of those elements for which the block returns a truthy value: (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } a # => {:bar=>1, :baz=>2} With no block given, returns an \Enumerator. Related: #reject. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@.o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@.;![;"I"%@yield [element] @return [Array];T;#0;$@.;.F;Bi;C0;7[;$@.o;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[;![;"I";T;#0;$@.;.F;Bi;C0;7[;$@.;![;"@.;#0;$@.;.F;/o;0;1T;2i;3i;%@y,;9I"static VALUE enum_find_all(VALUE obj) { VALUE ary; RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size); ary = rb_ary_new(); rb_block_call(obj, id_each, 0, 0, find_all_i, ary); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#filter;F;7[;[[@,i;T;: filter;0;[;{;IC; "Returns an array containing elements selected by the block. With a block given, calls the block with successive elements; returns an array of those elements for which the block returns a truthy value: (0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } a # => {:bar=>1, :baz=>2} With no block given, returns an \Enumerator. Related: #reject. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@.o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@.;![;"I"%@yield [element] @return [Array];T;#0;$@.;.F;Bi;C0;7[;$@.o;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[;![;"I";T;#0;$@.;.F;Bi;C0;7[;$@.;![;"@.;#0;$@.;.F;/o;0;1T;2i;3i;%@y,;9I"static VALUE enum_find_all(VALUE obj) { VALUE ary; RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size); ary = rb_ary_new(); rb_block_call(obj, id_each, 0, 0, find_all_i, ary); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#filter_map;F;7[;[[@,i%;T;:filter_map;0;[;{;IC; "Returns an array containing truthy elements returned by the block. With a block given, calls the block with successive elements; returns an array containing each truthy value returned by the block: (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] When no block given, returns an \Enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"filter_map;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@/o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@/;![;"I"%@yield [element] @return [Array];T;#0;$@/;.F;Bi;C0;7[;$@/o;= ;>I" overload;F;?0;;;@0;:I"filter_map;T;IC; ";T;[;![;"I";T;#0;$@/;.F;Bi;C0;7[;$@/;![;"I"Returns an array containing truthy elements returned by the block. With a block given, calls the block with successive elements; returns an array containing each truthy value returned by the block: (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz] When no block given, returns an \Enumerator. @overload filter_map @yield [element] @return [Array] @overload filter_map;T;#0;$@/;.F;/o;0;1T;2i;3i$;%@y,;9I"static VALUE enum_filter_map(VALUE obj) { VALUE ary; RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size); ary = rb_ary_new(); rb_block_call(obj, id_each, 0, 0, filter_map_i, ary); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#reject;F;7[;[[@,iP;T;: reject;0;[;{;IC; "Returns an array of objects rejected by the block. With a block given, calls the block with successive elements; returns an array of those elements for which the block returns +nil+ or +false+: (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} When no block given, returns an \Enumerator. Related: #select. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" reject;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@@/o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@@/;![;"I"%@yield [element] @return [Array];T;#0;$@@/;.F;Bi;C0;7[;$@@/o;= ;>I" overload;F;?0;;;@0;:I" reject;T;IC; ";T;[;![;"I";T;#0;$@@/;.F;Bi;C0;7[;$@@/;![;"I"Returns an array of objects rejected by the block. With a block given, calls the block with successive elements; returns an array of those elements for which the block returns +nil+ or +false+: (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9] {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2} When no block given, returns an \Enumerator. Related: #select. @overload reject @yield [element] @return [Array] @overload reject;T;#0;$@@/;.F;/o;0;1T;2i>;3iN;%@y,;9I"static VALUE enum_reject(VALUE obj) { VALUE ary; RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size); ary = rb_ary_new(); rb_block_call(obj, id_each, 0, 0, reject_i, ary); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#collect;F;7[;[[@,i};T;: collect;0;[;{;IC; "hReturns an array of objects returned by the block. With a block given, calls the block with successive elements; returns an array of the objects returned by the block: (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] With no block given, returns an \Enumerator. ;T;[o;= ;>I" overload;F;?0;:map;@0;:I"map;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@h/o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@h/;![;"I"%@yield [element] @return [Array];T;#0;$@h/;.F;Bi;C0;7[;$@h/o;= ;>I" overload;F;?0;;;@0;:I"map;T;IC; ";T;[;![;"I";T;#0;$@h/;.F;Bi;C0;7[;$@h/;![;"I"Returns an array of objects returned by the block. With a block given, calls the block with successive elements; returns an array of the objects returned by the block: (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] With no block given, returns an \Enumerator. @overload map @yield [element] @return [Array] @overload map;T;#0;$@h/;.F;/o;0;1T;2im;3i|;%@y,;9I"/static VALUE enum_collect(VALUE obj) { VALUE ary; int min_argc, max_argc; RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size); ary = rb_ary_new(); min_argc = rb_block_min_max_arity(&max_argc); rb_lambda_call(obj, id_each, 0, 0, collect_i, min_argc, max_argc, ary); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#map;F;7[;[[@,i};T;;;0;[;{;IC; "hReturns an array of objects returned by the block. With a block given, calls the block with successive elements; returns an array of the objects returned by the block: (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16] {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4] With no block given, returns an \Enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"map;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@/o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@/;![;"I"%@yield [element] @return [Array];T;#0;$@/;.F;Bi;C0;7[;$@/o;= ;>I" overload;F;?0;;;@0;:I"map;T;IC; ";T;[;![;"I";T;#0;$@/;.F;Bi;C0;7[;$@/;![;"@/;#0;$@/;.F;/o;0;1T;2im;3i|;%@y,;9I"/static VALUE enum_collect(VALUE obj) { VALUE ary; int min_argc, max_argc; RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size); ary = rb_ary_new(); min_argc = rb_block_min_max_arity(&max_argc); rb_lambda_call(obj, id_each, 0, 0, collect_i, min_argc, max_argc, ary); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#flat_map;F;7[;[[@,i;T;: flat_map;0;[;{;IC; "vReturns an array of flattened objects returned by the block. With a block given, calls the block with successive elements; returns a flattened array of objects returned by the block: [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] With no block given, returns an \Enumerator. Alias: #collect_concat. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" flat_map;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@/o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@/;![;"I"%@yield [element] @return [Array];T;#0;$@/;.F;Bi;C0;7[;$@/o;= ;>I" overload;F;?0;;;@0;:I" flat_map;T;IC; ";T;[;![;"I";T;#0;$@/;.F;Bi;C0;7[;$@/;![;"I"Returns an array of flattened objects returned by the block. With a block given, calls the block with successive elements; returns a flattened array of objects returned by the block: [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] With no block given, returns an \Enumerator. Alias: #collect_concat. @overload flat_map @yield [element] @return [Array] @overload flat_map;T;#0;$@/;.F;/o;0;1T;2i;3i;%@y,;9I"static VALUE enum_flat_map(VALUE obj) { VALUE ary; RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size); ary = rb_ary_new(); rb_block_call(obj, id_each, 0, 0, flat_map_i, ary); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#collect_concat;F;7[;[[@,i;T;:collect_concat;0;[;{;IC; "vReturns an array of flattened objects returned by the block. With a block given, calls the block with successive elements; returns a flattened array of objects returned by the block: [0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2] With no block given, returns an \Enumerator. Alias: #collect_concat. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" flat_map;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@/o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@/;![;"I"%@yield [element] @return [Array];T;#0;$@/;.F;Bi;C0;7[;$@/o;= ;>I" overload;F;?0;;;@0;:I" flat_map;T;IC; ";T;[;![;"I";T;#0;$@/;.F;Bi;C0;7[;$@/;![;"@/;#0;$@/;.F;/o;0;1T;2i;3i;%@y,;9I"static VALUE enum_flat_map(VALUE obj) { VALUE ary; RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size); ary = rb_ary_new(); rb_block_call(obj, id_each, 0, 0, flat_map_i, ary); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#inject;F;7[[@90;[[@,i;T;: inject;0;[;{;IC; "Returns an object formed from operands via either: - A method named by +symbol+. - A block to which each operand is passed. With method-name argument +symbol+, combines operands using the method: # Sum, without initial_operand. (1..4).inject(:+) # => 10 # Sum, with initial_operand. (1..4).inject(10, :+) # => 20 With a block, passes each operand to the block: # Sum of squares, without initial_operand. (1..4).inject {|sum, n| sum + n*n } # => 30 # Sum of squares, with initial_operand. (1..4).inject(2) {|sum, n| sum + n*n } # => 32 Operands If argument +initial_operand+ is not given, the operands for +inject+ are simply the elements of +self+. Example calls and their operands: - (1..4).inject(:+):: [1, 2, 3, 4]. - (1...4).inject(:+):: [1, 2, 3]. - ('a'..'d').inject(:+):: ['a', 'b', 'c', 'd']. - ('a'...'d').inject(:+):: ['a', 'b', 'c']. Examples with first operand (which is self.first) of various types: # Integer. (1..4).inject(:+) # => 10 # Float. [1.0, 2, 3, 4].inject(:+) # => 10.0 # Character. ('a'..'d').inject(:+) # => "abcd" # Complex. [Complex(1, 2), 3, 4].inject(:+) # => (8+2i) If argument +initial_operand+ is given, the operands for +inject+ are that value plus the elements of +self+. Example calls their operands: - (1..4).inject(10, :+):: [10, 1, 2, 3, 4]. - (1...4).inject(10, :+):: [10, 1, 2, 3]. - ('a'..'d').inject('e', :+):: ['e', 'a', 'b', 'c', 'd']. - ('a'...'d').inject('e', :+):: ['e', 'a', 'b', 'c']. Examples with +initial_operand+ of various types: # Integer. (1..4).inject(2, :+) # => 12 # Float. (1..4).inject(2.0, :+) # => 12.0 # String. ('a'..'d').inject('foo', :+) # => "fooabcd" # Array. %w[a b c].inject(['x'], :push) # => ["x", "a", "b", "c"] # Complex. (1..4).inject(Complex(2, 2), :+) # => (12+2i) Combination by Given \Method If the method-name argument +symbol+ is given, the operands are combined by that method: - The first and second operands are combined. - That result is combined with the third operand. - That result is combined with the fourth operand. - And so on. The return value from +inject+ is the result of the last combination. This call to +inject+ computes the sum of the operands: (1..4).inject(:+) # => 10 Examples with various methods: # Integer addition. (1..4).inject(:+) # => 10 # Integer multiplication. (1..4).inject(:*) # => 24 # Character range concatenation. ('a'..'d').inject('', :+) # => "abcd" # String array concatenation. %w[foo bar baz].inject('', :+) # => "foobarbaz" # Hash update. h = [{foo: 0, bar: 1}, {baz: 2}, {bat: 3}].inject(:update) h # => {:foo=>0, :bar=>1, :baz=>2, :bat=>3} # Hash conversion to nested arrays. h = {foo: 0, bar: 1}.inject([], :push) h # => [[:foo, 0], [:bar, 1]] Combination by Given Block If a block is given, the operands are passed to the block: - The first call passes the first and second operands. - The second call passes the result of the first call, along with the third operand. - The third call passes the result of the second call, along with the fourth operand. - And so on. The return value from +inject+ is the return value from the last block call. This call to +inject+ gives a block that writes the memo and element, and also sums the elements: (1..4).inject do |memo, element| p "Memo: #{memo}; element: #{element}" memo + element end # => 10 Output: "Memo: 1; element: 2" "Memo: 3; element: 3" "Memo: 6; element: 4" Enumerable#reduce is an alias for Enumerable#inject. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"inject(symbol);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@0;![;"I"@return [Object];T;#0;$@0;.F;Bi;C0;7[[I" symbol;T0;$@0o;= ;>I" overload;F;?0;;;@0;:I"$inject(initial_operand, symbol);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@0;![;"I"@return [Object];T;#0;$@0;.F;Bi;C0;7[[I"initial_operand;T0[I" symbol;T0;$@0o;= ;>I" overload;F;?0;;;@0;:I" inject;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" memo;TI" operand;T;$@0o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@0;![;"I",@yield [memo, operand] @return [Object];T;#0;$@0;.F;Bi;C0;7[;$@0o;= ;>I" overload;F;?0;;;@0;:I"inject(initial_operand);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" memo;TI" operand;T;$@0o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@0;![;"I",@yield [memo, operand] @return [Object];T;#0;$@0;.F;Bi;C0;7[[I"initial_operand;T0;$@0;![;"I"Returns an object formed from operands via either: - A method named by +symbol+. - A block to which each operand is passed. With method-name argument +symbol+, combines operands using the method: # Sum, without initial_operand. (1..4).inject(:+) # => 10 # Sum, with initial_operand. (1..4).inject(10, :+) # => 20 With a block, passes each operand to the block: # Sum of squares, without initial_operand. (1..4).inject {|sum, n| sum + n*n } # => 30 # Sum of squares, with initial_operand. (1..4).inject(2) {|sum, n| sum + n*n } # => 32 Operands If argument +initial_operand+ is not given, the operands for +inject+ are simply the elements of +self+. Example calls and their operands: - (1..4).inject(:+):: [1, 2, 3, 4]. - (1...4).inject(:+):: [1, 2, 3]. - ('a'..'d').inject(:+):: ['a', 'b', 'c', 'd']. - ('a'...'d').inject(:+):: ['a', 'b', 'c']. Examples with first operand (which is self.first) of various types: # Integer. (1..4).inject(:+) # => 10 # Float. [1.0, 2, 3, 4].inject(:+) # => 10.0 # Character. ('a'..'d').inject(:+) # => "abcd" # Complex. [Complex(1, 2), 3, 4].inject(:+) # => (8+2i) If argument +initial_operand+ is given, the operands for +inject+ are that value plus the elements of +self+. Example calls their operands: - (1..4).inject(10, :+):: [10, 1, 2, 3, 4]. - (1...4).inject(10, :+):: [10, 1, 2, 3]. - ('a'..'d').inject('e', :+):: ['e', 'a', 'b', 'c', 'd']. - ('a'...'d').inject('e', :+):: ['e', 'a', 'b', 'c']. Examples with +initial_operand+ of various types: # Integer. (1..4).inject(2, :+) # => 12 # Float. (1..4).inject(2.0, :+) # => 12.0 # String. ('a'..'d').inject('foo', :+) # => "fooabcd" # Array. %w[a b c].inject(['x'], :push) # => ["x", "a", "b", "c"] # Complex. (1..4).inject(Complex(2, 2), :+) # => (12+2i) Combination by Given \Method If the method-name argument +symbol+ is given, the operands are combined by that method: - The first and second operands are combined. - That result is combined with the third operand. - That result is combined with the fourth operand. - And so on. The return value from +inject+ is the result of the last combination. This call to +inject+ computes the sum of the operands: (1..4).inject(:+) # => 10 Examples with various methods: # Integer addition. (1..4).inject(:+) # => 10 # Integer multiplication. (1..4).inject(:*) # => 24 # Character range concatenation. ('a'..'d').inject('', :+) # => "abcd" # String array concatenation. %w[foo bar baz].inject('', :+) # => "foobarbaz" # Hash update. h = [{foo: 0, bar: 1}, {baz: 2}, {bat: 3}].inject(:update) h # => {:foo=>0, :bar=>1, :baz=>2, :bat=>3} # Hash conversion to nested arrays. h = {foo: 0, bar: 1}.inject([], :push) h # => [[:foo, 0], [:bar, 1]] Combination by Given Block If a block is given, the operands are passed to the block: - The first call passes the first and second operands. - The second call passes the result of the first call, along with the third operand. - The third call passes the result of the second call, along with the fourth operand. - And so on. The return value from +inject+ is the return value from the last block call. This call to +inject+ gives a block that writes the memo and element, and also sums the elements: (1..4).inject do |memo, element| p "Memo: #{memo}; element: #{element}" memo + element end # => 10 Output: "Memo: 1; element: 2" "Memo: 3; element: 3" "Memo: 6; element: 4" Enumerable#reduce is an alias for Enumerable#inject. @overload inject(symbol) @return [Object] @overload inject(initial_operand, symbol) @return [Object] @overload inject @yield [memo, operand] @return [Object] @overload inject(initial_operand) @yield [memo, operand] @return [Object];T;#0;$@0;.F;/o;0;1T;2ih;3i;%@y,;9I"static VALUE enum_inject(int argc, VALUE *argv, VALUE obj) { struct MEMO *memo; VALUE init, op; rb_block_call_func *iter = inject_i; ID id; switch (rb_scan_args(argc, argv, "02", &init, &op)) { case 0: init = Qundef; break; case 1: if (rb_block_given_p()) { break; } id = rb_check_id(&init); op = id ? ID2SYM(id) : init; init = Qundef; iter = inject_op_i; break; case 2: if (rb_block_given_p()) { rb_warning("given block not used"); } id = rb_check_id(&op); if (id) op = ID2SYM(id); iter = inject_op_i; break; } if (iter == inject_op_i && SYMBOL_P(op) && RB_TYPE_P(obj, T_ARRAY) && rb_method_basic_definition_p(CLASS_OF(obj), id_each)) { return ary_inject_op(obj, init, op); } memo = MEMO_NEW(init, Qnil, op); rb_block_call(obj, id_each, 0, 0, iter, (VALUE)memo); if (memo->v1 == Qundef) return Qnil; return memo->v1; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#reduce;F;7[[@90;[[@,i;T;: reduce;0;[;{;IC; "Returns an object formed from operands via either: - A method named by +symbol+. - A block to which each operand is passed. With method-name argument +symbol+, combines operands using the method: # Sum, without initial_operand. (1..4).inject(:+) # => 10 # Sum, with initial_operand. (1..4).inject(10, :+) # => 20 With a block, passes each operand to the block: # Sum of squares, without initial_operand. (1..4).inject {|sum, n| sum + n*n } # => 30 # Sum of squares, with initial_operand. (1..4).inject(2) {|sum, n| sum + n*n } # => 32 Operands If argument +initial_operand+ is not given, the operands for +inject+ are simply the elements of +self+. Example calls and their operands: - (1..4).inject(:+):: [1, 2, 3, 4]. - (1...4).inject(:+):: [1, 2, 3]. - ('a'..'d').inject(:+):: ['a', 'b', 'c', 'd']. - ('a'...'d').inject(:+):: ['a', 'b', 'c']. Examples with first operand (which is self.first) of various types: # Integer. (1..4).inject(:+) # => 10 # Float. [1.0, 2, 3, 4].inject(:+) # => 10.0 # Character. ('a'..'d').inject(:+) # => "abcd" # Complex. [Complex(1, 2), 3, 4].inject(:+) # => (8+2i) If argument +initial_operand+ is given, the operands for +inject+ are that value plus the elements of +self+. Example calls their operands: - (1..4).inject(10, :+):: [10, 1, 2, 3, 4]. - (1...4).inject(10, :+):: [10, 1, 2, 3]. - ('a'..'d').inject('e', :+):: ['e', 'a', 'b', 'c', 'd']. - ('a'...'d').inject('e', :+):: ['e', 'a', 'b', 'c']. Examples with +initial_operand+ of various types: # Integer. (1..4).inject(2, :+) # => 12 # Float. (1..4).inject(2.0, :+) # => 12.0 # String. ('a'..'d').inject('foo', :+) # => "fooabcd" # Array. %w[a b c].inject(['x'], :push) # => ["x", "a", "b", "c"] # Complex. (1..4).inject(Complex(2, 2), :+) # => (12+2i) Combination by Given \Method If the method-name argument +symbol+ is given, the operands are combined by that method: - The first and second operands are combined. - That result is combined with the third operand. - That result is combined with the fourth operand. - And so on. The return value from +inject+ is the result of the last combination. This call to +inject+ computes the sum of the operands: (1..4).inject(:+) # => 10 Examples with various methods: # Integer addition. (1..4).inject(:+) # => 10 # Integer multiplication. (1..4).inject(:*) # => 24 # Character range concatenation. ('a'..'d').inject('', :+) # => "abcd" # String array concatenation. %w[foo bar baz].inject('', :+) # => "foobarbaz" # Hash update. h = [{foo: 0, bar: 1}, {baz: 2}, {bat: 3}].inject(:update) h # => {:foo=>0, :bar=>1, :baz=>2, :bat=>3} # Hash conversion to nested arrays. h = {foo: 0, bar: 1}.inject([], :push) h # => [[:foo, 0], [:bar, 1]] Combination by Given Block If a block is given, the operands are passed to the block: - The first call passes the first and second operands. - The second call passes the result of the first call, along with the third operand. - The third call passes the result of the second call, along with the fourth operand. - And so on. The return value from +inject+ is the return value from the last block call. This call to +inject+ gives a block that writes the memo and element, and also sums the elements: (1..4).inject do |memo, element| p "Memo: #{memo}; element: #{element}" memo + element end # => 10 Output: "Memo: 1; element: 2" "Memo: 3; element: 3" "Memo: 6; element: 4" Enumerable#reduce is an alias for Enumerable#inject. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"inject(symbol);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@]0;![;"I"@return [Object];T;#0;$@]0;.F;Bi;C0;7[[I" symbol;T0;$@]0o;= ;>I" overload;F;?0;;;@0;:I"$inject(initial_operand, symbol);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@]0;![;"I"@return [Object];T;#0;$@]0;.F;Bi;C0;7[[I"initial_operand;T0[I" symbol;T0;$@]0o;= ;>I" overload;F;?0;;;@0;:I" inject;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" memo;TI" operand;T;$@]0o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@]0;![;"I",@yield [memo, operand] @return [Object];T;#0;$@]0;.F;Bi;C0;7[;$@]0o;= ;>I" overload;F;?0;;;@0;:I"inject(initial_operand);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" memo;TI" operand;T;$@]0o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@]0;![;"I",@yield [memo, operand] @return [Object];T;#0;$@]0;.F;Bi;C0;7[[I"initial_operand;T0;$@]0;![;"@Y0;#0;$@]0;.F;/o;0;1T;2ih;3i;%@y,;9I"static VALUE enum_inject(int argc, VALUE *argv, VALUE obj) { struct MEMO *memo; VALUE init, op; rb_block_call_func *iter = inject_i; ID id; switch (rb_scan_args(argc, argv, "02", &init, &op)) { case 0: init = Qundef; break; case 1: if (rb_block_given_p()) { break; } id = rb_check_id(&init); op = id ? ID2SYM(id) : init; init = Qundef; iter = inject_op_i; break; case 2: if (rb_block_given_p()) { rb_warning("given block not used"); } id = rb_check_id(&op); if (id) op = ID2SYM(id); iter = inject_op_i; break; } if (iter == inject_op_i && SYMBOL_P(op) && RB_TYPE_P(obj, T_ARRAY) && rb_method_basic_definition_p(CLASS_OF(obj), id_each)) { return ary_inject_op(obj, init, op); } memo = MEMO_NEW(init, Qnil, op); rb_block_call(obj, id_each, 0, 0, iter, (VALUE)memo); if (memo->v1 == Qundef) return Qnil; return memo->v1; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#partition;F;7[;[[@,iG;T;:partition;0;[;{;IC; "With a block given, returns an array of two arrays: - The first having those elements for which the block returns a truthy value. - The other having all other elements. Examples: p = (1..4).partition {|i| i.even? } p # => [[2, 4], [1, 3]] p = ('a'..'d').partition {|c| c < 'c' } p # => [["a", "b"], ["c", "d"]] h = {foo: 0, bar: 1, baz: 2, bat: 3} p = h.partition {|key, value| key.start_with?('b') } p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] p = h.partition {|key, value| value < 2 } p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] With no block given, returns an Enumerator. Related: Enumerable#group_by. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"partition;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@0o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@0;![;"I"%@yield [element] @return [Array];T;#0;$@0;.F;Bi;C0;7[;$@0o;= ;>I" overload;F;?0;;;@0;:I"partition;T;IC; ";T;[;![;"I";T;#0;$@0;.F;Bi;C0;7[;$@0;![;"I"With a block given, returns an array of two arrays: - The first having those elements for which the block returns a truthy value. - The other having all other elements. Examples: p = (1..4).partition {|i| i.even? } p # => [[2, 4], [1, 3]] p = ('a'..'d').partition {|c| c < 'c' } p # => [["a", "b"], ["c", "d"]] h = {foo: 0, bar: 1, baz: 2, bat: 3} p = h.partition {|key, value| key.start_with?('b') } p # => [[[:bar, 1], [:baz, 2], [:bat, 3]], [[:foo, 0]]] p = h.partition {|key, value| value < 2 } p # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]]] With no block given, returns an Enumerator. Related: Enumerable#group_by. @overload partition @yield [element] @return [Array] @overload partition;T;#0;$@0;.F;/o;0;1T;2i+;3iE;%@y,;9I"static VALUE enum_partition(VALUE obj) { struct MEMO *memo; RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size); memo = MEMO_NEW(rb_ary_new(), rb_ary_new(), 0); rb_block_call(obj, id_each, 0, 0, partition_i, (VALUE)memo); return rb_assoc_new(memo->v1, memo->v2); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#group_by;F;7[;[[@,i~;T;: group_by;0;[;{;IC; "With a block given returns a hash: - Each key is a return value from the block. - Each value is an array of those elements for which the block returned that key. Examples: g = (1..6).group_by {|i| i%3 } g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} h = {foo: 0, bar: 1, baz: 0, bat: 1} g = h.group_by {|key, value| value } g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} With no block given, returns an Enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" group_by;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@0o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@0;![;"I"$@yield [element] @return [Hash];T;#0;$@0;.F;Bi;C0;7[;$@0o;= ;>I" overload;F;?0;;;@0;:I" group_by;T;IC; ";T;[;![;"I";T;#0;$@0;.F;Bi;C0;7[;$@0;![;"I"With a block given returns a hash: - Each key is a return value from the block. - Each value is an array of those elements for which the block returned that key. Examples: g = (1..6).group_by {|i| i%3 } g # => {1=>[1, 4], 2=>[2, 5], 0=>[3, 6]} h = {foo: 0, bar: 1, baz: 0, bat: 1} g = h.group_by {|key, value| value } g # => {0=>[[:foo, 0], [:baz, 0]], 1=>[[:bar, 1], [:bat, 1]]} With no block given, returns an Enumerator. @overload group_by @yield [element] @return [Hash] @overload group_by;T;#0;$@0;.F;/o;0;1T;2ih;3i|;%@y,;9I"static VALUE enum_group_by(VALUE obj) { RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size); return enum_hashify(obj, 0, 0, group_by_i); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#tally;F;7[[@90;[[@,i;T;: tally;0;[;{;IC; "Returns a hash containing the counts of equal elements: - Each key is an element of +self+. - Each value is the number elements equal to that key. With no argument: %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} With a hash argument, that hash is used for the tally (instead of a new hash), and is returned; this may be useful for accumulating tallies across multiple enumerables: hash = {} hash = %w[a c d b c a].tally(hash) hash # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} hash = %w[b a z].tally(hash) hash # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} hash = %w[b a m].tally(hash) hash # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=> 1} ;T;[o;= ;>I" overload;F;?0;;;@0;:I" tally;T;IC; ";T;[;![;"I";T;#0;$@1;.F;Bi;C0;7[;$@1o;= ;>I" overload;F;?0;;;@0;:I"tally(hash);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@1;![;"I"@return [Hash];T;#0;$@1;.F;Bi;C0;7[[I" hash;T0;$@1;![;"I"Returns a hash containing the counts of equal elements: - Each key is an element of +self+. - Each value is the number elements equal to that key. With no argument: %w[a b c b c a c b].tally # => {"a"=>2, "b"=>3, "c"=>3} With a hash argument, that hash is used for the tally (instead of a new hash), and is returned; this may be useful for accumulating tallies across multiple enumerables: hash = {} hash = %w[a c d b c a].tally(hash) hash # => {"a"=>2, "c"=>2, "d"=>1, "b"=>1} hash = %w[b a z].tally(hash) hash # => {"a"=>3, "c"=>2, "d"=>1, "b"=>2, "z"=>1} hash = %w[b a m].tally(hash) hash # => {"a"=>4, "c"=>2, "d"=>1, "b"=>3, "z"=>1, "m"=> 1} @overload tally @overload tally(hash) @return [Hash];T;#0;$@1;.F;/o;0;1T;2i;3i;%@y,;9I"Dstatic VALUE enum_tally(int argc, VALUE *argv, VALUE obj) { VALUE hash; if (rb_check_arity(argc, 0, 1)) { hash = rb_convert_type(argv[0], T_HASH, "Hash", "to_hash"); rb_check_frozen(hash); } else { hash = rb_hash_new(); } return enum_hashify_into(obj, 0, 0, tally_i, hash); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#first;F;7[[@90;[[@,i;T;: first;0;[;{;IC; "Returns the first element or elements. With no argument, returns the first element, or +nil+ if there is none: (1..4).first # => 1 %w[a b c].first # => "a" {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] [].first # => nil With integer argument +n+, returns an array containing the first +n+ elements that exist: (1..4).first(2) # => [1, 2] %w[a b c d].first(3) # => ["a", "b", "c"] %w[a b c d].first(50) # => ["a", "b", "c", "d"] {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] [].first(2) # => [] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" first;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@)1;![;"I"@return [nil];T;#0;$@)1;.F;Bi;C0;7[;$@)1o;= ;>I" overload;F;?0;;;@0;:I" first(n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@)1;![;"I"@return [Array];T;#0;$@)1;.F;Bi;C0;7[[I"n;T0;$@)1;![;"I"Returns the first element or elements. With no argument, returns the first element, or +nil+ if there is none: (1..4).first # => 1 %w[a b c].first # => "a" {foo: 1, bar: 1, baz: 2}.first # => [:foo, 1] [].first # => nil With integer argument +n+, returns an array containing the first +n+ elements that exist: (1..4).first(2) # => [1, 2] %w[a b c d].first(3) # => ["a", "b", "c"] %w[a b c d].first(50) # => ["a", "b", "c", "d"] {foo: 1, bar: 1, baz: 2}.first(2) # => [[:foo, 1], [:bar, 1]] [].first(2) # => [] @overload first @return [nil] @overload first(n) @return [Array];T;#0;$@)1;.F;/o;0;1T;2i;3i;%@y,;9I"*static VALUE enum_first(int argc, VALUE *argv, VALUE obj) { struct MEMO *memo; rb_check_arity(argc, 0, 1); if (argc > 0) { return enum_take(obj, argv[0]); } else { memo = MEMO_NEW(Qnil, 0, 0); rb_block_call(obj, id_each, 0, 0, first_i, (VALUE)memo); return memo->v1; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#all?;F;7[[@90;[[@,i@;T;: all?;0;[;{;IC; "Returns whether every element meets a given criterion. With no argument and no block, returns whether every element is truthy: (1..4).all? # => true %w[a b c d].all? # => true [1, 2, nil].all? # => false ['a','b', false].all? # => false [].all? # => true With argument +pattern+ and no block, returns whether for each element +element+, pattern === element: (1..4).all?(Integer) # => true (1..4).all?(Numeric) # => true (1..4).all?(Float) # => false %w[bar baz bat bam].all?(/ba/) # => true %w[bar baz bat bam].all?(/bar/) # => false %w[bar baz bat bam].all?('ba') # => false {foo: 0, bar: 1, baz: 2}.all?(Array) # => true {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false [].all?(Integer) # => true With a block given, returns whether the block returns a truthy value for every element: (1..4).all? {|element| element < 5 } # => true (1..4).all? {|element| element < 4 } # => false {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false Related: #any?, #none? #one?.;T;[o;= ;>I" overload;F;?0;;;@0;:I" all?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@T1;![;"I"@return [Boolean];T;#0;$@T1;.F;Bi;C0;7[;$@T1o;= ;>I" overload;F;?0;;;@0;:I"all?(pattern);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@T1;![;"I"@return [Boolean];T;#0;$@T1;.F;Bi;C0;7[[I" pattern;T0;$@T1o;= ;>I" overload;F;?0;;;@0;:I" all?;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@T1o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@T1;![;"I"'@yield [element] @return [Boolean];T;#0;$@T1;.F;Bi;C0;7[;$@T1;![;"I"nReturns whether every element meets a given criterion. With no argument and no block, returns whether every element is truthy: (1..4).all? # => true %w[a b c d].all? # => true [1, 2, nil].all? # => false ['a','b', false].all? # => false [].all? # => true With argument +pattern+ and no block, returns whether for each element +element+, pattern === element: (1..4).all?(Integer) # => true (1..4).all?(Numeric) # => true (1..4).all?(Float) # => false %w[bar baz bat bam].all?(/ba/) # => true %w[bar baz bat bam].all?(/bar/) # => false %w[bar baz bat bam].all?('ba') # => false {foo: 0, bar: 1, baz: 2}.all?(Array) # => true {foo: 0, bar: 1, baz: 2}.all?(Hash) # => false [].all?(Integer) # => true With a block given, returns whether the block returns a truthy value for every element: (1..4).all? {|element| element < 5 } # => true (1..4).all? {|element| element < 4 } # => false {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 3 } # => true {foo: 0, bar: 1, baz: 2}.all? {|key, value| value < 2 } # => false Related: #any?, #none? #one?. @overload all? @return [Boolean] @overload all?(pattern) @return [Boolean] @overload all? @yield [element] @return [Boolean];T;#0;$@T1;.F;/o;0;1T;2i;3i@;Bi;%@y,;9I"static VALUE enum_all(int argc, VALUE *argv, VALUE obj) { struct MEMO *memo = MEMO_ENUM_NEW(Qtrue); WARN_UNUSED_BLOCK(argc); rb_block_call(obj, id_each, 0, 0, ENUMFUNC(all), (VALUE)memo); return memo->v1; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#any?;F;7[[@90;[[@,i|;T;: any?;0;[;{;IC; "Returns whether any element meets a given criterion. With no argument and no block, returns whether any element is truthy: (1..4).any? # => true %w[a b c d].any? # => true [1, false, nil].any? # => true [].any? # => false With argument +pattern+ and no block, returns whether for any element +element+, pattern === element: [nil, false, 0].any?(Integer) # => true [nil, false, 0].any?(Numeric) # => true [nil, false, 0].any?(Float) # => false %w[bar baz bat bam].any?(/m/) # => true %w[bar baz bat bam].any?(/foo/) # => false %w[bar baz bat bam].any?('ba') # => false {foo: 0, bar: 1, baz: 2}.any?(Array) # => true {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false [].any?(Integer) # => false With a block given, returns whether the block returns a truthy value for any element: (1..4).any? {|element| element < 2 } # => true (1..4).any? {|element| element < 1 } # => false {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false Related: #all?, #none?, #one?.;T;[o;= ;>I" overload;F;?0;;;@0;:I" any?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@1;![;"I"@return [Boolean];T;#0;$@1;.F;Bi;C0;7[;$@1o;= ;>I" overload;F;?0;;;@0;:I"any?(pattern);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@1;![;"I"@return [Boolean];T;#0;$@1;.F;Bi;C0;7[[I" pattern;T0;$@1o;= ;>I" overload;F;?0;;;@0;:I" any?;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@1o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@1;![;"I"'@yield [element] @return [Boolean];T;#0;$@1;.F;Bi;C0;7[;$@1;![;"I"BReturns whether any element meets a given criterion. With no argument and no block, returns whether any element is truthy: (1..4).any? # => true %w[a b c d].any? # => true [1, false, nil].any? # => true [].any? # => false With argument +pattern+ and no block, returns whether for any element +element+, pattern === element: [nil, false, 0].any?(Integer) # => true [nil, false, 0].any?(Numeric) # => true [nil, false, 0].any?(Float) # => false %w[bar baz bat bam].any?(/m/) # => true %w[bar baz bat bam].any?(/foo/) # => false %w[bar baz bat bam].any?('ba') # => false {foo: 0, bar: 1, baz: 2}.any?(Array) # => true {foo: 0, bar: 1, baz: 2}.any?(Hash) # => false [].any?(Integer) # => false With a block given, returns whether the block returns a truthy value for any element: (1..4).any? {|element| element < 2 } # => true (1..4).any? {|element| element < 1 } # => false {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false Related: #all?, #none?, #one?. @overload any? @return [Boolean] @overload any?(pattern) @return [Boolean] @overload any? @yield [element] @return [Boolean];T;#0;$@1;.F;/o;0;1T;2iR;3i|;Bi;%@y,;9I"static VALUE enum_any(int argc, VALUE *argv, VALUE obj) { struct MEMO *memo = MEMO_ENUM_NEW(Qfalse); WARN_UNUSED_BLOCK(argc); rb_block_call(obj, id_each, 0, 0, ENUMFUNC(any), (VALUE)memo); return memo->v1; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#one?;F;7[[@90;[[@,i;T;: one?;0;[;{;IC; "'Returns whether exactly one element meets a given criterion. With no argument and no block, returns whether exactly one element is truthy: (1..1).one? # => true [1, nil, false].one? # => true (1..4).one? # => false {foo: 0}.one? # => true {foo: 0, bar: 1}.one? # => false [].one? # => false With argument +pattern+ and no block, returns whether for exactly one element +element+, pattern === element: [nil, false, 0].one?(Integer) # => true [nil, false, 0].one?(Numeric) # => true [nil, false, 0].one?(Float) # => false %w[bar baz bat bam].one?(/m/) # => true %w[bar baz bat bam].one?(/foo/) # => false %w[bar baz bat bam].one?('ba') # => false {foo: 0, bar: 1, baz: 2}.one?(Array) # => false {foo: 0}.one?(Array) # => true [].one?(Integer) # => false With a block given, returns whether the block returns a truthy value for exactly one element: (1..4).one? {|element| element < 2 } # => true (1..4).one? {|element| element < 1 } # => false {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false Related: #none?, #all?, #any?.;T;[o;= ;>I" overload;F;?0;;;@0;:I" one?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@1;![;"I"@return [Boolean];T;#0;$@1;.F;Bi;C0;7[;$@1o;= ;>I" overload;F;?0;;;@0;:I"one?(pattern);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@1;![;"I"@return [Boolean];T;#0;$@1;.F;Bi;C0;7[[I" pattern;T0;$@1o;= ;>I" overload;F;?0;;;@0;:I" one?;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@1o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@1;![;"I"'@yield [element] @return [Boolean];T;#0;$@1;.F;Bi;C0;7[;$@1;![;"I"Returns whether exactly one element meets a given criterion. With no argument and no block, returns whether exactly one element is truthy: (1..1).one? # => true [1, nil, false].one? # => true (1..4).one? # => false {foo: 0}.one? # => true {foo: 0, bar: 1}.one? # => false [].one? # => false With argument +pattern+ and no block, returns whether for exactly one element +element+, pattern === element: [nil, false, 0].one?(Integer) # => true [nil, false, 0].one?(Numeric) # => true [nil, false, 0].one?(Float) # => false %w[bar baz bat bam].one?(/m/) # => true %w[bar baz bat bam].one?(/foo/) # => false %w[bar baz bat bam].one?('ba') # => false {foo: 0, bar: 1, baz: 2}.one?(Array) # => false {foo: 0}.one?(Array) # => true [].one?(Integer) # => false With a block given, returns whether the block returns a truthy value for exactly one element: (1..4).one? {|element| element < 2 } # => true (1..4).one? {|element| element < 1 } # => false {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 1 } # => true {foo: 0, bar: 1, baz: 2}.one? {|key, value| value < 2 } # => false Related: #none?, #all?, #any?. @overload one? @return [Boolean] @overload one?(pattern) @return [Boolean] @overload one? @yield [element] @return [Boolean];T;#0;$@1;.F;/o;0;1T;2iq;3i;Bi;%@y,;9I"0static VALUE enum_one(int argc, VALUE *argv, VALUE obj) { struct MEMO *memo = MEMO_ENUM_NEW(Qundef); VALUE result; WARN_UNUSED_BLOCK(argc); rb_block_call(obj, id_each, 0, 0, ENUMFUNC(one), (VALUE)memo); result = memo->v1; if (result == Qundef) return Qfalse; return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#none?;F;7[[@90;[[@,i;T;: none?;0;[;{;IC; "Returns whether no element meets a given criterion. With no argument and no block, returns whether no element is truthy: (1..4).none? # => false [nil, false].none? # => true {foo: 0}.none? # => false {foo: 0, bar: 1}.none? # => false [].none? # => true With argument +pattern+ and no block, returns whether for no element +element+, pattern === element: [nil, false, 1.1].none?(Integer) # => true %w[bar baz bat bam].none?(/m/) # => false %w[bar baz bat bam].none?(/foo/) # => true %w[bar baz bat bam].none?('ba') # => true {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true {foo: 0}.none?(Array) # => false [].none?(Integer) # => true With a block given, returns whether the block returns a truthy value for no element: (1..4).none? {|element| element < 1 } # => true (1..4).none? {|element| element < 2 } # => false {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false Related: #one?, #all?, #any?.;T;[o;= ;>I" overload;F;?0;;;@0;:I" none?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ 2;![;"I"@return [Boolean];T;#0;$@ 2;.F;Bi;C0;7[;$@ 2o;= ;>I" overload;F;?0;;;@0;:I"none?(pattern);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ 2;![;"I"@return [Boolean];T;#0;$@ 2;.F;Bi;C0;7[[I" pattern;T0;$@ 2o;= ;>I" overload;F;?0;;;@0;:I" none?;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@ 2o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ 2;![;"I"'@yield [element] @return [Boolean];T;#0;$@ 2;.F;Bi;C0;7[;$@ 2;![;"I"Returns whether no element meets a given criterion. With no argument and no block, returns whether no element is truthy: (1..4).none? # => false [nil, false].none? # => true {foo: 0}.none? # => false {foo: 0, bar: 1}.none? # => false [].none? # => true With argument +pattern+ and no block, returns whether for no element +element+, pattern === element: [nil, false, 1.1].none?(Integer) # => true %w[bar baz bat bam].none?(/m/) # => false %w[bar baz bat bam].none?(/foo/) # => true %w[bar baz bat bam].none?('ba') # => true {foo: 0, bar: 1, baz: 2}.none?(Hash) # => true {foo: 0}.none?(Array) # => false [].none?(Integer) # => true With a block given, returns whether the block returns a truthy value for no element: (1..4).none? {|element| element < 1 } # => true (1..4).none? {|element| element < 2 } # => false {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 0 } # => true {foo: 0, bar: 1, baz: 2}.none? {|key, value| value < 1 } # => false Related: #one?, #all?, #any?. @overload none? @return [Boolean] @overload none?(pattern) @return [Boolean] @overload none? @yield [element] @return [Boolean];T;#0;$@ 2;.F;/o;0;1T;2i;3i;Bi;%@y,;9I"static VALUE enum_none(int argc, VALUE *argv, VALUE obj) { struct MEMO *memo = MEMO_ENUM_NEW(Qtrue); WARN_UNUSED_BLOCK(argc); rb_block_call(obj, id_each, 0, 0, ENUMFUNC(none), (VALUE)memo); return memo->v1; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#min;F;7[[@90;[[@,iI;T;:min;0;[;{;IC; "/Returns the element with the minimum element according to a given criterion. The ordering of equal elements is indeterminate and may be unstable. With no argument and no block, returns the minimum element, using the elements' own method <=> for comparison: (1..4).min # => 1 (-4..-1).min # => -4 %w[d c b a].min # => "a" {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] [].min # => nil With positive integer argument +n+ given, and no block, returns an array containing the first +n+ minimum elements that exist: (1..4).min(2) # => [1, 2] (-4..-1).min(2) # => [-4, -3] %w[d c b a].min(2) # => ["a", "b"] {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] [].min(2) # => [] With a block given, the block determines the minimum elements. The block is called with two elements +a+ and +b+, and must return: - A negative integer if a < b. - Zero if a == b. - A positive integer if a > b. With a block given and no argument, returns the minimum element as determined by the block: %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" h = {foo: 0, bar: 1, baz: 2} h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] [].min {|a, b| a <=> b } # => nil With a block given and positive integer argument +n+ given, returns an array containing the first +n+ minimum elements that exist, as determined by the block. %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] h = {foo: 0, bar: 1, baz: 2} h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } # => [[:foo, 0], [:bar, 1]] [].min(2) {|a, b| a <=> b } # => [] Related: #min_by, #minmax, #max. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"min;T;IC; ";T;[;![;"I";T;#0;$@H2;.F;Bi;C0;7[;$@H2o;= ;>I" overload;F;?0;;;@0;:I" min(n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@H2;![;"I"@return [Array];T;#0;$@H2;.F;Bi;C0;7[[I"n;T0;$@H2o;= ;>I" overload;F;?0;;;@0;:I"min;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"a;TI"b;T;$@H2;![;"I"@yield [a, b];T;#0;$@H2;.F;Bi;C0;7[;$@H2o;= ;>I" overload;F;?0;;;@0;:I" min(n);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"a;TI"b;T;$@H2o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@H2;![;"I""@yield [a, b] @return [Array];T;#0;$@H2;.F;Bi;C0;7[[I"n;T0;$@H2;![;"I"Returns the element with the minimum element according to a given criterion. The ordering of equal elements is indeterminate and may be unstable. With no argument and no block, returns the minimum element, using the elements' own method <=> for comparison: (1..4).min # => 1 (-4..-1).min # => -4 %w[d c b a].min # => "a" {foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] [].min # => nil With positive integer argument +n+ given, and no block, returns an array containing the first +n+ minimum elements that exist: (1..4).min(2) # => [1, 2] (-4..-1).min(2) # => [-4, -3] %w[d c b a].min(2) # => ["a", "b"] {foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] [].min(2) # => [] With a block given, the block determines the minimum elements. The block is called with two elements +a+ and +b+, and must return: - A negative integer if a < b. - Zero if a == b. - A positive integer if a > b. With a block given and no argument, returns the minimum element as determined by the block: %w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" h = {foo: 0, bar: 1, baz: 2} h.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] [].min {|a, b| a <=> b } # => nil With a block given and positive integer argument +n+ given, returns an array containing the first +n+ minimum elements that exist, as determined by the block. %w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] h = {foo: 0, bar: 1, baz: 2} h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } # => [[:foo, 0], [:bar, 1]] [].min(2) {|a, b| a <=> b } # => [] Related: #min_by, #minmax, #max. @overload min @overload min(n) @return [Array] @overload min @yield [a, b] @overload min(n) @yield [a, b] @return [Array];T;#0;$@H2;.F;/o;0;1T;2i;3iI;%@y,;9I"Pstatic VALUE enum_min(int argc, VALUE *argv, VALUE obj) { VALUE memo; struct min_t *m = NEW_CMP_OPT_MEMO(struct min_t, memo); VALUE result; VALUE num; if (rb_check_arity(argc, 0, 1) && !NIL_P(num = argv[0])) return rb_nmin_run(obj, num, 0, 0, 0); m->min = Qundef; m->cmp_opt.opt_methods = 0; m->cmp_opt.opt_inited = 0; if (rb_block_given_p()) { rb_block_call(obj, id_each, 0, 0, min_ii, memo); } else { rb_block_call(obj, id_each, 0, 0, min_i, memo); } result = m->min; if (result == Qundef) return Qnil; return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#max;F;7[[@90;[[@,i;T;;e;0;[;{;IC; "9Returns the element with the maximum element according to a given criterion. The ordering of equal elements is indeterminate and may be unstable. With no argument and no block, returns the maximum element, using the elements' own method <=> for comparison: (1..4).max # => 4 (-4..-1).max # => -1 %w[d c b a].max # => "d" {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] [].max # => nil With positive integer argument +n+ given, and no block, returns an array containing the first +n+ maximum elements that exist: (1..4).max(2) # => [4, 3] (-4..-1).max(2) # => [-1, -2] %w[d c b a].max(2) # => ["d", "c"] {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] [].max(2) # => [] With a block given, the block determines the maximum elements. The block is called with two elements +a+ and +b+, and must return: - A negative integer if a < b. - Zero if a == b. - A positive integer if a > b. With a block given and no argument, returns the maximum element as determined by the block: %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" h = {foo: 0, bar: 1, baz: 2} h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] [].max {|a, b| a <=> b } # => nil With a block given and positive integer argument +n+ given, returns an array containing the first +n+ maximum elements that exist, as determined by the block. %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] h = {foo: 0, bar: 1, baz: 2} h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } # => [[:baz, 2], [:bar, 1]] [].max(2) {|a, b| a <=> b } # => [] Related: #min, #minmax, #max_by. ;T;[ o;= ;>I" overload;F;?0;;e;@0;:I"max;T;IC; ";T;[;![;"I";T;#0;$@2;.F;Bi;C0;7[;$@2o;= ;>I" overload;F;?0;;e;@0;:I" max(n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@2;![;"I"@return [Array];T;#0;$@2;.F;Bi;C0;7[[I"n;T0;$@2o;= ;>I" overload;F;?0;;e;@0;:I"max;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"a;TI"b;T;$@2;![;"I"@yield [a, b];T;#0;$@2;.F;Bi;C0;7[;$@2o;= ;>I" overload;F;?0;;e;@0;:I" max(n);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"a;TI"b;T;$@2o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@2;![;"I""@yield [a, b] @return [Array];T;#0;$@2;.F;Bi;C0;7[[I"n;T0;$@2;![;"I"Returns the element with the maximum element according to a given criterion. The ordering of equal elements is indeterminate and may be unstable. With no argument and no block, returns the maximum element, using the elements' own method <=> for comparison: (1..4).max # => 4 (-4..-1).max # => -1 %w[d c b a].max # => "d" {foo: 0, bar: 1, baz: 2}.max # => [:foo, 0] [].max # => nil With positive integer argument +n+ given, and no block, returns an array containing the first +n+ maximum elements that exist: (1..4).max(2) # => [4, 3] (-4..-1).max(2) # => [-1, -2] %w[d c b a].max(2) # => ["d", "c"] {foo: 0, bar: 1, baz: 2}.max(2) # => [[:foo, 0], [:baz, 2]] [].max(2) # => [] With a block given, the block determines the maximum elements. The block is called with two elements +a+ and +b+, and must return: - A negative integer if a < b. - Zero if a == b. - A positive integer if a > b. With a block given and no argument, returns the maximum element as determined by the block: %w[xxx x xxxx xx].max {|a, b| a.size <=> b.size } # => "xxxx" h = {foo: 0, bar: 1, baz: 2} h.max {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:baz, 2] [].max {|a, b| a <=> b } # => nil With a block given and positive integer argument +n+ given, returns an array containing the first +n+ maximum elements that exist, as determined by the block. %w[xxx x xxxx xx].max(2) {|a, b| a.size <=> b.size } # => ["xxxx", "xxx"] h = {foo: 0, bar: 1, baz: 2} h.max(2) {|pair1, pair2| pair1[1] <=> pair2[1] } # => [[:baz, 2], [:bar, 1]] [].max(2) {|a, b| a <=> b } # => [] Related: #min, #minmax, #max_by. @overload max @overload max(n) @return [Array] @overload max @yield [a, b] @overload max(n) @yield [a, b] @return [Array];T;#0;$@2;.F;/o;0;1T;2i;3i;%@y,;9I"^static VALUE enum_max(int argc, VALUE *argv, VALUE obj) { VALUE memo; struct max_t *m = NEW_CMP_OPT_MEMO(struct max_t, memo); VALUE result; VALUE num; if (rb_check_arity(argc, 0, 1) && !NIL_P(num = argv[0])) return rb_nmin_run(obj, num, 0, 1, 0); m->max = Qundef; m->cmp_opt.opt_methods = 0; m->cmp_opt.opt_inited = 0; if (rb_block_given_p()) { rb_block_call(obj, id_each, 0, 0, max_ii, (VALUE)memo); } else { rb_block_call(obj, id_each, 0, 0, max_i, (VALUE)memo); } result = m->max; if (result == Qundef) return Qnil; return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#minmax;F;7[;[[@,im ;T;: minmax;0;[;{;IC; "Returns a 2-element array containing the minimum and maximum elements according to a given criterion. The ordering of equal elements is indeterminate and may be unstable. With no argument and no block, returns the minimum and maximum elements, using the elements' own method <=> for comparison: (1..4).minmax # => [1, 4] (-4..-1).minmax # => [-4, -1] %w[d c b a].minmax # => ["a", "d"] {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] [].minmax # => [nil, nil] With a block given, returns the minimum and maximum elements as determined by the block: %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] h = {foo: 0, bar: 1, baz: 2} h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } # => [[:foo, 0], [:baz, 2]] [].minmax {|a, b| a <=> b } # => [nil, nil] Related: #min, #max, #minmax_by. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" minmax;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@2;![;"I"@return [Array];T;#0;$@2;.F;Bi;C0;7[;$@2o;= ;>I" overload;F;?0;;;@0;:I" minmax;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"a;TI"b;T;$@2o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@2;![;"I""@yield [a, b] @return [Array];T;#0;$@2;.F;Bi;C0;7[;$@2;![;"I"Returns a 2-element array containing the minimum and maximum elements according to a given criterion. The ordering of equal elements is indeterminate and may be unstable. With no argument and no block, returns the minimum and maximum elements, using the elements' own method <=> for comparison: (1..4).minmax # => [1, 4] (-4..-1).minmax # => [-4, -1] %w[d c b a].minmax # => ["a", "d"] {foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] [].minmax # => [nil, nil] With a block given, returns the minimum and maximum elements as determined by the block: %w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] h = {foo: 0, bar: 1, baz: 2} h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } # => [[:foo, 0], [:baz, 2]] [].minmax {|a, b| a <=> b } # => [nil, nil] Related: #min, #max, #minmax_by. @overload minmax @return [Array] @overload minmax @yield [a, b] @return [Array];T;#0;$@2;.F;/o;0;1T;2iN ;3il ;%@y,;9I"vstatic VALUE enum_minmax(VALUE obj) { VALUE memo; struct minmax_t *m = NEW_CMP_OPT_MEMO(struct minmax_t, memo); m->min = Qundef; m->last = Qundef; m->cmp_opt.opt_methods = 0; m->cmp_opt.opt_inited = 0; if (rb_block_given_p()) { rb_block_call(obj, id_each, 0, 0, minmax_ii, memo); if (m->last != Qundef) minmax_ii_update(m->last, m->last, m); } else { rb_block_call(obj, id_each, 0, 0, minmax_i, memo); if (m->last != Qundef) minmax_i_update(m->last, m->last, m); } if (m->min != Qundef) { return rb_assoc_new(m->min, m->max); } return rb_assoc_new(Qnil, Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#min_by;F;7[[@90;[[@,i ;T;: min_by;0;[;{;IC; "Returns the elements for which the block returns the minimum values. With a block given and no argument, returns the element for which the block returns the minimum value: (1..4).min_by {|element| -element } # => 4 %w[a b c d].min_by {|element| -element.ord } # => "d" {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] [].min_by {|element| -element } # => nil With a block given and positive integer argument +n+ given, returns an array containing the +n+ elements for which the block returns minimum values: (1..4).min_by(2) {|element| -element } # => [4, 3] %w[a b c d].min_by(2) {|element| -element.ord } # => ["d", "c"] {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } # => [[:baz, 2], [:bar, 1]] [].min_by(2) {|element| -element } # => [] Returns an Enumerator if no block is given. Related: #min, #minmax, #max_by. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I" min_by;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@3;![;"I"@yield [element];T;#0;$@3;.F;Bi;C0;7[;$@3o;= ;>I" overload;F;?0;;;@0;:I"min_by(n);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@3o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@3;![;"I"%@yield [element] @return [Array];T;#0;$@3;.F;Bi;C0;7[[I"n;T0;$@3o;= ;>I" overload;F;?0;;;@0;:I" min_by;T;IC; ";T;[;![;"I";T;#0;$@3;.F;Bi;C0;7[;$@3o;= ;>I" overload;F;?0;;;@0;:I"min_by(n);T;IC; ";T;[;![;"I";T;#0;$@3;.F;Bi;C0;7[[I"n;T0;$@3;![;"I"(Returns the elements for which the block returns the minimum values. With a block given and no argument, returns the element for which the block returns the minimum value: (1..4).min_by {|element| -element } # => 4 %w[a b c d].min_by {|element| -element.ord } # => "d" {foo: 0, bar: 1, baz: 2}.min_by {|key, value| -value } # => [:baz, 2] [].min_by {|element| -element } # => nil With a block given and positive integer argument +n+ given, returns an array containing the +n+ elements for which the block returns minimum values: (1..4).min_by(2) {|element| -element } # => [4, 3] %w[a b c d].min_by(2) {|element| -element.ord } # => ["d", "c"] {foo: 0, bar: 1, baz: 2}.min_by(2) {|key, value| -value } # => [[:baz, 2], [:bar, 1]] [].min_by(2) {|element| -element } # => [] Returns an Enumerator if no block is given. Related: #min, #minmax, #max_by. @overload min_by @yield [element] @overload min_by(n) @yield [element] @return [Array] @overload min_by @overload min_by(n);T;#0;$@3;.F;/o;0;1T;2i ;3i ;%@y,;9I"static VALUE enum_min_by(int argc, VALUE *argv, VALUE obj) { struct MEMO *memo; VALUE num; rb_check_arity(argc, 0, 1); RETURN_SIZED_ENUMERATOR(obj, argc, argv, enum_size); if (argc && !NIL_P(num = argv[0])) return rb_nmin_run(obj, num, 1, 0, 0); memo = MEMO_NEW(Qundef, Qnil, 0); rb_block_call(obj, id_each, 0, 0, min_by_i, (VALUE)memo); return memo->v2; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#max_by;F;7[[@90;[[@,i ;T;: max_by;0;[;{;IC; "Returns the elements for which the block returns the maximum values. With a block given and no argument, returns the element for which the block returns the maximum value: (1..4).max_by {|element| -element } # => 1 %w[a b c d].max_by {|element| -element.ord } # => "a" {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] [].max_by {|element| -element } # => nil With a block given and positive integer argument +n+ given, returns an array containing the +n+ elements for which the block returns maximum values: (1..4).max_by(2) {|element| -element } # => [1, 2] %w[a b c d].max_by(2) {|element| -element.ord } # => ["a", "b"] {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } # => [[:foo, 0], [:bar, 1]] [].max_by(2) {|element| -element } # => [] Returns an Enumerator if no block is given. Related: #max, #minmax, #min_by. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I" max_by;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@J3;![;"I"@yield [element];T;#0;$@J3;.F;Bi;C0;7[;$@J3o;= ;>I" overload;F;?0;;;@0;:I"max_by(n);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@J3o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@J3;![;"I"%@yield [element] @return [Array];T;#0;$@J3;.F;Bi;C0;7[[I"n;T0;$@J3o;= ;>I" overload;F;?0;;;@0;:I" max_by;T;IC; ";T;[;![;"I";T;#0;$@J3;.F;Bi;C0;7[;$@J3o;= ;>I" overload;F;?0;;;@0;:I"max_by(n);T;IC; ";T;[;![;"I";T;#0;$@J3;.F;Bi;C0;7[[I"n;T0;$@J3;![;"I"(Returns the elements for which the block returns the maximum values. With a block given and no argument, returns the element for which the block returns the maximum value: (1..4).max_by {|element| -element } # => 1 %w[a b c d].max_by {|element| -element.ord } # => "a" {foo: 0, bar: 1, baz: 2}.max_by {|key, value| -value } # => [:foo, 0] [].max_by {|element| -element } # => nil With a block given and positive integer argument +n+ given, returns an array containing the +n+ elements for which the block returns maximum values: (1..4).max_by(2) {|element| -element } # => [1, 2] %w[a b c d].max_by(2) {|element| -element.ord } # => ["a", "b"] {foo: 0, bar: 1, baz: 2}.max_by(2) {|key, value| -value } # => [[:foo, 0], [:bar, 1]] [].max_by(2) {|element| -element } # => [] Returns an Enumerator if no block is given. Related: #max, #minmax, #min_by. @overload max_by @yield [element] @overload max_by(n) @yield [element] @return [Array] @overload max_by @overload max_by(n);T;#0;$@J3;.F;/o;0;1T;2i ;3i ;%@y,;9I"static VALUE enum_max_by(int argc, VALUE *argv, VALUE obj) { struct MEMO *memo; VALUE num; rb_check_arity(argc, 0, 1); RETURN_SIZED_ENUMERATOR(obj, argc, argv, enum_size); if (argc && !NIL_P(num = argv[0])) return rb_nmin_run(obj, num, 1, 1, 0); memo = MEMO_NEW(Qundef, Qnil, 0); rb_block_call(obj, id_each, 0, 0, max_by_i, (VALUE)memo); return memo->v2; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#minmax_by;F;7[;[[@,i} ;T;:minmax_by;0;[;{;IC; "Returns a 2-element array containing the elements for which the block returns minimum and maximum values: (1..4).minmax_by {|element| -element } # => [4, 1] %w[a b c d].minmax_by {|element| -element.ord } # => ["d", "a"] {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } # => [[:baz, 2], [:foo, 0]] [].minmax_by {|element| -element } # => [nil, nil] Returns an Enumerator if no block is given. Related: #max_by, #minmax, #min_by. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"minmax_by;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@3o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@3;![;"I"%@yield [element] @return [Array];T;#0;$@3;.F;Bi;C0;7[;$@3o;= ;>I" overload;F;?0;;;@0;:I"minmax_by;T;IC; ";T;[;![;"I";T;#0;$@3;.F;Bi;C0;7[;$@3;![;"I"Returns a 2-element array containing the elements for which the block returns minimum and maximum values: (1..4).minmax_by {|element| -element } # => [4, 1] %w[a b c d].minmax_by {|element| -element.ord } # => ["d", "a"] {foo: 0, bar: 1, baz: 2}.minmax_by {|key, value| -value } # => [[:baz, 2], [:foo, 0]] [].minmax_by {|element| -element } # => [nil, nil] Returns an Enumerator if no block is given. Related: #max_by, #minmax, #min_by. @overload minmax_by @yield [element] @return [Array] @overload minmax_by;T;#0;$@3;.F;/o;0;1T;2if ;3i{ ;%@y,;9I".static VALUE enum_minmax_by(VALUE obj) { VALUE memo; struct minmax_by_t *m = NEW_MEMO_FOR(struct minmax_by_t, memo); RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size); m->min_bv = Qundef; m->max_bv = Qundef; m->min = Qnil; m->max = Qnil; m->last_bv = Qundef; m->last = Qundef; rb_block_call(obj, id_each, 0, 0, minmax_by_i, memo); if (m->last_bv != Qundef) minmax_by_i_update(m->last_bv, m->last_bv, m->last, m->last, m); m = MEMO_FOR(struct minmax_by_t, memo); return rb_assoc_new(m->min, m->max); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#member?;F;7[[I"val;T0;[[@,i ;T;;;0;[;{;IC; ""Returns whether for any element object == element: (1..4).include?(2) # => true (1..4).include?(5) # => false (1..4).include?('2') # => false %w[a b c d].include?('b') # => true %w[a b c d].include?('2') # => false {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true {foo: 0, bar: 1, baz: 2}.include?('foo') # => false {foo: 0, bar: 1, baz: 2}.include?(0) # => false Enumerable#member? is an alias for Enumerable#include?.;T;[o;= ;>I" overload;F;?0;;;@0;:I"include?(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@3;![;"I"@return [Boolean];T;#0;$@3;.F;Bi;C0;7[[I" object;T0;$@3;![;"I"TReturns whether for any element object == element: (1..4).include?(2) # => true (1..4).include?(5) # => false (1..4).include?('2') # => false %w[a b c d].include?('b') # => true %w[a b c d].include?('2') # => false {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true {foo: 0, bar: 1, baz: 2}.include?('foo') # => false {foo: 0, bar: 1, baz: 2}.include?(0) # => false Enumerable#member? is an alias for Enumerable#include?. @overload include?(object) @return [Boolean];T;#0;$@3;.F;/o;0;1T;2i ;3i ;Bi;%@y,;9I"static VALUE enum_member(VALUE obj, VALUE val) { struct MEMO *memo = MEMO_NEW(val, Qfalse, 0); rb_block_call(obj, id_each, 0, 0, member_i, (VALUE)memo); return memo->v2; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#include?;F;7[[I"val;T0;[[@,i ;T;;;0;[;{;IC; ""Returns whether for any element object == element: (1..4).include?(2) # => true (1..4).include?(5) # => false (1..4).include?('2') # => false %w[a b c d].include?('b') # => true %w[a b c d].include?('2') # => false {foo: 0, bar: 1, baz: 2}.include?(:foo) # => true {foo: 0, bar: 1, baz: 2}.include?('foo') # => false {foo: 0, bar: 1, baz: 2}.include?(0) # => false Enumerable#member? is an alias for Enumerable#include?.;T;[o;= ;>I" overload;F;?0;;;@0;:I"include?(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@3;![;"I"@return [Boolean];T;#0;$@3;.F;Bi;C0;7[[I" object;T0;$@3;![;"@3;#0;$@3;.F;/o;0;1T;2i ;3i ;Bi;%@y,;9I"static VALUE enum_member(VALUE obj, VALUE val) { struct MEMO *memo = MEMO_NEW(val, Qfalse, 0); rb_block_call(obj, id_each, 0, 0, member_i, (VALUE)memo); return memo->v2; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#each_with_index;F;7[[@90;[[@,i ;T;:each_with_index;0;[;{;IC; ";With a block given, calls the block with each element and its index; returns +self+: h = {} (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 h # => {1=>0, 2=>1, 3=>2, 4=>3} h = {} %w[a b c d].each_with_index {|element, i| h[element] = i } # => ["a", "b", "c", "d"] h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} a = [] h = {foo: 0, bar: 1, baz: 2} h.each_with_index {|element, i| a.push([i, element]) } # => {:foo=>0, :bar=>1, :baz=>2} a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] With no block given, returns an Enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"each_with_index(*args);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;TI"i;T;$@3o;A ;>I" return;F;?I";T;0;@[I" self;T;$@3;![;"I"'@yield [element, i] @return [self];T;#0;$@3;.F;Bi;C0;7[[I" *args;T0;$@3o;= ;>I" overload;F;?0;;;@0;:I"each_with_index(*args);T;IC; ";T;[;![;"I";T;#0;$@3;.F;Bi;C0;7[[I" *args;T0;$@3;![;"I"With a block given, calls the block with each element and its index; returns +self+: h = {} (1..4).each_with_index {|element, i| h[element] = i } # => 1..4 h # => {1=>0, 2=>1, 3=>2, 4=>3} h = {} %w[a b c d].each_with_index {|element, i| h[element] = i } # => ["a", "b", "c", "d"] h # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3} a = [] h = {foo: 0, bar: 1, baz: 2} h.each_with_index {|element, i| a.push([i, element]) } # => {:foo=>0, :bar=>1, :baz=>2} a # => [[0, [:foo, 0]], [1, [:bar, 1]], [2, [:baz, 2]]] With no block given, returns an Enumerator. @overload each_with_index(*args) @yield [element, i] @return [self] @overload each_with_index(*args);T;#0;$@3;.F;/o;0;1T;2i ;3i ;%@y,;9I"static VALUE enum_each_with_index(int argc, VALUE *argv, VALUE obj) { struct MEMO *memo; RETURN_SIZED_ENUMERATOR(obj, argc, argv, enum_size); memo = MEMO_NEW(0, 0, 0); rb_block_call(obj, id_each, argc, argv, each_with_index_i, (VALUE)memo); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#reverse_each;F;7[[@90;[[@,i ;T;:reverse_each;0;[;{;IC; "With a block given, calls the block with each element, but in reverse order; returns +self+: a = [] (1..4).reverse_each {|element| a.push(-element) } # => 1..4 a # => [-4, -3, -2, -1] a = [] %w[a b c d].reverse_each {|element| a.push(element) } # => ["a", "b", "c", "d"] a # => ["d", "c", "b", "a"] a = [] h.reverse_each {|element| a.push(element) } # => {:foo=>0, :bar=>1, :baz=>2} a # => [[:baz, 2], [:bar, 1], [:foo, 0]] With no block given, returns an Enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"reverse_each(*args);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@4o;A ;>I" return;F;?I";T;0;@[I" self;T;$@4;![;"I"$@yield [element] @return [self];T;#0;$@4;.F;Bi;C0;7[[I" *args;T0;$@4o;= ;>I" overload;F;?0;;;@0;:I"reverse_each(*args);T;IC; ";T;[;![;"I";T;#0;$@4;.F;Bi;C0;7[[I" *args;T0;$@4;![;"I"PWith a block given, calls the block with each element, but in reverse order; returns +self+: a = [] (1..4).reverse_each {|element| a.push(-element) } # => 1..4 a # => [-4, -3, -2, -1] a = [] %w[a b c d].reverse_each {|element| a.push(element) } # => ["a", "b", "c", "d"] a # => ["d", "c", "b", "a"] a = [] h.reverse_each {|element| a.push(element) } # => {:foo=>0, :bar=>1, :baz=>2} a # => [[:baz, 2], [:bar, 1], [:foo, 0]] With no block given, returns an Enumerator. @overload reverse_each(*args) @yield [element] @return [self] @overload reverse_each(*args);T;#0;$@4;.F;/o;0;1T;2i ;3i ;%@y,;9I"static VALUE enum_reverse_each(int argc, VALUE *argv, VALUE obj) { VALUE ary; long len; RETURN_SIZED_ENUMERATOR(obj, argc, argv, enum_size); ary = enum_to_a(argc, argv, obj); len = RARRAY_LEN(ary); while (len--) { long nlen; rb_yield(RARRAY_AREF(ary, len)); nlen = RARRAY_LEN(ary); if (nlen < len) { len = nlen; } } return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#each_entry;F;7[[@90;[[@,iL ;T;:each_entry;0;[;{;IC; "HCalls the given block with each element, converting multiple values from yield to an array; returns +self+: a = [] (1..4).each_entry {|element| a.push(element) } # => 1..4 a # => [1, 2, 3, 4] a = [] h = {foo: 0, bar: 1, baz:2} h.each_entry {|element| a.push(element) } # => {:foo=>0, :bar=>1, :baz=>2} a # => [[:foo, 0], [:bar, 1], [:baz, 2]] class Foo include Enumerable def each yield 1 yield 1, 2 yield end end Foo.new.each_entry {|yielded| p yielded } Output: 1 [1, 2] nil With no block given, returns an Enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"each_entry(*args);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@L4o;A ;>I" return;F;?I";T;0;@[I" self;T;$@L4;![;"I"$@yield [element] @return [self];T;#0;$@L4;.F;Bi;C0;7[[I" *args;T0;$@L4o;= ;>I" overload;F;?0;;;@0;:I"each_entry(*args);T;IC; ";T;[;![;"I";T;#0;$@L4;.F;Bi;C0;7[[I" *args;T0;$@L4;![;"I"Calls the given block with each element, converting multiple values from yield to an array; returns +self+: a = [] (1..4).each_entry {|element| a.push(element) } # => 1..4 a # => [1, 2, 3, 4] a = [] h = {foo: 0, bar: 1, baz:2} h.each_entry {|element| a.push(element) } # => {:foo=>0, :bar=>1, :baz=>2} a # => [[:foo, 0], [:bar, 1], [:baz, 2]] class Foo include Enumerable def each yield 1 yield 1, 2 yield end end Foo.new.each_entry {|yielded| p yielded } Output: 1 [1, 2] nil With no block given, returns an Enumerator. @overload each_entry(*args) @yield [element] @return [self] @overload each_entry(*args);T;#0;$@L4;.F;/o;0;1T;2i& ;3iJ ;%@y,;9I"static VALUE enum_each_entry(int argc, VALUE *argv, VALUE obj) { RETURN_SIZED_ENUMERATOR(obj, argc, argv, enum_size); rb_block_call(obj, id_each, argc, argv, each_val_i, 0); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#each_slice;F;7[[I"n;T0;[[@,i ;T;:each_slice;0;[;{;IC; "Calls the block with each successive disjoint +n+-tuple of elements; returns +self+: a = [] (1..10).each_slice(3) {|tuple| a.push(tuple) } a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] a = [] h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} h.each_slice(2) {|tuple| a.push(tuple) } a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] With no block given, returns an Enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"each_slice(n);T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@y4o;A ;>I" return;F;?I";T;0;@[I" self;T;$@y4;![;"I"@yield [] @return [self];T;#0;$@y4;.F;Bi;C0;7[[I"n;T0;$@y4o;= ;>I" overload;F;?0;;;@0;:I"each_slice(n);T;IC; ";T;[;![;"I";T;#0;$@y4;.F;Bi;C0;7[[I"n;T0;$@y4;![;"I"Calls the block with each successive disjoint +n+-tuple of elements; returns +self+: a = [] (1..10).each_slice(3) {|tuple| a.push(tuple) } a # => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] a = [] h = {foo: 0, bar: 1, baz: 2, bat: 3, bam: 4} h.each_slice(2) {|tuple| a.push(tuple) } a # => [[[:foo, 0], [:bar, 1]], [[:baz, 2], [:bat, 3]], [[:bam, 4]]] With no block given, returns an Enumerator. @overload each_slice(n) @yield [] @return [self] @overload each_slice(n);T;#0;$@y4;.F;/o;0;1T;2i ;3i ;%@y,;9I">static VALUE enum_each_slice(VALUE obj, VALUE n) { long size = NUM2LONG(n); VALUE ary; struct MEMO *memo; int arity; if (size <= 0) rb_raise(rb_eArgError, "invalid slice size"); RETURN_SIZED_ENUMERATOR(obj, 1, &n, enum_each_slice_size); size = limit_by_enum_size(obj, size); ary = rb_ary_new2(size); arity = rb_block_arity(); memo = MEMO_NEW(ary, dont_recycle_block_arg(arity), size); rb_block_call(obj, id_each, 0, 0, each_slice_i, (VALUE)memo); ary = memo->v1; if (RARRAY_LEN(ary) > 0) rb_yield(ary); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#each_cons;F;7[[I"n;T0;[[@,i ;T;:each_cons;0;[;{;IC; "Calls the block with each successive overlapped +n+-tuple of elements; returns +self+: a = [] (1..5).each_cons(3) {|element| a.push(element) } a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] a = [] h = {foo: 0, bar: 1, baz: 2, bam: 3} h.each_cons(2) {|element| a.push(element) } a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] With no block given, returns an Enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"each_cons(n);T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@4o;A ;>I" return;F;?I";T;0;@[I" self;T;$@4;![;"I"@yield [] @return [self];T;#0;$@4;.F;Bi;C0;7[[I"n;T0;$@4o;= ;>I" overload;F;?0;;;@0;:I"each_cons(n);T;IC; ";T;[;![;"I";T;#0;$@4;.F;Bi;C0;7[[I"n;T0;$@4;![;"I"Calls the block with each successive overlapped +n+-tuple of elements; returns +self+: a = [] (1..5).each_cons(3) {|element| a.push(element) } a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] a = [] h = {foo: 0, bar: 1, baz: 2, bam: 3} h.each_cons(2) {|element| a.push(element) } a # => [[[:foo, 0], [:bar, 1]], [[:bar, 1], [:baz, 2]], [[:baz, 2], [:bam, 3]]] With no block given, returns an Enumerator. @overload each_cons(n) @yield [] @return [self] @overload each_cons(n);T;#0;$@4;.F;/o;0;1T;2i ;3i ;%@y,;9I"static VALUE enum_each_cons(VALUE obj, VALUE n) { long size = NUM2LONG(n); struct MEMO *memo; int arity; if (size <= 0) rb_raise(rb_eArgError, "invalid size"); RETURN_SIZED_ENUMERATOR(obj, 1, &n, enum_each_cons_size); arity = rb_block_arity(); if (enum_size_over_p(obj, size)) return obj; memo = MEMO_NEW(rb_ary_new2(size), dont_recycle_block_arg(arity), size); rb_block_call(obj, id_each, 0, 0, each_cons_i, (VALUE)memo); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Enumerable#each_with_object;F;7[[I" memo;T0;[[@,i ;T;:each_with_object;0;[;{;IC; "1Calls the block once for each element, passing both the element and the given object: (1..4).each_with_object([]) {|i, a| a.push(i**2) } # => [1, 4, 9, 16] h.each_with_object({}) {|element, h| k, v = *element; h[v] = k } # => {0=>:foo, 1=>:bar, 2=>:baz} With no block given, returns an Enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"each_with_object(object);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" (*args);TI"memo_object;T;$@4o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@4;![;"I"3@yield [(*args), memo_object] @return [Object];T;#0;$@4;.F;Bi;C0;7[[I" object;T0;$@4o;= ;>I" overload;F;?0;;;@0;:I"each_with_object(object);T;IC; ";T;[;![;"I";T;#0;$@4;.F;Bi;C0;7[[I" object;T0;$@4;![;"I"Calls the block once for each element, passing both the element and the given object: (1..4).each_with_object([]) {|i, a| a.push(i**2) } # => [1, 4, 9, 16] h.each_with_object({}) {|element, h| k, v = *element; h[v] = k } # => {0=>:foo, 1=>:bar, 2=>:baz} With no block given, returns an Enumerator. @overload each_with_object(object) @yield [(*args), memo_object] @return [Object] @overload each_with_object(object);T;#0;$@4;.F;/o;0;1T;2i ;3i ;%@y,;9I"static VALUE enum_each_with_object(VALUE obj, VALUE memo) { RETURN_SIZED_ENUMERATOR(obj, 1, &memo, enum_size); rb_block_call(obj, id_each, 0, 0, each_with_object_i, memo); return memo; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#zip;F;7[[@90;[[@,i ;T;:zip;0;[;{;IC; "With no block given, returns a new array +new_array+ of size self.size whose elements are arrays. Each nested array new_array[n] is of size other_enums.size+1, and contains: - The +n+-th element of self. - The +n+-th element of each of the +other_enums+. If all +other_enums+ and self are the same size, all elements are included in the result, and there is no +nil+-filling: a = [:a0, :a1, :a2, :a3] b = [:b0, :b1, :b2, :b3] c = [:c0, :c1, :c2, :c3] d = a.zip(b, c) d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] f = {foo: 0, bar: 1, baz: 2} g = {goo: 3, gar: 4, gaz: 5} h = {hoo: 6, har: 7, haz: 8} d = f.zip(g, h) d # => [ # [[:foo, 0], [:goo, 3], [:hoo, 6]], # [[:bar, 1], [:gar, 4], [:har, 7]], # [[:baz, 2], [:gaz, 5], [:haz, 8]] # ] If any enumerable in other_enums is smaller than self, fills to self.size with +nil+: a = [:a0, :a1, :a2, :a3] b = [:b0, :b1, :b2] c = [:c0, :c1] d = a.zip(b, c) d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] If any enumerable in other_enums is larger than self, its trailing elements are ignored: a = [:a0, :a1, :a2, :a3] b = [:b0, :b1, :b2, :b3, :b4] c = [:c0, :c1, :c2, :c3, :c4, :c5] d = a.zip(b, c) d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] When a block is given, calls the block with each of the sub-arrays (formed as above); returns nil: a = [:a0, :a1, :a2, :a3] b = [:b0, :b1, :b2, :b3] c = [:c0, :c1, :c2, :c3] a.zip(b, c) {|sub_array| p sub_array} # => nil Output: [:a0, :b0, :c0] [:a1, :b1, :c1] [:a2, :b2, :c2] [:a3, :b3, :c3] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"zip(*other_enums);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@5;![;"I"@return [Array];T;#0;$@5;.F;Bi;C0;7[[I"*other_enums;T0;$@5o;= ;>I" overload;F;?0;;;@0;:I"zip(*other_enums);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" array;T;$@5o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@5;![;"I"!@yield [array] @return [nil];T;#0;$@5;.F;Bi;C0;7[[I"*other_enums;T0;$@5;![;"I"With no block given, returns a new array +new_array+ of size self.size whose elements are arrays. Each nested array new_array[n] is of size other_enums.size+1, and contains: - The +n+-th element of self. - The +n+-th element of each of the +other_enums+. If all +other_enums+ and self are the same size, all elements are included in the result, and there is no +nil+-filling: a = [:a0, :a1, :a2, :a3] b = [:b0, :b1, :b2, :b3] c = [:c0, :c1, :c2, :c3] d = a.zip(b, c) d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] f = {foo: 0, bar: 1, baz: 2} g = {goo: 3, gar: 4, gaz: 5} h = {hoo: 6, har: 7, haz: 8} d = f.zip(g, h) d # => [ # [[:foo, 0], [:goo, 3], [:hoo, 6]], # [[:bar, 1], [:gar, 4], [:har, 7]], # [[:baz, 2], [:gaz, 5], [:haz, 8]] # ] If any enumerable in other_enums is smaller than self, fills to self.size with +nil+: a = [:a0, :a1, :a2, :a3] b = [:b0, :b1, :b2] c = [:c0, :c1] d = a.zip(b, c) d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] If any enumerable in other_enums is larger than self, its trailing elements are ignored: a = [:a0, :a1, :a2, :a3] b = [:b0, :b1, :b2, :b3, :b4] c = [:c0, :c1, :c2, :c3, :c4, :c5] d = a.zip(b, c) d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] When a block is given, calls the block with each of the sub-arrays (formed as above); returns nil: a = [:a0, :a1, :a2, :a3] b = [:b0, :b1, :b2, :b3] c = [:c0, :c1, :c2, :c3] a.zip(b, c) {|sub_array| p sub_array} # => nil Output: [:a0, :b0, :c0] [:a1, :b1, :c1] [:a2, :b2, :c2] [:a3, :b3, :c3] @overload zip(*other_enums) @return [Array] @overload zip(*other_enums) @yield [array] @return [nil];T;#0;$@5;.F;/o;0;1T;2i} ;3i ;%@y,;9I"static VALUE enum_zip(int argc, VALUE *argv, VALUE obj) { int i; ID conv; struct MEMO *memo; VALUE result = Qnil; VALUE args = rb_ary_new4(argc, argv); int allary = TRUE; argv = RARRAY_PTR(args); for (i=0; i [1, 2] r.take(0) # => [] h = {foo: 0, bar: 1, baz: 2, bat: 3} h.take(2) # => [[:foo, 0], [:bar, 1]] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" take(n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@25;![;"I"@return [Array];T;#0;$@25;.F;Bi;C0;7[[I"n;T0;$@25;![;"I"For non-negative integer +n+, returns the first +n+ elements: r = (1..4) r.take(2) # => [1, 2] r.take(0) # => [] h = {foo: 0, bar: 1, baz: 2, bat: 3} h.take(2) # => [[:foo, 0], [:bar, 1]] @overload take(n) @return [Array];T;#0;$@25;.F;/o;0;1T;2i ;3i ;%@y,;9I"static VALUE enum_take(VALUE obj, VALUE n) { struct MEMO *memo; VALUE result; long len = NUM2LONG(n); if (len < 0) { rb_raise(rb_eArgError, "attempt to take negative size"); } if (len == 0) return rb_ary_new2(0); result = rb_ary_new2(len); memo = MEMO_NEW(result, 0, len); rb_block_call(obj, id_each, 0, 0, take_i, (VALUE)memo); return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#take_while;F;7[;[[@,i/ ;T;:take_while;0;[;{;IC; "\Calls the block with successive elements as long as the block returns a truthy value; returns an array of all elements up to that point: (1..4).take_while{|i| i < 3 } # => [1, 2] h = {foo: 0, bar: 1, baz: 2} h.take_while{|element| key, value = *element; value < 2 } # => [[:foo, 0], [:bar, 1]] With no block given, returns an Enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"take_while;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@Q5o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@Q5;![;"I"%@yield [element] @return [Array];T;#0;$@Q5;.F;Bi;C0;7[;$@Q5o;= ;>I" overload;F;?0;;;@0;:I"take_while;T;IC; ";T;[;![;"I";T;#0;$@Q5;.F;Bi;C0;7[;$@Q5;![;"I"Calls the block with successive elements as long as the block returns a truthy value; returns an array of all elements up to that point: (1..4).take_while{|i| i < 3 } # => [1, 2] h = {foo: 0, bar: 1, baz: 2} h.take_while{|element| key, value = *element; value < 2 } # => [[:foo, 0], [:bar, 1]] With no block given, returns an Enumerator. @overload take_while @yield [element] @return [Array] @overload take_while;T;#0;$@Q5;.F;/o;0;1T;2i ;3i- ;%@y,;9I"static VALUE enum_take_while(VALUE obj) { VALUE ary; RETURN_ENUMERATOR(obj, 0, 0); ary = rb_ary_new(); rb_block_call(obj, id_each, 0, 0, take_while_i, ary); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#drop;F;7[[I"n;T0;[[@,iZ ;T;: drop;0;[;{;IC; "2For positive integer +n+, returns an array containing all but the first +n+ elements: r = (1..4) r.drop(3) # => [4] r.drop(2) # => [3, 4] r.drop(1) # => [2, 3, 4] r.drop(0) # => [1, 2, 3, 4] r.drop(50) # => [] h = {foo: 0, bar: 1, baz: 2, bat: 3} h.drop(2) # => [[:baz, 2], [:bat, 3]] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" drop(n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@y5;![;"I"@return [Array];T;#0;$@y5;.F;Bi;C0;7[[I"n;T0;$@y5;![;"I"YFor positive integer +n+, returns an array containing all but the first +n+ elements: r = (1..4) r.drop(3) # => [4] r.drop(2) # => [3, 4] r.drop(1) # => [2, 3, 4] r.drop(0) # => [1, 2, 3, 4] r.drop(50) # => [] h = {foo: 0, bar: 1, baz: 2, bat: 3} h.drop(2) # => [[:baz, 2], [:bat, 3]] @overload drop(n) @return [Array];T;#0;$@y5;.F;/o;0;1T;2iG ;3iW ;%@y,;9I"Wstatic VALUE enum_drop(VALUE obj, VALUE n) { VALUE result; struct MEMO *memo; long len = NUM2LONG(n); if (len < 0) { rb_raise(rb_eArgError, "attempt to drop negative size"); } result = rb_ary_new(); memo = MEMO_NEW(result, 0, len); rb_block_call(obj, id_each, 0, 0, drop_i, (VALUE)memo); return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#drop_while;F;7[;[[@,i ;T;:drop_while;0;[;{;IC; "WCalls the block with successive elements as long as the block returns a truthy value; returns an array of all elements after that point: (1..4).drop_while{|i| i < 3 } # => [3, 4] h = {foo: 0, bar: 1, baz: 2} a = h.drop_while{|element| key, value = *element; value < 2 } a # => [[:baz, 2]] With no block given, returns an Enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"drop_while;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@5o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@5;![;"I"%@yield [element] @return [Array];T;#0;$@5;.F;Bi;C0;7[;$@5o;= ;>I" overload;F;?0;;;@0;:I"drop_while;T;IC; ";T;[;![;"I";T;#0;$@5;.F;Bi;C0;7[;$@5;![;"I"Calls the block with successive elements as long as the block returns a truthy value; returns an array of all elements after that point: (1..4).drop_while{|i| i < 3 } # => [3, 4] h = {foo: 0, bar: 1, baz: 2} a = h.drop_while{|element| key, value = *element; value < 2 } a # => [[:baz, 2]] With no block given, returns an Enumerator. @overload drop_while @yield [element] @return [Array] @overload drop_while;T;#0;$@5;.F;/o;0;1T;2i{ ;3i ;%@y,;9I"static VALUE enum_drop_while(VALUE obj) { VALUE result; struct MEMO *memo; RETURN_ENUMERATOR(obj, 0, 0); result = rb_ary_new(); memo = MEMO_NEW(result, 0, FALSE); rb_block_call(obj, id_each, 0, 0, drop_while_i, (VALUE)memo); return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#cycle;F;7[[@90;[[@,i ;T;: cycle;0;[;{;IC; "When called with positive integer argument +n+ and a block, calls the block with each element, then does so again, until it has done so +n+ times; returns +nil+: a = [] (1..4).cycle(3) {|element| a.push(element) } # => nil a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] a = [] ('a'..'d').cycle(2) {|element| a.push(element) } a # => ["a", "b", "c", "d", "a", "b", "c", "d"] a = [] {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] If count is zero or negative, does not call the block. When called with a block and +n+ is +nil+, cycles forever. When no block is given, returns an Enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"cycle(n = nil);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@5o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@5;![;"I"#@yield [element] @return [nil];T;#0;$@5;.F;Bi;C0;7[[I"n;TI"nil;T;$@5o;= ;>I" overload;F;?0;;;@0;:I"cycle(n = nil);T;IC; ";T;[;![;"I";T;#0;$@5;.F;Bi;C0;7[[I"n;TI"nil;T;$@5;![;"I"When called with positive integer argument +n+ and a block, calls the block with each element, then does so again, until it has done so +n+ times; returns +nil+: a = [] (1..4).cycle(3) {|element| a.push(element) } # => nil a # => [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] a = [] ('a'..'d').cycle(2) {|element| a.push(element) } a # => ["a", "b", "c", "d", "a", "b", "c", "d"] a = [] {foo: 0, bar: 1, baz: 2}.cycle(2) {|element| a.push(element) } a # => [[:foo, 0], [:bar, 1], [:baz, 2], [:foo, 0], [:bar, 1], [:baz, 2]] If count is zero or negative, does not call the block. When called with a block and +n+ is +nil+, cycles forever. When no block is given, returns an Enumerator. @overload cycle(n = nil) @yield [element] @return [nil] @overload cycle(n = nil);T;#0;$@5;.F;/o;0;1T;2i ;3i ;%@y,;9I"static VALUE enum_cycle(int argc, VALUE *argv, VALUE obj) { VALUE ary; VALUE nv = Qnil; long n, i, len; rb_check_arity(argc, 0, 1); RETURN_SIZED_ENUMERATOR(obj, argc, argv, enum_cycle_size); if (!argc || NIL_P(nv = argv[0])) { n = -1; } else { n = NUM2LONG(nv); if (n <= 0) return Qnil; } ary = rb_ary_new(); RBASIC_CLEAR_CLASS(ary); rb_block_call(obj, id_each, 0, 0, cycle_i, ary); len = RARRAY_LEN(ary); if (len == 0) return Qnil; while (n < 0 || 0 < --n) { for (i=0; i # # The enumerator elements. e.next # => [0, [0, 1, 2]] e.next # => [1, [3, 4, 5]] e.next # => [2, [6, 7, 8]] e.next # => [3, [9, 10]] \Method +chunk+ is especially useful for an enumerable that is already sorted. This example counts words for each initial letter in a large array of words: # Get sorted words from a web page. url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' words = URI::open(url).readlines # Make chunks, one for each letter. e = words.chunk {|word| word.upcase[0] } # => # # Display 'A' through 'F'. e.each {|c, words| p [c, words.length]; break if c == 'F' } Output: ["A", 17096] ["B", 11070] ["C", 19901] ["D", 10896] ["E", 8736] ["F", 6860] You can use the special symbol :_alone to force an element into its own separate chuck: a = [0, 0, 1, 1] e = a.chunk{|i| i.even? ? :_alone : true } e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] For example, you can put each line that contains a URL into its own chunk: pattern = /http/ open(filename) { |f| f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| pp lines } } You can use the special symbol :_separator or +nil+ to force an element to be ignored (not included in any chunk): a = [0, 0, -1, 1, 1] e = a.chunk{|i| i < 0 ? :_separator : true } e.to_a # => [[true, [0, 0]], [true, [1, 1]]] Note that the separator does end the chunk: a = [0, 0, -1, 1, -1, 1] e = a.chunk{|i| i < 0 ? :_separator : true } e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] For example, the sequence of hyphens in svn log can be eliminated as follows: sep = "-"*72 + "\n" IO.popen("svn log README") { |f| f.chunk { |line| line != sep || nil }.each { |_, lines| pp lines } } #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", # "\n", # "* README, README.ja: Update the portability section.\n", # "\n"] # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", # "\n", # "* README, README.ja: Add a note about default C flags.\n", # "\n"] # ... Paragraphs separated by empty lines can be parsed as follows: File.foreach("README").chunk { |line| /\A\s*\z/ !~ line || nil }.each { |_, lines| pp lines } ;T;[o;= ;>I" overload;F;?0;;;@0;:I" chunk;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" array;T;$@5;![;"I"@yield [array];T;#0;$@5;.F;Bi;C0;7[;$@5;![;"I" Each element in the returned enumerator is a 2-element array consisting of: - A value returned by the block. - An array ("chunk") containing the element for which that value was returned, and all following elements for which the block returned the same value: So that: - Each block return value that is different from its predecessor begins a new chunk. - Each block return value that is the same as its predecessor continues the same chunk. Example: e = (0..10).chunk {|i| (i / 3).floor } # => # # The enumerator elements. e.next # => [0, [0, 1, 2]] e.next # => [1, [3, 4, 5]] e.next # => [2, [6, 7, 8]] e.next # => [3, [9, 10]] \Method +chunk+ is especially useful for an enumerable that is already sorted. This example counts words for each initial letter in a large array of words: # Get sorted words from a web page. url = 'https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt' words = URI::open(url).readlines # Make chunks, one for each letter. e = words.chunk {|word| word.upcase[0] } # => # # Display 'A' through 'F'. e.each {|c, words| p [c, words.length]; break if c == 'F' } Output: ["A", 17096] ["B", 11070] ["C", 19901] ["D", 10896] ["E", 8736] ["F", 6860] You can use the special symbol :_alone to force an element into its own separate chuck: a = [0, 0, 1, 1] e = a.chunk{|i| i.even? ? :_alone : true } e.to_a # => [[:_alone, [0]], [:_alone, [0]], [true, [1, 1]]] For example, you can put each line that contains a URL into its own chunk: pattern = /http/ open(filename) { |f| f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines| pp lines } } You can use the special symbol :_separator or +nil+ to force an element to be ignored (not included in any chunk): a = [0, 0, -1, 1, 1] e = a.chunk{|i| i < 0 ? :_separator : true } e.to_a # => [[true, [0, 0]], [true, [1, 1]]] Note that the separator does end the chunk: a = [0, 0, -1, 1, -1, 1] e = a.chunk{|i| i < 0 ? :_separator : true } e.to_a # => [[true, [0, 0]], [true, [1]], [true, [1]]] For example, the sequence of hyphens in svn log can be eliminated as follows: sep = "-"*72 + "\n" IO.popen("svn log README") { |f| f.chunk { |line| line != sep || nil }.each { |_, lines| pp lines } } #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n", # "\n", # "* README, README.ja: Update the portability section.\n", # "\n"] # ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n", # "\n", # "* README, README.ja: Add a note about default C flags.\n", # "\n"] # ... Paragraphs separated by empty lines can be parsed as follows: File.foreach("README").chunk { |line| /\A\s*\z/ !~ line || nil }.each { |_, lines| pp lines } @overload chunk @yield [array];T;#0;$@5;.F;/o;0;1T;2iC;3i;%@y,;9I"static VALUE enum_chunk(VALUE enumerable) { VALUE enumerator; RETURN_SIZED_ENUMERATOR(enumerable, 0, 0, enum_size); enumerator = rb_obj_alloc(rb_cEnumerator); rb_ivar_set(enumerator, id_chunk_enumerable, enumerable); rb_ivar_set(enumerator, id_chunk_categorize, rb_block_proc()); rb_block_call(enumerator, idInitialize, 0, 0, chunk_i, enumerator); return enumerator; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#slice_before;F;7[[@90;[[@,i;T;:slice_before;0;[;{;IC; ":With argument +pattern+, returns an enumerator that uses the pattern to partition elements into arrays ("slices"). An element begins a new slice if element === pattern (or if it is the first element). a = %w[foo bar fop for baz fob fog bam foy] e = a.slice_before(/ba/) # => # e.each {|array| p array } Output: ["foo"] ["bar", "fop", "for"] ["baz", "fob", "fog"] ["bam", "foy"] With a block, returns an enumerator that uses the block to partition elements into arrays. An element begins a new slice if its block return is a truthy value (or if it is the first element): e = (1..20).slice_before {|i| i % 4 == 2 } # => # e.each {|array| p array } Output: [1] [2, 3, 4, 5] [6, 7, 8, 9] [10, 11, 12, 13] [14, 15, 16, 17] [18, 19, 20] Other methods of the Enumerator class and Enumerable module, such as +to_a+, +map+, etc., are also usable. For example, iteration over ChangeLog entries can be implemented as follows: # iterate over ChangeLog entries. open("ChangeLog") { |f| f.slice_before(/\A\S/).each { |e| pp e } } # same as above. block is used instead of pattern argument. open("ChangeLog") { |f| f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } } "svn proplist -R" produces multiline output for each file. They can be chunked as follows: IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| f.lines.slice_before(/\AProp/).each { |lines| p lines } } #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] # ... If the block needs to maintain state over multiple elements, local variables can be used. For example, three or more consecutive increasing numbers can be squashed as follows (see +chunk_while+ for a better way): a = [0, 2, 3, 4, 6, 7, 9] prev = a[0] p a.slice_before { |e| prev, prev2 = e, prev prev2 + 1 != e }.map { |es| es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" }.join(",") #=> "0,2-4,6,7,9" However local variables should be used carefully if the result enumerator is enumerated twice or more. The local variables should be initialized for each enumeration. Enumerator.new can be used to do it. # Word wrapping. This assumes all characters have same width. def wordwrap(words, maxwidth) Enumerator.new {|y| # cols is initialized in Enumerator.new. cols = 0 words.slice_before { |w| cols += 1 if cols != 0 cols += w.length if maxwidth < cols cols = w.length true else false end }.each {|ws| y.yield ws } } end text = (1..20).to_a.join(" ") enum = wordwrap(text.split(/\s+/), 10) puts "-"*10 enum.each { |ws| puts ws.join(" ") } # first enumeration. puts "-"*10 enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. puts "-"*10 #=> ---------- # 1 2 3 4 5 # 6 7 8 9 10 # 11 12 13 # 14 15 16 # 17 18 19 # 20 # ---------- # 1 2 3 4 5 # 6 7 8 9 10 # 11 12 13 # 14 15 16 # 17 18 19 # 20 # ---------- mbox contains series of mails which start with Unix From line. So each mail can be extracted by slice before Unix From line. # parse mbox open("mbox") { |f| f.slice_before { |line| line.start_with? "From " }.each { |mail| unix_from = mail.shift i = mail.index("\n") header = mail[0...i] body = mail[(i+1)..-1] body.pop if body.last == "\n" fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a p unix_from pp fields pp body } } # split mails in mbox (slice before Unix From line after an empty line) open("mbox") { |f| emp = true f.slice_before { |line| prevemp = emp emp = line == "\n" prevemp && line.start_with?("From ") }.each { |mail| mail.pop if mail.last == "\n" pp mail } } ;T;[o;= ;>I" overload;F;?0;;;@0;:I"slice_before(pattern);T;IC; ";T;[;![;"I";T;#0;$@ 6;.F;Bi;C0;7[[I" pattern;T0;$@ 6o;= ;>I" overload;F;?0;;;@0;:I"slice_before;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" array;T;$@ 6;![;"I"@yield [array];T;#0;$@ 6;.F;Bi;C0;7[;$@ 6;![;"I"With argument +pattern+, returns an enumerator that uses the pattern to partition elements into arrays ("slices"). An element begins a new slice if element === pattern (or if it is the first element). a = %w[foo bar fop for baz fob fog bam foy] e = a.slice_before(/ba/) # => # e.each {|array| p array } Output: ["foo"] ["bar", "fop", "for"] ["baz", "fob", "fog"] ["bam", "foy"] With a block, returns an enumerator that uses the block to partition elements into arrays. An element begins a new slice if its block return is a truthy value (or if it is the first element): e = (1..20).slice_before {|i| i % 4 == 2 } # => # e.each {|array| p array } Output: [1] [2, 3, 4, 5] [6, 7, 8, 9] [10, 11, 12, 13] [14, 15, 16, 17] [18, 19, 20] Other methods of the Enumerator class and Enumerable module, such as +to_a+, +map+, etc., are also usable. For example, iteration over ChangeLog entries can be implemented as follows: # iterate over ChangeLog entries. open("ChangeLog") { |f| f.slice_before(/\A\S/).each { |e| pp e } } # same as above. block is used instead of pattern argument. open("ChangeLog") { |f| f.slice_before { |line| /\A\S/ === line }.each { |e| pp e } } "svn proplist -R" produces multiline output for each file. They can be chunked as follows: IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f| f.lines.slice_before(/\AProp/).each { |lines| p lines } } #=> ["Properties on '.':\n", " svn:ignore\n", " svk:merge\n"] # ["Properties on 'goruby.c':\n", " svn:eol-style\n"] # ["Properties on 'complex.c':\n", " svn:mime-type\n", " svn:eol-style\n"] # ["Properties on 'regparse.c':\n", " svn:eol-style\n"] # ... If the block needs to maintain state over multiple elements, local variables can be used. For example, three or more consecutive increasing numbers can be squashed as follows (see +chunk_while+ for a better way): a = [0, 2, 3, 4, 6, 7, 9] prev = a[0] p a.slice_before { |e| prev, prev2 = e, prev prev2 + 1 != e }.map { |es| es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}" }.join(",") #=> "0,2-4,6,7,9" However local variables should be used carefully if the result enumerator is enumerated twice or more. The local variables should be initialized for each enumeration. Enumerator.new can be used to do it. # Word wrapping. This assumes all characters have same width. def wordwrap(words, maxwidth) Enumerator.new {|y| # cols is initialized in Enumerator.new. cols = 0 words.slice_before { |w| cols += 1 if cols != 0 cols += w.length if maxwidth < cols cols = w.length true else false end }.each {|ws| y.yield ws } } end text = (1..20).to_a.join(" ") enum = wordwrap(text.split(/\s+/), 10) puts "-"*10 enum.each { |ws| puts ws.join(" ") } # first enumeration. puts "-"*10 enum.each { |ws| puts ws.join(" ") } # second enumeration generates same result as the first. puts "-"*10 #=> ---------- # 1 2 3 4 5 # 6 7 8 9 10 # 11 12 13 # 14 15 16 # 17 18 19 # 20 # ---------- # 1 2 3 4 5 # 6 7 8 9 10 # 11 12 13 # 14 15 16 # 17 18 19 # 20 # ---------- mbox contains series of mails which start with Unix From line. So each mail can be extracted by slice before Unix From line. # parse mbox open("mbox") { |f| f.slice_before { |line| line.start_with? "From " }.each { |mail| unix_from = mail.shift i = mail.index("\n") header = mail[0...i] body = mail[(i+1)..-1] body.pop if body.last == "\n" fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a p unix_from pp fields pp body } } # split mails in mbox (slice before Unix From line after an empty line) open("mbox") { |f| emp = true f.slice_before { |line| prevemp = emp emp = line == "\n" prevemp && line.start_with?("From ") }.each { |mail| mail.pop if mail.last == "\n" pp mail } } @overload slice_before(pattern) @overload slice_before @yield [array];T;#0;$@ 6;.F;/o;0;1T;2i;3i;%@y,;9I"static VALUE enum_slice_before(int argc, VALUE *argv, VALUE enumerable) { VALUE enumerator; if (rb_block_given_p()) { if (argc != 0) rb_error_arity(argc, 0, 0); enumerator = rb_obj_alloc(rb_cEnumerator); rb_ivar_set(enumerator, id_slicebefore_sep_pred, rb_block_proc()); } else { VALUE sep_pat; rb_scan_args(argc, argv, "1", &sep_pat); enumerator = rb_obj_alloc(rb_cEnumerator); rb_ivar_set(enumerator, id_slicebefore_sep_pat, sep_pat); } rb_ivar_set(enumerator, id_slicebefore_enumerable, enumerable); rb_block_call(enumerator, idInitialize, 0, 0, slicebefore_i, enumerator); return enumerator; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#slice_after;F;7[[@90;[[@,i;T;:slice_after;0;[;{;IC; "With argument +pattern+, returns an enumerator that uses the pattern to partition elements into arrays ("slices"). An element ends the current slice if element === pattern: a = %w[foo bar fop for baz fob fog bam foy] e = a.slice_after(/ba/) # => # e.each {|array| p array } Output: ["foo", "bar"] ["fop", "for", "baz"] ["fob", "fog", "bam"] ["foy"] With a block, returns an enumerator that uses the block to partition elements into arrays. An element ends the current slice if its block return is a truthy value: e = (1..20).slice_after {|i| i % 4 == 2 } # => # e.each {|array| p array } Output: [1, 2] [3, 4, 5, 6] [7, 8, 9, 10] [11, 12, 13, 14] [15, 16, 17, 18] [19, 20] Other methods of the Enumerator class and Enumerable module, such as +map+, etc., are also usable. For example, continuation lines (lines end with backslash) can be concatenated as follows: lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } #=>["foo\n", "barbaz\n", "\n", "qux\n"] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"slice_after(pattern);T;IC; ";T;[;![;"I";T;#0;$@06;.F;Bi;C0;7[[I" pattern;T0;$@06o;= ;>I" overload;F;?0;;;@0;:I"slice_after;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" array;T;$@06;![;"I"@yield [array];T;#0;$@06;.F;Bi;C0;7[;$@06;![;"I"With argument +pattern+, returns an enumerator that uses the pattern to partition elements into arrays ("slices"). An element ends the current slice if element === pattern: a = %w[foo bar fop for baz fob fog bam foy] e = a.slice_after(/ba/) # => # e.each {|array| p array } Output: ["foo", "bar"] ["fop", "for", "baz"] ["fob", "fog", "bam"] ["foy"] With a block, returns an enumerator that uses the block to partition elements into arrays. An element ends the current slice if its block return is a truthy value: e = (1..20).slice_after {|i| i % 4 == 2 } # => # e.each {|array| p array } Output: [1, 2] [3, 4, 5, 6] [7, 8, 9, 10] [11, 12, 13, 14] [15, 16, 17, 18] [19, 20] Other methods of the Enumerator class and Enumerable module, such as +map+, etc., are also usable. For example, continuation lines (lines end with backslash) can be concatenated as follows: lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"] e = lines.slice_after(/(? [["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]] p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last } #=>["foo\n", "barbaz\n", "\n", "qux\n"] @overload slice_after(pattern) @overload slice_after @yield [array];T;#0;$@06;.F;/o;0;1T;2i;3i;%@y,;9I"static VALUE enum_slice_after(int argc, VALUE *argv, VALUE enumerable) { VALUE enumerator; VALUE pat = Qnil, pred = Qnil; if (rb_block_given_p()) { if (0 < argc) rb_raise(rb_eArgError, "both pattern and block are given"); pred = rb_block_proc(); } else { rb_scan_args(argc, argv, "1", &pat); } enumerator = rb_obj_alloc(rb_cEnumerator); rb_ivar_set(enumerator, id_sliceafter_enum, enumerable); rb_ivar_set(enumerator, id_sliceafter_pat, pat); rb_ivar_set(enumerator, id_sliceafter_pred, pred); rb_block_call(enumerator, idInitialize, 0, 0, sliceafter_i, enumerator); return enumerator; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#slice_when;F;7[;[[@,i;T;:slice_when;0;[;{;IC; "_The returned enumerator uses the block to partition elements into arrays ("slices"); it calls the block with each element and its successor; begins a new slice if and only if the block returns a truthy value: a = [0, 1, 2, 4, 5, 6, 8, 9] e = a.slice_when {|i, j| j != i + 1 } e.each {|array| p array } Output: [0, 1, 2] [4, 5, 6] [8, 9] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"slice_when;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;TI"next_element;T;$@V6;![;"I"#@yield [element, next_element];T;#0;$@V6;.F;Bi;C0;7[;$@V6;![;"I"The returned enumerator uses the block to partition elements into arrays ("slices"); it calls the block with each element and its successor; begins a new slice if and only if the block returns a truthy value: a = [0, 1, 2, 4, 5, 6, 8, 9] e = a.slice_when {|i, j| j != i + 1 } e.each {|array| p array } Output: [0, 1, 2] [4, 5, 6] [8, 9] @overload slice_when @yield [element, next_element];T;#0;$@V6;.F;/o;0;1T;2ix;3i;%@y,;9I"static VALUE enum_slice_when(VALUE enumerable) { VALUE enumerator; VALUE pred; pred = rb_block_proc(); enumerator = rb_obj_alloc(rb_cEnumerator); rb_ivar_set(enumerator, id_slicewhen_enum, enumerable); rb_ivar_set(enumerator, id_slicewhen_pred, pred); rb_ivar_set(enumerator, id_slicewhen_inverted, Qfalse); rb_block_call(enumerator, idInitialize, 0, 0, slicewhen_i, enumerator); return enumerator; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#chunk_while;F;7[;[[@,i;T;:chunk_while;0;[;{;IC; "The returned Enumerator uses the block to partition elements into arrays ("chunks"); it calls the block with each element and its successor; begins a new chunk if and only if the block returns a truthy value: Example: a = [1, 2, 4, 9, 10, 11, 12, 15, 16, 19, 20, 21] e = a.chunk_while {|i, j| j == i + 1 } e.each {|array| p array } Output: [1, 2] [4] [9, 10, 11, 12] [15, 16] [19, 20, 21] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"chunk_while;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;TI"next_element;T;$@r6;![;"I"#@yield [element, next_element];T;#0;$@r6;.F;Bi;C0;7[;$@r6;![;"I"The returned Enumerator uses the block to partition elements into arrays ("chunks"); it calls the block with each element and its successor; begins a new chunk if and only if the block returns a truthy value: Example: a = [1, 2, 4, 9, 10, 11, 12, 15, 16, 19, 20, 21] e = a.chunk_while {|i, j| j == i + 1 } e.each {|array| p array } Output: [1, 2] [4] [9, 10, 11, 12] [15, 16] [19, 20, 21] @overload chunk_while @yield [element, next_element];T;#0;$@r6;.F;/o;0;1T;2i;3i;%@y,;9I"static VALUE enum_chunk_while(VALUE enumerable) { VALUE enumerator; VALUE pred; pred = rb_block_proc(); enumerator = rb_obj_alloc(rb_cEnumerator); rb_ivar_set(enumerator, id_slicewhen_enum, enumerable); rb_ivar_set(enumerator, id_slicewhen_pred, pred); rb_ivar_set(enumerator, id_slicewhen_inverted, Qtrue); rb_block_call(enumerator, idInitialize, 0, 0, slicewhen_i, enumerator); return enumerator; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#sum;F;7[[@90;[[@,i;T;:sum;0;[;{;IC; "With no block given, returns the sum of +initial_value+ and the elements: (1..100).sum # => 5050 (1..100).sum(1) # => 5051 ('a'..'d').sum('foo') # => "fooabcd" Generally, the sum is computed using methods + and +each+; for performance optimizations, those methods may not be used, and so any redefinition of those methods may not have effect here. One such optimization: When possible, computes using Gauss's summation formula n(n+1)/2: 100 * (100 + 1) / 2 # => 5050 With a block given, calls the block with each element; returns the sum of +initial_value+ and the block return values: (1..4).sum {|i| i*i } # => 30 (1..4).sum(100) {|i| i*i } # => 130 h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} h.sum {|key, value| value.odd? ? value : 0 } # => 9 ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"sum(initial_value = 0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@6;![;"I"@return [Numeric];T;#0;$@6;.F;Bi;C0;7[[I"initial_value;TI"0;T;$@6o;= ;>I" overload;F;?0;;;@0;:I"sum(initial_value = 0);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@6o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@6;![;"I"&@yield [element] @return [Object];T;#0;$@6;.F;Bi;C0;7[[I"initial_value;TI"0;T;$@6;![;"I"With no block given, returns the sum of +initial_value+ and the elements: (1..100).sum # => 5050 (1..100).sum(1) # => 5051 ('a'..'d').sum('foo') # => "fooabcd" Generally, the sum is computed using methods + and +each+; for performance optimizations, those methods may not be used, and so any redefinition of those methods may not have effect here. One such optimization: When possible, computes using Gauss's summation formula n(n+1)/2: 100 * (100 + 1) / 2 # => 5050 With a block given, calls the block with each element; returns the sum of +initial_value+ and the block return values: (1..4).sum {|i| i*i } # => 30 (1..4).sum(100) {|i| i*i } # => 130 h = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5} h.sum {|key, value| value.odd? ? value : 0 } # => 9 ('a'..'f').sum('x') {|c| c < 'd' ? c : '' } # => "xabc" @overload sum(initial_value = 0) @return [Numeric] @overload sum(initial_value = 0) @yield [element] @return [Object];T;#0;$@6;.F;/o;0;1T;2i;3i;%@y,;9I"static VALUE enum_sum(int argc, VALUE* argv, VALUE obj) { struct enum_sum_memo memo; VALUE beg, end; int excl; memo.v = (rb_check_arity(argc, 0, 1) == 0) ? LONG2FIX(0) : argv[0]; memo.block_given = rb_block_given_p(); memo.n = 0; memo.r = Qundef; if ((memo.float_value = RB_FLOAT_TYPE_P(memo.v))) { memo.f = RFLOAT_VALUE(memo.v); memo.c = 0.0; } else { memo.f = 0.0; memo.c = 0.0; } if (RTEST(rb_range_values(obj, &beg, &end, &excl))) { if (!memo.block_given && !memo.float_value && (FIXNUM_P(beg) || RB_BIGNUM_TYPE_P(beg)) && (FIXNUM_P(end) || RB_BIGNUM_TYPE_P(end))) { return int_range_sum(beg, end, excl, memo.v); } } if (RB_TYPE_P(obj, T_HASH) && rb_method_basic_definition_p(CLASS_OF(obj), id_each)) hash_sum(obj, &memo); else rb_block_call(obj, id_each, 0, 0, enum_sum_i, (VALUE)&memo); if (memo.float_value) { return DBL2NUM(memo.f + memo.c); } else { if (memo.n != 0) memo.v = rb_fix_plus(LONG2FIX(memo.n), memo.v); if (memo.r != Qundef) { memo.v = rb_rational_plus(memo.r, memo.v); } return memo.v; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#uniq;F;7[;[[@,i;T;: uniq;0;[;{;IC; " With no block, returns a new array containing only unique elements; the array has no two elements +e0+ and +e1+ such that e0.eql?(e1): %w[a b c c b a a b c].uniq # => ["a", "b", "c"] [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] With a block, returns a new array containing only for which the block returns a unique value: a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] a = %w[a b c d e e d c b a a b c d e] a.uniq {|c| c < 'c' } # => ["a", "c"] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" uniq;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@6;![;"I"@return [Array];T;#0;$@6;.F;Bi;C0;7[;$@6o;= ;>I" overload;F;?0;;;@0;:I" uniq;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@6o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@6;![;"I"%@yield [element] @return [Array];T;#0;$@6;.F;Bi;C0;7[;$@6;![;"I"cWith no block, returns a new array containing only unique elements; the array has no two elements +e0+ and +e1+ such that e0.eql?(e1): %w[a b c c b a a b c].uniq # => ["a", "b", "c"] [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2] With a block, returns a new array containing only for which the block returns a unique value: a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1] a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4] a = %w[a b c d e e d c b a a b c d e] a.uniq {|c| c < 'c' } # => ["a", "c"] @overload uniq @return [Array] @overload uniq @yield [element] @return [Array];T;#0;$@6;.F;/o;0;1T;2i;3i;%@y,;9I"0static VALUE enum_uniq(VALUE obj) { VALUE hash, ret; rb_block_call_func *const func = rb_block_given_p() ? uniq_iter : uniq_func; hash = rb_obj_hide(rb_hash_new()); rb_block_call(obj, id_each, 0, 0, func, hash); ret = rb_hash_values(hash); rb_hash_clear(hash); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerable#compact;F;7[;[[@,i;T;: compact;0;[;{;IC; "Returns an array of all non-+nil+ elements: a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] a.compact # => [0, "a", false, false, "a", 0] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" compact;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@6;![;"I"@return [Array];T;#0;$@6;.F;Bi;C0;7[;$@6;![;"I"Returns an array of all non-+nil+ elements: a = [nil, 0, nil, 'a', false, nil, false, nil, 'a', nil, 0, nil] a.compact # => [0, "a", false, false, "a", 0] @overload compact @return [Array];T;#0;$@6;.F;/o;0;1T;2i;3i;%@y,;9I"static VALUE enum_compact(VALUE obj) { VALUE ary; ary = rb_ary_new(); rb_block_call(obj, id_each, 0, 0, compact_i, ary); return ary; };T;:I"static VALUE;T;;T; @y,; IC;[; @y,; IC;[; @y,; IC;{;IC;{;T;IC;{;T;T;{;[;[[@,i;F;:Enumerable;;;;;[;{;IC; "== What's Here \Module \Enumerable provides methods that are useful to a collection class for: - {Querying}[#module-Enumerable-label-Methods+for+Querying] - {Fetching}[#module-Enumerable-label-Methods+for+Fetching] - {Searching}[#module-Enumerable-label-Methods+for+Searching] - {Sorting}[#module-Enumerable-label-Methods+for+Sorting] - {Iterating}[#module-Enumerable-label-Methods+for+Iterating] - {And more....}[#module-Enumerable-label-Other+Methods] === Methods for Querying These methods return information about the \Enumerable other than the elements themselves: #include?, #member?:: Returns +true+ if self == object, +false+ otherwise. #all?:: Returns +true+ if all elements meet a specified criterion; +false+ otherwise. #any?:: Returns +true+ if any element meets a specified criterion; +false+ otherwise. #none?:: Returns +true+ if no element meets a specified criterion; +false+ otherwise. #one?:: Returns +true+ if exactly one element meets a specified criterion; +false+ otherwise. #count:: Returns the count of elements, based on an argument or block criterion, if given. #tally:: Returns a new \Hash containing the counts of occurrences of each element. === Methods for Fetching These methods return entries from the \Enumerable, without modifying it: Leading, trailing, or all elements: #entries, #to_a:: Returns all elements. #first:: Returns the first element or leading elements. #take:: Returns a specified number of leading elements. #drop:: Returns a specified number of trailing elements. #take_while:: Returns leading elements as specified by the given block. #drop_while:: Returns trailing elements as specified by the given block. Minimum and maximum value elements: #min:: Returns the elements whose values are smallest among the elements, as determined by <=> or a given block. #max:: Returns the elements whose values are largest among the elements, as determined by <=> or a given block. #minmax:: Returns a 2-element \Array containing the smallest and largest elements. #min_by:: Returns the smallest element, as determined by the given block. #max_by:: Returns the largest element, as determined by the given block. #minmax_by:: Returns the smallest and largest elements, as determined by the given block. Groups, slices, and partitions: #group_by:: Returns a \Hash that partitions the elements into groups. #partition:: Returns elements partitioned into two new Arrays, as determined by the given block. #slice_after:: Returns a new \Enumerator whose entries are a partition of +self+, based either on a given +object+ or a given block. #slice_before:: Returns a new \Enumerator whose entries are a partition of +self+, based either on a given +object+ or a given block. #slice_when:: Returns a new \Enumerator whose entries are a partition of +self+ based on the given block. #chunk:: Returns elements organized into chunks as specified by the given block. #chunk_while:: Returns elements organized into chunks as specified by the given block. === Methods for Searching and Filtering These methods return elements that meet a specified criterion. #find, #detect:: Returns an element selected by the block. #find_all, #filter, #select:: Returns elements selected by the block. #find_index:: Returns the index of an element selected by a given object or block. #reject:: Returns elements not rejected by the block. #uniq:: Returns elements that are not duplicates. === Methods for Sorting These methods return elements in sorted order. #sort:: Returns the elements, sorted by <=> or the given block. #sort_by:: Returns the elements, sorted by the given block. === Methods for Iterating #each_entry:: Calls the block with each successive element (slightly different from #each). #each_with_index:: Calls the block with each successive element and its index. #each_with_object:: Calls the block with each successive element and a given object. #each_slice:: Calls the block with successive non-overlapping slices. #each_cons:: Calls the block with successive overlapping slices. (different from #each_slice). #reverse_each:: Calls the block with each successive element, in reverse order. === Other Methods #map, #collect:: Returns objects returned by the block. #filter_map:: Returns truthy objects returned by the block. #flat_map, #collect_concat:: Returns flattened objects returned by the block. #grep:: Returns elements selected by a given object or objects returned by a given block. #grep_v:: Returns elements selected by a given object or objects returned by a given block. #reduce, #inject:: Returns the object formed by combining all elements. #sum:: Returns the sum of the elements, using method +++. #zip:: Combines each element with elements from other enumerables; returns the n-tuples or calls the block with each. #cycle:: Calls the block with each element, cycling repeatedly. == Usage To use module \Enumerable in a collection class: - Include it: include Enumerable - Implement method #each which must yield successive elements of the collection. The method will be called by almost any \Enumerable method. Example: class Foo include Enumerable def each yield 1 yield 1, 2 yield end end Foo.new.each_entry{ |element| p element } Output: 1 [1, 2] nil == \Enumerable in Ruby Core Classes Some Ruby classes include \Enumerable: - Array - Dir - Hash - IO - Range - Set - Struct Virtually all methods in \Enumerable call method +#each+ in the including class: - Hash#each yields the next key-value pair as a 2-element \Array. - Struct#each yields the next name-value pair as a 2-element \Array. - For the other classes above, +#each+ yields the next object from the collection. == About the Examples The example code snippets for the \Enumerable methods: - Always show the use of one or more \Array-like classes (often \Array itself). - Sometimes show the use of a \Hash-like class. For some methods, though, the usage would not make sense, and so it is not shown. Example: #tally would find exactly one of each \Hash entry. ;T;[;![;"I"== What's Here \Module \Enumerable provides methods that are useful to a collection class for: - {Querying}[#module-Enumerable-label-Methods+for+Querying] - {Fetching}[#module-Enumerable-label-Methods+for+Fetching] - {Searching}[#module-Enumerable-label-Methods+for+Searching] - {Sorting}[#module-Enumerable-label-Methods+for+Sorting] - {Iterating}[#module-Enumerable-label-Methods+for+Iterating] - {And more....}[#module-Enumerable-label-Other+Methods] === Methods for Querying These methods return information about the \Enumerable other than the elements themselves: #include?, #member?:: Returns +true+ if self == object, +false+ otherwise. #all?:: Returns +true+ if all elements meet a specified criterion; +false+ otherwise. #any?:: Returns +true+ if any element meets a specified criterion; +false+ otherwise. #none?:: Returns +true+ if no element meets a specified criterion; +false+ otherwise. #one?:: Returns +true+ if exactly one element meets a specified criterion; +false+ otherwise. #count:: Returns the count of elements, based on an argument or block criterion, if given. #tally:: Returns a new \Hash containing the counts of occurrences of each element. === Methods for Fetching These methods return entries from the \Enumerable, without modifying it: Leading, trailing, or all elements: #entries, #to_a:: Returns all elements. #first:: Returns the first element or leading elements. #take:: Returns a specified number of leading elements. #drop:: Returns a specified number of trailing elements. #take_while:: Returns leading elements as specified by the given block. #drop_while:: Returns trailing elements as specified by the given block. Minimum and maximum value elements: #min:: Returns the elements whose values are smallest among the elements, as determined by <=> or a given block. #max:: Returns the elements whose values are largest among the elements, as determined by <=> or a given block. #minmax:: Returns a 2-element \Array containing the smallest and largest elements. #min_by:: Returns the smallest element, as determined by the given block. #max_by:: Returns the largest element, as determined by the given block. #minmax_by:: Returns the smallest and largest elements, as determined by the given block. Groups, slices, and partitions: #group_by:: Returns a \Hash that partitions the elements into groups. #partition:: Returns elements partitioned into two new Arrays, as determined by the given block. #slice_after:: Returns a new \Enumerator whose entries are a partition of +self+, based either on a given +object+ or a given block. #slice_before:: Returns a new \Enumerator whose entries are a partition of +self+, based either on a given +object+ or a given block. #slice_when:: Returns a new \Enumerator whose entries are a partition of +self+ based on the given block. #chunk:: Returns elements organized into chunks as specified by the given block. #chunk_while:: Returns elements organized into chunks as specified by the given block. === Methods for Searching and Filtering These methods return elements that meet a specified criterion. #find, #detect:: Returns an element selected by the block. #find_all, #filter, #select:: Returns elements selected by the block. #find_index:: Returns the index of an element selected by a given object or block. #reject:: Returns elements not rejected by the block. #uniq:: Returns elements that are not duplicates. === Methods for Sorting These methods return elements in sorted order. #sort:: Returns the elements, sorted by <=> or the given block. #sort_by:: Returns the elements, sorted by the given block. === Methods for Iterating #each_entry:: Calls the block with each successive element (slightly different from #each). #each_with_index:: Calls the block with each successive element and its index. #each_with_object:: Calls the block with each successive element and a given object. #each_slice:: Calls the block with successive non-overlapping slices. #each_cons:: Calls the block with successive overlapping slices. (different from #each_slice). #reverse_each:: Calls the block with each successive element, in reverse order. === Other Methods #map, #collect:: Returns objects returned by the block. #filter_map:: Returns truthy objects returned by the block. #flat_map, #collect_concat:: Returns flattened objects returned by the block. #grep:: Returns elements selected by a given object or objects returned by a given block. #grep_v:: Returns elements selected by a given object or objects returned by a given block. #reduce, #inject:: Returns the object formed by combining all elements. #sum:: Returns the sum of the elements, using method +++. #zip:: Combines each element with elements from other enumerables; returns the n-tuples or calls the block with each. #cycle:: Calls the block with each element, cycling repeatedly. == Usage To use module \Enumerable in a collection class: - Include it: include Enumerable - Implement method #each which must yield successive elements of the collection. The method will be called by almost any \Enumerable method. Example: class Foo include Enumerable def each yield 1 yield 1, 2 yield end end Foo.new.each_entry{ |element| p element } Output: 1 [1, 2] nil == \Enumerable in Ruby Core Classes Some Ruby classes include \Enumerable: - Array - Dir - Hash - IO - Range - Set - Struct Virtually all methods in \Enumerable call method +#each+ in the including class: - Hash#each yields the next key-value pair as a 2-element \Array. - Struct#each yields the next name-value pair as a 2-element \Array. - For the other classes above, +#each+ yields the next object from the collection. == About the Examples The example code snippets for the \Enumerable methods: - Always show the use of one or more \Array-like classes (often \Array itself). - Sometimes show the use of a \Hash-like class. For some methods, though, the usage would not make sense, and so it is not shown. Example: #tally would find exactly one of each \Hash entry. ;T;#0;$@y,;.F;/o;0;1T;2i);3i;%@;&I"Enumerable;F; @+; IC;{;IC;{;T;IC;{;T;T;{;[;[[@?i4[@?i5;T;: WeakMap;;;;;[;{;IC; "An ObjectSpace::WeakMap object holds references to any objects, but those objects can get garbage collected. This class is mostly used internally by WeakRef, please use +lib/weakref.rb+ for the public interface. ;T;[;![;"I" An ObjectSpace::WeakMap object holds references to any objects, but those objects can get garbage collected. This class is mostly used internally by WeakRef, please use +lib/weakref.rb+ for the public interface. ;T;#0;$@+;.F;/o;0;1T;2i4;3i4;%@&;&I"ObjectSpace::WeakMap;F;'@; @&; IC;[; @&; IC;[; @&; IC;{;IC;{;T;IC;{;T;T;{;[;[ [@P(i[@&i4[@P(i[@*i[@?i4[@?i4;T;:ObjectSpace;;;;;[;{;IC; "The ObjectSpace module contains a number of routines that interact with the garbage collection facility and allow you to traverse all living objects with an iterator. ObjectSpace also provides support for object finalizers, procs that will be called when a specific object is about to be destroyed by garbage collection. See the documentation for ObjectSpace.define_finalizer for important information on how to use this method correctly. a = "A" b = "B" ObjectSpace.define_finalizer(a, proc {|id| puts "Finalizer one on #{id}" }) ObjectSpace.define_finalizer(b, proc {|id| puts "Finalizer two on #{id}" }) a = nil b = nil _produces:_ Finalizer two on 537763470 Finalizer one on 537763480;T;[;![;"I" The ObjectSpace module contains a number of routines that interact with the garbage collection facility and allow you to traverse all living objects with an iterator. ObjectSpace also provides support for object finalizers, procs that will be called when a specific object is about to be destroyed by garbage collection. See the documentation for ObjectSpace.define_finalizer for important information on how to use this method correctly. a = "A" b = "B" ObjectSpace.define_finalizer(a, proc {|id| puts "Finalizer one on #{id}" }) ObjectSpace.define_finalizer(b, proc {|id| puts "Finalizer two on #{id}" }) a = nil b = nil _produces:_ Finalizer two on 537763470 Finalizer one on 537763480 ;T;#0;$@&;.F;/o;0;1T;2i4;3i4;Bi;%@;&I"ObjectSpace;F@ho; ;IC;[Uo;4;5F;6;;;;&I"Module#include;F;7[[@90;[[@Oib;T;: include;0;[;{;IC; "GInvokes Module.append_features on each parameter in reverse order. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"include(module, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@C7;![;"I"@return [self];T;#0;$@C7;.F;Bi;C0;7[;$@C7;![;"I"yInvokes Module.append_features on each parameter in reverse order. @overload include(module, ...) @return [self];T;#0;$@C7;.F;/o;0;1T;2i[;3i_;%@A7;9I"`static VALUE rb_mod_include(int argc, VALUE *argv, VALUE module) { int i; ID id_append_features, id_included; CONST_ID(id_append_features, "append_features"); CONST_ID(id_included, "included"); if (FL_TEST(module, RMODULE_IS_REFINEMENT)) { rb_warn_deprecated_to_remove_at(3.2, "Refinement#include", NULL); } 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_append_features, 1, module); rb_funcall(argv[argc], id_included, 1, module); } return module; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#prepend;F;7[[@90;[[@Oi;T;: prepend;0;[;{;IC; "HInvokes Module.prepend_features on each parameter in reverse order. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"prepend(module, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@_7;![;"I"@return [self];T;#0;$@_7;.F;Bi;C0;7[;$@_7;![;"I"zInvokes Module.prepend_features on each parameter in reverse order. @overload prepend(module, ...) @return [self];T;#0;$@_7;.F;/o;0;1T;2i;3i;%@A7;9I"hstatic VALUE rb_mod_prepend(int argc, VALUE *argv, VALUE module) { int i; ID id_prepend_features, id_prepended; if (FL_TEST(module, RMODULE_IS_REFINEMENT)) { rb_warn_deprecated_to_remove_at(3.2, "Refinement#prepend", NULL); } CONST_ID(id_prepend_features, "prepend_features"); CONST_ID(id_prepended, "prepended"); 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_prepend_features, 1, module); rb_funcall(argv[argc], id_prepended, 1, module); } return module; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#append_features;F;7[[I" include;T0;[[@OiP;T;:append_features;0;[;{;IC; "PWhen this module is included in another, Ruby calls #append_features in this module, passing it the receiving module in _mod_. Ruby's default implementation is to add the constants, methods, and module variables of this module to _mod_ if this module has not already been added to _mod_ or one of its ancestors. See also Module#include. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"append_features(mod);T;IC; ";T;[;![;"I";T;#0;$@{7;.F;Bi;C0;7[[I"mod;T0;$@{7;![;"I"qWhen this module is included in another, Ruby calls #append_features in this module, passing it the receiving module in _mod_. Ruby's default implementation is to add the constants, methods, and module variables of this module to _mod_ if this module has not already been added to _mod_ or one of its ancestors. See also Module#include. @overload append_features(mod);T;#0;$@{7;.F;/o;0;1T;2iD;3iL;%@A7;9I"static VALUE rb_mod_append_features(VALUE module, VALUE include) { if (!CLASS_OR_MODULE_P(include)) { Check_Type(include, T_CLASS); } rb_include_module(include, module); return module; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#extend_object;F;7[[I"obj;T0;[[@OiK;T;:extend_object;0;[;{;IC; "#Extends the specified object by adding this module's constants and methods (which are added as singleton methods). This is the callback method used by Object#extend. module Picky def Picky.extend_object(o) if String === o puts "Can't add Picky to a String" else puts "Picky added to #{o.class}" super end end end (s = Array.new).extend Picky # Call Object.extend (s = "quick brown fox").extend Picky produces: Picky added to Array Can't add Picky to a String ;T;[o;= ;>I" overload;F;?0;;;@0;:I"extend_object(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@7;![;"I"@return [Object];T;#0;$@7;.F;Bi;C0;7[[I"obj;T0;$@7;![;"I"UExtends the specified object by adding this module's constants and methods (which are added as singleton methods). This is the callback method used by Object#extend. module Picky def Picky.extend_object(o) if String === o puts "Can't add Picky to a String" else puts "Picky added to #{o.class}" super end end end (s = Array.new).extend Picky # Call Object.extend (s = "quick brown fox").extend Picky produces: Picky added to Array Can't add Picky to a String @overload extend_object(obj) @return [Object];T;#0;$@7;.F;/o;0;1T;2i0;3iH;%@A7;9I"pstatic VALUE rb_mod_extend_object(VALUE mod, VALUE obj) { rb_extend_object(obj, mod); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#prepend_features;F;7[[I" prepend;T0;[[@Oi;T;:prepend_features;0;[;{;IC; "VWhen this module is prepended in another, Ruby calls #prepend_features in this module, passing it the receiving module in _mod_. Ruby's default implementation is to overlay the constants, methods, and module variables of this module to _mod_ if this module has not already been added to _mod_ or one of its ancestors. See also Module#prepend. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"prepend_features(mod);T;IC; ";T;[;![;"I";T;#0;$@7;.F;Bi;C0;7[[I"mod;T0;$@7;![;"I"xWhen this module is prepended in another, Ruby calls #prepend_features in this module, passing it the receiving module in _mod_. Ruby's default implementation is to overlay the constants, methods, and module variables of this module to _mod_ if this module has not already been added to _mod_ or one of its ancestors. See also Module#prepend. @overload prepend_features(mod);T;#0;$@7;.F;/o;0;1T;2iy;3i;%@A7;9I"static VALUE rb_mod_prepend_features(VALUE module, VALUE prepend) { if (!CLASS_OR_MODULE_P(prepend)) { Check_Type(prepend, T_CLASS); } rb_prepend_module(prepend, module); return module; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#refine;F;7[[I" klass;T0;[[@Oi^;T;: refine;0;[;{;IC; "]Refine mod in the receiver. Returns a module, where refined methods are defined. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"refine(mod);T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@7;![;"I"@yield [];T;#0;$@7;.F;Bi;C0;7[[I"mod;T0;$@7;![;"I"|Refine mod in the receiver. Returns a module, where refined methods are defined. @overload refine(mod) @yield [];T;#0;$@7;.F;/o;0;1T;2iU;3i[;%@A7;9I"static VALUE rb_mod_refine(VALUE module, VALUE klass) { VALUE refinement; ID id_refinements, id_activated_refinements, id_refined_class, id_defined_at; VALUE refinements, activated_refinements; rb_thread_t *th = GET_THREAD(); VALUE block_handler = rb_vm_frame_block_handler(th->ec->cfp); if (block_handler == VM_BLOCK_HANDLER_NONE) { rb_raise(rb_eArgError, "no block given"); } if (vm_block_handler_type(block_handler) != block_handler_type_iseq) { rb_raise(rb_eArgError, "can't pass a Proc as a block to Module#refine"); } ensure_class_or_module(klass); CONST_ID(id_refinements, "__refinements__"); refinements = rb_attr_get(module, id_refinements); if (NIL_P(refinements)) { refinements = hidden_identity_hash_new(); rb_ivar_set(module, id_refinements, refinements); } CONST_ID(id_activated_refinements, "__activated_refinements__"); activated_refinements = rb_attr_get(module, id_activated_refinements); if (NIL_P(activated_refinements)) { activated_refinements = hidden_identity_hash_new(); rb_ivar_set(module, id_activated_refinements, activated_refinements); } refinement = rb_hash_lookup(refinements, klass); if (NIL_P(refinement)) { VALUE superclass = refinement_superclass(klass); refinement = rb_refinement_new(); RCLASS_SET_SUPER(refinement, superclass); FL_SET(refinement, RMODULE_IS_REFINEMENT); CONST_ID(id_refined_class, "__refined_class__"); rb_ivar_set(refinement, id_refined_class, klass); CONST_ID(id_defined_at, "__defined_at__"); rb_ivar_set(refinement, id_defined_at, module); rb_hash_aset(refinements, klass, refinement); add_activated_refinement(activated_refinements, klass, refinement); } rb_yield_refine_block(refinement, activated_refinements); return refinement; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#using;F;7[[I" module;T0;[[@Oi;T;: using;0;[;{;IC; "]Import class refinements from module into the current class or module definition. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"using(module);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@7;![;"I"@return [self];T;#0;$@7;.F;Bi;C0;7[;$@7;![;"I"Import class refinements from module into the current class or module definition. @overload using(module) @return [self];T;#0;$@7;.F;/o;0;1T;2i;3i;%@A7;9I"static VALUE mod_using(VALUE self, VALUE module) { rb_control_frame_t *prev_cfp = previous_frame(GET_EC()); if (prev_frame_func()) { rb_raise(rb_eRuntimeError, "Module#using is not permitted in methods"); } if (prev_cfp && prev_cfp->self != self) { rb_raise(rb_eRuntimeError, "Module#using is not called on self"); } if (rb_block_given_p()) { ignored_block(module, "Module#"); } rb_using_module(rb_vm_cref_replace_with_duplicated_cref(), module); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module.used_modules;F;7[;[[@Oi;T;:used_modules;0;[;{;IC; ".Returns an array of all modules used in the current scope. The ordering of modules in the resulting array is not defined. module A refine Object do end end module B refine Object do end end using A using B p Module.used_modules produces: [B, A] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"used_modules;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@8;![;"I"@return [Array];T;#0;$@8;.F;Bi;C0;7[;$@8;![;"I"YReturns an array of all modules used in the current scope. The ordering of modules in the resulting array is not defined. module A refine Object do end end module B refine Object do end end using A using B p Module.used_modules produces: [B, A] @overload used_modules @return [Array];T;#0;$@8;.F;/o;0;1T;2i;3i;%@A7;9I"Jstatic VALUE rb_mod_s_used_modules(VALUE _) { const rb_cref_t *cref = rb_vm_cref(); VALUE ary = rb_ary_new(); while (cref) { if (!NIL_P(CREF_REFINEMENTS(cref))) { rb_hash_foreach(CREF_REFINEMENTS(cref), used_modules_i, ary); } cref = CREF_NEXT(cref); } return rb_funcall(ary, rb_intern("uniq"), 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#remove_method;F;7[[@90;[[@i;T;:remove_method;0;[;{;IC; "Removes the method identified by _symbol_ from the current class. For an example, see Module#undef_method. String arguments are converted to symbols. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"remove_method(symbol);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@#8;![;"I"@return [self];T;#0;$@#8;.F;Bi;C0;7[[I" symbol;T0;$@#8o;= ;>I" overload;F;?0;;;@0;:I"remove_method(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@#8;![;"I"@return [self];T;#0;$@#8;.F;Bi;C0;7[[I" string;T0;$@#8;![;"I"Removes the method identified by _symbol_ from the current class. For an example, see Module#undef_method. String arguments are converted to symbols. @overload remove_method(symbol) @return [self] @overload remove_method(string) @return [self];T;#0;$@#8;.F;/o;0;1T;2i;3i;%@A7;9I".static VALUE rb_mod_remove_method(int argc, VALUE *argv, VALUE mod) { int i; for (i = 0; i < argc; i++) { VALUE v = argv[i]; ID id = rb_check_id(&v); if (!id) { rb_name_err_raise("method `%1$s' not defined in %2$s", mod, v); } remove_method(mod, id); } return mod; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#undef_method;F;7[[@90;[[@i;T;:undef_method;0;[;{;IC; "Prevents the current class from responding to calls to the named method. Contrast this with remove_method, which deletes the method from the particular class; Ruby will still search superclasses and mixed-in modules for a possible receiver. String arguments are converted to symbols. class Parent def hello puts "In parent" end end class Child < Parent def hello puts "In child" end end c = Child.new c.hello class Child remove_method :hello # remove from child, still in parent end c.hello class Child undef_method :hello # prevent any calls to 'hello' end c.hello produces: In child In parent prog.rb:23: undefined method `hello' for # (NoMethodError) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"undef_method(symbol);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@P8;![;"I"@return [self];T;#0;$@P8;.F;Bi;C0;7[[I" symbol;T0;$@P8o;= ;>I" overload;F;?0;;;@0;:I"undef_method(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@P8;![;"I"@return [self];T;#0;$@P8;.F;Bi;C0;7[[I" string;T0;$@P8;![;"I"|Prevents the current class from responding to calls to the named method. Contrast this with remove_method, which deletes the method from the particular class; Ruby will still search superclasses and mixed-in modules for a possible receiver. String arguments are converted to symbols. class Parent def hello puts "In parent" end end class Child < Parent def hello puts "In child" end end c = Child.new c.hello class Child remove_method :hello # remove from child, still in parent end c.hello class Child undef_method :hello # prevent any calls to 'hello' end c.hello produces: In child In parent prog.rb:23: undefined method `hello' for # (NoMethodError) @overload undef_method(symbol) @return [self] @overload undef_method(string) @return [self];T;#0;$@P8;.F;/o;0;1T;2i;3i;%@A7;9I"static VALUE rb_mod_undef_method(int argc, VALUE *argv, VALUE mod) { int i; for (i = 0; i < argc; i++) { VALUE v = argv[i]; ID id = rb_check_id(&v); if (!id) { rb_method_name_error(mod, v); } rb_undef(mod, id); } return mod; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#alias_method;F;7[[I" newname;T0[I" oldname;T0;[[@i~;T;:alias_method;0;[;{;IC; "pMakes new_name a new copy of the method old_name. This can be used to retain access to methods that are overridden. module Mod alias_method :orig_exit, :exit #=> :orig_exit def exit(code=0) puts "Exiting with code #{code}" orig_exit(code) end end include Mod exit(99) produces: Exiting with code 99 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"%alias_method(new_name, old_name);T;IC; ";T;[;![;"I";T;#0;$@}8;.F;Bi;C0;7[[I" new_name;T0[I" old_name;T0;$@}8;![;"I"Makes new_name a new copy of the method old_name. This can be used to retain access to methods that are overridden. module Mod alias_method :orig_exit, :exit #=> :orig_exit def exit(code=0) puts "Exiting with code #{code}" orig_exit(code) end end include Mod exit(99) produces: Exiting with code 99 @overload alias_method(new_name, old_name);T;#0;$@}8;.F;/o;0;1T;2ih;3iz;%@A7;9I"static VALUE rb_mod_alias_method(VALUE mod, VALUE newname, VALUE oldname) { ID oldid = rb_check_id(&oldname); if (!oldid) { rb_print_undef_str(mod, oldname); } VALUE id = rb_to_id(newname); rb_alias(mod, id, oldid); return ID2SYM(id); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#public;F;7[[@90;[[@i;T;;;0;[;{;IC; "With no arguments, sets the default visibility for subsequently defined methods to public. With arguments, sets the named methods to have public visibility. String arguments are converted to symbols. An Array of Symbols and/or Strings is also accepted. If a single argument is passed, it is returned. If no argument is passed, nil is returned. If multiple arguments are passed, the arguments are returned as an array. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I" public;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@8;![;"I"@return [nil];T;#0;$@8;.F;Bi;C0;7[;$@8o;= ;>I" overload;F;?0;;;@0;:I"public(method_name);T;IC; ";T;[;![;"I";T;#0;$@8;.F;Bi;C0;7[[I"method_name;T0;$@8o;= ;>I" overload;F;?0;;;@0;:I"*public(method_name, method_name, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@8;![;"I"@return [Array];T;#0;$@8;.F;Bi;C0;7[[I"method_name;T0[I"method_name;T0[I"...;T0;$@8o;= ;>I" overload;F;?0;;;@0;:I"public(array);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@8;![;"I"@return [Array];T;#0;$@8;.F;Bi;C0;7[[I" array;T0;$@8;![;"I"NWith no arguments, sets the default visibility for subsequently defined methods to public. With arguments, sets the named methods to have public visibility. String arguments are converted to symbols. An Array of Symbols and/or Strings is also accepted. If a single argument is passed, it is returned. If no argument is passed, nil is returned. If multiple arguments are passed, the arguments are returned as an array. @overload public @return [nil] @overload public(method_name) @overload public(method_name, method_name, ...) @return [Array] @overload public(array) @return [Array];T;#0;$@8;.F;/o;0;1T;2i;3i;%@A7;9I"static VALUE rb_mod_public(int argc, VALUE *argv, VALUE module) { return set_visibility(argc, argv, module, METHOD_VISI_PUBLIC); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#protected;F;7[[@90;[[@i;T;:protected;0;[;{;IC; "DWith no arguments, sets the default visibility for subsequently defined methods to protected. With arguments, sets the named methods to have protected visibility. String arguments are converted to symbols. An Array of Symbols and/or Strings is also accepted. If a single argument is passed, it is returned. If no argument is passed, nil is returned. If multiple arguments are passed, the arguments are returned as an array. If a method has protected visibility, it is callable only where self of the context is the same as the method. (method definition or instance_eval). This behavior is different from Java's protected method. Usually private should be used. Note that a protected method is slow because it can't use inline cache. To show a private method on RDoc, use :doc: instead of this. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"protected;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@8;![;"I"@return [nil];T;#0;$@8;.F;Bi;C0;7[;$@8o;= ;>I" overload;F;?0;;;@0;:I"protected(method_name);T;IC; ";T;[;![;"I";T;#0;$@8;.F;Bi;C0;7[[I"method_name;T0;$@8o;= ;>I" overload;F;?0;;;@0;:I"-protected(method_name, method_name, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@8;![;"I"@return [Array];T;#0;$@8;.F;Bi;C0;7[[I"method_name;T0[I"method_name;T0[I"...;T0;$@8o;= ;>I" overload;F;?0;;;@0;:I"protected(array);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@8;![;"I"@return [Array];T;#0;$@8;.F;Bi;C0;7[[I" array;T0;$@8;![;"I"With no arguments, sets the default visibility for subsequently defined methods to protected. With arguments, sets the named methods to have protected visibility. String arguments are converted to symbols. An Array of Symbols and/or Strings is also accepted. If a single argument is passed, it is returned. If no argument is passed, nil is returned. If multiple arguments are passed, the arguments are returned as an array. If a method has protected visibility, it is callable only where self of the context is the same as the method. (method definition or instance_eval). This behavior is different from Java's protected method. Usually private should be used. Note that a protected method is slow because it can't use inline cache. To show a private method on RDoc, use :doc: instead of this. @overload protected @return [nil] @overload protected(method_name) @overload protected(method_name, method_name, ...) @return [Array] @overload protected(array) @return [Array];T;#0;$@8;.F;/o;0;1T;2i;3i;%@A7;9I"static VALUE rb_mod_protected(int argc, VALUE *argv, VALUE module) { return set_visibility(argc, argv, module, METHOD_VISI_PROTECTED); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#private;F;7[[@90;[[@i ;T;;;0;[;{;IC; "With no arguments, sets the default visibility for subsequently defined methods to private. With arguments, sets the named methods to have private visibility. String arguments are converted to symbols. An Array of Symbols and/or Strings is also accepted. If a single argument is passed, it is returned. If no argument is passed, nil is returned. If multiple arguments are passed, the arguments are returned as an array. module Mod def a() end def b() end private def c() end private :a end Mod.private_instance_methods #=> [:a, :c] Note that to show a private method on RDoc, use :doc:. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I" private;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@+9;![;"I"@return [nil];T;#0;$@+9;.F;Bi;C0;7[;$@+9o;= ;>I" overload;F;?0;;;@0;:I"private(method_name);T;IC; ";T;[;![;"I";T;#0;$@+9;.F;Bi;C0;7[[I"method_name;T0;$@+9o;= ;>I" overload;F;?0;;;@0;:I"+private(method_name, method_name, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@+9;![;"I"@return [Array];T;#0;$@+9;.F;Bi;C0;7[[I"method_name;T0[I"method_name;T0[I"...;T0;$@+9o;= ;>I" overload;F;?0;;;@0;:I"private(array);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@+9;![;"I"@return [Array];T;#0;$@+9;.F;Bi;C0;7[[I" array;T0;$@+9;![;"I"1With no arguments, sets the default visibility for subsequently defined methods to private. With arguments, sets the named methods to have private visibility. String arguments are converted to symbols. An Array of Symbols and/or Strings is also accepted. If a single argument is passed, it is returned. If no argument is passed, nil is returned. If multiple arguments are passed, the arguments are returned as an array. module Mod def a() end def b() end private def c() end private :a end Mod.private_instance_methods #=> [:a, :c] Note that to show a private method on RDoc, use :doc:. @overload private @return [nil] @overload private(method_name) @overload private(method_name, method_name, ...) @return [Array] @overload private(array) @return [Array];T;#0;$@+9;.F;/o;0;1T;2i;3i ;%@A7;9I"static VALUE rb_mod_private(int argc, VALUE *argv, VALUE module) { return set_visibility(argc, argv, module, METHOD_VISI_PRIVATE); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#module_function;F;7[[@90;[[@i ;T;:module_function;0;[;{;IC; "Creates module functions for the named methods. These functions may be called with the module as a receiver, and also become available as instance methods to classes that mix in the module. Module functions are copies of the original, and so may be changed independently. The instance-method versions are made private. If used with no arguments, subsequently defined methods become module functions. String arguments are converted to symbols. If a single argument is passed, it is returned. If no argument is passed, nil is returned. If multiple arguments are passed, the arguments are returned as an array. module Mod def one "This is one" end module_function :one end class Cls include Mod def call_one one end end Mod.one #=> "This is one" c = Cls.new c.call_one #=> "This is one" module Mod def one "This is the new one" end end Mod.one #=> "This is one" c.call_one #=> "This is the new one" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"module_function;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@s9;![;"I"@return [nil];T;#0;$@s9;.F;Bi;C0;7[;$@s9o;= ;>I" overload;F;?0;;;@0;:I"!module_function(method_name);T;IC; ";T;[;![;"I";T;#0;$@s9;.F;Bi;C0;7[[I"method_name;T0;$@s9o;= ;>I" overload;F;?0;;;@0;:I"3module_function(method_name, method_name, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@s9;![;"I"@return [Array];T;#0;$@s9;.F;Bi;C0;7[[I"method_name;T0[I"method_name;T0[I"...;T0;$@s9;![;"I"Creates module functions for the named methods. These functions may be called with the module as a receiver, and also become available as instance methods to classes that mix in the module. Module functions are copies of the original, and so may be changed independently. The instance-method versions are made private. If used with no arguments, subsequently defined methods become module functions. String arguments are converted to symbols. If a single argument is passed, it is returned. If no argument is passed, nil is returned. If multiple arguments are passed, the arguments are returned as an array. module Mod def one "This is one" end module_function :one end class Cls include Mod def call_one one end end Mod.one #=> "This is one" c = Cls.new c.call_one #=> "This is one" module Mod def one "This is the new one" end end Mod.one #=> "This is one" c.call_one #=> "This is the new one" @overload module_function @return [nil] @overload module_function(method_name) @overload module_function(method_name, method_name, ...) @return [Array];T;#0;$@s9;.F;/o;0;1T;2i ;3i ;%@A7;9I"static VALUE rb_mod_modfunc(int argc, VALUE *argv, VALUE module) { int i; ID id; const rb_method_entry_t *me; if (!RB_TYPE_P(module, T_MODULE)) { rb_raise(rb_eTypeError, "module_function must be called for modules"); } if (argc == 0) { rb_scope_module_func_set(); return Qnil; } set_method_visibility(module, argc, argv, METHOD_VISI_PRIVATE); for (i = 0; i < argc; i++) { VALUE m = module; id = rb_to_id(argv[i]); for (;;) { me = search_method(m, id, 0); if (me == 0) { me = search_method(rb_cObject, id, 0); } if (UNDEFINED_METHOD_ENTRY_P(me)) { rb_print_undef(module, id, METHOD_VISI_UNDEF); } if (me->def->type != VM_METHOD_TYPE_ZSUPER) { break; /* normal case: need not to follow 'super' link */ } m = RCLASS_SUPER(m); if (!m) break; } rb_method_entry_set(rb_singleton_class(module), id, me, METHOD_VISI_PUBLIC); } if (argc == 1) { return argv[0]; } return rb_ary_new_from_values(argc, argv); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#ruby2_keywords;F;7[[@90;[[@i> ;T;:ruby2_keywords;0;[;{;IC; " For the given method names, marks the method as passing keywords through a normal argument splat. This should only be called on methods that accept an argument splat (*args) but not explicit keywords or a keyword splat. It marks the method such that if the method is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the method to other methods. This should only be used for methods that delegate keywords to another method, and only for backwards compatibility with Ruby versions before 3.0. See https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/ for details on why +ruby2_keywords+ exists and when and how to use it. This method will probably be removed at some point, as it exists only for backwards compatibility. As it does not exist in Ruby versions before 2.7, check that the module responds to this method before calling it: module Mod def foo(meth, *args, &block) send(:"do_#{meth}", *args, &block) end ruby2_keywords(:foo) if respond_to?(:ruby2_keywords, true) end However, be aware that if the +ruby2_keywords+ method is removed, the behavior of the +foo+ method using the above approach will change so that the method does not pass through keywords. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"%ruby2_keywords(method_name, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@9;![;"I"@return [nil];T;#0;$@9;.F;Bi;C0;7[[I"method_name;T0[I"...;T0;$@9;![;"I"FFor the given method names, marks the method as passing keywords through a normal argument splat. This should only be called on methods that accept an argument splat (*args) but not explicit keywords or a keyword splat. It marks the method such that if the method is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the method to other methods. This should only be used for methods that delegate keywords to another method, and only for backwards compatibility with Ruby versions before 3.0. See https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/ for details on why +ruby2_keywords+ exists and when and how to use it. This method will probably be removed at some point, as it exists only for backwards compatibility. As it does not exist in Ruby versions before 2.7, check that the module responds to this method before calling it: module Mod def foo(meth, *args, &block) send(:"do_#{meth}", *args, &block) end ruby2_keywords(:foo) if respond_to?(:ruby2_keywords, true) end However, be aware that if the +ruby2_keywords+ method is removed, the behavior of the +foo+ method using the above approach will change so that the method does not pass through keywords. @overload ruby2_keywords(method_name, ...) @return [nil];T;#0;$@9;.F;/o;0;1T;2i ;3i; ;%@A7;9I": static VALUE rb_mod_ruby2_keywords(int argc, VALUE *argv, VALUE module) { int i; VALUE origin_class = RCLASS_ORIGIN(module); rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS); rb_check_frozen(module); for (i = 0; i < argc; i++) { VALUE v = argv[i]; ID name = rb_check_id(&v); rb_method_entry_t *me; VALUE defined_class; if (!name) { rb_print_undef_str(module, v); } me = search_method(origin_class, name, &defined_class); if (!me && RB_TYPE_P(module, T_MODULE)) { me = search_method(rb_cObject, name, &defined_class); } if (UNDEFINED_METHOD_ENTRY_P(me) || UNDEFINED_REFINED_METHOD_P(me->def)) { rb_print_undef(module, name, METHOD_VISI_UNDEF); } if (module == defined_class || origin_class == defined_class) { switch (me->def->type) { case VM_METHOD_TYPE_ISEQ: if (me->def->body.iseq.iseqptr->body->param.flags.has_rest && !me->def->body.iseq.iseqptr->body->param.flags.has_kw && !me->def->body.iseq.iseqptr->body->param.flags.has_kwrest) { me->def->body.iseq.iseqptr->body->param.flags.ruby2_keywords = 1; rb_clear_method_cache(module, name); } else { rb_warn("Skipping set of ruby2_keywords flag for %s (method accepts keywords or method does not accept argument splat)", rb_id2name(name)); } break; case VM_METHOD_TYPE_BMETHOD: { VALUE procval = me->def->body.bmethod.proc; if (vm_block_handler_type(procval) == block_handler_type_proc) { procval = vm_proc_to_block_handler(VM_BH_TO_PROC(procval)); } if (vm_block_handler_type(procval) == block_handler_type_iseq) { const struct rb_captured_block *captured = VM_BH_TO_ISEQ_BLOCK(procval); const rb_iseq_t *iseq = rb_iseq_check(captured->code.iseq); if (iseq->body->param.flags.has_rest && !iseq->body->param.flags.has_kw && !iseq->body->param.flags.has_kwrest) { iseq->body->param.flags.ruby2_keywords = 1; rb_clear_method_cache(module, name); } else { rb_warn("Skipping set of ruby2_keywords flag for %s (method accepts keywords or method does not accept argument splat)", rb_id2name(name)); } break; } } /* fallthrough */ default: rb_warn("Skipping set of ruby2_keywords flag for %s (method not defined in Ruby)", rb_id2name(name)); break; } } else { rb_warn("Skipping set of ruby2_keywords flag for %s (can only set in method defining module)", rb_id2name(name)); } } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#method_defined?;F;7[[@90;[[@iH;T;:method_defined?;0;[;{;IC; "Returns +true+ if the named method is defined by _mod_. If _inherit_ is set, the lookup will also search _mod_'s ancestors. Public and protected methods are matched. String arguments are converted to symbols. module A def method1() end def protected_method1() end protected :protected_method1 end class B def method2() end def private_method2() end private :private_method2 end class C < B include A def method3() end end A.method_defined? :method1 #=> true C.method_defined? "method1" #=> true C.method_defined? "method2" #=> true C.method_defined? "method2", true #=> true C.method_defined? "method2", false #=> false C.method_defined? "method3" #=> true C.method_defined? "protected_method1" #=> true C.method_defined? "method4" #=> false C.method_defined? "private_method2" #=> false;T;[o;= ;>I" overload;F;?0;;;@0;:I"*method_defined?(symbol, inherit=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@9;![;"I"@return [Boolean];T;#0;$@9;.F;Bi;C0;7[[I" symbol;T0[I" inherit;TI" true;T;$@9o;= ;>I" overload;F;?0;;;@0;:I"*method_defined?(string, inherit=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@9;![;"I"@return [Boolean];T;#0;$@9;.F;Bi;C0;7[[I" string;T0[I" inherit;TI" true;T;$@9;![;"I"HReturns +true+ if the named method is defined by _mod_. If _inherit_ is set, the lookup will also search _mod_'s ancestors. Public and protected methods are matched. String arguments are converted to symbols. module A def method1() end def protected_method1() end protected :protected_method1 end class B def method2() end def private_method2() end private :private_method2 end class C < B include A def method3() end end A.method_defined? :method1 #=> true C.method_defined? "method1" #=> true C.method_defined? "method2" #=> true C.method_defined? "method2", true #=> true C.method_defined? "method2", false #=> false C.method_defined? "method3" #=> true C.method_defined? "protected_method1" #=> true C.method_defined? "method4" #=> false C.method_defined? "private_method2" #=> false @overload method_defined?(symbol, inherit=true) @return [Boolean] @overload method_defined?(string, inherit=true) @return [Boolean];T;#0;$@9;.F;/o;0;1T;2i$;3iF;Bi;%@A7;9I"static VALUE rb_mod_method_defined(int argc, VALUE *argv, VALUE mod) { rb_method_visibility_t visi = check_definition_visibility(mod, argc, argv); return RBOOL(visi == METHOD_VISI_PUBLIC || visi == METHOD_VISI_PROTECTED); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""Module#public_method_defined?;F;7[[@90;[[@is;T;:public_method_defined?;0;[;{;IC; "Returns +true+ if the named public method is defined by _mod_. If _inherit_ is set, the lookup will also search _mod_'s ancestors. String arguments are converted to symbols. module A def method1() end end class B protected def method2() end end class C < B include A def method3() end end A.method_defined? :method1 #=> true C.public_method_defined? "method1" #=> true C.public_method_defined? "method1", true #=> true C.public_method_defined? "method1", false #=> true C.public_method_defined? "method2" #=> false C.method_defined? "method2" #=> true;T;[o;= ;>I" overload;F;?0;;;@0;:I"1public_method_defined?(symbol, inherit=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@9;![;"I"@return [Boolean];T;#0;$@9;.F;Bi;C0;7[[I" symbol;T0[I" inherit;TI" true;T;$@9o;= ;>I" overload;F;?0;;;@0;:I"1public_method_defined?(string, inherit=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@9;![;"I"@return [Boolean];T;#0;$@9;.F;Bi;C0;7[[I" string;T0[I" inherit;TI" true;T;$@9;![;"I"4Returns +true+ if the named public method is defined by _mod_. If _inherit_ is set, the lookup will also search _mod_'s ancestors. String arguments are converted to symbols. module A def method1() end end class B protected def method2() end end class C < B include A def method3() end end A.method_defined? :method1 #=> true C.public_method_defined? "method1" #=> true C.public_method_defined? "method1", true #=> true C.public_method_defined? "method1", false #=> true C.public_method_defined? "method2" #=> false C.method_defined? "method2" #=> true @overload public_method_defined?(symbol, inherit=true) @return [Boolean] @overload public_method_defined?(string, inherit=true) @return [Boolean];T;#0;$@9;.F;/o;0;1T;2iU;3iq;Bi;%@A7;9I"static VALUE rb_mod_public_method_defined(int argc, VALUE *argv, VALUE mod) { return check_definition(mod, argc, argv, METHOD_VISI_PUBLIC); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#Module#private_method_defined?;F;7[[@90;[[@i;T;:private_method_defined?;0;[;{;IC; "Returns +true+ if the named private method is defined by _mod_. If _inherit_ is set, the lookup will also search _mod_'s ancestors. String arguments are converted to symbols. module A def method1() end end class B private def method2() end end class C < B include A def method3() end end A.method_defined? :method1 #=> true C.private_method_defined? "method1" #=> false C.private_method_defined? "method2" #=> true C.private_method_defined? "method2", true #=> true C.private_method_defined? "method2", false #=> false C.method_defined? "method2" #=> false;T;[o;= ;>I" overload;F;?0;;;@0;:I"2private_method_defined?(symbol, inherit=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@2:;![;"I"@return [Boolean];T;#0;$@2:;.F;Bi;C0;7[[I" symbol;T0[I" inherit;TI" true;T;$@2:o;= ;>I" overload;F;?0;;;@0;:I"2private_method_defined?(string, inherit=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@2:;![;"I"@return [Boolean];T;#0;$@2:;.F;Bi;C0;7[[I" string;T0[I" inherit;TI" true;T;$@2:;![;"I"CReturns +true+ if the named private method is defined by _mod_. If _inherit_ is set, the lookup will also search _mod_'s ancestors. String arguments are converted to symbols. module A def method1() end end class B private def method2() end end class C < B include A def method3() end end A.method_defined? :method1 #=> true C.private_method_defined? "method1" #=> false C.private_method_defined? "method2" #=> true C.private_method_defined? "method2", true #=> true C.private_method_defined? "method2", false #=> false C.method_defined? "method2" #=> false @overload private_method_defined?(symbol, inherit=true) @return [Boolean] @overload private_method_defined?(string, inherit=true) @return [Boolean];T;#0;$@2:;.F;/o;0;1T;2iy;3i;Bi;%@A7;9I"static VALUE rb_mod_private_method_defined(int argc, VALUE *argv, VALUE mod) { return check_definition(mod, argc, argv, METHOD_VISI_PRIVATE); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%Module#protected_method_defined?;F;7[[@90;[[@i;T;:protected_method_defined?;0;[;{;IC; "Returns +true+ if the named protected method is defined _mod_. If _inherit_ is set, the lookup will also search _mod_'s ancestors. String arguments are converted to symbols. module A def method1() end end class B protected def method2() end end class C < B include A def method3() end end A.method_defined? :method1 #=> true C.protected_method_defined? "method1" #=> false C.protected_method_defined? "method2" #=> true C.protected_method_defined? "method2", true #=> true C.protected_method_defined? "method2", false #=> false C.method_defined? "method2" #=> true;T;[o;= ;>I" overload;F;?0;;;@0;:I"4protected_method_defined?(symbol, inherit=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@e:;![;"I"@return [Boolean];T;#0;$@e:;.F;Bi;C0;7[[I" symbol;T0[I" inherit;TI" true;T;$@e:o;= ;>I" overload;F;?0;;;@0;:I"4protected_method_defined?(string, inherit=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@e:;![;"I"@return [Boolean];T;#0;$@e:;.F;Bi;C0;7[[I" string;T0[I" inherit;TI" true;T;$@e:;![;"I"MReturns +true+ if the named protected method is defined _mod_. If _inherit_ is set, the lookup will also search _mod_'s ancestors. String arguments are converted to symbols. module A def method1() end end class B protected def method2() end end class C < B include A def method3() end end A.method_defined? :method1 #=> true C.protected_method_defined? "method1" #=> false C.protected_method_defined? "method2" #=> true C.protected_method_defined? "method2", true #=> true C.protected_method_defined? "method2", false #=> false C.method_defined? "method2" #=> true @overload protected_method_defined?(symbol, inherit=true) @return [Boolean] @overload protected_method_defined?(string, inherit=true) @return [Boolean];T;#0;$@e:;.F;/o;0;1T;2i;3i;Bi;%@A7;9I"static VALUE rb_mod_protected_method_defined(int argc, VALUE *argv, VALUE mod) { return check_definition(mod, argc, argv, METHOD_VISI_PROTECTED); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#public_class_method;F;7[[@90;[[@i ;T;:public_class_method;0;[;{;IC; "Makes a list of existing class methods public. String arguments are converted to symbols. An Array of Symbols and/or Strings is also accepted. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"%public_class_method(symbol, ...);T;IC; ";T;[;![;"I";T;#0;$@:;.F;Bi;C0;7[[I" symbol;T0[I"...;T0;$@:o;= ;>I" overload;F;?0;;;@0;:I"%public_class_method(string, ...);T;IC; ";T;[;![;"I";T;#0;$@:;.F;Bi;C0;7[[I" string;T0[I"...;T0;$@:o;= ;>I" overload;F;?0;;;@0;:I"public_class_method(array);T;IC; ";T;[;![;"I";T;#0;$@:;.F;Bi;C0;7[[I" array;T0;$@:;![;"I" Makes a list of existing class methods public. String arguments are converted to symbols. An Array of Symbols and/or Strings is also accepted. @overload public_class_method(symbol, ...) @overload public_class_method(string, ...) @overload public_class_method(array);T;#0;$@:;.F;/o;0;1T;2i ;3i ;%@A7;9I"static VALUE rb_mod_public_method(int argc, VALUE *argv, VALUE obj) { set_method_visibility(rb_singleton_class(obj), argc, argv, METHOD_VISI_PUBLIC); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Module#private_class_method;F;7[[@90;[[@i ;T;:private_class_method;0;[;{;IC; "Makes existing class methods private. Often used to hide the default constructor new. String arguments are converted to symbols. An Array of Symbols and/or Strings is also accepted. class SimpleSingleton # Not thread safe private_class_method :new def SimpleSingleton.create(*args, &block) @me = new(*args, &block) if ! @me @me end end ;T;[o;= ;>I" overload;F;?0;;;@0;:I"&private_class_method(symbol, ...);T;IC; ";T;[;![;"I";T;#0;$@:;.F;Bi;C0;7[[I" symbol;T0[I"...;T0;$@:o;= ;>I" overload;F;?0;;;@0;:I"&private_class_method(string, ...);T;IC; ";T;[;![;"I";T;#0;$@:;.F;Bi;C0;7[[I" string;T0[I"...;T0;$@:o;= ;>I" overload;F;?0;;;@0;:I" private_class_method(array);T;IC; ";T;[;![;"I";T;#0;$@:;.F;Bi;C0;7[[I" array;T0;$@:;![;"I"Makes existing class methods private. Often used to hide the default constructor new. String arguments are converted to symbols. An Array of Symbols and/or Strings is also accepted. class SimpleSingleton # Not thread safe private_class_method :new def SimpleSingleton.create(*args, &block) @me = new(*args, &block) if ! @me @me end end @overload private_class_method(symbol, ...) @overload private_class_method(string, ...) @overload private_class_method(array);T;#0;$@:;.F;/o;0;1T;2i ;3i ;%@A7;9I"static VALUE rb_mod_private_method(int argc, VALUE *argv, VALUE obj) { set_method_visibility(rb_singleton_class(obj), argc, argv, METHOD_VISI_PRIVATE); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#included;F;7[;[;F;; ;;;[;{;IC; "call-seq: included(othermod) Callback invoked whenever the receiver is included in another module or class. This should be used in preference to Module.append_features if your code wants to perform some action when a module is included in another. module A def A.included(mod) puts "#{self} included in #{mod}" end end module Enumerable include A end # => prints "A included in Enumerable" ;T;[;![;"I" call-seq: included(othermod) Callback invoked whenever the receiver is included in another module or class. This should be used in preference to Module.append_features if your code wants to perform some action when a module is included in another. module A def A.included(mod) puts "#{self} included in #{mod}" end end module Enumerable include A end # => prints "A included in Enumerable" ;T;#0;$@:;.F;/o;0;1T;2i;3i;%@A7;;To;4;5F;6;;;;&I"Module#extended;F;7[;[;F;: extended;;;[;{;IC; ":call-seq: extended(othermod) The equivalent of included, but for extended modules. module A def self.extended(mod) puts "#{self} extended in #{mod}" end end module Enumerable extend A end # => prints "A extended in Enumerable" ;T;[;![;"I"< call-seq: extended(othermod) The equivalent of included, but for extended modules. module A def self.extended(mod) puts "#{self} extended in #{mod}" end end module Enumerable extend A end # => prints "A extended in Enumerable" ;T;#0;$@;;.F;/o;0;1T;2i;3i;%@A7;;To;4;5F;6;;;;&I"Module#prepended;F;7[;[;F;:prepended;;;[;{;IC; "@call-seq: prepended(othermod) The equivalent of included, but for prepended modules. module A def self.prepended(mod) puts "#{self} prepended to #{mod}" end end module Enumerable prepend A end # => prints "A prepended to Enumerable" ;T;[;![;"I"B call-seq: prepended(othermod) The equivalent of included, but for prepended modules. module A def self.prepended(mod) puts "#{self} prepended to #{mod}" end end module Enumerable prepend A end # => prints "A prepended to Enumerable" ;T;#0;$@;;.F;/o;0;1T;2i;3i*;%@A7;;To;4;5F;6;;;;&I"Module#method_added;F;7[;[;F;:method_added;;;[;{;IC; "_call-seq: method_added(method_name) Invoked as a callback whenever an instance method is added to the receiver. module Chatty def self.method_added(method_name) puts "Adding #{method_name.inspect}" end def self.some_class_method() end def some_instance_method() end end produces: Adding :some_instance_method ;T;[;![;"I"b call-seq: method_added(method_name) Invoked as a callback whenever an instance method is added to the receiver. module Chatty def self.method_added(method_name) puts "Adding #{method_name.inspect}" end def self.some_class_method() end def some_instance_method() end end produces: Adding :some_instance_method ;T;#0;$@;;.F;/o;0;1T;2iR;3ie;%@A7;;To;4;5F;6;;;;&I"Module#method_removed;F;7[;[;F;:method_removed;;;[;{;IC; "call-seq: method_removed(method_name) Invoked as a callback whenever an instance method is removed from the receiver. module Chatty def self.method_removed(method_name) puts "Removing #{method_name.inspect}" end def self.some_class_method() end def some_instance_method() end class << self remove_method :some_class_method end remove_method :some_instance_method end produces: Removing :some_instance_method ;T;[;![;"I" call-seq: method_removed(method_name) Invoked as a callback whenever an instance method is removed from the receiver. module Chatty def self.method_removed(method_name) puts "Removing #{method_name.inspect}" end def self.some_class_method() end def some_instance_method() end class << self remove_method :some_class_method end remove_method :some_instance_method end produces: Removing :some_instance_method ;T;#0;$@&;;.F;/o;0;1T;2ii;3i;%@A7;;To;4;5F;6;;;;&I"Module#method_undefined;F;7[;[;F;:method_undefined;;;[;{;IC; "call-seq: method_undefined(method_name) Invoked as a callback whenever an instance method is undefined from the receiver. module Chatty def self.method_undefined(method_name) puts "Undefining #{method_name.inspect}" end def self.some_class_method() end def some_instance_method() end class << self undef_method :some_class_method end undef_method :some_instance_method end produces: Undefining :some_instance_method ;T;[;![;"I" call-seq: method_undefined(method_name) Invoked as a callback whenever an instance method is undefined from the receiver. module Chatty def self.method_undefined(method_name) puts "Undefining #{method_name.inspect}" end def self.some_class_method() end def some_instance_method() end class << self undef_method :some_class_method end undef_method :some_instance_method end produces: Undefining :some_instance_method ;T;#0;$@1;;.F;/o;0;1T;2i;3i;%@A7;;To;4;5F;6;;;;&I"Module#freeze;F;7[;[[@mod. This method returns self. ;T;[o;= ;>I" overload;F;?0;;f;@0;:I" freeze;T;IC; ";T;[;![;"I";T;#0;$@<;;.F;Bi;C0;7[;$@<;;![;"I"`Prevents further modifications to mod. This method returns self. @overload freeze;T;#0;$@<;;.F;/o;0;1T;2iW;3i\;%@A7;9I"estatic VALUE rb_mod_freeze(VALUE mod) { rb_class_name(mod); return rb_obj_freeze(mod); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#===;F;7[[I"arg;T0;[[@true if obj is an instance of mod or an instance of one of mod's descendants. Of limited use for modules, but can be used in case statements to classify objects by class. ;T;[o;= ;>I" overload;F;?0;;S;@0;:I" ===(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@R;;![;"I"@return [Boolean];T;#0;$@R;;.F;Bi;C0;7[[I"obj;T0;$@R;;![;"I"Case Equality---Returns true if obj is an instance of mod or an instance of one of mod's descendants. Of limited use for modules, but can be used in case statements to classify objects by class. @overload ===(obj) @return [Boolean];T;#0;$@R;;.F;/o;0;1T;2ig;3in;%@A7;9I"^static VALUE rb_mod_eqq(VALUE mod, VALUE arg) { return rb_obj_is_kind_of(arg, mod); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#==;F;7[[I" obj2;T0;[[@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;= ;>I" overload;F;?0;;F;@0;:I"==(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@q;;![;"I"@return [Boolean];T;#0;$@q;;.F;Bi;C0;7[[I" other;T0;$@q;o;= ;>I" overload;F;?0;;W;@0;:I"equal?(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@q;;![;"I"@return [Boolean];T;#0;$@q;;.F;Bi;C0;7[[I" other;T0;$@q;o;= ;>I" overload;F;?0;;V;@0;:I"eql?(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@q;;![;"I"@return [Boolean];T;#0;$@q;;.F;Bi;C0;7[[I" other;T0;$@q;;![;"@;#0;$@q;;.F;/o;0;1T;2i;3i;%@A7;9I"fMJIT_FUNC_EXPORTED VALUE rb_obj_equal(VALUE obj1, VALUE obj2) { return RBOOL(obj1 == obj2); };T;:I"MJIT_FUNC_EXPORTED VALUE;T;;To;4;5F;6;;;;&I"Module#<=>;F;7[[I"arg;T0;[[@I" overload;F;?0;;Y;@0;:I"<=>(other_module);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[ I"-1;TI"0;TI"+1;TI"nil;T;$@;;![;"I"@return [-1, 0, +1, nil];T;#0;$@;;.F;Bi;C0;7[[I"other_module;T0;$@;;![;"I"fComparison---Returns -1, 0, +1 or nil depending on whether +module+ includes +other_module+, they are the same, or if +module+ is included by +other_module+. Returns +nil+ if +module+ has no relationship with +other_module+, if +other_module+ is not a module, or if the two values are incomparable. @overload <=>(other_module) @return [-1, 0, +1, nil];T;#0;$@;;.F;/o;0;1T;2i;3i;%@A7;9I",static VALUE rb_mod_cmp(VALUE mod, VALUE arg) { VALUE cmp; if (mod == arg) return INT2FIX(0); if (!CLASS_OR_MODULE_P(arg)) { return Qnil; } cmp = rb_class_inherited_p(mod, arg); if (NIL_P(cmp)) return Qnil; if (cmp) { return INT2FIX(-1); } return INT2FIX(1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Module#<;F;7[[I"arg;T0;[[@mod is a subclass of other. Returns nil if there's no relationship between the two. (Think of the relationship in terms of the class definition: "class A < B" implies "A < B".) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" <(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;TI" false;TI"nil;T;$@;;![;"I"@return [true, false, nil];T;#0;$@;;.F;Bi;C0;7[[I" other;T0;$@;;![;"I"Returns true if mod is a subclass of other. Returns nil if there's no relationship between the two. (Think of the relationship in terms of the class definition: "class A < B" implies "A < B".) @overload <(other) @return [true, false, nil];T;#0;$@;;.F;/o;0;1T;2i;3i;%@A7;9I"~static VALUE rb_mod_lt(VALUE mod, VALUE arg) { if (mod == arg) return Qfalse; return rb_class_inherited_p(mod, arg); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#<=;F;7[[I"arg;T0;[[@mod is a subclass of other or is the same as other. Returns nil if there's no relationship between the two. (Think of the relationship in terms of the class definition: "class A < B" implies "A < B".) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"<=(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;TI" false;TI"nil;T;$@;;![;"I"@return [true, false, nil];T;#0;$@;;.F;Bi;C0;7[[I" other;T0;$@;;![;"I"-Returns true if mod is a subclass of other or is the same as other. Returns nil if there's no relationship between the two. (Think of the relationship in terms of the class definition: "class A < B" implies "A < B".) @overload <=(other) @return [true, false, nil];T;#0;$@;;.F;/o;0;1T;2iw;3i;%@A7;9I"VALUE rb_class_inherited_p(VALUE mod, VALUE arg) { if (mod == arg) return Qtrue; if (!CLASS_OR_MODULE_P(arg) && !RB_TYPE_P(arg, T_ICLASS)) { rb_raise(rb_eTypeError, "compared with non class/module"); } if (class_search_ancestor(mod, RCLASS_ORIGIN(arg))) { return Qtrue; } /* not mod < arg; check if mod > arg */ if (class_search_ancestor(arg, mod)) { return Qfalse; } return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I" Module#>;F;7[[I"arg;T0;[[@;0;[;{;IC; "Returns true if mod is an ancestor of other. Returns nil if there's no relationship between the two. (Think of the relationship in terms of the class definition: "class A < B" implies "B > A".) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" >(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;TI" false;TI"nil;T;$@<;![;"I"@return [true, false, nil];T;#0;$@<;.F;Bi;C0;7[[I" other;T0;$@<;![;"I"Returns true if mod is an ancestor of other. Returns nil if there's no relationship between the two. (Think of the relationship in terms of the class definition: "class A < B" implies "B > A".) @overload >(other) @return [true, false, nil];T;#0;$@<;.F;/o;0;1T;2i;3i;%@A7;9I"xstatic VALUE rb_mod_gt(VALUE mod, VALUE arg) { if (mod == arg) return Qfalse; return rb_mod_ge(mod, arg); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#>=;F;7[[I"arg;T0;[[@=;0;[;{;IC; "Returns true if mod is an ancestor of other, or the two modules are the same. Returns nil if there's no relationship between the two. (Think of the relationship in terms of the class definition: "class A < B" implies "B > A".) ;T;[o;= ;>I" overload;F;?0;;;@0;:I">=(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;TI" false;TI"nil;T;$@2<;![;"I"@return [true, false, nil];T;#0;$@2<;.F;Bi;C0;7[[I" other;T0;$@2<;![;"I"1Returns true if mod is an ancestor of other, or the two modules are the same. Returns nil if there's no relationship between the two. (Think of the relationship in terms of the class definition: "class A < B" implies "B > A".) @overload >=(other) @return [true, false, nil];T;#0;$@2<;.F;/o;0;1T;2i;3i;%@A7;9I"static VALUE rb_mod_ge(VALUE mod, VALUE arg) { if (!CLASS_OR_MODULE_P(arg)) { rb_raise(rb_eTypeError, "compared with non class/module"); } return rb_class_inherited_p(arg, mod); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#initialize_copy;F;7[[I" orig;T0;[[@ni;T;;];0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@S<;.F;/o;0;1T;2i;3i;%@A7;9I"OVALUE rb_mod_init_copy(VALUE clone, VALUE orig) { switch (BUILTIN_TYPE(clone)) { case T_CLASS: case T_ICLASS: class_init_copy_check(clone, orig); break; case T_MODULE: rb_module_check_initializable(clone); break; default: break; } if (!OBJ_INIT_COPY(clone, orig)) return clone; /* cloned flag is refer at constant inline cache * see vm_get_const_key_cref() in vm_insnhelper.c */ FL_SET(clone, RCLASS_CLONED); FL_SET(orig , RCLASS_CLONED); if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) { RBASIC_SET_CLASS(clone, rb_singleton_class_clone(orig)); rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone); } RCLASS_ALLOCATOR(clone) = RCLASS_ALLOCATOR(orig); copy_tables(clone, orig); if (RCLASS_M_TBL(orig)) { struct clone_method_arg arg; arg.old_klass = orig; arg.new_klass = clone; RCLASS_M_TBL_INIT(clone); rb_id_table_foreach(RCLASS_M_TBL(orig), clone_method_i, &arg); } if (RCLASS_ORIGIN(orig) == orig) { RCLASS_SET_SUPER(clone, RCLASS_SUPER(orig)); } else { VALUE p = RCLASS_SUPER(orig); VALUE orig_origin = RCLASS_ORIGIN(orig); VALUE prev_clone_p = clone; VALUE origin_stack = rb_ary_tmp_new(2); VALUE origin[2]; VALUE clone_p = 0; long origin_len; int add_subclass; VALUE clone_origin; ensure_origin(clone); clone_origin = RCLASS_ORIGIN(clone); while (p && p != orig_origin) { if (BUILTIN_TYPE(p) != T_ICLASS) { rb_bug("non iclass between module/class and origin"); } clone_p = class_alloc(RBASIC(p)->flags, RBASIC(p)->klass); RCLASS_SET_SUPER(prev_clone_p, clone_p); prev_clone_p = clone_p; RCLASS_M_TBL(clone_p) = RCLASS_M_TBL(p); RCLASS_CONST_TBL(clone_p) = RCLASS_CONST_TBL(p); RCLASS_IV_TBL(clone_p) = RCLASS_IV_TBL(p); RCLASS_ALLOCATOR(clone_p) = RCLASS_ALLOCATOR(p); if (RB_TYPE_P(clone, T_CLASS)) { RCLASS_SET_INCLUDER(clone_p, clone); } add_subclass = TRUE; if (p != RCLASS_ORIGIN(p)) { origin[0] = clone_p; origin[1] = RCLASS_ORIGIN(p); rb_ary_cat(origin_stack, origin, 2); } else if ((origin_len = RARRAY_LEN(origin_stack)) > 1 && RARRAY_AREF(origin_stack, origin_len - 1) == p) { RCLASS_SET_ORIGIN(RARRAY_AREF(origin_stack, (origin_len -= 2)), clone_p); RICLASS_SET_ORIGIN_SHARED_MTBL(clone_p); rb_ary_resize(origin_stack, origin_len); add_subclass = FALSE; } if (add_subclass) { rb_module_add_to_subclasses_list(RBASIC(p)->klass, clone_p); } p = RCLASS_SUPER(p); } if (p == orig_origin) { if (clone_p) { RCLASS_SET_SUPER(clone_p, clone_origin); RCLASS_SET_SUPER(clone_origin, RCLASS_SUPER(orig_origin)); } copy_tables(clone_origin, orig_origin); if (RCLASS_M_TBL(orig_origin)) { struct clone_method_arg arg; arg.old_klass = orig; arg.new_klass = clone; RCLASS_M_TBL_INIT(clone_origin); rb_id_table_foreach(RCLASS_M_TBL(orig_origin), clone_method_i, &arg); } } else { rb_bug("no origin for class that has origin"); } } return clone; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Module#to_s;F;7[;[[@I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@c<;![;"I"@return [String];T;#0;$@c<;.F;Bi;C0;7[;$@c<;![;"I"Returns a string representing this module or class. For basic classes and modules, this is the name. For singletons, we show information on the thing we're attached to as well. @overload to_s @return [String];T;#0;$o;4;5F;6;;;;&I"Module#inspect;F;7[;[[@"); return s; } refined_class = rb_refinement_module_get_refined_class(klass); if (!NIL_P(refined_class)) { VALUE s = rb_usascii_str_new2("#"); return s; } return rb_class_name(klass); };T;:I"MJIT_FUNC_EXPORTED VALUE;T;.F;/o;0;1T;2i+;3i1;%@A7;9I"?MJIT_FUNC_EXPORTED VALUE rb_mod_to_s(VALUE klass) { ID id_defined_at; VALUE refined_class, defined_at; if (FL_TEST(klass, FL_SINGLETON)) { VALUE s = rb_usascii_str_new2("#"); return s; } refined_class = rb_refinement_module_get_refined_class(klass); if (!NIL_P(refined_class)) { VALUE s = rb_usascii_str_new2("#"); return s; } return rb_class_name(klass); };T;:@<;;T@{mod or one of mod's ancestors. module Sub end module Mixin prepend Sub end module Outer include Mixin end Mixin.included_modules #=> [Sub] Outer.included_modules #=> [Sub, Mixin] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"included_modules;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@<;![;"I"@return [Array];T;#0;$@<;.F;Bi;C0;7[;$@<;![;"I"NReturns the list of modules included or prepended in mod or one of mod's ancestors. module Sub end module Mixin prepend Sub end module Outer include Mixin end Mixin.included_modules #=> [Sub] Outer.included_modules #=> [Sub, Mixin] @overload included_modules @return [Array];T;#0;$@<;.F;/o;0;1T;2i-;3i@;%@A7;9I"~VALUE rb_mod_included_modules(VALUE mod) { VALUE ary = rb_ary_new(); VALUE p; VALUE origin = RCLASS_ORIGIN(mod); for (p = RCLASS_SUPER(mod); p; p = RCLASS_SUPER(p)) { if (p != origin && RCLASS_ORIGIN(p) == p && BUILTIN_TYPE(p) == T_ICLASS) { VALUE m = RBASIC(p)->klass; if (RB_TYPE_P(m, T_MODULE)) rb_ary_push(ary, m); } } return ary; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Module#include?;F;7[[I" mod2;T0;[[@nig;T;;;0;[;{;IC; "Returns true if module is included or prepended in mod or one of mod's ancestors. module A end class B include A end class C < B end B.include?(A) #=> true C.include?(A) #=> true A.include?(A) #=> false;T;[o;= ;>I" overload;F;?0;;;@0;:I"include?(module);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@<;![;"I"@return [Boolean];T;#0;$@<;.F;Bi;C0;7[;$@<;![;"I"DReturns true if module is included or prepended in mod or one of mod's ancestors. module A end class B include A end class C < B end B.include?(A) #=> true C.include?(A) #=> true A.include?(A) #=> false @overload include?(module) @return [Boolean];T;#0;$@<;.F;/o;0;1T;2iT;3id;Bi;%@A7;9I"3VALUE rb_mod_include_p(VALUE mod, VALUE mod2) { VALUE p; Check_Type(mod2, T_MODULE); for (p = RCLASS_SUPER(mod); p; p = RCLASS_SUPER(p)) { if (BUILTIN_TYPE(p) == T_ICLASS && !FL_TEST(p, RICLASS_IS_ORIGIN)) { if (RBASIC(p)->klass == mod2) return Qtrue; } } return Qfalse; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Module#name;F;7[;[[@ i};T;;F;0;[;{;IC; "SReturns the name of the module mod. Returns nil for anonymous modules. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I" name;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@<;![;"I"@return [String];T;#0;$@<;.F;Bi;C0;7[;$@<;![;"I"wReturns the name of the module mod. Returns nil for anonymous modules. @overload name @return [String];T;#0;$@<;.F;/o;0;1T;2iv;3iz;%@A7;9I"_VALUE rb_mod_name(VALUE mod) { int permanent; return classname(mod, &permanent); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Module#ancestors;F;7[;[[@ni;T;:ancestors;0;[;{;IC; ">Returns a list of modules included/prepended in mod (including mod itself). module Mod include Math include Comparable prepend Enumerable end Mod.ancestors #=> [Enumerable, Mod, Comparable, Math] Math.ancestors #=> [Math] Enumerable.ancestors #=> [Enumerable] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ancestors;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@<;![;"I"@return [Array];T;#0;$@<;.F;Bi;C0;7[;$@<;![;"I"fReturns a list of modules included/prepended in mod (including mod itself). module Mod include Math include Comparable prepend Enumerable end Mod.ancestors #=> [Enumerable, Mod, Comparable, Math] Math.ancestors #=> [Math] Enumerable.ancestors #=> [Enumerable] @overload ancestors @return [Array];T;#0;$@<;.F;/o;0;1T;2iu;3i;%@A7;9I"VALUE rb_mod_ancestors(VALUE mod) { VALUE p, ary = rb_ary_new(); VALUE refined_class = Qnil; if (FL_TEST(mod, RMODULE_IS_REFINEMENT)) { refined_class = rb_refinement_module_get_refined_class(mod); } for (p = mod; p; p = RCLASS_SUPER(p)) { if (p == refined_class) break; if (p != RCLASS_ORIGIN(p)) continue; if (BUILTIN_TYPE(p) == T_ICLASS) { rb_ary_push(ary, RBASIC(p)->klass); } else { rb_ary_push(ary, p); } } return ary; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Module#attr;F;7[[@90;[[@attr_accessor(name) but deprecated. The last form is equivalent to attr_reader(name) but deprecated. Returns an array of defined method names as symbols. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"attr(name, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@<;![;"I"@return [Array];T;#0;$@<;.F;Bi;C0;7[[I" name;T0[I"...;T0;$@I" overload;F;?0;;;@0;:I"attr(name, true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@<;![;"I"@return [Array];T;#0;$@<;.F;Bi;C0;7[[I" name;T0[I" true;T0;$@I" overload;F;?0;;;@0;:I"attr(name, false);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@<;![;"I"@return [Array];T;#0;$@<;.F;Bi;C0;7[[I" name;T0[I" false;T0;$@<;![;"I"The first form is equivalent to #attr_reader. The second form is equivalent to attr_accessor(name) but deprecated. The last form is equivalent to attr_reader(name) but deprecated. Returns an array of defined method names as symbols. @overload attr(name, ...) @return [Array] @overload attr(name, true) @return [Array] @overload attr(name, false) @return [Array];T;#0;$@<;.F;/o;0;1T;2ib;3in;%@A7;9I"VALUE rb_mod_attr(int argc, VALUE *argv, VALUE klass) { if (argc == 2 && (argv[1] == Qtrue || argv[1] == Qfalse)) { ID id = id_for_attr(klass, argv[0]); VALUE names = rb_ary_new(); rb_category_warning(RB_WARN_CATEGORY_DEPRECATED, "optional boolean argument is obsoleted"); rb_attr(klass, id, 1, RTEST(argv[1]), TRUE); rb_ary_push(names, ID2SYM(id)); if (argv[1] == Qtrue) rb_ary_push(names, ID2SYM(rb_id_attrset(id))); return names; } return rb_mod_attr_reader(argc, argv, klass); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Module#attr_reader;F;7[[@90;[[@attr:name'' on each name in turn. String arguments are converted to symbols. Returns an array of defined method names as symbols. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"attr_reader(symbol, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@6=;![;"I"@return [Array];T;#0;$@6=;.F;Bi;C0;7[[I" symbol;T0[I"...;T0;$@6=o;= ;>I" overload;F;?0;;;@0;:I"attr(symbol, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@6=;![;"I"@return [Array];T;#0;$@6=;.F;Bi;C0;7[[I" symbol;T0[I"...;T0;$@6=o;= ;>I" overload;F;?0;;;@0;:I"attr_reader(string, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@6=;![;"I"@return [Array];T;#0;$@6=;.F;Bi;C0;7[[I" string;T0[I"...;T0;$@6=o;= ;>I" overload;F;?0;;;@0;:I"attr(string, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@6=;![;"I"@return [Array];T;#0;$@6=;.F;Bi;C0;7[[I" string;T0[I"...;T0;$@6=;![;"I"Creates instance variables and corresponding methods that return the value of each instance variable. Equivalent to calling ``attr:name'' on each name in turn. String arguments are converted to symbols. Returns an array of defined method names as symbols. @overload attr_reader(symbol, ...) @return [Array] @overload attr(symbol, ...) @return [Array] @overload attr_reader(string, ...) @return [Array] @overload attr(string, ...) @return [Array];T;#0;$@6=;.F;/o;0;1T;2iF;3iT;%@A7;9I"static VALUE rb_mod_attr_reader(int argc, VALUE *argv, VALUE klass) { int i; VALUE names = rb_ary_new2(argc); for (i=0; isymbol.id2name. String arguments are converted to symbols. Returns an array of defined method names as symbols. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"attr_writer(symbol, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@=;![;"I"@return [Array];T;#0;$@=;.F;Bi;C0;7[[I" symbol;T0[I"...;T0;$@=o;= ;>I" overload;F;?0;;;@0;:I"attr_writer(string, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@=;![;"I"@return [Array];T;#0;$@=;.F;Bi;C0;7[[I" string;T0[I"...;T0;$@=;![;"I"/Creates an accessor method to allow assignment to the attribute symbol.id2name. String arguments are converted to symbols. Returns an array of defined method names as symbols. @overload attr_writer(symbol, ...) @return [Array] @overload attr_writer(string, ...) @return [Array];T;#0;$@=;.F;/o;0;1T;2i;3i;%@A7;9I"+static VALUE rb_mod_attr_writer(int argc, VALUE *argv, VALUE klass) { int i; VALUE names = rb_ary_new2(argc); for (i=0; isymbol.id2name, creating an instance variable (@name) and a corresponding access method to read it. Also creates a method called name= to set the attribute. String arguments are converted to symbols. Returns an array of defined method names as symbols. module Mod attr_accessor(:one, :two) #=> [:one, :one=, :two, :two=] end Mod.instance_methods.sort #=> [:one, :one=, :two, :two=] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"attr_accessor(symbol, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@=;![;"I"@return [Array];T;#0;$@=;.F;Bi;C0;7[[I" symbol;T0[I"...;T0;$@=o;= ;>I" overload;F;?0;;;@0;:I"attr_accessor(string, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@=;![;"I"@return [Array];T;#0;$@=;.F;Bi;C0;7[[I" string;T0[I"...;T0;$@=;![;"I"iDefines a named attribute for this module, where the name is symbol.id2name, creating an instance variable (@name) and a corresponding access method to read it. Also creates a method called name= to set the attribute. String arguments are converted to symbols. Returns an array of defined method names as symbols. module Mod attr_accessor(:one, :two) #=> [:one, :one=, :two, :two=] end Mod.instance_methods.sort #=> [:one, :one=, :two, :two=] @overload attr_accessor(symbol, ...) @return [Array] @overload attr_accessor(string, ...) @return [Array];T;#0;$@=;.F;/o;0;1T;2i;3i;%@A7;9I"Rstatic VALUE rb_mod_attr_accessor(int argc, VALUE *argv, VALUE klass) { int i; VALUE names = rb_ary_new2(argc * 2); for (i=0; i "my string" a.meth1 #=> "hello" a.meth2 #=> "bye" Assign the module to a constant (name starting uppercase) if you want to treat it like a regular module. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new;T;IC; ";T;[;![;"I";T;#0;$@=;.F;Bi;C0;7[;$@=o;= ;>I" overload;F;?0;;E;@0;:I"new;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"mod;T;$@=;![;"I"@yield [mod];T;#0;$@=;.F;Bi;C0;7[;$@=;![;"I"Creates a new anonymous module. If a block is given, it is passed the module object, and the block is evaluated in the context of this module like #module_eval. fred = Module.new do def meth1 "hello" end def meth2 "bye" end end a = "my string" a.extend(fred) #=> "my string" a.meth1 #=> "hello" a.meth2 #=> "bye" Assign the module to a constant (name starting uppercase) if you want to treat it like a regular module. @overload new @overload new @yield [mod];T;#0;$@=;.F;/o;0;1T;2i;3i;%@A7;9I"static VALUE rb_mod_initialize(VALUE module) { rb_module_check_initializable(module); return rb_mod_initialize_exec(module); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#initialize_clone;F;7[[@90;[[@;.F;/o;0;1T;2i;3i;%@A7;9I"static VALUE rb_mod_initialize_clone(int argc, VALUE* argv, VALUE clone) { VALUE ret, orig, opts; rb_scan_args(argc, argv, "1:", &orig, &opts); ret = rb_obj_init_clone(argc, argv, clone); if (OBJ_FROZEN(orig)) rb_class_name(clone); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#instance_methods;F;7[[@90;[[@ni;T;:instance_methods;0;[;{;IC; "Returns an array containing the names of the public and protected instance methods in the receiver. For a module, these are the public and protected methods; for a class, they are the instance (not singleton) methods. If the optional parameter is false, the methods of any ancestors are not included. module A def method1() end end class B include A def method2() end end class C < B def method3() end end A.instance_methods(false) #=> [:method1] B.instance_methods(false) #=> [:method2] B.instance_methods(true).include?(:method1) #=> true C.instance_methods(false) #=> [:method3] C.instance_methods.include?(:method2) #=> true ;T;[o;= ;>I" overload;F;?0;;;@0;:I")instance_methods(include_super=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@>;![;"I"@return [Array];T;#0;$@>;.F;Bi;C0;7[[I"include_super;TI" true;T;$@>;![;"I":Returns an array containing the names of the public and protected instance methods in the receiver. For a module, these are the public and protected methods; for a class, they are the instance (not singleton) methods. If the optional parameter is false, the methods of any ancestors are not included. module A def method1() end end class B include A def method2() end end class C < B def method3() end end A.instance_methods(false) #=> [:method1] B.instance_methods(false) #=> [:method2] B.instance_methods(true).include?(:method1) #=> true C.instance_methods(false) #=> [:method3] C.instance_methods.include?(:method2) #=> true @overload instance_methods(include_super=true) @return [Array];T;#0;$@>;.F;/o;0;1T;2il;3i;%@A7;9I"VALUE rb_class_instance_methods(int argc, const VALUE *argv, VALUE mod) { return class_instance_method_list(argc, argv, mod, 0, ins_methods_i); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"#Module#public_instance_methods;F;7[[@90;[[@ni;T;:public_instance_methods;0;[;{;IC; "Returns a list of the public instance methods defined in mod. If the optional parameter is false, the methods of any ancestors are not included. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"0public_instance_methods(include_super=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@<>;![;"I"@return [Array];T;#0;$@<>;.F;Bi;C0;7[[I"include_super;TI" true;T;$@<>;![;"I"Returns a list of the public instance methods defined in mod. If the optional parameter is false, the methods of any ancestors are not included. @overload public_instance_methods(include_super=true) @return [Array];T;#0;$@<>;.F;/o;0;1T;2i;3i;%@A7;9I"VALUE rb_class_public_instance_methods(int argc, const VALUE *argv, VALUE mod) { return class_instance_method_list(argc, argv, mod, 0, ins_methods_pub_i); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"&Module#protected_instance_methods;F;7[[@90;[[@ni;T;:protected_instance_methods;0;[;{;IC; "Returns a list of the protected instance methods defined in mod. If the optional parameter is false, the methods of any ancestors are not included. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"3protected_instance_methods(include_super=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@[>;![;"I"@return [Array];T;#0;$@[>;.F;Bi;C0;7[[I"include_super;TI" true;T;$@[>;![;"I"Returns a list of the protected instance methods defined in mod. If the optional parameter is false, the methods of any ancestors are not included. @overload protected_instance_methods(include_super=true) @return [Array];T;#0;$@[>;.F;/o;0;1T;2i;3i;%@A7;9I"VALUE rb_class_protected_instance_methods(int argc, const VALUE *argv, VALUE mod) { return class_instance_method_list(argc, argv, mod, 0, ins_methods_prot_i); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"$Module#private_instance_methods;F;7[[@90;[[@ni;T;:private_instance_methods;0;[;{;IC; "cReturns a list of the private instance methods defined in mod. If the optional parameter is false, the methods of any ancestors are not included. module Mod def method1() end private :method1 def method2() end end Mod.instance_methods #=> [:method2] Mod.private_instance_methods #=> [:method1] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"1private_instance_methods(include_super=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@z>;![;"I"@return [Array];T;#0;$@z>;.F;Bi;C0;7[[I"include_super;TI" true;T;$@z>;![;"I"Returns a list of the private instance methods defined in mod. If the optional parameter is false, the methods of any ancestors are not included. module Mod def method1() end private :method1 def method2() end end Mod.instance_methods #=> [:method2] Mod.private_instance_methods #=> [:method1] @overload private_instance_methods(include_super=true) @return [Array];T;#0;$@z>;.F;/o;0;1T;2i;3i;%@A7;9I"VALUE rb_class_private_instance_methods(int argc, const VALUE *argv, VALUE mod) { return class_instance_method_list(argc, argv, mod, 0, ins_methods_priv_i); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Module#constants;F;7[[@90;[[@ i ;T;:constants;0;[;{;IC; "Returns an array of the names of the constants accessible in mod. This includes the names of constants in any included modules (example at start of section), unless the inherit parameter is set to false. The implementation makes no guarantees about the order in which the constants are yielded. IO.constants.include?(:SYNC) #=> true IO.constants(false).include?(:SYNC) #=> false Also see Module#const_defined?. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"constants(inherit=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@>;![;"I"@return [Array];T;#0;$@>;.F;Bi;C0;7[[I" inherit;TI" true;T;$@>;![;"I"Returns an array of the names of the constants accessible in mod. This includes the names of constants in any included modules (example at start of section), unless the inherit parameter is set to false. The implementation makes no guarantees about the order in which the constants are yielded. IO.constants.include?(:SYNC) #=> true IO.constants(false).include?(:SYNC) #=> false Also see Module#const_defined?. @overload constants(inherit=true) @return [Array];T;#0;$@>;.F;/o;0;1T;2i ;3i ;%@A7;9I"VALUE rb_mod_constants(int argc, const VALUE *argv, VALUE mod) { bool inherit = true; if (rb_check_arity(argc, 0, 1)) inherit = RTEST(argv[0]); if (inherit) { return rb_const_list(rb_mod_const_of(mod, 0)); } else { return rb_local_constants(mod); } };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Module#const_get;F;7[[@90;[[@mod. If +inherit+ is set, the lookup will also search the ancestors (and +Object+ if mod is a +Module+). The value of the constant is returned if a definition is found, otherwise a +NameError+ is raised. Math.const_get(:PI) #=> 3.14159265358979 This method will recursively look up constant names if a namespaced class name is provided. For example: module Foo; class Bar; end end Object.const_get 'Foo::Bar' The +inherit+ flag is respected on each lookup. For example: module Foo class Bar VAL = 10 end class Baz < Bar; end end Object.const_get 'Foo::Baz::VAL' # => 10 Object.const_get 'Foo::Baz::VAL', false # => NameError If the argument is not a valid constant name a +NameError+ will be raised with a warning "wrong constant name". Object.const_get 'foobar' #=> NameError: wrong constant name foobar ;T;[o;= ;>I" overload;F;?0;;;@0;:I"!const_get(sym, inherit=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@>;![;"I"@return [Object];T;#0;$@>;.F;Bi;C0;7[[I"sym;T0[I" inherit;TI" true;T;$@>o;= ;>I" overload;F;?0;;;@0;:I"!const_get(str, inherit=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@>;![;"I"@return [Object];T;#0;$@>;.F;Bi;C0;7[[I"str;T0[I" inherit;TI" true;T;$@>;![;"I"Checks for a constant with the given name in mod. If +inherit+ is set, the lookup will also search the ancestors (and +Object+ if mod is a +Module+). The value of the constant is returned if a definition is found, otherwise a +NameError+ is raised. Math.const_get(:PI) #=> 3.14159265358979 This method will recursively look up constant names if a namespaced class name is provided. For example: module Foo; class Bar; end end Object.const_get 'Foo::Bar' The +inherit+ flag is respected on each lookup. For example: module Foo class Bar VAL = 10 end class Baz < Bar; end end Object.const_get 'Foo::Baz::VAL' # => 10 Object.const_get 'Foo::Baz::VAL', false # => NameError If the argument is not a valid constant name a +NameError+ will be raised with a warning "wrong constant name". Object.const_get 'foobar' #=> NameError: wrong constant name foobar @overload const_get(sym, inherit=true) @return [Object] @overload const_get(str, inherit=true) @return [Object];T;#0;$@>;.F;/o;0;1T;2i;3i;%@A7;9I"static VALUE rb_mod_const_get(int argc, VALUE *argv, VALUE mod) { VALUE name, recur; rb_encoding *enc; const char *pbeg, *p, *path, *pend; ID id; rb_check_arity(argc, 1, 2); name = argv[0]; recur = (argc == 1) ? Qtrue : argv[1]; if (SYMBOL_P(name)) { if (!rb_is_const_sym(name)) goto wrong_name; id = rb_check_id(&name); if (!id) return rb_const_missing(mod, name); return RTEST(recur) ? rb_const_get(mod, id) : rb_const_get_at(mod, id); } path = StringValuePtr(name); enc = rb_enc_get(name); if (!rb_enc_asciicompat(enc)) { rb_raise(rb_eArgError, "invalid class path encoding (non ASCII)"); } pbeg = p = path; pend = path + RSTRING_LEN(name); if (p >= pend || !*p) { goto wrong_name; } if (p + 2 < pend && p[0] == ':' && p[1] == ':') { mod = rb_cObject; p += 2; pbeg = p; } while (p < pend) { VALUE part; long len, beglen; while (p < pend && *p != ':') p++; if (pbeg == p) goto wrong_name; id = rb_check_id_cstr(pbeg, len = p-pbeg, enc); beglen = pbeg-path; if (p < pend && p[0] == ':') { if (p + 2 >= pend || p[1] != ':') goto wrong_name; p += 2; pbeg = p; } if (!RB_TYPE_P(mod, T_MODULE) && !RB_TYPE_P(mod, T_CLASS)) { rb_raise(rb_eTypeError, "%"PRIsVALUE" does not refer to class/module", QUOTE(name)); } if (!id) { part = rb_str_subseq(name, beglen, len); OBJ_FREEZE(part); if (!rb_is_const_name(part)) { name = part; goto wrong_name; } else if (!rb_method_basic_definition_p(CLASS_OF(mod), id_const_missing)) { part = rb_str_intern(part); mod = rb_const_missing(mod, part); continue; } else { rb_mod_const_missing(mod, part); } } if (!rb_is_const_id(id)) { name = ID2SYM(id); goto wrong_name; } #if 0 mod = rb_const_get_0(mod, id, beglen > 0 || !RTEST(recur), RTEST(recur), FALSE); #else if (!RTEST(recur)) { mod = rb_const_get_at(mod, id); } else if (beglen == 0) { mod = rb_const_get(mod, id); } else { mod = rb_const_get_from(mod, id); } #endif } return mod; wrong_name: rb_name_err_raise(wrong_constant_name, mod, name); UNREACHABLE_RETURN(Qundef); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#const_set;F;7[[I" name;T0[I" value;T0;[[@ 3.14285714285714 Math::HIGH_SCHOOL_PI - Math::PI #=> 0.00126448926734968 If +sym+ or +str+ is not a valid constant name a +NameError+ will be raised with a warning "wrong constant name". Object.const_set('foobar', 42) #=> NameError: wrong constant name foobar ;T;[o;= ;>I" overload;F;?0;;;@0;:I"const_set(sym, obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@>;![;"I"@return [Object];T;#0;$@>;.F;Bi;C0;7[[I"sym;T0[I"obj;T0;$@>o;= ;>I" overload;F;?0;;;@0;:I"const_set(str, obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@>;![;"I"@return [Object];T;#0;$@>;.F;Bi;C0;7[[I"str;T0[I"obj;T0;$@>;![;"I"ASets the named constant to the given object, returning that object. Creates a new constant if no constant with the given name previously existed. Math.const_set("HIGH_SCHOOL_PI", 22.0/7.0) #=> 3.14285714285714 Math::HIGH_SCHOOL_PI - Math::PI #=> 0.00126448926734968 If +sym+ or +str+ is not a valid constant name a +NameError+ will be raised with a warning "wrong constant name". Object.const_set('foobar', 42) #=> NameError: wrong constant name foobar @overload const_set(sym, obj) @return [Object] @overload const_set(str, obj) @return [Object];T;#0;$@>;.F;/o;0;1T;2iK ;3i\ ;%@A7;9I"static VALUE rb_mod_const_set(VALUE mod, VALUE name, VALUE value) { ID id = id_for_var(mod, name, const); if (!id) id = rb_intern_str(name); rb_const_set(mod, id, value); return value; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#const_defined?;F;7[[@90;[[@ true, found in Float itself Float.const_defined?("String") #=> true, found in Object (ancestor) BasicObject.const_defined?(:Hash) #=> false If _mod_ is a +Module+, additionally +Object+ and its ancestors are checked: Math.const_defined?(:String) #=> true, found in Object In each of the checked classes or modules, if the constant is not present but there is an autoload for it, +true+ is returned directly without autoloading: module Admin autoload :User, 'admin/user' end Admin.const_defined?(:User) #=> true If the constant is not found the callback +const_missing+ is *not* called and the method returns +false+. If +inherit+ is false, the lookup only checks the constants in the receiver: IO.const_defined?(:SYNC) #=> true, found in File::Constants (ancestor) IO.const_defined?(:SYNC, false) #=> false, not found in IO itself In this case, the same logic for autoloading applies. If the argument is not a valid constant name a +NameError+ is raised with the message "wrong constant name _name_": Hash.const_defined? 'foobar' #=> NameError: wrong constant name foobar;T;[o;= ;>I" overload;F;?0;;;@0;:I"&const_defined?(sym, inherit=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@?;![;"I"@return [Boolean];T;#0;$@?;.F;Bi;C0;7[[I"sym;T0[I" inherit;TI" true;T;$@?o;= ;>I" overload;F;?0;;;@0;:I"&const_defined?(str, inherit=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@?;![;"I"@return [Boolean];T;#0;$@?;.F;Bi;C0;7[[I"str;T0[I" inherit;TI" true;T;$@?;![;"I"^Says whether _mod_ or its ancestors have a constant with the given name: Float.const_defined?(:EPSILON) #=> true, found in Float itself Float.const_defined?("String") #=> true, found in Object (ancestor) BasicObject.const_defined?(:Hash) #=> false If _mod_ is a +Module+, additionally +Object+ and its ancestors are checked: Math.const_defined?(:String) #=> true, found in Object In each of the checked classes or modules, if the constant is not present but there is an autoload for it, +true+ is returned directly without autoloading: module Admin autoload :User, 'admin/user' end Admin.const_defined?(:User) #=> true If the constant is not found the callback +const_missing+ is *not* called and the method returns +false+. If +inherit+ is false, the lookup only checks the constants in the receiver: IO.const_defined?(:SYNC) #=> true, found in File::Constants (ancestor) IO.const_defined?(:SYNC, false) #=> false, not found in IO itself In this case, the same logic for autoloading applies. If the argument is not a valid constant name a +NameError+ is raised with the message "wrong constant name _name_": Hash.const_defined? 'foobar' #=> NameError: wrong constant name foobar @overload const_defined?(sym, inherit=true) @return [Boolean] @overload const_defined?(str, inherit=true) @return [Boolean];T;#0;$@?;.F;/o;0;1T;2ih ;3i ;Bi;%@A7;9I" static VALUE rb_mod_const_defined(int argc, VALUE *argv, VALUE mod) { VALUE name, recur; rb_encoding *enc; const char *pbeg, *p, *path, *pend; ID id; rb_check_arity(argc, 1, 2); name = argv[0]; recur = (argc == 1) ? Qtrue : argv[1]; if (SYMBOL_P(name)) { if (!rb_is_const_sym(name)) goto wrong_name; id = rb_check_id(&name); if (!id) return Qfalse; return RTEST(recur) ? rb_const_defined(mod, id) : rb_const_defined_at(mod, id); } path = StringValuePtr(name); enc = rb_enc_get(name); if (!rb_enc_asciicompat(enc)) { rb_raise(rb_eArgError, "invalid class path encoding (non ASCII)"); } pbeg = p = path; pend = path + RSTRING_LEN(name); if (p >= pend || !*p) { goto wrong_name; } if (p + 2 < pend && p[0] == ':' && p[1] == ':') { mod = rb_cObject; p += 2; pbeg = p; } while (p < pend) { VALUE part; long len, beglen; while (p < pend && *p != ':') p++; if (pbeg == p) goto wrong_name; id = rb_check_id_cstr(pbeg, len = p-pbeg, enc); beglen = pbeg-path; if (p < pend && p[0] == ':') { if (p + 2 >= pend || p[1] != ':') goto wrong_name; p += 2; pbeg = p; } if (!id) { part = rb_str_subseq(name, beglen, len); OBJ_FREEZE(part); if (!rb_is_const_name(part)) { name = part; goto wrong_name; } else { return Qfalse; } } if (!rb_is_const_id(id)) { name = ID2SYM(id); goto wrong_name; } #if 0 mod = rb_const_search(mod, id, beglen > 0 || !RTEST(recur), RTEST(recur), FALSE); if (mod == Qundef) return Qfalse; #else if (!RTEST(recur)) { if (!rb_const_defined_at(mod, id)) return Qfalse; if (p == pend) return Qtrue; mod = rb_const_get_at(mod, id); } else if (beglen == 0) { if (!rb_const_defined(mod, id)) return Qfalse; if (p == pend) return Qtrue; mod = rb_const_get(mod, id); } else { if (!rb_const_defined_from(mod, id)) return Qfalse; if (p == pend) return Qtrue; mod = rb_const_get_from(mod, id); } #endif if (p < pend && !RB_TYPE_P(mod, T_MODULE) && !RB_TYPE_P(mod, T_CLASS)) { rb_raise(rb_eTypeError, "%"PRIsVALUE" does not refer to class/module", QUOTE(name)); } } return Qtrue; wrong_name: rb_name_err_raise(wrong_constant_name, mod, name); UNREACHABLE_RETURN(Qundef); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Module#const_source_location;F;7[[@90;[[@mod.ancestors (+true+ by default). # test.rb: class A # line 1 C1 = 1 C2 = 2 end module M # line 6 C3 = 3 end class B < A # line 10 include M C4 = 4 end class A # continuation of A definition C2 = 8 # constant redefinition; warned yet allowed end p B.const_source_location('C4') # => ["test.rb", 12] p B.const_source_location('C3') # => ["test.rb", 7] p B.const_source_location('C1') # => ["test.rb", 2] p B.const_source_location('C3', false) # => nil -- don't lookup in ancestors p A.const_source_location('C2') # => ["test.rb", 16] -- actual (last) definition place p Object.const_source_location('B') # => ["test.rb", 10] -- top-level constant could be looked through Object p Object.const_source_location('A') # => ["test.rb", 1] -- class reopening is NOT considered new definition p B.const_source_location('A') # => ["test.rb", 1] -- because Object is in ancestors p M.const_source_location('A') # => ["test.rb", 1] -- Object is not ancestor, but additionally checked for modules p Object.const_source_location('A::C1') # => ["test.rb", 2] -- nesting is supported p Object.const_source_location('String') # => [] -- constant is defined in C code ;T;[o;= ;>I" overload;F;?0;;;@0;:I"-const_source_location(sym, inherit=true);T;IC; ";T;[o;A ;>I" return;F;?I"];T;0;@[I" Array;TI" Integer;T;$@R?;![;"I"@return [Array, Integer]];T;#0;$@R?;.F;Bi;C0;7[[I"sym;T0[I" inherit;TI" true;T;$@R?o;= ;>I" overload;F;?0;;;@0;:I"-const_source_location(str, inherit=true);T;IC; ";T;[o;A ;>I" return;F;?I"];T;0;@[I" Array;TI" Integer;T;$@R?;![;"I"@return [Array, Integer]];T;#0;$@R?;.F;Bi;C0;7[[I"str;T0[I" inherit;TI" true;T;$@R?;![;"I"^Returns the Ruby source filename and line number containing the definition of the constant specified. If the named constant is not found, +nil+ is returned. If the constant is found, but its source location can not be extracted (constant is defined in C code), empty array is returned. _inherit_ specifies whether to lookup in mod.ancestors (+true+ by default). # test.rb: class A # line 1 C1 = 1 C2 = 2 end module M # line 6 C3 = 3 end class B < A # line 10 include M C4 = 4 end class A # continuation of A definition C2 = 8 # constant redefinition; warned yet allowed end p B.const_source_location('C4') # => ["test.rb", 12] p B.const_source_location('C3') # => ["test.rb", 7] p B.const_source_location('C1') # => ["test.rb", 2] p B.const_source_location('C3', false) # => nil -- don't lookup in ancestors p A.const_source_location('C2') # => ["test.rb", 16] -- actual (last) definition place p Object.const_source_location('B') # => ["test.rb", 10] -- top-level constant could be looked through Object p Object.const_source_location('A') # => ["test.rb", 1] -- class reopening is NOT considered new definition p B.const_source_location('A') # => ["test.rb", 1] -- because Object is in ancestors p M.const_source_location('A') # => ["test.rb", 1] -- Object is not ancestor, but additionally checked for modules p Object.const_source_location('A::C1') # => ["test.rb", 2] -- nesting is supported p Object.const_source_location('String') # => [] -- constant is defined in C code @overload const_source_location(sym, inherit=true) @return [Array, Integer]] @overload const_source_location(str, inherit=true) @return [Array, Integer]];T;#0;$@R?;.F;/o;0;1T;2i ;3i0 ;%@A7;9I" static VALUE rb_mod_const_source_location(int argc, VALUE *argv, VALUE mod) { VALUE name, recur, loc = Qnil; rb_encoding *enc; const char *pbeg, *p, *path, *pend; ID id; rb_check_arity(argc, 1, 2); name = argv[0]; recur = (argc == 1) ? Qtrue : argv[1]; if (SYMBOL_P(name)) { if (!rb_is_const_sym(name)) goto wrong_name; id = rb_check_id(&name); if (!id) return Qnil; return RTEST(recur) ? rb_const_source_location(mod, id) : rb_const_source_location_at(mod, id); } path = StringValuePtr(name); enc = rb_enc_get(name); if (!rb_enc_asciicompat(enc)) { rb_raise(rb_eArgError, "invalid class path encoding (non ASCII)"); } pbeg = p = path; pend = path + RSTRING_LEN(name); if (p >= pend || !*p) { goto wrong_name; } if (p + 2 < pend && p[0] == ':' && p[1] == ':') { mod = rb_cObject; p += 2; pbeg = p; } while (p < pend) { VALUE part; long len, beglen; while (p < pend && *p != ':') p++; if (pbeg == p) goto wrong_name; id = rb_check_id_cstr(pbeg, len = p-pbeg, enc); beglen = pbeg-path; if (p < pend && p[0] == ':') { if (p + 2 >= pend || p[1] != ':') goto wrong_name; p += 2; pbeg = p; } if (!id) { part = rb_str_subseq(name, beglen, len); OBJ_FREEZE(part); if (!rb_is_const_name(part)) { name = part; goto wrong_name; } else { return Qnil; } } if (!rb_is_const_id(id)) { name = ID2SYM(id); goto wrong_name; } if (p < pend) { if (RTEST(recur)) { mod = rb_const_get(mod, id); } else { mod = rb_const_get_at(mod, id); } if (!RB_TYPE_P(mod, T_MODULE) && !RB_TYPE_P(mod, T_CLASS)) { rb_raise(rb_eTypeError, "%"PRIsVALUE" does not refer to class/module", QUOTE(name)); } } else { if (RTEST(recur)) { loc = rb_const_source_location(mod, id); } else { loc = rb_const_source_location_at(mod, id); } break; } recur = Qfalse; } return loc; wrong_name: rb_name_err_raise(wrong_constant_name, mod, name); UNREACHABLE_RETURN(Qundef); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#remove_const;F;7[[I" name;T0;[[@ i ;T;:remove_const;0;[;{;IC; "Removes the definition of the given constant, returning that constant's previous value. If that constant referred to a module, this will not change that module's name and can lead to confusion. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"remove_const(sym);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@?;![;"I"@return [Object];T;#0;$@?;.F;Bi;C0;7[[I"sym;T0;$@?;![;"I"Removes the definition of the given constant, returning that constant's previous value. If that constant referred to a module, this will not change that module's name and can lead to confusion. @overload remove_const(sym) @return [Object];T;#0;$@?;.F;/o;0;1T;2i ;3i ;%@A7;9I"VALUE rb_mod_remove_const(VALUE mod, VALUE name) { const ID id = id_for_var(mod, name, a, constant); if (!id) { undefined_constant(mod, name); } return rb_const_remove(mod, id); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Module#const_missing;F;7[[I" name;T0;[[@ i;T;:const_missing;0;[;{;IC; "Invoked when a reference is made to an undefined constant in mod. It is passed a symbol for the undefined constant, and returns a value to be used for that constant. The following code is an example of the same: def Foo.const_missing(name) name # return the constant name as Symbol end Foo::UNDEFINED_CONST #=> :UNDEFINED_CONST: symbol returned In the next example when a reference is made to an undefined constant, it attempts to load a file whose name is the lowercase version of the constant (thus class Fred is assumed to be in file fred.rb). If found, it returns the loaded class. It therefore implements an autoload feature similar to Kernel#autoload and Module#autoload. def Object.const_missing(name) @looked_for ||= {} str_name = name.to_s raise "Class not found: #{name}" if @looked_for[str_name] @looked_for[str_name] = 1 file = str_name.downcase require file klass = const_get(name) return klass if klass raise "Class not found: #{name}" end ;T;[o;= ;>I" overload;F;?0;;;@0;:I"const_missing(sym);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@?;![;"I"@return [Object];T;#0;$@?;.F;Bi;C0;7[[I"sym;T0;$@?;![;"I"GInvoked when a reference is made to an undefined constant in mod. It is passed a symbol for the undefined constant, and returns a value to be used for that constant. The following code is an example of the same: def Foo.const_missing(name) name # return the constant name as Symbol end Foo::UNDEFINED_CONST #=> :UNDEFINED_CONST: symbol returned In the next example when a reference is made to an undefined constant, it attempts to load a file whose name is the lowercase version of the constant (thus class Fred is assumed to be in file fred.rb). If found, it returns the loaded class. It therefore implements an autoload feature similar to Kernel#autoload and Module#autoload. def Object.const_missing(name) @looked_for ||= {} str_name = name.to_s raise "Class not found: #{name}" if @looked_for[str_name] @looked_for[str_name] = 1 file = str_name.downcase require file klass = const_get(name) return klass if klass raise "Class not found: #{name}" end @overload const_missing(sym) @return [Object];T;#0;$@?;.F;/o;0;1T;2i;3i;%@A7;9I"2VALUE rb_mod_const_missing(VALUE klass, VALUE name) { VALUE ref = GET_EC()->private_const_reference; rb_vm_pop_cfunc_frame(); if (ref) { rb_name_err_raise("private constant %2$s::%1$s referenced", ref, name); } uninitialized_constant(klass, name); UNREACHABLE_RETURN(Qnil); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Module#class_variables;F;7[[@90;[[@ if;T;:class_variables;0;[;{;IC; "Returns an array of the names of class variables in mod. This includes the names of class variables in any included modules, unless the inherit parameter is set to false. class One @@var1 = 1 end class Two < One @@var2 = 2 end One.class_variables #=> [:@@var1] Two.class_variables #=> [:@@var2, :@@var1] Two.class_variables(false) #=> [:@@var2] ;T;[o;= ;>I" overload;F;?0;;;@0;:I""class_variables(inherit=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@?;![;"I"@return [Array];T;#0;$@?;.F;Bi;C0;7[[I" inherit;TI" true;T;$@?;![;"I"Returns an array of the names of class variables in mod. This includes the names of class variables in any included modules, unless the inherit parameter is set to false. class One @@var1 = 1 end class Two < One @@var2 = 2 end One.class_variables #=> [:@@var1] Two.class_variables #=> [:@@var2, :@@var1] Two.class_variables(false) #=> [:@@var2] @overload class_variables(inherit=true) @return [Array];T;#0;$@?;.F;/o;0;1T;2iR;3ic;%@A7;9I"0VALUE rb_mod_class_variables(int argc, const VALUE *argv, VALUE mod) { bool inherit = true; st_table *tbl; if (rb_check_arity(argc, 0, 1)) inherit = RTEST(argv[0]); if (inherit) { tbl = mod_cvar_of(mod, 0); } else { tbl = mod_cvar_at(mod, 0); } return cvar_list(tbl); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"!Module#remove_class_variable;F;7[[I" name;T0;[[@ i;T;:remove_class_variable;0;[;{;IC; "Removes the named class variable from the receiver, returning that variable's value. class Example @@var = 99 puts remove_class_variable(:@@var) p(defined? @@var) end produces: 99 nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I"remove_class_variable(sym);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@?;![;"I"@return [Object];T;#0;$@?;.F;Bi;C0;7[[I"sym;T0;$@?;![;"I"Removes the named class variable from the receiver, returning that variable's value. class Example @@var = 99 puts remove_class_variable(:@@var) p(defined? @@var) end produces: 99 nil @overload remove_class_variable(sym) @return [Object];T;#0;$@?;.F;/o;0;1T;2iv;3i;%@A7;9I"VVALUE rb_mod_remove_cvar(VALUE mod, VALUE name) { const ID id = id_for_var_message(mod, name, class, "wrong class variable name %1$s"); st_data_t val, n = id; if (!id) { goto not_defined; } rb_check_frozen(mod); if (RCLASS_IV_TBL(mod) && st_delete(RCLASS_IV_TBL(mod), &n, &val)) { return (VALUE)val; } if (rb_cvar_defined(mod, id)) { rb_name_err_raise("cannot remove %1$s for %2$s", mod, ID2SYM(id)); } not_defined: rb_name_err_raise("class variable %1$s not defined for %2$s", mod, name); UNREACHABLE_RETURN(Qundef); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Module#class_variable_get;F;7[[I"iv;T0;[[@@@ part of the variable name should be included for regular class variables. String arguments are converted to symbols. class Fred @@foo = 99 end Fred.class_variable_get(:@@foo) #=> 99 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"class_variable_get(symbol);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@@;![;"I"@return [Object];T;#0;$@@;.F;Bi;C0;7[[I" symbol;T0;$@@o;= ;>I" overload;F;?0;;;@0;:I"class_variable_get(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@@;![;"I"@return [Object];T;#0;$@@;.F;Bi;C0;7[[I" string;T0;$@@;![;"I"Returns the value of the given class variable (or throws a NameError exception). The @@ part of the variable name should be included for regular class variables. String arguments are converted to symbols. class Fred @@foo = 99 end Fred.class_variable_get(:@@foo) #=> 99 @overload class_variable_get(symbol) @return [Object] @overload class_variable_get(string) @return [Object];T;#0;$@@;.F;/o;0;1T;2i ;3i ;%@A7;9I"static VALUE rb_mod_cvar_get(VALUE obj, VALUE iv) { ID id = id_for_var(obj, iv, class); if (!id) { rb_name_err_raise("uninitialized class variable %1$s in %2$s", obj, iv); } return rb_cvar_get(obj, id); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#class_variable_set;F;7[[I"iv;T0[I"val;T0;[[@symbol to the given object. If the class variable name is passed as a string, that string is converted to a symbol. class Fred @@foo = 99 def foo @@foo end end Fred.class_variable_set(:@@foo, 101) #=> 101 Fred.new.foo #=> 101 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"$class_variable_set(symbol, obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@1@;![;"I"@return [Object];T;#0;$@1@;.F;Bi;C0;7[[I" symbol;T0[I"obj;T0;$@1@o;= ;>I" overload;F;?0;;;@0;:I"$class_variable_set(string, obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@1@;![;"I"@return [Object];T;#0;$@1@;.F;Bi;C0;7[[I" string;T0[I"obj;T0;$@1@;![;"I"Sets the class variable named by symbol to the given object. If the class variable name is passed as a string, that string is converted to a symbol. class Fred @@foo = 99 def foo @@foo end end Fred.class_variable_set(:@@foo, 101) #=> 101 Fred.new.foo #=> 101 @overload class_variable_set(symbol, obj) @return [Object] @overload class_variable_set(string, obj) @return [Object];T;#0;$@1@;.F;/o;0;1T;2i ;3i$ ;%@A7;9I"static VALUE rb_mod_cvar_set(VALUE obj, VALUE iv, VALUE val) { ID id = id_for_var(obj, iv, class); if (!id) id = rb_intern_str(iv); rb_cvar_set(obj, id, val); return val; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#Module#class_variable_defined?;F;7[[I"iv;T0;[[@true if the given class variable is defined in obj. String arguments are converted to symbols. class Fred @@foo = 99 end Fred.class_variable_defined?(:@@foo) #=> true Fred.class_variable_defined?(:@@bar) #=> false;T;[o;= ;>I" overload;F;?0;;;@0;:I"$class_variable_defined?(symbol);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@e@;![;"I"@return [Boolean];T;#0;$@e@;.F;Bi;C0;7[[I" symbol;T0;$@e@o;= ;>I" overload;F;?0;;;@0;:I"$class_variable_defined?(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@e@;![;"I"@return [Boolean];T;#0;$@e@;.F;Bi;C0;7[[I" string;T0;$@e@;![;"I"Returns true if the given class variable is defined in obj. String arguments are converted to symbols. class Fred @@foo = 99 end Fred.class_variable_defined?(:@@foo) #=> true Fred.class_variable_defined?(:@@bar) #=> false @overload class_variable_defined?(symbol) @return [Boolean] @overload class_variable_defined?(string) @return [Boolean];T;#0;$@e@;.F;/o;0;1T;2i/ ;3i= ;Bi;%@A7;9I"static VALUE rb_mod_cvar_defined(VALUE obj, VALUE iv) { ID id = id_for_var(obj, iv, class); if (!id) { return Qfalse; } return rb_cvar_defined(obj, id); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#public_constant;F;7[[@90;[[@ i ;T;:public_constant;0;[;{;IC; "/Makes a list of existing constants public. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"!public_constant(symbol, ...);T;IC; ";T;[;![;"I";T;#0;$@@;.F;Bi;C0;7[[I" symbol;T0[I"...;T0;$@@;![;"I"XMakes a list of existing constants public. @overload public_constant(symbol, ...);T;#0;$@@;.F;/o;0;1T;2i ;3i ;%@A7;9I"VALUE rb_mod_public_constant(int argc, const VALUE *argv, VALUE obj) { set_const_visibility(obj, argc, argv, CONST_PUBLIC, CONST_VISIBILITY_MASK); return obj; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Module#private_constant;F;7[[@90;[[@ i ;T;:private_constant;0;[;{;IC; "0Makes a list of existing constants private. ;T;[o;= ;>I" overload;F;?0;;;@0;:I""private_constant(symbol, ...);T;IC; ";T;[;![;"I";T;#0;$@@;.F;Bi;C0;7[[I" symbol;T0[I"...;T0;$@@;![;"I"ZMakes a list of existing constants private. @overload private_constant(symbol, ...);T;#0;$@@;.F;/o;0;1T;2i ;3i ;%@A7;9I"VALUE rb_mod_private_constant(int argc, const VALUE *argv, VALUE obj) { set_const_visibility(obj, argc, argv, CONST_PRIVATE, CONST_VISIBILITY_MASK); return obj; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Module#deprecate_constant;F;7[[@90;[[@ i7 ;T;:deprecate_constant;0;[;{;IC; "LMakes a list of existing constants deprecated. Attempt to refer to them will produce a warning. module HTTP NotFound = Exception.new NOT_FOUND = NotFound # previous version of the library used this name deprecate_constant :NOT_FOUND end HTTP::NOT_FOUND # warning: constant HTTP::NOT_FOUND is deprecated ;T;[o;= ;>I" overload;F;?0;;;@0;:I"$deprecate_constant(symbol, ...);T;IC; ";T;[;![;"I";T;#0;$@@;.F;Bi;C0;7[[I" symbol;T0[I"...;T0;$@@;![;"I"yMakes a list of existing constants deprecated. Attempt to refer to them will produce a warning. module HTTP NotFound = Exception.new NOT_FOUND = NotFound # previous version of the library used this name deprecate_constant :NOT_FOUND end HTTP::NOT_FOUND # warning: constant HTTP::NOT_FOUND is deprecated @overload deprecate_constant(symbol, ...);T;#0;$@@;.F;/o;0;1T;2i$ ;3i3 ;%@A7;9I"VALUE rb_mod_deprecate_constant(int argc, const VALUE *argv, VALUE obj) { set_const_visibility(obj, argc, argv, CONST_DEPRECATED, CONST_DEPRECATED); return obj; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Module#singleton_class?;F;7[;[[@true if mod is a singleton class or false if it is an ordinary class or module. class C end C.singleton_class? #=> false C.singleton_class.singleton_class? #=> true;T;[o;= ;>I" overload;F;?0;;;@0;:I"singleton_class?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@@;![;"I"@return [Boolean];T;#0;$@@;.F;Bi;C0;7[;$@@;![;"I"Returns true if mod is a singleton class or false if it is an ordinary class or module. class C end C.singleton_class? #=> false C.singleton_class.singleton_class? #=> true @overload singleton_class? @return [Boolean];T;#0;$@@;.F;/o;0;1T;2iJ ;3iT ;Bi;%@A7;9I"}static VALUE rb_mod_singleton_p(VALUE klass) { return RBOOL(RB_TYPE_P(klass, T_CLASS) && FL_TEST(klass, FL_SINGLETON)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#module_exec;F;7[[@90;[[@Ciu;T;:module_exec;0;[;{;IC; "Evaluates the given block in the context of the class/module. The method defined in the block will belong to the receiver. Any arguments passed to the method will be passed to the block. This can be used if the block needs to access instance variables. class Thing end Thing.class_exec{ def hello() "Hello there!" end } puts Thing.new.hello() produces: Hello there! ;T;[o;= ;>I" overload;F;?0;;;@0;:I"module_exec(arg...);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" var...;T;$@@o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@@;![;"I"%@yield [var...] @return [Object];T;#0;$@@;.F;Bi;C0;7[[I" arg...;T0;$@@o;= ;>I" overload;F;?0;:class_exec;@0;:I"class_exec(arg...);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" var...;T;$@@o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@@;![;"I"%@yield [var...] @return [Object];T;#0;$@@;.F;Bi;C0;7[[I" arg...;T0;$@@;![;"I"Evaluates the given block in the context of the class/module. The method defined in the block will belong to the receiver. Any arguments passed to the method will be passed to the block. This can be used if the block needs to access instance variables. class Thing end Thing.class_exec{ def hello() "Hello there!" end } puts Thing.new.hello() produces: Hello there! @overload module_exec(arg...) @yield [var...] @return [Object] @overload class_exec(arg...) @yield [var...] @return [Object];T;#0;$@@;.F;/o;0;1T;2i_;3iu;%@A7;9I"static VALUE rb_mod_module_exec_internal(int argc, const VALUE *argv, VALUE mod) { return yield_under(mod, FALSE, argc, argv, RB_PASS_CALLED_KEYWORDS); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#class_exec;F;7[[@90;[[@Ciu;T;;;0;[;{;IC; "Evaluates the given block in the context of the class/module. The method defined in the block will belong to the receiver. Any arguments passed to the method will be passed to the block. This can be used if the block needs to access instance variables. class Thing end Thing.class_exec{ def hello() "Hello there!" end } puts Thing.new.hello() produces: Hello there! ;T;[o;= ;>I" overload;F;?0;;;@0;:I"module_exec(arg...);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" var...;T;$@6Ao;A ;>I" return;F;?I";T;0;@[I" Object;T;$@6A;![;"I"%@yield [var...] @return [Object];T;#0;$@6A;.F;Bi;C0;7[[I" arg...;T0;$@6Ao;= ;>I" overload;F;?0;;;@0;:I"class_exec(arg...);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" var...;T;$@6Ao;A ;>I" return;F;?I";T;0;@[I" Object;T;$@6A;![;"I"%@yield [var...] @return [Object];T;#0;$@6A;.F;Bi;C0;7[[I" arg...;T0;$@6A;![;"@2A;#0;$@6A;.F;/o;0;1T;2i_;3iu;%@A7;9I"static VALUE rb_mod_module_exec_internal(int argc, const VALUE *argv, VALUE mod) { return yield_under(mod, FALSE, argc, argv, RB_PASS_CALLED_KEYWORDS); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#module_eval;F;7[[@90;[[@CiS;T;:module_eval;0;[;{;IC; "yEvaluates the string or block in the context of _mod_, except that when a block is given, constant/class variable lookup is not affected. This can be used to add methods to a class. module_eval returns the result of evaluating its argument. The optional _filename_ and _lineno_ parameters set the text for error messages. class Thing end a = %q{def hello() "Hello there!" end} Thing.module_eval(a) puts Thing.new.hello() Thing.module_eval("invalid code", "dummy", 123) produces: Hello there! dummy:123:in `module_eval': undefined local variable or method `code' for Thing:Class ;T;[ o;= ;>I" overload;F;?0;:class_eval;@0;:I"/class_eval(string [, filename [, lineno]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@lA;![;"I"@return [Object];T;#0;$@lA;.F;Bi;C0;7[[I""string[, filename [, lineno]];T0;$@lAo;= ;>I" overload;F;?0;;;@0;:I"class_eval;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"mod;T;$@lAo;A ;>I" return;F;?I";T;0;@[I" Object;T;$@lA;![;"I""@yield [mod] @return [Object];T;#0;$@lA;.F;Bi;C0;7[;$@lAo;= ;>I" overload;F;?0;;;@0;:I"0module_eval(string [, filename [, lineno]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@lA;![;"I"@return [Object];T;#0;$@lA;.F;Bi;C0;7[[I""string[, filename [, lineno]];T0;$@lAo;= ;>I" overload;F;?0;;;@0;:I"module_eval;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"mod;T;$@lAo;A ;>I" return;F;?I";T;0;@[I" Object;T;$@lA;![;"I""@yield [mod] @return [Object];T;#0;$@lA;.F;Bi;C0;7[;$@lA;![;"I"{Evaluates the string or block in the context of _mod_, except that when a block is given, constant/class variable lookup is not affected. This can be used to add methods to a class. module_eval returns the result of evaluating its argument. The optional _filename_ and _lineno_ parameters set the text for error messages. class Thing end a = %q{def hello() "Hello there!" end} Thing.module_eval(a) puts Thing.new.hello() Thing.module_eval("invalid code", "dummy", 123) produces: Hello there! dummy:123:in `module_eval': undefined local variable or method `code' for Thing:Class @overload class_eval(string [, filename [, lineno]]) @return [Object] @overload class_eval @yield [mod] @return [Object] @overload module_eval(string [, filename [, lineno]]) @return [Object] @overload module_eval @yield [mod] @return [Object];T;#0;$@lA;.F;/o;0;1T;2i8;3iU;%@A7;9I"static VALUE rb_mod_module_eval_internal(int argc, const VALUE *argv, VALUE mod) { return specific_eval(argc, argv, mod, FALSE, RB_PASS_CALLED_KEYWORDS); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#class_eval;F;7[[@90;[[@CiS;T;;;0;[;{;IC; "yEvaluates the string or block in the context of _mod_, except that when a block is given, constant/class variable lookup is not affected. This can be used to add methods to a class. module_eval returns the result of evaluating its argument. The optional _filename_ and _lineno_ parameters set the text for error messages. class Thing end a = %q{def hello() "Hello there!" end} Thing.module_eval(a) puts Thing.new.hello() Thing.module_eval("invalid code", "dummy", 123) produces: Hello there! dummy:123:in `module_eval': undefined local variable or method `code' for Thing:Class ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"/class_eval(string [, filename [, lineno]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@A;![;"I"@return [Object];T;#0;$@A;.F;Bi;C0;7[[I""string[, filename [, lineno]];T0;$@Ao;= ;>I" overload;F;?0;;;@0;:I"class_eval;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"mod;T;$@Ao;A ;>I" return;F;?I";T;0;@[I" Object;T;$@A;![;"I""@yield [mod] @return [Object];T;#0;$@A;.F;Bi;C0;7[;$@Ao;= ;>I" overload;F;?0;;;@0;:I"0module_eval(string [, filename [, lineno]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@A;![;"I"@return [Object];T;#0;$@A;.F;Bi;C0;7[[I""string[, filename [, lineno]];T0;$@Ao;= ;>I" overload;F;?0;;;@0;:I"module_eval;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"mod;T;$@Ao;A ;>I" return;F;?I";T;0;@[I" Object;T;$@A;![;"I""@yield [mod] @return [Object];T;#0;$@A;.F;Bi;C0;7[;$@A;![;"@A;#0;$@A;.F;/o;0;1T;2i8;3iU;%@A7;9I"static VALUE rb_mod_module_eval_internal(int argc, const VALUE *argv, VALUE mod) { return specific_eval(argc, argv, mod, FALSE, RB_PASS_CALLED_KEYWORDS); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#instance_method;F;7[[I"vid;T0;[[@i=;T;:instance_method;0;[;{;IC; "}Returns an +UnboundMethod+ representing the given instance method in _mod_. class Interpreter def do_a() print "there, "; end def do_d() print "Hello "; end def do_e() print "!\n"; end def do_v() print "Dave"; end Dispatcher = { "a" => instance_method(:do_a), "d" => instance_method(:do_d), "e" => instance_method(:do_e), "v" => instance_method(:do_v) } def interpret(string) string.each_char {|b| Dispatcher[b].bind(self).call } end end interpreter = Interpreter.new interpreter.interpret('dave') produces: Hello there, Dave! ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"instance_method(symbol);T;IC; ";T;[;![;"I";T;#0;$@ B;.F;Bi;C0;7[[I" symbol;T0;$@ B;![;"I"Returns an +UnboundMethod+ representing the given instance method in _mod_. class Interpreter def do_a() print "there, "; end def do_d() print "Hello "; end def do_e() print "!\n"; end def do_v() print "Dave"; end Dispatcher = { "a" => instance_method(:do_a), "d" => instance_method(:do_d), "e" => instance_method(:do_e), "v" => instance_method(:do_v) } def interpret(string) string.each_char {|b| Dispatcher[b].bind(self).call } end end interpreter = Interpreter.new interpreter.interpret('dave') produces: Hello there, Dave! @overload instance_method(symbol);T;#0;$@ B;.F;/o;0;1T;2i;3i9;%@A7;9I"static VALUE rb_mod_instance_method(VALUE mod, VALUE vid) { ID id = rb_check_id(&vid); if (!id) { rb_method_name_error(mod, vid); } return mnew_unbound(mod, id, rb_cUnboundMethod, FALSE); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""Module#public_instance_method;F;7[[I"vid;T0;[[@iN;T;:public_instance_method;0;[;{;IC; "?Similar to _instance_method_, searches public method only. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"#public_instance_method(symbol);T;IC; ";T;[;![;"I";T;#0;$@'B;.F;Bi;C0;7[[I" symbol;T0;$@'B;![;"I"jSimilar to _instance_method_, searches public method only. @overload public_instance_method(symbol);T;#0;$@'B;.F;/o;0;1T;2iG;3iJ;%@A7;9I"static VALUE rb_mod_public_instance_method(VALUE mod, VALUE vid) { ID id = rb_check_id(&vid); if (!id) { rb_method_name_error(mod, vid); } return mnew_unbound(mod, id, rb_cUnboundMethod, TRUE); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#define_method;F;7[[@90;[[@i;T;:define_method;0;[;{;IC; "?Defines an instance 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 the _method_ parameter has parameters, they're used as method parameters. This block is evaluated using #instance_eval. class A def fred puts "In Fred" end def create_method(name, &block) self.class.define_method(name, &block) end define_method(:wilma) { puts "Charge it!" } define_method(:flint) {|name| puts "I'm #{name}!"} end class B < A define_method(:barney, instance_method(:fred)) end a = B.new a.barney a.wilma a.flint('Dino') a.create_method(:betty) { p self } a.betty produces: In Fred Charge it! I'm Dino! # ;T;[o;= ;>I" overload;F;?0;; ;@0;:I""define_method(symbol, method);T;IC; ";T;[;![;"I";T;#0;$@AB;.F;Bi;C0;7[[I" symbol;T0[I" method;T0;$@ABo;= ;>I" overload;F;?0;; ;@0;:I"define_method(symbol);T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@AB;![;"I"@yield [];T;#0;$@AB;.F;Bi;C0;7[[I" symbol;T0;$@AB;![;"I"Defines an instance 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 the _method_ parameter has parameters, they're used as method parameters. This block is evaluated using #instance_eval. class A def fred puts "In Fred" end def create_method(name, &block) self.class.define_method(name, &block) end define_method(:wilma) { puts "Charge it!" } define_method(:flint) {|name| puts "I'm #{name}!"} end class B < A define_method(:barney, instance_method(:fred)) end a = B.new a.barney a.wilma a.flint('Dino') a.create_method(:betty) { p self } a.betty produces: In Fred Charge it! I'm Dino! # @overload define_method(symbol, method) @overload define_method(symbol) @yield [];T;#0;$@AB;.F;/o;0;1T;2iX;3i};%@A7;9I"static VALUE rb_mod_define_method(int argc, VALUE *argv, VALUE mod) { ID id; VALUE body; VALUE name; const rb_cref_t *cref = rb_vm_cref_in_context(mod, mod); const rb_scope_visibility_t default_scope_visi = {METHOD_VISI_PUBLIC, FALSE}; const rb_scope_visibility_t *scope_visi = &default_scope_visi; int is_method = FALSE; if (cref) { scope_visi = CREF_SCOPE_VISI(cref); } rb_check_arity(argc, 1, 2); name = argv[0]; id = rb_check_id(&name); if (argc == 1) { body = rb_block_lambda(); } else { body = argv[1]; if (rb_obj_is_method(body)) { is_method = TRUE; } else if (rb_obj_is_proc(body)) { is_method = FALSE; } else { rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc/Method/UnboundMethod)", rb_obj_classname(body)); } } if (!id) id = rb_to_id(name); if (is_method) { struct METHOD *method = (struct METHOD *)DATA_PTR(body); if (method->me->owner != mod && !RB_TYPE_P(method->me->owner, T_MODULE) && !RTEST(rb_class_inherited_p(mod, method->me->owner))) { if (FL_TEST(method->me->owner, FL_SINGLETON)) { rb_raise(rb_eTypeError, "can't bind singleton method to a different class"); } else { rb_raise(rb_eTypeError, "bind argument must be a subclass of % "PRIsVALUE, method->me->owner); } } rb_method_entry_set(mod, id, method->me, scope_visi->method_visi); if (scope_visi->module_func) { rb_method_entry_set(rb_singleton_class(mod), id, method->me, METHOD_VISI_PUBLIC); } RB_GC_GUARD(body); } else { VALUE procval = rb_proc_dup(body); if (vm_proc_iseq(procval) != NULL) { rb_proc_t *proc; GetProcPtr(procval, proc); proc->is_lambda = TRUE; proc->is_from_method = TRUE; } rb_add_method(mod, id, VM_METHOD_TYPE_BMETHOD, (void *)procval, scope_visi->method_visi); if (scope_visi->module_func) { rb_add_method(rb_singleton_class(mod), id, VM_METHOD_TYPE_BMETHOD, (void *)body, METHOD_VISI_PUBLIC); } } return ID2SYM(id); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#autoload;F;7[[I"sym;T0[I" file;T0;[[@Yi;T;;;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 in the namespace of _mod_. module A end A.autoload(:B, "b") A::B.doit # autoloads "b" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"autoload(module, filename);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@iB;![;"I"@return [nil];T;#0;$@iB;.F;Bi;C0;7[;$@iB;![;"I"+Registers _filename_ to be loaded (using Kernel::require) the first time that _module_ (which may be a String or a symbol) is accessed in the namespace of _mod_. module A end A.autoload(:B, "b") A::B.doit # autoloads "b" @overload autoload(module, filename) @return [nil];T;#0;$@iB;.F;/o;0;1T;2i;3i;%@A7;9I"static VALUE rb_mod_autoload(VALUE mod, VALUE sym, VALUE file) { ID id = rb_to_id(sym); FilePathValue(file); rb_autoload_str(mod, id, file); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module#autoload?;F;7[[@90;[[@Yi%;T;;;0;[;{;IC; "Returns _filename_ to be loaded if _name_ is registered as +autoload+ in the namespace of _mod_ or one of its ancestors. module A end A.autoload(:B, "b") A.autoload?(:B) #=> "b" If +inherit+ is false, the lookup only checks the autoloads in the receiver: class A autoload :CONST, "const.rb" end class B < A end B.autoload?(:CONST) #=> "const.rb", found in A (ancestor) B.autoload?(:CONST, false) #=> nil, not found in B itself;T;[o;= ;>I" overload;F;?0;;;@0;:I""autoload?(name, inherit=true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@B;![;"I"@return [String, nil];T;#0;$@B;.F;Bi;C0;7[[I" name;T0[I" inherit;TI" true;T;$@B;![;"I"+Returns _filename_ to be loaded if _name_ is registered as +autoload+ in the namespace of _mod_ or one of its ancestors. module A end A.autoload(:B, "b") A.autoload?(:B) #=> "b" If +inherit+ is false, the lookup only checks the autoloads in the receiver: class A autoload :CONST, "const.rb" end class B < A end B.autoload?(:CONST) #=> "const.rb", found in A (ancestor) B.autoload?(:CONST, false) #=> nil, not found in B itself @overload autoload?(name, inherit=true) @return [String, nil];T;#0;$@B;.F;/o;0;1T;2i ;3i";Bi;%@A7;9I"static VALUE rb_mod_autoload_p(int argc, VALUE *argv, VALUE mod) { int recur = (rb_check_arity(argc, 1, 2) == 1) ? TRUE : RTEST(argv[1]); VALUE sym = argv[0]; ID id = rb_check_id(&sym); if (!id) { return Qnil; } return rb_autoload_at_p(mod, id, recur); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module.nesting;F;7[;[[@OiZ;T;: nesting;0;[;{;IC; "Returns the list of +Modules+ nested at the point of call. module M1 module M2 $a = Module.nesting end end $a #=> [M1::M2, M1] $a[0].name #=> "M1::M2" ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" nesting;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@B;![;"I"@return [Array];T;#0;$@B;.F;Bi;C0;7[;$@B;![;"I"Returns the list of +Modules+ nested at the point of call. module M1 module M2 $a = Module.nesting end end $a #=> [M1::M2, M1] $a[0].name #=> "M1::M2" @overload nesting @return [Array];T;#0;$@B;.F;/o;0;1T;2iK;3iW;%@A7;9I"Astatic VALUE rb_mod_nesting(VALUE _) { VALUE ary = rb_ary_new(); const rb_cref_t *cref = rb_vm_cref(); while (cref && CREF_NEXT(cref)) { VALUE klass = CREF_CLASS(cref); if (!CREF_PUSHED_BY_EVAL(cref) && !NIL_P(klass)) { rb_ary_push(ary, klass); } cref = CREF_NEXT(cref); } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Module.constants;F;7[[@90;[[@Oi;T;;;0;[;{;IC; "In the first form, returns an array of the names of all constants accessible from the point of call. This list includes the names of all modules and classes defined in the global scope. Module.constants.first(4) # => [:ARGF, :ARGV, :ArgumentError, :Array] Module.constants.include?(:SEEK_SET) # => false class IO Module.constants.include?(:SEEK_SET) # => true end The second form calls the instance method +constants+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"constants;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@B;![;"I"@return [Array];T;#0;$@B;.F;Bi;C0;7[;$@Bo;= ;>I" overload;F;?0;;;@0;:I"constants(inherited);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@B;![;"I"@return [Array];T;#0;$@B;.F;Bi;C0;7[[I"inherited;T0;$@B;![;"I"In the first form, returns an array of the names of all constants accessible from the point of call. This list includes the names of all modules and classes defined in the global scope. Module.constants.first(4) # => [:ARGF, :ARGV, :ArgumentError, :Array] Module.constants.include?(:SEEK_SET) # => false class IO Module.constants.include?(:SEEK_SET) # => true end The second form calls the instance method +constants+. @overload constants @return [Array] @overload constants(inherited) @return [Array];T;#0;$@B;.F;/o;0;1T;2ik;3i;%@A7;9I"Lstatic VALUE rb_mod_s_constants(int argc, VALUE *argv, VALUE mod) { const rb_cref_t *cref = rb_vm_cref(); VALUE klass; VALUE cbase = 0; void *data = 0; if (argc > 0 || mod != rb_cModule) { return rb_mod_constants(argc, argv, mod); } while (cref) { klass = CREF_CLASS(cref); if (!CREF_PUSHED_BY_EVAL(cref) && !NIL_P(klass)) { data = rb_mod_const_at(CREF_CLASS(cref), data); if (!cbase) { cbase = klass; } } cref = CREF_NEXT(cref); } if (cbase) { data = rb_mod_const_of(cbase, data); } return rb_const_list(data); };T;:I"static VALUE;T;;T; @A7; IC;[; @A7; IC;[; @A7; IC;{;IC;{;T;IC;{;T;T;{@{<;G;[;[[@sym refers to a symbol, which is either a quoted string or a Symbol (such as :name). module Mod include Math CONST = 1 def meth # ... end end Mod.class #=> Module Mod.constants #=> [:CONST, :PI, :E] Mod.instance_methods #=> [:meth];T;[;![;"I"H********************************************************************* A Module is a collection of methods and constants. The methods in a module may be instance methods or module methods. Instance methods appear as methods in a class when the module is included, module methods do not. Conversely, module methods may be called without creating an encapsulating object, while instance methods may not. (See Module#module_function.) In the descriptions that follow, the parameter sym refers to a symbol, which is either a quoted string or a Symbol (such as :name). module Mod include Math CONST = 1 def meth # ... end end Mod.class #=> Module Mod.constants #=> [:CONST, :PI, :E] Mod.instance_methods #=> [:meth] ;T;#0;$@A7;.F;/o;0;1T;2i;3i(;Bi;%@;&I" Module;F;'@o;;IC;[o;4;5F;6;;;;&I" NKF#nkf;F;7[[I"opt;T0[I"src;T0;[[I"ext/nkf/nkf.c;Ti;T;:nkf;0;[;{;IC; "Convert _str_ and return converted result. Conversion details are specified by _opt_ as String. require 'nkf' output = NKF.nkf("-s", input) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"nkf(opt, str);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@C;![;"I"@return [String];T;#0;$@C;.F;Bi;C0;7[[I"opt;T0[I"str;T0;$@C;![;"I"Convert _str_ and return converted result. Conversion details are specified by _opt_ as String. require 'nkf' output = NKF.nkf("-s", input) @overload nkf(opt, str) @return [String];T;#0;$@C;.F;C0;%@C;9I"static VALUE rb_nkf_convert(VALUE obj, VALUE opt, VALUE src) { VALUE tmp; reinit(); nkf_split_options(StringValueCStr(opt)); if (!output_encoding) rb_raise(rb_eArgError, "no output encoding given"); switch (nkf_enc_to_index(output_encoding)) { case UTF_8_BOM: output_encoding = nkf_enc_from_index(UTF_8); break; case UTF_16BE_BOM: output_encoding = nkf_enc_from_index(UTF_16BE); break; case UTF_16LE_BOM: output_encoding = nkf_enc_from_index(UTF_16LE); break; case UTF_32BE_BOM: output_encoding = nkf_enc_from_index(UTF_32BE); break; case UTF_32LE_BOM: output_encoding = nkf_enc_from_index(UTF_32LE); break; } output_bom_f = FALSE; incsize = INCSIZE; input_ctr = 0; input = (unsigned char *)StringValuePtr(src); i_len = RSTRING_LENINT(src); tmp = rb_str_new(0, i_len*3 + 10); output_ctr = 0; output = (unsigned char *)RSTRING_PTR(tmp); o_len = RSTRING_LENINT(tmp); *output = '\0'; /* use _result_ begin*/ result = tmp; kanji_convert(NULL); result = Qnil; /* use _result_ end */ rb_str_set_len(tmp, output_ctr); if (mimeout_f) rb_enc_associate(tmp, rb_usascii_encoding()); else rb_enc_associate(tmp, rb_nkf_enc_get(nkf_enc_name(output_encoding))); return tmp; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I" NKF.nkf;F;7@C;@ C;T;;;0;@C;{;IC; "Convert _str_ and return converted result. Conversion details are specified by _opt_ as String. require 'nkf' output = NKF.nkf("-s", input);T;[o;= ;>I" overload;F;?0;;;@0;:I"nkf(opt, str);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@(C;![;"I"@return [String];T;#0;$@(C;.F;Bi;C0;7[[I"opt;T0[I"str;T0;$@(C;![;"I"Convert _str_ and return converted result. Conversion details are specified by _opt_ as String. require 'nkf' output = NKF.nkf("-s", input) @overload nkf(opt, str) @return [String];T;#0;$@(C;.F;/o;0;1T;2i|;3i;Bi;%@C;9@&C;:@'C;;To;4;5F;6;;;;&I"NKF#guess;F;7[[I"src;T0;[[@Ci;T;: guess;0;[;{;IC; "6Returns guessed encoding of _str_ by nkf routine. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"guess(str);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Encoding;T;$@AC;![;"I"@return [Encoding];T;#0;$@AC;.F;Bi;C0;7[[I"str;T0;$@AC;![;"I"aReturns guessed encoding of _str_ by nkf routine. @overload guess(str) @return [Encoding];T;#0;$@AC;.F;C0;%@C;9I"3static VALUE rb_nkf_guess(VALUE obj, VALUE src) { reinit(); input_ctr = 0; input = (unsigned char *)StringValuePtr(src); i_len = RSTRING_LENINT(src); guess_f = TRUE; kanji_convert( NULL ); guess_f = FALSE; return rb_enc_from_encoding(rb_nkf_enc_get(get_guessed_code())); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"NKF.guess;F;7@CC;@FC;T;;;0;@HC;{;IC; "6Returns guessed encoding of _str_ by nkf routine.;T;[o;= ;>I" overload;F;?0;;;@0;:I"guess(str);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Encoding;T;$@_C;![;"I"@return [Encoding];T;#0;$@_C;.F;Bi;C0;7[[I"str;T0;$@_C;![;"I"cReturns guessed encoding of _str_ by nkf routine. @overload guess(str) @return [Encoding];T;#0;$@_C;.F;/o;0;1T;2i;3i;Bi;%@C;9@]C;:@^C;;To;u;[[@Ci;F;: AUTO;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@vC;%@C;&I"NKF::AUTO;F;xI" Qnil;To;u;[[@Ci;F;: NOCONV;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@C;%@C;&I"NKF::NOCONV;F;xI" Qnil;To;u;[[@Ci;F;: UNKNOWN;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@C;%@C;&I"NKF::UNKNOWN;F;xI" Qnil;To;u;[[@Ci;F;: BINARY;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@C;%@C;&I"NKF::BINARY;F;xI"3rb_enc_from_encoding(rb_nkf_enc_get("BINARY"));To;u;[[@Ci;F;: ASCII;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@C;%@C;&I"NKF::ASCII;F;xI"5rb_enc_from_encoding(rb_nkf_enc_get("US-ASCII"));To;u;[[@Ci;F;:JIS;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@C;%@C;&I" NKF::JIS;F;xI"8rb_enc_from_encoding(rb_nkf_enc_get("ISO-2022-JP"));To;u;[[@Ci;F;:EUC;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@C;%@C;&I" NKF::EUC;F;xI"3rb_enc_from_encoding(rb_nkf_enc_get("EUC-JP"));To;u;[[@Ci;F;: SJIS;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@C;%@C;&I"NKF::SJIS;F;xI"6rb_enc_from_encoding(rb_nkf_enc_get("Shift_JIS"));To;u;[[@Ci;F;: UTF8;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@C;%@C;&I"NKF::UTF8;F;xI"-rb_enc_from_encoding(rb_utf8_encoding());To;u;[[@Ci;F;: UTF16;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@C;%@C;&I"NKF::UTF16;F;xI"5rb_enc_from_encoding(rb_nkf_enc_get("UTF-16BE"));To;u;[[@Ci;F;: UTF32;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@C;%@C;&I"NKF::UTF32;F;xI"5rb_enc_from_encoding(rb_nkf_enc_get("UTF-32BE"));To;u;[[@Ci;F;: VERSION;;w;;;[;{;IC; "Full version string of nkf ;T;[;![;"I"Full version string of nkf;T;#0;$@C;.F;/o;0;1T;2i;3i;%@C;&I"NKF::VERSION;F;xI""rb_str_new2(RUBY_NKF_VERSION);To;u;[[@Ci;F;:NKF_VERSION;;w;;;[;{;IC; "Version of nkf ;T;[;![;"I"Version of nkf;T;#0;$@C;.F;/o;0;1T;2i;3i;%@C;&I"NKF::NKF_VERSION;F;xI"rb_str_new2(NKF_VERSION);To;u;[[@Ci;F;:NKF_RELEASE_DATE;;w;;;[;{;IC; "Release date of nkf ;T;[;![;"I"Release date of nkf;T;#0;$@C;.F;/o;0;1T;2i;3i;%@C;&I"NKF::NKF_RELEASE_DATE;F;xI""rb_str_new2(NKF_RELEASE_DATE);T; @C; IC;[; @C; IC;[; @C; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Ci;F;:NKF;;;;;[;{;IC; " ;T;[;![;"@;#0;$@C;Bi;%@;&I"NKF;Fo;;IC;[o;;IC;[o;4;5F;6;;;;&I""Digest::Instance#bubblebabble;F;7[;[[I"+ext/digest/bubblebabble/bubblebabble.c;Tiw;T;:bubblebabble;0;[;{;IC; "{call-seq: digest_obj.bubblebabble -> hash_string Returns the resulting hash value in a Bubblebabble encoded form. ;T;[;![;"I"} call-seq: digest_obj.bubblebabble -> hash_string Returns the resulting hash value in a Bubblebabble encoded form. ;T;#0;$@D;.F;/o;0;1T;2ip;3iu;%@D;9I"}static VALUE rb_digest_instance_bubblebabble(VALUE self) { return bubblebabble_str_new(rb_funcall(self, id_digest, 0)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Instance#update;F;7[[I"str;T0;[[I"ext/digest/digest.c;Ti;T;: update;0;[;{;IC; "Updates the digest using a given _string_ and returns self. The update() method and the left-shift operator are overridden by each implementation subclass. (One should be an alias for the other) ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"update(string);T;IC; ";T;[;![;"I";T;#0;$@*D;.F;Bi;C0;7[[I" string;T0;$@*Do;= ;>I" overload;F;?0;;;@0;:I"<<(string);T;IC; ";T;[;![;"I";T;#0;$@*D;.F;Bi;C0;7[[I" string;T0;$@*D;![;"I"Updates the digest using a given _string_ and returns self. The update() method and the left-shift operator are overridden by each implementation subclass. (One should be an alias for the other) @overload update(string) @overload <<(string);T;#0;$@*D;.F;/o;0;1T;2i;3i;%@D;9I"static VALUE rb_digest_instance_update(VALUE self, VALUE str) { rb_digest_instance_method_unimpl(self, "update"); UNREACHABLE; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Instance#<<;F;7[[I"str;T0;[[@1Di;T;;;0;[;{;IC; "Updates the digest using a given _string_ and returns self. The update() method and the left-shift operator are overridden by each implementation subclass. (One should be an alias for the other) ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"update(string);T;IC; ";T;[;![;"I";T;#0;$@OD;.F;Bi;C0;7[[I" string;T0;$@ODo;= ;>I" overload;F;?0;;;@0;:I"<<(string);T;IC; ";T;[;![;"I";T;#0;$@OD;.F;Bi;C0;7[[I" string;T0;$@OD;![;"@KD;#0;$@OD;.F;/o;0;1T;2i;3i;%@D;9I"static VALUE rb_digest_instance_update(VALUE self, VALUE str) { rb_digest_instance_method_unimpl(self, "update"); UNREACHABLE; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Instance#finish;F;7[;[[@1Di;T;: finish;0;[;{;IC; "TFinishes the digest and returns the resulting hash value. This method is overridden by each implementation subclass and often made private, because some of those subclasses may leave internal data uninitialized. Do not call this method from outside. Use #digest!() instead, which ensures that internal data be reset for security reasons. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"instance_eval;T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@rD;![;"I"@yield [];T;#0;$@rD;.F;Bi;C0;7[;$@rD;![;"I"zFinishes the digest and returns the resulting hash value. This method is overridden by each implementation subclass and often made private, because some of those subclasses may leave internal data uninitialized. Do not call this method from outside. Use #digest!() instead, which ensures that internal data be reset for security reasons. @overload instance_eval @yield [];T;#0;$@rD;.F;/o;0;1T;2i;3i;%@D;9I"~static VALUE rb_digest_instance_finish(VALUE self) { rb_digest_instance_method_unimpl(self, "finish"); UNREACHABLE; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Instance#reset;F;7[;[[@1Di;T;;;0;[;{;IC; "yResets the digest to the initial state and returns self. This method is overridden by each implementation subclass. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" reset;T;IC; ";T;[;![;"I";T;#0;$@D;.F;Bi;C0;7[;$@D;![;"I"Resets the digest to the initial state and returns self. This method is overridden by each implementation subclass. @overload reset;T;#0;$@D;.F;/o;0;1T;2i;3i;%@D;9I"|static VALUE rb_digest_instance_reset(VALUE self) { rb_digest_instance_method_unimpl(self, "reset"); UNREACHABLE; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#Digest::Instance#digest_length;F;7[;[[@1Di;T;:digest_length;0;[;{;IC; "Returns the length of the hash value of the digest. This method should be overridden by each implementation subclass. If not, digest_obj.digest().length() is returned. ;T;[o;= ;>I" overload;F;?0;;";@0;:I"digest_length;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@D;![;"I"@return [Integer];T;#0;$@D;.F;Bi;C0;7[;$@D;![;"I"Returns the length of the hash value of the digest. This method should be overridden by each implementation subclass. If not, digest_obj.digest().length() is returned. @overload digest_length @return [Integer];T;#0;$@D;.F;/o;0;1T;2i;3i;%@D;9I"2static VALUE rb_digest_instance_digest_length(VALUE self) { /* subclasses really should redefine this method */ VALUE digest = rb_digest_instance_digest(0, 0, self); /* never blindly assume that #digest() returns a string */ StringValue(digest); return LONG2NUM(RSTRING_LEN(digest)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""Digest::Instance#block_length;F;7[;[[@1Di;T;:block_length;0;[;{;IC; "hReturns the block length of the digest. This method is overridden by each implementation subclass. ;T;[o;= ;>I" overload;F;?0;;#;@0;:I"block_length;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@D;![;"I"@return [Integer];T;#0;$@D;.F;Bi;C0;7[;$@D;![;"I"Returns the block length of the digest. This method is overridden by each implementation subclass. @overload block_length @return [Integer];T;#0;$@D;.F;/o;0;1T;2i;3i;%@D;9I"static VALUE rb_digest_instance_block_length(VALUE self) { rb_digest_instance_method_unimpl(self, "block_length"); UNREACHABLE; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Instance#==;F;7[[I" other;T0;[[@1Dio;T;;F;0;[;{;IC; "If a string is given, checks whether it is equal to the hex-encoded hash value of the digest object. If another digest instance is given, checks whether they have the same hash value. Otherwise returns false. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(another_digest_obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@D;![;"I"@return [Boolean];T;#0;$@D;.F;Bi;C0;7[[I"another_digest_obj;T0;$@Do;= ;>I" overload;F;?0;;F;@0;:I"==(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@D;![;"I"@return [Boolean];T;#0;$@D;.F;Bi;C0;7[[I" string;T0;$@D;![;"I"2If a string is given, checks whether it is equal to the hex-encoded hash value of the digest object. If another digest instance is given, checks whether they have the same hash value. Otherwise returns false. @overload ==(another_digest_obj) @return [Boolean] @overload ==(string) @return [Boolean];T;#0;$@D;.F;/o;0;1T;2ie;3in;%@D;9I"static VALUE rb_digest_instance_equal(VALUE self, VALUE other) { VALUE str1, str2; if (rb_obj_is_kind_of(other, rb_mDigest_Instance) == Qtrue) { str1 = rb_digest_instance_digest(0, 0, self); str2 = rb_digest_instance_digest(0, 0, other); } else { str1 = rb_digest_instance_to_s(self); str2 = rb_check_string_type(other); if (NIL_P(str2)) return Qfalse; } /* never blindly assume that subclass methods return strings */ StringValue(str1); StringValue(str2); if (RSTRING_LEN(str1) == RSTRING_LEN(str2) && rb_str_cmp(str1, str2) == 0) { return Qtrue; } return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Instance#inspect;F;7[;[[@1DiR;T;;J;0;[;{;IC; "6Creates a printable version of the digest object. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@E;![;"I"@return [String];T;#0;$@E;.F;Bi;C0;7[;$@E;![;"I"]Creates a printable version of the digest object. @overload inspect @return [String];T;#0;$@E;.F;/o;0;1T;2iL;3iP;%@D;9I"static VALUE rb_digest_instance_inspect(VALUE self) { VALUE str; size_t digest_len = 32; /* about this size at least */ const char *cname; cname = rb_obj_classname(self); /* # */ str = rb_str_buf_new(2 + strlen(cname) + 2 + digest_len * 2 + 1); rb_str_buf_cat2(str, "#<"); rb_str_buf_cat2(str, cname); rb_str_buf_cat2(str, ": "); rb_str_buf_append(str, rb_digest_instance_hexdigest(0, 0, self)); rb_str_buf_cat2(str, ">"); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Instance#new;F;7[;[[@1Di;T;;E;0;[;{;IC; "eReturns a new, initialized copy of the digest object. Equivalent to digest_obj.clone().reset(). ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new;T;IC; ";T;[;![;"I";T;#0;$@ E;.F;Bi;C0;7[;$@ E;![;"I"uReturns a new, initialized copy of the digest object. Equivalent to digest_obj.clone().reset(). @overload new;T;#0;$@ E;.F;/o;0;1T;2i;3i;%@D;9I"static VALUE rb_digest_instance_new(VALUE self) { VALUE clone = rb_obj_clone(self); rb_funcall(clone, id_reset, 0); return clone; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Instance#digest;F;7[[@90;[[@1Di;T;: digest;0;[;{;IC; "If none is given, returns the resulting hash value of the digest, keeping the digest's state. If a _string_ is given, returns the hash value for the given _string_, resetting the digest to the initial state before and after the process. ;T;[o;= ;>I" overload;F;?0;;$;@0;:I" digest;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@6E;![;"I"@return [String];T;#0;$@6E;.F;Bi;C0;7[;$@6Eo;= ;>I" overload;F;?0;;$;@0;:I"digest(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@6E;![;"I"@return [String];T;#0;$@6E;.F;Bi;C0;7[[I" string;T0;$@6E;![;"I"?If none is given, returns the resulting hash value of the digest, keeping the digest's state. If a _string_ is given, returns the hash value for the given _string_, resetting the digest to the initial state before and after the process. @overload digest @return [String] @overload digest(string) @return [String];T;#0;$@6E;.F;/o;0;1T;2i;3i;%@D;9I"static VALUE rb_digest_instance_digest(int argc, VALUE *argv, VALUE self) { VALUE str, value; if (rb_scan_args(argc, argv, "01", &str) > 0) { rb_funcall(self, id_reset, 0); rb_funcall(self, id_update, 1, str); value = rb_funcall(self, id_finish, 0); rb_funcall(self, id_reset, 0); } else { value = rb_funcall(rb_obj_clone(self), id_finish, 0); } return value; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Instance#digest!;F;7[;[[@1Di ;T;: digest!;0;[;{;IC; "QReturns the resulting hash value and resets the digest to the initial state. ;T;[o;= ;>I" overload;F;?0;;%;@0;:I" digest!;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@aE;![;"I"@return [String];T;#0;$@aE;.F;Bi;C0;7[;$@aE;![;"I"xReturns the resulting hash value and resets the digest to the initial state. @overload digest! @return [String];T;#0;$@aE;.F;/o;0;1T;2i;3i;%@D;9I"static VALUE rb_digest_instance_digest_bang(VALUE self) { VALUE value = rb_funcall(self, id_finish, 0); rb_funcall(self, id_reset, 0); return value; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Instance#hexdigest;F;7[[@90;[[@1Di;T;:hexdigest;0;[;{;IC; "If none is given, returns the resulting hash value of the digest in a hex-encoded form, keeping the digest's state. If a _string_ is given, returns the hash value for the given _string_ in a hex-encoded form, resetting the digest to the initial state before and after the process. ;T;[o;= ;>I" overload;F;?0;;&;@0;:I"hexdigest;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@|E;![;"I"@return [String];T;#0;$@|E;.F;Bi;C0;7[;$@|Eo;= ;>I" overload;F;?0;;&;@0;:I"hexdigest(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@|E;![;"I"@return [String];T;#0;$@|E;.F;Bi;C0;7[[I" string;T0;$@|E;![;"I"qIf none is given, returns the resulting hash value of the digest in a hex-encoded form, keeping the digest's state. If a _string_ is given, returns the hash value for the given _string_ in a hex-encoded form, resetting the digest to the initial state before and after the process. @overload hexdigest @return [String] @overload hexdigest(string) @return [String];T;#0;$@|E;.F;/o;0;1T;2i;3i;%@D;9I"static VALUE rb_digest_instance_hexdigest(int argc, VALUE *argv, VALUE self) { VALUE str, value; if (rb_scan_args(argc, argv, "01", &str) > 0) { rb_funcall(self, id_reset, 0); rb_funcall(self, id_update, 1, str); value = rb_funcall(self, id_finish, 0); rb_funcall(self, id_reset, 0); } else { value = rb_funcall(rb_obj_clone(self), id_finish, 0); } return hexencode_str_new(value); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Digest::Instance#hexdigest!;F;7[;[[@1Di7;T;:hexdigest!;0;[;{;IC; "gReturns the resulting hash value in a hex-encoded form and resets the digest to the initial state. ;T;[o;= ;>I" overload;F;?0;;';@0;:I"hexdigest!;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@E;![;"I"@return [String];T;#0;$@E;.F;Bi;C0;7[;$@E;![;"I"Returns the resulting hash value in a hex-encoded form and resets the digest to the initial state. @overload hexdigest! @return [String];T;#0;$@E;.F;/o;0;1T;2i0;3i5;%@D;9I"static VALUE rb_digest_instance_hexdigest_bang(VALUE self) { VALUE value = rb_funcall(self, id_finish, 0); rb_funcall(self, id_reset, 0); return hexencode_str_new(value); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Instance#to_s;F;7[;[[@1DiF;T;;G;0;[;{;IC; "$Returns digest_obj.hexdigest(). ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@E;![;"I"@return [String];T;#0;$@E;.F;Bi;C0;7[;$@E;![;"I"HReturns digest_obj.hexdigest(). @overload to_s @return [String];T;#0;$@E;.F;/o;0;1T;2i@;3iD;%@D;9I"gstatic VALUE rb_digest_instance_to_s(VALUE self) { return rb_funcall(self, id_hexdigest, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Instance#length;F;7[;[[@1Di;T;;b;0;[;{;IC; "(Returns digest_obj.digest_length(). ;T;[o;= ;>I" overload;F;?0;;b;@0;:I" length;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@E;![;"I"@return [Integer];T;#0;$@E;.F;Bi;C0;7[;$@Eo;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@E;![;"I"@return [Integer];T;#0;$@E;.F;Bi;C0;7[;$@E;![;"I"rReturns digest_obj.digest_length(). @overload length @return [Integer] @overload size @return [Integer];T;#0;$@E;.F;/o;0;1T;2i;3i;%@D;9I"mstatic VALUE rb_digest_instance_length(VALUE self) { return rb_funcall(self, id_digest_length, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Instance#size;F;7[;[[@1Di;T;;;0;[;{;IC; "(Returns digest_obj.digest_length(). ;T;[o;= ;>I" overload;F;?0;;b;@0;:I" length;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@F;![;"I"@return [Integer];T;#0;$@F;.F;Bi;C0;7[;$@Fo;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@F;![;"I"@return [Integer];T;#0;$@F;.F;Bi;C0;7[;$@F;![;"@F;#0;$@F;.F;/o;0;1T;2i;3i;%@D;9I"mstatic VALUE rb_digest_instance_length(VALUE self) { return rb_funcall(self, id_digest_length, 0); };T;:I"static VALUE;T;;T; @D; IC;[; @D; IC;[; @D; IC;{;IC;{;T;IC;{;T;T;{;[;[[@1Di[@ Di[@1Di ;T;: Instance;;;;;[;{;IC; "qThis module provides instance methods for a digest implementation object to calculate message digest values.;T;[;![;"I"s This module provides instance methods for a digest implementation object to calculate message digest values. ;T;#0;$@D;.F;/o;0;1T;2i;3i;Bi;%@D;&I"Digest::Instance;Fo; ;IC;[ o;4;5F;6;;;;&I"Digest::Class.bubblebabble;F;7[[@90;[[@ Dij;T;;;0;[;{;IC; "call-seq: Digest::Class.bubblebabble(string, ...) -> hash_string Returns the BubbleBabble encoded hash value of a given _string_. ;T;[;![;"I" call-seq: Digest::Class.bubblebabble(string, ...) -> hash_string Returns the BubbleBabble encoded hash value of a given _string_. ;T;#0;$@AF;.F;/o;0;1T;2ic;3ih;%@?F;9I"static VALUE rb_digest_class_s_bubblebabble(int argc, VALUE *argv, VALUE klass) { return bubblebabble_str_new(rb_funcallv(klass, id_digest, argc, argv)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Class#initialize;F;7[;[[@1Di;T;;D;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@PF;.F;/o;0;1T;2i;3i;%@?F;9I"Gstatic VALUE rb_digest_class_init(VALUE self) { return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Class.digest;F;7[[@90;[[@1Di;T;;$;0;[;{;IC; "Returns the hash value of a given _string_. This is equivalent to Digest::Class.new(*parameters).digest(string), where extra _parameters_, if any, are passed through to the constructor and the _string_ is passed to #digest(). ;T;[o;= ;>I" overload;F;?0;:Digest::Class.digest;@0;:I".Digest::Class.digest(string, *parameters);T;IC; ";T;[;![;"I";T;#0;$@^F;.F;Bi;C0;7[[I" string;T0[I"*parameters;T0;$@^F;![;"I"Returns the hash value of a given _string_. This is equivalent to Digest::Class.new(*parameters).digest(string), where extra _parameters_, if any, are passed through to the constructor and the _string_ is passed to #digest(). @overload Digest::Class.digest(string, *parameters);T;#0;$@^F;.F;/o;0;1T;2i;3i;%@?F;9I"nstatic VALUE rb_digest_class_s_digest(int argc, VALUE *argv, VALUE klass) { VALUE str; volatile VALUE obj; if (argc < 1) { rb_raise(rb_eArgError, "no data given"); } str = *argv++; argc--; StringValue(str); obj = rb_obj_alloc(klass); rb_obj_call_init(obj, argc, argv); return rb_funcall(obj, id_digest, 1, str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Class.hexdigest;F;7[[@90;[[@1Di;T;;&;0;[;{;IC; "Returns the hex-encoded hash value of a given _string_. This is almost equivalent to Digest.hexencode(Digest::Class.new(*parameters).digest(string)). ;T;[o;= ;>I" overload;F;?0;:Digest::Class.hexdigest;@0;:I"+Digest::Class.hexdigest(string[, ...]);T;IC; ";T;[;![;"I";T;#0;$@yF;.F;Bi;C0;7[[I"string[, ...];T0;$@yF;![;"I"Returns the hex-encoded hash value of a given _string_. This is almost equivalent to Digest.hexencode(Digest::Class.new(*parameters).digest(string)). @overload Digest::Class.hexdigest(string[, ...]);T;#0;$@yF;.F;/o;0;1T;2i;3i;%@?F;9I"static VALUE rb_digest_class_s_hexdigest(int argc, VALUE *argv, VALUE klass) { return hexencode_str_new(rb_funcallv(klass, id_digest, argc, argv)); };T;:I"static VALUE;T;;T; @?F; IC;[; @?F; IC;[@D; @?F; IC;{;IC;{;T;IC;{;T;T;{;[;[[@1Di[@ Di[@1Di%;T;: Class;;;;;[;{;IC; "JThis module stands as a base class for digest implementation classes.;T;[;![;"I"L This module stands as a base class for digest implementation classes. ;T;#0;$@?F;.F;/o;0;1T;2i;3i;Bi;%@D;&I"Digest::Class;F;'@o;4;5F;6;;;;&I"Digest#bubblebabble;F;7[[I"str;T0;[[@ Di];T;;;0;[;{;IC; "}call-seq: Digest.bubblebabble(string) -> bubblebabble_string Returns a BubbleBabble encoded version of a given _string_. ;T;[;![;"I"}call-seq: Digest.bubblebabble(string) -> bubblebabble_string Returns a BubbleBabble encoded version of a given _string_.;T;#0;$@F;.F;C0;%@D;9I"lstatic VALUE rb_digest_s_bubblebabble(VALUE klass, VALUE str) { return bubblebabble_str_new(str); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Digest.bubblebabble;F;7@F;@F;T;;;0;@F;{;IC; "}call-seq: Digest.bubblebabble(string) -> bubblebabble_string Returns a BubbleBabble encoded version of a given _string_.;T;[;![;"I" call-seq: Digest.bubblebabble(string) -> bubblebabble_string Returns a BubbleBabble encoded version of a given _string_. ;T;#0;$@F;.F;/o;0;1T;2iV;3i[;Bi;%@D;9@F;:@F;;To; ;IC;[; @F; IC;[; @F; IC;[; @F; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"ext/digest/md5/md5init.c;Ti[@Fi?;T;:MD5;;;;;[;{;IC; "A class for calculating message digests using the MD5 Message-Digest Algorithm by RSA Data Security, Inc., described in RFC1321. MD5 calculates a digest of 128 bits (16 bytes). == Examples require 'digest' # Compute a complete digest Digest::MD5.hexdigest 'abc' #=> "90015098..." # Compute digest by chunks md5 = Digest::MD5.new # =># md5.update "ab" md5 << "c" # alias for #update md5.hexdigest # => "90015098..." # Use the same object to compute another digest md5.reset md5 << "message" md5.hexdigest # => "78e73102..." ;T;[;![;"I"A class for calculating message digests using the MD5 Message-Digest Algorithm by RSA Data Security, Inc., described in RFC1321. MD5 calculates a digest of 128 bits (16 bytes). == Examples require 'digest' # Compute a complete digest Digest::MD5.hexdigest 'abc' #=> "90015098..." # Compute digest by chunks md5 = Digest::MD5.new # =># md5.update "ab" md5 << "c" # alias for #update md5.hexdigest # => "90015098..." # Use the same object to compute another digest md5.reset md5 << "message" md5.hexdigest # => "78e73102..." ;T;#0;$@F;.F;/o;0;1T;2i;3i1;%o;( ;)0;*0;+0;: Digest;%@;-@D;0;&I"Digest::MD5;F;'o;( ;)@;*I"Digest::Base;T;+0;: Base;%o;( ;)0;*0;+0;;-;%@;-@D;0;-o; ;IC;[ o;4;5F;6;;;;&I"!Digest::Base#initialize_copy;F;7[[I"obj;T0;[[@1Div;T;;];0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@F;.F;/o;0;1T;2iu;3iu;%@F;9I"static VALUE rb_digest_base_copy(VALUE copy, VALUE obj) { rb_digest_metadata_t *algo; void *pctx1, *pctx2; if (copy == obj) return copy; rb_check_frozen(copy); algo = get_digest_obj_metadata(copy); if (algo != get_digest_obj_metadata(obj)) rb_raise(rb_eTypeError, "different algorithms"); TypedData_Get_Struct(obj, void, &digest_type, pctx1); TypedData_Get_Struct(copy, void, &digest_type, pctx2); memcpy(pctx2, pctx1, algo->ctx_size); return copy; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Base#reset;F;7[;[[@1Di;T;;;0;[;{;IC; "=Reset the digest to its initial state and return +self+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" reset;T;IC; ";T;[;![;"I";T;#0;$@F;.F;Bi;C0;7[;$@F;![;"I"OReset the digest to its initial state and return +self+. @overload reset;T;#0;$@F;.F;/o;0;1T;2i;3i;%@F;9I"static VALUE rb_digest_base_reset(VALUE self) { rb_digest_metadata_t *algo; void *pctx; algo = get_digest_obj_metadata(self); TypedData_Get_Struct(self, void, &digest_type, pctx); algo_init(algo, pctx); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Base#update;F;7[[I"str;T0;[[@1Di;T;; ;0;[;{;IC; ">Update the digest using given _string_ and return +self+. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"update(string);T;IC; ";T;[;![;"I";T;#0;$@F;.F;Bi;C0;7[[I" string;T0;$@Fo;= ;>I" overload;F;?0;;;@0;:I"<<(string);T;IC; ";T;[;![;"I";T;#0;$@F;.F;Bi;C0;7[[I" string;T0;$@F;![;"I"nUpdate the digest using given _string_ and return +self+. @overload update(string) @overload <<(string);T;#0;$@F;.F;/o;0;1T;2i;3i;%@F;9I"dstatic VALUE rb_digest_base_update(VALUE self, VALUE str) { rb_digest_metadata_t *algo; void *pctx; algo = get_digest_obj_metadata(self); TypedData_Get_Struct(self, void, &digest_type, pctx); StringValue(str); algo->update_func(pctx, (unsigned char *)RSTRING_PTR(str), RSTRING_LEN(str)); RB_GC_GUARD(str); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Base#<<;F;7[[I"str;T0;[[@1Di;T;;;0;[;{;IC; ">Update the digest using given _string_ and return +self+. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"update(string);T;IC; ";T;[;![;"I";T;#0;$@!G;.F;Bi;C0;7[[I" string;T0;$@!Go;= ;>I" overload;F;?0;;;@0;:I"<<(string);T;IC; ";T;[;![;"I";T;#0;$@!G;.F;Bi;C0;7[[I" string;T0;$@!G;![;"@G;#0;$@!G;.F;/o;0;1T;2i;3i;%@F;9I"dstatic VALUE rb_digest_base_update(VALUE self, VALUE str) { rb_digest_metadata_t *algo; void *pctx; algo = get_digest_obj_metadata(self); TypedData_Get_Struct(self, void, &digest_type, pctx); StringValue(str); algo->update_func(pctx, (unsigned char *)RSTRING_PTR(str), RSTRING_LEN(str)); RB_GC_GUARD(str); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Base#finish;F;7[;[[@1Di;T;;!;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@DG;.F;/o;0;1T;2i;3i;%@F;9I"static VALUE rb_digest_base_finish(VALUE self) { rb_digest_metadata_t *algo; void *pctx; VALUE str; algo = get_digest_obj_metadata(self); TypedData_Get_Struct(self, void, &digest_type, pctx); str = rb_str_new(0, algo->digest_len); algo->finish_func(pctx, (unsigned char *)RSTRING_PTR(str)); /* avoid potential coredump caused by use of a finished context */ algo_init(algo, pctx); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Base#digest_length;F;7[;[[@1Di;T;;";0;[;{;IC; "2Return the length of the hash value in bytes. ;T;[o;= ;>I" overload;F;?0;;";@0;:I"digest_length;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@RG;![;"I"@return [Integer];T;#0;$@RG;.F;Bi;C0;7[;$@RG;![;"I"`Return the length of the hash value in bytes. @overload digest_length @return [Integer];T;#0;$@RG;.F;/o;0;1T;2i;3i;%@F;9I"static VALUE rb_digest_base_digest_length(VALUE self) { rb_digest_metadata_t *algo; algo = get_digest_obj_metadata(self); return SIZET2NUM(algo->digest_len); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest::Base#block_length;F;7[;[[@1Di;T;;#;0;[;{;IC; "4Return the block length of the digest in bytes. ;T;[o;= ;>I" overload;F;?0;;#;@0;:I"block_length;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@mG;![;"I"@return [Integer];T;#0;$@mG;.F;Bi;C0;7[;$@mG;![;"I"aReturn the block length of the digest in bytes. @overload block_length @return [Integer];T;#0;$@mG;.F;/o;0;1T;2i;3i;%@F;9I"static VALUE rb_digest_base_block_length(VALUE self) { rb_digest_metadata_t *algo; algo = get_digest_obj_metadata(self); return SIZET2NUM(algo->block_len); };T;:I"static VALUE;T;;T; @F; IC;[; @F; IC;[; @F; IC;{;IC;{;T;IC;{;T;T;{;[;[[@1Di[@1Di.;T;;.;;;;;[;{;IC; "This abstract class provides a common interface to message digest implementation classes written in C. ==Write a Digest subclass in C Digest::Base provides a common interface to message digest classes written in C. These classes must provide a struct of type rb_digest_metadata_t: typedef int (*rb_digest_hash_init_func_t)(void *); typedef void (*rb_digest_hash_update_func_t)(void *, unsigned char *, size_t); typedef int (*rb_digest_hash_finish_func_t)(void *, unsigned char *); typedef struct { int api_version; size_t digest_len; size_t block_len; size_t ctx_size; rb_digest_hash_init_func_t init_func; rb_digest_hash_update_func_t update_func; rb_digest_hash_finish_func_t finish_func; } rb_digest_metadata_t; This structure must be set as an instance variable named +metadata+ (without the +@+ in front of the name). By example: static const rb_digest_metadata_t sha1 = { RUBY_DIGEST_API_VERSION, SHA1_DIGEST_LENGTH, SHA1_BLOCK_LENGTH, sizeof(SHA1_CTX), (rb_digest_hash_init_func_t)SHA1_Init, (rb_digest_hash_update_func_t)SHA1_Update, (rb_digest_hash_finish_func_t)SHA1_Finish, }; rb_ivar_set(cDigest_SHA1, rb_intern("metadata"), Data_Wrap_Struct(0, 0, 0, (void *)&sha1));;T;[;![;"I" This abstract class provides a common interface to message digest implementation classes written in C. ==Write a Digest subclass in C Digest::Base provides a common interface to message digest classes written in C. These classes must provide a struct of type rb_digest_metadata_t: typedef int (*rb_digest_hash_init_func_t)(void *); typedef void (*rb_digest_hash_update_func_t)(void *, unsigned char *, size_t); typedef int (*rb_digest_hash_finish_func_t)(void *, unsigned char *); typedef struct { int api_version; size_t digest_len; size_t block_len; size_t ctx_size; rb_digest_hash_init_func_t init_func; rb_digest_hash_update_func_t update_func; rb_digest_hash_finish_func_t finish_func; } rb_digest_metadata_t; This structure must be set as an instance variable named +metadata+ (without the +@+ in front of the name). By example: static const rb_digest_metadata_t sha1 = { RUBY_DIGEST_API_VERSION, SHA1_DIGEST_LENGTH, SHA1_BLOCK_LENGTH, sizeof(SHA1_CTX), (rb_digest_hash_init_func_t)SHA1_Init, (rb_digest_hash_update_func_t)SHA1_Update, (rb_digest_hash_finish_func_t)SHA1_Finish, }; rb_ivar_set(cDigest_SHA1, rb_intern("metadata"), Data_Wrap_Struct(0, 0, 0, (void *)&sha1)); ;T;#0;$@F;.F;/o;0;1T;2i;3i;Bi;%@F;&I"Digest::Base;F;'@?F;;o; ;IC;[; @G; IC;[; @G; IC;[; @G; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"ext/digest/sha1/sha1init.c;Ti[@GiA;T;: SHA1;;;;;[;{;IC; "A class for calculating message digests using the SHA-1 Secure Hash Algorithm by NIST (the US' National Institute of Standards and Technology), described in FIPS PUB 180-1. See Digest::Instance for digest API. SHA-1 calculates a digest of 160 bits (20 bytes). == Examples require 'digest' # Compute a complete digest Digest::SHA1.hexdigest 'abc' #=> "a9993e36..." # Compute digest by chunks sha1 = Digest::SHA1.new # =># sha1.update "ab" sha1 << "c" # alias for #update sha1.hexdigest # => "a9993e36..." # Use the same object to compute another digest sha1.reset sha1 << "message" sha1.hexdigest # => "6f9b9af3..." ;T;[;![;"I"A class for calculating message digests using the SHA-1 Secure Hash Algorithm by NIST (the US' National Institute of Standards and Technology), described in FIPS PUB 180-1. See Digest::Instance for digest API. SHA-1 calculates a digest of 160 bits (20 bytes). == Examples require 'digest' # Compute a complete digest Digest::SHA1.hexdigest 'abc' #=> "a9993e36..." # Compute digest by chunks sha1 = Digest::SHA1.new # =># sha1.update "ab" sha1 << "c" # alias for #update sha1.hexdigest # => "a9993e36..." # Use the same object to compute another digest sha1.reset sha1 << "message" sha1.hexdigest # => "6f9b9af3..." ;T;#0;$@G;.F;/o;0;1T;2i;3i3;%o;( ;)0;*0;+0;;-;%@;-@D;0;&I"Digest::SHA1;F;'o;( ;)@;*I"Digest::Base;T;+0;;.;%@F;-@F;;o; ;IC;[; @G; IC;[; @G; IC;[; @G; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"#ext/digest/rmd160/rmd160init.c;Ti[@Gi;;T;: RMD160;;;;;[;{;IC; "A class for calculating message digests using RIPEMD-160 cryptographic hash function, designed by Hans Dobbertin, Antoon Bosselaers, and Bart Preneel. RMD160 calculates a digest of 160 bits (20 bytes). == Examples require 'digest' # Compute a complete digest Digest::RMD160.hexdigest 'abc' #=> "8eb208f7..." # Compute digest by chunks rmd160 = Digest::RMD160.new # =># rmd160.update "ab" rmd160 << "c" # alias for #update rmd160.hexdigest # => "8eb208f7..." # Use the same object to compute another digest rmd160.reset rmd160 << "message" rmd160.hexdigest # => "1dddbe1b..." ;T;[;![;"I"A class for calculating message digests using RIPEMD-160 cryptographic hash function, designed by Hans Dobbertin, Antoon Bosselaers, and Bart Preneel. RMD160 calculates a digest of 160 bits (20 bytes). == Examples require 'digest' # Compute a complete digest Digest::RMD160.hexdigest 'abc' #=> "8eb208f7..." # Compute digest by chunks rmd160 = Digest::RMD160.new # =># rmd160.update "ab" rmd160 << "c" # alias for #update rmd160.hexdigest # => "8eb208f7..." # Use the same object to compute another digest rmd160.reset rmd160 << "message" rmd160.hexdigest # => "1dddbe1b..." ;T;#0;$@G;.F;/o;0;1T;2i;3i-;%o;( ;)0;*0;+0;;-;%@;-@D;0;&I"Digest::RMD160;F;'o;( ;)@;*I"Digest::Base;T;+0;;.;%@F;-@F;;@Fo;4;5F;6;;;;&I"Digest#hexencode;F;7[[I"str;T0;[[@1Di;T;:hexencode;0;[;{;IC; "9Generates a hex-encoded version of a given _string_. ;T;[o;= ;>I" overload;F;?0;;1;@0;:I"hexencode(string);T;IC; ";T;[;![;"I";T;#0;$@G;.F;Bi;C0;7[[I" string;T0;$@G;![;"I"VGenerates a hex-encoded version of a given _string_. @overload hexencode(string) ;T;#0;$@G;.F;C0;%@D;9I"fstatic VALUE rb_digest_s_hexencode(VALUE klass, VALUE str) { return hexencode_str_new(str); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Digest.hexencode;F;7@G;@G;T;;1;0;@G;{;IC; "9Generates a hex-encoded version of a given _string_.;T;[o;= ;>I" overload;F;?0;;1;@0;:I"hexencode(string);T;IC; ";T;[;![;"I";T;#0;$@G;.F;Bi;C0;7[[I" string;T0;$@G;![;"I"WGenerates a hex-encoded version of a given _string_. @overload hexencode(string);T;#0;$@G;.F;/o;0;1T;2i;3i;Bi;%@D;9@G;:@G;;To; ;IC;[; @G; IC;[; @G; IC;[; @G; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"ext/openssl/ossl_digest.c;Ti;F;:DigestError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@G;%@D;&I"Digest::DigestError;F;'o; ;IC;[; @H; IC;[; @H; IC;[; @H; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"ext/openssl/ossl_pkcs7.c;Ti[I"#ext/openssl/ossl_ssl_session.c;Ti4[I"ext/openssl/ossl_hmac.c;Ti[I"ext/openssl/ossl_rand.c;Ti[I"ext/openssl/ossl_ocsp.c;Tiw[I"ext/openssl/ossl.c;Ti[I"ext/openssl/ossl_x509req.c;Ti[I"ext/openssl/ossl_kdf.c;Ti[I" ext/openssl/ossl_x509cert.c;Tie[I"!ext/openssl/ossl_x509store.c;Ti`[I"ext/openssl/ossl_x509crl.c;Ti[I"ext/openssl/ossl_pkey_ec.c;Ti[I"ext/openssl/ossl_bn.c;Ti[I"ext/openssl/ossl_cipher.c;TiQ[I"ext/openssl/ossl_pkcs12.c;Ti[@Hi>[I"ext/openssl/ossl_asn1.c;Ti}[I"#ext/openssl/ossl_x509revoked.c;Ti[I" ext/openssl/ossl_x509name.c;Ti [I"ext/openssl/ossl_x509ext.c;Ti[I"ext/openssl/ossl_ssl.c;Tiq [I"ext/openssl/ossl_config.c;Ti[I" ext/openssl/ossl_x509attr.c;Ti5[I"ext/openssl/ossl_engine.c;Ti [I"ext/openssl/ossl_ns_spki.c;Ti;F;:OpenSSLError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@H;%o;;IC;[.@Ho; ;IC;[&o; ;IC;[; @KH; IC;[; @KH; IC;[; @KH; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Hi;F;:PKCS7Error;;;;;[;{;IC; " ;T;[;![;"@;#0;$@KH;%@IH;&I"OpenSSL::PKCS7::PKCS7Error;F;'@Ho;4;5F;6;;;;&I"OpenSSL::PKCS7.read_smime;F;7[[I"arg;T0;[[@Hi;T;:read_smime;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;5;@0;:I"read_smime(string);T;IC; ";T;[;![;"I";T;#0;$@\H;.F;Bi;C0;7[[I" string;T0;$@\H;![;"I"" @overload read_smime(string);T;#0;$@\H;.F;/o;0;1T;2i;3i;%@IH;9I"static VALUE ossl_pkcs7_s_read_smime(VALUE klass, VALUE arg) { BIO *in, *out; PKCS7 *pkcs7; VALUE ret, data; ret = NewPKCS7(cPKCS7); in = ossl_obj2bio(&arg); out = NULL; pkcs7 = SMIME_read_PKCS7(in, &out); BIO_free(in); if(!pkcs7) ossl_raise(ePKCS7Error, NULL); data = out ? ossl_membio2str(out) : Qnil; SetPKCS7(ret, pkcs7); ossl_pkcs7_set_data(ret, data); ossl_pkcs7_set_err_string(ret, Qnil); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKCS7.write_smime;F;7[[@90;[[@Hi;T;:write_smime;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;6;@0;:I"*write_smime(pkcs7 [, data [, flags]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@vH;![;"I"@return [String];T;#0;$@vH;.F;Bi;C0;7[[I"pkcs7[, data [, flags]];T0;$@vH;![;"I"H @overload write_smime(pkcs7 [, data [, flags]]) @return [String];T;#0;$@vH;.F;/o;0;1T;2i;3i;%@IH;9I"static VALUE ossl_pkcs7_s_write_smime(int argc, VALUE *argv, VALUE klass) { VALUE pkcs7, data, flags; BIO *out, *in; PKCS7 *p7; VALUE str; int flg; rb_scan_args(argc, argv, "12", &pkcs7, &data, &flags); flg = NIL_P(flags) ? 0 : NUM2INT(flags); if(NIL_P(data)) data = ossl_pkcs7_get_data(pkcs7); GetPKCS7(pkcs7, p7); if(!NIL_P(data) && PKCS7_is_detached(p7)) flg |= PKCS7_DETACHED; in = NIL_P(data) ? NULL : ossl_obj2bio(&data); if(!(out = BIO_new(BIO_s_mem()))){ BIO_free(in); ossl_raise(ePKCS7Error, NULL); } if(!SMIME_write_PKCS7(out, p7, in, flg)){ BIO_free(out); BIO_free(in); ossl_raise(ePKCS7Error, NULL); } BIO_free(in); str = ossl_membio2str(out); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKCS7.sign;F;7[[@90;[[@Hi;T;: sign;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;7;@0;:I"/sign(cert, key, data, [, certs [, flags]]);T;IC; ";T;[;![;"I";T;#0;$@H;.F;Bi;C0;7[ [I" cert;T0[I"key;T0[I" data;T0[I"[, certs [, flags]];T0;$@H;![;"I": @overload sign(cert, key, data, [, certs [, flags]]);T;#0;$@H;.F;/o;0;1T;2i;3i;%@IH;9I"static VALUE ossl_pkcs7_s_sign(int argc, VALUE *argv, VALUE klass) { VALUE cert, key, data, certs, flags; X509 *x509; EVP_PKEY *pkey; BIO *in; STACK_OF(X509) *x509s; int flg, status = 0; PKCS7 *pkcs7; VALUE ret; rb_scan_args(argc, argv, "32", &cert, &key, &data, &certs, &flags); x509 = GetX509CertPtr(cert); /* NO NEED TO DUP */ pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */ flg = NIL_P(flags) ? 0 : NUM2INT(flags); ret = NewPKCS7(cPKCS7); in = ossl_obj2bio(&data); if(NIL_P(certs)) x509s = NULL; else{ x509s = ossl_protect_x509_ary2sk(certs, &status); if(status){ BIO_free(in); rb_jump_tag(status); } } if(!(pkcs7 = PKCS7_sign(x509, pkey, x509s, in, flg))){ BIO_free(in); sk_X509_pop_free(x509s, X509_free); ossl_raise(ePKCS7Error, NULL); } SetPKCS7(ret, pkcs7); ossl_pkcs7_set_data(ret, data); ossl_pkcs7_set_err_string(ret, Qnil); BIO_free(in); sk_X509_pop_free(x509s, X509_free); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKCS7.encrypt;F;7[[@90;[[@Hi;T;: encrypt;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;8;@0;:I"/encrypt(certs, data, [, cipher [, flags]]);T;IC; ";T;[;![;"I";T;#0;$@H;.F;Bi;C0;7[[I" certs;T0[I" data;T0[I"[, cipher [, flags]];T0;$@H;![;"I": @overload encrypt(certs, data, [, cipher [, flags]]);T;#0;$@H;.F;/o;0;1T;2i;3i;%@IH;9I"static VALUE ossl_pkcs7_s_encrypt(int argc, VALUE *argv, VALUE klass) { VALUE certs, data, cipher, flags; STACK_OF(X509) *x509s; BIO *in; const EVP_CIPHER *ciph; int flg, status = 0; VALUE ret; PKCS7 *p7; rb_scan_args(argc, argv, "22", &certs, &data, &cipher, &flags); if(NIL_P(cipher)){ #if !defined(OPENSSL_NO_RC2) ciph = EVP_rc2_40_cbc(); #elif !defined(OPENSSL_NO_DES) ciph = EVP_des_ede3_cbc(); #elif !defined(OPENSSL_NO_RC2) ciph = EVP_rc2_40_cbc(); #elif !defined(OPENSSL_NO_AES) ciph = EVP_EVP_aes_128_cbc(); #else ossl_raise(ePKCS7Error, "Must specify cipher"); #endif } else ciph = ossl_evp_get_cipherbyname(cipher); flg = NIL_P(flags) ? 0 : NUM2INT(flags); ret = NewPKCS7(cPKCS7); in = ossl_obj2bio(&data); x509s = ossl_protect_x509_ary2sk(certs, &status); if(status){ BIO_free(in); rb_jump_tag(status); } if(!(p7 = PKCS7_encrypt(x509s, in, (EVP_CIPHER*)ciph, flg))){ BIO_free(in); sk_X509_pop_free(x509s, X509_free); ossl_raise(ePKCS7Error, NULL); } BIO_free(in); SetPKCS7(ret, p7); ossl_pkcs7_set_data(ret, data); sk_X509_pop_free(x509s, X509_free); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::PKCS7#initialize_copy;F;7[[I" other;T0;[[@Hif;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@H;%@IH;9I"Wstatic VALUE ossl_pkcs7_copy(VALUE self, VALUE other) { PKCS7 *a, *b, *pkcs7; rb_check_frozen(self); if (self == other) return self; GetPKCS7(self, a); GetPKCS7(other, b); pkcs7 = PKCS7_dup(b); if (!pkcs7) { ossl_raise(ePKCS7Error, NULL); } DATA_PTR(self) = pkcs7; PKCS7_free(a); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKCS7#initialize;F;7[[@90;[[@HiJ;T;;D;0;[;{;IC; "2Many methods in this class aren't documented. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new;T;IC; ";T;[;![;"I";T;#0;$@H;.F;Bi;C0;7[;$@Ho;= ;>I" overload;F;?0;;E;@0;:I"new(string);T;IC; ";T;[;![;"I";T;#0;$@H;.F;Bi;C0;7[[I" string;T0;$@H;![;"I"XMany methods in this class aren't documented. @overload new @overload new(string);T;#0;$@H;.F;/o;0;1T;2iC;3iG;%@IH;9I"static VALUE ossl_pkcs7_initialize(int argc, VALUE *argv, VALUE self) { PKCS7 *p7, *p7_orig = RTYPEDDATA_DATA(self); BIO *in; VALUE arg; if(rb_scan_args(argc, argv, "01", &arg) == 0) return self; arg = ossl_to_der_if_possible(arg); in = ossl_obj2bio(&arg); p7 = d2i_PKCS7_bio(in, NULL); if (!p7) { OSSL_BIO_reset(in); p7 = PEM_read_bio_PKCS7(in, NULL, NULL, NULL); } BIO_free(in); if (!p7) ossl_raise(rb_eArgError, "Could not parse the PKCS7"); RTYPEDDATA_DATA(self) = p7; PKCS7_free(p7_orig); ossl_pkcs7_set_data(self, Qnil); ossl_pkcs7_set_err_string(self, Qnil); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKCS7#type=;F;7[[I" type;T0;[[@Hi;T;: type=;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;9;@0;:I"type=(type);T;IC; ";T;[;![;"I";T;#0;$@H;.F;Bi;C0;7[[I" type;T0;$@H;![;"I" @overload type=(type);T;#0;$@H;.F;/o;0;1T;2i;3i;%@IH;9I"static VALUE ossl_pkcs7_set_type(VALUE self, VALUE type) { PKCS7 *p7; GetPKCS7(self, p7); if(!PKCS7_set_type(p7, ossl_pkcs7_sym2typeid(type))) ossl_raise(ePKCS7Error, NULL); return type; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKCS7#type;F;7[;[[@Hi;T;;;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I" type;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@I;![;"I"@return [String, nil];T;#0;$@I;.F;Bi;C0;7[;$@I;![;"I", @overload type @return [String, nil];T;#0;$@I;.F;/o;0;1T;2i;3i;%@IH;9I"static VALUE ossl_pkcs7_get_type(VALUE self) { PKCS7 *p7; GetPKCS7(self, p7); if(PKCS7_type_is_signed(p7)) return ID2SYM(rb_intern("signed")); if(PKCS7_type_is_encrypted(p7)) return ID2SYM(rb_intern("encrypted")); if(PKCS7_type_is_enveloped(p7)) return ID2SYM(rb_intern("enveloped")); if(PKCS7_type_is_signedAndEnveloped(p7)) return ID2SYM(rb_intern("signedAndEnveloped")); if(PKCS7_type_is_data(p7)) return ID2SYM(rb_intern("data")); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKCS7#detached=;F;7[[I" flag;T0;[[@Hi;T;:detached=;0;[;{;IC; " ;T;[;![;"@;#0;$@5I;%@IH;9I"-static VALUE ossl_pkcs7_set_detached(VALUE self, VALUE flag) { PKCS7 *p7; GetPKCS7(self, p7); if(flag != Qtrue && flag != Qfalse) ossl_raise(ePKCS7Error, "must specify a boolean"); if(!PKCS7_set_detached(p7, flag == Qtrue ? 1 : 0)) ossl_raise(ePKCS7Error, NULL); return flag; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKCS7#detached;F;7[;[[@Hi;T;: detached;0;[;{;IC; " ;T;[;![;"@;#0;$@CI;%@IH;9I"static VALUE ossl_pkcs7_get_detached(VALUE self) { PKCS7 *p7; GetPKCS7(self, p7); return PKCS7_get_detached(p7) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKCS7#detached?;F;7[;[[@Hi;T;:detached?;0;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@OI;![;"@;#0;$@OI;Bi;%@IH;9I"static VALUE ossl_pkcs7_detached_p(VALUE self) { PKCS7 *p7; GetPKCS7(self, p7); return PKCS7_is_detached(p7) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKCS7#cipher=;F;7[[I" cipher;T0;[[@Hi;T;: cipher=;0;[;{;IC; " ;T;[;![;"@;#0;$@^I;%@IH;9I"static VALUE ossl_pkcs7_set_cipher(VALUE self, VALUE cipher) { PKCS7 *pkcs7; GetPKCS7(self, pkcs7); if (!PKCS7_set_cipher(pkcs7, ossl_evp_get_cipherbyname(cipher))) { ossl_raise(ePKCS7Error, NULL); } return cipher; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKCS7#add_signer;F;7[[I" signer;T0;[[@Hi;T;:add_signer;0;[;{;IC; " ;T;[;![;"@;#0;$@lI;%@IH;9I"static VALUE ossl_pkcs7_add_signer(VALUE self, VALUE signer) { PKCS7 *pkcs7; PKCS7_SIGNER_INFO *si, *si_new; GetPKCS7(self, pkcs7); GetPKCS7si(signer, si); si_new = ossl_PKCS7_SIGNER_INFO_dup(si); if (!si_new) ossl_raise(ePKCS7Error, "PKCS7_SIGNER_INFO_dup"); if (PKCS7_add_signer(pkcs7, si_new) != 1) { PKCS7_SIGNER_INFO_free(si_new); ossl_raise(ePKCS7Error, "PKCS7_add_signer"); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKCS7#signers;F;7[;[[@Hi;T;: signers;0;[;{;IC; " ;T;[;![;"@;#0;$@zI;%@IH;9I"Wstatic VALUE ossl_pkcs7_get_signer(VALUE self) { PKCS7 *pkcs7; STACK_OF(PKCS7_SIGNER_INFO) *sk; PKCS7_SIGNER_INFO *si; int num, i; VALUE ary; GetPKCS7(self, pkcs7); if (!(sk = PKCS7_get_signer_info(pkcs7))) { OSSL_Debug("OpenSSL::PKCS7#get_signer_info == NULL!"); return rb_ary_new(); } if ((num = sk_PKCS7_SIGNER_INFO_num(sk)) < 0) { ossl_raise(ePKCS7Error, "Negative number of signers!"); } ary = rb_ary_new2(num); for (i=0; id.enveloped->recipientinfo; else if (PKCS7_type_is_signedAndEnveloped(pkcs7)) sk = pkcs7->d.signed_and_enveloped->recipientinfo; else sk = NULL; if (!sk) return rb_ary_new(); if ((num = sk_PKCS7_RECIP_INFO_num(sk)) < 0) { ossl_raise(ePKCS7Error, "Negative number of recipient!"); } ary = rb_ary_new2(num); for (i=0; iissuer_and_serial->issuer); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::PKCS7::SignerInfo#serial;F;7[;[[@Hi;T;: serial;0;[;{;IC; " ;T;[;![;"@;#0;$@`J;%@@J;9I"static VALUE ossl_pkcs7si_get_serial(VALUE self) { PKCS7_SIGNER_INFO *p7si; GetPKCS7si(self, p7si); return asn1integer_to_num(p7si->issuer_and_serial->serial); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+OpenSSL::PKCS7::SignerInfo#signed_time;F;7[;[[@Hi;T;:signed_time;0;[;{;IC; " ;T;[;![;"@;#0;$@lJ;%@@J;9I"static VALUE ossl_pkcs7si_get_signed_time(VALUE self) { PKCS7_SIGNER_INFO *p7si; ASN1_TYPE *asn1obj; GetPKCS7si(self, p7si); if (!(asn1obj = PKCS7_get_signed_attribute(p7si, NID_pkcs9_signingTime))) { ossl_raise(ePKCS7Error, NULL); } if (asn1obj->type == V_ASN1_UTCTIME) { return asn1time_to_time(asn1obj->value.utctime); } /* * OR * ossl_raise(ePKCS7Error, "..."); * ? */ return Qnil; };T;:I"static VALUE;T;;T; @@J; IC;[; @@J; IC;[; @@J; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Hi;F;:SignerInfo;;;;;[;{;IC; " ;T;[;![;"@;#0;$@@J;%@IH;&I"OpenSSL::PKCS7::SignerInfo;F;'@o;u;[[@Hi;F;: Signer;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@J;%@IH;&I"OpenSSL::PKCS7::Signer;F;xI"cPKCS7Signer;To; ;IC;[ o;4;5F;6;;;;&I"-OpenSSL::PKCS7::RecipientInfo#initialize;F;7[[I" cert;T0;[[@Hi;T;;D;0;[;{;IC; " ;T;[;![;"@;#0;$@J;%@J;9I"$static VALUE ossl_pkcs7ri_initialize(VALUE self, VALUE cert) { PKCS7_RECIP_INFO *p7ri; X509 *x509; x509 = GetX509CertPtr(cert); /* NO NEED TO DUP */ GetPKCS7ri(self, p7ri); if (!PKCS7_RECIP_INFO_set(p7ri, x509)) { ossl_raise(ePKCS7Error, NULL); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I")OpenSSL::PKCS7::RecipientInfo#issuer;F;7[;[[@Hi;T;;N;0;[;{;IC; " ;T;[;![;"@;#0;$@J;%@J;9I"static VALUE ossl_pkcs7ri_get_issuer(VALUE self) { PKCS7_RECIP_INFO *p7ri; GetPKCS7ri(self, p7ri); return ossl_x509name_new(p7ri->issuer_and_serial->issuer); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I")OpenSSL::PKCS7::RecipientInfo#serial;F;7[;[[@Hi;T;;O;0;[;{;IC; " ;T;[;![;"@;#0;$@J;%@J;9I"static VALUE ossl_pkcs7ri_get_serial(VALUE self) { PKCS7_RECIP_INFO *p7ri; GetPKCS7ri(self, p7ri); return asn1integer_to_num(p7ri->issuer_and_serial->serial); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*OpenSSL::PKCS7::RecipientInfo#enc_key;F;7[;[[@Hi;T;: enc_key;0;[;{;IC; " ;T;[;![;"@;#0;$@J;%@J;9I"static VALUE ossl_pkcs7ri_get_enc_key(VALUE self) { PKCS7_RECIP_INFO *p7ri; GetPKCS7ri(self, p7ri); return asn1str_to_str(p7ri->enc_key); };T;:I"static VALUE;T;;T; @J; IC;[; @J; IC;[; @J; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Hi&;F;:RecipientInfo;;;;;[;{;IC; " ;T;[;![;"@;#0;$@J;%@IH;&I""OpenSSL::PKCS7::RecipientInfo;F;'@; @IH; IC;[; @IH; IC;[; @IH; IC;{;IC;{;T;IC;{;T;T;{@I;H@*J;L;[;[[@Hi;F;: PKCS7;;;;;[;{;IC; " ;T;[;![;"@;#0;$@IH;Bi;%@GH;&I"OpenSSL::PKCS7;F;'@o;;IC;[Eo; ;IC;[o; ;IC;[; @J; IC;[; @J; IC;[; @J; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Hi7;F;:SessionError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@J;%@J;&I"(OpenSSL::SSL::Session::SessionError;F;'@Ho;4;5F;6;;;;&I"%OpenSSL::SSL::Session#initialize;F;7[[I" arg1;T0;[[@Hi*;T;;D;0;[;{;IC; "ZCreates a new Session object from an instance of SSLSocket or DER/PEM encoded String. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(ssl_socket);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Session;T;$@J;![;"I"@return [Session];T;#0;$@J;.F;Bi;C0;7[[I"ssl_socket;T0;$@Jo;= ;>I" overload;F;?0;;E;@0;:I"new(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Session;T;$@J;![;"I"@return [Session];T;#0;$@J;.F;Bi;C0;7[[I" string;T0;$@J;![;"I"Creates a new Session object from an instance of SSLSocket or DER/PEM encoded String. @overload new(ssl_socket) @return [Session] @overload new(string) @return [Session];T;#0;$@J;.F;/o;0;1T;2i";3i);%@J;9I"static VALUE ossl_ssl_session_initialize(VALUE self, VALUE arg1) { SSL_SESSION *ctx; if (RTYPEDDATA_DATA(self)) ossl_raise(eSSLSession, "SSL Session already initialized"); if (rb_obj_is_instance_of(arg1, cSSLSocket)) { SSL *ssl; GetSSL(arg1, ssl); if ((ctx = SSL_get1_session(ssl)) == NULL) ossl_raise(eSSLSession, "no session available"); } else { BIO *in = ossl_obj2bio(&arg1); ctx = d2i_SSL_SESSION_bio(in, NULL); if (!ctx) { OSSL_BIO_reset(in); ctx = PEM_read_bio_SSL_SESSION(in, NULL, NULL, NULL); } BIO_free(in); if (!ctx) ossl_raise(rb_eArgError, "unknown type"); } RTYPEDDATA_DATA(self) = ctx; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*OpenSSL::SSL::Session#initialize_copy;F;7[[I" other;T0;[[@HiL;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@&K;%@J;9I"static VALUE ossl_ssl_session_initialize_copy(VALUE self, VALUE other) { SSL_SESSION *sess, *sess_other, *sess_new; rb_check_frozen(self); sess = RTYPEDDATA_DATA(self); /* XXX */ GetSSLSession(other, sess_other); sess_new = ASN1_dup((i2d_of_void *)i2d_SSL_SESSION, (d2i_of_void *)d2i_SSL_SESSION, (char *)sess_other); if (!sess_new) ossl_raise(eSSLSession, "ASN1_dup"); RTYPEDDATA_DATA(self) = sess_new; SSL_SESSION_free(sess); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::SSL::Session#==;F;7[[I" val2;T0;[[@Hiv;T;;F;0;[;{;IC; "CReturns +true+ if the two Session is the same, +false+ if not. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(session2);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@4K;![;"I"@return [Boolean];T;#0;$@4K;.F;Bi;C0;7[[I" session2;T0;$@4K;![;"I"pReturns +true+ if the two Session is the same, +false+ if not. @overload ==(session2) @return [Boolean];T;#0;$@4K;.F;/o;0;1T;2ip;3it;%@J;9I"static VALUE ossl_ssl_session_eq(VALUE val1, VALUE val2) { SSL_SESSION *ctx1, *ctx2; GetSSLSession(val1, ctx1); GetSSLSession(val2, ctx2); switch (ossl_SSL_SESSION_cmp(ctx1, ctx2)) { case 0: return Qtrue; default: return Qfalse; } };T;:I"=static VALUE ossl_ssl_session_eq(VALUE val1, VALUE val2);T;;To;4;5F;6;;;;&I"OpenSSL::SSL::Session#time;F;7[;[[@Hi;T;: time;0;[;{;IC; ";Returns the time at which the session was established. ;T;[o;= ;>I" overload;F;?0;;W;@0;:I" time;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@SK;![;"I"@return [Time];T;#0;$@SK;.F;Bi;C0;7[;$@SK;![;"I"]Returns the time at which the session was established. @overload time @return [Time];T;#0;$@SK;.F;/o;0;1T;2i~;3i;%@J;9I"static VALUE ossl_ssl_session_get_time(VALUE self) { SSL_SESSION *ctx; long t; GetSSLSession(self, ctx); t = SSL_SESSION_get_time(ctx); if (t == 0) return Qnil; return rb_funcall(rb_cTime, rb_intern("at"), 1, LONG2NUM(t)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" OpenSSL::SSL::Session#time=;F;7[[I" time_v;T0;[[@Hi;T;: time=;0;[;{;IC; "CSets start time of the session. Time resolution is in seconds. ;T;[o;= ;>I" overload;F;?0;;X;@0;:I"time=(time);T;IC; ";T;[;![;"I";T;#0;$@nK;.F;Bi;C0;7[[I" time;T0;$@nKo;= ;>I" overload;F;?0;;X;@0;:I"time=(integer);T;IC; ";T;[;![;"I";T;#0;$@nK;.F;Bi;C0;7[[I" integer;T0;$@nK;![;"I"uSets start time of the session. Time resolution is in seconds. @overload time=(time) @overload time=(integer);T;#0;$@nK;.F;/o;0;1T;2i;3i;%@J;9I"Cstatic VALUE ossl_ssl_session_set_time(VALUE self, VALUE time_v) { SSL_SESSION *ctx; long t; GetSSLSession(self, ctx); if (rb_obj_is_instance_of(time_v, rb_cTime)) { time_v = rb_funcall(time_v, rb_intern("to_i"), 0); } t = NUM2LONG(time_v); SSL_SESSION_set_time(ctx, t); return ossl_ssl_session_get_time(self); };T;:I"Estatic VALUE ossl_ssl_session_set_time(VALUE self, VALUE time_v);T;;To;4;5F;6;;;;&I""OpenSSL::SSL::Session#timeout;F;7[;[[@Hi;T;: timeout;0;[;{;IC; "YReturns the timeout value set for the session, in seconds from the established time. ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I" timeout;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@K;![;"I"@return [Integer];T;#0;$@K;.F;Bi;C0;7[;$@K;![;"I"}Returns the timeout value set for the session, in seconds from the established time. @overload timeout @return [Integer];T;#0;$@K;.F;/o;0;1T;2i;3i;%@J;9I"static VALUE ossl_ssl_session_get_timeout(VALUE self) { SSL_SESSION *ctx; long t; GetSSLSession(self, ctx); t = SSL_SESSION_get_timeout(ctx); return LONG2NUM(t); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::SSL::Session#timeout=;F;7[[I" time_v;T0;[[@Hi;T;: timeout=;0;[;{;IC; "8Sets how long until the session expires in seconds. ;T;[o;= ;>I" overload;F;?0;;Z;@0;:I"timeout=(integer);T;IC; ";T;[;![;"I";T;#0;$@K;.F;Bi;C0;7[[I" integer;T0;$@K;![;"I"VSets how long until the session expires in seconds. @overload timeout=(integer);T;#0;$@K;.F;/o;0;1T;2i;3i;%@J;9I"static VALUE ossl_ssl_session_set_timeout(VALUE self, VALUE time_v) { SSL_SESSION *ctx; long t; GetSSLSession(self, ctx); t = NUM2LONG(time_v); SSL_SESSION_set_timeout(ctx, t); return ossl_ssl_session_get_timeout(self); };T;:I"Hstatic VALUE ossl_ssl_session_set_timeout(VALUE self, VALUE time_v);T;;To;4;5F;6;;;;&I"OpenSSL::SSL::Session#id;F;7[;[[@Hi;T;:id;0;[;{;IC; "Returns the Session ID. ;T;[o;= ;>I" overload;F;?0;;[;@0;:I"id;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@K;![;"I"@return [String];T;#0;$@K;.F;Bi;C0;7[;$@K;![;"I">Returns the Session ID. @overload id @return [String];T;#0;$@K;.F;/o;0;1T;2i;3i;%@J;9I"static VALUE ossl_ssl_session_get_id(VALUE self) { SSL_SESSION *ctx; const unsigned char *p = NULL; unsigned int i = 0; GetSSLSession(self, ctx); p = SSL_SESSION_get_id(ctx, &i); return rb_str_new((const char *) p, i); };T;:I"5static VALUE ossl_ssl_session_get_id(VALUE self);T;;To;4;5F;6;;;;&I"!OpenSSL::SSL::Session#to_der;F;7[;[[@Hi;T;;M;0;[;{;IC; "EReturns an ASN1 encoded String that contains the Session object. ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" to_der;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@K;![;"I"@return [String];T;#0;$@K;.F;Bi;C0;7[;$@K;![;"I"kReturns an ASN1 encoded String that contains the Session object. @overload to_der @return [String];T;#0;$@K;.F;/o;0;1T;2i;3i;%@J;9I"wstatic VALUE ossl_ssl_session_to_der(VALUE self) { SSL_SESSION *ctx; unsigned char *p; int len; VALUE str; GetSSLSession(self, ctx); len = i2d_SSL_SESSION(ctx, NULL); if (len <= 0) { ossl_raise(eSSLSession, "i2d_SSL_SESSION"); } str = rb_str_new(0, len); p = (unsigned char *)RSTRING_PTR(str); i2d_SSL_SESSION(ctx, &p); ossl_str_adjust(str, p); return str; };T;:I"5static VALUE ossl_ssl_session_to_der(VALUE self);T;;To;4;5F;6;;;;&I"!OpenSSL::SSL::Session#to_pem;F;7[;[[@Hi;T;;L;0;[;{;IC; "CReturns a PEM encoded String that contains the Session object. ;T;[o;= ;>I" overload;F;?0;;L;@0;:I" to_pem;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@K;![;"I"@return [String];T;#0;$@K;.F;Bi;C0;7[;$@K;![;"I"iReturns a PEM encoded String that contains the Session object. @overload to_pem @return [String];T;#0;$@K;.F;/o;0;1T;2i;3i;%@J;9I"Vstatic VALUE ossl_ssl_session_to_pem(VALUE self) { SSL_SESSION *ctx; BIO *out; GetSSLSession(self, ctx); if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eSSLSession, "BIO_s_mem()"); } if (!PEM_write_bio_SSL_SESSION(out, ctx)) { BIO_free(out); ossl_raise(eSSLSession, "SSL_SESSION_print()"); } return ossl_membio2str(out); };T;:I"5static VALUE ossl_ssl_session_to_pem(VALUE self);T;;To;4;5F;6;;;;&I""OpenSSL::SSL::Session#to_text;F;7[;[[@Hi;T;: to_text;0;[;{;IC; "MShows everything in the Session object. This is for diagnostic purposes. ;T;[o;= ;>I" overload;F;?0;;\;@0;:I" to_text;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@L;![;"I"@return [String];T;#0;$@L;.F;Bi;C0;7[;$@L;![;"I"tShows everything in the Session object. This is for diagnostic purposes. @overload to_text @return [String];T;#0;$@L;.F;/o;0;1T;2i;3i;%@J;9I"Nstatic VALUE ossl_ssl_session_to_text(VALUE self) { SSL_SESSION *ctx; BIO *out; GetSSLSession(self, ctx); if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eSSLSession, "BIO_s_mem()"); } if (!SSL_SESSION_print(out, ctx)) { BIO_free(out); ossl_raise(eSSLSession, "SSL_SESSION_print()"); } return ossl_membio2str(out); };T;:I"6static VALUE ossl_ssl_session_to_text(VALUE self);T;;T; @J; IC;[; @J; IC;[; @J; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Hi6;F;: Session;;;;;[;{;IC; " ;T;[;![;"@;#0;$@J;Bi;%@J;&I"OpenSSL::SSL::Session;F;'@o; ;IC;[; @BL; IC;[; @BL; IC;[; @BL; IC;{;IC;{;T;IC;{;T;T;{;[;[[@9Hi [@9Hi ;T;: SSLError;;;;;[;{;IC; " Generic error class raised by SSLSocket and SSLContext. ;T;#0;$@BL;.F;/o;0;1T;2i ;3i ;%@J;&I"OpenSSL::SSL::SSLError;F;'@Ho; ;IC;[; @VL; IC;[; @VL; IC;[o;;IC;[; @ZL; IC;[; @ZL; IC;[; @ZL; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Tij7[@9Hir ;F;:WaitReadable;;;;;[;{;IC; " ;T;[;![;"@;#0;$@ZL;%o; ;IC;[o;u;[[@Tie7;F;: READABLE;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@mL;%@kL;&I"IO::READABLE;F;xI"INT2NUM(RUBY_IO_READABLE);To;u;[[@Tif7;F;: WRITABLE;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@wL;%@kL;&I"IO::WRITABLE;F;xI"INT2NUM(RUBY_IO_WRITABLE);To;u;[[@Tig7;F;: PRIORITY;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@L;%@kL;&I"IO::PRIORITY;F;xI"INT2NUM(RUBY_IO_PRIORITY);T@ZLo;;IC;[; @L; IC;[; @L; IC;[; @L; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Til7[@9His ;F;:WaitWritable;;;;;[;{;IC; " ;T;[;![;"@;#0;$@L;%@kL;&I"IO::WaitWritable;Fo; ;IC;[; @L; IC;[; @L; IC;[@ZL; @L; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Tin7;F;:EAGAINWaitReadable;;;;;[;{;IC; " ;T;[;![;"@;#0;$@L;%@kL;&I"IO::EAGAINWaitReadable;F;'o;( ;)0;*0;+0;: EAGAIN;%@;-0;;o; ;IC;[; @L; IC;[; @L; IC;[@L; @L; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Tiq7;F;:EAGAINWaitWritable;;;;;[;{;IC; " ;T;[;![;"@;#0;$@L;%@kL;&I"IO::EAGAINWaitWritable;F;'o;( ;)0;*0;+0;;e;%@;-0;;o; ;IC;[; @L; IC;[; @L; IC;[@ZL; @L; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Ti|7;F;:EWOULDBLOCKWaitReadable;;;;;[;{;IC; " ;T;[;![;"@;#0;$@L;%@kL;&I" IO::EWOULDBLOCKWaitReadable;F;'o;( ;)0;*0;+0;:EWOULDBLOCK;%@;-0;;o; ;IC;[; @L; IC;[; @L; IC;[@L; @L; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Ti7;F;:EWOULDBLOCKWaitWritable;;;;;[;{;IC; " ;T;[;![;"@;#0;$@L;%@kL;&I" IO::EWOULDBLOCKWaitWritable;F;'o;( ;)0;*0;+0;;h;%@;-0;;o; ;IC;[; @L; IC;[; @L; IC;[@ZL; @L; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Ti7;F;:EINPROGRESSWaitReadable;;;;;[;{;IC; " ;T;[;![;"@;#0;$@L;%@kL;&I" IO::EINPROGRESSWaitReadable;F;'o;( ;)0;*0;+0;:EINPROGRESS;%@;-0;;o; ;IC;[; @L; IC;[; @L; IC;[@L; @L; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Ti7;F;:EINPROGRESSWaitWritable;;;;;[;{;IC; " ;T;[;![;"@;#0;$@L;%@kL;&I" IO::EINPROGRESSWaitWritable;F;'o;( ;)0;*0;+0;;k;%@;-0;;o;4;5F;6;;;;&I" IO.new;F;7[[@90;[[@Ti";T;;E;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@ M;.F;/o;0;1T;2i";3i";%@kL;9I"Estatic VALUE rb_io_s_new(int argc, VALUE *argv, VALUE klass) { if (rb_block_given_p()) { VALUE cname = rb_obj_as_string(klass); rb_warn("%"PRIsVALUE"::new() does not take block; use %"PRIsVALUE"::open() instead", cname, cname); } return rb_class_new_instance_kw(argc, argv, klass, RB_PASS_CALLED_KEYWORDS); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO.open;F;7[[@90;[[@Ti6;T;;;0;[;{;IC; "call-seq: IO.open(fd, mode="r" [, opt]) -> io IO.open(fd, mode="r" [, opt]) {|io| block } -> obj With no associated block, IO.open is a synonym for IO.new. If the optional code block is given, it will be passed +io+ as an argument, and the IO object will automatically be closed when the block terminates. In this instance, IO.open returns the value of the block. See IO.new for a description of the +fd+, +mode+ and +opt+ parameters. ;T;[;![;"I" call-seq: IO.open(fd, mode="r" [, opt]) -> io IO.open(fd, mode="r" [, opt]) {|io| block } -> obj With no associated block, IO.open is a synonym for IO.new. If the optional code block is given, it will be passed +io+ as an argument, and the IO object will automatically be closed when the block terminates. In this instance, IO.open returns the value of the block. See IO.new for a description of the +fd+, +mode+ and +opt+ parameters. ;T;#0;$@M;.F;/o;0;1T;2i';3i2;%@kL;9I"static VALUE rb_io_s_open(int argc, VALUE *argv, VALUE klass) { VALUE io = rb_class_new_instance_kw(argc, argv, klass, RB_PASS_CALLED_KEYWORDS); if (rb_block_given_p()) { return rb_ensure(rb_yield, io, io_close, io); } return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO.sysopen;F;7[[@90;[[@TiL;T;: sysopen;0;[;{;IC; "tOpens the given path, returning the underlying file descriptor as a Integer. IO.sysopen("testfile") #=> 3 ;T;[o;= ;>I" overload;F;?0;;m;@0;:I""sysopen(path, [mode, [perm]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@'M;![;"I"@return [Integer];T;#0;$@'M;.F;Bi;C0;7[[I" path;T0[I"[mode, [perm]];T0;$@'M;![;"I"Opens the given path, returning the underlying file descriptor as a Integer. IO.sysopen("testfile") #=> 3 @overload sysopen(path, [mode, [perm]]) @return [Integer];T;#0;$@'M;.F;/o;0;1T;2iB;3iI;%@kL;9I"static VALUE rb_io_s_sysopen(int argc, VALUE *argv, VALUE _) { VALUE fname, vmode, vperm; VALUE intmode; int oflags, fd; mode_t perm; rb_scan_args(argc, argv, "12", &fname, &vmode, &vperm); FilePathValue(fname); if (NIL_P(vmode)) oflags = O_RDONLY; else if (!NIL_P(intmode = rb_check_to_integer(vmode, "to_int"))) oflags = NUM2INT(intmode); else { SafeStringValue(vmode); oflags = rb_io_modestr_oflags(StringValueCStr(vmode)); } if (NIL_P(vperm)) perm = 0666; else perm = NUM2MODET(vperm); RB_GC_GUARD(fname) = rb_str_new4(fname); fd = rb_sysopen(fname, oflags, perm); return INT2NUM(fd); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO.for_fd;F;7[[@90;[[@Ti";T;: for_fd;0;[;{;IC; "Synonym for IO.new. ;T;[o;= ;>I" overload;F;?0;;n;@0;:I"for_fd(fd, mode [, opt]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"IO;T;$@GM;![;"I"@return [IO];T;#0;$@GM;.F;Bi;C0;7[[I"fd;T0[I"mode[, opt];T0;$@GM;![;"I"MSynonym for IO.new. @overload for_fd(fd, mode [, opt]) @return [IO];T;#0;$@GM;.F;/o;0;1T;2i";3i";%@kL;9I"static VALUE rb_io_s_for_fd(int argc, VALUE *argv, VALUE klass) { VALUE io = rb_obj_alloc(klass); rb_io_initialize(argc, argv, io); return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO.popen;F;7[[@90;[[@Ti;T;: popen;0;[;{;IC; "E Runs the specified command as a subprocess; the subprocess's standard input and output will be connected to the returned IO object. The PID of the started process can be obtained by IO#pid method. _cmd_ is a string or an array as follows. cmd: "-" : fork commandline : command line string which is passed to a shell [env, cmdname, arg1, ..., opts] : command name and zero or more arguments (no shell) [env, [cmdname, argv0], arg1, ..., opts] : command name, argv[0] and zero or more arguments (no shell) (env and opts are optional.) If _cmd_ is a +String+ ``-'', then a new instance of Ruby is started as the subprocess. If cmd is an +Array+ of +String+, then it will be used as the subprocess's +argv+ bypassing a shell. The array can contain a hash at first for environments and a hash at last for options similar to #spawn. The default mode for the new file object is ``r'', but mode may be set to any of the modes listed in the description for class IO. The last argument opt qualifies mode. # set IO encoding IO.popen("nkf -e filename", :external_encoding=>"EUC-JP") {|nkf_io| euc_jp_string = nkf_io.read } # merge standard output and standard error using # spawn option. See the document of Kernel.spawn. IO.popen(["ls", "/", :err=>[:child, :out]]) {|ls_io| ls_result_with_error = ls_io.read } # spawn options can be mixed with IO options IO.popen(["ls", "/"], :err=>[:child, :out]) {|ls_io| ls_result_with_error = ls_io.read } Raises exceptions which IO.pipe and Kernel.spawn raise. If a block is given, Ruby will run the command as a child connected to Ruby with a pipe. Ruby's end of the pipe will be passed as a parameter to the block. At the end of block, Ruby closes the pipe and sets $?. In this case IO.popen returns the value of the block. If a block is given with a _cmd_ of ``-'', the block will be run in two separate processes: once in the parent, and once in a child. The parent process will be passed the pipe object as a parameter to the block, the child version of the block will be passed +nil+, and the child's standard in and standard out will be connected to the parent through the pipe. Not available on all platforms. f = IO.popen("uname") p f.readlines f.close puts "Parent is #{Process.pid}" IO.popen("date") {|f| puts f.gets } IO.popen("-") {|f| $stderr.puts "#{Process.pid} is here, f is #{f.inspect}"} p $? IO.popen(%w"sed -e s|^|| -e s&$&;zot;&", "r+") {|f| f.puts "bar"; f.close_write; puts f.gets } produces: ["Linux\n"] Parent is 21346 Thu Jan 15 22:41:19 JST 2009 21346 is here, f is # 21352 is here, f is nil # bar;zot; ;T;[o;= ;>I" overload;F;?0;;o;@0;:I"(popen([env,] cmd, mode="r" [, opt]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"IO;T;$@gM;![;"I"@return [IO];T;#0;$@gM;.F;Bi;C0;7[[I" [env,];T0[I" mode;TI""r"[, opt];T;$@gMo;= ;>I" overload;F;?0;;o;@0;:I"(popen([env,] cmd, mode="r" [, opt]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"io;T;$@gMo;A ;>I" return;F;?I";T;0;@[I" Object;T;$@gM;![;"I"!@yield [io] @return [Object];T;#0;$@gM;.F;Bi;C0;7[[I" [env,];T0[I" mode;TI""r"[, opt];T;$@gM;![;"I" Runs the specified command as a subprocess; the subprocess's standard input and output will be connected to the returned IO object. The PID of the started process can be obtained by IO#pid method. _cmd_ is a string or an array as follows. cmd: "-" : fork commandline : command line string which is passed to a shell [env, cmdname, arg1, ..., opts] : command name and zero or more arguments (no shell) [env, [cmdname, argv0], arg1, ..., opts] : command name, argv[0] and zero or more arguments (no shell) (env and opts are optional.) If _cmd_ is a +String+ ``-'', then a new instance of Ruby is started as the subprocess. If cmd is an +Array+ of +String+, then it will be used as the subprocess's +argv+ bypassing a shell. The array can contain a hash at first for environments and a hash at last for options similar to #spawn. The default mode for the new file object is ``r'', but mode may be set to any of the modes listed in the description for class IO. The last argument opt qualifies mode. # set IO encoding IO.popen("nkf -e filename", :external_encoding=>"EUC-JP") {|nkf_io| euc_jp_string = nkf_io.read } # merge standard output and standard error using # spawn option. See the document of Kernel.spawn. IO.popen(["ls", "/", :err=>[:child, :out]]) {|ls_io| ls_result_with_error = ls_io.read } # spawn options can be mixed with IO options IO.popen(["ls", "/"], :err=>[:child, :out]) {|ls_io| ls_result_with_error = ls_io.read } Raises exceptions which IO.pipe and Kernel.spawn raise. If a block is given, Ruby will run the command as a child connected to Ruby with a pipe. Ruby's end of the pipe will be passed as a parameter to the block. At the end of block, Ruby closes the pipe and sets $?. In this case IO.popen returns the value of the block. If a block is given with a _cmd_ of ``-'', the block will be run in two separate processes: once in the parent, and once in a child. The parent process will be passed the pipe object as a parameter to the block, the child version of the block will be passed +nil+, and the child's standard in and standard out will be connected to the parent through the pipe. Not available on all platforms. f = IO.popen("uname") p f.readlines f.close puts "Parent is #{Process.pid}" IO.popen("date") {|f| puts f.gets } IO.popen("-") {|f| $stderr.puts "#{Process.pid} is here, f is #{f.inspect}"} p $? IO.popen(%w"sed -e s|^|| -e s&$&;zot;&", "r+") {|f| f.puts "bar"; f.close_write; puts f.gets } produces: ["Linux\n"] Parent is 21346 Thu Jan 15 22:41:19 JST 2009 21346 is here, f is # 21352 is here, f is nil # bar;zot; @overload popen([env,] cmd, mode="r" [, opt]) @return [IO] @overload popen([env,] cmd, mode="r" [, opt]) @yield [io] @return [Object];T;#0;$@gM;.F;/o;0;1T;2iH;3i;%@kL;9I"static VALUE rb_io_s_popen(int argc, VALUE *argv, VALUE klass) { VALUE pname, pmode = Qnil, opt = Qnil, env = Qnil; if (argc > 1 && !NIL_P(opt = rb_check_hash_type(argv[argc-1]))) --argc; if (argc > 1 && !NIL_P(env = rb_check_hash_type(argv[0]))) --argc, ++argv; switch (argc) { case 2: pmode = argv[1]; case 1: pname = argv[0]; break; default: { int ex = !NIL_P(opt); rb_error_arity(argc + ex, 1 + ex, 2 + ex); } } return popen_finish(rb_io_popen(pname, pmode, env, opt), klass); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO.foreach;F;7[[@90;[[@Ti*;T;: foreach;0;[;{;IC; ""Executes the block for every line in the named I/O port, where lines are separated by sep. If no block is given, an enumerator is returned instead. If +name+ starts with a pipe character ("|") and the receiver is the IO class, a subprocess is created in the same way as Kernel#open, and its output is returned. Consider to use File.foreach to disable the behavior of subprocess invocation. File.foreach("testfile") {|x| print "GOT ", x } IO.foreach("| cat testfile") {|x| print "GOT ", x } produces: GOT This is line one GOT This is line two GOT This is line three GOT And so on... If the last argument is a hash, it's the keyword argument to open. See IO.readlines for details about getline_args. And see also IO.read for details about open_args. ;T;[ o;= ;>I" overload;F;?0;;p;@0;:I"6foreach(name, sep=$/ [, getline_args, open_args]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@Mo;A ;>I" return;F;?I";T;0;@[I"nil;T;$@M;![;"I" @yield [line] @return [nil];T;#0;$@M;.F;Bi;C0;7[[I" name;T0[I"sep;TI""$/[, getline_args, open_args];T;$@Mo;= ;>I" overload;F;?0;;p;@0;:I"5foreach(name, limit [, getline_args, open_args]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@Mo;A ;>I" return;F;?I";T;0;@[I"nil;T;$@M;![;"I" @yield [line] @return [nil];T;#0;$@M;.F;Bi;C0;7[[I" name;T0[I"%limit[, getline_args, open_args];T0;$@Mo;= ;>I" overload;F;?0;;p;@0;:I":foreach(name, sep, limit [, getline_args, open_args]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@Mo;A ;>I" return;F;?I";T;0;@[I"nil;T;$@M;![;"I" @yield [line] @return [nil];T;#0;$@M;.F;Bi;C0;7[[I" name;T0[I"sep;T0[I"%limit[, getline_args, open_args];T0;$@Mo;= ;>I" overload;F;?0;;p;@0;:I"foreach(...);T;IC; ";T;[;![;"I";T;#0;$@M;.F;Bi;C0;7[[I"...;T0;$@Mo;= ;>I" overload;F;?0;;p;@0;:I"6foreach(name, sep=$/ [, getline_args, open_args]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@Mo;A ;>I" return;F;?I";T;0;@[I"nil;T;$@M;![;"I" @yield [line] @return [nil];T;#0;$@M;.F;Bi;C0;7[[I" name;T0[I"sep;TI""$/[, getline_args, open_args];T;$@Mo;= ;>I" overload;F;?0;;p;@0;:I"5foreach(name, limit [, getline_args, open_args]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@Mo;A ;>I" return;F;?I";T;0;@[I"nil;T;$@M;![;"I" @yield [line] @return [nil];T;#0;$@M;.F;Bi;C0;7[[I" name;T0[I"%limit[, getline_args, open_args];T0;$@Mo;= ;>I" overload;F;?0;;p;@0;:I":foreach(name, sep, limit [, getline_args, open_args]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@Mo;A ;>I" return;F;?I";T;0;@[I"nil;T;$@M;![;"I" @yield [line] @return [nil];T;#0;$@M;.F;Bi;C0;7[[I" name;T0[I"sep;T0[I"%limit[, getline_args, open_args];T0;$@Mo;= ;>I" overload;F;?0;;p;@0;:I"foreach(...);T;IC; ";T;[;![;"I";T;#0;$@M;.F;Bi;C0;7[[I"...;T0;$@M;![;"I"Executes the block for every line in the named I/O port, where lines are separated by sep. If no block is given, an enumerator is returned instead. If +name+ starts with a pipe character ("|") and the receiver is the IO class, a subprocess is created in the same way as Kernel#open, and its output is returned. Consider to use File.foreach to disable the behavior of subprocess invocation. File.foreach("testfile") {|x| print "GOT ", x } IO.foreach("| cat testfile") {|x| print "GOT ", x } produces: GOT This is line one GOT This is line two GOT This is line three GOT And so on... If the last argument is a hash, it's the keyword argument to open. See IO.readlines for details about getline_args. And see also IO.read for details about open_args. @overload foreach(name, sep=$/ [, getline_args, open_args]) @yield [line] @return [nil] @overload foreach(name, limit [, getline_args, open_args]) @yield [line] @return [nil] @overload foreach(name, sep, limit [, getline_args, open_args]) @yield [line] @return [nil] @overload foreach(...) @overload foreach(name, sep=$/ [, getline_args, open_args]) @yield [line] @return [nil] @overload foreach(name, limit [, getline_args, open_args]) @yield [line] @return [nil] @overload foreach(name, sep, limit [, getline_args, open_args]) @yield [line] @return [nil] @overload foreach(...);T;#0;$@M;.F;/o;0;1T;2i*;3i*;%@kL;9I"Qstatic VALUE rb_io_s_foreach(int argc, VALUE *argv, VALUE self) { VALUE opt; int orig_argc = argc; struct foreach_arg arg; struct getline_arg garg; argc = rb_scan_args(argc, argv, "13:", NULL, NULL, NULL, NULL, &opt); RETURN_ENUMERATOR(self, orig_argc, argv); extract_getline_args(argc-1, argv+1, &garg); open_key_args(self, argc, argv, opt, &arg); if (NIL_P(arg.io)) return Qnil; extract_getline_opts(opt, &garg); check_getline_args(&garg.rs, &garg.limit, garg.io = arg.io); return rb_ensure(io_s_foreach, (VALUE)&garg, rb_io_close, arg.io); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO.readlines;F;7[[@90;[[@Ti +;T;;;0;[;{;IC; "Reads the entire file specified by name as individual lines, and returns those lines in an array. Lines are separated by sep. If +name+ starts with a pipe character ("|") and the receiver is the IO class, a subprocess is created in the same way as Kernel#open, and its output is returned. Consider to use File.readlines to disable the behavior of subprocess invocation. a = File.readlines("testfile") a[0] #=> "This is line one\n" b = File.readlines("testfile", chomp: true) b[0] #=> "This is line one" IO.readlines("|ls -a") #=> [".\n", "..\n", ...] If the last argument is a hash, it's the keyword argument to open. === Options for getline The options hash accepts the following keys: :chomp:: When the optional +chomp+ keyword argument has a true value, \n, \r, and \r\n will be removed from the end of each line. See also IO.read for details about +name+ and open_args. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"8readlines(name, sep=$/ [, getline_args, open_args]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@LN;![;"I"@return [Array];T;#0;$@LN;.F;Bi;C0;7[[I" name;T0[I"sep;TI""$/[, getline_args, open_args];T;$@LNo;= ;>I" overload;F;?0;;;@0;:I"7readlines(name, limit [, getline_args, open_args]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@LN;![;"I"@return [Array];T;#0;$@LN;.F;Bi;C0;7[[I" name;T0[I"%limit[, getline_args, open_args];T0;$@LNo;= ;>I" overload;F;?0;;;@0;:I"I" return;F;?I";T;0;@[I" Array;T;$@LN;![;"I"@return [Array];T;#0;$@LN;.F;Bi;C0;7[[I" name;T0[I"sep;T0[I"%limit[, getline_args, open_args];T0;$@LNo;= ;>I" overload;F;?0;;;@0;:I"8readlines(name, sep=$/ [, getline_args, open_args]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@LN;![;"I"@return [Array];T;#0;$@LN;.F;Bi;C0;7[[I" name;T0[I"sep;TI""$/[, getline_args, open_args];T;$@LNo;= ;>I" overload;F;?0;;;@0;:I"7readlines(name, limit [, getline_args, open_args]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@LN;![;"I"@return [Array];T;#0;$@LN;.F;Bi;C0;7[[I" name;T0[I"%limit[, getline_args, open_args];T0;$@LNo;= ;>I" overload;F;?0;;;@0;:I"I" return;F;?I";T;0;@[I" Array;T;$@LN;![;"I"@return [Array];T;#0;$@LN;.F;Bi;C0;7[[I" name;T0[I"sep;T0[I"%limit[, getline_args, open_args];T0;$@LN;![;"I"Reads the entire file specified by name as individual lines, and returns those lines in an array. Lines are separated by sep. If +name+ starts with a pipe character ("|") and the receiver is the IO class, a subprocess is created in the same way as Kernel#open, and its output is returned. Consider to use File.readlines to disable the behavior of subprocess invocation. a = File.readlines("testfile") a[0] #=> "This is line one\n" b = File.readlines("testfile", chomp: true) b[0] #=> "This is line one" IO.readlines("|ls -a") #=> [".\n", "..\n", ...] If the last argument is a hash, it's the keyword argument to open. === Options for getline The options hash accepts the following keys: :chomp:: When the optional +chomp+ keyword argument has a true value, \n, \r, and \r\n will be removed from the end of each line. See also IO.read for details about +name+ and open_args. @overload readlines(name, sep=$/ [, getline_args, open_args]) @return [Array] @overload readlines(name, limit [, getline_args, open_args]) @return [Array] @overload readlines(name, sep, limit [, getline_args, open_args]) @return [Array] @overload readlines(name, sep=$/ [, getline_args, open_args]) @return [Array] @overload readlines(name, limit [, getline_args, open_args]) @return [Array] @overload readlines(name, sep, limit [, getline_args, open_args]) @return [Array];T;#0;$@LN;.F;/o;0;1T;2i*;3i +;%@kL;9I" static VALUE rb_io_s_readlines(int argc, VALUE *argv, VALUE io) { VALUE opt; struct foreach_arg arg; struct getline_arg garg; argc = rb_scan_args(argc, argv, "13:", NULL, NULL, NULL, NULL, &opt); extract_getline_args(argc-1, argv+1, &garg); open_key_args(io, argc, argv, opt, &arg); if (NIL_P(arg.io)) return Qnil; extract_getline_opts(opt, &garg); check_getline_args(&garg.rs, &garg.limit, garg.io = arg.io); return rb_ensure(io_s_readlines, (VALUE)&garg, rb_io_close, arg.io); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO.read;F;7[[@90;[[@Ti^+;T;: read;0;[;{;IC; "XOpens the file, optionally seeks to the given +offset+, then returns +length+ bytes (defaulting to the rest of the file). #read ensures the file is closed before returning. If +name+ starts with a pipe character ("|") and the receiver is the IO class, a subprocess is created in the same way as Kernel#open, and its output is returned. Consider to use File.read to disable the behavior of subprocess invocation. === Options The options hash accepts the following keys: :encoding:: string or encoding Specifies the encoding of the read string. +:encoding+ will be ignored if +length+ is specified. See Encoding.aliases for possible encodings. :mode:: string or integer Specifies the mode argument for open(). It must start with an "r", otherwise it will cause an error. See IO.new for the list of possible modes. :open_args:: array Specifies arguments for open() as an array. This key can not be used in combination with either +:encoding+ or +:mode+. Examples: File.read("testfile") #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n" File.read("testfile", 20) #=> "This is line one\nThi" File.read("testfile", 20, 10) #=> "ne one\nThis is line " File.read("binfile", mode: "rb") #=> "\xF7\x00\x00\x0E\x12" IO.read("|ls -a") #=> ".\n..\n"... ;T;[o;= ;>I" overload;F;?0;;q;@0;:I",read(name, [length [, offset]] [, opt]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@N;![;"I"@return [String];T;#0;$@N;.F;Bi;C0;7[[I" name;T0[I"[length [, offset]][, opt];T0;$@No;= ;>I" overload;F;?0;;q;@0;:I",read(name, [length [, offset]] [, opt]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@N;![;"I"@return [String];T;#0;$@N;.F;Bi;C0;7[[I" name;T0[I"[length [, offset]][, opt];T0;$@N;![;"I"Opens the file, optionally seeks to the given +offset+, then returns +length+ bytes (defaulting to the rest of the file). #read ensures the file is closed before returning. If +name+ starts with a pipe character ("|") and the receiver is the IO class, a subprocess is created in the same way as Kernel#open, and its output is returned. Consider to use File.read to disable the behavior of subprocess invocation. === Options The options hash accepts the following keys: :encoding:: string or encoding Specifies the encoding of the read string. +:encoding+ will be ignored if +length+ is specified. See Encoding.aliases for possible encodings. :mode:: string or integer Specifies the mode argument for open(). It must start with an "r", otherwise it will cause an error. See IO.new for the list of possible modes. :open_args:: array Specifies arguments for open() as an array. This key can not be used in combination with either +:encoding+ or +:mode+. Examples: File.read("testfile") #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n" File.read("testfile", 20) #=> "This is line one\nThi" File.read("testfile", 20, 10) #=> "ne one\nThis is line " File.read("binfile", mode: "rb") #=> "\xF7\x00\x00\x0E\x12" IO.read("|ls -a") #=> ".\n..\n"... @overload read(name, [length [, offset]] [, opt]) @return [String] @overload read(name, [length [, offset]] [, opt]) @return [String];T;#0;$@N;.F;/o;0;1T;2i0+;3i\+;%@kL;9I"ystatic VALUE rb_io_s_read(int argc, VALUE *argv, VALUE io) { VALUE opt, offset; struct foreach_arg arg; argc = rb_scan_args(argc, argv, "13:", NULL, NULL, &offset, NULL, &opt); open_key_args(io, argc, argv, opt, &arg); if (NIL_P(arg.io)) return Qnil; if (!NIL_P(offset)) { struct seek_arg sarg; int state = 0; sarg.io = arg.io; sarg.offset = offset; sarg.mode = SEEK_SET; rb_protect(seek_before_access, (VALUE)&sarg, &state); if (state) { rb_io_close(arg.io); rb_jump_tag(state); } if (arg.argc == 2) arg.argc = 1; } return rb_ensure(io_s_read, (VALUE)&arg, rb_io_close, arg.io); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO.binread;F;7[[@90;[[@Ti+;T;: binread;0;[;{;IC; "Opens the file, optionally seeks to the given offset, then returns length bytes (defaulting to the rest of the file). #binread ensures the file is closed before returning. The open mode would be "rb:ASCII-8BIT". If +name+ starts with a pipe character ("|") and the receiver is the IO class, a subprocess is created in the same way as Kernel#open, and its output is returned. Consider to use File.binread to disable the behavior of subprocess invocation. File.binread("testfile") #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n" File.binread("testfile", 20) #=> "This is line one\nThi" File.binread("testfile", 20, 10) #=> "ne one\nThis is line " IO.binread("| cat testfile") #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n" See also IO.read for details about +name+ and open_args. ;T;[o;= ;>I" overload;F;?0;;r;@0;:I"'binread(name, [length [, offset]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@N;![;"I"@return [String];T;#0;$@N;.F;Bi;C0;7[[I" name;T0[I"[length [, offset]];T0;$@No;= ;>I" overload;F;?0;;r;@0;:I"'binread(name, [length [, offset]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@N;![;"I"@return [String];T;#0;$@N;.F;Bi;C0;7[[I" name;T0[I"[length [, offset]];T0;$@N;![;"I"Opens the file, optionally seeks to the given offset, then returns length bytes (defaulting to the rest of the file). #binread ensures the file is closed before returning. The open mode would be "rb:ASCII-8BIT". If +name+ starts with a pipe character ("|") and the receiver is the IO class, a subprocess is created in the same way as Kernel#open, and its output is returned. Consider to use File.binread to disable the behavior of subprocess invocation. File.binread("testfile") #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n" File.binread("testfile", 20) #=> "This is line one\nThi" File.binread("testfile", 20, 10) #=> "ne one\nThis is line " IO.binread("| cat testfile") #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n" See also IO.read for details about +name+ and open_args. @overload binread(name, [length [, offset]]) @return [String] @overload binread(name, [length [, offset]]) @return [String];T;#0;$@N;.F;/o;0;1T;2iw+;3i+;%@kL;9I"static VALUE rb_io_s_binread(int argc, VALUE *argv, VALUE io) { VALUE offset; struct foreach_arg arg; enum { fmode = FMODE_READABLE|FMODE_BINMODE, oflags = O_RDONLY #ifdef O_BINARY |O_BINARY #endif }; convconfig_t convconfig = {NULL, NULL, 0, Qnil}; rb_scan_args(argc, argv, "12", NULL, NULL, &offset); FilePathValue(argv[0]); convconfig.enc = rb_ascii8bit_encoding(); arg.io = rb_io_open_generic(io, argv[0], oflags, fmode, &convconfig, 0); if (NIL_P(arg.io)) return Qnil; arg.argv = argv+1; arg.argc = (argc > 1) ? 1 : 0; if (!NIL_P(offset)) { struct seek_arg sarg; int state = 0; sarg.io = arg.io; sarg.offset = offset; sarg.mode = SEEK_SET; rb_protect(seek_before_access, (VALUE)&sarg, &state); if (state) { rb_io_close(arg.io); rb_jump_tag(state); } } return rb_ensure(io_s_read, (VALUE)&arg, rb_io_close, arg.io); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO.write;F;7[[@90;[[@Ti,;T;: write;0;[;{;IC; " Opens the file, optionally seeks to the given offset, writes string, then returns the length written. #write ensures the file is closed before returning. If offset is not given in write mode, the file is truncated. Otherwise, it is not truncated. If +name+ starts with a pipe character ("|") and the receiver is the IO class, a subprocess is created in the same way as Kernel#open, and its output is returned. Consider to use File.write to disable the behavior of subprocess invocation. File.write("testfile", "0123456789", 20) #=> 10 # File could contain: "This is line one\nThi0123456789two\nThis is line three\nAnd so on...\n" File.write("testfile", "0123456789") #=> 10 # File would now read: "0123456789" IO.write("|tr a-z A-Z", "abc") #=> 3 # Prints "ABC" to the standard output If the last argument is a hash, it specifies options for the internal open(). It accepts the following keys: :encoding:: string or encoding Specifies the encoding of the read string. See Encoding.aliases for possible encodings. :mode:: string or integer Specifies the mode argument for open(). It must start with "w", "a", or "r+", otherwise it will cause an error. See IO.new for the list of possible modes. :perm:: integer Specifies the perm argument for open(). :open_args:: array Specifies arguments for open() as an array. This key can not be used in combination with other keys. See also IO.read for details about +name+ and open_args. ;T;[ o;= ;>I" overload;F;?0;;s;@0;:I"#write(name, string [, offset]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@)O;![;"I"@return [Integer];T;#0;$@)O;.F;Bi;C0;7[[I" name;T0[I"string[, offset];T0;$@)Oo;= ;>I" overload;F;?0;;s;@0;:I"+write(name, string [, offset] [, opt]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@)O;![;"I"@return [Integer];T;#0;$@)O;.F;Bi;C0;7[[I" name;T0[I"string[, offset][, opt];T0;$@)Oo;= ;>I" overload;F;?0;;s;@0;:I"#write(name, string [, offset]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@)O;![;"I"@return [Integer];T;#0;$@)O;.F;Bi;C0;7[[I" name;T0[I"string[, offset];T0;$@)Oo;= ;>I" overload;F;?0;;s;@0;:I"+write(name, string [, offset] [, opt]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@)O;![;"I"@return [Integer];T;#0;$@)O;.F;Bi;C0;7[[I" name;T0[I"string[, offset][, opt];T0;$@)O;![;"I"Opens the file, optionally seeks to the given offset, writes string, then returns the length written. #write ensures the file is closed before returning. If offset is not given in write mode, the file is truncated. Otherwise, it is not truncated. If +name+ starts with a pipe character ("|") and the receiver is the IO class, a subprocess is created in the same way as Kernel#open, and its output is returned. Consider to use File.write to disable the behavior of subprocess invocation. File.write("testfile", "0123456789", 20) #=> 10 # File could contain: "This is line one\nThi0123456789two\nThis is line three\nAnd so on...\n" File.write("testfile", "0123456789") #=> 10 # File would now read: "0123456789" IO.write("|tr a-z A-Z", "abc") #=> 3 # Prints "ABC" to the standard output If the last argument is a hash, it specifies options for the internal open(). It accepts the following keys: :encoding:: string or encoding Specifies the encoding of the read string. See Encoding.aliases for possible encodings. :mode:: string or integer Specifies the mode argument for open(). It must start with "w", "a", or "r+", otherwise it will cause an error. See IO.new for the list of possible modes. :perm:: integer Specifies the perm argument for open(). :open_args:: array Specifies arguments for open() as an array. This key can not be used in combination with other keys. See also IO.read for details about +name+ and open_args. @overload write(name, string [, offset]) @return [Integer] @overload write(name, string [, offset] [, opt]) @return [Integer] @overload write(name, string [, offset]) @return [Integer] @overload write(name, string [, offset] [, opt]) @return [Integer];T;#0;$@)O;.F;/o;0;1T;2i+;3i,;%@kL;9I"nstatic VALUE rb_io_s_write(int argc, VALUE *argv, VALUE io) { return io_s_write(argc, argv, io, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO.binwrite;F;7[[@90;[[@Ti7,;T;: binwrite;0;[;{;IC; "Same as IO.write except opening the file in binary mode and ASCII-8BIT encoding ("wb:ASCII-8BIT"). If +name+ starts with a pipe character ("|") and the receiver is the IO class, a subprocess is created in the same way as Kernel#open, and its output is returned. Consider to use File.binwrite to disable the behavior of subprocess invocation. See also IO.read for details about +name+ and open_args. ;T;[ o;= ;>I" overload;F;?0;;t;@0;:I"%binwrite(name, string, [offset]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@|O;![;"I"@return [Integer];T;#0;$@|O;.F;Bi;C0;7[[I" name;T0[I" string;T0[I" [offset];T0;$@|Oo;= ;>I" overload;F;?0;;t;@0;:I"0binwrite(name, string, [offset], open_args);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@|O;![;"I"@return [Integer];T;#0;$@|O;.F;Bi;C0;7[ [I" name;T0[I" string;T0[I" [offset];T0[I"open_args;T0;$@|Oo;= ;>I" overload;F;?0;;t;@0;:I"%binwrite(name, string, [offset]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@|O;![;"I"@return [Integer];T;#0;$@|O;.F;Bi;C0;7[[I" name;T0[I" string;T0[I" [offset];T0;$@|Oo;= ;>I" overload;F;?0;;t;@0;:I"0binwrite(name, string, [offset], open_args);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@|O;![;"I"@return [Integer];T;#0;$@|O;.F;Bi;C0;7[ [I" name;T0[I" string;T0[I" [offset];T0[I"open_args;T0;$@|O;![;"I"Same as IO.write except opening the file in binary mode and ASCII-8BIT encoding ("wb:ASCII-8BIT"). If +name+ starts with a pipe character ("|") and the receiver is the IO class, a subprocess is created in the same way as Kernel#open, and its output is returned. Consider to use File.binwrite to disable the behavior of subprocess invocation. See also IO.read for details about +name+ and open_args. @overload binwrite(name, string, [offset]) @return [Integer] @overload binwrite(name, string, [offset], open_args) @return [Integer] @overload binwrite(name, string, [offset]) @return [Integer] @overload binwrite(name, string, [offset], open_args) @return [Integer];T;#0;$@|O;.F;/o;0;1T;2i%,;3i7,;%@kL;9I"qstatic VALUE rb_io_s_binwrite(int argc, VALUE *argv, VALUE io) { return io_s_write(argc, argv, io, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO.select;F;7[[@90;[[@TiS';T;;;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;= ;>I" overload;F;?0;;;@0;:I"Cselect(read_array [, write_array [, error_array [, timeout]]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;TI"nil;T;$@O;![;"I"@return [Array, nil];T;#0;$@O;.F;Bi;C0;7[[I":read_array[, write_array [, error_array [, timeout]]];T0;$@O;![;"@ ;#0;$@O;.F;/o;0;1T;2i&;3iP';%@kL;9I" 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;4;5F;6;;;;&I" IO.pipe;F;7[[@90;[[@Ti!*;T;: pipe;0;[;{;IC; "0IO.pipe(...) {|read_io, write_io| ... } Creates a pair of pipe endpoints (connected to each other) and returns them as a two-element array of IO objects: [ read_io, write_io ]. If a block is given, the block is called and returns the value of the block. read_io and write_io are sent to the block as arguments. If read_io and write_io are not closed when the block exits, they are closed. i.e. closing read_io and/or write_io doesn't cause an error. Not available on all platforms. If an encoding (encoding name or encoding object) is specified as an optional argument, read string from pipe is tagged with the encoding specified. If the argument is a colon separated two encoding names "A:B", the read string is converted from encoding A (external encoding) to encoding B (internal encoding), then tagged with B. If two optional arguments are specified, those must be encoding objects or encoding names, and the first one is the external encoding, and the second one is the internal encoding. If the external encoding and the internal encoding is specified, optional hash argument specify the conversion option. In the example below, the two processes close the ends of the pipe that they are not using. This is not just a cosmetic nicety. The read end of a pipe will not generate an end of file condition if there are any writers with the pipe still open. In the case of the parent process, the rd.read will never return if it does not first issue a wr.close. rd, wr = IO.pipe if fork wr.close puts "Parent got: <#{rd.read}>" rd.close Process.wait else rd.close puts "Sending message to parent" wr.write "Hi Dad" wr.close end produces: Sending message to parent Parent got: ;T;[ o;= ;>I" overload;F;?0;;u;@0;:I" pipe;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@O;![;"I"@return [Array];T;#0;$@O;.F;Bi;C0;7[;$@Oo;= ;>I" overload;F;?0;;u;@0;:I"pipe(ext_enc);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@O;![;"I"@return [Array];T;#0;$@O;.F;Bi;C0;7[[I" ext_enc;T0;$@Oo;= ;>I" overload;F;?0;;u;@0;:I"$pipe("ext_enc:int_enc" [, opt]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@O;![;"I"@return [Array];T;#0;$@O;.F;Bi;C0;7[[""ext_enc:"int_enc"[, opt];$@Oo;= ;>I" overload;F;?0;;u;@0;:I"#pipe(ext_enc, int_enc [, opt]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@O;![;"I"@return [Array];T;#0;$@O;.F;Bi;C0;7[[I" ext_enc;T0[I"int_enc[, opt];T0;$@O;![;"I" IO.pipe(...) {|read_io, write_io| ... } Creates a pair of pipe endpoints (connected to each other) and returns them as a two-element array of IO objects: [ read_io, write_io ]. If a block is given, the block is called and returns the value of the block. read_io and write_io are sent to the block as arguments. If read_io and write_io are not closed when the block exits, they are closed. i.e. closing read_io and/or write_io doesn't cause an error. Not available on all platforms. If an encoding (encoding name or encoding object) is specified as an optional argument, read string from pipe is tagged with the encoding specified. If the argument is a colon separated two encoding names "A:B", the read string is converted from encoding A (external encoding) to encoding B (internal encoding), then tagged with B. If two optional arguments are specified, those must be encoding objects or encoding names, and the first one is the external encoding, and the second one is the internal encoding. If the external encoding and the internal encoding is specified, optional hash argument specify the conversion option. In the example below, the two processes close the ends of the pipe that they are not using. This is not just a cosmetic nicety. The read end of a pipe will not generate an end of file condition if there are any writers with the pipe still open. In the case of the parent process, the rd.read will never return if it does not first issue a wr.close. rd, wr = IO.pipe if fork wr.close puts "Parent got: <#{rd.read}>" rd.close Process.wait else rd.close puts "Sending message to parent" wr.write "Hi Dad" wr.close end produces: Sending message to parent Parent got: @overload pipe @return [Array] @overload pipe(ext_enc) @return [Array] @overload pipe("ext_enc:int_enc" [, opt]) @return [Array] @overload pipe(ext_enc, int_enc [, opt]) @return [Array];T;#0;$@O;.F;/o;0;1T;2i);3i!*;%@kL;9I"static VALUE rb_io_s_pipe(int argc, VALUE *argv, VALUE klass) { int pipes[2], state; VALUE r, w, args[3], v1, v2; VALUE opt; rb_io_t *fptr, *fptr2; struct io_encoding_set_args ies_args; int fmode = 0; VALUE ret; argc = rb_scan_args(argc, argv, "02:", &v1, &v2, &opt); if (rb_pipe(pipes) < 0) rb_sys_fail(0); args[0] = klass; args[1] = INT2NUM(pipes[0]); args[2] = INT2FIX(O_RDONLY); r = rb_protect(io_new_instance, (VALUE)args, &state); if (state) { close(pipes[0]); close(pipes[1]); rb_jump_tag(state); } GetOpenFile(r, fptr); ies_args.fptr = fptr; ies_args.v1 = v1; ies_args.v2 = v2; ies_args.opt = opt; rb_protect(io_encoding_set_v, (VALUE)&ies_args, &state); if (state) { close(pipes[1]); io_close(r); rb_jump_tag(state); } args[1] = INT2NUM(pipes[1]); args[2] = INT2FIX(O_WRONLY); w = rb_protect(io_new_instance, (VALUE)args, &state); if (state) { close(pipes[1]); if (!NIL_P(r)) rb_io_close(r); rb_jump_tag(state); } GetOpenFile(w, fptr2); rb_io_synchronized(fptr2); extract_binmode(opt, &fmode); if ((fmode & FMODE_BINMODE) && NIL_P(v1)) { rb_io_ascii8bit_binmode(r); rb_io_ascii8bit_binmode(w); } #if DEFAULT_TEXTMODE if ((fptr->mode & FMODE_TEXTMODE) && (fmode & FMODE_BINMODE)) { fptr->mode &= ~FMODE_TEXTMODE; setmode(fptr->fd, O_BINARY); } #if RUBY_CRLF_ENVIRONMENT if (fptr->encs.ecflags & ECONV_DEFAULT_NEWLINE_DECORATOR) { fptr->encs.ecflags |= ECONV_UNIVERSAL_NEWLINE_DECORATOR; } #endif #endif fptr->mode |= fmode; #if DEFAULT_TEXTMODE if ((fptr2->mode & FMODE_TEXTMODE) && (fmode & FMODE_BINMODE)) { fptr2->mode &= ~FMODE_TEXTMODE; setmode(fptr2->fd, O_BINARY); } #endif fptr2->mode |= fmode; ret = rb_assoc_new(r, w); if (rb_block_given_p()) { VALUE rw[2]; rw[0] = r; rw[1] = w; return rb_ensure(rb_yield, ret, pipe_pair_close, (VALUE)rw); } return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO.try_convert;F;7[[I"io;T0;[[@TiS;T;:try_convert;0;[;{;IC; "Attempts to convert +object+ into an \IO object via method +to_io+; returns the new \IO object if successful, or +nil+ otherwise: IO.try_convert(STDOUT) # => #> IO.try_convert(ARGF) # => #> IO.try_convert('STDOUT') # => nil ;T;[o;= ;>I" overload;F;?0;;v;@0;:I"try_convert(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@EP;![;"I"@return [nil];T;#0;$@EP;.F;Bi;C0;7[[I" object;T0;$@EP;![;"I"4Attempts to convert +object+ into an \IO object via method +to_io+; returns the new \IO object if successful, or +nil+ otherwise: IO.try_convert(STDOUT) # => #> IO.try_convert(ARGF) # => #> IO.try_convert('STDOUT') # => nil @overload try_convert(object) @return [nil];T;#0;$@EP;.F;/o;0;1T;2iG;3iQ;%@kL;9I"_static VALUE rb_io_s_try_convert(VALUE dummy, VALUE io) { return rb_io_check_io(io); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO.copy_stream;F;7[[@90;[[@Ti/;T;:copy_stream;0;[;{;IC; "UIO.copy_stream copies src to dst. src and dst is either a filename or an IO-like object. IO-like object for src should have #readpartial or #read method. IO-like object for dst should have #write method. (Specialized mechanisms, such as sendfile system call, may be used on appropriate situation.) This method returns the number of bytes copied. If optional arguments are not given, the start position of the copy is the beginning of the filename or the current file offset of the IO. The end position of the copy is the end of file. If copy_length is given, No more than copy_length bytes are copied. If src_offset is given, it specifies the start position of the copy. When src_offset is specified and src is an IO, IO.copy_stream doesn't move the current file offset. ;T;[o;= ;>I" overload;F;?0;;w;@0;:I"copy_stream(src, dst);T;IC; ";T;[;![;"I";T;#0;$@dP;.F;Bi;C0;7[[I"src;T0[I"dst;T0;$@dPo;= ;>I" overload;F;?0;;w;@0;:I"'copy_stream(src, dst, copy_length);T;IC; ";T;[;![;"I";T;#0;$@dP;.F;Bi;C0;7[[I"src;T0[I"dst;T0[I"copy_length;T0;$@dPo;= ;>I" overload;F;?0;;w;@0;:I"3copy_stream(src, dst, copy_length, src_offset);T;IC; ";T;[;![;"I";T;#0;$@dP;.F;Bi;C0;7[ [I"src;T0[I"dst;T0[I"copy_length;T0[I"src_offset;T0;$@dP;![;"I"IO.copy_stream copies src to dst. src and dst is either a filename or an IO-like object. IO-like object for src should have #readpartial or #read method. IO-like object for dst should have #write method. (Specialized mechanisms, such as sendfile system call, may be used on appropriate situation.) This method returns the number of bytes copied. If optional arguments are not given, the start position of the copy is the beginning of the filename or the current file offset of the IO. The end position of the copy is the end of file. If copy_length is given, No more than copy_length bytes are copied. If src_offset is given, it specifies the start position of the copy. When src_offset is specified and src is an IO, IO.copy_stream doesn't move the current file offset. @overload copy_stream(src, dst) @overload copy_stream(src, dst, copy_length) @overload copy_stream(src, dst, copy_length, src_offset);T;#0;$@dP;.F;/o;0;1T;2i/;3i/;%@kL;9I"static VALUE rb_io_s_copy_stream(int argc, VALUE *argv, VALUE io) { VALUE src, dst, length, src_offset; struct copy_stream_struct st; MEMZERO(&st, struct copy_stream_struct, 1); rb_scan_args(argc, argv, "22", &src, &dst, &length, &src_offset); st.src = src; st.dst = dst; st.src_fptr = NULL; st.dst_fptr = NULL; if (NIL_P(length)) st.copy_length = (off_t)-1; else st.copy_length = NUM2OFFT(length); if (NIL_P(src_offset)) st.src_offset = (off_t)-1; else st.src_offset = NUM2OFFT(src_offset); rb_ensure(copy_stream_body, (VALUE)&st, copy_stream_finalize, (VALUE)&st); return OFFT2NUM(st.total); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#initialize;F;7[[@90;[[@Ti>";T;;D;0;[;{;IC; "Returns a new IO object (a stream) for the given integer file descriptor +fd+ and +mode+ string. +opt+ may be used to specify parts of +mode+ in a more readable fashion. See also IO.sysopen and IO.for_fd. IO.new is called by various File and IO opening methods such as IO::open, Kernel#open, and File::open. === Open Mode When +mode+ is an integer it must be combination of the modes defined in File::Constants (+File::RDONLY+, File::WRONLY|File::CREAT). See the open(2) man page for more information. When +mode+ is a string it must be in one of the following forms: fmode fmode ":" ext_enc fmode ":" ext_enc ":" int_enc fmode ":" "BOM|UTF-*" +fmode+ is an IO open mode string, +ext_enc+ is the external encoding for the IO and +int_enc+ is the internal encoding. ==== IO Open Mode Ruby allows the following open modes: "r" Read-only, starts at beginning of file (default mode). "r+" Read-write, starts at beginning of file. "w" Write-only, truncates existing file to zero length or creates a new file for writing. "w+" Read-write, truncates existing file to zero length or creates a new file for reading and writing. "a" Write-only, each write call appends data at end of file. Creates a new file for writing if file does not exist. "a+" Read-write, each write call appends data at end of file. Creates a new file for reading and writing if file does not exist. The following modes must be used separately, and along with one or more of the modes seen above. "b" Binary file mode Suppresses EOL <-> CRLF conversion on Windows. And sets external encoding to ASCII-8BIT unless explicitly specified. "t" Text file mode The exclusive access mode ("x") can be used together with "w" to ensure the file is created. Errno::EEXIST is raised when it already exists. It may not be supported with all kinds of streams (e.g. pipes). When the open mode of original IO is read only, the mode cannot be changed to be writable. Similarly, the open mode cannot be changed from write only to readable. When such a change is attempted the error is raised in different locations according to the platform. === IO Encoding When +ext_enc+ is specified, strings read will be tagged by the encoding when reading, and strings output will be converted to the specified encoding when writing. When +ext_enc+ and +int_enc+ are specified read strings will be converted from +ext_enc+ to +int_enc+ upon input, and written strings will be converted from +int_enc+ to +ext_enc+ upon output. See Encoding for further details of transcoding on input and output. If "BOM|UTF-8", "BOM|UTF-16LE" or "BOM|UTF16-BE" are used, Ruby checks for a Unicode BOM in the input document to help determine the encoding. For UTF-16 encodings the file open mode must be binary. When present, the BOM is stripped and the external encoding from the BOM is used. When the BOM is missing the given Unicode encoding is used as +ext_enc+. (The BOM-set encoding option is case insensitive, so "bom|utf-8" is also valid.) === Options +opt+ can be used instead of +mode+ for improved readability. The following keys are supported: :mode :: Same as +mode+ parameter :flags :: Specifies file open flags as integer. If +mode+ parameter is given, this parameter will be bitwise-ORed. :\external_encoding :: External encoding for the IO. :\internal_encoding :: Internal encoding for the IO. "-" is a synonym for the default internal encoding. If the value is +nil+ no conversion occurs. :encoding :: Specifies external and internal encodings as "extern:intern". :textmode :: If the value is truth value, same as "t" in argument +mode+. :binmode :: If the value is truth value, same as "b" in argument +mode+. :autoclose :: If the value is +false+, the +fd+ will be kept open after this IO instance gets finalized. Also, +opt+ can have same keys in String#encode for controlling conversion between the external encoding and the internal encoding. === Example 1 fd = IO.sysopen("/dev/tty", "w") a = IO.new(fd,"w") $stderr.puts "Hello" a.puts "World" Produces: Hello World === Example 2 require 'fcntl' fd = STDERR.fcntl(Fcntl::F_DUPFD) io = IO.new(fd, mode: 'w:UTF-16LE', cr_newline: true) io.puts "Hello, World!" fd = STDERR.fcntl(Fcntl::F_DUPFD) io = IO.new(fd, mode: 'w', cr_newline: true, external_encoding: Encoding::UTF_16LE) io.puts "Hello, World!" Both of above print "Hello, World!" in UTF-16LE to standard error output with converting EOL generated by #puts to CR. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(fd [, mode] [, opt]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"IO;T;$@P;![;"I"@return [IO];T;#0;$@P;.F;Bi;C0;7[[I"fd[, mode][, opt];T0;$@P;![;"I"3Returns a new IO object (a stream) for the given integer file descriptor +fd+ and +mode+ string. +opt+ may be used to specify parts of +mode+ in a more readable fashion. See also IO.sysopen and IO.for_fd. IO.new is called by various File and IO opening methods such as IO::open, Kernel#open, and File::open. === Open Mode When +mode+ is an integer it must be combination of the modes defined in File::Constants (+File::RDONLY+, File::WRONLY|File::CREAT). See the open(2) man page for more information. When +mode+ is a string it must be in one of the following forms: fmode fmode ":" ext_enc fmode ":" ext_enc ":" int_enc fmode ":" "BOM|UTF-*" +fmode+ is an IO open mode string, +ext_enc+ is the external encoding for the IO and +int_enc+ is the internal encoding. ==== IO Open Mode Ruby allows the following open modes: "r" Read-only, starts at beginning of file (default mode). "r+" Read-write, starts at beginning of file. "w" Write-only, truncates existing file to zero length or creates a new file for writing. "w+" Read-write, truncates existing file to zero length or creates a new file for reading and writing. "a" Write-only, each write call appends data at end of file. Creates a new file for writing if file does not exist. "a+" Read-write, each write call appends data at end of file. Creates a new file for reading and writing if file does not exist. The following modes must be used separately, and along with one or more of the modes seen above. "b" Binary file mode Suppresses EOL <-> CRLF conversion on Windows. And sets external encoding to ASCII-8BIT unless explicitly specified. "t" Text file mode The exclusive access mode ("x") can be used together with "w" to ensure the file is created. Errno::EEXIST is raised when it already exists. It may not be supported with all kinds of streams (e.g. pipes). When the open mode of original IO is read only, the mode cannot be changed to be writable. Similarly, the open mode cannot be changed from write only to readable. When such a change is attempted the error is raised in different locations according to the platform. === IO Encoding When +ext_enc+ is specified, strings read will be tagged by the encoding when reading, and strings output will be converted to the specified encoding when writing. When +ext_enc+ and +int_enc+ are specified read strings will be converted from +ext_enc+ to +int_enc+ upon input, and written strings will be converted from +int_enc+ to +ext_enc+ upon output. See Encoding for further details of transcoding on input and output. If "BOM|UTF-8", "BOM|UTF-16LE" or "BOM|UTF16-BE" are used, Ruby checks for a Unicode BOM in the input document to help determine the encoding. For UTF-16 encodings the file open mode must be binary. When present, the BOM is stripped and the external encoding from the BOM is used. When the BOM is missing the given Unicode encoding is used as +ext_enc+. (The BOM-set encoding option is case insensitive, so "bom|utf-8" is also valid.) === Options +opt+ can be used instead of +mode+ for improved readability. The following keys are supported: :mode :: Same as +mode+ parameter :flags :: Specifies file open flags as integer. If +mode+ parameter is given, this parameter will be bitwise-ORed. :\external_encoding :: External encoding for the IO. :\internal_encoding :: Internal encoding for the IO. "-" is a synonym for the default internal encoding. If the value is +nil+ no conversion occurs. :encoding :: Specifies external and internal encodings as "extern:intern". :textmode :: If the value is truth value, same as "t" in argument +mode+. :binmode :: If the value is truth value, same as "b" in argument +mode+. :autoclose :: If the value is +false+, the +fd+ will be kept open after this IO instance gets finalized. Also, +opt+ can have same keys in String#encode for controlling conversion between the external encoding and the internal encoding. === Example 1 fd = IO.sysopen("/dev/tty", "w") a = IO.new(fd,"w") $stderr.puts "Hello" a.puts "World" Produces: Hello World === Example 2 require 'fcntl' fd = STDERR.fcntl(Fcntl::F_DUPFD) io = IO.new(fd, mode: 'w:UTF-16LE', cr_newline: true) io.puts "Hello, World!" fd = STDERR.fcntl(Fcntl::F_DUPFD) io = IO.new(fd, mode: 'w', cr_newline: true, external_encoding: Encoding::UTF_16LE) io.puts "Hello, World!" Both of above print "Hello, World!" in UTF-16LE to standard error output with converting EOL generated by #puts to CR. @overload new(fd [, mode] [, opt]) @return [IO];T;#0;$@P;.F;/o;0;1T;2i!;3i;";%@kL;9I"*static VALUE rb_io_initialize(int argc, VALUE *argv, VALUE io) { VALUE fnum, vmode; rb_io_t *fp; int fd, fmode, oflags = O_RDONLY; convconfig_t convconfig; VALUE opt; #if defined(HAVE_FCNTL) && defined(F_GETFL) int ofmode; #else struct stat st; #endif argc = rb_scan_args(argc, argv, "11:", &fnum, &vmode, &opt); rb_io_extract_modeenc(&vmode, 0, opt, &oflags, &fmode, &convconfig); fd = NUM2INT(fnum); if (rb_reserved_fd_p(fd)) { rb_raise(rb_eArgError, "The given fd is not accessible because RubyVM reserves it"); } #if defined(HAVE_FCNTL) && defined(F_GETFL) oflags = fcntl(fd, F_GETFL); if (oflags == -1) rb_sys_fail(0); #else if (fstat(fd, &st) < 0) rb_sys_fail(0); #endif rb_update_max_fd(fd); #if defined(HAVE_FCNTL) && defined(F_GETFL) ofmode = rb_io_oflags_fmode(oflags); if (NIL_P(vmode)) { fmode = ofmode; } else if ((~ofmode & fmode) & FMODE_READWRITE) { VALUE error = INT2FIX(EINVAL); rb_exc_raise(rb_class_new_instance(1, &error, rb_eSystemCallError)); } #endif if (!NIL_P(opt) && rb_hash_aref(opt, sym_autoclose) == Qfalse) { fmode |= FMODE_PREP; } MakeOpenFile(io, fp); fp->self = io; fp->fd = fd; fp->mode = fmode; fp->encs = convconfig; clear_codeconv(fp); io_check_tty(fp); if (fileno(stdin) == fd) fp->stdio_file = stdin; else if (fileno(stdout) == fd) fp->stdio_file = stdout; else if (fileno(stderr) == fd) fp->stdio_file = stderr; if (fmode & FMODE_SETENC_BY_BOM) io_set_encoding_by_bom(io); return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#initialize_copy;F;7[[I"io;T0;[[@Ti;T;;];0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@P;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE rb_io_init_copy(VALUE dest, VALUE io) { rb_io_t *fptr, *orig; int fd; VALUE write_io; off_t pos; io = rb_io_get_io(io); if (!OBJ_INIT_COPY(dest, io)) return dest; GetOpenFile(io, orig); MakeOpenFile(dest, fptr); rb_io_flush(io); /* copy rb_io_t structure */ fptr->mode = orig->mode & ~FMODE_PREP; fptr->encs = orig->encs; fptr->pid = orig->pid; fptr->lineno = orig->lineno; if (!NIL_P(orig->pathv)) fptr->pathv = orig->pathv; fptr_copy_finalizer(fptr, orig); fd = ruby_dup(orig->fd); fptr->fd = fd; pos = io_tell(orig); if (0 <= pos) io_seek(fptr, pos, SEEK_SET); if (fptr->mode & FMODE_BINMODE) { rb_io_binmode(dest); } write_io = GetWriteIO(io); if (io != write_io) { write_io = rb_obj_dup(write_io); fptr->tied_io_for_writing = write_io; rb_ivar_set(dest, rb_intern("@tied_io_for_writing"), write_io); } return dest; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#reopen;F;7[[@90;[[@Ti;T;;;0;[;{;IC; "Reassociates ios with the I/O stream given in other_IO or to a new stream opened on path. This may dynamically change the actual class of this stream. The +mode+ and +opt+ parameters accept the same values as IO.open. f1 = File.new("testfile") f2 = File.new("testfile") f2.readlines[0] #=> "This is line one\n" f2.reopen(f1) #=> # f2.readlines[0] #=> "This is line one\n" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"reopen(other_IO);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"IO;T;$@P;![;"I"@return [IO];T;#0;$@P;.F;Bi;C0;7[[I" other_IO;T0;$@Po;= ;>I" overload;F;?0;;;@0;:I"reopen(path, mode [, opt]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"IO;T;$@P;![;"I"@return [IO];T;#0;$@P;.F;Bi;C0;7[[I" path;T0[I"mode[, opt];T0;$@P;![;"I"Reassociates ios with the I/O stream given in other_IO or to a new stream opened on path. This may dynamically change the actual class of this stream. The +mode+ and +opt+ parameters accept the same values as IO.open. f1 = File.new("testfile") f2 = File.new("testfile") f2.readlines[0] #=> "This is line one\n" f2.reopen(f1) #=> # f2.readlines[0] #=> "This is line one\n" @overload reopen(other_IO) @return [IO] @overload reopen(path, mode [, opt]) @return [IO];T;#0;$@P;.F;/o;0;1T;2iz;3i;%@kL;9I" static VALUE rb_io_reopen(int argc, VALUE *argv, VALUE file) { VALUE fname, nmode, opt; int oflags; rb_io_t *fptr; if (rb_scan_args(argc, argv, "11:", &fname, &nmode, &opt) == 1) { VALUE tmp = rb_io_check_io(fname); if (!NIL_P(tmp)) { return io_reopen(file, tmp); } } FilePathValue(fname); rb_io_taint_check(file); fptr = RFILE(file)->fptr; if (!fptr) { fptr = RFILE(file)->fptr = ZALLOC(rb_io_t); } if (!NIL_P(nmode) || !NIL_P(opt)) { int fmode; convconfig_t convconfig; rb_io_extract_modeenc(&nmode, 0, opt, &oflags, &fmode, &convconfig); if (IS_PREP_STDIO(fptr) && ((fptr->mode & FMODE_READWRITE) & (fmode & FMODE_READWRITE)) != (fptr->mode & FMODE_READWRITE)) { rb_raise(rb_eArgError, "%s can't change access mode from \"%s\" to \"%s\"", PREP_STDIO_NAME(fptr), rb_io_fmode_modestr(fptr->mode), rb_io_fmode_modestr(fmode)); } fptr->mode = fmode; fptr->encs = convconfig; } else { oflags = rb_io_fmode_oflags(fptr->mode); } fptr->pathv = fname; if (fptr->fd < 0) { fptr->fd = rb_sysopen(fptr->pathv, oflags, 0666); fptr->stdio_file = 0; return file; } if (fptr->mode & FMODE_WRITABLE) { if (io_fflush(fptr) < 0) rb_sys_fail_on_write(fptr); } fptr->rbuf.off = fptr->rbuf.len = 0; if (fptr->stdio_file) { int e = rb_freopen(rb_str_encode_ospath(fptr->pathv), rb_io_oflags_modestr(oflags), fptr->stdio_file); if (e) rb_syserr_fail_path(e, fptr->pathv); fptr->fd = fileno(fptr->stdio_file); rb_fd_fix_cloexec(fptr->fd); #ifdef USE_SETVBUF if (setvbuf(fptr->stdio_file, NULL, _IOFBF, 0) != 0) rb_warn("setvbuf() can't be honoured for %"PRIsVALUE, fptr->pathv); #endif if (fptr->stdio_file == stderr) { if (setvbuf(fptr->stdio_file, NULL, _IONBF, BUFSIZ) != 0) rb_warn("setvbuf() can't be honoured for %"PRIsVALUE, fptr->pathv); } else if (fptr->stdio_file == stdout && isatty(fptr->fd)) { if (setvbuf(fptr->stdio_file, NULL, _IOLBF, BUFSIZ) != 0) rb_warn("setvbuf() can't be honoured for %"PRIsVALUE, fptr->pathv); } } else { int tmpfd = rb_sysopen(fptr->pathv, oflags, 0666); int err = 0; if (rb_cloexec_dup2(tmpfd, fptr->fd) < 0) err = errno; (void)close(tmpfd); if (err) { rb_syserr_fail_path(err, fptr->pathv); } } return file; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#print;F;7[[@90;[[@Ti];T;;;0;[;{;IC; "&Writes the given object(s) to ios. Returns +nil+. The stream must be opened for writing. Each given object that isn't a string will be converted by calling its to_s method. When called without arguments, prints the contents of $_. If the output field separator ($,) is not +nil+, it is inserted between objects. If the output record separator ($\\) is not +nil+, it is appended to the output. $stdout.print("This is ", 100, " percent.\n") produces: This is 100 percent. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" print;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@P;![;"I"@return [nil];T;#0;$@P;.F;Bi;C0;7[;$@Po;= ;>I" overload;F;?0;;;@0;:I"print(obj, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@P;![;"I"@return [nil];T;#0;$@P;.F;Bi;C0;7[[I"obj;T0[I"...;T0;$@P;![;"I"rWrites the given object(s) to ios. Returns +nil+. The stream must be opened for writing. Each given object that isn't a string will be converted by calling its to_s method. When called without arguments, prints the contents of $_. If the output field separator ($,) is not +nil+, it is inserted between objects. If the output record separator ($\\) is not +nil+, it is appended to the output. $stdout.print("This is ", 100, " percent.\n") produces: This is 100 percent. @overload print @return [nil] @overload print(obj, ...) @return [nil];T;#0;$@P;.F;/o;0;1T;2iE;3i[;%@kL;9I"KVALUE rb_io_print(int argc, const VALUE *argv, VALUE out) { int i; VALUE line; /* if no argument given, print `$_' */ if (argc == 0) { argc = 1; line = rb_lastline_get(); argv = &line; } if (argc > 1 && !NIL_P(rb_output_fs)) { rb_category_warn(RB_WARN_CATEGORY_DEPRECATED, "$, is set to non-nil value"); } for (i=0; i0) { rb_io_write(out, rb_output_fs); } rb_io_write(out, argv[i]); } if (argc > 0 && !NIL_P(rb_output_rs)) { rb_io_write(out, rb_output_rs); } return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I" IO#putc;F;7[[I"ch;T0;[[@Ti;T;;;0;[;{;IC; "If obj is Numeric, write the character whose code is the least-significant byte of obj. If obj is String, write the first character of obj to ios. Otherwise, raise TypeError. $stdout.putc "A" $stdout.putc 65 produces: AA ;T;[o;= ;>I" overload;F;?0;;;@0;:I"putc(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@'Q;![;"I"@return [Object];T;#0;$@'Q;.F;Bi;C0;7[[I"obj;T0;$@'Q;![;"I"AIf obj is Numeric, write the character whose code is the least-significant byte of obj. If obj is String, write the first character of obj to ios. Otherwise, raise TypeError. $stdout.putc "A" $stdout.putc 65 produces: AA @overload putc(obj) @return [Object];T;#0;$@'Q;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE rb_io_putc(VALUE io, VALUE ch) { VALUE str; if (RB_TYPE_P(ch, T_STRING)) { str = rb_str_substr(ch, 0, 1); } else { char c = NUM2CHR(ch); str = rb_str_new(&c, 1); } rb_io_write(io, str); return ch; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#puts;F;7[[@90;[[@Ti ;T;;;0;[;{;IC; "UWrites the given object(s) to ios. Writes a newline after any that do not already end with a newline sequence. Returns +nil+. The stream must be opened for writing. If called with an array argument, writes each element on a new line. Each given object that isn't a string or array will be converted by calling its +to_s+ method. If called without arguments, outputs a single newline. $stdout.puts("this", "is", ["a", "test"]) produces: this is a test Note that +puts+ always uses newlines and is not affected by the output record separator ($\\). ;T;[o;= ;>I" overload;F;?0;;;@0;:I"puts(obj, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@FQ;![;"I"@return [nil];T;#0;$@FQ;.F;Bi;C0;7[[I"obj;T0[I"...;T0;$@FQ;![;"I"Writes the given object(s) to ios. Writes a newline after any that do not already end with a newline sequence. Returns +nil+. The stream must be opened for writing. If called with an array argument, writes each element on a new line. Each given object that isn't a string or array will be converted by calling its +to_s+ method. If called without arguments, outputs a single newline. $stdout.puts("this", "is", ["a", "test"]) produces: this is a test Note that +puts+ always uses newlines and is not affected by the output record separator ($\\). @overload puts(obj, ...) @return [nil];T;#0;$@FQ;.F;/o;0;1T;2i;3i ;%@kL;9I"VALUE rb_io_puts(int argc, const VALUE *argv, VALUE out) { int i, n; VALUE line, args[2]; /* if no argument given, print newline. */ if (argc == 0) { rb_io_write(out, rb_default_rs); return Qnil; } for (i=0; iios, converting parameters under control of the format string. See Kernel#sprintf for details. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"'printf(format_string [, obj, ...]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@fQ;![;"I"@return [nil];T;#0;$@fQ;.F;Bi;C0;7[[I"format_string[, obj, ...];T0;$@fQ;![;"I"Formats and writes to ios, converting parameters under control of the format string. See Kernel#sprintf for details. @overload printf(format_string [, obj, ...]) @return [nil];T;#0;$@fQ;.F;/o;0;1T;2i;3i;%@kL;9I"VALUE rb_io_printf(int argc, const VALUE *argv, VALUE out) { rb_io_write(out, rb_f_sprintf(argc, argv)); return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I" IO#each;F;7[[@90;[[@Tiy;T;;;0;[;{;IC; "ios.each_line(sep=$/ [, getline_args]) {|line| block } -> ios ios.each_line(limit [, getline_args]) {|line| block } -> ios ios.each_line(sep, limit [, getline_args]) {|line| block } -> ios ios.each_line(...) -> an_enumerator Executes the block for every line in ios, where lines are separated by sep. ios must be opened for reading or an IOError will be raised. If no block is given, an enumerator is returned instead. f = File.new("testfile") f.each {|line| puts "#{f.lineno}: #{line}" } produces: 1: This is line one 2: This is line two 3: This is line three 4: And so on... See IO.readlines for details about getline_args. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I""each(sep=$/ [, getline_args]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@Qo;A ;>I" return;F;?I";T;0;@[I"IO;T;$@Q;![;"I"@yield [line] @return [IO];T;#0;$@Q;.F;Bi;C0;7[[I"sep;TI"$/[, getline_args];T;$@Qo;= ;>I" overload;F;?0;;;@0;:I"!each(limit [, getline_args]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@Qo;A ;>I" return;F;?I";T;0;@[I"IO;T;$@Q;![;"I"@yield [line] @return [IO];T;#0;$@Q;.F;Bi;C0;7[[I"limit[, getline_args];T0;$@Qo;= ;>I" overload;F;?0;;;@0;:I"&each(sep, limit [, getline_args]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@Qo;A ;>I" return;F;?I";T;0;@[I"IO;T;$@Q;![;"I"@yield [line] @return [IO];T;#0;$@Q;.F;Bi;C0;7[[I"sep;T0[I"limit[, getline_args];T0;$@Qo;= ;>I" overload;F;?0;;;@0;:I"each(...);T;IC; ";T;[;![;"I";T;#0;$@Q;.F;Bi;C0;7[[I"...;T0;$@Q;![;"I" ios.each_line(sep=$/ [, getline_args]) {|line| block } -> ios ios.each_line(limit [, getline_args]) {|line| block } -> ios ios.each_line(sep, limit [, getline_args]) {|line| block } -> ios ios.each_line(...) -> an_enumerator Executes the block for every line in ios, where lines are separated by sep. ios must be opened for reading or an IOError will be raised. If no block is given, an enumerator is returned instead. f = File.new("testfile") f.each {|line| puts "#{f.lineno}: #{line}" } produces: 1: This is line one 2: This is line two 3: This is line three 4: And so on... See IO.readlines for details about getline_args. @overload each(sep=$/ [, getline_args]) @yield [line] @return [IO] @overload each(limit [, getline_args]) @yield [line] @return [IO] @overload each(sep, limit [, getline_args]) @yield [line] @return [IO] @overload each(...);T;#0;$@Q;.F;/o;0;1T;2iZ;3i{;%@kL;9I"static VALUE rb_io_each_line(int argc, VALUE *argv, VALUE io) { VALUE str; struct getline_arg args; RETURN_ENUMERATOR(io, argc, argv); prepare_getline_args(argc, argv, &args, io); if (args.limit == 0) rb_raise(rb_eArgError, "invalid limit: 0 for each_line"); while (!NIL_P(str = rb_io_getline_1(args.rs, args.limit, args.chomp, io))) { rb_yield(str); } return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#each_line;F;7[[@90;[[@Tiy;T;:each_line;0;[;{;IC; "ios.each_line(sep=$/ [, getline_args]) {|line| block } -> ios ios.each_line(limit [, getline_args]) {|line| block } -> ios ios.each_line(sep, limit [, getline_args]) {|line| block } -> ios ios.each_line(...) -> an_enumerator Executes the block for every line in ios, where lines are separated by sep. ios must be opened for reading or an IOError will be raised. If no block is given, an enumerator is returned instead. f = File.new("testfile") f.each {|line| puts "#{f.lineno}: #{line}" } produces: 1: This is line one 2: This is line two 3: This is line three 4: And so on... See IO.readlines for details about getline_args. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I""each(sep=$/ [, getline_args]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@Qo;A ;>I" return;F;?I";T;0;@[I"IO;T;$@Q;![;"I"@yield [line] @return [IO];T;#0;$@Q;.F;Bi;C0;7[[I"sep;TI"$/[, getline_args];T;$@Qo;= ;>I" overload;F;?0;;;@0;:I"!each(limit [, getline_args]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@Qo;A ;>I" return;F;?I";T;0;@[I"IO;T;$@Q;![;"I"@yield [line] @return [IO];T;#0;$@Q;.F;Bi;C0;7[[I"limit[, getline_args];T0;$@Qo;= ;>I" overload;F;?0;;;@0;:I"&each(sep, limit [, getline_args]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@Qo;A ;>I" return;F;?I";T;0;@[I"IO;T;$@Q;![;"I"@yield [line] @return [IO];T;#0;$@Q;.F;Bi;C0;7[[I"sep;T0[I"limit[, getline_args];T0;$@Qo;= ;>I" overload;F;?0;;;@0;:I"each(...);T;IC; ";T;[;![;"I";T;#0;$@Q;.F;Bi;C0;7[[I"...;T0;$@Q;![;"@Q;#0;$@Q;.F;/o;0;1T;2iZ;3i{;%@kL;9I"static VALUE rb_io_each_line(int argc, VALUE *argv, VALUE io) { VALUE str; struct getline_arg args; RETURN_ENUMERATOR(io, argc, argv); prepare_getline_args(argc, argv, &args, io); if (args.limit == 0) rb_raise(rb_eArgError, "invalid limit: 0 for each_line"); while (!NIL_P(str = rb_io_getline_1(args.rs, args.limit, args.chomp, io))) { rb_yield(str); } return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#each_byte;F;7[;[[@Ti;T;:each_byte;0;[;{;IC; "vCalls the given block once for each byte (0..255) in ios, passing the byte as an argument. The stream must be opened for reading or an IOError will be raised. If no block is given, an enumerator is returned instead. f = File.new("testfile") checksum = 0 f.each_byte {|x| checksum ^= x } #=> # checksum #=> 12 ;T;[o;= ;>I" overload;F;?0;;y;@0;:I"each_byte;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" byte;T;$@3Ro;A ;>I" return;F;?I";T;0;@[I"IO;T;$@3R;![;"I"@yield [byte] @return [IO];T;#0;$@3R;.F;Bi;C0;7[;$@3Ro;= ;>I" overload;F;?0;;y;@0;:I"each_byte;T;IC; ";T;[;![;"I";T;#0;$@3R;.F;Bi;C0;7[;$@3R;![;"I"Calls the given block once for each byte (0..255) in ios, passing the byte as an argument. The stream must be opened for reading or an IOError will be raised. If no block is given, an enumerator is returned instead. f = File.new("testfile") checksum = 0 f.each_byte {|x| checksum ^= x } #=> # checksum #=> 12 @overload each_byte @yield [byte] @return [IO] @overload each_byte;T;#0;$@3R;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE rb_io_each_byte(VALUE io) { rb_io_t *fptr; RETURN_ENUMERATOR(io, 0, 0); GetOpenFile(io, fptr); do { while (fptr->rbuf.len > 0) { char *p = fptr->rbuf.ptr + fptr->rbuf.off++; fptr->rbuf.len--; rb_yield(INT2FIX(*p & 0xff)); rb_io_check_byte_readable(fptr); errno = 0; } READ_CHECK(fptr); } while (io_fillbuf(fptr) >= 0); return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#each_char;F;7[;[[@Ti);T;:each_char;0;[;{;IC; "9Calls the given block once for each character in ios, passing the character as an argument. The stream must be opened for reading or an IOError will be raised. If no block is given, an enumerator is returned instead. f = File.new("testfile") f.each_char {|c| print c, ' ' } #=> # ;T;[o;= ;>I" overload;F;?0;;z;@0;:I"each_char;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"c;T;$@[Ro;A ;>I" return;F;?I";T;0;@[I"IO;T;$@[R;![;"I"@yield [c] @return [IO];T;#0;$@[R;.F;Bi;C0;7[;$@[Ro;= ;>I" overload;F;?0;;z;@0;:I"each_char;T;IC; ";T;[;![;"I";T;#0;$@[R;.F;Bi;C0;7[;$@[R;![;"I"Calls the given block once for each character in ios, passing the character as an argument. The stream must be opened for reading or an IOError will be raised. If no block is given, an enumerator is returned instead. f = File.new("testfile") f.each_char {|c| print c, ' ' } #=> # @overload each_char @yield [c] @return [IO] @overload each_char;T;#0;$@[R;.F;/o;0;1T;2i;3i';%@kL;9I"Sstatic VALUE rb_io_each_char(VALUE io) { rb_io_t *fptr; rb_encoding *enc; VALUE c; RETURN_ENUMERATOR(io, 0, 0); GetOpenFile(io, fptr); rb_io_check_char_readable(fptr); enc = io_input_encoding(fptr); READ_CHECK(fptr); while (!NIL_P(c = io_getc(fptr, enc))) { rb_yield(c); } return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#each_codepoint;F;7[;[[@TiI;T;:each_codepoint;0;[;{;IC; "Passes the Integer ordinal of each character in ios, passing the codepoint as an argument. The stream must be opened for reading or an IOError will be raised. If no block is given, an enumerator is returned instead. ;T;[o;= ;>I" overload;F;?0;;{;@0;:I"each_codepoint;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"c;T;$@Ro;A ;>I" return;F;?I";T;0;@[I"IO;T;$@R;![;"I"@yield [c] @return [IO];T;#0;$@R;.F;Bi;C0;7[;$@Ro;= ;>I" overload;F;?0;;{;@0;:I"each_codepoint;T;IC; ";T;[;![;"I";T;#0;$@R;.F;Bi;C0;7[;$@R;![;"I"0Passes the Integer ordinal of each character in ios, passing the codepoint as an argument. The stream must be opened for reading or an IOError will be raised. If no block is given, an enumerator is returned instead. @overload each_codepoint @yield [c] @return [IO] @overload each_codepoint;T;#0;$@R;.F;/o;0;1T;2i<;3iG;%@kL;9I"$ static VALUE rb_io_each_codepoint(VALUE io) { rb_io_t *fptr; rb_encoding *enc; unsigned int c; int r, n; RETURN_ENUMERATOR(io, 0, 0); GetOpenFile(io, fptr); rb_io_check_char_readable(fptr); READ_CHECK(fptr); if (NEED_READCONV(fptr)) { SET_BINARY_MODE(fptr); r = 1; /* no invalid char yet */ for (;;) { make_readconv(fptr, 0); for (;;) { if (fptr->cbuf.len) { if (fptr->encs.enc) r = rb_enc_precise_mbclen(fptr->cbuf.ptr+fptr->cbuf.off, fptr->cbuf.ptr+fptr->cbuf.off+fptr->cbuf.len, fptr->encs.enc); else r = ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(1); if (!MBCLEN_NEEDMORE_P(r)) break; if (fptr->cbuf.len == fptr->cbuf.capa) { rb_raise(rb_eIOError, "too long character"); } } if (more_char(fptr) == MORE_CHAR_FINISHED) { clear_readconv(fptr); if (!MBCLEN_CHARFOUND_P(r)) { enc = fptr->encs.enc; goto invalid; } return io; } } if (MBCLEN_INVALID_P(r)) { enc = fptr->encs.enc; goto invalid; } n = MBCLEN_CHARFOUND_LEN(r); if (fptr->encs.enc) { c = rb_enc_codepoint(fptr->cbuf.ptr+fptr->cbuf.off, fptr->cbuf.ptr+fptr->cbuf.off+fptr->cbuf.len, fptr->encs.enc); } else { c = (unsigned char)fptr->cbuf.ptr[fptr->cbuf.off]; } fptr->cbuf.off += n; fptr->cbuf.len -= n; rb_yield(UINT2NUM(c)); rb_io_check_byte_readable(fptr); } } NEED_NEWLINE_DECORATOR_ON_READ_CHECK(fptr); enc = io_input_encoding(fptr); while (io_fillbuf(fptr) >= 0) { r = rb_enc_precise_mbclen(fptr->rbuf.ptr+fptr->rbuf.off, fptr->rbuf.ptr+fptr->rbuf.off+fptr->rbuf.len, enc); if (MBCLEN_CHARFOUND_P(r) && (n = MBCLEN_CHARFOUND_LEN(r)) <= fptr->rbuf.len) { c = rb_enc_codepoint(fptr->rbuf.ptr+fptr->rbuf.off, fptr->rbuf.ptr+fptr->rbuf.off+fptr->rbuf.len, enc); fptr->rbuf.off += n; fptr->rbuf.len -= n; rb_yield(UINT2NUM(c)); } else if (MBCLEN_INVALID_P(r)) { goto invalid; } else if (MBCLEN_NEEDMORE_P(r)) { char cbuf[8], *p = cbuf; int more = MBCLEN_NEEDMORE_LEN(r); if (more > numberof(cbuf)) goto invalid; more += n = fptr->rbuf.len; if (more > numberof(cbuf)) goto invalid; while ((n = (int)read_buffered_data(p, more, fptr)) > 0 && (p += n, (more -= n) > 0)) { if (io_fillbuf(fptr) < 0) goto invalid; if ((n = fptr->rbuf.len) > more) n = more; } r = rb_enc_precise_mbclen(cbuf, p, enc); if (!MBCLEN_CHARFOUND_P(r)) goto invalid; c = rb_enc_codepoint(cbuf, p, enc); rb_yield(UINT2NUM(c)); } else { continue; } rb_io_check_byte_readable(fptr); } return io; invalid: rb_raise(rb_eArgError, "invalid byte sequence in %s", rb_enc_name(enc)); UNREACHABLE_RETURN(Qundef); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#syswrite;F;7[[I"str;T0;[[@Ti;T;: syswrite;0;[;{;IC; ""Writes the given string to ios using a low-level write. Returns the number of bytes written. Do not mix with other methods that write to ios or you may get unpredictable results. Raises SystemCallError on error. f = File.new("out", "w") f.syswrite("ABCDEF") #=> 6 ;T;[o;= ;>I" overload;F;?0;;|;@0;:I"syswrite(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@R;![;"I"@return [Integer];T;#0;$@R;.F;Bi;C0;7[[I" string;T0;$@R;![;"I"SWrites the given string to ios using a low-level write. Returns the number of bytes written. Do not mix with other methods that write to ios or you may get unpredictable results. Raises SystemCallError on error. f = File.new("out", "w") f.syswrite("ABCDEF") #=> 6 @overload syswrite(string) @return [Integer];T;#0;$@R;.F;/o;0;1T;2iv;3i;%@kL;9I"Cstatic VALUE rb_io_syswrite(VALUE io, VALUE str) { VALUE tmp; rb_io_t *fptr; long n, len; const char *ptr; if (!RB_TYPE_P(str, T_STRING)) str = rb_obj_as_string(str); io = GetWriteIO(io); GetOpenFile(io, fptr); rb_io_check_writable(fptr); if (fptr->wbuf.len) { rb_warn("syswrite for buffered IO"); } tmp = rb_str_tmp_frozen_acquire(str); RSTRING_GETMEM(tmp, ptr, len); n = rb_write_internal(fptr, ptr, len); if (n < 0) rb_sys_fail_path(fptr->pathv); rb_str_tmp_frozen_release(str, tmp); return LONG2FIX(n); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#sysread;F;7[[@90;[[@Ti;T;: sysread;0;[;{;IC; "Reads maxlen bytes from ios using a low-level read and returns them as a string. Do not mix with other methods that read from ios or you may get unpredictable results. If the optional _outbuf_ argument is present, it must reference a String, which will receive the data. The _outbuf_ will contain only the received data after the method call even if it is not empty at the beginning. Raises SystemCallError on error and EOFError at end of file. f = File.new("testfile") f.sysread(16) #=> "This is line one" ;T;[o;= ;>I" overload;F;?0;;};@0;:I"sysread(maxlen[, outbuf]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@R;![;"I"@return [String];T;#0;$@R;.F;Bi;C0;7[[I"maxlen[, outbuf];T0;$@R;![;"I"XReads maxlen bytes from ios using a low-level read and returns them as a string. Do not mix with other methods that read from ios or you may get unpredictable results. If the optional _outbuf_ argument is present, it must reference a String, which will receive the data. The _outbuf_ will contain only the received data after the method call even if it is not empty at the beginning. Raises SystemCallError on error and EOFError at end of file. f = File.new("testfile") f.sysread(16) #=> "This is line one" @overload sysread(maxlen[, outbuf]) @return [String];T;#0;$@R;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE rb_io_sysread(int argc, VALUE *argv, VALUE io) { VALUE len, str; rb_io_t *fptr; long n, ilen; struct io_internal_read_struct iis; int shrinkable; rb_scan_args(argc, argv, "11", &len, &str); ilen = NUM2LONG(len); shrinkable = io_setstrbuf(&str, ilen); if (ilen == 0) return str; GetOpenFile(io, fptr); rb_io_check_byte_readable(fptr); if (READ_DATA_BUFFERED(fptr)) { rb_raise(rb_eIOError, "sysread for buffered IO"); } rb_io_check_closed(fptr); io_setstrbuf(&str, ilen); iis.th = rb_thread_current(); iis.fptr = fptr; iis.nonblock = 0; iis.buf = RSTRING_PTR(str); iis.capa = ilen; n = read_internal_locktmp(str, &iis); if (n < 0) { rb_sys_fail_path(fptr->pathv); } io_set_read_length(str, n, shrinkable); if (n == 0 && ilen > 0) { rb_eof_error(); } return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#pread;F;7[[@90;[[@Ti ;T;: pread;0;[;{;IC; "Reads maxlen bytes from ios using the pread system call and returns them as a string without modifying the underlying descriptor offset. This is advantageous compared to combining IO#seek and IO#read in that it is atomic, allowing multiple threads/process to share the same IO object for reading the file at various locations. This bypasses any userspace buffering of the IO layer. If the optional outbuf argument is present, it must reference a String, which will receive the data. Raises SystemCallError on error, EOFError at end of file and NotImplementedError if platform does not implement the system call. File.write("testfile", "This is line one\nThis is line two\n") File.open("testfile") do |f| p f.read # => "This is line one\nThis is line two\n" p f.pread(12, 0) # => "This is line" p f.pread(9, 8) # => "line one\n" end ;T;[o;= ;>I" overload;F;?0;;~;@0;:I"$pread(maxlen, offset[, outbuf]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@R;![;"I"@return [String];T;#0;$@R;.F;Bi;C0;7[[I" maxlen;T0[I"offset[, outbuf];T0;$@R;![;"I"Reads maxlen bytes from ios using the pread system call and returns them as a string without modifying the underlying descriptor offset. This is advantageous compared to combining IO#seek and IO#read in that it is atomic, allowing multiple threads/process to share the same IO object for reading the file at various locations. This bypasses any userspace buffering of the IO layer. If the optional outbuf argument is present, it must reference a String, which will receive the data. Raises SystemCallError on error, EOFError at end of file and NotImplementedError if platform does not implement the system call. File.write("testfile", "This is line one\nThis is line two\n") File.open("testfile") do |f| p f.read # => "This is line one\nThis is line two\n" p f.pread(12, 0) # => "This is line" p f.pread(9, 8) # => "line one\n" end @overload pread(maxlen, offset[, outbuf]) @return [String];T;#0;$@R;.F;/o;0;1T;2i;3i ;%@kL;9I"?static VALUE rb_io_pread(int argc, VALUE *argv, VALUE io) { VALUE len, offset, str; rb_io_t *fptr; ssize_t n; struct prdwr_internal_arg arg; int shrinkable; rb_scan_args(argc, argv, "21", &len, &offset, &str); arg.count = NUM2SIZET(len); arg.offset = NUM2OFFT(offset); shrinkable = io_setstrbuf(&str, (long)arg.count); if (arg.count == 0) return str; arg.buf = RSTRING_PTR(str); GetOpenFile(io, fptr); rb_io_check_byte_readable(fptr); arg.fd = fptr->fd; rb_io_check_closed(fptr); rb_str_locktmp(str); n = (ssize_t)rb_ensure(pread_internal_call, (VALUE)&arg, rb_str_unlocktmp, str); if (n < 0) { rb_sys_fail_path(fptr->pathv); } io_set_read_length(str, n, shrinkable); if (n == 0 && arg.count > 0) { rb_eof_error(); } return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#pwrite;F;7[[I"str;T0[I" offset;T0;[[@TiQ;T;: pwrite;0;[;{;IC; "WWrites the given string to ios at offset using pwrite() system call. This is advantageous to combining IO#seek and IO#write in that it is atomic, allowing multiple threads/process to share the same IO object for reading the file at various locations. This bypasses any userspace buffering of the IO layer. Returns the number of bytes written. Raises SystemCallError on error and NotImplementedError if platform does not implement the system call. File.open("out", "w") do |f| f.pwrite("ABCDEF", 3) #=> 6 end File.read("out") #=> "\u0000\u0000\u0000ABCDEF" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"pwrite(string, offset);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@S;![;"I"@return [Integer];T;#0;$@S;.F;Bi;C0;7[[I" string;T0[I" offset;T0;$@S;![;"I"Writes the given string to ios at offset using pwrite() system call. This is advantageous to combining IO#seek and IO#write in that it is atomic, allowing multiple threads/process to share the same IO object for reading the file at various locations. This bypasses any userspace buffering of the IO layer. Returns the number of bytes written. Raises SystemCallError on error and NotImplementedError if platform does not implement the system call. File.open("out", "w") do |f| f.pwrite("ABCDEF", 3) #=> 6 end File.read("out") #=> "\u0000\u0000\u0000ABCDEF" @overload pwrite(string, offset) @return [Integer];T;#0;$@S;.F;/o;0;1T;2i>;3iO;%@kL;9I"static VALUE rb_io_pwrite(VALUE io, VALUE str, VALUE offset) { rb_io_t *fptr; ssize_t n; struct prdwr_internal_arg arg; VALUE tmp; if (!RB_TYPE_P(str, T_STRING)) str = rb_obj_as_string(str); arg.offset = NUM2OFFT(offset); io = GetWriteIO(io); GetOpenFile(io, fptr); rb_io_check_writable(fptr); arg.fd = fptr->fd; tmp = rb_str_tmp_frozen_acquire(str); arg.buf = RSTRING_PTR(tmp); arg.count = (size_t)RSTRING_LEN(tmp); n = (ssize_t)rb_thread_io_blocking_region(internal_pwrite_func, &arg, fptr->fd); if (n < 0) rb_sys_fail_path(fptr->pathv); rb_str_tmp_frozen_release(str, tmp); return SSIZET2NUM(n); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#fileno;F;7[;[[@TiR ;T;: fileno;0;[;{;IC; "Returns the integer file descriptor for the stream: $stdin.fileno # => 0 $stdout.fileno # => 1 $stderr.fileno # => 2 File.open('t.txt').fileno # => 10 IO#to_i is an alias for IO#fileno. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" fileno;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@+S;![;"I"@return [Integer];T;#0;$@+S;.F;Bi;C0;7[;$@+S;![;"I" Returns the integer file descriptor for the stream: $stdin.fileno # => 0 $stdout.fileno # => 1 $stderr.fileno # => 2 File.open('t.txt').fileno # => 10 IO#to_i is an alias for IO#fileno. @overload fileno @return [Integer];T;#0;$o;4;5F;6;;;;&I" IO#to_i;F;7[;[[@Ti7;F;: to_i;;;[;{;@2S;%@kL;9I"static VALUE rb_io_fileno(VALUE io) { rb_io_t *fptr = RFILE(io)->fptr; int fd; rb_io_check_closed(fptr); fd = fptr->fd; return INT2FIX(fd); };T;:I"static VALUE;T;.F;/o;0;1T;2iC ;3iO ;%@kL;9I"static VALUE rb_io_fileno(VALUE io) { rb_io_t *fptr = RFILE(io)->fptr; int fd; rb_io_check_closed(fptr); fd = fptr->fd; return INT2FIX(fd); };T;:@KS;;T@CSo;4;5F;6;;;;&I" IO#to_io;F;7[;[[@Ti ;T;: to_io;0;[;{;IC; "Returns +self+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_io;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@NS;![;"I"@return [self];T;#0;$@NS;.F;Bi;C0;7[;$@NS;![;"I"8Returns +self+. @overload to_io @return [self];T;#0;$@NS;.F;/o;0;1T;2i ;3i ;%@kL;9I":static VALUE rb_io_to_io(VALUE io) { return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#fsync;F;7[;[[@Ti ;T;: fsync;0;[;{;IC; "Immediately writes to disk all data buffered in the stream, via the operating system's fsync(2). Note this difference: - IO#sync=: Ensures that data is flushed from the stream's internal buffers, but does not guarantee that the operating system actually writes the data to disk. - IO#fsync: Ensures both that data is flushed from internal buffers, and that data is written to disk. Raises an exception if the operating system does not support fsync(2). ;T;[o;= ;>I" overload;F;?0;;;@0;:I" fsync;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@iS;![;"I"@return [0];T;#0;$@iS;.F;Bi;C0;7[;$@iS;![;"I"Immediately writes to disk all data buffered in the stream, via the operating system's fsync(2). Note this difference: - IO#sync=: Ensures that data is flushed from the stream's internal buffers, but does not guarantee that the operating system actually writes the data to disk. - IO#fsync: Ensures both that data is flushed from internal buffers, and that data is written to disk. Raises an exception if the operating system does not support fsync(2). @overload fsync @return [0];T;#0;$@iS;.F;/o;0;1T;2i ;3i ;%@kL;9I"3static VALUE rb_io_fsync(VALUE io) { rb_io_t *fptr; io = GetWriteIO(io); GetOpenFile(io, fptr); if (io_fflush(fptr) < 0) rb_sys_fail_on_write(fptr); if ((int)rb_thread_io_blocking_region(nogvl_fsync, fptr, fptr->fd) < 0) rb_sys_fail_path(fptr->pathv); return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#fdatasync;F;7[;[[@Ti. ;T;:fdatasync;0;[;{;IC; "Immediately writes to disk all data buffered in the stream, via the operating system's: fdatasync(2), if supported, otherwise via fsync(2), if supported; otherwise raises an exception. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"fdatasync;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@S;![;"I"@return [0];T;#0;$@S;.F;Bi;C0;7[;$@S;![;"I"Immediately writes to disk all data buffered in the stream, via the operating system's: fdatasync(2), if supported, otherwise via fsync(2), if supported; otherwise raises an exception. @overload fdatasync @return [0];T;#0;$@S;.F;/o;0;1T;2i# ;3i+ ;%@kL;9I"Kstatic VALUE rb_io_fdatasync(VALUE io) { rb_io_t *fptr; io = GetWriteIO(io); GetOpenFile(io, fptr); if (io_fflush(fptr) < 0) rb_sys_fail_on_write(fptr); if ((int)rb_thread_io_blocking_region(nogvl_fdatasync, fptr, fptr->fd) == 0) return INT2FIX(0); /* fall back */ return rb_io_fsync(io); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#sync;F;7[;[[@Ti ;T;: sync;0;[;{;IC; "Returns the current sync mode of the stream. When sync mode is true, all output is immediately flushed to the underlying operating system and is not buffered by Ruby internally. See also #fsync. f = File.open('t.tmp', 'w') f.sync # => false f.sync = true f.sync # => true ;T;[o;= ;>I" overload;F;?0;;;@0;:I" sync;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@S;![;"I"@return [Boolean];T;#0;$@S;.F;Bi;C0;7[;$@S;![;"I">Returns the current sync mode of the stream. When sync mode is true, all output is immediately flushed to the underlying operating system and is not buffered by Ruby internally. See also #fsync. f = File.open('t.tmp', 'w') f.sync # => false f.sync = true f.sync # => true @overload sync @return [Boolean];T;#0;$@S;.F;/o;0;1T;2i ;3i ;%@kL;9I"static VALUE rb_io_sync(VALUE io) { rb_io_t *fptr; io = GetWriteIO(io); GetOpenFile(io, fptr); return RBOOL(fptr->mode & FMODE_SYNC); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#sync=;F;7[[I" sync;T0;[[@Ti ;T;: sync=;0;[;{;IC; " ;T;[;![;"@;#0;$@S;%@kL;9I"bstatic VALUE rb_io_set_sync(VALUE io, VALUE sync) { rb_notimplement(); UNREACHABLE; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#lineno;F;7[;[[@Ti;T;;L;0;[;{;IC; ">Returns the current line number in ios. The stream must be opened for reading. #lineno counts the number of times #gets is called rather than the number of newlines encountered. The two values will differ if #gets is called with a separator other than newline. Methods that use $/ like #each, #lines and #readline will also increment #lineno. See also the $. variable. f = File.new("testfile") f.lineno #=> 0 f.gets #=> "This is line one\n" f.lineno #=> 1 f.gets #=> "This is line two\n" f.lineno #=> 2 ;T;[o;= ;>I" overload;F;?0;;L;@0;:I" lineno;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@S;![;"I"@return [Integer];T;#0;$@S;.F;Bi;C0;7[;$@S;![;"I"eReturns the current line number in ios. The stream must be opened for reading. #lineno counts the number of times #gets is called rather than the number of newlines encountered. The two values will differ if #gets is called with a separator other than newline. Methods that use $/ like #each, #lines and #readline will also increment #lineno. See also the $. variable. f = File.new("testfile") f.lineno #=> 0 f.gets #=> "This is line one\n" f.lineno #=> 1 f.gets #=> "This is line two\n" f.lineno #=> 2 @overload lineno @return [Integer];T;#0;$@S;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE rb_io_lineno(VALUE io) { rb_io_t *fptr; GetOpenFile(io, fptr); rb_io_check_char_readable(fptr); return INT2NUM(fptr->lineno); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#lineno=;F;7[[I" lineno;T0;[[@Ti ;T;: lineno=;0;[;{;IC; "Manually sets the current line number to the given value. $. is updated only on the next read. f = File.new("testfile") f.gets #=> "This is line one\n" $. #=> 1 f.lineno = 1000 f.lineno #=> 1000 $. #=> 1 # lineno of last read f.gets #=> "This is line two\n" $. #=> 1001 # lineno of last read ;T;[o;= ;>I" overload;F;?0;;;@0;:I"lineno=(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@S;![;"I"@return [Integer];T;#0;$@S;.F;Bi;C0;7[[I" integer;T0;$@S;![;"I" Manually sets the current line number to the given value. $. is updated only on the next read. f = File.new("testfile") f.gets #=> "This is line one\n" $. #=> 1 f.lineno = 1000 f.lineno #=> 1000 $. #=> 1 # lineno of last read f.gets #=> "This is line two\n" $. #=> 1001 # lineno of last read @overload lineno=(integer) @return [Integer];T;#0;$@S;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE rb_io_set_lineno(VALUE io, VALUE lineno) { rb_io_t *fptr; GetOpenFile(io, fptr); rb_io_check_char_readable(fptr); fptr->lineno = NUM2INT(lineno); return lineno; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#readlines;F;7[[@90;[[@TiC;T;;;0;[;{;IC; "oReads all of the lines in ios, and returns them in an array. Lines are separated by the optional sep. If sep is +nil+, the rest of the stream is returned as a single record. If the first argument is an integer, or an optional second argument is given, the returning string would not be longer than the given value in bytes. The stream must be opened for reading or an IOError will be raised. f = File.new("testfile") f.readlines[0] #=> "This is line one\n" f = File.new("testfile", chomp: true) f.readlines[0] #=> "This is line one" See IO.readlines for details about getline_args. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"'readlines(sep=$/ [, getline_args]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@T;![;"I"@return [Array];T;#0;$@T;.F;Bi;C0;7[[I"sep;TI"$/[, getline_args];T;$@To;= ;>I" overload;F;?0;;;@0;:I"&readlines(limit [, getline_args]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@T;![;"I"@return [Array];T;#0;$@T;.F;Bi;C0;7[[I"limit[, getline_args];T0;$@To;= ;>I" overload;F;?0;;;@0;:I"+readlines(sep, limit [, getline_args]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@T;![;"I"@return [Array];T;#0;$@T;.F;Bi;C0;7[[I"sep;T0[I"limit[, getline_args];T0;$@T;![;"I"1Reads all of the lines in ios, and returns them in an array. Lines are separated by the optional sep. If sep is +nil+, the rest of the stream is returned as a single record. If the first argument is an integer, or an optional second argument is given, the returning string would not be longer than the given value in bytes. The stream must be opened for reading or an IOError will be raised. f = File.new("testfile") f.readlines[0] #=> "This is line one\n" f = File.new("testfile", chomp: true) f.readlines[0] #=> "This is line one" See IO.readlines for details about getline_args. @overload readlines(sep=$/ [, getline_args]) @return [Array] @overload readlines(limit [, getline_args]) @return [Array] @overload readlines(sep, limit [, getline_args]) @return [Array];T;#0;$@T;.F;/o;0;1T;2i+;3iB;%@kL;9I"static VALUE rb_io_readlines(int argc, VALUE *argv, VALUE io) { struct getline_arg args; prepare_getline_args(argc, argv, &args, io); return io_readlines(&args, io); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#readpartial;F;7[[@90;[[@Ti ;T;:readpartial;0;[;{;IC; " Reads up to +maxlen+ bytes from the stream; returns a string (either a new string or the given +out_string+). Its encoding is: - The unchanged encoding of +out_string+, if +out_string+ is given. - ASCII-8BIT, otherwise. - Contains +maxlen+ bytes from the stream, if available. - Otherwise contains all available bytes, if any available. - Otherwise is an empty string. With the single non-negative integer argument +maxlen+ given, returns a new string: f = File.new('t.txt') f.readpartial(30) # => "This is line one.\nThis is the" f.readpartial(30) # => " second line.\nThis is the thi" f.readpartial(30) # => "rd line.\n" f.eof # => true f.readpartial(30) # Raises EOFError. With both argument +maxlen+ and string argument +out_string+ given, returns modified +out_string+: f = File.new('t.txt') s = 'foo' f.readpartial(30, s) # => "This is line one.\nThis is the" s = 'bar' f.readpartial(0, s) # => "" This method is useful for a stream such as a pipe, a socket, or a tty. It blocks only when no data is immediately available. This means that it blocks only when _all_ of the following are true: - The byte buffer in the stream is empty. - The content of the stream is empty. - The stream is not at EOF. When blocked, the method waits for either more data or EOF on the stream: - If more data is read, the method returns the data. - If EOF is reached, the method raises EOFError. When not blocked, the method responds immediately: - Returns data from the buffer if there is any. - Otherwise returns data from the stream if there is any. - Otherwise raises EOFError if the stream has reached EOF. Note that this method is similar to sysread. The differences are: - If the byte buffer is not empty, read from the byte buffer instead of "sysread for buffered IO (IOError)". - It doesn't cause Errno::EWOULDBLOCK and Errno::EINTR. When readpartial meets EWOULDBLOCK and EINTR by read system call, readpartial retries the system call. The latter means that readpartial is non-blocking-flag insensitive. It blocks on the situation IO#sysread causes Errno::EWOULDBLOCK as if the fd is blocking mode. Examples: # # Returned Buffer Content Pipe Content r, w = IO.pipe # w << 'abc' # "" "abc". r.readpartial(4096) # => "abc" "" "" r.readpartial(4096) # (Blocks because buffer and pipe are empty.) # # Returned Buffer Content Pipe Content r, w = IO.pipe # w << 'abc' # "" "abc" w.close # "" "abc" EOF r.readpartial(4096) # => "abc" "" EOF r.readpartial(4096) # raises EOFError # # Returned Buffer Content Pipe Content r, w = IO.pipe # w << "abc\ndef\n" # "" "abc\ndef\n" r.gets # => "abc\n" "def\n" "" w << "ghi\n" # "def\n" "ghi\n" r.readpartial(4096) # => "def\n" "" "ghi\n" r.readpartial(4096) # => "ghi\n" "" "" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"readpartial(maxlen);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@AT;![;"I"@return [String];T;#0;$@AT;.F;Bi;C0;7[[I" maxlen;T0;$@ATo;= ;>I" overload;F;?0;;;@0;:I"$readpartial(maxlen, out_string);T;IC; ";T;[;![;"I";T;#0;$@AT;.F;Bi;C0;7[[I" maxlen;T0[I"out_string;T0;$@AT;![;"I"4 Reads up to +maxlen+ bytes from the stream; returns a string (either a new string or the given +out_string+). Its encoding is: - The unchanged encoding of +out_string+, if +out_string+ is given. - ASCII-8BIT, otherwise. - Contains +maxlen+ bytes from the stream, if available. - Otherwise contains all available bytes, if any available. - Otherwise is an empty string. With the single non-negative integer argument +maxlen+ given, returns a new string: f = File.new('t.txt') f.readpartial(30) # => "This is line one.\nThis is the" f.readpartial(30) # => " second line.\nThis is the thi" f.readpartial(30) # => "rd line.\n" f.eof # => true f.readpartial(30) # Raises EOFError. With both argument +maxlen+ and string argument +out_string+ given, returns modified +out_string+: f = File.new('t.txt') s = 'foo' f.readpartial(30, s) # => "This is line one.\nThis is the" s = 'bar' f.readpartial(0, s) # => "" This method is useful for a stream such as a pipe, a socket, or a tty. It blocks only when no data is immediately available. This means that it blocks only when _all_ of the following are true: - The byte buffer in the stream is empty. - The content of the stream is empty. - The stream is not at EOF. When blocked, the method waits for either more data or EOF on the stream: - If more data is read, the method returns the data. - If EOF is reached, the method raises EOFError. When not blocked, the method responds immediately: - Returns data from the buffer if there is any. - Otherwise returns data from the stream if there is any. - Otherwise raises EOFError if the stream has reached EOF. Note that this method is similar to sysread. The differences are: - If the byte buffer is not empty, read from the byte buffer instead of "sysread for buffered IO (IOError)". - It doesn't cause Errno::EWOULDBLOCK and Errno::EINTR. When readpartial meets EWOULDBLOCK and EINTR by read system call, readpartial retries the system call. The latter means that readpartial is non-blocking-flag insensitive. It blocks on the situation IO#sysread causes Errno::EWOULDBLOCK as if the fd is blocking mode. Examples: # # Returned Buffer Content Pipe Content r, w = IO.pipe # w << 'abc' # "" "abc". r.readpartial(4096) # => "abc" "" "" r.readpartial(4096) # (Blocks because buffer and pipe are empty.) # # Returned Buffer Content Pipe Content r, w = IO.pipe # w << 'abc' # "" "abc" w.close # "" "abc" EOF r.readpartial(4096) # => "abc" "" EOF r.readpartial(4096) # raises EOFError # # Returned Buffer Content Pipe Content r, w = IO.pipe # w << "abc\ndef\n" # "" "abc\ndef\n" r.gets # => "abc\n" "def\n" "" w << "ghi\n" # "def\n" "ghi\n" r.readpartial(4096) # => "def\n" "" "ghi\n" r.readpartial(4096) # => "ghi\n" "" "" @overload readpartial(maxlen) @return [String] @overload readpartial(maxlen, out_string);T;#0;$@AT;.F;/o;0;1T;2i ;3i ;%@kL;9I"static VALUE io_readpartial(int argc, VALUE *argv, VALUE io) { VALUE ret; ret = io_getpartial(argc, argv, io, Qnil, 0); if (NIL_P(ret)) rb_eof_error(); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#read;F;7[[@90;[[@Ti ;T;;q;0;[;{;IC; "oReads bytes from the stream (in binary mode): - If +maxlen+ is +nil+, reads all bytes. - Otherwise reads +maxlen+ bytes, if available. - Otherwise reads all bytes. Returns a string (either a new string or the given +out_string+) containing the bytes read. The encoding of the string depends on both +maxLen+ and +out_string+: - +maxlen+ is +nil+: uses internal encoding of +self+ (regardless of whether +out_string+ was given). - +maxlen+ not +nil+: - +out_string+ given: encoding of +out_string+ not modified. - +out_string+ not given: ASCII-8BIT is used. Without Argument +out_string+ When argument +out_string+ is omitted, the returned value is a new string: f = File.new('t.txt') f.read # => "This is line one.\nThis is the second line.\nThis is the third line.\n" f.rewind f.read(40) # => "This is line one.\r\nThis is the second li" f.read(40) # => "ne.\r\nThis is the third line.\r\n" f.read(40) # => nil If +maxlen+ is zero, returns an empty string. With Argument +out_string+ When argument +out_string+ is given, the returned value is +out_string+, whose content is replaced: f = File.new('t.txt') s = 'foo' # => "foo" f.read(nil, s) # => "This is line one.\nThis is the second line.\nThis is the third line.\n" s # => "This is line one.\nThis is the second line.\nThis is the third line.\n" f.rewind s = 'bar' f.read(40, s) # => "This is line one.\r\nThis is the second li" s # => "This is line one.\r\nThis is the second li" s = 'baz' f.read(40, s) # => "ne.\r\nThis is the third line.\r\n" s # => "ne.\r\nThis is the third line.\r\n" s = 'bat' f.read(40, s) # => nil s # => "" Note that this method behaves like the fread() function in C. This means it retries to invoke read(2) system calls to read data with the specified maxlen (or until EOF). This behavior is preserved even if the stream is in non-blocking mode. (This method is non-blocking-flag insensitive as other methods.) If you need the behavior like a single read(2) system call, consider #readpartial, #read_nonblock, and #sysread. ;T;[o;= ;>I" overload;F;?0;;q;@0;:I"read(maxlen = nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@kT;![;"I"@return [String, nil];T;#0;$@kT;.F;Bi;C0;7[[I" maxlen;TI"nil;T;$@kTo;= ;>I" overload;F;?0;;q;@0;:I"#read(maxlen = nil, out_string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@kT;![;"I"@return [nil];T;#0;$@kT;.F;Bi;C0;7[[I" maxlen;TI"nil;T[I"out_string;T0;$@kT;![;"I"Reads bytes from the stream (in binary mode): - If +maxlen+ is +nil+, reads all bytes. - Otherwise reads +maxlen+ bytes, if available. - Otherwise reads all bytes. Returns a string (either a new string or the given +out_string+) containing the bytes read. The encoding of the string depends on both +maxLen+ and +out_string+: - +maxlen+ is +nil+: uses internal encoding of +self+ (regardless of whether +out_string+ was given). - +maxlen+ not +nil+: - +out_string+ given: encoding of +out_string+ not modified. - +out_string+ not given: ASCII-8BIT is used. Without Argument +out_string+ When argument +out_string+ is omitted, the returned value is a new string: f = File.new('t.txt') f.read # => "This is line one.\nThis is the second line.\nThis is the third line.\n" f.rewind f.read(40) # => "This is line one.\r\nThis is the second li" f.read(40) # => "ne.\r\nThis is the third line.\r\n" f.read(40) # => nil If +maxlen+ is zero, returns an empty string. With Argument +out_string+ When argument +out_string+ is given, the returned value is +out_string+, whose content is replaced: f = File.new('t.txt') s = 'foo' # => "foo" f.read(nil, s) # => "This is line one.\nThis is the second line.\nThis is the third line.\n" s # => "This is line one.\nThis is the second line.\nThis is the third line.\n" f.rewind s = 'bar' f.read(40, s) # => "This is line one.\r\nThis is the second li" s # => "This is line one.\r\nThis is the second li" s = 'baz' f.read(40, s) # => "ne.\r\nThis is the third line.\r\n" s # => "ne.\r\nThis is the third line.\r\n" s = 'bat' f.read(40, s) # => nil s # => "" Note that this method behaves like the fread() function in C. This means it retries to invoke read(2) system calls to read data with the specified maxlen (or until EOF). This behavior is preserved even if the stream is in non-blocking mode. (This method is non-blocking-flag insensitive as other methods.) If you need the behavior like a single read(2) system call, consider #readpartial, #read_nonblock, and #sysread. @overload read(maxlen = nil) @return [String, nil] @overload read(maxlen = nil, out_string) @return [nil];T;#0;$@kT;.F;/o;0;1T;2i^ ;3i ;%@kL;9I"static VALUE io_read(int argc, VALUE *argv, VALUE io) { rb_io_t *fptr; long n, len; VALUE length, str; int shrinkable; #if RUBY_CRLF_ENVIRONMENT int previous_mode; #endif rb_scan_args(argc, argv, "02", &length, &str); if (NIL_P(length)) { GetOpenFile(io, fptr); rb_io_check_char_readable(fptr); return read_all(fptr, remain_size(fptr), str); } len = NUM2LONG(length); if (len < 0) { rb_raise(rb_eArgError, "negative length %ld given", len); } shrinkable = io_setstrbuf(&str,len); GetOpenFile(io, fptr); rb_io_check_byte_readable(fptr); if (len == 0) { io_set_read_length(str, 0, shrinkable); return str; } READ_CHECK(fptr); #if RUBY_CRLF_ENVIRONMENT previous_mode = set_binary_mode_with_seek_cur(fptr); #endif n = io_fread(str, 0, len, fptr); io_set_read_length(str, n, shrinkable); #if RUBY_CRLF_ENVIRONMENT if (previous_mode == O_TEXT) { setmode(fptr->fd, O_TEXT); } #endif if (n == 0) return Qnil; return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#write;F;7[[@90;[[@Ti;T;;s;0;[;{;IC; "uWrites each of the given +objects+ to +self+, which must be opened for writing (see {Modes}[#class-IO-label-Modes]); returns the total number bytes written; each of +objects+ that is not a string is converted via method +to_s+: $stdout.write('Hello', ', ', 'World!', "\n") # => 14 $stdout.write('foo', :bar, 2, "\n") # => 8 Output: Hello, World! foobar2 ;T;[o;= ;>I" overload;F;?0;;s;@0;:I"write(*objects);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@T;![;"I"@return [Integer];T;#0;$@T;.F;Bi;C0;7[[I" *objects;T0;$@T;![;"I"Writes each of the given +objects+ to +self+, which must be opened for writing (see {Modes}[#class-IO-label-Modes]); returns the total number bytes written; each of +objects+ that is not a string is converted via method +to_s+: $stdout.write('Hello', ', ', 'World!', "\n") # => 14 $stdout.write('foo', :bar, 2, "\n") # => 8 Output: Hello, World! foobar2 @overload write(*objects) @return [Integer];T;#0;$@T;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE io_write_m(int argc, VALUE *argv, VALUE io) { if (argc != 1) { return io_writev(argc, argv, io); } else { VALUE str = argv[0]; return io_write(io, str, 0); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#gets;F;7[[@90;[[@Ti;T;;;0;[;{;IC; " Reads and returns data from the stream; assigns the return value to $_. With no arguments given, returns the next line as determined by line separator $/, or +nil+ if none: f = File.open('t.txt') f.gets # => "This is line one.\n" $_ # => "This is line one.\n" f.gets # => "This is the second line.\n" f.gets # => "This is the third line.\n" f.gets # => nil With string argument +sep+ given, but not argument +limit+, returns the next line as determined by line separator +sep+, or +nil+ if none: f = File.open('t.txt') f.gets(' is') # => "This is" f.gets(' is') # => " line one.\nThis is" f.gets(' is') # => " the second line.\nThis is" f.gets(' is') # => " the third line.\n" f.gets(' is') # => nil Note two special values for +sep+: - +nil+: The entire stream is read and returned. - '' (empty string): The next "paragraph" is read and returned, the paragraph separator being two successive line separators. With integer argument +limit+ given, returns up to limit+1 bytes: # Text with 1-byte characters. File.open('t.txt') {|f| f.gets(1) } # => "T" File.open('t.txt') {|f| f.gets(2) } # => "Th" File.open('t.txt') {|f| f.gets(3) } # => "Thi" File.open('t.txt') {|f| f.gets(4) } # => "This" # No more than one line. File.open('t.txt') {|f| f.gets(17) } # => "This is line one." File.open('t.txt') {|f| f.gets(18) } # => "This is line one.\n" File.open('t.txt') {|f| f.gets(19) } # => "This is line one.\n" # Text with 2-byte characters, which will not be split. File.open('t.rus') {|f| f.gets(1).size } # => 1 File.open('t.rus') {|f| f.gets(2).size } # => 1 File.open('t.rus') {|f| f.gets(3).size } # => 2 File.open('t.rus') {|f| f.gets(4).size } # => 2 With arguments +sep+ and +limit+, combines the two behaviors above: - Returns the next line as determined by line separator +sep+, or +nil+ if none. - But returns no more than limit+1 bytes. For all forms above, trailing optional keyword arguments may be given; see {Getline Options}[#class-IO-label-Getline+Options]: f = File.open('t.txt') # Chomp the lines. f.gets(chomp: true) # => "This is line one." f.gets(chomp: true) # => "This is the second line." f.gets(chomp: true) # => "This is the third line." f.gets(chomp: true) # => nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I"#gets(sep = $/, **getline_opts);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@T;![;"I"@return [String, nil];T;#0;$@T;.F;Bi;C0;7[[I"sep;TI"$/;T[I"**getline_opts;T0;$@To;= ;>I" overload;F;?0;;;@0;:I" gets(limit, **getline_opts);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@T;![;"I"@return [String, nil];T;#0;$@T;.F;Bi;C0;7[[I" limit;T0[I"**getline_opts;T0;$@To;= ;>I" overload;F;?0;;;@0;:I"%gets(sep, limit, **getline_opts);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@T;![;"I"@return [String, nil];T;#0;$@T;.F;Bi;C0;7[[I"sep;T0[I" limit;T0[I"**getline_opts;T0;$@T;![;"I" Reads and returns data from the stream; assigns the return value to $_. With no arguments given, returns the next line as determined by line separator $/, or +nil+ if none: f = File.open('t.txt') f.gets # => "This is line one.\n" $_ # => "This is line one.\n" f.gets # => "This is the second line.\n" f.gets # => "This is the third line.\n" f.gets # => nil With string argument +sep+ given, but not argument +limit+, returns the next line as determined by line separator +sep+, or +nil+ if none: f = File.open('t.txt') f.gets(' is') # => "This is" f.gets(' is') # => " line one.\nThis is" f.gets(' is') # => " the second line.\nThis is" f.gets(' is') # => " the third line.\n" f.gets(' is') # => nil Note two special values for +sep+: - +nil+: The entire stream is read and returned. - '' (empty string): The next "paragraph" is read and returned, the paragraph separator being two successive line separators. With integer argument +limit+ given, returns up to limit+1 bytes: # Text with 1-byte characters. File.open('t.txt') {|f| f.gets(1) } # => "T" File.open('t.txt') {|f| f.gets(2) } # => "Th" File.open('t.txt') {|f| f.gets(3) } # => "Thi" File.open('t.txt') {|f| f.gets(4) } # => "This" # No more than one line. File.open('t.txt') {|f| f.gets(17) } # => "This is line one." File.open('t.txt') {|f| f.gets(18) } # => "This is line one.\n" File.open('t.txt') {|f| f.gets(19) } # => "This is line one.\n" # Text with 2-byte characters, which will not be split. File.open('t.rus') {|f| f.gets(1).size } # => 1 File.open('t.rus') {|f| f.gets(2).size } # => 1 File.open('t.rus') {|f| f.gets(3).size } # => 2 File.open('t.rus') {|f| f.gets(4).size } # => 2 With arguments +sep+ and +limit+, combines the two behaviors above: - Returns the next line as determined by line separator +sep+, or +nil+ if none. - But returns no more than limit+1 bytes. For all forms above, trailing optional keyword arguments may be given; see {Getline Options}[#class-IO-label-Getline+Options]: f = File.open('t.txt') # Chomp the lines. f.gets(chomp: true) # => "This is line one." f.gets(chomp: true) # => "This is the second line." f.gets(chomp: true) # => "This is the third line." f.gets(chomp: true) # => nil @overload gets(sep = $/, **getline_opts) @return [String, nil] @overload gets(limit, **getline_opts) @return [String, nil] @overload gets(sep, limit, **getline_opts) @return [String, nil];T;#0;$@T;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE rb_io_gets_m(int argc, VALUE *argv, VALUE io) { VALUE str; str = rb_io_getline(argc, argv, io); rb_lastline_set(str); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#readline;F;7[[@90;[[@Ti;T;;;0;[;{;IC; "IReads a line as with IO#gets, but raises an EOFError on end of file. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"&readline(sep=$/ [, getline_args]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@U;![;"I"@return [String];T;#0;$@U;.F;Bi;C0;7[[I"sep;TI"$/[, getline_args];T;$@Uo;= ;>I" overload;F;?0;;;@0;:I"%readline(limit [, getline_args]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@U;![;"I"@return [String];T;#0;$@U;.F;Bi;C0;7[[I"limit[, getline_args];T0;$@Uo;= ;>I" overload;F;?0;;;@0;:I"*readline(sep, limit [, getline_args]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@U;![;"I"@return [String];T;#0;$@U;.F;Bi;C0;7[[I"sep;T0[I"limit[, getline_args];T0;$@U;![;"I"Reads a line as with IO#gets, but raises an EOFError on end of file. @overload readline(sep=$/ [, getline_args]) @return [String] @overload readline(limit [, getline_args]) @return [String] @overload readline(sep, limit [, getline_args]) @return [String];T;#0;$@U;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE rb_io_readline(int argc, VALUE *argv, VALUE io) { VALUE line = rb_io_gets_m(argc, argv, io); if (NIL_P(line)) { rb_eof_error(); } return line; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#getc;F;7[;[[@Ti;T;: getc;0;[;{;IC; "Reads a one-character string from ios. Returns +nil+ if called at end of file. f = File.new("testfile") f.getc #=> "h" f.getc #=> "e" ;T;[o;= ;>I" overload;F;?0;;;@0;:I" getc;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@BU;![;"I"@return [String, nil];T;#0;$@BU;.F;Bi;C0;7[;$@BU;![;"I"Reads a one-character string from ios. Returns +nil+ if called at end of file. f = File.new("testfile") f.getc #=> "h" f.getc #=> "e" @overload getc @return [String, nil];T;#0;$@BU;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE rb_io_getc(VALUE io) { rb_io_t *fptr; rb_encoding *enc; GetOpenFile(io, fptr); rb_io_check_char_readable(fptr); enc = io_input_encoding(fptr); READ_CHECK(fptr); return io_getc(fptr, enc); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#getbyte;F;7[;[[@Ti;T;;;0;[;{;IC; "Gets the next 8-bit byte (0..255) from ios. Returns +nil+ if called at end of file. f = File.new("testfile") f.getbyte #=> 84 f.getbyte #=> 104 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" getbyte;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@^U;![;"I"@return [Integer, nil];T;#0;$@^U;.F;Bi;C0;7[;$@^U;![;"I"Gets the next 8-bit byte (0..255) from ios. Returns +nil+ if called at end of file. f = File.new("testfile") f.getbyte #=> 84 f.getbyte #=> 104 @overload getbyte @return [Integer, nil];T;#0;$@^U;.F;/o;0;1T;2i;3i;%@kL;9I"\VALUE rb_io_getbyte(VALUE io) { rb_io_t *fptr; int c; GetOpenFile(io, fptr); rb_io_check_byte_readable(fptr); READ_CHECK(fptr); VALUE r_stdout = rb_ractor_stdout(); if (fptr->fd == 0 && (fptr->mode & FMODE_TTY) && RB_TYPE_P(r_stdout, T_FILE)) { rb_io_t *ofp; GetOpenFile(r_stdout, ofp); if (ofp->mode & FMODE_TTY) { rb_io_flush(r_stdout); } } if (io_fillbuf(fptr) < 0) { return Qnil; } fptr->rbuf.off++; fptr->rbuf.len--; c = (unsigned char)fptr->rbuf.ptr[fptr->rbuf.off-1]; return INT2FIX(c & 0xff); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"IO#readchar;F;7[;[[@Ti;T;: readchar;0;[;{;IC; "Reads a one-character string from ios. Raises an EOFError on end of file. f = File.new("testfile") f.readchar #=> "h" f.readchar #=> "e" ;T;[o;= ;>I" overload;F;?0;;;@0;:I" readchar;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@zU;![;"I"@return [String];T;#0;$@zU;.F;Bi;C0;7[;$@zU;![;"I"Reads a one-character string from ios. Raises an EOFError on end of file. f = File.new("testfile") f.readchar #=> "h" f.readchar #=> "e" @overload readchar @return [String];T;#0;$@zU;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE rb_io_readchar(VALUE io) { VALUE c = rb_io_getc(io); if (NIL_P(c)) { rb_eof_error(); } return c; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#readbyte;F;7[;[[@Ti;T;: readbyte;0;[;{;IC; "LReads a byte as with IO#getbyte, but raises an EOFError on end of file. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" readbyte;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@U;![;"I"@return [Integer];T;#0;$@U;.F;Bi;C0;7[;$@U;![;"I"uReads a byte as with IO#getbyte, but raises an EOFError on end of file. @overload readbyte @return [Integer];T;#0;$@U;.F;/o;0;1T;2i;3i ;%@kL;9I"static VALUE rb_io_readbyte(VALUE io) { VALUE c = rb_io_getbyte(io); if (NIL_P(c)) { rb_eof_error(); } return c; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#ungetbyte;F;7[[I"b;T0;[[@Ti?;T;:ungetbyte;0;[;{;IC; "dPushes back bytes (passed as a parameter) onto ios, such that a subsequent buffered read will return it. It is only guaranteed to support a single byte, and only if ungetbyte or ungetc has not already been called on ios since the previous read of at least a single byte from ios. However, it can support additional bytes if there is space in the internal buffer to allow for it. f = File.new("testfile") #=> # b = f.getbyte #=> 0x38 f.ungetbyte(b) #=> nil f.getbyte #=> 0x38 If given an integer, only uses the lower 8 bits of the integer as the byte to push. f = File.new("testfile") #=> # f.ungetbyte(0x102) #=> nil f.getbyte #=> 0x2 Calling this method prepends to the existing buffer, even if the method has already been called previously: f = File.new("testfile") #=> # f.ungetbyte("ab") #=> nil f.ungetbyte("cd") #=> nil f.read(5) #=> "cdab8" Has no effect with unbuffered reads (such as IO#sysread). ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ungetbyte(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@U;![;"I"@return [nil];T;#0;$@U;.F;Bi;C0;7[[I" string;T0;$@Uo;= ;>I" overload;F;?0;;;@0;:I"ungetbyte(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@U;![;"I"@return [nil];T;#0;$@U;.F;Bi;C0;7[[I" integer;T0;$@U;![;"I"Pushes back bytes (passed as a parameter) onto ios, such that a subsequent buffered read will return it. It is only guaranteed to support a single byte, and only if ungetbyte or ungetc has not already been called on ios since the previous read of at least a single byte from ios. However, it can support additional bytes if there is space in the internal buffer to allow for it. f = File.new("testfile") #=> # b = f.getbyte #=> 0x38 f.ungetbyte(b) #=> nil f.getbyte #=> 0x38 If given an integer, only uses the lower 8 bits of the integer as the byte to push. f = File.new("testfile") #=> # f.ungetbyte(0x102) #=> nil f.getbyte #=> 0x2 Calling this method prepends to the existing buffer, even if the method has already been called previously: f = File.new("testfile") #=> # f.ungetbyte("ab") #=> nil f.ungetbyte("cd") #=> nil f.read(5) #=> "cdab8" Has no effect with unbuffered reads (such as IO#sysread). @overload ungetbyte(string) @return [nil] @overload ungetbyte(integer) @return [nil];T;#0;$@U;.F;/o;0;1T;2i;3i=;%@kL;9I"VALUE rb_io_ungetbyte(VALUE io, VALUE b) { rb_io_t *fptr; GetOpenFile(io, fptr); rb_io_check_byte_readable(fptr); switch (TYPE(b)) { case T_NIL: return Qnil; case T_FIXNUM: case T_BIGNUM: ; VALUE v = rb_int_modulo(b, INT2FIX(256)); unsigned char c = NUM2INT(v) & 0xFF; b = rb_str_new((const char *)&c, 1); break; default: SafeStringValue(b); } io_ungetbyte(b, fptr); return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"IO#ungetc;F;7[[I"c;T0;[[@Tiv;T;: ungetc;0;[;{;IC; "Pushes back characters (passed as a parameter) onto ios, such that a subsequent buffered read will return it. It is only guaranteed to support a single byte, and only if ungetbyte or ungetc has not already been called on ios since the previous read of at least a single byte from ios. However, it can support additional bytes if there is space in the internal buffer to allow for it. f = File.new("testfile") #=> # c = f.getc #=> "8" f.ungetc(c) #=> nil f.getc #=> "8" If given an integer, the integer must represent a valid codepoint in the external encoding of ios. Calling this method prepends to the existing buffer, even if the method has already been called previously: f = File.new("testfile") #=> # f.ungetc("ab") #=> nil f.ungetc("cd") #=> nil f.read(5) #=> "cdab8" Has no effect with unbuffered reads (such as IO#sysread). ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ungetc(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@U;![;"I"@return [nil];T;#0;$@U;.F;Bi;C0;7[[I" integer;T0;$@Uo;= ;>I" overload;F;?0;;;@0;:I"ungetc(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@U;![;"I"@return [nil];T;#0;$@U;.F;Bi;C0;7[[I" string;T0;$@U;![;"I"TPushes back characters (passed as a parameter) onto ios, such that a subsequent buffered read will return it. It is only guaranteed to support a single byte, and only if ungetbyte or ungetc has not already been called on ios since the previous read of at least a single byte from ios. However, it can support additional bytes if there is space in the internal buffer to allow for it. f = File.new("testfile") #=> # c = f.getc #=> "8" f.ungetc(c) #=> nil f.getc #=> "8" If given an integer, the integer must represent a valid codepoint in the external encoding of ios. Calling this method prepends to the existing buffer, even if the method has already been called previously: f = File.new("testfile") #=> # f.ungetc("ab") #=> nil f.ungetc("cd") #=> nil f.read(5) #=> "cdab8" Has no effect with unbuffered reads (such as IO#sysread). @overload ungetc(integer) @return [nil] @overload ungetc(string) @return [nil];T;#0;$@U;.F;/o;0;1T;2iV;3it;%@kL;9I"VALUE rb_io_ungetc(VALUE io, VALUE c) { rb_io_t *fptr; long len; GetOpenFile(io, fptr); rb_io_check_char_readable(fptr); if (FIXNUM_P(c)) { c = rb_enc_uint_chr(FIX2UINT(c), io_read_encoding(fptr)); } else if (RB_BIGNUM_TYPE_P(c)) { c = rb_enc_uint_chr(NUM2UINT(c), io_read_encoding(fptr)); } else { SafeStringValue(c); } if (NEED_READCONV(fptr)) { SET_BINARY_MODE(fptr); len = RSTRING_LEN(c); #if SIZEOF_LONG > SIZEOF_INT if (len > INT_MAX) rb_raise(rb_eIOError, "ungetc failed"); #endif make_readconv(fptr, (int)len); if (fptr->cbuf.capa - fptr->cbuf.len < len) rb_raise(rb_eIOError, "ungetc failed"); if (fptr->cbuf.off < len) { MEMMOVE(fptr->cbuf.ptr+fptr->cbuf.capa-fptr->cbuf.len, fptr->cbuf.ptr+fptr->cbuf.off, char, fptr->cbuf.len); fptr->cbuf.off = fptr->cbuf.capa-fptr->cbuf.len; } fptr->cbuf.off -= (int)len; fptr->cbuf.len += (int)len; MEMMOVE(fptr->cbuf.ptr+fptr->cbuf.off, RSTRING_PTR(c), char, len); } else { NEED_NEWLINE_DECORATOR_ON_READ_CHECK(fptr); io_ungetbyte(c, fptr); } return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I" IO#<<;F;7[[I"str;T0;[[@Ti=;T;;;0;[;{;IC; "9Writes the given +object+ to +self+, which must be opened for writing (see {Modes}[#class-IO-label-Modes]); returns +self+; if +object+ is not a string, it is converted via method +to_s+: $stdout << 'Hello' << ', ' << 'World!' << "\n" $stdout << 'foo' << :bar << 2 << "\n" Output: Hello, World! foobar2 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"<<(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@ V;![;"I"@return [self];T;#0;$@ V;.F;Bi;C0;7[[I" object;T0;$@ V;![;"I"bWrites the given +object+ to +self+, which must be opened for writing (see {Modes}[#class-IO-label-Modes]); returns +self+; if +object+ is not a string, it is converted via method +to_s+: $stdout << 'Hello' << ', ' << 'World!' << "\n" $stdout << 'foo' << :bar << 2 << "\n" Output: Hello, World! foobar2 @overload <<(object) @return [self];T;#0;$@ V;.F;/o;0;1T;2i);3i9;%@kL;9I"YVALUE rb_io_addstr(VALUE io, VALUE str) { rb_io_write(io, str); return io; };T;:I" VALUE;T;;To;4;5F;6;;;;&I" IO#flush;F;7[;[[@Tiu;T;: flush;0;[;{;IC; "Flushes data buffered in +self+ to the operating system (but does not necessarily flush data buffered in the operating system): $stdout.print 'no newline' # Not necessarily flushed. $stdout.flush # Flushed. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" flush;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@+V;![;"I"@return [self];T;#0;$@+V;.F;Bi;C0;7[;$@+V;![;"I"Flushes data buffered in +self+ to the operating system (but does not necessarily flush data buffered in the operating system): $stdout.print 'no newline' # Not necessarily flushed. $stdout.flush # Flushed. @overload flush @return [self];T;#0;$@+V;.F;/o;0;1T;2ii;3ir;%@kL;9I"GVALUE rb_io_flush(VALUE io) { return rb_io_flush_raw(io, 1); };T;:I" VALUE;T;;To;4;5F;6;;;;&I" IO#tell;F;7[;[[@Ti;T;: tell;0;[;{;IC; "Returns the current position (in bytes) in +self+ (see {Position}[#class-IO-label-Position]): f = File.new('t.txt') f.tell # => 0 f.readline # => "This is line one.\n" f.tell # => 19 Related: IO#pos=, IO#seek. IO#pos is an alias for IO#tell. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" tell;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@FV;![;"I"@return [Integer];T;#0;$@FV;.F;Bi;C0;7[;$@FV;![;"I"*Returns the current position (in bytes) in +self+ (see {Position}[#class-IO-label-Position]): f = File.new('t.txt') f.tell # => 0 f.readline # => "This is line one.\n" f.tell # => 19 Related: IO#pos=, IO#seek. IO#pos is an alias for IO#tell. @overload tell @return [Integer];T;#0;$@FV;.F;/o;0;1T;2i{;3i;%@kL;9I"static VALUE rb_io_tell(VALUE io) { rb_io_t *fptr; off_t pos; GetOpenFile(io, fptr); pos = io_tell(fptr); if (pos < 0 && errno) rb_sys_fail_path(fptr->pathv); pos -= fptr->rbuf.len; return OFFT2NUM(pos); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#seek;F;7[[@90;[[@Ti;T;: seek;0;[;{;IC; ""Seeks to the position given by integer +offset+ (see {Position}[#class-IO-label-Position]) and constant +whence+, which is one of: - +:CUR+ or IO::SEEK_CUR: Repositions the stream to its current position plus the given +offset+: f = File.open('t.txt') f.tell # => 0 f.seek(20, :CUR) # => 0 f.tell # => 20 f.seek(-10, :CUR) # => 0 f.tell # => 10 - +:END+ or IO::SEEK_END: Repositions the stream to its end plus the given +offset+: f = File.open('t.txt') f.tell # => 0 f.seek(0, :END) # => 0 # Repositions to stream end. f.tell # => 70 f.seek(-20, :END) # => 0 f.tell # => 50 f.seek(-40, :END) # => 0 f.tell # => 30 - +:SET+ or IO:SEEK_SET: Repositions the stream to the given +offset+: f = File.open('t.txt') f.tell # => 0 f.seek(20, :SET) # => 0 f.tell # => 20 f.seek(40, :SET) # => 0 f.tell # => 40 Related: IO#pos=, IO#tell. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"(seek(offset, whence = IO::SEEK_SET);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@aV;![;"I"@return [0];T;#0;$@aV;.F;Bi;C0;7[[I" offset;T0[I" whence;TI"IO::SEEK_SET;T;$@aV;![;"I"aSeeks to the position given by integer +offset+ (see {Position}[#class-IO-label-Position]) and constant +whence+, which is one of: - +:CUR+ or IO::SEEK_CUR: Repositions the stream to its current position plus the given +offset+: f = File.open('t.txt') f.tell # => 0 f.seek(20, :CUR) # => 0 f.tell # => 20 f.seek(-10, :CUR) # => 0 f.tell # => 10 - +:END+ or IO::SEEK_END: Repositions the stream to its end plus the given +offset+: f = File.open('t.txt') f.tell # => 0 f.seek(0, :END) # => 0 # Repositions to stream end. f.tell # => 70 f.seek(-20, :END) # => 0 f.tell # => 50 f.seek(-40, :END) # => 0 f.tell # => 30 - +:SET+ or IO:SEEK_SET: Repositions the stream to the given +offset+: f = File.open('t.txt') f.tell # => 0 f.seek(20, :SET) # => 0 f.tell # => 20 f.seek(40, :SET) # => 0 f.tell # => 40 Related: IO#pos=, IO#tell. @overload seek(offset, whence = IO::SEEK_SET) @return [0];T;#0;$@aV;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE rb_io_seek_m(int argc, VALUE *argv, VALUE io) { VALUE offset, ptrname; int whence = SEEK_SET; if (rb_scan_args(argc, argv, "11", &offset, &ptrname) == 2) { whence = interpret_seek_whence(ptrname); } return rb_io_seek(io, offset, whence); };T;:I"static VALUE;T;;To;u;[[@Ti7;F;: SEEK_SET;;w;;;[;{;IC; "(Set I/O position from the beginning ;T;[;![;"I"(Set I/O position from the beginning;T;#0;$@V;.F;/o;0;1T;2i7;3i7;%@kL;&I"IO::SEEK_SET;F;xI"INT2FIX(SEEK_SET);To;u;[[@Ti7;F;: SEEK_CUR;;w;;;[;{;IC; "/Set I/O position from the current position ;T;[;![;"I"/Set I/O position from the current position;T;#0;$@V;.F;/o;0;1T;2i7;3i7;%@kL;&I"IO::SEEK_CUR;F;xI"INT2FIX(SEEK_CUR);To;u;[[@Ti7;F;: SEEK_END;;w;;;[;{;IC; ""Set I/O position from the end ;T;[;![;"I""Set I/O position from the end;T;#0;$@V;.F;/o;0;1T;2i7;3i7;%@kL;&I"IO::SEEK_END;F;xI"INT2FIX(SEEK_END);To;u;[[@Ti7;F;:SEEK_DATA;;w;;;[;{;IC; ":Set I/O position to the next location containing data ;T;[;![;"I":Set I/O position to the next location containing data;T;#0;$@V;.F;/o;0;1T;2i7;3i7;%@kL;&I"IO::SEEK_DATA;F;xI"INT2FIX(SEEK_DATA);To;u;[[@Ti7;F;:SEEK_HOLE;;w;;;[;{;IC; "&Set I/O position to the next hole ;T;[;![;"I"&Set I/O position to the next hole;T;#0;$@V;.F;/o;0;1T;2i7;3i7;%@kL;&I"IO::SEEK_HOLE;F;xI"INT2FIX(SEEK_HOLE);To;4;5F;6;;;;&I"IO#rewind;F;7[;[[@Ti, ;T;: rewind;0;[;{;IC; "Repositions the stream to its beginning, setting both the position and the line number to zero; see {Position}[#class-IO-label-Position] and {Line Number}[#class-IO-label-Line+Number]: f = File.open('t.txt') f.tell # => 0 f.lineno # => 0 f.readline # => "This is line one.\n" f.tell # => 19 f.lineno # => 1 f.rewind # => 0 f.tell # => 0 f.lineno # => 0 Note that this method cannot be used with streams such as pipes, ttys, and sockets. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" rewind;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@V;![;"I"@return [0];T;#0;$@V;.F;Bi;C0;7[;$@V;![;"I"Repositions the stream to its beginning, setting both the position and the line number to zero; see {Position}[#class-IO-label-Position] and {Line Number}[#class-IO-label-Line+Number]: f = File.open('t.txt') f.tell # => 0 f.lineno # => 0 f.readline # => "This is line one.\n" f.tell # => 19 f.lineno # => 1 f.rewind # => 0 f.tell # => 0 f.lineno # => 0 Note that this method cannot be used with streams such as pipes, ttys, and sockets. @overload rewind @return [0];T;#0;$@V;.F;/o;0;1T;2i ;3i) ;%@kL;9I"Lstatic VALUE rb_io_rewind(VALUE io) { rb_io_t *fptr; GetOpenFile(io, fptr); if (io_seek(fptr, 0L, 0) < 0 && errno) rb_sys_fail_path(fptr->pathv); if (io == ARGF.current_file) { ARGF.lineno -= fptr->lineno; } fptr->lineno = 0; if (fptr->readconv) { clear_readconv(fptr); } return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#pos;F;7[;[[@Ti;T;;;0;[;{;IC; "Returns the current position (in bytes) in +self+ (see {Position}[#class-IO-label-Position]): f = File.new('t.txt') f.tell # => 0 f.readline # => "This is line one.\n" f.tell # => 19 Related: IO#pos=, IO#seek. IO#pos is an alias for IO#tell. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" tell;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@V;![;"I"@return [Integer];T;#0;$@V;.F;Bi;C0;7[;$@V;![;"@]V;#0;$@V;.F;/o;0;1T;2i{;3i;%@kL;9I"static VALUE rb_io_tell(VALUE io) { rb_io_t *fptr; off_t pos; GetOpenFile(io, fptr); pos = io_tell(fptr); if (pos < 0 && errno) rb_sys_fail_path(fptr->pathv); pos -= fptr->rbuf.len; return OFFT2NUM(pos); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#pos=;F;7[[I" offset;T0;[[@Ti ;T;;;0;[;{;IC; "Seeks to the given +new_position+ (in bytes); see {Position}[#class-IO-label-Position]: f = File.open('t.txt') f.tell # => 0 f.pos = 20 # => 20 f.tell # => 20 Related: IO#seek, IO#tell. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"pos=(new_position);T;IC; ";T;[;![;"I";T;#0;$@V;.F;Bi;C0;7[[I"new_position;T0;$@V;![;"I"Seeks to the given +new_position+ (in bytes); see {Position}[#class-IO-label-Position]: f = File.open('t.txt') f.tell # => 0 f.pos = 20 # => 20 f.tell # => 20 Related: IO#seek, IO#tell. @overload pos=(new_position);T;#0;$@V;.F;/o;0;1T;2i;3i ;%@kL;9I" static VALUE rb_io_set_pos(VALUE io, VALUE offset) { rb_io_t *fptr; off_t pos; pos = NUM2OFFT(offset); GetOpenFile(io, fptr); pos = io_seek(fptr, pos, SEEK_SET); if (pos < 0 && errno) rb_sys_fail_path(fptr->pathv); return OFFT2NUM(pos); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#eof;F;7[;[[@Ti ;T;:eof;0;[;{;IC; "Returns +true+ if the stream is positioned at its end, +false+ otherwise; see {Position}[#class-IO-label-Position]: f = File.open('t.txt') f.eof # => false f.seek(0, :END) # => 0 f.eof # => true Raises an exception unless the stream is opened for reading; see {Mode}[#class-IO-label-Mode]. If +self+ is a stream such as pipe or socket, this method blocks until the other end sends some data or closes it: r, w = IO.pipe Thread.new { sleep 1; w.close } r.eof? # => true # After 1-second wait. r, w = IO.pipe Thread.new { sleep 1; w.puts "a" } r.eof? # => false # After 1-second wait. r, w = IO.pipe r.eof? # blocks forever Note that this method reads data to the input byte buffer. So IO#sysread may not behave as you intend with IO#eof?, unless you call IO#rewind first (which is not available for some streams). I#eof? is an alias for IO#eof. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"eof;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ W;![;"I"@return [Boolean];T;#0;$@ W;.F;Bi;C0;7[;$@ W;![;"I"Returns +true+ if the stream is positioned at its end, +false+ otherwise; see {Position}[#class-IO-label-Position]: f = File.open('t.txt') f.eof # => false f.seek(0, :END) # => 0 f.eof # => true Raises an exception unless the stream is opened for reading; see {Mode}[#class-IO-label-Mode]. If +self+ is a stream such as pipe or socket, this method blocks until the other end sends some data or closes it: r, w = IO.pipe Thread.new { sleep 1; w.close } r.eof? # => true # After 1-second wait. r, w = IO.pipe Thread.new { sleep 1; w.puts "a" } r.eof? # => false # After 1-second wait. r, w = IO.pipe r.eof? # blocks forever Note that this method reads data to the input byte buffer. So IO#sysread may not behave as you intend with IO#eof?, unless you call IO#rewind first (which is not available for some streams). I#eof? is an alias for IO#eof. @overload eof @return [Boolean];T;#0;$@ W;.F;/o;0;1T;2ip ;3i ;%@kL;9I"VALUE rb_io_eof(VALUE io) { rb_io_t *fptr; GetOpenFile(io, fptr); rb_io_check_char_readable(fptr); if (READ_CHAR_PENDING(fptr)) return Qfalse; if (READ_DATA_PENDING(fptr)) return Qfalse; READ_CHECK(fptr); #if RUBY_CRLF_ENVIRONMENT if (!NEED_READCONV(fptr) && NEED_NEWLINE_DECORATOR_ON_READ(fptr)) { return RBOOL(eof(fptr->fd));; } #endif return RBOOL(io_fillbuf(fptr) < 0); };T;:I" VALUE;T;;To;4;5F;6;;;;&I" IO#eof?;F;7[;[[@Ti ;T;: eof?;0;[;{;IC; "Returns +true+ if the stream is positioned at its end, +false+ otherwise; see {Position}[#class-IO-label-Position]: f = File.open('t.txt') f.eof # => false f.seek(0, :END) # => 0 f.eof # => true Raises an exception unless the stream is opened for reading; see {Mode}[#class-IO-label-Mode]. If +self+ is a stream such as pipe or socket, this method blocks until the other end sends some data or closes it: r, w = IO.pipe Thread.new { sleep 1; w.close } r.eof? # => true # After 1-second wait. r, w = IO.pipe Thread.new { sleep 1; w.puts "a" } r.eof? # => false # After 1-second wait. r, w = IO.pipe r.eof? # blocks forever Note that this method reads data to the input byte buffer. So IO#sysread may not behave as you intend with IO#eof?, unless you call IO#rewind first (which is not available for some streams). I#eof? is an alias for IO#eof.;T;[o;= ;>I" overload;F;?0;;;@0;:I"eof;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@(W;![;"I"@return [Boolean];T;#0;$@(W;.F;Bi;C0;7[;$@(W;![;"@$W;#0;$@(W;.F;/o;0;1T;2ip ;3i ;Bi;%@kL;9I"VALUE rb_io_eof(VALUE io) { rb_io_t *fptr; GetOpenFile(io, fptr); rb_io_check_char_readable(fptr); if (READ_CHAR_PENDING(fptr)) return Qfalse; if (READ_DATA_PENDING(fptr)) return Qfalse; READ_CHECK(fptr); #if RUBY_CRLF_ENVIRONMENT if (!NEED_READCONV(fptr) && NEED_NEWLINE_DECORATOR_ON_READ(fptr)) { return RBOOL(eof(fptr->fd));; } #endif return RBOOL(io_fillbuf(fptr) < 0); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"IO#close_on_exec?;F;7[;[[@Ti;T;:close_on_exec?;0;[;{;IC; "Returns true if ios will be closed on exec. f = open("/dev/null") f.close_on_exec? #=> false f.close_on_exec = true f.close_on_exec? #=> true f.close_on_exec = false f.close_on_exec? #=> false;T;[o;= ;>I" overload;F;?0;;;@0;:I"close_on_exec?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@BW;![;"I"@return [Boolean];T;#0;$@BW;.F;Bi;C0;7[;$@BW;![;"I"HReturns true if ios will be closed on exec. f = open("/dev/null") f.close_on_exec? #=> false f.close_on_exec = true f.close_on_exec? #=> true f.close_on_exec = false f.close_on_exec? #=> false @overload close_on_exec? @return [Boolean];T;#0;$@BW;.F;/o;0;1T;2i;3i;Bi;%@kL;9I"astatic VALUE rb_io_close_on_exec_p(VALUE io) { rb_io_t *fptr; VALUE write_io; int fd, ret; write_io = GetWriteIO(io); if (io != write_io) { GetOpenFile(write_io, fptr); if (fptr && 0 <= (fd = fptr->fd)) { if ((ret = fcntl(fd, F_GETFD)) == -1) rb_sys_fail_path(fptr->pathv); if (!(ret & FD_CLOEXEC)) return Qfalse; } } GetOpenFile(io, fptr); if (fptr && 0 <= (fd = fptr->fd)) { if ((ret = fcntl(fd, F_GETFD)) == -1) rb_sys_fail_path(fptr->pathv); if (!(ret & FD_CLOEXEC)) return Qfalse; } return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#close_on_exec=;F;7[[I"arg;T0;[[@Ti;T;:close_on_exec=;0;[;{;IC; "FSets a close-on-exec flag. f = open("/dev/null") f.close_on_exec = true system("cat", "/proc/self/fd/#{f.fileno}") # cat: /proc/self/fd/3: No such file or directory f.closed? #=> false Ruby sets close-on-exec flags of all file descriptors by default since Ruby 2.0.0. So you don't need to set by yourself. Also, unsetting a close-on-exec flag can cause file descriptor leak if another thread use fork() and exec() (via system() method for example). If you really needs file descriptor inheritance to child process, use spawn()'s argument such as fd=>fd. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"close_on_exec=(bool);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@]W;![;"I"@return [Boolean];T;#0;$@]W;.F;Bi;C0;7[[I" bool;T0;$@]W;![;"I"{Sets a close-on-exec flag. f = open("/dev/null") f.close_on_exec = true system("cat", "/proc/self/fd/#{f.fileno}") # cat: /proc/self/fd/3: No such file or directory f.closed? #=> false Ruby sets close-on-exec flags of all file descriptors by default since Ruby 2.0.0. So you don't need to set by yourself. Also, unsetting a close-on-exec flag can cause file descriptor leak if another thread use fork() and exec() (via system() method for example). If you really needs file descriptor inheritance to child process, use spawn()'s argument such as fd=>fd. @overload close_on_exec=(bool) @return [Boolean];T;#0;$@]W;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE rb_io_set_close_on_exec(VALUE io, VALUE arg) { int flag = RTEST(arg) ? FD_CLOEXEC : 0; rb_io_t *fptr; VALUE write_io; int fd, ret; write_io = GetWriteIO(io); if (io != write_io) { GetOpenFile(write_io, fptr); if (fptr && 0 <= (fd = fptr->fd)) { if ((ret = fcntl(fptr->fd, F_GETFD)) == -1) rb_sys_fail_path(fptr->pathv); if ((ret & FD_CLOEXEC) != flag) { ret = (ret & ~FD_CLOEXEC) | flag; ret = fcntl(fd, F_SETFD, ret); if (ret != 0) rb_sys_fail_path(fptr->pathv); } } } GetOpenFile(io, fptr); if (fptr && 0 <= (fd = fptr->fd)) { if ((ret = fcntl(fd, F_GETFD)) == -1) rb_sys_fail_path(fptr->pathv); if ((ret & FD_CLOEXEC) != flag) { ret = (ret & ~FD_CLOEXEC) | flag; ret = fcntl(fd, F_SETFD, ret); if (ret != 0) rb_sys_fail_path(fptr->pathv); } } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#close;F;7[;[[@Ti;T;;;0;[;{;IC; "Closes ios and flushes any pending writes to the operating system. The stream is unavailable for any further data operations; an IOError is raised if such an attempt is made. I/O streams are automatically closed when they are claimed by the garbage collector. If ios is opened by IO.popen, #close sets $?. Calling this method on closed IO object is just ignored since Ruby 2.3. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" close;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@|W;![;"I"@return [nil];T;#0;$@|W;.F;Bi;C0;7[;$@|W;![;"I"Closes ios and flushes any pending writes to the operating system. The stream is unavailable for any further data operations; an IOError is raised if such an attempt is made. I/O streams are automatically closed when they are claimed by the garbage collector. If ios is opened by IO.popen, #close sets $?. Calling this method on closed IO object is just ignored since Ruby 2.3. @overload close @return [nil];T;#0;$@|W;.F;/o;0;1T;2i};3i;%@kL;9I"static VALUE rb_io_close_m(VALUE io) { rb_io_t *fptr = rb_io_get_fptr(io); if (fptr->fd < 0) { return Qnil; } rb_io_close(io); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#closed?;F;7[;[[@Ti;T;;\;0;[;{;IC; "mReturns true if ios is completely closed (for duplex streams, both reader and writer), false otherwise. f = File.new("testfile") f.close #=> nil f.closed? #=> true f = IO.popen("/bin/sh","r+") f.close_write #=> nil f.closed? #=> false f.close_read #=> nil f.closed? #=> true;T;[o;= ;>I" overload;F;?0;;\;@0;:I" closed?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@W;![;"I"@return [Boolean];T;#0;$@W;.F;Bi;C0;7[;$@W;![;"I"Returns true if ios is completely closed (for duplex streams, both reader and writer), false otherwise. f = File.new("testfile") f.close #=> nil f.closed? #=> true f = IO.popen("/bin/sh","r+") f.close_write #=> nil f.closed? #=> false f.close_read #=> nil f.closed? #=> true @overload closed? @return [Boolean];T;#0;$@W;.F;/o;0;1T;2i;3i;Bi;%@kL;9I"istatic VALUE rb_io_closed(VALUE io) { rb_io_t *fptr; VALUE write_io; rb_io_t *write_fptr; write_io = GetWriteIO(io); if (io != write_io) { write_fptr = RFILE(write_io)->fptr; if (write_fptr && 0 <= write_fptr->fd) { return Qfalse; } } fptr = rb_io_get_fptr(io); return RBOOL(0 > fptr->fd); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#close_read;F;7[;[[@Ti;T;:close_read;0;[;{;IC; "Closes the read end of a duplex I/O stream (i.e., one that contains both a read and a write stream, such as a pipe). Will raise an IOError if the stream is not duplexed. f = IO.popen("/bin/sh","r+") f.close_read f.readlines produces: prog.rb:3:in `readlines': not opened for reading (IOError) from prog.rb:3 Calling this method on closed IO object is just ignored since Ruby 2.3. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"close_read;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@W;![;"I"@return [nil];T;#0;$@W;.F;Bi;C0;7[;$@W;![;"I"Closes the read end of a duplex I/O stream (i.e., one that contains both a read and a write stream, such as a pipe). Will raise an IOError if the stream is not duplexed. f = IO.popen("/bin/sh","r+") f.close_read f.readlines produces: prog.rb:3:in `readlines': not opened for reading (IOError) from prog.rb:3 Calling this method on closed IO object is just ignored since Ruby 2.3. @overload close_read @return [nil];T;#0;$@W;.F;/o;0;1T;2i;3i;%@kL;9I"cstatic VALUE rb_io_close_read(VALUE io) { rb_io_t *fptr; VALUE write_io; fptr = rb_io_get_fptr(rb_io_taint_check(io)); if (fptr->fd < 0) return Qnil; if (is_socket(fptr->fd, fptr->pathv)) { #ifndef SHUT_RD # define SHUT_RD 0 #endif if (shutdown(fptr->fd, SHUT_RD) < 0) rb_sys_fail_path(fptr->pathv); fptr->mode &= ~FMODE_READABLE; if (!(fptr->mode & FMODE_WRITABLE)) return rb_io_close(io); return Qnil; } write_io = GetWriteIO(io); if (io != write_io) { rb_io_t *wfptr; wfptr = rb_io_get_fptr(rb_io_taint_check(write_io)); wfptr->pid = fptr->pid; fptr->pid = 0; RFILE(io)->fptr = wfptr; /* bind to write_io temporarily to get rid of memory/fd leak */ fptr->tied_io_for_writing = 0; RFILE(write_io)->fptr = fptr; rb_io_fptr_cleanup(fptr, FALSE); /* should not finalize fptr because another thread may be reading it */ return Qnil; } if ((fptr->mode & (FMODE_DUPLEX|FMODE_WRITABLE)) == FMODE_WRITABLE) { rb_raise(rb_eIOError, "closing non-duplex IO for reading"); } return rb_io_close(io); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#close_write;F;7[;[[@Ti-;T;:close_write;0;[;{;IC; "Closes the write end of a duplex I/O stream (i.e., one that contains both a read and a write stream, such as a pipe). Will raise an IOError if the stream is not duplexed. f = IO.popen("/bin/sh","r+") f.close_write f.print "nowhere" produces: prog.rb:3:in `write': not opened for writing (IOError) from prog.rb:3:in `print' from prog.rb:3 Calling this method on closed IO object is just ignored since Ruby 2.3. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"close_write;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@W;![;"I"@return [nil];T;#0;$@W;.F;Bi;C0;7[;$@W;![;"I"Closes the write end of a duplex I/O stream (i.e., one that contains both a read and a write stream, such as a pipe). Will raise an IOError if the stream is not duplexed. f = IO.popen("/bin/sh","r+") f.close_write f.print "nowhere" produces: prog.rb:3:in `write': not opened for writing (IOError) from prog.rb:3:in `print' from prog.rb:3 Calling this method on closed IO object is just ignored since Ruby 2.3. @overload close_write @return [nil];T;#0;$@W;.F;/o;0;1T;2i;3i*;%@kL;9I"7static VALUE rb_io_close_write(VALUE io) { rb_io_t *fptr; VALUE write_io; write_io = GetWriteIO(io); fptr = rb_io_get_fptr(rb_io_taint_check(write_io)); if (fptr->fd < 0) return Qnil; if (is_socket(fptr->fd, fptr->pathv)) { #ifndef SHUT_WR # define SHUT_WR 1 #endif if (shutdown(fptr->fd, SHUT_WR) < 0) rb_sys_fail_path(fptr->pathv); fptr->mode &= ~FMODE_WRITABLE; if (!(fptr->mode & FMODE_READABLE)) return rb_io_close(write_io); return Qnil; } if ((fptr->mode & (FMODE_DUPLEX|FMODE_READABLE)) == FMODE_READABLE) { rb_raise(rb_eIOError, "closing non-duplex IO for writing"); } if (io != write_io) { fptr = rb_io_get_fptr(rb_io_taint_check(io)); fptr->tied_io_for_writing = 0; } rb_io_close(write_io); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#isatty;F;7[;[[@Ti;T;: isatty;0;[;{;IC; "Returns true if ios is associated with a terminal device (tty), false otherwise. File.new("testfile").isatty #=> false File.new("/dev/tty").isatty #=> true ;T;[o;= ;>I" overload;F;?0;;;@0;:I" isatty;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@W;![;"I"@return [Boolean];T;#0;$@W;.F;Bi;C0;7[;$@Wo;= ;>I" overload;F;?0;: tty?;@0;:I" tty?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@W;![;"I"@return [Boolean];T;#0;$@W;.F;Bi;C0;7[;$@W;![;"I"Returns true if ios is associated with a terminal device (tty), false otherwise. File.new("testfile").isatty #=> false File.new("/dev/tty").isatty #=> true @overload isatty @return [Boolean] @overload tty? @return [Boolean];T;#0;$@W;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE rb_io_isatty(VALUE io) { rb_io_t *fptr; GetOpenFile(io, fptr); return RBOOL(isatty(fptr->fd) != 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#tty?;F;7[;[[@Ti;T;;;0;[;{;IC; "Returns true if ios is associated with a terminal device (tty), false otherwise. File.new("testfile").isatty #=> false File.new("/dev/tty").isatty #=> true;T;[o;= ;>I" overload;F;?0;;;@0;:I" isatty;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@X;![;"I"@return [Boolean];T;#0;$@X;.F;Bi;C0;7[;$@Xo;= ;>I" overload;F;?0;;;@0;:I" tty?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@X;![;"I"@return [Boolean];T;#0;$@X;.F;Bi;C0;7[;$@X;![;"@ X;#0;$@X;.F;/o;0;1T;2i;3i;Bi;%@kL;9I"static VALUE rb_io_isatty(VALUE io) { rb_io_t *fptr; GetOpenFile(io, fptr); return RBOOL(isatty(fptr->fd) != 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#binmode;F;7[;[[@Ti;T;: binmode;0;[;{;IC; "Puts ios into binary mode. Once a stream is in binary mode, it cannot be reset to nonbinary mode. - newline conversion disabled - encoding conversion disabled - content is treated as ASCII-8BIT ;T;[o;= ;>I" overload;F;?0;;;@0;:I" binmode;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"IO;T;$@7X;![;"I"@return [IO];T;#0;$@7X;.F;Bi;C0;7[;$@7X;![;"I"Puts ios into binary mode. Once a stream is in binary mode, it cannot be reset to nonbinary mode. - newline conversion disabled - encoding conversion disabled - content is treated as ASCII-8BIT @overload binmode @return [IO];T;#0;$@7X;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE rb_io_binmode_m(VALUE io) { VALUE write_io; rb_io_ascii8bit_binmode(io); write_io = GetWriteIO(io); if (write_io != io) rb_io_ascii8bit_binmode(write_io); return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#binmode?;F;7[;[[@Ti;T;: binmode?;0;[;{;IC; ":Returns true if ios is binmode.;T;[o;= ;>I" overload;F;?0;;;@0;:I" binmode?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@RX;![;"I"@return [Boolean];T;#0;$@RX;.F;Bi;C0;7[;$@RX;![;"I"cReturns true if ios is binmode. @overload binmode? @return [Boolean];T;#0;$@RX;.F;/o;0;1T;2i;3i;Bi;%@kL;9I"static VALUE rb_io_binmode_p(VALUE io) { rb_io_t *fptr; GetOpenFile(io, fptr); return RBOOL(fptr->mode & FMODE_BINMODE); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#sysseek;F;7[[@90;[[@Ti[;T;: sysseek;0;[;{;IC; "Seeks to a given offset in the stream according to the value of whence (see IO#seek for values of whence). Returns the new offset into the file. f = File.new("testfile") f.sysseek(-13, IO::SEEK_END) #=> 53 f.sysread(10) #=> "And so on." ;T;[o;= ;>I" overload;F;?0;;;@0;:I")sysseek(offset, whence=IO::SEEK_SET);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@mX;![;"I"@return [Integer];T;#0;$@mX;.F;Bi;C0;7[[I" offset;T0[I" whence;TI"IO::SEEK_SET;T;$@mX;![;"I"cSeeks to a given offset in the stream according to the value of whence (see IO#seek for values of whence). Returns the new offset into the file. f = File.new("testfile") f.sysseek(-13, IO::SEEK_END) #=> 53 f.sysread(10) #=> "And so on." @overload sysseek(offset, whence=IO::SEEK_SET) @return [Integer];T;#0;$@mX;.F;/o;0;1T;2iN;3iX;%@kL;9I"static VALUE rb_io_sysseek(int argc, VALUE *argv, VALUE io) { VALUE offset, ptrname; int whence = SEEK_SET; rb_io_t *fptr; off_t pos; if (rb_scan_args(argc, argv, "11", &offset, &ptrname) == 2) { whence = interpret_seek_whence(ptrname); } pos = NUM2OFFT(offset); GetOpenFile(io, fptr); if ((fptr->mode & FMODE_READABLE) && (READ_DATA_BUFFERED(fptr) || READ_CHAR_PENDING(fptr))) { rb_raise(rb_eIOError, "sysseek for buffered IO"); } if ((fptr->mode & FMODE_WRITABLE) && fptr->wbuf.len) { rb_warn("sysseek for buffered IO"); } errno = 0; pos = lseek(fptr->fd, pos, whence); if (pos < 0 && errno) rb_sys_fail_path(fptr->pathv); return OFFT2NUM(pos); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#advise;F;7[[@90;[[@Ti&;T;: advise;0;[;{;IC; ";Announce an intention to access data from the current file in a specific pattern. On platforms that do not support the posix_fadvise(2) system call, this method is a no-op. _advice_ is one of the following symbols: :normal:: No advice to give; the default assumption for an open file. :sequential:: The data will be accessed sequentially with lower offsets read before higher ones. :random:: The data will be accessed in random order. :willneed:: The data will be accessed in the near future. :dontneed:: The data will not be accessed in the near future. :noreuse:: The data will only be accessed once. The semantics of a piece of advice are platform-dependent. See man 2 posix_fadvise for details. "data" means the region of the current file that begins at _offset_ and extends for _len_ bytes. If _len_ is 0, the region ends at the last byte of the file. By default, both _offset_ and _len_ are 0, meaning that the advice applies to the entire file. If an error occurs, one of the following exceptions will be raised: IOError:: The IO stream is closed. Errno::EBADF:: The file descriptor of the current file is invalid. Errno::EINVAL:: An invalid value for _advice_ was given. Errno::ESPIPE:: The file descriptor of the current file refers to a FIFO or pipe. (Linux raises Errno::EINVAL in this case). TypeError:: Either _advice_ was not a Symbol, or one of the other arguments was not an Integer. RangeError:: One of the arguments given was too big/small. This list is not exhaustive; other Errno:: exceptions are also possible. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"$advise(advice, offset=0, len=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@X;![;"I"@return [nil];T;#0;$@X;.F;Bi;C0;7[[I" advice;T0[I" offset;TI"0;T[I"len;TI"0;T;$@X;![;"I"wAnnounce an intention to access data from the current file in a specific pattern. On platforms that do not support the posix_fadvise(2) system call, this method is a no-op. _advice_ is one of the following symbols: :normal:: No advice to give; the default assumption for an open file. :sequential:: The data will be accessed sequentially with lower offsets read before higher ones. :random:: The data will be accessed in random order. :willneed:: The data will be accessed in the near future. :dontneed:: The data will not be accessed in the near future. :noreuse:: The data will only be accessed once. The semantics of a piece of advice are platform-dependent. See man 2 posix_fadvise for details. "data" means the region of the current file that begins at _offset_ and extends for _len_ bytes. If _len_ is 0, the region ends at the last byte of the file. By default, both _offset_ and _len_ are 0, meaning that the advice applies to the entire file. If an error occurs, one of the following exceptions will be raised: IOError:: The IO stream is closed. Errno::EBADF:: The file descriptor of the current file is invalid. Errno::EINVAL:: An invalid value for _advice_ was given. Errno::ESPIPE:: The file descriptor of the current file refers to a FIFO or pipe. (Linux raises Errno::EINVAL in this case). TypeError:: Either _advice_ was not a Symbol, or one of the other arguments was not an Integer. RangeError:: One of the arguments given was too big/small. This list is not exhaustive; other Errno:: exceptions are also possible. @overload advise(advice, offset=0, len=0) @return [nil];T;#0;$@X;.F;/o;0;1T;2i&;3i&;%@kL;9I"static VALUE rb_io_advise(int argc, VALUE *argv, VALUE io) { VALUE advice, offset, len; off_t off, l; rb_io_t *fptr; rb_scan_args(argc, argv, "12", &advice, &offset, &len); advice_arg_check(advice); io = GetWriteIO(io); GetOpenFile(io, fptr); off = NIL_P(offset) ? 0 : NUM2OFFT(offset); l = NIL_P(len) ? 0 : NUM2OFFT(len); #ifdef HAVE_POSIX_FADVISE return do_io_advise(fptr, advice, off, l); #else ((void)off, (void)l); /* Ignore all hint */ return Qnil; #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#ioctl;F;7[[@90;[[@Ti(;T;: ioctl;0;[;{;IC; "[Provides a mechanism for issuing low-level commands to control or query I/O devices. Arguments and results are platform dependent. If arg is a number, its value is passed directly. If it is a string, it is interpreted as a binary sequence of bytes. On Unix platforms, see ioctl(2) for details. Not implemented on all platforms. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ioctl(integer_cmd, arg);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@X;![;"I"@return [Integer];T;#0;$@X;.F;Bi;C0;7[[I"integer_cmd;T0[I"arg;T0;$@X;![;"I"Provides a mechanism for issuing low-level commands to control or query I/O devices. Arguments and results are platform dependent. If arg is a number, its value is passed directly. If it is a string, it is interpreted as a binary sequence of bytes. On Unix platforms, see ioctl(2) for details. Not implemented on all platforms. @overload ioctl(integer_cmd, arg) @return [Integer];T;#0;$@X;.F;/o;0;1T;2i(;3i(;%@kL;9I"static VALUE rb_io_ioctl(int argc, VALUE *argv, VALUE io) { VALUE req, arg; rb_scan_args(argc, argv, "11", &req, &arg); return rb_ioctl(io, req, arg); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#fcntl;F;7[[@90;[[@Ti(;T;: fcntl;0;[;{;IC; "Provides a mechanism for issuing low-level commands to control or query file-oriented I/O streams. Arguments and results are platform dependent. If arg is a number, its value is passed directly. If it is a string, it is interpreted as a binary sequence of bytes (Array#pack might be a useful way to build this string). On Unix platforms, see fcntl(2) for details. Not implemented on all platforms. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"fcntl(integer_cmd, arg);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@X;![;"I"@return [Integer];T;#0;$@X;.F;Bi;C0;7[[I"integer_cmd;T0[I"arg;T0;$@X;![;"I"Provides a mechanism for issuing low-level commands to control or query file-oriented I/O streams. Arguments and results are platform dependent. If arg is a number, its value is passed directly. If it is a string, it is interpreted as a binary sequence of bytes (Array#pack might be a useful way to build this string). On Unix platforms, see fcntl(2) for details. Not implemented on all platforms. @overload fcntl(integer_cmd, arg) @return [Integer];T;#0;$@X;.F;/o;0;1T;2i(;3i(;%@kL;9I"static VALUE rb_io_fcntl(int argc, VALUE *argv, VALUE io) { VALUE req, arg; rb_scan_args(argc, argv, "11", &req, &arg); return rb_fcntl(io, req, arg); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#pid;F;7[;[[@Ti ;T;:pid;0;[;{;IC; "rReturns the process ID of a child process associated with the stream, which will have been set by IO#popen, or +nil+ if the stream was not created by IO#popen: pipe = IO.popen("-") if pipe $stderr.puts "In parent, child pid is #{pipe.pid}" else $stderr.puts "In child, pid is #{$$}" end Output: In child, pid is 26209 In parent, child pid is 26209 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"pid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@X;![;"I"@return [Integer, nil];T;#0;$@X;.F;Bi;C0;7[;$@X;![;"I"Returns the process ID of a child process associated with the stream, which will have been set by IO#popen, or +nil+ if the stream was not created by IO#popen: pipe = IO.popen("-") if pipe $stderr.puts "In parent, child pid is #{pipe.pid}" else $stderr.puts "In child, pid is #{$$}" end Output: In child, pid is 26209 In parent, child pid is 26209 @overload pid @return [Integer, nil];T;#0;$@X;.F;/o;0;1T;2ij ;3i} ;%@kL;9I"static VALUE rb_io_pid(VALUE io) { rb_io_t *fptr; GetOpenFile(io, fptr); if (!fptr->pid) return Qnil; return PIDT2NUM(fptr->pid); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#inspect;F;7[;[[@Ti ;T;;J;0;[;{;IC; "jReturns a string representation of +self+: f = File.open('t.txt') f.inspect # => "#" ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@Y;![;"I"@return [String];T;#0;$@Y;.F;Bi;C0;7[;$@Y;![;"I"Returns a string representation of +self+: f = File.open('t.txt') f.inspect # => "#" @overload inspect @return [String];T;#0;$@Y;.F;/o;0;1T;2i ;3i ;%@kL;9I"static VALUE rb_io_inspect(VALUE obj) { rb_io_t *fptr; VALUE result; static const char closed[] = " (closed)"; fptr = RFILE(obj)->fptr; if (!fptr) return rb_any_to_s(obj); result = rb_str_new_cstr("#<"); rb_str_append(result, rb_class_name(CLASS_OF(obj))); rb_str_cat2(result, ":"); if (NIL_P(fptr->pathv)) { if (fptr->fd < 0) { rb_str_cat(result, closed+1, strlen(closed)-1); } else { rb_str_catf(result, "fd %d", fptr->fd); } } else { rb_str_append(result, fptr->pathv); if (fptr->fd < 0) { rb_str_cat(result, closed, strlen(closed)); } } return rb_str_cat2(result, ">"); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#external_encoding;F;7[;[[@Ti 0;T;:external_encoding;0;[;{;IC; "Returns the Encoding object that represents the encoding of the file. If _io_ is in write mode and no encoding is specified, returns +nil+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"external_encoding;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Encoding;T;$@)Y;![;"I"@return [Encoding];T;#0;$@)Y;.F;Bi;C0;7[;$@)Y;![;"I"Returns the Encoding object that represents the encoding of the file. If _io_ is in write mode and no encoding is specified, returns +nil+. @overload external_encoding @return [Encoding];T;#0;$@)Y;.F;/o;0;1T;2i0;3i 0;%@kL;9I"vstatic VALUE rb_io_external_encoding(VALUE io) { rb_io_t *fptr = RFILE(rb_io_taint_check(io))->fptr; if (fptr->encs.enc2) { return rb_enc_from_encoding(fptr->encs.enc2); } if (fptr->mode & FMODE_WRITABLE) { if (fptr->encs.enc) return rb_enc_from_encoding(fptr->encs.enc); return Qnil; } return rb_enc_from_encoding(io_read_encoding(fptr)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#internal_encoding;F;7[;[[@Ti$0;T;:internal_encoding;0;[;{;IC; "fReturns the Encoding of the internal string if conversion is specified. Otherwise returns +nil+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"internal_encoding;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Encoding;T;$@DY;![;"I"@return [Encoding];T;#0;$@DY;.F;Bi;C0;7[;$@DY;![;"I"Returns the Encoding of the internal string if conversion is specified. Otherwise returns +nil+. @overload internal_encoding @return [Encoding];T;#0;$@DY;.F;/o;0;1T;2i0;3i!0;%@kL;9I"static VALUE rb_io_internal_encoding(VALUE io) { rb_io_t *fptr = RFILE(rb_io_taint_check(io))->fptr; if (!fptr->encs.enc2) return Qnil; return rb_enc_from_encoding(io_read_encoding(fptr)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#set_encoding;F;7[[@90;[[@Ti@0;T;:set_encoding;0;[;{;IC; "2If single argument is specified, read string from io is tagged with the encoding specified. If encoding is a colon separated two encoding names "A:B", the read string is converted from encoding A (external encoding) to encoding B (internal encoding), then tagged with B. If two arguments are specified, those must be encoding objects or encoding names, and the first one is the external encoding, and the second one is the internal encoding. If the external encoding and the internal encoding is specified, optional hash argument specify the conversion option. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"set_encoding(ext_enc);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"IO;T;$@_Y;![;"I"@return [IO];T;#0;$@_Y;.F;Bi;C0;7[[I" ext_enc;T0;$@_Yo;= ;>I" overload;F;?0;;;@0;:I"$set_encoding("ext_enc:int_enc");T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"IO;T;$@_Y;![;"I"@return [IO];T;#0;$@_Y;.F;Bi;C0;7[[""ext_enc:" int_enc";$@_Yo;= ;>I" overload;F;?0;;;@0;:I"#set_encoding(ext_enc, int_enc);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"IO;T;$@_Y;![;"I"@return [IO];T;#0;$@_Y;.F;Bi;C0;7[[I" ext_enc;T0[I" int_enc;T0;$@_Yo;= ;>I" overload;F;?0;;;@0;:I")set_encoding("ext_enc:int_enc", opt);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"IO;T;$@_Y;![;"I"@return [IO];T;#0;$@_Y;.F;Bi;C0;7[[""ext_enc:" int_enc"[I"opt;T0;$@_Yo;= ;>I" overload;F;?0;;;@0;:I"(set_encoding(ext_enc, int_enc, opt);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"IO;T;$@_Y;![;"I"@return [IO];T;#0;$@_Y;.F;Bi;C0;7[[I" ext_enc;T0[I" int_enc;T0[I"opt;T0;$@_Y;![;"I"OIf single argument is specified, read string from io is tagged with the encoding specified. If encoding is a colon separated two encoding names "A:B", the read string is converted from encoding A (external encoding) to encoding B (internal encoding), then tagged with B. If two arguments are specified, those must be encoding objects or encoding names, and the first one is the external encoding, and the second one is the internal encoding. If the external encoding and the internal encoding is specified, optional hash argument specify the conversion option. @overload set_encoding(ext_enc) @return [IO] @overload set_encoding("ext_enc:int_enc") @return [IO] @overload set_encoding(ext_enc, int_enc) @return [IO] @overload set_encoding("ext_enc:int_enc", opt) @return [IO] @overload set_encoding(ext_enc, int_enc, opt) @return [IO];T;#0;$@_Y;.F;/o;0;1T;2i-0;3iA0;%@kL;9I"_static VALUE rb_io_set_encoding(int argc, VALUE *argv, VALUE io) { rb_io_t *fptr; VALUE v1, v2, opt; if (!RB_TYPE_P(io, T_FILE)) { return forward(io, id_set_encoding, argc, argv); } argc = rb_scan_args(argc, argv, "11:", &v1, &v2, &opt); GetOpenFile(io, fptr); io_encoding_set(fptr, v1, v2, opt); return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#set_encoding_by_bom;F;7[;[[@Ti";T;:set_encoding_by_bom;0;[;{;IC; "Checks if +ios+ starts with a BOM, and then consumes it and sets the external encoding. Returns the result encoding if found, or nil. If +ios+ is not binmode or its encoding has been set already, an exception will be raised. File.write("bom.txt", "\u{FEFF}abc") ios = File.open("bom.txt", "rb") ios.set_encoding_by_bom #=> # File.write("nobom.txt", "abc") ios = File.open("nobom.txt", "rb") ios.set_encoding_by_bom #=> nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I"set_encoding_by_bom;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Encoding;TI"nil;T;$@Y;![;"I"@return [Encoding, nil];T;#0;$@Y;.F;Bi;C0;7[;$@Y;![;"I"Checks if +ios+ starts with a BOM, and then consumes it and sets the external encoding. Returns the result encoding if found, or nil. If +ios+ is not binmode or its encoding has been set already, an exception will be raised. File.write("bom.txt", "\u{FEFF}abc") ios = File.open("bom.txt", "rb") ios.set_encoding_by_bom #=> # File.write("nobom.txt", "abc") ios = File.open("nobom.txt", "rb") ios.set_encoding_by_bom #=> nil @overload set_encoding_by_bom @return [Encoding, nil];T;#0;$@Y;.F;/o;0;1T;2iz";3i";%@kL;9I"bstatic VALUE rb_io_set_encoding_by_bom(VALUE io) { rb_io_t *fptr; GetOpenFile(io, fptr); if (!(fptr->mode & FMODE_BINMODE)) { rb_raise(rb_eArgError, "ASCII incompatible encoding needs binmode"); } if (fptr->encs.enc2) { rb_raise(rb_eArgError, "encoding conversion is set"); } else if (fptr->encs.enc && fptr->encs.enc != rb_ascii8bit_encoding()) { rb_raise(rb_eArgError, "encoding is set to %s already", rb_enc_name(fptr->encs.enc)); } if (!io_set_encoding_by_bom(io)) return Qnil; return rb_enc_from_encoding(fptr->encs.enc); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#autoclose?;F;7[;[[@Ti";T;:autoclose?;0;[;{;IC; "~Returns +true+ if the underlying file descriptor of _ios_ will be closed automatically at its finalization, otherwise +false+.;T;[o;= ;>I" overload;F;?0;;;@0;:I"autoclose?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Y;![;"I"@return [Boolean];T;#0;$@Y;.F;Bi;C0;7[;$@Y;![;"I"Returns +true+ if the underlying file descriptor of _ios_ will be closed automatically at its finalization, otherwise +false+. @overload autoclose? @return [Boolean];T;#0;$@Y;.F;/o;0;1T;2i";3i";Bi;%@kL;9I"static VALUE rb_io_autoclose_p(VALUE io) { rb_io_t *fptr = RFILE(io)->fptr; rb_io_check_closed(fptr); return (fptr->mode & FMODE_PREP) ? Qfalse : Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#autoclose=;F;7[[I"autoclose;T0;[[@Ti #;T;:autoclose=;0;[;{;IC; "Sets auto-close flag. f = open("/dev/null") IO.for_fd(f.fileno) # ... f.gets # may cause Errno::EBADF f = open("/dev/null") IO.for_fd(f.fileno).autoclose = false # ... f.gets # won't cause Errno::EBADF ;T;[o;= ;>I" overload;F;?0;;;@0;:I"autoclose=(bool);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Y;![;"I"@return [Boolean];T;#0;$@Y;.F;Bi;C0;7[[I" bool;T0;$@Y;![;"I"Sets auto-close flag. f = open("/dev/null") IO.for_fd(f.fileno) # ... f.gets # may cause Errno::EBADF f = open("/dev/null") IO.for_fd(f.fileno).autoclose = false # ... f.gets # won't cause Errno::EBADF @overload autoclose=(bool) @return [Boolean];T;#0;$@Y;.F;/o;0;1T;2i";3i#;%@kL;9I"static VALUE rb_io_set_autoclose(VALUE io, VALUE autoclose) { rb_io_t *fptr; GetOpenFile(io, fptr); if (!RTEST(autoclose)) fptr->mode |= FMODE_PREP; else fptr->mode &= ~FMODE_PREP; return autoclose; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#nread;F;7[;[[I"ext/io/wait/wait.c;TiW;T;: nread;0;[;{;IC; "iReturns number of bytes that can be read without blocking. Returns zero if no information available. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" nread;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@Z;![;"I"@return [Integer];T;#0;$@Z;.F;Bi;C0;7[;$@Z;![;"I"Returns number of bytes that can be read without blocking. Returns zero if no information available. @overload nread @return [Integer];T;#0;$@Z;.F;/o;0;1T;2iO;3iT;%@kL;9I"static VALUE io_nread(VALUE io) { rb_io_t *fptr; int len; ioctl_arg n; GetOpenFile(io, fptr); rb_io_check_readable(fptr); len = rb_io_read_pending(fptr); if (len > 0) return INT2FIX(len); if (!FIONREAD_POSSIBLE_P(fptr->fd)) return INT2FIX(0); if (ioctl(fptr->fd, FIONREAD, &n)) return INT2FIX(0); if (n > 0) return ioctl_arg2num(n); return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#ready?;F;7[;[[@Zi;T;: ready?;0;[;{;IC; "DReturns +true+ if input available without blocking, or +false+.;T;[o;= ;>I" overload;F;?0;;;@0;:I" ready?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@5Z;![;"I"@return [Boolean];T;#0;$@5Z;.F;Bi;C0;7[;$@5Z;![;"I"kReturns +true+ if input available without blocking, or +false+. @overload ready? @return [Boolean];T;#0;$@5Z;.F;/o;0;1T;2i};3i|;Bi;%@kL;9I"static VALUE io_ready_p(VALUE io) { rb_io_t *fptr; #ifndef HAVE_RB_IO_WAIT struct timeval tv = {0, 0}; #endif GetOpenFile(io, fptr); rb_io_check_readable(fptr); if (rb_io_read_pending(fptr)) return Qtrue; #ifndef HAVE_RB_IO_WAIT if (wait_for_single_fd(fptr, RB_WAITFD_IN, &tv)) return Qtrue; #else if (RTEST(io_wait_event(io, RUBY_IO_READABLE, RB_INT2NUM(0)))) return Qtrue; #endif return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#wait;F;7[[@90;[[@Zi,;T;;h;0;[;{;IC; "bWaits until the IO becomes ready for the specified events and returns the subset of events that become ready, or +false+ when times out. The events can be a bit mask of +IO::READABLE+, +IO::WRITABLE+ or +IO::PRIORITY+. Returns +true+ immediately when buffered data is available. Optional parameter +mode+ is one of +:read+, +:write+, or +:read_write+. ;T;[o;= ;>I" overload;F;?0;;h;@0;:I"wait(events, timeout);T;IC; ";T;[;![;"I";T;#0;$@PZ;.F;Bi;C0;7[[I" events;T0[I" timeout;T0;$@PZo;= ;>I" overload;F;?0;;h;@0;:I"&wait(timeout = nil, mode = :read);T;IC; ";T;[;![;"I";T;#0;$@PZ;.F;Bi;C0;7[[I" timeout;TI"nil;T[I" mode;TI" :read;T;$@PZ;![;"I"Waits until the IO becomes ready for the specified events and returns the subset of events that become ready, or +false+ when times out. The events can be a bit mask of +IO::READABLE+, +IO::WRITABLE+ or +IO::PRIORITY+. Returns +true+ immediately when buffered data is available. Optional parameter +mode+ is one of +:read+, +:write+, or +:read_write+. @overload wait(events, timeout) @overload wait(timeout = nil, mode = :read);T;#0;$@PZ;.F;/o;0;1T;2i;3i(;%@kL;9I"static VALUE io_wait(int argc, VALUE *argv, VALUE io) { #ifndef HAVE_RB_IO_WAIT rb_io_t *fptr; struct timeval timerec; struct timeval *tv = NULL; int event = 0; int i; GetOpenFile(io, fptr); for (i = 0; i < argc; ++i) { if (SYMBOL_P(argv[i])) { event |= wait_mode_sym(argv[i]); } else { *(tv = &timerec) = rb_time_interval(argv[i]); } } /* rb_time_interval() and might_mode() might convert the argument */ rb_io_check_closed(fptr); if (!event) event = RB_WAITFD_IN; if ((event & RB_WAITFD_IN) && rb_io_read_pending(fptr)) return Qtrue; if (wait_for_single_fd(fptr, event, tv)) return io; return Qnil; #else VALUE timeout = Qundef; rb_io_event_t events = 0; if (argc != 2 || (RB_SYMBOL_P(argv[0]) || RB_SYMBOL_P(argv[1]))) { for (int i = 0; i < argc; i += 1) { if (RB_SYMBOL_P(argv[i])) { events |= wait_mode_sym(argv[i]); } else if (timeout == Qundef) { rb_time_interval(timeout = argv[i]); } else { rb_raise(rb_eArgError, "timeout given more than once"); } } if (timeout == Qundef) timeout = Qnil; } else /* argc == 2 */ { events = RB_NUM2UINT(argv[0]); timeout = argv[1]; } if (events == 0) { events = RUBY_IO_READABLE; } if (events & RUBY_IO_READABLE) { rb_io_t *fptr = NULL; RB_IO_POINTER(io, fptr); if (rb_io_read_pending(fptr)) { return Qtrue; } } return io_wait_event(io, events, timeout); #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#wait_readable;F;7[[@90;[[@Zi;T;:wait_readable;0;[;{;IC; "Waits until IO is readable and returns +true+, or +false+ when times out. Returns +true+ immediately when buffered data is available. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"wait_readable;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@yZ;![;"I"@return [Boolean];T;#0;$@yZ;.F;Bi;C0;7[;$@yZo;= ;>I" overload;F;?0;;;@0;:I"wait_readable(timeout);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@yZ;![;"I"@return [Boolean];T;#0;$@yZ;.F;Bi;C0;7[[I" timeout;T0;$@yZ;![;"I"Waits until IO is readable and returns +true+, or +false+ when times out. Returns +true+ immediately when buffered data is available. @overload wait_readable @return [Boolean] @overload wait_readable(timeout) @return [Boolean];T;#0;$@yZ;.F;/o;0;1T;2i;3i;%@kL;9I"kstatic VALUE io_wait_readable(int argc, VALUE *argv, VALUE io) { rb_io_t *fptr; #ifndef HAVE_RB_IO_WAIT struct timeval timerec; struct timeval *tv; #endif GetOpenFile(io, fptr); rb_io_check_readable(fptr); #ifndef HAVE_RB_IO_WAIT tv = get_timeout(argc, argv, &timerec); #endif if (rb_io_read_pending(fptr)) return Qtrue; #ifndef HAVE_RB_IO_WAIT if (wait_for_single_fd(fptr, RB_WAITFD_IN, tv)) { return io; } return Qnil; #else rb_check_arity(argc, 0, 1); VALUE timeout = (argc == 1 ? argv[0] : Qnil); return io_wait_event(io, RUBY_IO_READABLE, timeout); #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#wait_writable;F;7[[@90;[[@Zi;T;:wait_writable;0;[;{;IC; "MWaits until IO is writable and returns +true+ or +false+ when times out. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"wait_writable;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Z;![;"I"@return [Boolean];T;#0;$@Z;.F;Bi;C0;7[;$@Zo;= ;>I" overload;F;?0;;;@0;:I"wait_writable(timeout);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Z;![;"I"@return [Boolean];T;#0;$@Z;.F;Bi;C0;7[[I" timeout;T0;$@Z;![;"I"Waits until IO is writable and returns +true+ or +false+ when times out. @overload wait_writable @return [Boolean] @overload wait_writable(timeout) @return [Boolean];T;#0;$@Z;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE io_wait_writable(int argc, VALUE *argv, VALUE io) { rb_io_t *fptr; #ifndef HAVE_RB_IO_WAIT struct timeval timerec; struct timeval *tv; #endif GetOpenFile(io, fptr); rb_io_check_writable(fptr); #ifndef HAVE_RB_IO_WAIT tv = get_timeout(argc, argv, &timerec); if (wait_for_single_fd(fptr, RB_WAITFD_OUT, tv)) { return io; } return Qnil; #else rb_check_arity(argc, 0, 1); VALUE timeout = (argc == 1 ? argv[0] : Qnil); return io_wait_event(io, RUBY_IO_WRITABLE, timeout); #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#wait_priority;F;7[[@90;[[@Zi;T;:wait_priority;0;[;{;IC; "MWaits until IO is priority and returns +true+ or +false+ when times out. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"wait_priority;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Z;![;"I"@return [Boolean];T;#0;$@Z;.F;Bi;C0;7[;$@Zo;= ;>I" overload;F;?0;;;@0;:I"wait_priority(timeout);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Z;![;"I"@return [Boolean];T;#0;$@Z;.F;Bi;C0;7[[I" timeout;T0;$@Z;![;"I"Waits until IO is priority and returns +true+ or +false+ when times out. @overload wait_priority @return [Boolean] @overload wait_priority(timeout) @return [Boolean];T;#0;$@Z;.F;/o;0;1T;2i;3i;%@kL;9I"Vstatic VALUE io_wait_priority(int argc, VALUE *argv, VALUE io) { rb_io_t *fptr = NULL; RB_IO_POINTER(io, fptr); rb_io_check_readable(fptr); if (rb_io_read_pending(fptr)) return Qtrue; rb_check_arity(argc, 0, 1); VALUE timeout = argc == 1 ? argv[0] : Qnil; return io_wait_event(io, RUBY_IO_PRIORITY, timeout); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#nonblock?;F;7[;[[I"ext/io/nonblock/nonblock.c;Ti,;T;:nonblock?;0;[;{;IC; "I" overload;F;?0;;;@0;:I"nonblock?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Z;![;"I"@return [Boolean];T;#0;$@Z;.F;Bi;C0;7[;$@Z;![;"I"fReturns +true+ if an IO object is in non-blocking mode. @overload nonblock? @return [Boolean];T;#0;$@Z;.F;/o;0;1T;2i&;3i*;Bi;%@kL;9I"static VALUE rb_io_nonblock_p(VALUE io) { rb_io_t *fptr; GetOpenFile(io, fptr); if (io_nonblock_mode(fptr->fd) & O_NONBLOCK) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#nonblock=;F;7[[I"nb;T0;[[@ZiS;T;:nonblock=;0;[;{;IC; "eEnables non-blocking mode on a stream when set to +true+, and blocking mode when set to +false+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"nonblock=(boolean);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@[;![;"I"@return [Boolean];T;#0;$@[;.F;Bi;C0;7[[I" boolean;T0;$@[;![;"I"Enables non-blocking mode on a stream when set to +true+, and blocking mode when set to +false+. @overload nonblock=(boolean) @return [Boolean];T;#0;$@[;.F;/o;0;1T;2iL;3iQ;%@kL;9I"static VALUE rb_io_nonblock_set(VALUE io, VALUE nb) { rb_io_t *fptr; GetOpenFile(io, fptr); if (RTEST(nb)) rb_io_set_nonblock(fptr); else io_nonblock_set(fptr->fd, io_nonblock_mode(fptr->fd), RTEST(nb)); return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#nonblock;F;7[[@90;[[@Zir;T;: nonblock;0;[;{;IC; "Yields +self+ in non-blocking mode. When +false+ is given as an argument, +self+ is yielded in blocking mode. The original mode is restored after the block is executed. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" nonblock;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"io;T;$@5[o;A ;>I" return;F;?I";T;0;@[I"IO;T;$@5[;![;"I"@yield [io] @return [IO];T;#0;$@5[;.F;Bi;C0;7[;$@5[o;= ;>I" overload;F;?0;;;@0;:I"nonblock(boolean);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"io;T;$@5[o;A ;>I" return;F;?I";T;0;@[I"IO;T;$@5[;![;"I"@yield [io] @return [IO];T;#0;$@5[;.F;Bi;C0;7[[I" boolean;T0;$@5[;![;"I"Yields +self+ in non-blocking mode. When +false+ is given as an argument, +self+ is yielded in blocking mode. The original mode is restored after the block is executed. @overload nonblock @yield [io] @return [IO] @overload nonblock(boolean) @yield [io] @return [IO];T;#0;$@5[;.F;/o;0;1T;2ih;3is;%@kL;9I"static VALUE rb_io_nonblock_block(int argc, VALUE *argv, VALUE io) { int nb = 1; rb_io_t *fptr; int f, restore[2]; GetOpenFile(io, fptr); if (argc > 0) { VALUE v; rb_scan_args(argc, argv, "01", &v); nb = RTEST(v); } f = io_nonblock_mode(fptr->fd); restore[0] = fptr->fd; restore[1] = f; if (!io_nonblock_set(fptr->fd, f, nb)) return rb_yield(io); return rb_ensure(rb_yield, io, io_nonblock_restore, (VALUE)restore); };T;:I"static VALUE;T;;To; ;IC;[4o; ;IC;[; @l[; IC;[; @l[; IC;[; @l[; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"io_buffer.c;TiI;F;:LockedError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@l[;%@j[;&I"IO::Buffer::LockedError;F;'o;( ;)0;*0;+0;:RuntimeError;%@;-o; ;IC;[; @[; IC;[; @[; IC;[; @[; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)ie [@)iw ;T;;;;;;;[;{;IC; "A generic error class raised when an invalid operation is attempted. Kernel#raise will raise a RuntimeError if no Exception class is specified. raise "ouch" raises the exception: RuntimeError: ouch ;T;[;![;"I" A generic error class raised when an invalid operation is attempted. Kernel#raise will raise a RuntimeError if no Exception class is specified. raise "ouch" raises the exception: RuntimeError: ouch ;T;#0;$@[;.F;/o;0;1T;2ie ;3io ;%@;&I"RuntimeError;F;'@;;o; ;IC;[; @[; IC;[; @[; IC;[; @[; IC;{;IC;{;T;IC;{;T;T;{;[;[[@w[iJ;F;:AllocationError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@[;%@j[;&I" IO::Buffer::AllocationError;F;'o;( ;)0;*0;+0;;;%@;-@[;;o; ;IC;[; @[; IC;[; @[; IC;[; @[; IC;{;IC;{;T;IC;{;T;T;{;[;[[@w[iK;F;:AccessError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@[;%@j[;&I"IO::Buffer::AccessError;F;'o;( ;)0;*0;+0;;;%@;-@[;;o; ;IC;[; @[; IC;[; @[; IC;[; @[; IC;{;IC;{;T;IC;{;T;T;{;[;[[@w[iL;F;:InvalidatedError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@[;%@j[;&I"!IO::Buffer::InvalidatedError;F;'o;( ;)0;*0;+0;;;%@;-@[;;o;4;5F;6;;;;&I"IO::Buffer.for;F;7[[I" string;T0;[[@w[i6;T;:for;0;[;{;IC; "oCreates a IO::Buffer from the given string's memory. The buffer remains associated with the string, and writing to a buffer will update the string's contents. Until #free is invoked on the buffer, either explicitly or via the garbage collector, the source string will be locked and cannot be modified. If the string is frozen, it will create a read-only buffer which cannot be modified. string = 'test' buffer = IO::Buffer.for(str) buffer.external? #=> true buffer.get_string(0, 1) # => "t" string # => "best" buffer.resize(100) # in `resize': Cannot resize external buffer! (IO::Buffer::AccessError) ;T;[o;= ;>I" overload;F;?0;:IO::Buffer.for;@0;:I"IO::Buffer.for(string);T;IC; ";T;[;![;"I";T;#0;$@[;.F;Bi;C0;7[[I" string;T0;$@[;![;"I"Creates a IO::Buffer from the given string's memory. The buffer remains associated with the string, and writing to a buffer will update the string's contents. Until #free is invoked on the buffer, either explicitly or via the garbage collector, the source string will be locked and cannot be modified. If the string is frozen, it will create a read-only buffer which cannot be modified. string = 'test' buffer = IO::Buffer.for(str) buffer.external? #=> true buffer.get_string(0, 1) # => "t" string # => "best" buffer.resize(100) # in `resize': Cannot resize external buffer! (IO::Buffer::AccessError) @overload IO::Buffer.for(string);T;#0;$@[;.F;/o;0;1T;2i;3i4;%@j[;9I"6VALUE rb_io_buffer_type_for(VALUE klass, VALUE string) { io_buffer_experimental(); StringValue(string); VALUE instance = rb_io_buffer_type_allocate(klass); struct rb_io_buffer *data = NULL; TypedData_Get_Struct(instance, struct rb_io_buffer, &rb_io_buffer_type, data); rb_str_locktmp(string); enum rb_io_buffer_flags flags = RB_IO_BUFFER_EXTERNAL; if (RB_OBJ_FROZEN(string)) flags |= RB_IO_BUFFER_READONLY; io_buffer_initialize(data, RSTRING_PTR(string), RSTRING_LEN(string), flags, string); return instance; };T;:I" VALUE;T;;To;u;[[@w[i\;F;:PAGE_SIZE;;w;;;[;{;IC; "(Efficient sizing of mapped buffers: ;T;[;![;"I"(Efficient sizing of mapped buffers:;T;#0;$@[;.F;/o;0;1T;2i[;3i[;%@j[;&I"IO::Buffer::PAGE_SIZE;F;xI"(SIZET2NUM(RUBY_IO_BUFFER_PAGE_SIZE);To;u;[[@w[i];F;:DEFAULT_SIZE;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@[;%@j[;&I"IO::Buffer::DEFAULT_SIZE;F;xI"+SIZET2NUM(RUBY_IO_BUFFER_DEFAULT_SIZE);To;4;5F;6;;;;&I"IO::Buffer.map;F;7[[@90;[[@w[i;T;;;0;[;{;IC; "!Create an IO::Buffer for reading from +file+ by memory-mapping the file. +file_io+ should be a +File+ instance, opened for reading. Optional +size+ and +offset+ of mapping can be specified. By default, the buffer would be immutable (read only); to create a writable mapping, you need to open a file in read-write mode, and explicitly pass +flags+ argument without IO::Buffer::IMMUTABLE. File.write('test.txt', 'test') buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY) # => # buffer.readonly? # => true buffer.get_string # => "test" buffer.set_string('b', 0) # `set_string': Buffer is not writable! (IO::Buffer::AccessError) # create read/write mapping: length 4 bytes, offset 0, flags 0 buffer = IO::Buffer.map(File.open('test.txt', 'r+'), 4, 0) buffer.set_string('b', 0) # => 1 # Check it File.read('test.txt') # => "best" Note that some operating systems may not have cache coherency between mapped buffers and file reads. ;T;[o;= ;>I" overload;F;?0;:IO::Buffer.map;@0;:I"4IO::Buffer.map(file, [size, [offset, [flags]]]);T;IC; ";T;[;![;"I";T;#0;$@[;.F;Bi;C0;7[[I" file;T0[I"[size, [offset, [flags]]];T0;$@[;![;"I"^Create an IO::Buffer for reading from +file+ by memory-mapping the file. +file_io+ should be a +File+ instance, opened for reading. Optional +size+ and +offset+ of mapping can be specified. By default, the buffer would be immutable (read only); to create a writable mapping, you need to open a file in read-write mode, and explicitly pass +flags+ argument without IO::Buffer::IMMUTABLE. File.write('test.txt', 'test') buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY) # => # buffer.readonly? # => true buffer.get_string # => "test" buffer.set_string('b', 0) # `set_string': Buffer is not writable! (IO::Buffer::AccessError) # create read/write mapping: length 4 bytes, offset 0, flags 0 buffer = IO::Buffer.map(File.open('test.txt', 'r+'), 4, 0) buffer.set_string('b', 0) # => 1 # Check it File.read('test.txt') # => "best" Note that some operating systems may not have cache coherency between mapped buffers and file reads. @overload IO::Buffer.map(file, [size, [offset, [flags]]]);T;#0;$@[;.F;/o;0;1T;2il;3i;%@j[;9I"Gstatic VALUE io_buffer_map(int argc, VALUE *argv, VALUE klass) { if (argc < 1 || argc > 4) { rb_error_arity(argc, 2, 4); } // We might like to handle a string path? VALUE io = argv[0]; size_t size; if (argc >= 2 && !RB_NIL_P(argv[1])) { size = RB_NUM2SIZE(argv[1]); } else { off_t file_size = rb_file_size(io); // Compiler can confirm that we handled file_size < 0 case: if (file_size < 0) { rb_raise(rb_eArgError, "Invalid negative file size!"); } // Here, we assume that file_size is positive: else if ((uintmax_t)file_size > SIZE_MAX) { rb_raise(rb_eArgError, "File larger than address space!"); } else { // This conversion should be safe: size = (size_t)file_size; } } off_t offset = 0; if (argc >= 3) { offset = NUM2OFFT(argv[2]); } enum rb_io_buffer_flags flags = 0; if (argc >= 4) { flags = RB_NUM2UINT(argv[3]); } return rb_io_buffer_map(io, size, offset, flags); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#initialize;F;7[[@90;[[@w[i;T;;D;0;[;{;IC; " Create a new zero-filled IO::Buffer of +size+ bytes. By default, the buffer will be _internal_: directly allocated chunk of the memory. But if the requested +size+ is more than OS-specific IO::Bufer::PAGE_SIZE, the buffer would be allocated using the virtual memory mechanism (anonymous +mmap+ on Unix, +VirtualAlloc+ on Windows). The behavior can be forced by passing IO::Buffer::MAPPED as a second parameter. Examples buffer = IO::Buffer.new(4) # => # # # 0x00000000 00 00 00 00 .... buffer.get_string(0, 1) # => "\x00" buffer.set_string("test") buffer # => # # # 0x00000000 74 65 73 74 test ;T;[o;= ;>I" overload;F;?0;:IO::Buffer.new;@0;:I"7IO::Buffer.new([size = DEFAULT_SIZE, [flags = 0]]);T;IC; ";T;[;![;"I";T;#0;$@\;.F;Bi;C0;7[[I" [size;TI"DEFAULT_SIZE, [flags = 0]];T;$@\;![;"I"JCreate a new zero-filled IO::Buffer of +size+ bytes. By default, the buffer will be _internal_: directly allocated chunk of the memory. But if the requested +size+ is more than OS-specific IO::Bufer::PAGE_SIZE, the buffer would be allocated using the virtual memory mechanism (anonymous +mmap+ on Unix, +VirtualAlloc+ on Windows). The behavior can be forced by passing IO::Buffer::MAPPED as a second parameter. Examples buffer = IO::Buffer.new(4) # => # # # 0x00000000 00 00 00 00 .... buffer.get_string(0, 1) # => "\x00" buffer.set_string("test") buffer # => # # # 0x00000000 74 65 73 74 test @overload IO::Buffer.new([size = DEFAULT_SIZE, [flags = 0]]);T;#0;$@\;.F;/o;0;1T;2i;3i;%@j[;9I"VALUE rb_io_buffer_initialize(int argc, VALUE *argv, VALUE self) { io_buffer_experimental(); if (argc < 0 || argc > 2) { rb_error_arity(argc, 0, 2); } struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); size_t size; if (argc > 0) { size = RB_NUM2SIZE(argv[0]); } else { size = RUBY_IO_BUFFER_DEFAULT_SIZE; } enum rb_io_buffer_flags flags = 0; if (argc >= 2) { flags = RB_NUM2UINT(argv[1]); } else { flags |= io_flags_for_size(size); } io_buffer_initialize(data, NULL, size, flags, Qnil); return self; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#inspect;F;7[;[[@w[i;T;;J;0;[;{;IC; " ;T;[;![;"@;#0;$@.\;%@j[;9I"VALUE rb_io_buffer_inspect(VALUE self) { struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); VALUE result = rb_io_buffer_to_s(self); if (io_buffer_validate(data)) { // Limit the maximum size genearted by inspect. if (data->size <= 256) { io_buffer_hexdump(result, 16, data->base, data->size, 0); } } return result; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#hexdump;F;7[;[[@w[i;T;: hexdump;0;[;{;IC; " ;T;[;![;"@;#0;$@:\;%@j[;9I"static VALUE rb_io_buffer_hexdump(VALUE self) { struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); VALUE result = Qnil; if (io_buffer_validate(data) && data->base) { result = rb_str_buf_new(data->size*3 + (data->size/16)*12 + 1); io_buffer_hexdump(result, 16, data->base, data->size, 1); } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#to_s;F;7[;[[@w[i8;T;;G;0;[;{;IC; "Short representation of the buffer. It includes the address, size and symbolic flags. This format is subject to change. puts IO::Buffer.new(4) # uses to_s internally # # ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@F\;![;"I"@return [String];T;#0;$@F\;.F;Bi;C0;7[;$@F\;![;"I"Short representation of the buffer. It includes the address, size and symbolic flags. This format is subject to change. puts IO::Buffer.new(4) # uses to_s internally # # @overload to_s @return [String];T;#0;$@F\;.F;/o;0;1T;2i.;3i7;%@j[;9I"0VALUE rb_io_buffer_to_s(VALUE self) { struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); VALUE result = rb_str_new_cstr("#<"); rb_str_append(result, rb_class_name(CLASS_OF(self))); rb_str_catf(result, " %p+%"PRIdSIZE, data->base, data->size); if (data->base == NULL) { rb_str_cat2(result, " NULL"); } if (data->flags & RB_IO_BUFFER_EXTERNAL) { rb_str_cat2(result, " EXTERNAL"); } if (data->flags & RB_IO_BUFFER_INTERNAL) { rb_str_cat2(result, " INTERNAL"); } if (data->flags & RB_IO_BUFFER_MAPPED) { rb_str_cat2(result, " MAPPED"); } if (data->flags & RB_IO_BUFFER_LOCKED) { rb_str_cat2(result, " LOCKED"); } if (data->flags & RB_IO_BUFFER_READONLY) { rb_str_cat2(result, " READONLY"); } if (data->source != Qnil) { rb_str_cat2(result, " SLICE"); } if (!io_buffer_validate(data)) { rb_str_cat2(result, " INVALID"); } return rb_str_cat2(result, ">"); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#size;F;7[;[[@w[i;T;;;0;[;{;IC; "Returns the size of the buffer that was explicitly set (on creation with ::new or on #resize), or deduced on buffer's creation from string or file. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@a\;![;"I"@return [Integer];T;#0;$@a\;.F;Bi;C0;7[;$@a\;![;"I"Returns the size of the buffer that was explicitly set (on creation with ::new or on #resize), or deduced on buffer's creation from string or file. @overload size @return [Integer];T;#0;$@a\;.F;/o;0;1T;2i;3i;%@j[;9I"VALUE rb_io_buffer_size(VALUE self) { struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); return SIZET2NUM(data->size); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#valid?;F;7[;[[@w[i;T;: valid?;0;[;{;IC; "Returns whether the buffer data is accessible. A buffer becomes invalid if it is a slice of another buffer which has been freed.;T;[o;= ;>I" overload;F;?0;;;@0;:I" valid?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@|\;![;"I"@return [Boolean];T;#0;$@|\;.F;Bi;C0;7[;$@|\;![;"I"Returns whether the buffer data is accessible. A buffer becomes invalid if it is a slice of another buffer which has been freed. @overload valid? @return [Boolean];T;#0;$@|\;.F;/o;0;1T;2i;3i;Bi;%@j[;9I"static VALUE rb_io_buffer_valid_p(VALUE self) { struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); return RBOOL(io_buffer_validate(data)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#transfer;F;7[;[[@w[i;T;: transfer;0;[;{;IC; "dTransfers ownership to a new buffer, deallocating the current one. buffer = IO::Buffer.new('test') other = buffer.transfer other # => # # # 0x00000000 74 65 73 74 test buffer # => # # buffer.null? # => true ;T;[o;= ;>I" overload;F;?0;;;@0;:I" transfer;T;IC; ";T;[;![;"I";T;#0;$@\;.F;Bi;C0;7[;$@\;![;"I"zTransfers ownership to a new buffer, deallocating the current one. buffer = IO::Buffer.new('test') other = buffer.transfer other # => # # # 0x00000000 74 65 73 74 test buffer # => # # buffer.null? # => true @overload transfer;T;#0;$@\;.F;/o;0;1T;2i~;3i;%@j[;9I">VALUE rb_io_buffer_transfer(VALUE self) { struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); if (data->flags & RB_IO_BUFFER_LOCKED) { rb_raise(rb_eIOBufferLockedError, "Cannot transfer ownership of locked buffer!"); } VALUE instance = rb_io_buffer_type_allocate(rb_class_of(self)); struct rb_io_buffer *transferred; TypedData_Get_Struct(instance, struct rb_io_buffer, &rb_io_buffer_type, transferred); *transferred = *data; io_buffer_zero(data); return instance; };T;:I" VALUE;T;;To;u;[[@w[im;F;: EXTERNAL;;w;;;[;{;IC; " Flags: ;T;[;![;"I" Flags:;T;#0;$@\;.F;/o;0;1T;2il;3il;%@j[;&I"IO::Buffer::EXTERNAL;F;xI"&RB_INT2NUM(RB_IO_BUFFER_EXTERNAL);To;u;[[@w[in;F;: INTERNAL;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@\;%@j[;&I"IO::Buffer::INTERNAL;F;xI"&RB_INT2NUM(RB_IO_BUFFER_INTERNAL);To;u;[[@w[io;F;: MAPPED;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@\;%@j[;&I"IO::Buffer::MAPPED;F;xI"$RB_INT2NUM(RB_IO_BUFFER_MAPPED);To;u;[[@w[ip;F;: LOCKED;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@\;%@j[;&I"IO::Buffer::LOCKED;F;xI"$RB_INT2NUM(RB_IO_BUFFER_LOCKED);To;u;[[@w[iq;F;: PRIVATE;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@\;%@j[;&I"IO::Buffer::PRIVATE;F;xI"%RB_INT2NUM(RB_IO_BUFFER_PRIVATE);To;u;[[@w[ir;F;: READONLY;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@\;%@j[;&I"IO::Buffer::READONLY;F;xI"&RB_INT2NUM(RB_IO_BUFFER_READONLY);To;u;[[@w[iu;F;:LITTLE_ENDIAN;;w;;;[;{;IC; " Endian: ;T;[;![;"I" Endian:;T;#0;$@\;.F;/o;0;1T;2it;3it;%@j[;&I"IO::Buffer::LITTLE_ENDIAN;F;xI"+RB_INT2NUM(RB_IO_BUFFER_LITTLE_ENDIAN);To;u;[[@w[iv;F;:BIG_ENDIAN;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@\;%@j[;&I"IO::Buffer::BIG_ENDIAN;F;xI"(RB_INT2NUM(RB_IO_BUFFER_BIG_ENDIAN);To;u;[[@w[iw;F;:HOST_ENDIAN;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@];%@j[;&I"IO::Buffer::HOST_ENDIAN;F;xI")RB_INT2NUM(RB_IO_BUFFER_HOST_ENDIAN);To;u;[[@w[ix;F;:NETWORK_ENDIAN;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@ ];%@j[;&I"IO::Buffer::NETWORK_ENDIAN;F;xI",RB_INT2NUM(RB_IO_BUFFER_NETWORK_ENDIAN);To;4;5F;6;;;;&I"IO::Buffer#null?;F;7[;[[@w[i;T;: null?;0;[;{;IC; "RIf the buffer was freed with #free or was never allocated in the first place.;T;[o;= ;>I" overload;F;?0;;;@0;:I" null?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@];![;"I"@return [Boolean];T;#0;$@];.F;Bi;C0;7[;$@];![;"I"yIf the buffer was freed with #free or was never allocated in the first place. @overload null? @return [Boolean];T;#0;$@];.F;/o;0;1T;2i;3i;Bi;%@j[;9I"static VALUE rb_io_buffer_null_p(VALUE self) { struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); return RBOOL(data->base == NULL); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#empty?;F;7[;[[@w[i;T;;;0;[;{;IC; "If the buffer is _external_, meaning it references from memory which is not allocated or mapped by the buffer itself. A buffer created using ::for has an external reference to the string's memory. External buffer can't be resized.;T;[o;= ;>I" overload;F;?0;:external?;@0;:I"external?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@0];![;"I"@return [Boolean];T;#0;$@0];.F;Bi;C0;7[;$@0];![;"I"If the buffer is _external_, meaning it references from memory which is not allocated or mapped by the buffer itself. A buffer created using ::for has an external reference to the string's memory. External buffer can't be resized. @overload external? @return [Boolean];T;#0;$@0];.F;/o;0;1T;2i;3i;Bi;%@j[;9I"static VALUE rb_io_buffer_empty_p(VALUE self) { struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); return RBOOL(data->size == 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#external?;F;7[;[[@w[i;T;;;0;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@K];![;"@;#0;$@K];Bi;%@j[;9I"static VALUE rb_io_buffer_external_p(VALUE self) { struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); return RBOOL(data->flags & RB_IO_BUFFER_EXTERNAL); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#internal?;F;7[;[[@w[i;T;:internal?;0;[;{;IC; "If the buffer is _internal_, meaning it references memory allocated by the buffer itself. An internal buffer is not associated with any external memory (e.g. string) or file mapping. Internal buffers are created using ::new and is the default when the requested size is less than the IO::Buffer::PAGE_SIZE and it was not requested to be mapped on creation. Internal buffers can be resized, and such an operation will typically invalidate all slices, but not always.;T;[o;= ;>I" overload;F;?0;;;@0;:I"internal?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Z];![;"I"@return [Boolean];T;#0;$@Z];.F;Bi;C0;7[;$@Z];![;"I"If the buffer is _internal_, meaning it references memory allocated by the buffer itself. An internal buffer is not associated with any external memory (e.g. string) or file mapping. Internal buffers are created using ::new and is the default when the requested size is less than the IO::Buffer::PAGE_SIZE and it was not requested to be mapped on creation. Internal buffers can be resized, and such an operation will typically invalidate all slices, but not always. @overload internal? @return [Boolean];T;#0;$@Z];.F;/o;0;1T;2i;3i;Bi;%@j[;9I"static VALUE rb_io_buffer_internal_p(VALUE self) { struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); return RBOOL(data->flags & RB_IO_BUFFER_INTERNAL); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#mapped?;F;7[;[[@w[i(;T;: mapped?;0;[;{;IC; "zIf the buffer is _mapped_, meaning it references memory mapped by the buffer. Mapped buffers are either anonymous, if created by ::new with the IO::Buffer::MAPPED flag or if the size was at least IO::Buffer::PAGE_SIZE, or backed by a file if created with ::map. Mapped buffers can usually be resized, and such an operation will typically invalidate all slices, but not always.;T;[o;= ;>I" overload;F;?0;;;@0;:I" mapped?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@u];![;"I"@return [Boolean];T;#0;$@u];.F;Bi;C0;7[;$@u];![;"I"If the buffer is _mapped_, meaning it references memory mapped by the buffer. Mapped buffers are either anonymous, if created by ::new with the IO::Buffer::MAPPED flag or if the size was at least IO::Buffer::PAGE_SIZE, or backed by a file if created with ::map. Mapped buffers can usually be resized, and such an operation will typically invalidate all slices, but not always. @overload mapped? @return [Boolean];T;#0;$@u];.F;/o;0;1T;2i;3i';Bi;%@j[;9I"static VALUE rb_io_buffer_mapped_p(VALUE self) { struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); return RBOOL(data->flags & RB_IO_BUFFER_MAPPED); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#locked?;F;7[;[[@w[i@;T;;T;0;[;{;IC; "bIf the buffer is _locked_, meaning it is inside #locked block execution. Locked buffer can't be resized or freed, and another lock can't be acquired on it. Locking is not thread safe, but is a semantic used to ensure buffers don't move while being used by a system call. buffer.locked do buffer.write(io) # theoretical system call interface end;T;[o;= ;>I" overload;F;?0;;T;@0;:I" locked?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@];![;"I"@return [Boolean];T;#0;$@];.F;Bi;C0;7[;$@];![;"I"If the buffer is _locked_, meaning it is inside #locked block execution. Locked buffer can't be resized or freed, and another lock can't be acquired on it. Locking is not thread safe, but is a semantic used to ensure buffers don't move while being used by a system call. buffer.locked do buffer.write(io) # theoretical system call interface end @overload locked? @return [Boolean];T;#0;$@];.F;/o;0;1T;2i1;3i?;Bi;%@j[;9I"static VALUE rb_io_buffer_locked_p(VALUE self) { struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); return RBOOL(data->flags & RB_IO_BUFFER_LOCKED); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#readonly?;F;7[;[[@w[i[;T;:readonly?;0;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@];![;"@;#0;$@];Bi;%@j[;9I"gstatic VALUE io_buffer_readonly_p(VALUE self) { return RBOOL(rb_io_buffer_readonly_p(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#locked;F;7[;[[@w[i;T;: locked;0;[;{;IC; "Allows to process a buffer in exclusive way, for concurrency-safety. While the block is performed, the buffer is considered locked, and no other code can enter the lock. Also, locked buffer can't be changed with #resize or #free. buffer = IO::Buffer.new(4) buffer.locked? #=> false Fiber.schedule do buffer.locked do buffer.write(io) # theoretical system call interface end end Fiber.schedule do # in `locked': Buffer already locked! (IO::Buffer::LockedError) buffer.locked do buffer.set_string(...) end end The following operations acquire a lock: #resize, #free. Locking is not thread safe. It is designed as a safety net around non-blocking system calls. You can only share a buffer between threads with appropriate synchronisation techniques. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" locked;T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@];![;"I"@yield [];T;#0;$@];.F;Bi;C0;7[;$@];![;"I":Allows to process a buffer in exclusive way, for concurrency-safety. While the block is performed, the buffer is considered locked, and no other code can enter the lock. Also, locked buffer can't be changed with #resize or #free. buffer = IO::Buffer.new(4) buffer.locked? #=> false Fiber.schedule do buffer.locked do buffer.write(io) # theoretical system call interface end end Fiber.schedule do # in `locked': Buffer already locked! (IO::Buffer::LockedError) buffer.locked do buffer.set_string(...) end end The following operations acquire a lock: #resize, #free. Locking is not thread safe. It is designed as a safety net around non-blocking system calls. You can only share a buffer between threads with appropriate synchronisation techniques. @overload locked @yield [];T;#0;$@];.F;/o;0;1T;2i;3i;%@j[;9I"VALUE rb_io_buffer_locked(VALUE self) { struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); if (data->flags & RB_IO_BUFFER_LOCKED) { rb_raise(rb_eIOBufferLockedError, "Buffer already locked!"); } data->flags |= RB_IO_BUFFER_LOCKED; VALUE result = rb_yield(self); data->flags &= ~RB_IO_BUFFER_LOCKED; return result; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#slice;F;7[[I" _offset;T0[I" _length;T0;[[@w[i;T;: slice;0;[;{;IC; "Produce another IO::Buffer which is a slice (or view into) the current one starting at +offset+ bytes and going for +length+ bytes. The slicing happens without copying of memory, and the slice keeps being associated with the original buffer's source (string, or file), if any. Raises RuntimeError if the offset+length is out of the current buffer's bounds. string = 'test' buffer = IO::Buffer.for(string) slice = buffer.slice(1, 2) # => # # # 0x00000000 65 73 es # Put "o" into 0s position of the slice slice.set_string('o', 0) slice # => # # # 0x00000000 6f 73 os # it is also visible at position 1 of the original buffer buffer # => # # # 0x00000000 74 6f 73 74 tost # ...and original string string # => tost ;T;[o;= ;>I" overload;F;?0;;;@0;:I"slice(offset, length);T;IC; ";T;[;![;"I";T;#0;$@];.F;Bi;C0;7[[I" offset;T0[I" length;T0;$@];![;"I"+Produce another IO::Buffer which is a slice (or view into) the current one starting at +offset+ bytes and going for +length+ bytes. The slicing happens without copying of memory, and the slice keeps being associated with the original buffer's source (string, or file), if any. Raises RuntimeError if the offset+length is out of the current buffer's bounds. string = 'test' buffer = IO::Buffer.for(string) slice = buffer.slice(1, 2) # => # # # 0x00000000 65 73 es # Put "o" into 0s position of the slice slice.set_string('o', 0) slice # => # # # 0x00000000 6f 73 os # it is also visible at position 1 of the original buffer buffer # => # # # 0x00000000 74 6f 73 74 tost # ...and original string string # => tost @overload slice(offset, length);T;#0;$@];.F;/o;0;1T;2i;3i;%@j[;9I"&VALUE rb_io_buffer_slice(VALUE self, VALUE _offset, VALUE _length) { // TODO fail on negative offets/lengths. size_t offset = NUM2SIZET(_offset); size_t length = NUM2SIZET(_length); struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); io_buffer_validate_range(data, offset, length); VALUE instance = rb_io_buffer_type_allocate(rb_class_of(self)); struct rb_io_buffer *slice = NULL; TypedData_Get_Struct(instance, struct rb_io_buffer, &rb_io_buffer_type, slice); slice->base = (char*)data->base + offset; slice->size = length; // The source should be the root buffer: if (data->source != Qnil) slice->source = data->source; else slice->source = self; return instance; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#<=>;F;7[[I" other;T0;[[@w[i;T;;Y;0;[;{;IC; "gBuffers are compared by size and exact contents of the memory they are referencing using +memcmp+. ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I"<=>(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@];![;"I"@return [Boolean];T;#0;$@];.F;Bi;C0;7[[I" other;T0;$@];![;"I"Buffers are compared by size and exact contents of the memory they are referencing using +memcmp+. @overload <=>(other) @return [Boolean];T;#0;$@];.F;/o;0;1T;2i;3i;%@j[;9I"static VALUE rb_io_buffer_compare(VALUE self, VALUE other) { const void *ptr1, *ptr2; size_t size1, size2; rb_io_buffer_get_bytes_for_reading(self, &ptr1, &size1); rb_io_buffer_get_bytes_for_reading(other, &ptr2, &size2); if (size1 < size2) { return RB_INT2NUM(-1); } if (size1 > size2) { return RB_INT2NUM(1); } return RB_INT2NUM(memcmp(ptr1, ptr2, size1)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#resize;F;7[[I" size;T0;[[@w[i;T;: resize;0;[;{;IC; "Resizes a buffer to a +new_size+ bytes, preserving its content. Depending on the old and new size, the memory area associated with the buffer might be either extended, or rellocated at different address with content being copied. buffer = IO::Buffer.new(4) buffer.set_string("test", 0) buffer.resize(8) # resize to 8 bytes # => # # # 0x00000000 74 65 73 74 00 00 00 00 test.... External buffer (created with ::for), and locked buffer can not be resized. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"resize(new_size);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@^;![;"I"@return [self];T;#0;$@^;.F;Bi;C0;7[[I" new_size;T0;$@^;![;"I"FResizes a buffer to a +new_size+ bytes, preserving its content. Depending on the old and new size, the memory area associated with the buffer might be either extended, or rellocated at different address with content being copied. buffer = IO::Buffer.new(4) buffer.set_string("test", 0) buffer.resize(8) # resize to 8 bytes # => # # # 0x00000000 74 65 73 74 00 00 00 00 test.... External buffer (created with ::for), and locked buffer can not be resized. @overload resize(new_size) @return [self];T;#0;$@^;.F;/o;0;1T;2i;3i;%@j[;9I"{static VALUE io_buffer_resize(VALUE self, VALUE size) { rb_io_buffer_resize(self, NUM2SIZET(size)); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#clear;F;7[[@90;[[@w[i;T;;;0;[;{;IC; "Fill buffer with +value+, starting with +offset+ and going for +length+ bytes. buffer = IO::Buffer.for('test') # => # # 0x00000000 74 65 73 74 test buffer.clear # => # # 0x00000000 00 00 00 00 .... buf.clear(1) # fill with 1 # => # # 0x00000000 01 01 01 01 .... buffer.clear(2, 1, 2) # fill with 2, starting from offset 1, for 2 bytes # => # # 0x00000000 01 02 02 01 .... buffer.clear(2, 1) # fill with 2, starting from offset 1 # => # # 0x00000000 01 02 02 02 .... ;T;[o;= ;>I" overload;F;?0;;;@0;:I")clear(value = 0, [offset, [length]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@/^;![;"I"@return [self];T;#0;$@/^;.F;Bi;C0;7[[I" value;TI"0;T[I"[offset, [length]];T0;$@/^;![;"I"JFill buffer with +value+, starting with +offset+ and going for +length+ bytes. buffer = IO::Buffer.for('test') # => # # 0x00000000 74 65 73 74 test buffer.clear # => # # 0x00000000 00 00 00 00 .... buf.clear(1) # fill with 1 # => # # 0x00000000 01 01 01 01 .... buffer.clear(2, 1, 2) # fill with 2, starting from offset 1, for 2 bytes # => # # 0x00000000 01 02 02 01 .... buffer.clear(2, 1) # fill with 2, starting from offset 1 # => # # 0x00000000 01 02 02 02 .... @overload clear(value = 0, [offset, [length]]) @return [self];T;#0;$@/^;.F;/o;0;1T;2i;3i;%@j[;9I"dstatic VALUE io_buffer_clear(int argc, VALUE *argv, VALUE self) { if (argc > 3) rb_error_arity(argc, 0, 3); struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); uint8_t value = 0; if (argc >= 1) { value = NUM2UINT(argv[0]); } size_t offset = 0; if (argc >= 2) { offset = NUM2SIZET(argv[1]); } size_t length; if (argc >= 3) { length = NUM2SIZET(argv[2]); } else { length = data->size - offset; } rb_io_buffer_clear(self, value, offset, length); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#free;F;7[;[[@w[i;T;: free;0;[;{;IC; "If the buffer references memory, release it back to the operating system. * for a _mapped_ buffer (e.g. from file): unmap. * for a buffer created from scratch: free memory. * for a buffer created from string: undo the association. After the buffer is freed, no further operations can't be performed on it. buffer = IO::Buffer.for('test') buffer.free # => # buffer.get_value(:U8, 0) # in `get_value': The buffer is not allocated! (IO::Buffer::AllocationError) buffer.get_string # in `get_string': The buffer is not allocated! (IO::Buffer::AllocationError) buffer.null? # => true You can resize a freed buffer to re-allocate it. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" free;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@P^;![;"I"@return [self];T;#0;$@P^;.F;Bi;C0;7[;$@P^;![;"I"If the buffer references memory, release it back to the operating system. * for a _mapped_ buffer (e.g. from file): unmap. * for a buffer created from scratch: free memory. * for a buffer created from string: undo the association. After the buffer is freed, no further operations can't be performed on it. buffer = IO::Buffer.for('test') buffer.free # => # buffer.get_value(:U8, 0) # in `get_value': The buffer is not allocated! (IO::Buffer::AllocationError) buffer.get_string # in `get_string': The buffer is not allocated! (IO::Buffer::AllocationError) buffer.null? # => true You can resize a freed buffer to re-allocate it. @overload free @return [self];T;#0;$@P^;.F;/o;0;1T;2i;3i;%@j[;9I"=VALUE rb_io_buffer_free(VALUE self) { struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); if (data->flags & RB_IO_BUFFER_LOCKED) { rb_raise(rb_eIOBufferLockedError, "Buffer is locked!"); } io_buffer_free(data); return self; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#get_value;F;7[[I" type;T0[I" _offset;T0;[[@w[i;T;:get_value;0;[;{;IC; "Read from buffer a value of +type+ at +offset+. +type+ should be one of symbols: * +:U8+: unsigned integer, 1 byte * +:S8+: signed integer, 1 byte * +:u16+: unsigned integer, 2 bytes, little-endian * +:U16+: unsigned integer, 2 bytes, big-endian * +:s16+: signed integer, 2 bytes, little-endian * +:S16+: signed integer, 2 bytes, big-endian * +:u32+: unsigned integer, 4 bytes, little-endian * +:U32+: unsigned integer, 4 bytes, big-endian * +:s32+: signed integer, 4 bytes, little-endian * +:S32+: signed integer, 4 bytes, big-endian * +:u64+: unsigned integer, 8 bytes, little-endian * +:U64+: unsigned integer, 8 bytes, big-endian * +:s64+: signed integer, 8 bytes, little-endian * +:S64+: signed integer, 8 bytes, big-endian * +:f32+: float, 4 bytes, little-endian * +:F32+: float, 4 bytes, big-endian * +:f64+: double, 8 bytes, little-endian * +:F64+: double, 8 bytes, big-endian Example: string = [1.5].pack('f') # => "\x00\x00\xC0?" IO::Buffer.for(string).get_value(:f32, 0) # => 1.5 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"get_value(type, offset);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@k^;![;"I"@return [Numeric];T;#0;$@k^;.F;Bi;C0;7[[I" type;T0[I" offset;T0;$@k^;![;"I""Read from buffer a value of +type+ at +offset+. +type+ should be one of symbols: * +:U8+: unsigned integer, 1 byte * +:S8+: signed integer, 1 byte * +:u16+: unsigned integer, 2 bytes, little-endian * +:U16+: unsigned integer, 2 bytes, big-endian * +:s16+: signed integer, 2 bytes, little-endian * +:S16+: signed integer, 2 bytes, big-endian * +:u32+: unsigned integer, 4 bytes, little-endian * +:U32+: unsigned integer, 4 bytes, big-endian * +:s32+: signed integer, 4 bytes, little-endian * +:S32+: signed integer, 4 bytes, big-endian * +:u64+: unsigned integer, 8 bytes, little-endian * +:U64+: unsigned integer, 8 bytes, big-endian * +:s64+: signed integer, 8 bytes, little-endian * +:S64+: signed integer, 8 bytes, big-endian * +:f32+: float, 4 bytes, little-endian * +:F32+: float, 4 bytes, big-endian * +:f64+: double, 8 bytes, little-endian * +:F64+: double, 8 bytes, big-endian Example: string = [1.5].pack('f') # => "\x00\x00\xC0?" IO::Buffer.for(string).get_value(:f32, 0) # => 1.5 @overload get_value(type, offset) @return [Numeric];T;#0;$@k^;.F;/o;0;1T;2i;3i;%@j[;9I" static VALUE io_buffer_get_value(VALUE self, VALUE type, VALUE _offset) { const void *base; size_t size; size_t offset = NUM2SIZET(_offset); rb_io_buffer_get_bytes_for_reading(self, &base, &size); return rb_io_buffer_get_value(base, size, RB_SYM2ID(type), offset); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#set_value;F;7[[I" type;T0[I" _offset;T0[I" value;T0;[[@w[i;T;:set_value;0;[;{;IC; "Write to a buffer a +value+ of +type+ at +offset+. +type+ should be one of symbols described in #get_value. buffer = IO::Buffer.new(8) # => # # # 0x00000000 00 00 00 00 00 00 00 00 buffer.set_value(:U8, 1, 111) # => 1 buffer # => # # # 0x00000000 00 6f 00 00 00 00 00 00 .o...... Note that if the +type+ is integer and +value+ is Float, the implicit truncation is performed: buffer = IO::Buffer.new(8) buffer.set_value(:U32, 0, 2.5) buffer # => # # # 0x00000000 00 00 00 02 00 00 00 00 # ^^ the same as if we'd pass just integer 2 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"#set_value(type, offset, value);T;IC; ";T;[;![;"I";T;#0;$@^;.F;Bi;C0;7[[I" type;T0[I" offset;T0[I" value;T0;$@^;![;"I"Write to a buffer a +value+ of +type+ at +offset+. +type+ should be one of symbols described in #get_value. buffer = IO::Buffer.new(8) # => # # # 0x00000000 00 00 00 00 00 00 00 00 buffer.set_value(:U8, 1, 111) # => 1 buffer # => # # # 0x00000000 00 6f 00 00 00 00 00 00 .o...... Note that if the +type+ is integer and +value+ is Float, the implicit truncation is performed: buffer = IO::Buffer.new(8) buffer.set_value(:U32, 0, 2.5) buffer # => # # # 0x00000000 00 00 00 02 00 00 00 00 # ^^ the same as if we'd pass just integer 2 @overload set_value(type, offset, value);T;#0;$@^;.F;/o;0;1T;2i;3i;%@j[;9I"Fstatic VALUE io_buffer_set_value(VALUE self, VALUE type, VALUE _offset, VALUE value) { void *base; size_t size; size_t offset = NUM2SIZET(_offset); rb_io_buffer_get_bytes_for_writing(self, &base, &size); rb_io_buffer_set_value(base, size, RB_SYM2ID(type), offset, value); return SIZET2NUM(offset); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#copy;F;7[[@90;[[@w[i;T;: copy;0;[;{;IC; "GEfficiently copy data from a source IO::Buffer into the buffer, at +offset+ using +memcpy+. For copying String instances, see #set_string. buffer = IO::Buffer.new(32) # => # # # 0x00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ # 0x00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ * buffer.copy(IO::Buffer.for("test"), 8) # => 4 -- size of data copied buffer # => # # # 0x00000000 00 00 00 00 00 00 00 00 74 65 73 74 00 00 00 00 ........test.... # 0x00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ * #copy can be used to put data into strings associated with buffer: string= "data: " # => "data: " buffer = IO::Buffer.for(str) buffer.copy(IO::Buffer.for("test"), 5) # => 4 string # => "data:test" Attempt to copy into a read-only buffer will fail: File.write('test.txt', 'test') buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY) buffer.copy(IO::Buffer.for("test"), 8) # in `copy': Buffer is not writable! (IO::Buffer::AccessError) See ::map for details of creation of mutable file mappings, this will work: buffer = IO::Buffer.map(File.open('test.txt', 'r+')) buffer.copy("boom", 0) # => 4 File.read('test.txt') # => "boom" Attempt to copy the data which will need place outside of buffer's bounds will fail: buffer = IO::Buffer.new(2) buffer.copy('test', 0) # in `copy': Specified offset+length exceeds source size! (ArgumentError) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"6copy(source, [offset, [length, [source_offset]]]);T;IC; ";T;[;![;"I";T;#0;$@^;.F;Bi;C0;7[[I" source;T0[I"([offset, [length, [source_offset]]];T0;$@^;![;"I"Efficiently copy data from a source IO::Buffer into the buffer, at +offset+ using +memcpy+. For copying String instances, see #set_string. buffer = IO::Buffer.new(32) # => # # # 0x00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ # 0x00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ * buffer.copy(IO::Buffer.for("test"), 8) # => 4 -- size of data copied buffer # => # # # 0x00000000 00 00 00 00 00 00 00 00 74 65 73 74 00 00 00 00 ........test.... # 0x00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ * #copy can be used to put data into strings associated with buffer: string= "data: " # => "data: " buffer = IO::Buffer.for(str) buffer.copy(IO::Buffer.for("test"), 5) # => 4 string # => "data:test" Attempt to copy into a read-only buffer will fail: File.write('test.txt', 'test') buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY) buffer.copy(IO::Buffer.for("test"), 8) # in `copy': Buffer is not writable! (IO::Buffer::AccessError) See ::map for details of creation of mutable file mappings, this will work: buffer = IO::Buffer.map(File.open('test.txt', 'r+')) buffer.copy("boom", 0) # => 4 File.read('test.txt') # => "boom" Attempt to copy the data which will need place outside of buffer's bounds will fail: buffer = IO::Buffer.new(2) buffer.copy('test', 0) # in `copy': Specified offset+length exceeds source size! (ArgumentError) @overload copy(source, [offset, [length, [source_offset]]]);T;#0;$@^;.F;/o;0;1T;2i\;3i;%@j[;9I"static VALUE io_buffer_copy(int argc, VALUE *argv, VALUE self) { if (argc < 1 || argc > 4) rb_error_arity(argc, 1, 4); struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); VALUE source = argv[0]; const void *source_base; size_t source_size; rb_io_buffer_get_bytes_for_reading(source, &source_base, &source_size); return io_buffer_copy_from(data, source_base, source_size, argc-1, argv+1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#get_string;F;7[[@90;[[@w[i;T;:get_string;0;[;{;IC; "Read a chunk or all of the buffer into a string, in the specified +encoding+. If no encoding is provided +Encoding::BINARY+ is used. buffer = IO::Buffer.for('test') buffer.get_string # => "test" buffer.get_string(2) # => "st" buffer.get_string(2, 1) # => "s" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"/get_string([offset, [length, [encoding]]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@^;![;"I"@return [String];T;#0;$@^;.F;Bi;C0;7[[I"#[offset, [length, [encoding]]];T0;$@^;![;"I"dRead a chunk or all of the buffer into a string, in the specified +encoding+. If no encoding is provided +Encoding::BINARY+ is used. buffer = IO::Buffer.for('test') buffer.get_string # => "test" buffer.get_string(2) # => "st" buffer.get_string(2, 1) # => "s" @overload get_string([offset, [length, [encoding]]]) @return [String];T;#0;$@^;.F;/o;0;1T;2i;3i;%@j[;9I"Bstatic VALUE io_buffer_get_string(int argc, VALUE *argv, VALUE self) { if (argc > 3) rb_error_arity(argc, 0, 3); struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); const void *base; size_t size; io_buffer_get_bytes_for_reading(data, &base, &size); size_t offset = 0; size_t length = size; rb_encoding *encoding = rb_ascii8bit_encoding(); if (argc >= 1) { offset = NUM2SIZET(argv[0]); } if (argc >= 2 && !RB_NIL_P(argv[1])) { length = NUM2SIZET(argv[1]); } else { length = size - offset; } if (argc >= 3) { encoding = rb_find_encoding(argv[2]); } io_buffer_validate_range(data, offset, length); return rb_enc_str_new((const char*)base + offset, length, encoding); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#set_string;F;7[[@90;[[@w[i;T;:set_string;0;[;{;IC; " ;T;[;![;"@;#0;$@^;%@j[;9I"static VALUE io_buffer_set_string(int argc, VALUE *argv, VALUE self) { if (argc < 1 || argc > 4) rb_error_arity(argc, 1, 4); struct rb_io_buffer *data = NULL; TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data); VALUE string = rb_str_to_str(argv[0]); const void *source_base = RSTRING_PTR(string); size_t source_size = RSTRING_LEN(string); return io_buffer_copy_from(data, source_base, source_size, argc-1, argv+1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#read;F;7[[I"io;T0[I" length;T0;[[@w[ih;T;;q;0;[;{;IC; "IO operations: ;T;[;![;"I"IO operations:;T;#0;$@^;.F;/o;0;1T;2i;3i;%@j[;9I"static VALUE io_buffer_read(VALUE self, VALUE io, VALUE length) { return rb_io_buffer_read(self, io, RB_NUM2SIZE(length)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#pread;F;7[[I"io;T0[I" length;T0[I" offset;T0;[[@w[i;T;;~;0;[;{;IC; " ;T;[;![;"@;#0;$@_;%@j[;9I"static VALUE io_buffer_pread(VALUE self, VALUE io, VALUE length, VALUE offset) { return rb_io_buffer_pread(self, io, RB_NUM2SIZE(length), NUM2OFFT(offset)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#write;F;7[[I"io;T0[I" length;T0;[[@w[i;T;;s;0;[;{;IC; " ;T;[;![;"@;#0;$@_;%@j[;9I"static VALUE io_buffer_write(VALUE self, VALUE io, VALUE length) { return rb_io_buffer_write(self, io, RB_NUM2SIZE(length)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::Buffer#pwrite;F;7[[I"io;T0[I" length;T0[I" offset;T0;[[@w[i;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@*_;%@j[;9I"static VALUE io_buffer_pwrite(VALUE self, VALUE io, VALUE length, VALUE offset) { return rb_io_buffer_pwrite(self, io, RB_NUM2SIZE(length), NUM2OFFT(offset)); };T;:I"static VALUE;T;;T; @j[; IC;[; @j[; IC;[o;( ;)0;*0;+0;:Comparable;%@;-o;;IC;[ o;4;5F;6;;;;&I"Comparable#==;F;7[[I"y;T0;[[I" compar.c;TiS;T;;F;0;[;{;IC; "Compares two objects based on the receiver's <=> method, returning true if it returns 0. Also returns true if _obj_ and _other_ are the same object. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@A_;![;"I"@return [Boolean];T;#0;$@A_;.F;Bi;C0;7[[I" other;T0;$@A_;![;"I"Compares two objects based on the receiver's <=> method, returning true if it returns 0. Also returns true if _obj_ and _other_ are the same object. @overload ==(other) @return [Boolean];T;#0;$@A_;.F;/o;0;1T;2iJ;3iP;%@?_;9I"static VALUE cmp_equal(VALUE x, VALUE y) { VALUE c; if (x == y) return Qtrue; c = rb_exec_recursive_paired_outer(cmp_eq_recursive, x, y, y); if (NIL_P(c)) return Qfalse; return RBOOL(rb_cmpint(c, x, y) == 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Comparable#>;F;7[[I"y;T0;[[@H_im;T;;;0;[;{;IC; "Compares two objects based on the receiver's <=> method, returning true if it returns a value greater than 0. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" >(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@a_;![;"I"@return [Boolean];T;#0;$@a_;.F;Bi;C0;7[[I" other;T0;$@a_;![;"I"Compares two objects based on the receiver's <=> method, returning true if it returns a value greater than 0. @overload >(other) @return [Boolean];T;#0;$@a_;.F;/o;0;1T;2ie;3ij;%@?_;9I"Rstatic VALUE cmp_gt(VALUE x, VALUE y) { return RBOOL(cmpint(x, y) > 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Comparable#>=;F;7[[I"y;T0;[[@H_i{;T;;;0;[;{;IC; "Compares two objects based on the receiver's <=> method, returning true if it returns a value greater than or equal to 0. ;T;[o;= ;>I" overload;F;?0;;;@0;:I">=(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@_;![;"I"@return [Boolean];T;#0;$@_;.F;Bi;C0;7[[I" other;T0;$@_;![;"I"Compares two objects based on the receiver's <=> method, returning true if it returns a value greater than or equal to 0. @overload >=(other) @return [Boolean];T;#0;$@_;.F;/o;0;1T;2is;3ix;%@?_;9I"Sstatic VALUE cmp_ge(VALUE x, VALUE y) { return RBOOL(cmpint(x, y) >= 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Comparable#<;F;7[[I"y;T0;[[@H_i;T;;;0;[;{;IC; "|Compares two objects based on the receiver's <=> method, returning true if it returns a value less than 0. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" <(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@_;![;"I"@return [Boolean];T;#0;$@_;.F;Bi;C0;7[[I" other;T0;$@_;![;"I"Compares two objects based on the receiver's <=> method, returning true if it returns a value less than 0. @overload <(other) @return [Boolean];T;#0;$@_;.F;/o;0;1T;2i|;3i;%@?_;9I"Rstatic VALUE cmp_lt(VALUE x, VALUE y) { return RBOOL(cmpint(x, y) < 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Comparable#<=;F;7[[I"y;T0;[[@H_i;T;;;0;[;{;IC; "Compares two objects based on the receiver's <=> method, returning true if it returns a value less than or equal to 0. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"<=(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@_;![;"I"@return [Boolean];T;#0;$@_;.F;Bi;C0;7[[I" other;T0;$@_;![;"I"Compares two objects based on the receiver's <=> method, returning true if it returns a value less than or equal to 0. @overload <=(other) @return [Boolean];T;#0;$@_;.F;/o;0;1T;2i;3i;%@?_;9I"Sstatic VALUE cmp_le(VALUE x, VALUE y) { return RBOOL(cmpint(x, y) <= 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Comparable#between?;F;7[[I"min;T0[I"max;T0;[[@H_i;T;: between?;0;[;{;IC; "QReturns false if _obj_ <=> _min_ is less than zero or if _obj_ <=> _max_ is greater than zero, true otherwise. 3.between?(1, 5) #=> true 6.between?(1, 5) #=> false 'cat'.between?('ant', 'dog') #=> true 'gnu'.between?('ant', 'dog') #=> false;T;[o;= ;>I" overload;F;?0;;;@0;:I"between?(min, max);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@_;![;"I"@return [Boolean];T;#0;$@_;.F;Bi;C0;7[[I"min;T0[I"max;T0;$@_;![;"I"Returns false if _obj_ <=> _min_ is less than zero or if _obj_ <=> _max_ is greater than zero, true otherwise. 3.between?(1, 5) #=> true 6.between?(1, 5) #=> false 'cat'.between?('ant', 'dog') #=> true 'gnu'.between?('ant', 'dog') #=> false @overload between?(min, max) @return [Boolean];T;#0;$@_;.F;/o;0;1T;2i;3i;Bi;%@?_;9I"static VALUE cmp_between(VALUE x, VALUE min, VALUE max) { if (cmpint(x, min) < 0) return Qfalse; if (cmpint(x, max) > 0) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Comparable#clamp;F;7[[@90;[[@H_i;T;: clamp;0;[;{;IC; "!In (min, max) form, returns _min_ if _obj_ <=> _min_ is less than zero, _max_ if _obj_ <=> _max_ is greater than zero, and _obj_ otherwise. 12.clamp(0, 100) #=> 12 523.clamp(0, 100) #=> 100 -3.123.clamp(0, 100) #=> 0 'd'.clamp('a', 'f') #=> 'd' 'z'.clamp('a', 'f') #=> 'f' In (range) form, returns _range.begin_ if _obj_ <=> _range.begin_ is less than zero, _range.end_ if _obj_ <=> _range.end_ is greater than zero, and _obj_ otherwise. 12.clamp(0..100) #=> 12 523.clamp(0..100) #=> 100 -3.123.clamp(0..100) #=> 0 'd'.clamp('a'..'f') #=> 'd' 'z'.clamp('a'..'f') #=> 'f' If _range.begin_ is +nil+, it is considered smaller than _obj_, and if _range.end_ is +nil+, it is considered greater than _obj_. -20.clamp(0..) #=> 0 523.clamp(..100) #=> 100 When _range.end_ is excluded and not +nil+, an exception is raised. 100.clamp(0...100) # ArgumentError ;T;[o;= ;>I" overload;F;?0;;;@0;:I"clamp(min, max);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@`;![;"I"@return [Object];T;#0;$@`;.F;Bi;C0;7[[I"min;T0[I"max;T0;$@`o;= ;>I" overload;F;?0;;;@0;:I"clamp(range);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@`;![;"I"@return [Object];T;#0;$@`;.F;Bi;C0;7[[I" range;T0;$@`;![;"I"zIn (min, max) form, returns _min_ if _obj_ <=> _min_ is less than zero, _max_ if _obj_ <=> _max_ is greater than zero, and _obj_ otherwise. 12.clamp(0, 100) #=> 12 523.clamp(0, 100) #=> 100 -3.123.clamp(0, 100) #=> 0 'd'.clamp('a', 'f') #=> 'd' 'z'.clamp('a', 'f') #=> 'f' In (range) form, returns _range.begin_ if _obj_ <=> _range.begin_ is less than zero, _range.end_ if _obj_ <=> _range.end_ is greater than zero, and _obj_ otherwise. 12.clamp(0..100) #=> 12 523.clamp(0..100) #=> 100 -3.123.clamp(0..100) #=> 0 'd'.clamp('a'..'f') #=> 'd' 'z'.clamp('a'..'f') #=> 'f' If _range.begin_ is +nil+, it is considered smaller than _obj_, and if _range.end_ is +nil+, it is considered greater than _obj_. -20.clamp(0..) #=> 0 523.clamp(..100) #=> 100 When _range.end_ is excluded and not +nil+, an exception is raised. 100.clamp(0...100) # ArgumentError @overload clamp(min, max) @return [Object] @overload clamp(range) @return [Object];T;#0;$@`;.F;/o;0;1T;2i;3i;%@?_;9I"nstatic VALUE cmp_clamp(int argc, VALUE *argv, VALUE x) { VALUE min, max; int c, excl = 0; if (rb_scan_args(argc, argv, "11", &min, &max) == 1) { VALUE range = min; if (!rb_range_values(range, &min, &max, &excl)) { rb_raise(rb_eTypeError, "wrong argument type %s (expected Range)", rb_builtin_class_name(range)); } if (!NIL_P(max)) { if (excl) rb_raise(rb_eArgError, "cannot clamp with an exclusive range"); } } if (!NIL_P(min) && !NIL_P(max) && cmpint(min, max) > 0) { rb_raise(rb_eArgError, "min argument must be smaller than max argument"); } if (!NIL_P(min)) { c = cmpint(x, min); if (c == 0) return x; if (c < 0) return min; } if (!NIL_P(max)) { c = cmpint(x, max); if (c > 0) return max; } return x; };T;:I"static VALUE;T;;T; @?_; IC;[; @?_; IC;[; @?_; IC;{;IC;{;T;IC;{;T;T;{;[;[[@H_i4;F;;;;;;;[;{;IC; "The Comparable mixin is used by classes whose objects may be ordered. The class must define the <=> operator, which compares the receiver against another object, returning a value less than 0, returning 0, or returning a value greater than 0, depending on whether the receiver is less than, equal to, or greater than the other object. If the other object is not comparable then the <=> operator should return +nil+. Comparable uses <=> to implement the conventional comparison operators (<, <=, ==, >=, and >) and the method between?. class SizeMatters include Comparable attr :str def <=>(other) str.size <=> other.str.size end def initialize(str) @str = str end def inspect @str end end s1 = SizeMatters.new("Z") s2 = SizeMatters.new("YY") s3 = SizeMatters.new("XXX") s4 = SizeMatters.new("WWWW") s5 = SizeMatters.new("VVVVV") s1 < s2 #=> true s4.between?(s1, s3) #=> false s4.between?(s3, s5) #=> true [ s3, s2, s5, s4, s1 ].sort #=> [Z, YY, XXX, WWWW, VVVVV] == What's Here \Module \Comparable provides these methods, all of which use method <=>: - {<}[#method-i-3C]:: Returns whether +self+ is less than the given object. - {<=}[#method-i-3C-3D]:: Returns whether +self+ is less than or equal to the given object. - {==}[#method-i-3D-3D]:: Returns whether +self+ is equal to the given object. - {>}[#method-i-3E]:: Returns whether +self+ is greater than or equal to the given object. - {>=}[#method-i-3E-3D]:: Returns whether +self+ is greater than the given object. - #between? Returns +true+ if +self+ is between two given objects. - #clamp:: For given objects +min+ and +max+, or range (min..max), returns: - +min+ if (self <=> min) < 0. - +max+ if (self <=> max) > 0. - +self+ otherwise. ;T;[;![;"I"The Comparable mixin is used by classes whose objects may be ordered. The class must define the <=> operator, which compares the receiver against another object, returning a value less than 0, returning 0, or returning a value greater than 0, depending on whether the receiver is less than, equal to, or greater than the other object. If the other object is not comparable then the <=> operator should return +nil+. Comparable uses <=> to implement the conventional comparison operators (<, <=, ==, >=, and >) and the method between?. class SizeMatters include Comparable attr :str def <=>(other) str.size <=> other.str.size end def initialize(str) @str = str end def inspect @str end end s1 = SizeMatters.new("Z") s2 = SizeMatters.new("YY") s3 = SizeMatters.new("XXX") s4 = SizeMatters.new("WWWW") s5 = SizeMatters.new("VVVVV") s1 < s2 #=> true s4.between?(s1, s3) #=> false s4.between?(s3, s5) #=> true [ s3, s2, s5, s4, s1 ].sort #=> [Z, YY, XXX, WWWW, VVVVV] == What's Here \Module \Comparable provides these methods, all of which use method <=>: - {<}[#method-i-3C]:: Returns whether +self+ is less than the given object. - {<=}[#method-i-3C-3D]:: Returns whether +self+ is less than or equal to the given object. - {==}[#method-i-3D-3D]:: Returns whether +self+ is equal to the given object. - {>}[#method-i-3E]:: Returns whether +self+ is greater than or equal to the given object. - {>=}[#method-i-3E-3D]:: Returns whether +self+ is greater than the given object. - #between? Returns +true+ if +self+ is between two given objects. - #clamp:: For given objects +min+ and +max+, or range (min..max), returns: - +min+ if (self <=> min) < 0. - +max+ if (self <=> max) > 0. - +self+ otherwise. ;T;#0;$@?_;.F;/o;0;1T;2i;3i.;%@;&I"Comparable;F;0; @j[; IC;{;IC;{;T;IC;{;T;T;{;[;[[@w[i[@w[iH;T;: Buffer;;;;;[;{;IC; " IO::Buffer is a low-level efficient buffer for input/output. There are three ways of using buffer: * Create an empty buffer with ::new, fill it with data using #copy or #set_value, #set_string, get data with #get_string; * Create a buffer mapped to some string with ::for, then it could be used both for reading with #get_string or #get_value, and writing (writing will change the source string, too); * Create a buffer mapped to some file with ::map, then it could be used for reading and writing the underlying file. Interaction with string and file memory is performed by efficient low-level C mechanisms like `memcpy`. The class is meant to be an utility for implementing more high-level mechanisms like Fiber::SchedulerInterface#io_read and Fiber::SchedulerInterface#io_write. Examples of usage: Empty buffer: buffer = IO::Buffer.new(8) # create empty 8-byte buffer # => # # # ... buffer # => # # 0x00000000 00 00 00 00 00 00 00 00 buffer.set_string('test', 2) # put there bytes of the "test" string, starting from offset 2 # => 4 buffer.get_string # get the result # => "\x00\x00test\x00\x00" \Buffer from string: string = 'data' buffer = IO::Buffer.for(str) # => # # # ... buffer # => # # # 0x00000000 64 61 74 61 data buffer.get_string(2) # read content starting from offset 2 # => "ta" buffer.set_string('---', 1) # write content, starting from offset 1 # => 3 buffer # => # # # 0x00000000 64 2d 2d 2d d--- string # original string changed, too # => "d---" \Buffer from file: File.write('test.txt', 'test data') # => 9 buffer = IO::Buffer.map(File.open('test.txt')) # => # # # ... buffer.get_string(5, 2) # read 2 bytes, starting from offset 5 # => "da" buffer.set_string('---', 1) # attempt to write # in `set_string': Buffer is not writable! (IO::Buffer::AccessError) # To create writable file-mapped buffer # Open file for read-write, pass size, offset, and flags=0 buffer = IO::Buffer.map(File.open('test.txt', 'r+'), 9, 0, 0) buffer.set_string('---', 1) # => 3 -- bytes written File.read('test.txt') # => "t--- data" The class is experimental and the interface is subject to change.;T;[;![;"I" IO::Buffer is a low-level efficient buffer for input/output. There are three ways of using buffer: * Create an empty buffer with ::new, fill it with data using #copy or #set_value, #set_string, get data with #get_string; * Create a buffer mapped to some string with ::for, then it could be used both for reading with #get_string or #get_value, and writing (writing will change the source string, too); * Create a buffer mapped to some file with ::map, then it could be used for reading and writing the underlying file. Interaction with string and file memory is performed by efficient low-level C mechanisms like `memcpy`. The class is meant to be an utility for implementing more high-level mechanisms like Fiber::SchedulerInterface#io_read and Fiber::SchedulerInterface#io_write. Examples of usage: Empty buffer: buffer = IO::Buffer.new(8) # create empty 8-byte buffer # => # # # ... buffer # => # # 0x00000000 00 00 00 00 00 00 00 00 buffer.set_string('test', 2) # put there bytes of the "test" string, starting from offset 2 # => 4 buffer.get_string # get the result # => "\x00\x00test\x00\x00" \Buffer from string: string = 'data' buffer = IO::Buffer.for(str) # => # # # ... buffer # => # # # 0x00000000 64 61 74 61 data buffer.get_string(2) # read content starting from offset 2 # => "ta" buffer.set_string('---', 1) # write content, starting from offset 1 # => 3 buffer # => # # # 0x00000000 64 2d 2d 2d d--- string # original string changed, too # => "d---" \Buffer from file: File.write('test.txt', 'test data') # => 9 buffer = IO::Buffer.map(File.open('test.txt')) # => # # # ... buffer.get_string(5, 2) # read 2 bytes, starting from offset 5 # => "da" buffer.set_string('---', 1) # attempt to write # in `set_string': Buffer is not writable! (IO::Buffer::AccessError) # To create writable file-mapped buffer # Open file for read-write, pass size, offset, and flags=0 buffer = IO::Buffer.map(File.open('test.txt', 'r+'), 9, 0, 0) buffer.set_string('---', 1) # => 3 -- bytes written File.read('test.txt') # => "t--- data" The class is experimental and the interface is subject to change. ;T;#0;$@j[;.F;/o;0;1T;2i;3iB;Bi;%o;( ;)0;*0;+0;:IO;%@;-@kL;0;&I"IO::Buffer;F;'@o;4;5F;6;;;;&I" IO#raw;F;7[[@90;[[I"ext/io/console/console.c;Ti;T;:raw;0;[;{;IC; "ZYields +self+ within raw mode, and returns the result of the block. STDIN.raw(&:gets) will read and return a line without echo back and line editing. The parameter +min+ specifies the minimum number of bytes that should be received when a read operation is performed. (default: 1) The parameter +time+ specifies the timeout in _seconds_ with a precision of 1/10 of a second. (default: 0) If the parameter +intr+ is +true+, enables break, interrupt, quit, and suspend special characters. Refer to the manual page of termios for further details. You must require 'io/console' to use this method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"(raw(min: nil, time: nil, intr: nil);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"io;T;$@Q`;![;"I"@yield [io];T;#0;$@Q`;.F;Bi;C0;7[[I" min:;TI"nil;T[I" time:;TI"nil;T[I" intr:;TI"nil;T;$@Q`;![;"I"Yields +self+ within raw mode, and returns the result of the block. STDIN.raw(&:gets) will read and return a line without echo back and line editing. The parameter +min+ specifies the minimum number of bytes that should be received when a read operation is performed. (default: 1) The parameter +time+ specifies the timeout in _seconds_ with a precision of 1/10 of a second. (default: 0) If the parameter +intr+ is +true+, enables break, interrupt, quit, and suspend special characters. Refer to the manual page of termios for further details. You must require 'io/console' to use this method. @overload raw(min: nil, time: nil, intr: nil) @yield [io];T;#0;$@Q`;.F;/o;0;1T;2ir;3i;%@kL;9I"static VALUE console_raw(int argc, VALUE *argv, VALUE io) { rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 0, &opts); return ttymode(io, rb_yield, io, set_rawmode, optp); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#raw!;F;7[[@90;[[@W`i;T;: raw!;0;[;{;IC; "Enables raw mode, and returns +io+. If the terminal mode needs to be back, use io.raw { ... }. See IO#raw for details on the parameters. You must require 'io/console' to use this method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I")raw!(min: nil, time: nil, intr: nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"IO;T;$@w`;![;"I"@return [IO];T;#0;$@w`;.F;Bi;C0;7[[I" min:;TI"nil;T[I" time:;TI"nil;T[I" intr:;TI"nil;T;$@w`;![;"I" Enables raw mode, and returns +io+. If the terminal mode needs to be back, use io.raw { ... }. See IO#raw for details on the parameters. You must require 'io/console' to use this method. @overload raw!(min: nil, time: nil, intr: nil) @return [IO];T;#0;$@w`;.F;/o;0;1T;2i;3i;%@kL;9I"tstatic VALUE console_set_raw(int argc, VALUE *argv, VALUE io) { conmode t; rb_io_t *fptr; int fd; rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 0, &opts); GetOpenFile(io, fptr); fd = GetReadFD(fptr); if (!getattr(fd, &t)) sys_fail_fptr(fptr); set_rawmode(&t, optp); if (!setattr(fd, &t)) sys_fail_fptr(fptr); return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#cooked;F;7[;[[@W`i;T;: cooked;0;[;{;IC; "Yields +self+ within cooked mode. STDIN.cooked(&:gets) will read and return a line with echo back and line editing. You must require 'io/console' to use this method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" cooked;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"io;T;$@`;![;"I"@yield [io];T;#0;$@`;.F;Bi;C0;7[;$@`;![;"I"Yields +self+ within cooked mode. STDIN.cooked(&:gets) will read and return a line with echo back and line editing. You must require 'io/console' to use this method. @overload cooked @yield [io];T;#0;$@`;.F;/o;0;1T;2i;3i;%@kL;9I"jstatic VALUE console_cooked(VALUE io) { return ttymode(io, rb_yield, io, set_cookedmode, NULL); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#cooked!;F;7[;[[@W`i;T;: cooked!;0;[;{;IC; "Enables cooked mode. If the terminal mode needs to be back, use io.cooked { ... }. You must require 'io/console' to use this method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" cooked!;T;IC; ";T;[;![;"I";T;#0;$@`;.F;Bi;C0;7[;$@`;![;"I"Enables cooked mode. If the terminal mode needs to be back, use io.cooked { ... }. You must require 'io/console' to use this method. @overload cooked!;T;#0;$@`;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE console_set_cooked(VALUE io) { conmode t; rb_io_t *fptr; int fd; GetOpenFile(io, fptr); fd = GetReadFD(fptr); if (!getattr(fd, &t)) sys_fail_fptr(fptr); set_cookedmode(&t, NULL); if (!setattr(fd, &t)) sys_fail_fptr(fptr); return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#getch;F;7[[@90;[[@W`i;T;;;0;[;{;IC; "Reads and returns a character in raw mode. See IO#raw for details on the parameters. You must require 'io/console' to use this method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"*getch(min: nil, time: nil, intr: nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@`;![;"I"@return [String];T;#0;$@`;.F;Bi;C0;7[[I" min:;TI"nil;T[I" time:;TI"nil;T[I" intr:;TI"nil;T;$@`;![;"I"Reads and returns a character in raw mode. See IO#raw for details on the parameters. You must require 'io/console' to use this method. @overload getch(min: nil, time: nil, intr: nil) @return [String];T;#0;$@`;.F;/o;0;1T;2i;3i;%@kL;9I"9static VALUE console_getch(int argc, VALUE *argv, VALUE io) { rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 0, &opts); #ifndef _WIN32 return ttymode(io, getc_call, io, set_rawmode, optp); #else rb_io_t *fptr; VALUE str; wint_t c; int len; char buf[8]; wint_t wbuf[2]; # ifndef HAVE_RB_IO_WAIT struct timeval *to = NULL, tv; # else VALUE timeout = Qnil; # endif GetOpenFile(io, fptr); if (optp) { if (optp->vtime) { # ifndef HAVE_RB_IO_WAIT to = &tv; # else struct timeval tv; # endif tv.tv_sec = optp->vtime / 10; tv.tv_usec = (optp->vtime % 10) * 100000; # ifdef HAVE_RB_IO_WAIT timeout = rb_fiber_scheduler_make_timeout(&tv); # endif } switch (optp->vmin) { case 1: /* default */ break; case 0: /* return nil when timed out */ if (optp->vtime) break; /* fallthru */ default: rb_warning("min option larger than 1 ignored"); } if (optp->intr) { # ifndef HAVE_RB_IO_WAIT int w = rb_wait_for_single_fd(fptr->fd, RB_WAITFD_IN, to); if (w < 0) rb_eof_error(); if (!(w & RB_WAITFD_IN)) return Qnil; # else VALUE result = rb_io_wait(io, RUBY_IO_READABLE, timeout); if (!RTEST(result)) return Qnil; # endif } else if (optp->vtime) { rb_warning("Non-zero vtime option ignored if intr flag is unset"); } } len = (int)(VALUE)rb_thread_call_without_gvl(nogvl_getch, wbuf, RUBY_UBF_IO, 0); switch (len) { case 0: return Qnil; case 2: buf[0] = (char)wbuf[0]; c = wbuf[1]; len = 1; do { buf[len++] = (unsigned char)c; } while ((c >>= CHAR_BIT) && len < (int)sizeof(buf)); return rb_str_new(buf, len); default: c = wbuf[0]; len = rb_uv_to_utf8(buf, c); str = rb_utf8_str_new(buf, len); return rb_str_conv_enc(str, NULL, rb_default_external_encoding()); } #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#echo=;F;7[[I"f;T0;[[@W`ig;T;: echo=;0;[;{;IC; "Enables/disables echo back. On some platforms, all combinations of this flags and raw/cooked mode may not be valid. You must require 'io/console' to use this method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"echo=(flag);T;IC; ";T;[;![;"I";T;#0;$@`;.F;Bi;C0;7[[I" flag;T0;$@`;![;"I"Enables/disables echo back. On some platforms, all combinations of this flags and raw/cooked mode may not be valid. You must require 'io/console' to use this method. @overload echo=(flag);T;#0;$@`;.F;/o;0;1T;2i];3id;%@kL;9I"Lstatic VALUE console_set_echo(VALUE io, VALUE f) { conmode t; rb_io_t *fptr; int fd; GetOpenFile(io, fptr); fd = GetReadFD(fptr); if (!getattr(fd, &t)) sys_fail_fptr(fptr); if (RTEST(f)) set_echo(&t, NULL); else set_noecho(&t, NULL); if (!setattr(fd, &t)) sys_fail_fptr(fptr); return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#echo?;F;7[;[[@W`i;T;: echo?;0;[;{;IC; "_Returns +true+ if echo back is enabled. You must require 'io/console' to use this method.;T;[o;= ;>I" overload;F;?0;;;@0;:I" echo?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ a;![;"I"@return [Boolean];T;#0;$@ a;.F;Bi;C0;7[;$@ a;![;"I"Returns +true+ if echo back is enabled. You must require 'io/console' to use this method. @overload echo? @return [Boolean];T;#0;$@ a;.F;/o;0;1T;2iy;3i;Bi;%@kL;9I"static VALUE console_echo_p(VALUE io) { conmode t; rb_io_t *fptr; int fd; GetOpenFile(io, fptr); fd = GetReadFD(fptr); if (!getattr(fd, &t)) sys_fail_fptr(fptr); return echo_p(&t) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#console_mode;F;7[;[[@W`i;T;:console_mode;0;[;{;IC; "kReturns a data represents the current console mode. You must require 'io/console' to use this method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"console_mode;T;IC; ";T;[;![;"I";T;#0;$@'a;.F;Bi;C0;7[;$@'a;![;"I"Returns a data represents the current console mode. You must require 'io/console' to use this method. @overload console_mode;T;#0;$@'a;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE console_conmode_get(VALUE io) { conmode t; rb_io_t *fptr; int fd; GetOpenFile(io, fptr); fd = GetReadFD(fptr); if (!getattr(fd, &t)) sys_fail_fptr(fptr); return conmode_new(cConmode, &t); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#console_mode=;F;7[[I" mode;T0;[[@W`i;T;:console_mode=;0;[;{;IC; "XSets the console mode to +mode+. You must require 'io/console' to use this method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"console_mode=(mode);T;IC; ";T;[;![;"I";T;#0;$@=a;.F;Bi;C0;7[[I" mode;T0;$@=a;![;"I"xSets the console mode to +mode+. You must require 'io/console' to use this method. @overload console_mode=(mode);T;#0;$@=a;.F;/o;0;1T;2i;3i;%@kL;9I"*static VALUE console_conmode_set(VALUE io, VALUE mode) { conmode *t, r; rb_io_t *fptr; int fd; TypedData_Get_Struct(mode, conmode, &conmode_type, t); r = *t; GetOpenFile(io, fptr); fd = GetReadFD(fptr); if (!setattr(fd, &r)) sys_fail_fptr(fptr); return mode; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#noecho;F;7[;[[@W`iW;T;: noecho;0;[;{;IC; "Yields +self+ with disabling echo back. STDIN.noecho(&:gets) will read and return a line without echo back. You must require 'io/console' to use this method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" noecho;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"io;T;$@Wa;![;"I"@yield [io];T;#0;$@Wa;.F;Bi;C0;7[;$@Wa;![;"I"Yields +self+ with disabling echo back. STDIN.noecho(&:gets) will read and return a line without echo back. You must require 'io/console' to use this method. @overload noecho @yield [io];T;#0;$@Wa;.F;/o;0;1T;2iK;3iU;%@kL;9I"fstatic VALUE console_noecho(VALUE io) { return ttymode(io, rb_yield, io, set_noecho, NULL); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#winsize;F;7[;[[@W`i;T;: winsize;0;[;{;IC; "MReturns console size. You must require 'io/console' to use this method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" winsize;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@ra;![;"I"@return [Array];T;#0;$@ra;.F;Bi;C0;7[;$@ra;![;"I"sReturns console size. You must require 'io/console' to use this method. @overload winsize @return [Array];T;#0;$@ra;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE console_winsize(VALUE io) { rb_io_t *fptr; int fd; rb_console_size_t ws; GetOpenFile(io, fptr); fd = GetWriteFD(fptr); if (!getwinsize(fd, &ws)) sys_fail_fptr(fptr); return rb_assoc_new(INT2NUM(winsize_row(&ws)), INT2NUM(winsize_col(&ws))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#winsize=;F;7[[I" size;T0;[[@W`i-;T;: winsize=;0;[;{;IC; "Tries to set console size. The effect depends on the platform and the running environment. You must require 'io/console' to use this method. ;T;[;![;"I" Tries to set console size. The effect depends on the platform and the running environment. You must require 'io/console' to use this method. ;T;#0;$@a;.F;/o;0;1T;2i$;3i*;%@kL;9I"static VALUE console_set_winsize(VALUE io, VALUE size) { rb_io_t *fptr; rb_console_size_t ws; #if defined _WIN32 HANDLE wh; int newrow, newcol; BOOL ret; #endif VALUE row, col, xpixel, ypixel; const VALUE *sz; int fd; long sizelen; GetOpenFile(io, fptr); size = rb_Array(size); if ((sizelen = RARRAY_LEN(size)) != 2 && sizelen != 4) { rb_raise(rb_eArgError, "wrong number of arguments (given %ld, expected 2 or 4)", sizelen); } sz = RARRAY_CONST_PTR(size); row = sz[0], col = sz[1], xpixel = ypixel = Qnil; if (sizelen == 4) xpixel = sz[2], ypixel = sz[3]; fd = GetWriteFD(fptr); #if defined TIOCSWINSZ ws.ws_row = ws.ws_col = ws.ws_xpixel = ws.ws_ypixel = 0; #define SET(m) ws.ws_##m = NIL_P(m) ? 0 : (unsigned short)NUM2UINT(m) SET(row); SET(col); SET(xpixel); SET(ypixel); #undef SET if (!setwinsize(fd, &ws)) sys_fail_fptr(fptr); #elif defined _WIN32 wh = (HANDLE)rb_w32_get_osfhandle(fd); #define SET(m) new##m = NIL_P(m) ? 0 : (unsigned short)NUM2UINT(m) SET(row); SET(col); #undef SET if (!NIL_P(xpixel)) (void)NUM2UINT(xpixel); if (!NIL_P(ypixel)) (void)NUM2UINT(ypixel); if (!GetConsoleScreenBufferInfo(wh, &ws)) { rb_syserr_fail(LAST_ERROR, "GetConsoleScreenBufferInfo"); } ws.dwSize.X = newcol; ret = SetConsoleScreenBufferSize(wh, ws.dwSize); ws.srWindow.Left = 0; ws.srWindow.Top = 0; ws.srWindow.Right = newcol-1; ws.srWindow.Bottom = newrow-1; if (!SetConsoleWindowInfo(wh, TRUE, &ws.srWindow)) { rb_syserr_fail(LAST_ERROR, "SetConsoleWindowInfo"); } /* retry when shrinking buffer after shrunk window */ if (!ret && !SetConsoleScreenBufferSize(wh, ws.dwSize)) { rb_syserr_fail(LAST_ERROR, "SetConsoleScreenBufferInfo"); } /* remove scrollbar if possible */ if (!SetConsoleWindowInfo(wh, TRUE, &ws.srWindow)) { rb_syserr_fail(LAST_ERROR, "SetConsoleWindowInfo"); } #endif return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#iflush;F;7[;[[@W`i;T;: iflush;0;[;{;IC; "WFlushes input buffer in kernel. You must require 'io/console' to use this method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" iflush;T;IC; ";T;[;![;"I";T;#0;$@a;.F;Bi;C0;7[;$@a;![;"I"jFlushes input buffer in kernel. You must require 'io/console' to use this method. @overload iflush;T;#0;$@a;.F;/o;0;1T;2i;3i;%@kL;9I" static VALUE console_iflush(VALUE io) { rb_io_t *fptr; int fd; GetOpenFile(io, fptr); fd = GetReadFD(fptr); #if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H if (tcflush(fd, TCIFLUSH)) sys_fail_fptr(fptr); #endif (void)fd; return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#oflush;F;7[;[[@W`i;T;: oflush;0;[;{;IC; "XFlushes output buffer in kernel. You must require 'io/console' to use this method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" oflush;T;IC; ";T;[;![;"I";T;#0;$@a;.F;Bi;C0;7[;$@a;![;"I"kFlushes output buffer in kernel. You must require 'io/console' to use this method. @overload oflush;T;#0;$@a;.F;/o;0;1T;2i;3i;%@kL;9I" static VALUE console_oflush(VALUE io) { rb_io_t *fptr; int fd; GetOpenFile(io, fptr); fd = GetWriteFD(fptr); #if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H if (tcflush(fd, TCOFLUSH)) sys_fail_fptr(fptr); #endif (void)fd; return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#ioflush;F;7[;[[@W`i;T;: ioflush;0;[;{;IC; "cFlushes input and output buffers in kernel. You must require 'io/console' to use this method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" ioflush;T;IC; ";T;[;![;"I";T;#0;$@a;.F;Bi;C0;7[;$@a;![;"I"wFlushes input and output buffers in kernel. You must require 'io/console' to use this method. @overload ioflush;T;#0;$@a;.F;/o;0;1T;2i;3i;%@kL;9I"static VALUE console_ioflush(VALUE io) { rb_io_t *fptr; #if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H int fd1, fd2; #endif GetOpenFile(io, fptr); #if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H fd1 = GetReadFD(fptr); fd2 = GetWriteFD(fptr); if (fd2 != -1 && fd1 != fd2) { if (tcflush(fd1, TCIFLUSH)) sys_fail_fptr(fptr); if (tcflush(fd2, TCOFLUSH)) sys_fail_fptr(fptr); } else { if (tcflush(fd1, TCIOFLUSH)) sys_fail_fptr(fptr); } #endif return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#beep;F;7[;[[@W`i;T;: beep;0;[;{;IC; " ;T;[;![;"@;#0;$@a;%@kL;9I"static VALUE console_beep(VALUE io) { rb_io_t *fptr; int fd; GetOpenFile(io, fptr); fd = GetWriteFD(fptr); #ifdef _WIN32 (void)fd; MessageBeep(0); #else if (write(fd, "\a", 1) < 0) sys_fail_fptr(fptr); #endif return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#goto;F;7[[I"y;T0[I"x;T0;[[@W`i,;T;: goto;0;[;{;IC; " ;T;[;![;"@;#0;$@a;%@kL;9I"static VALUE console_goto(VALUE io, VALUE y, VALUE x) { rb_io_write(io, rb_sprintf("\x1b[%d;%dH", NUM2UINT(y)+1, NUM2UINT(x)+1)); return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#cursor;F;7[;[[@W`i;T;: cursor;0;[;{;IC; " ;T;[;![;"@;#0;$@a;%@kL;9I"static VALUE console_cursor_pos(VALUE io) { static const struct query_args query = {"\033[6n", 0}; VALUE resp = console_vt_response(0, 0, io, &query); VALUE row, column, term; unsigned int r, c; if (!RB_TYPE_P(resp, T_ARRAY) || RARRAY_LEN(resp) != 3) return Qnil; term = RARRAY_AREF(resp, 2); if (!RB_TYPE_P(term, T_STRING) || RSTRING_LEN(term) != 1) return Qnil; if (RSTRING_PTR(term)[0] != 'R') return Qnil; row = RARRAY_AREF(resp, 0); column = RARRAY_AREF(resp, 1); rb_ary_resize(resp, 2); r = NUM2UINT(row) - 1; c = NUM2UINT(column) - 1; RARRAY_ASET(resp, 0, INT2NUM(r)); RARRAY_ASET(resp, 1, INT2NUM(c)); return resp; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#cursor=;F;7[[I" cpos;T0;[[@W`id;T;: cursor=;0;[;{;IC; " ;T;[;![;"@;#0;$@b;%@kL;9I"static VALUE console_cursor_set(VALUE io, VALUE cpos) { cpos = rb_convert_type(cpos, T_ARRAY, "Array", "to_ary"); if (RARRAY_LEN(cpos) != 2) rb_raise(rb_eArgError, "expected 2D coordinate"); return console_goto(io, RARRAY_AREF(cpos, 0), RARRAY_AREF(cpos, 1)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#cursor_up;F;7[[I"val;T0;[[@W`il;T;:cursor_up;0;[;{;IC; " ;T;[;![;"@;#0;$@b;%@kL;9I"kstatic VALUE console_cursor_up(VALUE io, VALUE val) { return console_move(io, -NUM2INT(val), 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#cursor_down;F;7[[I"val;T0;[[@W`ir;T;:cursor_down;0;[;{;IC; " ;T;[;![;"@;#0;$@#b;%@kL;9I"mstatic VALUE console_cursor_down(VALUE io, VALUE val) { return console_move(io, +NUM2INT(val), 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#cursor_left;F;7[[I"val;T0;[[@W`ix;T;:cursor_left;0;[;{;IC; " ;T;[;![;"@;#0;$@1b;%@kL;9I"mstatic VALUE console_cursor_left(VALUE io, VALUE val) { return console_move(io, 0, -NUM2INT(val)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#cursor_right;F;7[[I"val;T0;[[@W`i~;T;:cursor_right;0;[;{;IC; " ;T;[;![;"@;#0;$@?b;%@kL;9I"nstatic VALUE console_cursor_right(VALUE io, VALUE val) { return console_move(io, 0, +NUM2INT(val)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#goto_column;F;7[[I"val;T0;[[@W`i@;T;:goto_column;0;[;{;IC; " ;T;[;![;"@;#0;$@Mb;%@kL;9I"static VALUE console_goto_column(VALUE io, VALUE val) { rb_io_write(io, rb_sprintf("\x1b[%dG", NUM2UINT(val)+1)); return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#erase_line;F;7[[I"val;T0;[[@W`iG;T;:erase_line;0;[;{;IC; " ;T;[;![;"@;#0;$@[b;%@kL;9I"static VALUE console_erase_line(VALUE io, VALUE val) { int mode = mode_in_range(val, 2, "line erase"); rb_io_write(io, rb_sprintf("\x1b[%dK", mode)); return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#erase_screen;F;7[[I"val;T0;[[@W`iO;T;:erase_screen;0;[;{;IC; " ;T;[;![;"@;#0;$@ib;%@kL;9I"static VALUE console_erase_screen(VALUE io, VALUE val) { int mode = mode_in_range(val, 3, "screen erase"); rb_io_write(io, rb_sprintf("\x1b[%dJ", mode)); return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#scroll_forward;F;7[[I"val;T0;[[@W`i;T;:scroll_forward;0;[;{;IC; " ;T;[;![;"@;#0;$@wb;%@kL;9I"ostatic VALUE console_scroll_forward(VALUE io, VALUE val) { return console_scroll(io, +NUM2INT(val)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#scroll_backward;F;7[[I"val;T0;[[@W`i;T;:scroll_backward;0;[;{;IC; " ;T;[;![;"@;#0;$@b;%@kL;9I"pstatic VALUE console_scroll_backward(VALUE io, VALUE val) { return console_scroll(io, -NUM2INT(val)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#clear_screen;F;7[;[[@W`i;T;:clear_screen;0;[;{;IC; " ;T;[;![;"@;#0;$@b;%@kL;9I"static VALUE console_clear_screen(VALUE io) { console_erase_screen(io, INT2FIX(2)); console_goto(io, INT2FIX(0), INT2FIX(0)); return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#pressed?;F;7[[I"k;T0;[[@W`i;T;: pressed?;0;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@b;![;"@;#0;$@b;Bi;%@kL;9I"static VALUE console_key_pressed_p(VALUE io, VALUE k) { int vk = -1; if (FIXNUM_P(k)) { vk = NUM2UINT(k); } else { const struct vktable *t; const char *kn; if (SYMBOL_P(k)) { k = rb_sym2str(k); kn = RSTRING_PTR(k); } else { kn = StringValuePtr(k); } t = console_win32_vk(kn, RSTRING_LEN(k)); if (!t || (vk = (short)t->vk) == -1) { rb_raise(rb_eArgError, "unknown virtual key code: % "PRIsVALUE, k); } } return GetKeyState(vk) & 0x80 ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#check_winsize_changed;F;7[;[[@W`ir;T;:check_winsize_changed;0;[;{;IC; " ;T;[;![;"@;#0;$@b;%@kL;9I"static VALUE console_check_winsize_changed(VALUE io) { rb_io_t *fptr; HANDLE h; DWORD num; GetOpenFile(io, fptr); h = (HANDLE)rb_w32_get_osfhandle(GetReadFD(fptr)); while (GetNumberOfConsoleInputEvents(h, &num) && num > 0) { INPUT_RECORD rec; if (ReadConsoleInput(h, &rec, 1, &num)) { if (rec.EventType == WINDOW_BUFFER_SIZE_EVENT) { rb_yield(Qnil); } } } return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO#getpass;F;7[[@90;[[@W`i2;T;: getpass;0;[;{;IC; "Reads and returns a line without echo back. Prints +prompt+ unless it is +nil+. The newline character that terminates the read line is removed from the returned string, see String#chomp!. You must require 'io/console' to use this method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"getpass(prompt=nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@b;![;"I"@return [String];T;#0;$@b;.F;Bi;C0;7[[I" prompt;TI"nil;T;$@b;![;"I""Reads and returns a line without echo back. Prints +prompt+ unless it is +nil+. The newline character that terminates the read line is removed from the returned string, see String#chomp!. You must require 'io/console' to use this method. @overload getpass(prompt=nil) @return [String];T;#0;$@b;.F;/o;0;1T;2i%;3i0;%@kL;9I"=static VALUE console_getpass(int argc, VALUE *argv, VALUE io) { VALUE str, wio; rb_check_arity(argc, 0, 1); wio = rb_io_get_write_io(io); if (wio == io && io == rb_stdin) wio = rb_stderr; prompt(argc, argv, wio); str = rb_ensure(getpass_call, io, puts_call, wio); return str_chomp(str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO.console;F;7[[@90;[[@W`i;T;: console;0;[;{;IC; "Returns an File instance opened console. If +sym+ is given, it will be sent to the opened console with +args+ and the result will be returned instead of the console IO itself. You must require 'io/console' to use this method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" console;T;IC; ";T;[o;A ;>I" return;F;?I"];T;0;@[I"#];T;#0;$@b;.F;Bi;C0;7[;$@bo;= ;>I" overload;F;?0;;;@0;:I"console(sym, *args);T;IC; ";T;[;![;"I";T;#0;$@b;.F;Bi;C0;7[[I"sym;T0[I" *args;T0;$@b;![;"I"2Returns an File instance opened console. If +sym+ is given, it will be sent to the opened console with +args+ and the result will be returned instead of the console IO itself. You must require 'io/console' to use this method. @overload console @return [#] @overload console(sym, *args);T;#0;$@b;.F;/o;0;1T;2i;3i;%@kL;9I"5static VALUE console_dev(int argc, VALUE *argv, VALUE klass) { VALUE con = 0; rb_io_t *fptr; VALUE sym = 0; rb_check_arity(argc, 0, UNLIMITED_ARGUMENTS); if (argc) { Check_Type(sym = argv[0], T_SYMBOL); } if (klass == rb_cIO) klass = rb_cFile; if (rb_const_defined(klass, id_console)) { con = rb_const_get(klass, id_console); if (!RB_TYPE_P(con, T_FILE) || (!(fptr = RFILE(con)->fptr) || GetReadFD(fptr) == -1)) { rb_const_remove(klass, id_console); con = 0; } } if (sym) { if (sym == ID2SYM(id_close) && argc == 1) { if (con) { rb_io_close(con); rb_const_remove(klass, id_console); con = 0; } return Qnil; } } if (!con) { VALUE args[2]; #if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H || defined HAVE_SGTTY_H # define CONSOLE_DEVICE "/dev/tty" #elif defined _WIN32 # define CONSOLE_DEVICE "con$" # define CONSOLE_DEVICE_FOR_READING "conin$" # define CONSOLE_DEVICE_FOR_WRITING "conout$" #endif #ifndef CONSOLE_DEVICE_FOR_READING # define CONSOLE_DEVICE_FOR_READING CONSOLE_DEVICE #endif #ifdef CONSOLE_DEVICE_FOR_WRITING VALUE out; rb_io_t *ofptr; #endif int fd; #ifdef CONSOLE_DEVICE_FOR_WRITING fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_WRITING, O_RDWR, 0); if (fd < 0) return Qnil; rb_update_max_fd(fd); args[1] = INT2FIX(O_WRONLY); args[0] = INT2NUM(fd); out = rb_class_new_instance(2, args, klass); #endif fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_READING, O_RDWR, 0); if (fd < 0) { #ifdef CONSOLE_DEVICE_FOR_WRITING rb_io_close(out); #endif return Qnil; } rb_update_max_fd(fd); args[1] = INT2FIX(O_RDWR); args[0] = INT2NUM(fd); con = rb_class_new_instance(2, args, klass); GetOpenFile(con, fptr); fptr->pathv = rb_obj_freeze(rb_str_new2(CONSOLE_DEVICE)); #ifdef CONSOLE_DEVICE_FOR_WRITING GetOpenFile(out, ofptr); ofptr->pathv = fptr->pathv; fptr->tied_io_for_writing = out; ofptr->mode |= FMODE_SYNC; #endif fptr->mode |= FMODE_SYNC; rb_const_set(klass, id_console, con); } if (sym) { return rb_f_send(argc, argv, con); } return con; };T;:I"static VALUE;T;;To;;IC;[ o;4;5F;6;;;;&I"IO::generic_readable#getch;F;7[[@90;[[@W`i;T;;;0;[;{;IC; "See IO#getch. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"*getch(min: nil, time: nil, intr: nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@c;![;"I"@return [String];T;#0;$@c;.F;Bi;C0;7[[I" min:;TI"nil;T[I" time:;TI"nil;T[I" intr:;TI"nil;T;$@c;![;"I"WSee IO#getch. @overload getch(min: nil, time: nil, intr: nil) @return [String];T;#0;$@c;.F;/o;0;1T;2i;3i;%@c;9I"pstatic VALUE io_getch(int argc, VALUE *argv, VALUE io) { return rb_funcallv(io, id_getc, argc, argv); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!IO::generic_readable#getpass;F;7[[@90;[[@W`iE;T;;;0;[;{;IC; "See IO#getpass. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"getpass(prompt=nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@*c;![;"I"@return [String];T;#0;$@*c;.F;Bi;C0;7[[I" prompt;TI"nil;T;$@*c;![;"I"GSee IO#getpass. @overload getpass(prompt=nil) @return [String];T;#0;$@*c;.F;/o;0;1T;2i?;3iC;%@c;9I"static VALUE io_getpass(int argc, VALUE *argv, VALUE io) { VALUE str; rb_check_arity(argc, 0, 1); prompt(argc, argv, io); str = str_chomp(rb_funcallv(io, id_gets, 0, 0)); puts_call(io); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""IO::generic_readable#readchar;F;7[;[[I"ext/stringio/stringio.c;Ti;T;;;0;[;{;IC; "See IO#readchar. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" readchar;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@Ic;![;"I"@return [String];T;#0;$@Ic;.F;Bi;C0;7[;$@Ic;![;"I"=See IO#readchar. @overload readchar @return [String];T;#0;$@Ic;.F;/o;0;1T;2i;3i;%@c;9I"static VALUE strio_readchar(VALUE self) { VALUE c = rb_funcallv(self, rb_intern("getc"), 0, 0); if (NIL_P(c)) rb_eof_error(); return c; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""IO::generic_readable#readbyte;F;7[;[[@Nci;T;;;0;[;{;IC; "See IO#readbyte. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" readbyte;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@ec;![;"I"@return [Fixnum];T;#0;$@ec;.F;Bi;C0;7[;$@ec;![;"I"=See IO#readbyte. @overload readbyte @return [Fixnum];T;#0;$@ec;.F;/o;0;1T;2i;3i;%@c;9I"static VALUE strio_readbyte(VALUE self) { VALUE c = rb_funcallv(self, rb_intern("getbyte"), 0, 0); if (NIL_P(c)) rb_eof_error(); return c; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""IO::generic_readable#readline;F;7[[@90;[[@Nci ;T;;;0;[;{;IC; "See IO#readline. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"#readline(sep=$/, chomp: false);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@c;![;"I"@return [String];T;#0;$@c;.F;Bi;C0;7[[I"sep;TI"$/;T[I" chomp:;TI" false;T;$@co;= ;>I" overload;F;?0;;;@0;:I""readline(limit, chomp: false);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@c;![;"I"@return [String, nil];T;#0;$@c;.F;Bi;C0;7[[I" limit;T0[I" chomp:;TI" false;T;$@co;= ;>I" overload;F;?0;;;@0;:I"'readline(sep, limit, chomp: false);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@c;![;"I"@return [String, nil];T;#0;$@c;.F;Bi;C0;7[[I"sep;T0[I" limit;T0[I" chomp:;TI" false;T;$@c;![;"I"See IO#readline. @overload readline(sep=$/, chomp: false) @return [String] @overload readline(limit, chomp: false) @return [String, nil] @overload readline(sep, limit, chomp: false) @return [String, nil];T;#0;$@c;.F;/o;0;1T;2i;3i ;%@c;9I"static VALUE strio_readline(int argc, VALUE *argv, VALUE self) { VALUE line = rb_funcallv_kw(self, rb_intern("gets"), argc, argv, RB_PASS_CALLED_KEYWORDS); if (NIL_P(line)) rb_eof_error(); return line; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!IO::generic_readable#sysread;F;7[[@90;[[@Nci;T;;};0;[;{;IC; "uSimilar to #read, but raises +EOFError+ at end of string instead of returning +nil+, as well as IO#sysread does. ;T;[o;= ;>I" overload;F;?0;;};@0;:I"sysread(integer[, outbuf]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@c;![;"I"@return [String];T;#0;$@c;.F;Bi;C0;7[[I"integer[, outbuf];T0;$@co;= ;>I" overload;F;?0;;;@0;:I"#readpartial(integer[, outbuf]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@c;![;"I"@return [String];T;#0;$@c;.F;Bi;C0;7[[I"integer[, outbuf];T0;$@c;![;"I"Similar to #read, but raises +EOFError+ at end of string instead of returning +nil+, as well as IO#sysread does. @overload sysread(integer[, outbuf]) @return [String] @overload readpartial(integer[, outbuf]) @return [String];T;#0;$@c;.F;/o;0;1T;2i;3i;%@c;9I"static VALUE strio_sysread(int argc, VALUE *argv, VALUE self) { VALUE val = rb_funcallv_kw(self, rb_intern("read"), argc, argv, RB_PASS_CALLED_KEYWORDS); if (NIL_P(val)) { rb_eof_error(); } return val; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%IO::generic_readable#readpartial;F;7[[@90;[[@Nci;T;;;0;[;{;IC; "uSimilar to #read, but raises +EOFError+ at end of string instead of returning +nil+, as well as IO#sysread does. ;T;[o;= ;>I" overload;F;?0;;};@0;:I"sysread(integer[, outbuf]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@c;![;"I"@return [String];T;#0;$@c;.F;Bi;C0;7[[I"integer[, outbuf];T0;$@co;= ;>I" overload;F;?0;;;@0;:I"#readpartial(integer[, outbuf]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@c;![;"I"@return [String];T;#0;$@c;.F;Bi;C0;7[[I"integer[, outbuf];T0;$@c;![;"@c;#0;$@c;.F;/o;0;1T;2i;3i;%@c;9I"static VALUE strio_sysread(int argc, VALUE *argv, VALUE self) { VALUE val = rb_funcallv_kw(self, rb_intern("read"), argc, argv, RB_PASS_CALLED_KEYWORDS); if (NIL_P(val)) { rb_eof_error(); } return val; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'IO::generic_readable#read_nonblock;F;7[[@90;[[@Nci-;T;:read_nonblock;0;[;{;IC; "pSimilar to #read, but raises +EOFError+ at end of string unless the +exception: false+ option is passed in. ;T;[o;= ;>I" overload;F;?0;;;@0;:I".read_nonblock(integer[, outbuf [, opts]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@#d;![;"I"@return [String];T;#0;$@#d;.F;Bi;C0;7[[I"integer[, outbuf [, opts]];T0;$@#d;![;"I"Similar to #read, but raises +EOFError+ at end of string unless the +exception: false+ option is passed in. @overload read_nonblock(integer[, outbuf [, opts]]) @return [String];T;#0;$@#d;.F;/o;0;1T;2i&;3i+;%@c;9I"static VALUE strio_read_nonblock(int argc, VALUE *argv, VALUE self) { VALUE opts = Qnil, val; rb_scan_args(argc, argv, "11:", NULL, NULL, &opts); if (!NIL_P(opts)) { argc--; } val = strio_read(argc, argv, self); if (NIL_P(val)) { if (!NIL_P(opts) && rb_hash_lookup2(opts, sym_exception, Qundef) == Qfalse) return Qnil; else rb_eof_error(); } return val; };T;:I"static VALUE;T;;T; @c; IC;[; @c; IC;[; @c; IC;{;IC;{;T;IC;{;T;T;{;[;[[@W`i[@Nci5;F;:generic_readable;;;;;[;{;IC; " ;T;[;![;"@;#0;$@c;Bi;%@kL;&I"IO::generic_readable;Fo; ;IC;[ o;4;5F;6;;;;&I"$IO::ConsoleMode#initialize_copy;F;7[[I" obj2;T0;[[@W`i;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@Sd;%@Qd;9I"static VALUE conmode_init_copy(VALUE obj, VALUE obj2) { conmode *t = rb_check_typeddata(obj, &conmode_type); conmode *t2 = rb_check_typeddata(obj2, &conmode_type); *t = *t2; return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::ConsoleMode#echo=;F;7[[I"f;T0;[[@W`i;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@ad;%@Qd;9I"static VALUE conmode_set_echo(VALUE obj, VALUE f) { conmode *t = rb_check_typeddata(obj, &conmode_type); if (RTEST(f)) set_echo(t, NULL); else set_noecho(t, NULL); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::ConsoleMode#raw!;F;7[[@90;[[@W`i;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@od;%@Qd;9I"static VALUE conmode_set_raw(int argc, VALUE *argv, VALUE obj) { conmode *t = rb_check_typeddata(obj, &conmode_type); rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 0, &opts); set_rawmode(t, optp); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO::ConsoleMode#raw;F;7[[@90;[[@W`i;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@|d;%@Qd;9I"!static VALUE conmode_raw_new(int argc, VALUE *argv, VALUE obj) { conmode *r = rb_check_typeddata(obj, &conmode_type); conmode t = *r; rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 0, &opts); set_rawmode(&t, optp); return conmode_new(rb_obj_class(obj), &t); };T;:I"static VALUE;T;;T; @Qd; IC;[; @Qd; IC;[; @Qd; IC;{;IC;{;T;IC;{;T;T;{;[;[[@W`i;F;:ConsoleMode;;;;;[;{;IC; " ;T;[;![;"@;#0;$@Qd;%@kL;&I"IO::ConsoleMode;F;'@o;4;5F;6;;;;&I"IO#pathconf;F;7[[I"arg;T0;[[I"ext/etc/etc.c;Ti;T;: pathconf;0;[;{;IC; "YReturns pathname configuration variable using fpathconf(). _name_ should be a constant under Etc which begins with PC_. The return value is an integer or nil. nil means indefinite limit. (fpathconf() returns -1 but errno is not set.) require 'etc' IO.pipe {|r, w| p w.pathconf(Etc::PC_PIPE_BUF) #=> 4096 } ;T;[;![;"I"[Returns pathname configuration variable using fpathconf(). _name_ should be a constant under Etc which begins with PC_. The return value is an integer or nil. nil means indefinite limit. (fpathconf() returns -1 but errno is not set.) require 'etc' IO.pipe {|r, w| p w.pathconf(Etc::PC_PIPE_BUF) #=> 4096 } ;T;#0;$@d;.F;/o;0;1T;2i;3i;%@kL;9I"bstatic VALUE io_pathconf(VALUE io, VALUE arg) { int name; long ret; rb_io_t *fptr; name = NUM2INT(arg); GetOpenFile(io, fptr); errno = 0; ret = fpathconf(fptr->fd, name); if (ret == -1) { if (errno == 0) /* no limit */ return Qnil; rb_sys_fail("fpathconf"); } return LONG2NUM(ret); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO.io_wait;F;7[[I"io;T0[I" events;T0[I" timeout;T0;[[I"ext/-test-/wait/wait.c;Ti ;T;: io_wait;0;[;{;IC; " ;T;[;![;"@;#0;$@d;%@kL;9I"}static VALUE io_wait(VALUE klass, VALUE io, VALUE events, VALUE timeout) { return rb_io_wait(io, events, timeout); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO.io_maybe_wait;F;7[ [I" error;T0[I"io;T0[I" events;T0[I" timeout;T0;[[@di;T;:io_maybe_wait;0;[;{;IC; " ;T;[;![;"@;#0;$@d;%@kL;9I"static VALUE io_maybe_wait(VALUE klass, VALUE error, VALUE io, VALUE events, VALUE timeout) { return rb_io_maybe_wait(RB_NUM2INT(error), io, events, timeout); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO.io_maybe_wait_readable;F;7[[I" error;T0[I"io;T0[I" timeout;T0;[[@di;T;:io_maybe_wait_readable;0;[;{;IC; " ;T;[;![;"@;#0;$@d;%@kL;9I"static VALUE io_maybe_wait_readable(VALUE klass, VALUE error, VALUE io, VALUE timeout) { return RB_INT2NUM( rb_io_maybe_wait_readable(RB_NUM2INT(error), io, timeout) ); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO.io_maybe_wait_writable;F;7[[I" error;T0[I"io;T0[I" timeout;T0;[[@di;T;:io_maybe_wait_writable;0;[;{;IC; " ;T;[;![;"@;#0;$@d;%@kL;9I"static VALUE io_maybe_wait_writable(VALUE klass, VALUE error, VALUE io, VALUE timeout) { return RB_INT2NUM( rb_io_maybe_wait_writable(RB_NUM2INT(error), io, timeout) ); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" IO#stat;F;7[;[[@8iD;T;: stat;0;[;{;IC; "Returns status information for ios as an object of type File::Stat. f = File.new("testfile") s = f.stat "%o" % s.mode #=> "100644" s.blksize #=> 4096 s.atime #=> Wed Apr 09 08:53:54 CDT 2003 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" stat;T;IC; ";T;[;![;"I";T;#0;$@d;.F;Bi;C0;7[;$@d;![;"I"Returns status information for ios as an object of type File::Stat. f = File.new("testfile") s = f.stat "%o" % s.mode #=> "100644" s.blksize #=> 4096 s.atime #=> Wed Apr 09 08:53:54 CDT 2003 @overload stat;T;#0;$@d;.F;/o;0;1T;2i5;3i@;%@kL;9I"static VALUE rb_io_stat(VALUE obj) { rb_io_t *fptr; struct stat st; GetOpenFile(obj, fptr); if (fstat(fptr->fd, &st) == -1) { rb_sys_fail_path(fptr->pathv); } return rb_stat_new(&st); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO.thread_fd_close;F;7[[I"fd;T0;[[I"%ext/-test-/thread_fd/thread_fd.c;Ti;T;:thread_fd_close;0;[;{;IC; " ;T;[;![;"@;#0;$@ e;%@kL;9I"pstatic VALUE thread_fd_close(VALUE ign, VALUE fd) { rb_thread_fd_close(NUM2INT(fd)); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO.thread_fd_wait;F;7[[I"fd;T0;[[@ei;T;:thread_fd_wait;0;[;{;IC; " ;T;[;![;"@;#0;$@e;%@kL;9I"{static VALUE thread_fd_wait(VALUE ign, VALUE fd) { int ret = rb_thread_wait_fd(NUM2INT(fd)); return INT2NUM(ret); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IO.thread_fd_writable;F;7[[I"fd;T0;[[@ei;T;:thread_fd_writable;0;[;{;IC; " ;T;[;![;"@;#0;$@'e;%@kL;9I"static VALUE thread_fd_writable(VALUE ign, VALUE fd) { int ret = rb_thread_fd_writable(NUM2INT(fd)); return INT2NUM(ret); };T;:I"static VALUE;T;;To;;IC;[ o;4;5F;6;;;;&I"IO::generic_writable#<<;F;7[;[;F;;;;;[;{;IC; " ;T;[;![;"@;#0;$@7e;%@5e;;To;4;5F;6;;;;&I"IO::generic_writable#print;F;7[;[;F;;;;;[;{;IC; " ;T;[;![;"@;#0;$@@e;%@5e;;To;4;5F;6;;;;&I" IO::generic_writable#printf;F;7[;[;F;;;;;[;{;IC; " ;T;[;![;"@;#0;$@Ie;%@5e;;To;4;5F;6;;;;&I"IO::generic_writable#puts;F;7[;[;F;;;;;[;{;IC; " ;T;[;![;"@;#0;$@Re;%@5e;;To;4;5F;6;;;;&I""IO::generic_writable#syswrite;F;7[;[;F;;|;;;[;{;IC; " ;T;[;![;"@;#0;$@[e;%@5e;;To;4;5F;6;;;;&I"(IO::generic_writable#write_nonblock;F;7[[@90;[[@NciF;T;:write_nonblock;0;[;{;IC; " ;T;[;![;"@;#0;$@de;%@5e;9I"static VALUE strio_syswrite_nonblock(int argc, VALUE *argv, VALUE self) { VALUE str; rb_scan_args(argc, argv, "10:", &str, NULL); return strio_syswrite(self, str); };T;:I"static VALUE;T;;T; @5e; IC;[; @5e; IC;[; @5e; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Nci?;F;:generic_writable;;;;;[;{;IC; " ;T;[;![;"@;#0;$@5e;%@kL;&I"IO::generic_writable;F; @kL; IC;[; @kL; IC;[o;( ;)0;*0;+0;;;%@;-@y,;0o;;IC;[o;u;[[@8i;F;: RDONLY;;w;;;[;{;IC; "open for reading only ;T;[;![;"I"open for reading only;T;#0;$@e;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::RDONLY;F;xI"INT2FIX(O_RDONLY);To;u;[[@8i;F;: WRONLY;;w;;;[;{;IC; "open for writing only ;T;[;![;"I"open for writing only;T;#0;$@e;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::WRONLY;F;xI"INT2FIX(O_WRONLY);To;u;[[@8i;F;: RDWR;;w;;;[;{;IC; "!open for reading and writing ;T;[;![;"I"!open for reading and writing;T;#0;$@e;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::RDWR;F;xI"INT2FIX(O_RDWR);To;u;[[@8i;F;: APPEND;;w;;;[;{;IC; "append on each write ;T;[;![;"I"append on each write;T;#0;$@e;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::APPEND;F;xI"INT2FIX(O_APPEND);To;u;[[@8i;F;: CREAT;;w;;;[;{;IC; "%create file if it does not exist ;T;[;![;"I"%create file if it does not exist;T;#0;$@e;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::CREAT;F;xI"INT2FIX(O_CREAT);To;u;[[@8i;F;: EXCL;;w;;;[;{;IC; "'error if CREAT and the file exists ;T;[;![;"I"'error if CREAT and the file exists;T;#0;$@e;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::EXCL;F;xI"INT2FIX(O_EXCL);To;u;[[@8i;F;: NONBLOCK;;w;;;[;{;IC; "9do not block on open or for data to become available ;T;[;![;"I"9do not block on open or for data to become available;T;#0;$@e;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::NONBLOCK;F;xI"INT2FIX(O_NONBLOCK);To;u;[[@8i;F;: TRUNC;;w;;;[;{;IC; "truncate size to 0 ;T;[;![;"I"truncate size to 0;T;#0;$@e;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::TRUNC;F;xI"INT2FIX(O_TRUNC);To;u;[[@8i;F;: NOCTTY;;w;;;[;{;IC; ":not to make opened IO the controlling terminal device ;T;[;![;"I":not to make opened IO the controlling terminal device;T;#0;$@e;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::NOCTTY;F;xI"INT2FIX(O_NOCTTY);To;u;[[@8i;F;;;;w;;;[;{;IC; "!disable line code conversion ;T;[;![;"I"!disable line code conversion;T;#0;$@e;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::BINARY;F;xI"INT2FIX(O_BINARY);To;u;[[@8i;F;:SHARE_DELETE;;w;;;[;{;IC; "can delete opened file ;T;[;![;"I"can delete opened file;T;#0;$@e;.F;/o;0;1T;2i;3i;%@e;&I""File::Constants::SHARE_DELETE;F;xI"INT2FIX(O_SHARE_DELETE);To;u;[[@8i;F;: SYNC;;w;;;[;{;IC; ".any write operation perform synchronously ;T;[;![;"I".any write operation perform synchronously;T;#0;$@ f;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::SYNC;F;xI"INT2FIX(O_SYNC);To;u;[[@8i;F;: DSYNC;;w;;;[;{;IC; "Dany write operation perform synchronously except some meta data ;T;[;![;"I"Dany write operation perform synchronously except some meta data;T;#0;$@f;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::DSYNC;F;xI"INT2FIX(O_DSYNC);To;u;[[@8i;F;: RSYNC;;w;;;[;{;IC; "Gany read operation perform synchronously. used with SYNC or DSYNC. ;T;[;![;"I"Gany read operation perform synchronously. used with SYNC or DSYNC.;T;#0;$@!f;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::RSYNC;F;xI"INT2FIX(O_RSYNC);To;u;[[@8i;F;: NOFOLLOW;;w;;;[;{;IC; "FreeBSD, Linux ;T;[;![;"I"FreeBSD, Linux;T;#0;$@-f;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::NOFOLLOW;F;xI"INT2FIX(O_NOFOLLOW);To;u;[[@8i;F;: NOATIME;;w;;;[;{;IC; " Linux ;T;[;![;"I" Linux;T;#0;$@9f;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::NOATIME;F;xI"INT2FIX(O_NOATIME);To;u;[[@8i;F;: DIRECT;;w;;;[;{;IC; "DTry to minimize cache effects of the I/O to and from this file. ;T;[;![;"I"DTry to minimize cache effects of the I/O to and from this file.;T;#0;$@Ef;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::DIRECT;F;xI"INT2FIX(O_DIRECT);To;u;[[@8i;F;: TMPFILE;;w;;;[;{;IC; "%Create an unnamed temporary file ;T;[;![;"I"%Create an unnamed temporary file;T;#0;$@Qf;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::TMPFILE;F;xI"INT2FIX(O_TMPFILE);To;u;[[@8i;F;: LOCK_SH;;w;;;[;{;IC; " shared lock. see File#flock ;T;[;![;"I" shared lock. see File#flock;T;#0;$@]f;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::LOCK_SH;F;xI"INT2FIX(LOCK_SH);To;u;[[@8i;F;: LOCK_EX;;w;;;[;{;IC; "#exclusive lock. see File#flock ;T;[;![;"I"#exclusive lock. see File#flock;T;#0;$@if;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::LOCK_EX;F;xI"INT2FIX(LOCK_EX);To;u;[[@8i;F;: LOCK_UN;;w;;;[;{;IC; "unlock. see File#flock ;T;[;![;"I"unlock. see File#flock;T;#0;$@uf;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::LOCK_UN;F;xI"INT2FIX(LOCK_UN);To;u;[[@8i;F;: LOCK_NB;;w;;;[;{;IC; "Dnon-blocking lock. used with LOCK_SH or LOCK_EX. see File#flock ;T;[;![;"I"Dnon-blocking lock. used with LOCK_SH or LOCK_EX. see File#flock;T;#0;$@f;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::LOCK_NB;F;xI"INT2FIX(LOCK_NB);To;u;[[@8i;F;: NULL;;w;;;[;{;IC; "Name of the null device ;T;[;![;"I"Name of the null device;T;#0;$@f;.F;/o;0;1T;2i;3i;%@e;&I"File::Constants::NULL;F;xI"&rb_fstring_cstr(ruby_null_device);T; @e; IC;[; @e; IC;[; @e; IC;{;IC;{;T;IC;{;T;T;{;[;[[@8i[@8i;T;;;;;;;[;{;IC; "^File::Constants provides file-related constants. All possible file constants are listed in the documentation but they may not all be present on your platform. If the underlying platform doesn't define a constant the corresponding Ruby constant is not defined. Your platform documentations (e.g. man open(2)) may describe more detailed information. ;T;[;![;"I"` File::Constants provides file-related constants. All possible file constants are listed in the documentation but they may not all be present on your platform. If the underlying platform doesn't define a constant the corresponding Ruby constant is not defined. Your platform documentations (e.g. man open(2)) may describe more detailed information. ;T;#0;$@e;.F;/o;0;1T;2i;3i;%o; ;IC;[Wo;4;5F;6;;;;&I"File.open;F;7[[@90;[[@Ti6;T;;;0;[;{;IC; "call-seq: IO.open(fd, mode="r" [, opt]) -> io IO.open(fd, mode="r" [, opt]) {|io| block } -> obj With no associated block, IO.open is a synonym for IO.new. If the optional code block is given, it will be passed +io+ as an argument, and the IO object will automatically be closed when the block terminates. In this instance, IO.open returns the value of the block. See IO.new for a description of the +fd+, +mode+ and +opt+ parameters. ;T;[;![;"@#M;#0;$@f;.F;/o;0;1T;2i';3i2;%@f;9I"static VALUE rb_io_s_open(int argc, VALUE *argv, VALUE klass) { VALUE io = rb_class_new_instance_kw(argc, argv, klass, RB_PASS_CALLED_KEYWORDS); if (rb_block_given_p()) { return rb_ensure(rb_yield, io, io_close, io); } return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File#initialize;F;7[[@90;[[@Ti";T;;D;0;[;{;IC; "~Opens the file named by +filename+ according to the given +mode+ and returns a new File object. See IO.new for a description of +mode+ and +opt+. If a file is being created, permission bits may be given in +perm+. These mode and permission bits are platform dependent; on Unix systems, see open(2) and chmod(2) man pages for details. The new File object is buffered mode (or non-sync mode), unless +filename+ is a tty. See IO#flush, IO#fsync, IO#fdatasync, and IO#sync= about sync mode. === Examples f = File.new("testfile", "r") f = File.new("newfile", "w+") f = File.new("newfile", File::CREAT|File::TRUNC|File::RDWR, 0644) ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"$new(filename, mode="r" [, opt]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" File;T;$@f;![;"I"@return [File];T;#0;$@f;.F;Bi;C0;7[[I" filename;T0[I" mode;TI""r"[, opt];T;$@fo;= ;>I" overload;F;?0;;E;@0;:I",new(filename [, mode [, perm]] [, opt]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" File;T;$@f;![;"I"@return [File];T;#0;$@f;.F;Bi;C0;7[[I"%filename[, mode [, perm]][, opt];T0;$@f;![;"I"Opens the file named by +filename+ according to the given +mode+ and returns a new File object. See IO.new for a description of +mode+ and +opt+. If a file is being created, permission bits may be given in +perm+. These mode and permission bits are platform dependent; on Unix systems, see open(2) and chmod(2) man pages for details. The new File object is buffered mode (or non-sync mode), unless +filename+ is a tty. See IO#flush, IO#fsync, IO#fdatasync, and IO#sync= about sync mode. === Examples f = File.new("testfile", "r") f = File.new("newfile", "w+") f = File.new("newfile", File::CREAT|File::TRUNC|File::RDWR, 0644) @overload new(filename, mode="r" [, opt]) @return [File] @overload new(filename [, mode [, perm]] [, opt]) @return [File];T;#0;$@f;.F;/o;0;1T;2i";3i";%@f;9I"ostatic VALUE rb_file_initialize(int argc, VALUE *argv, VALUE io) { if (RFILE(io)->fptr) { rb_raise(rb_eRuntimeError, "reinitializing File"); } if (0 < argc && argc < 3) { VALUE fd = rb_check_to_int(argv[0]); if (!NIL_P(fd)) { argv[0] = fd; return rb_io_initialize(argc, argv, io); } } rb_open_file(argc, argv, io); return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.fnmatch;F;7[[@90;[[I" dir.c;Tiq ;T;: fnmatch;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@f;.F;/o;0;1T;2ip ;3ip ;%@f;9I"static VALUE file_s_fnmatch(int argc, VALUE *argv, VALUE obj) { VALUE pattern, path; VALUE rflags; int flags; if (rb_scan_args(argc, argv, "21", &pattern, &path, &rflags) == 3) flags = NUM2INT(rflags); else flags = 0; StringValueCStr(pattern); FilePathStringValue(path); if (flags & FNM_EXTGLOB) { struct brace_args args; args.value = path; args.flags = flags; if (ruby_brace_expand(RSTRING_PTR(pattern), flags, fnmatch_brace, (VALUE)&args, rb_enc_get(pattern), pattern) > 0) return Qtrue; } else { rb_encoding *enc = rb_enc_compatible(pattern, path); if (!enc) return Qfalse; if (fnmatch(RSTRING_PTR(pattern), enc, RSTRING_PTR(path), flags) == 0) return Qtrue; } RB_GC_GUARD(pattern); return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.fnmatch?;F;7[[@90;[[@fiq ;T;: fnmatch?;0;[;{;IC; " :nodoc:;T;[o;A ;>I" return;F;?@;0;@[@L;$@f;![;"@f;#0;$@f;.F;/o;0;1T;2ip ;3ip ;Bi;%@f;9I"static VALUE file_s_fnmatch(int argc, VALUE *argv, VALUE obj) { VALUE pattern, path; VALUE rflags; int flags; if (rb_scan_args(argc, argv, "21", &pattern, &path, &rflags) == 3) flags = NUM2INT(rflags); else flags = 0; StringValueCStr(pattern); FilePathStringValue(path); if (flags & FNM_EXTGLOB) { struct brace_args args; args.value = path; args.flags = flags; if (ruby_brace_expand(RSTRING_PTR(pattern), flags, fnmatch_brace, (VALUE)&args, rb_enc_get(pattern), pattern) > 0) return Qtrue; } else { rb_encoding *enc = rb_enc_compatible(pattern, path); if (!enc) return Qfalse; if (fnmatch(RSTRING_PTR(pattern), enc, RSTRING_PTR(path), flags) == 0) return Qtrue; } RB_GC_GUARD(pattern); return Qfalse; };T;:I"static VALUE;T;;To; ;IC;[2o;4;5F;6;;;;&I"File::Stat#initialize;F;7[[I" fname;T0;[[@8i;T;;D;0;[;{;IC; "iCreate a File::Stat object for the given file name (raising an exception if the file doesn't exist). ;T;[o;= ;>I" overload;F;?0;:File::Stat.new;@0;:I"File::Stat.new(file_name);T;IC; ";T;[;![;"I";T;#0;$@ g;.F;Bi;C0;7[[I"file_name;T0;$@ g;![;"I"Create a File::Stat object for the given file name (raising an exception if the file doesn't exist). @overload File::Stat.new(file_name);T;#0;$@ g;.F;/o;0;1T;2i;3i;%@ g;9I"static VALUE rb_stat_init(VALUE obj, VALUE fname) { struct stat st, *nst; FilePathValue(fname); fname = rb_str_encode_ospath(fname); if (STAT(StringValueCStr(fname), &st) == -1) { rb_sys_fail_path(fname); } if (DATA_PTR(obj)) { xfree(DATA_PTR(obj)); DATA_PTR(obj) = NULL; } nst = ALLOC(struct stat); *nst = st; DATA_PTR(obj) = nst; return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#initialize_copy;F;7[[I" orig;T0;[[@8i;T;;];0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@'g;.F;/o;0;1T;2i;3i;%@ g;9I"Zstatic VALUE rb_stat_init_copy(VALUE copy, VALUE orig) { struct stat *nst; if (!OBJ_INIT_COPY(copy, orig)) return copy; if (DATA_PTR(copy)) { xfree(DATA_PTR(copy)); DATA_PTR(copy) = 0; } if (DATA_PTR(orig)) { nst = ALLOC(struct stat); *nst = *(struct stat*)DATA_PTR(orig); DATA_PTR(copy) = nst; } return copy; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#<=>;F;7[[I" other;T0;[[@8i;T;;Y;0;[;{;IC; "Compares File::Stat objects by comparing their respective modification times. +nil+ is returned if +other_stat+ is not a File::Stat object f1 = File.new("f1", "w") sleep 1 f2 = File.new("f2", "w") f1.stat <=> f2.stat #=> -1 ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I"<=>(other_stat);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[ I"-1;TI"0;TI"1;TI"nil;T;$@7g;![;"I"@return [-1, 0, 1, nil];T;#0;$@7g;.F;Bi;C0;7[[I"other_stat;T0;$@7g;![;"I"'Compares File::Stat objects by comparing their respective modification times. +nil+ is returned if +other_stat+ is not a File::Stat object f1 = File.new("f1", "w") sleep 1 f2 = File.new("f2", "w") f1.stat <=> f2.stat #=> -1 @overload <=>(other_stat) @return [-1, 0, 1, nil];T;#0;$@7g;.F;/o;0;1T;2i ;3i;%@ g;9I"$static VALUE rb_stat_cmp(VALUE self, VALUE other) { if (rb_obj_is_kind_of(other, rb_obj_class(self))) { struct timespec ts1 = stat_mtimespec(get_stat(self)); struct timespec ts2 = stat_mtimespec(get_stat(other)); if (ts1.tv_sec == ts2.tv_sec) { if (ts1.tv_nsec == ts2.tv_nsec) return INT2FIX(0); if (ts1.tv_nsec < ts2.tv_nsec) return INT2FIX(-1); return INT2FIX(1); } if (ts1.tv_sec < ts2.tv_sec) return INT2FIX(-1); return INT2FIX(1); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#dev;F;7[;[[@8iA;T;:dev;0;[;{;IC; "uReturns an integer representing the device on which stat resides. File.stat("testfile").dev #=> 774 ;T;[o;= ;>I" overload;F;?0;;&;@0;:I"dev;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@Yg;![;"I"@return [Integer];T;#0;$@Yg;.F;Bi;C0;7[;$@Yg;![;"I"Returns an integer representing the device on which stat resides. File.stat("testfile").dev #=> 774 @overload dev @return [Integer];T;#0;$@Yg;.F;/o;0;1T;2i7;3i>;%@ g;9I"static VALUE rb_stat_dev(VALUE self) { #if SIZEOF_STRUCT_STAT_ST_DEV <= SIZEOF_DEV_T return DEVT2NUM(get_stat(self)->st_dev); #elif SIZEOF_STRUCT_STAT_ST_DEV <= SIZEOF_LONG return ULONG2NUM(get_stat(self)->st_dev); #else return ULL2NUM(get_stat(self)->st_dev); #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#dev_major;F;7[;[[@8iX;T;:dev_major;0;[;{;IC; "Returns the major part of File_Stat#dev or nil. File.stat("/dev/fd1").dev_major #=> 2 File.stat("/dev/tty").dev_major #=> 5 ;T;[o;= ;>I" overload;F;?0;;';@0;:I"dev_major;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@tg;![;"I"@return [Integer];T;#0;$@tg;.F;Bi;C0;7[;$@tg;![;"I"Returns the major part of File_Stat#dev or nil. File.stat("/dev/fd1").dev_major #=> 2 File.stat("/dev/tty").dev_major #=> 5 @overload dev_major @return [Integer];T;#0;$@tg;.F;/o;0;1T;2iM;3iU;%@ g;9I"static VALUE rb_stat_dev_major(VALUE self) { #if defined(major) return UINT2NUM(major(get_stat(self)->st_dev)); #else return Qnil; #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#dev_minor;F;7[;[[@8im;T;:dev_minor;0;[;{;IC; "Returns the minor part of File_Stat#dev or nil. File.stat("/dev/fd1").dev_minor #=> 1 File.stat("/dev/tty").dev_minor #=> 0 ;T;[o;= ;>I" overload;F;?0;;(;@0;:I"dev_minor;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@g;![;"I"@return [Integer];T;#0;$@g;.F;Bi;C0;7[;$@g;![;"I"Returns the minor part of File_Stat#dev or nil. File.stat("/dev/fd1").dev_minor #=> 1 File.stat("/dev/tty").dev_minor #=> 0 @overload dev_minor @return [Integer];T;#0;$@g;.F;/o;0;1T;2ib;3ij;%@ g;9I"static VALUE rb_stat_dev_minor(VALUE self) { #if defined(minor) return UINT2NUM(minor(get_stat(self)->st_dev)); #else return Qnil; #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#ino;F;7[;[[@8i;T;:ino;0;[;{;IC; "ZReturns the inode number for stat. File.stat("testfile").ino #=> 1083669 ;T;[o;= ;>I" overload;F;?0;;);@0;:I"ino;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@g;![;"I"@return [Integer];T;#0;$@g;.F;Bi;C0;7[;$@g;![;"I"Returns the inode number for stat. File.stat("testfile").ino #=> 1083669 @overload ino @return [Integer];T;#0;$@g;.F;/o;0;1T;2iw;3i~;%@ g;9I"static VALUE rb_stat_ino(VALUE self) { #ifdef HAVE_STRUCT_STAT_ST_INOHIGH /* assume INTEGER_PACK_LSWORD_FIRST and st_inohigh is just next of st_ino */ return rb_integer_unpack(&get_stat(self)->st_ino, 2, SIZEOF_STRUCT_STAT_ST_INO, 0, INTEGER_PACK_LSWORD_FIRST|INTEGER_PACK_NATIVE_BYTE_ORDER| INTEGER_PACK_2COMP); #elif SIZEOF_STRUCT_STAT_ST_INO > SIZEOF_LONG return ULL2NUM(get_stat(self)->st_ino); #else return ULONG2NUM(get_stat(self)->st_ino); #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#mode;F;7[;[[@8i;T;: mode;0;[;{;IC; "Returns an integer representing the permission bits of stat. The meaning of the bits is platform dependent; on Unix systems, see stat(2). File.chmod(0644, "testfile") #=> 1 s = File.stat("testfile") sprintf("%o", s.mode) #=> "100644" ;T;[o;= ;>I" overload;F;?0;;*;@0;:I" mode;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@g;![;"I"@return [Integer];T;#0;$@g;.F;Bi;C0;7[;$@g;![;"I"7Returns an integer representing the permission bits of stat. The meaning of the bits is platform dependent; on Unix systems, see stat(2). File.chmod(0644, "testfile") #=> 1 s = File.stat("testfile") sprintf("%o", s.mode) #=> "100644" @overload mode @return [Integer];T;#0;$@g;.F;/o;0;1T;2i;3i;%@ g;9I"estatic VALUE rb_stat_mode(VALUE self) { return UINT2NUM(ST2UINT(get_stat(self)->st_mode)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#nlink;F;7[;[[@8i;T;: nlink;0;[;{;IC; "Returns the number of hard links to stat. File.stat("testfile").nlink #=> 1 File.link("testfile", "testfile.bak") #=> 0 File.stat("testfile").nlink #=> 2 ;T;[o;= ;>I" overload;F;?0;;+;@0;:I" nlink;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@g;![;"I"@return [Integer];T;#0;$@g;.F;Bi;C0;7[;$@g;![;"I"Returns the number of hard links to stat. File.stat("testfile").nlink #=> 1 File.link("testfile", "testfile.bak") #=> 0 File.stat("testfile").nlink #=> 2 @overload nlink @return [Integer];T;#0;$@g;.F;/o;0;1T;2i;3i;%@ g;9I"Bstatic VALUE rb_stat_nlink(VALUE self) { /* struct stat::st_nlink is nlink_t in POSIX. Not the case for Windows. */ const struct stat *ptr = get_stat(self); if (sizeof(ptr->st_nlink) <= sizeof(int)) { return UINT2NUM((unsigned)ptr->st_nlink); } else if (sizeof(ptr->st_nlink) == sizeof(long)) { return ULONG2NUM((unsigned long)ptr->st_nlink); } else if (sizeof(ptr->st_nlink) == sizeof(LONG_LONG)) { return ULL2NUM((unsigned LONG_LONG)ptr->st_nlink); } else { rb_bug(":FIXME: don't know what to do"); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#uid;F;7[;[[@8i;T;:uid;0;[;{;IC; "eReturns the numeric user id of the owner of stat. File.stat("testfile").uid #=> 501 ;T;[o;= ;>I" overload;F;?0;;,;@0;:I"uid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@g;![;"I"@return [Integer];T;#0;$@g;.F;Bi;C0;7[;$@g;![;"I"Returns the numeric user id of the owner of stat. File.stat("testfile").uid #=> 501 @overload uid @return [Integer];T;#0;$@g;.F;/o;0;1T;2i;3i;%@ g;9I"Zstatic VALUE rb_stat_uid(VALUE self) { return UIDT2NUM(get_stat(self)->st_uid); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#gid;F;7[;[[@8i;T;:gid;0;[;{;IC; "fReturns the numeric group id of the owner of stat. File.stat("testfile").gid #=> 500 ;T;[o;= ;>I" overload;F;?0;;-;@0;:I"gid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@h;![;"I"@return [Integer];T;#0;$@h;.F;Bi;C0;7[;$@h;![;"I"Returns the numeric group id of the owner of stat. File.stat("testfile").gid #=> 500 @overload gid @return [Integer];T;#0;$@h;.F;/o;0;1T;2i;3i;%@ g;9I"Zstatic VALUE rb_stat_gid(VALUE self) { return GIDT2NUM(get_stat(self)->st_gid); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#rdev;F;7[;[[@8i;T;: rdev;0;[;{;IC; "Returns an integer representing the device type on which stat resides. Returns nil if the operating system doesn't support this feature. File.stat("/dev/fd1").rdev #=> 513 File.stat("/dev/tty").rdev #=> 1280 ;T;[o;= ;>I" overload;F;?0;;.;@0;:I" rdev;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@1h;![;"I"@return [Integer, nil];T;#0;$@1h;.F;Bi;C0;7[;$@1h;![;"I"Returns an integer representing the device type on which stat resides. Returns nil if the operating system doesn't support this feature. File.stat("/dev/fd1").rdev #=> 513 File.stat("/dev/tty").rdev #=> 1280 @overload rdev @return [Integer, nil];T;#0;$@1h;.F;/o;0;1T;2i;3i;%@ g;9I"astatic VALUE rb_stat_rdev(VALUE self) { #ifdef HAVE_STRUCT_STAT_ST_RDEV # if SIZEOF_STRUCT_STAT_ST_RDEV <= SIZEOF_DEV_T return DEVT2NUM(get_stat(self)->st_rdev); # elif SIZEOF_STRUCT_STAT_ST_RDEV <= SIZEOF_LONG return ULONG2NUM(get_stat(self)->st_rdev); # else return ULL2NUM(get_stat(self)->st_rdev); # endif #else return Qnil; #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#rdev_major;F;7[;[[@8i ;T;:rdev_major;0;[;{;IC; "Returns the major part of File_Stat#rdev or nil. File.stat("/dev/fd1").rdev_major #=> 2 File.stat("/dev/tty").rdev_major #=> 5 ;T;[o;= ;>I" overload;F;?0;;/;@0;:I"rdev_major;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@Mh;![;"I"@return [Integer];T;#0;$@Mh;.F;Bi;C0;7[;$@Mh;![;"I"Returns the major part of File_Stat#rdev or nil. File.stat("/dev/fd1").rdev_major #=> 2 File.stat("/dev/tty").rdev_major #=> 5 @overload rdev_major @return [Integer];T;#0;$@Mh;.F;/o;0;1T;2i;3i;%@ g;9I"static VALUE rb_stat_rdev_major(VALUE self) { #if defined(HAVE_STRUCT_STAT_ST_RDEV) && defined(major) return UINT2NUM(major(get_stat(self)->st_rdev)); #else return Qnil; #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#rdev_minor;F;7[;[[@8i ;T;:rdev_minor;0;[;{;IC; "Returns the minor part of File_Stat#rdev or nil. File.stat("/dev/fd1").rdev_minor #=> 1 File.stat("/dev/tty").rdev_minor #=> 0 ;T;[o;= ;>I" overload;F;?0;;0;@0;:I"rdev_minor;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@hh;![;"I"@return [Integer];T;#0;$@hh;.F;Bi;C0;7[;$@hh;![;"I"Returns the minor part of File_Stat#rdev or nil. File.stat("/dev/fd1").rdev_minor #=> 1 File.stat("/dev/tty").rdev_minor #=> 0 @overload rdev_minor @return [Integer];T;#0;$@hh;.F;/o;0;1T;2i;3i;%@ g;9I"static VALUE rb_stat_rdev_minor(VALUE self) { #if defined(HAVE_STRUCT_STAT_ST_RDEV) && defined(minor) return UINT2NUM(minor(get_stat(self)->st_rdev)); #else return Qnil; #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#size;F;7[;[[@8i3;T;;;0;[;{;IC; "VReturns the size of stat in bytes. File.stat("testfile").size #=> 66 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@h;![;"I"@return [Integer];T;#0;$@h;.F;Bi;C0;7[;$@h;![;"I"{Returns the size of stat in bytes. File.stat("testfile").size #=> 66 @overload size @return [Integer];T;#0;$@h;.F;/o;0;1T;2i*;3i0;%@ g;9I"\static VALUE rb_stat_size(VALUE self) { return OFFT2NUM(get_stat(self)->st_size); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#blksize;F;7[;[[@8iD;T;: blksize;0;[;{;IC; "Returns the native file system's block size. Will return nil on platforms that don't support this information. File.stat("testfile").blksize #=> 4096 ;T;[o;= ;>I" overload;F;?0;;1;@0;:I" blksize;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@h;![;"I"@return [Integer, nil];T;#0;$@h;.F;Bi;C0;7[;$@h;![;"I"Returns the native file system's block size. Will return nil on platforms that don't support this information. File.stat("testfile").blksize #=> 4096 @overload blksize @return [Integer, nil];T;#0;$@h;.F;/o;0;1T;2i9;3iA;%@ g;9I"static VALUE rb_stat_blksize(VALUE self) { #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE return ULONG2NUM(get_stat(self)->st_blksize); #else return Qnil; #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#blocks;F;7[;[[@8iY;T;: blocks;0;[;{;IC; "Returns the number of native file system blocks allocated for this file, or nil if the operating system doesn't support this feature. File.stat("testfile").blocks #=> 2 ;T;[o;= ;>I" overload;F;?0;;2;@0;:I" blocks;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@h;![;"I"@return [Integer, nil];T;#0;$@h;.F;Bi;C0;7[;$@h;![;"I"Returns the number of native file system blocks allocated for this file, or nil if the operating system doesn't support this feature. File.stat("testfile").blocks #=> 2 @overload blocks @return [Integer, nil];T;#0;$@h;.F;/o;0;1T;2iN;3iV;%@ g;9I" static VALUE rb_stat_blocks(VALUE self) { #ifdef HAVE_STRUCT_STAT_ST_BLOCKS # if SIZEOF_STRUCT_STAT_ST_BLOCKS > SIZEOF_LONG return ULL2NUM(get_stat(self)->st_blocks); # else return ULONG2NUM(get_stat(self)->st_blocks); # endif #else return Qnil; #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#atime;F;7[;[[@8i;T;: atime;0;[;{;IC; "Returns the last access time for this file as an object of class Time. File.stat("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969 ;T;[o;= ;>I" overload;F;?0;;3;@0;:I" atime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@h;![;"I"@return [Time];T;#0;$@h;.F;Bi;C0;7[;$@h;![;"I"Returns the last access time for this file as an object of class Time. File.stat("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969 @overload atime @return [Time];T;#0;$@h;.F;/o;0;1T;2i;3i;%@ g;9I"Vstatic VALUE rb_stat_atime(VALUE self) { return stat_atime(get_stat(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#mtime;F;7[;[[@8i;T;: mtime;0;[;{;IC; "uReturns the modification time of stat. File.stat("testfile").mtime #=> Wed Apr 09 08:53:14 CDT 2003 ;T;[o;= ;>I" overload;F;?0;;4;@0;:I" mtime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" aTime;T;$@h;![;"I"@return [ aTime];T;#0;$@h;.F;Bi;C0;7[;$@h;![;"I"Returns the modification time of stat. File.stat("testfile").mtime #=> Wed Apr 09 08:53:14 CDT 2003 @overload mtime @return [ aTime];T;#0;$@h;.F;/o;0;1T;2i;3i;%@ g;9I"Vstatic VALUE rb_stat_mtime(VALUE self) { return stat_mtime(get_stat(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#ctime;F;7[;[[@8i;T;: ctime;0;[;{;IC; "Returns the change time for stat (that is, the time directory information about the file was changed, not the file itself). Note that on Windows (NTFS), returns creation time (birth time). File.stat("testfile").ctime #=> Wed Apr 09 08:53:14 CDT 2003 ;T;[o;= ;>I" overload;F;?0;;5;@0;:I" ctime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" aTime;T;$@ i;![;"I"@return [ aTime];T;#0;$@ i;.F;Bi;C0;7[;$@ i;![;"I"-Returns the change time for stat (that is, the time directory information about the file was changed, not the file itself). Note that on Windows (NTFS), returns creation time (birth time). File.stat("testfile").ctime #=> Wed Apr 09 08:53:14 CDT 2003 @overload ctime @return [ aTime];T;#0;$@ i;.F;/o;0;1T;2i;3i;%@ g;9I"Vstatic VALUE rb_stat_ctime(VALUE self) { return stat_ctime(get_stat(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#birthtime;F;7[;[[@8i;T;:birthtime;0;[;{;IC; "Returns the birth time for stat. If the platform doesn't have birthtime, raises NotImplementedError. File.write("testfile", "foo") sleep 10 File.write("testfile", "bar") sleep 10 File.chmod(0644, "testfile") sleep 10 File.read("testfile") File.stat("testfile").birthtime #=> 2014-02-24 11:19:17 +0900 File.stat("testfile").mtime #=> 2014-02-24 11:19:27 +0900 File.stat("testfile").ctime #=> 2014-02-24 11:19:37 +0900 File.stat("testfile").atime #=> 2014-02-24 11:19:47 +0900 ;T;[o;= ;>I" overload;F;?0;;6;@0;:I"birthtime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" aTime;T;$@'i;![;"I"@return [ aTime];T;#0;$@'i;.F;Bi;C0;7[;$@'i;![;"I"BReturns the birth time for stat. If the platform doesn't have birthtime, raises NotImplementedError. File.write("testfile", "foo") sleep 10 File.write("testfile", "bar") sleep 10 File.chmod(0644, "testfile") sleep 10 File.read("testfile") File.stat("testfile").birthtime #=> 2014-02-24 11:19:17 +0900 File.stat("testfile").mtime #=> 2014-02-24 11:19:27 +0900 File.stat("testfile").ctime #=> 2014-02-24 11:19:37 +0900 File.stat("testfile").atime #=> 2014-02-24 11:19:47 +0900 @overload birthtime @return [ aTime];T;#0;$@'i;.F;/o;0;1T;2i;3i ;%@ g;9I"^static VALUE rb_stat_birthtime(VALUE self) { return stat_birthtime(get_stat(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#inspect;F;7[;[[@8i&;T;;J;0;[;{;IC; "Produce a nicely formatted description of stat. File.stat("/etc/passwd").inspect #=> "#" ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@Bi;![;"I"@return [String];T;#0;$@Bi;.F;Bi;C0;7[;$@Bi;![;"I"Produce a nicely formatted description of stat. File.stat("/etc/passwd").inspect #=> "#" @overload inspect @return [String];T;#0;$@Bi;.F;/o;0;1T;2i;3i#;%@ g;9I"static VALUE rb_stat_inspect(VALUE self) { VALUE str; size_t i; static const struct { const char *name; VALUE (*func)(VALUE); } member[] = { {"dev", rb_stat_dev}, {"ino", rb_stat_ino}, {"mode", rb_stat_mode}, {"nlink", rb_stat_nlink}, {"uid", rb_stat_uid}, {"gid", rb_stat_gid}, {"rdev", rb_stat_rdev}, {"size", rb_stat_size}, {"blksize", rb_stat_blksize}, {"blocks", rb_stat_blocks}, {"atime", rb_stat_atime}, {"mtime", rb_stat_mtime}, {"ctime", rb_stat_ctime}, #if defined(HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC) {"birthtime", rb_stat_birthtime}, #endif }; struct stat* st; TypedData_Get_Struct(self, struct stat, &stat_data_type, st); if (!st) { return rb_sprintf("#<%s: uninitialized>", rb_obj_classname(self)); } str = rb_str_buf_new2("#<"); rb_str_buf_cat2(str, rb_obj_classname(self)); rb_str_buf_cat2(str, " "); for (i = 0; i < sizeof(member)/sizeof(member[0]); i++) { VALUE v; if (i > 0) { rb_str_buf_cat2(str, ", "); } rb_str_buf_cat2(str, member[i].name); rb_str_buf_cat2(str, "="); v = (*member[i].func)(self); if (i == 2) { /* mode */ rb_str_catf(str, "0%lo", (unsigned long)NUM2ULONG(v)); } else if (i == 0 || i == 6) { /* dev/rdev */ rb_str_catf(str, "0x%"PRI_DEVT_PREFIX"x", NUM2DEVT(v)); } else { rb_str_append(str, rb_inspect(v)); } } rb_str_buf_cat2(str, ">"); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#ftype;F;7[;[[@8i;T;: ftype;0;[;{;IC; "RIdentifies the type of stat. The return string is one of: ``file'', ``directory'', ``characterSpecial'', ``blockSpecial'', ``fifo'', ``link'', ``socket'', or ``unknown''. File.stat("/dev/tty").ftype #=> "characterSpecial" ;T;[o;= ;>I" overload;F;?0;;7;@0;:I" ftype;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@]i;![;"I"@return [String];T;#0;$@]i;.F;Bi;C0;7[;$@]i;![;"I"xIdentifies the type of stat. The return string is one of: ``file'', ``directory'', ``characterSpecial'', ``blockSpecial'', ``fifo'', ``link'', ``socket'', or ``unknown''. File.stat("/dev/tty").ftype #=> "characterSpecial" @overload ftype @return [String];T;#0;$@]i;.F;/o;0;1T;2i;3i;%@ g;9I"Wstatic VALUE rb_stat_ftype(VALUE obj) { return rb_file_ftype(get_stat(obj)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#directory?;F;7[;[[@8i;T;:directory?;0;[;{;IC; "Returns true if stat is a directory, false otherwise. File.stat("testfile").directory? #=> false File.stat(".").directory? #=> true;T;[o;= ;>I" overload;F;?0;;8;@0;:I"directory?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@xi;![;"I"@return [Boolean];T;#0;$@xi;.F;Bi;C0;7[;$@xi;![;"I"Returns true if stat is a directory, false otherwise. File.stat("testfile").directory? #=> false File.stat(".").directory? #=> true @overload directory? @return [Boolean];T;#0;$@xi;.F;/o;0;1T;2i;3i;Bi;%@ g;9I"tstatic VALUE rb_stat_d(VALUE obj) { if (S_ISDIR(get_stat(obj)->st_mode)) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#readable?;F;7[;[[@8i;T;:readable?;0;[;{;IC; "Returns true if stat is readable by the effective user id of this process. File.stat("testfile").readable? #=> true;T;[o;= ;>I" overload;F;?0;;9;@0;:I"readable?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@i;![;"I"@return [Boolean];T;#0;$@i;.F;Bi;C0;7[;$@i;![;"I"Returns true if stat is readable by the effective user id of this process. File.stat("testfile").readable? #=> true @overload readable? @return [Boolean];T;#0;$@i;.F;/o;0;1T;2i;3i;Bi;%@ g;9I"static VALUE rb_stat_r(VALUE obj) { struct stat *st = get_stat(obj); #ifdef USE_GETEUID if (geteuid() == 0) return Qtrue; #endif #ifdef S_IRUSR if (rb_stat_owned(obj)) return RBOOL(st->st_mode & S_IRUSR); #endif #ifdef S_IRGRP if (rb_stat_grpowned(obj)) return RBOOL(st->st_mode & S_IRGRP); #endif #ifdef S_IROTH if (!(st->st_mode & S_IROTH)) return Qfalse; #endif return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#readable_real?;F;7[;[[@8i;T;:readable_real?;0;[;{;IC; "Returns true if stat is readable by the real user id of this process. File.stat("testfile").readable_real? #=> true;T;[o;= ;>I" overload;F;?0;;:;@0;:I"readable_real?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@i;![;"I"@return [Boolean];T;#0;$@i;.F;Bi;C0;7[;$@i;![;"I"Returns true if stat is readable by the real user id of this process. File.stat("testfile").readable_real? #=> true @overload readable_real? @return [Boolean];T;#0;$@i;.F;/o;0;1T;2i;3i;Bi;%@ g;9I"static VALUE rb_stat_R(VALUE obj) { struct stat *st = get_stat(obj); #ifdef USE_GETEUID if (getuid() == 0) return Qtrue; #endif #ifdef S_IRUSR if (rb_stat_rowned(obj)) return RBOOL(st->st_mode & S_IRUSR); #endif #ifdef S_IRGRP if (rb_group_member(get_stat(obj)->st_gid)) return RBOOL(st->st_mode & S_IRGRP); #endif #ifdef S_IROTH if (!(st->st_mode & S_IROTH)) return Qfalse; #endif return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#world_readable?;F;7[;[[@8i;T;:world_readable?;0;[;{;IC; "KIf stat is readable by others, returns an integer representing the file permission bits of stat. Returns nil otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2). m = File.stat("/etc/passwd").world_readable? #=> 420 sprintf("%o", m) #=> "644";T;[o;= ;>I" overload;F;?0;;;;@0;:I"world_readable?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@i;![;"I"@return [Integer, nil];T;#0;$@i;.F;Bi;C0;7[;$@i;![;"I"If stat is readable by others, returns an integer representing the file permission bits of stat. Returns nil otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2). m = File.stat("/etc/passwd").world_readable? #=> 420 sprintf("%o", m) #=> "644" @overload world_readable? @return [Integer, nil];T;#0;$@i;.F;/o;0;1T;2i;3i;Bi;%@ g;9I"static VALUE rb_stat_wr(VALUE obj) { #ifdef S_IROTH struct stat *st = get_stat(obj); if ((st->st_mode & (S_IROTH)) == S_IROTH) { return UINT2NUM(st->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO)); } else { return Qnil; } #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#writable?;F;7[;[[@8i ;T;:writable?;0;[;{;IC; "Returns true if stat is writable by the effective user id of this process. File.stat("testfile").writable? #=> true;T;[o;= ;>I" overload;F;?0;;<;@0;:I"writable?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@i;![;"I"@return [Boolean];T;#0;$@i;.F;Bi;C0;7[;$@i;![;"I"Returns true if stat is writable by the effective user id of this process. File.stat("testfile").writable? #=> true @overload writable? @return [Boolean];T;#0;$@i;.F;/o;0;1T;2i;3i;Bi;%@ g;9I"static VALUE rb_stat_w(VALUE obj) { struct stat *st = get_stat(obj); #ifdef USE_GETEUID if (geteuid() == 0) return Qtrue; #endif #ifdef S_IWUSR if (rb_stat_owned(obj)) return RBOOL(st->st_mode & S_IWUSR); #endif #ifdef S_IWGRP if (rb_stat_grpowned(obj)) return RBOOL(st->st_mode & S_IWGRP); #endif #ifdef S_IWOTH if (!(st->st_mode & S_IWOTH)) return Qfalse; #endif return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#writable_real?;F;7[;[[@8i+;T;:writable_real?;0;[;{;IC; "Returns true if stat is writable by the real user id of this process. File.stat("testfile").writable_real? #=> true;T;[o;= ;>I" overload;F;?0;;=;@0;:I"writable_real?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@j;![;"I"@return [Boolean];T;#0;$@j;.F;Bi;C0;7[;$@j;![;"I"Returns true if stat is writable by the real user id of this process. File.stat("testfile").writable_real? #=> true @overload writable_real? @return [Boolean];T;#0;$@j;.F;/o;0;1T;2i ;3i(;Bi;%@ g;9I"static VALUE rb_stat_W(VALUE obj) { struct stat *st = get_stat(obj); #ifdef USE_GETEUID if (getuid() == 0) return Qtrue; #endif #ifdef S_IWUSR if (rb_stat_rowned(obj)) return RBOOL(st->st_mode & S_IWUSR); #endif #ifdef S_IWGRP if (rb_group_member(get_stat(obj)->st_gid)) return RBOOL(st->st_mode & S_IWGRP); #endif #ifdef S_IWOTH if (!(st->st_mode & S_IWOTH)) return Qfalse; #endif return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#world_writable?;F;7[;[[@8iN;T;:world_writable?;0;[;{;IC; "GIf stat is writable by others, returns an integer representing the file permission bits of stat. Returns nil otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2). m = File.stat("/tmp").world_writable? #=> 511 sprintf("%o", m) #=> "777";T;[o;= ;>I" overload;F;?0;;>;@0;:I"world_writable?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@j;![;"I"@return [Integer, nil];T;#0;$@j;.F;Bi;C0;7[;$@j;![;"I"|If stat is writable by others, returns an integer representing the file permission bits of stat. Returns nil otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2). m = File.stat("/tmp").world_writable? #=> 511 sprintf("%o", m) #=> "777" @overload world_writable? @return [Integer, nil];T;#0;$@j;.F;/o;0;1T;2iA;3iK;Bi;%@ g;9I"static VALUE rb_stat_ww(VALUE obj) { #ifdef S_IROTH struct stat *st = get_stat(obj); if ((st->st_mode & (S_IWOTH)) == S_IWOTH) { return UINT2NUM(st->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO)); } else { return Qnil; } #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#executable?;F;7[;[[@8ii;T;:executable?;0;[;{;IC; "Returns true if stat is executable or if the operating system doesn't distinguish executable files from nonexecutable files. The tests are made using the effective owner of the process. File.stat("testfile").executable? #=> false;T;[o;= ;>I" overload;F;?0;;?;@0;:I"executable?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@7j;![;"I"@return [Boolean];T;#0;$@7j;.F;Bi;C0;7[;$@7j;![;"I",Returns true if stat is executable or if the operating system doesn't distinguish executable files from nonexecutable files. The tests are made using the effective owner of the process. File.stat("testfile").executable? #=> false @overload executable? @return [Boolean];T;#0;$@7j;.F;/o;0;1T;2i\;3if;Bi;%@ g;9I"static VALUE rb_stat_x(VALUE obj) { struct stat *st = get_stat(obj); #ifdef USE_GETEUID if (geteuid() == 0) { return RBOOL(st->st_mode & S_IXUGO); } #endif #ifdef S_IXUSR if (rb_stat_owned(obj)) return RBOOL(st->st_mode & S_IXUSR); #endif #ifdef S_IXGRP if (rb_stat_grpowned(obj)) return RBOOL(st->st_mode & S_IXGRP); #endif #ifdef S_IXOTH if (!(st->st_mode & S_IXOTH)) return Qfalse; #endif return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" File::Stat#executable_real?;F;7[;[[@8i;T;:executable_real?;0;[;{;IC; "USame as executable?, but tests using the real owner of the process.;T;[o;= ;>I" overload;F;?0;;@;@0;:I"executable_real?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Rj;![;"I"@return [Boolean];T;#0;$@Rj;.F;Bi;C0;7[;$@Rj;![;"I"Same as executable?, but tests using the real owner of the process. @overload executable_real? @return [Boolean];T;#0;$@Rj;.F;/o;0;1T;2i;3i;Bi;%@ g;9I"static VALUE rb_stat_X(VALUE obj) { struct stat *st = get_stat(obj); #ifdef USE_GETEUID if (getuid() == 0) { return RBOOL(st->st_mode & S_IXUGO); } #endif #ifdef S_IXUSR if (rb_stat_rowned(obj)) return RBOOL(st->st_mode & S_IXUSR); #endif #ifdef S_IXGRP if (rb_group_member(get_stat(obj)->st_gid)) return RBOOL(st->st_mode & S_IXGRP); #endif #ifdef S_IXOTH if (!(st->st_mode & S_IXOTH)) return Qfalse; #endif return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#file?;F;7[;[[@8i;T;: file?;0;[;{;IC; "Returns true if stat is a regular file (not a device file, pipe, socket, etc.). File.stat("testfile").file? #=> true;T;[o;= ;>I" overload;F;?0;;A;@0;:I" file?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@mj;![;"I"@return [Boolean];T;#0;$@mj;.F;Bi;C0;7[;$@mj;![;"I"Returns true if stat is a regular file (not a device file, pipe, socket, etc.). File.stat("testfile").file? #=> true @overload file? @return [Boolean];T;#0;$@mj;.F;/o;0;1T;2i;3i;Bi;%@ g;9I"tstatic VALUE rb_stat_f(VALUE obj) { if (S_ISREG(get_stat(obj)->st_mode)) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#zero?;F;7[;[[@8i;T;: zero?;0;[;{;IC; "Returns true if stat is a zero-length file; false otherwise. File.stat("testfile").zero? #=> false;T;[o;= ;>I" overload;F;?0;;B;@0;:I" zero?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@j;![;"I"@return [Boolean];T;#0;$@j;.F;Bi;C0;7[;$@j;![;"I"Returns true if stat is a zero-length file; false otherwise. File.stat("testfile").zero? #=> false @overload zero? @return [Boolean];T;#0;$@j;.F;/o;0;1T;2i;3i;Bi;%@ g;9I"pstatic VALUE rb_stat_z(VALUE obj) { if (get_stat(obj)->st_size == 0) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#size?;F;7[;[[@8i;T;: size?;0;[;{;IC; "Returns +nil+ if stat is a zero-length file, the size of the file otherwise. File.stat("testfile").size? #=> 66 File.stat("/dev/null").size? #=> nil;T;[o;= ;>I" overload;F;?0;;C;@0;:I" size?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@j;![;"I"@return [Integer, nil];T;#0;$@j;.F;Bi;C0;7[;$@j;![;"I"Returns +nil+ if stat is a zero-length file, the size of the file otherwise. File.stat("testfile").size? #=> 66 File.stat("/dev/null").size? #=> nil @overload size? @return [Integer, nil];T;#0;$@j;.F;/o;0;1T;2i;3i;Bi;%@ g;9I"static VALUE rb_stat_s(VALUE obj) { off_t size = get_stat(obj)->st_size; if (size == 0) return Qnil; return OFFT2NUM(size); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#owned?;F;7[;[[@8i;T;;X;0;[;{;IC; "Returns true if the effective user id of the process is the same as the owner of stat. File.stat("testfile").owned? #=> true File.stat("/etc/passwd").owned? #=> false;T;[o;= ;>I" overload;F;?0;;X;@0;:I" owned?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@j;![;"I"@return [Boolean];T;#0;$@j;.F;Bi;C0;7[;$@j;![;"I"Returns true if the effective user id of the process is the same as the owner of stat. File.stat("testfile").owned? #=> true File.stat("/etc/passwd").owned? #=> false @overload owned? @return [Boolean];T;#0;$@j;.F;/o;0;1T;2is;3i|;Bi;%@ g;9I"{static VALUE rb_stat_owned(VALUE obj) { if (get_stat(obj)->st_uid == geteuid()) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#grpowned?;F;7[;[[@8i;T;:grpowned?;0;[;{;IC; "Returns true if the effective group id of the process is the same as the group id of stat. On Windows NT, returns false. File.stat("testfile").grpowned? #=> true File.stat("/etc/passwd").grpowned? #=> false;T;[o;= ;>I" overload;F;?0;;D;@0;:I"grpowned?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@j;![;"I"@return [Boolean];T;#0;$@j;.F;Bi;C0;7[;$@j;![;"I"Returns true if the effective group id of the process is the same as the group id of stat. On Windows NT, returns false. File.stat("testfile").grpowned? #=> true File.stat("/etc/passwd").grpowned? #=> false @overload grpowned? @return [Boolean];T;#0;$@j;.F;/o;0;1T;2i;3i;Bi;%@ g;9I"static VALUE rb_stat_grpowned(VALUE obj) { #ifndef _WIN32 if (rb_group_member(get_stat(obj)->st_gid)) return Qtrue; #endif return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#pipe?;F;7[;[[@8i;T;: pipe?;0;[;{;IC; "~Returns true if the operating system supports pipes and stat is a pipe; false otherwise.;T;[o;= ;>I" overload;F;?0;;E;@0;:I" pipe?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@j;![;"I"@return [Boolean];T;#0;$@j;.F;Bi;C0;7[;$@j;![;"I"Returns true if the operating system supports pipes and stat is a pipe; false otherwise. @overload pipe? @return [Boolean];T;#0;$@j;.F;/o;0;1T;2i;3i ;Bi;%@ g;9I"static VALUE rb_stat_p(VALUE obj) { #ifdef S_IFIFO if (S_ISFIFO(get_stat(obj)->st_mode)) return Qtrue; #endif return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#symlink?;F;7[;[[@8i);T;: symlink?;0;[;{;IC; "Returns true if stat is a symbolic link, false if it isn't or if the operating system doesn't support this feature. As File::stat automatically follows symbolic links, #symlink? will always be false for an object returned by File::stat. File.symlink("testfile", "alink") #=> 0 File.stat("alink").symlink? #=> false File.lstat("alink").symlink? #=> true;T;[o;= ;>I" overload;F;?0;;F;@0;:I" symlink?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@k;![;"I"@return [Boolean];T;#0;$@k;.F;Bi;C0;7[;$@k;![;"I"Returns true if stat is a symbolic link, false if it isn't or if the operating system doesn't support this feature. As File::stat automatically follows symbolic links, #symlink? will always be false for an object returned by File::stat. File.symlink("testfile", "alink") #=> 0 File.stat("alink").symlink? #=> false File.lstat("alink").symlink? #=> true @overload symlink? @return [Boolean];T;#0;$@k;.F;/o;0;1T;2i;3i&;Bi;%@ g;9I"static VALUE rb_stat_l(VALUE obj) { #ifdef S_ISLNK if (S_ISLNK(get_stat(obj)->st_mode)) return Qtrue; #endif return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#socket?;F;7[;[[@8i>;T;: socket?;0;[;{;IC; "Returns true if stat is a socket, false if it isn't or if the operating system doesn't support this feature. File.stat("testfile").socket? #=> false;T;[o;= ;>I" overload;F;?0;;G;@0;:I" socket?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@+k;![;"I"@return [Boolean];T;#0;$@+k;.F;Bi;C0;7[;$@+k;![;"I"Returns true if stat is a socket, false if it isn't or if the operating system doesn't support this feature. File.stat("testfile").socket? #=> false @overload socket? @return [Boolean];T;#0;$@+k;.F;/o;0;1T;2i2;3i;;Bi;%@ g;9I"static VALUE rb_stat_S(VALUE obj) { #ifdef S_ISSOCK if (S_ISSOCK(get_stat(obj)->st_mode)) return Qtrue; #endif return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#blockdev?;F;7[;[[@8iU;T;:blockdev?;0;[;{;IC; "Returns true if the file is a block device, false if it isn't or if the operating system doesn't support this feature. File.stat("testfile").blockdev? #=> false File.stat("/dev/hda1").blockdev? #=> true;T;[o;= ;>I" overload;F;?0;;H;@0;:I"blockdev?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Fk;![;"I"@return [Boolean];T;#0;$@Fk;.F;Bi;C0;7[;$@Fk;![;"I"Returns true if the file is a block device, false if it isn't or if the operating system doesn't support this feature. File.stat("testfile").blockdev? #=> false File.stat("/dev/hda1").blockdev? #=> true @overload blockdev? @return [Boolean];T;#0;$@Fk;.F;/o;0;1T;2iH;3iR;Bi;%@ g;9I"static VALUE rb_stat_b(VALUE obj) { #ifdef S_ISBLK if (S_ISBLK(get_stat(obj)->st_mode)) return Qtrue; #endif return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#chardev?;F;7[;[[@8ik;T;: chardev?;0;[;{;IC; "Returns true if the file is a character device, false if it isn't or if the operating system doesn't support this feature. File.stat("/dev/tty").chardev? #=> true;T;[o;= ;>I" overload;F;?0;;I;@0;:I" chardev?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ak;![;"I"@return [Boolean];T;#0;$@ak;.F;Bi;C0;7[;$@ak;![;"I"Returns true if the file is a character device, false if it isn't or if the operating system doesn't support this feature. File.stat("/dev/tty").chardev? #=> true @overload chardev? @return [Boolean];T;#0;$@ak;.F;/o;0;1T;2i_;3ih;Bi;%@ g;9I"ustatic VALUE rb_stat_c(VALUE obj) { if (S_ISCHR(get_stat(obj)->st_mode)) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#setuid?;F;7[;[[@8i;T;: setuid?;0;[;{;IC; "Returns true if stat has the set-user-id permission bit set, false if it doesn't or if the operating system doesn't support this feature. File.stat("/bin/su").setuid? #=> true;T;[o;= ;>I" overload;F;?0;;J;@0;:I" setuid?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@|k;![;"I"@return [Boolean];T;#0;$@|k;.F;Bi;C0;7[;$@|k;![;"I"Returns true if stat has the set-user-id permission bit set, false if it doesn't or if the operating system doesn't support this feature. File.stat("/bin/su").setuid? #=> true @overload setuid? @return [Boolean];T;#0;$@|k;.F;/o;0;1T;2i;3i;Bi;%@ g;9I"static VALUE rb_stat_suid(VALUE obj) { #ifdef S_ISUID if (get_stat(obj)->st_mode & S_ISUID) return Qtrue; #endif return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#setgid?;F;7[;[[@8i;T;: setgid?;0;[;{;IC; "Returns true if stat has the set-group-id permission bit set, false if it doesn't or if the operating system doesn't support this feature. File.stat("/usr/sbin/lpc").setgid? #=> true;T;[o;= ;>I" overload;F;?0;;K;@0;:I" setgid?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@k;![;"I"@return [Boolean];T;#0;$@k;.F;Bi;C0;7[;$@k;![;"I"Returns true if stat has the set-group-id permission bit set, false if it doesn't or if the operating system doesn't support this feature. File.stat("/usr/sbin/lpc").setgid? #=> true @overload setgid? @return [Boolean];T;#0;$@k;.F;/o;0;1T;2i;3i;Bi;%@ g;9I"static VALUE rb_stat_sgid(VALUE obj) { #ifdef S_ISGID if (get_stat(obj)->st_mode & S_ISGID) return Qtrue; #endif return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File::Stat#sticky?;F;7[;[[@8i;T;: sticky?;0;[;{;IC; "Returns true if stat has its sticky bit set, false if it doesn't or if the operating system doesn't support this feature. File.stat("testfile").sticky? #=> false;T;[o;= ;>I" overload;F;?0;;L;@0;:I" sticky?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@k;![;"I"@return [Boolean];T;#0;$@k;.F;Bi;C0;7[;$@k;![;"I"Returns true if stat has its sticky bit set, false if it doesn't or if the operating system doesn't support this feature. File.stat("testfile").sticky? #=> false @overload sticky? @return [Boolean];T;#0;$@k;.F;/o;0;1T;2i;3i ;Bi;%@ g;9I"static VALUE rb_stat_sticky(VALUE obj) { #ifdef S_ISVTX if (get_stat(obj)->st_mode & S_ISVTX) return Qtrue; #endif return Qfalse; };T;:I"static VALUE;T;;T; @ g; IC;[; @ g; IC;[@?_; @ g; IC;{;IC;{;T;IC;{;T;T;{;[;[[@8i[@8i;T;: Stat;;;;;[;{;IC; "Objects of class File::Stat encapsulate common status information for File objects. The information is recorded at the moment the File::Stat object is created; changes made to the file after that point will not be reflected. File::Stat objects are returned by IO#stat, File::stat, File#lstat, and File::lstat. Many of these methods return platform-specific values, and not all values are meaningful on all systems. See also Kernel#test.;T;[;![;"I" Objects of class File::Stat encapsulate common status information for File objects. The information is recorded at the moment the File::Stat object is created; changes made to the file after that point will not be reflected. File::Stat objects are returned by IO#stat, File::stat, File#lstat, and File::lstat. Many of these methods return platform-specific values, and not all values are meaningful on all systems. See also Kernel#test. ;T;#0;$@ g;.F;/o;0;1T;2i;3i;Bi;%o;( ;)0;*0;+0;: File;%@;-@f;0;&I"File::Stat;F;'@o;4;5F;6;;;;&I"File.directory?;F;7[[I" fname;T0;[[@8iD;T;;8;0;[;{;IC; "call-seq: File.directory?(file_name) -> true or false Returns true if the named file is a directory, or a symlink that points at a directory, and false otherwise. _file_name_ can be an IO object. File.directory?(".");T;[o;A ;>I" return;F;?@;0;@[@L;$@k;![;"I" call-seq: File.directory?(file_name) -> true or false Returns true if the named file is a directory, or a symlink that points at a directory, and false otherwise. _file_name_ can be an IO object. File.directory?(".") ;T;#0;$@k;.F;/o;0;1T;2i5;3i@;Bi;%@f;9I"VALUE rb_file_directory_p(VALUE obj, VALUE fname) { #ifndef S_ISDIR # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) #endif struct stat st; if (rb_stat(fname, &st) < 0) return Qfalse; if (S_ISDIR(st.st_mode)) return Qtrue; return Qfalse; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"File.exist?;F;7[[I" fname;T0;[[@8i;T;;;0;[;{;IC; "Return true if the named file exists. _file_name_ can be an IO object. "file exists" means that stat() or fstat() system call is successful.;T;[o;= ;>I" overload;F;?0;;;@0;:I"exist?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@k;![;"I"@return [Boolean];T;#0;$@k;.F;Bi;C0;7[[I"file_name;T0;$@k;![;"I"Return true if the named file exists. _file_name_ can be an IO object. "file exists" means that stat() or fstat() system call is successful. @overload exist?(file_name) @return [Boolean];T;#0;$@k;.F;/o;0;1T;2i;3i;Bi;%@f;9I"static VALUE rb_file_exist_p(VALUE obj, VALUE fname) { struct stat st; if (rb_stat(fname, &st) < 0) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.exists?;F;7[[I" fname;T0;[[@8i;T;: exists?;0;[;{;IC; " :nodoc:;T;[o;A ;>I" return;F;?@;0;@[@L;$@l;![;"I" :nodoc:;T;#0;$@l;.F;/o;0;1T;2i;3i;Bi;%@f;9I"static VALUE rb_file_exists_p(VALUE obj, VALUE fname) { const char *s = "FileTest#exist?"; if (obj == rb_mFileTest) { s = "FileTest.exist?"; } else if (obj == rb_cFile || (RB_TYPE_P(obj, T_CLASS) && RTEST(rb_class_inherited_p(obj, rb_cFile)))) { s = "File.exist?"; } rb_warn_deprecated("%.*ss?", s, (int)(strlen(s)-1), s); return rb_file_exist_p(obj, fname); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.readable?;F;7[[I" fname;T0;[[@8i;T;;9;0;[;{;IC; "Returns true if the named file is readable by the effective user and group id of this process. See eaccess(3). Note that some OS-level security features may cause this to return true even though the file is not readable by the effective user/group.;T;[o;= ;>I" overload;F;?0;;9;@0;:I"readable?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@%l;![;"I"@return [Boolean];T;#0;$@%l;.F;Bi;C0;7[[I"file_name;T0;$@%l;![;"I";Returns true if the named file is readable by the effective user and group id of this process. See eaccess(3). Note that some OS-level security features may cause this to return true even though the file is not readable by the effective user/group. @overload readable?(file_name) @return [Boolean];T;#0;$@%l;.F;/o;0;1T;2i;3i;Bi;%@f;9I"pstatic VALUE rb_file_readable_p(VALUE obj, VALUE fname) { return RBOOL(rb_eaccess(fname, R_OK) >= 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.readable_real?;F;7[[I" fname;T0;[[@8i*;T;;:;0;[;{;IC; "Returns true if the named file is readable by the real user and group id of this process. See access(3). Note that some OS-level security features may cause this to return true even though the file is not readable by the real user/group.;T;[o;= ;>I" overload;F;?0;;:;@0;:I"readable_real?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Dl;![;"I"@return [Boolean];T;#0;$@Dl;.F;Bi;C0;7[[I"file_name;T0;$@Dl;![;"I"5Returns true if the named file is readable by the real user and group id of this process. See access(3). Note that some OS-level security features may cause this to return true even though the file is not readable by the real user/group. @overload readable_real?(file_name) @return [Boolean];T;#0;$@Dl;.F;/o;0;1T;2i;3i';Bi;%@f;9I"tstatic VALUE rb_file_readable_real_p(VALUE obj, VALUE fname) { return RBOOL(rb_access(fname, R_OK) >= 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.world_readable?;F;7[[I" fname;T0;[[@8iH;T;;;;0;[;{;IC; "If file_name is readable by others, returns an integer representing the file permission bits of file_name. Returns nil otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2). _file_name_ can be an IO object. File.world_readable?("/etc/passwd") #=> 420 m = File.world_readable?("/etc/passwd") sprintf("%o", m) #=> "644";T;[o;= ;>I" overload;F;?0;;;;@0;:I"world_readable?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@cl;![;"I"@return [Integer, nil];T;#0;$@cl;.F;Bi;C0;7[[I"file_name;T0;$@cl;![;"I"If file_name is readable by others, returns an integer representing the file permission bits of file_name. Returns nil otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2). _file_name_ can be an IO object. File.world_readable?("/etc/passwd") #=> 420 m = File.world_readable?("/etc/passwd") sprintf("%o", m) #=> "644" @overload world_readable?(file_name) @return [Integer, nil];T;#0;$@cl;.F;/o;0;1T;2i8;3iE;Bi;%@f;9I"static VALUE rb_file_world_readable_p(VALUE obj, VALUE fname) { #ifdef S_IROTH struct stat st; if (rb_stat(fname, &st) < 0) return Qnil; if ((st.st_mode & (S_IROTH)) == S_IROTH) { return UINT2NUM(st.st_mode & (S_IRUGO|S_IWUGO|S_IXUGO)); } #endif return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.writable?;F;7[[I" fname;T0;[[@8ia;T;;<;0;[;{;IC; "Returns true if the named file is writable by the effective user and group id of this process. See eaccess(3). Note that some OS-level security features may cause this to return true even though the file is not writable by the effective user/group.;T;[o;= ;>I" overload;F;?0;;<;@0;:I"writable?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@l;![;"I"@return [Boolean];T;#0;$@l;.F;Bi;C0;7[[I"file_name;T0;$@l;![;"I";Returns true if the named file is writable by the effective user and group id of this process. See eaccess(3). Note that some OS-level security features may cause this to return true even though the file is not writable by the effective user/group. @overload writable?(file_name) @return [Boolean];T;#0;$@l;.F;/o;0;1T;2iV;3i^;Bi;%@f;9I"pstatic VALUE rb_file_writable_p(VALUE obj, VALUE fname) { return RBOOL(rb_eaccess(fname, W_OK) >= 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.writable_real?;F;7[[I" fname;T0;[[@8ir;T;;=;0;[;{;IC; "Returns true if the named file is writable by the real user and group id of this process. See access(3). Note that some OS-level security features may cause this to return true even though the file is not writable by the real user/group.;T;[o;= ;>I" overload;F;?0;;=;@0;:I"writable_real?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@l;![;"I"@return [Boolean];T;#0;$@l;.F;Bi;C0;7[[I"file_name;T0;$@l;![;"I"5Returns true if the named file is writable by the real user and group id of this process. See access(3). Note that some OS-level security features may cause this to return true even though the file is not writable by the real user/group. @overload writable_real?(file_name) @return [Boolean];T;#0;$@l;.F;/o;0;1T;2ig;3io;Bi;%@f;9I"tstatic VALUE rb_file_writable_real_p(VALUE obj, VALUE fname) { return RBOOL(rb_access(fname, W_OK) >= 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.world_writable?;F;7[[I" fname;T0;[[@8i;T;;>;0;[;{;IC; "If file_name is writable by others, returns an integer representing the file permission bits of file_name. Returns nil otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2). _file_name_ can be an IO object. File.world_writable?("/tmp") #=> 511 m = File.world_writable?("/tmp") sprintf("%o", m) #=> "777";T;[o;= ;>I" overload;F;?0;;>;@0;:I"world_writable?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@l;![;"I"@return [Integer, nil];T;#0;$@l;.F;Bi;C0;7[[I"file_name;T0;$@l;![;"I"If file_name is writable by others, returns an integer representing the file permission bits of file_name. Returns nil otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2). _file_name_ can be an IO object. File.world_writable?("/tmp") #=> 511 m = File.world_writable?("/tmp") sprintf("%o", m) #=> "777" @overload world_writable?(file_name) @return [Integer, nil];T;#0;$@l;.F;/o;0;1T;2ix;3i;Bi;%@f;9I"static VALUE rb_file_world_writable_p(VALUE obj, VALUE fname) { #ifdef S_IWOTH struct stat st; if (rb_stat(fname, &st) < 0) return Qnil; if ((st.st_mode & (S_IWOTH)) == S_IWOTH) { return UINT2NUM(st.st_mode & (S_IRUGO|S_IWUGO|S_IXUGO)); } #endif return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.executable?;F;7[[I" fname;T0;[[@8i;T;;?;0;[;{;IC; "Returns true if the named file is executable by the effective user and group id of this process. See eaccess(3). Windows does not support execute permissions separately from read permissions. On Windows, a file is only considered executable if it ends in .bat, .cmd, .com, or .exe. Note that some OS-level security features may cause this to return true even though the file is not executable by the effective user/group.;T;[o;= ;>I" overload;F;?0;;?;@0;:I"executable?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@l;![;"I"@return [Boolean];T;#0;$@l;.F;Bi;C0;7[[I"file_name;T0;$@l;![;"I"Returns true if the named file is executable by the effective user and group id of this process. See eaccess(3). Windows does not support execute permissions separately from read permissions. On Windows, a file is only considered executable if it ends in .bat, .cmd, .com, or .exe. Note that some OS-level security features may cause this to return true even though the file is not executable by the effective user/group. @overload executable?(file_name) @return [Boolean];T;#0;$@l;.F;/o;0;1T;2i;3i;Bi;%@f;9I"rstatic VALUE rb_file_executable_p(VALUE obj, VALUE fname) { return RBOOL(rb_eaccess(fname, X_OK) >= 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.executable_real?;F;7[[I" fname;T0;[[@8i;T;;@;0;[;{;IC; "Returns true if the named file is executable by the real user and group id of this process. See access(3). Windows does not support execute permissions separately from read permissions. On Windows, a file is only considered executable if it ends in .bat, .cmd, .com, or .exe. Note that some OS-level security features may cause this to return true even though the file is not executable by the real user/group.;T;[o;= ;>I" overload;F;?0;;@;@0;:I" executable_real?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@m;![;"I"@return [Boolean];T;#0;$@m;.F;Bi;C0;7[[I"file_name;T0;$@m;![;"I"Returns true if the named file is executable by the real user and group id of this process. See access(3). Windows does not support execute permissions separately from read permissions. On Windows, a file is only considered executable if it ends in .bat, .cmd, .com, or .exe. Note that some OS-level security features may cause this to return true even though the file is not executable by the real user/group. @overload executable_real?(file_name) @return [Boolean];T;#0;$@m;.F;/o;0;1T;2i;3i;Bi;%@f;9I"vstatic VALUE rb_file_executable_real_p(VALUE obj, VALUE fname) { return RBOOL(rb_access(fname, X_OK) >= 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.file?;F;7[[I" fname;T0;[[@8i;T;;A;0;[;{;IC; "Returns +true+ if the named +file+ exists and is a regular file. +file+ can be an IO object. If the +file+ argument is a symbolic link, it will resolve the symbolic link and use the file referenced by the link.;T;[o;= ;>I" overload;F;?0;;A;@0;:I"file?(file);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@m;![;"I"@return [Boolean];T;#0;$@m;.F;Bi;C0;7[[I" file;T0;$@m;![;"I"Returns +true+ if the named +file+ exists and is a regular file. +file+ can be an IO object. If the +file+ argument is a symbolic link, it will resolve the symbolic link and use the file referenced by the link. @overload file?(file) @return [Boolean];T;#0;$@m;.F;/o;0;1T;2i;3i;Bi;%@f;9I"static VALUE rb_file_file_p(VALUE obj, VALUE fname) { struct stat st; if (rb_stat(fname, &st) < 0) return Qfalse; return RBOOL(S_ISREG(st.st_mode)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.zero?;F;7[[I" fname;T0;[[@8i;T;;B;0;[;{;IC; "nReturns true if the named file exists and has a zero size. _file_name_ can be an IO object.;T;[o;= ;>I" overload;F;?0;;B;@0;:I"zero?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@>m;![;"I"@return [Boolean];T;#0;$@>m;.F;Bi;C0;7[[I"file_name;T0;$@>m;![;"I"Returns true if the named file exists and has a zero size. _file_name_ can be an IO object. @overload zero?(file_name) @return [Boolean];T;#0;$@>m;.F;/o;0;1T;2i;3i;Bi;%@f;9I"static VALUE rb_file_zero_p(VALUE obj, VALUE fname) { struct stat st; if (rb_stat(fname, &st) < 0) return Qfalse; return RBOOL(st.st_size == 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.empty?;F;7[[I" fname;T0;[[@8i;T;;;0;[;{;IC; "nReturns true if the named file exists and has a zero size. _file_name_ can be an IO object.;T;[o;= ;>I" overload;F;?0;;B;@0;:I"zero?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@]m;![;"I"@return [Boolean];T;#0;$@]m;.F;Bi;C0;7[[I"file_name;T0;$@]m;![;"@Ym;#0;$@]m;.F;/o;0;1T;2i;3i;Bi;%@f;9I"static VALUE rb_file_zero_p(VALUE obj, VALUE fname) { struct stat st; if (rb_stat(fname, &st) < 0) return Qfalse; return RBOOL(st.st_size == 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.size?;F;7[[I" fname;T0;[[@8i;T;;C;0;[;{;IC; "~Returns +nil+ if +file_name+ doesn't exist or has zero size, the size of the file otherwise. _file_name_ can be an IO object.;T;[o;= ;>I" overload;F;?0;;C;@0;:I"size?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@{m;![;"I"@return [Integer, nil];T;#0;$@{m;.F;Bi;C0;7[[I"file_name;T0;$@{m;![;"I"Returns +nil+ if +file_name+ doesn't exist or has zero size, the size of the file otherwise. _file_name_ can be an IO object. @overload size?(file_name) @return [Integer, nil];T;#0;$@{m;.F;/o;0;1T;2i;3i;Bi;%@f;9I"static VALUE rb_file_size_p(VALUE obj, VALUE fname) { struct stat st; if (rb_stat(fname, &st) < 0) return Qnil; if (st.st_size == 0) return Qnil; return OFFT2NUM(st.st_size); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.size;F;7[[I" fname;T0;[[@8i;T;;;0;[;{;IC; "RReturns the size of file_name. _file_name_ can be an IO object. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"size(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@m;![;"I"@return [Integer];T;#0;$@m;.F;Bi;C0;7[[I"file_name;T0;$@m;![;"I"}Returns the size of file_name. _file_name_ can be an IO object. @overload size(file_name) @return [Integer];T;#0;$@m;.F;/o;0;1T;2i;3i;%@f;9I"static VALUE rb_file_s_size(VALUE klass, VALUE fname) { struct stat st; if (rb_stat(fname, &st) < 0) { int e = errno; FilePathValue(fname); rb_syserr_fail_path(e, fname); } return OFFT2NUM(st.st_size); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.owned?;F;7[[I" fname;T0;[[@8i ;T;;X;0;[;{;IC; "Returns true if the named file exists and the effective used id of the calling process is the owner of the file. _file_name_ can be an IO object.;T;[o;= ;>I" overload;F;?0;;X;@0;:I"owned?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@m;![;"I"@return [Boolean];T;#0;$@m;.F;Bi;C0;7[[I"file_name;T0;$@m;![;"I"Returns true if the named file exists and the effective used id of the calling process is the owner of the file. _file_name_ can be an IO object. @overload owned?(file_name) @return [Boolean];T;#0;$@m;.F;/o;0;1T;2i;3i;Bi;%@f;9I"static VALUE rb_file_owned_p(VALUE obj, VALUE fname) { struct stat st; if (rb_stat(fname, &st) < 0) return Qfalse; return RBOOL(st.st_uid == geteuid()); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.grpowned?;F;7[[I" fname;T0;[[@8i(;T;;D;0;[;{;IC; "Returns true if the named file exists and the effective group id of the calling process is the owner of the file. Returns false on Windows. _file_name_ can be an IO object.;T;[o;= ;>I" overload;F;?0;;D;@0;:I"grpowned?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@m;![;"I"@return [Boolean];T;#0;$@m;.F;Bi;C0;7[[I"file_name;T0;$@m;![;"I"Returns true if the named file exists and the effective group id of the calling process is the owner of the file. Returns false on Windows. _file_name_ can be an IO object. @overload grpowned?(file_name) @return [Boolean];T;#0;$@m;.F;/o;0;1T;2i;3i%;Bi;%@f;9I"static VALUE rb_file_grpowned_p(VALUE obj, VALUE fname) { #ifndef _WIN32 struct stat st; if (rb_stat(fname, &st) < 0) return Qfalse; if (rb_group_member(st.st_gid)) return Qtrue; #endif return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.pipe?;F;7[[I" fname;T0;[[@8i[;T;;E;0;[;{;IC; "]Returns true if the named file is a pipe. _file_name_ can be an IO object.;T;[o;= ;>I" overload;F;?0;;E;@0;:I"pipe?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@m;![;"I"@return [Boolean];T;#0;$@m;.F;Bi;C0;7[[I"file_name;T0;$@m;![;"I"Returns true if the named file is a pipe. _file_name_ can be an IO object. @overload pipe?(file_name) @return [Boolean];T;#0;$@m;.F;/o;0;1T;2iR;3iX;Bi;%@f;9I"#static VALUE rb_file_pipe_p(VALUE obj, VALUE fname) { #ifdef S_IFIFO # ifndef S_ISFIFO # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) # endif struct stat st; if (rb_stat(fname, &st) < 0) return Qfalse; if (S_ISFIFO(st.st_mode)) return Qtrue; #endif return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.symlink?;F;7[[I" fname;T0;[[@8is;T;;F;0;[;{;IC; "DReturns true if the named file is a symbolic link.;T;[o;= ;>I" overload;F;?0;;F;@0;:I"symlink?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@n;![;"I"@return [Boolean];T;#0;$@n;.F;Bi;C0;7[[I"file_name;T0;$@n;![;"I"xReturns true if the named file is a symbolic link. @overload symlink?(file_name) @return [Boolean];T;#0;$@n;.F;/o;0;1T;2il;3ip;Bi;%@f;9I"Bstatic VALUE rb_file_symlink_p(VALUE obj, VALUE fname) { #ifndef S_ISLNK # ifdef _S_ISLNK # define S_ISLNK(m) _S_ISLNK(m) # else # ifdef _S_IFLNK # define S_ISLNK(m) (((m) & S_IFMT) == _S_IFLNK) # else # ifdef S_IFLNK # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) # endif # endif # endif #endif #ifdef S_ISLNK struct stat st; FilePathValue(fname); fname = rb_str_encode_ospath(fname); if (lstat_without_gvl(StringValueCStr(fname), &st) < 0) return Qfalse; if (S_ISLNK(st.st_mode)) return Qtrue; #endif return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.socket?;F;7[[I" fname;T0;[[@8i;T;;G;0;[;{;IC; "_Returns true if the named file is a socket. _file_name_ can be an IO object.;T;[o;= ;>I" overload;F;?0;;G;@0;:I"socket?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@6n;![;"I"@return [Boolean];T;#0;$@6n;.F;Bi;C0;7[[I"file_name;T0;$@6n;![;"I"Returns true if the named file is a socket. _file_name_ can be an IO object. @overload socket?(file_name) @return [Boolean];T;#0;$@6n;.F;/o;0;1T;2i;3i;Bi;%@f;9I"static VALUE rb_file_socket_p(VALUE obj, VALUE fname) { #ifndef S_ISSOCK # ifdef _S_ISSOCK # define S_ISSOCK(m) _S_ISSOCK(m) # else # ifdef _S_IFSOCK # define S_ISSOCK(m) (((m) & S_IFMT) == _S_IFSOCK) # else # ifdef S_IFSOCK # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) # endif # endif # endif #endif #ifdef S_ISSOCK struct stat st; if (rb_stat(fname, &st) < 0) return Qfalse; if (S_ISSOCK(st.st_mode)) return Qtrue; #endif return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.blockdev?;F;7[[I" fname;T0;[[@8i;T;;H;0;[;{;IC; "eReturns true if the named file is a block device. _file_name_ can be an IO object.;T;[o;= ;>I" overload;F;?0;;H;@0;:I"blockdev?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Un;![;"I"@return [Boolean];T;#0;$@Un;.F;Bi;C0;7[[I"file_name;T0;$@Un;![;"I"Returns true if the named file is a block device. _file_name_ can be an IO object. @overload blockdev?(file_name) @return [Boolean];T;#0;$@Un;.F;/o;0;1T;2i;3i;Bi;%@f;9I"ostatic VALUE rb_file_blockdev_p(VALUE obj, VALUE fname) { #ifndef S_ISBLK # ifdef S_IFBLK # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) # else # define S_ISBLK(m) (0) /* anytime false */ # endif #endif #ifdef S_ISBLK struct stat st; if (rb_stat(fname, &st) < 0) return Qfalse; if (S_ISBLK(st.st_mode)) return Qtrue; #endif return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.chardev?;F;7[[I" fname;T0;[[@8i;T;;I;0;[;{;IC; "iReturns true if the named file is a character device. _file_name_ can be an IO object.;T;[o;= ;>I" overload;F;?0;;I;@0;:I"chardev?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@tn;![;"I"@return [Boolean];T;#0;$@tn;.F;Bi;C0;7[[I"file_name;T0;$@tn;![;"I"Returns true if the named file is a character device. _file_name_ can be an IO object. @overload chardev?(file_name) @return [Boolean];T;#0;$@tn;.F;/o;0;1T;2i;3i;Bi;%@f;9I"static VALUE rb_file_chardev_p(VALUE obj, VALUE fname) { #ifndef S_ISCHR # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) #endif struct stat st; if (rb_stat(fname, &st) < 0) return Qfalse; if (S_ISCHR(st.st_mode)) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.setuid?;F;7[[I" fname;T0;[[@8iH;T;;J;0;[;{;IC; "jReturns true if the named file has the setuid bit set. _file_name_ can be an IO object.;T;[o;= ;>I" overload;F;?0;;J;@0;:I"setuid?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@n;![;"I"@return [Boolean];T;#0;$@n;.F;Bi;C0;7[[I"file_name;T0;$@n;![;"I"Returns true if the named file has the setuid bit set. _file_name_ can be an IO object. @overload setuid?(file_name) @return [Boolean];T;#0;$@n;.F;/o;0;1T;2i?;3iE;Bi;%@f;9I"static VALUE rb_file_suid_p(VALUE obj, VALUE fname) { #ifdef S_ISUID return check3rdbyte(fname, S_ISUID); #else return Qfalse; #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.setgid?;F;7[[I" fname;T0;[[@8i[;T;;K;0;[;{;IC; "jReturns true if the named file has the setgid bit set. _file_name_ can be an IO object.;T;[o;= ;>I" overload;F;?0;;K;@0;:I"setgid?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@n;![;"I"@return [Boolean];T;#0;$@n;.F;Bi;C0;7[[I"file_name;T0;$@n;![;"I"Returns true if the named file has the setgid bit set. _file_name_ can be an IO object. @overload setgid?(file_name) @return [Boolean];T;#0;$@n;.F;/o;0;1T;2iR;3iX;Bi;%@f;9I"static VALUE rb_file_sgid_p(VALUE obj, VALUE fname) { #ifdef S_ISGID return check3rdbyte(fname, S_ISGID); #else return Qfalse; #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.sticky?;F;7[[I" fname;T0;[[@8in;T;;L;0;[;{;IC; "jReturns true if the named file has the sticky bit set. _file_name_ can be an IO object.;T;[o;= ;>I" overload;F;?0;;L;@0;:I"sticky?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@n;![;"I"@return [Boolean];T;#0;$@n;.F;Bi;C0;7[[I"file_name;T0;$@n;![;"I"Returns true if the named file has the sticky bit set. _file_name_ can be an IO object. @overload sticky?(file_name) @return [Boolean];T;#0;$@n;.F;/o;0;1T;2ie;3ik;Bi;%@f;9I"static VALUE rb_file_sticky_p(VALUE obj, VALUE fname) { #ifdef S_ISVTX return check3rdbyte(fname, S_ISVTX); #else return Qnil; #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.identical?;F;7[[I" fname1;T0[I" fname2;T0;[[@8i;T;:identical?;0;[;{;IC; "Returns true if the named files are identical. _file_1_ and _file_2_ can be an IO object. open("a", "w") {} p File.identical?("a", "a") #=> true p File.identical?("a", "./a") #=> true File.link("a", "b") p File.identical?("a", "b") #=> true File.symlink("a", "c") p File.identical?("a", "c") #=> true open("d", "w") {} p File.identical?("a", "d") #=> false;T;[o;= ;>I" overload;F;?0;;P;@0;:I"identical?(file_1, file_2);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@n;![;"I"@return [Boolean];T;#0;$@n;.F;Bi;C0;7[[I" file_1;T0[I" file_2;T0;$@n;![;"I"Returns true if the named files are identical. _file_1_ and _file_2_ can be an IO object. open("a", "w") {} p File.identical?("a", "a") #=> true p File.identical?("a", "./a") #=> true File.link("a", "b") p File.identical?("a", "b") #=> true File.symlink("a", "c") p File.identical?("a", "c") #=> true open("d", "w") {} p File.identical?("a", "d") #=> false @overload identical?(file_1, file_2) @return [Boolean];T;#0;$@n;.F;/o;0;1T;2ix;3i;Bi;%@f;9I"static VALUE rb_file_identical_p(VALUE obj, VALUE fname1, VALUE fname2) { #ifndef _WIN32 struct stat st1, st2; if (rb_stat(fname1, &st1) < 0) return Qfalse; if (rb_stat(fname2, &st2) < 0) return Qfalse; if (st1.st_dev != st2.st_dev) return Qfalse; if (st1.st_ino != st2.st_ino) return Qfalse; return Qtrue; #else extern VALUE rb_w32_file_identical_p(VALUE, VALUE); return rb_w32_file_identical_p(fname1, fname2); #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.stat;F;7[[I" fname;T0;[[@8i(;T;;;0;[;{;IC; "Returns a File::Stat object for the named file (see File::Stat). File.stat("testfile").mtime #=> Tue Apr 08 12:58:04 CDT 2003 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"stat(file_name);T;IC; ";T;[;![;"I";T;#0;$@o;.F;Bi;C0;7[[I"file_name;T0;$@o;![;"I"Returns a File::Stat object for the named file (see File::Stat). File.stat("testfile").mtime #=> Tue Apr 08 12:58:04 CDT 2003 @overload stat(file_name);T;#0;$@o;.F;/o;0;1T;2i;3i$;%@f;9I"static VALUE rb_file_s_stat(VALUE klass, VALUE fname) { struct stat st; FilePathValue(fname); fname = rb_str_encode_ospath(fname); if (stat_without_gvl(RSTRING_PTR(fname), &st) < 0) { rb_sys_fail_path(fname); } return rb_stat_new(&st); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.lstat;F;7[[I" fname;T0;[[@8it;T;: lstat;0;[;{;IC; "+Same as File::stat, but does not follow the last symbolic link. Instead, reports on the link itself. File.symlink("testfile", "link2test") #=> 0 File.stat("testfile").size #=> 66 File.lstat("link2test").size #=> 8 File.stat("link2test").size #=> 66 ;T;[o;= ;>I" overload;F;?0;;Q;@0;:I"lstat(file_name);T;IC; ";T;[;![;"I";T;#0;$@-o;.F;Bi;C0;7[[I"file_name;T0;$@-o;![;"I"ISame as File::stat, but does not follow the last symbolic link. Instead, reports on the link itself. File.symlink("testfile", "link2test") #=> 0 File.stat("testfile").size #=> 66 File.lstat("link2test").size #=> 8 File.stat("link2test").size #=> 66 @overload lstat(file_name);T;#0;$@-o;.F;/o;0;1T;2if;3ip;%@f;9I"Wstatic VALUE rb_file_s_lstat(VALUE klass, VALUE fname) { #ifdef HAVE_LSTAT struct stat st; FilePathValue(fname); fname = rb_str_encode_ospath(fname); if (lstat_without_gvl(StringValueCStr(fname), &st) == -1) { rb_sys_fail_path(fname); } return rb_stat_new(&st); #else return rb_file_s_stat(klass, fname); #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.ftype;F;7[[I" fname;T0;[[@8i;T;;7;0;[;{;IC; "Identifies the type of the named file; the return string is one of ``file'', ``directory'', ``characterSpecial'', ``blockSpecial'', ``fifo'', ``link'', ``socket'', or ``unknown''. File.ftype("testfile") #=> "file" File.ftype("/dev/tty") #=> "characterSpecial" File.ftype("/tmp/.X11-unix/X0") #=> "socket" ;T;[o;= ;>I" overload;F;?0;;7;@0;:I"ftype(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@Go;![;"I"@return [String];T;#0;$@Go;.F;Bi;C0;7[[I"file_name;T0;$@Go;![;"I"Identifies the type of the named file; the return string is one of ``file'', ``directory'', ``characterSpecial'', ``blockSpecial'', ``fifo'', ``link'', ``socket'', or ``unknown''. File.ftype("testfile") #=> "file" File.ftype("/dev/tty") #=> "characterSpecial" File.ftype("/tmp/.X11-unix/X0") #=> "socket" @overload ftype(file_name) @return [String];T;#0;$@Go;.F;/o;0;1T;2i;3i;%@f;9I"static VALUE rb_file_s_ftype(VALUE klass, VALUE fname) { struct stat st; FilePathValue(fname); fname = rb_str_encode_ospath(fname); if (lstat_without_gvl(StringValueCStr(fname), &st) == -1) { rb_sys_fail_path(fname); } return rb_file_ftype(&st); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.atime;F;7[[I" fname;T0;[[@8i ;T;;3;0;[;{;IC; "Returns the last access time for the named file as a Time object. _file_name_ can be an IO object. File.atime("testfile") #=> Wed Apr 09 08:51:48 CDT 2003 ;T;[o;= ;>I" overload;F;?0;;3;@0;:I"atime(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@fo;![;"I"@return [Time];T;#0;$@fo;.F;Bi;C0;7[[I"file_name;T0;$@fo;![;"I"Returns the last access time for the named file as a Time object. _file_name_ can be an IO object. File.atime("testfile") #=> Wed Apr 09 08:51:48 CDT 2003 @overload atime(file_name) @return [Time];T;#0;$@fo;.F;/o;0;1T;2i;3i ;%@f;9I"static VALUE rb_file_s_atime(VALUE klass, VALUE fname) { struct stat st; if (rb_stat(fname, &st) < 0) { int e = errno; FilePathValue(fname); rb_syserr_fail_path(e, fname); } return stat_atime(&st); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.mtime;F;7[[I" fname;T0;[[@8i5 ;T;;4;0;[;{;IC; "Returns the modification time for the named file as a Time object. _file_name_ can be an IO object. File.mtime("testfile") #=> Tue Apr 08 12:58:04 CDT 2003 ;T;[o;= ;>I" overload;F;?0;;4;@0;:I"mtime(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@o;![;"I"@return [Time];T;#0;$@o;.F;Bi;C0;7[[I"file_name;T0;$@o;![;"I"Returns the modification time for the named file as a Time object. _file_name_ can be an IO object. File.mtime("testfile") #=> Tue Apr 08 12:58:04 CDT 2003 @overload mtime(file_name) @return [Time];T;#0;$@o;.F;/o;0;1T;2i) ;3i2 ;%@f;9I"static VALUE rb_file_s_mtime(VALUE klass, VALUE fname) { struct stat st; if (rb_stat(fname, &st) < 0) { int e = errno; FilePathValue(fname); rb_syserr_fail_path(e, fname); } return stat_mtime(&st); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.ctime;F;7[[I" fname;T0;[[@8ii ;T;;5;0;[;{;IC; "'Returns the change time for the named file (the time at which directory information about the file was changed, not the file itself). _file_name_ can be an IO object. Note that on Windows (NTFS), returns creation time (birth time). File.ctime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003 ;T;[o;= ;>I" overload;F;?0;;5;@0;:I"ctime(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@o;![;"I"@return [Time];T;#0;$@o;.F;Bi;C0;7[[I"file_name;T0;$@o;![;"I"VReturns the change time for the named file (the time at which directory information about the file was changed, not the file itself). _file_name_ can be an IO object. Note that on Windows (NTFS), returns creation time (birth time). File.ctime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003 @overload ctime(file_name) @return [Time];T;#0;$@o;.F;/o;0;1T;2iY ;3if ;%@f;9I"static VALUE rb_file_s_ctime(VALUE klass, VALUE fname) { struct stat st; if (rb_stat(fname, &st) < 0) { int e = errno; FilePathValue(fname); rb_syserr_fail_path(e, fname); } return stat_ctime(&st); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.birthtime;F;7[[I" fname;T0;[[@8i ;T;;6;0;[;{;IC; " ;T;[;![;"@;#0;$@o;%@f;9I"RUBY_FUNC_EXPORTED VALUE rb_file_s_birthtime(VALUE klass, VALUE fname) { statx_data st; if (rb_statx(fname, &st, STATX_BTIME) < 0) { int e = errno; FilePathValue(fname); rb_syserr_fail_path(e, fname); } return statx_birthtime(&st, fname); };T;:I"RUBY_FUNC_EXPORTED VALUE;T;;To;4;5F;6;;;;&I"File.utime;F;7[[@90;[[@8i ;T;: utime;0;[;{;IC; "Sets the access and modification times of each named file to the first two arguments. If a file is a symlink, this method acts upon its referent rather than the link itself; for the inverse behavior see File.lutime. Returns the number of file names in the argument list. ;T;[o;= ;>I" overload;F;?0;;R;@0;:I"(utime(atime, mtime, file_name, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@o;![;"I"@return [Integer];T;#0;$@o;.F;Bi;C0;7[ [I" atime;T0[I" mtime;T0[I"file_name;T0[I"...;T0;$@o;![;"I"RSets the access and modification times of each named file to the first two arguments. If a file is a symlink, this method acts upon its referent rather than the link itself; for the inverse behavior see File.lutime. Returns the number of file names in the argument list. @overload utime(atime, mtime, file_name, ...) @return [Integer];T;#0;$@o;.F;/o;0;1T;2ix ;3i ;%@f;9I"ustatic VALUE rb_file_s_utime(int argc, VALUE *argv, VALUE _) { return utime_internal_i(argc, argv, FALSE); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.chmod;F;7[[@90;[[@8i ;T;: chmod;0;[;{;IC; "AChanges permission bits on the named file(s) to the bit pattern represented by mode_int. Actual effects are operating system dependent (see the beginning of this section). On Unix systems, see chmod(2) for details. Returns the number of files processed. File.chmod(0644, "testfile", "out") #=> 2 ;T;[o;= ;>I" overload;F;?0;;S;@0;:I"%chmod(mode_int, file_name, ... );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@o;![;"I"@return [Integer];T;#0;$@o;.F;Bi;C0;7[[I" mode_int;T0[I"file_name;T0[I"...;T0;$@o;![;"I"Changes permission bits on the named file(s) to the bit pattern represented by mode_int. Actual effects are operating system dependent (see the beginning of this section). On Unix systems, see chmod(2) for details. Returns the number of files processed. File.chmod(0644, "testfile", "out") #=> 2 @overload chmod(mode_int, file_name, ... ) @return [Integer];T;#0;$@o;.F;/o;0;1T;2i ;3i ;%@f;9I"static VALUE rb_file_s_chmod(int argc, VALUE *argv, VALUE _) { mode_t mode; apply2args(1); mode = NUM2MODET(*argv++); return apply2files(chmod_internal, argc, argv, &mode); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.chown;F;7[[@90;[[@8i ;T;: chown;0;[;{;IC; "Changes the owner and group of the named file(s) to the given numeric owner and group id's. Only a process with superuser privileges may change the owner of a file. The current owner of a file may change the file's group to any group to which the owner belongs. A nil or -1 owner or group id is ignored. Returns the number of files processed. File.chown(nil, 100, "testfile") ;T;[o;= ;>I" overload;F;?0;;T;@0;:I"0chown(owner_int, group_int, file_name, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@p;![;"I"@return [Integer];T;#0;$@p;.F;Bi;C0;7[ [I"owner_int;T0[I"group_int;T0[I"file_name;T0[I"...;T0;$@p;![;"I"Changes the owner and group of the named file(s) to the given numeric owner and group id's. Only a process with superuser privileges may change the owner of a file. The current owner of a file may change the file's group to any group to which the owner belongs. A nil or -1 owner or group id is ignored. Returns the number of files processed. File.chown(nil, 100, "testfile") @overload chown(owner_int, group_int, file_name, ...) @return [Integer];T;#0;$@p;.F;/o;0;1T;2iz ;3i ;%@f;9I"static VALUE rb_file_s_chown(int argc, VALUE *argv, VALUE _) { struct chown_args arg; apply2args(2); arg.owner = to_uid(*argv++); arg.group = to_gid(*argv++); return apply2files(chown_internal, argc, argv, &arg); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.lchmod;F;7[[@90;[[@8iN ;T;: lchmod;0;[;{;IC; "Equivalent to File::chmod, but does not follow symbolic links (so it will change the permissions associated with the link, not the file referenced by the link). Often not available. ;T;[o;= ;>I" overload;F;?0;;U;@0;:I"%lchmod(mode_int, file_name, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;p;![;"I"@return [Integer];T;#0;$@;p;.F;Bi;C0;7[[I" mode_int;T0[I"file_name;T0[I"...;T0;$@;p;![;"I"Equivalent to File::chmod, but does not follow symbolic links (so it will change the permissions associated with the link, not the file referenced by the link). Often not available. @overload lchmod(mode_int, file_name, ...) @return [Integer];T;#0;$@;p;.F;/o;0;1T;2iD ;3iK ;%@f;9I"static VALUE rb_file_s_lchmod(int argc, VALUE *argv, VALUE _) { mode_t mode; apply2args(1); mode = NUM2MODET(*argv++); return apply2files(lchmod_internal, argc, argv, &mode); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.lchown;F;7[[@90;[[@8i ;T;: lchown;0;[;{;IC; "Equivalent to File::chown, but does not follow symbolic links (so it will change the owner associated with the link, not the file referenced by the link). Often not available. Returns number of files in the argument list. ;T;[o;= ;>I" overload;F;?0;;V;@0;:I"/lchown(owner_int, group_int, file_name,..);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@]p;![;"I"@return [Integer];T;#0;$@]p;.F;Bi;C0;7[ [I"owner_int;T0[I"group_int;T0[I"file_name;T0[I"..;T0;$@]p;![;"I")Equivalent to File::chown, but does not follow symbolic links (so it will change the owner associated with the link, not the file referenced by the link). Often not available. Returns number of files in the argument list. @overload lchown(owner_int, group_int, file_name,..) @return [Integer];T;#0;$@]p;.F;/o;0;1T;2i ;3i ;%@f;9I"static VALUE rb_file_s_lchown(int argc, VALUE *argv, VALUE _) { struct chown_args arg; apply2args(2); arg.owner = to_uid(*argv++); arg.group = to_gid(*argv++); return apply2files(lchown_internal, argc, argv, &arg); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.lutime;F;7[[@90;[[@8i ;T;: lutime;0;[;{;IC; "Sets the access and modification times of each named file to the first two arguments. If a file is a symlink, this method acts upon the link itself as opposed to its referent; for the inverse behavior, see File.utime. Returns the number of file names in the argument list. ;T;[o;= ;>I" overload;F;?0;;W;@0;:I")lutime(atime, mtime, file_name, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@p;![;"I"@return [Integer];T;#0;$@p;.F;Bi;C0;7[ [I" atime;T0[I" mtime;T0[I"file_name;T0[I"...;T0;$@p;![;"I"USets the access and modification times of each named file to the first two arguments. If a file is a symlink, this method acts upon the link itself as opposed to its referent; for the inverse behavior, see File.utime. Returns the number of file names in the argument list. @overload lutime(atime, mtime, file_name, ...) @return [Integer];T;#0;$@p;.F;/o;0;1T;2i ;3i ;%@f;9I"ustatic VALUE rb_file_s_lutime(int argc, VALUE *argv, VALUE _) { return utime_internal_i(argc, argv, TRUE); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.link;F;7[[I" from;T0[I"to;T0;[[@8i ;T;: link;0;[;{;IC; "+Creates a new name for an existing file using a hard link. Will not overwrite new_name if it already exists (raising a subclass of SystemCallError). Not available on all platforms. File.link("testfile", ".testfile") #=> 0 IO.readlines(".testfile")[0] #=> "This is line one\n" ;T;[o;= ;>I" overload;F;?0;;X;@0;:I"link(old_name, new_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@p;![;"I"@return [0];T;#0;$@p;.F;Bi;C0;7[[I" old_name;T0[I" new_name;T0;$@p;![;"I"^Creates a new name for an existing file using a hard link. Will not overwrite new_name if it already exists (raising a subclass of SystemCallError). Not available on all platforms. File.link("testfile", ".testfile") #=> 0 IO.readlines(".testfile")[0] #=> "This is line one\n" @overload link(old_name, new_name) @return [0];T;#0;$@p;.F;/o;0;1T;2i ;3i ;%@f;9I"0static VALUE rb_file_s_link(VALUE klass, VALUE from, VALUE to) { FilePathValue(from); FilePathValue(to); from = rb_str_encode_ospath(from); to = rb_str_encode_ospath(to); if (link(StringValueCStr(from), StringValueCStr(to)) < 0) { sys_fail2(from, to); } return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.symlink;F;7[[I" from;T0[I"to;T0;[[@8i ;T;: symlink;0;[;{;IC; "Creates a symbolic link called new_name for the existing file old_name. Raises a NotImplemented exception on platforms that do not support symbolic links. File.symlink("testfile", "link2test") #=> 0 ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I" symlink(old_name, new_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@p;![;"I"@return [0];T;#0;$@p;.F;Bi;C0;7[[I" old_name;T0[I" new_name;T0;$@p;![;"I"Creates a symbolic link called new_name for the existing file old_name. Raises a NotImplemented exception on platforms that do not support symbolic links. File.symlink("testfile", "link2test") #=> 0 @overload symlink(old_name, new_name) @return [0];T;#0;$@p;.F;/o;0;1T;2i ;3i ;%@f;9I"6static VALUE rb_file_s_symlink(VALUE klass, VALUE from, VALUE to) { FilePathValue(from); FilePathValue(to); from = rb_str_encode_ospath(from); to = rb_str_encode_ospath(to); if (symlink(StringValueCStr(from), StringValueCStr(to)) < 0) { sys_fail2(from, to); } return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.readlink;F;7[[I" path;T0;[[@8i ;T;: readlink;0;[;{;IC; "Returns the name of the file referenced by the given link. Not available on all platforms. File.symlink("testfile", "link2test") #=> 0 File.readlink("link2test") #=> "testfile" ;T;[o;= ;>I" overload;F;?0;;Z;@0;:I"readlink(link_name);T;IC; ";T;[;![;"I";T;#0;$@p;.F;Bi;C0;7[[I"link_name;T0;$@p;![;"I"Returns the name of the file referenced by the given link. Not available on all platforms. File.symlink("testfile", "link2test") #=> 0 File.readlink("link2test") #=> "testfile" @overload readlink(link_name);T;#0;$@p;.F;/o;0;1T;2i ;3i ;%@f;9I"ystatic VALUE rb_file_s_readlink(VALUE klass, VALUE path) { return rb_readlink(path, rb_filesystem_encoding()); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.unlink;F;7[[@90;[[@8i` ;T;: unlink;0;[;{;IC; "aDeletes the named files, returning the number of names passed as arguments. Raises an exception on any error. Since the underlying implementation relies on the unlink(2) system call, the type of exception raised depends on its error type (see https://linux.die.net/man/2/unlink) and has the form of e.g. Errno::ENOENT. See also Dir::rmdir. ;T;[o;= ;>I" overload;F;?0;: delete;@0;:I"delete(file_name, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@q;![;"I"@return [Integer];T;#0;$@q;.F;Bi;C0;7[[I"file_name;T0[I"...;T0;$@qo;= ;>I" overload;F;?0;;[;@0;:I"unlink(file_name, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@q;![;"I"@return [Integer];T;#0;$@q;.F;Bi;C0;7[[I"file_name;T0[I"...;T0;$@q;![;"I"Deletes the named files, returning the number of names passed as arguments. Raises an exception on any error. Since the underlying implementation relies on the unlink(2) system call, the type of exception raised depends on its error type (see https://linux.die.net/man/2/unlink) and has the form of e.g. Errno::ENOENT. See also Dir::rmdir. @overload delete(file_name, ...) @return [Integer] @overload unlink(file_name, ...) @return [Integer];T;#0;$@q;.F;/o;0;1T;2iP ;3i^ ;%@f;9I"}static VALUE rb_file_s_unlink(int argc, VALUE *argv, VALUE klass) { return apply2files(unlink_internal, argc, argv, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.delete;F;7[[@90;[[@8i` ;T;;\;0;[;{;IC; "aDeletes the named files, returning the number of names passed as arguments. Raises an exception on any error. Since the underlying implementation relies on the unlink(2) system call, the type of exception raised depends on its error type (see https://linux.die.net/man/2/unlink) and has the form of e.g. Errno::ENOENT. See also Dir::rmdir. ;T;[o;= ;>I" overload;F;?0;;\;@0;:I"delete(file_name, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@6q;![;"I"@return [Integer];T;#0;$@6q;.F;Bi;C0;7[[I"file_name;T0[I"...;T0;$@6qo;= ;>I" overload;F;?0;;[;@0;:I"unlink(file_name, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@6q;![;"I"@return [Integer];T;#0;$@6q;.F;Bi;C0;7[[I"file_name;T0[I"...;T0;$@6q;![;"@2q;#0;$@6q;.F;/o;0;1T;2iP ;3i^ ;%@f;9I"}static VALUE rb_file_s_unlink(int argc, VALUE *argv, VALUE klass) { return apply2files(unlink_internal, argc, argv, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.rename;F;7[[I" from;T0[I"to;T0;[[@8i} ;T;: rename;0;[;{;IC; "Renames the given file to the new name. Raises a SystemCallError if the file cannot be renamed. File.rename("afile", "afile.bak") #=> 0 ;T;[o;= ;>I" overload;F;?0;;];@0;:I"rename(old_name, new_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@fq;![;"I"@return [0];T;#0;$@fq;.F;Bi;C0;7[[I" old_name;T0[I" new_name;T0;$@fq;![;"I"Renames the given file to the new name. Raises a SystemCallError if the file cannot be renamed. File.rename("afile", "afile.bak") #=> 0 @overload rename(old_name, new_name) @return [0];T;#0;$@fq;.F;/o;0;1T;2is ;3iz ;%@f;9I"static VALUE rb_file_s_rename(VALUE klass, VALUE from, VALUE to) { struct rename_args ra; VALUE f, t; FilePathValue(from); FilePathValue(to); f = rb_str_encode_ospath(from); t = rb_str_encode_ospath(to); ra.src = StringValueCStr(f); ra.dst = StringValueCStr(t); #if defined __CYGWIN__ errno = 0; #endif if ((int)(VALUE)rb_thread_call_without_gvl(no_gvl_rename, &ra, RUBY_UBF_IO, 0) < 0) { int e = errno; #if defined DOSISH switch (e) { case EEXIST: if (chmod(ra.dst, 0666) == 0 && unlink(ra.dst) == 0 && rename(ra.src, ra.dst) == 0) return INT2FIX(0); } #endif syserr_fail2(e, from, to); } return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.umask;F;7[[@90;[[@8i ;T;: umask;0;[;{;IC; "VReturns the current umask value for this process. If the optional argument is given, set the umask to that value and return the previous value. Umask values are subtracted from the default permissions, so a umask of 0222 would make a file read-only for everyone. File.umask(0006) #=> 18 File.umask #=> 6 ;T;[o;= ;>I" overload;F;?0;;^;@0;:I" umask();T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@q;![;"I"@return [Integer];T;#0;$@q;.F;Bi;C0;7[;$@qo;= ;>I" overload;F;?0;;^;@0;:I"umask(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@q;![;"I"@return [Integer];T;#0;$@q;.F;Bi;C0;7[[I" integer;T0;$@q;![;"I"Returns the current umask value for this process. If the optional argument is given, set the umask to that value and return the previous value. Umask values are subtracted from the default permissions, so a umask of 0222 would make a file read-only for everyone. File.umask(0006) #=> 18 File.umask #=> 6 @overload umask() @return [Integer] @overload umask(integer) @return [Integer];T;#0;$@q;.F;/o;0;1T;2i ;3i ;%@f;9I"Astatic VALUE rb_file_s_umask(int argc, VALUE *argv, VALUE _) { mode_t omask = 0; switch (argc) { case 0: omask = umask(0); umask(omask); break; case 1: omask = umask(NUM2MODET(argv[0])); break; default: rb_error_arity(argc, 0, 1); } return MODET2NUM(omask); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.truncate;F;7[[I" path;T0[I"len;T0;[[@8i;T;: truncate;0;[;{;IC; "Truncates the file file_name to be at most integer bytes long. Not available on all platforms. f = File.new("out", "w") f.write("1234567890") #=> 10 f.close #=> nil File.truncate("out", 5) #=> 0 File.size("out") #=> 5 ;T;[o;= ;>I" overload;F;?0;;_;@0;:I"!truncate(file_name, integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@q;![;"I"@return [0];T;#0;$@q;.F;Bi;C0;7[[I"file_name;T0[I" integer;T0;$@q;![;"I"PTruncates the file file_name to be at most integer bytes long. Not available on all platforms. f = File.new("out", "w") f.write("1234567890") #=> 10 f.close #=> nil File.truncate("out", 5) #=> 0 File.size("out") #=> 5 @overload truncate(file_name, integer) @return [0];T;#0;$@q;.F;/o;0;1T;2i;3i;%@f;9I"static VALUE rb_file_s_truncate(VALUE klass, VALUE path, VALUE len) { struct truncate_arg ta; int r; ta.pos = NUM2POS(len); FilePathValue(path); path = rb_str_encode_ospath(path); ta.path = StringValueCStr(path); r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_truncate, &ta, RUBY_UBF_IO, NULL); if (r < 0) rb_sys_fail_path(path); return INT2FIX(0); #undef NUM2POS };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.mkfifo;F;7[[@90;[[@8i5;T;: mkfifo;0;[;{;IC; "Creates a FIFO special file with name _file_name_. _mode_ specifies the FIFO's permissions. It is modified by the process's umask in the usual way: the permissions of the created file are (mode & ~umask). ;T;[o;= ;>I" overload;F;?0;;`;@0;:I"!mkfifo(file_name, mode=0666);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@q;![;"I"@return [0];T;#0;$@q;.F;Bi;C0;7[[I"file_name;T0[I" mode;TI" 0666;T;$@q;![;"I"Creates a FIFO special file with name _file_name_. _mode_ specifies the FIFO's permissions. It is modified by the process's umask in the usual way: the permissions of the created file are (mode & ~umask). @overload mkfifo(file_name, mode=0666) @return [0];T;#0;$@q;.F;/o;0;1T;2i+;3i2;%@f;9I"static VALUE rb_file_s_mkfifo(int argc, VALUE *argv, VALUE _) { VALUE path; struct mkfifo_arg ma; ma.mode = 0666; rb_check_arity(argc, 1, 2); if (argc > 1) { ma.mode = NUM2MODET(argv[1]); } path = argv[0]; FilePathValue(path); path = rb_str_encode_ospath(path); ma.path = RSTRING_PTR(path); if (rb_thread_call_without_gvl(nogvl_mkfifo, &ma, RUBY_UBF_IO, 0)) { rb_sys_fail_path(path); } return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.expand_path;F;7[[I"*;T0[I"_;T0;[[@8i;T;:expand_path;0;[;{;IC; "Converts a pathname to an absolute pathname. Relative paths are referenced from the current working directory of the process unless +dir_string+ is given, in which case it will be used as the starting point. The given pathname may start with a ``~'', which expands to the process owner's home directory (the environment variable +HOME+ must be set correctly). ``~user'' expands to the named user's home directory. File.expand_path("~oracle/bin") #=> "/home/oracle/bin" A simple example of using +dir_string+ is as follows. File.expand_path("ruby", "/usr/bin") #=> "/usr/bin/ruby" A more complex example which also resolves parent directory is as follows. Suppose we are in bin/mygem and want the absolute path of lib/mygem.rb. File.expand_path("../../lib/mygem.rb", __FILE__) #=> ".../path/to/project/lib/mygem.rb" So first it resolves the parent of __FILE__, that is bin/, then go to the parent, the root of the project and appends +lib/mygem.rb+. ;T;[o;= ;>I" overload;F;?0;;a;@0;:I"+expand_path(file_name [, dir_string] );T;IC; ";T;[;![;"I";T;#0;$@q;.F;Bi;C0;7[[I"file_name[, dir_string];T0;$@q;![;"I"(Converts a pathname to an absolute pathname. Relative paths are referenced from the current working directory of the process unless +dir_string+ is given, in which case it will be used as the starting point. The given pathname may start with a ``~'', which expands to the process owner's home directory (the environment variable +HOME+ must be set correctly). ``~user'' expands to the named user's home directory. File.expand_path("~oracle/bin") #=> "/home/oracle/bin" A simple example of using +dir_string+ is as follows. File.expand_path("ruby", "/usr/bin") #=> "/usr/bin/ruby" A more complex example which also resolves parent directory is as follows. Suppose we are in bin/mygem and want the absolute path of lib/mygem.rb. File.expand_path("../../lib/mygem.rb", __FILE__) #=> ".../path/to/project/lib/mygem.rb" So first it resolves the parent of __FILE__, that is bin/, then go to the parent, the root of the project and appends +lib/mygem.rb+. @overload expand_path(file_name [, dir_string] );T;#0;$@q;.F;/o;0;1T;2i;3i;%@f;9I"lstatic VALUE s_expand_path(int c, const VALUE * v, VALUE _) { return rb_file_s_expand_path(c, v); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.absolute_path;F;7[[I"*;T0[I"_;T0;[[@8i>;T;;P;0;[;{;IC; "Converts a pathname to an absolute pathname. Relative paths are referenced from the current working directory of the process unless dir_string is given, in which case it will be used as the starting point. If the given pathname starts with a ``~'' it is NOT expanded, it is treated as a normal directory name. File.absolute_path("~oracle/bin") #=> "/~oracle/bin" ;T;[o;= ;>I" overload;F;?0;;P;@0;:I"-absolute_path(file_name [, dir_string] );T;IC; ";T;[;![;"I";T;#0;$@r;.F;Bi;C0;7[[I"file_name[, dir_string];T0;$@r;![;"I"Converts a pathname to an absolute pathname. Relative paths are referenced from the current working directory of the process unless dir_string is given, in which case it will be used as the starting point. If the given pathname starts with a ``~'' it is NOT expanded, it is treated as a normal directory name. File.absolute_path("~oracle/bin") #=> "/~oracle/bin" @overload absolute_path(file_name [, dir_string] );T;#0;$@r;.F;/o;0;1T;2i1;3i:;%@f;9I"pstatic VALUE s_absolute_path(int c, const VALUE * v, VALUE _) { return rb_file_s_absolute_path(c, v); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.absolute_path?;F;7[[I" fname;T0;[[@8iN;T;:absolute_path?;0;[;{;IC; "Returns true if +file_name+ is an absolute path, and false otherwise. File.absolute_path?("c:/foo") #=> false (on Linux), true (on Windows);T;[o;= ;>I" overload;F;?0;;b;@0;:I"absolute_path?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@0r;![;"I"@return [Boolean];T;#0;$@0r;.F;Bi;C0;7[[I"file_name;T0;$@0r;![;"I"Returns true if +file_name+ is an absolute path, and false otherwise. File.absolute_path?("c:/foo") #=> false (on Linux), true (on Windows) @overload absolute_path?(file_name) @return [Boolean];T;#0;$@0r;.F;/o;0;1T;2iD;3iK;Bi;%@f;9I"static VALUE s_absolute_path_p(VALUE klass, VALUE fname) { VALUE path = rb_get_path(fname); if (!rb_is_absolute_path(RSTRING_PTR(path))) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.realpath;F;7[[@90;[[@8i;T;: realpath;0;[;{;IC; "?Returns the real (absolute) pathname of _pathname_ in the actual filesystem not containing symlinks or useless dots. If _dir_string_ is given, it is used as a base directory for interpreting relative pathname instead of the current directory. All components of the pathname must exist when this method is called. ;T;[o;= ;>I" overload;F;?0;;c;@0;:I"&realpath(pathname [, dir_string]);T;IC; ";T;[;![;"I";T;#0;$@Or;.F;Bi;C0;7[[I"pathname[, dir_string];T0;$@Or;![;"I"n Returns the real (absolute) pathname of _pathname_ in the actual filesystem not containing symlinks or useless dots. If _dir_string_ is given, it is used as a base directory for interpreting relative pathname instead of the current directory. All components of the pathname must exist when this method is called. @overload realpath(pathname [, dir_string]);T;#0;$@Or;.F;/o;0;1T;2i;3i;%@f;9I"static VALUE rb_file_s_realpath(int argc, VALUE *argv, VALUE klass) { VALUE basedir = (rb_check_arity(argc, 1, 2) > 1) ? argv[1] : Qnil; VALUE path = argv[0]; FilePathValue(path); return rb_realpath_internal(basedir, path, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.realdirpath;F;7[[@90;[[@8i;T;:realdirpath;0;[;{;IC; "HReturns the real (absolute) pathname of _pathname_ in the actual filesystem. The real pathname doesn't contain symlinks or useless dots. If _dir_string_ is given, it is used as a base directory for interpreting relative pathname instead of the current directory. The last component of the real pathname can be nonexistent. ;T;[o;= ;>I" overload;F;?0;;d;@0;:I")realdirpath(pathname [, dir_string]);T;IC; ";T;[;![;"I";T;#0;$@hr;.F;Bi;C0;7[[I"pathname[, dir_string];T0;$@hr;![;"I"z Returns the real (absolute) pathname of _pathname_ in the actual filesystem. The real pathname doesn't contain symlinks or useless dots. If _dir_string_ is given, it is used as a base directory for interpreting relative pathname instead of the current directory. The last component of the real pathname can be nonexistent. @overload realdirpath(pathname [, dir_string]);T;#0;$@hr;.F;/o;0;1T;2i;3i;%@f;9I"static VALUE rb_file_s_realdirpath(int argc, VALUE *argv, VALUE klass) { VALUE basedir = (rb_check_arity(argc, 1, 2) > 1) ? argv[1] : Qnil; VALUE path = argv[0]; FilePathValue(path); return rb_realpath_internal(basedir, path, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.basename;F;7[[@90;[[@8i=;T;: basename;0;[;{;IC; "PReturns the last component of the filename given in file_name (after first stripping trailing separators), which can be formed using both File::SEPARATOR and File::ALT_SEPARATOR as the separator when File::ALT_SEPARATOR is not nil. If suffix is given and present at the end of file_name, it is removed. If suffix is ".*", any extension will be removed. File.basename("/home/gumby/work/ruby.rb") #=> "ruby.rb" File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby" File.basename("/home/gumby/work/ruby.rb", ".*") #=> "ruby" ;T;[o;= ;>I" overload;F;?0;;e;@0;:I"$basename(file_name [, suffix] );T;IC; ";T;[;![;"I";T;#0;$@r;.F;Bi;C0;7[[I"file_name[, suffix];T0;$@r;![;"I"|Returns the last component of the filename given in file_name (after first stripping trailing separators), which can be formed using both File::SEPARATOR and File::ALT_SEPARATOR as the separator when File::ALT_SEPARATOR is not nil. If suffix is given and present at the end of file_name, it is removed. If suffix is ".*", any extension will be removed. File.basename("/home/gumby/work/ruby.rb") #=> "ruby.rb" File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby" File.basename("/home/gumby/work/ruby.rb", ".*") #=> "ruby" @overload basename(file_name [, suffix] );T;#0;$@r;.F;/o;0;1T;2i,;3i9;%@f;9I"static VALUE rb_file_s_basename(int argc, VALUE *argv, VALUE _) { VALUE fname, fext, basename; const char *name, *p; long f, n; rb_encoding *enc; fext = Qnil; if (rb_check_arity(argc, 1, 2) == 2) { fext = argv[1]; StringValue(fext); enc = check_path_encoding(fext); } fname = argv[0]; FilePathStringValue(fname); if (NIL_P(fext) || !(enc = rb_enc_compatible(fname, fext))) { enc = rb_enc_get(fname); fext = Qnil; } if ((n = RSTRING_LEN(fname)) == 0 || !*(name = RSTRING_PTR(fname))) return rb_str_new_shared(fname); p = ruby_enc_find_basename(name, &f, &n, enc); if (n >= 0) { if (NIL_P(fext)) { f = n; } else { const char *fp; fp = StringValueCStr(fext); if (!(f = rmext(p, f, n, fp, RSTRING_LEN(fext), enc))) { f = n; } RB_GC_GUARD(fext); } if (f == RSTRING_LEN(fname)) return rb_str_new_shared(fname); } basename = rb_str_new(p, f); rb_enc_copy(basename, fname); return basename; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.dirname;F;7[[@90;[[@8i~;T;: dirname;0;[;{;IC; "Returns all components of the filename given in file_name except the last one (after first stripping trailing separators). The filename can be formed using both File::SEPARATOR and File::ALT_SEPARATOR as the separator when File::ALT_SEPARATOR is not nil. File.dirname("/home/gumby/work/ruby.rb") #=> "/home/gumby/work" If +level+ is given, removes the last +level+ components, not only one. File.dirname("/home/gumby/work/ruby.rb", 2) #=> "/home/gumby" File.dirname("/home/gumby/work/ruby.rb", 4) #=> "/" ;T;[o;= ;>I" overload;F;?0;;f;@0;:I""dirname(file_name, level = 1);T;IC; ";T;[;![;"I";T;#0;$@r;.F;Bi;C0;7[[I"file_name;T0[I" level;TI"1;T;$@r;![;"I"DReturns all components of the filename given in file_name except the last one (after first stripping trailing separators). The filename can be formed using both File::SEPARATOR and File::ALT_SEPARATOR as the separator when File::ALT_SEPARATOR is not nil. File.dirname("/home/gumby/work/ruby.rb") #=> "/home/gumby/work" If +level+ is given, removes the last +level+ components, not only one. File.dirname("/home/gumby/work/ruby.rb", 2) #=> "/home/gumby" File.dirname("/home/gumby/work/ruby.rb", 4) #=> "/" @overload dirname(file_name, level = 1);T;#0;$@r;.F;/o;0;1T;2ik;3iz;%@f;9I"static VALUE rb_file_s_dirname(int argc, VALUE *argv, VALUE klass) { int n = 1; if ((argc = rb_check_arity(argc, 1, 2)) > 1) { n = NUM2INT(argv[1]); } return rb_file_dirname_n(argv[0], n); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.extname;F;7[[I" fname;T0;[[@8i3;T;: extname;0;[;{;IC; "Returns the extension (the portion of file name in +path+ starting from the last period). If +path+ is a dotfile, or starts with a period, then the starting dot is not dealt with the start of the extension. An empty string will also be returned when the period is the last character in +path+. On Windows, trailing dots are truncated. File.extname("test.rb") #=> ".rb" File.extname("a/b/d/test.rb") #=> ".rb" File.extname(".a/b/d/test.rb") #=> ".rb" File.extname("foo.") #=> "" on Windows File.extname("foo.") #=> "." on non-Windows File.extname("test") #=> "" File.extname(".profile") #=> "" File.extname(".profile.sh") #=> ".sh" ;T;[o;= ;>I" overload;F;?0;;g;@0;:I"extname(path);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@r;![;"I"@return [String];T;#0;$@r;.F;Bi;C0;7[[I" path;T0;$@r;![;"I"Returns the extension (the portion of file name in +path+ starting from the last period). If +path+ is a dotfile, or starts with a period, then the starting dot is not dealt with the start of the extension. An empty string will also be returned when the period is the last character in +path+. On Windows, trailing dots are truncated. File.extname("test.rb") #=> ".rb" File.extname("a/b/d/test.rb") #=> ".rb" File.extname(".a/b/d/test.rb") #=> ".rb" File.extname("foo.") #=> "" on Windows File.extname("foo.") #=> "." on non-Windows File.extname("test") #=> "" File.extname(".profile") #=> "" File.extname(".profile.sh") #=> ".sh" @overload extname(path) @return [String];T;#0;$@r;.F;/o;0;1T;2i;3i0;%@f;9I"static VALUE rb_file_s_extname(VALUE klass, VALUE fname) { const char *name, *e; long len; VALUE extname; FilePathStringValue(fname); name = StringValueCStr(fname); len = RSTRING_LEN(fname); e = ruby_enc_find_extname(name, &len, rb_enc_get(fname)); if (len < 1) return rb_str_new(0, 0); extname = rb_str_subseq(fname, e - name, len); /* keep the dot, too! */ return extname; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.path;F;7[[I" fname;T0;[[@8iO;T;;O;0;[;{;IC; "Returns the string representation of the path File.path("/dev/null") #=> "/dev/null" File.path(Pathname.new("/tmp")) #=> "/tmp" ;T;[o;= ;>I" overload;F;?0;;O;@0;:I"path(path);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@r;![;"I"@return [String];T;#0;$@r;.F;Bi;C0;7[[I" path;T0;$@r;![;"I"Returns the string representation of the path File.path("/dev/null") #=> "/dev/null" File.path(Pathname.new("/tmp")) #=> "/tmp" @overload path(path) @return [String];T;#0;$@r;.F;/o;0;1T;2iD;3iL;%@f;9I"]static VALUE rb_file_s_path(VALUE klass, VALUE fname) { return rb_get_path(fname); };T;:I"static VALUE;T;;To;u;[[@8iv;F;:Separator;;w;;;[;{;IC; "&separates directory parts in path ;T;[;![;"I"&separates directory parts in path;T;#0;$@r;.F;/o;0;1T;2iu;3iu;%@f;&I"File::Separator;F;xI"separator;To;u;[[@8ix;F;:SEPARATOR;;w;;;[;{;IC; "&separates directory parts in path ;T;[;![;"I"&separates directory parts in path;T;#0;$@s;.F;/o;0;1T;2iw;3iw;%@f;&I"File::SEPARATOR;F;xI"separator;To;4;5F;6;;;;&I"File.split;F;7[[I" path;T0;[[@8i`;T;: split;0;[;{;IC; "Splits the given string into a directory and a file component and returns them in a two-element array. See also File::dirname and File::basename. File.split("/home/gumby/.profile") #=> ["/home/gumby", ".profile"] ;T;[o;= ;>I" overload;F;?0;;j;@0;:I"split(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@ s;![;"I"@return [Array];T;#0;$@ s;.F;Bi;C0;7[[I"file_name;T0;$@ s;![;"I" Splits the given string into a directory and a file component and returns them in a two-element array. See also File::dirname and File::basename. File.split("/home/gumby/.profile") #=> ["/home/gumby", ".profile"] @overload split(file_name) @return [Array];T;#0;$@ s;.F;/o;0;1T;2iU;3i];%@f;9I"static VALUE rb_file_s_split(VALUE klass, VALUE path) { FilePathStringValue(path); /* get rid of converting twice */ return rb_assoc_new(rb_file_dirname(path), rb_file_s_basename(1,&path,Qundef)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File.join;F;7[[I" args;T0;[[@8i;T;;4;0;[;{;IC; "Returns a new string formed by joining the strings using "/". File.join("usr", "mail", "gumby") #=> "usr/mail/gumby" ;T;[o;= ;>I" overload;F;?0;;4;@0;:I"join(string, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@+s;![;"I"@return [String];T;#0;$@+s;.F;Bi;C0;7[[I" string;T0[I"...;T0;$@+s;![;"I"Returns a new string formed by joining the strings using "/". File.join("usr", "mail", "gumby") #=> "usr/mail/gumby" @overload join(string, ...) @return [String];T;#0;$@+s;.F;/o;0;1T;2i;3i;%@f;9I"\static VALUE rb_file_s_join(VALUE klass, VALUE args) { return rb_file_join(args); };T;:I"static VALUE;T;;To;u;[[@8i~[@8i;F;:ALT_SEPARATOR;;w;;;[;{;IC; ",platform specific alternative separator ;T;[;![;"I",platform specific alternative separator;T;#0;$@Ls;.F;/o;0;1T;2i};3i};%@f;&I"File::ALT_SEPARATOR;F;xI" Qnil;To;u;[[@8i;F;:PATH_SEPARATOR;;w;;;[;{;IC; "path list separator ;T;[;![;"I"path list separator;T;#0;$@Ys;.F;/o;0;1T;2i;3i;%@f;&I"File::PATH_SEPARATOR;F;xI"rb_fstring_cstr(PATH_SEP);To;4;5F;6;;;;&I"File#lstat;F;7[;[[@8i;T;;Q;0;[;{;IC; "ESame as IO#stat, but does not follow the last symbolic link. Instead, reports on the link itself. File.symlink("testfile", "link2test") #=> 0 File.stat("testfile").size #=> 66 f = File.new("link2test") f.lstat.size #=> 8 f.stat.size #=> 66 ;T;[o;= ;>I" overload;F;?0;;Q;@0;:I" lstat;T;IC; ";T;[;![;"I";T;#0;$@es;.F;Bi;C0;7[;$@es;![;"I"WSame as IO#stat, but does not follow the last symbolic link. Instead, reports on the link itself. File.symlink("testfile", "link2test") #=> 0 File.stat("testfile").size #=> 66 f = File.new("link2test") f.lstat.size #=> 8 f.stat.size #=> 66 @overload lstat;T;#0;$@es;.F;/o;0;1T;2i;3i;%@f;9I"static VALUE rb_file_lstat(VALUE obj) { #ifdef HAVE_LSTAT rb_io_t *fptr; struct stat st; VALUE path; GetOpenFile(obj, fptr); if (NIL_P(fptr->pathv)) return Qnil; path = rb_str_encode_ospath(fptr->pathv); if (lstat_without_gvl(RSTRING_PTR(path), &st) == -1) { rb_sys_fail_path(fptr->pathv); } return rb_stat_new(&st); #else return rb_io_stat(obj); #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File#atime;F;7[;[[@8i ;T;;3;0;[;{;IC; "Returns the last access time (a Time object) for file, or epoch if file has not been accessed. File.new("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969 ;T;[o;= ;>I" overload;F;?0;;3;@0;:I" atime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@{s;![;"I"@return [Time];T;#0;$@{s;.F;Bi;C0;7[;$@{s;![;"I"Returns the last access time (a Time object) for file, or epoch if file has not been accessed. File.new("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969 @overload atime @return [Time];T;#0;$@{s;.F;/o;0;1T;2i ;3i ;%@f;9I"static VALUE rb_file_atime(VALUE obj) { rb_io_t *fptr; struct stat st; GetOpenFile(obj, fptr); if (fstat(fptr->fd, &st) == -1) { rb_sys_fail_path(fptr->pathv); } return stat_atime(&st); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File#mtime;F;7[;[[@8iL ;T;;4;0;[;{;IC; "uReturns the modification time for file. File.new("testfile").mtime #=> Wed Apr 09 08:53:14 CDT 2003 ;T;[o;= ;>I" overload;F;?0;;4;@0;:I" mtime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@s;![;"I"@return [Time];T;#0;$@s;.F;Bi;C0;7[;$@s;![;"I"Returns the modification time for file. File.new("testfile").mtime #=> Wed Apr 09 08:53:14 CDT 2003 @overload mtime @return [Time];T;#0;$@s;.F;/o;0;1T;2iB ;3iI ;%@f;9I"static VALUE rb_file_mtime(VALUE obj) { rb_io_t *fptr; struct stat st; GetOpenFile(obj, fptr); if (fstat(fptr->fd, &st) == -1) { rb_sys_fail_path(fptr->pathv); } return stat_mtime(&st); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File#ctime;F;7[;[[@8i ;T;;5;0;[;{;IC; "Returns the change time for file (that is, the time directory information about the file was changed, not the file itself). Note that on Windows (NTFS), returns creation time (birth time). File.new("testfile").ctime #=> Wed Apr 09 08:53:14 CDT 2003 ;T;[o;= ;>I" overload;F;?0;;5;@0;:I" ctime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@s;![;"I"@return [Time];T;#0;$@s;.F;Bi;C0;7[;$@s;![;"I"*Returns the change time for file (that is, the time directory information about the file was changed, not the file itself). Note that on Windows (NTFS), returns creation time (birth time). File.new("testfile").ctime #=> Wed Apr 09 08:53:14 CDT 2003 @overload ctime @return [Time];T;#0;$@s;.F;/o;0;1T;2iv ;3i ;%@f;9I"static VALUE rb_file_ctime(VALUE obj) { rb_io_t *fptr; struct stat st; GetOpenFile(obj, fptr); if (fstat(fptr->fd, &st) == -1) { rb_sys_fail_path(fptr->pathv); } return stat_ctime(&st); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File#birthtime;F;7[;[[@8i ;T;;6;0;[;{;IC; "Returns the birth time for file. File.new("testfile").birthtime #=> Wed Apr 09 08:53:14 CDT 2003 If the platform doesn't have birthtime, raises NotImplementedError. ;T;[o;= ;>I" overload;F;?0;;6;@0;:I"birthtime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@s;![;"I"@return [Time];T;#0;$@s;.F;Bi;C0;7[;$@s;![;"I"Returns the birth time for file. File.new("testfile").birthtime #=> Wed Apr 09 08:53:14 CDT 2003 If the platform doesn't have birthtime, raises NotImplementedError. @overload birthtime @return [Time];T;#0;$@s;.F;/o;0;1T;2i ;3i ;%@f;9I"static VALUE rb_file_birthtime(VALUE obj) { rb_io_t *fptr; statx_data st; GetOpenFile(obj, fptr); if (fstatx_without_gvl(fptr->fd, &st, STATX_BTIME) == -1) { rb_sys_fail_path(fptr->pathv); } return statx_birthtime(&st, fptr->pathv); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File#size;F;7[;[[@8i ;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@s;%@f;9I"Tstatic VALUE file_size(VALUE self) { return OFFT2NUM(rb_file_size(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File#chmod;F;7[[I" vmode;T0;[[@8i ;T;;S;0;[;{;IC; "Changes permission bits on file to the bit pattern represented by mode_int. Actual effects are platform dependent; on Unix systems, see chmod(2) for details. Follows symbolic links. Also see File#lchmod. f = File.new("out", "w"); f.chmod(0644) #=> 0 ;T;[o;= ;>I" overload;F;?0;;S;@0;:I"chmod(mode_int);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@s;![;"I"@return [0];T;#0;$@s;.F;Bi;C0;7[[I" mode_int;T0;$@s;![;"I"GChanges permission bits on file to the bit pattern represented by mode_int. Actual effects are platform dependent; on Unix systems, see chmod(2) for details. Follows symbolic links. Also see File#lchmod. f = File.new("out", "w"); f.chmod(0644) #=> 0 @overload chmod(mode_int) @return [0];T;#0;$@s;.F;/o;0;1T;2i ;3i ;%@f;9I"static VALUE rb_file_chmod(VALUE obj, VALUE vmode) { rb_io_t *fptr; mode_t mode; #if !defined HAVE_FCHMOD || !HAVE_FCHMOD VALUE path; #endif mode = NUM2MODET(vmode); GetOpenFile(obj, fptr); #ifdef HAVE_FCHMOD if (fchmod(fptr->fd, mode) == -1) { if (HAVE_FCHMOD || errno != ENOSYS) rb_sys_fail_path(fptr->pathv); } else { if (!HAVE_FCHMOD) return INT2FIX(0); } #endif #if !defined HAVE_FCHMOD || !HAVE_FCHMOD if (NIL_P(fptr->pathv)) return Qnil; path = rb_str_encode_ospath(fptr->pathv); if (chmod(RSTRING_PTR(path), mode) == -1) rb_sys_fail_path(fptr->pathv); #endif return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File#chown;F;7[[I" owner;T0[I" group;T0;[[@8i ;T;;T;0;[;{;IC; "Changes the owner and group of file to the given numeric owner and group id's. Only a process with superuser privileges may change the owner of a file. The current owner of a file may change the file's group to any group to which the owner belongs. A nil or -1 owner or group id is ignored. Follows symbolic links. See also File#lchown. File.new("testfile").chown(502, 1000) ;T;[o;= ;>I" overload;F;?0;;T;@0;:I"!chown(owner_int, group_int );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@t;![;"I"@return [0];T;#0;$@t;.F;Bi;C0;7[[I"owner_int;T0[I"group_int;T0;$@t;![;"I"Changes the owner and group of file to the given numeric owner and group id's. Only a process with superuser privileges may change the owner of a file. The current owner of a file may change the file's group to any group to which the owner belongs. A nil or -1 owner or group id is ignored. Follows symbolic links. See also File#lchown. File.new("testfile").chown(502, 1000) @overload chown(owner_int, group_int ) @return [0];T;#0;$@t;.F;/o;0;1T;2i ;3i ;%@f;9I"static VALUE rb_file_chown(VALUE obj, VALUE owner, VALUE group) { rb_io_t *fptr; rb_uid_t o; rb_gid_t g; #ifndef HAVE_FCHOWN VALUE path; #endif o = to_uid(owner); g = to_gid(group); GetOpenFile(obj, fptr); #ifndef HAVE_FCHOWN if (NIL_P(fptr->pathv)) return Qnil; path = rb_str_encode_ospath(fptr->pathv); if (chown(RSTRING_PTR(path), o, g) == -1) rb_sys_fail_path(fptr->pathv); #else if (fchown(fptr->fd, o, g) == -1) rb_sys_fail_path(fptr->pathv); #endif return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File#truncate;F;7[[I"len;T0;[[@8i1;T;;_;0;[;{;IC; "+Truncates file to at most integer bytes. The file must be opened for writing. Not available on all platforms. f = File.new("out", "w") f.syswrite("1234567890") #=> 10 f.truncate(5) #=> 0 f.close() #=> nil File.size("out") #=> 5 ;T;[o;= ;>I" overload;F;?0;;_;@0;:I"truncate(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@5t;![;"I"@return [0];T;#0;$@5t;.F;Bi;C0;7[[I" integer;T0;$@5t;![;"I"WTruncates file to at most integer bytes. The file must be opened for writing. Not available on all platforms. f = File.new("out", "w") f.syswrite("1234567890") #=> 10 f.truncate(5) #=> 0 f.close() #=> nil File.size("out") #=> 5 @overload truncate(integer) @return [0];T;#0;$@5t;.F;/o;0;1T;2i#;3i.;%@f;9I"static VALUE rb_file_truncate(VALUE obj, VALUE len) { rb_io_t *fptr; struct ftruncate_arg fa; fa.pos = NUM2POS(len); GetOpenFile(obj, fptr); if (!(fptr->mode & FMODE_WRITABLE)) { rb_raise(rb_eIOError, "not opened for writing"); } rb_io_flush_raw(obj, 0); fa.fd = fptr->fd; if ((int)rb_thread_io_blocking_region(nogvl_ftruncate, &fa, fa.fd) < 0) { rb_sys_fail_path(fptr->pathv); } return INT2FIX(0); #undef NUM2POS };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File#flock;F;7[[I"operation;T0;[[@8i;T;: flock;0;[;{;IC; " Locks or unlocks a file according to locking_constant (a logical or of the values in the table below). Returns false if File::LOCK_NB is specified and the operation would otherwise have blocked. Not available on all platforms. Locking constants (in class File): LOCK_EX | Exclusive lock. Only one process may hold an | exclusive lock for a given file at a time. ----------+------------------------------------------------ LOCK_NB | Don't block when locking. May be combined | with other lock options using logical or. ----------+------------------------------------------------ LOCK_SH | Shared lock. Multiple processes may each hold a | shared lock for a given file at the same time. ----------+------------------------------------------------ LOCK_UN | Unlock. Example: # update a counter using write lock # don't use "w" because it truncates the file before lock. File.open("counter", File::RDWR|File::CREAT, 0644) {|f| f.flock(File::LOCK_EX) value = f.read.to_i + 1 f.rewind f.write("#{value}\n") f.flush f.truncate(f.pos) } # read the counter using read lock File.open("counter", "r") {|f| f.flock(File::LOCK_SH) p f.read } ;T;[o;= ;>I" overload;F;?0;;m;@0;:I"flock(locking_constant);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI" false;T;$@Tt;![;"I"@return [0, false];T;#0;$@Tt;.F;Bi;C0;7[[I"locking_constant;T0;$@Tt;![;"I"ELocks or unlocks a file according to locking_constant (a logical or of the values in the table below). Returns false if File::LOCK_NB is specified and the operation would otherwise have blocked. Not available on all platforms. Locking constants (in class File): LOCK_EX | Exclusive lock. Only one process may hold an | exclusive lock for a given file at a time. ----------+------------------------------------------------ LOCK_NB | Don't block when locking. May be combined | with other lock options using logical or. ----------+------------------------------------------------ LOCK_SH | Shared lock. Multiple processes may each hold a | shared lock for a given file at the same time. ----------+------------------------------------------------ LOCK_UN | Unlock. Example: # update a counter using write lock # don't use "w" because it truncates the file before lock. File.open("counter", File::RDWR|File::CREAT, 0644) {|f| f.flock(File::LOCK_EX) value = f.read.to_i + 1 f.rewind f.write("#{value}\n") f.flush f.truncate(f.pos) } # read the counter using read lock File.open("counter", "r") {|f| f.flock(File::LOCK_SH) p f.read } @overload flock(locking_constant) @return [0, false];T;#0;$@Tt;.F;/o;0;1T;2ij;3i;%@f;9I"Ustatic VALUE rb_file_flock(VALUE obj, VALUE operation) { rb_io_t *fptr; int op[2], op1; struct timeval time; op[1] = op1 = NUM2INT(operation); GetOpenFile(obj, fptr); op[0] = fptr->fd; if (fptr->mode & FMODE_WRITABLE) { rb_io_flush_raw(obj, 0); } while ((int)rb_thread_io_blocking_region(rb_thread_flock, op, fptr->fd) < 0) { int e = errno; switch (e) { case EAGAIN: case EACCES: #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN case EWOULDBLOCK: #endif if (op1 & LOCK_NB) return Qfalse; time.tv_sec = 0; time.tv_usec = 100 * 1000; /* 0.1 sec */ rb_thread_wait_for(time); rb_io_check_closed(fptr); continue; case EINTR: #if defined(ERESTART) case ERESTART: #endif break; default: rb_syserr_fail_path(e, fptr->pathv); } } return INT2FIX(0); };T;:I"static VALUE;T;;T@eo;4;5F;6;;;;&I"File#path;F;7[;[[@8i;T;;O;0;[;{;IC; "Returns the pathname used to create file as a string. Does not normalize the name. The pathname may not point to the file corresponding to file. For instance, the pathname becomes void when the file has been moved or deleted. This method raises IOError for a file created using File::Constants::TMPFILE because they don't have a pathname. File.new("testfile").path #=> "testfile" File.new("/tmp/../tmp/xxx", "w").path #=> "/tmp/../tmp/xxx" ;T;[o;= ;>I" overload;F;?0;;O;@0;:I" path;T;IC; ";T;[;![;"I";T;#0;$@tt;.F;Bi;C0;7[;$@tto;= ;>I" overload;F;?0;: to_path;@0;:I" to_path;T;IC; ";T;[;![;"I";T;#0;$@tt;.F;Bi;C0;7[;$@tt;![;"I" Returns the pathname used to create file as a string. Does not normalize the name. The pathname may not point to the file corresponding to file. For instance, the pathname becomes void when the file has been moved or deleted. This method raises IOError for a file created using File::Constants::TMPFILE because they don't have a pathname. File.new("testfile").path #=> "testfile" File.new("/tmp/../tmp/xxx", "w").path #=> "/tmp/../tmp/xxx" @overload path @overload to_path;T;#0;$@tt;.F;/o;0;1T;2i;3i;%@f;9I"static VALUE rb_file_path(VALUE obj) { rb_io_t *fptr; fptr = RFILE(rb_io_taint_check(obj))->fptr; rb_io_check_initialized(fptr); if (NIL_P(fptr->pathv)) { rb_raise(rb_eIOError, "File is unnamed (TMPFILE?)"); } return rb_str_dup(fptr->pathv); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"File#to_path;F;7[;[[@8i;T;;n;0;[;{;IC; "Returns the pathname used to create file as a string. Does not normalize the name. The pathname may not point to the file corresponding to file. For instance, the pathname becomes void when the file has been moved or deleted. This method raises IOError for a file created using File::Constants::TMPFILE because they don't have a pathname. File.new("testfile").path #=> "testfile" File.new("/tmp/../tmp/xxx", "w").path #=> "/tmp/../tmp/xxx" ;T;[o;= ;>I" overload;F;?0;;O;@0;:I" path;T;IC; ";T;[;![;"I";T;#0;$@t;.F;Bi;C0;7[;$@to;= ;>I" overload;F;?0;;n;@0;:I" to_path;T;IC; ";T;[;![;"I";T;#0;$@t;.F;Bi;C0;7[;$@t;![;"@t;#0;$@t;.F;/o;0;1T;2i;3i;%@f;9I"static VALUE rb_file_path(VALUE obj) { rb_io_t *fptr; fptr = RFILE(rb_io_taint_check(obj))->fptr; rb_io_check_initialized(fptr); if (NIL_P(fptr->pathv)) { rb_raise(rb_eIOError, "File is unnamed (TMPFILE?)"); } return rb_str_dup(fptr->pathv); };T;:I"static VALUE;T;;T; @f; IC;[; @f; IC;[; @f; IC;{;IC;{;T;IC;{;T;T;{;[;[[@8i.;F;;N;;;;;[;{;IC; "V A File is an abstraction of any file object accessible by the program and is closely associated with class IO. File includes the methods of module FileTest as class methods, allowing you to write (for example) File.exist?("foo"). In the description of File methods, permission bits are a platform-specific set of bits that indicate permissions of a file. On Unix-based systems, permissions are viewed as a set of three octets, for the owner, the group, and the rest of the world. For each of these entities, permissions may be set to read, write, or execute the file: The permission bits 0644 (in octal) would thus be interpreted as read/write for owner, and read-only for group and other. Higher-order bits may also be used to indicate the type of file (plain, directory, pipe, socket, and so on) and various other special features. If the permissions are for a directory, the meaning of the execute bit changes; when set the directory can be searched. On non-Posix operating systems, there may be only the ability to make a file read-only or read-write. In this case, the remaining permission bits will be synthesized to resemble typical values. For instance, on Windows NT the default permission bits are 0644, which means read/write for owner, read-only for all others. The only change that can be made is to make the file read-only, which is reported as 0444. Various constants for the methods in File can be found in File::Constants. == What's Here First, what's elsewhere. \Class \File: - Inherits from {class IO}[IO.html#class-IO-label-What-27s+Here], in particular, methods for creating, reading, and writing files - Includes {module FileTest}[FileTest.html#module-FileTest-label-What-27s+Here]. which provides dozens of additional methods. Here, class \File provides methods that are useful for: - {Creating}[#class-File-label-Creating] - {Querying}[#class-File-label-Querying] - {Settings}[#class-File-label-Settings] - {Other}[#class-File-label-Other] === Creating - ::new:: Opens the file at the given path; returns the file. - ::open:: Same as ::new, but when given a block will yield the file to the block, and close the file upon exiting the block. - ::link:: Creates a new name for an existing file using a hard link. - ::mkfifo:: Returns the FIFO file created at the given path. - ::symlink:: Creates a symbolic link for the given file path. === Querying _Paths_ - ::absolute_path:: Returns the absolute file path for the given path. - ::absolute_path?:: Returns whether the given path is the absolute file path. - ::basename:: Returns the last component of the given file path. - ::dirname:: Returns all but the last component of the given file path. - ::expand_path:: Returns the absolute file path for the given path, expanding ~ for a home directory. - ::extname:: Returns the file extension for the given file path. - ::fnmatch? (aliased as ::fnmatch):: Returns whether the given file path matches the given pattern. - ::join:: Joins path components into a single path string. - ::path:: Returns the string representation of the given path. - ::readlink:: Returns the path to the file at the given symbolic link. - ::realdirpath:: Returns the real path for the given file path, where the last component need not exist. - ::realpath:: Returns the real path for the given file path, where all components must exist. - ::split:: Returns an array of two strings: the directory name and basename of the file at the given path. - #path (aliased as #to_path):: Returns the string representation of the given path. _Times_ - ::atime:: Returns a \Time for the most recent access to the given file. - ::birthtime:: Returns a \Time for the creation of the given file. - ::ctime:: Returns a \Time for the metadata change of the given file. - ::mtime:: Returns a \Time for the most recent data modification to the content of the given file. - #atime:: Returns a \Time for the most recent access to +self+. - #birthtime:: Returns a \Time the creation for +self+. - #ctime:: Returns a \Time for the metadata change of +self+. - #mtime:: Returns a \Time for the most recent data modification to the content of +self+. _Types_ - ::blockdev?:: Returns whether the file at the given path is a block device. - ::chardev?:: Returns whether the file at the given path is a character device. - ::directory?:: Returns whether the file at the given path is a diretory. - ::executable?:: Returns whether the file at the given path is executable by the effective user and group of the current process. - ::executable_real?:: Returns whether the file at the given path is executable by the real user and group of the current process. - ::exist?:: Returns whether the file at the given path exists. - ::file?:: Returns whether the file at the given path is a regular file. - ::ftype:: Returns a string giving the type of the file at the given path. - ::grpowned?:: Returns whether the effective group of the current process owns the file at the given path. - ::identical?:: Returns whether the files at two given paths are identical. - ::lstat:: Returns the File::Stat object for the last symbolic link in the given path. - ::owned?:: Returns whether the effective user of the current process owns the file at the given path. - ::pipe?:: Returns whether the file at the given path is a pipe. - ::readable?:: Returns whether the file at the given path is readable by the effective user and group of the current process. - ::readable_real?:: Returns whether the file at the given path is readable by the real user and group of the current process. - ::setgid?:: Returns whether the setgid bit is set for the file at the given path. - ::setuid?:: Returns whether the setuid bit is set for the file at the given path. - ::socket?:: Returns whether the file at the given path is a socket. - ::stat:: Returns the File::Stat object for the file at the given path. - ::sticky?:: Returns whether the file at the given path has its sticky bit set. - ::symlink?:: Returns whether the file at the given path is a symbolic link. - ::umask:: Returns the umask value for the current process. - ::world_readable?:: Returns whether the file at the given path is readable by others. - ::world_writable?:: Returns whether the file at the given path is writable by others. - ::writable?:: Returns whether the file at the given path is writable by the effective user and group of the current process. - ::writable_real?:: Returns whether the file at the given path is writable by the real user and group of the current process. - #lstat:: Returns the File::Stat object for the last symbolic link in the path for +self+. _Contents_ - ::empty? (aliased as ::zero?):: Returns whether the file at the given path exists and is empty. - ::size:: Returns the size (bytes) of the file at the given path. - ::size?:: Returns +nil+ if there is no file at the given path, or if that file is empty; otherwise returns the file size (bytes). - #size:: Returns the size (bytes) of +self+. === Settings - ::chmod:: Changes permissions of the file at the given path. - ::chown:: Change ownership of the file at the given path. - ::lchmod:: Changes permissions of the last symbolic link in the given path. - ::lchown:: Change ownership of the last symbolic in the given path. - ::lutime:: For each given file path, sets the access time and modification time of the last symbolic link in the path. - ::rename:: Moves the file at one given path to another given path. - ::utime:: Sets the access time and modification time of each file at the given paths. - #flock:: Locks or unlocks +self+. === Other - ::truncate:: Truncates the file at the given file path to the given size. - ::unlink (aliased as ::delete):: Deletes the file for each given file path. - #truncate:: Truncates +self+ to the given size.;T;[;![;"I"X A File is an abstraction of any file object accessible by the program and is closely associated with class IO. File includes the methods of module FileTest as class methods, allowing you to write (for example) File.exist?("foo"). In the description of File methods, permission bits are a platform-specific set of bits that indicate permissions of a file. On Unix-based systems, permissions are viewed as a set of three octets, for the owner, the group, and the rest of the world. For each of these entities, permissions may be set to read, write, or execute the file: The permission bits 0644 (in octal) would thus be interpreted as read/write for owner, and read-only for group and other. Higher-order bits may also be used to indicate the type of file (plain, directory, pipe, socket, and so on) and various other special features. If the permissions are for a directory, the meaning of the execute bit changes; when set the directory can be searched. On non-Posix operating systems, there may be only the ability to make a file read-only or read-write. In this case, the remaining permission bits will be synthesized to resemble typical values. For instance, on Windows NT the default permission bits are 0644, which means read/write for owner, read-only for all others. The only change that can be made is to make the file read-only, which is reported as 0444. Various constants for the methods in File can be found in File::Constants. == What's Here First, what's elsewhere. \Class \File: - Inherits from {class IO}[IO.html#class-IO-label-What-27s+Here], in particular, methods for creating, reading, and writing files - Includes {module FileTest}[FileTest.html#module-FileTest-label-What-27s+Here]. which provides dozens of additional methods. Here, class \File provides methods that are useful for: - {Creating}[#class-File-label-Creating] - {Querying}[#class-File-label-Querying] - {Settings}[#class-File-label-Settings] - {Other}[#class-File-label-Other] === Creating - ::new:: Opens the file at the given path; returns the file. - ::open:: Same as ::new, but when given a block will yield the file to the block, and close the file upon exiting the block. - ::link:: Creates a new name for an existing file using a hard link. - ::mkfifo:: Returns the FIFO file created at the given path. - ::symlink:: Creates a symbolic link for the given file path. === Querying _Paths_ - ::absolute_path:: Returns the absolute file path for the given path. - ::absolute_path?:: Returns whether the given path is the absolute file path. - ::basename:: Returns the last component of the given file path. - ::dirname:: Returns all but the last component of the given file path. - ::expand_path:: Returns the absolute file path for the given path, expanding ~ for a home directory. - ::extname:: Returns the file extension for the given file path. - ::fnmatch? (aliased as ::fnmatch):: Returns whether the given file path matches the given pattern. - ::join:: Joins path components into a single path string. - ::path:: Returns the string representation of the given path. - ::readlink:: Returns the path to the file at the given symbolic link. - ::realdirpath:: Returns the real path for the given file path, where the last component need not exist. - ::realpath:: Returns the real path for the given file path, where all components must exist. - ::split:: Returns an array of two strings: the directory name and basename of the file at the given path. - #path (aliased as #to_path):: Returns the string representation of the given path. _Times_ - ::atime:: Returns a \Time for the most recent access to the given file. - ::birthtime:: Returns a \Time for the creation of the given file. - ::ctime:: Returns a \Time for the metadata change of the given file. - ::mtime:: Returns a \Time for the most recent data modification to the content of the given file. - #atime:: Returns a \Time for the most recent access to +self+. - #birthtime:: Returns a \Time the creation for +self+. - #ctime:: Returns a \Time for the metadata change of +self+. - #mtime:: Returns a \Time for the most recent data modification to the content of +self+. _Types_ - ::blockdev?:: Returns whether the file at the given path is a block device. - ::chardev?:: Returns whether the file at the given path is a character device. - ::directory?:: Returns whether the file at the given path is a diretory. - ::executable?:: Returns whether the file at the given path is executable by the effective user and group of the current process. - ::executable_real?:: Returns whether the file at the given path is executable by the real user and group of the current process. - ::exist?:: Returns whether the file at the given path exists. - ::file?:: Returns whether the file at the given path is a regular file. - ::ftype:: Returns a string giving the type of the file at the given path. - ::grpowned?:: Returns whether the effective group of the current process owns the file at the given path. - ::identical?:: Returns whether the files at two given paths are identical. - ::lstat:: Returns the File::Stat object for the last symbolic link in the given path. - ::owned?:: Returns whether the effective user of the current process owns the file at the given path. - ::pipe?:: Returns whether the file at the given path is a pipe. - ::readable?:: Returns whether the file at the given path is readable by the effective user and group of the current process. - ::readable_real?:: Returns whether the file at the given path is readable by the real user and group of the current process. - ::setgid?:: Returns whether the setgid bit is set for the file at the given path. - ::setuid?:: Returns whether the setuid bit is set for the file at the given path. - ::socket?:: Returns whether the file at the given path is a socket. - ::stat:: Returns the File::Stat object for the file at the given path. - ::sticky?:: Returns whether the file at the given path has its sticky bit set. - ::symlink?:: Returns whether the file at the given path is a symbolic link. - ::umask:: Returns the umask value for the current process. - ::world_readable?:: Returns whether the file at the given path is readable by others. - ::world_writable?:: Returns whether the file at the given path is writable by others. - ::writable?:: Returns whether the file at the given path is writable by the effective user and group of the current process. - ::writable_real?:: Returns whether the file at the given path is writable by the real user and group of the current process. - #lstat:: Returns the File::Stat object for the last symbolic link in the path for +self+. _Contents_ - ::empty? (aliased as ::zero?):: Returns whether the file at the given path exists and is empty. - ::size:: Returns the size (bytes) of the file at the given path. - ::size?:: Returns +nil+ if there is no file at the given path, or if that file is empty; otherwise returns the file size (bytes). - #size:: Returns the size (bytes) of +self+. === Settings - ::chmod:: Changes permissions of the file at the given path. - ::chown:: Change ownership of the file at the given path. - ::lchmod:: Changes permissions of the last symbolic link in the given path. - ::lchown:: Change ownership of the last symbolic in the given path. - ::lutime:: For each given file path, sets the access time and modification time of the last symbolic link in the path. - ::rename:: Moves the file at one given path to another given path. - ::utime:: Sets the access time and modification time of each file at the given paths. - #flock:: Locks or unlocks +self+. === Other - ::truncate:: Truncates the file at the given file path to the given size. - ::unlink (aliased as ::delete):: Deletes the file for each given file path. - #truncate:: Truncates +self+ to the given size. ;T;#0;$@f;.F;/o;0;1T;2i;3i%;Bi;%@;&I" File;F;'@kL;&I"File::Constants;F; @kL; IC;{;IC;{;T;IC;{;T;T;{@CS;;[;[[@Tib7;F;;;;;;;[;{;IC; "FThe IO class is the basis for all input and output in Ruby. An I/O stream may be duplexed (that is, bidirectional), and so may use more than one native operating system stream. Many of the examples in this section use the File class, the only standard subclass of IO. The two classes are closely associated. Like the File class, the Socket library subclasses from IO (such as TCPSocket or UDPSocket). The Kernel#open method can create an IO (or File) object for these types of arguments: * A plain string represents a filename suitable for the underlying operating system. * A string starting with "|" indicates a subprocess. The remainder of the string following the "|" is invoked as a process with appropriate input/output channels connected to it. * A string equal to "|-" will create another Ruby instance as a subprocess. The IO may be opened with different file modes (read-only, write-only) and encodings for proper conversion. See IO.new for these options. See Kernel#open for details of the various command formats described above. IO.popen, the Open3 library, or Process#spawn may also be used to communicate with subprocesses through an IO. Ruby will convert pathnames between different operating system conventions if possible. For instance, on a Windows system the filename "/gumby/ruby/test.rb" will be opened as "\gumby\ruby\test.rb". When specifying a Windows-style filename in a Ruby string, remember to escape the backslashes: "C:\\gumby\\ruby\\test.rb" Our examples here will use the Unix-style forward slashes; File::ALT_SEPARATOR can be used to get the platform-specific separator character. The global constant ARGF (also accessible as $<) provides an IO-like stream which allows access to all files mentioned on the command line (or STDIN if no files are mentioned). ARGF#path and its alias ARGF#filename are provided to access the name of the file currently being read. == io/console The io/console extension provides methods for interacting with the console. The console can be accessed from IO.console or the standard input/output/error IO objects. Requiring io/console adds the following methods: * IO::console * IO#raw * IO#raw! * IO#cooked * IO#cooked! * IO#getch * IO#echo= * IO#echo? * IO#noecho * IO#winsize * IO#winsize= * IO#iflush * IO#ioflush * IO#oflush Example: require 'io/console' rows, columns = $stdout.winsize puts "Your screen is #{columns} wide and #{rows} tall" == Example Files Many examples here use these filenames and their corresponding files: - t.txt: A text-only file that is assumed to exist via: text = <<~EOT This is line one. This is the second line. This is the third line. EOT File.write('t.txt', text) - t.dat: A data file that is assumed to exist via: data = "\u9990\u9991\u9992\u9993\u9994" f = File.open('t.dat', 'wb:UTF-16') f.write(data) f.close - t.rus: A Russian-language text file that is assumed to exist via: File.write('t.rus', "\u{442 435 441 442}") - t.tmp: A file that is assumed _not_ to exist. == Modes A number of \IO method calls must or may specify a _mode_ for the stream; the mode determines how stream is to be accessible, including: - Whether the stream is to be read-only, write-only, or read-write. - Whether the stream is positioned at its beginning or its end. - Whether the stream treats data as text-only or binary. - The external and internal encodings. === Mode Specified as an \Integer When +mode+ is an integer it must be one or more (combined by bitwise OR (|) of the modes defined in File::Constants: - +File::RDONLY+: Open for reading only. - +File::WRONLY+: Open for writing only. - +File::RDWR+: Open for reading and writing. - +File::APPEND+: Open for appending only. - +File::CREAT+: Create file if it does not exist. - +File::EXCL+: Raise an exception if +File::CREAT+ is given and the file exists. Examples: File.new('t.txt', File::RDONLY) File.new('t.tmp', File::RDWR | File::CREAT | File::EXCL) Note: Method IO#set_encoding does not allow the mode to be specified as an integer. === Mode Specified As a \String When +mode+ is a string it must begin with one of the following: - 'r': Read-only stream, positioned at the beginning; the stream cannot be changed to writable. - 'w': Write-only stream, positioned at the beginning; the stream cannot be changed to readable. - 'a': Write-only stream, positioned at the end; every write appends to the end; the stream cannot be changed to readable. - 'r+': Read-write stream, positioned at the beginning. - 'w+': Read-write stream, positioned at the end. - 'a+': Read-write stream, positioned at the end. For a writable file stream (that is, any except read-only), the file is truncated to zero if it exists, and is created if it does not exist. Examples: File.open('t.txt', 'r') File.open('t.tmp', 'w') Either of the following may be suffixed to any of the above: - 't': Text data; sets the default external encoding to +Encoding::UTF_8+; on Windows, enables conversion between EOL and CRLF. - 'b': Binary data; sets the default external encoding to +Encoding::ASCII_8BIT+; on Windows, suppresses conversion between EOL and CRLF. If neither is given, the stream defaults to text data. Examples: File.open('t.txt', 'rt') File.open('t.dat', 'rb') The following may be suffixed to any writable mode above: - 'x': Creates the file if it does not exist; raises an exception if the file exists. Example: File.open('t.tmp', 'wx') Finally, the mode string may specify encodings -- either external encoding only or both external and internal encodings -- by appending one or both encoding names, separated by colons: f = File.new('t.dat', 'rb') f.external_encoding # => # f.internal_encoding # => nil f = File.new('t.dat', 'rb:UTF-16') f.external_encoding # => # f.internal_encoding # => nil f = File.new('t.dat', 'rb:UTF-16:UTF-16') f.external_encoding # => # f.internal_encoding # => # The numerous encoding names are available in array Encoding.name_list: Encoding.name_list.size # => 175 Encoding.name_list.take(3) # => ["ASCII-8BIT", "UTF-8", "US-ASCII"] == Encodings When the external encoding is set, strings read are tagged by that encoding when reading, and strings written are converted to that encoding when writing. When both external and internal encodings are set, strings read are converted from external to internal encoding, and strings written are converted from internal to external encoding. For further details about transcoding input and output, see Encoding. If the external encoding is 'BOM|UTF-8', 'BOM|UTF-16LE' or 'BOM|UTF16-BE', Ruby checks for a Unicode BOM in the input document to help determine the encoding. For UTF-16 encodings the file open mode must be binary. If the BOM is found, it is stripped and the external encoding from the BOM is used. Note that the BOM-style encoding option is case insensitive, so 'bom|utf-8' is also valid.) == Open Options A number of \IO methods accept an optional parameter +opts+, which determines how a new stream is to be opened: - +:mode+: Stream mode. - +:flags+: \Integer file open flags; If +mode+ is also given, the two are bitwise-ORed. - +:external_encoding+: External encoding for the stream. - +:internal_encoding+: Internal encoding for the stream. '-' is a synonym for the default internal encoding. If the value is +nil+ no conversion occurs. - +:encoding+: Specifies external and internal encodings as 'extern:intern'. - +:textmode+: If a truthy value, specifies the mode as text-only, binary otherwise. - +:binmode+: If a truthy value, specifies the mode as binary, text-only otherwise. - +:autoclose+: If a truthy value, specifies that the +fd+ will close when the stream closes; otherwise it remains open. Also available are the options offered in String#encode, which may control conversion between external internal encoding. == Getline Options A number of \IO methods accept optional keyword arguments that determine how a stream is to be treated: - +:chomp+: If +true+, line separators are omitted; default is +false+. == Position An \IO stream has a _position_, which is the non-negative integer offset (in bytes) in the stream where the next read or write will occur. Note that a text stream may have multi-byte characters, so a text stream whose position is +n+ (_bytes_) may not have +n+ _characters_ preceding the current position -- there may be fewer. A new stream is initially positioned: - At the beginning (position +0+) if its mode is 'r', 'w', or 'r+'. - At the end (position self.size) if its mode is 'a', 'w+', or 'a+'. Methods to query the position: - IO#tell and its alias IO#pos return the position for an open stream. - IO#eof? and its alias IO#eof return whether the position is at the end of a readable stream. Reading from a stream usually changes its position: f = File.open('t.txt') f.tell # => 0 f.readline # => "This is line one.\n" f.tell # => 19 f.readline # => "This is the second line.\n" f.tell # => 45 f.eof? # => false f.readline # => "Here's the third line.\n" f.eof? # => true Writing to a stream usually changes its position: f = File.open('t.tmp', 'w') f.tell # => 0 f.write('foo') # => 3 f.tell # => 3 f.write('bar') # => 3 f.tell # => 6 Iterating over a stream usually changes its position: f = File.open('t.txt') f.each do |line| p "position=#{f.pos} eof?=#{f.eof?} line=#{line}" end Output: "position=19 eof?=false line=This is line one.\n" "position=45 eof?=false line=This is the second line.\n" "position=70 eof?=true line=This is the third line.\n" The position may also be changed by certain other methods: - IO#pos= and IO#seek change the position to a specified offset. - IO#rewind changes the position to the beginning. == Line Number A readable \IO stream has a _line_ _number_, which is the non-negative integer line number in the stream where the next read will occur. A new stream is initially has line number +0+. \Method IO#lineno returns the line number. Reading lines from a stream usually changes its line number: f = File.open('t.txt', 'r') f.lineno # => 0 f.readline # => "This is line one.\n" f.lineno # => 1 f.readline # => "This is the second line.\n" f.lineno # => 2 f.readline # => "Here's the third line.\n" f.lineno # => 3 f.eof? # => true Iterating over lines in a stream usually changes its line number: f = File.open('t.txt') f.each_line do |line| p "position=#{f.pos} eof?=#{f.eof?} line=#{line}" end Output: "position=19 eof?=false line=This is line one.\n" "position=45 eof?=false line=This is the second line.\n" "position=70 eof?=true line=This is the third line.\n" == What's Here First, what's elsewhere. \Class \IO: - Inherits from {class Object}[Object.html#class-Object-label-What-27s+Here]. - Includes {module Enumerable}[Enumerable.html#module-Enumerable-label-What-27s+Here], which provides dozens of additional methods. Here, class \IO provides methods that are useful for: - {Creating}[#class-IO-label-Creating] - {Reading}[#class-IO-label-Reading] - {Writing}[#class-IO-label-Writing] - {Positioning}[#class-IO-label-Positioning] - {Iterating}[#class-IO-label-Iterating] - {Settings}[#class-IO-label-Settings] - {Querying}[#class-IO-label-Querying] - {Buffering}[#class-IO-label-Buffering] - {Low-Level Access}[#class-IO-label-Low-Level+Access] - {Other}[#class-IO-label-Other] === Creating - ::new (aliased as ::for_fd):: Creates and returns a new \IO object for the given integer file descriptor. - ::open:: Creates a new \IO object. - ::pipe:: Creates a connected pair of reader and writer \IO objects. - ::popen:: Creates an \IO object to interact with a subprocess. - ::select:: Selects which given \IO instances are ready for reading, writing, or have pending exceptions. === Reading - ::binread:: Returns a binary string with all or a subset of bytes from the given file. - ::read:: Returns a string with all or a subset of bytes from the given file. - ::readlines:: Returns an array of strings, which are the lines from the given file. - #getbyte:: Returns the next 8-bit byte read from +self+ as an integer. - #getc:: Returns the next character read from +self+ as a string. - #gets:: Returns the line read from +self+. - #pread:: Returns all or the next _n_ bytes read from +self+, not updating the receiver's offset. - #read:: Returns all remaining or the next _n_ bytes read from +self+ for a given _n_. - #read_nonblock:: the next _n_ bytes read from +self+ for a given _n_, in non-block mode. - #readbyte:: Returns the next byte read from +self+; same as #getbyte, but raises an exception on end-of-file. - #readchar:: Returns the next character read from +self+; same as #getc, but raises an exception on end-of-file. - #readline:: Returns the next line read from +self+; same as #getline, but raises an exception of end-of-file. - #readlines:: Returns an array of all lines read read from +self+. - #readpartial:: Returns up to the given number of bytes from +self+. === Writing - ::binwrite:: Writes the given string to the file at the given filepath, in binary mode. - ::write:: Writes the given string to +self+. - {::<<}[#method-i-3C-3C]:: Appends the given string to +self+. - #print:: Prints last read line or given objects to +self+. - #printf:: Writes to +self+ based on the given format string and objects. - #putc:: Writes a character to +self+. - #puts:: Writes lines to +self+, making sure line ends with a newline. - #pwrite:: Writes the given string at the given offset, not updating the receiver's offset. - #write:: Writes one or more given strings to +self+. - #write_nonblock:: Writes one or more given strings to +self+ in non-blocking mode. === Positioning - #lineno:: Returns the current line number in +self+. - #lineno=:: Sets the line number is +self+. - #pos (aliased as #tell):: Returns the current byte offset in +self+. - #pos=:: Sets the byte offset in +self+. - #reopen:: Reassociates +self+ with a new or existing \IO stream. - #rewind:: Positions +self+ to the beginning of input. - #seek:: Sets the offset for +self+ relative to given position. === Iterating - ::foreach:: Yields each line of given file to the block. - #each (aliased as #each_line):: Calls the given block with each successive line in +self+. - #each_byte:: Calls the given block with each successive byte in +self+ as an integer. - #each_char:: Calls the given block with each successive character in +self+ as a string. - #each_codepoint:: Calls the given block with each successive codepoint in +self+ as an integer. === Settings - #autoclose=:: Sets whether +self+ auto-closes. - #binmode:: Sets +self+ to binary mode. - #close:: Closes +self+. - #close_on_exec=:: Sets the close-on-exec flag. - #close_read:: Closes +self+ for reading. - #close_write:: Closes +self+ for writing. - #set_encoding:: Sets the encoding for +self+. - #set_encoding_by_bom:: Sets the encoding for +self+, based on its Unicode byte-order-mark. - #sync=:: Sets the sync-mode to the given value. === Querying - #autoclose?:: Returns whether +self+ auto-closes. - #binmode?:: Returns whether +self+ is in binary mode. - #close_on_exec?:: Returns the close-on-exec flag for +self+. - #closed?:: Returns whether +self+ is closed. - #eof? (aliased as #eof):: Returns whether +self+ is at end-of-file. - #external_encoding:: Returns the external encoding object for +self+. - #fileno (aliased as #to_i):: Returns the integer file descriptor for +self+ - #internal_encoding:: Returns the internal encoding object for +self+. - #pid:: Returns the process ID of a child process associated with +self+, if +self+ was created by ::popen. - #stat:: Returns the File::Stat object containing status information for +self+. - #sync:: Returns whether +self+ is in sync-mode. - #tty (aliased as #isatty):: Returns whether +self+ is a terminal. === Buffering - #fdatasync:: Immediately writes all buffered data in +self+ to disk. - #flush:: Flushes any buffered data within +self+ to the underlying operating system. - #fsync:: Immediately writes all buffered data and attributes in +self+ to disk. - #ungetbyte:: Prepends buffer for +self+ with given integer byte or string. - #ungetc:: Prepends buffer for +self+ with given string. === Low-Level Access - ::sysopen:: Opens the file given by its path, returning the integer file descriptor. - #advise:: Announces the intention to access data from +self+ in a specific way. - #fcntl:: Passes a low-level command to the file specified by the given file descriptor. - #ioctl:: Passes a low-level command to the device specified by the given file descriptor. - #sysread:: Returns up to the next _n_ bytes read from self using a low-level read. - #sysseek:: Sets the offset for +self+. - #syswrite:: Writes the given string to +self+ using a low-level write. === Other - ::copy_stream:: Copies data from a source to a destination, each of which is a filepath or an \IO-like object. - ::try_convert:: Returns a new \IO object resulting from converting the given object. - #inspect:: Returns the string representation of +self+.;T;[;![;"I"FThe IO class is the basis for all input and output in Ruby. An I/O stream may be duplexed (that is, bidirectional), and so may use more than one native operating system stream. Many of the examples in this section use the File class, the only standard subclass of IO. The two classes are closely associated. Like the File class, the Socket library subclasses from IO (such as TCPSocket or UDPSocket). The Kernel#open method can create an IO (or File) object for these types of arguments: * A plain string represents a filename suitable for the underlying operating system. * A string starting with "|" indicates a subprocess. The remainder of the string following the "|" is invoked as a process with appropriate input/output channels connected to it. * A string equal to "|-" will create another Ruby instance as a subprocess. The IO may be opened with different file modes (read-only, write-only) and encodings for proper conversion. See IO.new for these options. See Kernel#open for details of the various command formats described above. IO.popen, the Open3 library, or Process#spawn may also be used to communicate with subprocesses through an IO. Ruby will convert pathnames between different operating system conventions if possible. For instance, on a Windows system the filename "/gumby/ruby/test.rb" will be opened as "\gumby\ruby\test.rb". When specifying a Windows-style filename in a Ruby string, remember to escape the backslashes: "C:\\gumby\\ruby\\test.rb" Our examples here will use the Unix-style forward slashes; File::ALT_SEPARATOR can be used to get the platform-specific separator character. The global constant ARGF (also accessible as $<) provides an IO-like stream which allows access to all files mentioned on the command line (or STDIN if no files are mentioned). ARGF#path and its alias ARGF#filename are provided to access the name of the file currently being read. == io/console The io/console extension provides methods for interacting with the console. The console can be accessed from IO.console or the standard input/output/error IO objects. Requiring io/console adds the following methods: * IO::console * IO#raw * IO#raw! * IO#cooked * IO#cooked! * IO#getch * IO#echo= * IO#echo? * IO#noecho * IO#winsize * IO#winsize= * IO#iflush * IO#ioflush * IO#oflush Example: require 'io/console' rows, columns = $stdout.winsize puts "Your screen is #{columns} wide and #{rows} tall" == Example Files Many examples here use these filenames and their corresponding files: - t.txt: A text-only file that is assumed to exist via: text = <<~EOT This is line one. This is the second line. This is the third line. EOT File.write('t.txt', text) - t.dat: A data file that is assumed to exist via: data = "\u9990\u9991\u9992\u9993\u9994" f = File.open('t.dat', 'wb:UTF-16') f.write(data) f.close - t.rus: A Russian-language text file that is assumed to exist via: File.write('t.rus', "\u{442 435 441 442}") - t.tmp: A file that is assumed _not_ to exist. == Modes A number of \IO method calls must or may specify a _mode_ for the stream; the mode determines how stream is to be accessible, including: - Whether the stream is to be read-only, write-only, or read-write. - Whether the stream is positioned at its beginning or its end. - Whether the stream treats data as text-only or binary. - The external and internal encodings. === Mode Specified as an \Integer When +mode+ is an integer it must be one or more (combined by bitwise OR (|) of the modes defined in File::Constants: - +File::RDONLY+: Open for reading only. - +File::WRONLY+: Open for writing only. - +File::RDWR+: Open for reading and writing. - +File::APPEND+: Open for appending only. - +File::CREAT+: Create file if it does not exist. - +File::EXCL+: Raise an exception if +File::CREAT+ is given and the file exists. Examples: File.new('t.txt', File::RDONLY) File.new('t.tmp', File::RDWR | File::CREAT | File::EXCL) Note: Method IO#set_encoding does not allow the mode to be specified as an integer. === Mode Specified As a \String When +mode+ is a string it must begin with one of the following: - 'r': Read-only stream, positioned at the beginning; the stream cannot be changed to writable. - 'w': Write-only stream, positioned at the beginning; the stream cannot be changed to readable. - 'a': Write-only stream, positioned at the end; every write appends to the end; the stream cannot be changed to readable. - 'r+': Read-write stream, positioned at the beginning. - 'w+': Read-write stream, positioned at the end. - 'a+': Read-write stream, positioned at the end. For a writable file stream (that is, any except read-only), the file is truncated to zero if it exists, and is created if it does not exist. Examples: File.open('t.txt', 'r') File.open('t.tmp', 'w') Either of the following may be suffixed to any of the above: - 't': Text data; sets the default external encoding to +Encoding::UTF_8+; on Windows, enables conversion between EOL and CRLF. - 'b': Binary data; sets the default external encoding to +Encoding::ASCII_8BIT+; on Windows, suppresses conversion between EOL and CRLF. If neither is given, the stream defaults to text data. Examples: File.open('t.txt', 'rt') File.open('t.dat', 'rb') The following may be suffixed to any writable mode above: - 'x': Creates the file if it does not exist; raises an exception if the file exists. Example: File.open('t.tmp', 'wx') Finally, the mode string may specify encodings -- either external encoding only or both external and internal encodings -- by appending one or both encoding names, separated by colons: f = File.new('t.dat', 'rb') f.external_encoding # => # f.internal_encoding # => nil f = File.new('t.dat', 'rb:UTF-16') f.external_encoding # => # f.internal_encoding # => nil f = File.new('t.dat', 'rb:UTF-16:UTF-16') f.external_encoding # => # f.internal_encoding # => # The numerous encoding names are available in array Encoding.name_list: Encoding.name_list.size # => 175 Encoding.name_list.take(3) # => ["ASCII-8BIT", "UTF-8", "US-ASCII"] == Encodings When the external encoding is set, strings read are tagged by that encoding when reading, and strings written are converted to that encoding when writing. When both external and internal encodings are set, strings read are converted from external to internal encoding, and strings written are converted from internal to external encoding. For further details about transcoding input and output, see Encoding. If the external encoding is 'BOM|UTF-8', 'BOM|UTF-16LE' or 'BOM|UTF16-BE', Ruby checks for a Unicode BOM in the input document to help determine the encoding. For UTF-16 encodings the file open mode must be binary. If the BOM is found, it is stripped and the external encoding from the BOM is used. Note that the BOM-style encoding option is case insensitive, so 'bom|utf-8' is also valid.) == Open Options A number of \IO methods accept an optional parameter +opts+, which determines how a new stream is to be opened: - +:mode+: Stream mode. - +:flags+: \Integer file open flags; If +mode+ is also given, the two are bitwise-ORed. - +:external_encoding+: External encoding for the stream. - +:internal_encoding+: Internal encoding for the stream. '-' is a synonym for the default internal encoding. If the value is +nil+ no conversion occurs. - +:encoding+: Specifies external and internal encodings as 'extern:intern'. - +:textmode+: If a truthy value, specifies the mode as text-only, binary otherwise. - +:binmode+: If a truthy value, specifies the mode as binary, text-only otherwise. - +:autoclose+: If a truthy value, specifies that the +fd+ will close when the stream closes; otherwise it remains open. Also available are the options offered in String#encode, which may control conversion between external internal encoding. == Getline Options A number of \IO methods accept optional keyword arguments that determine how a stream is to be treated: - +:chomp+: If +true+, line separators are omitted; default is +false+. == Position An \IO stream has a _position_, which is the non-negative integer offset (in bytes) in the stream where the next read or write will occur. Note that a text stream may have multi-byte characters, so a text stream whose position is +n+ (_bytes_) may not have +n+ _characters_ preceding the current position -- there may be fewer. A new stream is initially positioned: - At the beginning (position +0+) if its mode is 'r', 'w', or 'r+'. - At the end (position self.size) if its mode is 'a', 'w+', or 'a+'. Methods to query the position: - IO#tell and its alias IO#pos return the position for an open stream. - IO#eof? and its alias IO#eof return whether the position is at the end of a readable stream. Reading from a stream usually changes its position: f = File.open('t.txt') f.tell # => 0 f.readline # => "This is line one.\n" f.tell # => 19 f.readline # => "This is the second line.\n" f.tell # => 45 f.eof? # => false f.readline # => "Here's the third line.\n" f.eof? # => true Writing to a stream usually changes its position: f = File.open('t.tmp', 'w') f.tell # => 0 f.write('foo') # => 3 f.tell # => 3 f.write('bar') # => 3 f.tell # => 6 Iterating over a stream usually changes its position: f = File.open('t.txt') f.each do |line| p "position=#{f.pos} eof?=#{f.eof?} line=#{line}" end Output: "position=19 eof?=false line=This is line one.\n" "position=45 eof?=false line=This is the second line.\n" "position=70 eof?=true line=This is the third line.\n" The position may also be changed by certain other methods: - IO#pos= and IO#seek change the position to a specified offset. - IO#rewind changes the position to the beginning. == Line Number A readable \IO stream has a _line_ _number_, which is the non-negative integer line number in the stream where the next read will occur. A new stream is initially has line number +0+. \Method IO#lineno returns the line number. Reading lines from a stream usually changes its line number: f = File.open('t.txt', 'r') f.lineno # => 0 f.readline # => "This is line one.\n" f.lineno # => 1 f.readline # => "This is the second line.\n" f.lineno # => 2 f.readline # => "Here's the third line.\n" f.lineno # => 3 f.eof? # => true Iterating over lines in a stream usually changes its line number: f = File.open('t.txt') f.each_line do |line| p "position=#{f.pos} eof?=#{f.eof?} line=#{line}" end Output: "position=19 eof?=false line=This is line one.\n" "position=45 eof?=false line=This is the second line.\n" "position=70 eof?=true line=This is the third line.\n" == What's Here First, what's elsewhere. \Class \IO: - Inherits from {class Object}[Object.html#class-Object-label-What-27s+Here]. - Includes {module Enumerable}[Enumerable.html#module-Enumerable-label-What-27s+Here], which provides dozens of additional methods. Here, class \IO provides methods that are useful for: - {Creating}[#class-IO-label-Creating] - {Reading}[#class-IO-label-Reading] - {Writing}[#class-IO-label-Writing] - {Positioning}[#class-IO-label-Positioning] - {Iterating}[#class-IO-label-Iterating] - {Settings}[#class-IO-label-Settings] - {Querying}[#class-IO-label-Querying] - {Buffering}[#class-IO-label-Buffering] - {Low-Level Access}[#class-IO-label-Low-Level+Access] - {Other}[#class-IO-label-Other] === Creating - ::new (aliased as ::for_fd):: Creates and returns a new \IO object for the given integer file descriptor. - ::open:: Creates a new \IO object. - ::pipe:: Creates a connected pair of reader and writer \IO objects. - ::popen:: Creates an \IO object to interact with a subprocess. - ::select:: Selects which given \IO instances are ready for reading, writing, or have pending exceptions. === Reading - ::binread:: Returns a binary string with all or a subset of bytes from the given file. - ::read:: Returns a string with all or a subset of bytes from the given file. - ::readlines:: Returns an array of strings, which are the lines from the given file. - #getbyte:: Returns the next 8-bit byte read from +self+ as an integer. - #getc:: Returns the next character read from +self+ as a string. - #gets:: Returns the line read from +self+. - #pread:: Returns all or the next _n_ bytes read from +self+, not updating the receiver's offset. - #read:: Returns all remaining or the next _n_ bytes read from +self+ for a given _n_. - #read_nonblock:: the next _n_ bytes read from +self+ for a given _n_, in non-block mode. - #readbyte:: Returns the next byte read from +self+; same as #getbyte, but raises an exception on end-of-file. - #readchar:: Returns the next character read from +self+; same as #getc, but raises an exception on end-of-file. - #readline:: Returns the next line read from +self+; same as #getline, but raises an exception of end-of-file. - #readlines:: Returns an array of all lines read read from +self+. - #readpartial:: Returns up to the given number of bytes from +self+. === Writing - ::binwrite:: Writes the given string to the file at the given filepath, in binary mode. - ::write:: Writes the given string to +self+. - {::<<}[#method-i-3C-3C]:: Appends the given string to +self+. - #print:: Prints last read line or given objects to +self+. - #printf:: Writes to +self+ based on the given format string and objects. - #putc:: Writes a character to +self+. - #puts:: Writes lines to +self+, making sure line ends with a newline. - #pwrite:: Writes the given string at the given offset, not updating the receiver's offset. - #write:: Writes one or more given strings to +self+. - #write_nonblock:: Writes one or more given strings to +self+ in non-blocking mode. === Positioning - #lineno:: Returns the current line number in +self+. - #lineno=:: Sets the line number is +self+. - #pos (aliased as #tell):: Returns the current byte offset in +self+. - #pos=:: Sets the byte offset in +self+. - #reopen:: Reassociates +self+ with a new or existing \IO stream. - #rewind:: Positions +self+ to the beginning of input. - #seek:: Sets the offset for +self+ relative to given position. === Iterating - ::foreach:: Yields each line of given file to the block. - #each (aliased as #each_line):: Calls the given block with each successive line in +self+. - #each_byte:: Calls the given block with each successive byte in +self+ as an integer. - #each_char:: Calls the given block with each successive character in +self+ as a string. - #each_codepoint:: Calls the given block with each successive codepoint in +self+ as an integer. === Settings - #autoclose=:: Sets whether +self+ auto-closes. - #binmode:: Sets +self+ to binary mode. - #close:: Closes +self+. - #close_on_exec=:: Sets the close-on-exec flag. - #close_read:: Closes +self+ for reading. - #close_write:: Closes +self+ for writing. - #set_encoding:: Sets the encoding for +self+. - #set_encoding_by_bom:: Sets the encoding for +self+, based on its Unicode byte-order-mark. - #sync=:: Sets the sync-mode to the given value. === Querying - #autoclose?:: Returns whether +self+ auto-closes. - #binmode?:: Returns whether +self+ is in binary mode. - #close_on_exec?:: Returns the close-on-exec flag for +self+. - #closed?:: Returns whether +self+ is closed. - #eof? (aliased as #eof):: Returns whether +self+ is at end-of-file. - #external_encoding:: Returns the external encoding object for +self+. - #fileno (aliased as #to_i):: Returns the integer file descriptor for +self+ - #internal_encoding:: Returns the internal encoding object for +self+. - #pid:: Returns the process ID of a child process associated with +self+, if +self+ was created by ::popen. - #stat:: Returns the File::Stat object containing status information for +self+. - #sync:: Returns whether +self+ is in sync-mode. - #tty (aliased as #isatty):: Returns whether +self+ is a terminal. === Buffering - #fdatasync:: Immediately writes all buffered data in +self+ to disk. - #flush:: Flushes any buffered data within +self+ to the underlying operating system. - #fsync:: Immediately writes all buffered data and attributes in +self+ to disk. - #ungetbyte:: Prepends buffer for +self+ with given integer byte or string. - #ungetc:: Prepends buffer for +self+ with given string. === Low-Level Access - ::sysopen:: Opens the file given by its path, returning the integer file descriptor. - #advise:: Announces the intention to access data from +self+ in a specific way. - #fcntl:: Passes a low-level command to the file specified by the given file descriptor. - #ioctl:: Passes a low-level command to the device specified by the given file descriptor. - #sysread:: Returns up to the next _n_ bytes read from self using a low-level read. - #sysseek:: Sets the offset for +self+. - #syswrite:: Writes the given string to +self+ using a low-level write. === Other - ::copy_stream:: Copies data from a source to a destination, each of which is a filepath or an \IO-like object. - ::try_convert:: Returns a new \IO object resulting from converting the given object. - #inspect:: Returns the string representation of +self+. ;T;#0;$@kL;.F;/o;0;1T;2iA5;3i17;Bi;%@;&I"IO;F;'@;&I"IO::WaitReadable;F; @VL; IC;{;IC;{;T;IC;{;T;T;{;[;[[@9Hi ;F;:SSLErrorWaitReadable;;;;;[;{;IC; " ;T;[;![;"@;#0;$@VL;%@J;&I"'OpenSSL::SSL::SSLErrorWaitReadable;F;'@BLo; ;IC;[; @t; IC;[; @t; IC;[@L; @t; IC;{;IC;{;T;IC;{;T;T;{;[;[[@9Hi ;F;:SSLErrorWaitWritable;;;;;[;{;IC; " ;T;[;![;"@;#0;$@t;%@J;&I"'OpenSSL::SSL::SSLErrorWaitWritable;F;'@BLo; ;IC;[$o;4;5F;6;;;;&I")OpenSSL::SSL::SSLContext#ssl_timeout;F;7[;[[@9Hi ;F;:ssl_timeout;;;[;{;IC; " ;T;[;![;"@;#0;$@t;%@t;:I"def ssl_timeout;To;4;5F;6;;;;&I"*OpenSSL::SSL::SSLContext#ssl_timeout=;F;7[;[[@9Hi ;F;:ssl_timeout=;;;[;{;IC; " ;T;[;![;"@;#0;$@t;%@t;:I"def ssl_timeout=;To;4;5F;6;;;;&I"6OpenSSL::SSL::SSLContext#set_minmax_proto_version;F;7[[I" min_v;T0[I" max_v;T0;[[@9Hi;T;:set_minmax_proto_version;0;[;{;IC; "cSets the minimum and maximum supported protocol versions. See #min_version= and #max_version=. ;T;[o;= ;>I" overload;F;?0;;s;@0;:I"'set_minmax_proto_version(min, max);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@u;![;"I"@return [nil];T;#0;$@u;.F;Bi;C0;7[[I"min;T0[I"max;T0;$@u;![;"I"Sets the minimum and maximum supported protocol versions. See #min_version= and #max_version=. @overload set_minmax_proto_version(min, max) @return [nil];T;#0;$@u;.F;/o;0;1T;2i;3i;%@t;9I"static VALUE ossl_sslctx_set_minmax_proto_version(VALUE self, VALUE min_v, VALUE max_v) { SSL_CTX *ctx; int min, max; GetSSLCTX(self, ctx); min = parse_proto_version(min_v); max = parse_proto_version(max_v); #ifdef HAVE_SSL_CTX_SET_MIN_PROTO_VERSION if (!SSL_CTX_set_min_proto_version(ctx, min)) ossl_raise(eSSLError, "SSL_CTX_set_min_proto_version"); if (!SSL_CTX_set_max_proto_version(ctx, max)) ossl_raise(eSSLError, "SSL_CTX_set_max_proto_version"); #else { unsigned long sum = 0, opts = 0; int i; static const struct { int ver; unsigned long opts; } options_map[] = { { SSL2_VERSION, SSL_OP_NO_SSLv2 }, { SSL3_VERSION, SSL_OP_NO_SSLv3 }, { TLS1_VERSION, SSL_OP_NO_TLSv1 }, { TLS1_1_VERSION, SSL_OP_NO_TLSv1_1 }, { TLS1_2_VERSION, SSL_OP_NO_TLSv1_2 }, # if defined(TLS1_3_VERSION) { TLS1_3_VERSION, SSL_OP_NO_TLSv1_3 }, # endif }; for (i = 0; i < numberof(options_map); i++) { sum |= options_map[i].opts; if ((min && min > options_map[i].ver) || (max && max < options_map[i].ver)) { opts |= options_map[i].opts; } } SSL_CTX_clear_options(ctx, sum); SSL_CTX_set_options(ctx, opts); } #endif return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%OpenSSL::SSL::SSLContext#ciphers;F;7[;[[@9Hi;T;: ciphers;0;[;{;IC; ";The list of cipher suites configured for this context. ;T;[o;= ;>I" overload;F;?0;;t;@0;:I" ciphers;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@*u;![;"I"@return [Array];T;#0;$@*u;.F;Bi;C0;7[;$@*u;![;"I"aThe list of cipher suites configured for this context. @overload ciphers @return [Array];T;#0;$@*u;.F;/o;0;1T;2i;3i;%@t;9I"static VALUE ossl_sslctx_get_ciphers(VALUE self) { SSL_CTX *ctx; STACK_OF(SSL_CIPHER) *ciphers; const SSL_CIPHER *cipher; VALUE ary; int i, num; GetSSLCTX(self, ctx); ciphers = SSL_CTX_get_ciphers(ctx); if (!ciphers) return rb_ary_new(); num = sk_SSL_CIPHER_num(ciphers); ary = rb_ary_new2(num); for(i = 0; i < num; i++){ cipher = sk_SSL_CIPHER_value(ciphers, i); rb_ary_push(ary, ossl_ssl_cipher_to_ary(cipher)); } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::SSL::SSLContext#ciphers=;F;7[[I"v;T0;[[@9Hi;T;: ciphers=;0;[;{;IC; "5ctx.ciphers = [name, ...] ctx.ciphers = [[name, version, bits, alg_bits], ...] Sets the list of available cipher suites for this context. Note in a server context some ciphers require the appropriate certificates. For example, an RSA cipher suite can only be chosen when an RSA certificate is available. ;T;[;![;"I": ctx.ciphers = [name, ...] ctx.ciphers = [[name, version, bits, alg_bits], ...] Sets the list of available cipher suites for this context. Note in a server context some ciphers require the appropriate certificates. For example, an RSA cipher suite can only be chosen when an RSA certificate is available. ;T;#0;$@Eu;.F;/o;0;1T;2i;3i;%@t;9I"static VALUE ossl_sslctx_set_ciphers(VALUE self, VALUE v) { SSL_CTX *ctx; VALUE str, elem; int i; rb_check_frozen(self); if (NIL_P(v)) return v; else if (RB_TYPE_P(v, T_ARRAY)) { str = rb_str_new(0, 0); for (i = 0; i < RARRAY_LEN(v); i++) { elem = rb_ary_entry(v, i); if (RB_TYPE_P(elem, T_ARRAY)) elem = rb_ary_entry(elem, 0); elem = rb_String(elem); rb_str_append(str, elem); if (i < RARRAY_LEN(v)-1) rb_str_cat2(str, ":"); } } else { str = v; StringValue(str); } GetSSLCTX(self, ctx); if (!SSL_CTX_set_cipher_list(ctx, StringValueCStr(str))) { ossl_raise(eSSLError, "SSL_CTX_set_cipher_list"); } return v; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%OpenSSL::SSL::SSLContext#tmp_dh=;F;7[[I"arg;T0;[[@9Hi;T;: tmp_dh=;0;[;{;IC; "Sets DH parameters used for ephemeral DH key exchange. This is relevant for servers only. +pkey+ is an instance of OpenSSL::PKey::DH. Note that key components contained in the key object, if any, are ignored. The server will always generate a new key pair for each handshake. Added in version 3.0. See also the man page SSL_set0_tmp_dh_pkey(3). Example: ctx = OpenSSL::SSL::SSLContext.new ctx.tmp_dh = OpenSSL::DH.generate(2048) svr = OpenSSL::SSL::SSLServer.new(tcp_svr, ctx) Thread.new { svr.accept } ;T;[o;= ;>I" overload;F;?0;;v;@0;:I"tmp_dh=(pkey);T;IC; ";T;[;![;"I";T;#0;$@Uu;.F;Bi;C0;7[[I" pkey;T0;$@Uu;![;"I"Sets DH parameters used for ephemeral DH key exchange. This is relevant for servers only. +pkey+ is an instance of OpenSSL::PKey::DH. Note that key components contained in the key object, if any, are ignored. The server will always generate a new key pair for each handshake. Added in version 3.0. See also the man page SSL_set0_tmp_dh_pkey(3). Example: ctx = OpenSSL::SSL::SSLContext.new ctx.tmp_dh = OpenSSL::DH.generate(2048) svr = OpenSSL::SSL::SSLServer.new(tcp_svr, ctx) Thread.new { svr.accept } @overload tmp_dh=(pkey);T;#0;$@Uu;.F;/o;0;1T;2i;3i;%@t;9I"static VALUE ossl_sslctx_set_tmp_dh(VALUE self, VALUE arg) { SSL_CTX *ctx; EVP_PKEY *pkey; rb_check_frozen(self); GetSSLCTX(self, ctx); pkey = GetPKeyPtr(arg); if (EVP_PKEY_base_id(pkey) != EVP_PKEY_DH) rb_raise(eSSLError, "invalid pkey type %s (expected DH)", OBJ_nid2sn(EVP_PKEY_base_id(pkey))); #ifdef HAVE_SSL_SET0_TMP_DH_PKEY if (!SSL_CTX_set0_tmp_dh_pkey(ctx, pkey)) ossl_raise(eSSLError, "SSL_CTX_set0_tmp_dh_pkey"); EVP_PKEY_up_ref(pkey); #else if (!SSL_CTX_set_tmp_dh(ctx, EVP_PKEY_get0_DH(pkey))) ossl_raise(eSSLError, "SSL_CTX_set_tmp_dh"); #endif return arg; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*OpenSSL::SSL::SSLContext#ecdh_curves=;F;7[[I"arg;T0;[[@9Hi3;T;:ecdh_curves=;0;[;{;IC; "Sets the list of "supported elliptic curves" for this context. For a TLS client, the list is directly used in the Supported Elliptic Curves Extension. For a server, the list is used by OpenSSL to determine the set of shared curves. OpenSSL will pick the most appropriate one from it. === Example ctx1 = OpenSSL::SSL::SSLContext.new ctx1.ecdh_curves = "X25519:P-256:P-224" svr = OpenSSL::SSL::SSLServer.new(tcp_svr, ctx1) Thread.new { svr.accept } ctx2 = OpenSSL::SSL::SSLContext.new ctx2.ecdh_curves = "P-256" cli = OpenSSL::SSL::SSLSocket.new(tcp_sock, ctx2) cli.connect p cli.tmp_key.group.curve_name # => "prime256v1" (is an alias for NIST P-256) ;T;[o;= ;>I" overload;F;?0;;w;@0;:I"ecdh_curves=(curve_list);T;IC; ";T;[;![;"I";T;#0;$@ou;.F;Bi;C0;7[[I"curve_list;T0;$@ou;![;"I"Sets the list of "supported elliptic curves" for this context. For a TLS client, the list is directly used in the Supported Elliptic Curves Extension. For a server, the list is used by OpenSSL to determine the set of shared curves. OpenSSL will pick the most appropriate one from it. === Example ctx1 = OpenSSL::SSL::SSLContext.new ctx1.ecdh_curves = "X25519:P-256:P-224" svr = OpenSSL::SSL::SSLServer.new(tcp_svr, ctx1) Thread.new { svr.accept } ctx2 = OpenSSL::SSL::SSLContext.new ctx2.ecdh_curves = "P-256" cli = OpenSSL::SSL::SSLSocket.new(tcp_sock, ctx2) cli.connect p cli.tmp_key.group.curve_name # => "prime256v1" (is an alias for NIST P-256) @overload ecdh_curves=(curve_list);T;#0;$@ou;.F;/o;0;1T;2i;3i0;%@t;9I"static VALUE ossl_sslctx_set_ecdh_curves(VALUE self, VALUE arg) { SSL_CTX *ctx; rb_check_frozen(self); GetSSLCTX(self, ctx); StringValueCStr(arg); if (!SSL_CTX_set1_curves_list(ctx, RSTRING_PTR(arg))) ossl_raise(eSSLError, NULL); return arg; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",OpenSSL::SSL::SSLContext#security_level;F;7[;[[@9HiL;T;:security_level;0;[;{;IC; "dReturns the security level for the context. See also OpenSSL::SSL::SSLContext#security_level=. ;T;[o;= ;>I" overload;F;?0;;x;@0;:I"security_level;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@u;![;"I"@return [Integer];T;#0;$@u;.F;Bi;C0;7[;$@u;![;"I"Returns the security level for the context. See also OpenSSL::SSL::SSLContext#security_level=. @overload security_level @return [Integer];T;#0;$@u;.F;/o;0;1T;2iD;3iJ;%@t;9I"static VALUE ossl_sslctx_get_security_level(VALUE self) { SSL_CTX *ctx; GetSSLCTX(self, ctx); #if defined(HAVE_SSL_CTX_GET_SECURITY_LEVEL) return INT2NUM(SSL_CTX_get_security_level(ctx)); #else (void)ctx; return INT2FIX(0); #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"-OpenSSL::SSL::SSLContext#security_level=;F;7[[I" value;T0;[[@9Hin;T;:security_level=;0;[;{;IC; "Sets the security level for the context. OpenSSL limits parameters according to the level. The "parameters" include: ciphersuites, curves, key sizes, certificate signature algorithms, protocol version and so on. For example, level 1 rejects parameters offering below 80 bits of security, such as ciphersuites using MD5 for the MAC or RSA keys shorter than 1024 bits. Note that attempts to set such parameters with insufficient security are also blocked. You need to lower the level first. This feature is not supported in OpenSSL < 1.1.0, and setting the level to other than 0 will raise NotImplementedError. Level 0 means everything is permitted, the same behavior as previous versions of OpenSSL. See the manpage of SSL_CTX_set_security_level(3) for details. ;T;[o;= ;>I" overload;F;?0;;y;@0;:I"security_level=(integer);T;IC; ";T;[;![;"I";T;#0;$@u;.F;Bi;C0;7[[I" integer;T0;$@u;![;"I" Sets the security level for the context. OpenSSL limits parameters according to the level. The "parameters" include: ciphersuites, curves, key sizes, certificate signature algorithms, protocol version and so on. For example, level 1 rejects parameters offering below 80 bits of security, such as ciphersuites using MD5 for the MAC or RSA keys shorter than 1024 bits. Note that attempts to set such parameters with insufficient security are also blocked. You need to lower the level first. This feature is not supported in OpenSSL < 1.1.0, and setting the level to other than 0 will raise NotImplementedError. Level 0 means everything is permitted, the same behavior as previous versions of OpenSSL. See the manpage of SSL_CTX_set_security_level(3) for details. @overload security_level=(integer);T;#0;$@u;.F;/o;0;1T;2i[;3ik;%@t;9I"static VALUE ossl_sslctx_set_security_level(VALUE self, VALUE value) { SSL_CTX *ctx; rb_check_frozen(self); GetSSLCTX(self, ctx); #if defined(HAVE_SSL_CTX_GET_SECURITY_LEVEL) SSL_CTX_set_security_level(ctx, NUM2INT(value)); #else (void)ctx; if (NUM2INT(value) != 0) ossl_raise(rb_eNotImpError, "setting security level to other than 0 is " "not supported in this version of OpenSSL"); #endif return value; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"2OpenSSL::SSL::SSLContext#enable_fallback_scsv;F;7[;[[@9Hi;T;:enable_fallback_scsv;0;[;{;IC; "?Activate TLS_FALLBACK_SCSV for this context. See RFC 7507. ;T;[o;= ;>I" overload;F;?0;;z;@0;:I"enable_fallback_scsv();T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@u;![;"I"@return [nil];T;#0;$@u;.F;Bi;C0;7[;$@u;![;"I"rActivate TLS_FALLBACK_SCSV for this context. See RFC 7507. @overload enable_fallback_scsv() @return [nil];T;#0;$@u;.F;/o;0;1T;2i;3i;%@t;9I"static VALUE ossl_sslctx_enable_fallback_scsv(VALUE self) { SSL_CTX *ctx; GetSSLCTX(self, ctx); SSL_CTX_set_mode(ctx, SSL_MODE_SEND_FALLBACK_SCSV); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"-OpenSSL::SSL::SSLContext#add_certificate;F;7[[@90;[[@9Hi;T;;B;0;[;{;IC; "hAdds a certificate to the context. _pkey_ must be a corresponding private key with _certificate_. Multiple certificates with different public key type can be added by repeated calls of this method, and OpenSSL will choose the most appropriate certificate during the handshake. #cert=, #key=, and #extra_chain_cert= are old accessor methods for setting certificate and internally call this method. === Parameters _certificate_:: A certificate. An instance of OpenSSL::X509::Certificate. _pkey_:: The private key for _certificate_. An instance of OpenSSL::PKey::PKey. _extra_certs_:: Optional. An array of OpenSSL::X509::Certificate. When sending a certificate chain, the certificates specified by this are sent following _certificate_, in the order in the array. === Example rsa_cert = OpenSSL::X509::Certificate.new(...) rsa_pkey = OpenSSL::PKey.read(...) ca_intermediate_cert = OpenSSL::X509::Certificate.new(...) ctx.add_certificate(rsa_cert, rsa_pkey, [ca_intermediate_cert]) ecdsa_cert = ... ecdsa_pkey = ... another_ca_cert = ... ctx.add_certificate(ecdsa_cert, ecdsa_pkey, [another_ca_cert]) ;T;[o;= ;>I" overload;F;?0;;B;@0;:I"7add_certificate(certificate, pkey [, extra_certs]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@u;![;"I"@return [self];T;#0;$@u;.F;Bi;C0;7[[I"certificate;T0[I"pkey[, extra_certs];T0;$@u;![;"I"Adds a certificate to the context. _pkey_ must be a corresponding private key with _certificate_. Multiple certificates with different public key type can be added by repeated calls of this method, and OpenSSL will choose the most appropriate certificate during the handshake. #cert=, #key=, and #extra_chain_cert= are old accessor methods for setting certificate and internally call this method. === Parameters _certificate_:: A certificate. An instance of OpenSSL::X509::Certificate. _pkey_:: The private key for _certificate_. An instance of OpenSSL::PKey::PKey. _extra_certs_:: Optional. An array of OpenSSL::X509::Certificate. When sending a certificate chain, the certificates specified by this are sent following _certificate_, in the order in the array. === Example rsa_cert = OpenSSL::X509::Certificate.new(...) rsa_pkey = OpenSSL::PKey.read(...) ca_intermediate_cert = OpenSSL::X509::Certificate.new(...) ctx.add_certificate(rsa_cert, rsa_pkey, [ca_intermediate_cert]) ecdsa_cert = ... ecdsa_pkey = ... another_ca_cert = ... ctx.add_certificate(ecdsa_cert, ecdsa_pkey, [another_ca_cert]) @overload add_certificate(certificate, pkey [, extra_certs]) @return [self];T;#0;$@u;.F;/o;0;1T;2i;3i;%@t;9I"Kstatic VALUE ossl_sslctx_add_certificate(int argc, VALUE *argv, VALUE self) { VALUE cert, key, extra_chain_ary; SSL_CTX *ctx; X509 *x509; STACK_OF(X509) *extra_chain = NULL; EVP_PKEY *pkey, *pub_pkey; GetSSLCTX(self, ctx); rb_scan_args(argc, argv, "21", &cert, &key, &extra_chain_ary); rb_check_frozen(self); x509 = GetX509CertPtr(cert); pkey = GetPrivPKeyPtr(key); /* * The reference counter is bumped, and decremented immediately. * X509_get0_pubkey() is only available in OpenSSL >= 1.1.0. */ pub_pkey = X509_get_pubkey(x509); EVP_PKEY_free(pub_pkey); if (!pub_pkey) rb_raise(rb_eArgError, "certificate does not contain public key"); if (EVP_PKEY_eq(pub_pkey, pkey) != 1) rb_raise(rb_eArgError, "public key mismatch"); if (argc >= 3) extra_chain = ossl_x509_ary2sk(extra_chain_ary); if (!SSL_CTX_use_certificate(ctx, x509)) { sk_X509_pop_free(extra_chain, X509_free); ossl_raise(eSSLError, "SSL_CTX_use_certificate"); } if (!SSL_CTX_use_PrivateKey(ctx, pkey)) { sk_X509_pop_free(extra_chain, X509_free); ossl_raise(eSSLError, "SSL_CTX_use_PrivateKey"); } if (extra_chain && !SSL_CTX_set0_chain(ctx, extra_chain)) { sk_X509_pop_free(extra_chain, X509_free); ossl_raise(eSSLError, "SSL_CTX_set0_chain"); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::SSL::SSLContext#setup;F;7[;[[@9Hi;T;: setup;0;[;{;IC; "This method is called automatically when a new SSLSocket is created. However, it is not thread-safe and must be called before creating SSLSocket objects in a multi-threaded program. ;T;[o;= ;>I" overload;F;?0;;{;@0;:I" setup;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Qtrue #firstt time;T;$@u;![;"I"!@return [Qtrue # first time];T;#0;$@u;.F;Bi;C0;7[;$@uo;= ;>I" overload;F;?0;;{;@0;:I" setup;T;IC; ";T;[;![;"I";T;#0;$@u;.F;Bi;C0;7[;$@u;![;"I"This method is called automatically when a new SSLSocket is created. However, it is not thread-safe and must be called before creating SSLSocket objects in a multi-threaded program. @overload setup @return [Qtrue # first time] @overload setup;T;#0;$o;4;5F;6;;;;&I"$OpenSSL::SSL::SSLContext#freeze;F;7[;[[@9Hi ;F;;f;;;[;{;@v;%@t;9I"jstatic VALUE ossl_sslctx_setup(VALUE self) { SSL_CTX *ctx; X509 *cert = NULL, *client_ca = NULL; EVP_PKEY *key = NULL; char *ca_path = NULL, *ca_file = NULL; int verify_mode; long i; VALUE val; if(OBJ_FROZEN(self)) return Qnil; GetSSLCTX(self, ctx); #if !defined(OPENSSL_NO_DH) SSL_CTX_set_tmp_dh_callback(ctx, ossl_tmp_dh_callback); #endif #ifdef HAVE_SSL_CTX_SET_POST_HANDSHAKE_AUTH SSL_CTX_set_post_handshake_auth(ctx, 1); #endif val = rb_attr_get(self, id_i_cert_store); if (!NIL_P(val)) { X509_STORE *store = GetX509StorePtr(val); /* NO NEED TO DUP */ SSL_CTX_set_cert_store(ctx, store); X509_STORE_up_ref(store); } val = rb_attr_get(self, id_i_extra_chain_cert); if(!NIL_P(val)){ rb_block_call(val, rb_intern("each"), 0, 0, ossl_sslctx_add_extra_chain_cert_i, self); } /* private key may be bundled in certificate file. */ val = rb_attr_get(self, id_i_cert); cert = NIL_P(val) ? NULL : GetX509CertPtr(val); /* NO DUP NEEDED */ val = rb_attr_get(self, id_i_key); key = NIL_P(val) ? NULL : GetPrivPKeyPtr(val); /* NO DUP NEEDED */ if (cert && key) { if (!SSL_CTX_use_certificate(ctx, cert)) { /* Adds a ref => Safe to FREE */ ossl_raise(eSSLError, "SSL_CTX_use_certificate"); } if (!SSL_CTX_use_PrivateKey(ctx, key)) { /* Adds a ref => Safe to FREE */ ossl_raise(eSSLError, "SSL_CTX_use_PrivateKey"); } if (!SSL_CTX_check_private_key(ctx)) { ossl_raise(eSSLError, "SSL_CTX_check_private_key"); } } val = rb_attr_get(self, id_i_client_ca); if(!NIL_P(val)){ if (RB_TYPE_P(val, T_ARRAY)) { for(i = 0; i < RARRAY_LEN(val); i++){ client_ca = GetX509CertPtr(RARRAY_AREF(val, i)); if (!SSL_CTX_add_client_CA(ctx, client_ca)){ /* Copies X509_NAME => FREE it. */ ossl_raise(eSSLError, "SSL_CTX_add_client_CA"); } } } else{ client_ca = GetX509CertPtr(val); /* NO DUP NEEDED. */ if (!SSL_CTX_add_client_CA(ctx, client_ca)){ /* Copies X509_NAME => FREE it. */ ossl_raise(eSSLError, "SSL_CTX_add_client_CA"); } } } val = rb_attr_get(self, id_i_ca_file); ca_file = NIL_P(val) ? NULL : StringValueCStr(val); val = rb_attr_get(self, id_i_ca_path); ca_path = NIL_P(val) ? NULL : StringValueCStr(val); #ifdef HAVE_SSL_CTX_LOAD_VERIFY_FILE if (ca_file && !SSL_CTX_load_verify_file(ctx, ca_file)) ossl_raise(eSSLError, "SSL_CTX_load_verify_file"); if (ca_path && !SSL_CTX_load_verify_dir(ctx, ca_path)) ossl_raise(eSSLError, "SSL_CTX_load_verify_dir"); #else if(ca_file || ca_path){ if (!SSL_CTX_load_verify_locations(ctx, ca_file, ca_path)) rb_warning("can't set verify locations"); } #endif val = rb_attr_get(self, id_i_verify_mode); verify_mode = NIL_P(val) ? SSL_VERIFY_NONE : NUM2INT(val); SSL_CTX_set_verify(ctx, verify_mode, ossl_ssl_verify_callback); if (RTEST(rb_attr_get(self, id_i_client_cert_cb))) SSL_CTX_set_client_cert_cb(ctx, ossl_client_cert_cb); val = rb_attr_get(self, id_i_timeout); if(!NIL_P(val)) SSL_CTX_set_timeout(ctx, NUM2LONG(val)); val = rb_attr_get(self, id_i_verify_depth); if(!NIL_P(val)) SSL_CTX_set_verify_depth(ctx, NUM2INT(val)); #ifndef OPENSSL_NO_NEXTPROTONEG val = rb_attr_get(self, id_i_npn_protocols); if (!NIL_P(val)) { VALUE encoded = ssl_encode_npn_protocols(val); rb_ivar_set(self, id_npn_protocols_encoded, encoded); SSL_CTX_set_next_protos_advertised_cb(ctx, ssl_npn_advertise_cb, (void *)self); OSSL_Debug("SSL NPN advertise callback added"); } if (RTEST(rb_attr_get(self, id_i_npn_select_cb))) { SSL_CTX_set_next_proto_select_cb(ctx, ssl_npn_select_cb, (void *) self); OSSL_Debug("SSL NPN select callback added"); } #endif val = rb_attr_get(self, id_i_alpn_protocols); if (!NIL_P(val)) { VALUE rprotos = ssl_encode_npn_protocols(val); /* returns 0 on success */ if (SSL_CTX_set_alpn_protos(ctx, (unsigned char *)RSTRING_PTR(rprotos), RSTRING_LENINT(rprotos))) ossl_raise(eSSLError, "SSL_CTX_set_alpn_protos"); OSSL_Debug("SSL ALPN values added"); } if (RTEST(rb_attr_get(self, id_i_alpn_select_cb))) { SSL_CTX_set_alpn_select_cb(ctx, ssl_alpn_select_cb, (void *) self); OSSL_Debug("SSL ALPN select callback added"); } rb_obj_freeze(self); val = rb_attr_get(self, id_i_session_id_context); if (!NIL_P(val)){ StringValue(val); if (!SSL_CTX_set_session_id_context(ctx, (unsigned char *)RSTRING_PTR(val), RSTRING_LENINT(val))){ ossl_raise(eSSLError, "SSL_CTX_set_session_id_context"); } } if (RTEST(rb_attr_get(self, id_i_session_get_cb))) { SSL_CTX_sess_set_get_cb(ctx, ossl_sslctx_session_get_cb); OSSL_Debug("SSL SESSION get callback added"); } if (RTEST(rb_attr_get(self, id_i_session_new_cb))) { SSL_CTX_sess_set_new_cb(ctx, ossl_sslctx_session_new_cb); OSSL_Debug("SSL SESSION new callback added"); } if (RTEST(rb_attr_get(self, id_i_session_remove_cb))) { SSL_CTX_sess_set_remove_cb(ctx, ossl_sslctx_session_remove_cb); OSSL_Debug("SSL SESSION remove callback added"); } val = rb_attr_get(self, id_i_servername_cb); if (!NIL_P(val)) { SSL_CTX_set_tlsext_servername_callback(ctx, ssl_servername_cb); OSSL_Debug("SSL TLSEXT servername callback added"); } return Qtrue; };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@t;9I"jstatic VALUE ossl_sslctx_setup(VALUE self) { SSL_CTX *ctx; X509 *cert = NULL, *client_ca = NULL; EVP_PKEY *key = NULL; char *ca_path = NULL, *ca_file = NULL; int verify_mode; long i; VALUE val; if(OBJ_FROZEN(self)) return Qnil; GetSSLCTX(self, ctx); #if !defined(OPENSSL_NO_DH) SSL_CTX_set_tmp_dh_callback(ctx, ossl_tmp_dh_callback); #endif #ifdef HAVE_SSL_CTX_SET_POST_HANDSHAKE_AUTH SSL_CTX_set_post_handshake_auth(ctx, 1); #endif val = rb_attr_get(self, id_i_cert_store); if (!NIL_P(val)) { X509_STORE *store = GetX509StorePtr(val); /* NO NEED TO DUP */ SSL_CTX_set_cert_store(ctx, store); X509_STORE_up_ref(store); } val = rb_attr_get(self, id_i_extra_chain_cert); if(!NIL_P(val)){ rb_block_call(val, rb_intern("each"), 0, 0, ossl_sslctx_add_extra_chain_cert_i, self); } /* private key may be bundled in certificate file. */ val = rb_attr_get(self, id_i_cert); cert = NIL_P(val) ? NULL : GetX509CertPtr(val); /* NO DUP NEEDED */ val = rb_attr_get(self, id_i_key); key = NIL_P(val) ? NULL : GetPrivPKeyPtr(val); /* NO DUP NEEDED */ if (cert && key) { if (!SSL_CTX_use_certificate(ctx, cert)) { /* Adds a ref => Safe to FREE */ ossl_raise(eSSLError, "SSL_CTX_use_certificate"); } if (!SSL_CTX_use_PrivateKey(ctx, key)) { /* Adds a ref => Safe to FREE */ ossl_raise(eSSLError, "SSL_CTX_use_PrivateKey"); } if (!SSL_CTX_check_private_key(ctx)) { ossl_raise(eSSLError, "SSL_CTX_check_private_key"); } } val = rb_attr_get(self, id_i_client_ca); if(!NIL_P(val)){ if (RB_TYPE_P(val, T_ARRAY)) { for(i = 0; i < RARRAY_LEN(val); i++){ client_ca = GetX509CertPtr(RARRAY_AREF(val, i)); if (!SSL_CTX_add_client_CA(ctx, client_ca)){ /* Copies X509_NAME => FREE it. */ ossl_raise(eSSLError, "SSL_CTX_add_client_CA"); } } } else{ client_ca = GetX509CertPtr(val); /* NO DUP NEEDED. */ if (!SSL_CTX_add_client_CA(ctx, client_ca)){ /* Copies X509_NAME => FREE it. */ ossl_raise(eSSLError, "SSL_CTX_add_client_CA"); } } } val = rb_attr_get(self, id_i_ca_file); ca_file = NIL_P(val) ? NULL : StringValueCStr(val); val = rb_attr_get(self, id_i_ca_path); ca_path = NIL_P(val) ? NULL : StringValueCStr(val); #ifdef HAVE_SSL_CTX_LOAD_VERIFY_FILE if (ca_file && !SSL_CTX_load_verify_file(ctx, ca_file)) ossl_raise(eSSLError, "SSL_CTX_load_verify_file"); if (ca_path && !SSL_CTX_load_verify_dir(ctx, ca_path)) ossl_raise(eSSLError, "SSL_CTX_load_verify_dir"); #else if(ca_file || ca_path){ if (!SSL_CTX_load_verify_locations(ctx, ca_file, ca_path)) rb_warning("can't set verify locations"); } #endif val = rb_attr_get(self, id_i_verify_mode); verify_mode = NIL_P(val) ? SSL_VERIFY_NONE : NUM2INT(val); SSL_CTX_set_verify(ctx, verify_mode, ossl_ssl_verify_callback); if (RTEST(rb_attr_get(self, id_i_client_cert_cb))) SSL_CTX_set_client_cert_cb(ctx, ossl_client_cert_cb); val = rb_attr_get(self, id_i_timeout); if(!NIL_P(val)) SSL_CTX_set_timeout(ctx, NUM2LONG(val)); val = rb_attr_get(self, id_i_verify_depth); if(!NIL_P(val)) SSL_CTX_set_verify_depth(ctx, NUM2INT(val)); #ifndef OPENSSL_NO_NEXTPROTONEG val = rb_attr_get(self, id_i_npn_protocols); if (!NIL_P(val)) { VALUE encoded = ssl_encode_npn_protocols(val); rb_ivar_set(self, id_npn_protocols_encoded, encoded); SSL_CTX_set_next_protos_advertised_cb(ctx, ssl_npn_advertise_cb, (void *)self); OSSL_Debug("SSL NPN advertise callback added"); } if (RTEST(rb_attr_get(self, id_i_npn_select_cb))) { SSL_CTX_set_next_proto_select_cb(ctx, ssl_npn_select_cb, (void *) self); OSSL_Debug("SSL NPN select callback added"); } #endif val = rb_attr_get(self, id_i_alpn_protocols); if (!NIL_P(val)) { VALUE rprotos = ssl_encode_npn_protocols(val); /* returns 0 on success */ if (SSL_CTX_set_alpn_protos(ctx, (unsigned char *)RSTRING_PTR(rprotos), RSTRING_LENINT(rprotos))) ossl_raise(eSSLError, "SSL_CTX_set_alpn_protos"); OSSL_Debug("SSL ALPN values added"); } if (RTEST(rb_attr_get(self, id_i_alpn_select_cb))) { SSL_CTX_set_alpn_select_cb(ctx, ssl_alpn_select_cb, (void *) self); OSSL_Debug("SSL ALPN select callback added"); } rb_obj_freeze(self); val = rb_attr_get(self, id_i_session_id_context); if (!NIL_P(val)){ StringValue(val); if (!SSL_CTX_set_session_id_context(ctx, (unsigned char *)RSTRING_PTR(val), RSTRING_LENINT(val))){ ossl_raise(eSSLError, "SSL_CTX_set_session_id_context"); } } if (RTEST(rb_attr_get(self, id_i_session_get_cb))) { SSL_CTX_sess_set_get_cb(ctx, ossl_sslctx_session_get_cb); OSSL_Debug("SSL SESSION get callback added"); } if (RTEST(rb_attr_get(self, id_i_session_new_cb))) { SSL_CTX_sess_set_new_cb(ctx, ossl_sslctx_session_new_cb); OSSL_Debug("SSL SESSION new callback added"); } if (RTEST(rb_attr_get(self, id_i_session_remove_cb))) { SSL_CTX_sess_set_remove_cb(ctx, ossl_sslctx_session_remove_cb); OSSL_Debug("SSL SESSION remove callback added"); } val = rb_attr_get(self, id_i_servername_cb); if (!NIL_P(val)) { SSL_CTX_set_tlsext_servername_callback(ctx, ssl_servername_cb); OSSL_Debug("SSL TLSEXT servername callback added"); } return Qtrue; };T;:@!v;;T@vo;u;[[@9Hi ;F;:SESSION_CACHE_OFF;;w;;;[;{;IC; ",No session caching for client or server ;T;[;![;"I"-No session caching for client or server ;T;#0;$@$v;.F;/o;0;1T;2i ;3i ;%@t;&I"0OpenSSL::SSL::SSLContext::SESSION_CACHE_OFF;F;xI"!LONG2NUM(SSL_SESS_CACHE_OFF);To;u;[[@9Hi ;F;:SESSION_CACHE_CLIENT;;w;;;[;{;IC; "+doesn't actually do anything in 0.9.8e ;T;[;![;"I"+doesn't actually do anything in 0.9.8e;T;#0;$@0v;.F;/o;0;1T;2i ;3i ;%@t;&I"3OpenSSL::SSL::SSLContext::SESSION_CACHE_CLIENT;F;xI"$LONG2NUM(SSL_SESS_CACHE_CLIENT);To;u;[[@9Hi ;F;:SESSION_CACHE_SERVER;;w;;;[;{;IC; "3Server sessions are added to the session cache ;T;[;![;"I"4Server sessions are added to the session cache ;T;#0;$@Never automatically store sessions in the internal store. ;T;[;![;"I"?Never automatically store sessions in the internal store. ;T;#0;$@lv;.F;/o;0;1T;2i ;3i ;%@t;&I">OpenSSL::SSL::SSLContext::SESSION_CACHE_NO_INTERNAL_STORE;F;xI"/LONG2NUM(SSL_SESS_CACHE_NO_INTERNAL_STORE);To;u;[[@9Hi ;F;:SESSION_CACHE_NO_INTERNAL;;w;;;[;{;IC; "WEnables both SESSION_CACHE_NO_INTERNAL_LOOKUP and SESSION_CACHE_NO_INTERNAL_STORE. ;T;[;![;"I"XEnables both SESSION_CACHE_NO_INTERNAL_LOOKUP and SESSION_CACHE_NO_INTERNAL_STORE. ;T;#0;$@xv;.F;/o;0;1T;2i ;3i ;%@t;&I"8OpenSSL::SSL::SSLContext::SESSION_CACHE_NO_INTERNAL;F;xI")LONG2NUM(SSL_SESS_CACHE_NO_INTERNAL);To;4;5F;6;;;;&I")OpenSSL::SSL::SSLContext#session_add;F;7[[I"arg;T0;[[@9Hi;T;:session_add;0;[;{;IC; ")Adds _session_ to the session cache. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"session_add(session);T;IC; ";T;[;![;"I";T;#0;$@v;.F;Bi;C0;7[[I" session;T0;$@v;![;"I"JAdds _session_ to the session cache. @overload session_add(session);T;#0;$@v;.F;/o;0;1T;2i;3i;%@t;9I"static VALUE ossl_sslctx_session_add(VALUE self, VALUE arg) { SSL_CTX *ctx; SSL_SESSION *sess; GetSSLCTX(self, ctx); GetSSLSession(arg, sess); return SSL_CTX_add_session(ctx, sess) == 1 ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",OpenSSL::SSL::SSLContext#session_remove;F;7[[I"arg;T0;[[@9Hi;T;:session_remove;0;[;{;IC; ".Removes _session_ from the session cache. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"session_remove(session);T;IC; ";T;[;![;"I";T;#0;$@v;.F;Bi;C0;7[[I" session;T0;$@v;![;"I"RRemoves _session_ from the session cache. @overload session_remove(session);T;#0;$@v;.F;/o;0;1T;2i;3i;%@t;9I"static VALUE ossl_sslctx_session_remove(VALUE self, VALUE arg) { SSL_CTX *ctx; SSL_SESSION *sess; GetSSLCTX(self, ctx); GetSSLSession(arg, sess); return SSL_CTX_remove_session(ctx, sess) == 1 ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"0OpenSSL::SSL::SSLContext#session_cache_mode;F;7[;[[@9Hi;T;:session_cache_mode;0;[;{;IC; "$The current session cache mode. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"session_cache_mode;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@v;![;"I"@return [Integer];T;#0;$@v;.F;Bi;C0;7[;$@v;![;"I"WThe current session cache mode. @overload session_cache_mode @return [Integer];T;#0;$@v;.F;/o;0;1T;2i ;3i ;%@t;9I"static VALUE ossl_sslctx_get_session_cache_mode(VALUE self) { SSL_CTX *ctx; GetSSLCTX(self, ctx); return LONG2NUM(SSL_CTX_get_session_cache_mode(ctx)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"1OpenSSL::SSL::SSLContext#session_cache_mode=;F;7[[I"arg;T0;[[@9Hi!;T;:session_cache_mode=;0;[;{;IC; "Sets the SSL session cache mode. Bitwise-or together the desired SESSION_CACHE_* constants to set. See SSL_CTX_set_session_cache_mode(3) for details. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"!session_cache_mode=(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@v;![;"I"@return [Integer];T;#0;$@v;.F;Bi;C0;7[[I" integer;T0;$@v;![;"I"Sets the SSL session cache mode. Bitwise-or together the desired SESSION_CACHE_* constants to set. See SSL_CTX_set_session_cache_mode(3) for details. @overload session_cache_mode=(integer) @return [Integer];T;#0;$@v;.F;/o;0;1T;2i;3i;%@t;9I"static VALUE ossl_sslctx_set_session_cache_mode(VALUE self, VALUE arg) { SSL_CTX *ctx; GetSSLCTX(self, ctx); SSL_CTX_set_session_cache_mode(ctx, NUM2LONG(arg)); return arg; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"0OpenSSL::SSL::SSLContext#session_cache_size;F;7[;[[@9Hi4;T;:session_cache_size;0;[;{;IC; "`Returns the current session cache size. Zero is used to represent an unlimited cache size. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"session_cache_size;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@v;![;"I"@return [Integer];T;#0;$@v;.F;Bi;C0;7[;$@v;![;"I"Returns the current session cache size. Zero is used to represent an unlimited cache size. @overload session_cache_size @return [Integer];T;#0;$@v;.F;/o;0;1T;2i-;3i2;%@t;9I"static VALUE ossl_sslctx_get_session_cache_size(VALUE self) { SSL_CTX *ctx; GetSSLCTX(self, ctx); return LONG2NUM(SSL_CTX_sess_get_cache_size(ctx)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"1OpenSSL::SSL::SSLContext#session_cache_size=;F;7[[I"arg;T0;[[@9HiE;T;:session_cache_size=;0;[;{;IC; "Sets the session cache size. Returns the previously valid session cache size. Zero is used to represent an unlimited session cache size. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"!session_cache_size=(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ w;![;"I"@return [Integer];T;#0;$@ w;.F;Bi;C0;7[[I" integer;T0;$@ w;![;"I"Sets the session cache size. Returns the previously valid session cache size. Zero is used to represent an unlimited session cache size. @overload session_cache_size=(integer) @return [Integer];T;#0;$@ w;.F;/o;0;1T;2i>;3iC;%@t;9I"static VALUE ossl_sslctx_set_session_cache_size(VALUE self, VALUE arg) { SSL_CTX *ctx; GetSSLCTX(self, ctx); SSL_CTX_sess_set_cache_size(ctx, NUM2LONG(arg)); return arg; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"1OpenSSL::SSL::SSLContext#session_cache_stats;F;7[;[[@9Hig;T;:session_cache_stats;0;[;{;IC; "Returns a Hash containing the following keys: :accept:: Number of started SSL/TLS handshakes in server mode :accept_good:: Number of established SSL/TLS sessions in server mode :accept_renegotiate:: Number of start renegotiations in server mode :cache_full:: Number of sessions that were removed due to cache overflow :cache_hits:: Number of successfully reused connections :cache_misses:: Number of sessions proposed by clients that were not found in the cache :cache_num:: Number of sessions in the internal session cache :cb_hits:: Number of sessions retrieved from the external cache in server mode :connect:: Number of started SSL/TLS handshakes in client mode :connect_good:: Number of established SSL/TLS sessions in client mode :connect_renegotiate:: Number of start renegotiations in client mode :timeouts:: Number of sessions proposed by clients that were found in the cache but had expired due to timeouts ;T;[o;= ;>I" overload;F;?0;;;@0;:I"session_cache_stats;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@,w;![;"I"@return [Hash];T;#0;$@,w;.F;Bi;C0;7[;$@,w;![;"I"Returns a Hash containing the following keys: :accept:: Number of started SSL/TLS handshakes in server mode :accept_good:: Number of established SSL/TLS sessions in server mode :accept_renegotiate:: Number of start renegotiations in server mode :cache_full:: Number of sessions that were removed due to cache overflow :cache_hits:: Number of successfully reused connections :cache_misses:: Number of sessions proposed by clients that were not found in the cache :cache_num:: Number of sessions in the internal session cache :cb_hits:: Number of sessions retrieved from the external cache in server mode :connect:: Number of started SSL/TLS handshakes in client mode :connect_good:: Number of established SSL/TLS sessions in client mode :connect_renegotiate:: Number of start renegotiations in client mode :timeouts:: Number of sessions proposed by clients that were found in the cache but had expired due to timeouts @overload session_cache_stats @return [Hash];T;#0;$@,w;.F;/o;0;1T;2iQ;3ie;%@t;9I"9static VALUE ossl_sslctx_get_session_cache_stats(VALUE self) { SSL_CTX *ctx; VALUE hash; GetSSLCTX(self, ctx); hash = rb_hash_new(); rb_hash_aset(hash, ID2SYM(rb_intern("cache_num")), LONG2NUM(SSL_CTX_sess_number(ctx))); rb_hash_aset(hash, ID2SYM(rb_intern("connect")), LONG2NUM(SSL_CTX_sess_connect(ctx))); rb_hash_aset(hash, ID2SYM(rb_intern("connect_good")), LONG2NUM(SSL_CTX_sess_connect_good(ctx))); rb_hash_aset(hash, ID2SYM(rb_intern("connect_renegotiate")), LONG2NUM(SSL_CTX_sess_connect_renegotiate(ctx))); rb_hash_aset(hash, ID2SYM(rb_intern("accept")), LONG2NUM(SSL_CTX_sess_accept(ctx))); rb_hash_aset(hash, ID2SYM(rb_intern("accept_good")), LONG2NUM(SSL_CTX_sess_accept_good(ctx))); rb_hash_aset(hash, ID2SYM(rb_intern("accept_renegotiate")), LONG2NUM(SSL_CTX_sess_accept_renegotiate(ctx))); rb_hash_aset(hash, ID2SYM(rb_intern("cache_hits")), LONG2NUM(SSL_CTX_sess_hits(ctx))); rb_hash_aset(hash, ID2SYM(rb_intern("cb_hits")), LONG2NUM(SSL_CTX_sess_cb_hits(ctx))); rb_hash_aset(hash, ID2SYM(rb_intern("cache_misses")), LONG2NUM(SSL_CTX_sess_misses(ctx))); rb_hash_aset(hash, ID2SYM(rb_intern("cache_full")), LONG2NUM(SSL_CTX_sess_cache_full(ctx))); rb_hash_aset(hash, ID2SYM(rb_intern("timeouts")), LONG2NUM(SSL_CTX_sess_timeouts(ctx))); return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",OpenSSL::SSL::SSLContext#flush_sessions;F;7[[@90;[[@9Hi;T;:flush_sessions;0;[;{;IC; "HRemoves sessions in the internal cache that have expired at _time_. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"flush_sessions(time);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@Gw;![;"I"@return [self];T;#0;$@Gw;.F;Bi;C0;7[[I" time;T0;$@Gw;![;"I"zRemoves sessions in the internal cache that have expired at _time_. @overload flush_sessions(time) @return [self];T;#0;$@Gw;.F;/o;0;1T;2i;3i;%@t;9I"static VALUE ossl_sslctx_flush_sessions(int argc, VALUE *argv, VALUE self) { VALUE arg1; SSL_CTX *ctx; time_t tm = 0; rb_scan_args(argc, argv, "01", &arg1); GetSSLCTX(self, ctx); if (NIL_P(arg1)) { tm = time(0); } else if (rb_obj_is_instance_of(arg1, rb_cTime)) { tm = NUM2LONG(rb_funcall(arg1, rb_intern("to_i"), 0)); } else { ossl_raise(rb_eArgError, "arg must be Time or nil"); } SSL_CTX_flush_sessions(ctx, (long)tm); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%OpenSSL::SSL::SSLContext#options;F;7[;[[@9Hi;T;;;0;[;{;IC; ""Gets various OpenSSL options. ;T;[;![;"I"#Gets various OpenSSL options. ;T;#0;$@ew;.F;/o;0;1T;2i;3i;%@t;9I"static VALUE ossl_sslctx_get_options(VALUE self) { SSL_CTX *ctx; GetSSLCTX(self, ctx); /* * Do explicit cast because SSL_CTX_get_options() returned (signed) long in * OpenSSL before 1.1.0. */ return ULONG2NUM((unsigned long)SSL_CTX_get_options(ctx)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::SSL::SSLContext#options=;F;7[[I" options;T0;[[@9Hi;T;: options=;0;[;{;IC; ""Sets various OpenSSL options. ;T;[;![;"I"#Sets various OpenSSL options. ;T;#0;$@sw;.F;/o;0;1T;2i;3i;%@t;9I"\static VALUE ossl_sslctx_set_options(VALUE self, VALUE options) { SSL_CTX *ctx; rb_check_frozen(self); GetSSLCTX(self, ctx); SSL_CTX_clear_options(ctx, SSL_CTX_get_options(ctx)); if (NIL_P(options)) { SSL_CTX_set_options(ctx, SSL_OP_ALL); } else { SSL_CTX_set_options(ctx, NUM2ULONG(options)); } return self; };T;:I"static VALUE;T;;T; @t; IC;[; @t; IC;[; @t; IC;{;IC;{;T;IC;{;T;T;{@t;Y@t;Z@v;{;[;[[@9Hi [@9Hi ;T;:SSLContext;;;;;[;{;IC; " An SSLContext is used to set various options regarding certificates, algorithms, verification, session caching, etc. The SSLContext is used to create an SSLSocket. All attributes must be set before creating an SSLSocket as the SSLContext will be frozen afterward. ;T;[;![;"I"  An SSLContext is used to set various options regarding certificates, algorithms, verification, session caching, etc. The SSLContext is used to create an SSLSocket. All attributes must be set before creating an SSLSocket as the SSLContext will be frozen afterward. ;T;#0;$@t;.F;/o;0;1T;2i ;3i ;%@J;&I"OpenSSL::SSL::SSLContext;F;'@o; ;IC;[ o;4;5F;6;;;;&I"'OpenSSL::SSL::SSLSocket#initialize;F;7[[@90;[[@iF[@9Hi;T;;D;0;[;{;IC; "Creates a new SSL socket from _io_ which must be a real IO object (not an IO-like object that responds to read/write). If _ctx_ is provided the SSL Sockets initial params will be taken from the context. The OpenSSL::Buffering module provides additional IO methods. This method will freeze the SSLContext if one is provided; however, session management is still allowed in the frozen SSLContext. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I" new(io);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"aSSLSocket;T;$@w;![;"I"@return [aSSLSocket];T;#0;$@w;.F;Bi;C0;7[[I"io;T0;$@wo;= ;>I" overload;F;?0;;E;@0;:I"new(io, ctx);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"aSSLSocket;T;$@w;![;"I"@return [aSSLSocket];T;#0;$@w;.F;Bi;C0;7[[I"io;T0[I"ctx;T0;$@w;![;"I"Creates a new SSL socket from _io_ which must be a real IO object (not an IO-like object that responds to read/write). If _ctx_ is provided the SSL Sockets initial params will be taken from the context. The OpenSSL::Buffering module provides additional IO methods. This method will freeze the SSLContext if one is provided; however, session management is still allowed in the frozen SSLContext. @overload new(io) @return [aSSLSocket] @overload new(io, ctx) @return [aSSLSocket];T;#0;$@w;.F;/o;0;1T;2i;3i;%@w;9I"VALUE rb_f_notimplement(int argc, const VALUE *argv, VALUE obj, VALUE marker) { rb_notimplement(); UNREACHABLE_RETURN(Qnil); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"$OpenSSL::SSL::SSLSocket#connect;F;7[;[[@9Hi;T;: connect;0;[;{;IC; "2Initiates an SSL/TLS handshake with a server. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" connect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@w;![;"I"@return [self];T;#0;$@w;.F;Bi;C0;7[;$@w;![;"I"WInitiates an SSL/TLS handshake with a server. @overload connect @return [self];T;#0;$@w;.F;/o;0;1T;2i;3i;%@w;9I"static VALUE ossl_ssl_connect(VALUE self) { ossl_ssl_setup(self); return ossl_start_ssl(self, SSL_connect, "SSL_connect", Qfalse); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"-OpenSSL::SSL::SSLSocket#connect_nonblock;F;7[[@90;[[@9Hi;T;:connect_nonblock;0;[;{;IC; "Initiates the SSL/TLS handshake as a client in non-blocking manner. # emulates blocking connect begin ssl.connect_nonblock rescue IO::WaitReadable IO.select([s2]) retry rescue IO::WaitWritable IO.select(nil, [s2]) retry end By specifying a keyword argument _exception_ to +false+, you can indicate that connect_nonblock should not raise an IO::WaitReadable or IO::WaitWritable exception, but return the symbol +:wait_readable+ or +:wait_writable+ instead. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" connect_nonblock([options]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@w;![;"I"@return [self];T;#0;$@w;.F;Bi;C0;7[[I"[options];T0;$@w;![;"I" Initiates the SSL/TLS handshake as a client in non-blocking manner. # emulates blocking connect begin ssl.connect_nonblock rescue IO::WaitReadable IO.select([s2]) retry rescue IO::WaitWritable IO.select(nil, [s2]) retry end By specifying a keyword argument _exception_ to +false+, you can indicate that connect_nonblock should not raise an IO::WaitReadable or IO::WaitWritable exception, but return the symbol +:wait_readable+ or +:wait_writable+ instead. @overload connect_nonblock([options]) @return [self];T;#0;$@w;.F;/o;0;1T;2i;3i;%@w;9I"static VALUE ossl_ssl_connect_nonblock(int argc, VALUE *argv, VALUE self) { VALUE opts; rb_scan_args(argc, argv, "0:", &opts); ossl_ssl_setup(self); return ossl_start_ssl(self, SSL_connect, "SSL_connect", opts); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::SSL::SSLSocket#accept;F;7[;[[@9Hi;T;: accept;0;[;{;IC; "8Waits for a SSL/TLS client to initiate a handshake. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" accept;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@x;![;"I"@return [self];T;#0;$@x;.F;Bi;C0;7[;$@x;![;"I"\Waits for a SSL/TLS client to initiate a handshake. @overload accept @return [self];T;#0;$@x;.F;/o;0;1T;2i;3i;%@w;9I"static VALUE ossl_ssl_accept(VALUE self) { ossl_ssl_setup(self); return ossl_start_ssl(self, SSL_accept, "SSL_accept", Qfalse); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",OpenSSL::SSL::SSLSocket#accept_nonblock;F;7[[@90;[[@9Hi;T;:accept_nonblock;0;[;{;IC; "Initiates the SSL/TLS handshake as a server in non-blocking manner. # emulates blocking accept begin ssl.accept_nonblock rescue IO::WaitReadable IO.select([s2]) retry rescue IO::WaitWritable IO.select(nil, [s2]) retry end By specifying a keyword argument _exception_ to +false+, you can indicate that accept_nonblock should not raise an IO::WaitReadable or IO::WaitWritable exception, but return the symbol +:wait_readable+ or +:wait_writable+ instead. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"accept_nonblock([options]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@x;![;"I"@return [self];T;#0;$@x;.F;Bi;C0;7[[I"[options];T0;$@x;![;"I"Initiates the SSL/TLS handshake as a server in non-blocking manner. # emulates blocking accept begin ssl.accept_nonblock rescue IO::WaitReadable IO.select([s2]) retry rescue IO::WaitWritable IO.select(nil, [s2]) retry end By specifying a keyword argument _exception_ to +false+, you can indicate that accept_nonblock should not raise an IO::WaitReadable or IO::WaitWritable exception, but return the symbol +:wait_readable+ or +:wait_writable+ instead. @overload accept_nonblock([options]) @return [self];T;#0;$@x;.F;/o;0;1T;2i;3i;%@w;9I"static VALUE ossl_ssl_accept_nonblock(int argc, VALUE *argv, VALUE self) { VALUE opts; rb_scan_args(argc, argv, "0:", &opts); ossl_ssl_setup(self); return ossl_start_ssl(self, SSL_accept, "SSL_accept", opts); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$OpenSSL::SSL::SSLSocket#sysread;F;7[[@90;[[@9Hie;T;;};0;[;{;IC; "}Reads _length_ bytes from the SSL connection. If a pre-allocated _buffer_ is provided the data will be written into it. ;T;[o;= ;>I" overload;F;?0;;};@0;:I"sysread(length);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@9x;![;"I"@return [String];T;#0;$@9x;.F;Bi;C0;7[[I" length;T0;$@9xo;= ;>I" overload;F;?0;;};@0;:I"sysread(length, buffer);T;IC; ";T;[;![;"I";T;#0;$@9x;.F;Bi;C0;7[[I" length;T0[I" buffer;T0;$@9x;![;"I"Reads _length_ bytes from the SSL connection. If a pre-allocated _buffer_ is provided the data will be written into it. @overload sysread(length) @return [String] @overload sysread(length, buffer);T;#0;$@9x;.F;/o;0;1T;2i];3ic;%@w;9I"~static VALUE ossl_ssl_read(int argc, VALUE *argv, VALUE self) { return ossl_ssl_read_internal(argc, argv, self, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"-OpenSSL::SSL::SSLSocket#sysread_nonblock;F;7[[@90;[[@9Hix;T;:sysread_nonblock;0;[;{;IC; "UA non-blocking version of #sysread. Raises an SSLError if reading would block. If "exception: false" is passed, this method returns a symbol of :wait_readable, :wait_writable, or nil, rather than raising an exception. Reads _length_ bytes from the SSL connection. If a pre-allocated _buffer_ is provided the data will be written into it. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"sysread_nonblock(length);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@cx;![;"I"@return [String];T;#0;$@cx;.F;Bi;C0;7[[I" length;T0;$@cxo;= ;>I" overload;F;?0;;;@0;:I"%sysread_nonblock(length, buffer);T;IC; ";T;[;![;"I";T;#0;$@cx;.F;Bi;C0;7[[I" length;T0[I" buffer;T0;$@cxo;= ;>I" overload;F;?0;;;@0;:I"/sysread_nonblock(length[, buffer [, opts]);T;IC; ";T;[;![;"I";T;#0;$@cx;.F;Bi;C0;7[[I"length[, buffer [, opts]);T0;$@cx;![;"I"A non-blocking version of #sysread. Raises an SSLError if reading would block. If "exception: false" is passed, this method returns a symbol of :wait_readable, :wait_writable, or nil, rather than raising an exception. Reads _length_ bytes from the SSL connection. If a pre-allocated _buffer_ is provided the data will be written into it. @overload sysread_nonblock(length) @return [String] @overload sysread_nonblock(length, buffer) @overload sysread_nonblock(length[, buffer [, opts]);T;#0;$@cx;.F;/o;0;1T;2ik;3iv;%@w;9I"static VALUE ossl_ssl_read_nonblock(int argc, VALUE *argv, VALUE self) { return ossl_ssl_read_internal(argc, argv, self, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%OpenSSL::SSL::SSLSocket#syswrite;F;7[[I"str;T0;[[@9Hi;T;;|;0;[;{;IC; "+Writes _string_ to the SSL connection. ;T;[o;= ;>I" overload;F;?0;;|;@0;:I"syswrite(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@x;![;"I"@return [Integer];T;#0;$@x;.F;Bi;C0;7[[I" string;T0;$@x;![;"I"\Writes _string_ to the SSL connection. @overload syswrite(string) @return [Integer];T;#0;$@x;.F;/o;0;1T;2i;3i;%@w;9I"rstatic VALUE ossl_ssl_write(VALUE self, VALUE str) { return ossl_ssl_write_internal(self, str, Qfalse); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I".OpenSSL::SSL::SSLSocket#syswrite_nonblock;F;7[[@90;[[@9Hi;T;:syswrite_nonblock;0;[;{;IC; "pWrites _string_ to the SSL connection in a non-blocking manner. Raises an SSLError if writing would block. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"syswrite_nonblock(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@x;![;"I"@return [Integer];T;#0;$@x;.F;Bi;C0;7[[I" string;T0;$@x;![;"I"Writes _string_ to the SSL connection in a non-blocking manner. Raises an SSLError if writing would block. @overload syswrite_nonblock(string) @return [Integer];T;#0;$@x;.F;/o;0;1T;2i;3i;%@w;9I"static VALUE ossl_ssl_write_nonblock(int argc, VALUE *argv, VALUE self) { VALUE str, opts; rb_scan_args(argc, argv, "1:", &str, &opts); return ossl_ssl_write_internal(self, str, opts); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!OpenSSL::SSL::SSLSocket#stop;F;7[;[[@9Hi;T;;';0;[;{;IC; "[Sends "close notify" to the peer and tries to shut down the SSL connection gracefully. ;T;[o;= ;>I" overload;F;?0;;';@0;:I" stop;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@x;![;"I"@return [nil];T;#0;$@x;.F;Bi;C0;7[;$@x;![;"I"|Sends "close notify" to the peer and tries to shut down the SSL connection gracefully. @overload stop @return [nil];T;#0;$@x;.F;/o;0;1T;2i;3i;%@w;9I"static VALUE ossl_ssl_stop(VALUE self) { SSL *ssl; int ret; GetSSL(self, ssl); if (!ssl_started(ssl)) return Qnil; ret = SSL_shutdown(ssl); if (ret == 1) /* Have already received close_notify */ return Qnil; if (ret == 0) /* Sent close_notify, but we don't wait for reply */ return Qnil; /* * XXX: Something happened. Possibly it failed because the underlying socket * is not writable/readable, since it is in non-blocking mode. We should do * some proper error handling using SSL_get_error() and maybe retry, but we * can't block here. Give up for now. */ ossl_clear_error(); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!OpenSSL::SSL::SSLSocket#cert;F;7[;[[@9Hi;T;: cert;0;[;{;IC; "3The X509 certificate for this socket endpoint. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" cert;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@x;![;"I"@return [nil];T;#0;$@x;.F;Bi;C0;7[;$@x;![;"I"TThe X509 certificate for this socket endpoint. @overload cert @return [nil];T;#0;$@x;.F;/o;0;1T;2i;3i;%@w;9I"Nstatic VALUE ossl_ssl_get_cert(VALUE self) { SSL *ssl; X509 *cert = NULL; GetSSL(self, ssl); /* * Is this OpenSSL bug? Should add a ref? * TODO: Ask for. */ cert = SSL_get_certificate(ssl); /* NO DUPs => DON'T FREE. */ if (!cert) { return Qnil; } return ossl_x509_new(cert); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::SSL::SSLSocket#peer_cert;F;7[;[[@9Hi;T;:peer_cert;0;[;{;IC; "1The X509 certificate for this socket's peer. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"peer_cert;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@ y;![;"I"@return [nil];T;#0;$@ y;.F;Bi;C0;7[;$@ y;![;"I"WThe X509 certificate for this socket's peer. @overload peer_cert @return [nil];T;#0;$@ y;.F;/o;0;1T;2i ;3i;%@w;9I">static VALUE ossl_ssl_get_peer_cert(VALUE self) { SSL *ssl; X509 *cert = NULL; VALUE obj; GetSSL(self, ssl); cert = SSL_get_peer_certificate(ssl); /* Adds a ref => Safe to FREE. */ if (!cert) { return Qnil; } obj = ossl_x509_new(cert); X509_free(cert); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",OpenSSL::SSL::SSLSocket#peer_cert_chain;F;7[;[[@9Hi,;T;:peer_cert_chain;0;[;{;IC; "7The X509 certificate chain for this socket's peer. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"peer_cert_chain;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;TI"nil;T;$@%y;![;"I"@return [Array, nil];T;#0;$@%y;.F;Bi;C0;7[;$@%y;![;"I"jThe X509 certificate chain for this socket's peer. @overload peer_cert_chain @return [Array, nil];T;#0;$@%y;.F;/o;0;1T;2i&;3i*;%@w;9I"static VALUE ossl_ssl_get_peer_cert_chain(VALUE self) { SSL *ssl; STACK_OF(X509) *chain; X509 *cert; VALUE ary; int i, num; GetSSL(self, ssl); chain = SSL_get_peer_cert_chain(ssl); if(!chain) return Qnil; num = sk_X509_num(chain); ary = rb_ary_new2(num); for (i = 0; i < num; i++){ cert = sk_X509_value(chain, i); rb_ary_push(ary, ossl_x509_new(cert)); } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(OpenSSL::SSL::SSLSocket#ssl_version;F;7[;[[@9HiJ;T;:ssl_version;0;[;{;IC; "uReturns a String representing the SSL/TLS version that was negotiated for the connection, for example "TLSv1.2". ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ssl_version;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@Ay;![;"I"@return [String];T;#0;$@Ay;.F;Bi;C0;7[;$@Ay;![;"I"Returns a String representing the SSL/TLS version that was negotiated for the connection, for example "TLSv1.2". @overload ssl_version @return [String];T;#0;$@Ay;.F;/o;0;1T;2iC;3iH;%@w;9I"static VALUE ossl_ssl_get_version(VALUE self) { SSL *ssl; GetSSL(self, ssl); return rb_str_new2(SSL_get_version(ssl)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::SSL::SSLSocket#cipher;F;7[;[[@9Hi[;T;: cipher;0;[;{;IC; "nReturns the cipher suite actually used in the current session, or nil if no session has been established. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" cipher;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;TI" Array;T;$@\y;![;"I"@return [nil, Array];T;#0;$@\y;.F;Bi;C0;7[;$@\y;![;"I"Returns the cipher suite actually used in the current session, or nil if no session has been established. @overload cipher @return [nil, Array];T;#0;$@\y;.F;/o;0;1T;2iT;3iY;%@w;9I"static VALUE ossl_ssl_get_cipher(VALUE self) { SSL *ssl; const SSL_CIPHER *cipher; GetSSL(self, ssl); cipher = SSL_get_current_cipher(ssl); return cipher ? ossl_ssl_cipher_to_ary(cipher) : Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::SSL::SSLSocket#state;F;7[;[[@9Him;T;: state;0;[;{;IC; "YA description of the current connection state. This is for diagnostic purposes only. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" state;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@xy;![;"I"@return [String];T;#0;$@xy;.F;Bi;C0;7[;$@xy;![;"I"~A description of the current connection state. This is for diagnostic purposes only. @overload state @return [String];T;#0;$@xy;.F;/o;0;1T;2if;3ik;%@w;9I"static VALUE ossl_ssl_get_state(VALUE self) { SSL *ssl; VALUE ret; GetSSL(self, ssl); ret = rb_str_new2(SSL_state_string(ssl)); if (ruby_verbose) { rb_str_cat2(ret, ": "); rb_str_cat2(ret, SSL_state_string_long(ssl)); } return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$OpenSSL::SSL::SSLSocket#pending;F;7[;[[@9Hi;T;: pending;0;[;{;IC; "DThe number of bytes that are immediately available for reading. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" pending;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@y;![;"I"@return [Integer];T;#0;$@y;.F;Bi;C0;7[;$@y;![;"I"lThe number of bytes that are immediately available for reading. @overload pending @return [Integer];T;#0;$@y;.F;/o;0;1T;2i};3i;%@w;9I"static VALUE ossl_ssl_pending(VALUE self) { SSL *ssl; GetSSL(self, ssl); return INT2NUM(SSL_pending(ssl)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",OpenSSL::SSL::SSLSocket#session_reused?;F;7[;[[@9Hi;T;:session_reused?;0;[;{;IC; "LReturns +true+ if a reused session was negotiated during the handshake.;T;[o;= ;>I" overload;F;?0;;;@0;:I"session_reused?;T;IC; ";T;[;![;"I";T;#0;$@y;.F;Bi;C0;7[;$@yo;A ;>I" return;F;?@;0;@[@L;$@y;![;"I"hReturns +true+ if a reused session was negotiated during the handshake. @overload session_reused?;T;#0;$@y;.F;/o;0;1T;2i;3i;Bi;%@w;9I"static VALUE ossl_ssl_session_reused(VALUE self) { SSL *ssl; GetSSL(self, ssl); return SSL_session_reused(ssl) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%OpenSSL::SSL::SSLSocket#session=;F;7[[I" arg1;T0;[[@9Hi;T;: session=;0;[;{;IC; "DSets the Session to be used when the connection is established. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"session=(session);T;IC; ";T;[;![;"I";T;#0;$@y;.F;Bi;C0;7[[I" session;T0;$@y;![;"I"bSets the Session to be used when the connection is established. @overload session=(session);T;#0;$@y;.F;/o;0;1T;2i;3i;%@w;9I"static VALUE ossl_ssl_set_session(VALUE self, VALUE arg1) { SSL *ssl; SSL_SESSION *sess; GetSSL(self, ssl); GetSSLSession(arg1, sess); if (SSL_set_session(ssl, sess) != 1) ossl_raise(eSSLError, "SSL_set_session"); return arg1; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*OpenSSL::SSL::SSLSocket#verify_result;F;7[;[[@9Hi;T;:verify_result;0;[;{;IC; "Returns the result of the peer certificates verification. See verify(1) for error values and descriptions. If no peer certificate was presented X509_V_OK is returned. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"verify_result;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@y;![;"I"@return [Integer];T;#0;$@y;.F;Bi;C0;7[;$@y;![;"I"Returns the result of the peer certificates verification. See verify(1) for error values and descriptions. If no peer certificate was presented X509_V_OK is returned. @overload verify_result @return [Integer];T;#0;$@y;.F;/o;0;1T;2i;3i;%@w;9I"static VALUE ossl_ssl_get_verify_result(VALUE self) { SSL *ssl; GetSSL(self, ssl); return LONG2NUM(SSL_get_verify_result(ssl)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::SSL::SSLSocket#client_ca;F;7[;[[@9Hi ;T;:client_ca;0;[;{;IC; "EReturns the list of client CAs. Please note that in contrast to SSLContext#client_ca= no array of X509::Certificate is returned but X509::Name instances of the CA's subject distinguished name. In server mode, returns the list set by SSLContext#client_ca=. In client mode, returns the list of client CAs sent from the server. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"client_ca;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@y;![;"I"@return [Array];T;#0;$@y;.F;Bi;C0;7[;$@y;![;"I"mReturns the list of client CAs. Please note that in contrast to SSLContext#client_ca= no array of X509::Certificate is returned but X509::Name instances of the CA's subject distinguished name. In server mode, returns the list set by SSLContext#client_ca=. In client mode, returns the list of client CAs sent from the server. @overload client_ca @return [Array];T;#0;$@y;.F;/o;0;1T;2i ;3i ;%@w;9I"static VALUE ossl_ssl_get_client_ca_list(VALUE self) { SSL *ssl; STACK_OF(X509_NAME) *ca; GetSSL(self, ssl); ca = SSL_get_client_CA_list(ssl); return ossl_x509name_sk2ary(ca); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::SSL::SSLSocket#hostname=;F;7[[I"arg;T0;[[@9Hi;T;:hostname=;0;[;{;IC; "ZSets the server hostname used for SNI. This needs to be set before SSLSocket#connect. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"hostname=(hostname);T;IC; ";T;[;![;"I";T;#0;$@z;.F;Bi;C0;7[[I" hostname;T0;$@z;![;"I"zSets the server hostname used for SNI. This needs to be set before SSLSocket#connect. @overload hostname=(hostname);T;#0;$@z;.F;/o;0;1T;2i;3i;%@w;9I"estatic VALUE ossl_ssl_set_hostname(VALUE self, VALUE arg) { SSL *ssl; char *hostname = NULL; GetSSL(self, ssl); if (!NIL_P(arg)) hostname = StringValueCStr(arg); if (!SSL_set_tlsext_host_name(ssl, hostname)) ossl_raise(eSSLError, NULL); /* for SSLSocket#hostname */ rb_ivar_set(self, id_i_hostname, arg); return arg; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"-OpenSSL::SSL::SSLSocket#finished_message;F;7[;[[@9Hi;T;:finished_message;0;[;{;IC; "-Returns the last *Finished* message sent ;T;[o;= ;>I" overload;F;?0;;;@0;:I"finished_message;T;IC; ";T;[;![;"I";T;#0;$@1z;.F;Bi;C0;7[;$@1z;![;"I"KReturns the last *Finished* message sent @overload finished_message;T;#0;$@1z;.F;/o;0;1T;2i;3i;%@w;9I":static VALUE ossl_ssl_get_finished(VALUE self) { SSL *ssl; char sizer[1], *buf; size_t len; GetSSL(self, ssl); len = SSL_get_finished(ssl, sizer, 0); if (len == 0) return Qnil; buf = ALLOCA_N(char, len); SSL_get_finished(ssl, buf, len); return rb_str_new(buf, len); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"2OpenSSL::SSL::SSLSocket#peer_finished_message;F;7[;[[@9Hi ;T;:peer_finished_message;0;[;{;IC; "1Returns the last *Finished* message received ;T;[o;= ;>I" overload;F;?0;;;@0;:I"peer_finished_message;T;IC; ";T;[;![;"I";T;#0;$@Gz;.F;Bi;C0;7[;$@Gz;![;"I"TReturns the last *Finished* message received @overload peer_finished_message;T;#0;$@Gz;.F;/o;0;1T;2i;3i;%@w;9I"Istatic VALUE ossl_ssl_get_peer_finished(VALUE self) { SSL *ssl; char sizer[1], *buf; size_t len; GetSSL(self, ssl); len = SSL_get_peer_finished(ssl, sizer, 0); if (len == 0) return Qnil; buf = ALLOCA_N(char, len); SSL_get_peer_finished(ssl, buf, len); return rb_str_new(buf, len); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$OpenSSL::SSL::SSLSocket#tmp_key;F;7[;[[@9Hi_ ;T;: tmp_key;0;[;{;IC; "FReturns the ephemeral key used in case of forward secrecy cipher. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" tmp_key;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" PKey;TI"nil;T;$@]z;![;"I"@return [PKey, nil];T;#0;$@]z;.F;Bi;C0;7[;$@]z;![;"I"pReturns the ephemeral key used in case of forward secrecy cipher. @overload tmp_key @return [PKey, nil];T;#0;$@]z;.F;/o;0;1T;2iY ;3i] ;%@w;9I"static VALUE ossl_ssl_tmp_key(VALUE self) { SSL *ssl; EVP_PKEY *key; GetSSL(self, ssl); if (!SSL_get_server_tmp_key(ssl, &key)) return Qnil; return ossl_pkey_new(key); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*OpenSSL::SSL::SSLSocket#alpn_protocol;F;7[;[[@9HiI ;T;:alpn_protocol;0;[;{;IC; "cReturns the ALPN protocol string that was finally selected by the server during the handshake. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"alpn_protocol;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"String | nil;T;$@yz;![;"I"@return [String | nil];T;#0;$@yz;.F;Bi;C0;7[;$@yz;![;"I"Returns the ALPN protocol string that was finally selected by the server during the handshake. @overload alpn_protocol @return [String | nil];T;#0;$@yz;.F;/o;0;1T;2iB ;3iG ;%@w;9I"static VALUE ossl_ssl_alpn_protocol(VALUE self) { SSL *ssl; const unsigned char *out; unsigned int outlen; GetSSL(self, ssl); SSL_get0_alpn_selected(ssl, &out, &outlen); if (!outlen) return Qnil; else return rb_str_new((const char *) out, outlen); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I")OpenSSL::SSL::SSLSocket#npn_protocol;F;7[;[[@9Hi1 ;T;:npn_protocol;0;[;{;IC; "^Returns the protocol string that was finally selected by the client during the handshake. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"npn_protocol;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"String | nil;T;$@z;![;"I"@return [String | nil];T;#0;$@z;.F;Bi;C0;7[;$@z;![;"I"Returns the protocol string that was finally selected by the client during the handshake. @overload npn_protocol @return [String | nil];T;#0;$@z;.F;/o;0;1T;2i* ;3i/ ;%@w;9I" static VALUE ossl_ssl_npn_protocol(VALUE self) { SSL *ssl; const unsigned char *out; unsigned int outlen; GetSSL(self, ssl); SSL_get0_next_proto_negotiated(ssl, &out, &outlen); if (!outlen) return Qnil; else return rb_str_new((const char *) out, outlen); };T;:I"static VALUE;T;;T; @w; IC;[; @w; IC;[; @w; IC;{;IC;{;T;IC;{;T;T;{;[;[[@9Hi ;F;:SSLSocket;;;;;[;{;IC; " ;T;[;![;"@;#0;$@w;Bi;%@J;&I"OpenSSL::SSL::SSLSocket;F;'@o;u;[[@9Hi ;F;:VERIFY_NONE;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@z;%@J;&I"OpenSSL::SSL::VERIFY_NONE;F;xI"INT2NUM(SSL_VERIFY_NONE);To;u;[[@9Hi ;F;:VERIFY_PEER;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@z;%@J;&I"OpenSSL::SSL::VERIFY_PEER;F;xI"INT2NUM(SSL_VERIFY_PEER);To;u;[[@9Hi ;F;: VERIFY_FAIL_IF_NO_PEER_CERT;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@z;%@J;&I".OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT;F;xI"-INT2NUM(SSL_VERIFY_FAIL_IF_NO_PEER_CERT);To;u;[[@9Hi ;F;:VERIFY_CLIENT_ONCE;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@z;%@J;&I"%OpenSSL::SSL::VERIFY_CLIENT_ONCE;F;xI"$INT2NUM(SSL_VERIFY_CLIENT_ONCE);To;u;[[@9Hi ;F;: OP_ALL;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@z;%@J;&I"OpenSSL::SSL::OP_ALL;F;xI"ULONG2NUM(SSL_OP_ALL);To;u;[[@9Hi ;F;:OP_CLEANSE_PLAINTEXT;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@z;%@J;&I"'OpenSSL::SSL::OP_CLEANSE_PLAINTEXT;F;xI"(ULONG2NUM(SSL_OP_CLEANSE_PLAINTEXT);To;u;[[@9Hi ;F;:OP_LEGACY_SERVER_CONNECT;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@z;%@J;&I"+OpenSSL::SSL::OP_LEGACY_SERVER_CONNECT;F;xI",ULONG2NUM(SSL_OP_LEGACY_SERVER_CONNECT);To;u;[[@9Hi ;F;:OP_ENABLE_KTLS;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@{;%@J;&I"!OpenSSL::SSL::OP_ENABLE_KTLS;F;xI""ULONG2NUM(SSL_OP_ENABLE_KTLS);To;u;[[@9Hi ;F;:OP_TLSEXT_PADDING;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@{;%@J;&I"$OpenSSL::SSL::OP_TLSEXT_PADDING;F;xI"%ULONG2NUM(SSL_OP_TLSEXT_PADDING);To;u;[[@9Hi ;F;:OP_SAFARI_ECDHE_ECDSA_BUG;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@{;%@J;&I",OpenSSL::SSL::OP_SAFARI_ECDHE_ECDSA_BUG;F;xI"-ULONG2NUM(SSL_OP_SAFARI_ECDHE_ECDSA_BUG);To;u;[[@9Hi ;F;:OP_IGNORE_UNEXPECTED_EOF;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@"{;%@J;&I"+OpenSSL::SSL::OP_IGNORE_UNEXPECTED_EOF;F;xI",ULONG2NUM(SSL_OP_IGNORE_UNEXPECTED_EOF);To;u;[[@9Hi ;F;:"OP_ALLOW_CLIENT_RENEGOTIATION;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@,{;%@J;&I"0OpenSSL::SSL::OP_ALLOW_CLIENT_RENEGOTIATION;F;xI"1ULONG2NUM(SSL_OP_ALLOW_CLIENT_RENEGOTIATION);To;u;[[@9Hi ;F;:OP_DISABLE_TLSEXT_CA_NAMES;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@6{;%@J;&I"-OpenSSL::SSL::OP_DISABLE_TLSEXT_CA_NAMES;F;xI".ULONG2NUM(SSL_OP_DISABLE_TLSEXT_CA_NAMES);To;u;[[@9Hi ;F;:OP_ALLOW_NO_DHE_KEX;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@@{;%@J;&I"&OpenSSL::SSL::OP_ALLOW_NO_DHE_KEX;F;xI"'ULONG2NUM(SSL_OP_ALLOW_NO_DHE_KEX);To;u;[[@9Hi! ;F;:#OP_DONT_INSERT_EMPTY_FRAGMENTS;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@J{;%@J;&I"1OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS;F;xI"2ULONG2NUM(SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS);To;u;[[@9Hi" ;F;:OP_NO_TICKET;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@T{;%@J;&I"OpenSSL::SSL::OP_NO_TICKET;F;xI" ULONG2NUM(SSL_OP_NO_TICKET);To;u;[[@9Hi# ;F;:.OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@^{;%@J;&I" ;F;:OP_CRYPTOPRO_TLSEXT_BUG;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@{;%@J;&I"*OpenSSL::SSL::OP_CRYPTOPRO_TLSEXT_BUG;F;xI"+ULONG2NUM(SSL_OP_CRYPTOPRO_TLSEXT_BUG);To;u;[[@9HiB ;F;:OP_NO_QUERY_MTU;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@{;%@J;&I""OpenSSL::SSL::OP_NO_QUERY_MTU;F;xI"#ULONG2NUM(SSL_OP_NO_QUERY_MTU);To;u;[[@9HiC ;F;:OP_COOKIE_EXCHANGE;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@|;%@J;&I"%OpenSSL::SSL::OP_COOKIE_EXCHANGE;F;xI"&ULONG2NUM(SSL_OP_COOKIE_EXCHANGE);To;u;[[@9HiD ;F;:OP_CISCO_ANYCONNECT;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@|;%@J;&I"&OpenSSL::SSL::OP_CISCO_ANYCONNECT;F;xI"'ULONG2NUM(SSL_OP_CISCO_ANYCONNECT);To;u;[[@9HiH ;F;:OP_MICROSOFT_SESS_ID_BUG;;w;;;[;{;IC; "!Deprecated in OpenSSL 1.1.0. ;T;[;![;"I"!Deprecated in OpenSSL 1.1.0.;T;#0;$@|;.F;/o;0;1T;2iG ;3iG ;%@J;&I"+OpenSSL::SSL::OP_MICROSOFT_SESS_ID_BUG;F;xI",ULONG2NUM(SSL_OP_MICROSOFT_SESS_ID_BUG);To;u;[[@9HiJ ;F;:OP_NETSCAPE_CHALLENGE_BUG;;w;;;[;{;IC; "!Deprecated in OpenSSL 1.1.0. ;T;[;![;"I"!Deprecated in OpenSSL 1.1.0.;T;#0;$@(|;.F;/o;0;1T;2iI ;3iI ;%@J;&I",OpenSSL::SSL::OP_NETSCAPE_CHALLENGE_BUG;F;xI"-ULONG2NUM(SSL_OP_NETSCAPE_CHALLENGE_BUG);To;u;[[@9HiL ;F;:(OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG;;w;;;[;{;IC; "-Deprecated in OpenSSL 0.9.8q and 1.0.0c. ;T;[;![;"I"-Deprecated in OpenSSL 0.9.8q and 1.0.0c.;T;#0;$@4|;.F;/o;0;1T;2iK ;3iK ;%@J;&I"6OpenSSL::SSL::OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG;F;xI"7ULONG2NUM(SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG);To;u;[[@9HiN ;F;:#OP_SSLREF2_REUSE_CERT_TYPE_BUG;;w;;;[;{;IC; ",Deprecated in OpenSSL 1.0.1h and 1.0.2. ;T;[;![;"I",Deprecated in OpenSSL 1.0.1h and 1.0.2.;T;#0;$@@|;.F;/o;0;1T;2iM ;3iM ;%@J;&I"1OpenSSL::SSL::OP_SSLREF2_REUSE_CERT_TYPE_BUG;F;xI"2ULONG2NUM(SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG);To;u;[[@9HiP ;F;:"OP_MICROSOFT_BIG_SSLV3_BUFFER;;w;;;[;{;IC; "!Deprecated in OpenSSL 1.1.0. ;T;[;![;"I"!Deprecated in OpenSSL 1.1.0.;T;#0;$@L|;.F;/o;0;1T;2iO ;3iO ;%@J;&I"0OpenSSL::SSL::OP_MICROSOFT_BIG_SSLV3_BUFFER;F;xI"1ULONG2NUM(SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER);To;u;[[@9HiR ;F;:OP_MSIE_SSLV2_RSA_PADDING;;w;;;[;{;IC; "-Deprecated in OpenSSL 0.9.7h and 0.9.8b. ;T;[;![;"I"-Deprecated in OpenSSL 0.9.7h and 0.9.8b.;T;#0;$@X|;.F;/o;0;1T;2iQ ;3iQ ;%@J;&I",OpenSSL::SSL::OP_MSIE_SSLV2_RSA_PADDING;F;xI"-ULONG2NUM(SSL_OP_MSIE_SSLV2_RSA_PADDING);To;u;[[@9HiT ;F;: OP_SSLEAY_080_CLIENT_DH_BUG;;w;;;[;{;IC; "!Deprecated in OpenSSL 1.1.0. ;T;[;![;"I"!Deprecated in OpenSSL 1.1.0.;T;#0;$@d|;.F;/o;0;1T;2iS ;3iS ;%@J;&I".OpenSSL::SSL::OP_SSLEAY_080_CLIENT_DH_BUG;F;xI"/ULONG2NUM(SSL_OP_SSLEAY_080_CLIENT_DH_BUG);To;u;[[@9HiV ;F;:OP_TLS_D5_BUG;;w;;;[;{;IC; "!Deprecated in OpenSSL 1.1.0. ;T;[;![;"I"!Deprecated in OpenSSL 1.1.0.;T;#0;$@p|;.F;/o;0;1T;2iU ;3iU ;%@J;&I" OpenSSL::SSL::OP_TLS_D5_BUG;F;xI"!ULONG2NUM(SSL_OP_TLS_D5_BUG);To;u;[[@9HiX ;F;:OP_TLS_BLOCK_PADDING_BUG;;w;;;[;{;IC; "!Deprecated in OpenSSL 1.1.0. ;T;[;![;"I"!Deprecated in OpenSSL 1.1.0.;T;#0;$@||;.F;/o;0;1T;2iW ;3iW ;%@J;&I"+OpenSSL::SSL::OP_TLS_BLOCK_PADDING_BUG;F;xI",ULONG2NUM(SSL_OP_TLS_BLOCK_PADDING_BUG);To;u;[[@9HiZ ;F;:OP_SINGLE_ECDH_USE;;w;;;[;{;IC; "!Deprecated in OpenSSL 1.1.0. ;T;[;![;"I"!Deprecated in OpenSSL 1.1.0.;T;#0;$@|;.F;/o;0;1T;2iY ;3iY ;%@J;&I"%OpenSSL::SSL::OP_SINGLE_ECDH_USE;F;xI"&ULONG2NUM(SSL_OP_SINGLE_ECDH_USE);To;u;[[@9Hi\ ;F;:OP_SINGLE_DH_USE;;w;;;[;{;IC; "!Deprecated in OpenSSL 1.1.0. ;T;[;![;"I"!Deprecated in OpenSSL 1.1.0.;T;#0;$@|;.F;/o;0;1T;2i[ ;3i[ ;%@J;&I"#OpenSSL::SSL::OP_SINGLE_DH_USE;F;xI"$ULONG2NUM(SSL_OP_SINGLE_DH_USE);To;u;[[@9Hi^ ;F;:OP_EPHEMERAL_RSA;;w;;;[;{;IC; ",Deprecated in OpenSSL 1.0.1k and 1.0.2. ;T;[;![;"I",Deprecated in OpenSSL 1.0.1k and 1.0.2.;T;#0;$@|;.F;/o;0;1T;2i] ;3i] ;%@J;&I"#OpenSSL::SSL::OP_EPHEMERAL_RSA;F;xI"$ULONG2NUM(SSL_OP_EPHEMERAL_RSA);To;u;[[@9Hi` ;F;:OP_NO_SSLv2;;w;;;[;{;IC; "!Deprecated in OpenSSL 1.1.0. ;T;[;![;"I"!Deprecated in OpenSSL 1.1.0.;T;#0;$@|;.F;/o;0;1T;2i_ ;3i_ ;%@J;&I"OpenSSL::SSL::OP_NO_SSLv2;F;xI"ULONG2NUM(SSL_OP_NO_SSLv2);To;u;[[@9Hib ;F;:OP_PKCS1_CHECK_1;;w;;;[;{;IC; "!Deprecated in OpenSSL 1.0.1. ;T;[;![;"I"!Deprecated in OpenSSL 1.0.1.;T;#0;$@|;.F;/o;0;1T;2ia ;3ia ;%@J;&I"#OpenSSL::SSL::OP_PKCS1_CHECK_1;F;xI"$ULONG2NUM(SSL_OP_PKCS1_CHECK_1);To;u;[[@9Hid ;F;:OP_PKCS1_CHECK_2;;w;;;[;{;IC; "!Deprecated in OpenSSL 1.0.1. ;T;[;![;"I"!Deprecated in OpenSSL 1.0.1.;T;#0;$@|;.F;/o;0;1T;2ic ;3ic ;%@J;&I"#OpenSSL::SSL::OP_PKCS1_CHECK_2;F;xI"$ULONG2NUM(SSL_OP_PKCS1_CHECK_2);To;u;[[@9Hif ;F;:OP_NETSCAPE_CA_DN_BUG;;w;;;[;{;IC; "!Deprecated in OpenSSL 1.1.0. ;T;[;![;"I"!Deprecated in OpenSSL 1.1.0.;T;#0;$@|;.F;/o;0;1T;2ie ;3ie ;%@J;&I"(OpenSSL::SSL::OP_NETSCAPE_CA_DN_BUG;F;xI")ULONG2NUM(SSL_OP_NETSCAPE_CA_DN_BUG);To;u;[[@9Hih ;F;:'OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG;;w;;;[;{;IC; "!Deprecated in OpenSSL 1.1.0. ;T;[;![;"I"!Deprecated in OpenSSL 1.1.0.;T;#0;$@|;.F;/o;0;1T;2ig ;3ig ;%@J;&I"5OpenSSL::SSL::OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG;F;xI"6ULONG2NUM(SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG);To;u;[[@9Hip ;F;:SSL2_VERSION;;w;;;[;{;IC; " SSL 2.0 ;T;[;![;"I" SSL 2.0;T;#0;$@|;.F;/o;0;1T;2io ;3io ;%@J;&I"OpenSSL::SSL::SSL2_VERSION;F;xI"INT2NUM(SSL2_VERSION);To;u;[[@9Hir ;F;:SSL3_VERSION;;w;;;[;{;IC; " SSL 3.0 ;T;[;![;"I" SSL 3.0;T;#0;$@|;.F;/o;0;1T;2iq ;3iq ;%@J;&I"OpenSSL::SSL::SSL3_VERSION;F;xI"INT2NUM(SSL3_VERSION);To;u;[[@9Hit ;F;:TLS1_VERSION;;w;;;[;{;IC; " TLS 1.0 ;T;[;![;"I" TLS 1.0;T;#0;$@};.F;/o;0;1T;2is ;3is ;%@J;&I"OpenSSL::SSL::TLS1_VERSION;F;xI"INT2NUM(TLS1_VERSION);To;u;[[@9Hiv ;F;:TLS1_1_VERSION;;w;;;[;{;IC; " TLS 1.1 ;T;[;![;"I" TLS 1.1;T;#0;$@ };.F;/o;0;1T;2iu ;3iu ;%@J;&I"!OpenSSL::SSL::TLS1_1_VERSION;F;xI"INT2NUM(TLS1_1_VERSION);To;u;[[@9Hix ;F;:TLS1_2_VERSION;;w;;;[;{;IC; " TLS 1.2 ;T;[;![;"I" TLS 1.2;T;#0;$@};.F;/o;0;1T;2iw ;3iw ;%@J;&I"!OpenSSL::SSL::TLS1_2_VERSION;F;xI"INT2NUM(TLS1_2_VERSION);To;u;[[@9Hi{ ;F;:TLS1_3_VERSION;;w;;;[;{;IC; " TLS 1.3 ;T;[;![;"I" TLS 1.3;T;#0;$@$};.F;/o;0;1T;2iz ;3iz ;%@J;&I"!OpenSSL::SSL::TLS1_3_VERSION;F;xI"INT2NUM(TLS1_3_VERSION);T; @J; IC;[; @J; IC;[; @J; IC;{;IC;{;T;IC;{;T;T;{;[;[[@9Hi [@Hi3[@9Hi ;T;:SSL;;;;;[;{;IC; "Use SSLContext to set up the parameters for a TLS (former SSL) connection. Both client and server TLS connections are supported, SSLSocket and SSLServer may be used in conjunction with an instance of SSLContext to set up connections.;T;[;![;"I" Use SSLContext to set up the parameters for a TLS (former SSL) connection. Both client and server TLS connections are supported, SSLSocket and SSLServer may be used in conjunction with an instance of SSLContext to set up connections. ;T;#0;$@J;.F;/o;0;1T;2i ;3i ;Bi;%@GH;&I"OpenSSL::SSL;Fo; ;IC;[; @C}; IC;[; @C}; IC;[; @C}; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Hi;F;:HMACError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@C};%@GH;&I"OpenSSL::HMACError;F;'@Ho; ;IC;[o;4;5F;6;;;;&I"OpenSSL::HMAC#initialize;F;7[[I"key;T0[I" digest;T0;[[@Hia;T;;D;0;[;{;IC; "Returns an instance of OpenSSL::HMAC set with the key and digest algorithm to be used. The instance represents the initial state of the message authentication code before any data has been processed. To process data with it, use the instance method #update with your data as an argument. === Example key = 'key' instance = OpenSSL::HMAC.new(key, 'SHA1') #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance.class #=> OpenSSL::HMAC === A note about comparisons Two instances can be securely compared with #== in constant time: other_instance = OpenSSL::HMAC.new('key', 'SHA1') #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance == other_instance #=> true ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(key, digest);T;IC; ";T;[;![;"I";T;#0;$@V};.F;Bi;C0;7[[I"key;T0[I" digest;T0;$@V};![;"I"Returns an instance of OpenSSL::HMAC set with the key and digest algorithm to be used. The instance represents the initial state of the message authentication code before any data has been processed. To process data with it, use the instance method #update with your data as an argument. === Example key = 'key' instance = OpenSSL::HMAC.new(key, 'SHA1') #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance.class #=> OpenSSL::HMAC === A note about comparisons Two instances can be securely compared with #== in constant time: other_instance = OpenSSL::HMAC.new('key', 'SHA1') #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance == other_instance #=> true @overload new(key, digest);T;#0;$@V};.F;/o;0;1T;2iE;3i^;%@T};9I"static VALUE ossl_hmac_initialize(VALUE self, VALUE key, VALUE digest) { EVP_MD_CTX *ctx; EVP_PKEY *pkey; GetHMAC(self, ctx); StringValue(key); pkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, (unsigned char *)RSTRING_PTR(key), RSTRING_LENINT(key)); if (!pkey) ossl_raise(eHMACError, "EVP_PKEY_new_mac_key"); if (EVP_DigestSignInit(ctx, NULL, ossl_evp_get_digestbyname(digest), NULL, pkey) != 1) { EVP_PKEY_free(pkey); ossl_raise(eHMACError, "EVP_DigestSignInit"); } /* Decrement reference counter; EVP_MD_CTX still keeps it */ EVP_PKEY_free(pkey); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::HMAC#initialize_copy;F;7[[I" other;T0;[[@Hiy;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@t};%@T};9I"7static VALUE ossl_hmac_copy(VALUE self, VALUE other) { EVP_MD_CTX *ctx1, *ctx2; rb_check_frozen(self); if (self == other) return self; GetHMAC(self, ctx1); GetHMAC(other, ctx2); if (EVP_MD_CTX_copy(ctx1, ctx2) != 1) ossl_raise(eHMACError, "EVP_MD_CTX_copy"); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::HMAC#reset;F;7[;[[@Hi;T;;;0;[;{;IC; "|Returns _hmac_ as it was when it was first initialized, with all processed data cleared from it. === Example data = "The quick brown fox jumps over the lazy dog" instance = OpenSSL::HMAC.new('key', 'SHA1') #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance.update(data) #=> de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9 instance.reset #=> f42bb0eeb018ebbd4597ae7213711ec60760843f ;T;[o;= ;>I" overload;F;?0;;;@0;:I" reset;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@};![;"I"@return [self];T;#0;$@};.F;Bi;C0;7[;$@};![;"I"Returns _hmac_ as it was when it was first initialized, with all processed data cleared from it. === Example data = "The quick brown fox jumps over the lazy dog" instance = OpenSSL::HMAC.new('key', 'SHA1') #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance.update(data) #=> de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9 instance.reset #=> f42bb0eeb018ebbd4597ae7213711ec60760843f @overload reset @return [self];T;#0;$@};.F;/o;0;1T;2i;3i;%@T};9I"Hstatic VALUE ossl_hmac_reset(VALUE self) { EVP_MD_CTX *ctx; EVP_PKEY *pkey; GetHMAC(self, ctx); pkey = EVP_PKEY_CTX_get0_pkey(EVP_MD_CTX_get_pkey_ctx(ctx)); if (EVP_DigestSignInit(ctx, NULL, EVP_MD_CTX_get0_md(ctx), NULL, pkey) != 1) ossl_raise(eHMACError, "EVP_DigestSignInit"); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::HMAC#update;F;7[[I" data;T0;[[@Hi;T;; ;0;[;{;IC; "cReturns _hmac_ updated with the message to be authenticated. Can be called repeatedly with chunks of the message. === Example first_chunk = 'The quick brown fox jumps ' second_chunk = 'over the lazy dog' instance.update(first_chunk) #=> 5b9a8038a65d571076d97fe783989e52278a492a instance.update(second_chunk) #=> de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"update(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@};![;"I"@return [self];T;#0;$@};.F;Bi;C0;7[[I" string;T0;$@};![;"I"Returns _hmac_ updated with the message to be authenticated. Can be called repeatedly with chunks of the message. === Example first_chunk = 'The quick brown fox jumps ' second_chunk = 'over the lazy dog' instance.update(first_chunk) #=> 5b9a8038a65d571076d97fe783989e52278a492a instance.update(second_chunk) #=> de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9 @overload update(string) @return [self];T;#0;$o;4;5F;6;;;;&I"OpenSSL::HMAC#<<;F;7[;[[@Hi);F;;;;;[;{;@};%@T};9I"static VALUE ossl_hmac_update(VALUE self, VALUE data) { EVP_MD_CTX *ctx; StringValue(data); GetHMAC(self, ctx); if (EVP_DigestSignUpdate(ctx, RSTRING_PTR(data), RSTRING_LEN(data)) != 1) ossl_raise(eHMACError, "EVP_DigestSignUpdate"); return self; };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@T};9I"static VALUE ossl_hmac_update(VALUE self, VALUE data) { EVP_MD_CTX *ctx; StringValue(data); GetHMAC(self, ctx); if (EVP_DigestSignUpdate(ctx, RSTRING_PTR(data), RSTRING_LEN(data)) != 1) ossl_raise(eHMACError, "EVP_DigestSignUpdate"); return self; };T;:@};;T@}o;4;5F;6;;;;&I"OpenSSL::HMAC#digest;F;7[;[[@Hi;T;;$;0;[;{;IC; "Returns the authentication code an instance represents as a binary string. === Example instance = OpenSSL::HMAC.new('key', 'SHA1') #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance.digest #=> "\xF4+\xB0\xEE\xB0\x18\xEB\xBDE\x97\xAEr\x13q\x1E\xC6\a`\x84?" ;T;[o;= ;>I" overload;F;?0;;$;@0;:I" digest;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@};![;"I"@return [String];T;#0;$@};.F;Bi;C0;7[;$@};![;"I")Returns the authentication code an instance represents as a binary string. === Example instance = OpenSSL::HMAC.new('key', 'SHA1') #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance.digest #=> "\xF4+\xB0\xEE\xB0\x18\xEB\xBDE\x97\xAEr\x13q\x1E\xC6\a`\x84?" @overload digest @return [String];T;#0;$@};.F;/o;0;1T;2i;3i;%@T};9I"static VALUE ossl_hmac_digest(VALUE self) { EVP_MD_CTX *ctx; size_t buf_len = EVP_MAX_MD_SIZE; VALUE ret; GetHMAC(self, ctx); ret = rb_str_new(NULL, EVP_MAX_MD_SIZE); if (EVP_DigestSignFinal(ctx, (unsigned char *)RSTRING_PTR(ret), &buf_len) != 1) ossl_raise(eHMACError, "EVP_DigestSignFinal"); rb_str_set_len(ret, (long)buf_len); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::HMAC#hexdigest;F;7[;[[@Hi;T;;&;0;[;{;IC; "TReturns the authentication code an instance represents as a hex-encoded string. ;T;[o;= ;>I" overload;F;?0;;&;@0;:I"hexdigest;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@};![;"I"@return [String];T;#0;$@};.F;Bi;C0;7[;$@};![;"I"}Returns the authentication code an instance represents as a hex-encoded string. @overload hexdigest @return [String];T;#0;$o;4;5F;6;;;;&I"OpenSSL::HMAC#to_s;F;7[;[[@Hi-;F;;G;;;[;{;@};%@T};9I"static VALUE ossl_hmac_hexdigest(VALUE self) { EVP_MD_CTX *ctx; unsigned char buf[EVP_MAX_MD_SIZE]; size_t buf_len = EVP_MAX_MD_SIZE; VALUE ret; GetHMAC(self, ctx); if (EVP_DigestSignFinal(ctx, buf, &buf_len) != 1) ossl_raise(eHMACError, "EVP_DigestSignFinal"); ret = rb_str_new(NULL, buf_len * 2); ossl_bin2hex(buf, RSTRING_PTR(ret), buf_len); return ret; };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@T};9I"static VALUE ossl_hmac_hexdigest(VALUE self) { EVP_MD_CTX *ctx; unsigned char buf[EVP_MAX_MD_SIZE]; size_t buf_len = EVP_MAX_MD_SIZE; VALUE ret; GetHMAC(self, ctx); if (EVP_DigestSignFinal(ctx, buf, &buf_len) != 1) ossl_raise(eHMACError, "EVP_DigestSignFinal"); ret = rb_str_new(NULL, buf_len * 2); ossl_bin2hex(buf, RSTRING_PTR(ret), buf_len); return ret; };T;:@};;To;4;5F;6;;;;&I"OpenSSL::HMAC#inspect;F;7[;[[@Hi,;F;;J;;;[;{;@};%@T};9I"static VALUE ossl_hmac_hexdigest(VALUE self) { EVP_MD_CTX *ctx; unsigned char buf[EVP_MAX_MD_SIZE]; size_t buf_len = EVP_MAX_MD_SIZE; VALUE ret; GetHMAC(self, ctx); if (EVP_DigestSignFinal(ctx, buf, &buf_len) != 1) ossl_raise(eHMACError, "EVP_DigestSignFinal"); ret = rb_str_new(NULL, buf_len * 2); ossl_bin2hex(buf, RSTRING_PTR(ret), buf_len); return ret; };T;:@}@}; @T}; IC;[; @T}; IC;[; @T}; IC;{;IC;{;T;IC;{;T;T;{@}; @~;&@};&;[;[[@Hi[@Hi ;T;: HMAC;;;;;[;{;IC; "OpenSSL::HMAC allows computing Hash-based Message Authentication Code (HMAC). It is a type of message authentication code (MAC) involving a hash function in combination with a key. HMAC can be used to verify the integrity of a message as well as the authenticity. OpenSSL::HMAC has a similar interface to OpenSSL::Digest. === HMAC-SHA256 using one-shot interface key = "key" data = "message-to-be-authenticated" mac = OpenSSL::HMAC.hexdigest("SHA256", key, data) #=> "cddb0db23f469c8bf072b21fd837149bd6ace9ab771cceef14c9e517cc93282e" === HMAC-SHA256 using incremental interface data1 = File.binread("file1") data2 = File.binread("file2") key = "key" hmac = OpenSSL::HMAC.new(key, 'SHA256') hmac << data1 hmac << data2 mac = hmac.digest ;T;[;![;"I" OpenSSL::HMAC allows computing Hash-based Message Authentication Code (HMAC). It is a type of message authentication code (MAC) involving a hash function in combination with a key. HMAC can be used to verify the integrity of a message as well as the authenticity. OpenSSL::HMAC has a similar interface to OpenSSL::Digest. === HMAC-SHA256 using one-shot interface key = "key" data = "message-to-be-authenticated" mac = OpenSSL::HMAC.hexdigest("SHA256", key, data) #=> "cddb0db23f469c8bf072b21fd837149bd6ace9ab771cceef14c9e517cc93282e" === HMAC-SHA256 using incremental interface data1 = File.binread("file1") data2 = File.binread("file2") key = "key" hmac = OpenSSL::HMAC.new(key, 'SHA256') hmac << data1 hmac << data2 mac = hmac.digest ;T;#0;$@T};.F;/o;0;1T;2i;3i;%@GH;&I"OpenSSL::HMAC;F;'@o;;IC;[o; ;IC;[; @~; IC;[; @~; IC;[; @~; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Hi;F;:RandomError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@~;%@~;&I"!OpenSSL::Random::RandomError;F;'@Ho;4;5F;6;;;;&I"OpenSSL::Random#seed;F;7[[I"str;T0;[[@Hi;T;: seed;0;[;{;IC; "F::seed is equivalent to ::add where _entropy_ is length of _str_. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"seed(str);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@/~;![;"I"@return [String];T;#0;$@/~;.F;Bi;C0;7[[I"str;T0;$@/~;![;"I"n::seed is equivalent to ::add where _entropy_ is length of _str_. @overload seed(str) @return [String];T;#0;$@/~;.F;C0;%@~;9I"static VALUE ossl_rand_seed(VALUE self, VALUE str) { StringValue(str); RAND_seed(RSTRING_PTR(str), RSTRING_LENINT(str)); return str; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"OpenSSL::Random.seed;F;7@1~;@4~;T;;;0;@6~;{;IC; "F::seed is equivalent to ::add where _entropy_ is length of _str_.;T;[o;= ;>I" overload;F;?0;;;@0;:I"seed(str);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@M~;![;"I"@return [String];T;#0;$@M~;.F;Bi;C0;7[[I"str;T0;$@M~;![;"I"o::seed is equivalent to ::add where _entropy_ is length of _str_. @overload seed(str) @return [String];T;#0;$@M~;.F;/o;0;1T;2i;3i;Bi;%@~;9@K~;:@L~;;To;4;5F;6;;;;&I"OpenSSL::Random#random_add;F;7[[I"str;T0[I" entropy;T0;[[@Hi9;T;:random_add;0;[;{;IC; "Mixes the bytes from _str_ into the Pseudo Random Number Generator(PRNG) state. Thus, if the data from _str_ are unpredictable to an adversary, this increases the uncertainty about the state and makes the PRNG output less predictable. The _entropy_ argument is (the lower bound of) an estimate of how much randomness is contained in _str_, measured in bytes. === Example pid = $$ now = Time.now ary = [now.to_i, now.nsec, 1000, pid] OpenSSL::Random.add(ary.join, 0.0) OpenSSL::Random.seed(ary.join) ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"add(str, entropy);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@d~;![;"I"@return [self];T;#0;$@d~;.F;Bi;C0;7[[I"str;T0[I" entropy;T0;$@d~;![;"I".Mixes the bytes from _str_ into the Pseudo Random Number Generator(PRNG) state. Thus, if the data from _str_ are unpredictable to an adversary, this increases the uncertainty about the state and makes the PRNG output less predictable. The _entropy_ argument is (the lower bound of) an estimate of how much randomness is contained in _str_, measured in bytes. === Example pid = $$ now = Time.now ary = [now.to_i, now.nsec, 1000, pid] OpenSSL::Random.add(ary.join, 0.0) OpenSSL::Random.seed(ary.join) @overload add(str, entropy) @return [self];T;#0;$@d~;.F;C0;%@~;9I"static VALUE ossl_rand_add(VALUE self, VALUE str, VALUE entropy) { StringValue(str); RAND_add(RSTRING_PTR(str), RSTRING_LENINT(str), NUM2DBL(entropy)); return self; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"OpenSSL::Random.random_add;F;7@f~;@k~;T;;;0;@m~;{;IC; "Mixes the bytes from _str_ into the Pseudo Random Number Generator(PRNG) state. Thus, if the data from _str_ are unpredictable to an adversary, this increases the uncertainty about the state and makes the PRNG output less predictable. The _entropy_ argument is (the lower bound of) an estimate of how much randomness is contained in _str_, measured in bytes. === Example pid = $$ now = Time.now ary = [now.to_i, now.nsec, 1000, pid] OpenSSL::Random.add(ary.join, 0.0) OpenSSL::Random.seed(ary.join);T;[o;= ;>I" overload;F;?0;; ;@0;:I"add(str, entropy);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@~;![;"I"@return [self];T;#0;$@~;.F;Bi;C0;7[[I"str;T0[I" entropy;T0;$@~;![;"I"/Mixes the bytes from _str_ into the Pseudo Random Number Generator(PRNG) state. Thus, if the data from _str_ are unpredictable to an adversary, this increases the uncertainty about the state and makes the PRNG output less predictable. The _entropy_ argument is (the lower bound of) an estimate of how much randomness is contained in _str_, measured in bytes. === Example pid = $$ now = Time.now ary = [now.to_i, now.nsec, 1000, pid] OpenSSL::Random.add(ary.join, 0.0) OpenSSL::Random.seed(ary.join) @overload add(str, entropy) @return [self];T;#0;$@~;.F;/o;0;1T;2i#;3i7;Bi;%@~;9@~;:@~;;To;4;5F;6;;;;&I"%OpenSSL::Random#load_random_file;F;7[[I" filename;T0;[[@HiH;T;:load_random_file;0;[;{;IC; ";Reads bytes from _filename_ and adds them to the PRNG. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"load_random_file(filename);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;T;$@~;![;"I"@return [true];T;#0;$@~;.F;Bi;C0;7[[I" filename;T0;$@~;![;"I"rReads bytes from _filename_ and adds them to the PRNG. @overload load_random_file(filename) @return [true];T;#0;$@~;.F;C0;%@~;9I"static VALUE ossl_rand_load_file(VALUE self, VALUE filename) { if(!RAND_load_file(StringValueCStr(filename), -1)) { ossl_raise(eRandomError, NULL); } return Qtrue; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"%OpenSSL::Random.load_random_file;F;7@~;@~;T;;;0;@~;{;IC; ";Reads bytes from _filename_ and adds them to the PRNG.;T;[o;= ;>I" overload;F;?0;;;@0;:I"load_random_file(filename);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;T;$@~;![;"I"@return [true];T;#0;$@~;.F;Bi;C0;7[[I" filename;T0;$@~;![;"I"sReads bytes from _filename_ and adds them to the PRNG. @overload load_random_file(filename) @return [true];T;#0;$@~;.F;/o;0;1T;2iB;3iF;Bi;%@~;9@~;:@~;;To;4;5F;6;;;;&I"&OpenSSL::Random#write_random_file;F;7[[I" filename;T0;[[@HiY;T;:write_random_file;0;[;{;IC; "Writes a number of random generated bytes (currently 1024) to _filename_ which can be used to initialize the PRNG by calling ::load_random_file in a later session. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" write_random_file(filename);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;T;$@~;![;"I"@return [true];T;#0;$@~;.F;Bi;C0;7[[I" filename;T0;$@~;![;"I"Writes a number of random generated bytes (currently 1024) to _filename_ which can be used to initialize the PRNG by calling ::load_random_file in a later session. @overload write_random_file(filename) @return [true];T;#0;$@~;.F;C0;%@~;9I"static VALUE ossl_rand_write_file(VALUE self, VALUE filename) { if (RAND_write_file(StringValueCStr(filename)) == -1) { ossl_raise(eRandomError, NULL); } return Qtrue; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"&OpenSSL::Random.write_random_file;F;7@~;@~;T;;;0;@~;{;IC; "Writes a number of random generated bytes (currently 1024) to _filename_ which can be used to initialize the PRNG by calling ::load_random_file in a later session.;T;[o;= ;>I" overload;F;?0;;;@0;:I" write_random_file(filename);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;T;$@~;![;"I"@return [true];T;#0;$@~;.F;Bi;C0;7[[I" filename;T0;$@~;![;"I"Writes a number of random generated bytes (currently 1024) to _filename_ which can be used to initialize the PRNG by calling ::load_random_file in a later session. @overload write_random_file(filename) @return [true];T;#0;$@~;.F;/o;0;1T;2iQ;3iW;Bi;%@~;9@~;:@~;;To;4;5F;6;;;;&I"!OpenSSL::Random#random_bytes;F;7[[I"len;T0;[[@Hin;T;:random_bytes;0;[;{;IC; "random_bytes(length) -> string Generates a String with _length_ number of cryptographically strong pseudo-random bytes. === Example OpenSSL::Random.random_bytes(12) #=> "..." ;T;[;![;"I"random_bytes(length) -> string Generates a String with _length_ number of cryptographically strong pseudo-random bytes. === Example OpenSSL::Random.random_bytes(12) #=> "...";T;#0;$@ ;.F;C0;%@~;9I"pstatic VALUE ossl_rand_bytes(VALUE self, VALUE len) { VALUE str; int n = NUM2INT(len); int ret; str = rb_str_new(0, n); ret = RAND_bytes((unsigned char *)RSTRING_PTR(str), n); if (ret == 0) { ossl_raise(eRandomError, "RAND_bytes"); } else if (ret == -1) { ossl_raise(eRandomError, "RAND_bytes is not supported"); } return str; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"!OpenSSL::Random.random_bytes;F;7@ ;@;T;;;0;@;{;IC; "random_bytes(length) -> string Generates a String with _length_ number of cryptographically strong pseudo-random bytes. === Example OpenSSL::Random.random_bytes(12) #=> "...";T;[;![;"I"random_bytes(length) -> string Generates a String with _length_ number of cryptographically strong pseudo-random bytes. === Example OpenSSL::Random.random_bytes(12) #=> "..." ;T;#0;$@;.F;/o;0;1T;2ib;3il;Bi;%@~;9@;:@;;To;4;5F;6;;;;&I"OpenSSL::Random#egd;F;7[[I" filename;T0;[[@Hi;T;:egd;0;[;{;IC; ":Same as ::egd_bytes but queries 255 bytes by default. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"egd(filename);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;T;$@ ;![;"I"@return [true];T;#0;$@ ;.F;Bi;C0;7[[I" filename;T0;$@ ;![;"I"dSame as ::egd_bytes but queries 255 bytes by default. @overload egd(filename) @return [true];T;#0;$@ ;.F;C0;%@~;9I"static VALUE ossl_rand_egd(VALUE self, VALUE filename) { if (RAND_egd(StringValueCStr(filename)) == -1) { ossl_raise(eRandomError, NULL); } return Qtrue; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"OpenSSL::Random.egd;F;7@";@%;T;;;0;@';{;IC; ":Same as ::egd_bytes but queries 255 bytes by default.;T;[o;= ;>I" overload;F;?0;;;@0;:I"egd(filename);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;T;$@>;![;"I"@return [true];T;#0;$@>;.F;Bi;C0;7[[I" filename;T0;$@>;![;"I"eSame as ::egd_bytes but queries 255 bytes by default. @overload egd(filename) @return [true];T;#0;$@>;.F;/o;0;1T;2i|;3i;Bi;%@~;9@<;:@=;;To;4;5F;6;;;;&I"OpenSSL::Random#egd_bytes;F;7[[I" filename;T0[I"len;T0;[[@Hi;T;:egd_bytes;0;[;{;IC; "Queries the entropy gathering daemon EGD on socket path given by _filename_. Fetches _length_ number of bytes and uses ::add to seed the OpenSSL built-in PRNG. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" egd_bytes(filename, length);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;T;$@U;![;"I"@return [true];T;#0;$@U;.F;Bi;C0;7[[I" filename;T0[I" length;T0;$@U;![;"I"Queries the entropy gathering daemon EGD on socket path given by _filename_. Fetches _length_ number of bytes and uses ::add to seed the OpenSSL built-in PRNG. @overload egd_bytes(filename, length) @return [true];T;#0;$@U;.F;C0;%@~;9I"static VALUE ossl_rand_egd_bytes(VALUE self, VALUE filename, VALUE len) { int n = NUM2INT(len); if (RAND_egd_bytes(StringValueCStr(filename), n) == -1) { ossl_raise(eRandomError, NULL); } return Qtrue; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"OpenSSL::Random.egd_bytes;F;7@W;@\;T;;;0;@^;{;IC; "Queries the entropy gathering daemon EGD on socket path given by _filename_. Fetches _length_ number of bytes and uses ::add to seed the OpenSSL built-in PRNG.;T;[o;= ;>I" overload;F;?0;;;@0;:I" egd_bytes(filename, length);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;T;$@w;![;"I"@return [true];T;#0;$@w;.F;Bi;C0;7[[I" filename;T0[I" length;T0;$@w;![;"I"Queries the entropy gathering daemon EGD on socket path given by _filename_. Fetches _length_ number of bytes and uses ::add to seed the OpenSSL built-in PRNG. @overload egd_bytes(filename, length) @return [true];T;#0;$@w;.F;/o;0;1T;2i;3i;Bi;%@~;9@u;:@v;;To;4;5F;6;;;;&I"OpenSSL::Random#status?;F;7[;[[@Hi;T;: status?;0;[;{;IC; "SReturn +true+ if the PRNG has been seeded with enough data, +false+ otherwise. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" status?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"yReturn +true+ if the PRNG has been seeded with enough data, +false+ otherwise. @overload status? @return [Boolean] ;T;#0;$@;.F;C0;%@~;9I"]static VALUE ossl_rand_status(VALUE self) { return RAND_status() ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"OpenSSL::Random.status?;F;7@;@;T;;;0;@;{;IC; "SReturn +true+ if the PRNG has been seeded with enough data, +false+ otherwise.;T;[o;= ;>I" overload;F;?0;;;@0;:I" status?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"gReturn +true+ if the PRNG has been seeded with enough data, +false+ otherwise. @overload status?;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@~;9@;:@;;T; @~; IC;[; @~; IC;[; @~; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Hi;F;: Random;;;;;[;{;IC; " ;T;[;![;"@;#0;$@~;Bi;%@GH;&I"OpenSSL::Random;Fo;;IC;[+o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Hi;F;:OCSPError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"OpenSSL::OCSP::OCSPError;F;'@Ho; ;IC;[o;4;5F;6;;;;&I"+OpenSSL::OCSP::Request#initialize_copy;F;7[[I" other;T0;[[@Hi;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE ossl_ocspreq_initialize_copy(VALUE self, VALUE other) { OCSP_REQUEST *req, *req_old, *req_new; rb_check_frozen(self); GetOCSPReq(self, req_old); GetOCSPReq(other, req); req_new = ASN1_item_dup(ASN1_ITEM_rptr(OCSP_REQUEST), req); if (!req_new) ossl_raise(eOCSPError, "ASN1_item_dup"); SetOCSPReq(self, req_new); OCSP_REQUEST_free(req_old); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::OCSP::Request#initialize;F;7[[@90;[[@Hi;T;;D;0;[;{;IC; "lCreates a new OpenSSL::OCSP::Request. The request may be created empty or from a _request_der_ string. ;T;[o;= ;>I" overload;F;?0;:OpenSSL::OCSP::Request.new;@0;:I"OpenSSL::OCSP::Request.new;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I",OpenSSL::OCSP::Request.new(request_der);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"request_der;T0;$@;![;"I"Creates a new OpenSSL::OCSP::Request. The request may be created empty or from a _request_der_ string. @overload OpenSSL::OCSP::Request.new @overload OpenSSL::OCSP::Request.new(request_der);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_ocspreq_initialize(int argc, VALUE *argv, VALUE self) { VALUE arg; OCSP_REQUEST *req, *req_new; const unsigned char *p; rb_scan_args(argc, argv, "01", &arg); if(!NIL_P(arg)){ GetOCSPReq(self, req); arg = ossl_to_der_if_possible(arg); StringValue(arg); p = (unsigned char *)RSTRING_PTR(arg); req_new = d2i_OCSP_REQUEST(NULL, &p, RSTRING_LEN(arg)); if (!req_new) ossl_raise(eOCSPError, "d2i_OCSP_REQUEST"); SetOCSPReq(self, req_new); OCSP_REQUEST_free(req); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%OpenSSL::OCSP::Request#add_nonce;F;7[[@90;[[@Hi;T;:add_nonce;0;[;{;IC; "Adds a _nonce_ to the OCSP request. If no nonce is given a random one will be generated. The nonce is used to prevent replay attacks but some servers do not support it. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"add_nonce(nonce = nil);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" nonce;TI"nil;T;$@;![;"I"Adds a _nonce_ to the OCSP request. If no nonce is given a random one will be generated. The nonce is used to prevent replay attacks but some servers do not support it. @overload add_nonce(nonce = nil);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_ocspreq_add_nonce(int argc, VALUE *argv, VALUE self) { OCSP_REQUEST *req; VALUE val; int ret; rb_scan_args(argc, argv, "01", &val); if(NIL_P(val)) { GetOCSPReq(self, req); ret = OCSP_request_add1_nonce(req, NULL, -1); } else{ StringValue(val); GetOCSPReq(self, req); ret = OCSP_request_add1_nonce(req, (unsigned char *)RSTRING_PTR(val), RSTRING_LENINT(val)); } if(!ret) ossl_raise(eOCSPError, NULL); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::OCSP::Request#check_nonce;F;7[[I"basic_resp;T0;[[@Hi;T;:check_nonce;0;[;{;IC; "Checks the nonce validity for this request and _response_. The return value is one of the following: -1 :: nonce in request only. 0 :: nonces both present and not equal. 1 :: nonces present and equal. 2 :: nonces both absent. 3 :: nonce present in response only. For most responses, clients can check _result_ > 0. If a responder doesn't handle nonces result.nonzero? may be necessary. A result of 0 is always an error. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"check_nonce(response);T;IC; ";T;[;![;"I";T;#0;$@*;.F;Bi;C0;7[[I" response;T0;$@*;![;"I"Checks the nonce validity for this request and _response_. The return value is one of the following: -1 :: nonce in request only. 0 :: nonces both present and not equal. 1 :: nonces present and equal. 2 :: nonces both absent. 3 :: nonce present in response only. For most responses, clients can check _result_ > 0. If a responder doesn't handle nonces result.nonzero? may be necessary. A result of 0 is always an error. @overload check_nonce(response);T;#0;$@*;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_ocspreq_check_nonce(VALUE self, VALUE basic_resp) { OCSP_REQUEST *req; OCSP_BASICRESP *bs; int res; GetOCSPReq(self, req); GetOCSPBasicRes(basic_resp, bs); res = OCSP_check_nonce(req, bs); return INT2NUM(res); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::OCSP::Request#add_certid;F;7[[I" certid;T0;[[@Hi,;T;:add_certid;0;[;{;IC; "*Adds _certificate_id_ to the request. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"add_certid(certificate_id);T;IC; ";T;[;![;"I";T;#0;$@D;.F;Bi;C0;7[[I"certificate_id;T0;$@D;![;"I"QAdds _certificate_id_ to the request. @overload add_certid(certificate_id);T;#0;$@D;.F;/o;0;1T;2i%;3i(;%@;9I"static VALUE ossl_ocspreq_add_certid(VALUE self, VALUE certid) { OCSP_REQUEST *req; OCSP_CERTID *id, *id_new; GetOCSPReq(self, req); GetOCSPCertId(certid, id); if (!(id_new = OCSP_CERTID_dup(id))) ossl_raise(eOCSPError, "OCSP_CERTID_dup"); if (!OCSP_request_add0_id(req, id_new)) { OCSP_CERTID_free(id_new); ossl_raise(eOCSPError, "OCSP_request_add0_id"); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::OCSP::Request#certid;F;7[;[[@HiF;T;: certid;0;[;{;IC; "1Returns all certificate IDs in this request. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" certid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@^;![;"I"@return [Array];T;#0;$@^;.F;Bi;C0;7[;$@^;![;"I"VReturns all certificate IDs in this request. @overload certid @return [Array];T;#0;$@^;.F;/o;0;1T;2i?;3iC;%@;9I"static VALUE ossl_ocspreq_get_certid(VALUE self) { OCSP_REQUEST *req; OCSP_ONEREQ *one; OCSP_CERTID *id; VALUE ary, tmp; int i, count; GetOCSPReq(self, req); count = OCSP_request_onereq_count(req); ary = (count > 0) ? rb_ary_new() : Qnil; for(i = 0; i < count; i++){ one = OCSP_request_onereq_get0(req, i); tmp = NewOCSPCertId(cOCSPCertId); if(!(id = OCSP_CERTID_dup(OCSP_onereq_get0_id(one)))) ossl_raise(eOCSPError, NULL); SetOCSPCertId(tmp, id); rb_ary_push(ary, tmp); } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::OCSP::Request#signed?;F;7[;[[@Hi;T;: signed?;0;[;{;IC; "Returns +true+ if the request is signed, +false+ otherwise. Note that the validity of the signature is *not* checked. Use #verify to verify that.;T;[o;= ;>I" overload;F;?0;;;@0;:I" signed?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@y;![;"I"@return [Boolean];T;#0;$@y;.F;Bi;C0;7[;$@y;![;"I"Returns +true+ if the request is signed, +false+ otherwise. Note that the validity of the signature is *not* checked. Use #verify to verify that. @overload signed? @return [Boolean];T;#0;$@y;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE ossl_ocspreq_signed_p(VALUE self) { OCSP_REQUEST *req; GetOCSPReq(self, req); return OCSP_request_is_signed(req) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" OpenSSL::OCSP::Request#sign;F;7[[@90;[[@Hin;T;;7;0;[;{;IC; "Signs this OCSP request using _cert_, _key_ and optional _digest_. If _digest_ is not specified, SHA-1 is used. _certs_ is an optional Array of additional certificates which are included in the request in addition to the signer certificate. Note that if _certs_ is +nil+ or not given, flag OpenSSL::OCSP::NOCERTS is enabled. Pass an empty array to include only the signer certificate. _flags_ is a bitwise OR of the following constants: OpenSSL::OCSP::NOCERTS:: Don't include any certificates in the request. _certs_ will be ignored. ;T;[o;= ;>I" overload;F;?0;;7;@0;:I":sign(cert, key, certs = nil, flags = 0, digest = nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[ [I" cert;T0[I"key;T0[I" certs;TI"nil;T[I" flags;TI"0;T[I" digest;TI"nil;T;$@;![;"I"lSigns this OCSP request using _cert_, _key_ and optional _digest_. If _digest_ is not specified, SHA-1 is used. _certs_ is an optional Array of additional certificates which are included in the request in addition to the signer certificate. Note that if _certs_ is +nil+ or not given, flag OpenSSL::OCSP::NOCERTS is enabled. Pass an empty array to include only the signer certificate. _flags_ is a bitwise OR of the following constants: OpenSSL::OCSP::NOCERTS:: Don't include any certificates in the request. _certs_ will be ignored. @overload sign(cert, key, certs = nil, flags = 0, digest = nil) @return [self];T;#0;$@;.F;/o;0;1T;2i^;3il;%@;9I"dstatic VALUE ossl_ocspreq_sign(int argc, VALUE *argv, VALUE self) { VALUE signer_cert, signer_key, certs, flags, digest; OCSP_REQUEST *req; X509 *signer; EVP_PKEY *key; STACK_OF(X509) *x509s = NULL; unsigned long flg = 0; const EVP_MD *md; int ret; rb_scan_args(argc, argv, "23", &signer_cert, &signer_key, &certs, &flags, &digest); GetOCSPReq(self, req); signer = GetX509CertPtr(signer_cert); key = GetPrivPKeyPtr(signer_key); if (!NIL_P(flags)) flg = NUM2INT(flags); if (NIL_P(digest)) md = EVP_sha1(); else md = ossl_evp_get_digestbyname(digest); if (NIL_P(certs)) flg |= OCSP_NOCERTS; else x509s = ossl_x509_ary2sk(certs); ret = OCSP_request_sign(req, signer, key, md, x509s, flg); sk_X509_pop_free(x509s, X509_free); if (!ret) ossl_raise(eOCSPError, NULL); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::OCSP::Request#verify;F;7[[@90;[[@Hi;T;;J;0;[;{;IC; "$Verifies this request using the given _certificates_ and _store_. _certificates_ is an array of OpenSSL::X509::Certificate, _store_ is an OpenSSL::X509::Store. Note that +false+ is returned if the request does not have a signature. Use #signed? to check whether the request is signed or not. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I"+verify(certificates, store, flags = 0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"certificates;T0[I" store;T0[I" flags;TI"0;T;$@;![;"I"kVerifies this request using the given _certificates_ and _store_. _certificates_ is an array of OpenSSL::X509::Certificate, _store_ is an OpenSSL::X509::Store. Note that +false+ is returned if the request does not have a signature. Use #signed? to check whether the request is signed or not. @overload verify(certificates, store, flags = 0) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"Jstatic VALUE ossl_ocspreq_verify(int argc, VALUE *argv, VALUE self) { VALUE certs, store, flags; OCSP_REQUEST *req; STACK_OF(X509) *x509s; X509_STORE *x509st; int flg, result; rb_scan_args(argc, argv, "21", &certs, &store, &flags); GetOCSPReq(self, req); x509st = GetX509StorePtr(store); flg = NIL_P(flags) ? 0 : NUM2INT(flags); x509s = ossl_x509_ary2sk(certs); result = OCSP_request_verify(req, x509s, x509st, flg); sk_X509_pop_free(x509s, X509_free); if (result <= 0) ossl_clear_error(); return result > 0 ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::OCSP::Request#to_der;F;7[;[[@Hi;T;;M;0;[;{;IC; "1Returns this request as a DER-encoded string ;T;[;![;"I"2Returns this request as a DER-encoded string ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_ocspreq_to_der(VALUE self) { OCSP_REQUEST *req; VALUE str; unsigned char *p; long len; GetOCSPReq(self, req); if((len = i2d_OCSP_REQUEST(req, NULL)) <= 0) ossl_raise(eOCSPError, NULL); str = rb_str_new(0, len); p = (unsigned char *)RSTRING_PTR(str); if(i2d_OCSP_REQUEST(req, &p) <= 0) ossl_raise(eOCSPError, NULL); ossl_str_adjust(str, p); return str; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Hi;F;: Request;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I"OpenSSL::OCSP::Request;F;'@o; ;IC;[ o;4;5F;6;;;;&I"#OpenSSL::OCSP::Response.create;F;7[[I" status;T0[I"basic_resp;T0;[[@Hi;T;: create;0;[;{;IC; "KCreates an OpenSSL::OCSP::Response from _status_ and _basic_response_. ;T;[o;= ;>I" overload;F;?0;:#OpenSSL::OCSP::Response.create;@0;:I"AOpenSSL::OCSP::Response.create(status, basic_response = nil);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" status;T0[I"basic_response;TI"nil;T;$@;![;"I"Creates an OpenSSL::OCSP::Response from _status_ and _basic_response_. @overload OpenSSL::OCSP::Response.create(status, basic_response = nil);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_ocspres_s_create(VALUE klass, VALUE status, VALUE basic_resp) { OCSP_BASICRESP *bs; OCSP_RESPONSE *res; VALUE obj; int st = NUM2INT(status); if(NIL_P(basic_resp)) bs = NULL; else GetOCSPBasicRes(basic_resp, bs); /* NO NEED TO DUP */ obj = NewOCSPRes(klass); if(!(res = OCSP_response_create(st, bs))) ossl_raise(eOCSPError, NULL); SetOCSPRes(obj, res); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",OpenSSL::OCSP::Response#initialize_copy;F;7[[I" other;T0;[[@Hi;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE ossl_ocspres_initialize_copy(VALUE self, VALUE other) { OCSP_RESPONSE *res, *res_old, *res_new; rb_check_frozen(self); GetOCSPRes(self, res_old); GetOCSPRes(other, res); res_new = ASN1_item_dup(ASN1_ITEM_rptr(OCSP_RESPONSE), res); if (!res_new) ossl_raise(eOCSPError, "ASN1_item_dup"); SetOCSPRes(self, res_new); OCSP_RESPONSE_free(res_old); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::OCSP::Response#initialize;F;7[[@90;[[@Hi ;T;;D;0;[;{;IC; "oCreates a new OpenSSL::OCSP::Response. The response may be created empty or from a _response_der_ string. ;T;[o;= ;>I" overload;F;?0;: OpenSSL::OCSP::Response.new;@0;:I" OpenSSL::OCSP::Response.new;T;IC; ";T;[;![;"I";T;#0;$@,;.F;Bi;C0;7[;$@,o;= ;>I" overload;F;?0;;;@0;:I".OpenSSL::OCSP::Response.new(response_der);T;IC; ";T;[;![;"I";T;#0;$@,;.F;Bi;C0;7[[I"response_der;T0;$@,;![;"I"Creates a new OpenSSL::OCSP::Response. The response may be created empty or from a _response_der_ string. @overload OpenSSL::OCSP::Response.new @overload OpenSSL::OCSP::Response.new(response_der);T;#0;$@,;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_ocspres_initialize(int argc, VALUE *argv, VALUE self) { VALUE arg; OCSP_RESPONSE *res, *res_new; const unsigned char *p; rb_scan_args(argc, argv, "01", &arg); if(!NIL_P(arg)){ GetOCSPRes(self, res); arg = ossl_to_der_if_possible(arg); StringValue(arg); p = (unsigned char *)RSTRING_PTR(arg); res_new = d2i_OCSP_RESPONSE(NULL, &p, RSTRING_LEN(arg)); if (!res_new) ossl_raise(eOCSPError, "d2i_OCSP_RESPONSE"); SetOCSPRes(self, res_new); OCSP_RESPONSE_free(res); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::OCSP::Response#status;F;7[;[[@Hi>;T;;>;0;[;{;IC; "(Returns the status of the response. ;T;[o;= ;>I" overload;F;?0;;>;@0;:I" status;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@M;![;"I"@return [Integer];T;#0;$@M;.F;Bi;C0;7[;$@M;![;"I"OReturns the status of the response. @overload status @return [Integer];T;#0;$@M;.F;/o;0;1T;2i7;3i;;%@;9I"static VALUE ossl_ocspres_status(VALUE self) { OCSP_RESPONSE *res; int st; GetOCSPRes(self, res); st = OCSP_response_status(res); return INT2NUM(st); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*OpenSSL::OCSP::Response#status_string;F;7[;[[@HiQ;T;:status_string;0;[;{;IC; ".Returns a status string for the response. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"status_string;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@h;![;"I"@return [String];T;#0;$@h;.F;Bi;C0;7[;$@h;![;"I"[Returns a status string for the response. @overload status_string @return [String];T;#0;$@h;.F;/o;0;1T;2iJ;3iN;%@;9I"static VALUE ossl_ocspres_status_string(VALUE self) { OCSP_RESPONSE *res; int st; GetOCSPRes(self, res); st = OCSP_response_status(res); return rb_str_new2(OCSP_response_status_str(st)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::OCSP::Response#basic;F;7[;[[@Hid;T;: basic;0;[;{;IC; ".Returns a BasicResponse for this response ;T;[o;= ;>I" overload;F;?0;;;@0;:I" basic;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"@Returns a BasicResponse for this response @overload basic;T;#0;$@;.F;/o;0;1T;2i];3i`;%@;9I"#static VALUE ossl_ocspres_get_basic(VALUE self) { OCSP_RESPONSE *res; OCSP_BASICRESP *bs; VALUE ret; GetOCSPRes(self, res); ret = NewOCSPBasicRes(cOCSPBasicRes); if(!(bs = OCSP_response_get1_basic(res))) return Qnil; SetOCSPBasicRes(ret, bs); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::OCSP::Response#to_der;F;7[;[[@Hi{;T;;M;0;[;{;IC; "3Returns this response as a DER-encoded string. ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" to_der;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"YReturns this response as a DER-encoded string. @overload to_der @return [String];T;#0;$@;.F;/o;0;1T;2it;3ix;%@;9I"static VALUE ossl_ocspres_to_der(VALUE self) { OCSP_RESPONSE *res; VALUE str; long len; unsigned char *p; GetOCSPRes(self, res); if((len = i2d_OCSP_RESPONSE(res, NULL)) <= 0) ossl_raise(eOCSPError, NULL); str = rb_str_new(0, len); p = (unsigned char *)RSTRING_PTR(str); if(i2d_OCSP_RESPONSE(res, &p) <= 0) ossl_raise(eOCSPError, NULL); ossl_str_adjust(str, p); return str; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Hi;F;: Response;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I"OpenSSL::OCSP::Response;F;'@o; ;IC;[o;4;5F;6;;;;&I"1OpenSSL::OCSP::BasicResponse#initialize_copy;F;7[[I" other;T0;[[@Hi;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@Ł;%@Á;9I"static VALUE ossl_ocspbres_initialize_copy(VALUE self, VALUE other) { OCSP_BASICRESP *bs, *bs_old, *bs_new; rb_check_frozen(self); GetOCSPBasicRes(self, bs_old); GetOCSPBasicRes(other, bs); bs_new = ASN1_item_dup(ASN1_ITEM_rptr(OCSP_BASICRESP), bs); if (!bs_new) ossl_raise(eOCSPError, "ASN1_item_dup"); SetOCSPBasicRes(self, bs_new); OCSP_BASICRESP_free(bs_old); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",OpenSSL::OCSP::BasicResponse#initialize;F;7[[@90;[[@Hi;T;;D;0;[;{;IC; "XCreates a new BasicResponse. If _der_string_ is given, decodes _der_string_ as DER. ;T;[o;= ;>I" overload;F;?0;:%OpenSSL::OCSP::BasicResponse.new;@0;:I"7OpenSSL::OCSP::BasicResponse.new(der_string = nil);T;IC; ";T;[;![;"I";T;#0;$@Ӂ;.F;Bi;C0;7[[I"der_string;TI"nil;T;$@Ӂ;![;"I"Creates a new BasicResponse. If _der_string_ is given, decodes _der_string_ as DER. @overload OpenSSL::OCSP::BasicResponse.new(der_string = nil);T;#0;$@Ӂ;.F;/o;0;1T;2i;3i;%@Á;9I"*static VALUE ossl_ocspbres_initialize(int argc, VALUE *argv, VALUE self) { VALUE arg; OCSP_BASICRESP *res, *res_new; const unsigned char *p; rb_scan_args(argc, argv, "01", &arg); if (!NIL_P(arg)) { GetOCSPBasicRes(self, res); arg = ossl_to_der_if_possible(arg); StringValue(arg); p = (unsigned char *)RSTRING_PTR(arg); res_new = d2i_OCSP_BASICRESP(NULL, &p, RSTRING_LEN(arg)); if (!res_new) ossl_raise(eOCSPError, "d2i_OCSP_BASICRESP"); SetOCSPBasicRes(self, res_new); OCSP_BASICRESP_free(res); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",OpenSSL::OCSP::BasicResponse#copy_nonce;F;7[[I" request;T0;[[@Hi;T;:copy_nonce;0;[;{;IC; "`Copies the nonce from _request_ into this response. Returns 1 on success and 0 on failure. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"copy_nonce(request);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I" request;T0;$@;![;"I"Copies the nonce from _request_ into this response. Returns 1 on success and 0 on failure. @overload copy_nonce(request) @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@Á;9I"static VALUE ossl_ocspbres_copy_nonce(VALUE self, VALUE request) { OCSP_BASICRESP *bs; OCSP_REQUEST *req; int ret; GetOCSPBasicRes(self, bs); GetOCSPReq(request, req); ret = OCSP_copy_nonce(bs, req); return INT2NUM(ret); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+OpenSSL::OCSP::BasicResponse#add_nonce;F;7[[@90;[[@Hi;T;;;0;[;{;IC; "[Adds _nonce_ to this response. If no nonce was provided a random nonce will be added. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"add_nonce(nonce = nil);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I" nonce;TI"nil;T;$@ ;![;"I"~Adds _nonce_ to this response. If no nonce was provided a random nonce will be added. @overload add_nonce(nonce = nil);T;#0;$@ ;.F;/o;0;1T;2i;3i;%@Á;9I"static VALUE ossl_ocspbres_add_nonce(int argc, VALUE *argv, VALUE self) { OCSP_BASICRESP *bs; VALUE val; int ret; rb_scan_args(argc, argv, "01", &val); if(NIL_P(val)) { GetOCSPBasicRes(self, bs); ret = OCSP_basic_add1_nonce(bs, NULL, -1); } else{ StringValue(val); GetOCSPBasicRes(self, bs); ret = OCSP_basic_add1_nonce(bs, (unsigned char *)RSTRING_PTR(val), RSTRING_LENINT(val)); } if(!ret) ossl_raise(eOCSPError, NULL); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",OpenSSL::OCSP::BasicResponse#add_status;F;7[ [I"cid;T0[I" status;T0[I" reason;T0[I" revtime;T0[I" thisupd;T0[I" nextupd;T0[I"ext;T0;[[@Hi1;T;:add_status;0;[;{;IC; "Adds a certificate status for _certificate_id_. _status_ is the status, and must be one of these: - OpenSSL::OCSP::V_CERTSTATUS_GOOD - OpenSSL::OCSP::V_CERTSTATUS_REVOKED - OpenSSL::OCSP::V_CERTSTATUS_UNKNOWN _reason_ and _revocation_time_ can be given only when _status_ is OpenSSL::OCSP::V_CERTSTATUS_REVOKED. _reason_ describes the reason for the revocation, and must be one of OpenSSL::OCSP::REVOKED_STATUS_* constants. _revocation_time_ is the time when the certificate is revoked. _this_update_ and _next_update_ indicate the time at which the status is verified to be correct and the time at or before which newer information will be available, respectively. _next_update_ is optional. _extensions_ is an Array of OpenSSL::X509::Extension to be included in the SingleResponse. This is also optional. Note that the times, _revocation_time_, _this_update_ and _next_update_ can be specified in either of Integer or Time object. If they are Integer, it is treated as the relative seconds from the current time. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"fadd_status(certificate_id, status, reason, revocation_time, this_update, next_update, extensions);T;IC; ";T;[;![;"I";T;#0;$@&;.F;Bi;C0;7[ [I"certificate_id;T0[I" status;T0[I" reason;T0[I"revocation_time;T0[I"this_update;T0[I"next_update;T0[I"extensions;T0;$@&;![;"I"iAdds a certificate status for _certificate_id_. _status_ is the status, and must be one of these: - OpenSSL::OCSP::V_CERTSTATUS_GOOD - OpenSSL::OCSP::V_CERTSTATUS_REVOKED - OpenSSL::OCSP::V_CERTSTATUS_UNKNOWN _reason_ and _revocation_time_ can be given only when _status_ is OpenSSL::OCSP::V_CERTSTATUS_REVOKED. _reason_ describes the reason for the revocation, and must be one of OpenSSL::OCSP::REVOKED_STATUS_* constants. _revocation_time_ is the time when the certificate is revoked. _this_update_ and _next_update_ indicate the time at which the status is verified to be correct and the time at or before which newer information will be available, respectively. _next_update_ is optional. _extensions_ is an Array of OpenSSL::X509::Extension to be included in the SingleResponse. This is also optional. Note that the times, _revocation_time_, _this_update_ and _next_update_ can be specified in either of Integer or Time object. If they are Integer, it is treated as the relative seconds from the current time. @overload add_status(certificate_id, status, reason, revocation_time, this_update, next_update, extensions);T;#0;$@&;.F;/o;0;1T;2i;3i.;%@Á;9I"Ustatic VALUE ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status, VALUE reason, VALUE revtime, VALUE thisupd, VALUE nextupd, VALUE ext) { OCSP_BASICRESP *bs; OCSP_SINGLERESP *single; OCSP_CERTID *id; ASN1_TIME *ths = NULL, *nxt = NULL, *rev = NULL; int st, rsn = 0, error = 0, rstatus = 0; long i; VALUE tmp; GetOCSPBasicRes(self, bs); GetOCSPCertId(cid, id); st = NUM2INT(status); if (!NIL_P(ext)) { /* All ext's members must be X509::Extension */ ext = rb_check_array_type(ext); for (i = 0; i < RARRAY_LEN(ext); i++) OSSL_Check_Kind(RARRAY_AREF(ext, i), cX509Ext); } if (st == V_OCSP_CERTSTATUS_REVOKED) { rsn = NUM2INT(reason); tmp = rb_protect(add_status_convert_time, revtime, &rstatus); if (rstatus) goto err; rev = (ASN1_TIME *)tmp; } tmp = rb_protect(add_status_convert_time, thisupd, &rstatus); if (rstatus) goto err; ths = (ASN1_TIME *)tmp; if (!NIL_P(nextupd)) { tmp = rb_protect(add_status_convert_time, nextupd, &rstatus); if (rstatus) goto err; nxt = (ASN1_TIME *)tmp; } if(!(single = OCSP_basic_add1_status(bs, id, st, rsn, rev, ths, nxt))){ error = 1; goto err; } if(!NIL_P(ext)){ X509_EXTENSION *x509ext; for(i = 0; i < RARRAY_LEN(ext); i++){ x509ext = GetX509ExtPtr(RARRAY_AREF(ext, i)); if(!OCSP_SINGLERESP_add_ext(single, x509ext, -1)){ error = 1; goto err; } } } err: ASN1_TIME_free(ths); ASN1_TIME_free(nxt); ASN1_TIME_free(rev); if(error) ossl_raise(eOCSPError, NULL); if(rstatus) rb_jump_tag(rstatus); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(OpenSSL::OCSP::BasicResponse#status;F;7[;[[@Hi;T;;>;0;[;{;IC; "Returns an Array of statuses for this response. Each status contains a CertificateId, the status (0 for good, 1 for revoked, 2 for unknown), the reason for the status, the revocation time, the time of this update, the time for the next update and a list of OpenSSL::X509::Extension. This should be superseded by BasicResponse#responses and #find_response that return SingleResponse. ;T;[o;= ;>I" overload;F;?0;;>;@0;:I" status;T;IC; ";T;[;![;"I";T;#0;$@X;.F;Bi;C0;7[;$@X;![;"I"Returns an Array of statuses for this response. Each status contains a CertificateId, the status (0 for good, 1 for revoked, 2 for unknown), the reason for the status, the revocation time, the time of this update, the time for the next update and a list of OpenSSL::X509::Extension. This should be superseded by BasicResponse#responses and #find_response that return SingleResponse. @overload status;T;#0;$@X;.F;/o;0;1T;2is;3i|;%@Á;9I"@static VALUE ossl_ocspbres_get_status(VALUE self) { OCSP_BASICRESP *bs; OCSP_SINGLERESP *single; OCSP_CERTID *cid; ASN1_TIME *revtime, *thisupd, *nextupd; int status, reason; X509_EXTENSION *x509ext; VALUE ret, ary, ext; int count, ext_count, i, j; GetOCSPBasicRes(self, bs); ret = rb_ary_new(); count = OCSP_resp_count(bs); for(i = 0; i < count; i++){ single = OCSP_resp_get0(bs, i); if(!single) continue; revtime = thisupd = nextupd = NULL; status = OCSP_single_get0_status(single, &reason, &revtime, &thisupd, &nextupd); if(status < 0) continue; if(!(cid = OCSP_CERTID_dup((OCSP_CERTID *)OCSP_SINGLERESP_get0_id(single)))) /* FIXME */ ossl_raise(eOCSPError, NULL); ary = rb_ary_new(); rb_ary_push(ary, ossl_ocspcertid_new(cid)); rb_ary_push(ary, INT2NUM(status)); rb_ary_push(ary, INT2NUM(reason)); rb_ary_push(ary, revtime ? asn1time_to_time(revtime) : Qnil); rb_ary_push(ary, thisupd ? asn1time_to_time(thisupd) : Qnil); rb_ary_push(ary, nextupd ? asn1time_to_time(nextupd) : Qnil); ext = rb_ary_new(); ext_count = OCSP_SINGLERESP_get_ext_count(single); for(j = 0; j < ext_count; j++){ x509ext = OCSP_SINGLERESP_get_ext(single, j); rb_ary_push(ext, ossl_x509ext_new(x509ext)); } rb_ary_push(ary, ext); rb_ary_push(ret, ary); } return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+OpenSSL::OCSP::BasicResponse#responses;F;7[;[[@Hi;T;:responses;0;[;{;IC; "?Returns an Array of SingleResponse for this BasicResponse. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"responses;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Array of SingleResponse;T;$@n;![;"I"&@return [Array of SingleResponse];T;#0;$@n;.F;Bi;C0;7[;$@n;![;"I"yReturns an Array of SingleResponse for this BasicResponse. @overload responses @return [Array of SingleResponse];T;#0;$@n;.F;/o;0;1T;2i;3i;%@Á;9I"static VALUE ossl_ocspbres_get_responses(VALUE self) { OCSP_BASICRESP *bs; VALUE ret; int count, i; GetOCSPBasicRes(self, bs); count = OCSP_resp_count(bs); ret = rb_ary_new2(count); for (i = 0; i < count; i++) { OCSP_SINGLERESP *sres, *sres_new; sres = OCSP_resp_get0(bs, i); sres_new = ASN1_item_dup(ASN1_ITEM_rptr(OCSP_SINGLERESP), sres); if (!sres_new) ossl_raise(eOCSPError, "ASN1_item_dup"); rb_ary_push(ret, ossl_ocspsres_new(sres_new)); } return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"/OpenSSL::OCSP::BasicResponse#find_response;F;7[[I" target;T0;[[@Hi;T;:find_response;0;[;{;IC; "}Returns a SingleResponse whose CertId matches with _certificate_id_, or +nil+ if this BasicResponse does not contain it. ;T;[o;= ;>I" overload;F;?0;;;@0;:I""find_response(certificate_id);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"SingleResponse | nil;T;$@;![;"I"#@return [SingleResponse | nil];T;#0;$@;.F;Bi;C0;7[[I"certificate_id;T0;$@;![;"I"Returns a SingleResponse whose CertId matches with _certificate_id_, or +nil+ if this BasicResponse does not contain it. @overload find_response(certificate_id) @return [SingleResponse | nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@Á;9I"static VALUE ossl_ocspbres_find_response(VALUE self, VALUE target) { OCSP_BASICRESP *bs; OCSP_SINGLERESP *sres, *sres_new; OCSP_CERTID *id; int n; GetOCSPCertId(target, id); GetOCSPBasicRes(self, bs); if ((n = OCSP_resp_find(bs, id, -1)) == -1) return Qnil; sres = OCSP_resp_get0(bs, n); sres_new = ASN1_item_dup(ASN1_ITEM_rptr(OCSP_SINGLERESP), sres); if (!sres_new) ossl_raise(eOCSPError, "ASN1_item_dup"); return ossl_ocspsres_new(sres_new); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::OCSP::BasicResponse#sign;F;7[[@90;[[@Hi;T;;7;0;[;{;IC; "MSigns this OCSP response using the _cert_, _key_ and optional _digest_. This behaves in the similar way as OpenSSL::OCSP::Request#sign. _flags_ can include: OpenSSL::OCSP::NOCERTS:: don't include certificates OpenSSL::OCSP::NOTIME:: don't set producedAt OpenSSL::OCSP::RESPID_KEY:: use signer's public key hash as responderID ;T;[o;= ;>I" overload;F;?0;;7;@0;:I":sign(cert, key, certs = nil, flags = 0, digest = nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[ [I" cert;T0[I"key;T0[I" certs;TI"nil;T[I" flags;TI"0;T[I" digest;TI"nil;T;$@;![;"I"Signs this OCSP response using the _cert_, _key_ and optional _digest_. This behaves in the similar way as OpenSSL::OCSP::Request#sign. _flags_ can include: OpenSSL::OCSP::NOCERTS:: don't include certificates OpenSSL::OCSP::NOTIME:: don't set producedAt OpenSSL::OCSP::RESPID_KEY:: use signer's public key hash as responderID @overload sign(cert, key, certs = nil, flags = 0, digest = nil) @return [self];T;#0;$@;.F;/o;0;1T;2i;3i;%@Á;9I"gstatic VALUE ossl_ocspbres_sign(int argc, VALUE *argv, VALUE self) { VALUE signer_cert, signer_key, certs, flags, digest; OCSP_BASICRESP *bs; X509 *signer; EVP_PKEY *key; STACK_OF(X509) *x509s = NULL; unsigned long flg = 0; const EVP_MD *md; int ret; rb_scan_args(argc, argv, "23", &signer_cert, &signer_key, &certs, &flags, &digest); GetOCSPBasicRes(self, bs); signer = GetX509CertPtr(signer_cert); key = GetPrivPKeyPtr(signer_key); if (!NIL_P(flags)) flg = NUM2INT(flags); if (NIL_P(digest)) md = EVP_sha1(); else md = ossl_evp_get_digestbyname(digest); if (NIL_P(certs)) flg |= OCSP_NOCERTS; else x509s = ossl_x509_ary2sk(certs); ret = OCSP_basic_sign(bs, signer, key, md, x509s, flg); sk_X509_pop_free(x509s, X509_free); if (!ret) ossl_raise(eOCSPError, NULL); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(OpenSSL::OCSP::BasicResponse#verify;F;7[[@90;[[@Hi";T;;J;0;[;{;IC; "Verifies the signature of the response using the given _certificates_ and _store_. This works in the similar way as OpenSSL::OCSP::Request#verify. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I"+verify(certificates, store, flags = 0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@т;![;"I"@return [Boolean];T;#0;$@т;.F;Bi;C0;7[[I"certificates;T0[I" store;T0[I" flags;TI"0;T;$@т;![;"I"Verifies the signature of the response using the given _certificates_ and _store_. This works in the similar way as OpenSSL::OCSP::Request#verify. @overload verify(certificates, store, flags = 0) @return [Boolean];T;#0;$@т;.F;/o;0;1T;2i;3i ;%@Á;9I"Mstatic VALUE ossl_ocspbres_verify(int argc, VALUE *argv, VALUE self) { VALUE certs, store, flags; OCSP_BASICRESP *bs; STACK_OF(X509) *x509s; X509_STORE *x509st; int flg, result; rb_scan_args(argc, argv, "21", &certs, &store, &flags); GetOCSPBasicRes(self, bs); x509st = GetX509StorePtr(store); flg = NIL_P(flags) ? 0 : NUM2INT(flags); x509s = ossl_x509_ary2sk(certs); result = OCSP_basic_verify(bs, x509s, x509st, flg); sk_X509_pop_free(x509s, X509_free); if (result <= 0) ossl_clear_error(); return result > 0 ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(OpenSSL::OCSP::BasicResponse#to_der;F;7[;[[@Hi>;T;;M;0;[;{;IC; ";Encodes this basic response into a DER-encoded string. ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" to_der;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"aEncodes this basic response into a DER-encoded string. @overload to_der @return [String];T;#0;$@;.F;/o;0;1T;2i8;3i<;%@Á;9I"static VALUE ossl_ocspbres_to_der(VALUE self) { OCSP_BASICRESP *res; VALUE str; long len; unsigned char *p; GetOCSPBasicRes(self, res); if ((len = i2d_OCSP_BASICRESP(res, NULL)) <= 0) ossl_raise(eOCSPError, NULL); str = rb_str_new(0, len); p = (unsigned char *)RSTRING_PTR(str); if (i2d_OCSP_BASICRESP(res, &p) <= 0) ossl_raise(eOCSPError, NULL); ossl_str_adjust(str, p); return str; };T;:I"static VALUE;T;;T; @Á; IC;[; @Á; IC;[; @Á; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Hi;F;:BasicResponse;;;;;[;{;IC; " ;T;[;![;"@;#0;$@Á;Bi;%@;&I"!OpenSSL::OCSP::BasicResponse;F;'@o; ;IC;[o;4;5F;6;;;;&I"2OpenSSL::OCSP::SingleResponse#initialize_copy;F;7[[I" other;T0;[[@Hi;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@ ;%@;9I"static VALUE ossl_ocspsres_initialize_copy(VALUE self, VALUE other) { OCSP_SINGLERESP *sres, *sres_old, *sres_new; rb_check_frozen(self); GetOCSPSingleRes(self, sres_old); GetOCSPSingleRes(other, sres); sres_new = ASN1_item_dup(ASN1_ITEM_rptr(OCSP_SINGLERESP), sres); if (!sres_new) ossl_raise(eOCSPError, "ASN1_item_dup"); SetOCSPSingleRes(self, sres_new); OCSP_SINGLERESP_free(sres_old); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"-OpenSSL::OCSP::SingleResponse#initialize;F;7[[I"arg;T0;[[@Hit;T;;D;0;[;{;IC; "4Creates a new SingleResponse from _der_string_. ;T;[o;= ;>I" overload;F;?0;:&OpenSSL::OCSP::SingleResponse.new;@0;:I"2OpenSSL::OCSP::SingleResponse.new(der_string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"SingleResponse;T;$@.;![;"I"@return [SingleResponse];T;#0;$@.;.F;Bi;C0;7[[I"der_string;T0;$@.;![;"I"Creates a new SingleResponse from _der_string_. @overload OpenSSL::OCSP::SingleResponse.new(der_string) @return [SingleResponse];T;#0;$@.;.F;/o;0;1T;2in;3ir;%@;9I"static VALUE ossl_ocspsres_initialize(VALUE self, VALUE arg) { OCSP_SINGLERESP *res, *res_new; const unsigned char *p; arg = ossl_to_der_if_possible(arg); StringValue(arg); GetOCSPSingleRes(self, res); p = (unsigned char*)RSTRING_PTR(arg); res_new = d2i_OCSP_SINGLERESP(NULL, &p, RSTRING_LEN(arg)); if (!res_new) ossl_raise(eOCSPError, "d2i_OCSP_SINGLERESP"); SetOCSPSingleRes(self, res_new); OCSP_SINGLERESP_free(res); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"1OpenSSL::OCSP::SingleResponse#check_validity;F;7[[@90;[[@Hi;T;:check_validity;0;[;{;IC; "Checks the validity of thisUpdate and nextUpdate fields of this SingleResponse. This checks the current time is within the range thisUpdate to nextUpdate. It is possible that the OCSP request takes a few seconds or the time is not accurate. To avoid rejecting a valid response, this method allows the times to be within _nsec_ seconds of the current time. Some responders don't set the nextUpdate field. This may cause a very old response to be considered valid. The _maxsec_ parameter can be used to limit the age of responses. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"*check_validity(nsec = 0, maxsec = -1);T;IC; ";T;[;![;"I";T;#0;$@M;.F;Bi;C0;7[[I" nsec;TI"0;T[I" maxsec;TI"-1;T;$@M;![;"I"DChecks the validity of thisUpdate and nextUpdate fields of this SingleResponse. This checks the current time is within the range thisUpdate to nextUpdate. It is possible that the OCSP request takes a few seconds or the time is not accurate. To avoid rejecting a valid response, this method allows the times to be within _nsec_ seconds of the current time. Some responders don't set the nextUpdate field. This may cause a very old response to be considered valid. The _maxsec_ parameter can be used to limit the age of responses. @overload check_validity(nsec = 0, maxsec = -1);T;#0;$@M;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_ocspsres_check_validity(int argc, VALUE *argv, VALUE self) { OCSP_SINGLERESP *sres; ASN1_GENERALIZEDTIME *this_update, *next_update; VALUE nsec_v, maxsec_v; int nsec, maxsec, status, ret; rb_scan_args(argc, argv, "02", &nsec_v, &maxsec_v); nsec = NIL_P(nsec_v) ? 0 : NUM2INT(nsec_v); maxsec = NIL_P(maxsec_v) ? -1 : NUM2INT(maxsec_v); GetOCSPSingleRes(self, sres); status = OCSP_single_get0_status(sres, NULL, NULL, &this_update, &next_update); if (status < 0) ossl_raise(eOCSPError, "OCSP_single_get0_status"); ret = OCSP_check_validity(this_update, next_update, nsec, maxsec); if (ret) return Qtrue; else { ossl_clear_error(); return Qfalse; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I")OpenSSL::OCSP::SingleResponse#certid;F;7[;[[@Hi;T;;;0;[;{;IC; "@Returns the CertificateId for which this SingleResponse is. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" certid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"CertificateId;T;$@j;![;"I"@return [CertificateId];T;#0;$@j;.F;Bi;C0;7[;$@j;![;"I"mReturns the CertificateId for which this SingleResponse is. @overload certid @return [CertificateId];T;#0;$@j;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_ocspsres_get_certid(VALUE self) { OCSP_SINGLERESP *sres; OCSP_CERTID *id; GetOCSPSingleRes(self, sres); id = OCSP_CERTID_dup((OCSP_CERTID *)OCSP_SINGLERESP_get0_id(sres)); /* FIXME */ return ossl_ocspcertid_new(id); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I".OpenSSL::OCSP::SingleResponse#cert_status;F;7[;[[@Hi;T;:cert_status;0;[;{;IC; "/Returns the status of the certificate identified by the certid. The return value may be one of these constant: - V_CERTSTATUS_GOOD - V_CERTSTATUS_REVOKED - V_CERTSTATUS_UNKNOWN When the status is V_CERTSTATUS_REVOKED, the time at which the certificate was revoked can be retrieved by #revocation_time. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"cert_status;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"[Returns the status of the certificate identified by the certid. The return value may be one of these constant: - V_CERTSTATUS_GOOD - V_CERTSTATUS_REVOKED - V_CERTSTATUS_UNKNOWN When the status is V_CERTSTATUS_REVOKED, the time at which the certificate was revoked can be retrieved by #revocation_time. @overload cert_status @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"1static VALUE ossl_ocspsres_get_cert_status(VALUE self) { OCSP_SINGLERESP *sres; int status; GetOCSPSingleRes(self, sres); status = OCSP_single_get0_status(sres, NULL, NULL, NULL, NULL); if (status < 0) ossl_raise(eOCSPError, "OCSP_single_get0_status"); return INT2NUM(status); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I".OpenSSL::OCSP::SingleResponse#this_update;F;7[;[[@Hi;T;:this_update;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"this_update;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@;![;"I"@return [Time];T;#0;$@;.F;Bi;C0;7[;$@;![;"I", @overload this_update @return [Time];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"vstatic VALUE ossl_ocspsres_get_this_update(VALUE self) { OCSP_SINGLERESP *sres; int status; ASN1_GENERALIZEDTIME *time; GetOCSPSingleRes(self, sres); status = OCSP_single_get0_status(sres, NULL, NULL, &time, NULL); if (status < 0) ossl_raise(eOCSPError, "OCSP_single_get0_status"); if (!time) return Qnil; return asn1time_to_time(time); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I".OpenSSL::OCSP::SingleResponse#next_update;F;7[;[[@Hi ;T;:next_update;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"next_update;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Time | nil;T;$@;![;"I"@return [Time | nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"2 @overload next_update @return [Time | nil];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"vstatic VALUE ossl_ocspsres_get_next_update(VALUE self) { OCSP_SINGLERESP *sres; int status; ASN1_GENERALIZEDTIME *time; GetOCSPSingleRes(self, sres); status = OCSP_single_get0_status(sres, NULL, NULL, NULL, &time); if (status < 0) ossl_raise(eOCSPError, "OCSP_single_get0_status"); if (!time) return Qnil; return asn1time_to_time(time); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"2OpenSSL::OCSP::SingleResponse#revocation_time;F;7[;[[@Hi";T;:revocation_time;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"revocation_time;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Time | nil;T;$@փ;![;"I"@return [Time | nil];T;#0;$@փ;.F;Bi;C0;7[;$@փ;![;"I"6 @overload revocation_time @return [Time | nil];T;#0;$@փ;.F;/o;0;1T;2i;3i ;%@;9I"static VALUE ossl_ocspsres_get_revocation_time(VALUE self) { OCSP_SINGLERESP *sres; int status; ASN1_GENERALIZEDTIME *time; GetOCSPSingleRes(self, sres); status = OCSP_single_get0_status(sres, NULL, &time, NULL, NULL); if (status < 0) ossl_raise(eOCSPError, "OCSP_single_get0_status"); if (status != V_OCSP_CERTSTATUS_REVOKED) ossl_raise(eOCSPError, "certificate is not revoked"); if (!time) return Qnil; return asn1time_to_time(time); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"4OpenSSL::OCSP::SingleResponse#revocation_reason;F;7[;[[@Hi9;T;:revocation_reason;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"revocation_reason;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Integer | nil;T;$@;![;"I"@return [Integer | nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"; @overload revocation_reason @return [Integer | nil];T;#0;$@;.F;/o;0;1T;2i5;3i7;%@;9I"static VALUE ossl_ocspsres_get_revocation_reason(VALUE self) { OCSP_SINGLERESP *sres; int status, reason; GetOCSPSingleRes(self, sres); status = OCSP_single_get0_status(sres, &reason, NULL, NULL, NULL); if (status < 0) ossl_raise(eOCSPError, "OCSP_single_get0_status"); if (status != V_OCSP_CERTSTATUS_REVOKED) ossl_raise(eOCSPError, "certificate is not revoked"); return INT2NUM(reason); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"-OpenSSL::OCSP::SingleResponse#extensions;F;7[;[[@HiM;T;:extensions;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"extensions;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Array of X509::Extension;T;$@ ;![;"I"'@return [Array of X509::Extension];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"? @overload extensions @return [Array of X509::Extension];T;#0;$@ ;.F;/o;0;1T;2iI;3iK;%@;9I"static VALUE ossl_ocspsres_get_extensions(VALUE self) { OCSP_SINGLERESP *sres; X509_EXTENSION *ext; int count, i; VALUE ary; GetOCSPSingleRes(self, sres); count = OCSP_SINGLERESP_get_ext_count(sres); ary = rb_ary_new2(count); for (i = 0; i < count; i++) { ext = OCSP_SINGLERESP_get_ext(sres, i); rb_ary_push(ary, ossl_x509ext_new(ext)); /* will dup */ } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I")OpenSSL::OCSP::SingleResponse#to_der;F;7[;[[@Hig;T;;M;0;[;{;IC; ";Encodes this SingleResponse into a DER-encoded string. ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" to_der;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@';![;"I"@return [String];T;#0;$@';.F;Bi;C0;7[;$@';![;"I"aEncodes this SingleResponse into a DER-encoded string. @overload to_der @return [String];T;#0;$@';.F;/o;0;1T;2ia;3ie;%@;9I"static VALUE ossl_ocspsres_to_der(VALUE self) { OCSP_SINGLERESP *sres; VALUE str; long len; unsigned char *p; GetOCSPSingleRes(self, sres); if ((len = i2d_OCSP_SINGLERESP(sres, NULL)) <= 0) ossl_raise(eOCSPError, NULL); str = rb_str_new(0, len); p = (unsigned char *)RSTRING_PTR(str); if (i2d_OCSP_SINGLERESP(sres, &p) <= 0) ossl_raise(eOCSPError, NULL); ossl_str_adjust(str, p); return str; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Hi%;F;:SingleResponse;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I""OpenSSL::OCSP::SingleResponse;F;'@o; ;IC;[o;4;5F;6;;;;&I"1OpenSSL::OCSP::CertificateId#initialize_copy;F;7[[I" other;T0;[[@Hi;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@S;%@Q;9I"static VALUE ossl_ocspcid_initialize_copy(VALUE self, VALUE other) { OCSP_CERTID *cid, *cid_old, *cid_new; rb_check_frozen(self); GetOCSPCertId(self, cid_old); GetOCSPCertId(other, cid); cid_new = OCSP_CERTID_dup(cid); if (!cid_new) ossl_raise(eOCSPError, "OCSP_CERTID_dup"); SetOCSPCertId(self, cid_new); OCSP_CERTID_free(cid_old); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",OpenSSL::OCSP::CertificateId#initialize;F;7[[@90;[[@Hi;T;;D;0;[;{;IC; "lCreates a new OpenSSL::OCSP::CertificateId for the given _subject_ and _issuer_ X509 certificates. The _digest_ is a digest algorithm that is used to compute the hash values. This defaults to SHA-1. If only one argument is given, decodes it as DER representation of a certificate ID or generates certificate ID from the object that responds to the to_der method. ;T;[o;= ;>I" overload;F;?0;:%OpenSSL::OCSP::CertificateId.new;@0;:I"DOpenSSL::OCSP::CertificateId.new(subject, issuer, digest = nil);T;IC; ";T;[;![;"I";T;#0;$@a;.F;Bi;C0;7[[I" subject;T0[I" issuer;T0[I" digest;TI"nil;T;$@ao;= ;>I" overload;F;?0;; ;@0;:I"1OpenSSL::OCSP::CertificateId.new(der_string);T;IC; ";T;[;![;"I";T;#0;$@a;.F;Bi;C0;7[[I"der_string;T0;$@ao;= ;>I" overload;F;?0;; ;@0;:I"*OpenSSL::OCSP::CertificateId.new(obj);T;IC; ";T;[;![;"I";T;#0;$@a;.F;Bi;C0;7[[I"obj;T0;$@a;![;"I"Creates a new OpenSSL::OCSP::CertificateId for the given _subject_ and _issuer_ X509 certificates. The _digest_ is a digest algorithm that is used to compute the hash values. This defaults to SHA-1. If only one argument is given, decodes it as DER representation of a certificate ID or generates certificate ID from the object that responds to the to_der method. @overload OpenSSL::OCSP::CertificateId.new(subject, issuer, digest = nil) @overload OpenSSL::OCSP::CertificateId.new(der_string) @overload OpenSSL::OCSP::CertificateId.new(obj);T;#0;$@a;.F;/o;0;1T;2i;3i;%@Q;9I"static VALUE ossl_ocspcid_initialize(int argc, VALUE *argv, VALUE self) { OCSP_CERTID *id, *newid; VALUE subject, issuer, digest; GetOCSPCertId(self, id); if (rb_scan_args(argc, argv, "12", &subject, &issuer, &digest) == 1) { VALUE arg; const unsigned char *p; arg = ossl_to_der_if_possible(subject); StringValue(arg); p = (unsigned char *)RSTRING_PTR(arg); newid = d2i_OCSP_CERTID(NULL, &p, RSTRING_LEN(arg)); if (!newid) ossl_raise(eOCSPError, "d2i_OCSP_CERTID"); } else { X509 *x509s, *x509i; const EVP_MD *md; x509s = GetX509CertPtr(subject); /* NO NEED TO DUP */ x509i = GetX509CertPtr(issuer); /* NO NEED TO DUP */ md = !NIL_P(digest) ? ossl_evp_get_digestbyname(digest) : NULL; newid = OCSP_cert_to_id(md, x509s, x509i); if (!newid) ossl_raise(eOCSPError, "OCSP_cert_to_id"); } SetOCSPCertId(self, newid); OCSP_CERTID_free(id); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%OpenSSL::OCSP::CertificateId#cmp;F;7[[I" other;T0;[[@Hi;T;:cmp;0;[;{;IC; "WCompares this certificate id with _other_ and returns +true+ if they are the same. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"cmp(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" other;T0;$@;![;"I"}Compares this certificate id with _other_ and returns +true+ if they are the same. @overload cmp(other) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;%@Q;9I"static VALUE ossl_ocspcid_cmp(VALUE self, VALUE other) { OCSP_CERTID *id, *id2; int result; GetOCSPCertId(self, id); GetOCSPCertId(other, id2); result = OCSP_id_cmp(id, id2); return (result == 0) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",OpenSSL::OCSP::CertificateId#cmp_issuer;F;7[[I" other;T0;[[@Hi;T;:cmp_issuer;0;[;{;IC; "`Compares this certificate id's issuer with _other_ and returns +true+ if they are the same. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"cmp_issuer(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" other;T0;$@;![;"I"Compares this certificate id's issuer with _other_ and returns +true+ if they are the same. @overload cmp_issuer(other) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;%@Q;9I"static VALUE ossl_ocspcid_cmp_issuer(VALUE self, VALUE other) { OCSP_CERTID *id, *id2; int result; GetOCSPCertId(self, id); GetOCSPCertId(other, id2); result = OCSP_id_issuer_cmp(id, id2); return (result == 0) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(OpenSSL::OCSP::CertificateId#serial;F;7[;[[@Hi;T;;O;0;[;{;IC; "VReturns the serial number of the certificate for which status is being requested. ;T;[o;= ;>I" overload;F;?0;;O;@0;:I" serial;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ф;![;"I"@return [Integer];T;#0;$@ф;.F;Bi;C0;7[;$@ф;![;"I"}Returns the serial number of the certificate for which status is being requested. @overload serial @return [Integer];T;#0;$@ф;.F;/o;0;1T;2i;3i;%@Q;9I"static VALUE ossl_ocspcid_get_serial(VALUE self) { OCSP_CERTID *id; ASN1_INTEGER *serial; GetOCSPCertId(self, id); OCSP_id_get0_info(NULL, NULL, NULL, &serial, id); return asn1integer_to_num(serial); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"2OpenSSL::OCSP::CertificateId#issuer_name_hash;F;7[;[[@Hi;T;:issuer_name_hash;0;[;{;IC; "Returns the issuerNameHash of this certificate ID, the hash of the issuer's distinguished name calculated with the hashAlgorithm. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"issuer_name_hash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the issuerNameHash of this certificate ID, the hash of the issuer's distinguished name calculated with the hashAlgorithm. @overload issuer_name_hash @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@Q;9I"hstatic VALUE ossl_ocspcid_get_issuer_name_hash(VALUE self) { OCSP_CERTID *id; ASN1_OCTET_STRING *name_hash; VALUE ret; GetOCSPCertId(self, id); OCSP_id_get0_info(&name_hash, NULL, NULL, NULL, id); ret = rb_str_new(NULL, name_hash->length * 2); ossl_bin2hex(name_hash->data, RSTRING_PTR(ret), name_hash->length); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"1OpenSSL::OCSP::CertificateId#issuer_key_hash;F;7[;[[@Hi-;T;:issuer_key_hash;0;[;{;IC; "[Returns the issuerKeyHash of this certificate ID, the hash of the issuer's public key. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"issuer_key_hash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the issuerKeyHash of this certificate ID, the hash of the issuer's public key. @overload issuer_key_hash @return [String];T;#0;$@;.F;/o;0;1T;2i&;3i+;%@Q;9I"bstatic VALUE ossl_ocspcid_get_issuer_key_hash(VALUE self) { OCSP_CERTID *id; ASN1_OCTET_STRING *key_hash; VALUE ret; GetOCSPCertId(self, id); OCSP_id_get0_info(NULL, NULL, &key_hash, NULL, id); ret = rb_str_new(NULL, key_hash->length * 2); ossl_bin2hex(key_hash->data, RSTRING_PTR(ret), key_hash->length); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"0OpenSSL::OCSP::CertificateId#hash_algorithm;F;7[;[[@HiD;T;:hash_algorithm;0;[;{;IC; "wReturns the ln (long name) of the hash algorithm used to generate the issuerNameHash and the issuerKeyHash values. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"hash_algorithm;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@";![;"I"@return [String];T;#0;$@";.F;Bi;C0;7[;$@";![;"I"Returns the ln (long name) of the hash algorithm used to generate the issuerNameHash and the issuerKeyHash values. @overload hash_algorithm @return [String];T;#0;$@";.F;/o;0;1T;2i=;3iB;%@Q;9I"static VALUE ossl_ocspcid_get_hash_algorithm(VALUE self) { OCSP_CERTID *id; ASN1_OBJECT *oid; BIO *out; GetOCSPCertId(self, id); OCSP_id_get0_info(NULL, &oid, NULL, NULL, id); if (!(out = BIO_new(BIO_s_mem()))) ossl_raise(eOCSPError, "BIO_new"); if (!i2a_ASN1_OBJECT(out, oid)) { BIO_free(out); ossl_raise(eOCSPError, "i2a_ASN1_OBJECT"); } return ossl_membio2str(out); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(OpenSSL::OCSP::CertificateId#to_der;F;7[;[[@Hi^;T;;M;0;[;{;IC; "CEncodes this certificate identifier into a DER-encoded string. ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" to_der;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@=;![;"I"@return [String];T;#0;$@=;.F;Bi;C0;7[;$@=;![;"I"iEncodes this certificate identifier into a DER-encoded string. @overload to_der @return [String];T;#0;$@=;.F;/o;0;1T;2iX;3i\;%@Q;9I"static VALUE ossl_ocspcid_to_der(VALUE self) { OCSP_CERTID *id; VALUE str; long len; unsigned char *p; GetOCSPCertId(self, id); if ((len = i2d_OCSP_CERTID(id, NULL)) <= 0) ossl_raise(eOCSPError, NULL); str = rb_str_new(0, len); p = (unsigned char *)RSTRING_PTR(str); if (i2d_OCSP_CERTID(id, &p) <= 0) ossl_raise(eOCSPError, NULL); ossl_str_adjust(str, p); return str; };T;:I"static VALUE;T;;T; @Q; IC;[; @Q; IC;[; @Q; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Hi8;F;:CertificateId;;;;;[;{;IC; " ;T;[;![;"@;#0;$@Q;Bi;%@;&I"!OpenSSL::OCSP::CertificateId;F;'@o;u;[[@HiE;F;:"RESPONSE_STATUS_INTERNALERROR;;w;;;[;{;IC; "Internal error in issuer ;T;[;![;"I"Internal error in issuer;T;#0;$@g;.F;/o;0;1T;2iD;3iD;%@;&I"1OpenSSL::OCSP::RESPONSE_STATUS_INTERNALERROR;F;xI"0INT2NUM(OCSP_RESPONSE_STATUS_INTERNALERROR);To;u;[[@HiH;F;:%RESPONSE_STATUS_MALFORMEDREQUEST;;w;;;[;{;IC; "!Illegal confirmation request ;T;[;![;"I"!Illegal confirmation request;T;#0;$@s;.F;/o;0;1T;2iG;3iG;%@;&I"4OpenSSL::OCSP::RESPONSE_STATUS_MALFORMEDREQUEST;F;xI"3INT2NUM(OCSP_RESPONSE_STATUS_MALFORMEDREQUEST);To;u;[[@HiK;F;:REVOKED_STATUS_NOSTATUS;;w;;;[;{;IC; "6The certificate was revoked for an unknown reason ;T;[;![;"I"6The certificate was revoked for an unknown reason;T;#0;$@;.F;/o;0;1T;2iJ;3iJ;%@;&I"+OpenSSL::OCSP::REVOKED_STATUS_NOSTATUS;F;xI"*INT2NUM(OCSP_REVOKED_STATUS_NOSTATUS);To;u;[[@HiN;F;: RESPONSE_STATUS_SIGREQUIRED;;w;;;[;{;IC; "+You must sign the request and resubmit ;T;[;![;"I"+You must sign the request and resubmit;T;#0;$@;.F;/o;0;1T;2iM;3iM;%@;&I"/OpenSSL::OCSP::RESPONSE_STATUS_SIGREQUIRED;F;xI".INT2NUM(OCSP_RESPONSE_STATUS_SIGREQUIRED);To;u;[[@HiQ;F;:RESPONSE_STATUS_SUCCESSFUL;;w;;;[;{;IC; "%Response has valid confirmations ;T;[;![;"I"%Response has valid confirmations;T;#0;$@;.F;/o;0;1T;2iP;3iP;%@;&I".OpenSSL::OCSP::RESPONSE_STATUS_SUCCESSFUL;F;xI"-INT2NUM(OCSP_RESPONSE_STATUS_SUCCESSFUL);To;u;[[@HiT;F;:RESPONSE_STATUS_TRYLATER;;w;;;[;{;IC; "Try again later ;T;[;![;"I"Try again later;T;#0;$@;.F;/o;0;1T;2iS;3iS;%@;&I",OpenSSL::OCSP::RESPONSE_STATUS_TRYLATER;F;xI"+INT2NUM(OCSP_RESPONSE_STATUS_TRYLATER);To;u;[[@HiW;F;:&REVOKED_STATUS_AFFILIATIONCHANGED;;w;;;[;{;IC; "@The certificate subject's name or other information changed ;T;[;![;"I"@The certificate subject's name or other information changed;T;#0;$@;.F;/o;0;1T;2iV;3iV;%@;&I"5OpenSSL::OCSP::REVOKED_STATUS_AFFILIATIONCHANGED;F;xI"4INT2NUM(OCSP_REVOKED_STATUS_AFFILIATIONCHANGED);To;u;[[@HiZ;F;: REVOKED_STATUS_CACOMPROMISE;;w;;;[;{;IC; "#ifdef OPENSSL_FIPS Qtrue #else Qfalse #endif;To;4;5F;6;;;;&I"OpenSSL#fips_mode;F;7[;[;F;:fips_mode;;;[;{;IC; " ;T;[;![;"I";F;#0;$@,;.F;C0;%@GH;;To;4;5T;6;;;;&I"OpenSSL.fips_mode;F;7@.;@/;F;;7;;;@0;{;IC; " ;T;[;![;"@;#0;$@6;Bi;%@GH;;To;4;5F;6;;;;&I"OpenSSL#fips_mode=;F;7[;[;F;:fips_mode=;;;[;{;IC; " ;T;[;![;"I";F;#0;$@<;.F;C0;%@GH;;To;4;5T;6;;;;&I"OpenSSL.fips_mode=;F;7@>;@?;F;;8;;;@@;{;IC; " ;T;[;![;"@;#0;$@F;Bi;%@GH;;To;4;5F;6;;;;&I"OpenSSL#debug;F;7[;[;F;: debug;;;[;{;IC; " ;T;[;![;"I";F;#0;$@L;.F;C0;%@GH;;To;4;5T;6;;;;&I"OpenSSL.debug;F;7@N;@O;F;;9;;;@P;{;IC; " ;T;[;![;"@;#0;$@V;Bi;%@GH;;To;4;5F;6;;;;&I"OpenSSL#debug=;F;7[;[;F;: debug=;;;[;{;IC; " ;T;[;![;"I";F;#0;$@\;.F;C0;%@GH;;To;4;5T;6;;;;&I"OpenSSL.debug=;F;7@^;@_;F;;:;;;@`;{;IC; " ;T;[;![;"@;#0;$@f;Bi;%@GH;;To;4;5F;6;;;;&I"OpenSSL#errors;F;7[;[;F;: errors;;;[;{;IC; " ;T;[;![;"I";F;#0;$@l;.F;C0;%@GH;;To;4;5T;6;;;;&I"OpenSSL.errors;F;7@n;@o;F;;;;;;@p;{;IC; " ;T;[;![;"@;#0;$@v;Bi;%@GH;;To;4;5F;6;;;;&I"OpenSSL#mem_check_start;F;7[;[;F;:mem_check_start;;;[;{;IC; " ;T;[;![;"I";F;#0;$@|;.F;C0;%@GH;;To;4;5T;6;;;;&I"OpenSSL.mem_check_start;F;7@~;@;F;;<;;;@;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@GH;;To;4;5F;6;;;;&I"OpenSSL#print_mem_leaks;F;7[;[;F;:print_mem_leaks;;;[;{;IC; " ;T;[;![;"I";F;#0;$@;.F;C0;%@GH;;To;4;5T;6;;;;&I"OpenSSL.print_mem_leaks;F;7@;@;F;;=;;;@;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@GH;;To;;IC;[o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Hi;F;:RequestError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I" OpenSSL::X509::RequestError;F;'@Ho; ;IC;[o;4;5F;6;;;;&I"&OpenSSL::X509::Request#initialize;F;7[[@90;[[@HiS;T;;D;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE ossl_x509req_initialize(int argc, VALUE *argv, VALUE self) { BIO *in; X509_REQ *req, *req_orig = RTYPEDDATA_DATA(self); VALUE arg; rb_check_frozen(self); if (rb_scan_args(argc, argv, "01", &arg) == 0) { return self; } arg = ossl_to_der_if_possible(arg); in = ossl_obj2bio(&arg); req = d2i_X509_REQ_bio(in, NULL); if (!req) { OSSL_BIO_reset(in); req = PEM_read_bio_X509_REQ(in, NULL, NULL, NULL); } BIO_free(in); if (!req) ossl_raise(eX509ReqError, "PEM_read_bio_X509_REQ"); RTYPEDDATA_DATA(self) = req; X509_REQ_free(req_orig); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+OpenSSL::X509::Request#initialize_copy;F;7[[I" other;T0;[[@Hio;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"Wstatic VALUE ossl_x509req_copy(VALUE self, VALUE other) { X509_REQ *a, *b, *req; rb_check_frozen(self); if (self == other) return self; GetX509Req(self, a); GetX509Req(other, b); if (!(req = X509_REQ_dup(b))) { ossl_raise(eX509ReqError, NULL); } X509_REQ_free(a); DATA_PTR(self) = req; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::X509::Request#to_pem;F;7[;[[@Hi|;T;;L;0;[;{;IC; " ;T;[;![;"@;#0;$o;4;5F;6;;;;&I" OpenSSL::X509::Request#to_s;F;7[;[[@Hi;F;;G;;;[;{;@Ӈ;%@;9I"Estatic VALUE ossl_x509req_to_pem(VALUE self) { X509_REQ *req; BIO *out; GetX509Req(self, req); if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eX509ReqError, NULL); } if (!PEM_write_bio_X509_REQ(out, req)) { BIO_free(out); ossl_raise(eX509ReqError, NULL); } return ossl_membio2str(out); };T;:I"static VALUE;T;%@;9I"Estatic VALUE ossl_x509req_to_pem(VALUE self) { X509_REQ *req; BIO *out; GetX509Req(self, req); if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eX509ReqError, NULL); } if (!PEM_write_bio_X509_REQ(out, req)) { BIO_free(out); ossl_raise(eX509ReqError, NULL); } return ossl_membio2str(out); };T;:@އ;;To;4;5F;6;;;;&I""OpenSSL::X509::Request#to_der;F;7[;[[@Hi;T;;M;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE ossl_x509req_to_der(VALUE self) { X509_REQ *req; VALUE str; long len; unsigned char *p; GetX509Req(self, req); if ((len = i2d_X509_REQ(req, NULL)) <= 0) ossl_raise(eX509ReqError, NULL); str = rb_str_new(0, len); p = (unsigned char *)RSTRING_PTR(str); if (i2d_X509_REQ(req, &p) <= 0) ossl_raise(eX509ReqError, NULL); ossl_str_adjust(str, p); return str; };T;:I"static VALUE;T;;T@ևo;4;5F;6;;;;&I"#OpenSSL::X509::Request#to_text;F;7[;[[@Hi;T;;\;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I">static VALUE ossl_x509req_to_text(VALUE self) { X509_REQ *req; BIO *out; GetX509Req(self, req); if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eX509ReqError, NULL); } if (!X509_REQ_print(out, req)) { BIO_free(out); ossl_raise(eX509ReqError, NULL); } return ossl_membio2str(out); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::X509::Request#version;F;7[;[[@Hi;T;: version;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE ossl_x509req_get_version(VALUE self) { X509_REQ *req; long version; GetX509Req(self, req); version = X509_REQ_get_version(req); return LONG2NUM(version); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$OpenSSL::X509::Request#version=;F;7[[I" version;T0;[[@Hi;T;: version=;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"_static VALUE ossl_x509req_set_version(VALUE self, VALUE version) { X509_REQ *req; long ver; if ((ver = NUM2LONG(version)) < 0) { ossl_raise(eX509ReqError, "version must be >= 0!"); } GetX509Req(self, req); if (!X509_REQ_set_version(req, ver)) { ossl_raise(eX509ReqError, "X509_REQ_set_version"); } return version; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::X509::Request#subject;F;7[;[[@Hi;T;: subject;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE ossl_x509req_get_subject(VALUE self) { X509_REQ *req; X509_NAME *name; GetX509Req(self, req); if (!(name = X509_REQ_get_subject_name(req))) { /* NO DUP - don't free */ ossl_raise(eX509ReqError, NULL); } return ossl_x509name_new(name); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$OpenSSL::X509::Request#subject=;F;7[[I" subject;T0;[[@Hi;T;: subject=;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE ossl_x509req_set_subject(VALUE self, VALUE subject) { X509_REQ *req; GetX509Req(self, req); /* DUPs name */ if (!X509_REQ_set_subject_name(req, GetX509NamePtr(subject))) { ossl_raise(eX509ReqError, NULL); } return subject; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"/OpenSSL::X509::Request#signature_algorithm;F;7[;[[@Hi;T;:signature_algorithm;0;[;{;IC; " ;T;[;![;"@;#0;$@,;%@;9I"static VALUE ossl_x509req_get_signature_algorithm(VALUE self) { X509_REQ *req; const X509_ALGOR *alg; BIO *out; GetX509Req(self, req); if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eX509ReqError, NULL); } X509_REQ_get0_signature(req, NULL, &alg); if (!i2a_ASN1_OBJECT(out, alg->algorithm)) { BIO_free(out); ossl_raise(eX509ReqError, NULL); } return ossl_membio2str(out); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::X509::Request#public_key;F;7[;[[@Hi;T;:public_key;0;[;{;IC; " ;T;[;![;"@;#0;$@8;%@;9I"static VALUE ossl_x509req_get_public_key(VALUE self) { X509_REQ *req; EVP_PKEY *pkey; GetX509Req(self, req); if (!(pkey = X509_REQ_get_pubkey(req))) { /* adds reference */ ossl_raise(eX509ReqError, NULL); } return ossl_pkey_new(pkey); /* NO DUP - OK */ };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::X509::Request#public_key=;F;7[[I"key;T0;[[@Hi$;T;:public_key=;0;[;{;IC; "NO DUP - OK ;T;[;![;"I"NO DUP - OK;T;#0;$@D;.F;/o;0;1T;2i!;3i!;%@;9I"4static VALUE ossl_x509req_set_public_key(VALUE self, VALUE key) { X509_REQ *req; EVP_PKEY *pkey; GetX509Req(self, req); pkey = GetPKeyPtr(key); ossl_pkey_check_public_key(pkey); if (!X509_REQ_set_pubkey(req, pkey)) ossl_raise(eX509ReqError, "X509_REQ_set_pubkey"); return key; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" OpenSSL::X509::Request#sign;F;7[[I"key;T0[I" digest;T0;[[@Hi2;T;;7;0;[;{;IC; " ;T;[;![;"@;#0;$@T;%@;9I"dstatic VALUE ossl_x509req_sign(VALUE self, VALUE key, VALUE digest) { X509_REQ *req; EVP_PKEY *pkey; const EVP_MD *md; GetX509Req(self, req); pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */ md = ossl_evp_get_digestbyname(digest); if (!X509_REQ_sign(req, pkey, md)) { ossl_raise(eX509ReqError, NULL); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::X509::Request#verify;F;7[[I"key;T0;[[@HiF;T;;J;0;[;{;IC; "MChecks that cert signature is made with PRIVversion of this PUBLIC 'key' ;T;[;![;"I"NChecks that cert signature is made with PRIVversion of this PUBLIC 'key' ;T;#0;$@d;.F;/o;0;1T;2iC;3iD;%@;9I"qstatic VALUE ossl_x509req_verify(VALUE self, VALUE key) { X509_REQ *req; EVP_PKEY *pkey; GetX509Req(self, req); pkey = GetPKeyPtr(key); ossl_pkey_check_public_key(pkey); switch (X509_REQ_verify(req, pkey)) { case 1: return Qtrue; case 0: ossl_clear_error(); return Qfalse; default: ossl_raise(eX509ReqError, NULL); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::X509::Request#attributes;F;7[;[[@HiZ;T;:attributes;0;[;{;IC; " ;T;[;![;"@;#0;$@t;%@;9I"static VALUE ossl_x509req_get_attributes(VALUE self) { X509_REQ *req; int count, i; X509_ATTRIBUTE *attr; VALUE ary; GetX509Req(self, req); count = X509_REQ_get_attr_count(req); if (count < 0) { OSSL_Debug("count < 0???"); return rb_ary_new(); } ary = rb_ary_new2(count); for (i=0; iI" overload;F;?0;:$OpenSSL::X509::Certificate.load;@0;:I",OpenSSL::X509::Certificate.load(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" string;T0;$@o;= ;>I" overload;F;?0;;J;@0;:I"*OpenSSL::X509::Certificate.load(file);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" file;T0;$@;![;"I"Read the chained certificates from the given input. Supports both PEM and DER encoded certificates. PEM is a text format and supports more than one certificate. DER is a binary format and only supports one certificate. If the file is empty, or contains only unrelated data, an +OpenSSL::X509::CertificateError+ exception will be raised. @overload OpenSSL::X509::Certificate.load(string) @return [Array] @overload OpenSSL::X509::Certificate.load(file) @return [Array];T;#0;$@;.F;/o;0;1T;2iF;3iT;%@;9I"static VALUE ossl_x509_load(VALUE klass, VALUE buffer) { BIO *in = ossl_obj2bio(&buffer); return rb_ensure(load_chained_certificates, (VALUE)in, load_chained_certificates_ensure, (VALUE)in); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*OpenSSL::X509::Certificate#initialize;F;7[[@90;[[@"Hiw;T;;D;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;E;@0;:I"new(string);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;T0;$@;![;"I") @overload new @overload new(string);T;#0;$@;.F;/o;0;1T;2ir;3it;%@;9I"static VALUE ossl_x509_initialize(int argc, VALUE *argv, VALUE self) { BIO *in; X509 *x509, *x509_orig = RTYPEDDATA_DATA(self); VALUE arg; rb_check_frozen(self); if (rb_scan_args(argc, argv, "01", &arg) == 0) { /* create just empty X509Cert */ return self; } arg = ossl_to_der_if_possible(arg); in = ossl_obj2bio(&arg); x509 = d2i_X509_bio(in, NULL); if (!x509) { OSSL_BIO_reset(in); x509 = PEM_read_bio_X509(in, NULL, NULL, NULL); } BIO_free(in); if (!x509) ossl_raise(eX509CertError, "PEM_read_bio_X509"); RTYPEDDATA_DATA(self) = x509; X509_free(x509_orig); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"/OpenSSL::X509::Certificate#initialize_copy;F;7[[I" other;T0;[[@"Hi;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@ ;%@;9I"Hstatic VALUE ossl_x509_copy(VALUE self, VALUE other) { X509 *a, *b, *x509; rb_check_frozen(self); if (self == other) return self; GetX509(self, a); GetX509(other, b); x509 = X509_dup(b); if (!x509) ossl_raise(eX509CertError, NULL); DATA_PTR(self) = x509; X509_free(a); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::X509::Certificate#to_der;F;7[;[[@"Hi;T;;M;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" to_der;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I") @overload to_der @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509_to_der(VALUE self) { X509 *x509; VALUE str; long len; unsigned char *p; GetX509(self, x509); if ((len = i2d_X509(x509, NULL)) <= 0) ossl_raise(eX509CertError, NULL); str = rb_str_new(0, len); p = (unsigned char *)RSTRING_PTR(str); if (i2d_X509(x509, &p) <= 0) ossl_raise(eX509CertError, NULL); ossl_str_adjust(str, p); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::X509::Certificate#to_pem;F;7[;[[@"Hi;T;;L;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;L;@0;:I" to_pem;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@6;![;"I"@return [String];T;#0;$@6;.F;Bi;C0;7[;$@6;![;"I") @overload to_pem @return [String];T;#0;$o;4;5F;6;;;;&I"$OpenSSL::X509::Certificate#to_s;F;7[;[[@"Hi;F;;G;;;[;{;@=;%@;9I"Ystatic VALUE ossl_x509_to_pem(VALUE self) { X509 *x509; BIO *out; VALUE str; GetX509(self, x509); out = BIO_new(BIO_s_mem()); if (!out) ossl_raise(eX509CertError, NULL); if (!PEM_write_bio_X509(out, x509)) { BIO_free(out); ossl_raise(eX509CertError, NULL); } str = ossl_membio2str(out); return str; };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@;9I"Ystatic VALUE ossl_x509_to_pem(VALUE self) { X509 *x509; BIO *out; VALUE str; GetX509(self, x509); out = BIO_new(BIO_s_mem()); if (!out) ossl_raise(eX509CertError, NULL); if (!PEM_write_bio_X509(out, x509)) { BIO_free(out); ossl_raise(eX509CertError, NULL); } str = ossl_membio2str(out); return str; };T;:@V;;T@No;4;5F;6;;;;&I"'OpenSSL::X509::Certificate#to_text;F;7[;[[@"Hi;T;;\;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;\;@0;:I" to_text;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@Y;![;"I"@return [String];T;#0;$@Y;.F;Bi;C0;7[;$@Y;![;"I"* @overload to_text @return [String];T;#0;$@Y;.F;/o;0;1T;2i;3i;%@;9I"Sstatic VALUE ossl_x509_to_text(VALUE self) { X509 *x509; BIO *out; VALUE str; GetX509(self, x509); out = BIO_new(BIO_s_mem()); if (!out) ossl_raise(eX509CertError, NULL); if (!X509_print(out, x509)) { BIO_free(out); ossl_raise(eX509CertError, NULL); } str = ossl_membio2str(out); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::X509::Certificate#version;F;7[;[[@"Hi;T;;?;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;?;@0;:I" version;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@t;![;"I"@return [Integer];T;#0;$@t;.F;Bi;C0;7[;$@t;![;"I"+ @overload version @return [Integer];T;#0;$@t;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509_get_version(VALUE self) { X509 *x509; GetX509(self, x509); return LONG2NUM(X509_get_version(x509)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(OpenSSL::X509::Certificate#version=;F;7[[I" version;T0;[[@"Hi;T;;@;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;@;@0;:I"version=(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I" integer;T0;$@;![;"I"5 @overload version=(integer) @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"Dstatic VALUE ossl_x509_set_version(VALUE self, VALUE version) { X509 *x509; long ver; if ((ver = NUM2LONG(version)) < 0) { ossl_raise(eX509CertError, "version must be >= 0!"); } GetX509(self, x509); if (!X509_set_version(x509, ver)) { ossl_raise(eX509CertError, NULL); } return version; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"3OpenSSL::X509::Certificate#signature_algorithm;F;7[;[[@"HiF;T;;C;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;C;@0;:I"signature_algorithm;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"6 @overload signature_algorithm @return [String];T;#0;$@;.F;/o;0;1T;2iB;3iD;%@;9I"static VALUE ossl_x509_get_signature_algorithm(VALUE self) { X509 *x509; BIO *out; VALUE str; GetX509(self, x509); out = BIO_new(BIO_s_mem()); if (!out) ossl_raise(eX509CertError, NULL); if (!i2a_ASN1_OBJECT(out, X509_get0_tbs_sigalg(x509)->algorithm)) { BIO_free(out); ossl_raise(eX509CertError, NULL); } str = ossl_membio2str(out); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::X509::Certificate#serial;F;7[;[[@"Hi);T;;O;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;O;@0;:I" serial;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ɉ;![;"I"@return [Integer];T;#0;$@ɉ;.F;Bi;C0;7[;$@ɉ;![;"I"* @overload serial @return [Integer];T;#0;$@ɉ;.F;/o;0;1T;2i%;3i';%@;9I"static VALUE ossl_x509_get_serial(VALUE self) { X509 *x509; GetX509(self, x509); return asn1integer_to_num(X509_get_serialNumber(x509)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::X509::Certificate#serial=;F;7[[I"num;T0;[[@"Hi7;T;: serial=;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;K;@0;:I"serial=(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I" integer;T0;$@;![;"I"4 @overload serial=(integer) @return [Integer];T;#0;$@;.F;/o;0;1T;2i3;3i5;%@;9I"static VALUE ossl_x509_set_serial(VALUE self, VALUE num) { X509 *x509; GetX509(self, x509); X509_set_serialNumber(x509, num_to_asn1integer(num, X509_get_serialNumber(x509))); return num; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::X509::Certificate#subject;F;7[;[[@"Hi^;T;;A;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;A;@0;:I" subject;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I" @overload subject;T;#0;$@;.F;/o;0;1T;2iZ;3i[;%@;9I" static VALUE ossl_x509_get_subject(VALUE self) { X509 *x509; X509_NAME *name; GetX509(self, x509); if (!(name = X509_get_subject_name(x509))) { /* NO DUP - don't free! */ ossl_raise(eX509CertError, NULL); } return ossl_x509name_new(name); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(OpenSSL::X509::Certificate#subject=;F;7[[I" subject;T0;[[@"Hip;T;;B;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;B;@0;:I"subject=(name);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" name;T0;$@;![;"I" @overload subject=(name);T;#0;$@;.F;/o;0;1T;2il;3im;%@;9I"static VALUE ossl_x509_set_subject(VALUE self, VALUE subject) { X509 *x509; GetX509(self, x509); if (!X509_set_subject_name(x509, GetX509NamePtr(subject))) { /* DUPs name */ ossl_raise(eX509CertError, NULL); } return subject; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::X509::Certificate#issuer;F;7[;[[@"Hi;T;;N;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;N;@0;:I" issuer;T;IC; ";T;[;![;"I";T;#0;$@3;.F;Bi;C0;7[;$@3;![;"I" @overload issuer;T;#0;$@3;.F;/o;0;1T;2i};3i~;%@;9I"static VALUE ossl_x509_get_issuer(VALUE self) { X509 *x509; X509_NAME *name; GetX509(self, x509); if(!(name = X509_get_issuer_name(x509))) { /* NO DUP - don't free! */ ossl_raise(eX509CertError, NULL); } return ossl_x509name_new(name); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::X509::Certificate#issuer=;F;7[[I" issuer;T0;[[@"Hi;T;: issuer=;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;L;@0;:I"issuer=(name);T;IC; ";T;[;![;"I";T;#0;$@I;.F;Bi;C0;7[[I" name;T0;$@I;![;"I" @overload issuer=(name);T;#0;$@I;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509_set_issuer(VALUE self, VALUE issuer) { X509 *x509; GetX509(self, x509); if (!X509_set_issuer_name(x509, GetX509NamePtr(issuer))) { /* DUPs name */ ossl_raise(eX509CertError, NULL); } return issuer; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*OpenSSL::X509::Certificate#not_before;F;7[;[[@"Hi;T;:not_before;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;M;@0;:I"not_before;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@c;![;"I"@return [Time];T;#0;$@c;.F;Bi;C0;7[;$@c;![;"I"+ @overload not_before @return [Time];T;#0;$@c;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509_get_not_before(VALUE self) { X509 *x509; const ASN1_TIME *asn1time; GetX509(self, x509); if (!(asn1time = X509_get0_notBefore(x509))) { ossl_raise(eX509CertError, NULL); } return asn1time_to_time(asn1time); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+OpenSSL::X509::Certificate#not_before=;F;7[[I" time;T0;[[@"Hi;T;:not_before=;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;N;@0;:I"not_before=(time);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@~;![;"I"@return [Time];T;#0;$@~;.F;Bi;C0;7[[I" time;T0;$@~;![;"I"2 @overload not_before=(time) @return [Time];T;#0;$@~;.F;/o;0;1T;2i;3i;%@;9I"jstatic VALUE ossl_x509_set_not_before(VALUE self, VALUE time) { X509 *x509; ASN1_TIME *asn1time; GetX509(self, x509); asn1time = ossl_x509_time_adjust(NULL, time); if (!X509_set1_notBefore(x509, asn1time)) { ASN1_TIME_free(asn1time); ossl_raise(eX509CertError, "X509_set_notBefore"); } ASN1_TIME_free(asn1time); return time; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I")OpenSSL::X509::Certificate#not_after;F;7[;[[@"Hi;T;:not_after;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;O;@0;:I"not_after;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@;![;"I"@return [Time];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"* @overload not_after @return [Time];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509_get_not_after(VALUE self) { X509 *x509; const ASN1_TIME *asn1time; GetX509(self, x509); if (!(asn1time = X509_get0_notAfter(x509))) { ossl_raise(eX509CertError, NULL); } return asn1time_to_time(asn1time); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*OpenSSL::X509::Certificate#not_after=;F;7[[I" time;T0;[[@"Hi;T;:not_after=;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;P;@0;:I"not_after=(time);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@;![;"I"@return [Time];T;#0;$@;.F;Bi;C0;7[[I" time;T0;$@;![;"I"1 @overload not_after=(time) @return [Time];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"gstatic VALUE ossl_x509_set_not_after(VALUE self, VALUE time) { X509 *x509; ASN1_TIME *asn1time; GetX509(self, x509); asn1time = ossl_x509_time_adjust(NULL, time); if (!X509_set1_notAfter(x509, asn1time)) { ASN1_TIME_free(asn1time); ossl_raise(eX509CertError, "X509_set_notAfter"); } ASN1_TIME_free(asn1time); return time; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*OpenSSL::X509::Certificate#public_key;F;7[;[[@"Hi;T;;D;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;D;@0;:I"public_key;T;IC; ";T;[;![;"I";T;#0;$@׊;.F;Bi;C0;7[;$@׊;![;"I" @overload public_key;T;#0;$@׊;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509_get_public_key(VALUE self) { X509 *x509; EVP_PKEY *pkey; GetX509(self, x509); if (!(pkey = X509_get_pubkey(x509))) { /* adds an reference */ ossl_raise(eX509CertError, NULL); } return ossl_pkey_new(pkey); /* NO DUP - OK */ };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+OpenSSL::X509::Certificate#public_key=;F;7[[I"key;T0;[[@"Hi;T;;E;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"public_key=(key);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"key;T0;$@;![;"I" @overload public_key=(key);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"&static VALUE ossl_x509_set_public_key(VALUE self, VALUE key) { X509 *x509; EVP_PKEY *pkey; GetX509(self, x509); pkey = GetPKeyPtr(key); ossl_pkey_check_public_key(pkey); if (!X509_set_pubkey(x509, pkey)) ossl_raise(eX509CertError, "X509_set_pubkey"); return key; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$OpenSSL::X509::Certificate#sign;F;7[[I"key;T0[I" digest;T0;[[@"Hi;T;;7;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;7;@0;:I"sign(key, digest);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[[I"key;T0[I" digest;T0;$@;![;"I"2 @overload sign(key, digest) @return [self];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"Zstatic VALUE ossl_x509_sign(VALUE self, VALUE key, VALUE digest) { X509 *x509; EVP_PKEY *pkey; const EVP_MD *md; pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */ md = ossl_evp_get_digestbyname(digest); GetX509(self, x509); if (!X509_sign(x509, pkey, md)) { ossl_raise(eX509CertError, NULL); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::X509::Certificate#verify;F;7[[I"key;T0;[[@"Hi.;T;;J;0;[;{;IC; "vVerifies the signature of the certificate, with the public key _key_. _key_ must be an instance of OpenSSL::PKey. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I"verify(key);T;IC; ";T;[;![;"I";T;#0;$@*;.F;Bi;C0;7[[I"key;T0;$@*;![;"I"Verifies the signature of the certificate, with the public key _key_. _key_ must be an instance of OpenSSL::PKey. @overload verify(key);T;#0;$@*;.F;/o;0;1T;2i';3i+;%@;9I"gstatic VALUE ossl_x509_verify(VALUE self, VALUE key) { X509 *x509; EVP_PKEY *pkey; GetX509(self, x509); pkey = GetPKeyPtr(key); ossl_pkey_check_public_key(pkey); switch (X509_verify(x509, pkey)) { case 1: return Qtrue; case 0: ossl_clear_error(); return Qfalse; default: ossl_raise(eX509CertError, NULL); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"1OpenSSL::X509::Certificate#check_private_key;F;7[[I"key;T0;[[@"HiI;T;:check_private_key;0;[;{;IC; "wReturns +true+ if _key_ is the corresponding private key to the Subject Public Key Information, +false+ otherwise. ;T;[o;= ;>I" overload;F;?0;;Q;@0;:I"check_private_key(key);T;IC; ";T;[;![;"I";T;#0;$@D;.F;Bi;C0;7[[I"key;T0;$@D;![;"I"Returns +true+ if _key_ is the corresponding private key to the Subject Public Key Information, +false+ otherwise. @overload check_private_key(key);T;#0;$@D;.F;/o;0;1T;2iB;3iF;%@;9I"Sstatic VALUE ossl_x509_check_private_key(VALUE self, VALUE key) { X509 *x509; EVP_PKEY *pkey; /* not needed private key, but should be */ pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */ GetX509(self, x509); if (!X509_check_private_key(x509, pkey)) { ossl_clear_error(); return Qfalse; } return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*OpenSSL::X509::Certificate#extensions;F;7[;[[@"Hi^;T;;;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"extensions;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@^;![;"I"@return [Array];T;#0;$@^;.F;Bi;C0;7[;$@^;![;"I", @overload extensions @return [Array];T;#0;$@^;.F;/o;0;1T;2iZ;3i\;%@;9I"static VALUE ossl_x509_get_extensions(VALUE self) { X509 *x509; int count, i; X509_EXTENSION *ext; VALUE ary; GetX509(self, x509); count = X509_get_ext_count(x509); if (count < 0) { return rb_ary_new(); } ary = rb_ary_new2(count); for (i=0; iI" overload;F;?0;;S;@0;:I"add_extension(extension);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"extension;T0;$@;![;"I"( @overload add_extension(extension);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"-static VALUE ossl_x509_add_extension(VALUE self, VALUE extension) { X509 *x509; X509_EXTENSION *ext; GetX509(self, x509); ext = GetX509ExtPtr(extension); if (!X509_add_ext(x509, ext, -1)) { /* DUPs ext - FREE it */ ossl_raise(eX509CertError, NULL); } return extension; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::X509::Certificate#inspect;F;7[;[[@"Hi;T;;J;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE ossl_x509_inspect(VALUE self) { return rb_sprintf("#<%"PRIsVALUE": subject=%+"PRIsVALUE", " "issuer=%+"PRIsVALUE", serial=%+"PRIsVALUE", " "not_before=%+"PRIsVALUE", not_after=%+"PRIsVALUE">", rb_obj_class(self), ossl_x509_get_subject(self), ossl_x509_get_issuer(self), ossl_x509_get_serial(self), ossl_x509_get_not_before(self), ossl_x509_get_not_after(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::X509::Certificate#==;F;7[[I" other;T0;[[@"Hi;T;;F;0;[;{;IC; "|Compares the two certificates. Note that this takes into account all fields, not just the issuer name and the serial number. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(cert2);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" cert2;T0;$@;![;"I"Compares the two certificates. Note that this takes into account all fields, not just the issuer name and the serial number. @overload ==(cert2);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509_eq(VALUE self, VALUE other) { X509 *a, *b; GetX509(self, a); if (!rb_obj_is_kind_of(other, cX509Cert)) return Qfalse; GetX509(other, b); return !X509_cmp(a, b) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{@N;L;[;[[@"Hik[@"Hi;T;:Certificate;;;;;[;{;IC; "bImplementation of an X.509 certificate as specified in RFC 5280. Provides access to a certificate's attributes and allows certificates to be read from a string, but also supports the creation of new certificates from scratch. === Reading a certificate from a file Certificate is capable of handling DER-encoded certificates and certificates encoded in OpenSSL's PEM format. raw = File.binread "cert.cer" # DER- or PEM-encoded certificate = OpenSSL::X509::Certificate.new raw === Saving a certificate to a file A certificate may be encoded in DER format cert = ... File.open("cert.cer", "wb") { |f| f.print cert.to_der } or in PEM format cert = ... File.open("cert.pem", "wb") { |f| f.print cert.to_pem } X.509 certificates are associated with a private/public key pair, typically a RSA, DSA or ECC key (see also OpenSSL::PKey::RSA, OpenSSL::PKey::DSA and OpenSSL::PKey::EC), the public key itself is stored within the certificate and can be accessed in form of an OpenSSL::PKey. Certificates are typically used to be able to associate some form of identity with a key pair, for example web servers serving pages over HTTPs use certificates to authenticate themselves to the user. The public key infrastructure (PKI) model relies on trusted certificate authorities ("root CAs") that issue these certificates, so that end users need to base their trust just on a selected few authorities that themselves again vouch for subordinate CAs issuing their certificates to end users. The OpenSSL::X509 module provides the tools to set up an independent PKI, similar to scenarios where the 'openssl' command line tool is used for issuing certificates in a private PKI. === Creating a root CA certificate and an end-entity certificate First, we need to create a "self-signed" root certificate. To do so, we need to generate a key first. Please note that the choice of "1" as a serial number is considered a security flaw for real certificates. Secure choices are integers in the two-digit byte range and ideally not sequential but secure random numbers, steps omitted here to keep the example concise. root_key = OpenSSL::PKey::RSA.new 2048 # the CA's public/private key root_ca = OpenSSL::X509::Certificate.new root_ca.version = 2 # cf. RFC 5280 - to make it a "v3" certificate root_ca.serial = 1 root_ca.subject = OpenSSL::X509::Name.parse "/DC=org/DC=ruby-lang/CN=Ruby CA" root_ca.issuer = root_ca.subject # root CA's are "self-signed" root_ca.public_key = root_key.public_key root_ca.not_before = Time.now root_ca.not_after = root_ca.not_before + 2 * 365 * 24 * 60 * 60 # 2 years validity ef = OpenSSL::X509::ExtensionFactory.new ef.subject_certificate = root_ca ef.issuer_certificate = root_ca root_ca.add_extension(ef.create_extension("basicConstraints","CA:TRUE",true)) root_ca.add_extension(ef.create_extension("keyUsage","keyCertSign, cRLSign", true)) root_ca.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false)) root_ca.add_extension(ef.create_extension("authorityKeyIdentifier","keyid:always",false)) root_ca.sign(root_key, OpenSSL::Digest.new('SHA256')) The next step is to create the end-entity certificate using the root CA certificate. key = OpenSSL::PKey::RSA.new 2048 cert = OpenSSL::X509::Certificate.new cert.version = 2 cert.serial = 2 cert.subject = OpenSSL::X509::Name.parse "/DC=org/DC=ruby-lang/CN=Ruby certificate" cert.issuer = root_ca.subject # root CA is the issuer cert.public_key = key.public_key cert.not_before = Time.now cert.not_after = cert.not_before + 1 * 365 * 24 * 60 * 60 # 1 years validity ef = OpenSSL::X509::ExtensionFactory.new ef.subject_certificate = cert ef.issuer_certificate = root_ca cert.add_extension(ef.create_extension("keyUsage","digitalSignature", true)) cert.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false)) cert.sign(root_key, OpenSSL::Digest.new('SHA256')) ;T;[;![;"I"e Implementation of an X.509 certificate as specified in RFC 5280. Provides access to a certificate's attributes and allows certificates to be read from a string, but also supports the creation of new certificates from scratch. === Reading a certificate from a file Certificate is capable of handling DER-encoded certificates and certificates encoded in OpenSSL's PEM format. raw = File.binread "cert.cer" # DER- or PEM-encoded certificate = OpenSSL::X509::Certificate.new raw === Saving a certificate to a file A certificate may be encoded in DER format cert = ... File.open("cert.cer", "wb") { |f| f.print cert.to_der } or in PEM format cert = ... File.open("cert.pem", "wb") { |f| f.print cert.to_pem } X.509 certificates are associated with a private/public key pair, typically a RSA, DSA or ECC key (see also OpenSSL::PKey::RSA, OpenSSL::PKey::DSA and OpenSSL::PKey::EC), the public key itself is stored within the certificate and can be accessed in form of an OpenSSL::PKey. Certificates are typically used to be able to associate some form of identity with a key pair, for example web servers serving pages over HTTPs use certificates to authenticate themselves to the user. The public key infrastructure (PKI) model relies on trusted certificate authorities ("root CAs") that issue these certificates, so that end users need to base their trust just on a selected few authorities that themselves again vouch for subordinate CAs issuing their certificates to end users. The OpenSSL::X509 module provides the tools to set up an independent PKI, similar to scenarios where the 'openssl' command line tool is used for issuing certificates in a private PKI. === Creating a root CA certificate and an end-entity certificate First, we need to create a "self-signed" root certificate. To do so, we need to generate a key first. Please note that the choice of "1" as a serial number is considered a security flaw for real certificates. Secure choices are integers in the two-digit byte range and ideally not sequential but secure random numbers, steps omitted here to keep the example concise. root_key = OpenSSL::PKey::RSA.new 2048 # the CA's public/private key root_ca = OpenSSL::X509::Certificate.new root_ca.version = 2 # cf. RFC 5280 - to make it a "v3" certificate root_ca.serial = 1 root_ca.subject = OpenSSL::X509::Name.parse "/DC=org/DC=ruby-lang/CN=Ruby CA" root_ca.issuer = root_ca.subject # root CA's are "self-signed" root_ca.public_key = root_key.public_key root_ca.not_before = Time.now root_ca.not_after = root_ca.not_before + 2 * 365 * 24 * 60 * 60 # 2 years validity ef = OpenSSL::X509::ExtensionFactory.new ef.subject_certificate = root_ca ef.issuer_certificate = root_ca root_ca.add_extension(ef.create_extension("basicConstraints","CA:TRUE",true)) root_ca.add_extension(ef.create_extension("keyUsage","keyCertSign, cRLSign", true)) root_ca.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false)) root_ca.add_extension(ef.create_extension("authorityKeyIdentifier","keyid:always",false)) root_ca.sign(root_key, OpenSSL::Digest.new('SHA256')) The next step is to create the end-entity certificate using the root CA certificate. key = OpenSSL::PKey::RSA.new 2048 cert = OpenSSL::X509::Certificate.new cert.version = 2 cert.serial = 2 cert.subject = OpenSSL::X509::Name.parse "/DC=org/DC=ruby-lang/CN=Ruby certificate" cert.issuer = root_ca.subject # root CA is the issuer cert.public_key = key.public_key cert.not_before = Time.now cert.not_after = cert.not_before + 1 * 365 * 24 * 60 * 60 # 1 years validity ef = OpenSSL::X509::ExtensionFactory.new ef.subject_certificate = cert ef.issuer_certificate = root_ca cert.add_extension(ef.create_extension("keyUsage","digitalSignature", true)) cert.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false)) cert.sign(root_key, OpenSSL::Digest.new('SHA256')) ;T;#0;$@;.F;/o;0;1T;2ik;3i;%@;&I"OpenSSL::X509::Certificate;F;'@o; ;IC;[; @ۋ; IC;[; @ۋ; IC;[; @ۋ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@$Hil;F;:StoreError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@ۋ;%@;&I"OpenSSL::X509::StoreError;F;'@Ho; ;IC;[o;4;5F;6;;;;&I"$OpenSSL::X509::Store#initialize;F;7[[@90;[[@$Hi;T;;D;0;[;{;IC; "Creates a new X509::Store. ;T;[o;= ;>I" overload;F;?0;:X509::Store.new;@0;:I"X509::Store.new;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I";Creates a new X509::Store. @overload X509::Store.new;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509store_initialize(int argc, VALUE *argv, VALUE self) { X509_STORE *store; GetX509Store(self, store); if (argc != 0) rb_warn("OpenSSL::X509::Store.new does not take any arguments"); #if !defined(HAVE_OPAQUE_OPENSSL) /* [Bug #405] [Bug #1678] [Bug #3000]; already fixed? */ store->ex_data.sk = NULL; #endif X509_STORE_set_verify_cb(store, x509store_verify_cb); ossl_x509store_set_vfy_cb(self, Qnil); /* last verification status */ rb_iv_set(self, "@error", Qnil); rb_iv_set(self, "@error_string", Qnil); rb_iv_set(self, "@chain", Qnil); rb_iv_set(self, "@time", Qnil); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*OpenSSL::X509::Store#verify_callback=;F;7[[I"cb;T0;[[@$Hi;T;:verify_callback=;0;[;{;IC; "(General callback for OpenSSL verify ;T;[;![;"I")General callback for OpenSSL verify ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509store_set_vfy_cb(VALUE self, VALUE cb) { X509_STORE *store; GetX509Store(self, store); X509_STORE_set_ex_data(store, store_ex_verify_cb_idx, (void *)cb); rb_iv_set(self, "@verify_callback", cb); return cb; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" OpenSSL::X509::Store#flags=;F;7[[I" flags;T0;[[@$Hi;T;: flags=;0;[;{;IC; "fSets the default flags used by certificate chain verification performed with the Store. _flags_ consists of zero or more of the constants defined in OpenSSL::X509 with name V_FLAG_* or'ed together. OpenSSL::X509::StoreContext#flags= can be used to change the flags for a single verification operation. See also the man page X509_VERIFY_PARAM_set_flags(3). ;T;[o;= ;>I" overload;F;?0;;X;@0;:I"flags=(flags);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" flags;T0;$@;![;"I"Sets the default flags used by certificate chain verification performed with the Store. _flags_ consists of zero or more of the constants defined in OpenSSL::X509 with name V_FLAG_* or'ed together. OpenSSL::X509::StoreContext#flags= can be used to change the flags for a single verification operation. See also the man page X509_VERIFY_PARAM_set_flags(3). @overload flags=(flags);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509store_set_flags(VALUE self, VALUE flags) { X509_STORE *store; long f = NUM2LONG(flags); GetX509Store(self, store); X509_STORE_set_flags(store, f); return flags; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::X509::Store#purpose=;F;7[[I" purpose;T0;[[@$Hi;T;: purpose=;0;[;{;IC; "gSets the store's default verification purpose. If specified, the verifications on the store will check every certificate's extensions are consistent with the purpose. The purpose is specified by constants: * X509::PURPOSE_SSL_CLIENT * X509::PURPOSE_SSL_SERVER * X509::PURPOSE_NS_SSL_SERVER * X509::PURPOSE_SMIME_SIGN * X509::PURPOSE_SMIME_ENCRYPT * X509::PURPOSE_CRL_SIGN * X509::PURPOSE_ANY * X509::PURPOSE_OCSP_HELPER * X509::PURPOSE_TIMESTAMP_SIGN OpenSSL::X509::StoreContext#purpose= can be used to change the value for a single verification operation. See also the man page X509_VERIFY_PARAM_set_purpose(3). ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I"purpose=(purpose);T;IC; ";T;[;![;"I";T;#0;$@/;.F;Bi;C0;7[[I" purpose;T0;$@/;![;"I"Sets the store's default verification purpose. If specified, the verifications on the store will check every certificate's extensions are consistent with the purpose. The purpose is specified by constants: * X509::PURPOSE_SSL_CLIENT * X509::PURPOSE_SSL_SERVER * X509::PURPOSE_NS_SSL_SERVER * X509::PURPOSE_SMIME_SIGN * X509::PURPOSE_SMIME_ENCRYPT * X509::PURPOSE_CRL_SIGN * X509::PURPOSE_ANY * X509::PURPOSE_OCSP_HELPER * X509::PURPOSE_TIMESTAMP_SIGN OpenSSL::X509::StoreContext#purpose= can be used to change the value for a single verification operation. See also the man page X509_VERIFY_PARAM_set_purpose(3). @overload purpose=(purpose);T;#0;$@/;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509store_set_purpose(VALUE self, VALUE purpose) { X509_STORE *store; int p = NUM2INT(purpose); GetX509Store(self, store); X509_STORE_set_purpose(store, p); return purpose; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" OpenSSL::X509::Store#trust=;F;7[[I" trust;T0;[[@$Hi-;T;: trust=;0;[;{;IC; "Sets the default trust settings used by the certificate verification with the store. OpenSSL::X509::StoreContext#trust= can be used to change the value for a single verification operation. See also the man page X509_VERIFY_PARAM_set_trust(3). ;T;[o;= ;>I" overload;F;?0;;Z;@0;:I"trust=(trust);T;IC; ";T;[;![;"I";T;#0;$@I;.F;Bi;C0;7[[I" trust;T0;$@I;![;"I"Sets the default trust settings used by the certificate verification with the store. OpenSSL::X509::StoreContext#trust= can be used to change the value for a single verification operation. See also the man page X509_VERIFY_PARAM_set_trust(3). @overload trust=(trust);T;#0;$@I;.F;/o;0;1T;2i!;3i*;%@;9I"static VALUE ossl_x509store_set_trust(VALUE self, VALUE trust) { X509_STORE *store; int t = NUM2INT(trust); GetX509Store(self, store); X509_STORE_set_trust(store, t); return trust; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::X509::Store#time=;F;7[[I" time;T0;[[@$HiE;T;;X;0;[;{;IC; "&Sets the time to be used in the certificate verifications with the store. By default, if not specified, the current system time is used. OpenSSL::X509::StoreContext#time= can be used to change the value for a single verification operation. See also the man page X509_VERIFY_PARAM_set_time(3). ;T;[o;= ;>I" overload;F;?0;;X;@0;:I"time=(time);T;IC; ";T;[;![;"I";T;#0;$@c;.F;Bi;C0;7[[I" time;T0;$@c;![;"I">Sets the time to be used in the certificate verifications with the store. By default, if not specified, the current system time is used. OpenSSL::X509::StoreContext#time= can be used to change the value for a single verification operation. See also the man page X509_VERIFY_PARAM_set_time(3). @overload time=(time);T;#0;$@c;.F;/o;0;1T;2i9;3iB;%@;9I"zstatic VALUE ossl_x509store_set_time(VALUE self, VALUE time) { rb_iv_set(self, "@time", time); return time; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::X509::Store#add_path;F;7[[I"dir;T0;[[@$Hiy;T;: add_path;0;[;{;IC; "nAdds _path_ as the hash dir to be looked up by the store. See also the man page X509_LOOKUP_hash_dir(3). ;T;[o;= ;>I" overload;F;?0;;[;@0;:I"add_path(path);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@};![;"I"@return [self];T;#0;$@};.F;Bi;C0;7[[I" path;T0;$@};![;"I"Adds _path_ as the hash dir to be looked up by the store. See also the man page X509_LOOKUP_hash_dir(3). @overload add_path(path) @return [self];T;#0;$@};.F;/o;0;1T;2iq;3iw;%@;9I"static VALUE ossl_x509store_add_path(VALUE self, VALUE dir) { X509_STORE *store; X509_LOOKUP *lookup; const char *path; GetX509Store(self, store); path = StringValueCStr(dir); lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir()); if (!lookup) ossl_raise(eX509StoreError, "X509_STORE_add_lookup"); if (X509_LOOKUP_add_dir(lookup, path, X509_FILETYPE_PEM) != 1) ossl_raise(eX509StoreError, "X509_LOOKUP_add_dir"); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::X509::Store#add_file;F;7[[I" file;T0;[[@$HiV;T;: add_file;0;[;{;IC; "Adds the certificates in _file_ to the certificate store. _file_ is the path to the file, and the file contains one or more certificates in PEM format concatenated together. See also the man page X509_LOOKUP_file(3). ;T;[o;= ;>I" overload;F;?0;;\;@0;:I"add_file(file);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[[I" file;T0;$@;![;"I"Adds the certificates in _file_ to the certificate store. _file_ is the path to the file, and the file contains one or more certificates in PEM format concatenated together. See also the man page X509_LOOKUP_file(3). @overload add_file(file) @return [self];T;#0;$@;.F;/o;0;1T;2iL;3iT;%@;9I"static VALUE ossl_x509store_add_file(VALUE self, VALUE file) { X509_STORE *store; X509_LOOKUP *lookup; const char *path; GetX509Store(self, store); path = StringValueCStr(file); lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file()); if (!lookup) ossl_raise(eX509StoreError, "X509_STORE_add_lookup"); if (X509_LOOKUP_load_file(lookup, path, X509_FILETYPE_PEM) != 1) ossl_raise(eX509StoreError, "X509_LOOKUP_load_file"); #if OPENSSL_VERSION_NUMBER < 0x10101000 || defined(LIBRESSL_VERSION_NUMBER) /* * X509_load_cert_crl_file() which is called from X509_LOOKUP_load_file() * did not check the return value of X509_STORE_add_{cert,crl}(), leaking * "cert already in hash table" errors on the error queue, if duplicate * certificates are found. This will be fixed by OpenSSL 1.1.1. */ ossl_clear_error(); #endif return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+OpenSSL::X509::Store#set_default_paths;F;7[;[[@$Hi;T;:set_default_paths;0;[;{;IC; "Configures _store_ to look up CA certificates from the system default certificate store as needed basis. The location of the store can usually be determined by: * OpenSSL::X509::DEFAULT_CERT_FILE * OpenSSL::X509::DEFAULT_CERT_DIR See also the man page X509_STORE_set_default_paths(3). ;T;[o;= ;>I" overload;F;?0;;];@0;:I"set_default_paths;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"<Configures _store_ to look up CA certificates from the system default certificate store as needed basis. The location of the store can usually be determined by: * OpenSSL::X509::DEFAULT_CERT_FILE * OpenSSL::X509::DEFAULT_CERT_DIR See also the man page X509_STORE_set_default_paths(3). @overload set_default_paths;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509store_set_default_paths(VALUE self) { X509_STORE *store; GetX509Store(self, store); if (X509_STORE_set_default_paths(store) != 1) ossl_raise(eX509StoreError, "X509_STORE_set_default_paths"); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::X509::Store#add_cert;F;7[[I"arg;T0;[[@$Hi;T;: add_cert;0;[;{;IC; "xAdds the OpenSSL::X509::Certificate _cert_ to the certificate store. See also the man page X509_STORE_add_cert(3). ;T;[o;= ;>I" overload;F;?0;;^;@0;:I"add_cert(cert);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@ь;![;"I"@return [self];T;#0;$@ь;.F;Bi;C0;7[[I" cert;T0;$@ь;![;"I"Adds the OpenSSL::X509::Certificate _cert_ to the certificate store. See also the man page X509_STORE_add_cert(3). @overload add_cert(cert) @return [self];T;#0;$@ь;.F;/o;0;1T;2i;3i;%@;9I"8static VALUE ossl_x509store_add_cert(VALUE self, VALUE arg) { X509_STORE *store; X509 *cert; cert = GetX509CertPtr(arg); /* NO NEED TO DUP */ GetX509Store(self, store); if (X509_STORE_add_cert(store, cert) != 1) ossl_raise(eX509StoreError, "X509_STORE_add_cert"); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!OpenSSL::X509::Store#add_crl;F;7[[I"arg;T0;[[@$Hi;T;;E;0;[;{;IC; "bAdds the OpenSSL::X509::CRL _crl_ to the store. See also the man page X509_STORE_add_crl(3). ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"add_crl(crl);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[[I"crl;T0;$@;![;"I"Adds the OpenSSL::X509::CRL _crl_ to the store. See also the man page X509_STORE_add_crl(3). @overload add_crl(crl) @return [self];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"5static VALUE ossl_x509store_add_crl(VALUE self, VALUE arg) { X509_STORE *store; X509_CRL *crl; crl = GetX509CRLPtr(arg); /* NO NEED TO DUP */ GetX509Store(self, store); if (X509_STORE_add_crl(store, crl) != 1) ossl_raise(eX509StoreError, "X509_STORE_add_crl"); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" OpenSSL::X509::Store#verify;F;7[[@90;[[@$Hi;T;;J;0;[;{;IC; "Performs a certificate verification on the OpenSSL::X509::Certificate _cert_. _chain_ can be an array of OpenSSL::X509::Certificate that is used to construct the certificate chain. If a block is given, it overrides the callback set by #verify_callback=. After finishing the verification, the error information can be retrieved by #error, #error_string, and the resulting complete certificate chain can be retrieved by #chain. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I"verify(cert, chain = nil);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" cert;T0[I" chain;TI"nil;T;$@;![;"I"Performs a certificate verification on the OpenSSL::X509::Certificate _cert_. _chain_ can be an array of OpenSSL::X509::Certificate that is used to construct the certificate chain. If a block is given, it overrides the callback set by #verify_callback=. After finishing the verification, the error information can be retrieved by #error, #error_string, and the resulting complete certificate chain can be retrieved by #chain. @overload verify(cert, chain = nil);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509store_verify(int argc, VALUE *argv, VALUE self) { VALUE cert, chain; VALUE ctx, proc, result; rb_scan_args(argc, argv, "11", &cert, &chain); ctx = rb_funcall(cX509StoreContext, rb_intern("new"), 3, self, cert, chain); proc = rb_block_given_p() ? rb_block_proc() : rb_iv_get(self, "@verify_callback"); rb_iv_set(ctx, "@verify_callback", proc); result = rb_funcall(ctx, rb_intern("verify"), 0); rb_iv_set(self, "@error", ossl_x509stctx_get_err(ctx)); rb_iv_set(self, "@error_string", ossl_x509stctx_get_err_string(ctx)); rb_iv_set(self, "@chain", ossl_x509stctx_get_chain(ctx)); return result; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@$Hin[@$Hi;T;: Store;;;;;[;{;IC; "fThe X509 certificate store holds trusted CA certificates used to verify peer certificates. The easiest way to create a useful certificate store is: cert_store = OpenSSL::X509::Store.new cert_store.set_default_paths This will use your system's built-in certificates. If your system does not have a default set of certificates you can obtain a set extracted from Mozilla CA certificate store by cURL maintainers here: https://curl.haxx.se/docs/caextract.html (You may wish to use the firefox-db2pem.sh script to extract the certificates from a local install to avoid man-in-the-middle attacks.) After downloading or generating a cacert.pem from the above link you can create a certificate store from the pem file like this: cert_store = OpenSSL::X509::Store.new cert_store.add_file 'cacert.pem' The certificate store can be used with an SSLSocket like this: ssl_context = OpenSSL::SSL::SSLContext.new ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER ssl_context.cert_store = cert_store tcp_socket = TCPSocket.open 'example.com', 443 ssl_socket = OpenSSL::SSL::SSLSocket.new tcp_socket, ssl_context ;T;[;![;"I"h The X509 certificate store holds trusted CA certificates used to verify peer certificates. The easiest way to create a useful certificate store is: cert_store = OpenSSL::X509::Store.new cert_store.set_default_paths This will use your system's built-in certificates. If your system does not have a default set of certificates you can obtain a set extracted from Mozilla CA certificate store by cURL maintainers here: https://curl.haxx.se/docs/caextract.html (You may wish to use the firefox-db2pem.sh script to extract the certificates from a local install to avoid man-in-the-middle attacks.) After downloading or generating a cacert.pem from the above link you can create a certificate store from the pem file like this: cert_store = OpenSSL::X509::Store.new cert_store.add_file 'cacert.pem' The certificate store can be used with an SSLSocket like this: ssl_context = OpenSSL::SSL::SSLContext.new ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER ssl_context.cert_store = cert_store tcp_socket = TCPSocket.open 'example.com', 443 ssl_socket = OpenSSL::SSL::SSLSocket.new tcp_socket, ssl_context ;T;#0;$@;.F;/o;0;1T;2in;3i;%@;&I"OpenSSL::X509::Store;F;'@o; ;IC;[o;4;5F;6;;;;&I"+OpenSSL::X509::StoreContext#initialize;F;7[[@90;[[@$Hi8;T;;D;0;[;{;IC; "OSets up a StoreContext for a verification of the X.509 certificate _cert_. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I",new(store, cert = nil, untrusted = nil);T;IC; ";T;[;![;"I";T;#0;$@?;.F;Bi;C0;7[[I" store;T0[I" cert;TI"nil;T[I"untrusted;TI"nil;T;$@?;![;"I"~Sets up a StoreContext for a verification of the X.509 certificate _cert_. @overload new(store, cert = nil, untrusted = nil);T;#0;$@?;.F;/o;0;1T;2i2;3i5;%@=;9I"static VALUE ossl_x509stctx_initialize(int argc, VALUE *argv, VALUE self) { VALUE store, cert, chain, t; X509_STORE_CTX *ctx; X509_STORE *x509st; X509 *x509 = NULL; STACK_OF(X509) *x509s = NULL; int state; rb_scan_args(argc, argv, "12", &store, &cert, &chain); GetX509StCtx(self, ctx); GetX509Store(store, x509st); if (!NIL_P(cert)) x509 = DupX509CertPtr(cert); /* NEED TO DUP */ if (!NIL_P(chain)) { x509s = ossl_protect_x509_ary2sk(chain, &state); if (state) { X509_free(x509); rb_jump_tag(state); } } if (X509_STORE_CTX_init(ctx, x509st, x509, x509s) != 1){ X509_free(x509); sk_X509_pop_free(x509s, X509_free); ossl_raise(eX509StoreError, "X509_STORE_CTX_init"); } if (!NIL_P(t = rb_iv_get(store, "@time"))) ossl_x509stctx_set_time(self, t); rb_iv_set(self, "@verify_callback", rb_iv_get(store, "@verify_callback")); rb_iv_set(self, "@cert", cert); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::X509::StoreContext#verify;F;7[;[[@$Hic;T;;J;0;[;{;IC; "{Performs the certificate verification using the parameters set to _stctx_. See also the man page X509_verify_cert(3). ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" verify;T;IC; ";T;[;![;"I";T;#0;$@^;.F;Bi;C0;7[;$@^;![;"I"Performs the certificate verification using the parameters set to _stctx_. See also the man page X509_verify_cert(3). @overload verify;T;#0;$@^;.F;/o;0;1T;2i[;3i`;%@=;9I"static VALUE ossl_x509stctx_verify(VALUE self) { X509_STORE_CTX *ctx; GetX509StCtx(self, ctx); X509_STORE_CTX_set_ex_data(ctx, stctx_ex_verify_cb_idx, (void *)rb_iv_get(self, "@verify_callback")); switch (X509_verify_cert(ctx)) { case 1: return Qtrue; case 0: ossl_clear_error(); return Qfalse; default: ossl_raise(eX509CertError, "X509_verify_cert"); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::X509::StoreContext#chain;F;7[;[[@$Hi;T;;;0;[;{;IC; "^Returns the verified chain. See also the man page X509_STORE_CTX_set0_verified_chain(3). ;T;[o;= ;>I" overload;F;?0;;;@0;:I" chain;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"%nil | Array of X509::Certificate;T;$@t;![;"I"/@return [nil | Array of X509::Certificate];T;#0;$@t;.F;Bi;C0;7[;$@t;![;"I"Returns the verified chain. See also the man page X509_STORE_CTX_set0_verified_chain(3). @overload chain @return [nil | Array of X509::Certificate];T;#0;$@t;.F;/o;0;1T;2iw;3i};%@=;9I")static VALUE ossl_x509stctx_get_chain(VALUE self) { X509_STORE_CTX *ctx; const STACK_OF(X509) *chain; GetX509StCtx(self, ctx); chain = X509_STORE_CTX_get0_chain(ctx); if (!chain) return Qnil; /* Could be an empty array instead? */ return ossl_x509_sk2ary(chain); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::X509::StoreContext#error;F;7[;[[@$Hi;T;: error;0;[;{;IC; "Returns the error code of _stctx_. This is typically called after #verify is done, or from the verification callback set to OpenSSL::X509::Store#verify_callback=. See also the man page X509_STORE_CTX_get_error(3). ;T;[o;= ;>I" overload;F;?0;;`;@0;:I" error;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the error code of _stctx_. This is typically called after #verify is done, or from the verification callback set to OpenSSL::X509::Store#verify_callback=. See also the man page X509_STORE_CTX_get_error(3). @overload error @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@=;9I"static VALUE ossl_x509stctx_get_err(VALUE self) { X509_STORE_CTX *ctx; GetX509StCtx(self, ctx); return INT2NUM(X509_STORE_CTX_get_error(ctx)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::X509::StoreContext#error=;F;7[[I"err;T0;[[@$Hi;T;: error=;0;[;{;IC; "Sets the error code of _stctx_. This is used by the verification callback set to OpenSSL::X509::Store#verify_callback=. See also the man page X509_STORE_CTX_set_error(3). ;T;[o;= ;>I" overload;F;?0;;a;@0;:I"error=(error_code);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"error_code;T0;$@;![;"I"Sets the error code of _stctx_. This is used by the verification callback set to OpenSSL::X509::Store#verify_callback=. See also the man page X509_STORE_CTX_set_error(3). @overload error=(error_code);T;#0;$@;.F;/o;0;1T;2i;3i;%@=;9I"static VALUE ossl_x509stctx_set_error(VALUE self, VALUE err) { X509_STORE_CTX *ctx; GetX509StCtx(self, ctx); X509_STORE_CTX_set_error(ctx, NUM2INT(err)); return err; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"-OpenSSL::X509::StoreContext#error_string;F;7[;[[@$Hi;T;:error_string;0;[;{;IC; "Returns the human readable error string corresponding to the error code retrieved by #error. See also the man page X509_verify_cert_error_string(3). ;T;[o;= ;>I" overload;F;?0;;b;@0;:I"error_string;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@č;![;"I"@return [String];T;#0;$@č;.F;Bi;C0;7[;$@č;![;"I"Returns the human readable error string corresponding to the error code retrieved by #error. See also the man page X509_verify_cert_error_string(3). @overload error_string @return [String];T;#0;$@č;.F;/o;0;1T;2i;3i;%@=;9I"static VALUE ossl_x509stctx_get_err_string(VALUE self) { X509_STORE_CTX *ctx; long err; GetX509StCtx(self, ctx); err = X509_STORE_CTX_get_error(ctx); return rb_str_new2(X509_verify_cert_error_string(err)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",OpenSSL::X509::StoreContext#error_depth;F;7[;[[@$Hi;T;:error_depth;0;[;{;IC; "Returns the depth of the chain. This is used in combination with #error. See also the man page X509_STORE_CTX_get_error_depth(3). ;T;[o;= ;>I" overload;F;?0;;c;@0;:I"error_depth;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ߍ;![;"I"@return [Integer];T;#0;$@ߍ;.F;Bi;C0;7[;$@ߍ;![;"I"Returns the depth of the chain. This is used in combination with #error. See also the man page X509_STORE_CTX_get_error_depth(3). @overload error_depth @return [Integer];T;#0;$@ߍ;.F;/o;0;1T;2i;3i;%@=;9I"static VALUE ossl_x509stctx_get_err_depth(VALUE self) { X509_STORE_CTX *ctx; GetX509StCtx(self, ctx); return INT2NUM(X509_STORE_CTX_get_error_depth(ctx)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"-OpenSSL::X509::StoreContext#current_cert;F;7[;[[@$Hi;T;:current_cert;0;[;{;IC; "oReturns the certificate which caused the error. See also the man page X509_STORE_CTX_get_current_cert(3). ;T;[o;= ;>I" overload;F;?0;;d;@0;:I"current_cert;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"X509::Certificate;T;$@;![;"I" @return [X509::Certificate];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the certificate which caused the error. See also the man page X509_STORE_CTX_get_current_cert(3). @overload current_cert @return [X509::Certificate];T;#0;$@;.F;/o;0;1T;2i;3i;%@=;9I"static VALUE ossl_x509stctx_get_curr_cert(VALUE self) { X509_STORE_CTX *ctx; GetX509StCtx(self, ctx); return ossl_x509_new(X509_STORE_CTX_get_current_cert(ctx)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",OpenSSL::X509::StoreContext#current_crl;F;7[;[[@$Hi;T;:current_crl;0;[;{;IC; "fReturns the CRL which caused the error. See also the man page X509_STORE_CTX_get_current_crl(3). ;T;[o;= ;>I" overload;F;?0;;e;@0;:I"current_crl;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"X509::CRL;T;$@;![;"I"@return [X509::CRL];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the CRL which caused the error. See also the man page X509_STORE_CTX_get_current_crl(3). @overload current_crl @return [X509::CRL];T;#0;$@;.F;/o;0;1T;2i;3i;%@=;9I"static VALUE ossl_x509stctx_get_curr_crl(VALUE self) { X509_STORE_CTX *ctx; X509_CRL *crl; GetX509StCtx(self, ctx); crl = X509_STORE_CTX_get0_current_crl(ctx); if (!crl) return Qnil; return ossl_x509crl_new(crl); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::X509::StoreContext#flags=;F;7[[I" flags;T0;[[@$Hi ;T;;X;0;[;{;IC; "Sets the verification flags to the context. This overrides the default value set by Store#flags=. See also the man page X509_VERIFY_PARAM_set_flags(3). ;T;[o;= ;>I" overload;F;?0;;X;@0;:I"flags=(flags);T;IC; ";T;[;![;"I";T;#0;$@0;.F;Bi;C0;7[[I" flags;T0;$@0;![;"I"Sets the verification flags to the context. This overrides the default value set by Store#flags=. See also the man page X509_VERIFY_PARAM_set_flags(3). @overload flags=(flags);T;#0;$@0;.F;/o;0;1T;2i;3i ;%@=;9I"static VALUE ossl_x509stctx_set_flags(VALUE self, VALUE flags) { X509_STORE_CTX *store; long f = NUM2LONG(flags); GetX509StCtx(self, store); X509_STORE_CTX_set_flags(store, f); return flags; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I")OpenSSL::X509::StoreContext#purpose=;F;7[[I" purpose;T0;[[@$Hi!;T;;Y;0;[;{;IC; "Sets the purpose of the context. This overrides the default value set by Store#purpose=. See also the man page X509_VERIFY_PARAM_set_purpose(3). ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I"purpose=(purpose);T;IC; ";T;[;![;"I";T;#0;$@J;.F;Bi;C0;7[[I" purpose;T0;$@J;![;"I"Sets the purpose of the context. This overrides the default value set by Store#purpose=. See also the man page X509_VERIFY_PARAM_set_purpose(3). @overload purpose=(purpose);T;#0;$@J;.F;/o;0;1T;2i;3i;%@=;9I"static VALUE ossl_x509stctx_set_purpose(VALUE self, VALUE purpose) { X509_STORE_CTX *store; int p = NUM2INT(purpose); GetX509StCtx(self, store); X509_STORE_CTX_set_purpose(store, p); return purpose; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::X509::StoreContext#trust=;F;7[[I" trust;T0;[[@$Hi6;T;;Z;0;[;{;IC; "Sets the trust settings of the context. This overrides the default value set by Store#trust=. See also the man page X509_VERIFY_PARAM_set_trust(3). ;T;[o;= ;>I" overload;F;?0;;Z;@0;:I"trust=(trust);T;IC; ";T;[;![;"I";T;#0;$@d;.F;Bi;C0;7[[I" trust;T0;$@d;![;"I"Sets the trust settings of the context. This overrides the default value set by Store#trust=. See also the man page X509_VERIFY_PARAM_set_trust(3). @overload trust=(trust);T;#0;$@d;.F;/o;0;1T;2i-;3i3;%@=;9I"static VALUE ossl_x509stctx_set_trust(VALUE self, VALUE trust) { X509_STORE_CTX *store; int t = NUM2INT(trust); GetX509StCtx(self, store); X509_STORE_CTX_set_trust(store, t); return trust; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::X509::StoreContext#time=;F;7[[I" time;T0;[[@$HiJ;T;;X;0;[;{;IC; "Sets the time used in the verification. If not set, the current time is used. See also the man page X509_VERIFY_PARAM_set_time(3). ;T;[o;= ;>I" overload;F;?0;;X;@0;:I"time=(time);T;IC; ";T;[;![;"I";T;#0;$@~;.F;Bi;C0;7[[I" time;T0;$@~;![;"I"Sets the time used in the verification. If not set, the current time is used. See also the man page X509_VERIFY_PARAM_set_time(3). @overload time=(time);T;#0;$@~;.F;/o;0;1T;2iB;3iG;%@=;9I"static VALUE ossl_x509stctx_set_time(VALUE self, VALUE time) { X509_STORE_CTX *store; long t; t = NUM2LONG(rb_Integer(time)); GetX509StCtx(self, store); X509_STORE_CTX_set_time(store, 0, t); return time; };T;:I"static VALUE;T;;T; @=; IC;[; @=; IC;[; @=; IC;{;IC;{;T;IC;{;T;T;{;[;[[@$Hi[@$Hi;T;:StoreContext;;;;;[;{;IC; "`A StoreContext is used while validating a single certificate and holds the status involved. ;T;[;![;"I"b A StoreContext is used while validating a single certificate and holds the status involved. ;T;#0;$@=;.F;/o;0;1T;2i;3i;%@;&I" OpenSSL::X509::StoreContext;F;'@o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@&Hi;F;: CRLError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"OpenSSL::X509::CRLError;F;'@Ho; ;IC;[o;4;5F;6;;;;&I""OpenSSL::X509::CRL#initialize;F;7[[@90;[[@&Hia;T;;D;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE ossl_x509crl_initialize(int argc, VALUE *argv, VALUE self) { BIO *in; X509_CRL *crl, *crl_orig = RTYPEDDATA_DATA(self); VALUE arg; rb_check_frozen(self); if (rb_scan_args(argc, argv, "01", &arg) == 0) { return self; } arg = ossl_to_der_if_possible(arg); in = ossl_obj2bio(&arg); crl = d2i_X509_CRL_bio(in, NULL); if (!crl) { OSSL_BIO_reset(in); crl = PEM_read_bio_X509_CRL(in, NULL, NULL, NULL); } BIO_free(in); if (!crl) ossl_raise(eX509CRLError, "PEM_read_bio_X509_CRL"); RTYPEDDATA_DATA(self) = crl; X509_CRL_free(crl_orig); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::X509::CRL#initialize_copy;F;7[[I" other;T0;[[@&Hi};T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@ʎ;%@;9I"Wstatic VALUE ossl_x509crl_copy(VALUE self, VALUE other) { X509_CRL *a, *b, *crl; rb_check_frozen(self); if (self == other) return self; GetX509CRL(self, a); GetX509CRL(other, b); if (!(crl = X509_CRL_dup(b))) { ossl_raise(eX509CRLError, NULL); } X509_CRL_free(a); DATA_PTR(self) = crl; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::X509::CRL#version;F;7[;[[@&Hi;T;;?;0;[;{;IC; " ;T;[;![;"@;#0;$@؎;%@;9I"static VALUE ossl_x509crl_get_version(VALUE self) { X509_CRL *crl; long ver; GetX509CRL(self, crl); ver = X509_CRL_get_version(crl); return LONG2NUM(ver); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" OpenSSL::X509::CRL#version=;F;7[[I" version;T0;[[@&Hi;T;;@;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"Mstatic VALUE ossl_x509crl_set_version(VALUE self, VALUE version) { X509_CRL *crl; long ver; if ((ver = NUM2LONG(version)) < 0) { ossl_raise(eX509CRLError, "version must be >= 0!"); } GetX509CRL(self, crl); if (!X509_CRL_set_version(crl, ver)) { ossl_raise(eX509CRLError, NULL); } return version; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+OpenSSL::X509::CRL#signature_algorithm;F;7[;[[@&Hi;T;;C;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE ossl_x509crl_get_signature_algorithm(VALUE self) { X509_CRL *crl; const X509_ALGOR *alg; BIO *out; GetX509CRL(self, crl); if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eX509CRLError, NULL); } X509_CRL_get0_signature(crl, NULL, &alg); if (!i2a_ASN1_OBJECT(out, alg->algorithm)) { BIO_free(out); ossl_raise(eX509CRLError, NULL); } return ossl_membio2str(out); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::X509::CRL#issuer;F;7[;[[@&Hi;T;;N;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE ossl_x509crl_get_issuer(VALUE self) { X509_CRL *crl; GetX509CRL(self, crl); return ossl_x509name_new(X509_CRL_get_issuer(crl)); /* NO DUP - don't free */ };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::X509::CRL#issuer=;F;7[[I" issuer;T0;[[@&Hi;T;;L;0;[;{;IC; "NO DUP - don't free ;T;[;![;"I"NO DUP - don't free;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509crl_set_issuer(VALUE self, VALUE issuer) { X509_CRL *crl; GetX509CRL(self, crl); if (!X509_CRL_set_issuer_name(crl, GetX509NamePtr(issuer))) { /* DUPs name */ ossl_raise(eX509CRLError, NULL); } return issuer; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::X509::CRL#last_update;F;7[;[[@&Hi;T;:last_update;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE ossl_x509crl_get_last_update(VALUE self) { X509_CRL *crl; const ASN1_TIME *time; GetX509CRL(self, crl); time = X509_CRL_get0_lastUpdate(crl); if (!time) return Qnil; return asn1time_to_time(time); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$OpenSSL::X509::CRL#last_update=;F;7[[I" time;T0;[[@&Hi;T;:last_update=;0;[;{;IC; " ;T;[;![;"@;#0;$@&;%@;9I"{static VALUE ossl_x509crl_set_last_update(VALUE self, VALUE time) { X509_CRL *crl; ASN1_TIME *asn1time; GetX509CRL(self, crl); asn1time = ossl_x509_time_adjust(NULL, time); if (!X509_CRL_set1_lastUpdate(crl, asn1time)) { ASN1_TIME_free(asn1time); ossl_raise(eX509CRLError, "X509_CRL_set_lastUpdate"); } ASN1_TIME_free(asn1time); return time; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::X509::CRL#next_update;F;7[;[[@&Hi;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@4;%@;9I"static VALUE ossl_x509crl_get_next_update(VALUE self) { X509_CRL *crl; const ASN1_TIME *time; GetX509CRL(self, crl); time = X509_CRL_get0_nextUpdate(crl); if (!time) return Qnil; return asn1time_to_time(time); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$OpenSSL::X509::CRL#next_update=;F;7[[I" time;T0;[[@&Hi;T;:next_update=;0;[;{;IC; " ;T;[;![;"@;#0;$@@;%@;9I"{static VALUE ossl_x509crl_set_next_update(VALUE self, VALUE time) { X509_CRL *crl; ASN1_TIME *asn1time; GetX509CRL(self, crl); asn1time = ossl_x509_time_adjust(NULL, time); if (!X509_CRL_set1_nextUpdate(crl, asn1time)) { ASN1_TIME_free(asn1time); ossl_raise(eX509CRLError, "X509_CRL_set_nextUpdate"); } ASN1_TIME_free(asn1time); return time; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::X509::CRL#revoked;F;7[;[[@&Hi;T;: revoked;0;[;{;IC; " ;T;[;![;"@;#0;$@N;%@;9I"static VALUE ossl_x509crl_get_revoked(VALUE self) { X509_CRL *crl; int i, num; X509_REVOKED *rev; VALUE ary, revoked; GetX509CRL(self, crl); num = sk_X509_REVOKED_num(X509_CRL_get_REVOKED(crl)); if (num < 0) { OSSL_Debug("num < 0???"); return rb_ary_new(); } ary = rb_ary_new2(num); for(i=0; istatic VALUE ossl_x509crl_to_text(VALUE self) { X509_CRL *crl; BIO *out; GetX509CRL(self, crl); if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eX509CRLError, NULL); } if (!X509_CRL_print(out, crl)) { BIO_free(out); ossl_raise(eX509CRLError, NULL); } return ossl_membio2str(out); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::X509::CRL#extensions;F;7[;[[@&Hi;T;;;0;[;{;IC; "7Gets X509v3 extensions as array of X509Ext objects ;T;[;![;"I"8Gets X509v3 extensions as array of X509Ext objects ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509crl_get_extensions(VALUE self) { X509_CRL *crl; int count, i; X509_EXTENSION *ext; VALUE ary; GetX509CRL(self, crl); count = X509_CRL_get_ext_count(crl); if (count < 0) { OSSL_Debug("count < 0???"); return rb_ary_new(); } ary = rb_ary_new2(count); for (i=0; iI" overload;F;?0;:X509::Name.new;@0;:I"X509::Name.new;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;q;@0;:I"X509::Name.new(der);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"der;T0;$@o;= ;>I" overload;F;?0;;q;@0;:I"'X509::Name.new(distinguished_name);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"distinguished_name;T0;$@o;= ;>I" overload;F;?0;;q;@0;:I"1X509::Name.new(distinguished_name, template);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"distinguished_name;T0[I" template;T0;$@;![;"I" Creates a new Name. A name may be created from a DER encoded string _der_, an Array representing a _distinguished_name_ or a _distinguished_name_ along with a _template_. name = OpenSSL::X509::Name.new [['CN', 'nobody'], ['DC', 'example']] name = OpenSSL::X509::Name.new name.to_der See add_entry for a description of the _distinguished_name_ Array's contents @overload X509::Name.new @overload X509::Name.new(der) @overload X509::Name.new(distinguished_name) @overload X509::Name.new(distinguished_name, template);T;#0;$@;.F;/o;0;1T;2i};3i;%@;9I"Gstatic VALUE ossl_x509name_initialize(int argc, VALUE *argv, VALUE self) { X509_NAME *name; VALUE arg, template; GetX509Name(self, name); if (rb_scan_args(argc, argv, "02", &arg, &template) == 0) { return self; } else { VALUE tmp = rb_check_array_type(arg); if (!NIL_P(tmp)) { VALUE args; if(NIL_P(template)) template = OBJECT_TYPE_TEMPLATE; args = rb_ary_new3(2, self, template); rb_block_call(tmp, rb_intern("each"), 0, 0, ossl_x509name_init_i, args); } else{ const unsigned char *p; VALUE str = ossl_to_der_if_possible(arg); X509_NAME *x; StringValue(str); p = (unsigned char *)RSTRING_PTR(str); x = d2i_X509_NAME(&name, &p, RSTRING_LEN(str)); DATA_PTR(self) = name; if(!x){ ossl_raise(eX509NameError, NULL); } } } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(OpenSSL::X509::Name#initialize_copy;F;7[[I" other;T0;[[@5Hi;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@ݐ;%@;9I"static VALUE ossl_x509name_initialize_copy(VALUE self, VALUE other) { X509_NAME *name, *name_other, *name_new; rb_check_frozen(self); GetX509Name(self, name); GetX509Name(other, name_other); name_new = X509_NAME_dup(name_other); if (!name_new) ossl_raise(eX509NameError, "X509_NAME_dup"); SetX509Name(self, name_new); X509_NAME_free(name); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::X509::Name#add_entry;F;7[[@90;[[@5Hi;T;:add_entry;0;[;{;IC; " Adds a new entry with the given _oid_ and _value_ to this name. The _oid_ is an object identifier defined in ASN.1. Some common OIDs are: C:: Country Name CN:: Common Name DC:: Domain Component O:: Organization Name OU:: Organizational Unit Name ST:: State or Province Name The optional keyword parameters _loc_ and _set_ specify where to insert the new attribute. Refer to the manpage of X509_NAME_add_entry(3) for details. _loc_ defaults to -1 and _set_ defaults to 0. This appends a single-valued RDN to the end. ;T;[o;= ;>I" overload;F;?0;;r;@0;:I"4add_entry(oid, value [, type], loc: -1, set: 0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[ [I"oid;T0[I"value[, type];T0[I" loc:;TI"-1;T[I" set:;TI"0;T;$@;![;"I"VAdds a new entry with the given _oid_ and _value_ to this name. The _oid_ is an object identifier defined in ASN.1. Some common OIDs are: C:: Country Name CN:: Common Name DC:: Domain Component O:: Organization Name OU:: Organizational Unit Name ST:: State or Province Name The optional keyword parameters _loc_ and _set_ specify where to insert the new attribute. Refer to the manpage of X509_NAME_add_entry(3) for details. _loc_ defaults to -1 and _set_ defaults to 0. This appends a single-valued RDN to the end. @overload add_entry(oid, value [, type], loc: -1, set: 0) @return [self];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509name_add_entry(int argc, VALUE *argv, VALUE self) { X509_NAME *name; VALUE oid, value, type, opts, kwargs[2]; static ID kwargs_ids[2]; const char *oid_name; int loc = -1, set = 0; if (!kwargs_ids[0]) { kwargs_ids[0] = rb_intern_const("loc"); kwargs_ids[1] = rb_intern_const("set"); } rb_scan_args(argc, argv, "21:", &oid, &value, &type, &opts); rb_get_kwargs(opts, kwargs_ids, 0, 2, kwargs); oid_name = StringValueCStr(oid); StringValue(value); if(NIL_P(type)) type = rb_aref(OBJECT_TYPE_TEMPLATE, oid); if (kwargs[0] != Qundef) loc = NUM2INT(kwargs[0]); if (kwargs[1] != Qundef) set = NUM2INT(kwargs[1]); GetX509Name(self, name); if (!X509_NAME_add_entry_by_txt(name, oid_name, NUM2INT(type), (unsigned char *)RSTRING_PTR(value), RSTRING_LENINT(value), loc, set)) ossl_raise(eX509NameError, "X509_NAME_add_entry_by_txt"); return self; };T;:I" static;T;;To;4;5F;6;;;;&I"OpenSSL::X509::Name#to_s;F;7[[@90;[[@5Hi/;T;;G;0;[;{;IC; "Returns a String representation of the Distinguished Name. _format_ is one of: * OpenSSL::X509::Name::COMPAT * OpenSSL::X509::Name::RFC2253 * OpenSSL::X509::Name::ONELINE * OpenSSL::X509::Name::MULTILINE If _format_ is omitted, the largely broken and traditional OpenSSL format (X509_NAME_oneline() format) is chosen. Use of this method is discouraged. None of the formats other than OpenSSL::X509::Name::RFC2253 is standardized and may show an inconsistent behavior through \OpenSSL versions. It is recommended to use #to_utf8 instead, which is equivalent to calling name.to_s(OpenSSL::X509::Name::RFC2253).force_encoding("UTF-8"). ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;G;@0;:I"to_s(format);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I" format;T0;$@;![;"I"Returns a String representation of the Distinguished Name. _format_ is one of: * OpenSSL::X509::Name::COMPAT * OpenSSL::X509::Name::RFC2253 * OpenSSL::X509::Name::ONELINE * OpenSSL::X509::Name::MULTILINE If _format_ is omitted, the largely broken and traditional OpenSSL format (X509_NAME_oneline() format) is chosen. Use of this method is discouraged. None of the formats other than OpenSSL::X509::Name::RFC2253 is standardized and may show an inconsistent behavior through \OpenSSL versions. It is recommended to use #to_utf8 instead, which is equivalent to calling name.to_s(OpenSSL::X509::Name::RFC2253).force_encoding("UTF-8"). @overload to_s @return [String] @overload to_s(format) @return [String];T;#0;$@;.F;/o;0;1T;2i;3i.;%@;9I" static VALUE ossl_x509name_to_s(int argc, VALUE *argv, VALUE self) { rb_check_arity(argc, 0, 1); /* name.to_s(nil) was allowed */ if (!argc || NIL_P(argv[0])) return ossl_x509name_to_s_old(self); else return x509name_print(self, NUM2ULONG(argv[0])); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" OpenSSL::X509::Name#to_utf8;F;7[;[[@5HiA;T;: to_utf8;0;[;{;IC; "|Returns an UTF-8 representation of the distinguished name, as specified in {RFC 2253}[https://www.ietf.org/rfc/rfc2253.txt]. ;T;[o;= ;>I" overload;F;?0;;s;@0;:I" to_utf8;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@<;![;"I"@return [String];T;#0;$@<;.F;Bi;C0;7[;$@<;![;"I"Returns an UTF-8 representation of the distinguished name, as specified in {RFC 2253}[https://www.ietf.org/rfc/rfc2253.txt]. @overload to_utf8 @return [String];T;#0;$@<;.F;/o;0;1T;2i:;3i?;%@;9I"static VALUE ossl_x509name_to_utf8(VALUE self) { VALUE str = x509name_print(self, XN_FLAG_RFC2253 & ~ASN1_STRFLGS_ESC_MSB); rb_enc_associate_index(str, rb_utf8_encindex()); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" OpenSSL::X509::Name#inspect;F;7[;[[@5HiJ;T;;J;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@W;.F;/o;0;1T;2iI;3iI;%@;9I"static VALUE ossl_x509name_inspect(VALUE self) { return rb_enc_sprintf(rb_utf8_encoding(), "#<%"PRIsVALUE" %"PRIsVALUE">", rb_obj_class(self), ossl_x509name_to_utf8(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::X509::Name#to_a;F;7[;[[@5HiX;T;;;0;[;{;IC; "\Returns an Array representation of the distinguished name suitable for passing to ::new ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_a;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@e;![;"I"@return [Array];T;#0;$@e;.F;Bi;C0;7[;$@e;![;"I"Returns an Array representation of the distinguished name suitable for passing to ::new @overload to_a @return [Array];T;#0;$@e;.F;/o;0;1T;2iQ;3iV;%@;9I"static VALUE ossl_x509name_to_a(VALUE self) { X509_NAME *name; X509_NAME_ENTRY *entry; int i,entries,nid; char long_name[512]; const char *short_name; VALUE ary, vname, ret; ASN1_STRING *value; GetX509Name(self, name); entries = X509_NAME_entry_count(name); if (entries < 0) { OSSL_Debug("name entries < 0!"); return rb_ary_new(); } ret = rb_ary_new2(entries); for (i=0; itype)); rb_ary_push(ret, ary); } return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::X509::Name#cmp;F;7[[I" other;T0;[[@5Hi;T;; ;0;[;{;IC; "Compares this Name with _other_ and returns +0+ if they are the same and +-1+ or ++1+ if they are greater or less than each other respectively. Returns +nil+ if they are not comparable (i.e. different types). ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"cmp(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"-1 | 0 | 1 | nil;T;$@;![;"I"@return [-1 | 0 | 1 | nil];T;#0;$@;.F;Bi;C0;7[[I" other;T0;$@o;= ;>I" overload;F;?0;;Y;@0;:I"<=>(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"-1 | 0 | 1 | nil;T;$@;![;"I"@return [-1 | 0 | 1 | nil];T;#0;$@;.F;Bi;C0;7[[I" other;T0;$@;![;"I"6Compares this Name with _other_ and returns +0+ if they are the same and +-1+ or ++1+ if they are greater or less than each other respectively. Returns +nil+ if they are not comparable (i.e. different types). @overload cmp(other) @return [-1 | 0 | 1 | nil] @overload <=>(other) @return [-1 | 0 | 1 | nil];T;#0;$o;4;5F;6;;;;&I"OpenSSL::X509::Name#<=>;F;7[;[[@5Hi;F;;Y;;;[;{;@;%@;9I"static VALUE ossl_x509name_cmp(VALUE self, VALUE other) { int result; if (!rb_obj_is_kind_of(other, cX509Name)) return Qnil; result = ossl_x509name_cmp0(self, other); if (result < 0) return INT2FIX(-1); if (result > 0) return INT2FIX(1); return INT2FIX(0); };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509name_cmp(VALUE self, VALUE other) { int result; if (!rb_obj_is_kind_of(other, cX509Name)) return Qnil; result = ossl_x509name_cmp0(self, other); if (result < 0) return INT2FIX(-1); if (result > 0) return INT2FIX(1); return INT2FIX(0); };T;:@;;T@o;4;5F;6;;;;&I"OpenSSL::X509::Name#eql?;F;7[[I" other;T0;[[@5Hi;T;;V;0;[;{;IC; "CReturns true if _name_ and _other_ refer to the same hash key.;T;[o;= ;>I" overload;F;?0;;V;@0;:I"eql?(other);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" other;T0;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"[Returns true if _name_ and _other_ refer to the same hash key. @overload eql?(other);T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE ossl_x509name_eql(VALUE self, VALUE other) { if (!rb_obj_is_kind_of(other, cX509Name)) return Qfalse; return ossl_x509name_cmp0(self, other) == 0 ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::X509::Name#hash;F;7[;[[@5Hi;T;;X;0;[;{;IC; "ZThe hash value returned is suitable for use as a certificate's filename in a CA path. ;T;[o;= ;>I" overload;F;?0;;X;@0;:I" hash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ӑ;![;"I"@return [Integer];T;#0;$@ӑ;.F;Bi;C0;7[;$@ӑ;![;"I"The hash value returned is suitable for use as a certificate's filename in a CA path. @overload hash @return [Integer];T;#0;$@ӑ;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509name_hash(VALUE self) { X509_NAME *name; unsigned long hash; GetX509Name(self, name); hash = X509_NAME_hash(name); return ULONG2NUM(hash); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!OpenSSL::X509::Name#hash_old;F;7[;[[@5Hi;T;: hash_old;0;[;{;IC; "5Returns an MD5 based hash used in OpenSSL 0.9.X. ;T;[o;= ;>I" overload;F;?0;;t;@0;:I" hash_old;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"^Returns an MD5 based hash used in OpenSSL 0.9.X. @overload hash_old @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509name_hash_old(VALUE self) { X509_NAME *name; unsigned long hash; GetX509Name(self, name); hash = X509_NAME_hash_old(name); return ULONG2NUM(hash); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::X509::Name#to_der;F;7[;[[@5Hi;T;;M;0;[;{;IC; "&Converts the name to DER encoding ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" to_der;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"LConverts the name to DER encoding @overload to_der @return [String];T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509name_to_der(VALUE self) { X509_NAME *name; VALUE str; long len; unsigned char *p; GetX509Name(self, name); if((len = i2d_X509_NAME(name, NULL)) <= 0) ossl_raise(eX509NameError, NULL); str = rb_str_new(0, len); p = (unsigned char *)RSTRING_PTR(str); if(i2d_X509_NAME(name, &p) <= 0) ossl_raise(eX509NameError, NULL); ossl_str_adjust(str, p); return str; };T;:I"static VALUE;T;;To;u;[[@5Hi);F;:DEFAULT_OBJECT_TYPE;;w;;;[;{;IC; ".The default object type for name entries. ;T;[;![;"I"/The default object type for name entries. ;T;#0;$@$;.F;/o;0;1T;2i&;3i';%@;&I"-OpenSSL::X509::Name::DEFAULT_OBJECT_TYPE;F;xI" utf8str;To;u;[[@5Hi7;F;:OBJECT_TYPE_TEMPLATE;;w;;;[;{;IC; "7The default object type template for name entries. ;T;[;![;"I"8The default object type template for name entries. ;T;#0;$@0;.F;/o;0;1T;2i4;3i5;%@;&I".OpenSSL::X509::Name::OBJECT_TYPE_TEMPLATE;F;xI" hash;To;u;[[@5Hi?;F;: COMPAT;;w;;;[;{;IC; "bA flag for #to_s. Breaks the name returned into multiple lines if longer than 80 characters. ;T;[;![;"I"cA flag for #to_s. Breaks the name returned into multiple lines if longer than 80 characters. ;T;#0;$@<;.F;/o;0;1T;2i9;3i=;%@;&I" OpenSSL::X509::Name::COMPAT;F;xI"ULONG2NUM(XN_FLAG_COMPAT);To;u;[[@5HiF;F;: RFC2253;;w;;;[;{;IC; "7A flag for #to_s. Returns an RFC2253 format name. ;T;[;![;"I"8A flag for #to_s. Returns an RFC2253 format name. ;T;#0;$@H;.F;/o;0;1T;2iA;3iD;%@;&I"!OpenSSL::X509::Name::RFC2253;F;xI"ULONG2NUM(XN_FLAG_RFC2253);To;u;[[@5HiM;F;: ONELINE;;w;;;[;{;IC; "DA flag for #to_s. Returns a more readable format than RFC2253. ;T;[;![;"I"EA flag for #to_s. Returns a more readable format than RFC2253. ;T;#0;$@T;.F;/o;0;1T;2iH;3iK;%@;&I"!OpenSSL::X509::Name::ONELINE;F;xI"ULONG2NUM(XN_FLAG_ONELINE);To;u;[[@5HiT;F;:MULTILINE;;w;;;[;{;IC; "3A flag for #to_s. Returns a multiline format. ;T;[;![;"I"4A flag for #to_s. Returns a multiline format. ;T;#0;$@`;.F;/o;0;1T;2iO;3iR;%@;&I"#OpenSSL::X509::Name::MULTILINE;F;xI"!ULONG2NUM(XN_FLAG_MULTILINE);T; @; IC;[; @; IC;[@?_; @; IC;{;IC;{;T;IC;{;T;T;{@; ;[;[[@5Hi[@5Hi;T;: Name;;;;;[;{;IC; "]An X.509 name represents a hostname, email address or other entity associated with a public key. You can create a Name by parsing a distinguished name String or by supplying the distinguished name as an Array. name = OpenSSL::X509::Name.parse_rfc2253 'DC=example,CN=nobody' name = OpenSSL::X509::Name.new [['CN', 'nobody'], ['DC', 'example']];T;[;![;"I"_ An X.509 name represents a hostname, email address or other entity associated with a public key. You can create a Name by parsing a distinguished name String or by supplying the distinguished name as an Array. name = OpenSSL::X509::Name.parse_rfc2253 'DC=example,CN=nobody' name = OpenSSL::X509::Name.new [['CN', 'nobody'], ['DC', 'example']] ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%o;( ;)@;*I"OpenSSL::X509;T;+0;: X509;%@GH;-@;0;&I"OpenSSL::X509::Name;F;'@o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@5Hi;F;:NameError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"OpenSSL::X509::NameError;F;'@Ho; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@7Hi;F;:ExtensionError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I""OpenSSL::X509::ExtensionError;F;'@Ho; ;IC;[ o;4;5F;6;;;;&I"/OpenSSL::X509::ExtensionFactory#initialize;F;7[[@90;[[@7Hi;T;;D;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"wstatic VALUE ossl_x509extfactory_initialize(int argc, VALUE *argv, VALUE self) { /*X509V3_CTX *ctx;*/ VALUE issuer_cert, subject_cert, subject_req, crl; /*GetX509ExtFactory(self, ctx);*/ rb_scan_args(argc, argv, "04", &issuer_cert, &subject_cert, &subject_req, &crl); if (!NIL_P(issuer_cert)) ossl_x509extfactory_set_issuer_cert(self, issuer_cert); if (!NIL_P(subject_cert)) ossl_x509extfactory_set_subject_cert(self, subject_cert); if (!NIL_P(subject_req)) ossl_x509extfactory_set_subject_req(self, subject_req); if (!NIL_P(crl)) ossl_x509extfactory_set_crl(self, crl); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"8OpenSSL::X509::ExtensionFactory#issuer_certificate=;F;7[[I" cert;T0;[[@7Hi~;T;:issuer_certificate=;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I" static VALUE ossl_x509extfactory_set_issuer_cert(VALUE self, VALUE cert) { X509V3_CTX *ctx; GetX509ExtFactory(self, ctx); rb_iv_set(self, "@issuer_certificate", cert); ctx->issuer_cert = GetX509CertPtr(cert); /* NO DUP NEEDED */ return cert; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"9OpenSSL::X509::ExtensionFactory#subject_certificate=;F;7[[I" cert;T0;[[@7Hi;T;:subject_certificate=;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I" static VALUE ossl_x509extfactory_set_subject_cert(VALUE self, VALUE cert) { X509V3_CTX *ctx; GetX509ExtFactory(self, ctx); rb_iv_set(self, "@subject_certificate", cert); ctx->subject_cert = GetX509CertPtr(cert); /* NO DUP NEEDED */ return cert; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"5OpenSSL::X509::ExtensionFactory#subject_request=;F;7[[I"req;T0;[[@7Hi;T;:subject_request=;0;[;{;IC; " ;T;[;![;"@;#0;$@͒;%@;9I"static VALUE ossl_x509extfactory_set_subject_req(VALUE self, VALUE req) { X509V3_CTX *ctx; GetX509ExtFactory(self, ctx); rb_iv_set(self, "@subject_request", req); ctx->subject_req = GetX509ReqPtr(req); /* NO DUP NEEDED */ return req; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I")OpenSSL::X509::ExtensionFactory#crl=;F;7[[I"crl;T0;[[@7Hi;T;: crl=;0;[;{;IC; " ;T;[;![;"@;#0;$@ے;%@;9I"static VALUE ossl_x509extfactory_set_crl(VALUE self, VALUE crl) { X509V3_CTX *ctx; GetX509ExtFactory(self, ctx); rb_iv_set(self, "@crl", crl); ctx->crl = GetX509CRLPtr(crl); /* NO DUP NEEDED */ return crl; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"/OpenSSL::X509::ExtensionFactory#create_ext;F;7[[@90;[[@7Hi;T;:create_ext;0;[;{;IC; "QCreates a new X509::Extension with passed values. See also x509v3_config(5). ;T;[o;= ;>I" overload;F;?0;;;@0;:I"4create_ext(ln_or_sn, "value", critical = false);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"X509::Extension;T;$@;![;"I"@return [X509::Extension];T;#0;$@;.F;Bi;C0;7[[I" ln_or_sn;T0[" "value"0[I" critical;TI" false;T;$@o;= ;>I" overload;F;?0;;;@0;:I"+create_ext(ln_or_sn, "critical,value");T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"X509::Extension;T;$@;![;"I"@return [X509::Extension];T;#0;$@;.F;Bi;C0;7[[I" ln_or_sn;T0[""critical,value"0;$@;![;"I"Creates a new X509::Extension with passed values. See also x509v3_config(5). @overload create_ext(ln_or_sn, "value", critical = false) @return [X509::Extension] @overload create_ext(ln_or_sn, "critical,value") @return [X509::Extension];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"Astatic VALUE ossl_x509extfactory_create_ext(int argc, VALUE *argv, VALUE self) { X509V3_CTX *ctx; X509_EXTENSION *ext; VALUE oid, value, critical, valstr, obj; int nid; VALUE rconf; CONF *conf; rb_scan_args(argc, argv, "21", &oid, &value, &critical); StringValueCStr(oid); StringValue(value); if(NIL_P(critical)) critical = Qfalse; nid = OBJ_ln2nid(RSTRING_PTR(oid)); if(!nid) nid = OBJ_sn2nid(RSTRING_PTR(oid)); if(!nid) ossl_raise(eX509ExtError, "unknown OID `%"PRIsVALUE"'", oid); valstr = rb_str_new2(RTEST(critical) ? "critical," : ""); rb_str_append(valstr, value); StringValueCStr(valstr); GetX509ExtFactory(self, ctx); obj = NewX509Ext(cX509Ext); rconf = rb_iv_get(self, "@config"); conf = NIL_P(rconf) ? NULL : GetConfig(rconf); X509V3_set_nconf(ctx, conf); ext = X509V3_EXT_nconf_nid(conf, ctx, nid, RSTRING_PTR(valstr)); X509V3_set_ctx_nodb(ctx); if (!ext){ ossl_raise(eX509ExtError, "%"PRIsVALUE" = %"PRIsVALUE, oid, valstr); } SetX509Ext(obj, ext); return obj; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@7Hi;F;:ExtensionFactory;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I"$OpenSSL::X509::ExtensionFactory;F;'@o; ;IC;[o;4;5F;6;;;;&I"(OpenSSL::X509::Extension#initialize;F;7[[@90;[[@7Hi;T;;D;0;[;{;IC; "Creates an X509 extension. The extension may be created from _der_ data or from an extension _oid_ and _value_. The _oid_ may be either an OID or an extension name. If _critical_ is +true+ the extension is marked critical. ;T;[o;= ;>I" overload;F;?0;:!OpenSSL::X509::Extension.new;@0;:I"&OpenSSL::X509::Extension.new(der);T;IC; ";T;[;![;"I";T;#0;$@.;.F;Bi;C0;7[[I"der;T0;$@.o;= ;>I" overload;F;?0;;;@0;:I"-OpenSSL::X509::Extension.new(oid, value);T;IC; ";T;[;![;"I";T;#0;$@.;.F;Bi;C0;7[[I"oid;T0[I" value;T0;$@.o;= ;>I" overload;F;?0;;;@0;:I"7OpenSSL::X509::Extension.new(oid, value, critical);T;IC; ";T;[;![;"I";T;#0;$@.;.F;Bi;C0;7[[I"oid;T0[I" value;T0[I" critical;T0;$@.;![;"I"Creates an X509 extension. The extension may be created from _der_ data or from an extension _oid_ and _value_. The _oid_ may be either an OID or an extension name. If _critical_ is +true+ the extension is marked critical. @overload OpenSSL::X509::Extension.new(der) @overload OpenSSL::X509::Extension.new(oid, value) @overload OpenSSL::X509::Extension.new(oid, value, critical);T;#0;$@.;.F;/o;0;1T;2i;3i ;%@,;9I"static VALUE ossl_x509ext_initialize(int argc, VALUE *argv, VALUE self) { VALUE oid, value, critical; const unsigned char *p; X509_EXTENSION *ext, *x; GetX509Ext(self, ext); if(rb_scan_args(argc, argv, "12", &oid, &value, &critical) == 1){ oid = ossl_to_der_if_possible(oid); StringValue(oid); p = (unsigned char *)RSTRING_PTR(oid); x = d2i_X509_EXTENSION(&ext, &p, RSTRING_LEN(oid)); DATA_PTR(self) = ext; if(!x) ossl_raise(eX509ExtError, NULL); return self; } rb_funcall(self, rb_intern("oid="), 1, oid); rb_funcall(self, rb_intern("value="), 1, value); if(argc > 2) rb_funcall(self, rb_intern("critical="), 1, critical); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"-OpenSSL::X509::Extension#initialize_copy;F;7[[I" other;T0;[[@7Hi(;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@a;%@,;9I"static VALUE ossl_x509ext_initialize_copy(VALUE self, VALUE other) { X509_EXTENSION *ext, *ext_other, *ext_new; rb_check_frozen(self); GetX509Ext(self, ext); GetX509Ext(other, ext_other); ext_new = X509_EXTENSION_dup(ext_other); if (!ext_new) ossl_raise(eX509ExtError, "X509_EXTENSION_dup"); SetX509Ext(self, ext_new); X509_EXTENSION_free(ext); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::X509::Extension#oid=;F;7[[I"oid;T0;[[@7Hi;;T;: oid=;0;[;{;IC; " ;T;[;![;"@;#0;$@o;%@,;9I"static VALUE ossl_x509ext_set_oid(VALUE self, VALUE oid) { X509_EXTENSION *ext; ASN1_OBJECT *obj; GetX509Ext(self, ext); obj = OBJ_txt2obj(StringValueCStr(oid), 0); if (!obj) ossl_raise(eX509ExtError, "OBJ_txt2obj"); if (!X509_EXTENSION_set_object(ext, obj)) { ASN1_OBJECT_free(obj); ossl_raise(eX509ExtError, "X509_EXTENSION_set_object"); } ASN1_OBJECT_free(obj); return oid; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$OpenSSL::X509::Extension#value=;F;7[[I" data;T0;[[@7HiN;T;: value=;0;[;{;IC; " ;T;[;![;"@;#0;$@};%@,;9I"static VALUE ossl_x509ext_set_value(VALUE self, VALUE data) { X509_EXTENSION *ext; ASN1_OCTET_STRING *asn1s; GetX509Ext(self, ext); data = ossl_to_der_if_possible(data); StringValue(data); asn1s = X509_EXTENSION_get_data(ext); if (!ASN1_OCTET_STRING_set(asn1s, (unsigned char *)RSTRING_PTR(data), RSTRING_LENINT(data))) { ossl_raise(eX509ExtError, "ASN1_OCTET_STRING_set"); } return data; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::X509::Extension#critical=;F;7[[I" flag;T0;[[@7Hia;T;:critical=;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@,;9I"static VALUE ossl_x509ext_set_critical(VALUE self, VALUE flag) { X509_EXTENSION *ext; GetX509Ext(self, ext); X509_EXTENSION_set_critical(ext, RTEST(flag) ? 1 : 0); return flag; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!OpenSSL::X509::Extension#oid;F;7[;[[@7Hil;T;:oid;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@,;9I"static VALUE ossl_x509ext_get_oid(VALUE obj) { X509_EXTENSION *ext; ASN1_OBJECT *extobj; BIO *out; VALUE ret; int nid; GetX509Ext(obj, ext); extobj = X509_EXTENSION_get_object(ext); if ((nid = OBJ_obj2nid(extobj)) != NID_undef) ret = rb_str_new2(OBJ_nid2sn(nid)); else{ if (!(out = BIO_new(BIO_s_mem()))) ossl_raise(eX509ExtError, NULL); i2a_ASN1_OBJECT(out, extobj); ret = ossl_membio2str(out); } return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::X509::Extension#value;F;7[;[[@7Hi;T;;5;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@,;9I"nstatic VALUE ossl_x509ext_get_value(VALUE obj) { X509_EXTENSION *ext; BIO *out; VALUE ret; GetX509Ext(obj, ext); if (!(out = BIO_new(BIO_s_mem()))) ossl_raise(eX509ExtError, NULL); if (!X509V3_EXT_print(out, ext, 0, 0)) ASN1_STRING_print(out, (ASN1_STRING *)X509_EXTENSION_get_data(ext)); ret = ossl_membio2str(out); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::X509::Extension#value_der;F;7[;[[@7Hi;T;:value_der;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@,;9I"$static VALUE ossl_x509ext_get_value_der(VALUE obj) { X509_EXTENSION *ext; ASN1_OCTET_STRING *value; GetX509Ext(obj, ext); if ((value = X509_EXTENSION_get_data(ext)) == NULL) ossl_raise(eX509ExtError, NULL); return rb_str_new((const char *)value->data, value->length); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::X509::Extension#critical?;F;7[;[[@7Hi;T;:critical?;0;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"@;#0;$@;Bi;%@,;9I"static VALUE ossl_x509ext_get_critical(VALUE obj) { X509_EXTENSION *ext; GetX509Ext(obj, ext); return X509_EXTENSION_get_critical(ext) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$OpenSSL::X509::Extension#to_der;F;7[;[[@7Hi;T;;M;0;[;{;IC; " ;T;[;![;"@;#0;$@̓;%@,;9I"static VALUE ossl_x509ext_to_der(VALUE obj) { X509_EXTENSION *ext; unsigned char *p; long len; VALUE str; GetX509Ext(obj, ext); if((len = i2d_X509_EXTENSION(ext, NULL)) <= 0) ossl_raise(eX509ExtError, NULL); str = rb_str_new(0, len); p = (unsigned char *)RSTRING_PTR(str); if(i2d_X509_EXTENSION(ext, &p) < 0) ossl_raise(eX509ExtError, NULL); ossl_str_adjust(str, p); return str; };T;:I"static VALUE;T;;T; @,; IC;[; @,; IC;[; @,; IC;{;IC;{;T;IC;{;T;T;{;[;[[@7Hi;F;:Extension;;;;;[;{;IC; " ;T;[;![;"@;#0;$@,;Bi;%@;&I"OpenSSL::X509::Extension;F;'@o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@=Hi9;F;:AttributeError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I""OpenSSL::X509::AttributeError;F;'@Ho; ;IC;[ o;4;5F;6;;;;&I"(OpenSSL::X509::Attribute#initialize;F;7[[@90;[[@=Hij;T;;D;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(oid [, value]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"oid[, value];T0;$@;![;"I"" @overload new(oid [, value]);T;#0;$@;.F;/o;0;1T;2if;3ig;%@;9I"bstatic VALUE ossl_x509attr_initialize(int argc, VALUE *argv, VALUE self) { VALUE oid, value; X509_ATTRIBUTE *attr, *x; const unsigned char *p; GetX509Attr(self, attr); if(rb_scan_args(argc, argv, "11", &oid, &value) == 1){ oid = ossl_to_der_if_possible(oid); StringValue(oid); p = (unsigned char *)RSTRING_PTR(oid); x = d2i_X509_ATTRIBUTE(&attr, &p, RSTRING_LEN(oid)); DATA_PTR(self) = attr; if(!x){ ossl_raise(eX509AttrError, NULL); } return self; } rb_funcall(self, rb_intern("oid="), 1, oid); rb_funcall(self, rb_intern("value="), 1, value); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"-OpenSSL::X509::Attribute#initialize_copy;F;7[[I" other;T0;[[@=Hi~;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE ossl_x509attr_initialize_copy(VALUE self, VALUE other) { X509_ATTRIBUTE *attr, *attr_other, *attr_new; rb_check_frozen(self); GetX509Attr(self, attr); GetX509Attr(other, attr_other); attr_new = X509_ATTRIBUTE_dup(attr_other); if (!attr_new) ossl_raise(eX509AttrError, "X509_ATTRIBUTE_dup"); SetX509Attr(self, attr_new); X509_ATTRIBUTE_free(attr); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::X509::Attribute#oid=;F;7[[I"oid;T0;[[@=Hi;T;;;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"oid=(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@!;![;"I"@return [String];T;#0;$@!;.F;Bi;C0;7[[I" string;T0;$@!;![;"I"/ @overload oid=(string) @return [String];T;#0;$@!;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509attr_set_oid(VALUE self, VALUE oid) { X509_ATTRIBUTE *attr; ASN1_OBJECT *obj; char *s; GetX509Attr(self, attr); s = StringValueCStr(oid); obj = OBJ_txt2obj(s, 0); if(!obj) ossl_raise(eX509AttrError, NULL); if (!X509_ATTRIBUTE_set1_object(attr, obj)) { ASN1_OBJECT_free(obj); ossl_raise(eX509AttrError, "X509_ATTRIBUTE_set1_object"); } ASN1_OBJECT_free(obj); return oid; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!OpenSSL::X509::Attribute#oid;F;7[;[[@=Hi;T;;;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"oid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@@;![;"I"@return [String];T;#0;$@@;.F;Bi;C0;7[;$@@;![;"I"& @overload oid @return [String];T;#0;$@@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509attr_get_oid(VALUE self) { X509_ATTRIBUTE *attr; ASN1_OBJECT *oid; BIO *out; VALUE ret; int nid; GetX509Attr(self, attr); oid = X509_ATTRIBUTE_get0_object(attr); if ((nid = OBJ_obj2nid(oid)) != NID_undef) ret = rb_str_new2(OBJ_nid2sn(nid)); else{ if (!(out = BIO_new(BIO_s_mem()))) ossl_raise(eX509AttrError, NULL); i2a_ASN1_OBJECT(out, oid); ret = ossl_membio2str(out); } return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$OpenSSL::X509::Attribute#value=;F;7[[I" value;T0;[[@=Hi;T;;;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"value=(asn1);T;IC; ";T;[;![;"I";T;#0;$@[;.F;Bi;C0;7[[I" asn1;T0;$@[;![;"I" @overload value=(asn1);T;#0;$@[;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509attr_set_value(VALUE self, VALUE value) { X509_ATTRIBUTE *attr; VALUE asn1_value; int i, asn1_tag; OSSL_Check_Kind(value, cASN1Data); asn1_tag = NUM2INT(rb_attr_get(value, rb_intern("@tag"))); asn1_value = rb_attr_get(value, rb_intern("@value")); if (asn1_tag != V_ASN1_SET) ossl_raise(eASN1Error, "argument must be ASN1::Set"); if (!RB_TYPE_P(asn1_value, T_ARRAY)) ossl_raise(eASN1Error, "ASN1::Set has non-array value"); GetX509Attr(self, attr); if (X509_ATTRIBUTE_count(attr)) { /* populated, reset first */ ASN1_OBJECT *obj = X509_ATTRIBUTE_get0_object(attr); X509_ATTRIBUTE *new_attr = X509_ATTRIBUTE_create_by_OBJ(NULL, obj, 0, NULL, -1); if (!new_attr) ossl_raise(eX509AttrError, NULL); SetX509Attr(self, new_attr); X509_ATTRIBUTE_free(attr); attr = new_attr; } for (i = 0; i < RARRAY_LEN(asn1_value); i++) { ASN1_TYPE *a1type = ossl_asn1_get_asn1type(RARRAY_AREF(asn1_value, i)); if (!X509_ATTRIBUTE_set1_data(attr, ASN1_TYPE_get(a1type), a1type->value.ptr, -1)) { ASN1_TYPE_free(a1type); ossl_raise(eX509AttrError, NULL); } ASN1_TYPE_free(a1type); } return value; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::X509::Attribute#value;F;7[;[[@=Hi;T;;5;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;5;@0;:I" value;T;IC; ";T;[;![;"I";T;#0;$@u;.F;Bi;C0;7[;$@u;![;"I" @overload value;T;#0;$@u;.F;/o;0;1T;2i;3i;%@;9I"hstatic VALUE ossl_x509attr_get_value(VALUE self) { X509_ATTRIBUTE *attr; STACK_OF(ASN1_TYPE) *sk; VALUE str; int i, count, len; unsigned char *p; GetX509Attr(self, attr); /* there is no X509_ATTRIBUTE_get0_set() :( */ if (!(sk = sk_ASN1_TYPE_new_null())) ossl_raise(eX509AttrError, "sk_new"); count = X509_ATTRIBUTE_count(attr); for (i = 0; i < count; i++) sk_ASN1_TYPE_push(sk, X509_ATTRIBUTE_get0_type(attr, i)); if ((len = i2d_ASN1_SET_ANY(sk, NULL)) <= 0) { sk_ASN1_TYPE_free(sk); ossl_raise(eX509AttrError, NULL); } str = rb_str_new(0, len); p = (unsigned char *)RSTRING_PTR(str); if (i2d_ASN1_SET_ANY(sk, &p) <= 0) { sk_ASN1_TYPE_free(sk); ossl_raise(eX509AttrError, NULL); } ossl_str_adjust(str, p); sk_ASN1_TYPE_free(sk); return rb_funcall(mASN1, rb_intern("decode"), 1, str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$OpenSSL::X509::Attribute#to_der;F;7[;[[@=Hi;T;;M;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" to_der;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I") @overload to_der @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_x509attr_to_der(VALUE self) { X509_ATTRIBUTE *attr; VALUE str; int len; unsigned char *p; GetX509Attr(self, attr); if((len = i2d_X509_ATTRIBUTE(attr, NULL)) <= 0) ossl_raise(eX509AttrError, NULL); str = rb_str_new(0, len); p = (unsigned char *)RSTRING_PTR(str); if(i2d_X509_ATTRIBUTE(attr, &p) <= 0) ossl_raise(eX509AttrError, NULL); ossl_str_adjust(str, p); return str; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@=Hi;;F;:Attribute;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I"OpenSSL::X509::Attribute;F;'@; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Hi[@"Hif[@$Hia[@&Hi[@3Hi[I"ext/openssl/ossl_x509.c;Ti)[@5Hi [@7Hi[@=Hi6;F;;|;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@GH;&I"OpenSSL::X509;Fo; ;IC;[; @͔; IC;[; @͔; IC;[; @͔; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"ext/openssl/ossl_ts.c;Ti;T;:Timestamp;;;;;[;{;IC; "Provides classes and methods to request, create and validate {RFC3161-compliant}[http://www.ietf.org/rfc/rfc3161.txt] timestamps. Request may be used to either create requests from scratch or to parse existing requests that again can be used to request timestamps from a timestamp server, e.g. via the net/http. The resulting timestamp response may be parsed using Response. Please note that Response is read-only and immutable. To create a Response, an instance of Factory as well as a valid Request are needed. ===Create a Response: #Assumes ts.p12 is a PKCS#12-compatible file with a private key #and a certificate that has an extended key usage of 'timeStamping' p12 = OpenSSL::PKCS12.new(File.binread('ts.p12'), 'pwd') md = OpenSSL::Digest.new('SHA1') hash = md.digest(data) #some binary data to be timestamped req = OpenSSL::Timestamp::Request.new req.algorithm = 'SHA1' req.message_imprint = hash req.policy_id = "1.2.3.4.5" req.nonce = 42 fac = OpenSSL::Timestamp::Factory.new fac.gen_time = Time.now fac.serial_number = 1 timestamp = fac.create_timestamp(p12.key, p12.certificate, req) ===Verify a timestamp response: #Assume we have a timestamp token in a file called ts.der ts = OpenSSL::Timestamp::Response.new(File.binread('ts.der')) #Assume we have the Request for this token in a file called req.der req = OpenSSL::Timestamp::Request.new(File.binread('req.der')) # Assume the associated root CA certificate is contained in a # DER-encoded file named root.cer root = OpenSSL::X509::Certificate.new(File.binread('root.cer')) # get the necessary intermediate certificates, available in # DER-encoded form in inter1.cer and inter2.cer inter1 = OpenSSL::X509::Certificate.new(File.binread('inter1.cer')) inter2 = OpenSSL::X509::Certificate.new(File.binread('inter2.cer')) ts.verify(req, root, inter1, inter2) -> ts or raises an exception if validation fails ;T;[;![;"I"Provides classes and methods to request, create and validate {RFC3161-compliant}[http://www.ietf.org/rfc/rfc3161.txt] timestamps. Request may be used to either create requests from scratch or to parse existing requests that again can be used to request timestamps from a timestamp server, e.g. via the net/http. The resulting timestamp response may be parsed using Response. Please note that Response is read-only and immutable. To create a Response, an instance of Factory as well as a valid Request are needed. ===Create a Response: #Assumes ts.p12 is a PKCS#12-compatible file with a private key #and a certificate that has an extended key usage of 'timeStamping' p12 = OpenSSL::PKCS12.new(File.binread('ts.p12'), 'pwd') md = OpenSSL::Digest.new('SHA1') hash = md.digest(data) #some binary data to be timestamped req = OpenSSL::Timestamp::Request.new req.algorithm = 'SHA1' req.message_imprint = hash req.policy_id = "1.2.3.4.5" req.nonce = 42 fac = OpenSSL::Timestamp::Factory.new fac.gen_time = Time.now fac.serial_number = 1 timestamp = fac.create_timestamp(p12.key, p12.certificate, req) ===Verify a timestamp response: #Assume we have a timestamp token in a file called ts.der ts = OpenSSL::Timestamp::Response.new(File.binread('ts.der')) #Assume we have the Request for this token in a file called req.der req = OpenSSL::Timestamp::Request.new(File.binread('req.der')) # Assume the associated root CA certificate is contained in a # DER-encoded file named root.cer root = OpenSSL::X509::Certificate.new(File.binread('root.cer')) # get the necessary intermediate certificates, available in # DER-encoded form in inter1.cer and inter2.cer inter1 = OpenSSL::X509::Certificate.new(File.binread('inter1.cer')) inter2 = OpenSSL::X509::Certificate.new(File.binread('inter2.cer')) ts.verify(req, root, inter1, inter2) -> ts or raises an exception if validation fails ;T;#0;$@͔;.F;/o;0;1T;2i;3i6;%o;( ;)0;*0;+0;: OpenSSL;%@;-@GH;0;&I"OpenSSL::Timestamp;F;'o;( ;)0;*0;+0;;;%@;-@;0o;;IC;[ o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ Hi.;F;: KDFError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"OpenSSL::KDF::KDFError;F;'@Ho;4;5F;6;;;;&I"OpenSSL::KDF#pbkdf2_hmac;F;7[[@90;[[@ Hi*;T;:pbkdf2_hmac;0;[;{;IC; "(PKCS #5 PBKDF2 (Password-Based Key Derivation Function 2) in combination with HMAC. Takes _pass_, _salt_ and _iterations_, and then derives a key of _length_ bytes. For more information about PBKDF2, see RFC 2898 Section 5.2 (https://tools.ietf.org/html/rfc2898#section-5.2). === Parameters pass :: The passphrase. salt :: The salt. Salts prevent attacks based on dictionaries of common passwords and attacks based on rainbow tables. It is a public value that can be safely stored along with the password (e.g. if the derived value is used for password storage). iterations :: The iteration count. This provides the ability to tune the algorithm. It is better to use the highest count possible for the maximum resistance to brute-force attacks. length :: The desired length of the derived key in octets. hash :: The hash algorithm used with HMAC for the PRF. May be a String representing the algorithm name, or an instance of OpenSSL::Digest. ;T;[o;= ;>I" overload;F;?0;;;@0;:I":pbkdf2_hmac(pass, salt:, iterations:, length:, hash:);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" aString;T;$@;![;"I"@return [aString];T;#0;$@;.F;Bi;C0;7[ [I" pass;T0[I" salt:;TI";T[I"iterations:;TI";T[I" length:;TI";T[I" hash:;TI";T;$@;![;"I"}PKCS #5 PBKDF2 (Password-Based Key Derivation Function 2) in combination with HMAC. Takes _pass_, _salt_ and _iterations_, and then derives a key of _length_ bytes. For more information about PBKDF2, see RFC 2898 Section 5.2 (https://tools.ietf.org/html/rfc2898#section-5.2). === Parameters pass :: The passphrase. salt :: The salt. Salts prevent attacks based on dictionaries of common passwords and attacks based on rainbow tables. It is a public value that can be safely stored along with the password (e.g. if the derived value is used for password storage). iterations :: The iteration count. This provides the ability to tune the algorithm. It is better to use the highest count possible for the maximum resistance to brute-force attacks. length :: The desired length of the derived key in octets. hash :: The hash algorithm used with HMAC for the PRF. May be a String representing the algorithm name, or an instance of OpenSSL::Digest. @overload pbkdf2_hmac(pass, salt:, iterations:, length:, hash:) @return [aString];T;#0;$@;.F;C0;%@;9I"static VALUE kdf_pbkdf2_hmac(int argc, VALUE *argv, VALUE self) { VALUE pass, salt, opts, kwargs[4], str; static ID kwargs_ids[4]; int iters, len; const EVP_MD *md; if (!kwargs_ids[0]) { kwargs_ids[0] = rb_intern_const("salt"); kwargs_ids[1] = rb_intern_const("iterations"); kwargs_ids[2] = rb_intern_const("length"); kwargs_ids[3] = rb_intern_const("hash"); } rb_scan_args(argc, argv, "1:", &pass, &opts); rb_get_kwargs(opts, kwargs_ids, 4, 0, kwargs); StringValue(pass); salt = StringValue(kwargs[0]); iters = NUM2INT(kwargs[1]); len = NUM2INT(kwargs[2]); md = ossl_evp_get_digestbyname(kwargs[3]); str = rb_str_new(0, len); if (!PKCS5_PBKDF2_HMAC(RSTRING_PTR(pass), RSTRING_LENINT(pass), (unsigned char *)RSTRING_PTR(salt), RSTRING_LENINT(salt), iters, md, len, (unsigned char *)RSTRING_PTR(str))) ossl_raise(eKDF, "PKCS5_PBKDF2_HMAC"); return str; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"OpenSSL::KDF.pbkdf2_hmac;F;7@;@;T;;;0;@;{;IC; "(PKCS #5 PBKDF2 (Password-Based Key Derivation Function 2) in combination with HMAC. Takes _pass_, _salt_ and _iterations_, and then derives a key of _length_ bytes. For more information about PBKDF2, see RFC 2898 Section 5.2 (https://tools.ietf.org/html/rfc2898#section-5.2). === Parameters pass :: The passphrase. salt :: The salt. Salts prevent attacks based on dictionaries of common passwords and attacks based on rainbow tables. It is a public value that can be safely stored along with the password (e.g. if the derived value is used for password storage). iterations :: The iteration count. This provides the ability to tune the algorithm. It is better to use the highest count possible for the maximum resistance to brute-force attacks. length :: The desired length of the derived key in octets. hash :: The hash algorithm used with HMAC for the PRF. May be a String representing the algorithm name, or an instance of OpenSSL::Digest.;T;[o;= ;>I" overload;F;?0;;;@0;:I":pbkdf2_hmac(pass, salt:, iterations:, length:, hash:);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" aString;T;$@;![;"I"@return [aString];T;#0;$@;.F;Bi;C0;7[ [I" pass;T0[I" salt:;TI";T[I"iterations:;TI";T[I" length:;TI";T[I" hash:;TI";T;$@;![;"I"~PKCS #5 PBKDF2 (Password-Based Key Derivation Function 2) in combination with HMAC. Takes _pass_, _salt_ and _iterations_, and then derives a key of _length_ bytes. For more information about PBKDF2, see RFC 2898 Section 5.2 (https://tools.ietf.org/html/rfc2898#section-5.2). === Parameters pass :: The passphrase. salt :: The salt. Salts prevent attacks based on dictionaries of common passwords and attacks based on rainbow tables. It is a public value that can be safely stored along with the password (e.g. if the derived value is used for password storage). iterations :: The iteration count. This provides the ability to tune the algorithm. It is better to use the highest count possible for the maximum resistance to brute-force attacks. length :: The desired length of the derived key in octets. hash :: The hash algorithm used with HMAC for the PRF. May be a String representing the algorithm name, or an instance of OpenSSL::Digest. @overload pbkdf2_hmac(pass, salt:, iterations:, length:, hash:) @return [aString];T;#0;$@;.F;/o;0;1T;2i;3i(;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"OpenSSL::KDF#scrypt;F;7[[@90;[[@ Hil;T;: scrypt;0;[;{;IC; "Derives a key from _pass_ using given parameters with the scrypt password-based key derivation function. The result can be used for password storage. scrypt is designed to be memory-hard and more secure against brute-force attacks using custom hardwares than alternative KDFs such as PBKDF2 or bcrypt. The keyword arguments _N_, _r_ and _p_ can be used to tune scrypt. RFC 7914 (published on 2016-08, https://tools.ietf.org/html/rfc7914#section-2) states that using values r=8 and p=1 appears to yield good results. See RFC 7914 (https://tools.ietf.org/html/rfc7914) for more information. === Parameters pass :: Passphrase. salt :: Salt. N :: CPU/memory cost parameter. This must be a power of 2. r :: Block size parameter. p :: Parallelization parameter. length :: Length in octets of the derived key. === Example pass = "password" salt = SecureRandom.random_bytes(16) dk = OpenSSL::KDF.scrypt(pass, salt: salt, N: 2**14, r: 8, p: 1, length: 32) p dk #=> "\xDA\xE4\xE2...\x7F\xA1\x01T" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"-scrypt(pass, salt:, N:, r:, p:, length:);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" aString;T;$@B;![;"I"@return [aString];T;#0;$@B;.F;Bi;C0;7[ [I" pass;T0[I" salt:;TI";T[I"N:;TI",r:;T[I"p:;TI";T[I" length:;TI";T;$@B;![;"I"BDerives a key from _pass_ using given parameters with the scrypt password-based key derivation function. The result can be used for password storage. scrypt is designed to be memory-hard and more secure against brute-force attacks using custom hardwares than alternative KDFs such as PBKDF2 or bcrypt. The keyword arguments _N_, _r_ and _p_ can be used to tune scrypt. RFC 7914 (published on 2016-08, https://tools.ietf.org/html/rfc7914#section-2) states that using values r=8 and p=1 appears to yield good results. See RFC 7914 (https://tools.ietf.org/html/rfc7914) for more information. === Parameters pass :: Passphrase. salt :: Salt. N :: CPU/memory cost parameter. This must be a power of 2. r :: Block size parameter. p :: Parallelization parameter. length :: Length in octets of the derived key. === Example pass = "password" salt = SecureRandom.random_bytes(16) dk = OpenSSL::KDF.scrypt(pass, salt: salt, N: 2**14, r: 8, p: 1, length: 32) p dk #=> "\xDA\xE4\xE2...\x7F\xA1\x01T" @overload scrypt(pass, salt:, N:, r:, p:, length:) @return [aString];T;#0;$@B;.F;C0;%@;9I"static VALUE kdf_scrypt(int argc, VALUE *argv, VALUE self) { VALUE pass, salt, opts, kwargs[5], str; static ID kwargs_ids[5]; size_t len; uint64_t N, r, p, maxmem; if (!kwargs_ids[0]) { kwargs_ids[0] = rb_intern_const("salt"); kwargs_ids[1] = rb_intern_const("N"); kwargs_ids[2] = rb_intern_const("r"); kwargs_ids[3] = rb_intern_const("p"); kwargs_ids[4] = rb_intern_const("length"); } rb_scan_args(argc, argv, "1:", &pass, &opts); rb_get_kwargs(opts, kwargs_ids, 5, 0, kwargs); StringValue(pass); salt = StringValue(kwargs[0]); N = NUM2UINT64T(kwargs[1]); r = NUM2UINT64T(kwargs[2]); p = NUM2UINT64T(kwargs[3]); len = NUM2LONG(kwargs[4]); /* * OpenSSL uses 32MB by default (if zero is specified), which is too small. * Let's not limit memory consumption but just let malloc() fail inside * OpenSSL. The amount is controllable by other parameters. */ maxmem = SIZE_MAX; str = rb_str_new(0, len); if (!EVP_PBE_scrypt(RSTRING_PTR(pass), RSTRING_LEN(pass), (unsigned char *)RSTRING_PTR(salt), RSTRING_LEN(salt), N, r, p, maxmem, (unsigned char *)RSTRING_PTR(str), len)) ossl_raise(eKDF, "EVP_PBE_scrypt"); return str; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"OpenSSL::KDF.scrypt;F;7@D;@F;T;;;0;@H;{;IC; "Derives a key from _pass_ using given parameters with the scrypt password-based key derivation function. The result can be used for password storage. scrypt is designed to be memory-hard and more secure against brute-force attacks using custom hardwares than alternative KDFs such as PBKDF2 or bcrypt. The keyword arguments _N_, _r_ and _p_ can be used to tune scrypt. RFC 7914 (published on 2016-08, https://tools.ietf.org/html/rfc7914#section-2) states that using values r=8 and p=1 appears to yield good results. See RFC 7914 (https://tools.ietf.org/html/rfc7914) for more information. === Parameters pass :: Passphrase. salt :: Salt. N :: CPU/memory cost parameter. This must be a power of 2. r :: Block size parameter. p :: Parallelization parameter. length :: Length in octets of the derived key. === Example pass = "password" salt = SecureRandom.random_bytes(16) dk = OpenSSL::KDF.scrypt(pass, salt: salt, N: 2**14, r: 8, p: 1, length: 32) p dk #=> "\xDA\xE4\xE2...\x7F\xA1\x01T";T;[o;= ;>I" overload;F;?0;;;@0;:I"-scrypt(pass, salt:, N:, r:, p:, length:);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" aString;T;$@k;![;"I"@return [aString];T;#0;$@k;.F;Bi;C0;7[ [I" pass;T0[I" salt:;TI";T[I"N:;TI",r:;T[I"p:;TI";T[I" length:;TI";T;$@k;![;"I"CDerives a key from _pass_ using given parameters with the scrypt password-based key derivation function. The result can be used for password storage. scrypt is designed to be memory-hard and more secure against brute-force attacks using custom hardwares than alternative KDFs such as PBKDF2 or bcrypt. The keyword arguments _N_, _r_ and _p_ can be used to tune scrypt. RFC 7914 (published on 2016-08, https://tools.ietf.org/html/rfc7914#section-2) states that using values r=8 and p=1 appears to yield good results. See RFC 7914 (https://tools.ietf.org/html/rfc7914) for more information. === Parameters pass :: Passphrase. salt :: Salt. N :: CPU/memory cost parameter. This must be a power of 2. r :: Block size parameter. p :: Parallelization parameter. length :: Length in octets of the derived key. === Example pass = "password" salt = SecureRandom.random_bytes(16) dk = OpenSSL::KDF.scrypt(pass, salt: salt, N: 2**14, r: 8, p: 1, length: 32) p dk #=> "\xDA\xE4\xE2...\x7F\xA1\x01T" @overload scrypt(pass, salt:, N:, r:, p:, length:) @return [aString];T;#0;$@k;.F;/o;0;1T;2iL;3ij;Bi;%@;9@i;:@j;;To;4;5F;6;;;;&I"OpenSSL::KDF#hkdf;F;7[[@90;[[@ Hi;T;: hkdf;0;[;{;IC; "HMAC-based Extract-and-Expand Key Derivation Function (HKDF) as specified in {RFC 5869}[https://tools.ietf.org/html/rfc5869]. New in OpenSSL 1.1.0. === Parameters _ikm_:: The input keying material. _salt_:: The salt. _info_:: The context and application specific information. _length_:: The output length in octets. Must be <= 255 * HashLen, where HashLen is the length of the hash function output in octets. _hash_:: The hash function. === Example # The values from https://datatracker.ietf.org/doc/html/rfc5869#appendix-A.1 ikm = ["0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"].pack("H*") salt = ["000102030405060708090a0b0c"].pack("H*") info = ["f0f1f2f3f4f5f6f7f8f9"].pack("H*") p OpenSSL::KDF.hkdf(ikm, salt: salt, info: info, length: 42, hash: "SHA256").unpack1("H*") # => "3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865" ;T;[o;= ;>I" overload;F;?0;;;@0;:I",hkdf(ikm, salt:, info:, length:, hash:);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[ [I"ikm;T0[I" salt:;TI";T[I" info:;TI";T[I" length:;TI";T[I" hash:;TI";T;$@;![;"I"HMAC-based Extract-and-Expand Key Derivation Function (HKDF) as specified in {RFC 5869}[https://tools.ietf.org/html/rfc5869]. New in OpenSSL 1.1.0. === Parameters _ikm_:: The input keying material. _salt_:: The salt. _info_:: The context and application specific information. _length_:: The output length in octets. Must be <= 255 * HashLen, where HashLen is the length of the hash function output in octets. _hash_:: The hash function. === Example # The values from https://datatracker.ietf.org/doc/html/rfc5869#appendix-A.1 ikm = ["0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"].pack("H*") salt = ["000102030405060708090a0b0c"].pack("H*") info = ["f0f1f2f3f4f5f6f7f8f9"].pack("H*") p OpenSSL::KDF.hkdf(ikm, salt: salt, info: info, length: 42, hash: "SHA256").unpack1("H*") # => "3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865" @overload hkdf(ikm, salt:, info:, length:, hash:) @return [String];T;#0;$@;.F;C0;%@;9I"static VALUE kdf_hkdf(int argc, VALUE *argv, VALUE self) { VALUE ikm, salt, info, opts, kwargs[4], str; static ID kwargs_ids[4]; int saltlen, ikmlen, infolen; size_t len; const EVP_MD *md; EVP_PKEY_CTX *pctx; if (!kwargs_ids[0]) { kwargs_ids[0] = rb_intern_const("salt"); kwargs_ids[1] = rb_intern_const("info"); kwargs_ids[2] = rb_intern_const("length"); kwargs_ids[3] = rb_intern_const("hash"); } rb_scan_args(argc, argv, "1:", &ikm, &opts); rb_get_kwargs(opts, kwargs_ids, 4, 0, kwargs); StringValue(ikm); ikmlen = RSTRING_LENINT(ikm); salt = StringValue(kwargs[0]); saltlen = RSTRING_LENINT(salt); info = StringValue(kwargs[1]); infolen = RSTRING_LENINT(info); len = (size_t)NUM2LONG(kwargs[2]); if (len > LONG_MAX) rb_raise(rb_eArgError, "length must be non-negative"); md = ossl_evp_get_digestbyname(kwargs[3]); str = rb_str_new(NULL, (long)len); pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, NULL); if (!pctx) ossl_raise(eKDF, "EVP_PKEY_CTX_new_id"); if (EVP_PKEY_derive_init(pctx) <= 0) { EVP_PKEY_CTX_free(pctx); ossl_raise(eKDF, "EVP_PKEY_derive_init"); } if (EVP_PKEY_CTX_set_hkdf_md(pctx, md) <= 0) { EVP_PKEY_CTX_free(pctx); ossl_raise(eKDF, "EVP_PKEY_CTX_set_hkdf_md"); } if (EVP_PKEY_CTX_set1_hkdf_salt(pctx, (unsigned char *)RSTRING_PTR(salt), saltlen) <= 0) { EVP_PKEY_CTX_free(pctx); ossl_raise(eKDF, "EVP_PKEY_CTX_set_hkdf_salt"); } if (EVP_PKEY_CTX_set1_hkdf_key(pctx, (unsigned char *)RSTRING_PTR(ikm), ikmlen) <= 0) { EVP_PKEY_CTX_free(pctx); ossl_raise(eKDF, "EVP_PKEY_CTX_set_hkdf_key"); } if (EVP_PKEY_CTX_add1_hkdf_info(pctx, (unsigned char *)RSTRING_PTR(info), infolen) <= 0) { EVP_PKEY_CTX_free(pctx); ossl_raise(eKDF, "EVP_PKEY_CTX_set_hkdf_info"); } if (EVP_PKEY_derive(pctx, (unsigned char *)RSTRING_PTR(str), &len) <= 0) { EVP_PKEY_CTX_free(pctx); ossl_raise(eKDF, "EVP_PKEY_derive"); } rb_str_set_len(str, (long)len); EVP_PKEY_CTX_free(pctx); return str; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"OpenSSL::KDF.hkdf;F;7@;@;T;;;0;@;{;IC; "HMAC-based Extract-and-Expand Key Derivation Function (HKDF) as specified in {RFC 5869}[https://tools.ietf.org/html/rfc5869]. New in OpenSSL 1.1.0. === Parameters _ikm_:: The input keying material. _salt_:: The salt. _info_:: The context and application specific information. _length_:: The output length in octets. Must be <= 255 * HashLen, where HashLen is the length of the hash function output in octets. _hash_:: The hash function. === Example # The values from https://datatracker.ietf.org/doc/html/rfc5869#appendix-A.1 ikm = ["0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"].pack("H*") salt = ["000102030405060708090a0b0c"].pack("H*") info = ["f0f1f2f3f4f5f6f7f8f9"].pack("H*") p OpenSSL::KDF.hkdf(ikm, salt: salt, info: info, length: 42, hash: "SHA256").unpack1("H*") # => "3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865";T;[o;= ;>I" overload;F;?0;;;@0;:I",hkdf(ikm, salt:, info:, length:, hash:);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[ [I"ikm;T0[I" salt:;TI";T[I" info:;TI";T[I" length:;TI";T[I" hash:;TI";T;$@;![;"I"HMAC-based Extract-and-Expand Key Derivation Function (HKDF) as specified in {RFC 5869}[https://tools.ietf.org/html/rfc5869]. New in OpenSSL 1.1.0. === Parameters _ikm_:: The input keying material. _salt_:: The salt. _info_:: The context and application specific information. _length_:: The output length in octets. Must be <= 255 * HashLen, where HashLen is the length of the hash function output in octets. _hash_:: The hash function. === Example # The values from https://datatracker.ietf.org/doc/html/rfc5869#appendix-A.1 ikm = ["0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"].pack("H*") salt = ["000102030405060708090a0b0c"].pack("H*") info = ["f0f1f2f3f4f5f6f7f8f9"].pack("H*") p OpenSSL::KDF.hkdf(ikm, salt: salt, info: info, length: 42, hash: "SHA256").unpack1("H*") # => "3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865" @overload hkdf(ikm, salt:, info:, length:, hash:) @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ Hi[@ Hi*;T;:KDF;;;;;[;{;IC; "Provides functionality of various KDFs (key derivation function). KDF is typically used for securely deriving arbitrary length symmetric keys to be used with an OpenSSL::Cipher from passwords. Another use case is for storing passwords: Due to the ability to tweak the effort of computation by increasing the iteration count, computation can be slowed down artificially in order to render possible attacks infeasible. Currently, OpenSSL::KDF provides implementations for the following KDF: * PKCS #5 PBKDF2 (Password-Based Key Derivation Function 2) in combination with HMAC * scrypt * HKDF == Examples === Generating a 128 bit key for a Cipher (e.g. AES) pass = "secret" salt = OpenSSL::Random.random_bytes(16) iter = 20_000 key_len = 16 key = OpenSSL::KDF.pbkdf2_hmac(pass, salt: salt, iterations: iter, length: key_len, hash: "sha1") === Storing Passwords pass = "secret" # store this with the generated value salt = OpenSSL::Random.random_bytes(16) iter = 20_000 hash = OpenSSL::Digest.new('SHA256') len = hash.digest_length # the final value to be stored value = OpenSSL::KDF.pbkdf2_hmac(pass, salt: salt, iterations: iter, length: len, hash: hash) == Important Note on Checking Passwords When comparing passwords provided by the user with previously stored values, a common mistake made is comparing the two values using "==". Typically, "==" short-circuits on evaluation, and is therefore vulnerable to timing attacks. The proper way is to use a method that always takes the same amount of time when comparing two values, thus not leaking any information to potential attackers. To do this, use +OpenSSL.fixed_length_secure_compare+. ;T;[;![;"I" Provides functionality of various KDFs (key derivation function). KDF is typically used for securely deriving arbitrary length symmetric keys to be used with an OpenSSL::Cipher from passwords. Another use case is for storing passwords: Due to the ability to tweak the effort of computation by increasing the iteration count, computation can be slowed down artificially in order to render possible attacks infeasible. Currently, OpenSSL::KDF provides implementations for the following KDF: * PKCS #5 PBKDF2 (Password-Based Key Derivation Function 2) in combination with HMAC * scrypt * HKDF == Examples === Generating a 128 bit key for a Cipher (e.g. AES) pass = "secret" salt = OpenSSL::Random.random_bytes(16) iter = 20_000 key_len = 16 key = OpenSSL::KDF.pbkdf2_hmac(pass, salt: salt, iterations: iter, length: key_len, hash: "sha1") === Storing Passwords pass = "secret" # store this with the generated value salt = OpenSSL::Random.random_bytes(16) iter = 20_000 hash = OpenSSL::Digest.new('SHA256') len = hash.digest_length # the final value to be stored value = OpenSSL::KDF.pbkdf2_hmac(pass, salt: salt, iterations: iter, length: len, hash: hash) == Important Note on Checking Passwords When comparing passwords provided by the user with previously stored values, a common mistake made is comparing the two values using "==". Typically, "==" short-circuits on evaluation, and is therefore vulnerable to timing attacks. The proper way is to use a method that always takes the same amount of time when comparing two values, thus not leaking any information to potential attackers. To do this, use +OpenSSL.fixed_length_secure_compare+. ;T;#0;$@;.F;/o;0;1T;2i;3i';%@GH;&I"OpenSSL::KDF;Fo;;IC;[o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[ [I"ext/openssl/ossl_pkey.c;Ti[I"ext/openssl/ossl_pkey_dh.c;Tio[@(Hi[I" ext/openssl/ossl_pkey_rsa.c;Ti[I" ext/openssl/ossl_pkey_dsa.c;Ti7;T;: PKey;;;;;[;{;IC; "An abstract class that bundles signature creation (PKey#sign) and validation (PKey#verify) that is common to all implementations except OpenSSL::PKey::DH * OpenSSL::PKey::RSA * OpenSSL::PKey::DSA * OpenSSL::PKey::EC ;T;[;![;"I" An abstract class that bundles signature creation (PKey#sign) and validation (PKey#verify) that is common to all implementations except OpenSSL::PKey::DH * OpenSSL::PKey::RSA * OpenSSL::PKey::DSA * OpenSSL::PKey::EC ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"OpenSSL::PKey::PKey;F;'@o; ;IC;[; @ ; IC;[; @ ; IC;[; @ ; IC;{;IC;{;T;IC;{;T;T;{;[;[ [@i[@ip[@(Hi[@i[@i8;T;:PKeyError;;;;;[;{;IC; ">Raised when errors occur during PKey#sign or PKey#verify. ;T;[;![;"I"@ Raised when errors occur during PKey#sign or PKey#verify. ;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;&I"OpenSSL::PKey::PKeyError;F;'@Ho; ;IC;[; @ ; IC;[; @ ; IC;[; @ ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@is[@iy;T;: DHError;;;;;[;{;IC; "Generic exception that is raised if an operation on a DH PKey fails unexpectedly or in case an instantiation of an instance of DH fails due to non-conformant input data. ;T;[;![;"I" Generic exception that is raised if an operation on a DH PKey fails unexpectedly or in case an instantiation of an instance of DH fails due to non-conformant input data. ;T;#0;$@ ;.F;/o;0;1T;2is;3iw;%@;&I"OpenSSL::PKey::DHError;F;'@ o; ;IC;[o;4;5F;6;;;;&I"!OpenSSL::PKey::DH#initialize;F;7[[@90;[[@iM;T;;D;0;[;{;IC; "FCreates a new instance of OpenSSL::PKey::DH. If called without arguments, an empty instance without any parameter or key components is created. Use #set_pqg to manually set the parameters afterwards (and optionally #set_key to set private and public key components). If a String is given, tries to parse it as a DER- or PEM- encoded parameters. See also OpenSSL::PKey.read which can parse keys of any kinds. The DH.new(size [, generator]) form is an alias of DH.generate. +string+:: A String that contains the DER or PEM encoded key. +size+:: See DH.generate. +generator+:: See DH.generate. Examples: # Creating an instance from scratch # Note that this is deprecated and will not work on OpenSSL 3.0 or later. dh = OpenSSL::PKey::DH.new dh.set_pqg(bn_p, nil, bn_g) # Generating a parameters and a key pair dh = OpenSSL::PKey::DH.new(2048) # An alias of OpenSSL::PKey::DH.generate(2048) # Reading DH parameters dh_params = OpenSSL::PKey::DH.new(File.read('parameters.pem')) # loads parameters only dh = OpenSSL::PKey.generate_key(dh_params) # generates a key pair ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new;T;IC; ";T;[;![;"I";T;#0;$@6;.F;Bi;C0;7[;$@6o;= ;>I" overload;F;?0;;E;@0;:I"new(string);T;IC; ";T;[;![;"I";T;#0;$@6;.F;Bi;C0;7[[I" string;T0;$@6o;= ;>I" overload;F;?0;;E;@0;:I"new(size [, generator]);T;IC; ";T;[;![;"I";T;#0;$@6;.F;Bi;C0;7[[I"size[, generator];T0;$@6;![;"I"Creates a new instance of OpenSSL::PKey::DH. If called without arguments, an empty instance without any parameter or key components is created. Use #set_pqg to manually set the parameters afterwards (and optionally #set_key to set private and public key components). If a String is given, tries to parse it as a DER- or PEM- encoded parameters. See also OpenSSL::PKey.read which can parse keys of any kinds. The DH.new(size [, generator]) form is an alias of DH.generate. +string+:: A String that contains the DER or PEM encoded key. +size+:: See DH.generate. +generator+:: See DH.generate. Examples: # Creating an instance from scratch # Note that this is deprecated and will not work on OpenSSL 3.0 or later. dh = OpenSSL::PKey::DH.new dh.set_pqg(bn_p, nil, bn_g) # Generating a parameters and a key pair dh = OpenSSL::PKey::DH.new(2048) # An alias of OpenSSL::PKey::DH.generate(2048) # Reading DH parameters dh_params = OpenSSL::PKey::DH.new(File.read('parameters.pem')) # loads parameters only dh = OpenSSL::PKey.generate_key(dh_params) # generates a key pair @overload new @overload new(string) @overload new(size [, generator]);T;#0;$@6;.F;/o;0;1T;2i(;3iJ;%@4;9I"static VALUE ossl_dh_initialize(int argc, VALUE *argv, VALUE self) { EVP_PKEY *pkey; int type; DH *dh; BIO *in = NULL; VALUE arg; TypedData_Get_Struct(self, EVP_PKEY, &ossl_evp_pkey_type, pkey); if (pkey) rb_raise(rb_eTypeError, "pkey already initialized"); /* The DH.new(size, generator) form is handled by lib/openssl/pkey.rb */ if (rb_scan_args(argc, argv, "01", &arg) == 0) { dh = DH_new(); if (!dh) ossl_raise(eDHError, "DH_new"); goto legacy; } arg = ossl_to_der_if_possible(arg); in = ossl_obj2bio(&arg); /* * On OpenSSL <= 1.1.1 and current versions of LibreSSL, the generic * routine does not support DER-encoded parameters */ dh = d2i_DHparams_bio(in, NULL); if (dh) goto legacy; OSSL_BIO_reset(in); pkey = ossl_pkey_read_generic(in, Qnil); BIO_free(in); if (!pkey) ossl_raise(eDHError, "could not parse pkey"); type = EVP_PKEY_base_id(pkey); if (type != EVP_PKEY_DH) { EVP_PKEY_free(pkey); rb_raise(eDHError, "incorrect pkey type: %s", OBJ_nid2sn(type)); } RTYPEDDATA_DATA(self) = pkey; return self; legacy: BIO_free(in); pkey = EVP_PKEY_new(); if (!pkey || EVP_PKEY_assign_DH(pkey, dh) != 1) { EVP_PKEY_free(pkey); DH_free(dh); ossl_raise(eDHError, "EVP_PKEY_assign_DH"); } RTYPEDDATA_DATA(self) = pkey; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::PKey::DH#initialize_copy;F;7[[I" other;T0;[[@i;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@a;%@4;9I"static VALUE ossl_dh_initialize_copy(VALUE self, VALUE other) { EVP_PKEY *pkey; DH *dh, *dh_other; const BIGNUM *pub, *priv; TypedData_Get_Struct(self, EVP_PKEY, &ossl_evp_pkey_type, pkey); if (pkey) rb_raise(rb_eTypeError, "pkey already initialized"); GetDH(other, dh_other); dh = DHparams_dup(dh_other); if (!dh) ossl_raise(eDHError, "DHparams_dup"); DH_get0_key(dh_other, &pub, &priv); if (pub) { BIGNUM *pub2 = BN_dup(pub); BIGNUM *priv2 = BN_dup(priv); if (!pub2 || (priv && !priv2)) { BN_clear_free(pub2); BN_clear_free(priv2); ossl_raise(eDHError, "BN_dup"); } DH_set0_key(dh, pub2, priv2); } pkey = EVP_PKEY_new(); if (!pkey || EVP_PKEY_assign_DH(pkey, dh) != 1) { EVP_PKEY_free(pkey); DH_free(dh); ossl_raise(eDHError, "EVP_PKEY_assign_DH"); } RTYPEDDATA_DATA(self) = pkey; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKey::DH#public?;F;7[;[[@i;T;: public?;0;[;{;IC; "Indicates whether this DH instance has a public key associated with it or not. The public key may be retrieved with DH#pub_key.;T;[o;= ;>I" overload;F;?0;;;@0;:I" public?;T;IC; ";T;[;![;"I";T;#0;$@o;.F;Bi;C0;7[;$@oo;A ;>I" return;F;?@;0;@[@L;$@o;![;"I"Indicates whether this DH instance has a public key associated with it or not. The public key may be retrieved with DH#pub_key. @overload public?;T;#0;$@o;.F;/o;0;1T;2i;3i;Bi;%@4;9I"static VALUE ossl_dh_is_public(VALUE self) { DH *dh; const BIGNUM *bn; GetDH(self, dh); DH_get0_key(dh, &bn, NULL); return bn ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKey::DH#private?;F;7[;[[@i;T;: private?;0;[;{;IC; "Indicates whether this DH instance has a private key associated with it or not. The private key may be retrieved with DH#priv_key.;T;[o;= ;>I" overload;F;?0;;;@0;:I" private?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"Indicates whether this DH instance has a private key associated with it or not. The private key may be retrieved with DH#priv_key. @overload private?;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@4;9I" static VALUE ossl_dh_is_private(VALUE self) { DH *dh; const BIGNUM *bn; GetDH(self, dh); DH_get0_key(dh, NULL, &bn); #if !defined(OPENSSL_NO_ENGINE) return (bn || DH_get0_engine(dh)) ? Qtrue : Qfalse; #else return bn ? Qtrue : Qfalse; #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKey::DH#export;F;7[;[[@i;T;: export;0;[;{;IC; "Encodes this DH to its PEM encoding. Note that any existing per-session public/private keys will *not* get encoded, just the Diffie-Hellman parameters will be encoded. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" export;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" aString;T;$@;![;"I"@return [aString];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;L;@0;:I" to_pem;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" aString;T;$@;![;"I"@return [aString];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" aString;T;$@;![;"I"@return [aString];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Encodes this DH to its PEM encoding. Note that any existing per-session public/private keys will *not* get encoded, just the Diffie-Hellman parameters will be encoded. @overload export @return [aString] @overload to_pem @return [aString] @overload to_s @return [aString];T;#0;$o;4;5F;6;;;;&I"OpenSSL::PKey::DH#to_s;F;7[;[[@i;F;;G;;;[;{;@;%@4;9I"Fstatic VALUE ossl_dh_export(VALUE self) { DH *dh; BIO *out; VALUE str; GetDH(self, dh); if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eDHError, NULL); } if (!PEM_write_bio_DHparams(out, dh)) { BIO_free(out); ossl_raise(eDHError, NULL); } str = ossl_membio2str(out); return str; };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@4;9I"Fstatic VALUE ossl_dh_export(VALUE self) { DH *dh; BIO *out; VALUE str; GetDH(self, dh); if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eDHError, NULL); } if (!PEM_write_bio_DHparams(out, dh)) { BIO_free(out); ossl_raise(eDHError, NULL); } str = ossl_membio2str(out); return str; };T;:@ۖ;;To;4;5F;6;;;;&I"OpenSSL::PKey::DH#to_pem;F;7[;[[@i;F;;L;;;[;{;@;%@4;9I"Fstatic VALUE ossl_dh_export(VALUE self) { DH *dh; BIO *out; VALUE str; GetDH(self, dh); if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eDHError, NULL); } if (!PEM_write_bio_DHparams(out, dh)) { BIO_free(out); ossl_raise(eDHError, NULL); } str = ossl_membio2str(out); return str; };T;:@ۖ@Ӗo;4;5F;6;;;;&I"OpenSSL::PKey::DH#to_der;F;7[;[[@i;T;;M;0;[;{;IC; "Encodes this DH to its DER encoding. Note that any existing per-session public/private keys will *not* get encoded, just the Diffie-Hellman parameters will be encoded. ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" to_der;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" aString;T;$@;![;"I"@return [aString];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Encodes this DH to its DER encoding. Note that any existing per-session public/private keys will *not* get encoded, just the Diffie-Hellman parameters will be encoded. @overload to_der @return [aString];T;#0;$@;.F;/o;0;1T;2i;3i;%@4;9I"~static VALUE ossl_dh_to_der(VALUE self) { DH *dh; unsigned char *p; long len; VALUE str; GetDH(self, dh); if((len = i2d_DHparams(dh, NULL)) <= 0) ossl_raise(eDHError, NULL); str = rb_str_new(0, len); p = (unsigned char *)RSTRING_PTR(str); if(i2d_DHparams(dh, &p) < 0) ossl_raise(eDHError, NULL); ossl_str_adjust(str, p); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!OpenSSL::PKey::DH#params_ok?;F;7[;[[@i7;T;:params_ok?;0;[;{;IC; "Validates the Diffie-Hellman parameters associated with this instance. It checks whether a safe prime and a suitable generator are used. If this is not the case, +false+ is returned. See also the man page EVP_PKEY_param_check(3).;T;[o;= ;>I" overload;F;?0;;;@0;:I"params_ok?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"Validates the Diffie-Hellman parameters associated with this instance. It checks whether a safe prime and a suitable generator are used. If this is not the case, +false+ is returned. See also the man page EVP_PKEY_param_check(3). @overload params_ok?;T;#0;$@;.F;/o;0;1T;2i-;3i4;Bi;%@4;9I"rstatic VALUE ossl_dh_check_params(VALUE self) { int ret; #ifdef HAVE_EVP_PKEY_CHECK EVP_PKEY *pkey; EVP_PKEY_CTX *pctx; GetPKey(self, pkey); pctx = EVP_PKEY_CTX_new(pkey, /* engine */NULL); if (!pctx) ossl_raise(eDHError, "EVP_PKEY_CTX_new"); ret = EVP_PKEY_param_check(pctx); EVP_PKEY_CTX_free(pctx); #else DH *dh; int codes; GetDH(self, dh); ret = DH_check(dh, &codes) == 1 && codes == 0; #endif if (ret == 1) return Qtrue; else { /* DH_check_ex() will put error entry on failure */ ossl_clear_error(); return Qfalse; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKey::DH#set_pqg;F;7[;[;F;: set_pqg;;;[;{;IC; "+Sets _p_, _q_, _g_ to the DH instance. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"set_pqg(p, q, g);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[[I"p;T0[I"q;T0[I"g;T0;$@;![;"I"YSets _p_, _q_, _g_ to the DH instance. @overload set_pqg(p, q, g) @return [self];T;#0;$@;.F;/o;0;1T;2iV;3iZ;%@4;;To;4;5F;6;;;;&I"OpenSSL::PKey::DH#set_key;F;7[;[;F;: set_key;;;[;{;IC; "PSets _pub_key_ and _priv_key_ for the DH instance. _priv_key_ may be +nil+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"set_key(pub_key, priv_key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@8;![;"I"@return [self];T;#0;$@8;.F;Bi;C0;7[[I" pub_key;T0[I" priv_key;T0;$@8;![;"I"Sets _pub_key_ and _priv_key_ for the DH instance. _priv_key_ may be +nil+. @overload set_key(pub_key, priv_key) @return [self];T;#0;$@8;.F;/o;0;1T;2i^;3ib;%@4;;To;4;5F;6;;;;&I"OpenSSL::PKey::DH#params;F;7[;[[@i;T;: params;0;[;{;IC; "{Stores all parameters of key to the hash INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!! Don't use :-)) (I's up to you) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" params;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@T;![;"I"@return [Hash];T;#0;$@T;.F;Bi;C0;7[;$@T;![;"I"Stores all parameters of key to the hash INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!! Don't use :-)) (I's up to you) @overload params @return [Hash];T;#0;$@T;.F;/o;0;1T;2i;3i;%@4;9I"Gstatic VALUE ossl_dh_get_params(VALUE self) { DH *dh; VALUE hash; const BIGNUM *p, *q, *g, *pub_key, *priv_key; GetDH(self, dh); DH_get0_pqg(dh, &p, &q, &g); DH_get0_key(dh, &pub_key, &priv_key); hash = rb_hash_new(); rb_hash_aset(hash, rb_str_new2("p"), ossl_bn_new(p)); rb_hash_aset(hash, rb_str_new2("q"), ossl_bn_new(q)); rb_hash_aset(hash, rb_str_new2("g"), ossl_bn_new(g)); rb_hash_aset(hash, rb_str_new2("pub_key"), ossl_bn_new(pub_key)); rb_hash_aset(hash, rb_str_new2("priv_key"), ossl_bn_new(priv_key)); return hash; };T;:I"static VALUE;T;;T; @4; IC;[; @4; IC;[; @4; IC;{;IC;{;T;IC;{;T;T;{@ޖ;@Ӗ;;[;[[@iz[@i;T;:DH;;;;;[;{;IC; "An implementation of the Diffie-Hellman key exchange protocol based on discrete logarithms in finite fields, the same basis that DSA is built on. === Accessor methods for the Diffie-Hellman parameters DH#p:: The prime (an OpenSSL::BN) of the Diffie-Hellman parameters. DH#g:: The generator (an OpenSSL::BN) g of the Diffie-Hellman parameters. DH#pub_key:: The per-session public key (an OpenSSL::BN) matching the private key. This needs to be passed to DH#compute_key. DH#priv_key:: The per-session private key, an OpenSSL::BN. === Example of a key exchange # you may send the parameters (der) and own public key (pub1) publicly # to the participating party dh1 = OpenSSL::PKey::DH.new(2048) der = dh1.to_der pub1 = dh1.pub_key # the other party generates its per-session key pair dhparams = OpenSSL::PKey::DH.new(der) dh2 = OpenSSL::PKey.generate_key(dhparams) pub2 = dh2.pub_key symm_key1 = dh1.compute_key(pub2) symm_key2 = dh2.compute_key(pub1) puts symm_key1 == symm_key2 # => true ;T;[;![;"I" An implementation of the Diffie-Hellman key exchange protocol based on discrete logarithms in finite fields, the same basis that DSA is built on. === Accessor methods for the Diffie-Hellman parameters DH#p:: The prime (an OpenSSL::BN) of the Diffie-Hellman parameters. DH#g:: The generator (an OpenSSL::BN) g of the Diffie-Hellman parameters. DH#pub_key:: The per-session public key (an OpenSSL::BN) matching the private key. This needs to be passed to DH#compute_key. DH#priv_key:: The per-session private key, an OpenSSL::BN. === Example of a key exchange # you may send the parameters (der) and own public key (pub1) publicly # to the participating party dh1 = OpenSSL::PKey::DH.new(2048) der = dh1.to_der pub1 = dh1.pub_key # the other party generates its per-session key pair dhparams = OpenSSL::PKey::DH.new(der) dh2 = OpenSSL::PKey.generate_key(dhparams) pub2 = dh2.pub_key symm_key1 = dh1.compute_key(pub2) symm_key2 = dh2.compute_key(pub1) puts symm_key1 == symm_key2 # => true ;T;#0;$@4;.F;/o;0;1T;2iz;3i;%@;&I"OpenSSL::PKey::DH;F;'@o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@(Hi;F;: ECError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"OpenSSL::PKey::ECError;F;'@ o; ;IC;[o; ;IC;[o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@(Hi;F;;;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"$OpenSSL::PKey::EC::Group::Error;F;'@Ho;4;5F;6;;;;&I"(OpenSSL::PKey::EC::Group#initialize;F;7[[@90;[[@(Hi);T;;D;0;[;{;IC; "xCreates a new EC::Group object. If the first argument is :GFp or :GF2m, creates a new curve with given parameters. ;T;[ o;= ;>I" overload;F;?0;:!OpenSSL::PKey::EC::Group.new;@0;:I"+OpenSSL::PKey::EC::Group.new(ec_group);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" ec_group;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"5OpenSSL::PKey::EC::Group.new(pem_or_der_encoded);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"pem_or_der_encoded;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"EOpenSSL::PKey::EC::Group.new(:GFp, bignum_p, bignum_a, bignum_b);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[ [I":;TI"GFp;T[I" bignum_p;T0[I" bignum_a;T0[I" bignum_b;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"FOpenSSL::PKey::EC::Group.new(:GF2m, bignum_p, bignum_a, bignum_b);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[ [I":;TI" GF2m;T[I" bignum_p;T0[I" bignum_a;T0[I" bignum_b;T0;$@;![;"I"xCreates a new EC::Group object. If the first argument is :GFp or :GF2m, creates a new curve with given parameters. @overload OpenSSL::PKey::EC::Group.new(ec_group) @overload OpenSSL::PKey::EC::Group.new(pem_or_der_encoded) @overload OpenSSL::PKey::EC::Group.new(:GFp, bignum_p, bignum_a, bignum_b) @overload OpenSSL::PKey::EC::Group.new(:GF2m, bignum_p, bignum_a, bignum_b);T;#0;$@;.F;/o;0;1T;2i;3i&;%@;9I"m static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self) { VALUE arg1, arg2, arg3, arg4; EC_GROUP *group; TypedData_Get_Struct(self, EC_GROUP, &ossl_ec_group_type, group); if (group) ossl_raise(rb_eRuntimeError, "EC_GROUP is already initialized"); switch (rb_scan_args(argc, argv, "13", &arg1, &arg2, &arg3, &arg4)) { case 1: if (rb_obj_is_kind_of(arg1, cEC_GROUP)) { const EC_GROUP *arg1_group; GetECGroup(arg1, arg1_group); if ((group = EC_GROUP_dup(arg1_group)) == NULL) ossl_raise(eEC_GROUP, "EC_GROUP_dup"); } else { BIO *in = ossl_obj2bio(&arg1); group = PEM_read_bio_ECPKParameters(in, NULL, NULL, NULL); if (!group) { OSSL_BIO_reset(in); group = d2i_ECPKParameters_bio(in, NULL); } BIO_free(in); if (!group) { const char *name = StringValueCStr(arg1); int nid = OBJ_sn2nid(name); ossl_clear_error(); /* ignore errors in d2i_ECPKParameters_bio() */ if (nid == NID_undef) ossl_raise(eEC_GROUP, "unknown curve name (%"PRIsVALUE")", arg1); group = EC_GROUP_new_by_curve_name(nid); if (group == NULL) ossl_raise(eEC_GROUP, "unable to create curve (%"PRIsVALUE")", arg1); EC_GROUP_set_asn1_flag(group, OPENSSL_EC_NAMED_CURVE); EC_GROUP_set_point_conversion_form(group, POINT_CONVERSION_UNCOMPRESSED); } } break; case 4: if (SYMBOL_P(arg1)) { ID id = SYM2ID(arg1); EC_GROUP *(*new_curve)(const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *) = NULL; const BIGNUM *p = GetBNPtr(arg2); const BIGNUM *a = GetBNPtr(arg3); const BIGNUM *b = GetBNPtr(arg4); if (id == s_GFp) { new_curve = EC_GROUP_new_curve_GFp; #if !defined(OPENSSL_NO_EC2M) } else if (id == s_GF2m) { new_curve = EC_GROUP_new_curve_GF2m; #endif } else { ossl_raise(rb_eArgError, "unknown symbol, must be :GFp or :GF2m"); } if ((group = new_curve(p, a, b, ossl_bn_ctx)) == NULL) ossl_raise(eEC_GROUP, "EC_GROUP_new_by_GF*"); } else { ossl_raise(rb_eArgError, "unknown argument, must be :GFp or :GF2m"); } break; default: ossl_raise(rb_eArgError, "wrong number of arguments"); } ASSUME(group); RTYPEDDATA_DATA(self) = group; return self; };T;:I"Mstatic VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self);T;;To;4;5F;6;;;;&I"-OpenSSL::PKey::EC::Group#initialize_copy;F;7[[I" other;T0;[[@(Hiz;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE ossl_ec_group_initialize_copy(VALUE self, VALUE other) { EC_GROUP *group, *group_new; TypedData_Get_Struct(self, EC_GROUP, &ossl_ec_group_type, group_new); if (group_new) ossl_raise(eEC_GROUP, "EC::Group already initialized"); GetECGroup(other, group); group_new = EC_GROUP_dup(group); if (!group_new) ossl_raise(eEC_GROUP, "EC_GROUP_dup"); RTYPEDDATA_DATA(self) = group_new; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::PKey::EC::Group#eql?;F;7[[I"b;T0;[[@(Hi;T;;V;0;[;{;IC; "iReturns +true+ if the two groups use the same curve and have the same parameters, +false+ otherwise.;T;[o;= ;>I" overload;F;?0;;V;@0;:I"eql?(group2);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" group2;T0;$@o;= ;>I" overload;F;?0;;F;@0;:I"==(group2);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" group2;T0;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"Returns +true+ if the two groups use the same curve and have the same parameters, +false+ otherwise. @overload eql?(group2) @overload ==(group2);T;#0;$o;4;5F;6;;;;&I" OpenSSL::PKey::EC::Group#==;F;7[;[[@(Hi*;F;;F;;;[;{;@;%@;9I"static VALUE ossl_ec_group_eql(VALUE a, VALUE b) { EC_GROUP *group1 = NULL, *group2 = NULL; GetECGroup(a, group1); GetECGroup(b, group2); if (EC_GROUP_cmp(group1, group2, ossl_bn_ctx) == 1) return Qfalse; return Qtrue; };T;:I"5static VALUE ossl_ec_group_eql(VALUE a, VALUE b);T;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE ossl_ec_group_eql(VALUE a, VALUE b) { EC_GROUP *group1 = NULL, *group2 = NULL; GetECGroup(a, group1); GetECGroup(b, group2); if (EC_GROUP_cmp(group1, group2, ossl_bn_ctx) == 1) return Qfalse; return Qtrue; };T;:@&;;T@o;4;5F;6;;;;&I"'OpenSSL::PKey::EC::Group#generator;F;7[;[[@(Hi;T;:generator;0;[;{;IC; "eReturns the generator of the group. See the OpenSSL documentation for EC_GROUP_get0_generator() ;T;[o;= ;>I" overload;F;?0;;;@0;:I"generator;T;IC; ";T;[;![;"I";T;#0;$@);.F;Bi;C0;7[;$@);![;"I"{Returns the generator of the group. See the OpenSSL documentation for EC_GROUP_get0_generator() @overload generator;T;#0;$@);.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_ec_group_get_generator(VALUE self) { EC_GROUP *group; const EC_POINT *generator; GetECGroup(self, group); generator = EC_GROUP_get0_generator(group); if (!generator) return Qnil; return ec_point_new(generator, group); };T;:I"9static VALUE ossl_ec_group_get_generator(VALUE self);T;;To;4;5F;6;;;;&I"+OpenSSL::PKey::EC::Group#set_generator;F;7[[I"generator;T0[I" order;T0[I" cofactor;T0;[[@(Hi;T;:set_generator;0;[;{;IC; "Sets the curve parameters. _generator_ must be an instance of EC::Point that is on the curve. _order_ and _cofactor_ are integers. See the OpenSSL documentation for EC_GROUP_set_generator() ;T;[o;= ;>I" overload;F;?0;;;@0;:I".set_generator(generator, order, cofactor);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@?;![;"I"@return [self];T;#0;$@?;.F;Bi;C0;7[[I"generator;T0[I" order;T0[I" cofactor;T0;$@?;![;"I"Sets the curve parameters. _generator_ must be an instance of EC::Point that is on the curve. _order_ and _cofactor_ are integers. See the OpenSSL documentation for EC_GROUP_set_generator() @overload set_generator(generator, order, cofactor) @return [self];T;#0;$@?;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_ec_group_set_generator(VALUE self, VALUE generator, VALUE order, VALUE cofactor) { EC_GROUP *group = NULL; const EC_POINT *point; const BIGNUM *o, *co; GetECGroup(self, group); GetECPoint(generator, point); o = GetBNPtr(order); co = GetBNPtr(cofactor); if (EC_GROUP_set_generator(group, point, o, co) != 1) ossl_raise(eEC_GROUP, "EC_GROUP_set_generator"); return self; };T;:I"gstatic VALUE ossl_ec_group_set_generator(VALUE self, VALUE generator, VALUE order, VALUE cofactor);T;;To;4;5F;6;;;;&I"#OpenSSL::PKey::EC::Group#order;F;7[;[[@(Hi;T;: order;0;[;{;IC; "\Returns the order of the group. See the OpenSSL documentation for EC_GROUP_get_order() ;T;[o;= ;>I" overload;F;?0;:get_order;@0;:I"get_order;T;IC; ";T;[;![;"I";T;#0;$@f;.F;Bi;C0;7[;$@f;![;"I"rReturns the order of the group. See the OpenSSL documentation for EC_GROUP_get_order() @overload get_order;T;#0;$@f;.F;/o;0;1T;2i;3i;%@;9I"Ostatic VALUE ossl_ec_group_get_order(VALUE self) { VALUE bn_obj; BIGNUM *bn; EC_GROUP *group = NULL; GetECGroup(self, group); bn_obj = ossl_bn_new(NULL); bn = GetBNPtr(bn_obj); if (EC_GROUP_get_order(group, bn, ossl_bn_ctx) != 1) ossl_raise(eEC_GROUP, "EC_GROUP_get_order"); return bn_obj; };T;:I"5static VALUE ossl_ec_group_get_order(VALUE self);T;;To;4;5F;6;;;;&I"&OpenSSL::PKey::EC::Group#cofactor;F;7[;[[@(Hi;T;: cofactor;0;[;{;IC; "bReturns the cofactor of the group. See the OpenSSL documentation for EC_GROUP_get_cofactor() ;T;[o;= ;>I" overload;F;?0;:get_cofactor;@0;:I"get_cofactor;T;IC; ";T;[;![;"I";T;#0;$@|;.F;Bi;C0;7[;$@|;![;"I"{Returns the cofactor of the group. See the OpenSSL documentation for EC_GROUP_get_cofactor() @overload get_cofactor;T;#0;$@|;.F;/o;0;1T;2i;3i;%@;9I"Xstatic VALUE ossl_ec_group_get_cofactor(VALUE self) { VALUE bn_obj; BIGNUM *bn; EC_GROUP *group = NULL; GetECGroup(self, group); bn_obj = ossl_bn_new(NULL); bn = GetBNPtr(bn_obj); if (EC_GROUP_get_cofactor(group, bn, ossl_bn_ctx) != 1) ossl_raise(eEC_GROUP, "EC_GROUP_get_cofactor"); return bn_obj; };T;:I"8static VALUE ossl_ec_group_get_cofactor(VALUE self);T;;To;4;5F;6;;;;&I"(OpenSSL::PKey::EC::Group#curve_name;F;7[;[[@(Hi ;T;:curve_name;0;[;{;IC; "^Returns the curve name (sn). See the OpenSSL documentation for EC_GROUP_get_curve_name() ;T;[o;= ;>I" overload;F;?0;;;@0;:I"curve_name;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the curve name (sn). See the OpenSSL documentation for EC_GROUP_get_curve_name() @overload curve_name @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"=static VALUE ossl_ec_group_get_curve_name(VALUE self) { EC_GROUP *group = NULL; int nid; GetECGroup(self, group); if (group == NULL) return Qnil; nid = EC_GROUP_get_curve_name(group); /* BUG: an nid or asn1 object should be returned, maybe. */ return rb_str_new2(OBJ_nid2sn(nid)); };T;:I":static VALUE ossl_ec_group_get_curve_name(VALUE self);T;;To;4;5F;6;;;;&I"'OpenSSL::PKey::EC::Group#asn1_flag;F;7[;[[@(HiF;T;:asn1_flag;0;[;{;IC; "?Returns the flags set on the group. See also #asn1_flag=. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"asn1_flag;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"iReturns the flags set on the group. See also #asn1_flag=. @overload asn1_flag @return [Integer];T;#0;$@;.F;/o;0;1T;2i>;3iD;%@;9I"static VALUE ossl_ec_group_get_asn1_flag(VALUE self) { EC_GROUP *group = NULL; int flag; GetECGroup(self, group); flag = EC_GROUP_get_asn1_flag(group); return INT2NUM(flag); };T;:I"9static VALUE ossl_ec_group_get_asn1_flag(VALUE self);T;;To;4;5F;6;;;;&I"(OpenSSL::PKey::EC::Group#asn1_flag=;F;7[[I" flag_v;T0;[[@(Hi_;T;:asn1_flag=;0;[;{;IC; "Sets flags on the group. The flag value is used to determine how to encode the group: encode explicit parameters or named curve using an OID. The flag value can be either of: * EC::NAMED_CURVE * EC::EXPLICIT_CURVE See the OpenSSL documentation for EC_GROUP_set_asn1_flag(). ;T;[o;= ;>I" overload;F;?0;;;@0;:I"asn1_flag=(flags);T;IC; ";T;[;![;"I";T;#0;$@Ș;.F;Bi;C0;7[[I" flags;T0;$@Ș;![;"I"2Sets flags on the group. The flag value is used to determine how to encode the group: encode explicit parameters or named curve using an OID. The flag value can be either of: * EC::NAMED_CURVE * EC::EXPLICIT_CURVE See the OpenSSL documentation for EC_GROUP_set_asn1_flag(). @overload asn1_flag=(flags);T;#0;$@Ș;.F;/o;0;1T;2iQ;3i\;%@;9I"static VALUE ossl_ec_group_set_asn1_flag(VALUE self, VALUE flag_v) { EC_GROUP *group = NULL; GetECGroup(self, group); EC_GROUP_set_asn1_flag(group, NUM2INT(flag_v)); return flag_v; };T;:I"Gstatic VALUE ossl_ec_group_set_asn1_flag(VALUE self, VALUE flag_v);T;;To;4;5F;6;;;;&I"3OpenSSL::PKey::EC::Group#point_conversion_form;F;7[;[[@(Hiq;T;:point_conversion_form;0;[;{;IC; "`Returns the form how EC::Point data is encoded as ASN.1. See also #point_conversion_form=. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"point_conversion_form;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Symbol;T;$@;![;"I"@return [Symbol];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the form how EC::Point data is encoded as ASN.1. See also #point_conversion_form=. @overload point_conversion_form @return [Symbol];T;#0;$@;.F;/o;0;1T;2ii;3io;%@;9I"Lstatic VALUE ossl_ec_group_get_point_conversion_form(VALUE self) { EC_GROUP *group = NULL; point_conversion_form_t form; VALUE ret; GetECGroup(self, group); form = EC_GROUP_get_point_conversion_form(group); switch (form) { case POINT_CONVERSION_UNCOMPRESSED: ret = ID_uncompressed; break; case POINT_CONVERSION_COMPRESSED: ret = ID_compressed; break; case POINT_CONVERSION_HYBRID: ret = ID_hybrid; break; default: ossl_raise(eEC_GROUP, "unsupported point conversion form: %d, this module should be updated", form); } return ID2SYM(ret); };T;:I"Estatic VALUE ossl_ec_group_get_point_conversion_form(VALUE self);T;;To;4;5F;6;;;;&I"4OpenSSL::PKey::EC::Group#point_conversion_form=;F;7[[I" form_v;T0;[[@(Hi;T;:point_conversion_form=;0;[;{;IC; "Sets the form how EC::Point data is encoded as ASN.1 as defined in X9.62. _format_ can be one of these: +:compressed+:: Encoded as z||x, where z is an octet indicating which solution of the equation y is. z will be 0x02 or 0x03. +:uncompressed+:: Encoded as z||x||y, where z is an octet 0x04. +:hybrid+:: Encodes as z||x||y, where z is an octet indicating which solution of the equation y is. z will be 0x06 or 0x07. See the OpenSSL documentation for EC_GROUP_set_point_conversion_form() ;T;[o;= ;>I" overload;F;?0;;;@0;:I"!point_conversion_form=(form);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" form;T0;$@;![;"I"Sets the form how EC::Point data is encoded as ASN.1 as defined in X9.62. _format_ can be one of these: +:compressed+:: Encoded as z||x, where z is an octet indicating which solution of the equation y is. z will be 0x02 or 0x03. +:uncompressed+:: Encoded as z||x||y, where z is an octet 0x04. +:hybrid+:: Encodes as z||x||y, where z is an octet indicating which solution of the equation y is. z will be 0x06 or 0x07. See the OpenSSL documentation for EC_GROUP_set_point_conversion_form() @overload point_conversion_form=(form);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"(static VALUE ossl_ec_group_set_point_conversion_form(VALUE self, VALUE form_v) { EC_GROUP *group; point_conversion_form_t form; GetECGroup(self, group); form = parse_point_conversion_form_symbol(form_v); EC_GROUP_set_point_conversion_form(group, form); return form_v; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::PKey::EC::Group#seed;F;7[;[[@(Hi;T;;;0;[;{;IC; ";See the OpenSSL documentation for EC_GROUP_get0_seed() ;T;[o;= ;>I" overload;F;?0;;;@0;:I" seed;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@;![;"I"@return [String, nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"dSee the OpenSSL documentation for EC_GROUP_get0_seed() @overload seed @return [String, nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"'static VALUE ossl_ec_group_get_seed(VALUE self) { EC_GROUP *group = NULL; size_t seed_len; GetECGroup(self, group); seed_len = EC_GROUP_get_seed_len(group); if (seed_len == 0) return Qnil; return rb_str_new((const char *)EC_GROUP_get0_seed(group), seed_len); };T;:I"4static VALUE ossl_ec_group_get_seed(VALUE self);T;;To;4;5F;6;;;;&I"#OpenSSL::PKey::EC::Group#seed=;F;7[[I" seed;T0;[[@(Hi;T;: seed=;0;[;{;IC; ":See the OpenSSL documentation for EC_GROUP_set_seed() ;T;[o;= ;>I" overload;F;?0;;;@0;:I"seed=(seed);T;IC; ";T;[;![;"I";T;#0;$@3;.F;Bi;C0;7[[I" seed;T0;$@3;![;"I"RSee the OpenSSL documentation for EC_GROUP_set_seed() @overload seed=(seed);T;#0;$@3;.F;/o;0;1T;2i;3i;%@;9I"Mstatic VALUE ossl_ec_group_set_seed(VALUE self, VALUE seed) { EC_GROUP *group = NULL; GetECGroup(self, group); StringValue(seed); if (EC_GROUP_set_seed(group, (unsigned char *)RSTRING_PTR(seed), RSTRING_LEN(seed)) != (size_t)RSTRING_LEN(seed)) ossl_raise(eEC_GROUP, "EC_GROUP_set_seed"); return seed; };T;:I"@static VALUE ossl_ec_group_set_seed(VALUE self, VALUE seed);T;;To;4;5F;6;;;;&I"$OpenSSL::PKey::EC::Group#degree;F;7[;[[@(Hi;T;: degree;0;[;{;IC; "I" overload;F;?0;;;@0;:I" degree;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@M;![;"I"@return [Integer];T;#0;$@M;.F;Bi;C0;7[;$@M;![;"I"cSee the OpenSSL documentation for EC_GROUP_get_degree() @overload degree @return [Integer];T;#0;$@M;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_ec_group_get_degree(VALUE self) { EC_GROUP *group = NULL; GetECGroup(self, group); return INT2NUM(EC_GROUP_get_degree(group)); };T;:I"6static VALUE ossl_ec_group_get_degree(VALUE self);T;;To;4;5F;6;;;;&I"$OpenSSL::PKey::EC::Group#to_pem;F;7[;[[@(Hi;T;;L;0;[;{;IC; "ESee the OpenSSL documentation for PEM_write_bio_ECPKParameters() ;T;[o;= ;>I" overload;F;?0;;L;@0;:I" to_pem;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@h;![;"I"@return [String];T;#0;$@h;.F;Bi;C0;7[;$@h;![;"I"l See the OpenSSL documentation for PEM_write_bio_ECPKParameters() @overload to_pem @return [String];T;#0;$@h;.F;/o;0;1T;2i;3i;%@;9I"lstatic VALUE ossl_ec_group_to_pem(VALUE self) { return ossl_ec_group_to_string(self, EXPORT_PEM); };T;:I"2static VALUE ossl_ec_group_to_pem(VALUE self);T;;To;4;5F;6;;;;&I"$OpenSSL::PKey::EC::Group#to_der;F;7[;[[@(Hi ;T;;M;0;[;{;IC; "?See the OpenSSL documentation for i2d_ECPKParameters_bio() ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" to_der;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"eSee the OpenSSL documentation for i2d_ECPKParameters_bio() @overload to_der @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"lstatic VALUE ossl_ec_group_to_der(VALUE self) { return ossl_ec_group_to_string(self, EXPORT_DER); };T;:I"2static VALUE ossl_ec_group_to_der(VALUE self);T;;To;4;5F;6;;;;&I"%OpenSSL::PKey::EC::Group#to_text;F;7[;[[@(Hi+;T;;\;0;[;{;IC; "=See the OpenSSL documentation for ECPKParameters_print() ;T;[o;= ;>I" overload;F;?0;;\;@0;:I" to_text;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"dSee the OpenSSL documentation for ECPKParameters_print() @overload to_text @return [String];T;#0;$@;.F;/o;0;1T;2i%;3i);%@;9I"vstatic VALUE ossl_ec_group_to_text(VALUE self) { EC_GROUP *group; BIO *out; VALUE str; GetECGroup(self, group); if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eEC_GROUP, "BIO_new(BIO_s_mem())"); } if (!ECPKParameters_print(out, group, 0)) { BIO_free(out); ossl_raise(eEC_GROUP, NULL); } str = ossl_membio2str(out); return str; };T;:I"3static VALUE ossl_ec_group_to_text(VALUE self);T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{@;V;[;[[@(Hi;F;: Group;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I"OpenSSL::PKey::EC::Group;F;'@o; ;IC;[o; ;IC;[; @ʙ; IC;[; @ʙ; IC;[; @ʙ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@(Hi;F;;;;;;;[;{;IC; " ;T;[;![;"@;#0;$@ʙ;%@ș;&I"$OpenSSL::PKey::EC::Point::Error;F;'@Ho;4;5F;6;;;;&I"(OpenSSL::PKey::EC::Point#initialize;F;7[[@90;[[@(His;T;;D;0;[;{;IC; "Creates a new instance of OpenSSL::PKey::EC::Point. If the only argument is an instance of EC::Point, a copy is returned. Otherwise, creates a point that belongs to _group_. _encoded_point_ is the octet string representation of the point. This must be either a String or an OpenSSL::BN. ;T;[o;= ;>I" overload;F;?0;:!OpenSSL::PKey::EC::Point.new;@0;:I"(OpenSSL::PKey::EC::Point.new(point);T;IC; ";T;[;![;"I";T;#0;$@ۙ;.F;Bi;C0;7[[I" point;T0;$@ۙo;= ;>I" overload;F;?0;;;@0;:I":OpenSSL::PKey::EC::Point.new(group [, encoded_point]);T;IC; ";T;[;![;"I";T;#0;$@ۙ;.F;Bi;C0;7[[I"group[, encoded_point];T0;$@ۙ;![;"I"Creates a new instance of OpenSSL::PKey::EC::Point. If the only argument is an instance of EC::Point, a copy is returned. Otherwise, creates a point that belongs to _group_. _encoded_point_ is the octet string representation of the point. This must be either a String or an OpenSSL::BN. @overload OpenSSL::PKey::EC::Point.new(point) @overload OpenSSL::PKey::EC::Point.new(group [, encoded_point]);T;#0;$@ۙ;.F;/o;0;1T;2ig;3ip;%@ș;9I"static VALUE ossl_ec_point_initialize(int argc, VALUE *argv, VALUE self) { EC_POINT *point; VALUE group_v, arg2; const EC_GROUP *group; TypedData_Get_Struct(self, EC_POINT, &ossl_ec_point_type, point); if (point) rb_raise(eEC_POINT, "EC_POINT already initialized"); rb_scan_args(argc, argv, "11", &group_v, &arg2); if (rb_obj_is_kind_of(group_v, cEC_POINT)) { if (argc != 1) rb_raise(rb_eArgError, "invalid second argument"); return ossl_ec_point_initialize_copy(self, group_v); } GetECGroup(group_v, group); if (argc == 1) { point = EC_POINT_new(group); if (!point) ossl_raise(eEC_POINT, "EC_POINT_new"); } else { if (rb_obj_is_kind_of(arg2, cBN)) { point = EC_POINT_bn2point(group, GetBNPtr(arg2), NULL, ossl_bn_ctx); if (!point) ossl_raise(eEC_POINT, "EC_POINT_bn2point"); } else { StringValue(arg2); point = EC_POINT_new(group); if (!point) ossl_raise(eEC_POINT, "EC_POINT_new"); if (!EC_POINT_oct2point(group, point, (unsigned char *)RSTRING_PTR(arg2), RSTRING_LEN(arg2), ossl_bn_ctx)) { EC_POINT_free(point); ossl_raise(eEC_POINT, "EC_POINT_oct2point"); } } } RTYPEDDATA_DATA(self) = point; rb_ivar_set(self, id_i_group, group_v); return self; };T;:I"Mstatic VALUE ossl_ec_point_initialize(int argc, VALUE *argv, VALUE self);T;;To;4;5F;6;;;;&I"-OpenSSL::PKey::EC::Point#initialize_copy;F;7[[I" other;T0;[[@(Hi;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@;%@ș;9I"nstatic VALUE ossl_ec_point_initialize_copy(VALUE self, VALUE other) { EC_POINT *point, *point_new; EC_GROUP *group; VALUE group_v; TypedData_Get_Struct(self, EC_POINT, &ossl_ec_point_type, point_new); if (point_new) ossl_raise(eEC_POINT, "EC::Point already initialized"); GetECPoint(other, point); group_v = rb_obj_dup(rb_attr_get(other, id_i_group)); GetECGroup(group_v, group); point_new = EC_POINT_dup(point, group); if (!point_new) ossl_raise(eEC_POINT, "EC_POINT_dup"); RTYPEDDATA_DATA(self) = point_new; rb_ivar_set(self, id_i_group, group_v); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::PKey::EC::Point#eql?;F;7[[I"b;T0;[[@(Hi;T;;V;0;[;{;IC; ";T;[o;= ;>I" overload;F;?0;;V;@0;:I"eql?(point2);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I" point2;T0;$@ o;= ;>I" overload;F;?0;;F;@0;:I"==(point2);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I" point2;T0;$@ o;A ;>I" return;F;?@;0;@[@L;$@ ;![;"I"1 @overload eql?(point2) @overload ==(point2);T;#0;$o;4;5F;6;;;;&I" OpenSSL::PKey::EC::Point#==;F;7[;[[@(HiO;F;;F;;;[;{;@;%@ș;9I"static VALUE ossl_ec_point_eql(VALUE a, VALUE b) { EC_POINT *point1, *point2; VALUE group_v1 = rb_attr_get(a, id_i_group); VALUE group_v2 = rb_attr_get(b, id_i_group); const EC_GROUP *group; if (ossl_ec_group_eql(group_v1, group_v2) == Qfalse) return Qfalse; GetECPoint(a, point1); GetECPoint(b, point2); GetECGroup(group_v1, group); if (EC_POINT_cmp(group, point1, point2, ossl_bn_ctx) == 1) return Qfalse; return Qtrue; };T;:I"5static VALUE ossl_ec_point_eql(VALUE a, VALUE b);T;.F;/o;0;1T;2i;3i;Bi;%@ș;9I"static VALUE ossl_ec_point_eql(VALUE a, VALUE b) { EC_POINT *point1, *point2; VALUE group_v1 = rb_attr_get(a, id_i_group); VALUE group_v2 = rb_attr_get(b, id_i_group); const EC_GROUP *group; if (ossl_ec_group_eql(group_v1, group_v2) == Qfalse) return Qfalse; GetECPoint(a, point1); GetECPoint(b, point2); GetECGroup(group_v1, group); if (EC_POINT_cmp(group, point1, point2, ossl_bn_ctx) == 1) return Qfalse; return Qtrue; };T;:@8;;T@0o;4;5F;6;;;;&I"'OpenSSL::PKey::EC::Point#infinity?;F;7[;[[@(Hi;T;:infinity?;0;[;{;IC; ";T;[o;= ;>I" overload;F;?0;;;@0;:I"infinity?;T;IC; ";T;[;![;"I";T;#0;$@;;.F;Bi;C0;7[;$@;o;A ;>I" return;F;?@;0;@[@L;$@;;![;"I" @overload infinity?;T;#0;$@;;.F;/o;0;1T;2i;3i;Bi;%@ș;9I"kstatic VALUE ossl_ec_point_is_at_infinity(VALUE self) { EC_POINT *point; const EC_GROUP *group; GetECPoint(self, point); GetECPointGroup(self, group); switch (EC_POINT_is_at_infinity(group, point)) { case 1: return Qtrue; case 0: return Qfalse; default: ossl_raise(cEC_POINT, "EC_POINT_is_at_infinity"); } UNREACHABLE; };T;:I":static VALUE ossl_ec_point_is_at_infinity(VALUE self);T;;To;4;5F;6;;;;&I"'OpenSSL::PKey::EC::Point#on_curve?;F;7[;[[@(Hi;T;:on_curve?;0;[;{;IC; ";T;[o;= ;>I" overload;F;?0;;;@0;:I"on_curve?;T;IC; ";T;[;![;"I";T;#0;$@T;.F;Bi;C0;7[;$@To;A ;>I" return;F;?@;0;@[@L;$@T;![;"I" @overload on_curve?;T;#0;$@T;.F;/o;0;1T;2i;3i;Bi;%@ș;9I"ostatic VALUE ossl_ec_point_is_on_curve(VALUE self) { EC_POINT *point; const EC_GROUP *group; GetECPoint(self, point); GetECPointGroup(self, group); switch (EC_POINT_is_on_curve(group, point, ossl_bn_ctx)) { case 1: return Qtrue; case 0: return Qfalse; default: ossl_raise(cEC_POINT, "EC_POINT_is_on_curve"); } UNREACHABLE; };T;:I"7static VALUE ossl_ec_point_is_on_curve(VALUE self);T;;To;4;5F;6;;;;&I"*OpenSSL::PKey::EC::Point#make_affine!;F;7[;[[@(Hi;T;:make_affine!;0;[;{;IC; "GThis method is deprecated and should not be used. This is a no-op. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"make_affine!;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@m;![;"I"@return [self];T;#0;$@m;.F;Bi;C0;7[;$@m;![;"I"qThis method is deprecated and should not be used. This is a no-op. @overload make_affine! @return [self];T;#0;$@m;.F;/o;0;1T;2i;3i;%@ș;9I"static VALUE ossl_ec_point_make_affine(VALUE self) { EC_POINT *point; const EC_GROUP *group; GetECPoint(self, point); GetECPointGroup(self, group); rb_warn("OpenSSL::PKey::EC::Point#make_affine! is deprecated"); #if !OSSL_OPENSSL_PREREQ(3, 0, 0) if (EC_POINT_make_affine(group, point, ossl_bn_ctx) != 1) ossl_raise(cEC_POINT, "EC_POINT_make_affine"); #endif return self; };T;:I"7static VALUE ossl_ec_point_make_affine(VALUE self);T;;To;4;5F;6;;;;&I"%OpenSSL::PKey::EC::Point#invert!;F;7[;[[@(Hi;T;: invert!;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I" invert!;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"( @overload invert! @return [self];T;#0;$@;.F;/o;0;1T;2i;3i;%@ș;9I"static VALUE ossl_ec_point_invert(VALUE self) { EC_POINT *point; const EC_GROUP *group; GetECPoint(self, point); GetECPointGroup(self, group); if (EC_POINT_invert(group, point, ossl_bn_ctx) != 1) ossl_raise(cEC_POINT, "EC_POINT_invert"); return self; };T;:I"2static VALUE ossl_ec_point_invert(VALUE self);T;;To;4;5F;6;;;;&I".OpenSSL::PKey::EC::Point#set_to_infinity!;F;7[;[[@(Hi,;T;:set_to_infinity!;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"set_to_infinity!;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"1 @overload set_to_infinity! @return [self];T;#0;$@;.F;/o;0;1T;2i(;3i*;%@ș;9I"-static VALUE ossl_ec_point_set_to_infinity(VALUE self) { EC_POINT *point; const EC_GROUP *group; GetECPoint(self, point); GetECPointGroup(self, group); if (EC_POINT_set_to_infinity(group, point) != 1) ossl_raise(cEC_POINT, "EC_POINT_set_to_infinity"); return self; };T;:I";static VALUE ossl_ec_point_set_to_infinity(VALUE self);T;;To;4;5F;6;;;;&I"-OpenSSL::PKey::EC::Point#to_octet_string;F;7[[I"conversion_form;T0;[[@(HiF;T;:to_octet_string;0;[;{;IC; "Returns the octet string representation of the elliptic curve point. _conversion_form_ specifies how the point is converted. Possible values are: - +:compressed+ - +:uncompressed+ - +:hybrid+ ;T;[o;= ;>I" overload;F;?0;;;@0;:I"%to_octet_string(conversion_form);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I"conversion_form;T0;$@;![;"I"Returns the octet string representation of the elliptic curve point. _conversion_form_ specifies how the point is converted. Possible values are: - +:compressed+ - +:uncompressed+ - +:hybrid+ @overload to_octet_string(conversion_form) @return [String];T;#0;$@;.F;/o;0;1T;2i:;3iD;%@ș;9I"static VALUE ossl_ec_point_to_octet_string(VALUE self, VALUE conversion_form) { EC_POINT *point; const EC_GROUP *group; point_conversion_form_t form; VALUE str; size_t len; GetECPoint(self, point); GetECPointGroup(self, group); form = parse_point_conversion_form_symbol(conversion_form); len = EC_POINT_point2oct(group, point, form, NULL, 0, ossl_bn_ctx); if (!len) ossl_raise(eEC_POINT, "EC_POINT_point2oct"); str = rb_str_new(NULL, (long)len); if (!EC_POINT_point2oct(group, point, form, (unsigned char *)RSTRING_PTR(str), len, ossl_bn_ctx)) ossl_raise(eEC_POINT, "EC_POINT_point2oct"); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!OpenSSL::PKey::EC::Point#add;F;7[[I" other;T0;[[@(Hid;T;; ;0;[;{;IC; ",Performs elliptic curve point addition. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"add(point);T;IC; ";T;[;![;"I";T;#0;$@ݚ;.F;Bi;C0;7[[I" point;T0;$@ݚ;![;"I"CPerforms elliptic curve point addition. @overload add(point);T;#0;$@ݚ;.F;/o;0;1T;2i^;3ia;%@ș;9I"[static VALUE ossl_ec_point_add(VALUE self, VALUE other) { EC_POINT *point_self, *point_other, *point_result; const EC_GROUP *group; VALUE group_v = rb_attr_get(self, id_i_group); VALUE result; GetECPoint(self, point_self); GetECPoint(other, point_other); GetECGroup(group_v, group); result = rb_obj_alloc(cEC_POINT); ossl_ec_point_initialize(1, &group_v, result); GetECPoint(result, point_result); if (EC_POINT_add(group, point_result, point_self, point_other, ossl_bn_ctx) != 1) { ossl_raise(eEC_POINT, "EC_POINT_add"); } return result; };T;:I"bn1 * point + bn2 * G, where +G+ is the generator of the group of _point_. _bn2_ may be omitted, and in that case, the result is just bn1 * point. The second form calculates bns[0] * point + bns[1] * points[0] + ... + bns[-1] * points[-1] + bn2 * G. _bn2_ may be omitted. _bns_ must be an array of OpenSSL::BN. _points_ must be an array of OpenSSL::PKey::EC::Point. Please note that points[0] is not multiplied by bns[0], but bns[1]. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"mul(bn1 [, bn2]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"bn1[, bn2];T0;$@o;= ;>I" overload;F;?0;;;@0;:I"mul(bns, points [, bn2]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"bns;T0[I"points[, bn2];T0;$@;![;"I"qPerforms elliptic curve point multiplication. The first form calculates bn1 * point + bn2 * G, where +G+ is the generator of the group of _point_. _bn2_ may be omitted, and in that case, the result is just bn1 * point. The second form calculates bns[0] * point + bns[1] * points[0] + ... + bns[-1] * points[-1] + bn2 * G. _bn2_ may be omitted. _bns_ must be an array of OpenSSL::BN. _points_ must be an array of OpenSSL::PKey::EC::Point. Please note that points[0] is not multiplied by bns[0], but bns[1]. @overload mul(bn1 [, bn2]) @overload mul(bns, points [, bn2]);T;#0;$@;.F;/o;0;1T;2iz;3i;%@ș;9I"static VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self) { EC_POINT *point_self, *point_result; const EC_GROUP *group; VALUE group_v = rb_attr_get(self, id_i_group); VALUE arg1, arg2, arg3, result; const BIGNUM *bn_g = NULL; GetECPoint(self, point_self); GetECGroup(group_v, group); result = rb_obj_alloc(cEC_POINT); ossl_ec_point_initialize(1, &group_v, result); GetECPoint(result, point_result); rb_scan_args(argc, argv, "12", &arg1, &arg2, &arg3); if (!RB_TYPE_P(arg1, T_ARRAY)) { BIGNUM *bn = GetBNPtr(arg1); if (!NIL_P(arg2)) bn_g = GetBNPtr(arg2); if (EC_POINT_mul(group, point_result, bn_g, point_self, bn, ossl_bn_ctx) != 1) ossl_raise(eEC_POINT, NULL); } else { #if (defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3) || defined(LIBRESSL_VERSION_NUMBER) rb_raise(rb_eNotImpError, "calling #mul with arrays is not" \ "supported by this OpenSSL version"); #else /* * bignums | arg1[0] | arg1[1] | arg1[2] | ... * points | self | arg2[0] | arg2[1] | ... */ long i, num; VALUE bns_tmp, tmp_p, tmp_b; const EC_POINT **points; const BIGNUM **bignums; Check_Type(arg1, T_ARRAY); Check_Type(arg2, T_ARRAY); if (RARRAY_LEN(arg1) != RARRAY_LEN(arg2) + 1) /* arg2 must be 1 larger */ ossl_raise(rb_eArgError, "bns must be 1 longer than points; see the documentation"); rb_warning("OpenSSL::PKey::EC::Point#mul(ary, ary) is deprecated; " \ "use #mul(bn) form instead"); num = RARRAY_LEN(arg1); bns_tmp = rb_ary_tmp_new(num); bignums = ALLOCV_N(const BIGNUM *, tmp_b, num); for (i = 0; i < num; i++) { VALUE item = RARRAY_AREF(arg1, i); bignums[i] = GetBNPtr(item); rb_ary_push(bns_tmp, item); } points = ALLOCV_N(const EC_POINT *, tmp_p, num); points[0] = point_self; /* self */ for (i = 0; i < num - 1; i++) GetECPoint(RARRAY_AREF(arg2, i), points[i + 1]); if (!NIL_P(arg3)) bn_g = GetBNPtr(arg3); if (EC_POINTs_mul(group, point_result, bn_g, num, points, bignums, ossl_bn_ctx) != 1) { ALLOCV_END(tmp_b); ALLOCV_END(tmp_p); ossl_raise(eEC_POINT, NULL); } ALLOCV_END(tmp_b); ALLOCV_END(tmp_p); #endif } return result; };T;:I"Fstatic VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self);T;;T; @ș; IC;[; @ș; IC;[; @ș; IC;{;IC;{;T;IC;{;T;T;{@0;V;[;[[@(Hi;F;: Point;;;;;[;{;IC; " ;T;[;![;"@;#0;$@ș;Bi;%@;&I"OpenSSL::PKey::EC::Point;F;'@o;u;[[@(Hi;F;:NAMED_CURVE;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@+;%@;&I"#OpenSSL::PKey::EC::NAMED_CURVE;F;xI"$INT2NUM(OPENSSL_EC_NAMED_CURVE);To;u;[[@(Hi;F;:EXPLICIT_CURVE;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@5;%@;&I"&OpenSSL::PKey::EC::EXPLICIT_CURVE;F;xI"'INT2NUM(OPENSSL_EC_EXPLICIT_CURVE);To;4;5F;6;;;;&I"%OpenSSL::PKey::EC.builtin_curves;F;7[;[[@(Hi";T;:builtin_curves;0;[;{;IC; "Obtains a list of all predefined curves by the OpenSSL. Curve names are returned as sn. See the OpenSSL documentation for EC_get_builtin_curves(). ;T;[o;= ;>I" overload;F;?0;;;@0;:I"builtin_curves;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@?;![;"I"@return [Array];T;#0;$@?;.F;Bi;C0;7[;$@?;![;"I"Obtains a list of all predefined curves by the OpenSSL. Curve names are returned as sn. See the OpenSSL documentation for EC_get_builtin_curves(). @overload builtin_curves @return [Array];T;#0;$@?;.F;/o;0;1T;2i;3i ;%@;9I"static VALUE ossl_s_builtin_curves(VALUE self) { EC_builtin_curve *curves = NULL; int n; int crv_len = rb_long2int(EC_get_builtin_curves(NULL, 0)); VALUE ary, ret; curves = ALLOCA_N(EC_builtin_curve, crv_len); if (curves == NULL) return Qnil; if (!EC_get_builtin_curves(curves, crv_len)) ossl_raise(rb_eRuntimeError, "EC_get_builtin_curves"); ret = rb_ary_new2(crv_len); for (n = 0; n < crv_len; n++) { const char *sname = OBJ_nid2sn(curves[n].nid); const char *comment = curves[n].comment; ary = rb_ary_new2(2); rb_ary_push(ary, rb_str_new2(sname)); rb_ary_push(ary, comment ? rb_str_new2(comment) : Qnil); rb_ary_push(ret, ary); } return ret; };T;:I"3static VALUE ossl_s_builtin_curves(VALUE self);T;;To;4;5F;6;;;;&I"OpenSSL::PKey::EC.generate;F;7[[I"arg;T0;[[@(Him;T;: generate;0;[;{;IC; "HCreates a new EC instance with a new random private and public key. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"generate(ec_group);T;IC; ";T;[;![;"I";T;#0;$@Z;.F;Bi;C0;7[[I" ec_group;T0;$@Zo;= ;>I" overload;F;?0;;;@0;:I"generate(string);T;IC; ";T;[;![;"I";T;#0;$@Z;.F;Bi;C0;7[[I" string;T0;$@Z;![;"I"}Creates a new EC instance with a new random private and public key. @overload generate(ec_group) @overload generate(string);T;#0;$@Z;.F;/o;0;1T;2if;3ij;%@;9I"static VALUE ossl_ec_key_s_generate(VALUE klass, VALUE arg) { EVP_PKEY *pkey; EC_KEY *ec; VALUE obj; obj = rb_obj_alloc(klass); ec = ec_key_new_from_group(arg); pkey = EVP_PKEY_new(); if (!pkey || EVP_PKEY_assign_EC_KEY(pkey, ec) != 1) { EVP_PKEY_free(pkey); EC_KEY_free(ec); ossl_raise(eECError, "EVP_PKEY_assign_EC_KEY"); } RTYPEDDATA_DATA(obj) = pkey; if (!EC_KEY_generate_key(ec)) ossl_raise(eECError, "EC_KEY_generate_key"); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!OpenSSL::PKey::EC#initialize;F;7[[@90;[[@(Hi;T;;D;0;[;{;IC; "2Creates a new EC object from given arguments. ;T;[ o;= ;>I" overload;F;?0;:OpenSSL::PKey::EC.new;@0;:I"OpenSSL::PKey::EC.new;T;IC; ";T;[;![;"I";T;#0;$@~;.F;Bi;C0;7[;$@~o;= ;>I" overload;F;?0;;;@0;:I""OpenSSL::PKey::EC.new(ec_key);T;IC; ";T;[;![;"I";T;#0;$@~;.F;Bi;C0;7[[I" ec_key;T0;$@~o;= ;>I" overload;F;?0;;;@0;:I"$OpenSSL::PKey::EC.new(ec_group);T;IC; ";T;[;![;"I";T;#0;$@~;.F;Bi;C0;7[[I" ec_group;T0;$@~o;= ;>I" overload;F;?0;;;@0;:I"'OpenSSL::PKey::EC.new("secp112r1");T;IC; ";T;[;![;"I";T;#0;$@~;.F;Bi;C0;7[[""secp112r1"0;$@~o;= ;>I" overload;F;?0;;;@0;:I".OpenSSL::PKey::EC.new(pem_string [, pwd]);T;IC; ";T;[;![;"I";T;#0;$@~;.F;Bi;C0;7[[I"pem_string[, pwd];T0;$@~o;= ;>I" overload;F;?0;;;@0;:I"&OpenSSL::PKey::EC.new(der_string);T;IC; ";T;[;![;"I";T;#0;$@~;.F;Bi;C0;7[[I"der_string;T0;$@~;![;"I".Creates a new EC object from given arguments. @overload OpenSSL::PKey::EC.new @overload OpenSSL::PKey::EC.new(ec_key) @overload OpenSSL::PKey::EC.new(ec_group) @overload OpenSSL::PKey::EC.new("secp112r1") @overload OpenSSL::PKey::EC.new(pem_string [, pwd]) @overload OpenSSL::PKey::EC.new(der_string);T;#0;$@~;.F;/o;0;1T;2i;3i;%@;9I"cstatic VALUE ossl_ec_key_initialize(int argc, VALUE *argv, VALUE self) { EVP_PKEY *pkey; EC_KEY *ec; BIO *in; VALUE arg, pass; int type; TypedData_Get_Struct(self, EVP_PKEY, &ossl_evp_pkey_type, pkey); if (pkey) rb_raise(rb_eTypeError, "pkey already initialized"); rb_scan_args(argc, argv, "02", &arg, &pass); if (NIL_P(arg)) { if (!(ec = EC_KEY_new())) ossl_raise(eECError, "EC_KEY_new"); goto legacy; } else if (rb_obj_is_kind_of(arg, cEC_GROUP)) { ec = ec_key_new_from_group(arg); goto legacy; } pass = ossl_pem_passwd_value(pass); arg = ossl_to_der_if_possible(arg); in = ossl_obj2bio(&arg); pkey = ossl_pkey_read_generic(in, pass); BIO_free(in); if (!pkey) { ossl_clear_error(); ec = ec_key_new_from_group(arg); goto legacy; } type = EVP_PKEY_base_id(pkey); if (type != EVP_PKEY_EC) { EVP_PKEY_free(pkey); rb_raise(eDSAError, "incorrect pkey type: %s", OBJ_nid2sn(type)); } RTYPEDDATA_DATA(self) = pkey; return self; legacy: pkey = EVP_PKEY_new(); if (!pkey || EVP_PKEY_assign_EC_KEY(pkey, ec) != 1) { EVP_PKEY_free(pkey); EC_KEY_free(ec); ossl_raise(eECError, "EVP_PKEY_assign_EC_KEY"); } RTYPEDDATA_DATA(self) = pkey; return self; };T;:I"Kstatic VALUE ossl_ec_key_initialize(int argc, VALUE *argv, VALUE self);T;;To;4;5F;6;;;;&I"&OpenSSL::PKey::EC#initialize_copy;F;7[[I" other;T0;[[@(Hi;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@Ǜ;%@;9I"Vstatic VALUE ossl_ec_key_initialize_copy(VALUE self, VALUE other) { EVP_PKEY *pkey; EC_KEY *ec, *ec_new; TypedData_Get_Struct(self, EVP_PKEY, &ossl_evp_pkey_type, pkey); if (pkey) rb_raise(rb_eTypeError, "pkey already initialized"); GetEC(other, ec); ec_new = EC_KEY_dup(ec); if (!ec_new) ossl_raise(eECError, "EC_KEY_dup"); pkey = EVP_PKEY_new(); if (!pkey || EVP_PKEY_assign_EC_KEY(pkey, ec_new) != 1) { EC_KEY_free(ec_new); ossl_raise(eECError, "EVP_PKEY_assign_EC_KEY"); } RTYPEDDATA_DATA(self) = pkey; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKey::EC#group;F;7[;[[@(Hi;T;;E;0;[;{;IC; "oReturns the EC::Group that the key is associated with. Modifying the returned group does not affect _key_. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I" group;T;IC; ";T;[;![;"I";T;#0;$@՛;.F;Bi;C0;7[;$@՛;![;"I"|Returns the EC::Group that the key is associated with. Modifying the returned group does not affect _key_. @overload group;T;#0;$@՛;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_ec_key_get_group(VALUE self) { EC_KEY *ec; const EC_GROUP *group; GetEC(self, ec); group = EC_KEY_get0_group(ec); if (!group) return Qnil; return ec_group_new(group); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKey::EC#group=;F;7[[I" group_v;T0;[[@(Hi;T;: group=;0;[;{;IC; "Sets the EC::Group for the key. The group structure is internally copied so modification to _group_ after assigning to a key has no effect on the key. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"group=(group);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" group;T0;$@;![;"I"Sets the EC::Group for the key. The group structure is internally copied so modification to _group_ after assigning to a key has no effect on the key. @overload group=(group);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"|static VALUE ossl_ec_key_set_group(VALUE self, VALUE group_v) { #if OSSL_OPENSSL_PREREQ(3, 0, 0) rb_raise(ePKeyError, "pkeys are immutable on OpenSSL 3.0"); #else EC_KEY *ec; EC_GROUP *group; GetEC(self, ec); GetECGroup(group_v, group); if (EC_KEY_set_group(ec, group) != 1) ossl_raise(eECError, "EC_KEY_set_group"); return group_v; #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::PKey::EC#private_key;F;7[;[[@(Hi;T;:private_key;0;[;{;IC; "@See the OpenSSL documentation for EC_KEY_get0_private_key() ;T;[o;= ;>I" overload;F;?0;;;@0;:I"private_key;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"OpenSSL::BN;T;$@;![;"I"@return [OpenSSL::BN];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"pSee the OpenSSL documentation for EC_KEY_get0_private_key() @overload private_key @return [OpenSSL::BN];T;#0;$@;.F;/o;0;1T;2i ;3i;%@;9I"static VALUE ossl_ec_key_get_private_key(VALUE self) { EC_KEY *ec; const BIGNUM *bn; GetEC(self, ec); if ((bn = EC_KEY_get0_private_key(ec)) == NULL) return Qnil; return ossl_bn_new(bn); };T;:I"9static VALUE ossl_ec_key_get_private_key(VALUE self);T;;To;4;5F;6;;;;&I"#OpenSSL::PKey::EC#private_key=;F;7[[I"private_key;T0;[[@(Hi#;T;:private_key=;0;[;{;IC; "?See the OpenSSL documentation for EC_KEY_set_private_key() ;T;[o;= ;>I" overload;F;?0;;;@0;:I"private_key=(openssl_bn);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I"openssl_bn;T0;$@ ;![;"I"dSee the OpenSSL documentation for EC_KEY_set_private_key() @overload private_key=(openssl_bn);T;#0;$@ ;.F;/o;0;1T;2i;3i ;%@;9I"/static VALUE ossl_ec_key_set_private_key(VALUE self, VALUE private_key) { #if OSSL_OPENSSL_PREREQ(3, 0, 0) rb_raise(ePKeyError, "pkeys are immutable on OpenSSL 3.0"); #else EC_KEY *ec; BIGNUM *bn = NULL; GetEC(self, ec); if (!NIL_P(private_key)) bn = GetBNPtr(private_key); switch (EC_KEY_set_private_key(ec, bn)) { case 1: break; case 0: if (bn == NULL) break; /* fallthrough */ default: ossl_raise(eECError, "EC_KEY_set_private_key"); } return private_key; #endif };T;:I"Lstatic VALUE ossl_ec_key_set_private_key(VALUE self, VALUE private_key);T;;To;4;5F;6;;;;&I"!OpenSSL::PKey::EC#public_key;F;7[;[[@(HiD;T;;D;0;[;{;IC; "?See the OpenSSL documentation for EC_KEY_get0_public_key() ;T;[o;= ;>I" overload;F;?0;;D;@0;:I"public_key;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"OpenSSL::PKey::EC::Point;T;$@:;![;"I"'@return [OpenSSL::PKey::EC::Point];T;#0;$@:;.F;Bi;C0;7[;$@:;![;"I"{See the OpenSSL documentation for EC_KEY_get0_public_key() @overload public_key @return [OpenSSL::PKey::EC::Point];T;#0;$@:;.F;/o;0;1T;2i>;3iB;%@;9I"static VALUE ossl_ec_key_get_public_key(VALUE self) { EC_KEY *ec; const EC_POINT *point; GetEC(self, ec); if ((point = EC_KEY_get0_public_key(ec)) == NULL) return Qnil; return ec_point_new(point, EC_KEY_get0_group(ec)); };T;:I"8static VALUE ossl_ec_key_get_public_key(VALUE self);T;;To;4;5F;6;;;;&I""OpenSSL::PKey::EC#public_key=;F;7[[I"public_key;T0;[[@(HiV;T;;E;0;[;{;IC; ">See the OpenSSL documentation for EC_KEY_set_public_key() ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"public_key=(ec_point);T;IC; ";T;[;![;"I";T;#0;$@U;.F;Bi;C0;7[[I" ec_point;T0;$@U;![;"I"`See the OpenSSL documentation for EC_KEY_set_public_key() @overload public_key=(ec_point);T;#0;$@U;.F;/o;0;1T;2iP;3iS;%@;9I"7static VALUE ossl_ec_key_set_public_key(VALUE self, VALUE public_key) { #if OSSL_OPENSSL_PREREQ(3, 0, 0) rb_raise(ePKeyError, "pkeys are immutable on OpenSSL 3.0"); #else EC_KEY *ec; EC_POINT *point = NULL; GetEC(self, ec); if (!NIL_P(public_key)) GetECPoint(public_key, point); switch (EC_KEY_set_public_key(ec, point)) { case 1: break; case 0: if (point == NULL) break; /* fallthrough */ default: ossl_raise(eECError, "EC_KEY_set_public_key"); } return public_key; #endif };T;:I"Jstatic VALUE ossl_ec_key_set_public_key(VALUE self, VALUE public_key);T;;To;4;5F;6;;;;&I"OpenSSL::PKey::EC#private?;F;7[;[[@(Hi;T;;;0;[;{;IC; "sReturns whether this EC instance has a private key. The private key (BN) can be retrieved with EC#private_key.;T;[o;= ;>I" overload;F;?0;;;@0;:I" private?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@o;![;"I"@return [Boolean];T;#0;$@o;.F;Bi;C0;7[;$@o;![;"I"Returns whether this EC instance has a private key. The private key (BN) can be retrieved with EC#private_key. @overload private? @return [Boolean];T;#0;$o;4;5F;6;;;;&I"#OpenSSL::PKey::EC#private_key?;F;7[;[[@(Hi;F;:private_key?;;;[;{;@v;%@;9I"static VALUE ossl_ec_key_is_private(VALUE self) { EC_KEY *ec; GetEC(self, ec); return EC_KEY_get0_private_key(ec) ? Qtrue : Qfalse; };T;:I"4static VALUE ossl_ec_key_is_private(VALUE self);T;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE ossl_ec_key_is_private(VALUE self) { EC_KEY *ec; GetEC(self, ec); return EC_KEY_get0_private_key(ec) ? Qtrue : Qfalse; };T;:@;;To;4;5F;6;;;;&I"OpenSSL::PKey::EC#public?;F;7[;[[@(Hix;T;;;0;[;{;IC; "wReturns whether this EC instance has a public key. The public key (EC::Point) can be retrieved with EC#public_key.;T;[o;= ;>I" overload;F;?0;;;@0;:I" public?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns whether this EC instance has a public key. The public key (EC::Point) can be retrieved with EC#public_key. @overload public? @return [Boolean];T;#0;$o;4;5F;6;;;;&I""OpenSSL::PKey::EC#public_key?;F;7[;[[@(Hi;F;:public_key?;;;[;{;@;%@;9I"static VALUE ossl_ec_key_is_public(VALUE self) { EC_KEY *ec; GetEC(self, ec); return EC_KEY_get0_public_key(ec) ? Qtrue : Qfalse; };T;:I"3static VALUE ossl_ec_key_is_public(VALUE self);T;.F;/o;0;1T;2iq;3iv;Bi;%@;9I"static VALUE ossl_ec_key_is_public(VALUE self) { EC_KEY *ec; GetEC(self, ec); return EC_KEY_get0_public_key(ec) ? Qtrue : Qfalse; };T;:@;;T@@o;4;5F;6;;;;&I"$OpenSSL::PKey::EC#generate_key!;F;7[;[[@(Hi;T;:generate_key!;0;[;{;IC; "Generates a new random private and public key. See also the OpenSSL documentation for EC_KEY_generate_key() === Example ec = OpenSSL::PKey::EC.new("prime256v1") p ec.private_key # => nil ec.generate_key! p ec.private_key # => # ;T;[o;= ;>I" overload;F;?0;;;@0;:I"generate_key!;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"(Generates a new random private and public key. See also the OpenSSL documentation for EC_KEY_generate_key() === Example ec = OpenSSL::PKey::EC.new("prime256v1") p ec.private_key # => nil ec.generate_key! p ec.private_key # => # @overload generate_key! @return [self];T;#0;$o;4;5F;6;;;;&I"#OpenSSL::PKey::EC#generate_key;F;7[;[[@(Hi;F;:generate_key;;;[;{;@;%@;9I"/static VALUE ossl_ec_key_generate_key(VALUE self) { #if OSSL_OPENSSL_PREREQ(3, 0, 0) rb_raise(ePKeyError, "pkeys are immutable on OpenSSL 3.0"); #else EC_KEY *ec; GetEC(self, ec); if (EC_KEY_generate_key(ec) != 1) ossl_raise(eECError, "EC_KEY_generate_key"); return self; #endif };T;:I"6static VALUE ossl_ec_key_generate_key(VALUE self);T;.F;/o;0;1T;2i;3i;%@;9I"/static VALUE ossl_ec_key_generate_key(VALUE self) { #if OSSL_OPENSSL_PREREQ(3, 0, 0) rb_raise(ePKeyError, "pkeys are immutable on OpenSSL 3.0"); #else EC_KEY *ec; GetEC(self, ec); if (EC_KEY_generate_key(ec) != 1) ossl_raise(eECError, "EC_KEY_generate_key"); return self; #endif };T;:@՜;;T@͜o;4;5F;6;;;;&I" OpenSSL::PKey::EC#check_key;F;7[;[[@(Hi;T;:check_key;0;[;{;IC; "`Raises an exception if the key is invalid. See also the man page EVP_PKEY_public_check(3). ;T;[o;= ;>I" overload;F;?0;;;@0;:I"check_key;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;T;$@؜;![;"I"@return [true];T;#0;$@؜;.F;Bi;C0;7[;$@؜;![;"I"Raises an exception if the key is invalid. See also the man page EVP_PKEY_public_check(3). @overload check_key @return [true];T;#0;$@؜;.F;/o;0;1T;2i;3i;%@;9I"7static VALUE ossl_ec_key_check_key(VALUE self) { #ifdef HAVE_EVP_PKEY_CHECK EVP_PKEY *pkey; EVP_PKEY_CTX *pctx; int ret; GetPKey(self, pkey); pctx = EVP_PKEY_CTX_new(pkey, /* engine */NULL); if (!pctx) ossl_raise(eDHError, "EVP_PKEY_CTX_new"); ret = EVP_PKEY_public_check(pctx); EVP_PKEY_CTX_free(pctx); if (ret != 1) ossl_raise(eECError, "EVP_PKEY_public_check"); #else EC_KEY *ec; GetEC(self, ec); if (EC_KEY_check_key(ec) != 1) ossl_raise(eECError, "EC_KEY_check_key"); #endif return Qtrue; };T;:I"3static VALUE ossl_ec_key_check_key(VALUE self);T;;To;4;5F;6;;;;&I"OpenSSL::PKey::EC#export;F;7[[@90;[[@(Hi;T;;;0;[;{;IC; "Outputs the EC key in PEM encoding. If _cipher_ and _pass_phrase_ are given they will be used to encrypt the key. _cipher_ must be an OpenSSL::Cipher instance. Note that encryption will only be effective for a private key, public keys will always be encoded in plain text. ;T;[o;= ;>I" overload;F;?0;;;@0;:I""export([cipher, pass_phrase]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I"[cipher, pass_phrase];T0;$@o;= ;>I" overload;F;?0;;L;@0;:I""to_pem([cipher, pass_phrase]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I"[cipher, pass_phrase];T0;$@;![;"I"Outputs the EC key in PEM encoding. If _cipher_ and _pass_phrase_ are given they will be used to encrypt the key. _cipher_ must be an OpenSSL::Cipher instance. Note that encryption will only be effective for a private key, public keys will always be encoded in plain text. @overload export([cipher, pass_phrase]) @return [String] @overload to_pem([cipher, pass_phrase]) @return [String];T;#0;$o;4;5F;6;;;;&I"OpenSSL::PKey::EC#to_pem;F;7[;[[@(Hi";F;;L;;;[;{;@;%@;9I" static VALUE ossl_ec_key_export(int argc, VALUE *argv, VALUE self) { EC_KEY *ec; GetEC(self, ec); if (EC_KEY_get0_private_key(ec)) return ossl_pkey_export_traditional(argc, argv, self, 0); else return ossl_pkey_export_spki(self, 0); };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@;9I" static VALUE ossl_ec_key_export(int argc, VALUE *argv, VALUE self) { EC_KEY *ec; GetEC(self, ec); if (EC_KEY_get0_private_key(ec)) return ossl_pkey_export_traditional(argc, argv, self, 0); else return ossl_pkey_export_spki(self, 0); };T;:@%;;T@o;4;5F;6;;;;&I"OpenSSL::PKey::EC#to_der;F;7[;[[@(Hi;T;;M;0;[;{;IC; "=See the OpenSSL documentation for i2d_ECPrivateKey_bio() ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" to_der;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@(;![;"I"@return [String];T;#0;$@(;.F;Bi;C0;7[;$@(;![;"I"cSee the OpenSSL documentation for i2d_ECPrivateKey_bio() @overload to_der @return [String];T;#0;$@(;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_ec_key_to_der(VALUE self) { EC_KEY *ec; GetEC(self, ec); if (EC_KEY_get0_private_key(ec)) return ossl_pkey_export_traditional(0, NULL, self, 1); else return ossl_pkey_export_spki(self, 1); };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{ @;@;@͜;@;;[;[[@(Hi[@(Hi;T;:EC;;;;;[;{;IC; "OpenSSL::PKey::EC provides access to Elliptic Curve Digital Signature Algorithm (ECDSA) and Elliptic Curve Diffie-Hellman (ECDH). === Key exchange ec1 = OpenSSL::PKey::EC.generate("prime256v1") ec2 = OpenSSL::PKey::EC.generate("prime256v1") # ec1 and ec2 have own private key respectively shared_key1 = ec1.dh_compute_key(ec2.public_key) shared_key2 = ec2.dh_compute_key(ec1.public_key) p shared_key1 == shared_key2 #=> true ;T;[;![;"I" OpenSSL::PKey::EC provides access to Elliptic Curve Digital Signature Algorithm (ECDSA) and Elliptic Curve Diffie-Hellman (ECDH). === Key exchange ec1 = OpenSSL::PKey::EC.generate("prime256v1") ec2 = OpenSSL::PKey::EC.generate("prime256v1") # ec1 and ec2 have own private key respectively shared_key1 = ec1.dh_compute_key(ec2.public_key) shared_key2 = ec2.dh_compute_key(ec1.public_key) p shared_key1 == shared_key2 #=> true ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"OpenSSL::PKey::EC;F;'@o; ;IC;[; @U; IC;[; @U; IC;[; @U; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i ;T;: RSAError;;;;;[;{;IC; "Generic exception that is raised if an operation on an RSA PKey fails unexpectedly or in case an instantiation of an instance of RSA fails due to non-conformant input data. ;T;[;![;"I" Generic exception that is raised if an operation on an RSA PKey fails unexpectedly or in case an instantiation of an instance of RSA fails due to non-conformant input data. ;T;#0;$@U;.F;/o;0;1T;2i;3i ;%@;&I"OpenSSL::PKey::RSAError;F;'@ o; ;IC;[o;4;5F;6;;;;&I""OpenSSL::PKey::RSA#initialize;F;7[[@90;[[@iQ;T;;D;0;[;{;IC; "Generates or loads an \RSA keypair. If called without arguments, creates a new instance with no key components set. They can be set individually by #set_key, #set_factors, and #set_crt_params. If called with a String, tries to parse as DER or PEM encoding of an \RSA key. Note that, if _passphrase_ is not specified but the key is encrypted with a passphrase, \OpenSSL will prompt for it. See also OpenSSL::PKey.read which can parse keys of any kinds. If called with a number, generates a new key pair. This form works as an alias of RSA.generate. Examples: OpenSSL::PKey::RSA.new 2048 OpenSSL::PKey::RSA.new File.read 'rsa.pem' OpenSSL::PKey::RSA.new File.read('rsa.pem'), 'my pass phrase' ;T;[ o;= ;>I" overload;F;?0;;E;@0;:I"new;T;IC; ";T;[;![;"I";T;#0;$@k;.F;Bi;C0;7[;$@ko;= ;>I" overload;F;?0;;E;@0;:I"$new(encoded_key [, passphrase]);T;IC; ";T;[;![;"I";T;#0;$@k;.F;Bi;C0;7[[I"encoded_key[, passphrase];T0;$@ko;= ;>I" overload;F;?0;;E;@0;:I"new(encoded_key);T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@k;![;"I"@yield [];T;#0;$@k;.F;Bi;C0;7[[I"encoded_key;T0;$@ko;= ;>I" overload;F;?0;;E;@0;:I"new(size [, exponent]);T;IC; ";T;[;![;"I";T;#0;$@k;.F;Bi;C0;7[[I"size[, exponent];T0;$@k;![;"I">Generates or loads an \RSA keypair. If called without arguments, creates a new instance with no key components set. They can be set individually by #set_key, #set_factors, and #set_crt_params. If called with a String, tries to parse as DER or PEM encoding of an \RSA key. Note that, if _passphrase_ is not specified but the key is encrypted with a passphrase, \OpenSSL will prompt for it. See also OpenSSL::PKey.read which can parse keys of any kinds. If called with a number, generates a new key pair. This form works as an alias of RSA.generate. Examples: OpenSSL::PKey::RSA.new 2048 OpenSSL::PKey::RSA.new File.read 'rsa.pem' OpenSSL::PKey::RSA.new File.read('rsa.pem'), 'my pass phrase' @overload new @overload new(encoded_key [, passphrase]) @overload new(encoded_key) @yield [] @overload new(size [, exponent]);T;#0;$@k;.F;/o;0;1T;2i7;3iO;%@i;9I"Jstatic VALUE ossl_rsa_initialize(int argc, VALUE *argv, VALUE self) { EVP_PKEY *pkey; RSA *rsa; BIO *in = NULL; VALUE arg, pass; int type; TypedData_Get_Struct(self, EVP_PKEY, &ossl_evp_pkey_type, pkey); if (pkey) rb_raise(rb_eTypeError, "pkey already initialized"); /* The RSA.new(size, generator) form is handled by lib/openssl/pkey.rb */ rb_scan_args(argc, argv, "02", &arg, &pass); if (argc == 0) { rsa = RSA_new(); if (!rsa) ossl_raise(eRSAError, "RSA_new"); goto legacy; } pass = ossl_pem_passwd_value(pass); arg = ossl_to_der_if_possible(arg); in = ossl_obj2bio(&arg); /* First try RSAPublicKey format */ rsa = d2i_RSAPublicKey_bio(in, NULL); if (rsa) goto legacy; OSSL_BIO_reset(in); rsa = PEM_read_bio_RSAPublicKey(in, NULL, NULL, NULL); if (rsa) goto legacy; OSSL_BIO_reset(in); /* Use the generic routine */ pkey = ossl_pkey_read_generic(in, pass); BIO_free(in); if (!pkey) ossl_raise(eRSAError, "Neither PUB key nor PRIV key"); type = EVP_PKEY_base_id(pkey); if (type != EVP_PKEY_RSA) { EVP_PKEY_free(pkey); rb_raise(eRSAError, "incorrect pkey type: %s", OBJ_nid2sn(type)); } RTYPEDDATA_DATA(self) = pkey; return self; legacy: BIO_free(in); pkey = EVP_PKEY_new(); if (!pkey || EVP_PKEY_assign_RSA(pkey, rsa) != 1) { EVP_PKEY_free(pkey); RSA_free(rsa); ossl_raise(eRSAError, "EVP_PKEY_assign_RSA"); } RTYPEDDATA_DATA(self) = pkey; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::PKey::RSA#initialize_copy;F;7[[I" other;T0;[[@i;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@;%@i;9I"static VALUE ossl_rsa_initialize_copy(VALUE self, VALUE other) { EVP_PKEY *pkey; RSA *rsa, *rsa_new; TypedData_Get_Struct(self, EVP_PKEY, &ossl_evp_pkey_type, pkey); if (pkey) rb_raise(rb_eTypeError, "pkey already initialized"); GetRSA(other, rsa); rsa_new = (RSA *)ASN1_dup((i2d_of_void *)i2d_RSAPrivateKey, (d2i_of_void *)d2i_RSAPrivateKey, (char *)rsa); if (!rsa_new) ossl_raise(eRSAError, "ASN1_dup"); pkey = EVP_PKEY_new(); if (!pkey || EVP_PKEY_assign_RSA(pkey, rsa_new) != 1) { RSA_free(rsa_new); ossl_raise(eRSAError, "EVP_PKEY_assign_RSA"); } RTYPEDDATA_DATA(self) = pkey; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKey::RSA#public?;F;7[;[[@i;T;;;0;[;{;IC; "TThe return value is always +true+ since every private key is also a public key.;T;[o;= ;>I" overload;F;?0;;;@0;:I" public?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;T;$@;![;"I"@return [true];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"yThe return value is always +true+ since every private key is also a public key. @overload public? @return [true];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@i;9I"static VALUE ossl_rsa_is_public(VALUE self) { RSA *rsa; GetRSA(self, rsa); /* * This method should check for n and e. BUG. */ (void)rsa; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" OpenSSL::PKey::RSA#private?;F;7[;[[@i;T;;;0;[;{;IC; "-Does this keypair contain a private key?;T;[o;= ;>I" overload;F;?0;;;@0;:I" private?;T;IC; ";T;[;![;"I";T;#0;$@̝;.F;Bi;C0;7[;$@̝o;A ;>I" return;F;?@;0;@[@L;$@̝;![;"I"BDoes this keypair contain a private key? @overload private?;T;#0;$@̝;.F;/o;0;1T;2i;3i;Bi;%@i;9I"static VALUE ossl_rsa_is_private(VALUE self) { RSA *rsa; GetRSA(self, rsa); return RSA_PRIVATE(self, rsa) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKey::RSA#export;F;7[[@90;[[@i;T;;;0;[;{;IC; "Outputs this keypair in PEM encoding. If _cipher_ and _pass_phrase_ are given they will be used to encrypt the key. _cipher_ must be an OpenSSL::Cipher instance. ;T;[o;= ;>I" overload;F;?0;;;@0;:I""export([cipher, pass_phrase]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"PEM-format String;T;$@;![;"I" @return [PEM-format String];T;#0;$@;.F;Bi;C0;7[[I"[cipher, pass_phrase];T0;$@o;= ;>I" overload;F;?0;;L;@0;:I""to_pem([cipher, pass_phrase]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"PEM-format String;T;$@;![;"I" @return [PEM-format String];T;#0;$@;.F;Bi;C0;7[[I"[cipher, pass_phrase];T0;$@o;= ;>I" overload;F;?0;;G;@0;:I" to_s([cipher, pass_phrase]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"PEM-format String;T;$@;![;"I" @return [PEM-format String];T;#0;$@;.F;Bi;C0;7[[I"[cipher, pass_phrase];T0;$@;![;"I"uOutputs this keypair in PEM encoding. If _cipher_ and _pass_phrase_ are given they will be used to encrypt the key. _cipher_ must be an OpenSSL::Cipher instance. @overload export([cipher, pass_phrase]) @return [PEM-format String] @overload to_pem([cipher, pass_phrase]) @return [PEM-format String] @overload to_s([cipher, pass_phrase]) @return [PEM-format String];T;#0;$o;4;5F;6;;;;&I"OpenSSL::PKey::RSA#to_s;F;7[;[[@i$;F;;G;;;[;{;@;%@i;9I"static VALUE ossl_rsa_export(int argc, VALUE *argv, VALUE self) { if (can_export_rsaprivatekey(self)) return ossl_pkey_export_traditional(argc, argv, self, 0); else return ossl_pkey_export_spki(self, 0); };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@i;9I"static VALUE ossl_rsa_export(int argc, VALUE *argv, VALUE self) { if (can_export_rsaprivatekey(self)) return ossl_pkey_export_traditional(argc, argv, self, 0); else return ossl_pkey_export_spki(self, 0); };T;:@&;;To;4;5F;6;;;;&I"OpenSSL::PKey::RSA#to_pem;F;7[;[[@i#;F;;L;;;[;{;@;%@i;9I"static VALUE ossl_rsa_export(int argc, VALUE *argv, VALUE self) { if (can_export_rsaprivatekey(self)) return ossl_pkey_export_traditional(argc, argv, self, 0); else return ossl_pkey_export_spki(self, 0); };T;:@&@o;4;5F;6;;;;&I"OpenSSL::PKey::RSA#to_der;F;7[;[[@i;T;;M;0;[;{;IC; "*Outputs this keypair in DER encoding. ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" to_der;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"DER-format String;T;$@1;![;"I" @return [DER-format String];T;#0;$@1;.F;Bi;C0;7[;$@1;![;"I"[Outputs this keypair in DER encoding. @overload to_der @return [DER-format String];T;#0;$@1;.F;/o;0;1T;2i;3i;%@i;9I"static VALUE ossl_rsa_to_der(VALUE self) { if (can_export_rsaprivatekey(self)) return ossl_pkey_export_traditional(0, NULL, self, 1); else return ossl_pkey_export_spki(self, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" OpenSSL::PKey::RSA#sign_pss;F;7[[@90;[[@i;T;: sign_pss;0;[;{;IC; "Signs _data_ using the Probabilistic Signature Scheme (RSA-PSS) and returns the calculated signature. RSAError will be raised if an error occurs. See #verify_pss for the verification operation. === Parameters _digest_:: A String containing the message digest algorithm name. _data_:: A String. The data to be signed. _salt_length_:: The length in octets of the salt. Two special values are reserved: +:digest+ means the digest length, and +:max+ means the maximum possible length for the combination of the private key and the selected message digest algorithm. _mgf1_hash_:: The hash algorithm used in MGF1 (the currently supported mask generation function (MGF)). === Example data = "Sign me!" pkey = OpenSSL::PKey::RSA.new(2048) signature = pkey.sign_pss("SHA256", data, salt_length: :max, mgf1_hash: "SHA256") pub_key = OpenSSL::PKey.read(pkey.public_to_der) puts pub_key.verify_pss("SHA256", signature, data, salt_length: :auto, mgf1_hash: "SHA256") # => true ;T;[o;= ;>I" overload;F;?0;;;@0;:I"5sign_pss(digest, data, salt_length:, mgf1_hash:);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@L;![;"I"@return [String];T;#0;$@L;.F;Bi;C0;7[ [I" digest;T0[I" data;T0[I"salt_length:;TI";T[I"mgf1_hash:;TI";T;$@L;![;"I"LSigns _data_ using the Probabilistic Signature Scheme (RSA-PSS) and returns the calculated signature. RSAError will be raised if an error occurs. See #verify_pss for the verification operation. === Parameters _digest_:: A String containing the message digest algorithm name. _data_:: A String. The data to be signed. _salt_length_:: The length in octets of the salt. Two special values are reserved: +:digest+ means the digest length, and +:max+ means the maximum possible length for the combination of the private key and the selected message digest algorithm. _mgf1_hash_:: The hash algorithm used in MGF1 (the currently supported mask generation function (MGF)). === Example data = "Sign me!" pkey = OpenSSL::PKey::RSA.new(2048) signature = pkey.sign_pss("SHA256", data, salt_length: :max, mgf1_hash: "SHA256") pub_key = OpenSSL::PKey.read(pkey.public_to_der) puts pub_key.verify_pss("SHA256", signature, data, salt_length: :auto, mgf1_hash: "SHA256") # => true @overload sign_pss(digest, data, salt_length:, mgf1_hash:) @return [String];T;#0;$@L;.F;/o;0;1T;2i;3i;%@i;9I"static VALUE ossl_rsa_sign_pss(int argc, VALUE *argv, VALUE self) { VALUE digest, data, options, kwargs[2], signature; static ID kwargs_ids[2]; EVP_PKEY *pkey; EVP_PKEY_CTX *pkey_ctx; const EVP_MD *md, *mgf1md; EVP_MD_CTX *md_ctx; size_t buf_len; int salt_len; if (!kwargs_ids[0]) { kwargs_ids[0] = rb_intern_const("salt_length"); kwargs_ids[1] = rb_intern_const("mgf1_hash"); } rb_scan_args(argc, argv, "2:", &digest, &data, &options); rb_get_kwargs(options, kwargs_ids, 2, 0, kwargs); if (kwargs[0] == ID2SYM(rb_intern("max"))) salt_len = -2; /* RSA_PSS_SALTLEN_MAX_SIGN */ else if (kwargs[0] == ID2SYM(rb_intern("digest"))) salt_len = -1; /* RSA_PSS_SALTLEN_DIGEST */ else salt_len = NUM2INT(kwargs[0]); mgf1md = ossl_evp_get_digestbyname(kwargs[1]); pkey = GetPrivPKeyPtr(self); buf_len = EVP_PKEY_size(pkey); md = ossl_evp_get_digestbyname(digest); StringValue(data); signature = rb_str_new(NULL, (long)buf_len); md_ctx = EVP_MD_CTX_new(); if (!md_ctx) goto err; if (EVP_DigestSignInit(md_ctx, &pkey_ctx, md, NULL, pkey) != 1) goto err; if (EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) != 1) goto err; if (EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, salt_len) != 1) goto err; if (EVP_PKEY_CTX_set_rsa_mgf1_md(pkey_ctx, mgf1md) != 1) goto err; if (EVP_DigestSignUpdate(md_ctx, RSTRING_PTR(data), RSTRING_LEN(data)) != 1) goto err; if (EVP_DigestSignFinal(md_ctx, (unsigned char *)RSTRING_PTR(signature), &buf_len) != 1) goto err; rb_str_set_len(signature, (long)buf_len); EVP_MD_CTX_free(md_ctx); return signature; err: EVP_MD_CTX_free(md_ctx); ossl_raise(eRSAError, NULL); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::PKey::RSA#verify_pss;F;7[[@90;[[@it;T;:verify_pss;0;[;{;IC; "sVerifies _data_ using the Probabilistic Signature Scheme (RSA-PSS). The return value is +true+ if the signature is valid, +false+ otherwise. RSAError will be raised if an error occurs. See #sign_pss for the signing operation and an example code. === Parameters _digest_:: A String containing the message digest algorithm name. _data_:: A String. The data to be signed. _salt_length_:: The length in octets of the salt. Two special values are reserved: +:digest+ means the digest length, and +:auto+ means automatically determining the length based on the signature. _mgf1_hash_:: The hash algorithm used in MGF1. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"Bverify_pss(digest, signature, data, salt_length:, mgf1_hash:);T;IC; ";T;[;![;"I";T;#0;$@r;.F;Bi;C0;7[ [I" digest;T0[I"signature;T0[I" data;T0[I"salt_length:;TI";T[I"mgf1_hash:;TI";T;$@r;![;"I"Verifies _data_ using the Probabilistic Signature Scheme (RSA-PSS). The return value is +true+ if the signature is valid, +false+ otherwise. RSAError will be raised if an error occurs. See #sign_pss for the signing operation and an example code. === Parameters _digest_:: A String containing the message digest algorithm name. _data_:: A String. The data to be signed. _salt_length_:: The length in octets of the salt. Two special values are reserved: +:digest+ means the digest length, and +:auto+ means automatically determining the length based on the signature. _mgf1_hash_:: The hash algorithm used in MGF1. @overload verify_pss(digest, signature, data, salt_length:, mgf1_hash:);T;#0;$@r;.F;/o;0;1T;2i];3iq;%@i;9I" static VALUE ossl_rsa_verify_pss(int argc, VALUE *argv, VALUE self) { VALUE digest, signature, data, options, kwargs[2]; static ID kwargs_ids[2]; EVP_PKEY *pkey; EVP_PKEY_CTX *pkey_ctx; const EVP_MD *md, *mgf1md; EVP_MD_CTX *md_ctx; int result, salt_len; if (!kwargs_ids[0]) { kwargs_ids[0] = rb_intern_const("salt_length"); kwargs_ids[1] = rb_intern_const("mgf1_hash"); } rb_scan_args(argc, argv, "3:", &digest, &signature, &data, &options); rb_get_kwargs(options, kwargs_ids, 2, 0, kwargs); if (kwargs[0] == ID2SYM(rb_intern("auto"))) salt_len = -2; /* RSA_PSS_SALTLEN_AUTO */ else if (kwargs[0] == ID2SYM(rb_intern("digest"))) salt_len = -1; /* RSA_PSS_SALTLEN_DIGEST */ else salt_len = NUM2INT(kwargs[0]); mgf1md = ossl_evp_get_digestbyname(kwargs[1]); GetPKey(self, pkey); md = ossl_evp_get_digestbyname(digest); StringValue(signature); StringValue(data); md_ctx = EVP_MD_CTX_new(); if (!md_ctx) goto err; if (EVP_DigestVerifyInit(md_ctx, &pkey_ctx, md, NULL, pkey) != 1) goto err; if (EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) != 1) goto err; if (EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, salt_len) != 1) goto err; if (EVP_PKEY_CTX_set_rsa_mgf1_md(pkey_ctx, mgf1md) != 1) goto err; if (EVP_DigestVerifyUpdate(md_ctx, RSTRING_PTR(data), RSTRING_LEN(data)) != 1) goto err; result = EVP_DigestVerifyFinal(md_ctx, (unsigned char *)RSTRING_PTR(signature), RSTRING_LEN(signature)); switch (result) { case 0: ossl_clear_error(); EVP_MD_CTX_free(md_ctx); return Qfalse; case 1: EVP_MD_CTX_free(md_ctx); return Qtrue; default: goto err; } err: EVP_MD_CTX_free(md_ctx); ossl_raise(eRSAError, NULL); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKey::RSA#set_key;F;7[;[;F;;;;;[;{;IC; "-Sets _n_, _e_, _d_ for the RSA instance. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"set_key(n, e, d);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[[I"n;T0[I"e;T0[I"d;T0;$@;![;"I"[Sets _n_, _e_, _d_ for the RSA instance. @overload set_key(n, e, d) @return [self];T;#0;$@;.F;/o;0;1T;2i;3i;%@i;;To;4;5F;6;;;;&I"#OpenSSL::PKey::RSA#set_factors;F;7[;[;F;:set_factors;;;[;{;IC; "(Sets _p_, _q_ for the RSA instance. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"set_factors(p, q);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[[I"p;T0[I"q;T0;$@;![;"I"WSets _p_, _q_ for the RSA instance. @overload set_factors(p, q) @return [self];T;#0;$@;.F;/o;0;1T;2i;3i;%@i;;To;4;5F;6;;;;&I"&OpenSSL::PKey::RSA#set_crt_params;F;7[;[;F;:set_crt_params;;;[;{;IC; "Sets _dmp1_, _dmq1_, _iqmp_ for the RSA instance. They are calculated by d mod (p - 1), d mod (q - 1) and q^(-1) mod p respectively. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"%set_crt_params(dmp1, dmq1, iqmp);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@Ϟ;![;"I"@return [self];T;#0;$@Ϟ;.F;Bi;C0;7[[I" dmp1;T0[I" dmq1;T0[I" iqmp;T0;$@Ϟ;![;"I"Sets _dmp1_, _dmq1_, _iqmp_ for the RSA instance. They are calculated by d mod (p - 1), d mod (q - 1) and q^(-1) mod p respectively. @overload set_crt_params(dmp1, dmq1, iqmp) @return [self];T;#0;$@Ϟ;.F;/o;0;1T;2i;3i;%@i;;To;4;5F;6;;;;&I"OpenSSL::PKey::RSA#params;F;7[;[[@i;T;;;0;[;{;IC; "THIS METHOD IS INSECURE, PRIVATE INFORMATION CAN LEAK OUT!!! Stores all parameters of key to the hash. The hash has keys 'n', 'e', 'd', 'p', 'q', 'dmp1', 'dmq1', 'iqmp'. Don't use :-)) (It's up to you) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" params;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@;![;"I"@return [Hash];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"THIS METHOD IS INSECURE, PRIVATE INFORMATION CAN LEAK OUT!!! Stores all parameters of key to the hash. The hash has keys 'n', 'e', 'd', 'p', 'q', 'dmp1', 'dmq1', 'iqmp'. Don't use :-)) (It's up to you) @overload params @return [Hash];T;#0;$@;.F;/o;0;1T;2i;3i;%@i;9I"(static VALUE ossl_rsa_get_params(VALUE self) { RSA *rsa; VALUE hash; const BIGNUM *n, *e, *d, *p, *q, *dmp1, *dmq1, *iqmp; GetRSA(self, rsa); RSA_get0_key(rsa, &n, &e, &d); RSA_get0_factors(rsa, &p, &q); RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp); hash = rb_hash_new(); rb_hash_aset(hash, rb_str_new2("n"), ossl_bn_new(n)); rb_hash_aset(hash, rb_str_new2("e"), ossl_bn_new(e)); rb_hash_aset(hash, rb_str_new2("d"), ossl_bn_new(d)); rb_hash_aset(hash, rb_str_new2("p"), ossl_bn_new(p)); rb_hash_aset(hash, rb_str_new2("q"), ossl_bn_new(q)); rb_hash_aset(hash, rb_str_new2("dmp1"), ossl_bn_new(dmp1)); rb_hash_aset(hash, rb_str_new2("dmq1"), ossl_bn_new(dmq1)); rb_hash_aset(hash, rb_str_new2("iqmp"), ossl_bn_new(iqmp)); return hash; };T;:I"static VALUE;T;;T; @i; IC;[; @i; IC;[; @i; IC;{;IC;{;T;IC;{;T;T;{@);@;;[;[[@i[@i;T;:RSA;;;;;[;{;IC; "RSA is an asymmetric public key algorithm that has been formalized in RFC 3447. It is in widespread use in public key infrastructures (PKI) where certificates (cf. OpenSSL::X509::Certificate) often are issued on the basis of a public/private RSA key pair. RSA is used in a wide field of applications such as secure (symmetric) key exchange, e.g. when establishing a secure TLS/SSL connection. It is also used in various digital signature schemes. ;T;[;![;"I" RSA is an asymmetric public key algorithm that has been formalized in RFC 3447. It is in widespread use in public key infrastructures (PKI) where certificates (cf. OpenSSL::X509::Certificate) often are issued on the basis of a public/private RSA key pair. RSA is used in a wide field of applications such as secure (symmetric) key exchange, e.g. when establishing a secure TLS/SSL connection. It is also used in various digital signature schemes. ;T;#0;$@i;.F;/o;0;1T;2i;3i;%@;&I"OpenSSL::PKey::RSA;F;'@o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i;[@iA;T;: DSAError;;;;;[;{;IC; "Generic exception that is raised if an operation on a DSA PKey fails unexpectedly or in case an instantiation of an instance of DSA fails due to non-conformant input data. ;T;[;![;"I" Generic exception that is raised if an operation on a DSA PKey fails unexpectedly or in case an instantiation of an instance of DSA fails due to non-conformant input data. ;T;#0;$@;.F;/o;0;1T;2i;;3i?;%@;&I"OpenSSL::PKey::DSAError;F;'@ o; ;IC;[o;4;5F;6;;;;&I""OpenSSL::PKey::DSA#initialize;F;7[[@90;[[@iX;T;;D;0;[;{;IC; "Creates a new DSA instance by reading an existing key from _string_. If called without arguments, creates a new instance with no key components set. They can be set individually by #set_pqg and #set_key. If called with a String, tries to parse as DER or PEM encoding of a \DSA key. See also OpenSSL::PKey.read which can parse keys of any kinds. If called with a number, generates random parameters and a key pair. This form works as an alias of DSA.generate. +string+:: A String that contains a DER or PEM encoded key. +pass+:: A String that contains an optional password. +size+:: See DSA.generate. Examples: p OpenSSL::PKey::DSA.new(1024) #=> # p OpenSSL::PKey::DSA.new(File.read('dsa.pem')) #=> # p OpenSSL::PKey::DSA.new(File.read('dsa.pem'), 'mypassword') #=> # ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new;T;IC; ";T;[;![;"I";T;#0;$@0;.F;Bi;C0;7[;$@0o;= ;>I" overload;F;?0;;E;@0;:I"new(string [, pass]);T;IC; ";T;[;![;"I";T;#0;$@0;.F;Bi;C0;7[[I"string[, pass];T0;$@0o;= ;>I" overload;F;?0;;E;@0;:I"new(size);T;IC; ";T;[;![;"I";T;#0;$@0;.F;Bi;C0;7[[I" size;T0;$@0;![;"I"Creates a new DSA instance by reading an existing key from _string_. If called without arguments, creates a new instance with no key components set. They can be set individually by #set_pqg and #set_key. If called with a String, tries to parse as DER or PEM encoding of a \DSA key. See also OpenSSL::PKey.read which can parse keys of any kinds. If called with a number, generates random parameters and a key pair. This form works as an alias of DSA.generate. +string+:: A String that contains a DER or PEM encoded key. +pass+:: A String that contains an optional password. +size+:: See DSA.generate. Examples: p OpenSSL::PKey::DSA.new(1024) #=> # p OpenSSL::PKey::DSA.new(File.read('dsa.pem')) #=> # p OpenSSL::PKey::DSA.new(File.read('dsa.pem'), 'mypassword') #=> # @overload new @overload new(string [, pass]) @overload new(size);T;#0;$@0;.F;/o;0;1T;2i6;3iU;%@.;9I"qstatic VALUE ossl_dsa_initialize(int argc, VALUE *argv, VALUE self) { EVP_PKEY *pkey; DSA *dsa; BIO *in = NULL; VALUE arg, pass; int type; TypedData_Get_Struct(self, EVP_PKEY, &ossl_evp_pkey_type, pkey); if (pkey) rb_raise(rb_eTypeError, "pkey already initialized"); /* The DSA.new(size, generator) form is handled by lib/openssl/pkey.rb */ rb_scan_args(argc, argv, "02", &arg, &pass); if (argc == 0) { dsa = DSA_new(); if (!dsa) ossl_raise(eDSAError, "DSA_new"); goto legacy; } pass = ossl_pem_passwd_value(pass); arg = ossl_to_der_if_possible(arg); in = ossl_obj2bio(&arg); /* DER-encoded DSAPublicKey format isn't supported by the generic routine */ dsa = (DSA *)PEM_ASN1_read_bio((d2i_of_void *)d2i_DSAPublicKey, PEM_STRING_DSA_PUBLIC, in, NULL, NULL, NULL); if (dsa) goto legacy; OSSL_BIO_reset(in); pkey = ossl_pkey_read_generic(in, pass); BIO_free(in); if (!pkey) ossl_raise(eDSAError, "Neither PUB key nor PRIV key"); type = EVP_PKEY_base_id(pkey); if (type != EVP_PKEY_DSA) { EVP_PKEY_free(pkey); rb_raise(eDSAError, "incorrect pkey type: %s", OBJ_nid2sn(type)); } RTYPEDDATA_DATA(self) = pkey; return self; legacy: BIO_free(in); pkey = EVP_PKEY_new(); if (!pkey || EVP_PKEY_assign_DSA(pkey, dsa) != 1) { EVP_PKEY_free(pkey); DSA_free(dsa); ossl_raise(eDSAError, "EVP_PKEY_assign_DSA"); } RTYPEDDATA_DATA(self) = pkey; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::PKey::DSA#initialize_copy;F;7[[I" other;T0;[[@i;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@[;%@.;9I"static VALUE ossl_dsa_initialize_copy(VALUE self, VALUE other) { EVP_PKEY *pkey; DSA *dsa, *dsa_new; TypedData_Get_Struct(self, EVP_PKEY, &ossl_evp_pkey_type, pkey); if (pkey) rb_raise(rb_eTypeError, "pkey already initialized"); GetDSA(other, dsa); dsa_new = (DSA *)ASN1_dup((i2d_of_void *)i2d_DSAPrivateKey, (d2i_of_void *)d2i_DSAPrivateKey, (char *)dsa); if (!dsa_new) ossl_raise(eDSAError, "ASN1_dup"); pkey = EVP_PKEY_new(); if (!pkey || EVP_PKEY_assign_DSA(pkey, dsa_new) != 1) { EVP_PKEY_free(pkey); DSA_free(dsa_new); ossl_raise(eDSAError, "EVP_PKEY_assign_DSA"); } RTYPEDDATA_DATA(self) = pkey; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKey::DSA#public?;F;7[;[[@i;T;;;0;[;{;IC; "Indicates whether this DSA instance has a public key associated with it or not. The public key may be retrieved with DSA#public_key.;T;[o;= ;>I" overload;F;?0;;;@0;:I" public?;T;IC; ";T;[;![;"I";T;#0;$@i;.F;Bi;C0;7[;$@io;A ;>I" return;F;?@;0;@[@L;$@i;![;"I"Indicates whether this DSA instance has a public key associated with it or not. The public key may be retrieved with DSA#public_key. @overload public?;T;#0;$@i;.F;/o;0;1T;2i;3i;Bi;%@.;9I"static VALUE ossl_dsa_is_public(VALUE self) { DSA *dsa; const BIGNUM *bn; GetDSA(self, dsa); DSA_get0_key(dsa, &bn, NULL); return bn ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" OpenSSL::PKey::DSA#private?;F;7[;[[@i;T;;;0;[;{;IC; "Indicates whether this DSA instance has a private key associated with it or not. The private key may be retrieved with DSA#private_key.;T;[o;= ;>I" overload;F;?0;;;@0;:I" private?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"Indicates whether this DSA instance has a private key associated with it or not. The private key may be retrieved with DSA#private_key. @overload private?;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@.;9I"static VALUE ossl_dsa_is_private(VALUE self) { DSA *dsa; GetDSA(self, dsa); return DSA_PRIVATE(self, dsa) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKey::DSA#export;F;7[[@90;[[@i;T;;;0;[;{;IC; "Encodes this DSA to its PEM encoding. === Parameters * _cipher_ is an OpenSSL::Cipher. * _password_ is a string containing your password. === Examples DSA.to_pem -> aString DSA.to_pem(cipher, 'mypassword') -> aString ;T;[o;= ;>I" overload;F;?0;;;@0;:I"export([cipher, password]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" aString;T;$@;![;"I"@return [aString];T;#0;$@;.F;Bi;C0;7[[I"[cipher, password];T0;$@o;= ;>I" overload;F;?0;;L;@0;:I"to_pem([cipher, password]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" aString;T;$@;![;"I"@return [aString];T;#0;$@;.F;Bi;C0;7[[I"[cipher, password];T0;$@o;= ;>I" overload;F;?0;;G;@0;:I"to_s([cipher, password]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" aString;T;$@;![;"I"@return [aString];T;#0;$@;.F;Bi;C0;7[[I"[cipher, password];T0;$@;![;"I"Encodes this DSA to its PEM encoding. === Parameters * _cipher_ is an OpenSSL::Cipher. * _password_ is a string containing your password. === Examples DSA.to_pem -> aString DSA.to_pem(cipher, 'mypassword') -> aString @overload export([cipher, password]) @return [aString] @overload to_pem([cipher, password]) @return [aString] @overload to_s([cipher, password]) @return [aString];T;#0;$o;4;5F;6;;;;&I"OpenSSL::PKey::DSA#to_s;F;7[;[[@iT;F;;G;;;[;{;@;%@.;9I"static VALUE ossl_dsa_export(int argc, VALUE *argv, VALUE self) { DSA *dsa; GetDSA(self, dsa); if (DSA_HAS_PRIVATE(dsa)) return ossl_pkey_export_traditional(argc, argv, self, 0); else return ossl_pkey_export_spki(self, 0); };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@.;9I"static VALUE ossl_dsa_export(int argc, VALUE *argv, VALUE self) { DSA *dsa; GetDSA(self, dsa); if (DSA_HAS_PRIVATE(dsa)) return ossl_pkey_export_traditional(argc, argv, self, 0); else return ossl_pkey_export_spki(self, 0); };T;:@ܟ;;To;4;5F;6;;;;&I"OpenSSL::PKey::DSA#to_pem;F;7[;[[@iS;F;;L;;;[;{;@;%@.;9I"static VALUE ossl_dsa_export(int argc, VALUE *argv, VALUE self) { DSA *dsa; GetDSA(self, dsa); if (DSA_HAS_PRIVATE(dsa)) return ossl_pkey_export_traditional(argc, argv, self, 0); else return ossl_pkey_export_spki(self, 0); };T;:@ܟ@ԟo;4;5F;6;;;;&I"OpenSSL::PKey::DSA#to_der;F;7[;[[@i;T;;M;0;[;{;IC; "*Encodes this DSA to its DER encoding. ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" to_der;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" aString;T;$@;![;"I"@return [aString];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"REncodes this DSA to its DER encoding. @overload to_der @return [aString];T;#0;$@;.F;/o;0;1T;2i;3i;%@.;9I"static VALUE ossl_dsa_to_der(VALUE self) { DSA *dsa; GetDSA(self, dsa); if (DSA_HAS_PRIVATE(dsa)) return ossl_pkey_export_traditional(0, NULL, self, 1); else return ossl_pkey_export_spki(self, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKey::DSA#set_pqg;F;7[;[;F;;;;;[;{;IC; ",Sets _p_, _q_, _g_ to the DSA instance. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"set_pqg(p, q, g);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[[I"p;T0[I"q;T0[I"g;T0;$@;![;"I"ZSets _p_, _q_, _g_ to the DSA instance. @overload set_pqg(p, q, g) @return [self];T;#0;$@;.F;/o;0;1T;2i;3i";%@.;;To;4;5F;6;;;;&I"OpenSSL::PKey::DSA#set_key;F;7[;[;F;;;;;[;{;IC; "QSets _pub_key_ and _priv_key_ for the DSA instance. _priv_key_ may be +nil+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"set_key(pub_key, priv_key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@ ;![;"I"@return [self];T;#0;$@ ;.F;Bi;C0;7[[I" pub_key;T0[I" priv_key;T0;$@ ;![;"I"Sets _pub_key_ and _priv_key_ for the DSA instance. _priv_key_ may be +nil+. @overload set_key(pub_key, priv_key) @return [self];T;#0;$@ ;.F;/o;0;1T;2i&;3i*;%@.;;To;4;5F;6;;;;&I"OpenSSL::PKey::DSA#params;F;7[;[[@i ;T;;;0;[;{;IC; "{Stores all parameters of key to the hash INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!! Don't use :-)) (I's up to you) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" params;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@<;![;"I"@return [Hash];T;#0;$@<;.F;Bi;C0;7[;$@<;![;"I"Stores all parameters of key to the hash INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!! Don't use :-)) (I's up to you) @overload params @return [Hash];T;#0;$@<;.F;/o;0;1T;2i;3i;%@.;9I"Pstatic VALUE ossl_dsa_get_params(VALUE self) { DSA *dsa; VALUE hash; const BIGNUM *p, *q, *g, *pub_key, *priv_key; GetDSA(self, dsa); DSA_get0_pqg(dsa, &p, &q, &g); DSA_get0_key(dsa, &pub_key, &priv_key); hash = rb_hash_new(); rb_hash_aset(hash, rb_str_new2("p"), ossl_bn_new(p)); rb_hash_aset(hash, rb_str_new2("q"), ossl_bn_new(q)); rb_hash_aset(hash, rb_str_new2("g"), ossl_bn_new(g)); rb_hash_aset(hash, rb_str_new2("pub_key"), ossl_bn_new(pub_key)); rb_hash_aset(hash, rb_str_new2("priv_key"), ossl_bn_new(priv_key)); return hash; };T;:I"static VALUE;T;;T; @.; IC;[; @.; IC;[; @.; IC;{;IC;{;T;IC;{;T;T;{@ߟ;@ԟ;;[;[[@iC[@iI;T;:DSA;;;;;[;{;IC; "DSA, the Digital Signature Algorithm, is specified in NIST's FIPS 186-3. It is an asymmetric public key algorithm that may be used similar to e.g. RSA. ;T;[;![;"I" DSA, the Digital Signature Algorithm, is specified in NIST's FIPS 186-3. It is an asymmetric public key algorithm that may be used similar to e.g. RSA. ;T;#0;$@.;.F;/o;0;1T;2iC;3iG;%@;&I"OpenSSL::PKey::DSA;F;'@; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[ [@i[@in[@(Hi[@i[@i6;T;;;;;;;[;{;IC; " == Asymmetric Public Key Algorithms Asymmetric public key algorithms solve the problem of establishing and sharing secret keys to en-/decrypt messages. The key in such an algorithm consists of two parts: a public key that may be distributed to others and a private key that needs to remain secret. Messages encrypted with a public key can only be decrypted by recipients that are in possession of the associated private key. Since public key algorithms are considerably slower than symmetric key algorithms (cf. OpenSSL::Cipher) they are often used to establish a symmetric key shared between two parties that are in possession of each other's public key. Asymmetric algorithms offer a lot of nice features that are used in a lot of different areas. A very common application is the creation and validation of digital signatures. To sign a document, the signatory generally uses a message digest algorithm (cf. OpenSSL::Digest) to compute a digest of the document that is then encrypted (i.e. signed) using the private key. Anyone in possession of the public key may then verify the signature by computing the message digest of the original document on their own, decrypting the signature using the signatory's public key and comparing the result to the message digest they previously computed. The signature is valid if and only if the decrypted signature is equal to this message digest. The PKey module offers support for three popular public/private key algorithms: * RSA (OpenSSL::PKey::RSA) * DSA (OpenSSL::PKey::DSA) * Elliptic Curve Cryptography (OpenSSL::PKey::EC) Each of these implementations is in fact a sub-class of the abstract PKey class which offers the interface for supporting digital signatures in the form of PKey#sign and PKey#verify. == Diffie-Hellman Key Exchange Finally PKey also features OpenSSL::PKey::DH, an implementation of the Diffie-Hellman key exchange protocol based on discrete logarithms in finite fields, the same basis that DSA is built on. The Diffie-Hellman protocol can be used to exchange (symmetric) keys over insecure channels without needing any prior joint knowledge between the participating parties. As the security of DH demands relatively long "public keys" (i.e. the part that is overtly transmitted between participants) DH tends to be quite slow. If security or speed is your primary concern, OpenSSL::PKey::EC offers another implementation of the Diffie-Hellman protocol.;T;[;![;"I" == Asymmetric Public Key Algorithms Asymmetric public key algorithms solve the problem of establishing and sharing secret keys to en-/decrypt messages. The key in such an algorithm consists of two parts: a public key that may be distributed to others and a private key that needs to remain secret. Messages encrypted with a public key can only be decrypted by recipients that are in possession of the associated private key. Since public key algorithms are considerably slower than symmetric key algorithms (cf. OpenSSL::Cipher) they are often used to establish a symmetric key shared between two parties that are in possession of each other's public key. Asymmetric algorithms offer a lot of nice features that are used in a lot of different areas. A very common application is the creation and validation of digital signatures. To sign a document, the signatory generally uses a message digest algorithm (cf. OpenSSL::Digest) to compute a digest of the document that is then encrypted (i.e. signed) using the private key. Anyone in possession of the public key may then verify the signature by computing the message digest of the original document on their own, decrypting the signature using the signatory's public key and comparing the result to the message digest they previously computed. The signature is valid if and only if the decrypted signature is equal to this message digest. The PKey module offers support for three popular public/private key algorithms: * RSA (OpenSSL::PKey::RSA) * DSA (OpenSSL::PKey::DSA) * Elliptic Curve Cryptography (OpenSSL::PKey::EC) Each of these implementations is in fact a sub-class of the abstract PKey class which offers the interface for supporting digital signatures in the form of PKey#sign and PKey#verify. == Diffie-Hellman Key Exchange Finally PKey also features OpenSSL::PKey::DH, an implementation of the Diffie-Hellman key exchange protocol based on discrete logarithms in finite fields, the same basis that DSA is built on. The Diffie-Hellman protocol can be used to exchange (symmetric) keys over insecure channels without needing any prior joint knowledge between the participating parties. As the security of DH demands relatively long "public keys" (i.e. the part that is overtly transmitted between participants) DH tends to be quite slow. If security or speed is your primary concern, OpenSSL::PKey::EC offers another implementation of the Diffie-Hellman protocol. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@GH;&I"OpenSSL::PKey;Fo; ;IC;[; @~; IC;[; @~; IC;[; @~; IC;{;IC;{;T;IC;{;T;T;{;[;[[@*Hi9[@*Hi;T;: BNError;;;;;[;{;IC; "3Generic Error for all of OpenSSL::BN (big num) ;T;[;![;"I"5 Generic Error for all of OpenSSL::BN (big num) ;T;#0;$@~;.F;/o;0;1T;2i9;3i;;%o;( ;)0;*0;+0;;;%@;-@GH;0;&I"OpenSSL::BNError;F;'@Ho; ;IC;[;o;4;5F;6;;;;&I"OpenSSL::BN#initialize;F;7[[@90;[[@*Hi;T;;D;0;[;{;IC; "Construct a new \OpenSSL BIGNUM object. If +bn+ is an Integer or OpenSSL::BN, a new instance of OpenSSL::BN representing the same value is returned. See also Integer#to_bn for the short-hand. If a String is given, the content will be parsed according to +base+. +string+:: The string to be parsed. +base+:: The format. Must be one of the following: - +0+ - MPI format. See the man page BN_mpi2bn(3) for details. - +2+ - Variable-length and big-endian binary encoding of a positive number. - +10+ - Decimal number representation, with a leading '-' for a negative number. - +16+ - Hexadeciaml number representation, with a leading '-' for a negative number. ;T;[o;= ;>I" overload;F;?0;:OpenSSL::BN.new;@0;:I"OpenSSL::BN.new(bn);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"bn;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"OpenSSL::BN.new(integer);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" integer;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"'OpenSSL::BN.new(string, base = 10);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;T0[I" base;TI"10;T;$@;![;"I"Construct a new \OpenSSL BIGNUM object. If +bn+ is an Integer or OpenSSL::BN, a new instance of OpenSSL::BN representing the same value is returned. See also Integer#to_bn for the short-hand. If a String is given, the content will be parsed according to +base+. +string+:: The string to be parsed. +base+:: The format. Must be one of the following: - +0+ - MPI format. See the man page BN_mpi2bn(3) for details. - +2+ - Variable-length and big-endian binary encoding of a positive number. - +10+ - Decimal number representation, with a leading '-' for a negative number. - +16+ - Hexadeciaml number representation, with a leading '-' for a negative number. @overload OpenSSL::BN.new(bn) @overload OpenSSL::BN.new(integer) @overload OpenSSL::BN.new(string, base = 10);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_bn_initialize(int argc, VALUE *argv, VALUE self) { BIGNUM *bn; VALUE str, bs; int base = 10; char *ptr; if (rb_scan_args(argc, argv, "11", &str, &bs) == 2) { base = NUM2INT(bs); } if (NIL_P(str)) { ossl_raise(rb_eArgError, "invalid argument"); } if (RB_INTEGER_TYPE_P(str)) { GetBN(self, bn); integer_to_bnptr(str, bn); return self; } if (RTEST(rb_obj_is_kind_of(str, cBN))) { BIGNUM *other; GetBN(self, bn); GetBN(str, other); /* Safe - we checked kind_of? above */ if (!BN_copy(bn, other)) { ossl_raise(eBNError, NULL); } return self; } GetBN(self, bn); switch (base) { case 0: ptr = StringValuePtr(str); if (!BN_mpi2bn((unsigned char *)ptr, RSTRING_LENINT(str), bn)) { ossl_raise(eBNError, NULL); } break; case 2: ptr = StringValuePtr(str); if (!BN_bin2bn((unsigned char *)ptr, RSTRING_LENINT(str), bn)) { ossl_raise(eBNError, NULL); } break; case 10: if (!BN_dec2bn(&bn, StringValueCStr(str))) { ossl_raise(eBNError, NULL); } break; case 16: if (!BN_hex2bn(&bn, StringValueCStr(str))) { ossl_raise(eBNError, NULL); } break; default: ossl_raise(rb_eArgError, "invalid radix %d", base); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" OpenSSL::BN#initialize_copy;F;7[;[;F;;];;;[;{;IC; " ;T;[;![;"@;#0;$@Š;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#copy;F;7[;[;F;;;;;[;{;IC; " ;T;[;![;"@;#0;$@Π;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#num_bytes;F;7[;[;F;:num_bytes;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"num_bytes;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@נ;![;"I"@return [Integer];T;#0;$@נ;.F;Bi;C0;7[;$@נ;![;"I"- @overload num_bytes @return [Integer];T;#0;$@נ;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#num_bits;F;7[;[;F;: num_bits;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I" num_bits;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I", @overload num_bits @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#+@;F;7[;[[@*Hi;T;:+@;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;:+;@0;:I"+bn;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I" @overload +bn;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_bn_uplus(VALUE self) { VALUE obj; BIGNUM *bn1, *bn2; GetBN(self, bn1); obj = NewBN(cBN); bn2 = BN_dup(bn1); if (!bn2) ossl_raise(eBNError, "BN_dup"); SetBN(obj, bn2); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::BN#-@;F;7[;[[@*Hi;T;:-@;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;:-;@0;:I"-bn;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I" @overload -bn;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_bn_uminus(VALUE self) { VALUE obj; BIGNUM *bn1, *bn2; GetBN(self, bn1); obj = NewBN(cBN); bn2 = BN_dup(bn1); if (!bn2) ossl_raise(eBNError, "BN_dup"); SetBN(obj, bn2); BN_set_negative(bn2, !BN_is_negative(bn2)); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::BN#abs;F;7[;[[@*Hi;T;:abs;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"abs;T;IC; ";T;[;![;"I";T;#0;$@3;.F;Bi;C0;7[;$@3;![;"I" @overload abs;T;#0;$@3;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_bn_abs(VALUE self) { BIGNUM *bn1; GetBN(self, bn1); if (BN_is_negative(bn1)) { return ossl_bn_uminus(self); } else { return ossl_bn_uplus(self); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::BN#+;F;7[;[;F;;;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I" +(bn2);T;IC; ";T;[;![;"I";T;#0;$@I;.F;Bi;C0;7[[I"bn2;T0;$@I;![;"I" @overload +(bn2);T;#0;$@I;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#-;F;7[;[;F;;;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I" -(bn2);T;IC; ";T;[;![;"I";T;#0;$@^;.F;Bi;C0;7[[I"bn2;T0;$@^;![;"I" @overload -(bn2);T;#0;$@^;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#*;F;7[;[;F;:*;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I" *(bn2);T;IC; ";T;[;![;"I";T;#0;$@s;.F;Bi;C0;7[[I"bn2;T0;$@s;![;"I" @overload *(bn2);T;#0;$@s;.F;/o;0;1T;2i!;3i";%@;;To;4;5F;6;;;;&I"OpenSSL::BN#sqr;F;7[;[;F;:sqr;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"sqr;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I" @overload sqr;T;#0;$@;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#/;F;7[[I" other;T0;[[@*Hi[;T;:/;0;[;{;IC; "&Division of OpenSSL::BN instances ;T;[o;= ;>I" overload;F;?0;;;@0;:I" /(bn2);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"bn2;T0;$@;![;"I"KDivision of OpenSSL::BN instances @overload /(bn2) @return [Array];T;#0;$@;.F;/o;0;1T;2iU;3iY;%@;9I">static VALUE ossl_bn_div(VALUE self, VALUE other) { BIGNUM *bn1, *bn2 = GetBNPtr(other), *r1, *r2; VALUE klass, obj1, obj2; GetBN(self, bn1); klass = rb_obj_class(self); obj1 = NewBN(klass); obj2 = NewBN(klass); if (!(r1 = BN_new())) { ossl_raise(eBNError, NULL); } if (!(r2 = BN_new())) { BN_free(r1); ossl_raise(eBNError, NULL); } if (!BN_div(r1, r2, bn1, bn2, ossl_bn_ctx)) { BN_free(r1); BN_free(r2); ossl_raise(eBNError, NULL); } SetBN(obj1, r1); SetBN(obj2, r2); return rb_ary_new3(2, obj1, obj2); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::BN#%;F;7[;[;F;:%;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I" %(bn2);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"bn2;T0;$@;![;"I" @overload %(bn2);T;#0;$@;.F;/o;0;1T;2i(;3i);%@;;To;4;5F;6;;;;&I"OpenSSL::BN#mod_add;F;7[;[;F;: mod_add;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"mod_add(bn1, bn2);T;IC; ";T;[;![;"I";T;#0;$@ϡ;.F;Bi;C0;7[[I"bn1;T0[I"bn2;T0;$@ϡ;![;"I"! @overload mod_add(bn1, bn2);T;#0;$@ϡ;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#mod_sub;F;7[;[;F;: mod_sub;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"mod_sub(bn1, bn2);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"bn1;T0[I"bn2;T0;$@;![;"I"! @overload mod_sub(bn1, bn2);T;#0;$@;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#mod_mul;F;7[;[;F;: mod_mul;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"mod_mul(bn1, bn2);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"bn1;T0[I"bn2;T0;$@;![;"I"! @overload mod_mul(bn1, bn2);T;#0;$@;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#mod_sqr;F;7[;[;F;: mod_sqr;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"mod_sqr(bn2);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"bn2;T0;$@;![;"I" @overload mod_sqr(bn2);T;#0;$@;.F;/o;0;1T;2i=;3i>;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#**;F;7[;[;F;:**;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I" **(bn2);T;IC; ";T;[;![;"I";T;#0;$@);.F;Bi;C0;7[[I"bn2;T0;$@);![;"I" @overload **(bn2);T;#0;$@);.F;/o;0;1T;2i/;3i0;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#mod_exp;F;7[;[;F;: mod_exp;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"mod_exp(bn1, bn2);T;IC; ";T;[;![;"I";T;#0;$@>;.F;Bi;C0;7[[I"bn1;T0[I"bn2;T0;$@>;![;"I"! @overload mod_exp(bn1, bn2);T;#0;$@>;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#gcd;F;7[;[;F;:gcd;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I" gcd(bn2);T;IC; ";T;[;![;"I";T;#0;$@U;.F;Bi;C0;7[[I"bn2;T0;$@U;![;"I" @overload gcd(bn2);T;#0;$@U;.F;/o;0;1T;2i6;3i7;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#cmp;F;7[;[;F;; ;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" cmp(bn2);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@j;![;"I"@return [Integer];T;#0;$@j;.F;Bi;C0;7[[I"bn2;T0;$@j;![;"I", @overload cmp(bn2) @return [Integer];T;#0;$o;4;5F;6;;;;&I"OpenSSL::BN#<=>;F;7[;[[@*Hi;F;;Y;;;[;{;@p;%@;9I";F;:0;.F;/o;0;1T;2i;3i;%@;;T@o;4;5F;6;;;;&I"OpenSSL::BN#ucmp;F;7[;[;F;: ucmp;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ucmp(bn2);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I"bn2;T0;$@;![;"I"- @overload ucmp(bn2) @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#eql?;F;7[[I" other;T0;[[@*Hi#;T;;V;0;[;{;IC; "Returns true only if obj is a OpenSSL::BN with the same value as bn. Contrast this with OpenSSL::BN#==, which performs type conversions.;T;[o;= ;>I" overload;F;?0;;V;@0;:I"eql?(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"obj;T0;$@;![;"I"Returns true only if obj is a OpenSSL::BN with the same value as bn. Contrast this with OpenSSL::BN#==, which performs type conversions. @overload eql?(obj) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i!;Bi;%@;9I"static VALUE ossl_bn_eql(VALUE self, VALUE other) { BIGNUM *bn1, *bn2; if (!rb_obj_is_kind_of(other, cBN)) return Qfalse; GetBN(self, bn1); GetBN(other, bn2); return BN_cmp(bn1, bn2) ? Qfalse : Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::BN#hash;F;7[;[[@*Hi8;T;;X;0;[;{;IC; "@Returns a hash code for this object. See also Object#hash. ;T;[o;= ;>I" overload;F;?0;;X;@0;:I" hash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@Ţ;![;"I"@return [Integer];T;#0;$@Ţ;.F;Bi;C0;7[;$@Ţ;![;"I"eReturns a hash code for this object. See also Object#hash. @overload hash @return [Integer];T;#0;$@Ţ;.F;/o;0;1T;2i0;3i6;%@;9I"sstatic VALUE ossl_bn_hash(VALUE self) { BIGNUM *bn; VALUE tmp, hash; unsigned char *buf; int len; GetBN(self, bn); len = BN_num_bytes(bn); buf = ALLOCV(tmp, len); if (BN_bn2bin(bn, buf) != len) { ALLOCV_END(tmp); ossl_raise(eBNError, "BN_bn2bin"); } hash = ST2FIX(rb_memhash(buf, len)); ALLOCV_END(tmp); return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::BN#==;F;7[;[;F;;F;;;[;{;IC; " ;T;[;![;"@;#0;$o;4;5F;6;;;;&I"OpenSSL::BN#===;F;7[;[[@*Hi;F;;S;;;[;{;@;%@;9I";F;:0;%@;;T@o;4;5F;6;;;;&I"OpenSSL::BN#zero?;F;7[;[;F;;B;;;[;{;IC; ";T;[o;= ;>I" overload;F;?0;;B;@0;:I" zero?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I" @overload zero?;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#one?;F;7[;[;F;;;;;[;{;IC; ";T;[o;= ;>I" overload;F;?0;;;@0;:I" one?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I" @overload one?;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#odd?;F;7[;[;F;: odd?;;;[;{;IC; ";T;[o;= ;>I" overload;F;?0;;;@0;:I" odd?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I" @overload odd?;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#negative?;F;7[;[;F;:negative?;;;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@3;![;"@;#0;$@3;Bi;%@;;To;4;5F;6;;;;&I"OpenSSL::BN.rand;F;7[;[;F;;;;;[;{;IC; "7zero one value_one - DON'T IMPL. set_word get_word ;T;[;![;"I"7zero one value_one - DON'T IMPL. set_word get_word;T;#0;$@?;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"OpenSSL::BN.rand_range;F;7[[I" range;T0;[[@*HiG;T;:rand_range;0;[;{;IC; "|Generates a cryptographically strong pseudo-random number in the range 0...+range+. See also the man page BN_rand_range(3). ;T;[o;= ;>I" overload;F;?0;;;@0;:I"rand_range(range);T;IC; ";T;[;![;"I";T;#0;$@J;.F;Bi;C0;7[[I" range;T0;$@J;![;"I"Generates a cryptographically strong pseudo-random number in the range 0...+range+. See also the man page BN_rand_range(3). @overload rand_range(range);T;#0;$@J;.F;/o;0;1T;2i>;3iD;%@;9I"nstatic VALUE ossl_bn_s_rand_range(VALUE klass, VALUE range) { BIGNUM *bn = GetBNPtr(range), *result; VALUE obj = NewBN(klass); if (!(result = BN_new())) ossl_raise(eBNError, "BN_new"); if (BN_rand_range(result, bn) <= 0) { BN_free(result); ossl_raise(eBNError, "BN_rand_range"); } SetBN(obj, result); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::BN.generate_prime;F;7[[@90;[[@*Hid;T;:generate_prime;0;[;{;IC; "Generates a random prime number of bit length _bits_. If _safe_ is set to +true+, generates a safe prime. If _add_ is specified, generates a prime that fulfills condition p % add = rem. === Parameters * _bits_ - integer * _safe_ - boolean * _add_ - BN * _rem_ - BN ;T;[o;= ;>I" overload;F;?0;;;@0;:I"3generate_prime(bits, [, safe [, add [, rem]]]);T;IC; ";T;[;![;"I";T;#0;$@d;.F;Bi;C0;7[[I" bits;T0[I"[, safe [, add [, rem]]];T0;$@d;![;"I"MGenerates a random prime number of bit length _bits_. If _safe_ is set to +true+, generates a safe prime. If _add_ is specified, generates a prime that fulfills condition p % add = rem. === Parameters * _bits_ - integer * _safe_ - boolean * _add_ - BN * _rem_ - BN @overload generate_prime(bits, [, safe [, add [, rem]]]);T;#0;$@d;.F;/o;0;1T;2iV;3ia;%@;9I"static VALUE ossl_bn_s_generate_prime(int argc, VALUE *argv, VALUE klass) { BIGNUM *add = NULL, *rem = NULL, *result; int safe = 1, num; VALUE vnum, vsafe, vadd, vrem, obj; rb_scan_args(argc, argv, "13", &vnum, &vsafe, &vadd, &vrem); num = NUM2INT(vnum); if (vsafe == Qfalse) { safe = 0; } if (!NIL_P(vadd)) { add = GetBNPtr(vadd); rem = NIL_P(vrem) ? NULL : GetBNPtr(vrem); } obj = NewBN(klass); if (!(result = BN_new())) { ossl_raise(eBNError, NULL); } if (!BN_generate_prime_ex(result, num, safe, add, rem, NULL)) { BN_free(result); ossl_raise(eBNError, NULL); } SetBN(obj, result); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::BN#prime?;F;7[[@90;[[@*HiW;T;: prime?;0;[;{;IC; "Performs a Miller-Rabin probabilistic primality test for +bn+. +checks+ parameter is deprecated in version 3.0. It has no effect.;T;[o;= ;>I" overload;F;?0;;;@0;:I" prime?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"prime?(checks);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" checks;T0;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"Performs a Miller-Rabin probabilistic primality test for +bn+. +checks+ parameter is deprecated in version 3.0. It has no effect. @overload prime? @overload prime?(checks);T;#0;$@;.F;/o;0;1T;2iN;3iT;Bi;%@;9I"static VALUE ossl_bn_is_prime(int argc, VALUE *argv, VALUE self) { BIGNUM *bn; int ret; rb_check_arity(argc, 0, 1); GetBN(self, bn); #ifdef HAVE_BN_CHECK_PRIME ret = BN_check_prime(bn, ossl_bn_ctx, NULL); if (ret < 0) ossl_raise(eBNError, "BN_check_prime"); #else ret = BN_is_prime_fasttest_ex(bn, BN_prime_checks, ossl_bn_ctx, 1, NULL); if (ret < 0) ossl_raise(eBNError, "BN_is_prime_fasttest_ex"); #endif return ret ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" OpenSSL::BN#prime_fasttest?;F;7[[@90;[[@*Hix;T;:prime_fasttest?;0;[;{;IC; "Performs a Miller-Rabin probabilistic primality test for +bn+. Deprecated in version 3.0. Use #prime? instead. +checks+ and +trial_div+ parameters no longer have any effect.;T;[ o;= ;>I" overload;F;?0;;;@0;:I"prime_fasttest?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"prime_fasttest?(checks);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" checks;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"'prime_fasttest?(checks, trial_div);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" checks;T0[I"trial_div;T0;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"!Performs a Miller-Rabin probabilistic primality test for +bn+. Deprecated in version 3.0. Use #prime? instead. +checks+ and +trial_div+ parameters no longer have any effect. @overload prime_fasttest? @overload prime_fasttest?(checks) @overload prime_fasttest?(checks, trial_div);T;#0;$@;.F;/o;0;1T;2il;3iu;Bi;%@;9I"static VALUE ossl_bn_is_prime_fasttest(int argc, VALUE *argv, VALUE self) { rb_check_arity(argc, 0, 2); return ossl_bn_is_prime(0, argv, self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::BN#set_bit!;F;7[;[;F;: set_bit!;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"set_bit!(bit);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@ӣ;![;"I"@return [self];T;#0;$@ӣ;.F;Bi;C0;7[[I"bit;T0;$@ӣ;![;"I". @overload set_bit!(bit) @return [self];T;#0;$@ӣ;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#clear_bit!;F;7[;[;F;:clear_bit!;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"clear_bit!(bit);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[[I"bit;T0;$@;![;"I"0 @overload clear_bit!(bit) @return [self];T;#0;$@;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#bit_set?;F;7[;[;F;: bit_set?;;;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"@;#0;$@;Bi;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#mask_bits!;F;7[;[;F;:mask_bits!;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#<<;F;7[;[;F;;;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I" <<(bits);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" bits;T0;$@;![;"I" @overload <<(bits);T;#0;$@;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#>>;F;7[;[;F;:>>;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I" >>(bits);T;IC; ";T;[;![;"I";T;#0;$@1;.F;Bi;C0;7[[I" bits;T0;$@1;![;"I" @overload >>(bits);T;#0;$@1;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#lshift!;F;7[;[;F;: lshift!;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"lshift!(bits);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@F;![;"I"@return [self];T;#0;$@F;.F;Bi;C0;7[[I" bits;T0;$@F;![;"I". @overload lshift!(bits) @return [self];T;#0;$@F;.F;/o;0;1T;2i ;3i;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#rshift!;F;7[;[;F;: rshift!;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"rshift!(bits);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@`;![;"I"@return [self];T;#0;$@`;.F;Bi;C0;7[[I" bits;T0;$@`;![;"I". @overload rshift!(bits) @return [self];T;#0;$@`;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"OpenSSL::BN#get_flags;F;7[[I"arg;T0;[[@*Hi;T;:get_flags;0;[;{;IC; "pReturns the flags on the BN object. The argument is used as a bit mask. === Parameters * _flags_ - integer ;T;[o;= ;>I" overload;F;?0;;;@0;:I"get_flags(flags);T;IC; ";T;[;![;"I";T;#0;$@z;.F;Bi;C0;7[[I" flags;T0;$@z;![;"I"Returns the flags on the BN object. The argument is used as a bit mask. === Parameters * _flags_ - integer @overload get_flags(flags);T;#0;$@z;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_bn_get_flags(VALUE self, VALUE arg) { BIGNUM *bn; GetBN(self, bn); return INT2NUM(BN_get_flags(bn, NUM2INT(arg))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::BN#set_flags;F;7[[I"arg;T0;[[@*Hi;T;:set_flags;0;[;{;IC; "rEnables the flags on the BN object. Currently, the flags argument can contain zero of OpenSSL::BN::CONSTTIME. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"set_flags(flags);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I" flags;T0;$@;![;"I"Enables the flags on the BN object. Currently, the flags argument can contain zero of OpenSSL::BN::CONSTTIME. @overload set_flags(flags) @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_bn_set_flags(VALUE self, VALUE arg) { BIGNUM *bn; GetBN(self, bn); BN_set_flags(bn, NUM2INT(arg)); return Qnil; };T;:I"static VALUE;T;;To;u;[[@*Hi ;F;:CONSTTIME;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"OpenSSL::BN::CONSTTIME;F;xI"INT2NUM(BN_FLG_CONSTTIME);To;4;5F;6;;;;&I"OpenSSL::BN#to_s;F;7[[@90;[[@*HiL;T;;G;0;[;{;IC; "Returns the string representation of the bignum. BN.new can parse the encoded string to convert back into an OpenSSL::BN. +base+:: The format. Must be one of the following: - +0+ - MPI format. See the man page BN_bn2mpi(3) for details. - +2+ - Variable-length and big-endian binary encoding. The sign of the bignum is ignored. - +10+ - Decimal number representation, with a leading '-' for a negative bignum. - +16+ - Hexadeciaml number representation, with a leading '-' for a negative bignum. ;T;[o;= ;>I" overload;F;?0;;G;@0;:I"to_s(base = 10);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I" base;TI"10;T;$@;![;"I"7Returns the string representation of the bignum. BN.new can parse the encoded string to convert back into an OpenSSL::BN. +base+:: The format. Must be one of the following: - +0+ - MPI format. See the man page BN_bn2mpi(3) for details. - +2+ - Variable-length and big-endian binary encoding. The sign of the bignum is ignored. - +10+ - Decimal number representation, with a leading '-' for a negative bignum. - +16+ - Hexadeciaml number representation, with a leading '-' for a negative bignum. @overload to_s(base = 10) @return [String];T;#0;$@;.F;/o;0;1T;2i:;3iJ;%@;9I"static VALUE ossl_bn_to_s(int argc, VALUE *argv, VALUE self) { BIGNUM *bn; VALUE str, bs; int base = 10, len; char *buf; if (rb_scan_args(argc, argv, "01", &bs) == 1) { base = NUM2INT(bs); } GetBN(self, bn); switch (base) { case 0: len = BN_bn2mpi(bn, NULL); str = rb_str_new(0, len); if (BN_bn2mpi(bn, (unsigned char *)RSTRING_PTR(str)) != len) ossl_raise(eBNError, NULL); break; case 2: len = BN_num_bytes(bn); str = rb_str_new(0, len); if (BN_bn2bin(bn, (unsigned char *)RSTRING_PTR(str)) != len) ossl_raise(eBNError, NULL); break; case 10: if (!(buf = BN_bn2dec(bn))) ossl_raise(eBNError, NULL); str = ossl_buf2str(buf, rb_long2int(strlen(buf))); break; case 16: if (!(buf = BN_bn2hex(bn))) ossl_raise(eBNError, NULL); str = ossl_buf2str(buf, rb_long2int(strlen(buf))); break; default: ossl_raise(rb_eArgError, "invalid radix %d", base); } return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::BN#to_i;F;7[;[[@*Hix;T;;;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_i;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ܤ;![;"I"@return [Integer];T;#0;$@ܤ;.F;Bi;C0;7[;$@ܤ;![;"I"( @overload to_i @return [Integer];T;#0;$o;4;5F;6;;;;&I"OpenSSL::BN#to_int;F;7[;[[@*Hi%;F;: to_int;;;[;{;@;%@;9I"static VALUE ossl_bn_to_i(VALUE self) { BIGNUM *bn; char *txt; VALUE num; GetBN(self, bn); if (!(txt = BN_bn2hex(bn))) { ossl_raise(eBNError, NULL); } num = rb_cstr_to_inum(txt, 16, Qtrue); OPENSSL_free(txt); return num; };T;:I"static VALUE;T;.F;/o;0;1T;2it;3iv;%@;9I"static VALUE ossl_bn_to_i(VALUE self) { BIGNUM *bn; char *txt; VALUE num; GetBN(self, bn); if (!(txt = BN_bn2hex(bn))) { ossl_raise(eBNError, NULL); } num = rb_cstr_to_inum(txt, 16, Qtrue); OPENSSL_free(txt); return num; };T;:@;;T@o;4;5F;6;;;;&I"OpenSSL::BN#to_bn;F;7[;[[@*Hi;T;: to_bn;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"@static VALUE ossl_bn_to_bn(VALUE self) { return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::BN#coerce;F;7[[I" other;T0;[[@*Hi;T;: coerce;0;[;{;IC; " ;T;[;![;"@;#0;$@ ;%@;9I"static VALUE ossl_bn_coerce(VALUE self, VALUE other) { switch(TYPE(other)) { case T_STRING: self = ossl_bn_to_s(0, NULL, self); break; case T_FIXNUM: case T_BIGNUM: self = ossl_bn_to_i(self); break; default: if (!RTEST(rb_obj_is_kind_of(other, cBN))) { ossl_raise(rb_eTypeError, "Don't know how to coerce"); } } return rb_assoc_new(other, self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::BN#mod_inverse;F;7[;[;F;:mod_inverse;;;[;{;IC; ">TODO: But how to: from_bin, from_mpi? PACK? to_bin to_mpi ;T;[;![;"I"?TODO: But how to: from_bin, from_mpi? PACK? to_bin to_mpi ;T;#0;$@;.F;/o;0;1T;2i);3i-;%@;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{@; @;F@;;[;[[@*Hi;F;:BN;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@GH;&I"OpenSSL::BN;F;'@o; ;IC;[o; ;IC;[; @5; IC;[; @5; IC;[; @5; IC;{;IC;{;T;IC;{;T;T;{;[;[[@,Hi;F;:CipherError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@5;%@3;&I"!OpenSSL::Cipher::CipherError;F;'@Ho;4;5F;6;;;;&I"$OpenSSL::Cipher#initialize_copy;F;7[[I" other;T0;[[@,Hi;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@F;%@3;9I"istatic VALUE ossl_cipher_copy(VALUE self, VALUE other) { EVP_CIPHER_CTX *ctx1, *ctx2; rb_check_frozen(self); if (self == other) return self; GetCipherInit(self, ctx1); if (!ctx1) { AllocCipher(self, ctx1); } GetCipher(other, ctx2); if (EVP_CIPHER_CTX_copy(ctx1, ctx2) != 1) ossl_raise(eCipherError, NULL); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Cipher#ciphers;F;7[;[[@,Hi;T;;t;0;[;{;IC; "I" overload;F;?0;:OpenSSL::Cipher.ciphers;@0;:I"OpenSSL::Cipher.ciphers;T;IC; ";T;[;![;"I";T;#0;$@T;.F;Bi;C0;7[;$@T;![;"I"_Returns the names of all available ciphers in an array. @overload OpenSSL::Cipher.ciphers ;T;#0;$@T;.F;C0;%@3;9I"static VALUE ossl_s_ciphers(VALUE self) { VALUE ary; ary = rb_ary_new(); OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH, add_cipher_name_to_ary, (void*)ary); return ary; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"OpenSSL::Cipher.ciphers;F;7@V;@W;T;;t;0;@Y;{;IC; "I" overload;F;?0;;;@0;:I"OpenSSL::Cipher.ciphers;T;IC; ";T;[;![;"I";T;#0;$@i;.F;Bi;C0;7[;$@i;![;"I"`Returns the names of all available ciphers in an array. @overload OpenSSL::Cipher.ciphers;T;#0;$@i;.F;/o;0;1T;2i;3i;Bi;%@3;9@g;:@h;;To;4;5F;6;;;;&I"OpenSSL::Cipher#initialize;F;7[[I"str;T0;[[@,Hit;T;;D;0;[;{;IC; "The string must contain a valid cipher name like "aes-256-cbc". A list of cipher names is available by calling OpenSSL::Cipher.ciphers. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(string);T;IC; ";T;[;![;"I";T;#0;$@y;.F;Bi;C0;7[[I" string;T0;$@y;![;"I"The string must contain a valid cipher name like "aes-256-cbc". A list of cipher names is available by calling OpenSSL::Cipher.ciphers. @overload new(string);T;#0;$@y;.F;/o;0;1T;2il;3iq;%@3;9I"5static VALUE ossl_cipher_initialize(VALUE self, VALUE str) { EVP_CIPHER_CTX *ctx; const EVP_CIPHER *cipher; char *name; name = StringValueCStr(str); GetCipherInit(self, ctx); if (ctx) { ossl_raise(rb_eRuntimeError, "Cipher already initialized!"); } AllocCipher(self, ctx); if (!(cipher = EVP_get_cipherbyname(name))) { ossl_raise(rb_eRuntimeError, "unsupported cipher algorithm (%"PRIsVALUE")", str); } if (EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, -1) != 1) ossl_raise(eCipherError, NULL); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Cipher#reset;F;7[;[[@,Hi;T;;;0;[;{;IC; "Fully resets the internal state of the Cipher. By using this, the same Cipher instance may be used several times for encryption or decryption tasks. Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, -1). ;T;[o;= ;>I" overload;F;?0;;;@0;:I" reset;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Fully resets the internal state of the Cipher. By using this, the same Cipher instance may be used several times for encryption or decryption tasks. Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, -1). @overload reset @return [self];T;#0;$@;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE ossl_cipher_reset(VALUE self) { EVP_CIPHER_CTX *ctx; GetCipher(self, ctx); if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, -1) != 1) ossl_raise(eCipherError, NULL); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Cipher#encrypt;F;7[[@90;[[@,Hi;T;;8;0;[;{;IC; "Initializes the Cipher for encryption. Make sure to call Cipher#encrypt or Cipher#decrypt before using any of the following methods: * [#key=, #iv=, #random_key, #random_iv, #pkcs5_keyivgen] Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, 1). ;T;[o;= ;>I" overload;F;?0;;8;@0;:I" encrypt;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[;$@;![;"I")Initializes the Cipher for encryption. Make sure to call Cipher#encrypt or Cipher#decrypt before using any of the following methods: * [#key=, #iv=, #random_key, #random_iv, #pkcs5_keyivgen] Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, 1). @overload encrypt @return [self];T;#0;$@;.F;/o;0;1T;2i;3i;%@3;9I"~static VALUE ossl_cipher_encrypt(int argc, VALUE *argv, VALUE self) { return ossl_cipher_init(argc, argv, self, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Cipher#decrypt;F;7[[@90;[[@,Hi;T;;K;0;[;{;IC; "Initializes the Cipher for decryption. Make sure to call Cipher#encrypt or Cipher#decrypt before using any of the following methods: * [#key=, #iv=, #random_key, #random_iv, #pkcs5_keyivgen] Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, 0). ;T;[o;= ;>I" overload;F;?0;;K;@0;:I" decrypt;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@ʥ;![;"I"@return [self];T;#0;$@ʥ;.F;Bi;C0;7[;$@ʥ;![;"I")Initializes the Cipher for decryption. Make sure to call Cipher#encrypt or Cipher#decrypt before using any of the following methods: * [#key=, #iv=, #random_key, #random_iv, #pkcs5_keyivgen] Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, 0). @overload decrypt @return [self];T;#0;$@ʥ;.F;/o;0;1T;2i;3i;%@3;9I"~static VALUE ossl_cipher_decrypt(int argc, VALUE *argv, VALUE self) { return ossl_cipher_init(argc, argv, self, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::Cipher#pkcs5_keyivgen;F;7[[@90;[[@,Hi-;T;:pkcs5_keyivgen;0;[;{;IC; "CGenerates and sets the key/IV based on a password. *WARNING*: This method is only PKCS5 v1.5 compliant when using RC2, RC4-40, or DES with MD5 or SHA1. Using anything else (like AES) will generate the key/iv using an OpenSSL specific method. This method is deprecated and should no longer be used. Use a PKCS5 v2 key generation method from OpenSSL::PKCS5 instead. === Parameters * _salt_ must be an 8 byte string if provided. * _iterations_ is an integer with a default of 2048. * _digest_ is a Digest object that defaults to 'MD5' A minimum of 1000 iterations is recommended. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"Hpkcs5_keyivgen(pass, salt = nil, iterations = 2048, digest = "MD5");T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[ [I" pass;T0[I" salt;TI"nil;T[I"iterations;TI" 2048;T[I" digest;TI" "MD5";T;$@;![;"I"Generates and sets the key/IV based on a password. *WARNING*: This method is only PKCS5 v1.5 compliant when using RC2, RC4-40, or DES with MD5 or SHA1. Using anything else (like AES) will generate the key/iv using an OpenSSL specific method. This method is deprecated and should no longer be used. Use a PKCS5 v2 key generation method from OpenSSL::PKCS5 instead. === Parameters * _salt_ must be an 8 byte string if provided. * _iterations_ is an integer with a default of 2048. * _digest_ is a Digest object that defaults to 'MD5' A minimum of 1000 iterations is recommended. @overload pkcs5_keyivgen(pass, salt = nil, iterations = 2048, digest = "MD5") @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i+;%@3;9I"static VALUE ossl_cipher_pkcs5_keyivgen(int argc, VALUE *argv, VALUE self) { EVP_CIPHER_CTX *ctx; const EVP_MD *digest; VALUE vpass, vsalt, viter, vdigest; unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH], *salt = NULL; int iter; rb_scan_args(argc, argv, "13", &vpass, &vsalt, &viter, &vdigest); StringValue(vpass); if(!NIL_P(vsalt)){ StringValue(vsalt); if(RSTRING_LEN(vsalt) != PKCS5_SALT_LEN) ossl_raise(eCipherError, "salt must be an 8-octet string"); salt = (unsigned char *)RSTRING_PTR(vsalt); } iter = NIL_P(viter) ? 2048 : NUM2INT(viter); if (iter <= 0) rb_raise(rb_eArgError, "iterations must be a positive integer"); digest = NIL_P(vdigest) ? EVP_md5() : ossl_evp_get_digestbyname(vdigest); GetCipher(self, ctx); EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), digest, salt, (unsigned char *)RSTRING_PTR(vpass), RSTRING_LENINT(vpass), iter, key, iv); if (EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, -1) != 1) ossl_raise(eCipherError, NULL); OPENSSL_cleanse(key, sizeof key); OPENSSL_cleanse(iv, sizeof iv); rb_ivar_set(self, id_key_set, Qtrue); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Cipher#update;F;7[[@90;[[@,Hit;T;; ;0;[;{;IC; "^Encrypts data in a streaming fashion. Hand consecutive blocks of data to the #update method in order to encrypt it. Returns the encrypted data chunk. When done, the output of Cipher#final should be additionally added to the result. If _buffer_ is given, the encryption/decryption result will be written to it. _buffer_ will be resized automatically. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"update(data [, buffer]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[[I"data[, buffer];T0;$@ ;![;"I"Encrypts data in a streaming fashion. Hand consecutive blocks of data to the #update method in order to encrypt it. Returns the encrypted data chunk. When done, the output of Cipher#final should be additionally added to the result. If _buffer_ is given, the encryption/decryption result will be written to it. _buffer_ will be resized automatically. @overload update(data [, buffer]) @return [String];T;#0;$@ ;.F;/o;0;1T;2ih;3ir;%@3;9I"static VALUE ossl_cipher_update(int argc, VALUE *argv, VALUE self) { EVP_CIPHER_CTX *ctx; unsigned char *in; long in_len, out_len; VALUE data, str; rb_scan_args(argc, argv, "11", &data, &str); if (!RTEST(rb_attr_get(self, id_key_set))) ossl_raise(eCipherError, "key not set"); StringValue(data); in = (unsigned char *)RSTRING_PTR(data); if ((in_len = RSTRING_LEN(data)) == 0) ossl_raise(rb_eArgError, "data must not be empty"); GetCipher(self, ctx); out_len = in_len+EVP_CIPHER_CTX_block_size(ctx); if (out_len <= 0) { ossl_raise(rb_eRangeError, "data too big to make output buffer: %ld bytes", in_len); } if (NIL_P(str)) { str = rb_str_new(0, out_len); } else { StringValue(str); rb_str_resize(str, out_len); } if (!ossl_cipher_update_long(ctx, (unsigned char *)RSTRING_PTR(str), &out_len, in, in_len)) ossl_raise(eCipherError, NULL); assert(out_len < RSTRING_LEN(str)); rb_str_set_len(str, out_len); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Cipher#final;F;7[;[[@,Hi;T;: final;0;[;{;IC; "Returns the remaining data held in the cipher object. Further calls to Cipher#update or Cipher#final will return garbage. This call should always be made as the last call of an encryption or decryption operation, after having fed the entire plaintext or ciphertext to the Cipher instance. If an authenticated cipher was used, a CipherError is raised if the tag could not be authenticated successfully. Only call this method after setting the authentication tag and passing the entire contents of the ciphertext into the cipher. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" final;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@+;![;"I"@return [String];T;#0;$@+;.F;Bi;C0;7[;$@+;![;"I"5Returns the remaining data held in the cipher object. Further calls to Cipher#update or Cipher#final will return garbage. This call should always be made as the last call of an encryption or decryption operation, after having fed the entire plaintext or ciphertext to the Cipher instance. If an authenticated cipher was used, a CipherError is raised if the tag could not be authenticated successfully. Only call this method after setting the authentication tag and passing the entire contents of the ciphertext into the cipher. @overload final @return [String];T;#0;$@+;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE ossl_cipher_final(VALUE self) { EVP_CIPHER_CTX *ctx; int out_len; VALUE str; GetCipher(self, ctx); str = rb_str_new(0, EVP_CIPHER_CTX_block_size(ctx)); if (!EVP_CipherFinal_ex(ctx, (unsigned char *)RSTRING_PTR(str), &out_len)) ossl_raise(eCipherError, NULL); assert(out_len <= RSTRING_LEN(str)); rb_str_set_len(str, out_len); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Cipher#name;F;7[;[[@,Hi;T;;F;0;[;{;IC; "^Returns the name of the cipher which may differ slightly from the original name provided. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I" name;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@F;![;"I"@return [String];T;#0;$@F;.F;Bi;C0;7[;$@F;![;"I"}Returns the name of the cipher which may differ slightly from the original name provided. @overload name @return [String];T;#0;$@F;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE ossl_cipher_name(VALUE self) { EVP_CIPHER_CTX *ctx; GetCipher(self, ctx); return rb_str_new2(EVP_CIPHER_name(EVP_CIPHER_CTX_cipher(ctx))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Cipher#key=;F;7[[I"key;T0;[[@,Hi;T;: key=;0;[;{;IC; "[Sets the cipher key. To generate a key, you should either use a secure random byte string or, if the key is to be derived from a password, you should rely on PBKDF2 functionality provided by OpenSSL::PKCS5. To generate a secure random-based key, Cipher#random_key may be used. Only call this method after calling Cipher#encrypt or Cipher#decrypt. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"key=(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@a;![;"I"@return [String];T;#0;$@a;.F;Bi;C0;7[[I" string;T0;$@a;![;"I"Sets the cipher key. To generate a key, you should either use a secure random byte string or, if the key is to be derived from a password, you should rely on PBKDF2 functionality provided by OpenSSL::PKCS5. To generate a secure random-based key, Cipher#random_key may be used. Only call this method after calling Cipher#encrypt or Cipher#decrypt. @overload key=(string) @return [String];T;#0;$@a;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE ossl_cipher_set_key(VALUE self, VALUE key) { EVP_CIPHER_CTX *ctx; int key_len; StringValue(key); GetCipher(self, ctx); key_len = EVP_CIPHER_CTX_key_length(ctx); if (RSTRING_LEN(key) != key_len) ossl_raise(rb_eArgError, "key must be %d bytes", key_len); if (EVP_CipherInit_ex(ctx, NULL, NULL, (unsigned char *)RSTRING_PTR(key), NULL, -1) != 1) ossl_raise(eCipherError, NULL); rb_ivar_set(self, id_key_set, Qtrue); return key; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Cipher#auth_data=;F;7[[I" data;T0;[[@,Hi0;T;:auth_data=;0;[;{;IC; "Sets the cipher's additional authenticated data. This field must be set when using AEAD cipher modes such as GCM or CCM. If no associated data shall be used, this method must *still* be called with a value of "". The contents of this field should be non-sensitive data which will be added to the ciphertext to generate the authentication tag which validates the contents of the ciphertext. The AAD must be set prior to encryption or decryption. In encryption mode, it must be set after calling Cipher#encrypt and setting Cipher#key= and Cipher#iv=. When decrypting, the authenticated data must be set after key, iv and especially *after* the authentication tag has been set. I.e. set it only after calling Cipher#decrypt, Cipher#key=, Cipher#iv= and Cipher#auth_tag= first. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"auth_data=(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I" string;T0;$@;![;"I"8Sets the cipher's additional authenticated data. This field must be set when using AEAD cipher modes such as GCM or CCM. If no associated data shall be used, this method must *still* be called with a value of "". The contents of this field should be non-sensitive data which will be added to the ciphertext to generate the authentication tag which validates the contents of the ciphertext. The AAD must be set prior to encryption or decryption. In encryption mode, it must be set after calling Cipher#encrypt and setting Cipher#key= and Cipher#iv=. When decrypting, the authenticated data must be set after key, iv and especially *after* the authentication tag has been set. I.e. set it only after calling Cipher#decrypt, Cipher#key=, Cipher#iv= and Cipher#auth_tag= first. @overload auth_data=(string) @return [String];T;#0;$@;.F;/o;0;1T;2i;3i.;%@3;9I"Istatic VALUE ossl_cipher_set_auth_data(VALUE self, VALUE data) { EVP_CIPHER_CTX *ctx; unsigned char *in; long in_len, out_len; StringValue(data); in = (unsigned char *) RSTRING_PTR(data); in_len = RSTRING_LEN(data); GetCipher(self, ctx); if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER)) ossl_raise(eCipherError, "AEAD not supported by this cipher"); if (!ossl_cipher_update_long(ctx, NULL, &out_len, in, in_len)) ossl_raise(eCipherError, "couldn't set additional authenticated data"); return data; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Cipher#auth_tag=;F;7[[I" vtag;T0;[[@,Hi{;T;:auth_tag=;0;[;{;IC; "Sets the authentication tag to verify the integrity of the ciphertext. This can be called only when the cipher supports AE. The tag must be set after calling Cipher#decrypt, Cipher#key= and Cipher#iv=, but before calling Cipher#final. After all decryption is performed, the tag is verified automatically in the call to Cipher#final. For OCB mode, the tag length must be supplied with #auth_tag_len= beforehand. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"auth_tag=(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I" string;T0;$@;![;"I"Sets the authentication tag to verify the integrity of the ciphertext. This can be called only when the cipher supports AE. The tag must be set after calling Cipher#decrypt, Cipher#key= and Cipher#iv=, but before calling Cipher#final. After all decryption is performed, the tag is verified automatically in the call to Cipher#final. For OCB mode, the tag length must be supplied with #auth_tag_len= beforehand. @overload auth_tag=(string) @return [String];T;#0;$@;.F;/o;0;1T;2in;3iy;%@3;9I"<static VALUE ossl_cipher_set_auth_tag(VALUE self, VALUE vtag) { EVP_CIPHER_CTX *ctx; unsigned char *tag; int tag_len; StringValue(vtag); tag = (unsigned char *) RSTRING_PTR(vtag); tag_len = RSTRING_LENINT(vtag); GetCipher(self, ctx); if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER)) ossl_raise(eCipherError, "authentication tag not supported by this cipher"); if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tag_len, tag)) ossl_raise(eCipherError, "unable to set AEAD tag"); return vtag; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Cipher#auth_tag;F;7[[@90;[[@,HiU;T;: auth_tag;0;[;{;IC; "KGets the authentication tag generated by Authenticated Encryption Cipher modes (GCM for example). This tag may be stored along with the ciphertext, then set on the decryption cipher to authenticate the contents of the ciphertext against changes. If the optional integer parameter _tag_len_ is given, the returned tag will be _tag_len_ bytes long. If the parameter is omitted, the default length of 16 bytes or the length previously set by #auth_tag_len= will be used. For maximum security, the longest possible should be chosen. The tag may only be retrieved after calling Cipher#final. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"auth_tag(tag_len = 16);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I" tag_len;TI"16;T;$@;![;"I"Gets the authentication tag generated by Authenticated Encryption Cipher modes (GCM for example). This tag may be stored along with the ciphertext, then set on the decryption cipher to authenticate the contents of the ciphertext against changes. If the optional integer parameter _tag_len_ is given, the returned tag will be _tag_len_ bytes long. If the parameter is omitted, the default length of 16 bytes or the length previously set by #auth_tag_len= will be used. For maximum security, the longest possible should be chosen. The tag may only be retrieved after calling Cipher#final. @overload auth_tag(tag_len = 16) @return [String];T;#0;$@;.F;/o;0;1T;2iF;3iS;%@3;9I"static VALUE ossl_cipher_get_auth_tag(int argc, VALUE *argv, VALUE self) { VALUE vtag_len, ret; EVP_CIPHER_CTX *ctx; int tag_len = 16; rb_scan_args(argc, argv, "01", &vtag_len); if (NIL_P(vtag_len)) vtag_len = rb_attr_get(self, id_auth_tag_len); if (!NIL_P(vtag_len)) tag_len = NUM2INT(vtag_len); GetCipher(self, ctx); if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER)) ossl_raise(eCipherError, "authentication tag not supported by this cipher"); ret = rb_str_new(NULL, tag_len); if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, tag_len, RSTRING_PTR(ret))) ossl_raise(eCipherError, "retrieving the authentication tag failed"); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::Cipher#auth_tag_len=;F;7[[I" vlen;T0;[[@,Hi;T;:auth_tag_len=;0;[;{;IC; ".Sets the length of the authentication tag to be generated or to be given for AEAD ciphers that requires it as in input parameter. Note that not all AEAD ciphers support this method. In OCB mode, the length must be supplied both when encrypting and when decrypting, and must be before specifying an IV. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"auth_tag_len=(Integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ݦ;![;"I"@return [Integer];T;#0;$@ݦ;.F;Bi;C0;7[[I" Integer;T0;$@ݦ;![;"I"eSets the length of the authentication tag to be generated or to be given for AEAD ciphers that requires it as in input parameter. Note that not all AEAD ciphers support this method. In OCB mode, the length must be supplied both when encrypting and when decrypting, and must be before specifying an IV. @overload auth_tag_len=(Integer) @return [Integer];T;#0;$@ݦ;.F;/o;0;1T;2i;3i;%@3;9I"$static VALUE ossl_cipher_set_auth_tag_len(VALUE self, VALUE vlen) { int tag_len = NUM2INT(vlen); EVP_CIPHER_CTX *ctx; GetCipher(self, ctx); if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER)) ossl_raise(eCipherError, "AEAD not supported by this cipher"); if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tag_len, NULL)) ossl_raise(eCipherError, "unable to set authentication tag length"); /* for #auth_tag */ rb_ivar_set(self, id_auth_tag_len, INT2NUM(tag_len)); return vlen; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::Cipher#authenticated?;F;7[;[[@,Hi;T;:authenticated?;0;[;{;IC; "RIndicated whether this Cipher instance uses an Authenticated Encryption mode.;T;[o;= ;>I" overload;F;?0;;;@0;:I"authenticated?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"mIndicated whether this Cipher instance uses an Authenticated Encryption mode. @overload authenticated?;T;#0;$@;.F;/o;0;1T;2i ;3i;Bi;%@3;9I"static VALUE ossl_cipher_is_authenticated(VALUE self) { EVP_CIPHER_CTX *ctx; GetCipher(self, ctx); return (EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Cipher#key_len=;F;7[[I"key_length;T0;[[@,Hi;T;: key_len=;0;[;{;IC; ";Sets the key length of the cipher. If the cipher is a fixed length cipher then attempting to set the key length to any value other than the fixed value is an error. Under normal circumstances you do not need to call this method (and probably shouldn't). See EVP_CIPHER_CTX_set_key_length for further information. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"key_len=(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I" integer;T0;$@;![;"I"mSets the key length of the cipher. If the cipher is a fixed length cipher then attempting to set the key length to any value other than the fixed value is an error. Under normal circumstances you do not need to call this method (and probably shouldn't). See EVP_CIPHER_CTX_set_key_length for further information. @overload key_len=(integer) @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE ossl_cipher_set_key_length(VALUE self, VALUE key_length) { int len = NUM2INT(key_length); EVP_CIPHER_CTX *ctx; GetCipher(self, ctx); if (EVP_CIPHER_CTX_set_key_length(ctx, len) != 1) ossl_raise(eCipherError, NULL); return key_length; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Cipher#key_len;F;7[;[[@,Hi;T;: key_len;0;[;{;IC; "3Returns the key length in bytes of the Cipher. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" key_len;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@4;![;"I"@return [Integer];T;#0;$@4;.F;Bi;C0;7[;$@4;![;"I"[Returns the key length in bytes of the Cipher. @overload key_len @return [Integer];T;#0;$@4;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE ossl_cipher_key_length(VALUE self) { EVP_CIPHER_CTX *ctx; GetCipher(self, ctx); return INT2NUM(EVP_CIPHER_CTX_key_length(ctx)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Cipher#iv=;F;7[[I"iv;T0;[[@,Hi;T;:iv=;0;[;{;IC; "Sets the cipher IV. Please note that since you should never be using ECB mode, an IV is always explicitly required and should be set prior to encryption. The IV itself can be safely transmitted in public, but it should be unpredictable to prevent certain kinds of attacks. You may use Cipher#random_iv to create a secure random IV. Only call this method after calling Cipher#encrypt or Cipher#decrypt. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"iv=(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@O;![;"I"@return [String];T;#0;$@O;.F;Bi;C0;7[[I" string;T0;$@O;![;"I"Sets the cipher IV. Please note that since you should never be using ECB mode, an IV is always explicitly required and should be set prior to encryption. The IV itself can be safely transmitted in public, but it should be unpredictable to prevent certain kinds of attacks. You may use Cipher#random_iv to create a secure random IV. Only call this method after calling Cipher#encrypt or Cipher#decrypt. @overload iv=(string) @return [String];T;#0;$@O;.F;/o;0;1T;2i;3i;%@3;9I"Gstatic VALUE ossl_cipher_set_iv(VALUE self, VALUE iv) { EVP_CIPHER_CTX *ctx; int iv_len = 0; StringValue(iv); GetCipher(self, ctx); if (EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER) iv_len = (int)(VALUE)EVP_CIPHER_CTX_get_app_data(ctx); if (!iv_len) iv_len = EVP_CIPHER_CTX_iv_length(ctx); if (RSTRING_LEN(iv) != iv_len) ossl_raise(rb_eArgError, "iv must be %d bytes", iv_len); if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, (unsigned char *)RSTRING_PTR(iv), -1) != 1) ossl_raise(eCipherError, NULL); return iv; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Cipher#iv_len=;F;7[[I"iv_length;T0;[[@,Hi;T;: iv_len=;0;[;{;IC; "Sets the IV/nonce length of the Cipher. Normally block ciphers don't allow changing the IV length, but some make use of IV for 'nonce'. You may need this for interoperability with other applications. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"iv_len=(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@n;![;"I"@return [Integer];T;#0;$@n;.F;Bi;C0;7[[I" integer;T0;$@n;![;"I"Sets the IV/nonce length of the Cipher. Normally block ciphers don't allow changing the IV length, but some make use of IV for 'nonce'. You may need this for interoperability with other applications. @overload iv_len=(integer) @return [Integer];T;#0;$@n;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE ossl_cipher_set_iv_length(VALUE self, VALUE iv_length) { int len = NUM2INT(iv_length); EVP_CIPHER_CTX *ctx; GetCipher(self, ctx); if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER)) ossl_raise(eCipherError, "cipher does not support AEAD"); if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, len, NULL)) ossl_raise(eCipherError, "unable to set IV length"); /* * EVP_CIPHER_CTX_iv_length() returns the default length. So we need to save * the length somewhere. Luckily currently we aren't using app_data. */ EVP_CIPHER_CTX_set_app_data(ctx, (void *)(VALUE)len); return iv_length; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Cipher#iv_len;F;7[;[[@,Hi;T;: iv_len;0;[;{;IC; "DReturns the expected length in bytes for an IV for this Cipher. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" iv_len;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"kReturns the expected length in bytes for an IV for this Cipher. @overload iv_len @return [Integer];T;#0;$@;.F;/o;0;1T;2i ;3i;%@3;9I"Lstatic VALUE ossl_cipher_iv_length(VALUE self) { EVP_CIPHER_CTX *ctx; int len = 0; GetCipher(self, ctx); if (EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER) len = (int)(VALUE)EVP_CIPHER_CTX_get_app_data(ctx); if (!len) len = EVP_CIPHER_CTX_iv_length(ctx); return INT2NUM(len); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Cipher#block_size;F;7[;[[@,Hi&;T;:block_size;0;[;{;IC; "NReturns the size in bytes of the blocks on which this Cipher operates on. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"block_size;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"yReturns the size in bytes of the blocks on which this Cipher operates on. @overload block_size @return [Integer];T;#0;$@;.F;/o;0;1T;2i ;3i$;%@3;9I"static VALUE ossl_cipher_block_size(VALUE self) { EVP_CIPHER_CTX *ctx; GetCipher(self, ctx); return INT2NUM(EVP_CIPHER_CTX_block_size(ctx)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Cipher#padding=;F;7[[I" padding;T0;[[@,Hi;T;: padding=;0;[;{;IC; "Enables or disables padding. By default encryption operations are padded using standard block padding and the padding is checked and removed when decrypting. If the pad parameter is zero then no padding is performed, the total amount of data encrypted or decrypted must then be a multiple of the block size or an error will occur. See EVP_CIPHER_CTX_set_padding for further information. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"padding=(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ç;![;"I"@return [Integer];T;#0;$@ç;.F;Bi;C0;7[[I" integer;T0;$@ç;![;"I"Enables or disables padding. By default encryption operations are padded using standard block padding and the padding is checked and removed when decrypting. If the pad parameter is zero then no padding is performed, the total amount of data encrypted or decrypted must then be a multiple of the block size or an error will occur. See EVP_CIPHER_CTX_set_padding for further information. @overload padding=(integer) @return [Integer];T;#0;$@ç;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE ossl_cipher_set_padding(VALUE self, VALUE padding) { EVP_CIPHER_CTX *ctx; int pad = NUM2INT(padding); GetCipher(self, ctx); if (EVP_CIPHER_CTX_set_padding(ctx, pad) != 1) ossl_raise(eCipherError, NULL); return padding; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""OpenSSL::Cipher#ccm_data_len=;F;7[[I" data_len;T0;[[@,Hi:;T;:ccm_data_len=;0;[;{;IC; "Sets the length of the plaintext / ciphertext message that will be processed in CCM mode. Make sure to call this method after #key= and #iv= have been set, and before #auth_data=. Only call this method after calling Cipher#encrypt or Cipher#decrypt. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"ccm_data_len=(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I" integer;T0;$@;![;"I"1Sets the length of the plaintext / ciphertext message that will be processed in CCM mode. Make sure to call this method after #key= and #iv= have been set, and before #auth_data=. Only call this method after calling Cipher#encrypt or Cipher#decrypt. @overload ccm_data_len=(integer) @return [Integer];T;#0;$@;.F;/o;0;1T;2i0;3i8;%@3;9I"7static VALUE ossl_cipher_set_ccm_data_len(VALUE self, VALUE data_len) { int in_len, out_len; EVP_CIPHER_CTX *ctx; in_len = NUM2INT(data_len); GetCipher(self, ctx); if (EVP_CipherUpdate(ctx, NULL, &out_len, NULL, in_len) != 1) ossl_raise(eCipherError, NULL); return data_len; };T;:I"static VALUE;T;;T; @3; IC;[; @3; IC;[; @3; IC;{;IC;{;T;IC;{;T;T;{;[;[[@,HiT[@,Hi;T;: Cipher;;;;;[;{;IC; "Provides symmetric algorithms for encryption and decryption. The algorithms that are available depend on the particular version of OpenSSL that is installed. === Listing all supported algorithms A list of supported algorithms can be obtained by puts OpenSSL::Cipher.ciphers === Instantiating a Cipher There are several ways to create a Cipher instance. Generally, a Cipher algorithm is categorized by its name, the key length in bits and the cipher mode to be used. The most generic way to create a Cipher is the following cipher = OpenSSL::Cipher.new('--') That is, a string consisting of the hyphenated concatenation of the individual components name, key length and mode. Either all uppercase or all lowercase strings may be used, for example: cipher = OpenSSL::Cipher.new('aes-128-cbc') === Choosing either encryption or decryption mode Encryption and decryption are often very similar operations for symmetric algorithms, this is reflected by not having to choose different classes for either operation, both can be done using the same class. Still, after obtaining a Cipher instance, we need to tell the instance what it is that we intend to do with it, so we need to call either cipher.encrypt or cipher.decrypt on the Cipher instance. This should be the first call after creating the instance, otherwise configuration that has already been set could get lost in the process. === Choosing a key Symmetric encryption requires a key that is the same for the encrypting and for the decrypting party and after initial key establishment should be kept as private information. There are a lot of ways to create insecure keys, the most notable is to simply take a password as the key without processing the password further. A simple and secure way to create a key for a particular Cipher is cipher = OpenSSL::Cipher.new('aes-256-cfb') cipher.encrypt key = cipher.random_key # also sets the generated key on the Cipher If you absolutely need to use passwords as encryption keys, you should use Password-Based Key Derivation Function 2 (PBKDF2) by generating the key with the help of the functionality provided by OpenSSL::PKCS5.pbkdf2_hmac_sha1 or OpenSSL::PKCS5.pbkdf2_hmac. Although there is Cipher#pkcs5_keyivgen, its use is deprecated and it should only be used in legacy applications because it does not use the newer PKCS#5 v2 algorithms. === Choosing an IV The cipher modes CBC, CFB, OFB and CTR all need an "initialization vector", or short, IV. ECB mode is the only mode that does not require an IV, but there is almost no legitimate use case for this mode because of the fact that it does not sufficiently hide plaintext patterns. Therefore You should never use ECB mode unless you are absolutely sure that you absolutely need it Because of this, you will end up with a mode that explicitly requires an IV in any case. Although the IV can be seen as public information, i.e. it may be transmitted in public once generated, it should still stay unpredictable to prevent certain kinds of attacks. Therefore, ideally Always create a secure random IV for every encryption of your Cipher A new, random IV should be created for every encryption of data. Think of the IV as a nonce (number used once) - it's public but random and unpredictable. A secure random IV can be created as follows cipher = ... cipher.encrypt key = cipher.random_key iv = cipher.random_iv # also sets the generated IV on the Cipher Although the key is generally a random value, too, it is a bad choice as an IV. There are elaborate ways how an attacker can take advantage of such an IV. As a general rule of thumb, exposing the key directly or indirectly should be avoided at all cost and exceptions only be made with good reason. === Calling Cipher#final ECB (which should not be used) and CBC are both block-based modes. This means that unlike for the other streaming-based modes, they operate on fixed-size blocks of data, and therefore they require a "finalization" step to produce or correctly decrypt the last block of data by appropriately handling some form of padding. Therefore it is essential to add the output of OpenSSL::Cipher#final to your encryption/decryption buffer or you will end up with decryption errors or truncated data. Although this is not really necessary for streaming-mode ciphers, it is still recommended to apply the same pattern of adding the output of Cipher#final there as well - it also enables you to switch between modes more easily in the future. === Encrypting and decrypting some data data = "Very, very confidential data" cipher = OpenSSL::Cipher.new('aes-128-cbc') cipher.encrypt key = cipher.random_key iv = cipher.random_iv encrypted = cipher.update(data) + cipher.final ... decipher = OpenSSL::Cipher.new('aes-128-cbc') decipher.decrypt decipher.key = key decipher.iv = iv plain = decipher.update(encrypted) + decipher.final puts data == plain #=> true === Authenticated Encryption and Associated Data (AEAD) If the OpenSSL version used supports it, an Authenticated Encryption mode (such as GCM or CCM) should always be preferred over any unauthenticated mode. Currently, OpenSSL supports AE only in combination with Associated Data (AEAD) where additional associated data is included in the encryption process to compute a tag at the end of the encryption. This tag will also be used in the decryption process and by verifying its validity, the authenticity of a given ciphertext is established. This is superior to unauthenticated modes in that it allows to detect if somebody effectively changed the ciphertext after it had been encrypted. This prevents malicious modifications of the ciphertext that could otherwise be exploited to modify ciphertexts in ways beneficial to potential attackers. An associated data is used where there is additional information, such as headers or some metadata, that must be also authenticated but not necessarily need to be encrypted. If no associated data is needed for encryption and later decryption, the OpenSSL library still requires a value to be set - "" may be used in case none is available. An example using the GCM (Galois/Counter Mode). You have 16 bytes _key_, 12 bytes (96 bits) _nonce_ and the associated data _auth_data_. Be sure not to reuse the _key_ and _nonce_ pair. Reusing an nonce ruins the security guarantees of GCM mode. cipher = OpenSSL::Cipher.new('aes-128-gcm').encrypt cipher.key = key cipher.iv = nonce cipher.auth_data = auth_data encrypted = cipher.update(data) + cipher.final tag = cipher.auth_tag # produces 16 bytes tag by default Now you are the receiver. You know the _key_ and have received _nonce_, _auth_data_, _encrypted_ and _tag_ through an untrusted network. Note that GCM accepts an arbitrary length tag between 1 and 16 bytes. You may additionally need to check that the received tag has the correct length, or you allow attackers to forge a valid single byte tag for the tampered ciphertext with a probability of 1/256. raise "tag is truncated!" unless tag.bytesize == 16 decipher = OpenSSL::Cipher.new('aes-128-gcm').decrypt decipher.key = key decipher.iv = nonce decipher.auth_tag = tag decipher.auth_data = auth_data decrypted = decipher.update(encrypted) + decipher.final puts data == decrypted #=> true ;T;[;![;"I" Provides symmetric algorithms for encryption and decryption. The algorithms that are available depend on the particular version of OpenSSL that is installed. === Listing all supported algorithms A list of supported algorithms can be obtained by puts OpenSSL::Cipher.ciphers === Instantiating a Cipher There are several ways to create a Cipher instance. Generally, a Cipher algorithm is categorized by its name, the key length in bits and the cipher mode to be used. The most generic way to create a Cipher is the following cipher = OpenSSL::Cipher.new('--') That is, a string consisting of the hyphenated concatenation of the individual components name, key length and mode. Either all uppercase or all lowercase strings may be used, for example: cipher = OpenSSL::Cipher.new('aes-128-cbc') === Choosing either encryption or decryption mode Encryption and decryption are often very similar operations for symmetric algorithms, this is reflected by not having to choose different classes for either operation, both can be done using the same class. Still, after obtaining a Cipher instance, we need to tell the instance what it is that we intend to do with it, so we need to call either cipher.encrypt or cipher.decrypt on the Cipher instance. This should be the first call after creating the instance, otherwise configuration that has already been set could get lost in the process. === Choosing a key Symmetric encryption requires a key that is the same for the encrypting and for the decrypting party and after initial key establishment should be kept as private information. There are a lot of ways to create insecure keys, the most notable is to simply take a password as the key without processing the password further. A simple and secure way to create a key for a particular Cipher is cipher = OpenSSL::Cipher.new('aes-256-cfb') cipher.encrypt key = cipher.random_key # also sets the generated key on the Cipher If you absolutely need to use passwords as encryption keys, you should use Password-Based Key Derivation Function 2 (PBKDF2) by generating the key with the help of the functionality provided by OpenSSL::PKCS5.pbkdf2_hmac_sha1 or OpenSSL::PKCS5.pbkdf2_hmac. Although there is Cipher#pkcs5_keyivgen, its use is deprecated and it should only be used in legacy applications because it does not use the newer PKCS#5 v2 algorithms. === Choosing an IV The cipher modes CBC, CFB, OFB and CTR all need an "initialization vector", or short, IV. ECB mode is the only mode that does not require an IV, but there is almost no legitimate use case for this mode because of the fact that it does not sufficiently hide plaintext patterns. Therefore You should never use ECB mode unless you are absolutely sure that you absolutely need it Because of this, you will end up with a mode that explicitly requires an IV in any case. Although the IV can be seen as public information, i.e. it may be transmitted in public once generated, it should still stay unpredictable to prevent certain kinds of attacks. Therefore, ideally Always create a secure random IV for every encryption of your Cipher A new, random IV should be created for every encryption of data. Think of the IV as a nonce (number used once) - it's public but random and unpredictable. A secure random IV can be created as follows cipher = ... cipher.encrypt key = cipher.random_key iv = cipher.random_iv # also sets the generated IV on the Cipher Although the key is generally a random value, too, it is a bad choice as an IV. There are elaborate ways how an attacker can take advantage of such an IV. As a general rule of thumb, exposing the key directly or indirectly should be avoided at all cost and exceptions only be made with good reason. === Calling Cipher#final ECB (which should not be used) and CBC are both block-based modes. This means that unlike for the other streaming-based modes, they operate on fixed-size blocks of data, and therefore they require a "finalization" step to produce or correctly decrypt the last block of data by appropriately handling some form of padding. Therefore it is essential to add the output of OpenSSL::Cipher#final to your encryption/decryption buffer or you will end up with decryption errors or truncated data. Although this is not really necessary for streaming-mode ciphers, it is still recommended to apply the same pattern of adding the output of Cipher#final there as well - it also enables you to switch between modes more easily in the future. === Encrypting and decrypting some data data = "Very, very confidential data" cipher = OpenSSL::Cipher.new('aes-128-cbc') cipher.encrypt key = cipher.random_key iv = cipher.random_iv encrypted = cipher.update(data) + cipher.final ... decipher = OpenSSL::Cipher.new('aes-128-cbc') decipher.decrypt decipher.key = key decipher.iv = iv plain = decipher.update(encrypted) + decipher.final puts data == plain #=> true === Authenticated Encryption and Associated Data (AEAD) If the OpenSSL version used supports it, an Authenticated Encryption mode (such as GCM or CCM) should always be preferred over any unauthenticated mode. Currently, OpenSSL supports AE only in combination with Associated Data (AEAD) where additional associated data is included in the encryption process to compute a tag at the end of the encryption. This tag will also be used in the decryption process and by verifying its validity, the authenticity of a given ciphertext is established. This is superior to unauthenticated modes in that it allows to detect if somebody effectively changed the ciphertext after it had been encrypted. This prevents malicious modifications of the ciphertext that could otherwise be exploited to modify ciphertexts in ways beneficial to potential attackers. An associated data is used where there is additional information, such as headers or some metadata, that must be also authenticated but not necessarily need to be encrypted. If no associated data is needed for encryption and later decryption, the OpenSSL library still requires a value to be set - "" may be used in case none is available. An example using the GCM (Galois/Counter Mode). You have 16 bytes _key_, 12 bytes (96 bits) _nonce_ and the associated data _auth_data_. Be sure not to reuse the _key_ and _nonce_ pair. Reusing an nonce ruins the security guarantees of GCM mode. cipher = OpenSSL::Cipher.new('aes-128-gcm').encrypt cipher.key = key cipher.iv = nonce cipher.auth_data = auth_data encrypted = cipher.update(data) + cipher.final tag = cipher.auth_tag # produces 16 bytes tag by default Now you are the receiver. You know the _key_ and have received _nonce_, _auth_data_, _encrypted_ and _tag_ through an untrusted network. Note that GCM accepts an arbitrary length tag between 1 and 16 bytes. You may additionally need to check that the received tag has the correct length, or you allow attackers to forge a valid single byte tag for the tampered ciphertext with a probability of 1/256. raise "tag is truncated!" unless tag.bytesize == 16 decipher = OpenSSL::Cipher.new('aes-128-gcm').decrypt decipher.key = key decipher.iv = nonce decipher.auth_tag = tag decipher.auth_data = auth_data decrypted = decipher.update(encrypted) + decipher.final puts data == decrypted #=> true ;T;#0;$@3;.F;/o;0;1T;2iT;3i;%@GH;&I"OpenSSL::Cipher;F;'@o; ;IC;[ o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@.Hi ;F;:PKCS12Error;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"!OpenSSL::PKCS12::PKCS12Error;F;'@Ho;4;5F;6;;;;&I"OpenSSL::PKCS12.create;F;7[[@90;[[@.Him;T;;;0;[;{;IC; "[=== Parameters * _pass_ - string * _name_ - A string describing the key. * _key_ - Any PKey. * _cert_ - A X509::Certificate. * The public_key portion of the certificate must contain a valid public key. * The not_before and not_after fields must be filled in. * _ca_ - An optional array of X509::Certificate's. * _key_pbe_ - string * _cert_pbe_ - string * _key_iter_ - integer * _mac_iter_ - integer * _keytype_ - An integer representing an MSIE specific extension. Any optional arguments may be supplied as +nil+ to preserve the OpenSSL defaults. See the OpenSSL documentation for PKCS12_create(). ;T;[o;= ;>I" overload;F;?0;;;@0;:I"icreate(pass, name, key, cert [, ca, [, key_pbe [, cert_pbe [, key_iter [, mac_iter [, keytype]]]]]]);T;IC; ";T;[;![;"I";T;#0;$@&;.F;Bi;C0;7[ [I" pass;T0[I" name;T0[I"key;T0[I"Ocert[, ca, [, key_pbe [, cert_pbe [, key_iter [, mac_iter [, keytype]]]]]];T0;$@&;![;"I"=== Parameters * _pass_ - string * _name_ - A string describing the key. * _key_ - Any PKey. * _cert_ - A X509::Certificate. * The public_key portion of the certificate must contain a valid public key. * The not_before and not_after fields must be filled in. * _ca_ - An optional array of X509::Certificate's. * _key_pbe_ - string * _cert_pbe_ - string * _key_iter_ - integer * _mac_iter_ - integer * _keytype_ - An integer representing an MSIE specific extension. Any optional arguments may be supplied as +nil+ to preserve the OpenSSL defaults. See the OpenSSL documentation for PKCS12_create(). @overload create(pass, name, key, cert [, ca, [, key_pbe [, cert_pbe [, key_iter [, mac_iter [, keytype]]]]]]);T;#0;$@&;.F;/o;0;1T;2iW;3ij;%@;9I"static VALUE ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self) { VALUE pass, name, pkey, cert, ca, key_nid, cert_nid, key_iter, mac_iter, keytype; VALUE obj; char *passphrase, *friendlyname; EVP_PKEY *key; X509 *x509; STACK_OF(X509) *x509s; int nkey = 0, ncert = 0, kiter = 0, miter = 0, ktype = 0; PKCS12 *p12; rb_scan_args(argc, argv, "46", &pass, &name, &pkey, &cert, &ca, &key_nid, &cert_nid, &key_iter, &mac_iter, &keytype); passphrase = NIL_P(pass) ? NULL : StringValueCStr(pass); friendlyname = NIL_P(name) ? NULL : StringValueCStr(name); key = GetPKeyPtr(pkey); x509 = GetX509CertPtr(cert); /* TODO: make a VALUE to nid function */ if (!NIL_P(key_nid)) { if ((nkey = OBJ_txt2nid(StringValueCStr(key_nid))) == NID_undef) ossl_raise(rb_eArgError, "Unknown PBE algorithm %"PRIsVALUE, key_nid); } if (!NIL_P(cert_nid)) { if ((ncert = OBJ_txt2nid(StringValueCStr(cert_nid))) == NID_undef) ossl_raise(rb_eArgError, "Unknown PBE algorithm %"PRIsVALUE, cert_nid); } if (!NIL_P(key_iter)) kiter = NUM2INT(key_iter); if (!NIL_P(mac_iter)) miter = NUM2INT(mac_iter); if (!NIL_P(keytype)) ktype = NUM2INT(keytype); obj = NewPKCS12(cPKCS12); x509s = NIL_P(ca) ? NULL : ossl_x509_ary2sk(ca); p12 = PKCS12_create(passphrase, friendlyname, key, x509, x509s, nkey, ncert, kiter, miter, ktype); sk_X509_pop_free(x509s, X509_free); if(!p12) ossl_raise(ePKCS12Error, NULL); SetPKCS12(obj, p12); ossl_pkcs12_set_key(obj, pkey); ossl_pkcs12_set_cert(obj, cert); ossl_pkcs12_set_ca_certs(obj, ca); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$OpenSSL::PKCS12#initialize_copy;F;7[[I" other;T0;[[@.HiD;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@E;%@;9I"static VALUE ossl_pkcs12_initialize_copy(VALUE self, VALUE other) { PKCS12 *p12, *p12_old, *p12_new; rb_check_frozen(self); GetPKCS12(self, p12_old); GetPKCS12(other, p12); p12_new = ASN1_dup((i2d_of_void *)i2d_PKCS12, (d2i_of_void *)d2i_PKCS12, (char *)p12); if (!p12_new) ossl_raise(ePKCS12Error, "ASN1_dup"); SetPKCS12(self, p12_new); PKCS12_free(p12_old); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKCS12#initialize;F;7[[@90;[[@.Hi;T;;D;0;[;{;IC; "T=== Parameters * _str_ - Must be a DER encoded PKCS12 string. * _pass_ - string ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new;T;IC; ";T;[;![;"I";T;#0;$@S;.F;Bi;C0;7[;$@So;= ;>I" overload;F;?0;;E;@0;:I" new(str);T;IC; ";T;[;![;"I";T;#0;$@S;.F;Bi;C0;7[[I"str;T0;$@So;= ;>I" overload;F;?0;;E;@0;:I"new(str, pass);T;IC; ";T;[;![;"I";T;#0;$@S;.F;Bi;C0;7[[I"str;T0[I" pass;T0;$@S;![;"I"=== Parameters * _str_ - Must be a DER encoded PKCS12 string. * _pass_ - string @overload new @overload new(str) @overload new(str, pass);T;#0;$@S;.F;/o;0;1T;2i;3i;%@;9I"'static VALUE ossl_pkcs12_initialize(int argc, VALUE *argv, VALUE self) { BIO *in; VALUE arg, pass, pkey, cert, ca; char *passphrase; EVP_PKEY *key; X509 *x509; STACK_OF(X509) *x509s = NULL; int st = 0; PKCS12 *pkcs = DATA_PTR(self); if(rb_scan_args(argc, argv, "02", &arg, &pass) == 0) return self; passphrase = NIL_P(pass) ? NULL : StringValueCStr(pass); in = ossl_obj2bio(&arg); d2i_PKCS12_bio(in, &pkcs); DATA_PTR(self) = pkcs; BIO_free(in); pkey = cert = ca = Qnil; /* OpenSSL's bug; PKCS12_parse() puts errors even if it succeeds. * Fixed in OpenSSL 1.0.0t, 1.0.1p, 1.0.2d */ ERR_set_mark(); if(!PKCS12_parse(pkcs, passphrase, &key, &x509, &x509s)) ossl_raise(ePKCS12Error, "PKCS12_parse"); ERR_pop_to_mark(); if (key) { pkey = rb_protect(ossl_pkey_new_i, (VALUE)key, &st); if (st) goto err; } if (x509) { cert = rb_protect(ossl_x509_new_i, (VALUE)x509, &st); if (st) goto err; } if (x509s) { ca = rb_protect(ossl_x509_sk2ary_i, (VALUE)x509s, &st); if (st) goto err; } err: X509_free(x509); sk_X509_pop_free(x509s, X509_free); ossl_pkcs12_set_key(self, pkey); ossl_pkcs12_set_cert(self, cert); ossl_pkcs12_set_ca_certs(self, ca); if(st) rb_jump_tag(st); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::PKCS12#to_der;F;7[;[[@.Hi;T;;M;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE ossl_pkcs12_to_der(VALUE self) { PKCS12 *p12; VALUE str; long len; unsigned char *p; GetPKCS12(self, p12); if((len = i2d_PKCS12(p12, NULL)) <= 0) ossl_raise(ePKCS12Error, NULL); str = rb_str_new(0, len); p = (unsigned char *)RSTRING_PTR(str); if(i2d_PKCS12(p12, &p) <= 0) ossl_raise(ePKCS12Error, NULL); ossl_str_adjust(str, p); return str; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@.Hi;F;: PKCS12;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@GH;&I"OpenSSL::PKCS12;F;'@o; ;IC;[o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Hi;T;;2;;;;;[;{;IC; "YGeneric Exception class that is raised if an error occurs during a Digest operation. ;T;[;![;"I"[ Generic Exception class that is raised if an error occurs during a Digest operation. ;T;#0;$@;.F;/o;0;1T;2i;3i;%o;( ;)@;*I"OpenSSL::Digest;T;+0;;-;%o;( ;)0;*0;+0;;;%@;-@GH;0;-@;0;&I"!OpenSSL::Digest::DigestError;F;'o;( ;)0;*0;+0;;;%@;-@;0; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@HiA;T;;-;;;;;[;{;IC; "@ OpenSSL::Digest allows you to compute message digests (sometimes interchangeably called "hashes") of arbitrary data that are cryptographically secure, i.e. a Digest implements a secure one-way function. One-way functions offer some useful properties. E.g. given two distinct inputs the probability that both yield the same output is highly unlikely. Combined with the fact that every message digest algorithm has a fixed-length output of just a few bytes, digests are often used to create unique identifiers for arbitrary data. A common example is the creation of a unique id for binary documents that are stored in a database. Another useful characteristic of one-way functions (and thus the name) is that given a digest there is no indication about the original data that produced it, i.e. the only way to identify the original input is to "brute-force" through every possible combination of inputs. These characteristics make one-way functions also ideal companions for public key signature algorithms: instead of signing an entire document, first a hash of the document is produced with a considerably faster message digest algorithm and only the few bytes of its output need to be signed using the slower public key algorithm. To validate the integrity of a signed document, it suffices to re-compute the hash and verify that it is equal to that in the signature. You can get a list of all digest algorithms supported on your system by running this command in your terminal: openssl list -digest-algorithms Among the OpenSSL 1.1.1 supported message digest algorithms are: * SHA224, SHA256, SHA384, SHA512, SHA512-224 and SHA512-256 * SHA3-224, SHA3-256, SHA3-384 and SHA3-512 * BLAKE2s256 and BLAKE2b512 Each of these algorithms can be instantiated using the name: digest = OpenSSL::Digest.new('SHA256') "Breaking" a message digest algorithm means defying its one-way function characteristics, i.e. producing a collision or finding a way to get to the original data by means that are more efficient than brute-forcing etc. Most of the supported digest algorithms can be considered broken in this sense, even the very popular MD5 and SHA1 algorithms. Should security be your highest concern, then you should probably rely on SHA224, SHA256, SHA384 or SHA512. === Hashing a file data = File.binread('document') sha256 = OpenSSL::Digest.new('SHA256') digest = sha256.digest(data) === Hashing several pieces of data at once data1 = File.binread('file1') data2 = File.binread('file2') data3 = File.binread('file3') sha256 = OpenSSL::Digest.new('SHA256') sha256 << data1 sha256 << data2 sha256 << data3 digest = sha256.digest === Reuse a Digest instance data1 = File.binread('file1') sha256 = OpenSSL::Digest.new('SHA256') digest1 = sha256.digest(data1) data2 = File.binread('file2') sha256.reset digest2 = sha256.digest(data2);T;[;![;"I"C OpenSSL::Digest allows you to compute message digests (sometimes interchangeably called "hashes") of arbitrary data that are cryptographically secure, i.e. a Digest implements a secure one-way function. One-way functions offer some useful properties. E.g. given two distinct inputs the probability that both yield the same output is highly unlikely. Combined with the fact that every message digest algorithm has a fixed-length output of just a few bytes, digests are often used to create unique identifiers for arbitrary data. A common example is the creation of a unique id for binary documents that are stored in a database. Another useful characteristic of one-way functions (and thus the name) is that given a digest there is no indication about the original data that produced it, i.e. the only way to identify the original input is to "brute-force" through every possible combination of inputs. These characteristics make one-way functions also ideal companions for public key signature algorithms: instead of signing an entire document, first a hash of the document is produced with a considerably faster message digest algorithm and only the few bytes of its output need to be signed using the slower public key algorithm. To validate the integrity of a signed document, it suffices to re-compute the hash and verify that it is equal to that in the signature. You can get a list of all digest algorithms supported on your system by running this command in your terminal: openssl list -digest-algorithms Among the OpenSSL 1.1.1 supported message digest algorithms are: * SHA224, SHA256, SHA384, SHA512, SHA512-224 and SHA512-256 * SHA3-224, SHA3-256, SHA3-384 and SHA3-512 * BLAKE2s256 and BLAKE2b512 Each of these algorithms can be instantiated using the name: digest = OpenSSL::Digest.new('SHA256') "Breaking" a message digest algorithm means defying its one-way function characteristics, i.e. producing a collision or finding a way to get to the original data by means that are more efficient than brute-forcing etc. Most of the supported digest algorithms can be considered broken in this sense, even the very popular MD5 and SHA1 algorithms. Should security be your highest concern, then you should probably rely on SHA224, SHA256, SHA384 or SHA512. === Hashing a file data = File.binread('document') sha256 = OpenSSL::Digest.new('SHA256') digest = sha256.digest(data) === Hashing several pieces of data at once data1 = File.binread('file1') data2 = File.binread('file2') data3 = File.binread('file3') sha256 = OpenSSL::Digest.new('SHA256') sha256 << data1 sha256 << data2 sha256 << data3 digest = sha256.digest === Reuse a Digest instance data1 = File.binread('file1') sha256 = OpenSSL::Digest.new('SHA256') digest1 = sha256.digest(data1) data2 = File.binread('file2') sha256.reset digest2 = sha256.digest(data2) ;T;#0;$@;.F;/o;0;1T;2iA;3i;Bi;%@;&I"OpenSSL::Digest;F;'o;( ;)0;*0;+0;;;%@;-@;0o;;IC;[o; ;IC;[; @Ȩ; IC;[; @Ȩ; IC;[; @Ȩ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@1Hi [@1Hi;T;:ASN1Error;;;;;[;{;IC; "\Generic error class for all errors raised in ASN1 and any of the classes defined in it. ;T;[;![;"I"^ Generic error class for all errors raised in ASN1 and any of the classes defined in it. ;T;#0;$@Ȩ;.F;/o;0;1T;2i ;3i;%@ƨ;&I"OpenSSL::ASN1::ASN1Error;F;'@Ho;4;5F;6;;;;&I"OpenSSL::ASN1#traverse;F;7[[I"obj;T0;[[@1Hi;T;: traverse;0;[;{;IC; "[If a block is given, it prints out each of the elements encountered. Block parameters are (in that order): * depth: The recursion depth, plus one with each constructed value being encountered (Integer) * offset: Current byte offset (Integer) * header length: Combined length in bytes of the Tag and Length headers. (Integer) * length: The overall remaining length of the entire data (Integer) * constructed: Whether this value is constructed or not (Boolean) * tag_class: Current tag class (Symbol) * tag: The current tag number (Integer) == Example der = File.binread('asn1data.der') OpenSSL::ASN1.traverse(der) do | depth, offset, header_len, length, constructed, tag_class, tag| puts "Depth: #{depth} Offset: #{offset} Length: #{length}" puts "Header length: #{header_len} Tag: #{tag} Tag class: #{tag_class} Constructed: #{constructed}" end ;T;[o;= ;>I" overload;F;?0;:OpenSSL::ASN1.traverse;@0;:I"!OpenSSL::ASN1.traverse(asn1);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@ܨ;![;"I"@return [nil];T;#0;$@ܨ;.F;Bi;C0;7[[I" asn1;T0;$@ܨ;![;"I"If a block is given, it prints out each of the elements encountered. Block parameters are (in that order): * depth: The recursion depth, plus one with each constructed value being encountered (Integer) * offset: Current byte offset (Integer) * header length: Combined length in bytes of the Tag and Length headers. (Integer) * length: The overall remaining length of the entire data (Integer) * constructed: Whether this value is constructed or not (Boolean) * tag_class: Current tag class (Symbol) * tag: The current tag number (Integer) == Example der = File.binread('asn1data.der') OpenSSL::ASN1.traverse(der) do | depth, offset, header_len, length, constructed, tag_class, tag| puts "Depth: #{depth} Offset: #{offset} Length: #{length}" puts "Header length: #{header_len} Tag: #{tag} Tag class: #{tag_class} Constructed: #{constructed}" end @overload OpenSSL::ASN1.traverse(asn1) @return [nil];T;#0;$@ܨ;.F;C0;%@ƨ;9I"static VALUE ossl_asn1_traverse(VALUE self, VALUE obj) { unsigned char *p; VALUE tmp; long len, read = 0, offset = 0; obj = ossl_to_der_if_possible(obj); tmp = rb_str_new4(StringValue(obj)); p = (unsigned char *)RSTRING_PTR(tmp); len = RSTRING_LEN(tmp); ossl_asn1_decode0(&p, len, &offset, 0, 1, &read); RB_GC_GUARD(tmp); int_ossl_decode_sanity_check(len, read, offset); return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"OpenSSL::ASN1.traverse;F;7@ި;@;T;;;0;@;{;IC; "[If a block is given, it prints out each of the elements encountered. Block parameters are (in that order): * depth: The recursion depth, plus one with each constructed value being encountered (Integer) * offset: Current byte offset (Integer) * header length: Combined length in bytes of the Tag and Length headers. (Integer) * length: The overall remaining length of the entire data (Integer) * constructed: Whether this value is constructed or not (Boolean) * tag_class: Current tag class (Symbol) * tag: The current tag number (Integer) == Example der = File.binread('asn1data.der') OpenSSL::ASN1.traverse(der) do | depth, offset, header_len, length, constructed, tag_class, tag| puts "Depth: #{depth} Offset: #{offset} Length: #{length}" puts "Header length: #{header_len} Tag: #{tag} Tag class: #{tag_class} Constructed: #{constructed}" end;T;[o;= ;>I" overload;F;?0;;;@0;:I"!OpenSSL::ASN1.traverse(asn1);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I" asn1;T0;$@;![;"I"If a block is given, it prints out each of the elements encountered. Block parameters are (in that order): * depth: The recursion depth, plus one with each constructed value being encountered (Integer) * offset: Current byte offset (Integer) * header length: Combined length in bytes of the Tag and Length headers. (Integer) * length: The overall remaining length of the entire data (Integer) * constructed: Whether this value is constructed or not (Boolean) * tag_class: Current tag class (Symbol) * tag: The current tag number (Integer) == Example der = File.binread('asn1data.der') OpenSSL::ASN1.traverse(der) do | depth, offset, header_len, length, constructed, tag_class, tag| puts "Depth: #{depth} Offset: #{offset} Length: #{length}" puts "Header length: #{header_len} Tag: #{tag} Tag class: #{tag_class} Constructed: #{constructed}" end @overload OpenSSL::ASN1.traverse(asn1) @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@ƨ;9@;:@;;To;4;5F;6;;;;&I"OpenSSL::ASN1#decode;F;7[[I"obj;T0;[[@1Hi;T;: decode;0;[;{;IC; " Decodes a BER- or DER-encoded value and creates an ASN1Data instance. _der_ may be a String or any object that features a +.to_der+ method transforming it into a BER-/DER-encoded String+ == Example der = File.binread('asn1data') asn1 = OpenSSL::ASN1.decode(der) ;T;[o;= ;>I" overload;F;?0;:OpenSSL::ASN1.decode;@0;:I"OpenSSL::ASN1.decode(der);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" ASN1Data;T;$@;![;"I"@return [ASN1Data];T;#0;$@;.F;Bi;C0;7[[I"der;T0;$@;![;"I"DDecodes a BER- or DER-encoded value and creates an ASN1Data instance. _der_ may be a String or any object that features a +.to_der+ method transforming it into a BER-/DER-encoded String+ == Example der = File.binread('asn1data') asn1 = OpenSSL::ASN1.decode(der) @overload OpenSSL::ASN1.decode(der) @return [ASN1Data];T;#0;$@;.F;C0;%@ƨ;9I"static VALUE ossl_asn1_decode(VALUE self, VALUE obj) { VALUE ret; unsigned char *p; VALUE tmp; long len, read = 0, offset = 0; obj = ossl_to_der_if_possible(obj); tmp = rb_str_new4(StringValue(obj)); p = (unsigned char *)RSTRING_PTR(tmp); len = RSTRING_LEN(tmp); ret = ossl_asn1_decode0(&p, len, &offset, 0, 0, &read); RB_GC_GUARD(tmp); int_ossl_decode_sanity_check(len, read, offset); return ret; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"OpenSSL::ASN1.decode;F;7@;@;T;;;0;@;{;IC; " Decodes a BER- or DER-encoded value and creates an ASN1Data instance. _der_ may be a String or any object that features a +.to_der+ method transforming it into a BER-/DER-encoded String+ == Example der = File.binread('asn1data') asn1 = OpenSSL::ASN1.decode(der);T;[o;= ;>I" overload;F;?0;;;@0;:I"OpenSSL::ASN1.decode(der);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" ASN1Data;T;$@/;![;"I"@return [ASN1Data];T;#0;$@/;.F;Bi;C0;7[[I"der;T0;$@/;![;"I"EDecodes a BER- or DER-encoded value and creates an ASN1Data instance. _der_ may be a String or any object that features a +.to_der+ method transforming it into a BER-/DER-encoded String+ == Example der = File.binread('asn1data') asn1 = OpenSSL::ASN1.decode(der) @overload OpenSSL::ASN1.decode(der) @return [ASN1Data];T;#0;$@/;.F;/o;0;1T;2i;3i;Bi;%@ƨ;9@-;:@.;;To;4;5F;6;;;;&I"OpenSSL::ASN1#decode_all;F;7[[I"obj;T0;[[@1Hi;T;:decode_all;0;[;{;IC; ">Similar to #decode with the difference that #decode expects one distinct value represented in _der_. #decode_all on the contrary decodes a sequence of sequential BER/DER values lined up in _der_ and returns them as an array. == Example ders = File.binread('asn1data_seq') asn1_ary = OpenSSL::ASN1.decode_all(ders) ;T;[o;= ;>I" overload;F;?0;:OpenSSL::ASN1.decode_all;@0;:I""OpenSSL::ASN1.decode_all(der);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Array of ASN1Data;T;$@F;![;"I" @return [Array of ASN1Data];T;#0;$@F;.F;Bi;C0;7[[I"der;T0;$@F;![;"I"Similar to #decode with the difference that #decode expects one distinct value represented in _der_. #decode_all on the contrary decodes a sequence of sequential BER/DER values lined up in _der_ and returns them as an array. == Example ders = File.binread('asn1data_seq') asn1_ary = OpenSSL::ASN1.decode_all(ders) @overload OpenSSL::ASN1.decode_all(der) @return [Array of ASN1Data];T;#0;$@F;.F;C0;%@ƨ;9I"{static VALUE ossl_asn1_decode_all(VALUE self, VALUE obj) { VALUE ary, val; unsigned char *p; long len, tmp_len = 0, read = 0, offset = 0; VALUE tmp; obj = ossl_to_der_if_possible(obj); tmp = rb_str_new4(StringValue(obj)); p = (unsigned char *)RSTRING_PTR(tmp); len = RSTRING_LEN(tmp); tmp_len = len; ary = rb_ary_new(); while (tmp_len > 0) { long tmp_read = 0; val = ossl_asn1_decode0(&p, tmp_len, &offset, 0, 0, &tmp_read); rb_ary_push(ary, val); read += tmp_read; tmp_len -= tmp_read; } RB_GC_GUARD(tmp); int_ossl_decode_sanity_check(len, read, offset); return ary; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"OpenSSL::ASN1.decode_all;F;7@H;@K;T;;;0;@M;{;IC; ">Similar to #decode with the difference that #decode expects one distinct value represented in _der_. #decode_all on the contrary decodes a sequence of sequential BER/DER values lined up in _der_ and returns them as an array. == Example ders = File.binread('asn1data_seq') asn1_ary = OpenSSL::ASN1.decode_all(ders);T;[o;= ;>I" overload;F;?0;;;@0;:I""OpenSSL::ASN1.decode_all(der);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Array of ASN1Data;T;$@d;![;"I" @return [Array of ASN1Data];T;#0;$@d;.F;Bi;C0;7[[I"der;T0;$@d;![;"I"Similar to #decode with the difference that #decode expects one distinct value represented in _der_. #decode_all on the contrary decodes a sequence of sequential BER/DER values lined up in _der_ and returns them as an array. == Example ders = File.binread('asn1data_seq') asn1_ary = OpenSSL::ASN1.decode_all(ders) @overload OpenSSL::ASN1.decode_all(der) @return [Array of ASN1Data];T;#0;$@d;.F;/o;0;1T;2i;3i;Bi;%@ƨ;9@b;:@c;;To;u;[[@1Hi;F;:UNIVERSAL_TAG_NAME;;w;;;[;{;IC; "0Array storing tag names at the tag's index. ;T;[;![;"I"1Array storing tag names at the tag's index. ;T;#0;$@{;.F;/o;0;1T;2i;3i;%@ƨ;&I"&OpenSSL::ASN1::UNIVERSAL_TAG_NAME;F;xI"ary;To; ;IC;[ o;4;5F;6;;;;&I",OpenSSL::ASN1::ASN1Data#infinite_length;F;7[;[[@1Hi;F;:infinite_length;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;:I"def infinite_length;To;4;5F;6;;;;&I"-OpenSSL::ASN1::ASN1Data#infinite_length=;F;7[;[[@1Hi;F;:infinite_length=;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;:I"def infinite_length=;To;4;5F;6;;;;&I"'OpenSSL::ASN1::ASN1Data#initialize;F;7[[I" value;T0[I"tag;T0[I"tag_class;T0;[[@1Hi;T;;D;0;[;{;IC; "_value_: Please have a look at Constructive and Primitive to see how Ruby types are mapped to ASN.1 types and vice versa. _tag_: An Integer indicating the tag number. _tag_class_: A Symbol indicating the tag class. Please cf. ASN1 for possible values. == Example asn1_int = OpenSSL::ASN1Data.new(42, 2, :UNIVERSAL) # => Same as OpenSSL::ASN1::Integer.new(42) tagged_int = OpenSSL::ASN1Data.new(42, 0, :CONTEXT_SPECIFIC) # implicitly 0-tagged INTEGER ;T;[o;= ;>I" overload;F;?0;: OpenSSL::ASN1::ASN1Data.new;@0;:I"7OpenSSL::ASN1::ASN1Data.new(value, tag, tag_class);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" ASN1Data;T;$@;![;"I"@return [ASN1Data];T;#0;$@;.F;Bi;C0;7[[I" value;T0[I"tag;T0[I"tag_class;T0;$@;![;"I"_value_: Please have a look at Constructive and Primitive to see how Ruby types are mapped to ASN.1 types and vice versa. _tag_: An Integer indicating the tag number. _tag_class_: A Symbol indicating the tag class. Please cf. ASN1 for possible values. == Example asn1_int = OpenSSL::ASN1Data.new(42, 2, :UNIVERSAL) # => Same as OpenSSL::ASN1::Integer.new(42) tagged_int = OpenSSL::ASN1Data.new(42, 0, :CONTEXT_SPECIFIC) # implicitly 0-tagged INTEGER @overload OpenSSL::ASN1::ASN1Data.new(value, tag, tag_class) @return [ASN1Data];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"dstatic VALUE ossl_asn1data_initialize(VALUE self, VALUE value, VALUE tag, VALUE tag_class) { if(!SYMBOL_P(tag_class)) ossl_raise(eASN1Error, "invalid tag class"); ossl_asn1_set_tag(self, tag); ossl_asn1_set_value(self, value); ossl_asn1_set_tag_class(self, tag_class); ossl_asn1_set_indefinite_length(self, Qfalse); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::ASN1::ASN1Data#to_der;F;7[;[[@1Hi;T;;M;0;[;{;IC; " Encodes this ASN1Data into a DER-encoded String value. The result is DER-encoded except for the possibility of indefinite length forms. Indefinite length forms are not allowed in strict DER, so strictly speaking the result of such an encoding would be a BER-encoding. ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" to_der;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"DER-encoded String;T;$@Ʃ;![;"I"!@return [DER-encoded String];T;#0;$@Ʃ;.F;Bi;C0;7[;$@Ʃ;![;"I"=Encodes this ASN1Data into a DER-encoded String value. The result is DER-encoded except for the possibility of indefinite length forms. Indefinite length forms are not allowed in strict DER, so strictly speaking the result of such an encoding would be a BER-encoding. @overload to_der @return [DER-encoded String];T;#0;$@Ʃ;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_asn1data_to_der(VALUE self) { VALUE value = ossl_asn1_get_value(self); if (rb_obj_is_kind_of(value, rb_cArray)) return ossl_asn1cons_to_der(self); else { if (RTEST(ossl_asn1_get_indefinite_length(self))) ossl_raise(eASN1Error, "indefinite length form cannot be used " \ "with primitive encoding"); return ossl_asn1prim_to_der(self); } };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{@:indefinite_length@:indefinite_length=;[;[[@1Hi [@1Hiw;T;: ASN1Data;;;;;[;{;IC; " The top-level class representing any ASN.1 object. When parsed by ASN1.decode, tagged values are always represented by an instance of ASN1Data. == The role of ASN1Data for parsing tagged values When encoding an ASN.1 type it is inherently clear what original type (e.g. INTEGER, OCTET STRING etc.) this value has, regardless of its tagging. But opposed to the time an ASN.1 type is to be encoded, when parsing them it is not possible to deduce the "real type" of tagged values. This is why tagged values are generally parsed into ASN1Data instances, but with a different outcome for implicit and explicit tagging. === Example of a parsed implicitly tagged value An implicitly 1-tagged INTEGER value will be parsed as an ASN1Data with * _tag_ equal to 1 * _tag_class_ equal to +:CONTEXT_SPECIFIC+ * _value_ equal to a String that carries the raw encoding of the INTEGER. This implies that a subsequent decoding step is required to completely decode implicitly tagged values. === Example of a parsed explicitly tagged value An explicitly 1-tagged INTEGER value will be parsed as an ASN1Data with * _tag_ equal to 1 * _tag_class_ equal to +:CONTEXT_SPECIFIC+ * _value_ equal to an Array with one single element, an instance of OpenSSL::ASN1::Integer, i.e. the inner element is the non-tagged primitive value, and the tagging is represented in the outer ASN1Data == Example - Decoding an implicitly tagged INTEGER int = OpenSSL::ASN1::Integer.new(1, 0, :IMPLICIT) # implicit 0-tagged seq = OpenSSL::ASN1::Sequence.new( [int] ) der = seq.to_der asn1 = OpenSSL::ASN1.decode(der) # pp asn1 => #]> raw_int = asn1.value[0] # manually rewrite tag and tag class to make it an UNIVERSAL value raw_int.tag = OpenSSL::ASN1::INTEGER raw_int.tag_class = :UNIVERSAL int2 = OpenSSL::ASN1.decode(raw_int) puts int2.value # => 1 == Example - Decoding an explicitly tagged INTEGER int = OpenSSL::ASN1::Integer.new(1, 0, :EXPLICIT) # explicit 0-tagged seq = OpenSSL::ASN1::Sequence.new( [int] ) der = seq.to_der asn1 = OpenSSL::ASN1.decode(der) # pp asn1 => #]>]> int2 = asn1.value[0].value[0] puts int2.value # => 1 ;T;[;![;"I" The top-level class representing any ASN.1 object. When parsed by ASN1.decode, tagged values are always represented by an instance of ASN1Data. == The role of ASN1Data for parsing tagged values When encoding an ASN.1 type it is inherently clear what original type (e.g. INTEGER, OCTET STRING etc.) this value has, regardless of its tagging. But opposed to the time an ASN.1 type is to be encoded, when parsing them it is not possible to deduce the "real type" of tagged values. This is why tagged values are generally parsed into ASN1Data instances, but with a different outcome for implicit and explicit tagging. === Example of a parsed implicitly tagged value An implicitly 1-tagged INTEGER value will be parsed as an ASN1Data with * _tag_ equal to 1 * _tag_class_ equal to +:CONTEXT_SPECIFIC+ * _value_ equal to a String that carries the raw encoding of the INTEGER. This implies that a subsequent decoding step is required to completely decode implicitly tagged values. === Example of a parsed explicitly tagged value An explicitly 1-tagged INTEGER value will be parsed as an ASN1Data with * _tag_ equal to 1 * _tag_class_ equal to +:CONTEXT_SPECIFIC+ * _value_ equal to an Array with one single element, an instance of OpenSSL::ASN1::Integer, i.e. the inner element is the non-tagged primitive value, and the tagging is represented in the outer ASN1Data == Example - Decoding an implicitly tagged INTEGER int = OpenSSL::ASN1::Integer.new(1, 0, :IMPLICIT) # implicit 0-tagged seq = OpenSSL::ASN1::Sequence.new( [int] ) der = seq.to_der asn1 = OpenSSL::ASN1.decode(der) # pp asn1 => #]> raw_int = asn1.value[0] # manually rewrite tag and tag class to make it an UNIVERSAL value raw_int.tag = OpenSSL::ASN1::INTEGER raw_int.tag_class = :UNIVERSAL int2 = OpenSSL::ASN1.decode(raw_int) puts int2.value # => 1 == Example - Decoding an explicitly tagged INTEGER int = OpenSSL::ASN1::Integer.new(1, 0, :EXPLICIT) # explicit 0-tagged seq = OpenSSL::ASN1::Sequence.new( [int] ) der = seq.to_der asn1 = OpenSSL::ASN1.decode(der) # pp asn1 => #]>]> int2 = asn1.value[0].value[0] puts int2.value # => 1 ;T;#0;$@;.F;/o;0;1T;2i ;3iu;%@ƨ;&I"OpenSSL::ASN1::ASN1Data;F;'@o; ;IC;[o;4;5F;6;;;;&I"(OpenSSL::ASN1::Primitive#initialize;F;7[[@90;[[@1Hi1;T;;D;0;[;{;IC; "_value_: is mandatory. _tag_: optional, may be specified for tagged values. If no _tag_ is specified, the UNIVERSAL tag corresponding to the Primitive sub-class is used by default. _tagging_: may be used as an encoding hint to encode a value either explicitly or implicitly, see ASN1 for possible values. _tag_class_: if _tag_ and _tagging_ are +nil+ then this is set to +:UNIVERSAL+ by default. If either _tag_ or _tagging_ are set then +:CONTEXT_SPECIFIC+ is used as the default. For possible values please cf. ASN1. == Example int = OpenSSL::ASN1::Integer.new(42) zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :IMPLICIT) private_explicit_zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :EXPLICIT, :PRIVATE) ;T;[o;= ;>I" overload;F;?0;:!OpenSSL::ASN1::Primitive.new;@0;:I"EOpenSSL::ASN1::Primitive.new(value [, tag, tagging, tag_class ]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Primitive;T;$@;![;"I"@return [Primitive];T;#0;$@;.F;Bi;C0;7[[I"&value[, tag, tagging, tag_class ];T0;$@;![;"I"<_value_: is mandatory. _tag_: optional, may be specified for tagged values. If no _tag_ is specified, the UNIVERSAL tag corresponding to the Primitive sub-class is used by default. _tagging_: may be used as an encoding hint to encode a value either explicitly or implicitly, see ASN1 for possible values. _tag_class_: if _tag_ and _tagging_ are +nil+ then this is set to +:UNIVERSAL+ by default. If either _tag_ or _tagging_ are set then +:CONTEXT_SPECIFIC+ is used as the default. For possible values please cf. ASN1. == Example int = OpenSSL::ASN1::Integer.new(42) zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :IMPLICIT) private_explicit_zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :EXPLICIT, :PRIVATE) @overload OpenSSL::ASN1::Primitive.new(value [, tag, tagging, tag_class ]) @return [Primitive];T;#0;$@;.F;/o;0;1T;2i;3i/;%@;9I"=static VALUE ossl_asn1_initialize(int argc, VALUE *argv, VALUE self) { VALUE value, tag, tagging, tag_class; int default_tag; rb_scan_args(argc, argv, "13", &value, &tag, &tagging, &tag_class); default_tag = ossl_asn1_default_tag(self); if (default_tag == -1 || argc > 1) { if(NIL_P(tag)) ossl_raise(eASN1Error, "must specify tag number"); if(!NIL_P(tagging) && !SYMBOL_P(tagging)) ossl_raise(eASN1Error, "invalid tagging method"); if(NIL_P(tag_class)) { if (NIL_P(tagging)) tag_class = sym_UNIVERSAL; else tag_class = sym_CONTEXT_SPECIFIC; } if(!SYMBOL_P(tag_class)) ossl_raise(eASN1Error, "invalid tag class"); } else{ tag = INT2NUM(default_tag); tagging = Qnil; tag_class = sym_UNIVERSAL; } ossl_asn1_set_tag(self, tag); ossl_asn1_set_value(self, value); ossl_asn1_set_tagging(self, tagging); ossl_asn1_set_tag_class(self, tag_class); ossl_asn1_set_indefinite_length(self, Qfalse); if (default_tag == V_ASN1_BIT_STRING) rb_ivar_set(self, sivUNUSED_BITS, INT2FIX(0)); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$OpenSSL::ASN1::Primitive#to_der;F;7[;[[@1His;T;;M;0;[;{;IC; "%See ASN1Data#to_der for details. ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" to_der;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"DER-encoded String;T;$@;![;"I"!@return [DER-encoded String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"WSee ASN1Data#to_der for details. @overload to_der @return [DER-encoded String];T;#0;$@;.F;/o;0;1T;2im;3iq;%@;9I"static VALUE ossl_asn1prim_to_der(VALUE self) { ASN1_TYPE *asn1; long alllen, bodylen; unsigned char *p0, *p1; int j, tag, tc, state; VALUE str; if (ossl_asn1_default_tag(self) == -1) { str = ossl_asn1_get_value(self); return to_der_internal(self, 0, 0, StringValue(str)); } asn1 = ossl_asn1_get_asn1type(self); alllen = i2d_ASN1_TYPE(asn1, NULL); if (alllen < 0) { ASN1_TYPE_free(asn1); ossl_raise(eASN1Error, "i2d_ASN1_TYPE"); } str = ossl_str_new(NULL, alllen, &state); if (state) { ASN1_TYPE_free(asn1); rb_jump_tag(state); } p0 = p1 = (unsigned char *)RSTRING_PTR(str); i2d_ASN1_TYPE(asn1, &p0); ASN1_TYPE_free(asn1); assert(p0 - p1 == alllen); /* Strip header since to_der_internal() wants only the payload */ j = ASN1_get_object((const unsigned char **)&p1, &bodylen, &tag, &tc, alllen); if (j & 0x80) ossl_raise(eASN1Error, "ASN1_get_object"); /* should not happen */ return to_der_internal(self, 0, 0, rb_str_drop_bytes(str, alllen - bodylen)); };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@1Hi[@1Hi;T;:Primitive;;;;;[;{;IC; " The parent class for all primitive encodings. Attributes are the same as for ASN1Data, with the addition of _tagging_. Primitive values can never be encoded with indefinite length form, thus it is not possible to set the _indefinite_length_ attribute for Primitive and its sub-classes. == Primitive sub-classes and their mapping to Ruby classes * OpenSSL::ASN1::EndOfContent <=> _value_ is always +nil+ * OpenSSL::ASN1::Boolean <=> _value_ is +true+ or +false+ * OpenSSL::ASN1::Integer <=> _value_ is an OpenSSL::BN * OpenSSL::ASN1::BitString <=> _value_ is a String * OpenSSL::ASN1::OctetString <=> _value_ is a String * OpenSSL::ASN1::Null <=> _value_ is always +nil+ * OpenSSL::ASN1::Object <=> _value_ is a String * OpenSSL::ASN1::Enumerated <=> _value_ is an OpenSSL::BN * OpenSSL::ASN1::UTF8String <=> _value_ is a String * OpenSSL::ASN1::NumericString <=> _value_ is a String * OpenSSL::ASN1::PrintableString <=> _value_ is a String * OpenSSL::ASN1::T61String <=> _value_ is a String * OpenSSL::ASN1::VideotexString <=> _value_ is a String * OpenSSL::ASN1::IA5String <=> _value_ is a String * OpenSSL::ASN1::UTCTime <=> _value_ is a Time * OpenSSL::ASN1::GeneralizedTime <=> _value_ is a Time * OpenSSL::ASN1::GraphicString <=> _value_ is a String * OpenSSL::ASN1::ISO64String <=> _value_ is a String * OpenSSL::ASN1::GeneralString <=> _value_ is a String * OpenSSL::ASN1::UniversalString <=> _value_ is a String * OpenSSL::ASN1::BMPString <=> _value_ is a String == OpenSSL::ASN1::BitString === Additional attributes _unused_bits_: if the underlying BIT STRING's length is a multiple of 8 then _unused_bits_ is 0. Otherwise _unused_bits_ indicates the number of bits that are to be ignored in the final octet of the BitString's _value_. == OpenSSL::ASN1::ObjectId NOTE: While OpenSSL::ASN1::ObjectId.new will allocate a new ObjectId, it is not typically allocated this way, but rather that are received from parsed ASN1 encodings. === Additional attributes * _sn_: the short name as defined in . * _ln_: the long name as defined in . * _oid_: the object identifier as a String, e.g. "1.2.3.4.5" * _short_name_: alias for _sn_. * _long_name_: alias for _ln_. == Examples With the Exception of OpenSSL::ASN1::EndOfContent, each Primitive class constructor takes at least one parameter, the _value_. === Creating EndOfContent eoc = OpenSSL::ASN1::EndOfContent.new === Creating any other Primitive prim = .new(value) # being one of the sub-classes except EndOfContent prim_zero_tagged_implicit = .new(value, 0, :IMPLICIT) prim_zero_tagged_explicit = .new(value, 0, :EXPLICIT) ;T;[;![;"I" The parent class for all primitive encodings. Attributes are the same as for ASN1Data, with the addition of _tagging_. Primitive values can never be encoded with indefinite length form, thus it is not possible to set the _indefinite_length_ attribute for Primitive and its sub-classes. == Primitive sub-classes and their mapping to Ruby classes * OpenSSL::ASN1::EndOfContent <=> _value_ is always +nil+ * OpenSSL::ASN1::Boolean <=> _value_ is +true+ or +false+ * OpenSSL::ASN1::Integer <=> _value_ is an OpenSSL::BN * OpenSSL::ASN1::BitString <=> _value_ is a String * OpenSSL::ASN1::OctetString <=> _value_ is a String * OpenSSL::ASN1::Null <=> _value_ is always +nil+ * OpenSSL::ASN1::Object <=> _value_ is a String * OpenSSL::ASN1::Enumerated <=> _value_ is an OpenSSL::BN * OpenSSL::ASN1::UTF8String <=> _value_ is a String * OpenSSL::ASN1::NumericString <=> _value_ is a String * OpenSSL::ASN1::PrintableString <=> _value_ is a String * OpenSSL::ASN1::T61String <=> _value_ is a String * OpenSSL::ASN1::VideotexString <=> _value_ is a String * OpenSSL::ASN1::IA5String <=> _value_ is a String * OpenSSL::ASN1::UTCTime <=> _value_ is a Time * OpenSSL::ASN1::GeneralizedTime <=> _value_ is a Time * OpenSSL::ASN1::GraphicString <=> _value_ is a String * OpenSSL::ASN1::ISO64String <=> _value_ is a String * OpenSSL::ASN1::GeneralString <=> _value_ is a String * OpenSSL::ASN1::UniversalString <=> _value_ is a String * OpenSSL::ASN1::BMPString <=> _value_ is a String == OpenSSL::ASN1::BitString === Additional attributes _unused_bits_: if the underlying BIT STRING's length is a multiple of 8 then _unused_bits_ is 0. Otherwise _unused_bits_ indicates the number of bits that are to be ignored in the final octet of the BitString's _value_. == OpenSSL::ASN1::ObjectId NOTE: While OpenSSL::ASN1::ObjectId.new will allocate a new ObjectId, it is not typically allocated this way, but rather that are received from parsed ASN1 encodings. === Additional attributes * _sn_: the short name as defined in . * _ln_: the long name as defined in . * _oid_: the object identifier as a String, e.g. "1.2.3.4.5" * _short_name_: alias for _sn_. * _long_name_: alias for _ln_. == Examples With the Exception of OpenSSL::ASN1::EndOfContent, each Primitive class constructor takes at least one parameter, the _value_. === Creating EndOfContent eoc = OpenSSL::ASN1::EndOfContent.new === Creating any other Primitive prim = .new(value) # being one of the sub-classes except EndOfContent prim_zero_tagged_implicit = .new(value, 0, :IMPLICIT) prim_zero_tagged_explicit = .new(value, 0, :EXPLICIT) ;T;#0;$@;.F;/o;0;1T;2i;3i;%@ƨ;&I"OpenSSL::ASN1::Primitive;F;'@o; ;IC;[o;4;5F;6;;;;&I"+OpenSSL::ASN1::Constructive#initialize;F;7[[@90;[[@1Hi1;T;;D;0;[;{;IC; "_value_: is mandatory. _tag_: optional, may be specified for tagged values. If no _tag_ is specified, the UNIVERSAL tag corresponding to the Primitive sub-class is used by default. _tagging_: may be used as an encoding hint to encode a value either explicitly or implicitly, see ASN1 for possible values. _tag_class_: if _tag_ and _tagging_ are +nil+ then this is set to +:UNIVERSAL+ by default. If either _tag_ or _tagging_ are set then +:CONTEXT_SPECIFIC+ is used as the default. For possible values please cf. ASN1. == Example int = OpenSSL::ASN1::Integer.new(42) zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :IMPLICIT) private_explicit_zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :EXPLICIT, :PRIVATE) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"EOpenSSL::ASN1::Primitive.new(value [, tag, tagging, tag_class ]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Primitive;T;$@B;![;"I"@return [Primitive];T;#0;$@B;.F;Bi;C0;7[[I"&value[, tag, tagging, tag_class ];T0;$@B;![;"@;#0;$@B;.F;/o;0;1T;2i;3i/;%@@;9I"=static VALUE ossl_asn1_initialize(int argc, VALUE *argv, VALUE self) { VALUE value, tag, tagging, tag_class; int default_tag; rb_scan_args(argc, argv, "13", &value, &tag, &tagging, &tag_class); default_tag = ossl_asn1_default_tag(self); if (default_tag == -1 || argc > 1) { if(NIL_P(tag)) ossl_raise(eASN1Error, "must specify tag number"); if(!NIL_P(tagging) && !SYMBOL_P(tagging)) ossl_raise(eASN1Error, "invalid tagging method"); if(NIL_P(tag_class)) { if (NIL_P(tagging)) tag_class = sym_UNIVERSAL; else tag_class = sym_CONTEXT_SPECIFIC; } if(!SYMBOL_P(tag_class)) ossl_raise(eASN1Error, "invalid tag class"); } else{ tag = INT2NUM(default_tag); tagging = Qnil; tag_class = sym_UNIVERSAL; } ossl_asn1_set_tag(self, tag); ossl_asn1_set_value(self, value); ossl_asn1_set_tagging(self, tagging); ossl_asn1_set_tag_class(self, tag_class); ossl_asn1_set_indefinite_length(self, Qfalse); if (default_tag == V_ASN1_BIT_STRING) rb_ivar_set(self, sivUNUSED_BITS, INT2FIX(0)); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::ASN1::Constructive#to_der;F;7[;[[@1Hi;T;;M;0;[;{;IC; "%See ASN1Data#to_der for details. ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" to_der;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"DER-encoded String;T;$@_;![;"I"!@return [DER-encoded String];T;#0;$@_;.F;Bi;C0;7[;$@_;![;"I"WSee ASN1Data#to_der for details. @overload to_der @return [DER-encoded String];T;#0;$@_;.F;/o;0;1T;2i;3i;%@@;9I"static VALUE ossl_asn1cons_to_der(VALUE self) { VALUE ary, str; long i; int indef_len; indef_len = RTEST(ossl_asn1_get_indefinite_length(self)); ary = rb_convert_type(ossl_asn1_get_value(self), T_ARRAY, "Array", "to_a"); str = rb_str_new(NULL, 0); for (i = 0; i < RARRAY_LEN(ary); i++) { VALUE item = RARRAY_AREF(ary, i); if (indef_len && rb_obj_is_kind_of(item, cASN1EndOfContent)) { if (i != RARRAY_LEN(ary) - 1) ossl_raise(eASN1Error, "illegal EOC octets in value"); /* * EOC is not really part of the content, but we required to add one * at the end in the past. */ break; } item = ossl_to_der_if_possible(item); StringValue(item); rb_str_append(str, item); } return to_der_internal(self, 1, indef_len, str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%OpenSSL::ASN1::Constructive#each;F;7[;[[@1Hi;T;;;0;[;{;IC; "Calls the given block once for each element in self, passing that element as parameter _asn1_. If no block is given, an enumerator is returned instead. == Example asn1_ary.each do |asn1| puts asn1 end ;T;[o;= ;>I" overload;F;?0;;;@0;:I" each;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" asn1;T;$@z;![;"I"@yield [asn1];T;#0;$@z;.F;Bi;C0;7[;$@z;![;"I"Calls the given block once for each element in self, passing that element as parameter _asn1_. If no block is given, an enumerator is returned instead. == Example asn1_ary.each do |asn1| puts asn1 end @overload each @yield [asn1];T;#0;$@z;.F;/o;0;1T;2i;3i;%@@;9I"static VALUE ossl_asn1cons_each(VALUE self) { rb_block_call(ossl_asn1_get_value(self), id_each, 0, 0, 0, 0); return self; };T;:I"static VALUE;T;;T; @@; IC;[; @@; IC;[@y,; @@; IC;{;IC;{;T;IC;{;T;T;{;[;[[@1Hi[@1Hi;T;:Constructive;;;;;[;{;IC; "pThe parent class for all constructed encodings. The _value_ attribute of a Constructive is always an Array. Attributes are the same as for ASN1Data, with the addition of _tagging_. == SET and SEQUENCE Most constructed encodings come in the form of a SET or a SEQUENCE. These encodings are represented by one of the two sub-classes of Constructive: * OpenSSL::ASN1::Set * OpenSSL::ASN1::Sequence Please note that tagged sequences and sets are still parsed as instances of ASN1Data. Find further details on tagged values there. === Example - constructing a SEQUENCE int = OpenSSL::ASN1::Integer.new(1) str = OpenSSL::ASN1::PrintableString.new('abc') sequence = OpenSSL::ASN1::Sequence.new( [ int, str ] ) === Example - constructing a SET int = OpenSSL::ASN1::Integer.new(1) str = OpenSSL::ASN1::PrintableString.new('abc') set = OpenSSL::ASN1::Set.new( [ int, str ] ) ;T;[;![;"I"r The parent class for all constructed encodings. The _value_ attribute of a Constructive is always an Array. Attributes are the same as for ASN1Data, with the addition of _tagging_. == SET and SEQUENCE Most constructed encodings come in the form of a SET or a SEQUENCE. These encodings are represented by one of the two sub-classes of Constructive: * OpenSSL::ASN1::Set * OpenSSL::ASN1::Sequence Please note that tagged sequences and sets are still parsed as instances of ASN1Data. Find further details on tagged values there. === Example - constructing a SEQUENCE int = OpenSSL::ASN1::Integer.new(1) str = OpenSSL::ASN1::PrintableString.new('abc') sequence = OpenSSL::ASN1::Sequence.new( [ int, str ] ) === Example - constructing a SET int = OpenSSL::ASN1::Integer.new(1) str = OpenSSL::ASN1::PrintableString.new('abc') set = OpenSSL::ASN1::Set.new( [ int, str ] ) ;T;#0;$@@;.F;/o;0;1T;2i;3i;%@ƨ;&I" OpenSSL::ASN1::Constructive;F;'@o; ;IC;[ o;4;5F;6;;;;&I"%OpenSSL::ASN1::ObjectId.register;F;7[[I"oid;T0[I"sn;T0[I"ln;T0;[[@1Hi;T;: register;0;[;{;IC; "This adds a new ObjectId to the internal tables. Where _object_id_ is the numerical form, _short_name_ is the short name, and _long_name_ is the long name. Returns +true+ if successful. Raises an OpenSSL::ASN1::ASN1Error if it fails. ;T;[o;= ;>I" overload;F;?0;:%OpenSSL::ASN1::ObjectId.register;@0;:I"GOpenSSL::ASN1::ObjectId.register(object_id, short_name, long_name);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"object_id;T0[I"short_name;T0[I"long_name;T0;$@;![;"I":This adds a new ObjectId to the internal tables. Where _object_id_ is the numerical form, _short_name_ is the short name, and _long_name_ is the long name. Returns +true+ if successful. Raises an OpenSSL::ASN1::ASN1Error if it fails. @overload OpenSSL::ASN1::ObjectId.register(object_id, short_name, long_name);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_asn1obj_s_register(VALUE self, VALUE oid, VALUE sn, VALUE ln) { StringValueCStr(oid); StringValueCStr(sn); StringValueCStr(ln); if(!OBJ_create(RSTRING_PTR(oid), RSTRING_PTR(sn), RSTRING_PTR(ln))) ossl_raise(eASN1Error, NULL); return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::ASN1::ObjectId#sn;F;7[;[[@1Hi;T;:sn;0;[;{;IC; "GThe short name of the ObjectId, as defined in . ;T;[o;= ;>I" overload;F;?0;;";@0;:I"sn;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@˪;![;"I"@return [String];T;#0;$@˪;.F;Bi;C0;7[;$@˪o;= ;>I" overload;F;?0;:short_name;@0;:I"short_name;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@˪;![;"I"@return [String];T;#0;$@˪;.F;Bi;C0;7[;$@˪;![;"I"The short name of the ObjectId, as defined in . @overload sn @return [String] @overload short_name @return [String];T;#0;$o;4;5F;6;;;;&I"'OpenSSL::ASN1::ObjectId#short_name;F;7[;[[@1Hi?;F;;#;;;[;{;@Ҫ;%@;9I"static VALUE ossl_asn1obj_get_sn(VALUE self) { VALUE val, ret = Qnil; int nid; val = ossl_asn1_get_value(self); if ((nid = OBJ_txt2nid(StringValueCStr(val))) != NID_undef) ret = rb_str_new2(OBJ_nid2sn(nid)); return ret; };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_asn1obj_get_sn(VALUE self) { VALUE val, ret = Qnil; int nid; val = ossl_asn1_get_value(self); if ((nid = OBJ_txt2nid(StringValueCStr(val))) != NID_undef) ret = rb_str_new2(OBJ_nid2sn(nid)); return ret; };T;:@;;To;4;5F;6;;;;&I"OpenSSL::ASN1::ObjectId#ln;F;7[;[[@1Hi;T;:ln;0;[;{;IC; "FThe long name of the ObjectId, as defined in . ;T;[o;= ;>I" overload;F;?0;;$;@0;:I"ln;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;:long_name;@0;:I"long_name;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"The long name of the ObjectId, as defined in . @overload ln @return [String] @overload long_name @return [String];T;#0;$o;4;5F;6;;;;&I"&OpenSSL::ASN1::ObjectId#long_name;F;7[;[[@1Hi@;F;;%;;;[;{;@;%@;9I"static VALUE ossl_asn1obj_get_ln(VALUE self) { VALUE val, ret = Qnil; int nid; val = ossl_asn1_get_value(self); if ((nid = OBJ_txt2nid(StringValueCStr(val))) != NID_undef) ret = rb_str_new2(OBJ_nid2ln(nid)); return ret; };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_asn1obj_get_ln(VALUE self) { VALUE val, ret = Qnil; int nid; val = ossl_asn1_get_value(self); if ((nid = OBJ_txt2nid(StringValueCStr(val))) != NID_undef) ret = rb_str_new2(OBJ_nid2ln(nid)); return ret; };T;:@(;;To;4;5F;6;;;;&I" OpenSSL::ASN1::ObjectId#oid;F;7[;[[@1HiI;T;;;0;[;{;IC; "^Returns a String representing the Object Identifier in the dot notation, e.g. "1.2.3.4.5" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"oid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@+;![;"I"@return [String];T;#0;$@+;.F;Bi;C0;7[;$@+;![;"I"|Returns a String representing the Object Identifier in the dot notation, e.g. "1.2.3.4.5" @overload oid @return [String];T;#0;$@+;.F;/o;0;1T;2iB;3iG;%@;9I"/static VALUE ossl_asn1obj_get_oid(VALUE self) { VALUE str; ASN1_OBJECT *a1obj; int state; a1obj = obj_to_asn1obj(ossl_asn1_get_value(self)); str = rb_protect(asn1obj_get_oid_i, (VALUE)a1obj, &state); ASN1_OBJECT_free(a1obj); if (state) rb_jump_tag(state); return str; };T;:I"static VALUE;T;;T@@ o;4;5F;6;;;;&I"OpenSSL::ASN1::ObjectId#==;F;7[[I" other;T0;[[@1Hi;T;;F;0;[;{;IC; "7Returns +true+ if _other_oid_ is the same as _oid_ ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(other_oid);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@F;![;"I"@return [Boolean];T;#0;$@F;.F;Bi;C0;7[[I"other_oid;T0;$@F;![;"I"eReturns +true+ if _other_oid_ is the same as _oid_ @overload ==(other_oid) @return [Boolean];T;#0;$@F;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_asn1obj_eq(VALUE self, VALUE other) { VALUE valSelf, valOther; int nidSelf, nidOther; valSelf = ossl_asn1_get_value(self); valOther = ossl_asn1_get_value(other); if ((nidSelf = OBJ_txt2nid(StringValueCStr(valSelf))) == NID_undef) ossl_raise(eASN1Error, "OBJ_txt2nid"); if ((nidOther = OBJ_txt2nid(StringValueCStr(valOther))) == NID_undef) ossl_raise(eASN1Error, "OBJ_txt2nid"); return nidSelf == nidOther ? Qtrue : Qfalse; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{@;"@ ;$;[;[[@1Hi4[@1Hi9;T;: ObjectId;;;;;[;{;IC; "9Represents the primitive object id for OpenSSL::ASN1 ;T;[;![;"I"; Represents the primitive object id for OpenSSL::ASN1 ;T;#0;$@;.F;/o;0;1T;2i4;3i6;%@ƨ;&I"OpenSSL::ASN1::ObjectId;F;'@; @ƨ; IC;[; @ƨ; IC;[; @ƨ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@1Hi[@1Hi ;T;: ASN1;;;;;[;{;IC; "Abstract Syntax Notation One (or ASN.1) is a notation syntax to describe data structures and is defined in ITU-T X.680. ASN.1 itself does not mandate any encoding or parsing rules, but usually ASN.1 data structures are encoded using the Distinguished Encoding Rules (DER) or less often the Basic Encoding Rules (BER) described in ITU-T X.690. DER and BER encodings are binary Tag-Length-Value (TLV) encodings that are quite concise compared to other popular data description formats such as XML, JSON etc. ASN.1 data structures are very common in cryptographic applications, e.g. X.509 public key certificates or certificate revocation lists (CRLs) are all defined in ASN.1 and DER-encoded. ASN.1, DER and BER are the building blocks of applied cryptography. The ASN1 module provides the necessary classes that allow generation of ASN.1 data structures and the methods to encode them using a DER encoding. The decode method allows parsing arbitrary BER-/DER-encoded data to a Ruby object that can then be modified and re-encoded at will. == ASN.1 class hierarchy The base class representing ASN.1 structures is ASN1Data. ASN1Data offers attributes to read and set the _tag_, the _tag_class_ and finally the _value_ of a particular ASN.1 item. Upon parsing, any tagged values (implicit or explicit) will be represented by ASN1Data instances because their "real type" can only be determined using out-of-band information from the ASN.1 type declaration. Since this information is normally known when encoding a type, all sub-classes of ASN1Data offer an additional attribute _tagging_ that allows to encode a value implicitly (+:IMPLICIT+) or explicitly (+:EXPLICIT+). === Constructive Constructive is, as its name implies, the base class for all constructed encodings, i.e. those that consist of several values, opposed to "primitive" encodings with just one single value. The value of an Constructive is always an Array. ==== ASN1::Set and ASN1::Sequence The most common constructive encodings are SETs and SEQUENCEs, which is why there are two sub-classes of Constructive representing each of them. === Primitive This is the super class of all primitive values. Primitive itself is not used when parsing ASN.1 data, all values are either instances of a corresponding sub-class of Primitive or they are instances of ASN1Data if the value was tagged implicitly or explicitly. Please cf. Primitive documentation for details on sub-classes and their respective mappings of ASN.1 data types to Ruby objects. == Possible values for _tagging_ When constructing an ASN1Data object the ASN.1 type definition may require certain elements to be either implicitly or explicitly tagged. This can be achieved by setting the _tagging_ attribute manually for sub-classes of ASN1Data. Use the symbol +:IMPLICIT+ for implicit tagging and +:EXPLICIT+ if the element requires explicit tagging. == Possible values for _tag_class_ It is possible to create arbitrary ASN1Data objects that also support a PRIVATE or APPLICATION tag class. Possible values for the _tag_class_ attribute are: * +:UNIVERSAL+ (the default for untagged values) * +:CONTEXT_SPECIFIC+ (the default for tagged values) * +:APPLICATION+ * +:PRIVATE+ == Tag constants There is a constant defined for each universal tag: * OpenSSL::ASN1::EOC (0) * OpenSSL::ASN1::BOOLEAN (1) * OpenSSL::ASN1::INTEGER (2) * OpenSSL::ASN1::BIT_STRING (3) * OpenSSL::ASN1::OCTET_STRING (4) * OpenSSL::ASN1::NULL (5) * OpenSSL::ASN1::OBJECT (6) * OpenSSL::ASN1::ENUMERATED (10) * OpenSSL::ASN1::UTF8STRING (12) * OpenSSL::ASN1::SEQUENCE (16) * OpenSSL::ASN1::SET (17) * OpenSSL::ASN1::NUMERICSTRING (18) * OpenSSL::ASN1::PRINTABLESTRING (19) * OpenSSL::ASN1::T61STRING (20) * OpenSSL::ASN1::VIDEOTEXSTRING (21) * OpenSSL::ASN1::IA5STRING (22) * OpenSSL::ASN1::UTCTIME (23) * OpenSSL::ASN1::GENERALIZEDTIME (24) * OpenSSL::ASN1::GRAPHICSTRING (25) * OpenSSL::ASN1::ISO64STRING (26) * OpenSSL::ASN1::GENERALSTRING (27) * OpenSSL::ASN1::UNIVERSALSTRING (28) * OpenSSL::ASN1::BMPSTRING (30) == UNIVERSAL_TAG_NAME constant An Array that stores the name of a given tag number. These names are the same as the name of the tag constant that is additionally defined, e.g. +UNIVERSAL_TAG_NAME[2] = "INTEGER"+ and +OpenSSL::ASN1::INTEGER = 2+. == Example usage === Decoding and viewing a DER-encoded file require 'openssl' require 'pp' der = File.binread('data.der') asn1 = OpenSSL::ASN1.decode(der) pp der === Creating an ASN.1 structure and DER-encoding it require 'openssl' version = OpenSSL::ASN1::Integer.new(1) # Explicitly 0-tagged implies context-specific tag class serial = OpenSSL::ASN1::Integer.new(12345, 0, :EXPLICIT, :CONTEXT_SPECIFIC) name = OpenSSL::ASN1::PrintableString.new('Data 1') sequence = OpenSSL::ASN1::Sequence.new( [ version, serial, name ] ) der = sequence.to_der;T;[;![;"I" Abstract Syntax Notation One (or ASN.1) is a notation syntax to describe data structures and is defined in ITU-T X.680. ASN.1 itself does not mandate any encoding or parsing rules, but usually ASN.1 data structures are encoded using the Distinguished Encoding Rules (DER) or less often the Basic Encoding Rules (BER) described in ITU-T X.690. DER and BER encodings are binary Tag-Length-Value (TLV) encodings that are quite concise compared to other popular data description formats such as XML, JSON etc. ASN.1 data structures are very common in cryptographic applications, e.g. X.509 public key certificates or certificate revocation lists (CRLs) are all defined in ASN.1 and DER-encoded. ASN.1, DER and BER are the building blocks of applied cryptography. The ASN1 module provides the necessary classes that allow generation of ASN.1 data structures and the methods to encode them using a DER encoding. The decode method allows parsing arbitrary BER-/DER-encoded data to a Ruby object that can then be modified and re-encoded at will. == ASN.1 class hierarchy The base class representing ASN.1 structures is ASN1Data. ASN1Data offers attributes to read and set the _tag_, the _tag_class_ and finally the _value_ of a particular ASN.1 item. Upon parsing, any tagged values (implicit or explicit) will be represented by ASN1Data instances because their "real type" can only be determined using out-of-band information from the ASN.1 type declaration. Since this information is normally known when encoding a type, all sub-classes of ASN1Data offer an additional attribute _tagging_ that allows to encode a value implicitly (+:IMPLICIT+) or explicitly (+:EXPLICIT+). === Constructive Constructive is, as its name implies, the base class for all constructed encodings, i.e. those that consist of several values, opposed to "primitive" encodings with just one single value. The value of an Constructive is always an Array. ==== ASN1::Set and ASN1::Sequence The most common constructive encodings are SETs and SEQUENCEs, which is why there are two sub-classes of Constructive representing each of them. === Primitive This is the super class of all primitive values. Primitive itself is not used when parsing ASN.1 data, all values are either instances of a corresponding sub-class of Primitive or they are instances of ASN1Data if the value was tagged implicitly or explicitly. Please cf. Primitive documentation for details on sub-classes and their respective mappings of ASN.1 data types to Ruby objects. == Possible values for _tagging_ When constructing an ASN1Data object the ASN.1 type definition may require certain elements to be either implicitly or explicitly tagged. This can be achieved by setting the _tagging_ attribute manually for sub-classes of ASN1Data. Use the symbol +:IMPLICIT+ for implicit tagging and +:EXPLICIT+ if the element requires explicit tagging. == Possible values for _tag_class_ It is possible to create arbitrary ASN1Data objects that also support a PRIVATE or APPLICATION tag class. Possible values for the _tag_class_ attribute are: * +:UNIVERSAL+ (the default for untagged values) * +:CONTEXT_SPECIFIC+ (the default for tagged values) * +:APPLICATION+ * +:PRIVATE+ == Tag constants There is a constant defined for each universal tag: * OpenSSL::ASN1::EOC (0) * OpenSSL::ASN1::BOOLEAN (1) * OpenSSL::ASN1::INTEGER (2) * OpenSSL::ASN1::BIT_STRING (3) * OpenSSL::ASN1::OCTET_STRING (4) * OpenSSL::ASN1::NULL (5) * OpenSSL::ASN1::OBJECT (6) * OpenSSL::ASN1::ENUMERATED (10) * OpenSSL::ASN1::UTF8STRING (12) * OpenSSL::ASN1::SEQUENCE (16) * OpenSSL::ASN1::SET (17) * OpenSSL::ASN1::NUMERICSTRING (18) * OpenSSL::ASN1::PRINTABLESTRING (19) * OpenSSL::ASN1::T61STRING (20) * OpenSSL::ASN1::VIDEOTEXSTRING (21) * OpenSSL::ASN1::IA5STRING (22) * OpenSSL::ASN1::UTCTIME (23) * OpenSSL::ASN1::GENERALIZEDTIME (24) * OpenSSL::ASN1::GRAPHICSTRING (25) * OpenSSL::ASN1::ISO64STRING (26) * OpenSSL::ASN1::GENERALSTRING (27) * OpenSSL::ASN1::UNIVERSALSTRING (28) * OpenSSL::ASN1::BMPSTRING (30) == UNIVERSAL_TAG_NAME constant An Array that stores the name of a given tag number. These names are the same as the name of the tag constant that is additionally defined, e.g. +UNIVERSAL_TAG_NAME[2] = "INTEGER"+ and +OpenSSL::ASN1::INTEGER = 2+. == Example usage === Decoding and viewing a DER-encoded file require 'openssl' require 'pp' der = File.binread('data.der') asn1 = OpenSSL::ASN1.decode(der) pp der === Creating an ASN.1 structure and DER-encoding it require 'openssl' version = OpenSSL::ASN1::Integer.new(1) # Explicitly 0-tagged implies context-specific tag class serial = OpenSSL::ASN1::Integer.new(12345, 0, :EXPLICIT, :CONTEXT_SPECIFIC) name = OpenSSL::ASN1::PrintableString.new('Data 1') sequence = OpenSSL::ASN1::Sequence.new( [ version, serial, name ] ) der = sequence.to_der ;T;#0;$@ƨ;.F;/o;0;1T;2i;3i;Bi;%@GH;&I"OpenSSL::ASN1;Fo;;IC;[o;u;[[@9Hi8 ;F;:HAVE_TLSEXT_HOST_NAME;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I".OpenSSL::ExtConfig::HAVE_TLSEXT_HOST_NAME;F;xI" Qtrue;To;u;[[@9Hi [@9Hi ;F;:OPENSSL_NO_SOCK;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"(OpenSSL::ExtConfig::OPENSSL_NO_SOCK;F;xI" Qfalse;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@9Hi [@9Hi ;T;:ExtConfig;;;;;[;{;IC; "0This module contains configuration information about the SSL extension, for example if socket support is enabled, or the host name TLS extension is enabled. Constants in this module will always be defined, but contain +true+ or +false+ values depending on the configuration of your OpenSSL installation. ;T;[;![;"I"2 This module contains configuration information about the SSL extension, for example if socket support is enabled, or the host name TLS extension is enabled. Constants in this module will always be defined, but contain +true+ or +false+ values depending on the configuration of your OpenSSL installation. ;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@GH;&I"OpenSSL::ExtConfig;Fo; ;IC;[o;4;5F;6;;;;&I"OpenSSL::Config.parse;F;7[[I"str;T0;[[@;HiV;T;: parse;0;[;{;IC; "OParses a given _string_ as a blob that contains configuration for OpenSSL. ;T;[o;= ;>I" overload;F;?0;;+;@0;:I"parse(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"OpenSSL::Config;T;$@;![;"I"@return [OpenSSL::Config];T;#0;$@;.F;Bi;C0;7[[I" string;T0;$@;![;"I"Parses a given _string_ as a blob that contains configuration for OpenSSL. @overload parse(string) @return [OpenSSL::Config];T;#0;$@;.F;/o;0;1T;2iP;3iT;%@;9I"static VALUE config_s_parse(VALUE klass, VALUE str) { VALUE obj = config_s_alloc(klass); CONF *conf = GetConfig(obj); BIO *bio; bio = ossl_obj2bio(&str); config_load_bio(conf, bio); /* Consumes BIO */ return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!OpenSSL::Config.parse_config;F;7[[I"io;T0;[[@;Hil;T;:parse_config;0;[;{;IC; "ZParses the configuration data read from _io_ and returns the whole content as a Hash. ;T;[o;= ;>I" overload;F;?0;;,;@0;:I"parse_config(io);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@ӫ;![;"I"@return [Hash];T;#0;$@ӫ;.F;Bi;C0;7[[I"io;T0;$@ӫ;![;"I"Parses the configuration data read from _io_ and returns the whole content as a Hash. @overload parse_config(io) @return [Hash];T;#0;$@ӫ;.F;/o;0;1T;2ie;3ij;%@;9I"static VALUE config_s_parse_config(VALUE klass, VALUE io) { VALUE obj, sections, ret; long i; obj = config_s_parse(klass, io); sections = config_get_sections(obj); ret = rb_hash_new(); for (i = 0; i < RARRAY_LEN(sections); i++) { VALUE section = rb_ary_entry(sections, i); rb_hash_aset(ret, section, config_get_section(obj, section)); } return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Config#initialize;F;7[[@90;[[@;Hi;T;;D;0;[;{;IC; "UCreates an instance of OpenSSL::Config from the content of the file specified by _filename_. This can be used in contexts like OpenSSL::X509::ExtensionFactory.config= This can raise IO exceptions based on the access, or availability of the file. A ConfigError exception may be raised depending on the validity of the data being configured. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(filename);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"OpenSSL::Config;T;$@;![;"I"@return [OpenSSL::Config];T;#0;$@;.F;Bi;C0;7[[I" filename;T0;$@;![;"I"Creates an instance of OpenSSL::Config from the content of the file specified by _filename_. This can be used in contexts like OpenSSL::X509::ExtensionFactory.config= This can raise IO exceptions based on the access, or availability of the file. A ConfigError exception may be raised depending on the validity of the data being configured. @overload new(filename) @return [OpenSSL::Config];T;#0;$@;.F;/o;0;1T;2i|;3i;%@;9I"static VALUE config_initialize(int argc, VALUE *argv, VALUE self) { CONF *conf = GetConfig(self); VALUE filename; /* 0-arguments call has no use-case, but is kept for compatibility */ rb_scan_args(argc, argv, "01", &filename); rb_check_frozen(self); if (!NIL_P(filename)) { BIO *bio = BIO_new_file(StringValueCStr(filename), "rb"); if (!bio) ossl_raise(eConfigError, "BIO_new_file"); config_load_bio(conf, bio); /* Consumes BIO */ } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$OpenSSL::Config#initialize_copy;F;7[[I" other;T0;[[@;Hi;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"0static VALUE config_initialize_copy(VALUE self, VALUE other) { CONF *conf = GetConfig(self); VALUE str; BIO *bio; str = rb_funcall(other, rb_intern("to_s"), 0); rb_check_frozen(self); bio = ossl_obj2bio(&str); config_load_bio(conf, bio); /* Consumes BIO */ return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Config#get_value;F;7[[I" section;T0[I"key;T0;[[@;Hi;T;;;0;[;{;IC; "Gets the value of _key_ from the given _section_. Given the following configurating file being loaded: config = OpenSSL::Config.load('foo.cnf') #=> # puts config.to_s #=> [ default ] # foo=bar You can get a specific value from the config if you know the _section_ and _key_ like so: config.get_value('default','foo') #=> "bar" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"get_value(section, key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I" section;T0[I"key;T0;$@;![;"I"Gets the value of _key_ from the given _section_. Given the following configurating file being loaded: config = OpenSSL::Config.load('foo.cnf') #=> # puts config.to_s #=> [ default ] # foo=bar You can get a specific value from the config if you know the _section_ and _key_ like so: config.get_value('default','foo') #=> "bar" @overload get_value(section, key) @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE config_get_value(VALUE self, VALUE section, VALUE key) { CONF *conf = GetConfig(self); const char *str, *sectionp; StringValueCStr(section); StringValueCStr(key); /* For compatibility; NULL means "default". */ sectionp = RSTRING_LEN(section) ? RSTRING_PTR(section) : NULL; str = NCONF_get_string(conf, sectionp, RSTRING_PTR(key)); if (!str) { ossl_clear_error(); return Qnil; } return rb_str_new_cstr(str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Config#[];F;7[[I" section;T0;[[@;Hi;T;;;0;[;{;IC; "zGets all key-value pairs in a specific _section_ from the current configuration. Given the following configurating file being loaded: config = OpenSSL::Config.load('foo.cnf') #=> # puts config.to_s #=> [ default ] # foo=bar You can get a hash of the specific section like so: config['default'] #=> {"foo"=>"bar"} ;T;[o;= ;>I" overload;F;?0;;;@0;:I"[](section);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@A;![;"I"@return [Hash];T;#0;$@A;.F;Bi;C0;7[[I" section;T0;$@A;![;"I"Gets all key-value pairs in a specific _section_ from the current configuration. Given the following configurating file being loaded: config = OpenSSL::Config.load('foo.cnf') #=> # puts config.to_s #=> [ default ] # foo=bar You can get a hash of the specific section like so: config['default'] #=> {"foo"=>"bar"} @overload [](section) @return [Hash];T;#0;$@A;.F;/o;0;1T;2i;3i;%@;9I"Ystatic VALUE config_get_section(VALUE self, VALUE section) { CONF *conf = GetConfig(self); STACK_OF(CONF_VALUE) *sk; int i, entries; VALUE hash; hash = rb_hash_new(); StringValueCStr(section); if (!(sk = NCONF_get_section(conf, RSTRING_PTR(section)))) { ossl_clear_error(); return hash; } entries = sk_CONF_VALUE_num(sk); for (i = 0; i < entries; i++) { CONF_VALUE *entry = sk_CONF_VALUE_value(sk, i); rb_hash_aset(hash, rb_str_new_cstr(entry->name), rb_str_new_cstr(entry->value)); } return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Config#sections;F;7[;[[@;Hib;T;: sections;0;[;{;IC; " ;T;[;![;"@;#0;$@`;%@;9I"2static VALUE config_get_sections(VALUE self);;T;:I"2static VALUE config_get_sections(VALUE self);;T;;To;4;5F;6;;;;&I"OpenSSL::Config#to_s;F;7[;[;F;;G;;;[;{;IC; " ;T;[;![;"@;#0;$@l;%@;;To;4;5F;6;;;;&I"OpenSSL::Config#each;F;7[;[;F;;;;;[;{;IC; " ;T;[;![;"@;#0;$@u;%@;;To;4;5F;6;;;;&I"OpenSSL::Config#inspect;F;7[;[[@;Hi;T;;J;0;[;{;IC; "cString representation of this configuration object, including the class name and its sections. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@~;![;"I"@return [String];T;#0;$@~;.F;Bi;C0;7[;$@~;![;"I"String representation of this configuration object, including the class name and its sections. @overload inspect @return [String];T;#0;$@~;.F;/o;0;1T;2i;3i;%@;9I"Zstatic VALUE config_inspect(VALUE self) { VALUE str, ary = config_get_sections(self); const char *cname = rb_class2name(rb_obj_class(self)); str = rb_str_new_cstr("#<"); rb_str_cat_cstr(str, cname); rb_str_cat_cstr(str, " sections="); rb_str_append(str, rb_inspect(ary)); rb_str_cat_cstr(str, ">"); return str; };T;:I"static VALUE;T;;To;u;[[@;Hi;F;:DEFAULT_CONFIG_FILE;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I")OpenSSL::Config::DEFAULT_CONFIG_FILE;F;xI" path_str;T; @; IC;[; @; IC;[@y,; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@;Hi[@;Hi;T;: Config;;;;;[;{;IC; "Configuration for the openssl library. Many system's installation of openssl library will depend on your system configuration. See the value of OpenSSL::Config::DEFAULT_CONFIG_FILE for the location of the file for your host. See also http://www.openssl.org/docs/apps/config.html ;T;[;![;"I" Configuration for the openssl library. Many system's installation of openssl library will depend on your system configuration. See the value of OpenSSL::Config::DEFAULT_CONFIG_FILE for the location of the file for your host. See also http://www.openssl.org/docs/apps/config.html ;T;#0;$@;.F;/o;0;1T;2i;3i;%@GH;&I"OpenSSL::Config;F;'@o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@;Hi[@;Hi;T;:ConfigError;;;;;[;{;IC; "fGeneral error for openssl library configuration files. Including formatting, parsing errors, etc. ;T;[;![;"I"h General error for openssl library configuration files. Including formatting, parsing errors, etc. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@GH;&I"OpenSSL::ConfigError;F;'@Ho; ;IC;[o; ;IC;[; @ˬ; IC;[; @ˬ; IC;[; @ˬ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@?Hi.[@?Hi;T;:EngineError;;;;;[;{;IC; "EThis is the generic exception for OpenSSL::Engine related errors ;T;[;![;"I"G This is the generic exception for OpenSSL::Engine related errors ;T;#0;$@ˬ;.F;/o;0;1T;2i.;3i0;%o;( ;)@;*I"OpenSSL::Engine;T;+0;: Engine;%o;( ;)0;*0;+0;;;%@;-@GH;0;-@ɬ;0;&I"!OpenSSL::Engine::EngineError;F;'@Ho;4;5F;6;;;;&I"OpenSSL::Engine.load;F;7[[@90;[[@?Hic;T;;;0;[;{;IC; "This method loads engines. If _name_ is nil, then all builtin engines are loaded. Otherwise, the given _name_, as a String, is loaded if available to your runtime, and returns true. If _name_ is not found, then nil is returned. ;T;[o;= ;>I" overload;F;?0;:OpenSSL::Engine.load;@0;:I"%OpenSSL::Engine.load(name = nil);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" name;TI"nil;T;$@;![;"I"This method loads engines. If _name_ is nil, then all builtin engines are loaded. Otherwise, the given _name_, as a String, is loaded if available to your runtime, and returns true. If _name_ is not found, then nil is returned. @overload OpenSSL::Engine.load(name = nil);T;#0;$@;.F;/o;0;1T;2iY;3i`;%@ɬ;9I"7static VALUE ossl_engine_s_load(int argc, VALUE *argv, VALUE klass) { VALUE name; rb_scan_args(argc, argv, "01", &name); if(NIL_P(name)){ ENGINE_load_builtin_engines(); return Qtrue; } StringValueCStr(name); #ifdef HAVE_ENGINE_LOAD_DYNAMIC OSSL_ENGINE_LOAD_IF_MATCH(dynamic, DYNAMIC); #endif #ifndef OPENSSL_NO_STATIC_ENGINE #ifdef HAVE_ENGINE_LOAD_4758CCA OSSL_ENGINE_LOAD_IF_MATCH(4758cca, 4758CCA); #endif #ifdef HAVE_ENGINE_LOAD_AEP OSSL_ENGINE_LOAD_IF_MATCH(aep, AEP); #endif #ifdef HAVE_ENGINE_LOAD_ATALLA OSSL_ENGINE_LOAD_IF_MATCH(atalla, ATALLA); #endif #ifdef HAVE_ENGINE_LOAD_CHIL OSSL_ENGINE_LOAD_IF_MATCH(chil, CHIL); #endif #ifdef HAVE_ENGINE_LOAD_CSWIFT OSSL_ENGINE_LOAD_IF_MATCH(cswift, CSWIFT); #endif #ifdef HAVE_ENGINE_LOAD_NURON OSSL_ENGINE_LOAD_IF_MATCH(nuron, NURON); #endif #ifdef HAVE_ENGINE_LOAD_SUREWARE OSSL_ENGINE_LOAD_IF_MATCH(sureware, SUREWARE); #endif #ifdef HAVE_ENGINE_LOAD_UBSEC OSSL_ENGINE_LOAD_IF_MATCH(ubsec, UBSEC); #endif #ifdef HAVE_ENGINE_LOAD_PADLOCK OSSL_ENGINE_LOAD_IF_MATCH(padlock, PADLOCK); #endif #ifdef HAVE_ENGINE_LOAD_CAPI OSSL_ENGINE_LOAD_IF_MATCH(capi, CAPI); #endif #ifdef HAVE_ENGINE_LOAD_GMP OSSL_ENGINE_LOAD_IF_MATCH(gmp, GMP); #endif #ifdef HAVE_ENGINE_LOAD_GOST OSSL_ENGINE_LOAD_IF_MATCH(gost, GOST); #endif #endif #ifdef HAVE_ENGINE_LOAD_CRYPTODEV OSSL_ENGINE_LOAD_IF_MATCH(cryptodev, CRYPTODEV); #endif OSSL_ENGINE_LOAD_IF_MATCH(openssl, OPENSSL); rb_warning("no such builtin loader for `%"PRIsVALUE"'", name); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Engine.cleanup;F;7[;[[@?Hi;T;: cleanup;0;[;{;IC; "It is only necessary to run cleanup when engines are loaded via OpenSSL::Engine.load. However, running cleanup before exit is recommended. Note that this is needed and works only in OpenSSL < 1.1.0. ;T;[o;= ;>I" overload;F;?0;:OpenSSL::Engine.cleanup;@0;:I"OpenSSL::Engine.cleanup;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"It is only necessary to run cleanup when engines are loaded via OpenSSL::Engine.load. However, running cleanup before exit is recommended. Note that this is needed and works only in OpenSSL < 1.1.0. @overload OpenSSL::Engine.cleanup;T;#0;$@;.F;/o;0;1T;2i;3i;%@ɬ;9I"static VALUE ossl_engine_s_cleanup(VALUE self) { #if defined(LIBRESSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000 ENGINE_cleanup(); #endif return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Engine.engines;F;7[;[[@?Hi;T;: engines;0;[;{;IC; "2Returns an array of currently loaded engines. ;T;[o;= ;>I" overload;F;?0;:OpenSSL::Engine.engines;@0;:I"OpenSSL::Engine.engines;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"hReturns an array of currently loaded engines. @overload OpenSSL::Engine.engines @return [Array];T;#0;$@;.F;/o;0;1T;2i;3i;%@ɬ;9I"static VALUE ossl_engine_s_engines(VALUE klass) { ENGINE *e; VALUE ary, obj; ary = rb_ary_new(); for(e = ENGINE_get_first(); e; e = ENGINE_get_next(e)){ obj = NewEngine(klass); /* Need a ref count of two here because of ENGINE_free being * called internally by OpenSSL when moving to the next ENGINE * and by us when releasing the ENGINE reference */ ENGINE_up_ref(e); SetEngine(obj, e); rb_ary_push(ary, obj); } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Engine.by_id;F;7[[I"id;T0;[[@?Hi;T;: by_id;0;[;{;IC; "Fetches the engine as specified by the _id_ String. OpenSSL::Engine.by_id("openssl") => # See OpenSSL::Engine.engines for the currently loaded engines. ;T;[o;= ;>I" overload;F;?0;:OpenSSL::Engine.by_id;@0;:I" OpenSSL::Engine.by_id(name);T;IC; ";T;[;![;"I";T;#0;$@-;.F;Bi;C0;7[[I" name;T0;$@-;![;"I"Fetches the engine as specified by the _id_ String. OpenSSL::Engine.by_id("openssl") => # See OpenSSL::Engine.engines for the currently loaded engines. @overload OpenSSL::Engine.by_id(name);T;#0;$@-;.F;/o;0;1T;2i;3i;%@ɬ;9I" static VALUE ossl_engine_s_by_id(VALUE klass, VALUE id) { ENGINE *e; VALUE obj; StringValueCStr(id); ossl_engine_s_load(1, &id, klass); obj = NewEngine(klass); if(!(e = ENGINE_by_id(RSTRING_PTR(id)))) ossl_raise(eEngineError, NULL); SetEngine(obj, e); if(rb_block_given_p()) rb_yield(obj); if(!ENGINE_init(e)) ossl_raise(eEngineError, NULL); ENGINE_ctrl(e, ENGINE_CTRL_SET_PASSWORD_CALLBACK, 0, NULL, (void(*)(void))ossl_pem_passwd_cb); ossl_clear_error(); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Engine#id;F;7[;[[@?Hi;T;;[;0;[;{;IC; "Gets the id for this engine. OpenSSL::Engine.load OpenSSL::Engine.engines #=> [#, ...] OpenSSL::Engine.engines.first.id #=> "rsax" ;T;[o;= ;>I" overload;F;?0;;[;@0;:I"id;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@G;![;"I"@return [String];T;#0;$@G;.F;Bi;C0;7[;$@G;![;"I"Gets the id for this engine. OpenSSL::Engine.load OpenSSL::Engine.engines #=> [#, ...] OpenSSL::Engine.engines.first.id #=> "rsax" @overload id @return [String];T;#0;$@G;.F;/o;0;1T;2i;3i;%@ɬ;9I"static VALUE ossl_engine_get_id(VALUE self) { ENGINE *e; GetEngine(self, e); return rb_str_new2(ENGINE_get_id(e)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Engine#name;F;7[;[[@?Hi;T;;F;0;[;{;IC; "Get the descriptive name for this engine. OpenSSL::Engine.load OpenSSL::Engine.engines #=> [#, ...] OpenSSL::Engine.engines.first.name #=> "RSAX engine support" ;T;[o;= ;>I" overload;F;?0;;F;@0;:I" name;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@b;![;"I"@return [String];T;#0;$@b;.F;Bi;C0;7[;$@b;![;"I"Get the descriptive name for this engine. OpenSSL::Engine.load OpenSSL::Engine.engines #=> [#, ...] OpenSSL::Engine.engines.first.name #=> "RSAX engine support" @overload name @return [String];T;#0;$@b;.F;/o;0;1T;2i;3i;%@ɬ;9I"static VALUE ossl_engine_get_name(VALUE self) { ENGINE *e; GetEngine(self, e); return rb_str_new2(ENGINE_get_name(e)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Engine#finish;F;7[;[[@?Hi;T;;!;0;[;{;IC; "xReleases all internal structural references for this engine. May raise an EngineError if the engine is unavailable ;T;[o;= ;>I" overload;F;?0;;!;@0;:I" finish;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@};![;"I"@return [nil];T;#0;$@};.F;Bi;C0;7[;$@};![;"I"Releases all internal structural references for this engine. May raise an EngineError if the engine is unavailable @overload finish @return [nil];T;#0;$@};.F;/o;0;1T;2i;3i;%@ɬ;9I"static VALUE ossl_engine_finish(VALUE self) { ENGINE *e; GetEngine(self, e); if(!ENGINE_finish(e)) ossl_raise(eEngineError, NULL); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Engine#cipher;F;7[[I" name;T0;[[@?Hi0;T;;;0;[;{;IC; "AReturns a new instance of OpenSSL::Cipher by _name_, if it is available in this engine. An EngineError will be raised if the cipher is unavailable. e = OpenSSL::Engine.by_id("openssl") => # e.cipher("RC4") => # ;T;[o;= ;>I" overload;F;?0;;;@0;:I"cipher(name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"OpenSSL::Cipher;T;$@;![;"I"@return [OpenSSL::Cipher];T;#0;$@;.F;Bi;C0;7[[I" name;T0;$@;![;"I"wReturns a new instance of OpenSSL::Cipher by _name_, if it is available in this engine. An EngineError will be raised if the cipher is unavailable. e = OpenSSL::Engine.by_id("openssl") => # e.cipher("RC4") => # @overload cipher(name) @return [OpenSSL::Cipher];T;#0;$@;.F;/o;0;1T;2i!;3i.;%@ɬ;9I"static VALUE ossl_engine_get_cipher(VALUE self, VALUE name) { ENGINE *e; const EVP_CIPHER *ciph, *tmp; int nid; tmp = EVP_get_cipherbyname(StringValueCStr(name)); if(!tmp) ossl_raise(eEngineError, "no such cipher `%"PRIsVALUE"'", name); nid = EVP_CIPHER_nid(tmp); GetEngine(self, e); ciph = ENGINE_get_cipher(e, nid); if(!ciph) ossl_raise(eEngineError, NULL); return ossl_cipher_new(ciph); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Engine#digest;F;7[[I" name;T0;[[@?HiP;T;;$;0;[;{;IC; "zReturns a new instance of OpenSSL::Digest by _name_. Will raise an EngineError if the digest is unavailable. e = OpenSSL::Engine.by_id("openssl") #=> # e.digest("SHA1") #=> # e.digest("zomg") #=> OpenSSL::Engine::EngineError: no such digest `zomg' ;T;[o;= ;>I" overload;F;?0;;$;@0;:I"digest(name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"OpenSSL::Digest;T;$@;![;"I"@return [OpenSSL::Digest];T;#0;$@;.F;Bi;C0;7[[I" name;T0;$@;![;"I"Returns a new instance of OpenSSL::Digest by _name_. Will raise an EngineError if the digest is unavailable. e = OpenSSL::Engine.by_id("openssl") #=> # e.digest("SHA1") #=> # e.digest("zomg") #=> OpenSSL::Engine::EngineError: no such digest `zomg' @overload digest(name) @return [OpenSSL::Digest];T;#0;$@;.F;/o;0;1T;2iA;3iN;%@ɬ;9I"static VALUE ossl_engine_get_digest(VALUE self, VALUE name) { ENGINE *e; const EVP_MD *md, *tmp; int nid; tmp = EVP_get_digestbyname(StringValueCStr(name)); if(!tmp) ossl_raise(eEngineError, "no such digest `%"PRIsVALUE"'", name); nid = EVP_MD_nid(tmp); GetEngine(self, e); md = ENGINE_get_digest(e, nid); if(!md) ossl_raise(eEngineError, NULL); return ossl_digest_new(md); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%OpenSSL::Engine#load_private_key;F;7[[@90;[[@?Hij;T;:load_private_key;0;[;{;IC; "~Loads the given private key identified by _id_ and _data_. An EngineError is raised of the OpenSSL::PKey is unavailable. ;T;[o;= ;>I" overload;F;?0;;:;@0;:I"+load_private_key(id = nil, data = nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"OpenSSL::PKey;T;$@֭;![;"I"@return [OpenSSL::PKey];T;#0;$@֭;.F;Bi;C0;7[[I"id;TI"nil;T[I" data;TI"nil;T;$@֭;![;"I"Loads the given private key identified by _id_ and _data_. An EngineError is raised of the OpenSSL::PKey is unavailable. @overload load_private_key(id = nil, data = nil) @return [OpenSSL::PKey];T;#0;$@֭;.F;/o;0;1T;2ia;3ih;%@ɬ;9I" static VALUE ossl_engine_load_privkey(int argc, VALUE *argv, VALUE self) { ENGINE *e; EVP_PKEY *pkey; VALUE id, data, obj; char *sid, *sdata; rb_scan_args(argc, argv, "02", &id, &data); sid = NIL_P(id) ? NULL : StringValueCStr(id); sdata = NIL_P(data) ? NULL : StringValueCStr(data); GetEngine(self, e); pkey = ENGINE_load_private_key(e, sid, NULL, sdata); if (!pkey) ossl_raise(eEngineError, NULL); obj = ossl_pkey_new(pkey); OSSL_PKEY_SET_PRIVATE(obj); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$OpenSSL::Engine#load_public_key;F;7[[@90;[[@?Hi;T;:load_public_key;0;[;{;IC; "}Loads the given public key identified by _id_ and _data_. An EngineError is raised of the OpenSSL::PKey is unavailable. ;T;[o;= ;>I" overload;F;?0;;;;@0;:I"*load_public_key(id = nil, data = nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"OpenSSL::PKey;T;$@;![;"I"@return [OpenSSL::PKey];T;#0;$@;.F;Bi;C0;7[[I"id;TI"nil;T[I" data;TI"nil;T;$@;![;"I"Loads the given public key identified by _id_ and _data_. An EngineError is raised of the OpenSSL::PKey is unavailable. @overload load_public_key(id = nil, data = nil) @return [OpenSSL::PKey];T;#0;$@;.F;/o;0;1T;2i~;3i;%@ɬ;9I"static VALUE ossl_engine_load_pubkey(int argc, VALUE *argv, VALUE self) { ENGINE *e; EVP_PKEY *pkey; VALUE id, data; char *sid, *sdata; rb_scan_args(argc, argv, "02", &id, &data); sid = NIL_P(id) ? NULL : StringValueCStr(id); sdata = NIL_P(data) ? NULL : StringValueCStr(data); GetEngine(self, e); pkey = ENGINE_load_public_key(e, sid, NULL, sdata); if (!pkey) ossl_raise(eEngineError, NULL); return ossl_pkey_new(pkey); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" OpenSSL::Engine#set_default;F;7[[I" flag;T0;[[@?Hi;T;:set_default;0;[;{;IC; "Set the defaults for this engine with the given _flag_. These flags are used to control combinations of algorithm methods. _flag_ can be one of the following, other flags are available depending on your OS. [All flags] 0xFFFF [No flags] 0x0000 See also ;T;[o;= ;>I" overload;F;?0;;<;@0;:I"set_default(flag);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" flag;T0;$@;![;"I"2Set the defaults for this engine with the given _flag_. These flags are used to control combinations of algorithm methods. _flag_ can be one of the following, other flags are available depending on your OS. [All flags] 0xFFFF [No flags] 0x0000 See also @overload set_default(flag);T;#0;$@;.F;/o;0;1T;2i;3i;%@ɬ;9I"static VALUE ossl_engine_set_default(VALUE self, VALUE flag) { ENGINE *e; int f = NUM2INT(flag); GetEngine(self, e); ENGINE_set_default(e, f); return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Engine#ctrl_cmd;F;7[[@90;[[@?Hi;T;: ctrl_cmd;0;[;{;IC; "[Sends the given _command_ to this engine. Raises an EngineError if the command fails. ;T;[o;= ;>I" overload;F;?0;;=;@0;:I"#ctrl_cmd(command, value = nil);T;IC; ";T;[;![;"I";T;#0;$@4;.F;Bi;C0;7[[I" command;T0[I" value;TI"nil;T;$@4;![;"I"Sends the given _command_ to this engine. Raises an EngineError if the command fails. @overload ctrl_cmd(command, value = nil);T;#0;$@4;.F;/o;0;1T;2i;3i;%@ɬ;9I"nstatic VALUE ossl_engine_ctrl_cmd(int argc, VALUE *argv, VALUE self) { ENGINE *e; VALUE cmd, val; int ret; GetEngine(self, e); rb_scan_args(argc, argv, "11", &cmd, &val); ret = ENGINE_ctrl_cmd_string(e, StringValueCStr(cmd), NIL_P(val) ? NULL : StringValueCStr(val), 0); if (!ret) ossl_raise(eEngineError, NULL); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Engine#cmds;F;7[;[[@?Hi;T;: cmds;0;[;{;IC; "CReturns an array of command definitions for the current engine ;T;[o;= ;>I" overload;F;?0;;>;@0;:I" cmds;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@P;![;"I"@return [Array];T;#0;$@P;.F;Bi;C0;7[;$@P;![;"I"fReturns an array of command definitions for the current engine @overload cmds @return [Array];T;#0;$@P;.F;/o;0;1T;2i;3i;%@ɬ;9I"static VALUE ossl_engine_get_cmds(VALUE self) { ENGINE *e; const ENGINE_CMD_DEFN *defn, *p; VALUE ary, tmp; GetEngine(self, e); ary = rb_ary_new(); if ((defn = ENGINE_get_cmd_defns(e)) != NULL){ for (p = defn; p->cmd_num > 0; p++){ tmp = rb_ary_new(); rb_ary_push(tmp, rb_str_new2(p->cmd_name)); rb_ary_push(tmp, rb_str_new2(p->cmd_desc)); rb_ary_push(tmp, ossl_engine_cmd_flag_to_name(p->cmd_flags)); rb_ary_push(ary, tmp); } } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"OpenSSL::Engine#inspect;F;7[;[[@?Hi;T;;J;0;[;{;IC; "Pretty prints this engine. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@k;![;"I"@return [String];T;#0;$@k;.F;Bi;C0;7[;$@k;![;"I"FPretty prints this engine. @overload inspect @return [String];T;#0;$@k;.F;/o;0;1T;2i;3i;%@ɬ;9I"static VALUE ossl_engine_inspect(VALUE self) { ENGINE *e; GetEngine(self, e); return rb_sprintf("#<%"PRIsVALUE" id=\"%s\" name=\"%s\">", rb_obj_class(self), ENGINE_get_id(e), ENGINE_get_name(e)); };T;:I"static VALUE;T;;T; @ɬ; IC;[; @ɬ; IC;[; @ɬ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@?Hi&[@?Hi;T;;2;;;;;[;{;IC; "This class is the access to openssl's ENGINE cryptographic module implementation. See also, https://www.openssl.org/docs/crypto/engine.html;T;[;![;"I" This class is the access to openssl's ENGINE cryptographic module implementation. See also, https://www.openssl.org/docs/crypto/engine.html ;T;#0;$@ɬ;.F;/o;0;1T;2i&;3i+;Bi;%@;&I"OpenSSL::Engine;F;'@o;;IC;[o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@AHit[@AHi;T;:SPKIError;;;;;[;{;IC; "}Generic Exception class that is raised if an error occurs during an operation on an instance of OpenSSL::Netscape::SPKI. ;T;[;![;"I" Generic Exception class that is raised if an error occurs during an operation on an instance of OpenSSL::Netscape::SPKI. ;T;#0;$@;.F;/o;0;1T;2it;3iw;%o;( ;)@;*I"OpenSSL::Netscape;T;+0;: Netscape;%o;( ;)0;*0;+0;;;%@;-@GH;0;-@;0;&I"!OpenSSL::Netscape::SPKIError;F;'@Ho; ;IC;[o;4;5F;6;;;;&I"'OpenSSL::Netscape::SPKI#initialize;T;7[[@90;[[@AHiS;T;;D;0;[;{;IC; "T=== Parameters * _request_ - optional raw request, either in PEM or DER format. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new([request]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"[request];T0;$@;![;"I"o=== Parameters * _request_ - optional raw request, either in PEM or DER format. @overload new([request]);T;#0;$@;.F;/o;0;1T;2iL;3iP;%@;9I"Rstatic VALUE ossl_spki_initialize(int argc, VALUE *argv, VALUE self) { NETSCAPE_SPKI *spki; VALUE buffer; const unsigned char *p; if (rb_scan_args(argc, argv, "01", &buffer) == 0) { return self; } StringValue(buffer); if (!(spki = NETSCAPE_SPKI_b64_decode(RSTRING_PTR(buffer), RSTRING_LENINT(buffer)))) { ossl_clear_error(); p = (unsigned char *)RSTRING_PTR(buffer); if (!(spki = d2i_NETSCAPE_SPKI(NULL, &p, RSTRING_LEN(buffer)))) { ossl_raise(eSPKIError, NULL); } } NETSCAPE_SPKI_free(DATA_PTR(self)); SetSPKI(self, spki); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::Netscape::SPKI#to_der;T;7[;[[@AHiq;T;;M;0;[;{;IC; "+Returns the DER encoding of this SPKI. ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" to_der;T;IC; ";T;[;![;"I";T;#0;$@̮;.F;Bi;C0;7[;$@̮;![;"I">Returns the DER encoding of this SPKI. @overload to_der;T;#0;$@̮;.F;/o;0;1T;2ik;3in;%@;9I"static VALUE ossl_spki_to_der(VALUE self) { NETSCAPE_SPKI *spki; VALUE str; long len; unsigned char *p; GetSPKI(self, spki); if ((len = i2d_NETSCAPE_SPKI(spki, NULL)) <= 0) ossl_raise(eX509CertError, NULL); str = rb_str_new(0, len); p = (unsigned char *)RSTRING_PTR(str); if (i2d_NETSCAPE_SPKI(spki, &p) <= 0) ossl_raise(eX509CertError, NULL); ossl_str_adjust(str, p); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::Netscape::SPKI#to_pem;T;7[;[[@AHi;T;;L;0;[;{;IC; "+Returns the PEM encoding of this SPKI. ;T;[o;= ;>I" overload;F;?0;;L;@0;:I" to_pem;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I">Returns the PEM encoding of this SPKI. @overload to_pem;T;#0;$o;4;5F;6;;;;&I"!OpenSSL::Netscape::SPKI#to_s;T;7[;[[@AHi;F;;G;;;[;{;@;%@;9I""static VALUE ossl_spki_to_pem(VALUE self) { NETSCAPE_SPKI *spki; char *data; VALUE str; GetSPKI(self, spki); if (!(data = NETSCAPE_SPKI_b64_encode(spki))) { ossl_raise(eSPKIError, NULL); } str = ossl_buf2str(data, rb_long2int(strlen(data))); return str; };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@;9I""static VALUE ossl_spki_to_pem(VALUE self) { NETSCAPE_SPKI *spki; char *data; VALUE str; GetSPKI(self, spki); if (!(data = NETSCAPE_SPKI_b64_encode(spki))) { ossl_raise(eSPKIError, NULL); } str = ossl_buf2str(data, rb_long2int(strlen(data))); return str; };T;:@;;T@o;4;5F;6;;;;&I"$OpenSSL::Netscape::SPKI#to_text;T;7[;[[@AHi;T;;\;0;[;{;IC; "RReturns a textual representation of this SPKI, useful for debugging purposes. ;T;[o;= ;>I" overload;F;?0;;\;@0;:I" to_text;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"yReturns a textual representation of this SPKI, useful for debugging purposes. @overload to_text @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"=static VALUE ossl_spki_print(VALUE self) { NETSCAPE_SPKI *spki; BIO *out; GetSPKI(self, spki); if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eSPKIError, NULL); } if (!NETSCAPE_SPKI_print(out, spki)) { BIO_free(out); ossl_raise(eSPKIError, NULL); } return ossl_membio2str(out); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::Netscape::SPKI#public_key;T;7[;[[@AHi;T;;D;0;[;{;IC; "SReturns the public key associated with the SPKI, an instance of OpenSSL::PKey. ;T;[o;= ;>I" overload;F;?0;;D;@0;:I"public_key;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"jReturns the public key associated with the SPKI, an instance of OpenSSL::PKey. @overload public_key;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I" static VALUE ossl_spki_get_public_key(VALUE self) { NETSCAPE_SPKI *spki; EVP_PKEY *pkey; GetSPKI(self, spki); if (!(pkey = NETSCAPE_SPKI_get_pubkey(spki))) { /* adds an reference */ ossl_raise(eSPKIError, NULL); } return ossl_pkey_new(pkey); /* NO DUP - OK */ };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(OpenSSL::Netscape::SPKI#public_key=;T;7[[I"key;T0;[[@AHi;T;;E;0;[;{;IC; "=== Parameters * _pub_ - the public key to be set for this instance Sets the public key to be associated with the SPKI, an instance of OpenSSL::PKey. This should be the public key corresponding to the private key used for signing the SPKI. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"public_key=(pub);T;IC; ";T;[;![;"I";T;#0;$@1;.F;Bi;C0;7[[I"pub;T0;$@1;![;"I" === Parameters * _pub_ - the public key to be set for this instance Sets the public key to be associated with the SPKI, an instance of OpenSSL::PKey. This should be the public key corresponding to the private key used for signing the SPKI. @overload public_key=(pub);T;#0;$@1;.F;/o;0;1T;2i;3i;%@;9I"=static VALUE ossl_spki_set_public_key(VALUE self, VALUE key) { NETSCAPE_SPKI *spki; EVP_PKEY *pkey; GetSPKI(self, spki); pkey = GetPKeyPtr(key); ossl_pkey_check_public_key(pkey); if (!NETSCAPE_SPKI_set_pubkey(spki, pkey)) ossl_raise(eSPKIError, "NETSCAPE_SPKI_set_pubkey"); return key; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!OpenSSL::Netscape::SPKI#sign;T;7[[I"key;T0[I" digest;T0;[[@AHi;T;;7;0;[;{;IC; "o=== Parameters * _key_ - the private key to be used for signing this instance * _digest_ - the digest to be used for signing this instance To sign an SPKI, the private key corresponding to the public key set for this instance should be used, in addition to a digest algorithm in the form of an OpenSSL::Digest. The private key should be an instance of OpenSSL::PKey. ;T;[o;= ;>I" overload;F;?0;;7;@0;:I"sign(key, digest);T;IC; ";T;[;![;"I";T;#0;$@K;.F;Bi;C0;7[[I"key;T0[I" digest;T0;$@K;![;"I"=== Parameters * _key_ - the private key to be used for signing this instance * _digest_ - the digest to be used for signing this instance To sign an SPKI, the private key corresponding to the public key set for this instance should be used, in addition to a digest algorithm in the form of an OpenSSL::Digest. The private key should be an instance of OpenSSL::PKey. @overload sign(key, digest);T;#0;$@K;.F;/o;0;1T;2i ;3i;%@;9I"hstatic VALUE ossl_spki_sign(VALUE self, VALUE key, VALUE digest) { NETSCAPE_SPKI *spki; EVP_PKEY *pkey; const EVP_MD *md; pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */ md = ossl_evp_get_digestbyname(digest); GetSPKI(self, spki); if (!NETSCAPE_SPKI_sign(spki, pkey, md)) { ossl_raise(eSPKIError, NULL); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#OpenSSL::Netscape::SPKI#verify;T;7[[I"key;T0;[[@AHi3;T;;J;0;[;{;IC; "=== Parameters * _key_ - the public key to be used for verifying the SPKI signature Returns +true+ if the signature is valid, +false+ otherwise. To verify an SPKI, the public key contained within the SPKI should be used. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I"verify(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@i;![;"I"@return [Boolean];T;#0;$@i;.F;Bi;C0;7[[I"key;T0;$@i;![;"I" === Parameters * _key_ - the public key to be used for verifying the SPKI signature Returns +true+ if the signature is valid, +false+ otherwise. To verify an SPKI, the public key contained within the SPKI should be used. @overload verify(key) @return [Boolean];T;#0;$@i;.F;/o;0;1T;2i);3i1;%@;9I"static VALUE ossl_spki_verify(VALUE self, VALUE key) { NETSCAPE_SPKI *spki; EVP_PKEY *pkey; GetSPKI(self, spki); pkey = GetPKeyPtr(key); ossl_pkey_check_public_key(pkey); switch (NETSCAPE_SPKI_verify(spki, pkey)) { case 0: ossl_clear_error(); return Qfalse; case 1: return Qtrue; default: ossl_raise(eSPKIError, "NETSCAPE_SPKI_verify"); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::Netscape::SPKI#challenge;T;7[;[[@AHi;T;:challenge;0;[;{;IC; "I" overload;F;?0;;A;@0;:I"challenge;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"eReturns the challenge string associated with this SPKI. @overload challenge @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"Istatic VALUE ossl_spki_get_challenge(VALUE self) { NETSCAPE_SPKI *spki; GetSPKI(self, spki); if (spki->spkac->challenge->length <= 0) { OSSL_Debug("Challenge.length <= 0?"); return rb_str_new(0, 0); } return rb_str_new((const char *)spki->spkac->challenge->data, spki->spkac->challenge->length); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::Netscape::SPKI#challenge=;T;7[[I"str;T0;[[@AHi;T;:challenge=;0;[;{;IC; "=== Parameters * _str_ - the challenge string to be set for this instance Sets the challenge to be associated with the SPKI. May be used by the server, e.g. to prevent replay. ;T;[o;= ;>I" overload;F;?0;;B;@0;:I"challenge=(str);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I"str;T0;$@;![;"I"=== Parameters * _str_ - the challenge string to be set for this instance Sets the challenge to be associated with the SPKI. May be used by the server, e.g. to prevent replay. @overload challenge=(str) @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_spki_set_challenge(VALUE self, VALUE str) { NETSCAPE_SPKI *spki; StringValue(str); GetSPKI(self, spki); if (!ASN1_STRING_set(spki->spkac->challenge, RSTRING_PTR(str), RSTRING_LENINT(str))) { ossl_raise(eSPKIError, NULL); } return str; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{@;L;[;[[@AHiG[@AHi;T;: SPKI;;;;;[;{;IC; "9A Simple Public Key Infrastructure implementation (pronounced "spooky"). The structure is defined as PublicKeyAndChallenge ::= SEQUENCE { spki SubjectPublicKeyInfo, challenge IA5STRING } SignedPublicKeyAndChallenge ::= SEQUENCE { publicKeyAndChallenge PublicKeyAndChallenge, signatureAlgorithm AlgorithmIdentifier, signature BIT STRING } where the definitions of SubjectPublicKeyInfo and AlgorithmIdentifier can be found in RFC5280. SPKI is typically used in browsers for generating a public/private key pair and a subsequent certificate request, using the HTML element. == Examples === Creating an SPKI key = OpenSSL::PKey::RSA.new 2048 spki = OpenSSL::Netscape::SPKI.new spki.challenge = "RandomChallenge" spki.public_key = key.public_key spki.sign(key, OpenSSL::Digest.new('SHA256')) #send a request containing this to a server generating a certificate === Verifying an SPKI request request = #... spki = OpenSSL::Netscape::SPKI.new request unless spki.verify(spki.public_key) # signature is invalid end #proceed;T;[;![;"I"; A Simple Public Key Infrastructure implementation (pronounced "spooky"). The structure is defined as PublicKeyAndChallenge ::= SEQUENCE { spki SubjectPublicKeyInfo, challenge IA5STRING } SignedPublicKeyAndChallenge ::= SEQUENCE { publicKeyAndChallenge PublicKeyAndChallenge, signatureAlgorithm AlgorithmIdentifier, signature BIT STRING } where the definitions of SubjectPublicKeyInfo and AlgorithmIdentifier can be found in RFC5280. SPKI is typically used in browsers for generating a public/private key pair and a subsequent certificate request, using the HTML element. == Examples === Creating an SPKI key = OpenSSL::PKey::RSA.new 2048 spki = OpenSSL::Netscape::SPKI.new spki.challenge = "RandomChallenge" spki.public_key = key.public_key spki.sign(key, OpenSSL::Digest.new('SHA256')) #send a request containing this to a server generating a certificate === Verifying an SPKI request request = #... spki = OpenSSL::Netscape::SPKI.new request unless spki.verify(spki.public_key) # signature is invalid end #proceed ;T;#0;$@;.F;/o;0;1T;2iG;3ii;Bi;%o;( ;)@;*I"OpenSSL::Netscape;T;+0;;@;%@;-@;0;&I"OpenSSL::Netscape::SPKI;T;'@; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@AHil[@AHi;T;;@;;;;;[;{;IC; "OpenSSL::Netscape is a namespace for SPKI (Simple Public Key Infrastructure) which implements Signed Public Key and Challenge. See {RFC 2692}[http://tools.ietf.org/html/rfc2692] and {RFC 2693}[http://tools.ietf.org/html/rfc2692] for details.;T;[;![;"I" OpenSSL::Netscape is a namespace for SPKI (Simple Public Key Infrastructure) which implements Signed Public Key and Challenge. See {RFC 2692}[http://tools.ietf.org/html/rfc2692] and {RFC 2693}[http://tools.ietf.org/html/rfc2692] for details. ;T;#0;$@;.F;/o;0;1T;2il;3iq;Bi;%@;&I"OpenSSL::Netscape;F; @GH; IC;[; @GH; IC;[; @GH; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Hi[@Hi2[@Hi[@Hi[@Hiv[@Hi[@Hi[@ؔi[@ Hi[@"Hid[@$Hi_[@&Hi[@*Hi[@,HiP[@.Hi[@Hi=[@1Hi|[@3Hi[@Ôi&[@5Hi[@7Hi[@9Hip [@;Hi[@=Hi4[@?Hi [@AHi~;F;;;;;;;[;{;IC; " ;T;[;![;"@;#0;$@GH;Bi;%@;&I" OpenSSL;F;&I"OpenSSL::OpenSSLError;F;'@o;4;5F;6;;;;&I"Digest#initialize;F;7[[@90;[[@Hi{;T;;D;0;[;{;IC; "oCreates a Digest instance based on _string_, which is either the ln (long name) or sn (short name) of a supported digest algorithm. If _data_ (a String) is given, it is used as the initial input to the Digest instance, i.e. digest = OpenSSL::Digest.new('sha256', 'digestdata') is equivalent to digest = OpenSSL::Digest.new('sha256') digest.update('digestdata') ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(string [, data]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Digest;T;$@;![;"I"@return [Digest];T;#0;$@;.F;Bi;C0;7[[I"string[, data];T0;$@;![;"I"Creates a Digest instance based on _string_, which is either the ln (long name) or sn (short name) of a supported digest algorithm. If _data_ (a String) is given, it is used as the initial input to the Digest instance, i.e. digest = OpenSSL::Digest.new('sha256', 'digestdata') is equivalent to digest = OpenSSL::Digest.new('sha256') digest.update('digestdata') @overload new(string [, data]) @return [Digest];T;#0;$@;.F;/o;0;1T;2ij;3iy;%@D;9I"static VALUE ossl_digest_initialize(int argc, VALUE *argv, VALUE self) { EVP_MD_CTX *ctx; const EVP_MD *md; VALUE type, data; rb_scan_args(argc, argv, "11", &type, &data); md = ossl_evp_get_digestbyname(type); if (!NIL_P(data)) StringValue(data); TypedData_Get_Struct(self, EVP_MD_CTX, &ossl_digest_type, ctx); if (!ctx) { RTYPEDDATA_DATA(self) = ctx = EVP_MD_CTX_new(); if (!ctx) ossl_raise(eDigestError, "EVP_MD_CTX_new"); } if (!EVP_DigestInit_ex(ctx, md, NULL)) ossl_raise(eDigestError, "Digest initialization failed"); if (!NIL_P(data)) return ossl_digest_update(self, data); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest#initialize_copy;F;7[[I" other;T0;[[@Hi;T;;];0;[;{;IC; " ;T;[;![;"@;#0;$@/;%@D;9I"static VALUE ossl_digest_copy(VALUE self, VALUE other) { EVP_MD_CTX *ctx1, *ctx2; rb_check_frozen(self); if (self == other) return self; TypedData_Get_Struct(self, EVP_MD_CTX, &ossl_digest_type, ctx1); if (!ctx1) { RTYPEDDATA_DATA(self) = ctx1 = EVP_MD_CTX_new(); if (!ctx1) ossl_raise(eDigestError, "EVP_MD_CTX_new"); } GetDigest(other, ctx2); if (!EVP_MD_CTX_copy(ctx1, ctx2)) { ossl_raise(eDigestError, NULL); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest#reset;F;7[;[[@Hi;T;;;0;[;{;IC; "Resets the Digest in the sense that any Digest#update that has been performed is abandoned and the Digest is set to its initial state again. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" reset;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@=;![;"I"@return [self];T;#0;$@=;.F;Bi;C0;7[;$@=;![;"I"Resets the Digest in the sense that any Digest#update that has been performed is abandoned and the Digest is set to its initial state again. @overload reset @return [self];T;#0;$@=;.F;/o;0;1T;2i;3i;%@D;9I"static VALUE ossl_digest_reset(VALUE self) { EVP_MD_CTX *ctx; GetDigest(self, ctx); if (EVP_DigestInit_ex(ctx, EVP_MD_CTX_get0_md(ctx), NULL) != 1) { ossl_raise(eDigestError, "Digest initialization failed."); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest#update;F;7[[I" data;T0;[[@Hi;T;; ;0;[;{;IC; "sNot every message digest can be computed in one single pass. If a message digest is to be computed from several subsequent sources, then each may be passed individually to the Digest instance. === Example digest = OpenSSL::Digest.new('SHA256') digest.update('First input') digest << 'Second input' # equivalent to digest.update('Second input') result = digest.digest ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"update(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" aString;T;$@X;![;"I"@return [aString];T;#0;$@X;.F;Bi;C0;7[[I" string;T0;$@X;![;"I"Not every message digest can be computed in one single pass. If a message digest is to be computed from several subsequent sources, then each may be passed individually to the Digest instance. === Example digest = OpenSSL::Digest.new('SHA256') digest.update('First input') digest << 'Second input' # equivalent to digest.update('Second input') result = digest.digest @overload update(string) @return [aString];T;#0;$o;4;5F;6;;;;&I"Digest#<<;F;7[;[[@Hi;F;;;;;[;{;@a;%@D;9I"VALUE ossl_digest_update(VALUE self, VALUE data) { EVP_MD_CTX *ctx; StringValue(data); GetDigest(self, ctx); if (!EVP_DigestUpdate(ctx, RSTRING_PTR(data), RSTRING_LEN(data))) ossl_raise(eDigestError, "EVP_DigestUpdate"); return self; };T;:I" VALUE;T;.F;/o;0;1T;2i;3i;%@D;9I"VALUE ossl_digest_update(VALUE self, VALUE data) { EVP_MD_CTX *ctx; StringValue(data); GetDigest(self, ctx); if (!EVP_DigestUpdate(ctx, RSTRING_PTR(data), RSTRING_LEN(data))) ossl_raise(eDigestError, "EVP_DigestUpdate"); return self; };T;:@|;;T@to;4;5F;6;;;;&I"Digest#finish;F;7[[@90;[[@Hi;T;;!;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;!;@0;:I" finish;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" aString;T;$@;![;"I"@return [aString];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"+ @overload finish @return [aString];T;#0;$@;.F;/o;0;1T;2i;3i;%@D;9I"static VALUE ossl_digest_finish(int argc, VALUE *argv, VALUE self) { EVP_MD_CTX *ctx; VALUE str; int out_len; GetDigest(self, ctx); rb_scan_args(argc, argv, "01", &str); out_len = EVP_MD_CTX_size(ctx); if (NIL_P(str)) { str = rb_str_new(NULL, out_len); } else { StringValue(str); rb_str_resize(str, out_len); } if (!EVP_DigestFinal_ex(ctx, (unsigned char *)RSTRING_PTR(str), NULL)) ossl_raise(eDigestError, "EVP_DigestFinal_ex"); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest#digest_length;F;7[;[[@Hi;T;;";0;[;{;IC; "Returns the output size of the digest, i.e. the length in bytes of the final message digest result. === Example digest = OpenSSL::Digest.new('SHA1') puts digest.digest_length # => 20 ;T;[o;= ;>I" overload;F;?0;;";@0;:I"digest_length;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the output size of the digest, i.e. the length in bytes of the final message digest result. === Example digest = OpenSSL::Digest.new('SHA1') puts digest.digest_length # => 20 @overload digest_length @return [Integer];T;#0;$@;.F;/o;0;1T;2i ;3i;%@D;9I"static VALUE ossl_digest_size(VALUE self) { EVP_MD_CTX *ctx; GetDigest(self, ctx); return INT2NUM(EVP_MD_CTX_size(ctx)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest#block_length;F;7[;[[@Hi,;T;;#;0;[;{;IC; "7Returns the block length of the digest algorithm, i.e. the length in bytes of an individual block. Most modern algorithms partition a message to be digested into a sequence of fix-sized blocks that are processed consecutively. === Example digest = OpenSSL::Digest.new('SHA1') puts digest.block_length # => 64 ;T;[o;= ;>I" overload;F;?0;;#;@0;:I"block_length;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"dReturns the block length of the digest algorithm, i.e. the length in bytes of an individual block. Most modern algorithms partition a message to be digested into a sequence of fix-sized blocks that are processed consecutively. === Example digest = OpenSSL::Digest.new('SHA1') puts digest.block_length # => 64 @overload block_length @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i*;%@D;9I"static VALUE ossl_digest_block_length(VALUE self) { EVP_MD_CTX *ctx; GetDigest(self, ctx); return INT2NUM(EVP_MD_CTX_block_size(ctx)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Digest#name;F;7[;[[@Hi;T;;F;0;[;{;IC; "{Returns the sn of this Digest algorithm. === Example digest = OpenSSL::Digest.new('SHA512') puts digest.name # => SHA512 ;T;[o;= ;>I" overload;F;?0;;F;@0;:I" name;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@Ѱ;![;"I"@return [String];T;#0;$@Ѱ;.F;Bi;C0;7[;$@Ѱ;![;"I"Returns the sn of this Digest algorithm. === Example digest = OpenSSL::Digest.new('SHA512') puts digest.name # => SHA512 @overload name @return [String];T;#0;$@Ѱ;.F;/o;0;1T;2i;3i;%@D;9I"static VALUE ossl_digest_name(VALUE self) { EVP_MD_CTX *ctx; GetDigest(self, ctx); return rb_str_new_cstr(EVP_MD_name(EVP_MD_CTX_get0_md(ctx))); };T;:I"static VALUE;T;;T; @D; IC;[; @D; IC;[; @D; IC;{;IC;{;T;IC;{;T;T;{@t; ;[;[ [@1Di![@ Di[@Fi:[@Gi<[@Gi6[@1Di;T;;-;;;;;[;{;IC; "This module provides a framework for message digest libraries. You may want to look at OpenSSL::Digest as it supports more algorithms. A cryptographic hash function is a procedure that takes data and returns a fixed bit string: the hash value, also known as _digest_. Hash functions are also called one-way functions, it is easy to compute a digest from a message, but it is infeasible to generate a message from a digest. == Examples require 'digest' # Compute a complete digest Digest::SHA256.digest 'message' #=> "\xABS\n\x13\xE4Y..." sha256 = Digest::SHA256.new sha256.digest 'message' #=> "\xABS\n\x13\xE4Y..." # Other encoding formats Digest::SHA256.hexdigest 'message' #=> "ab530a13e459..." Digest::SHA256.base64digest 'message' #=> "q1MKE+RZFJgr..." # Compute digest by chunks md5 = Digest::MD5.new md5.update 'message1' md5 << 'message2' # << is an alias for update md5.hexdigest #=> "94af09c09bb9..." # Compute digest for a file sha256 = Digest::SHA256.file 'testfile' sha256.hexdigest Additionally digests can be encoded in "bubble babble" format as a sequence of consonants and vowels which is more recognizable and comparable than a hexadecimal digest. require 'digest/bubblebabble' Digest::SHA256.bubblebabble 'message' #=> "xopoh-fedac-fenyh-..." See the bubble babble specification at http://web.mit.edu/kenta/www/one/bubblebabble/spec/jrtrjwzi/draft-huima-01.txt. == Digest algorithms Different digest algorithms (or hash functions) are available: MD5:: See RFC 1321 The MD5 Message-Digest Algorithm RIPEMD-160:: As Digest::RMD160. See http://homes.esat.kuleuven.be/~bosselae/ripemd160.html. SHA1:: See FIPS 180 Secure Hash Standard. SHA2 family:: See FIPS 180 Secure Hash Standard which defines the following algorithms: * SHA512 * SHA384 * SHA256 The latest versions of the FIPS publications can be found here: http://csrc.nist.gov/publications/PubsFIPS.html.;T;[;![;"I" This module provides a framework for message digest libraries. You may want to look at OpenSSL::Digest as it supports more algorithms. A cryptographic hash function is a procedure that takes data and returns a fixed bit string: the hash value, also known as _digest_. Hash functions are also called one-way functions, it is easy to compute a digest from a message, but it is infeasible to generate a message from a digest. == Examples require 'digest' # Compute a complete digest Digest::SHA256.digest 'message' #=> "\xABS\n\x13\xE4Y..." sha256 = Digest::SHA256.new sha256.digest 'message' #=> "\xABS\n\x13\xE4Y..." # Other encoding formats Digest::SHA256.hexdigest 'message' #=> "ab530a13e459..." Digest::SHA256.base64digest 'message' #=> "q1MKE+RZFJgr..." # Compute digest by chunks md5 = Digest::MD5.new md5.update 'message1' md5 << 'message2' # << is an alias for update md5.hexdigest #=> "94af09c09bb9..." # Compute digest for a file sha256 = Digest::SHA256.file 'testfile' sha256.hexdigest Additionally digests can be encoded in "bubble babble" format as a sequence of consonants and vowels which is more recognizable and comparable than a hexadecimal digest. require 'digest/bubblebabble' Digest::SHA256.bubblebabble 'message' #=> "xopoh-fedac-fenyh-..." See the bubble babble specification at http://web.mit.edu/kenta/www/one/bubblebabble/spec/jrtrjwzi/draft-huima-01.txt. == Digest algorithms Different digest algorithms (or hash functions) are available: MD5:: See RFC 1321 The MD5 Message-Digest Algorithm RIPEMD-160:: As Digest::RMD160. See http://homes.esat.kuleuven.be/~bosselae/ripemd160.html. SHA1:: See FIPS 180 Secure Hash Standard. SHA2 family:: See FIPS 180 Secure Hash Standard which defines the following algorithms: * SHA512 * SHA384 * SHA256 The latest versions of the FIPS publications can be found here: http://csrc.nist.gov/publications/PubsFIPS.html. ;T;#0;$@D;.F;/o;0;1T;2i!;3ib;Bi;%@;&I" Digest;F@o;;IC;[o; ;IC;[o;4;5F;6;;;;&I"Process::Status.wait;F;7[[@90;[[@ i~;T;;h;0;[;{;IC; "Waits for a child process to exit and returns a Process::Status object containing information on that process. Which child it waits on depends on the value of _pid_: > 0:: Waits for the child whose process ID equals _pid_. 0:: Waits for any child whose process group ID equals that of the calling process. -1:: Waits for any child process (the default if no _pid_ is given). < -1:: Waits for any child whose process group ID equals the absolute value of _pid_. The _flags_ argument may be a logical or of the flag values Process::WNOHANG (do not block if no child available) or Process::WUNTRACED (return stopped children that haven't been reported). Not all flags are available on all platforms, but a flag value of zero will work on all platforms. Returns +nil+ if there are no child processes. Not available on all platforms. May invoke the scheduler hook _process_wait_. fork { exit 99 } #=> 27429 Process::Status.wait #=> pid 27429 exit 99 $? #=> nil pid = fork { sleep 3 } #=> 27440 Time.now #=> 2008-03-08 19:56:16 +0900 Process::Status.wait(pid, Process::WNOHANG) #=> nil Time.now #=> 2008-03-08 19:56:16 +0900 Process::Status.wait(pid, 0) #=> pid 27440 exit 99 Time.now #=> 2008-03-08 19:56:19 +0900 This is an EXPERIMENTAL FEATURE. ;T;[o;= ;>I" overload;F;?0;:Process::Status.wait;@0;:I"*Process::Status.wait(pid=-1, flags=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Process::Status;T;$@;![;"I"@return [Process::Status];T;#0;$@;.F;Bi;C0;7[[I"pid;TI"-1;T[I" flags;TI"0;T;$@;![;"I"hWaits for a child process to exit and returns a Process::Status object containing information on that process. Which child it waits on depends on the value of _pid_: > 0:: Waits for the child whose process ID equals _pid_. 0:: Waits for any child whose process group ID equals that of the calling process. -1:: Waits for any child process (the default if no _pid_ is given). < -1:: Waits for any child whose process group ID equals the absolute value of _pid_. The _flags_ argument may be a logical or of the flag values Process::WNOHANG (do not block if no child available) or Process::WUNTRACED (return stopped children that haven't been reported). Not all flags are available on all platforms, but a flag value of zero will work on all platforms. Returns +nil+ if there are no child processes. Not available on all platforms. May invoke the scheduler hook _process_wait_. fork { exit 99 } #=> 27429 Process::Status.wait #=> pid 27429 exit 99 $? #=> nil pid = fork { sleep 3 } #=> 27440 Time.now #=> 2008-03-08 19:56:16 +0900 Process::Status.wait(pid, Process::WNOHANG) #=> nil Time.now #=> 2008-03-08 19:56:16 +0900 Process::Status.wait(pid, 0) #=> pid 27440 exit 99 Time.now #=> 2008-03-08 19:56:19 +0900 This is an EXPERIMENTAL FEATURE. @overload Process::Status.wait(pid=-1, flags=0) @return [Process::Status];T;#0;$@;.F;/o;0;1T;2iR;3i{;%@;9I":VALUE rb_process_status_waitv(int argc, VALUE *argv, VALUE _) { rb_check_arity(argc, 0, 2); rb_pid_t pid = -1; int flags = 0; if (argc >= 1) { pid = NUM2PIDT(argv[0]); } if (argc >= 2) { flags = RB_NUM2INT(argv[1]); } return rb_process_status_wait(pid, flags); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Process::Status#==;F;7[[I"st2;T0;[[@ iE;T;;F;0;[;{;IC; "IReturns +true+ if the integer value of _stat_ equals other. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@(;![;"I"@return [Boolean];T;#0;$@(;.F;Bi;C0;7[[I" other;T0;$@(;![;"I"sReturns +true+ if the integer value of _stat_ equals other. @overload ==(other) @return [Boolean];T;#0;$@(;.F;/o;0;1T;2i=;3iB;%@;9I"{static VALUE pst_equal(VALUE st1, VALUE st2) { if (st1 == st2) return Qtrue; return rb_equal(pst_to_i(st1), st2); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process::Status#&;F;7[[I"st2;T0;[[@ iY;T;:&;0;[;{;IC; "Logical AND of the bits in _stat_ with num. fork { exit 0x37 } Process.wait sprintf('%04x', $?.to_i) #=> "3700" sprintf('%04x', $? & 0x1e00) #=> "1600" ;T;[o;= ;>I" overload;F;?0;;E;@0;:I" &(num);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@G;![;"I"@return [Integer];T;#0;$@G;.F;Bi;C0;7[[I"num;T0;$@G;![;"I"Logical AND of the bits in _stat_ with num. fork { exit 0x37 } Process.wait sprintf('%04x', $?.to_i) #=> "3700" sprintf('%04x', $? & 0x1e00) #=> "1600" @overload &(num) @return [Integer];T;#0;$@G;.F;/o;0;1T;2iM;3iV;%@;9I"|static VALUE pst_bitand(VALUE st1, VALUE st2) { int status = PST2INT(st1) & NUM2INT(st2); return INT2NUM(status); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process::Status#>>;F;7[[I"st2;T0;[[@ in;T;;;0;[;{;IC; "Shift the bits in _stat_ right num places. fork { exit 99 } #=> 26563 Process.wait #=> 26563 $?.to_i #=> 25344 $? >> 8 #=> 99 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" >>(num);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@f;![;"I"@return [Integer];T;#0;$@f;.F;Bi;C0;7[[I"num;T0;$@f;![;"I"Shift the bits in _stat_ right num places. fork { exit 99 } #=> 26563 Process.wait #=> 26563 $?.to_i #=> 25344 $? >> 8 #=> 99 @overload >>(num) @return [Integer];T;#0;$@f;.F;/o;0;1T;2ib;3ik;%@;9I"}static VALUE pst_rshift(VALUE st1, VALUE st2) { int status = PST2INT(st1) >> NUM2INT(st2); return INT2NUM(status); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process::Status#to_i;F;7[;[[@ i;T;;;0;[;{;IC; "Returns the bits in _stat_ as an Integer. Poking around in these bits is platform dependent. fork { exit 0xab } #=> 26566 Process.wait #=> 26566 sprintf('%04x', $?.to_i) #=> "ab00" ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_i;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the bits in _stat_ as an Integer. Poking around in these bits is platform dependent. fork { exit 0xab } #=> 26566 Process.wait #=> 26566 sprintf('%04x', $?.to_i) #=> "ab00" @overload to_i @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"lstatic VALUE pst_to_i(VALUE self) { int status = pst_status(self); return RB_INT2NUM(status); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process::Status#to_s;F;7[;[[@ i;T;;G;0;[;{;IC; "hShow pid and exit status as a string. system("false") p $?.to_s #=> "pid 12766 exit 1" ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Show pid and exit status as a string. system("false") p $?.to_s #=> "pid 12766 exit 1" @overload to_s @return [String];T;#0;$@;.F;/o;0;1T;2i;3i ;%@;9I"static VALUE pst_to_s(VALUE st) { rb_pid_t pid; int status; VALUE str; pid = pst_pid(st); status = PST2INT(st); str = rb_str_buf_new(0); pst_message(str, pid, status); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process::Status#inspect;F;7[;[[@ i);T;;J;0;[;{;IC; "qOverride the inspection method. system("false") p $?.inspect #=> "#" ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Override the inspection method. system("false") p $?.inspect #=> "#" @overload inspect @return [String];T;#0;$@;.F;/o;0;1T;2i;3i&;%@;9I"{static VALUE pst_inspect(VALUE st) { rb_pid_t pid; int status; VALUE str; pid = pst_pid(st); if (!pid) { return rb_sprintf("#<%s: uninitialized>", rb_class2name(CLASS_OF(st))); } status = PST2INT(st); str = rb_sprintf("#<%s: ", rb_class2name(CLASS_OF(st))); pst_message(str, pid, status); rb_str_cat2(str, ">"); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process::Status#pid;F;7[;[[@ i;T;;;0;[;{;IC; "Returns the process ID that this status object represents. fork { exit } #=> 26569 Process.wait #=> 26569 $?.pid #=> 26569 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"pid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ֱ;![;"I"@return [Integer];T;#0;$@ֱ;.F;Bi;C0;7[;$@ֱ;![;"I"Returns the process ID that this status object represents. fork { exit } #=> 26569 Process.wait #=> 26569 $?.pid #=> 26569 @overload pid @return [Integer];T;#0;$@ֱ;.F;/o;0;1T;2i;3i;%@;9I"gstatic VALUE pst_pid_m(VALUE self) { rb_pid_t pid = pst_pid(self); return PIDT2NUM(pid); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process::Status#stopped?;F;7[;[[@ i;T;: stopped?;0;[;{;IC; "Returns +true+ if this process is stopped. This is only returned if the corresponding #wait call had the Process::WUNTRACED flag set.;T;[o;= ;>I" overload;F;?0;;F;@0;:I" stopped?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns +true+ if this process is stopped. This is only returned if the corresponding #wait call had the Process::WUNTRACED flag set. @overload stopped? @return [Boolean];T;#0;$@;.F;/o;0;1T;2iw;3i};Bi;%@;9I"sstatic VALUE pst_wifstopped(VALUE st) { int status = PST2INT(st); return RBOOL(WIFSTOPPED(status)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process::Status#stopsig;F;7[;[[@ i;T;: stopsig;0;[;{;IC; "cReturns the number of the signal that caused _stat_ to stop (or +nil+ if self is not stopped). ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" stopsig;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@ ;![;"I"@return [Integer, nil];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Returns the number of the signal that caused _stat_ to stop (or +nil+ if self is not stopped). @overload stopsig @return [Integer, nil];T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;9I"static VALUE pst_wstopsig(VALUE st) { int status = PST2INT(st); if (WIFSTOPPED(status)) return INT2NUM(WSTOPSIG(status)); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process::Status#signaled?;F;7[;[[@ i;T;:signaled?;0;[;{;IC; "GReturns +true+ if _stat_ terminated because of an uncaught signal.;T;[o;= ;>I" overload;F;?0;;H;@0;:I"signaled?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@(;![;"I"@return [Boolean];T;#0;$@(;.F;Bi;C0;7[;$@(;![;"I"qReturns +true+ if _stat_ terminated because of an uncaught signal. @overload signaled? @return [Boolean];T;#0;$@(;.F;/o;0;1T;2i;3i;Bi;%@;9I"ustatic VALUE pst_wifsignaled(VALUE st) { int status = PST2INT(st); return RBOOL(WIFSIGNALED(status)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process::Status#termsig;F;7[;[[@ i;T;: termsig;0;[;{;IC; "}Returns the number of the signal that caused _stat_ to terminate (or +nil+ if self was not terminated by an uncaught signal). ;T;[o;= ;>I" overload;F;?0;;I;@0;:I" termsig;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@C;![;"I"@return [Integer, nil];T;#0;$@C;.F;Bi;C0;7[;$@C;![;"I"Returns the number of the signal that caused _stat_ to terminate (or +nil+ if self was not terminated by an uncaught signal). @overload termsig @return [Integer, nil];T;#0;$@C;.F;/o;0;1T;2i;3i;%@;9I"static VALUE pst_wtermsig(VALUE st) { int status = PST2INT(st); if (WIFSIGNALED(status)) return INT2NUM(WTERMSIG(status)); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process::Status#exited?;F;7[;[[@ i;T;: exited?;0;[;{;IC; "wReturns +true+ if _stat_ exited normally (for example using an exit() call or finishing the program).;T;[o;= ;>I" overload;F;?0;;J;@0;:I" exited?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@_;![;"I"@return [Boolean];T;#0;$@_;.F;Bi;C0;7[;$@_;![;"I"Returns +true+ if _stat_ exited normally (for example using an exit() call or finishing the program). @overload exited? @return [Boolean];T;#0;$@_;.F;/o;0;1T;2i;3i;Bi;%@;9I"qstatic VALUE pst_wifexited(VALUE st) { int status = PST2INT(st); return RBOOL(WIFEXITED(status)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process::Status#exitstatus;F;7[;[[@ i;T;:exitstatus;0;[;{;IC; "eReturns the least significant eight bits of the return code of _stat_. Only available if #exited? is +true+. fork { } #=> 26572 Process.wait #=> 26572 $?.exited? #=> true $?.exitstatus #=> 0 fork { exit 99 } #=> 26573 Process.wait #=> 26573 $?.exited? #=> true $?.exitstatus #=> 99 ;T;[o;= ;>I" overload;F;?0;;K;@0;:I"exitstatus;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@z;![;"I"@return [Integer, nil];T;#0;$@z;.F;Bi;C0;7[;$@z;![;"I"Returns the least significant eight bits of the return code of _stat_. Only available if #exited? is +true+. fork { } #=> 26572 Process.wait #=> 26572 $?.exited? #=> true $?.exitstatus #=> 0 fork { exit 99 } #=> 26573 Process.wait #=> 26573 $?.exited? #=> true $?.exitstatus #=> 99 @overload exitstatus @return [Integer, nil];T;#0;$@z;.F;/o;0;1T;2i;3i;%@;9I"static VALUE pst_wexitstatus(VALUE st) { int status = PST2INT(st); if (WIFEXITED(status)) return INT2NUM(WEXITSTATUS(status)); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process::Status#success?;F;7[;[[@ i;T;: success?;0;[;{;IC; "eReturns +true+ if _stat_ is successful, +false+ if not. Returns +nil+ if #exited? is not +true+.;T;[o;= ;>I" overload;F;?0;;L;@0;:I" success?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;TI" false;TI"nil;T;$@;![;"I"@return [true, false, nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns +true+ if _stat_ is successful, +false+ if not. Returns +nil+ if #exited? is not +true+. @overload success? @return [true, false, nil];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE pst_success_p(VALUE st) { int status = PST2INT(st); if (!WIFEXITED(status)) return Qnil; return RBOOL(WEXITSTATUS(status) == EXIT_SUCCESS); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process::Status#coredump?;F;7[;[[@ i ;T;:coredump?;0;[;{;IC; "fReturns +true+ if _stat_ generated a coredump when it terminated. Not available on all platforms.;T;[o;= ;>I" overload;F;?0;;M;@0;:I"coredump?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns +true+ if _stat_ generated a coredump when it terminated. Not available on all platforms. @overload coredump? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE pst_wcoredump(VALUE st) { #ifdef WCOREDUMP int status = PST2INT(st); return RBOOL(WCOREDUMP(status)); #else return Qfalse; #endif };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ i[@ i ";T;: Status;;;;;[;{;IC; "******************************************************************* Process::Status encapsulates the information on the status of a running or terminated system process. The built-in variable $? is either +nil+ or a Process::Status object. fork { exit 99 } #=> 26557 Process.wait #=> 26557 $?.class #=> Process::Status $?.to_i #=> 25344 $? >> 8 #=> 99 $?.stopped? #=> false $?.exited? #=> true $?.exitstatus #=> 99 Posix systems record information on processes using a 16-bit integer. The lower bits record the process status (stopped, exited, signaled) and the upper bits possibly contain additional information (for example the program's return code in the case of exited processes). Pre Ruby 1.8, these bits were exposed directly to the Ruby program. Ruby now encapsulates these in a Process::Status object. To maximize compatibility, however, these objects retain a bit-oriented interface. In the descriptions that follow, when we talk about the integer value of _stat_, we're referring to this 16 bit value.;T;[;![;"I"******************************************************************* Process::Status encapsulates the information on the status of a running or terminated system process. The built-in variable $? is either +nil+ or a Process::Status object. fork { exit 99 } #=> 26557 Process.wait #=> 26557 $?.class #=> Process::Status $?.to_i #=> 25344 $? >> 8 #=> 99 $?.stopped? #=> false $?.exited? #=> true $?.exitstatus #=> 99 Posix systems record information on processes using a 16-bit integer. The lower bits record the process status (stopped, exited, signaled) and the upper bits possibly contain additional information (for example the program's return code in the case of exited processes). Pre Ruby 1.8, these bits were exposed directly to the Ruby program. Ruby now encapsulates these in a Process::Status object. To maximize compatibility, however, these objects retain a bit-oriented interface. In the descriptions that follow, when we talk about the integer value of _stat_, we're referring to this 16 bit value. ;T;#0;$@;.F;/o;0;1T;2i;3i:;Bi;%o;( ;)0;*0;+0;: Process;%@;-@;0;&I"Process::Status;F;'@o;u;[[@ i![@ i!;F;: WNOHANG;;w;;;[;{;IC; "see Process.wait ;T;[;![;"I"see Process.wait;T;#0;$@;.F;/o;0;1T;2i!;3i!;%@;&I"Process::WNOHANG;F;xI"INT2FIX(0);To;u;[[@ i"[@ i";F;:WUNTRACED;;w;;;[;{;IC; "see Process.wait ;T;[;![;"I"see Process.wait;T;#0;$@;.F;/o;0;1T;2i";3i";%@;&I"Process::WUNTRACED;F;xI"INT2FIX(0);To;4;5F;6;;;;&I"Process.exec;F;7[[I"*a;T0[I"_;T0;[[@ i~ ;T;;;0;[;{;IC; " Replaces the current process by running the given external _command_, which can take one of the following forms: [exec(commandline)] command line string which is passed to the standard shell [exec(cmdname, arg1, ...)] command name and one or more arguments (no shell) [exec([cmdname, argv0], arg1, ...)] command name, argv[0] and zero or more arguments (no shell) In the first form, the string is taken as a command line that is subject to shell expansion before being executed. The standard shell always means "/bin/sh" on Unix-like systems, otherwise, ENV["RUBYSHELL"] or ENV["COMSPEC"] on Windows and similar. The command is passed as an argument to the "-c" switch to the shell, except in the case of +COMSPEC+. If the string from the first form (exec("command")) follows these simple rules: * no meta characters * not starting with shell reserved word or special built-in * Ruby invokes the command directly without shell You can force shell invocation by adding ";" to the string (because ";" is a meta character). Note that this behavior is observable by pid obtained (return value of spawn() and IO#pid for IO.popen) is the pid of the invoked command, not shell. In the second form (exec("command1", "arg1", ...)), the first is taken as a command name and the rest are passed as parameters to command with no shell expansion. In the third form (exec(["command", "argv0"], "arg1", ...)), starting a two-element array at the beginning of the command, the first element is the command to be executed, and the second argument is used as the argv[0] value, which may show up in process listings. In order to execute the command, one of the exec(2) system calls are used, so the running command may inherit some of the environment of the original program (including open file descriptors). This behavior is modified by the given +env+ and +options+ parameters. See ::spawn for details. If the command fails to execute (typically Errno::ENOENT when it was not found) a SystemCallError exception is raised. This method modifies process attributes according to given +options+ before exec(2) system call. See ::spawn for more details about the given +options+. The modified attributes may be retained when exec(2) system call fails. For example, hard resource limits are not restorable. Consider to create a child process using ::spawn or Kernel#system if this is not acceptable. exec "echo *" # echoes list of files in current directory # never get here exec "echo", "*" # echoes an asterisk # never get here ;T;[o;= ;>I" overload;F;?0;;;@0;:I"'exec([env,] command... [,options]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"[env,][,options];T0;$@;![;"@ ;#0;$@;.F;/o;0;1T;2i4 ;3iz ;%@;9I"ostatic VALUE f_exec(int c, const VALUE *a, VALUE _) { rb_f_exec(c, a); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process.fork;F;7[;[[@ i,;T;;;0;[;{;IC; "Creates a subprocess. If a block is specified, that block is run in the subprocess, and the subprocess terminates with a status of zero. Otherwise, the +fork+ call returns twice, once in the parent, returning the process ID of the child, and once in the child, returning _nil_. The child process can exit using Kernel.exit! to avoid running any at_exit functions. The parent process should use Process.wait to collect the termination statuses of its children or use Process.detach to register disinterest in their status; otherwise, the operating system may accumulate zombie processes. The thread calling fork is the only thread in the created child process. fork doesn't copy other threads. If fork is not usable, Process.respond_to?(:fork) returns false. Note that fork(2) is not available on some platforms like Windows and NetBSD 4. Therefore you should use spawn() instead of fork(). ;T;[o;= ;>I" overload;F;?0;;;@0;:I" fork;T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@;![;"I"%@yield [] @return [Integer, nil];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" fork;T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@;![;"I"%@yield [] @return [Integer, nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"@ ;#0;$@;.F;/o;0;1T;2i;3i,;%@;9I"static VALUE rb_f_fork(VALUE obj) { rb_pid_t pid; pid = rb_call_proc__fork(); if (pid == 0) { if (rb_block_given_p()) { int status; rb_protect(rb_yield, Qundef, &status); ruby_stop(status); } return Qnil; } return PIDT2NUM(pid); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process.spawn;F;7[[@90;[[@ i;T;;;0;[;{;IC; "7*spawn executes specified command and return its pid. pid = spawn("tar xf ruby-2.0.0-p195.tar.bz2") Process.wait pid pid = spawn(RbConfig.ruby, "-eputs'Hello, world!'") Process.wait pid This method is similar to Kernel#system but it doesn't wait for the command to finish. The parent process should use Process.wait to collect the termination status of its child or use Process.detach to register disinterest in their status; otherwise, the operating system may accumulate zombie processes. spawn has bunch of options to specify process attributes: env: hash name => val : set the environment variable name => nil : unset the environment variable the keys and the values except for +nil+ must be strings. command...: commandline : command line string which is passed to the standard shell cmdname, arg1, ... : command name and one or more arguments (This form does not use the shell. See below for caveats.) [cmdname, argv0], arg1, ... : command name, argv[0] and zero or more arguments (no shell) options: hash clearing environment variables: :unsetenv_others => true : clear environment variables except specified by env :unsetenv_others => false : don't clear (default) process group: :pgroup => true or 0 : make a new process group :pgroup => pgid : join the specified process group :pgroup => nil : don't change the process group (default) create new process group: Windows only :new_pgroup => true : the new process is the root process of a new process group :new_pgroup => false : don't create a new process group (default) resource limit: resourcename is core, cpu, data, etc. See Process.setrlimit. :rlimit_resourcename => limit :rlimit_resourcename => [cur_limit, max_limit] umask: :umask => int redirection: key: FD : single file descriptor in child process [FD, FD, ...] : multiple file descriptor in child process value: FD : redirect to the file descriptor in parent process string : redirect to file with open(string, "r" or "w") [string] : redirect to file with open(string, File::RDONLY) [string, open_mode] : redirect to file with open(string, open_mode, 0644) [string, open_mode, perm] : redirect to file with open(string, open_mode, perm) [:child, FD] : redirect to the redirected file descriptor :close : close the file descriptor in child process FD is one of follows :in : the file descriptor 0 which is the standard input :out : the file descriptor 1 which is the standard output :err : the file descriptor 2 which is the standard error integer : the file descriptor of specified the integer io : the file descriptor specified as io.fileno file descriptor inheritance: close non-redirected non-standard fds (3, 4, 5, ...) or not :close_others => false : inherit current directory: :chdir => str The cmdname, arg1, ... form does not use the shell. However, on different OSes, different things are provided as built-in commands. An example of this is +'echo'+, which is a built-in on Windows, but is a normal program on Linux and Mac OS X. This means that Process.spawn 'echo', '%Path%' will display the contents of the %Path% environment variable on Windows, but Process.spawn 'echo', '$PATH' prints the literal $PATH. If a hash is given as +env+, the environment is updated by +env+ before exec(2) in the child process. If a pair in +env+ has nil as the value, the variable is deleted. # set FOO as BAR and unset BAZ. pid = spawn({"FOO"=>"BAR", "BAZ"=>nil}, command) If a hash is given as +options+, it specifies process group, create new process group, resource limit, current directory, umask and redirects for the child process. Also, it can be specified to clear environment variables. The :unsetenv_others key in +options+ specifies to clear environment variables, other than specified by +env+. pid = spawn(command, :unsetenv_others=>true) # no environment variable pid = spawn({"FOO"=>"BAR"}, command, :unsetenv_others=>true) # FOO only The :pgroup key in +options+ specifies a process group. The corresponding value should be true, zero, a positive integer, or nil. true and zero cause the process to be a process leader of a new process group. A non-zero positive integer causes the process to join the provided process group. The default value, nil, causes the process to remain in the same process group. pid = spawn(command, :pgroup=>true) # process leader pid = spawn(command, :pgroup=>10) # belongs to the process group 10 The :new_pgroup key in +options+ specifies to pass +CREATE_NEW_PROCESS_GROUP+ flag to CreateProcessW() that is Windows API. This option is only for Windows. true means the new process is the root process of the new process group. The new process has CTRL+C disabled. This flag is necessary for Process.kill(:SIGINT, pid) on the subprocess. :new_pgroup is false by default. pid = spawn(command, :new_pgroup=>true) # new process group pid = spawn(command, :new_pgroup=>false) # same process group The :rlimit_foo key specifies a resource limit. foo should be one of resource types such as core. The corresponding value should be an integer or an array which have one or two integers: same as cur_limit and max_limit arguments for Process.setrlimit. cur, max = Process.getrlimit(:CORE) pid = spawn(command, :rlimit_core=>[0,max]) # disable core temporary. pid = spawn(command, :rlimit_core=>max) # enable core dump pid = spawn(command, :rlimit_core=>0) # never dump core. The :umask key in +options+ specifies the umask. pid = spawn(command, :umask=>077) The :in, :out, :err, an integer, an IO and an array key specifies a redirection. The redirection maps a file descriptor in the child process. For example, stderr can be merged into stdout as follows: pid = spawn(command, :err=>:out) pid = spawn(command, 2=>1) pid = spawn(command, STDERR=>:out) pid = spawn(command, STDERR=>STDOUT) The hash keys specifies a file descriptor in the child process started by #spawn. :err, 2 and STDERR specifies the standard error stream (stderr). The hash values specifies a file descriptor in the parent process which invokes #spawn. :out, 1 and STDOUT specifies the standard output stream (stdout). In the above example, the standard output in the child process is not specified. So it is inherited from the parent process. The standard input stream (stdin) can be specified by :in, 0 and STDIN. A filename can be specified as a hash value. pid = spawn(command, :in=>"/dev/null") # read mode pid = spawn(command, :out=>"/dev/null") # write mode pid = spawn(command, :err=>"log") # write mode pid = spawn(command, [:out, :err]=>"/dev/null") # write mode pid = spawn(command, 3=>"/dev/null") # read mode For stdout and stderr (and combination of them), it is opened in write mode. Otherwise read mode is used. For specifying flags and permission of file creation explicitly, an array is used instead. pid = spawn(command, :in=>["file"]) # read mode is assumed pid = spawn(command, :in=>["file", "r"]) pid = spawn(command, :out=>["log", "w"]) # 0644 assumed pid = spawn(command, :out=>["log", "w", 0600]) pid = spawn(command, :out=>["log", File::WRONLY|File::EXCL|File::CREAT, 0600]) The array specifies a filename, flags and permission. The flags can be a string or an integer. If the flags is omitted or nil, File::RDONLY is assumed. The permission should be an integer. If the permission is omitted or nil, 0644 is assumed. If an array of IOs and integers are specified as a hash key, all the elements are redirected. # stdout and stderr is redirected to log file. # The file "log" is opened just once. pid = spawn(command, [:out, :err]=>["log", "w"]) Another way to merge multiple file descriptors is [:child, fd]. \[:child, fd] means the file descriptor in the child process. This is different from fd. For example, :err=>:out means redirecting child stderr to parent stdout. But :err=>[:child, :out] means redirecting child stderr to child stdout. They differ if stdout is redirected in the child process as follows. # stdout and stderr is redirected to log file. # The file "log" is opened just once. pid = spawn(command, :out=>["log", "w"], :err=>[:child, :out]) \[:child, :out] can be used to merge stderr into stdout in IO.popen. In this case, IO.popen redirects stdout to a pipe in the child process and [:child, :out] refers the redirected stdout. io = IO.popen(["sh", "-c", "echo out; echo err >&2", :err=>[:child, :out]]) p io.read #=> "out\nerr\n" The :chdir key in +options+ specifies the current directory. pid = spawn(command, :chdir=>"/var/tmp") spawn closes all non-standard unspecified descriptors by default. The "standard" descriptors are 0, 1 and 2. This behavior is specified by :close_others option. :close_others doesn't affect the standard descriptors which are closed only if :close is specified explicitly. pid = spawn(command, :close_others=>true) # close 3,4,5,... (default) pid = spawn(command, :close_others=>false) # don't close 3,4,5,... :close_others is false by default for spawn and IO.popen. Note that fds which close-on-exec flag is already set are closed regardless of :close_others option. So IO.pipe and spawn can be used as IO.popen. # similar to r = IO.popen(command) r, w = IO.pipe pid = spawn(command, :out=>w) # r, w is closed in the child process. w.close :close is specified as a hash value to close a fd individually. f = open(foo) system(command, f=>:close) # don't inherit f. If a file descriptor need to be inherited, io=>io can be used. # valgrind has --log-fd option for log destination. # log_w=>log_w indicates log_w.fileno inherits to child process. log_r, log_w = IO.pipe pid = spawn("valgrind", "--log-fd=#{log_w.fileno}", "echo", "a", log_w=>log_w) log_w.close p log_r.read It is also possible to exchange file descriptors. pid = spawn(command, :out=>:err, :err=>:out) The hash keys specify file descriptors in the child process. The hash values specifies file descriptors in the parent process. So the above specifies exchanging stdout and stderr. Internally, +spawn+ uses an extra file descriptor to resolve such cyclic file descriptor mapping. See Kernel.exec for the standard shell. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"(spawn([env,] command... [,options]);T;IC; ";T;[;![;"I";T;#0;$@E;.F;Bi;C0;7[[I"[env,][,options];T0;$@Eo;= ;>I" overload;F;?0;;;@0;:I"(spawn([env,] command... [,options]);T;IC; ";T;[;![;"I";T;#0;$@E;.F;Bi;C0;7[[I"[env,][,options];T0;$@E;![;"@ ;#0;$@E;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_f_spawn(int argc, VALUE *argv, VALUE _) { rb_pid_t pid; char errmsg[CHILD_ERRMSG_BUFLEN] = { '\0' }; VALUE execarg_obj, fail_str; struct rb_execarg *eargp; execarg_obj = rb_execarg_new(argc, argv, TRUE, FALSE); eargp = rb_execarg_get(execarg_obj); fail_str = eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name; pid = rb_execarg_spawn(execarg_obj, errmsg, sizeof(errmsg)); if (pid == -1) { int err = errno; rb_exec_fail(eargp, err, errmsg); RB_GC_GUARD(execarg_obj); rb_syserr_fail_str(err, fail_str); } #if defined(HAVE_WORKING_FORK) || defined(HAVE_SPAWNV) return PIDT2NUM(pid); #else return Qnil; #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process.exit!;F;7[[@90;[[@ if;T;;;0;[;{;IC; "Exits the process immediately. No exit handlers are run. status is returned to the underlying system as the exit status. Process.exit!(true) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"exit!(status=false);T;IC; ";T;[;![;"I";T;#0;$@g;.F;Bi;C0;7[[I" status;TI" false;T;$@g;![;"@ ;#0;$@g;.F;/o;0;1T;2i[;3ib;%@;9I"static VALUE rb_f_exit_bang(int argc, VALUE *argv, VALUE obj) { int istatus; if (rb_check_arity(argc, 0, 1) == 1) { istatus = exit_status_code(argv[0]); } else { istatus = EXIT_FAILURE; } _exit(istatus); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process.exit;F;7[[I"*a;T0[I"_;T0;[[@ i;T;;;0;[;{;IC; "Initiates the termination of the Ruby script by raising the SystemExit exception. This exception may be caught. The optional parameter is used to return a status code to the invoking environment. +true+ and +FALSE+ of _status_ means success and failure respectively. The interpretation of other integer values are system dependent. begin exit puts "never get here" rescue SystemExit puts "rescued a SystemExit exception" end puts "after begin block" produces: rescued a SystemExit exception after begin block Just prior to termination, Ruby executes any at_exit functions (see Kernel::at_exit) and runs any object finalizers (see ObjectSpace::define_finalizer). at_exit { puts "at_exit function" } ObjectSpace.define_finalizer("string", proc { puts "in finalizer" }) exit produces: at_exit function in finalizer ;T;[o;= ;>I" overload;F;?0;;;@0;:I"exit(status=true);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" status;TI" true;T;$@o;= ;>I" overload;F;?0;;;@0;:I"Kernel::exit(status=true);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" status;TI" true;T;$@o;= ;>I" overload;F;?0;;;@0;:I"Process::exit(status=true);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" status;TI" true;T;$@;![;"@q ;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"ostatic VALUE f_exit(int c, const VALUE *a, VALUE _) { rb_f_exit(c, a); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process.abort;F;7[[I"*a;T0[I"_;T0;[[@ i;T;;;0;[;{;IC; "Terminate execution immediately, effectively by calling Kernel.exit(false). If _msg_ is given, it is written to STDERR prior to terminating. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" abort;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"Kernel::abort([msg]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" [msg];T0;$@o;= ;>I" overload;F;?0;;;@0;:I"abort([msg]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" [msg];T0;$@;![;"@ ;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"qstatic VALUE f_abort(int c, const VALUE *a, VALUE _) { rb_f_abort(c, a); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process.last_status;F;7[;[[@ ik;T;:last_status;0;[;{;IC; "?Returns the status of the last executed child process in the current thread. Process.wait Process.spawn("ruby", "-e", "exit 13") Process.last_status #=> # If no child process has ever been executed in the current thread, this returns +nil+. Process.last_status #=> nil ;T;[o;= ;>I" overload;F;?0;;R;@0;:I"last_status;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Process::Status;TI"nil;T;$@߳;![;"I"#@return [Process::Status, nil];T;#0;$@߳;.F;Bi;C0;7[;$@߳;![;"I"xReturns the status of the last executed child process in the current thread. Process.wait Process.spawn("ruby", "-e", "exit 13") Process.last_status #=> # If no child process has ever been executed in the current thread, this returns +nil+. Process.last_status #=> nil @overload last_status @return [Process::Status, nil];T;#0;$@߳;.F;/o;0;1T;2i\;3ii;%@;9I"Tstatic VALUE proc_s_last_status(VALUE mod) { return rb_last_status_get(); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Process._fork;F;7[;[[@ i;T;: _fork;0;[;{;IC; "2An internal API for fork. Do not call this method directly. Currently, this is called via Kernel#fork, Process.fork, and IO.popen with "-". This method is not for casual code but for application monitoring libraries. You can add custom code before and after fork events by overriding this method. ;T;[o;= ;>I" overload;F;?0;;S;@0;:I" _fork;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"XAn internal API for fork. Do not call this method directly. Currently, this is called via Kernel#fork, Process.fork, and IO.popen with "-". This method is not for casual code but for application monitoring libraries. You can add custom code before and after fork events by overriding this method. @overload _fork @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"VALUE rb_proc__fork(VALUE _obj) { rb_pid_t pid = rb_fork_ruby(NULL); if (pid == -1) { rb_sys_fail("fork(2)"); } return PIDT2NUM(pid); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Process#kill;F;7[[I"*v;T0[I"_;T0;[[@ i!;T;;(;0;[;{;IC; "Sends the given signal to the specified process id(s) if _pid_ is positive. If _pid_ is zero, _signal_ is sent to all processes whose group ID is equal to the group ID of the process. If _pid_ is negative, results are dependent on the operating system. _signal_ may be an integer signal number or a POSIX signal name (either with or without a +SIG+ prefix). If _signal_ is negative (or starts with a minus sign), kills process groups instead of processes. Not all signals are available on all platforms. The keys and values of Signal.list are known signal names and numbers, respectively. pid = fork do Signal.trap("HUP") { puts "Ouch!"; exit } # ... do some work ... end # ... Process.kill("HUP", pid) Process.wait produces: Ouch! If _signal_ is an integer but wrong for signal, Errno::EINVAL or RangeError will be raised. Otherwise unless _signal_ is a String or a Symbol, and a known signal name, ArgumentError will be raised. Also, Errno::ESRCH or RangeError for invalid _pid_, Errno::EPERM when failed because of no privilege, will be raised. In these cases, signals may have been sent to preceding processes. ;T;[o;= ;>I" overload;F;?0;;(;@0;:I"kill(signal, pid, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I" signal;T0[I"pid;T0[I"...;T0;$@;![;"I"Sends the given signal to the specified process id(s) if _pid_ is positive. If _pid_ is zero, _signal_ is sent to all processes whose group ID is equal to the group ID of the process. If _pid_ is negative, results are dependent on the operating system. _signal_ may be an integer signal number or a POSIX signal name (either with or without a +SIG+ prefix). If _signal_ is negative (or starts with a minus sign), kills process groups instead of processes. Not all signals are available on all platforms. The keys and values of Signal.list are known signal names and numbers, respectively. pid = fork do Signal.trap("HUP") { puts "Ouch!"; exit } # ... do some work ... end # ... Process.kill("HUP", pid) Process.wait produces: Ouch! If _signal_ is an integer but wrong for signal, Errno::EINVAL or RangeError will be raised. Otherwise unless _signal_ is a String or a Symbol, and a known signal name, ArgumentError will be raised. Also, Errno::ESRCH or RangeError for invalid _pid_, Errno::EPERM when failed because of no privilege, will be raised. In these cases, signals may have been sent to preceding processes. @overload kill(signal, pid, ...) @return [Integer];T;#0;$@;.F;C0;%@;9I"`static VALUE proc_rb_f_kill(int c, const VALUE *v, VALUE _) { return rb_f_kill(c, v); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.kill;F;7@;@;T;;(;0;@;{;IC; "Sends the given signal to the specified process id(s) if _pid_ is positive. If _pid_ is zero, _signal_ is sent to all processes whose group ID is equal to the group ID of the process. If _pid_ is negative, results are dependent on the operating system. _signal_ may be an integer signal number or a POSIX signal name (either with or without a +SIG+ prefix). If _signal_ is negative (or starts with a minus sign), kills process groups instead of processes. Not all signals are available on all platforms. The keys and values of Signal.list are known signal names and numbers, respectively. pid = fork do Signal.trap("HUP") { puts "Ouch!"; exit } # ... do some work ... end # ... Process.kill("HUP", pid) Process.wait produces: Ouch! If _signal_ is an integer but wrong for signal, Errno::EINVAL or RangeError will be raised. Otherwise unless _signal_ is a String or a Symbol, and a known signal name, ArgumentError will be raised. Also, Errno::ESRCH or RangeError for invalid _pid_, Errno::EPERM when failed because of no privilege, will be raised. In these cases, signals may have been sent to preceding processes.;T;[o;= ;>I" overload;F;?0;;(;@0;:I"kill(signal, pid, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@:;![;"I"@return [Integer];T;#0;$@:;.F;Bi;C0;7[[I" signal;T0[I"pid;T0[I"...;T0;$@:;![;"I"Sends the given signal to the specified process id(s) if _pid_ is positive. If _pid_ is zero, _signal_ is sent to all processes whose group ID is equal to the group ID of the process. If _pid_ is negative, results are dependent on the operating system. _signal_ may be an integer signal number or a POSIX signal name (either with or without a +SIG+ prefix). If _signal_ is negative (or starts with a minus sign), kills process groups instead of processes. Not all signals are available on all platforms. The keys and values of Signal.list are known signal names and numbers, respectively. pid = fork do Signal.trap("HUP") { puts "Ouch!"; exit } # ... do some work ... end # ... Process.kill("HUP", pid) Process.wait produces: Ouch! If _signal_ is an integer but wrong for signal, Errno::EINVAL or RangeError will be raised. Otherwise unless _signal_ is a String or a Symbol, and a known signal name, ArgumentError will be raised. Also, Errno::ESRCH or RangeError for invalid _pid_, Errno::EPERM when failed because of no privilege, will be raised. In these cases, signals may have been sent to preceding processes. @overload kill(signal, pid, ...) @return [Integer];T;#0;$@:;.F;/o;0;1T;2i!;3i!;Bi;%@;9@8;:@9;;To;4;5F;6;;;;&I"Process#wait;F;7[[I"*v;T0[I"_;T0;[[@ i;T;;h;0;[;{;IC; "Waits for a child process to exit, returns its process id, and sets $? to a Process::Status object containing information on that process. Which child it waits on depends on the value of _pid_: > 0:: Waits for the child whose process ID equals _pid_. 0:: Waits for any child whose process group ID equals that of the calling process. -1:: Waits for any child process (the default if no _pid_ is given). < -1:: Waits for any child whose process group ID equals the absolute value of _pid_. The _flags_ argument may be a logical or of the flag values Process::WNOHANG (do not block if no child available) or Process::WUNTRACED (return stopped children that haven't been reported). Not all flags are available on all platforms, but a flag value of zero will work on all platforms. Calling this method raises a SystemCallError if there are no child processes. Not available on all platforms. include Process fork { exit 99 } #=> 27429 wait #=> 27429 $?.exitstatus #=> 99 pid = fork { sleep 3 } #=> 27440 Time.now #=> 2008-03-08 19:56:16 +0900 waitpid(pid, Process::WNOHANG) #=> nil Time.now #=> 2008-03-08 19:56:16 +0900 waitpid(pid, 0) #=> 27440 Time.now #=> 2008-03-08 19:56:19 +0900 ;T;[o;= ;>I" overload;F;?0;;h;@0;:I" wait();T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@U;![;"I"@return [Integer];T;#0;$@U;.F;Bi;C0;7[;$@Uo;= ;>I" overload;F;?0;;h;@0;:I"wait(pid=-1, flags=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@U;![;"I"@return [Integer];T;#0;$@U;.F;Bi;C0;7[[I"pid;TI"-1;T[I" flags;TI"0;T;$@Uo;= ;>I" overload;F;?0;: waitpid;@0;:I"waitpid(pid=-1, flags=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@U;![;"I"@return [Integer];T;#0;$@U;.F;Bi;C0;7[[I"pid;TI"-1;T[I" flags;TI"0;T;$@U;![;"I")Waits for a child process to exit, returns its process id, and sets $? to a Process::Status object containing information on that process. Which child it waits on depends on the value of _pid_: > 0:: Waits for the child whose process ID equals _pid_. 0:: Waits for any child whose process group ID equals that of the calling process. -1:: Waits for any child process (the default if no _pid_ is given). < -1:: Waits for any child whose process group ID equals the absolute value of _pid_. The _flags_ argument may be a logical or of the flag values Process::WNOHANG (do not block if no child available) or Process::WUNTRACED (return stopped children that haven't been reported). Not all flags are available on all platforms, but a flag value of zero will work on all platforms. Calling this method raises a SystemCallError if there are no child processes. Not available on all platforms. include Process fork { exit 99 } #=> 27429 wait #=> 27429 $?.exitstatus #=> 99 pid = fork { sleep 3 } #=> 27440 Time.now #=> 2008-03-08 19:56:16 +0900 waitpid(pid, Process::WNOHANG) #=> nil Time.now #=> 2008-03-08 19:56:16 +0900 waitpid(pid, 0) #=> 27440 Time.now #=> 2008-03-08 19:56:19 +0900 @overload wait() @return [Integer] @overload wait(pid=-1, flags=0) @return [Integer] @overload waitpid(pid=-1, flags=0) @return [Integer];T;#0;$@U;.F;C0;%@;9I"Wstatic VALUE proc_m_wait(int c, VALUE *v, VALUE _) { return proc_wait(c, v); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.wait;F;7@W;@\;T;;h;0;@^;{;IC; "Waits for a child process to exit, returns its process id, and sets $? to a Process::Status object containing information on that process. Which child it waits on depends on the value of _pid_: > 0:: Waits for the child whose process ID equals _pid_. 0:: Waits for any child whose process group ID equals that of the calling process. -1:: Waits for any child process (the default if no _pid_ is given). < -1:: Waits for any child whose process group ID equals the absolute value of _pid_. The _flags_ argument may be a logical or of the flag values Process::WNOHANG (do not block if no child available) or Process::WUNTRACED (return stopped children that haven't been reported). Not all flags are available on all platforms, but a flag value of zero will work on all platforms. Calling this method raises a SystemCallError if there are no child processes. Not available on all platforms. include Process fork { exit 99 } #=> 27429 wait #=> 27429 $?.exitstatus #=> 99 pid = fork { sleep 3 } #=> 27440 Time.now #=> 2008-03-08 19:56:16 +0900 waitpid(pid, Process::WNOHANG) #=> nil Time.now #=> 2008-03-08 19:56:16 +0900 waitpid(pid, 0) #=> 27440 Time.now #=> 2008-03-08 19:56:19 +0900;T;[o;= ;>I" overload;F;?0;;h;@0;:I" wait();T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;h;@0;:I"wait(pid=-1, flags=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I"pid;TI"-1;T[I" flags;TI"0;T;$@o;= ;>I" overload;F;?0;;T;@0;:I"waitpid(pid=-1, flags=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I"pid;TI"-1;T[I" flags;TI"0;T;$@;![;"I"(Waits for a child process to exit, returns its process id, and sets $? to a Process::Status object containing information on that process. Which child it waits on depends on the value of _pid_: > 0:: Waits for the child whose process ID equals _pid_. 0:: Waits for any child whose process group ID equals that of the calling process. -1:: Waits for any child process (the default if no _pid_ is given). < -1:: Waits for any child whose process group ID equals the absolute value of _pid_. The _flags_ argument may be a logical or of the flag values Process::WNOHANG (do not block if no child available) or Process::WUNTRACED (return stopped children that haven't been reported). Not all flags are available on all platforms, but a flag value of zero will work on all platforms. Calling this method raises a SystemCallError if there are no child processes. Not available on all platforms. include Process fork { exit 99 } #=> 27429 wait #=> 27429 $?.exitstatus #=> 99 pid = fork { sleep 3 } #=> 27440 Time.now #=> 2008-03-08 19:56:16 +0900 waitpid(pid, Process::WNOHANG) #=> nil Time.now #=> 2008-03-08 19:56:16 +0900 waitpid(pid, 0) #=> 27440 Time.now #=> 2008-03-08 19:56:19 +0900 @overload wait() @return [Integer] @overload wait(pid=-1, flags=0) @return [Integer] @overload waitpid(pid=-1, flags=0) @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process#wait2;F;7[[@90;[[@ i;T;: wait2;0;[;{;IC; "Waits for a child process to exit (see Process::waitpid for exact semantics) and returns an array containing the process id and the exit status (a Process::Status object) of that child. Raises a SystemCallError if there are no child processes. Process.fork { exit 99 } #=> 27437 pid, status = Process.wait2 pid #=> 27437 status.exitstatus #=> 99 ;T;[o;= ;>I" overload;F;?0;;U;@0;:I"wait2(pid=-1, flags=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@Դ;![;"I"@return [Array];T;#0;$@Դ;.F;Bi;C0;7[[I"pid;TI"-1;T[I" flags;TI"0;T;$@Դo;= ;>I" overload;F;?0;: waitpid2;@0;:I"waitpid2(pid=-1, flags=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@Դ;![;"I"@return [Array];T;#0;$@Դ;.F;Bi;C0;7[[I"pid;TI"-1;T[I" flags;TI"0;T;$@Դ;![;"I"Waits for a child process to exit (see Process::waitpid for exact semantics) and returns an array containing the process id and the exit status (a Process::Status object) of that child. Raises a SystemCallError if there are no child processes. Process.fork { exit 99 } #=> 27437 pid, status = Process.wait2 pid #=> 27437 status.exitstatus #=> 99 @overload wait2(pid=-1, flags=0) @return [Array] @overload waitpid2(pid=-1, flags=0) @return [Array];T;#0;$@Դ;.F;C0;%@;9I"static VALUE proc_wait2(int argc, VALUE *argv, VALUE _) { VALUE pid = proc_wait(argc, argv); if (NIL_P(pid)) return Qnil; return rb_assoc_new(pid, rb_last_status_get()); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.wait2;F;7@ִ;@ش;T;;U;0;@ڴ;{;IC; "Waits for a child process to exit (see Process::waitpid for exact semantics) and returns an array containing the process id and the exit status (a Process::Status object) of that child. Raises a SystemCallError if there are no child processes. Process.fork { exit 99 } #=> 27437 pid, status = Process.wait2 pid #=> 27437 status.exitstatus #=> 99;T;[o;= ;>I" overload;F;?0;;U;@0;:I"wait2(pid=-1, flags=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"pid;TI"-1;T[I" flags;TI"0;T;$@o;= ;>I" overload;F;?0;;V;@0;:I"waitpid2(pid=-1, flags=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"pid;TI"-1;T[I" flags;TI"0;T;$@;![;"I"Waits for a child process to exit (see Process::waitpid for exact semantics) and returns an array containing the process id and the exit status (a Process::Status object) of that child. Raises a SystemCallError if there are no child processes. Process.fork { exit 99 } #=> 27437 pid, status = Process.wait2 pid #=> 27437 status.exitstatus #=> 99 @overload wait2(pid=-1, flags=0) @return [Array] @overload waitpid2(pid=-1, flags=0) @return [Array];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process#waitpid;F;7[[I"*v;T0[I"_;T0;[[@ i;T;;T;0;[;{;IC; "Waits for a child process to exit, returns its process id, and sets $? to a Process::Status object containing information on that process. Which child it waits on depends on the value of _pid_: > 0:: Waits for the child whose process ID equals _pid_. 0:: Waits for any child whose process group ID equals that of the calling process. -1:: Waits for any child process (the default if no _pid_ is given). < -1:: Waits for any child whose process group ID equals the absolute value of _pid_. The _flags_ argument may be a logical or of the flag values Process::WNOHANG (do not block if no child available) or Process::WUNTRACED (return stopped children that haven't been reported). Not all flags are available on all platforms, but a flag value of zero will work on all platforms. Calling this method raises a SystemCallError if there are no child processes. Not available on all platforms. include Process fork { exit 99 } #=> 27429 wait #=> 27429 $?.exitstatus #=> 99 pid = fork { sleep 3 } #=> 27440 Time.now #=> 2008-03-08 19:56:16 +0900 waitpid(pid, Process::WNOHANG) #=> nil Time.now #=> 2008-03-08 19:56:16 +0900 waitpid(pid, 0) #=> 27440 Time.now #=> 2008-03-08 19:56:19 +0900 ;T;[o;= ;>I" overload;F;?0;;h;@0;:I" wait();T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@6;![;"I"@return [Integer];T;#0;$@6;.F;Bi;C0;7[;$@6o;= ;>I" overload;F;?0;;h;@0;:I"wait(pid=-1, flags=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@6;![;"I"@return [Integer];T;#0;$@6;.F;Bi;C0;7[[I"pid;TI"-1;T[I" flags;TI"0;T;$@6o;= ;>I" overload;F;?0;;T;@0;:I"waitpid(pid=-1, flags=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@6;![;"I"@return [Integer];T;#0;$@6;.F;Bi;C0;7[[I"pid;TI"-1;T[I" flags;TI"0;T;$@6;![;"I")Waits for a child process to exit, returns its process id, and sets $? to a Process::Status object containing information on that process. Which child it waits on depends on the value of _pid_: > 0:: Waits for the child whose process ID equals _pid_. 0:: Waits for any child whose process group ID equals that of the calling process. -1:: Waits for any child process (the default if no _pid_ is given). < -1:: Waits for any child whose process group ID equals the absolute value of _pid_. The _flags_ argument may be a logical or of the flag values Process::WNOHANG (do not block if no child available) or Process::WUNTRACED (return stopped children that haven't been reported). Not all flags are available on all platforms, but a flag value of zero will work on all platforms. Calling this method raises a SystemCallError if there are no child processes. Not available on all platforms. include Process fork { exit 99 } #=> 27429 wait #=> 27429 $?.exitstatus #=> 99 pid = fork { sleep 3 } #=> 27440 Time.now #=> 2008-03-08 19:56:16 +0900 waitpid(pid, Process::WNOHANG) #=> nil Time.now #=> 2008-03-08 19:56:16 +0900 waitpid(pid, 0) #=> 27440 Time.now #=> 2008-03-08 19:56:19 +0900 @overload wait() @return [Integer] @overload wait(pid=-1, flags=0) @return [Integer] @overload waitpid(pid=-1, flags=0) @return [Integer];T;#0;$@6;.F;C0;%@;9I"Wstatic VALUE proc_m_wait(int c, VALUE *v, VALUE _) { return proc_wait(c, v); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.waitpid;F;7@8;@=;T;;T;0;@?;{;IC; "Waits for a child process to exit, returns its process id, and sets $? to a Process::Status object containing information on that process. Which child it waits on depends on the value of _pid_: > 0:: Waits for the child whose process ID equals _pid_. 0:: Waits for any child whose process group ID equals that of the calling process. -1:: Waits for any child process (the default if no _pid_ is given). < -1:: Waits for any child whose process group ID equals the absolute value of _pid_. The _flags_ argument may be a logical or of the flag values Process::WNOHANG (do not block if no child available) or Process::WUNTRACED (return stopped children that haven't been reported). Not all flags are available on all platforms, but a flag value of zero will work on all platforms. Calling this method raises a SystemCallError if there are no child processes. Not available on all platforms. include Process fork { exit 99 } #=> 27429 wait #=> 27429 $?.exitstatus #=> 99 pid = fork { sleep 3 } #=> 27440 Time.now #=> 2008-03-08 19:56:16 +0900 waitpid(pid, Process::WNOHANG) #=> nil Time.now #=> 2008-03-08 19:56:16 +0900 waitpid(pid, 0) #=> 27440 Time.now #=> 2008-03-08 19:56:19 +0900;T;[o;= ;>I" overload;F;?0;;h;@0;:I" wait();T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@z;![;"I"@return [Integer];T;#0;$@z;.F;Bi;C0;7[;$@zo;= ;>I" overload;F;?0;;h;@0;:I"wait(pid=-1, flags=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@z;![;"I"@return [Integer];T;#0;$@z;.F;Bi;C0;7[[I"pid;TI"-1;T[I" flags;TI"0;T;$@zo;= ;>I" overload;F;?0;;T;@0;:I"waitpid(pid=-1, flags=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@z;![;"I"@return [Integer];T;#0;$@z;.F;Bi;C0;7[[I"pid;TI"-1;T[I" flags;TI"0;T;$@z;![;"@Ҵ;#0;$@z;.F;/o;0;1T;2i;3i;Bi;%@;9@x;:@y;;To;4;5F;6;;;;&I"Process#waitpid2;F;7[[@90;[[@ i;T;;V;0;[;{;IC; "Waits for a child process to exit (see Process::waitpid for exact semantics) and returns an array containing the process id and the exit status (a Process::Status object) of that child. Raises a SystemCallError if there are no child processes. Process.fork { exit 99 } #=> 27437 pid, status = Process.wait2 pid #=> 27437 status.exitstatus #=> 99 ;T;[o;= ;>I" overload;F;?0;;U;@0;:I"wait2(pid=-1, flags=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"pid;TI"-1;T[I" flags;TI"0;T;$@o;= ;>I" overload;F;?0;;V;@0;:I"waitpid2(pid=-1, flags=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"pid;TI"-1;T[I" flags;TI"0;T;$@;![;"I"Waits for a child process to exit (see Process::waitpid for exact semantics) and returns an array containing the process id and the exit status (a Process::Status object) of that child. Raises a SystemCallError if there are no child processes. Process.fork { exit 99 } #=> 27437 pid, status = Process.wait2 pid #=> 27437 status.exitstatus #=> 99 @overload wait2(pid=-1, flags=0) @return [Array] @overload waitpid2(pid=-1, flags=0) @return [Array];T;#0;$@;.F;C0;%@;9I"static VALUE proc_wait2(int argc, VALUE *argv, VALUE _) { VALUE pid = proc_wait(argc, argv); if (NIL_P(pid)) return Qnil; return rb_assoc_new(pid, rb_last_status_get()); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.waitpid2;F;7@;@;T;;V;0;@;{;IC; "Waits for a child process to exit (see Process::waitpid for exact semantics) and returns an array containing the process id and the exit status (a Process::Status object) of that child. Raises a SystemCallError if there are no child processes. Process.fork { exit 99 } #=> 27437 pid, status = Process.wait2 pid #=> 27437 status.exitstatus #=> 99;T;[o;= ;>I" overload;F;?0;;U;@0;:I"wait2(pid=-1, flags=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"pid;TI"-1;T[I" flags;TI"0;T;$@o;= ;>I" overload;F;?0;;V;@0;:I"waitpid2(pid=-1, flags=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"pid;TI"-1;T[I" flags;TI"0;T;$@;![;"@4;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process#waitall;F;7[;[[@ i1;T;: waitall;0;[;{;IC; "Waits for all children, returning an array of _pid_/_status_ pairs (where _status_ is a Process::Status object). fork { sleep 0.2; exit 2 } #=> 27432 fork { sleep 0.1; exit 1 } #=> 27433 fork { exit 0 } #=> 27434 p Process.waitall produces: [[30982, #], [30979, #], [30976, #]] ;T;[o;= ;>I" overload;F;?0;;W;@0;:I" waitall;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Waits for all children, returning an array of _pid_/_status_ pairs (where _status_ is a Process::Status object). fork { sleep 0.2; exit 2 } #=> 27432 fork { sleep 0.1; exit 1 } #=> 27433 fork { exit 0 } #=> 27434 p Process.waitall produces: [[30982, #], [30979, #], [30976, #]] @overload waitall @return [Array];T;#0;$@;.F;C0;%@;9I"static VALUE proc_waitall(VALUE _) { VALUE result; rb_pid_t pid; int status; result = rb_ary_new(); rb_last_status_clear(); for (pid = -1;;) { pid = rb_waitpid(-1, &status, 0); if (pid == -1) { int e = errno; if (e == ECHILD) break; rb_syserr_fail(e, 0); } rb_ary_push(result, rb_assoc_new(PIDT2NUM(pid), rb_last_status_get())); } return result; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.waitall;F;7@;@;T;;W;0;@;{;IC; "Waits for all children, returning an array of _pid_/_status_ pairs (where _status_ is a Process::Status object). fork { sleep 0.2; exit 2 } #=> 27432 fork { sleep 0.1; exit 1 } #=> 27433 fork { exit 0 } #=> 27434 p Process.waitall produces: [[30982, #], [30979, #], [30976, #]];T;[o;= ;>I" overload;F;?0;;W;@0;:I" waitall;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@/;![;"I"@return [Array];T;#0;$@/;.F;Bi;C0;7[;$@/;![;"I"Waits for all children, returning an array of _pid_/_status_ pairs (where _status_ is a Process::Status object). fork { sleep 0.2; exit 2 } #=> 27432 fork { sleep 0.1; exit 1 } #=> 27433 fork { exit 0 } #=> 27434 p Process.waitall produces: [[30982, #], [30979, #], [30976, #]] @overload waitall @return [Array];T;#0;$@/;.F;/o;0;1T;2i;3i.;Bi;%@;9@-;:@.;;To;4;5F;6;;;;&I"Process#detach;F;7[[I"pid;T0;[[@ i;T;: detach;0;[;{;IC; ""Some operating systems retain the status of terminated child processes until the parent collects that status (normally using some variant of wait()). If the parent never collects this status, the child stays around as a zombie process. Process::detach prevents this by setting up a separate Ruby thread whose sole job is to reap the status of the process _pid_ when it terminates. Use #detach only when you do not intend to explicitly wait for the child to terminate. The waiting thread returns the exit status of the detached process when it terminates, so you can use Thread#join to know the result. If specified _pid_ is not a valid child process ID, the thread returns +nil+ immediately. The waiting thread has #pid method which returns the pid. In this first example, we don't reap the first child process, so it appears as a zombie in the process status display. p1 = fork { sleep 0.1 } p2 = fork { sleep 0.2 } Process.waitpid(p2) sleep 2 system("ps -ho pid,state -p #{p1}") produces: 27389 Z In the next example, Process::detach is used to reap the child automatically. p1 = fork { sleep 0.1 } p2 = fork { sleep 0.2 } Process.detach(p1) Process.waitpid(p2) sleep 2 system("ps -ho pid,state -p #{p1}") (produces no output) ;T;[o;= ;>I" overload;F;?0;;X;@0;:I"detach(pid);T;IC; ";T;[;![;"I";T;#0;$@D;.F;Bi;C0;7[[I"pid;T0;$@D;![;"I"9Some operating systems retain the status of terminated child processes until the parent collects that status (normally using some variant of wait()). If the parent never collects this status, the child stays around as a zombie process. Process::detach prevents this by setting up a separate Ruby thread whose sole job is to reap the status of the process _pid_ when it terminates. Use #detach only when you do not intend to explicitly wait for the child to terminate. The waiting thread returns the exit status of the detached process when it terminates, so you can use Thread#join to know the result. If specified _pid_ is not a valid child process ID, the thread returns +nil+ immediately. The waiting thread has #pid method which returns the pid. In this first example, we don't reap the first child process, so it appears as a zombie in the process status display. p1 = fork { sleep 0.1 } p2 = fork { sleep 0.2 } Process.waitpid(p2) sleep 2 system("ps -ho pid,state -p #{p1}") produces: 27389 Z In the next example, Process::detach is used to reap the child automatically. p1 = fork { sleep 0.1 } p2 = fork { sleep 0.2 } Process.detach(p1) Process.waitpid(p2) sleep 2 system("ps -ho pid,state -p #{p1}") (produces no output) @overload detach(pid) ;T;#0;$@D;.F;C0;%@;9I"dstatic VALUE proc_detach(VALUE obj, VALUE pid) { return rb_detach_process(NUM2PIDT(pid)); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.detach;F;7@F;@I;T;;X;0;@K;{;IC; ""Some operating systems retain the status of terminated child processes until the parent collects that status (normally using some variant of wait()). If the parent never collects this status, the child stays around as a zombie process. Process::detach prevents this by setting up a separate Ruby thread whose sole job is to reap the status of the process _pid_ when it terminates. Use #detach only when you do not intend to explicitly wait for the child to terminate. The waiting thread returns the exit status of the detached process when it terminates, so you can use Thread#join to know the result. If specified _pid_ is not a valid child process ID, the thread returns +nil+ immediately. The waiting thread has #pid method which returns the pid. In this first example, we don't reap the first child process, so it appears as a zombie in the process status display. p1 = fork { sleep 0.1 } p2 = fork { sleep 0.2 } Process.waitpid(p2) sleep 2 system("ps -ho pid,state -p #{p1}") produces: 27389 Z In the next example, Process::detach is used to reap the child automatically. p1 = fork { sleep 0.1 } p2 = fork { sleep 0.2 } Process.detach(p1) Process.waitpid(p2) sleep 2 system("ps -ho pid,state -p #{p1}") (produces no output);T;[o;= ;>I" overload;F;?0;;X;@0;:I"detach(pid);T;IC; ";T;[;![;"I";T;#0;$@];.F;Bi;C0;7[[I"pid;T0;$@];![;"I":Some operating systems retain the status of terminated child processes until the parent collects that status (normally using some variant of wait()). If the parent never collects this status, the child stays around as a zombie process. Process::detach prevents this by setting up a separate Ruby thread whose sole job is to reap the status of the process _pid_ when it terminates. Use #detach only when you do not intend to explicitly wait for the child to terminate. The waiting thread returns the exit status of the detached process when it terminates, so you can use Thread#join to know the result. If specified _pid_ is not a valid child process ID, the thread returns +nil+ immediately. The waiting thread has #pid method which returns the pid. In this first example, we don't reap the first child process, so it appears as a zombie in the process status display. p1 = fork { sleep 0.1 } p2 = fork { sleep 0.2 } Process.waitpid(p2) sleep 2 system("ps -ho pid,state -p #{p1}") produces: 27389 Z In the next example, Process::detach is used to reap the child automatically. p1 = fork { sleep 0.1 } p2 = fork { sleep 0.2 } Process.detach(p1) Process.waitpid(p2) sleep 2 system("ps -ho pid,state -p #{p1}") (produces no output) @overload detach(pid);T;#0;$@];.F;/o;0;1T;2if;3i;Bi;%@;9@[;:@\;;To; ;IC;[o;4;5F;6;;;;&I"Process::Waiter#pid;F;7[;[[@ iJ;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@q;%@o;9I"gstatic VALUE detach_process_pid(VALUE thread) { return rb_thread_local_aref(thread, id_pid); };T;:I"static VALUE;T;;T; @o; IC;[; @o; IC;[; @o; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ i";F;: Waiter;;;;;[;{;IC; " ;T;[;![;"@;#0;$@o;%@;&I"Process::Waiter;F;'@Ho;4;5F;6;;;;&I"Process#pid;F;7[;[[@ i;T;;;0;[;{;IC; "hReturns the process id of this process. Not available on all platforms. Process.pid #=> 27415 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"pid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the process id of this process. Not available on all platforms. Process.pid #=> 27415 @overload pid @return [Integer];T;#0;$@;.F;C0;%@;9I"Astatic VALUE proc_get_pid(VALUE _) { return get_pid(); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.pid;F;7@;@;T;;;0;@;{;IC; "hReturns the process id of this process. Not available on all platforms. Process.pid #=> 27415;T;[o;= ;>I" overload;F;?0;;;@0;:I"pid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the process id of this process. Not available on all platforms. Process.pid #=> 27415 @overload pid @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process#ppid;F;7[;[[@ i;T;: ppid;0;[;{;IC; "Returns the process id of the parent of this process. Returns untrustworthy value on Win32/64. Not available on all platforms. puts "I am #{Process.pid}" Process.fork { puts "Dad is #{Process.ppid}" } produces: I am 27417 Dad is 27417 ;T;[o;= ;>I" overload;F;?0;;Z;@0;:I" ppid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"&Returns the process id of the parent of this process. Returns untrustworthy value on Win32/64. Not available on all platforms. puts "I am #{Process.pid}" Process.fork { puts "Dad is #{Process.ppid}" } produces: I am 27417 Dad is 27417 @overload ppid @return [Integer];T;#0;$@;.F;C0;%@;9I"Cstatic VALUE proc_get_ppid(VALUE _) { return get_ppid(); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.ppid;F;7@;@;T;;Z;0;@;{;IC; "Returns the process id of the parent of this process. Returns untrustworthy value on Win32/64. Not available on all platforms. puts "I am #{Process.pid}" Process.fork { puts "Dad is #{Process.ppid}" } produces: I am 27417 Dad is 27417;T;[o;= ;>I" overload;F;?0;;Z;@0;:I" ppid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ն;![;"I"@return [Integer];T;#0;$@ն;.F;Bi;C0;7[;$@ն;![;"I"'Returns the process id of the parent of this process. Returns untrustworthy value on Win32/64. Not available on all platforms. puts "I am #{Process.pid}" Process.fork { puts "Dad is #{Process.ppid}" } produces: I am 27417 Dad is 27417 @overload ppid @return [Integer];T;#0;$@ն;.F;/o;0;1T;2i;3i;Bi;%@;9@Ӷ;:@Զ;;To;4;5F;6;;;;&I"Process#getpgrp;F;7[;[[@ iO;T;: getpgrp;0;[;{;IC; "Returns the process group ID for this process. Not available on all platforms. Process.getpgid(0) #=> 25527 Process.getpgrp #=> 25527 ;T;[o;= ;>I" overload;F;?0;;[;@0;:I" getpgrp;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the process group ID for this process. Not available on all platforms. Process.getpgid(0) #=> 25527 Process.getpgrp #=> 25527 @overload getpgrp @return [Integer];T;#0;$@;.F;C0;%@;9I"=static VALUE proc_getpgrp(VALUE _) { rb_pid_t pgrp; #if defined(HAVE_GETPGRP) && defined(GETPGRP_VOID) pgrp = getpgrp(); if (pgrp < 0) rb_sys_fail(0); return PIDT2NUM(pgrp); #else /* defined(HAVE_GETPGID) */ pgrp = getpgid(0); if (pgrp < 0) rb_sys_fail(0); return PIDT2NUM(pgrp); #endif };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.getpgrp;F;7@;@;T;;[;0;@;{;IC; "Returns the process group ID for this process. Not available on all platforms. Process.getpgid(0) #=> 25527 Process.getpgrp #=> 25527;T;[o;= ;>I" overload;F;?0;;[;@0;:I" getpgrp;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the process group ID for this process. Not available on all platforms. Process.getpgid(0) #=> 25527 Process.getpgrp #=> 25527 @overload getpgrp @return [Integer];T;#0;$@;.F;/o;0;1T;2iD;3iL;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process#setpgrp;F;7[;[[@ il;T;: setpgrp;0;[;{;IC; "MEquivalent to setpgid(0,0). Not available on all platforms. ;T;[o;= ;>I" overload;F;?0;;\;@0;:I" setpgrp;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@;![;"I"@return [0];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"nEquivalent to setpgid(0,0). Not available on all platforms. @overload setpgrp @return [0];T;#0;$@;.F;C0;%@;9I"static VALUE proc_setpgrp(VALUE _) { /* check for posix setpgid() first; this matches the posix */ /* getpgrp() above. It appears that configure will set SETPGRP_VOID */ /* even though setpgrp(0,0) would be preferred. The posix call avoids */ /* this confusion. */ #ifdef HAVE_SETPGID if (setpgid(0,0) < 0) rb_sys_fail(0); #elif defined(HAVE_SETPGRP) && defined(SETPGRP_VOID) if (setpgrp() < 0) rb_sys_fail(0); #endif return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.setpgrp;F;7@;@;T;;\;0;@;{;IC; "MEquivalent to setpgid(0,0). Not available on all platforms.;T;[o;= ;>I" overload;F;?0;;\;@0;:I" setpgrp;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@3;![;"I"@return [0];T;#0;$@3;.F;Bi;C0;7[;$@3;![;"I"oEquivalent to setpgid(0,0). Not available on all platforms. @overload setpgrp @return [0];T;#0;$@3;.F;/o;0;1T;2id;3ii;Bi;%@;9@1;:@2;;To;4;5F;6;;;;&I"Process#getpgid;F;7[[I"pid;T0;[[@ i;T;: getpgid;0;[;{;IC; "Returns the process group ID for the given process id. Not available on all platforms. Process.getpgid(Process.ppid()) #=> 25527 ;T;[o;= ;>I" overload;F;?0;;];@0;:I"getpgid(pid);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@H;![;"I"@return [Integer];T;#0;$@H;.F;Bi;C0;7[[I"pid;T0;$@H;![;"I"Returns the process group ID for the given process id. Not available on all platforms. Process.getpgid(Process.ppid()) #=> 25527 @overload getpgid(pid) @return [Integer];T;#0;$@H;.F;C0;%@;9I"static VALUE proc_getpgid(VALUE obj, VALUE pid) { rb_pid_t i; i = getpgid(NUM2PIDT(pid)); if (i < 0) rb_sys_fail(0); return PIDT2NUM(i); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.getpgid;F;7@J;@M;T;;];0;@O;{;IC; "Returns the process group ID for the given process id. Not available on all platforms. Process.getpgid(Process.ppid()) #=> 25527;T;[o;= ;>I" overload;F;?0;;];@0;:I"getpgid(pid);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@f;![;"I"@return [Integer];T;#0;$@f;.F;Bi;C0;7[[I"pid;T0;$@f;![;"I"Returns the process group ID for the given process id. Not available on all platforms. Process.getpgid(Process.ppid()) #=> 25527 @overload getpgid(pid) @return [Integer];T;#0;$@f;.F;/o;0;1T;2i;3i;Bi;%@;9@d;:@e;;To;4;5F;6;;;;&I"Process#setpgid;F;7[[I"pid;T0[I" pgrp;T0;[[@ i;T;: setpgid;0;[;{;IC; "wSets the process group ID of _pid_ (0 indicates this process) to integer. Not available on all platforms. ;T;[o;= ;>I" overload;F;?0;;^;@0;:I"setpgid(pid, integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@};![;"I"@return [0];T;#0;$@};.F;Bi;C0;7[[I"pid;T0[I" integer;T0;$@};![;"I"Sets the process group ID of _pid_ (0 indicates this process) to integer. Not available on all platforms. @overload setpgid(pid, integer) @return [0];T;#0;$@};.F;C0;%@;9I"static VALUE proc_setpgid(VALUE obj, VALUE pid, VALUE pgrp) { rb_pid_t ipid, ipgrp; ipid = NUM2PIDT(pid); ipgrp = NUM2PIDT(pgrp); if (setpgid(ipid, ipgrp) < 0) rb_sys_fail(0); return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.setpgid;F;7@;@;T;;^;0;@;{;IC; "wSets the process group ID of _pid_ (0 indicates this process) to integer. Not available on all platforms.;T;[o;= ;>I" overload;F;?0;;^;@0;:I"setpgid(pid, integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@;![;"I"@return [0];T;#0;$@;.F;Bi;C0;7[[I"pid;T0[I" integer;T0;$@;![;"I"Sets the process group ID of _pid_ (0 indicates this process) to integer. Not available on all platforms. @overload setpgid(pid, integer) @return [0];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process#getsid;F;7[[@90;[[@ i;T;: getsid;0;[;{;IC; "Returns the session ID for the given process id. If not given, return current process sid. Not available on all platforms. Process.getsid() #=> 27422 Process.getsid(0) #=> 27422 Process.getsid(Process.pid()) #=> 27422 ;T;[o;= ;>I" overload;F;?0;;_;@0;:I" getsid();T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;_;@0;:I"getsid(pid);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I"pid;T0;$@;![;"I"UReturns the session ID for the given process id. If not given, return current process sid. Not available on all platforms. Process.getsid() #=> 27422 Process.getsid(0) #=> 27422 Process.getsid(Process.pid()) #=> 27422 @overload getsid() @return [Integer] @overload getsid(pid) @return [Integer];T;#0;$@;.F;C0;%@;9I"static VALUE proc_getsid(int argc, VALUE *argv, VALUE _) { rb_pid_t sid; rb_pid_t pid = 0; if (rb_check_arity(argc, 0, 1) == 1 && !NIL_P(argv[0])) pid = NUM2PIDT(argv[0]); sid = getsid(pid); if (sid < 0) rb_sys_fail(0); return PIDT2NUM(sid); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.getsid;F;7@;@;T;;_;0;@;{;IC; "Returns the session ID for the given process id. If not given, return current process sid. Not available on all platforms. Process.getsid() #=> 27422 Process.getsid(0) #=> 27422 Process.getsid(Process.pid()) #=> 27422;T;[o;= ;>I" overload;F;?0;;_;@0;:I" getsid();T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;_;@0;:I"getsid(pid);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I"pid;T0;$@;![;"I"UReturns the session ID for the given process id. If not given, return current process sid. Not available on all platforms. Process.getsid() #=> 27422 Process.getsid(0) #=> 27422 Process.getsid(Process.pid()) #=> 27422 @overload getsid() @return [Integer] @overload getsid(pid) @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process#setsid;F;7[;[[@ i;T;: setsid;0;[;{;IC; "Establishes this process as a new session and process group leader, with no controlling tty. Returns the session id. Not available on all platforms. Process.setsid #=> 27422 ;T;[o;= ;>I" overload;F;?0;;`;@0;:I" setsid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Establishes this process as a new session and process group leader, with no controlling tty. Returns the session id. Not available on all platforms. Process.setsid #=> 27422 @overload setsid @return [Integer];T;#0;$@;.F;C0;%@;9I"static VALUE proc_setsid(VALUE _) { rb_pid_t pid; pid = setsid(); if (pid < 0) rb_sys_fail(0); return PIDT2NUM(pid); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.setsid;F;7@;@ ;T;;`;0;@ ;{;IC; "Establishes this process as a new session and process group leader, with no controlling tty. Returns the session id. Not available on all platforms. Process.setsid #=> 27422;T;[o;= ;>I" overload;F;?0;;`;@0;:I" setsid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Establishes this process as a new session and process group leader, with no controlling tty. Returns the session id. Not available on all platforms. Process.setsid #=> 27422 @overload setsid @return [Integer];T;#0;$@ ;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process#getpriority;F;7[[I" which;T0[I"who;T0;[[@ i;T;:getpriority;0;[;{;IC; "Gets the scheduling priority for specified process, process group, or user. kind indicates the kind of entity to find: one of Process::PRIO_PGRP, Process::PRIO_USER, or Process::PRIO_PROCESS. _integer_ is an id indicating the particular process, process group, or user (an id of 0 means _current_). Lower priorities are more favorable for scheduling. Not available on all platforms. Process.getpriority(Process::PRIO_USER, 0) #=> 19 Process.getpriority(Process::PRIO_PROCESS, 0) #=> 19 ;T;[o;= ;>I" overload;F;?0;;a;@0;:I"getpriority(kind, integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@5;![;"I"@return [Integer];T;#0;$@5;.F;Bi;C0;7[[I" kind;T0[I" integer;T0;$@5;![;"I"6Gets the scheduling priority for specified process, process group, or user. kind indicates the kind of entity to find: one of Process::PRIO_PGRP, Process::PRIO_USER, or Process::PRIO_PROCESS. _integer_ is an id indicating the particular process, process group, or user (an id of 0 means _current_). Lower priorities are more favorable for scheduling. Not available on all platforms. Process.getpriority(Process::PRIO_USER, 0) #=> 19 Process.getpriority(Process::PRIO_PROCESS, 0) #=> 19 @overload getpriority(kind, integer) @return [Integer];T;#0;$@5;.F;C0;%@;9I"static VALUE proc_getpriority(VALUE obj, VALUE which, VALUE who) { int prio, iwhich, iwho; iwhich = NUM2INT(which); iwho = NUM2INT(who); errno = 0; prio = getpriority(iwhich, iwho); if (errno) rb_sys_fail(0); return INT2FIX(prio); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.getpriority;F;7@7;@<;T;;a;0;@>;{;IC; "Gets the scheduling priority for specified process, process group, or user. kind indicates the kind of entity to find: one of Process::PRIO_PGRP, Process::PRIO_USER, or Process::PRIO_PROCESS. _integer_ is an id indicating the particular process, process group, or user (an id of 0 means _current_). Lower priorities are more favorable for scheduling. Not available on all platforms. Process.getpriority(Process::PRIO_USER, 0) #=> 19 Process.getpriority(Process::PRIO_PROCESS, 0) #=> 19;T;[o;= ;>I" overload;F;?0;;a;@0;:I"getpriority(kind, integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@W;![;"I"@return [Integer];T;#0;$@W;.F;Bi;C0;7[[I" kind;T0[I" integer;T0;$@W;![;"I"7Gets the scheduling priority for specified process, process group, or user. kind indicates the kind of entity to find: one of Process::PRIO_PGRP, Process::PRIO_USER, or Process::PRIO_PROCESS. _integer_ is an id indicating the particular process, process group, or user (an id of 0 means _current_). Lower priorities are more favorable for scheduling. Not available on all platforms. Process.getpriority(Process::PRIO_USER, 0) #=> 19 Process.getpriority(Process::PRIO_PROCESS, 0) #=> 19 @overload getpriority(kind, integer) @return [Integer];T;#0;$@W;.F;/o;0;1T;2i ;3i;Bi;%@;9@U;:@V;;To;4;5F;6;;;;&I"Process#setpriority;F;7[[I" which;T0[I"who;T0[I" prio;T0;[[@ i;;T;:setpriority;0;[;{;IC; "See Process.getpriority. Process.setpriority(Process::PRIO_USER, 0, 19) #=> 0 Process.setpriority(Process::PRIO_PROCESS, 0, 19) #=> 0 Process.getpriority(Process::PRIO_USER, 0) #=> 19 Process.getpriority(Process::PRIO_PROCESS, 0) #=> 19 ;T;[o;= ;>I" overload;F;?0;;b;@0;:I")setpriority(kind, integer, priority);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@p;![;"I"@return [0];T;#0;$@p;.F;Bi;C0;7[[I" kind;T0[I" integer;T0[I" priority;T0;$@p;![;"I"MSee Process.getpriority. Process.setpriority(Process::PRIO_USER, 0, 19) #=> 0 Process.setpriority(Process::PRIO_PROCESS, 0, 19) #=> 0 Process.getpriority(Process::PRIO_USER, 0) #=> 19 Process.getpriority(Process::PRIO_PROCESS, 0) #=> 19 @overload setpriority(kind, integer, priority) @return [0];T;#0;$@p;.F;C0;%@;9I"static VALUE proc_setpriority(VALUE obj, VALUE which, VALUE who, VALUE prio) { int iwhich, iwho, iprio; iwhich = NUM2INT(which); iwho = NUM2INT(who); iprio = NUM2INT(prio); if (setpriority(iwhich, iwho, iprio) < 0) rb_sys_fail(0); return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.setpriority;F;7@r;@y;T;;b;0;@{;{;IC; "See Process.getpriority. Process.setpriority(Process::PRIO_USER, 0, 19) #=> 0 Process.setpriority(Process::PRIO_PROCESS, 0, 19) #=> 0 Process.getpriority(Process::PRIO_USER, 0) #=> 19 Process.getpriority(Process::PRIO_PROCESS, 0) #=> 19;T;[o;= ;>I" overload;F;?0;;b;@0;:I")setpriority(kind, integer, priority);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@;![;"I"@return [0];T;#0;$@;.F;Bi;C0;7[[I" kind;T0[I" integer;T0[I" priority;T0;$@;![;"I"NSee Process.getpriority. Process.setpriority(Process::PRIO_USER, 0, 19) #=> 0 Process.setpriority(Process::PRIO_PROCESS, 0, 19) #=> 0 Process.getpriority(Process::PRIO_USER, 0) #=> 19 Process.getpriority(Process::PRIO_PROCESS, 0) #=> 19 @overload setpriority(kind, integer, priority) @return [0];T;#0;$@;.F;/o;0;1T;2i/;3i8;Bi;%@;9@;:@;;To;u;[[@ iJ";F;:PRIO_PROCESS;;w;;;[;{;IC; "see Process.setpriority ;T;[;![;"I"see Process.setpriority;T;#0;$@;.F;/o;0;1T;2iI";3iI";%@;&I"Process::PRIO_PROCESS;F;xI"INT2FIX(PRIO_PROCESS);To;u;[[@ iL";F;:PRIO_PGRP;;w;;;[;{;IC; "see Process.setpriority ;T;[;![;"I"see Process.setpriority;T;#0;$@;.F;/o;0;1T;2iK";3iK";%@;&I"Process::PRIO_PGRP;F;xI"INT2FIX(PRIO_PGRP);To;u;[[@ iN";F;:PRIO_USER;;w;;;[;{;IC; "see Process.setpriority ;T;[;![;"I"see Process.setpriority;T;#0;$@ɸ;.F;/o;0;1T;2iM";3iM";%@;&I"Process::PRIO_USER;F;xI"INT2FIX(PRIO_USER);To;4;5F;6;;;;&I"Process#getrlimit;F;7[[I" resource;T0;[[@ i?;T;:getrlimit;0;[;{;IC; "Gets the resource limit of the process. _cur_limit_ means current (soft) limit and _max_limit_ means maximum (hard) limit. _resource_ indicates the kind of resource to limit. It is specified as a symbol such as :CORE, a string such as "CORE" or a constant such as Process::RLIMIT_CORE. See Process.setrlimit for details. _cur_limit_ and _max_limit_ may be Process::RLIM_INFINITY, Process::RLIM_SAVED_MAX or Process::RLIM_SAVED_CUR. See Process.setrlimit and the system getrlimit(2) manual for details. ;T;[o;= ;>I" overload;F;?0;;f;@0;:I"getrlimit(resource);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@ո;![;"I"@return [Array];T;#0;$@ո;.F;Bi;C0;7[[I" resource;T0;$@ո;![;"I"BGets the resource limit of the process. _cur_limit_ means current (soft) limit and _max_limit_ means maximum (hard) limit. _resource_ indicates the kind of resource to limit. It is specified as a symbol such as :CORE, a string such as "CORE" or a constant such as Process::RLIMIT_CORE. See Process.setrlimit for details. _cur_limit_ and _max_limit_ may be Process::RLIM_INFINITY, Process::RLIM_SAVED_MAX or Process::RLIM_SAVED_CUR. See Process.setrlimit and the system getrlimit(2) manual for details. @overload getrlimit(resource) @return [Array];T;#0;$@ո;.F;C0;%@;9I"static VALUE proc_getrlimit(VALUE obj, VALUE resource) { struct rlimit rlim; if (getrlimit(rlimit_resource_type(resource), &rlim) < 0) { rb_sys_fail("getrlimit"); } return rb_assoc_new(RLIM2NUM(rlim.rlim_cur), RLIM2NUM(rlim.rlim_max)); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.getrlimit;F;7@׸;@ڸ;T;;f;0;@ܸ;{;IC; "Gets the resource limit of the process. _cur_limit_ means current (soft) limit and _max_limit_ means maximum (hard) limit. _resource_ indicates the kind of resource to limit. It is specified as a symbol such as :CORE, a string such as "CORE" or a constant such as Process::RLIMIT_CORE. See Process.setrlimit for details. _cur_limit_ and _max_limit_ may be Process::RLIM_INFINITY, Process::RLIM_SAVED_MAX or Process::RLIM_SAVED_CUR. See Process.setrlimit and the system getrlimit(2) manual for details.;T;[o;= ;>I" overload;F;?0;;f;@0;:I"getrlimit(resource);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" resource;T0;$@;![;"I"CGets the resource limit of the process. _cur_limit_ means current (soft) limit and _max_limit_ means maximum (hard) limit. _resource_ indicates the kind of resource to limit. It is specified as a symbol such as :CORE, a string such as "CORE" or a constant such as Process::RLIMIT_CORE. See Process.setrlimit for details. _cur_limit_ and _max_limit_ may be Process::RLIM_INFINITY, Process::RLIM_SAVED_MAX or Process::RLIM_SAVED_CUR. See Process.setrlimit and the system getrlimit(2) manual for details. @overload getrlimit(resource) @return [Array];T;#0;$@;.F;/o;0;1T;2i+;3i<;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process#setrlimit;F;7[[@90;[[@ i;T;:setrlimit;0;[;{;IC; "Sets the resource limit of the process. _cur_limit_ means current (soft) limit and _max_limit_ means maximum (hard) limit. If _max_limit_ is not given, _cur_limit_ is used. _resource_ indicates the kind of resource to limit. It should be a symbol such as :CORE, a string such as "CORE" or a constant such as Process::RLIMIT_CORE. The available resources are OS dependent. Ruby may support following resources. [AS] total available memory (bytes) (SUSv3, NetBSD, FreeBSD, OpenBSD but 4.4BSD-Lite) [CORE] core size (bytes) (SUSv3) [CPU] CPU time (seconds) (SUSv3) [DATA] data segment (bytes) (SUSv3) [FSIZE] file size (bytes) (SUSv3) [MEMLOCK] total size for mlock(2) (bytes) (4.4BSD, GNU/Linux) [MSGQUEUE] allocation for POSIX message queues (bytes) (GNU/Linux) [NICE] ceiling on process's nice(2) value (number) (GNU/Linux) [NOFILE] file descriptors (number) (SUSv3) [NPROC] number of processes for the user (number) (4.4BSD, GNU/Linux) [RSS] resident memory size (bytes) (4.2BSD, GNU/Linux) [RTPRIO] ceiling on the process's real-time priority (number) (GNU/Linux) [RTTIME] CPU time for real-time process (us) (GNU/Linux) [SBSIZE] all socket buffers (bytes) (NetBSD, FreeBSD) [SIGPENDING] number of queued signals allowed (signals) (GNU/Linux) [STACK] stack size (bytes) (SUSv3) _cur_limit_ and _max_limit_ may be :INFINITY, "INFINITY" or Process::RLIM_INFINITY, which means that the resource is not limited. They may be Process::RLIM_SAVED_MAX, Process::RLIM_SAVED_CUR and corresponding symbols and strings too. See system setrlimit(2) manual for details. The following example raises the soft limit of core size to the hard limit to try to make core dump possible. Process.setrlimit(:CORE, Process.getrlimit(:CORE)[1]) ;T;[o;= ;>I" overload;F;?0;;g;@0;:I".setrlimit(resource, cur_limit, max_limit);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@ ;![;"I"@return [nil];T;#0;$@ ;.F;Bi;C0;7[[I" resource;T0[I"cur_limit;T0[I"max_limit;T0;$@ o;= ;>I" overload;F;?0;;g;@0;:I"#setrlimit(resource, cur_limit);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@ ;![;"I"@return [nil];T;#0;$@ ;.F;Bi;C0;7[[I" resource;T0[I"cur_limit;T0;$@ ;![;"I"tSets the resource limit of the process. _cur_limit_ means current (soft) limit and _max_limit_ means maximum (hard) limit. If _max_limit_ is not given, _cur_limit_ is used. _resource_ indicates the kind of resource to limit. It should be a symbol such as :CORE, a string such as "CORE" or a constant such as Process::RLIMIT_CORE. The available resources are OS dependent. Ruby may support following resources. [AS] total available memory (bytes) (SUSv3, NetBSD, FreeBSD, OpenBSD but 4.4BSD-Lite) [CORE] core size (bytes) (SUSv3) [CPU] CPU time (seconds) (SUSv3) [DATA] data segment (bytes) (SUSv3) [FSIZE] file size (bytes) (SUSv3) [MEMLOCK] total size for mlock(2) (bytes) (4.4BSD, GNU/Linux) [MSGQUEUE] allocation for POSIX message queues (bytes) (GNU/Linux) [NICE] ceiling on process's nice(2) value (number) (GNU/Linux) [NOFILE] file descriptors (number) (SUSv3) [NPROC] number of processes for the user (number) (4.4BSD, GNU/Linux) [RSS] resident memory size (bytes) (4.2BSD, GNU/Linux) [RTPRIO] ceiling on the process's real-time priority (number) (GNU/Linux) [RTTIME] CPU time for real-time process (us) (GNU/Linux) [SBSIZE] all socket buffers (bytes) (NetBSD, FreeBSD) [SIGPENDING] number of queued signals allowed (signals) (GNU/Linux) [STACK] stack size (bytes) (SUSv3) _cur_limit_ and _max_limit_ may be :INFINITY, "INFINITY" or Process::RLIM_INFINITY, which means that the resource is not limited. They may be Process::RLIM_SAVED_MAX, Process::RLIM_SAVED_CUR and corresponding symbols and strings too. See system setrlimit(2) manual for details. The following example raises the soft limit of core size to the hard limit to try to make core dump possible. Process.setrlimit(:CORE, Process.getrlimit(:CORE)[1]) @overload setrlimit(resource, cur_limit, max_limit) @return [nil] @overload setrlimit(resource, cur_limit) @return [nil];T;#0;$@ ;.F;C0;%@;9I"static VALUE proc_setrlimit(int argc, VALUE *argv, VALUE obj) { VALUE resource, rlim_cur, rlim_max; struct rlimit rlim; rb_check_arity(argc, 2, 3); resource = argv[0]; rlim_cur = argv[1]; if (argc < 3 || NIL_P(rlim_max = argv[2])) rlim_max = rlim_cur; rlim.rlim_cur = rlimit_resource_value(rlim_cur); rlim.rlim_max = rlimit_resource_value(rlim_max); if (setrlimit(rlimit_resource_type(resource), &rlim) < 0) { rb_sys_fail("setrlimit"); } return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.setrlimit;F;7@ ;@;T;;g;0;@;{;IC; "Sets the resource limit of the process. _cur_limit_ means current (soft) limit and _max_limit_ means maximum (hard) limit. If _max_limit_ is not given, _cur_limit_ is used. _resource_ indicates the kind of resource to limit. It should be a symbol such as :CORE, a string such as "CORE" or a constant such as Process::RLIMIT_CORE. The available resources are OS dependent. Ruby may support following resources. [AS] total available memory (bytes) (SUSv3, NetBSD, FreeBSD, OpenBSD but 4.4BSD-Lite) [CORE] core size (bytes) (SUSv3) [CPU] CPU time (seconds) (SUSv3) [DATA] data segment (bytes) (SUSv3) [FSIZE] file size (bytes) (SUSv3) [MEMLOCK] total size for mlock(2) (bytes) (4.4BSD, GNU/Linux) [MSGQUEUE] allocation for POSIX message queues (bytes) (GNU/Linux) [NICE] ceiling on process's nice(2) value (number) (GNU/Linux) [NOFILE] file descriptors (number) (SUSv3) [NPROC] number of processes for the user (number) (4.4BSD, GNU/Linux) [RSS] resident memory size (bytes) (4.2BSD, GNU/Linux) [RTPRIO] ceiling on the process's real-time priority (number) (GNU/Linux) [RTTIME] CPU time for real-time process (us) (GNU/Linux) [SBSIZE] all socket buffers (bytes) (NetBSD, FreeBSD) [SIGPENDING] number of queued signals allowed (signals) (GNU/Linux) [STACK] stack size (bytes) (SUSv3) _cur_limit_ and _max_limit_ may be :INFINITY, "INFINITY" or Process::RLIM_INFINITY, which means that the resource is not limited. They may be Process::RLIM_SAVED_MAX, Process::RLIM_SAVED_CUR and corresponding symbols and strings too. See system setrlimit(2) manual for details. The following example raises the soft limit of core size to the hard limit to try to make core dump possible. Process.setrlimit(:CORE, Process.getrlimit(:CORE)[1]);T;[o;= ;>I" overload;F;?0;;g;@0;:I".setrlimit(resource, cur_limit, max_limit);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@<;![;"I"@return [nil];T;#0;$@<;.F;Bi;C0;7[[I" resource;T0[I"cur_limit;T0[I"max_limit;T0;$@I" overload;F;?0;;g;@0;:I"#setrlimit(resource, cur_limit);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@<;![;"I"@return [nil];T;#0;$@<;.F;Bi;C0;7[[I" resource;T0[I"cur_limit;T0;$@<;![;"I"uSets the resource limit of the process. _cur_limit_ means current (soft) limit and _max_limit_ means maximum (hard) limit. If _max_limit_ is not given, _cur_limit_ is used. _resource_ indicates the kind of resource to limit. It should be a symbol such as :CORE, a string such as "CORE" or a constant such as Process::RLIMIT_CORE. The available resources are OS dependent. Ruby may support following resources. [AS] total available memory (bytes) (SUSv3, NetBSD, FreeBSD, OpenBSD but 4.4BSD-Lite) [CORE] core size (bytes) (SUSv3) [CPU] CPU time (seconds) (SUSv3) [DATA] data segment (bytes) (SUSv3) [FSIZE] file size (bytes) (SUSv3) [MEMLOCK] total size for mlock(2) (bytes) (4.4BSD, GNU/Linux) [MSGQUEUE] allocation for POSIX message queues (bytes) (GNU/Linux) [NICE] ceiling on process's nice(2) value (number) (GNU/Linux) [NOFILE] file descriptors (number) (SUSv3) [NPROC] number of processes for the user (number) (4.4BSD, GNU/Linux) [RSS] resident memory size (bytes) (4.2BSD, GNU/Linux) [RTPRIO] ceiling on the process's real-time priority (number) (GNU/Linux) [RTTIME] CPU time for real-time process (us) (GNU/Linux) [SBSIZE] all socket buffers (bytes) (NetBSD, FreeBSD) [SIGPENDING] number of queued signals allowed (signals) (GNU/Linux) [STACK] stack size (bytes) (SUSv3) _cur_limit_ and _max_limit_ may be :INFINITY, "INFINITY" or Process::RLIM_INFINITY, which means that the resource is not limited. They may be Process::RLIM_SAVED_MAX, Process::RLIM_SAVED_CUR and corresponding symbols and strings too. See system setrlimit(2) manual for details. The following example raises the soft limit of core size to the hard limit to try to make core dump possible. Process.setrlimit(:CORE, Process.getrlimit(:CORE)[1]) @overload setrlimit(resource, cur_limit, max_limit) @return [nil] @overload setrlimit(resource, cur_limit) @return [nil];T;#0;$@<;.F;/o;0;1T;2iN;3i;Bi;%@;9@:;:@;;;To;u;[[@ iZ";F;:RLIM_SAVED_MAX;;w;;;[;{;IC; "see Process.setrlimit ;T;[;![;"I"see Process.setrlimit;T;#0;$@h;.F;/o;0;1T;2iY";3iY";%@;&I"Process::RLIM_SAVED_MAX;F;xI"v;To;u;[[@ i^";F;:RLIM_INFINITY;;w;;;[;{;IC; "see Process.setrlimit ;T;[;![;"I"see Process.setrlimit;T;#0;$@t;.F;/o;0;1T;2i]";3i]";%@;&I"Process::RLIM_INFINITY;F;xI"inf;To;u;[[@ ic";F;:RLIM_SAVED_CUR;;w;;;[;{;IC; "see Process.setrlimit ;T;[;![;"I"see Process.setrlimit;T;#0;$@;.F;/o;0;1T;2ib";3ib";%@;&I"Process::RLIM_SAVED_CUR;F;xI"v;To;u;[[@ il";F;:RLIMIT_AS;;w;;;[;{;IC; "|Maximum size of the process's virtual memory (address space) in bytes. see the system getrlimit(2) manual for details. ;T;[;![;"I"}Maximum size of the process's virtual memory (address space) in bytes. see the system getrlimit(2) manual for details. ;T;#0;$@;.F;/o;0;1T;2ih";3ik";%@;&I"Process::RLIMIT_AS;F;xI"INT2FIX(RLIMIT_AS);To;u;[[@ is";F;:RLIMIT_CORE;;w;;;[;{;IC; "TMaximum size of the core file. see the system getrlimit(2) manual for details. ;T;[;![;"I"UMaximum size of the core file. see the system getrlimit(2) manual for details. ;T;#0;$@;.F;/o;0;1T;2io";3ir";%@;&I"Process::RLIMIT_CORE;F;xI"INT2FIX(RLIMIT_CORE);To;u;[[@ iz";F;:RLIMIT_CPU;;w;;;[;{;IC; "PCPU time limit in seconds. see the system getrlimit(2) manual for details. ;T;[;![;"I"QCPU time limit in seconds. see the system getrlimit(2) manual for details. ;T;#0;$@;.F;/o;0;1T;2iv";3iy";%@;&I"Process::RLIMIT_CPU;F;xI"INT2FIX(RLIMIT_CPU);To;u;[[@ i";F;:RLIMIT_DATA;;w;;;[;{;IC; "aMaximum size of the process's data segment. see the system getrlimit(2) manual for details. ;T;[;![;"I"bMaximum size of the process's data segment. see the system getrlimit(2) manual for details. ;T;#0;$@;.F;/o;0;1T;2i}";3i";%@;&I"Process::RLIMIT_DATA;F;xI"INT2FIX(RLIMIT_DATA);To;u;[[@ i";F;:RLIMIT_FSIZE;;w;;;[;{;IC; "hMaximum size of files that the process may create. see the system getrlimit(2) manual for details. ;T;[;![;"I"iMaximum size of files that the process may create. see the system getrlimit(2) manual for details. ;T;#0;$@;.F;/o;0;1T;2i";3i";%@;&I"Process::RLIMIT_FSIZE;F;xI"INT2FIX(RLIMIT_FSIZE);To;u;[[@ i";F;:RLIMIT_MEMLOCK;;w;;;[;{;IC; "tMaximum number of bytes of memory that may be locked into RAM. see the system getrlimit(2) manual for details. ;T;[;![;"I"uMaximum number of bytes of memory that may be locked into RAM. see the system getrlimit(2) manual for details. ;T;#0;$@ȹ;.F;/o;0;1T;2i";3i";%@;&I"Process::RLIMIT_MEMLOCK;F;xI"INT2FIX(RLIMIT_MEMLOCK);To;u;[[@ i";F;:RLIMIT_MSGQUEUE;;w;;;[;{;IC; "Specifies the limit on the number of bytes that can be allocated for POSIX message queues for the real user ID of the calling process. see the system getrlimit(2) manual for details. ;T;[;![;"I"Specifies the limit on the number of bytes that can be allocated for POSIX message queues for the real user ID of the calling process. see the system getrlimit(2) manual for details. ;T;#0;$@Թ;.F;/o;0;1T;2i";3i";%@;&I"Process::RLIMIT_MSGQUEUE;F;xI"INT2FIX(RLIMIT_MSGQUEUE);To;u;[[@ i";F;:RLIMIT_NICE;;w;;;[;{;IC; "zSpecifies a ceiling to which the process's nice value can be raised. see the system getrlimit(2) manual for details. ;T;[;![;"I"{Specifies a ceiling to which the process's nice value can be raised. see the system getrlimit(2) manual for details. ;T;#0;$@;.F;/o;0;1T;2i";3i";%@;&I"Process::RLIMIT_NICE;F;xI"INT2FIX(RLIMIT_NICE);To;u;[[@ i";F;:RLIMIT_NOFILE;;w;;;[;{;IC; "Specifies a value one greater than the maximum file descriptor number that can be opened by this process. see the system getrlimit(2) manual for details. ;T;[;![;"I"Specifies a value one greater than the maximum file descriptor number that can be opened by this process. see the system getrlimit(2) manual for details. ;T;#0;$@;.F;/o;0;1T;2i";3i";%@;&I"Process::RLIMIT_NOFILE;F;xI"INT2FIX(RLIMIT_NOFILE);To;u;[[@ i";F;:RLIMIT_NPROC;;w;;;[;{;IC; "The maximum number of processes that can be created for the real user ID of the calling process. see the system getrlimit(2) manual for details. ;T;[;![;"I"The maximum number of processes that can be created for the real user ID of the calling process. see the system getrlimit(2) manual for details. ;T;#0;$@;.F;/o;0;1T;2i";3i";%@;&I"Process::RLIMIT_NPROC;F;xI"INT2FIX(RLIMIT_NPROC);To;u;[[@ i";F;:RLIMIT_RSS;;w;;;[;{;IC; "sSpecifies the limit (in pages) of the process's resident set. see the system getrlimit(2) manual for details. ;T;[;![;"I"tSpecifies the limit (in pages) of the process's resident set. see the system getrlimit(2) manual for details. ;T;#0;$@;.F;/o;0;1T;2i";3i";%@;&I"Process::RLIMIT_RSS;F;xI"INT2FIX(RLIMIT_RSS);To;u;[[@ i";F;:RLIMIT_RTPRIO;;w;;;[;{;IC; "Specifies a ceiling on the real-time priority that may be set for this process. see the system getrlimit(2) manual for details. ;T;[;![;"I"Specifies a ceiling on the real-time priority that may be set for this process. see the system getrlimit(2) manual for details. ;T;#0;$@;.F;/o;0;1T;2i";3i";%@;&I"Process::RLIMIT_RTPRIO;F;xI"INT2FIX(RLIMIT_RTPRIO);To;u;[[@ i";F;:RLIMIT_RTTIME;;w;;;[;{;IC; "Specifies limit on CPU time this process scheduled under a real-time scheduling policy can consume. see the system getrlimit(2) manual for details. ;T;[;![;"I"Specifies limit on CPU time this process scheduled under a real-time scheduling policy can consume. see the system getrlimit(2) manual for details. ;T;#0;$@;.F;/o;0;1T;2i";3i";%@;&I"Process::RLIMIT_RTTIME;F;xI"INT2FIX(RLIMIT_RTTIME);To;u;[[@ i";F;:RLIMIT_SBSIZE;;w;;;[;{;IC; "'Maximum size of the socket buffer. ;T;[;![;"I"(Maximum size of the socket buffer. ;T;#0;$@(;.F;/o;0;1T;2i";3i";%@;&I"Process::RLIMIT_SBSIZE;F;xI"INT2FIX(RLIMIT_SBSIZE);To;u;[[@ i";F;:RLIMIT_SIGPENDING;;w;;;[;{;IC; "Specifies a limit on the number of signals that may be queued for the real user ID of the calling process. see the system getrlimit(2) manual for details. ;T;[;![;"I"Specifies a limit on the number of signals that may be queued for the real user ID of the calling process. see the system getrlimit(2) manual for details. ;T;#0;$@4;.F;/o;0;1T;2i";3i";%@;&I"Process::RLIMIT_SIGPENDING;F;xI"INT2FIX(RLIMIT_SIGPENDING);To;u;[[@ i";F;:RLIMIT_STACK;;w;;;[;{;IC; "ZMaximum size of the stack, in bytes. see the system getrlimit(2) manual for details. ;T;[;![;"I"[Maximum size of the stack, in bytes. see the system getrlimit(2) manual for details. ;T;#0;$@@;.F;/o;0;1T;2i";3i";%@;&I"Process::RLIMIT_STACK;F;xI"INT2FIX(RLIMIT_STACK);To;4;5F;6;;;;&I"Process#uid;F;7[;[[@ i;T;;,;0;[;{;IC; "JReturns the (real) user ID of this process. Process.uid #=> 501 ;T;[o;= ;>I" overload;F;?0;;,;@0;:I"uid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@L;![;"I"@return [Integer];T;#0;$@L;.F;Bi;C0;7[;$@Lo;= ;>I" overload;F;?0;:Process::UID.rid;@0;:I"Process::UID.rid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@L;![;"I"@return [Integer];T;#0;$@L;.F;Bi;C0;7[;$@Lo;= ;>I" overload;F;?0;:Process::Sys.getuid;@0;:I"Process::Sys.getuid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@L;![;"I"@return [Integer];T;#0;$@L;.F;Bi;C0;7[;$@L;![;"I"Returns the (real) user ID of this process. Process.uid #=> 501 @overload uid @return [Integer] @overload Process::UID.rid @return [Integer] @overload Process::Sys.getuid @return [Integer];T;#0;$@L;.F;C0;%@;9I"cstatic VALUE proc_getuid(VALUE obj) { rb_uid_t uid = getuid(); return UIDT2NUM(uid); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.uid;F;7@N;@O;T;;,;0;@Q;{;IC; "JReturns the (real) user ID of this process. Process.uid #=> 501;T;[o;= ;>I" overload;F;?0;;,;@0;:I"uid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;{;@0;:I"Process::UID.rid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;|;@0;:I"Process::Sys.getuid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the (real) user ID of this process. Process.uid #=> 501 @overload uid @return [Integer] @overload Process::UID.rid @return [Integer] @overload Process::Sys.getuid @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@~;:@;;To;4;5F;6;;;;&I"Process#uid=;F;7[[I"id;T0;[[@ i;T;: uid=;0;[;{;IC; "NSets the (user) user ID for this process. Not available on all platforms. ;T;[o;= ;>I" overload;F;?0;;};@0;:I"uid=(user);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@;![;"I"@return [Numeric];T;#0;$@;.F;Bi;C0;7[[I" user;T0;$@;![;"I"xSets the (user) user ID for this process. Not available on all platforms. @overload uid=(user) @return [Numeric];T;#0;$@;.F;C0;%@;9I"static VALUE proc_setuid(VALUE obj, VALUE id) { rb_uid_t uid; check_uid_switch(); uid = OBJ2UID(id); #if defined(HAVE_SETRESUID) if (setresuid(uid, -1, -1) < 0) rb_sys_fail(0); #elif defined HAVE_SETREUID if (setreuid(uid, -1) < 0) rb_sys_fail(0); #elif defined HAVE_SETRUID if (setruid(uid) < 0) rb_sys_fail(0); #elif defined HAVE_SETUID { if (geteuid() == uid) { if (setuid(uid) < 0) rb_sys_fail(0); } else { rb_notimplement(); } } #endif return id; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.uid=;F;7@;@;T;;};0;@;{;IC; "NSets the (user) user ID for this process. Not available on all platforms.;T;[o;= ;>I" overload;F;?0;;};@0;:I"uid=(user);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@ͺ;![;"I"@return [Numeric];T;#0;$@ͺ;.F;Bi;C0;7[[I" user;T0;$@ͺ;![;"I"ySets the (user) user ID for this process. Not available on all platforms. @overload uid=(user) @return [Numeric];T;#0;$@ͺ;.F;/o;0;1T;2i;3i;Bi;%@;9@˺;:@̺;;To;4;5F;6;;;;&I"Process#gid;F;7[;[[@ i];T;;-;0;[;{;IC; "LReturns the (real) group ID for this process. Process.gid #=> 500 ;T;[o;= ;>I" overload;F;?0;;-;@0;:I"gid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;:Process::GID.rid;@0;:I"Process::GID.rid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;:Process::Sys.getgid;@0;:I"Process::Sys.getgid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the (real) group ID for this process. Process.gid #=> 500 @overload gid @return [Integer] @overload Process::GID.rid @return [Integer] @overload Process::Sys.getgid @return [Integer];T;#0;$@;.F;C0;%@;9I"cstatic VALUE proc_getgid(VALUE obj) { rb_gid_t gid = getgid(); return GIDT2NUM(gid); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.gid;F;7@;@;T;;-;0;@;{;IC; "LReturns the (real) group ID for this process. Process.gid #=> 500;T;[o;= ;>I" overload;F;?0;;-;@0;:I"gid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;~;@0;:I"Process::GID.rid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.getgid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the (real) group ID for this process. Process.gid #=> 500 @overload gid @return [Integer] @overload Process::GID.rid @return [Integer] @overload Process::Sys.getgid @return [Integer];T;#0;$@;.F;/o;0;1T;2iR;3i\;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process#gid=;F;7[[I"id;T0;[[@ im;T;: gid=;0;[;{;IC; "(Sets the group ID for this process. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"gid=(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@G;![;"I"@return [Integer];T;#0;$@G;.F;Bi;C0;7[[I" integer;T0;$@G;![;"I"USets the group ID for this process. @overload gid=(integer) @return [Integer];T;#0;$@G;.F;C0;%@;9I"static VALUE proc_setgid(VALUE obj, VALUE id) { rb_gid_t gid; check_gid_switch(); gid = OBJ2GID(id); #if defined(HAVE_SETRESGID) if (setresgid(gid, -1, -1) < 0) rb_sys_fail(0); #elif defined HAVE_SETREGID if (setregid(gid, -1) < 0) rb_sys_fail(0); #elif defined HAVE_SETRGID if (setrgid(gid) < 0) rb_sys_fail(0); #elif defined HAVE_SETGID { if (getegid() == gid) { if (setgid(gid) < 0) rb_sys_fail(0); } else { rb_notimplement(); } } #endif return GIDT2NUM(gid); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.gid=;F;7@I;@L;T;;;0;@N;{;IC; "(Sets the group ID for this process.;T;[o;= ;>I" overload;F;?0;;;@0;:I"gid=(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@e;![;"I"@return [Integer];T;#0;$@e;.F;Bi;C0;7[[I" integer;T0;$@e;![;"I"VSets the group ID for this process. @overload gid=(integer) @return [Integer];T;#0;$@e;.F;/o;0;1T;2if;3ij;Bi;%@;9@c;:@d;;To;4;5F;6;;;;&I"Process#euid;F;7[;[[@ i;T;: euid;0;[;{;IC; "OReturns the effective user ID for this process. Process.euid #=> 501 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" euid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@|;![;"I"@return [Integer];T;#0;$@|;.F;Bi;C0;7[;$@|o;= ;>I" overload;F;?0;:Process::UID.eid;@0;:I"Process::UID.eid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@|;![;"I"@return [Integer];T;#0;$@|;.F;Bi;C0;7[;$@|o;= ;>I" overload;F;?0;:Process::Sys.geteuid;@0;:I"Process::Sys.geteuid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@|;![;"I"@return [Integer];T;#0;$@|;.F;Bi;C0;7[;$@|;![;"I"Returns the effective user ID for this process. Process.euid #=> 501 @overload euid @return [Integer] @overload Process::UID.eid @return [Integer] @overload Process::Sys.geteuid @return [Integer];T;#0;$@|;.F;C0;%@;9I"gstatic VALUE proc_geteuid(VALUE obj) { rb_uid_t euid = geteuid(); return UIDT2NUM(euid); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.euid;F;7@~;@;T;;;0;@;{;IC; "OReturns the effective user ID for this process. Process.euid #=> 501;T;[o;= ;>I" overload;F;?0;;;@0;:I" euid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"Process::UID.eid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.geteuid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the effective user ID for this process. Process.euid #=> 501 @overload euid @return [Integer] @overload Process::UID.eid @return [Integer] @overload Process::Sys.geteuid @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process#euid=;F;7[[I" euid;T0;[[@ i;T;: euid=;0;[;{;IC; "QSets the effective user ID for this process. Not available on all platforms. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"euid=(user);T;IC; ";T;[;![;"I";T;#0;$@߻;.F;Bi;C0;7[[I" user;T0;$@߻;![;"I"hSets the effective user ID for this process. Not available on all platforms. @overload euid=(user) ;T;#0;$@߻;.F;C0;%@;9I"static VALUE proc_seteuid_m(VALUE mod, VALUE euid) { check_uid_switch(); proc_seteuid(OBJ2UID(euid)); return euid; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.euid=;F;7@;@;T;;;0;@;{;IC; "QSets the effective user ID for this process. Not available on all platforms.;T;[o;= ;>I" overload;F;?0;;;@0;:I"euid=(user);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" user;T0;$@;![;"I"iSets the effective user ID for this process. Not available on all platforms. @overload euid=(user);T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process#egid;F;7[;[[@ i;T;: egid;0;[;{;IC; "pReturns the effective group ID for this process. Not available on all platforms. Process.egid #=> 500 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" egid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;:Process::GID.eid;@0;:I"Process::GID.eid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;:Process::Sys.geteid;@0;:I"Process::Sys.geteid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Returns the effective group ID for this process. Not available on all platforms. Process.egid #=> 500 @overload egid @return [Integer] @overload Process::GID.eid @return [Integer] @overload Process::Sys.geteid @return [Integer];T;#0;$@ ;.F;C0;%@;9I"hstatic VALUE proc_getegid(VALUE obj) { rb_gid_t egid = getegid(); return GIDT2NUM(egid); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.egid;F;7@ ;@ ;T;;;0;@;{;IC; "pReturns the effective group ID for this process. Not available on all platforms. Process.egid #=> 500;T;[o;= ;>I" overload;F;?0;;;@0;:I" egid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@>;![;"I"@return [Integer];T;#0;$@>;.F;Bi;C0;7[;$@>o;= ;>I" overload;F;?0;;;@0;:I"Process::GID.eid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@>;![;"I"@return [Integer];T;#0;$@>;.F;Bi;C0;7[;$@>o;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.geteid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@>;![;"I"@return [Integer];T;#0;$@>;.F;Bi;C0;7[;$@>;![;"I"Returns the effective group ID for this process. Not available on all platforms. Process.egid #=> 500 @overload egid @return [Integer] @overload Process::GID.eid @return [Integer] @overload Process::Sys.geteid @return [Integer];T;#0;$@>;.F;/o;0;1T;2i;3i;Bi;%@;9@<;:@=;;To;4;5F;6;;;;&I"Process#egid=;F;7[;[;F;: egid=;;;[;{;IC; " ;T;[;![;"I";F;#0;$@m;.F;C0;%@;;To;4;5T;6;;;;&I"Process.egid=;F;7@o;@p;F;;;;;@q;{;IC; " ;T;[;![;"@;#0;$@w;Bi;%@;;To;4;5F;6;;;;&I"Process#initgroups;F;7[[I" uname;T0[I" base_grp;T0;[[@ i6;T;:initgroups;0;[;{;IC; "Initializes the supplemental group access list by reading the system group database and using all groups of which the given user is a member. The group with the specified gid is also added to the list. Returns the resulting Array of the gids of all the groups in the supplementary group access list. Not available on all platforms. Process.groups #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27] Process.initgroups( "mgranger", 30 ) #=> [30, 6, 10, 11] Process.groups #=> [30, 6, 10, 11] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"initgroups(username, gid);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@};![;"I"@return [Array];T;#0;$@};.F;Bi;C0;7[[I" username;T0[I"gid;T0;$@};![;"I"1Initializes the supplemental group access list by reading the system group database and using all groups of which the given user is a member. The group with the specified gid is also added to the list. Returns the resulting Array of the gids of all the groups in the supplementary group access list. Not available on all platforms. Process.groups #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27] Process.initgroups( "mgranger", 30 ) #=> [30, 6, 10, 11] Process.groups #=> [30, 6, 10, 11] @overload initgroups(username, gid) @return [Array];T;#0;$@};.F;C0;%@;9I"static VALUE proc_initgroups(VALUE obj, VALUE uname, VALUE base_grp) { if (initgroups(StringValueCStr(uname), OBJ2GID(base_grp)) != 0) { rb_sys_fail(0); } return proc_getgroups(obj); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.initgroups;F;7@;@;T;;;0;@;{;IC; "Initializes the supplemental group access list by reading the system group database and using all groups of which the given user is a member. The group with the specified gid is also added to the list. Returns the resulting Array of the gids of all the groups in the supplementary group access list. Not available on all platforms. Process.groups #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27] Process.initgroups( "mgranger", 30 ) #=> [30, 6, 10, 11] Process.groups #=> [30, 6, 10, 11];T;[o;= ;>I" overload;F;?0;;;@0;:I"initgroups(username, gid);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" username;T0[I"gid;T0;$@;![;"I"3Initializes the supplemental group access list by reading the system group database and using all groups of which the given user is a member. The group with the specified gid is also added to the list. Returns the resulting Array of the gids of all the groups in the supplementary group access list. Not available on all platforms. Process.groups #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27] Process.initgroups( "mgranger", 30 ) #=> [30, 6, 10, 11] Process.groups #=> [30, 6, 10, 11] @overload initgroups(username, gid) @return [Array];T;#0;$@;.F;/o;0;1T;2i%;3i3;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process#groups;F;7[;[[@ i;T;: groups;0;[;{;IC; "Get an Array of the group IDs in the supplemental group access list for this process. Process.groups #=> [27, 6, 10, 11] Note that this method is just a wrapper of getgroups(2). This means that the following characteristics of the result completely depend on your system: - the result is sorted - the result includes effective GIDs - the result does not include duplicated GIDs You can make sure to get a sorted unique GID list of the current process by this expression: Process.groups.uniq.sort ;T;[o;= ;>I" overload;F;?0;;;@0;:I" groups;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I" Get an Array of the group IDs in the supplemental group access list for this process. Process.groups #=> [27, 6, 10, 11] Note that this method is just a wrapper of getgroups(2). This means that the following characteristics of the result completely depend on your system: - the result is sorted - the result includes effective GIDs - the result does not include duplicated GIDs You can make sure to get a sorted unique GID list of the current process by this expression: Process.groups.uniq.sort @overload groups @return [Array];T;#0;$@;.F;C0;%@;9I"static VALUE proc_getgroups(VALUE obj) { VALUE ary, tmp; int i, ngroups; rb_gid_t *groups; ngroups = getgroups(0, NULL); if (ngroups == -1) rb_sys_fail(0); groups = ALLOCV_N(rb_gid_t, tmp, ngroups); ngroups = getgroups(ngroups, groups); if (ngroups == -1) rb_sys_fail(0); ary = rb_ary_new(); for (i = 0; i < ngroups; i++) rb_ary_push(ary, GIDT2NUM(groups[i])); ALLOCV_END(tmp); return ary; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.groups;F;7@;@;T;;;0;@;{;IC; "Get an Array of the group IDs in the supplemental group access list for this process. Process.groups #=> [27, 6, 10, 11] Note that this method is just a wrapper of getgroups(2). This means that the following characteristics of the result completely depend on your system: - the result is sorted - the result includes effective GIDs - the result does not include duplicated GIDs You can make sure to get a sorted unique GID list of the current process by this expression: Process.groups.uniq.sort;T;[o;= ;>I" overload;F;?0;;;@0;:I" groups;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@Ҽ;![;"I"@return [Array];T;#0;$@Ҽ;.F;Bi;C0;7[;$@Ҽ;![;"I""Get an Array of the group IDs in the supplemental group access list for this process. Process.groups #=> [27, 6, 10, 11] Note that this method is just a wrapper of getgroups(2). This means that the following characteristics of the result completely depend on your system: - the result is sorted - the result includes effective GIDs - the result does not include duplicated GIDs You can make sure to get a sorted unique GID list of the current process by this expression: Process.groups.uniq.sort @overload groups @return [Array];T;#0;$@Ҽ;.F;/o;0;1T;2i;3i;Bi;%@;9@м;:@Ѽ;;To;4;5F;6;;;;&I"Process#groups=;F;7[[I"ary;T0;[[@ i;T;: groups=;0;[;{;IC; "Set the supplemental group access list to the given Array of group IDs. Process.groups #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27] Process.groups = [27, 6, 10, 11] #=> [27, 6, 10, 11] Process.groups #=> [27, 6, 10, 11] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"groups=(array);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" array;T0;$@;![;"I"Set the supplemental group access list to the given Array of group IDs. Process.groups #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27] Process.groups = [27, 6, 10, 11] #=> [27, 6, 10, 11] Process.groups #=> [27, 6, 10, 11] @overload groups=(array) @return [Array];T;#0;$@;.F;C0;%@;9I"_static VALUE proc_setgroups(VALUE obj, VALUE ary) { int ngroups, i; rb_gid_t *groups; VALUE tmp; PREPARE_GETGRNAM; Check_Type(ary, T_ARRAY); ngroups = RARRAY_LENINT(ary); if (ngroups > maxgroups()) rb_raise(rb_eArgError, "too many groups, %d max", maxgroups()); groups = ALLOCV_N(rb_gid_t, tmp, ngroups); for (i = 0; i < ngroups; i++) { VALUE g = RARRAY_AREF(ary, i); groups[i] = OBJ2GID1(g); } FINISH_GETGRNAM; if (setgroups(ngroups, groups) == -1) /* ngroups <= maxgroups */ rb_sys_fail(0); ALLOCV_END(tmp); return proc_getgroups(obj); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.groups=;F;7@;@;T;;;0;@;{;IC; "Set the supplemental group access list to the given Array of group IDs. Process.groups #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27] Process.groups = [27, 6, 10, 11] #=> [27, 6, 10, 11] Process.groups #=> [27, 6, 10, 11];T;[o;= ;>I" overload;F;?0;;;@0;:I"groups=(array);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" array;T0;$@;![;"I"Set the supplemental group access list to the given Array of group IDs. Process.groups #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27] Process.groups = [27, 6, 10, 11] #=> [27, 6, 10, 11] Process.groups #=> [27, 6, 10, 11] @overload groups=(array) @return [Array];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process#maxgroups;F;7[;[[@ iM;T;:maxgroups;0;[;{;IC; "uReturns the maximum number of gids allowed in the supplemental group access list. Process.maxgroups #=> 32 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"maxgroups;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the maximum number of gids allowed in the supplemental group access list. Process.maxgroups #=> 32 @overload maxgroups @return [Integer];T;#0;$@;.F;C0;%@;9I"Sstatic VALUE proc_getmaxgroups(VALUE obj) { return INT2FIX(maxgroups()); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.maxgroups;F;7@;@;T;;;0;@!;{;IC; "uReturns the maximum number of gids allowed in the supplemental group access list. Process.maxgroups #=> 32;T;[o;= ;>I" overload;F;?0;;;@0;:I"maxgroups;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@6;![;"I"@return [Integer];T;#0;$@6;.F;Bi;C0;7[;$@6;![;"I"Returns the maximum number of gids allowed in the supplemental group access list. Process.maxgroups #=> 32 @overload maxgroups @return [Integer];T;#0;$@6;.F;/o;0;1T;2iC;3iJ;Bi;%@;9@4;:@5;;To;4;5F;6;;;;&I"Process#maxgroups=;F;7[[I"val;T0;[[@ i_;T;:maxgroups=;0;[;{;IC; "SSets the maximum number of gids allowed in the supplemental group access list. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"maxgroups=(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@K;![;"I"@return [Integer];T;#0;$@K;.F;Bi;C0;7[[I" integer;T0;$@K;![;"I"Sets the maximum number of gids allowed in the supplemental group access list. @overload maxgroups=(integer) @return [Integer];T;#0;$@K;.F;C0;%@;9I"static VALUE proc_setmaxgroups(VALUE obj, VALUE val) { int ngroups = FIX2INT(val); int ngroups_max = get_sc_ngroups_max(); if (ngroups <= 0) rb_raise(rb_eArgError, "maxgroups %d should be positive", ngroups); if (ngroups > RB_MAX_GROUPS) ngroups = RB_MAX_GROUPS; if (ngroups_max > 0 && ngroups > ngroups_max) ngroups = ngroups_max; _maxgroups = ngroups; return INT2FIX(_maxgroups); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.maxgroups=;F;7@M;@P;T;;;0;@R;{;IC; "SSets the maximum number of gids allowed in the supplemental group access list.;T;[o;= ;>I" overload;F;?0;;;@0;:I"maxgroups=(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@i;![;"I"@return [Integer];T;#0;$@i;.F;Bi;C0;7[[I" integer;T0;$@i;![;"I"Sets the maximum number of gids allowed in the supplemental group access list. @overload maxgroups=(integer) @return [Integer];T;#0;$@i;.F;/o;0;1T;2iW;3i\;Bi;%@;9@g;:@h;;To;4;5F;6;;;;&I"Process#daemon;F;7[[@90;[[@ i;T;: daemon;0;[;{;IC; "zDetach the process from controlling terminal and run in the background as system daemon. Unless the argument nochdir is true (i.e. non false), it changes the current working directory to the root ("/"). Unless the argument noclose is true, daemon() will redirect standard input, standard output and standard error to /dev/null. Return zero on success, or raise one of Errno::*. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" daemon();T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@;![;"I"@return [0];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"$daemon(nochdir=nil,noclose=nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@;![;"I"@return [0];T;#0;$@;.F;Bi;C0;7[[I" nochdir;TI"nil;T[I" noclose;TI"nil;T;$@;![;"I"Detach the process from controlling terminal and run in the background as system daemon. Unless the argument nochdir is true (i.e. non false), it changes the current working directory to the root ("/"). Unless the argument noclose is true, daemon() will redirect standard input, standard output and standard error to /dev/null. Return zero on success, or raise one of Errno::*. @overload daemon() @return [0] @overload daemon(nochdir=nil,noclose=nil) @return [0];T;#0;$@;.F;C0;%@;9I"vstatic VALUE proc_daemon(int argc, VALUE *argv, VALUE _) { int n, nochdir = FALSE, noclose = FALSE; switch (rb_check_arity(argc, 0, 2)) { case 2: noclose = TO_BOOL(argv[1], "noclose"); case 1: nochdir = TO_BOOL(argv[0], "nochdir"); } prefork(); n = rb_daemon(nochdir, noclose); if (n < 0) rb_sys_fail("daemon"); return INT2FIX(n); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.daemon;F;7@;@;T;;;0;@;{;IC; "zDetach the process from controlling terminal and run in the background as system daemon. Unless the argument nochdir is true (i.e. non false), it changes the current working directory to the root ("/"). Unless the argument noclose is true, daemon() will redirect standard input, standard output and standard error to /dev/null. Return zero on success, or raise one of Errno::*.;T;[o;= ;>I" overload;F;?0;;;@0;:I" daemon();T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@;![;"I"@return [0];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"$daemon(nochdir=nil,noclose=nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@;![;"I"@return [0];T;#0;$@;.F;Bi;C0;7[[I" nochdir;TI"nil;T[I" noclose;TI"nil;T;$@;![;"I"Detach the process from controlling terminal and run in the background as system daemon. Unless the argument nochdir is true (i.e. non false), it changes the current working directory to the root ("/"). Unless the argument noclose is true, daemon() will redirect standard input, standard output and standard error to /dev/null. Return zero on success, or raise one of Errno::*. @overload daemon() @return [0] @overload daemon(nochdir=nil,noclose=nil) @return [0];T;#0;$@;.F;/o;0;1T;2iy;3i;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process#times;F;7[;[[@ i;T;: times;0;[;{;IC; "Returns a Tms structure (see Process::Tms) that contains user and system CPU times for this process, and also for children processes. t = Process.times [ t.utime, t.stime, t.cutime, t.cstime ] #=> [0.0, 0.02, 0.00, 0.00] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" times;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"aProcessTms;T;$@ֽ;![;"I"@return [aProcessTms];T;#0;$@ֽ;.F;Bi;C0;7[;$@ֽ;![;"I"Returns a Tms structure (see Process::Tms) that contains user and system CPU times for this process, and also for children processes. t = Process.times [ t.utime, t.stime, t.cutime, t.cstime ] #=> [0.0, 0.02, 0.00, 0.00] @overload times @return [aProcessTms];T;#0;$@ֽ;.F;C0;%@;9I"fVALUE rb_proc_times(VALUE obj) { VALUE utime, stime, cutime, cstime, ret; #if defined(RUSAGE_SELF) && defined(RUSAGE_CHILDREN) struct rusage usage_s, usage_c; if (getrusage(RUSAGE_SELF, &usage_s) != 0 || getrusage(RUSAGE_CHILDREN, &usage_c) != 0) rb_sys_fail("getrusage"); utime = DBL2NUM((double)usage_s.ru_utime.tv_sec + (double)usage_s.ru_utime.tv_usec/1e6); stime = DBL2NUM((double)usage_s.ru_stime.tv_sec + (double)usage_s.ru_stime.tv_usec/1e6); cutime = DBL2NUM((double)usage_c.ru_utime.tv_sec + (double)usage_c.ru_utime.tv_usec/1e6); cstime = DBL2NUM((double)usage_c.ru_stime.tv_sec + (double)usage_c.ru_stime.tv_usec/1e6); #else const double hertz = (double)get_clk_tck(); struct tms buf; times(&buf); utime = DBL2NUM(buf.tms_utime / hertz); stime = DBL2NUM(buf.tms_stime / hertz); cutime = DBL2NUM(buf.tms_cutime / hertz); cstime = DBL2NUM(buf.tms_cstime / hertz); #endif ret = rb_struct_new(rb_cProcessTms, utime, stime, cutime, cstime); RB_GC_GUARD(utime); RB_GC_GUARD(stime); RB_GC_GUARD(cutime); RB_GC_GUARD(cstime); return ret; };T;:I" VALUE;T;;To;4;5T;6;;;;&I"Process.times;F;7@ؽ;@ٽ;T;;;0;@۽;{;IC; "Returns a Tms structure (see Process::Tms) that contains user and system CPU times for this process, and also for children processes. t = Process.times [ t.utime, t.stime, t.cutime, t.cstime ] #=> [0.0, 0.02, 0.00, 0.00];T;[o;= ;>I" overload;F;?0;;;@0;:I" times;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"aProcessTms;T;$@;![;"I"@return [aProcessTms];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a Tms structure (see Process::Tms) that contains user and system CPU times for this process, and also for children processes. t = Process.times [ t.utime, t.stime, t.cutime, t.cstime ] #=> [0.0, 0.02, 0.00, 0.00] @overload times @return [aProcessTms];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;To;u;[[@ i"[@ i";F;:CLOCK_REALTIME;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@;.F;/o;0;1T;2i";3i";%@;&I"Process::CLOCK_REALTIME;F;xI"+RUBY_GETTIMEOFDAY_BASED_CLOCK_REALTIME;To;u;[[@ i"[@ i";F;:CLOCK_MONOTONIC;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@;.F;/o;0;1T;2i";3i";%@;&I"Process::CLOCK_MONOTONIC;F;xI"2RUBY_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC;To;u;[[@ i"[@ i#;F;:CLOCK_PROCESS_CPUTIME_ID;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@;.F;/o;0;1T;2i#;3i#;%@;&I"&Process::CLOCK_PROCESS_CPUTIME_ID;F;xI"2RUBY_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID;To;u;[[@ i#;F;:CLOCK_THREAD_CPUTIME_ID;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@,;.F;/o;0;1T;2i#;3i#;%@;&I"%Process::CLOCK_THREAD_CPUTIME_ID;F;xI")CLOCKID2NUM(CLOCK_THREAD_CPUTIME_ID);To;u;[[@ i #;F;:CLOCK_VIRTUAL;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@8;.F;/o;0;1T;2i#;3i#;%@;&I"Process::CLOCK_VIRTUAL;F;xI"CLOCKID2NUM(CLOCK_VIRTUAL);To;u;[[@ i #;F;:CLOCK_PROF;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@D;.F;/o;0;1T;2i #;3i #;%@;&I"Process::CLOCK_PROF;F;xI"CLOCKID2NUM(CLOCK_PROF);To;u;[[@ i#;F;:CLOCK_REALTIME_FAST;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@P;.F;/o;0;1T;2i#;3i#;%@;&I"!Process::CLOCK_REALTIME_FAST;F;xI"%CLOCKID2NUM(CLOCK_REALTIME_FAST);To;u;[[@ i#;F;:CLOCK_REALTIME_PRECISE;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@\;.F;/o;0;1T;2i#;3i#;%@;&I"$Process::CLOCK_REALTIME_PRECISE;F;xI"(CLOCKID2NUM(CLOCK_REALTIME_PRECISE);To;u;[[@ i#;F;:CLOCK_REALTIME_COARSE;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@h;.F;/o;0;1T;2i#;3i#;%@;&I"#Process::CLOCK_REALTIME_COARSE;F;xI"'CLOCKID2NUM(CLOCK_REALTIME_COARSE);To;u;[[@ i#;F;:CLOCK_REALTIME_ALARM;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@t;.F;/o;0;1T;2i#;3i#;%@;&I""Process::CLOCK_REALTIME_ALARM;F;xI"&CLOCKID2NUM(CLOCK_REALTIME_ALARM);To;u;[[@ i!#;F;:CLOCK_MONOTONIC_FAST;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@;.F;/o;0;1T;2i #;3i #;%@;&I""Process::CLOCK_MONOTONIC_FAST;F;xI"&CLOCKID2NUM(CLOCK_MONOTONIC_FAST);To;u;[[@ i%#;F;:CLOCK_MONOTONIC_PRECISE;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@;.F;/o;0;1T;2i$#;3i$#;%@;&I"%Process::CLOCK_MONOTONIC_PRECISE;F;xI")CLOCKID2NUM(CLOCK_MONOTONIC_PRECISE);To;u;[[@ i)#;F;:CLOCK_MONOTONIC_RAW;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@;.F;/o;0;1T;2i(#;3i(#;%@;&I"!Process::CLOCK_MONOTONIC_RAW;F;xI"%CLOCKID2NUM(CLOCK_MONOTONIC_RAW);To;u;[[@ i-#;F;:CLOCK_MONOTONIC_RAW_APPROX;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@;.F;/o;0;1T;2i,#;3i,#;%@;&I"(Process::CLOCK_MONOTONIC_RAW_APPROX;F;xI",CLOCKID2NUM(CLOCK_MONOTONIC_RAW_APPROX);To;u;[[@ i1#;F;:CLOCK_MONOTONIC_COARSE;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@;.F;/o;0;1T;2i0#;3i0#;%@;&I"$Process::CLOCK_MONOTONIC_COARSE;F;xI"(CLOCKID2NUM(CLOCK_MONOTONIC_COARSE);To;u;[[@ i5#;F;:CLOCK_BOOTTIME;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@;.F;/o;0;1T;2i4#;3i4#;%@;&I"Process::CLOCK_BOOTTIME;F;xI" CLOCKID2NUM(CLOCK_BOOTTIME);To;u;[[@ i9#;F;:CLOCK_BOOTTIME_ALARM;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@Ⱦ;.F;/o;0;1T;2i8#;3i8#;%@;&I""Process::CLOCK_BOOTTIME_ALARM;F;xI"&CLOCKID2NUM(CLOCK_BOOTTIME_ALARM);To;u;[[@ i=#;F;:CLOCK_UPTIME;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@Ծ;.F;/o;0;1T;2i<#;3i<#;%@;&I"Process::CLOCK_UPTIME;F;xI"CLOCKID2NUM(CLOCK_UPTIME);To;u;[[@ iA#;F;:CLOCK_UPTIME_FAST;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@;.F;/o;0;1T;2i@#;3i@#;%@;&I"Process::CLOCK_UPTIME_FAST;F;xI"#CLOCKID2NUM(CLOCK_UPTIME_FAST);To;u;[[@ iE#;F;:CLOCK_UPTIME_PRECISE;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@;.F;/o;0;1T;2iD#;3iD#;%@;&I""Process::CLOCK_UPTIME_PRECISE;F;xI"&CLOCKID2NUM(CLOCK_UPTIME_PRECISE);To;u;[[@ iI#;F;:CLOCK_UPTIME_RAW;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@;.F;/o;0;1T;2iH#;3iH#;%@;&I"Process::CLOCK_UPTIME_RAW;F;xI""CLOCKID2NUM(CLOCK_UPTIME_RAW);To;u;[[@ iM#;F;:CLOCK_UPTIME_RAW_APPROX;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@;.F;/o;0;1T;2iL#;3iL#;%@;&I"%Process::CLOCK_UPTIME_RAW_APPROX;F;xI")CLOCKID2NUM(CLOCK_UPTIME_RAW_APPROX);To;u;[[@ iQ#;F;:CLOCK_SECOND;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@;.F;/o;0;1T;2iP#;3iP#;%@;&I"Process::CLOCK_SECOND;F;xI"CLOCKID2NUM(CLOCK_SECOND);To;u;[[@ iU#;F;:CLOCK_TAI;;w;;;[;{;IC; "see Process.clock_gettime ;T;[;![;"I"see Process.clock_gettime;T;#0;$@;.F;/o;0;1T;2iT#;3iT#;%@;&I"Process::CLOCK_TAI;F;xI"CLOCKID2NUM(CLOCK_TAI);To;4;5F;6;;;;&I"Process#clock_gettime;F;7[[@90;[[@ it ;T;:clock_gettime;0;[;{;IC; "Returns a time returned by POSIX clock_gettime() function. p Process.clock_gettime(Process::CLOCK_MONOTONIC) #=> 896053.968060096 +clock_id+ specifies a kind of clock. It is specified as a constant which begins with Process::CLOCK_ such as Process::CLOCK_REALTIME and Process::CLOCK_MONOTONIC. The supported constants depends on OS and version. Ruby provides following types of +clock_id+ if available. [CLOCK_REALTIME] SUSv2 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 2.1, macOS 10.12, Windows-8/Server-2012 [CLOCK_MONOTONIC] SUSv3 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 3.4, macOS 10.12, Windows-2000 [CLOCK_PROCESS_CPUTIME_ID] SUSv3 to 4, Linux 2.5.63, FreeBSD 9.3, OpenBSD 5.4, macOS 10.12 [CLOCK_THREAD_CPUTIME_ID] SUSv3 to 4, Linux 2.5.63, FreeBSD 7.1, OpenBSD 5.4, macOS 10.12 [CLOCK_VIRTUAL] FreeBSD 3.0, OpenBSD 2.1 [CLOCK_PROF] FreeBSD 3.0, OpenBSD 2.1 [CLOCK_REALTIME_FAST] FreeBSD 8.1 [CLOCK_REALTIME_PRECISE] FreeBSD 8.1 [CLOCK_REALTIME_COARSE] Linux 2.6.32 [CLOCK_REALTIME_ALARM] Linux 3.0 [CLOCK_MONOTONIC_FAST] FreeBSD 8.1 [CLOCK_MONOTONIC_PRECISE] FreeBSD 8.1 [CLOCK_MONOTONIC_COARSE] Linux 2.6.32 [CLOCK_MONOTONIC_RAW] Linux 2.6.28, macOS 10.12 [CLOCK_MONOTONIC_RAW_APPROX] macOS 10.12 [CLOCK_BOOTTIME] Linux 2.6.39 [CLOCK_BOOTTIME_ALARM] Linux 3.0 [CLOCK_UPTIME] FreeBSD 7.0, OpenBSD 5.5 [CLOCK_UPTIME_FAST] FreeBSD 8.1 [CLOCK_UPTIME_RAW] macOS 10.12 [CLOCK_UPTIME_RAW_APPROX] macOS 10.12 [CLOCK_UPTIME_PRECISE] FreeBSD 8.1 [CLOCK_SECOND] FreeBSD 8.1 [CLOCK_TAI] Linux 3.10 Note that SUS stands for Single Unix Specification. SUS contains POSIX and clock_gettime is defined in the POSIX part. SUS defines CLOCK_REALTIME mandatory but CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID are optional. Also, several symbols are accepted as +clock_id+. There are emulations for clock_gettime(). For example, Process::CLOCK_REALTIME is defined as +:GETTIMEOFDAY_BASED_CLOCK_REALTIME+ when clock_gettime() is not available. Emulations for +CLOCK_REALTIME+: [:GETTIMEOFDAY_BASED_CLOCK_REALTIME] Use gettimeofday() defined by SUS. (SUSv4 obsoleted it, though.) The resolution is 1 microsecond. [:TIME_BASED_CLOCK_REALTIME] Use time() defined by ISO C. The resolution is 1 second. Emulations for +CLOCK_MONOTONIC+: [:MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC] Use mach_absolute_time(), available on Darwin. The resolution is CPU dependent. [:TIMES_BASED_CLOCK_MONOTONIC] Use the result value of times() defined by POSIX. POSIX defines it as "times() shall return the elapsed real time, in clock ticks, since an arbitrary point in the past (for example, system start-up time)". For example, GNU/Linux returns a value based on jiffies and it is monotonic. However, 4.4BSD uses gettimeofday() and it is not monotonic. (FreeBSD uses clock_gettime(CLOCK_MONOTONIC) instead, though.) The resolution is the clock tick. "getconf CLK_TCK" command shows the clock ticks per second. (The clock ticks per second is defined by HZ macro in older systems.) If it is 100 and clock_t is 32 bits integer type, the resolution is 10 millisecond and cannot represent over 497 days. Emulations for +CLOCK_PROCESS_CPUTIME_ID+: [:GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID] Use getrusage() defined by SUS. getrusage() is used with RUSAGE_SELF to obtain the time only for the calling process (excluding the time for child processes). The result is addition of user time (ru_utime) and system time (ru_stime). The resolution is 1 microsecond. [:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID] Use times() defined by POSIX. The result is addition of user time (tms_utime) and system time (tms_stime). tms_cutime and tms_cstime are ignored to exclude the time for child processes. The resolution is the clock tick. "getconf CLK_TCK" command shows the clock ticks per second. (The clock ticks per second is defined by HZ macro in older systems.) If it is 100, the resolution is 10 millisecond. [:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID] Use clock() defined by ISO C. The resolution is 1/CLOCKS_PER_SEC. CLOCKS_PER_SEC is the C-level macro defined by time.h. SUS defines CLOCKS_PER_SEC is 1000000. Non-Unix systems may define it a different value, though. If CLOCKS_PER_SEC is 1000000 as SUS, the resolution is 1 microsecond. If CLOCKS_PER_SEC is 1000000 and clock_t is 32 bits integer type, it cannot represent over 72 minutes. If the given +clock_id+ is not supported, Errno::EINVAL is raised. +unit+ specifies a type of the return value. [:float_second] number of seconds as a float (default) [:float_millisecond] number of milliseconds as a float [:float_microsecond] number of microseconds as a float [:second] number of seconds as an integer [:millisecond] number of milliseconds as an integer [:microsecond] number of microseconds as an integer [:nanosecond] number of nanoseconds as an integer The underlying function, clock_gettime(), returns a number of nanoseconds. Float object (IEEE 754 double) is not enough to represent the return value for CLOCK_REALTIME. If the exact nanoseconds value is required, use +:nanoseconds+ as the +unit+. The origin (zero) of the returned value varies. For example, system start up time, process start up time, the Epoch, etc. The origin in CLOCK_REALTIME is defined as the Epoch (1970-01-01 00:00:00 UTC). But some systems count leap seconds and others doesn't. So the result can be interpreted differently across systems. Time.now is recommended over CLOCK_REALTIME. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"%clock_gettime(clock_id [, unit]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@(;![;"I"@return [Numeric];T;#0;$@(;.F;Bi;C0;7[[I"clock_id[, unit];T0;$@(;![;"I"Returns a time returned by POSIX clock_gettime() function. p Process.clock_gettime(Process::CLOCK_MONOTONIC) #=> 896053.968060096 +clock_id+ specifies a kind of clock. It is specified as a constant which begins with Process::CLOCK_ such as Process::CLOCK_REALTIME and Process::CLOCK_MONOTONIC. The supported constants depends on OS and version. Ruby provides following types of +clock_id+ if available. [CLOCK_REALTIME] SUSv2 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 2.1, macOS 10.12, Windows-8/Server-2012 [CLOCK_MONOTONIC] SUSv3 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 3.4, macOS 10.12, Windows-2000 [CLOCK_PROCESS_CPUTIME_ID] SUSv3 to 4, Linux 2.5.63, FreeBSD 9.3, OpenBSD 5.4, macOS 10.12 [CLOCK_THREAD_CPUTIME_ID] SUSv3 to 4, Linux 2.5.63, FreeBSD 7.1, OpenBSD 5.4, macOS 10.12 [CLOCK_VIRTUAL] FreeBSD 3.0, OpenBSD 2.1 [CLOCK_PROF] FreeBSD 3.0, OpenBSD 2.1 [CLOCK_REALTIME_FAST] FreeBSD 8.1 [CLOCK_REALTIME_PRECISE] FreeBSD 8.1 [CLOCK_REALTIME_COARSE] Linux 2.6.32 [CLOCK_REALTIME_ALARM] Linux 3.0 [CLOCK_MONOTONIC_FAST] FreeBSD 8.1 [CLOCK_MONOTONIC_PRECISE] FreeBSD 8.1 [CLOCK_MONOTONIC_COARSE] Linux 2.6.32 [CLOCK_MONOTONIC_RAW] Linux 2.6.28, macOS 10.12 [CLOCK_MONOTONIC_RAW_APPROX] macOS 10.12 [CLOCK_BOOTTIME] Linux 2.6.39 [CLOCK_BOOTTIME_ALARM] Linux 3.0 [CLOCK_UPTIME] FreeBSD 7.0, OpenBSD 5.5 [CLOCK_UPTIME_FAST] FreeBSD 8.1 [CLOCK_UPTIME_RAW] macOS 10.12 [CLOCK_UPTIME_RAW_APPROX] macOS 10.12 [CLOCK_UPTIME_PRECISE] FreeBSD 8.1 [CLOCK_SECOND] FreeBSD 8.1 [CLOCK_TAI] Linux 3.10 Note that SUS stands for Single Unix Specification. SUS contains POSIX and clock_gettime is defined in the POSIX part. SUS defines CLOCK_REALTIME mandatory but CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID are optional. Also, several symbols are accepted as +clock_id+. There are emulations for clock_gettime(). For example, Process::CLOCK_REALTIME is defined as +:GETTIMEOFDAY_BASED_CLOCK_REALTIME+ when clock_gettime() is not available. Emulations for +CLOCK_REALTIME+: [:GETTIMEOFDAY_BASED_CLOCK_REALTIME] Use gettimeofday() defined by SUS. (SUSv4 obsoleted it, though.) The resolution is 1 microsecond. [:TIME_BASED_CLOCK_REALTIME] Use time() defined by ISO C. The resolution is 1 second. Emulations for +CLOCK_MONOTONIC+: [:MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC] Use mach_absolute_time(), available on Darwin. The resolution is CPU dependent. [:TIMES_BASED_CLOCK_MONOTONIC] Use the result value of times() defined by POSIX. POSIX defines it as "times() shall return the elapsed real time, in clock ticks, since an arbitrary point in the past (for example, system start-up time)". For example, GNU/Linux returns a value based on jiffies and it is monotonic. However, 4.4BSD uses gettimeofday() and it is not monotonic. (FreeBSD uses clock_gettime(CLOCK_MONOTONIC) instead, though.) The resolution is the clock tick. "getconf CLK_TCK" command shows the clock ticks per second. (The clock ticks per second is defined by HZ macro in older systems.) If it is 100 and clock_t is 32 bits integer type, the resolution is 10 millisecond and cannot represent over 497 days. Emulations for +CLOCK_PROCESS_CPUTIME_ID+: [:GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID] Use getrusage() defined by SUS. getrusage() is used with RUSAGE_SELF to obtain the time only for the calling process (excluding the time for child processes). The result is addition of user time (ru_utime) and system time (ru_stime). The resolution is 1 microsecond. [:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID] Use times() defined by POSIX. The result is addition of user time (tms_utime) and system time (tms_stime). tms_cutime and tms_cstime are ignored to exclude the time for child processes. The resolution is the clock tick. "getconf CLK_TCK" command shows the clock ticks per second. (The clock ticks per second is defined by HZ macro in older systems.) If it is 100, the resolution is 10 millisecond. [:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID] Use clock() defined by ISO C. The resolution is 1/CLOCKS_PER_SEC. CLOCKS_PER_SEC is the C-level macro defined by time.h. SUS defines CLOCKS_PER_SEC is 1000000. Non-Unix systems may define it a different value, though. If CLOCKS_PER_SEC is 1000000 as SUS, the resolution is 1 microsecond. If CLOCKS_PER_SEC is 1000000 and clock_t is 32 bits integer type, it cannot represent over 72 minutes. If the given +clock_id+ is not supported, Errno::EINVAL is raised. +unit+ specifies a type of the return value. [:float_second] number of seconds as a float (default) [:float_millisecond] number of milliseconds as a float [:float_microsecond] number of microseconds as a float [:second] number of seconds as an integer [:millisecond] number of milliseconds as an integer [:microsecond] number of microseconds as an integer [:nanosecond] number of nanoseconds as an integer The underlying function, clock_gettime(), returns a number of nanoseconds. Float object (IEEE 754 double) is not enough to represent the return value for CLOCK_REALTIME. If the exact nanoseconds value is required, use +:nanoseconds+ as the +unit+. The origin (zero) of the returned value varies. For example, system start up time, process start up time, the Epoch, etc. The origin in CLOCK_REALTIME is defined as the Epoch (1970-01-01 00:00:00 UTC). But some systems count leap seconds and others doesn't. So the result can be interpreted differently across systems. Time.now is recommended over CLOCK_REALTIME. @overload clock_gettime(clock_id [, unit]) @return [Numeric];T;#0;$@(;.F;C0;%@;9I"static VALUE rb_clock_gettime(int argc, VALUE *argv, VALUE _) { int ret; struct timetick tt; timetick_int_t numerators[2]; timetick_int_t denominators[2]; int num_numerators = 0; int num_denominators = 0; VALUE unit = (rb_check_arity(argc, 1, 2) == 2) ? argv[1] : Qnil; VALUE clk_id = argv[0]; if (SYMBOL_P(clk_id)) { /* * Non-clock_gettime clocks are provided by symbol clk_id. */ #ifdef HAVE_GETTIMEOFDAY /* * GETTIMEOFDAY_BASED_CLOCK_REALTIME is used for * CLOCK_REALTIME if clock_gettime is not available. */ #define RUBY_GETTIMEOFDAY_BASED_CLOCK_REALTIME ID2SYM(id_GETTIMEOFDAY_BASED_CLOCK_REALTIME) if (clk_id == RUBY_GETTIMEOFDAY_BASED_CLOCK_REALTIME) { struct timeval tv; ret = gettimeofday(&tv, 0); if (ret != 0) rb_sys_fail("gettimeofday"); tt.giga_count = tv.tv_sec; tt.count = (int32_t)tv.tv_usec * 1000; denominators[num_denominators++] = 1000000000; goto success; } #endif #define RUBY_TIME_BASED_CLOCK_REALTIME ID2SYM(id_TIME_BASED_CLOCK_REALTIME) if (clk_id == RUBY_TIME_BASED_CLOCK_REALTIME) { time_t t; t = time(NULL); if (t == (time_t)-1) rb_sys_fail("time"); tt.giga_count = t; tt.count = 0; denominators[num_denominators++] = 1000000000; goto success; } #ifdef HAVE_TIMES #define RUBY_TIMES_BASED_CLOCK_MONOTONIC \ ID2SYM(id_TIMES_BASED_CLOCK_MONOTONIC) if (clk_id == RUBY_TIMES_BASED_CLOCK_MONOTONIC) { struct tms buf; clock_t c; unsigned_clock_t uc; c = times(&buf); if (c == (clock_t)-1) rb_sys_fail("times"); uc = (unsigned_clock_t)c; tt.count = (int32_t)(uc % 1000000000); tt.giga_count = (uc / 1000000000); denominators[num_denominators++] = get_clk_tck(); goto success; } #endif #ifdef RUSAGE_SELF #define RUBY_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID \ ID2SYM(id_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID) if (clk_id == RUBY_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID) { struct rusage usage; int32_t usec; ret = getrusage(RUSAGE_SELF, &usage); if (ret != 0) rb_sys_fail("getrusage"); tt.giga_count = usage.ru_utime.tv_sec + usage.ru_stime.tv_sec; usec = (int32_t)(usage.ru_utime.tv_usec + usage.ru_stime.tv_usec); if (1000000 <= usec) { tt.giga_count++; usec -= 1000000; } tt.count = usec * 1000; denominators[num_denominators++] = 1000000000; goto success; } #endif #ifdef HAVE_TIMES #define RUBY_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID \ ID2SYM(id_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID) if (clk_id == RUBY_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID) { struct tms buf; unsigned_clock_t utime, stime; if (times(&buf) == (clock_t)-1) rb_sys_fail("times"); utime = (unsigned_clock_t)buf.tms_utime; stime = (unsigned_clock_t)buf.tms_stime; tt.count = (int32_t)((utime % 1000000000) + (stime % 1000000000)); tt.giga_count = (utime / 1000000000) + (stime / 1000000000); if (1000000000 <= tt.count) { tt.count -= 1000000000; tt.giga_count++; } denominators[num_denominators++] = get_clk_tck(); goto success; } #endif #define RUBY_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID \ ID2SYM(id_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID) if (clk_id == RUBY_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID) { clock_t c; unsigned_clock_t uc; errno = 0; c = clock(); if (c == (clock_t)-1) rb_sys_fail("clock"); uc = (unsigned_clock_t)c; tt.count = (int32_t)(uc % 1000000000); tt.giga_count = uc / 1000000000; denominators[num_denominators++] = CLOCKS_PER_SEC; goto success; } #ifdef __APPLE__ #define RUBY_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC ID2SYM(id_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC) if (clk_id == RUBY_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC) { const mach_timebase_info_data_t *info = get_mach_timebase_info(); uint64_t t = mach_absolute_time(); tt.count = (int32_t)(t % 1000000000); tt.giga_count = t / 1000000000; numerators[num_numerators++] = info->numer; denominators[num_denominators++] = info->denom; denominators[num_denominators++] = 1000000000; goto success; } #endif } else { #if defined(HAVE_CLOCK_GETTIME) struct timespec ts; clockid_t c; c = NUM2CLOCKID(clk_id); ret = clock_gettime(c, &ts); if (ret == -1) rb_sys_fail("clock_gettime"); tt.count = (int32_t)ts.tv_nsec; tt.giga_count = ts.tv_sec; denominators[num_denominators++] = 1000000000; goto success; #endif } /* EINVAL emulates clock_gettime behavior when clock_id is invalid. */ rb_syserr_fail(EINVAL, 0); success: return make_clock_result(&tt, numerators, num_numerators, denominators, num_denominators, unit); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.clock_gettime;F;7@*;@,;T;;;0;@.;{;IC; "Returns a time returned by POSIX clock_gettime() function. p Process.clock_gettime(Process::CLOCK_MONOTONIC) #=> 896053.968060096 +clock_id+ specifies a kind of clock. It is specified as a constant which begins with Process::CLOCK_ such as Process::CLOCK_REALTIME and Process::CLOCK_MONOTONIC. The supported constants depends on OS and version. Ruby provides following types of +clock_id+ if available. [CLOCK_REALTIME] SUSv2 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 2.1, macOS 10.12, Windows-8/Server-2012 [CLOCK_MONOTONIC] SUSv3 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 3.4, macOS 10.12, Windows-2000 [CLOCK_PROCESS_CPUTIME_ID] SUSv3 to 4, Linux 2.5.63, FreeBSD 9.3, OpenBSD 5.4, macOS 10.12 [CLOCK_THREAD_CPUTIME_ID] SUSv3 to 4, Linux 2.5.63, FreeBSD 7.1, OpenBSD 5.4, macOS 10.12 [CLOCK_VIRTUAL] FreeBSD 3.0, OpenBSD 2.1 [CLOCK_PROF] FreeBSD 3.0, OpenBSD 2.1 [CLOCK_REALTIME_FAST] FreeBSD 8.1 [CLOCK_REALTIME_PRECISE] FreeBSD 8.1 [CLOCK_REALTIME_COARSE] Linux 2.6.32 [CLOCK_REALTIME_ALARM] Linux 3.0 [CLOCK_MONOTONIC_FAST] FreeBSD 8.1 [CLOCK_MONOTONIC_PRECISE] FreeBSD 8.1 [CLOCK_MONOTONIC_COARSE] Linux 2.6.32 [CLOCK_MONOTONIC_RAW] Linux 2.6.28, macOS 10.12 [CLOCK_MONOTONIC_RAW_APPROX] macOS 10.12 [CLOCK_BOOTTIME] Linux 2.6.39 [CLOCK_BOOTTIME_ALARM] Linux 3.0 [CLOCK_UPTIME] FreeBSD 7.0, OpenBSD 5.5 [CLOCK_UPTIME_FAST] FreeBSD 8.1 [CLOCK_UPTIME_RAW] macOS 10.12 [CLOCK_UPTIME_RAW_APPROX] macOS 10.12 [CLOCK_UPTIME_PRECISE] FreeBSD 8.1 [CLOCK_SECOND] FreeBSD 8.1 [CLOCK_TAI] Linux 3.10 Note that SUS stands for Single Unix Specification. SUS contains POSIX and clock_gettime is defined in the POSIX part. SUS defines CLOCK_REALTIME mandatory but CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID are optional. Also, several symbols are accepted as +clock_id+. There are emulations for clock_gettime(). For example, Process::CLOCK_REALTIME is defined as +:GETTIMEOFDAY_BASED_CLOCK_REALTIME+ when clock_gettime() is not available. Emulations for +CLOCK_REALTIME+: [:GETTIMEOFDAY_BASED_CLOCK_REALTIME] Use gettimeofday() defined by SUS. (SUSv4 obsoleted it, though.) The resolution is 1 microsecond. [:TIME_BASED_CLOCK_REALTIME] Use time() defined by ISO C. The resolution is 1 second. Emulations for +CLOCK_MONOTONIC+: [:MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC] Use mach_absolute_time(), available on Darwin. The resolution is CPU dependent. [:TIMES_BASED_CLOCK_MONOTONIC] Use the result value of times() defined by POSIX. POSIX defines it as "times() shall return the elapsed real time, in clock ticks, since an arbitrary point in the past (for example, system start-up time)". For example, GNU/Linux returns a value based on jiffies and it is monotonic. However, 4.4BSD uses gettimeofday() and it is not monotonic. (FreeBSD uses clock_gettime(CLOCK_MONOTONIC) instead, though.) The resolution is the clock tick. "getconf CLK_TCK" command shows the clock ticks per second. (The clock ticks per second is defined by HZ macro in older systems.) If it is 100 and clock_t is 32 bits integer type, the resolution is 10 millisecond and cannot represent over 497 days. Emulations for +CLOCK_PROCESS_CPUTIME_ID+: [:GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID] Use getrusage() defined by SUS. getrusage() is used with RUSAGE_SELF to obtain the time only for the calling process (excluding the time for child processes). The result is addition of user time (ru_utime) and system time (ru_stime). The resolution is 1 microsecond. [:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID] Use times() defined by POSIX. The result is addition of user time (tms_utime) and system time (tms_stime). tms_cutime and tms_cstime are ignored to exclude the time for child processes. The resolution is the clock tick. "getconf CLK_TCK" command shows the clock ticks per second. (The clock ticks per second is defined by HZ macro in older systems.) If it is 100, the resolution is 10 millisecond. [:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID] Use clock() defined by ISO C. The resolution is 1/CLOCKS_PER_SEC. CLOCKS_PER_SEC is the C-level macro defined by time.h. SUS defines CLOCKS_PER_SEC is 1000000. Non-Unix systems may define it a different value, though. If CLOCKS_PER_SEC is 1000000 as SUS, the resolution is 1 microsecond. If CLOCKS_PER_SEC is 1000000 and clock_t is 32 bits integer type, it cannot represent over 72 minutes. If the given +clock_id+ is not supported, Errno::EINVAL is raised. +unit+ specifies a type of the return value. [:float_second] number of seconds as a float (default) [:float_millisecond] number of milliseconds as a float [:float_microsecond] number of microseconds as a float [:second] number of seconds as an integer [:millisecond] number of milliseconds as an integer [:microsecond] number of microseconds as an integer [:nanosecond] number of nanoseconds as an integer The underlying function, clock_gettime(), returns a number of nanoseconds. Float object (IEEE 754 double) is not enough to represent the return value for CLOCK_REALTIME. If the exact nanoseconds value is required, use +:nanoseconds+ as the +unit+. The origin (zero) of the returned value varies. For example, system start up time, process start up time, the Epoch, etc. The origin in CLOCK_REALTIME is defined as the Epoch (1970-01-01 00:00:00 UTC). But some systems count leap seconds and others doesn't. So the result can be interpreted differently across systems. Time.now is recommended over CLOCK_REALTIME.;T;[o;= ;>I" overload;F;?0;;;@0;:I"%clock_gettime(clock_id [, unit]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@E;![;"I"@return [Numeric];T;#0;$@E;.F;Bi;C0;7[[I"clock_id[, unit];T0;$@E;![;"I"Returns a time returned by POSIX clock_gettime() function. p Process.clock_gettime(Process::CLOCK_MONOTONIC) #=> 896053.968060096 +clock_id+ specifies a kind of clock. It is specified as a constant which begins with Process::CLOCK_ such as Process::CLOCK_REALTIME and Process::CLOCK_MONOTONIC. The supported constants depends on OS and version. Ruby provides following types of +clock_id+ if available. [CLOCK_REALTIME] SUSv2 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 2.1, macOS 10.12, Windows-8/Server-2012 [CLOCK_MONOTONIC] SUSv3 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 3.4, macOS 10.12, Windows-2000 [CLOCK_PROCESS_CPUTIME_ID] SUSv3 to 4, Linux 2.5.63, FreeBSD 9.3, OpenBSD 5.4, macOS 10.12 [CLOCK_THREAD_CPUTIME_ID] SUSv3 to 4, Linux 2.5.63, FreeBSD 7.1, OpenBSD 5.4, macOS 10.12 [CLOCK_VIRTUAL] FreeBSD 3.0, OpenBSD 2.1 [CLOCK_PROF] FreeBSD 3.0, OpenBSD 2.1 [CLOCK_REALTIME_FAST] FreeBSD 8.1 [CLOCK_REALTIME_PRECISE] FreeBSD 8.1 [CLOCK_REALTIME_COARSE] Linux 2.6.32 [CLOCK_REALTIME_ALARM] Linux 3.0 [CLOCK_MONOTONIC_FAST] FreeBSD 8.1 [CLOCK_MONOTONIC_PRECISE] FreeBSD 8.1 [CLOCK_MONOTONIC_COARSE] Linux 2.6.32 [CLOCK_MONOTONIC_RAW] Linux 2.6.28, macOS 10.12 [CLOCK_MONOTONIC_RAW_APPROX] macOS 10.12 [CLOCK_BOOTTIME] Linux 2.6.39 [CLOCK_BOOTTIME_ALARM] Linux 3.0 [CLOCK_UPTIME] FreeBSD 7.0, OpenBSD 5.5 [CLOCK_UPTIME_FAST] FreeBSD 8.1 [CLOCK_UPTIME_RAW] macOS 10.12 [CLOCK_UPTIME_RAW_APPROX] macOS 10.12 [CLOCK_UPTIME_PRECISE] FreeBSD 8.1 [CLOCK_SECOND] FreeBSD 8.1 [CLOCK_TAI] Linux 3.10 Note that SUS stands for Single Unix Specification. SUS contains POSIX and clock_gettime is defined in the POSIX part. SUS defines CLOCK_REALTIME mandatory but CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID are optional. Also, several symbols are accepted as +clock_id+. There are emulations for clock_gettime(). For example, Process::CLOCK_REALTIME is defined as +:GETTIMEOFDAY_BASED_CLOCK_REALTIME+ when clock_gettime() is not available. Emulations for +CLOCK_REALTIME+: [:GETTIMEOFDAY_BASED_CLOCK_REALTIME] Use gettimeofday() defined by SUS. (SUSv4 obsoleted it, though.) The resolution is 1 microsecond. [:TIME_BASED_CLOCK_REALTIME] Use time() defined by ISO C. The resolution is 1 second. Emulations for +CLOCK_MONOTONIC+: [:MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC] Use mach_absolute_time(), available on Darwin. The resolution is CPU dependent. [:TIMES_BASED_CLOCK_MONOTONIC] Use the result value of times() defined by POSIX. POSIX defines it as "times() shall return the elapsed real time, in clock ticks, since an arbitrary point in the past (for example, system start-up time)". For example, GNU/Linux returns a value based on jiffies and it is monotonic. However, 4.4BSD uses gettimeofday() and it is not monotonic. (FreeBSD uses clock_gettime(CLOCK_MONOTONIC) instead, though.) The resolution is the clock tick. "getconf CLK_TCK" command shows the clock ticks per second. (The clock ticks per second is defined by HZ macro in older systems.) If it is 100 and clock_t is 32 bits integer type, the resolution is 10 millisecond and cannot represent over 497 days. Emulations for +CLOCK_PROCESS_CPUTIME_ID+: [:GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID] Use getrusage() defined by SUS. getrusage() is used with RUSAGE_SELF to obtain the time only for the calling process (excluding the time for child processes). The result is addition of user time (ru_utime) and system time (ru_stime). The resolution is 1 microsecond. [:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID] Use times() defined by POSIX. The result is addition of user time (tms_utime) and system time (tms_stime). tms_cutime and tms_cstime are ignored to exclude the time for child processes. The resolution is the clock tick. "getconf CLK_TCK" command shows the clock ticks per second. (The clock ticks per second is defined by HZ macro in older systems.) If it is 100, the resolution is 10 millisecond. [:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID] Use clock() defined by ISO C. The resolution is 1/CLOCKS_PER_SEC. CLOCKS_PER_SEC is the C-level macro defined by time.h. SUS defines CLOCKS_PER_SEC is 1000000. Non-Unix systems may define it a different value, though. If CLOCKS_PER_SEC is 1000000 as SUS, the resolution is 1 microsecond. If CLOCKS_PER_SEC is 1000000 and clock_t is 32 bits integer type, it cannot represent over 72 minutes. If the given +clock_id+ is not supported, Errno::EINVAL is raised. +unit+ specifies a type of the return value. [:float_second] number of seconds as a float (default) [:float_millisecond] number of milliseconds as a float [:float_microsecond] number of microseconds as a float [:second] number of seconds as an integer [:millisecond] number of milliseconds as an integer [:microsecond] number of microseconds as an integer [:nanosecond] number of nanoseconds as an integer The underlying function, clock_gettime(), returns a number of nanoseconds. Float object (IEEE 754 double) is not enough to represent the return value for CLOCK_REALTIME. If the exact nanoseconds value is required, use +:nanoseconds+ as the +unit+. The origin (zero) of the returned value varies. For example, system start up time, process start up time, the Epoch, etc. The origin in CLOCK_REALTIME is defined as the Epoch (1970-01-01 00:00:00 UTC). But some systems count leap seconds and others doesn't. So the result can be interpreted differently across systems. Time.now is recommended over CLOCK_REALTIME. @overload clock_gettime(clock_id [, unit]) @return [Numeric];T;#0;$@E;.F;/o;0;1T;2i;3ir ;Bi;%@;9@C;:@D;;To;4;5F;6;;;;&I"Process#clock_getres;F;7[[@90;[[@ i=!;T;:clock_getres;0;[;{;IC; "Returns an estimate of the resolution of a +clock_id+ using the POSIX clock_getres() function. Note the reported resolution is often inaccurate on most platforms due to underlying bugs for this function and therefore the reported resolution often differs from the actual resolution of the clock in practice. Inaccurate reported resolutions have been observed for various clocks including CLOCK_MONOTONIC and CLOCK_MONOTONIC_RAW when using Linux, macOS, BSD or AIX platforms, when using ARM processors, or when using virtualization. +clock_id+ specifies a kind of clock. See the document of +Process.clock_gettime+ for details. +clock_id+ can be a symbol as for +Process.clock_gettime+. If the given +clock_id+ is not supported, Errno::EINVAL is raised. +unit+ specifies the type of the return value. +Process.clock_getres+ accepts +unit+ as +Process.clock_gettime+. The default value, +:float_second+, is also the same as +Process.clock_gettime+. +Process.clock_getres+ also accepts +:hertz+ as +unit+. +:hertz+ means the reciprocal of +:float_second+. +:hertz+ can be used to obtain the exact value of the clock ticks per second for the times() function and CLOCKS_PER_SEC for the clock() function. Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz) returns the clock ticks per second. Process.clock_getres(:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz) returns CLOCKS_PER_SEC. p Process.clock_getres(Process::CLOCK_MONOTONIC) #=> 1.0e-09 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"$clock_getres(clock_id [, unit]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@\;![;"I"@return [Numeric];T;#0;$@\;.F;Bi;C0;7[[I"clock_id[, unit];T0;$@\;![;"I"#Returns an estimate of the resolution of a +clock_id+ using the POSIX clock_getres() function. Note the reported resolution is often inaccurate on most platforms due to underlying bugs for this function and therefore the reported resolution often differs from the actual resolution of the clock in practice. Inaccurate reported resolutions have been observed for various clocks including CLOCK_MONOTONIC and CLOCK_MONOTONIC_RAW when using Linux, macOS, BSD or AIX platforms, when using ARM processors, or when using virtualization. +clock_id+ specifies a kind of clock. See the document of +Process.clock_gettime+ for details. +clock_id+ can be a symbol as for +Process.clock_gettime+. If the given +clock_id+ is not supported, Errno::EINVAL is raised. +unit+ specifies the type of the return value. +Process.clock_getres+ accepts +unit+ as +Process.clock_gettime+. The default value, +:float_second+, is also the same as +Process.clock_gettime+. +Process.clock_getres+ also accepts +:hertz+ as +unit+. +:hertz+ means the reciprocal of +:float_second+. +:hertz+ can be used to obtain the exact value of the clock ticks per second for the times() function and CLOCKS_PER_SEC for the clock() function. Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz) returns the clock ticks per second. Process.clock_getres(:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz) returns CLOCKS_PER_SEC. p Process.clock_getres(Process::CLOCK_MONOTONIC) #=> 1.0e-09 @overload clock_getres(clock_id [, unit]) @return [Numeric];T;#0;$@\;.F;C0;%@;9I" static VALUE rb_clock_getres(int argc, VALUE *argv, VALUE _) { struct timetick tt; timetick_int_t numerators[2]; timetick_int_t denominators[2]; int num_numerators = 0; int num_denominators = 0; VALUE unit = (rb_check_arity(argc, 1, 2) == 2) ? argv[1] : Qnil; VALUE clk_id = argv[0]; if (SYMBOL_P(clk_id)) { #ifdef RUBY_GETTIMEOFDAY_BASED_CLOCK_REALTIME if (clk_id == RUBY_GETTIMEOFDAY_BASED_CLOCK_REALTIME) { tt.giga_count = 0; tt.count = 1000; denominators[num_denominators++] = 1000000000; goto success; } #endif #ifdef RUBY_TIME_BASED_CLOCK_REALTIME if (clk_id == RUBY_TIME_BASED_CLOCK_REALTIME) { tt.giga_count = 1; tt.count = 0; denominators[num_denominators++] = 1000000000; goto success; } #endif #ifdef RUBY_TIMES_BASED_CLOCK_MONOTONIC if (clk_id == RUBY_TIMES_BASED_CLOCK_MONOTONIC) { tt.count = 1; tt.giga_count = 0; denominators[num_denominators++] = get_clk_tck(); goto success; } #endif #ifdef RUBY_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID if (clk_id == RUBY_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID) { tt.giga_count = 0; tt.count = 1000; denominators[num_denominators++] = 1000000000; goto success; } #endif #ifdef RUBY_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID if (clk_id == RUBY_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID) { tt.count = 1; tt.giga_count = 0; denominators[num_denominators++] = get_clk_tck(); goto success; } #endif #ifdef RUBY_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID if (clk_id == RUBY_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID) { tt.count = 1; tt.giga_count = 0; denominators[num_denominators++] = CLOCKS_PER_SEC; goto success; } #endif #ifdef RUBY_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC if (clk_id == RUBY_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC) { const mach_timebase_info_data_t *info = get_mach_timebase_info(); tt.count = 1; tt.giga_count = 0; numerators[num_numerators++] = info->numer; denominators[num_denominators++] = info->denom; denominators[num_denominators++] = 1000000000; goto success; } #endif } else { #if defined(HAVE_CLOCK_GETRES) struct timespec ts; clockid_t c = NUM2CLOCKID(clk_id); int ret = clock_getres(c, &ts); if (ret == -1) rb_sys_fail("clock_getres"); tt.count = (int32_t)ts.tv_nsec; tt.giga_count = ts.tv_sec; denominators[num_denominators++] = 1000000000; goto success; #endif } /* EINVAL emulates clock_getres behavior when clock_id is invalid. */ rb_syserr_fail(EINVAL, 0); success: if (unit == ID2SYM(id_hertz)) { return timetick2dblnum_reciprocal(&tt, numerators, num_numerators, denominators, num_denominators); } else { return make_clock_result(&tt, numerators, num_numerators, denominators, num_denominators, unit); } };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.clock_getres;F;7@^;@`;T;;;0;@b;{;IC; "Returns an estimate of the resolution of a +clock_id+ using the POSIX clock_getres() function. Note the reported resolution is often inaccurate on most platforms due to underlying bugs for this function and therefore the reported resolution often differs from the actual resolution of the clock in practice. Inaccurate reported resolutions have been observed for various clocks including CLOCK_MONOTONIC and CLOCK_MONOTONIC_RAW when using Linux, macOS, BSD or AIX platforms, when using ARM processors, or when using virtualization. +clock_id+ specifies a kind of clock. See the document of +Process.clock_gettime+ for details. +clock_id+ can be a symbol as for +Process.clock_gettime+. If the given +clock_id+ is not supported, Errno::EINVAL is raised. +unit+ specifies the type of the return value. +Process.clock_getres+ accepts +unit+ as +Process.clock_gettime+. The default value, +:float_second+, is also the same as +Process.clock_gettime+. +Process.clock_getres+ also accepts +:hertz+ as +unit+. +:hertz+ means the reciprocal of +:float_second+. +:hertz+ can be used to obtain the exact value of the clock ticks per second for the times() function and CLOCKS_PER_SEC for the clock() function. Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz) returns the clock ticks per second. Process.clock_getres(:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz) returns CLOCKS_PER_SEC. p Process.clock_getres(Process::CLOCK_MONOTONIC) #=> 1.0e-09;T;[o;= ;>I" overload;F;?0;;;@0;:I"$clock_getres(clock_id [, unit]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@y;![;"I"@return [Numeric];T;#0;$@y;.F;Bi;C0;7[[I"clock_id[, unit];T0;$@y;![;"I"%Returns an estimate of the resolution of a +clock_id+ using the POSIX clock_getres() function. Note the reported resolution is often inaccurate on most platforms due to underlying bugs for this function and therefore the reported resolution often differs from the actual resolution of the clock in practice. Inaccurate reported resolutions have been observed for various clocks including CLOCK_MONOTONIC and CLOCK_MONOTONIC_RAW when using Linux, macOS, BSD or AIX platforms, when using ARM processors, or when using virtualization. +clock_id+ specifies a kind of clock. See the document of +Process.clock_gettime+ for details. +clock_id+ can be a symbol as for +Process.clock_gettime+. If the given +clock_id+ is not supported, Errno::EINVAL is raised. +unit+ specifies the type of the return value. +Process.clock_getres+ accepts +unit+ as +Process.clock_gettime+. The default value, +:float_second+, is also the same as +Process.clock_gettime+. +Process.clock_getres+ also accepts +:hertz+ as +unit+. +:hertz+ means the reciprocal of +:float_second+. +:hertz+ can be used to obtain the exact value of the clock ticks per second for the times() function and CLOCKS_PER_SEC for the clock() function. Process.clock_getres(:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz) returns the clock ticks per second. Process.clock_getres(:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz) returns CLOCKS_PER_SEC. p Process.clock_getres(Process::CLOCK_MONOTONIC) #=> 1.0e-09 @overload clock_getres(clock_id [, unit]) @return [Numeric];T;#0;$@y;.F;/o;0;1T;2i!;3i;!;Bi;%@;9@w;:@x;;To;;IC;[o;4;5F;6;;;;&I"Process::UID#rid;F;7[;[[@ i;T;:rid;0;[;{;IC; "JReturns the (real) user ID of this process. Process.uid #=> 501 ;T;[o;= ;>I" overload;F;?0;;,;@0;:I"uid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;{;@0;:I"Process::UID.rid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;|;@0;:I"Process::Sys.getuid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the (real) user ID of this process. Process.uid #=> 501 @overload uid @return [Integer] @overload Process::UID.rid @return [Integer] @overload Process::Sys.getuid @return [Integer];T;#0;$@;.F;C0;%@;9I"cstatic VALUE proc_getuid(VALUE obj) { rb_uid_t uid = getuid(); return UIDT2NUM(uid); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::UID.rid;F;7@;@;T;;;0;@;{;IC; "JReturns the (real) user ID of this process. Process.uid #=> 501;T;[o;= ;>I" overload;F;?0;;,;@0;:I"uid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ƿ;![;"I"@return [Integer];T;#0;$@ƿ;.F;Bi;C0;7[;$@ƿo;= ;>I" overload;F;?0;;{;@0;:I"Process::UID.rid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ƿ;![;"I"@return [Integer];T;#0;$@ƿ;.F;Bi;C0;7[;$@ƿo;= ;>I" overload;F;?0;;|;@0;:I"Process::Sys.getuid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ƿ;![;"I"@return [Integer];T;#0;$@ƿ;.F;Bi;C0;7[;$@ƿ;![;"@;#0;$@ƿ;.F;/o;0;1T;2i;3i;Bi;%@;9@Ŀ;:@ſ;;To;4;5F;6;;;;&I"Process::UID#eid;F;7[;[[@ i;T;:eid;0;[;{;IC; "OReturns the effective user ID for this process. Process.euid #=> 501 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" euid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"Process::UID.eid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.geteuid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the effective user ID for this process. Process.euid #=> 501 @overload euid @return [Integer] @overload Process::UID.eid @return [Integer] @overload Process::Sys.geteuid @return [Integer];T;#0;$@;.F;C0;%@;9I"gstatic VALUE proc_geteuid(VALUE obj) { rb_uid_t euid = geteuid(); return UIDT2NUM(euid); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::UID.eid;F;7@;@;T;;;0;@;{;IC; "OReturns the effective user ID for this process. Process.euid #=> 501;T;[o;= ;>I" overload;F;?0;;;@0;:I" euid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@(;![;"I"@return [Integer];T;#0;$@(;.F;Bi;C0;7[;$@(o;= ;>I" overload;F;?0;;;@0;:I"Process::UID.eid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@(;![;"I"@return [Integer];T;#0;$@(;.F;Bi;C0;7[;$@(o;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.geteuid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@(;![;"I"@return [Integer];T;#0;$@(;.F;Bi;C0;7[;$@(;![;"@ݻ;#0;$@(;.F;/o;0;1T;2i;3i;Bi;%@;9@&;:@';;To;4;5F;6;;;;&I""Process::UID#change_privilege;F;7[[I"id;T0;[[@ i";T;:change_privilege;0;[;{;IC; "%Change the current process's real and effective user ID to that specified by _user_. Returns the new user ID. Not available on all platforms. [Process.uid, Process.euid] #=> [0, 0] Process::UID.change_privilege(31) #=> 31 [Process.uid, Process.euid] #=> [31, 31] ;T;[o;= ;>I" overload;F;?0;:"Process::UID.change_privilege;@0;:I"(Process::UID.change_privilege(user);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@V;![;"I"@return [Integer];T;#0;$@V;.F;Bi;C0;7[[I" user;T0;$@V;![;"I"hChange the current process's real and effective user ID to that specified by _user_. Returns the new user ID. Not available on all platforms. [Process.uid, Process.euid] #=> [0, 0] Process::UID.change_privilege(31) #=> 31 [Process.uid, Process.euid] #=> [31, 31] @overload Process::UID.change_privilege(user) @return [Integer];T;#0;$@V;.F;C0;%@;9I"kstatic VALUE p_uid_change_privilege(VALUE obj, VALUE id) { rb_uid_t uid; check_uid_switch(); uid = OBJ2UID(id); if (geteuid() == 0) { /* root-user */ #if defined(HAVE_SETRESUID) if (setresuid(uid, uid, uid) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; #elif defined(HAVE_SETUID) if (setuid(uid) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; #elif defined(HAVE_SETREUID) && !defined(OBSOLETE_SETREUID) if (getuid() == uid) { if (SAVED_USER_ID == uid) { if (setreuid(-1, uid) < 0) rb_sys_fail(0); } else { if (uid == 0) { /* (r,e,s) == (root, root, x) */ if (setreuid(-1, SAVED_USER_ID) < 0) rb_sys_fail(0); if (setreuid(SAVED_USER_ID, 0) < 0) rb_sys_fail(0); SAVED_USER_ID = 0; /* (r,e,s) == (x, root, root) */ if (setreuid(uid, uid) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; } else { if (setreuid(0, -1) < 0) rb_sys_fail(0); SAVED_USER_ID = 0; if (setreuid(uid, uid) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; } } } else { if (setreuid(uid, uid) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; } #elif defined(HAVE_SETRUID) && defined(HAVE_SETEUID) if (getuid() == uid) { if (SAVED_USER_ID == uid) { if (seteuid(uid) < 0) rb_sys_fail(0); } else { if (uid == 0) { if (setruid(SAVED_USER_ID) < 0) rb_sys_fail(0); SAVED_USER_ID = 0; if (setruid(0) < 0) rb_sys_fail(0); } else { if (setruid(0) < 0) rb_sys_fail(0); SAVED_USER_ID = 0; if (seteuid(uid) < 0) rb_sys_fail(0); if (setruid(uid) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; } } } else { if (seteuid(uid) < 0) rb_sys_fail(0); if (setruid(uid) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; } #else (void)uid; rb_notimplement(); #endif } else { /* unprivileged user */ #if defined(HAVE_SETRESUID) if (setresuid((getuid() == uid)? (rb_uid_t)-1: uid, (geteuid() == uid)? (rb_uid_t)-1: uid, (SAVED_USER_ID == uid)? (rb_uid_t)-1: uid) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; #elif defined(HAVE_SETREUID) && !defined(OBSOLETE_SETREUID) if (SAVED_USER_ID == uid) { if (setreuid((getuid() == uid)? (rb_uid_t)-1: uid, (geteuid() == uid)? (rb_uid_t)-1: uid) < 0) rb_sys_fail(0); } else if (getuid() != uid) { if (setreuid(uid, (geteuid() == uid)? (rb_uid_t)-1: uid) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; } else if (/* getuid() == uid && */ geteuid() != uid) { if (setreuid(geteuid(), uid) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; if (setreuid(uid, -1) < 0) rb_sys_fail(0); } else { /* getuid() == uid && geteuid() == uid */ if (setreuid(-1, SAVED_USER_ID) < 0) rb_sys_fail(0); if (setreuid(SAVED_USER_ID, uid) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; if (setreuid(uid, -1) < 0) rb_sys_fail(0); } #elif defined(HAVE_SETRUID) && defined(HAVE_SETEUID) if (SAVED_USER_ID == uid) { if (geteuid() != uid && seteuid(uid) < 0) rb_sys_fail(0); if (getuid() != uid && setruid(uid) < 0) rb_sys_fail(0); } else if (/* SAVED_USER_ID != uid && */ geteuid() == uid) { if (getuid() != uid) { if (setruid(uid) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; } else { if (setruid(SAVED_USER_ID) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; if (setruid(uid) < 0) rb_sys_fail(0); } } else if (/* geteuid() != uid && */ getuid() == uid) { if (seteuid(uid) < 0) rb_sys_fail(0); if (setruid(SAVED_USER_ID) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; if (setruid(uid) < 0) rb_sys_fail(0); } else { rb_syserr_fail(EPERM, 0); } #elif defined HAVE_44BSD_SETUID if (getuid() == uid) { /* (r,e,s)==(uid,?,?) ==> (uid,uid,uid) */ if (setuid(uid) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; } else { rb_syserr_fail(EPERM, 0); } #elif defined HAVE_SETEUID if (getuid() == uid && SAVED_USER_ID == uid) { if (seteuid(uid) < 0) rb_sys_fail(0); } else { rb_syserr_fail(EPERM, 0); } #elif defined HAVE_SETUID if (getuid() == uid && SAVED_USER_ID == uid) { if (setuid(uid) < 0) rb_sys_fail(0); } else { rb_syserr_fail(EPERM, 0); } #else rb_notimplement(); #endif } return id; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I""Process::UID.change_privilege;F;7@X;@[;T;;;0;@];{;IC; "%Change the current process's real and effective user ID to that specified by _user_. Returns the new user ID. Not available on all platforms. [Process.uid, Process.euid] #=> [0, 0] Process::UID.change_privilege(31) #=> 31 [Process.uid, Process.euid] #=> [31, 31];T;[o;= ;>I" overload;F;?0;;;@0;:I"(Process::UID.change_privilege(user);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@t;![;"I"@return [Integer];T;#0;$@t;.F;Bi;C0;7[[I" user;T0;$@t;![;"I"iChange the current process's real and effective user ID to that specified by _user_. Returns the new user ID. Not available on all platforms. [Process.uid, Process.euid] #=> [0, 0] Process::UID.change_privilege(31) #=> 31 [Process.uid, Process.euid] #=> [31, 31] @overload Process::UID.change_privilege(user) @return [Integer];T;#0;$@t;.F;/o;0;1T;2i;3i;Bi;%@;9@r;:@s;;To;4;5F;6;;;;&I"!Process::UID#grant_privilege;F;7[[I"id;T0;[[@ i;T;:grant_privilege;0;[;{;IC; ";Set the effective user ID, and if possible, the saved user ID of the process to the given _user_. Returns the new effective user ID. Not available on all platforms. [Process.uid, Process.euid] #=> [0, 0] Process::UID.grant_privilege(31) #=> 31 [Process.uid, Process.euid] #=> [0, 31] ;T;[o;= ;>I" overload;F;?0;:!Process::UID.grant_privilege;@0;:I"'Process::UID.grant_privilege(user);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I" user;T0;$@o;= ;>I" overload;F;?0;:Process::UID.eid=;@0;:I"Process::UID.eid= user;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I" user;T0;$@;![;"I"Set the effective user ID, and if possible, the saved user ID of the process to the given _user_. Returns the new effective user ID. Not available on all platforms. [Process.uid, Process.euid] #=> [0, 0] Process::UID.grant_privilege(31) #=> 31 [Process.uid, Process.euid] #=> [0, 31] @overload Process::UID.grant_privilege(user) @return [Integer] @overload Process::UID.eid= user @return [Integer];T;#0;$@;.F;C0;%@;9I"qstatic VALUE p_uid_grant_privilege(VALUE obj, VALUE id) { rb_seteuid_core(OBJ2UID(id)); return id; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"!Process::UID.grant_privilege;F;7@;@;T;;;0;@;{;IC; ";Set the effective user ID, and if possible, the saved user ID of the process to the given _user_. Returns the new effective user ID. Not available on all platforms. [Process.uid, Process.euid] #=> [0, 0] Process::UID.grant_privilege(31) #=> 31 [Process.uid, Process.euid] #=> [0, 31];T;[o;= ;>I" overload;F;?0;;;@0;:I"'Process::UID.grant_privilege(user);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I" user;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"Process::UID.eid= user;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I" user;T0;$@;![;"I"Set the effective user ID, and if possible, the saved user ID of the process to the given _user_. Returns the new effective user ID. Not available on all platforms. [Process.uid, Process.euid] #=> [0, 0] Process::UID.grant_privilege(31) #=> 31 [Process.uid, Process.euid] #=> [0, 31] @overload Process::UID.grant_privilege(user) @return [Integer] @overload Process::UID.eid= user @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process::UID#re_exchange;F;7[;[[@ i;T;:re_exchange;0;[;{;IC; "Exchange real and effective user IDs and return the new effective user ID. Not available on all platforms. [Process.uid, Process.euid] #=> [0, 31] Process::UID.re_exchange #=> 0 [Process.uid, Process.euid] #=> [31, 0] ;T;[o;= ;>I" overload;F;?0;:Process::UID.re_exchange;@0;:I"Process::UID.re_exchange;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"$Exchange real and effective user IDs and return the new effective user ID. Not available on all platforms. [Process.uid, Process.euid] #=> [0, 31] Process::UID.re_exchange #=> 0 [Process.uid, Process.euid] #=> [31, 0] @overload Process::UID.re_exchange @return [Integer];T;#0;$@;.F;C0;%@;9I"static VALUE p_uid_exchange(VALUE obj) { rb_uid_t uid; #if defined(HAVE_SETRESUID) || (defined(HAVE_SETREUID) && !defined(OBSOLETE_SETREUID)) rb_uid_t euid; #endif check_uid_switch(); uid = getuid(); #if defined(HAVE_SETRESUID) || (defined(HAVE_SETREUID) && !defined(OBSOLETE_SETREUID)) euid = geteuid(); #endif #if defined(HAVE_SETRESUID) if (setresuid(euid, uid, uid) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; #elif defined(HAVE_SETREUID) && !defined(OBSOLETE_SETREUID) if (setreuid(euid,uid) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; #else rb_notimplement(); #endif return UIDT2NUM(uid); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::UID.re_exchange;F;7@;@;T;;;0;@;{;IC; "Exchange real and effective user IDs and return the new effective user ID. Not available on all platforms. [Process.uid, Process.euid] #=> [0, 31] Process::UID.re_exchange #=> 0 [Process.uid, Process.euid] #=> [31, 0];T;[o;= ;>I" overload;F;?0;;;@0;:I"Process::UID.re_exchange;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"%Exchange real and effective user IDs and return the new effective user ID. Not available on all platforms. [Process.uid, Process.euid] #=> [0, 31] Process::UID.re_exchange #=> 0 [Process.uid, Process.euid] #=> [31, 0] @overload Process::UID.re_exchange @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;To;4;5F;6;;;;&I""Process::UID#re_exchangeable?;F;7[;[[@ i;T;:re_exchangeable?;0;[;{;IC; "mReturns +true+ if the real and effective user IDs of a process may be exchanged on the current platform. ;T;[o;= ;>I" overload;F;?0;:"Process::UID.re_exchangeable?;@0;:I""Process::UID.re_exchangeable?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ ;![;"I"@return [Boolean];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Returns +true+ if the real and effective user IDs of a process may be exchanged on the current platform. @overload Process::UID.re_exchangeable? @return [Boolean];T;#0;$@ ;.F;C0;%@;9I"static VALUE p_uid_exchangeable(VALUE _) { #if defined(HAVE_SETRESUID) return Qtrue; #elif defined(HAVE_SETREUID) && !defined(OBSOLETE_SETREUID) return Qtrue; #else return Qfalse; #endif };T;:I"static VALUE;T;;To;4;5T;6;;;;&I""Process::UID.re_exchangeable?;F;7@;@;T;;;0;@;{;IC; "mReturns +true+ if the real and effective user IDs of a process may be exchanged on the current platform.;T;[o;= ;>I" overload;F;?0;;;@0;:I""Process::UID.re_exchangeable?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@';![;"I"@return [Boolean];T;#0;$@';.F;Bi;C0;7[;$@';![;"I"Returns +true+ if the real and effective user IDs of a process may be exchanged on the current platform. @overload Process::UID.re_exchangeable? @return [Boolean];T;#0;$@';.F;/o;0;1T;2i;3i;Bi;%@;9@%;:@&;;To;4;5F;6;;;;&I" Process::UID#sid_available?;F;7[;[[@ i ;T;:sid_available?;0;[;{;IC; "LReturns +true+ if the current platform has saved user ID functionality. ;T;[o;= ;>I" overload;F;?0;: Process::UID.sid_available?;@0;:I" Process::UID.sid_available?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@<;![;"I"@return [Boolean];T;#0;$@<;.F;Bi;C0;7[;$@<;![;"I"Returns +true+ if the current platform has saved user ID functionality. @overload Process::UID.sid_available? @return [Boolean];T;#0;$@<;.F;C0;%@;9I"static VALUE p_uid_have_saved_id(VALUE _) { #if defined(HAVE_SETRESUID) || defined(HAVE_SETEUID) || defined(_POSIX_SAVED_IDS) return Qtrue; #else return Qfalse; #endif };T;:I"static VALUE;T;;To;4;5T;6;;;;&I" Process::UID.sid_available?;F;7@>;@?;T;;;0;@A;{;IC; "LReturns +true+ if the current platform has saved user ID functionality.;T;[o;= ;>I" overload;F;?0;;;@0;:I" Process::UID.sid_available?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@V;![;"I"@return [Boolean];T;#0;$@V;.F;Bi;C0;7[;$@V;![;"I"Returns +true+ if the current platform has saved user ID functionality. @overload Process::UID.sid_available? @return [Boolean];T;#0;$@V;.F;/o;0;1T;2i;3i;Bi;%@;9@T;:@U;;To;4;5F;6;;;;&I"Process::UID#switch;F;7[;[[@ iZ;T;: switch;0;[;{;IC; " ;T;[;![;"I";F;#0;$@k;.F;C0;%@;9I"sstatic VALUE p_uid_switch(VALUE obj) { rb_uid_t uid, euid; check_uid_switch(); uid = getuid(); euid = geteuid(); if (uid == euid) { rb_syserr_fail(EPERM, 0); } p_uid_exchange(obj); if (rb_block_given_p()) { under_uid_switch = 1; return rb_ensure(rb_yield, Qnil, p_uid_sw_ensure, obj); } else { return UIDT2NUM(euid); } };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::UID.switch;F;7@m;@n;T;;;0;@p;{;IC; " ;T;[;![;"@;#0;$@x;Bi;%@;9@v;:@w;;To;4;5F;6;;;;&I"Process::UID#from_name;F;7[[I"id;T0;[[@ i;T;:from_name;0;[;{;IC; "Get the user ID by the _name_. If the user is not found, +ArgumentError+ will be raised. Process::UID.from_name("root") #=> 0 Process::UID.from_name("nosuchuser") #=> can't find user for nosuchuser (ArgumentError) ;T;[o;= ;>I" overload;F;?0;:Process::UID.from_name;@0;:I"!Process::UID.from_name(name);T;IC; ";T;[;![;"I";T;#0;$@~;.F;Bi;C0;7[[I" name;T0;$@~;![;"I"Get the user ID by the _name_. If the user is not found, +ArgumentError+ will be raised. Process::UID.from_name("root") #=> 0 Process::UID.from_name("nosuchuser") #=> can't find user for nosuchuser (ArgumentError) @overload Process::UID.from_name(name) ;T;#0;$@~;.F;C0;%@;9I"]static VALUE p_uid_from_name(VALUE self, VALUE id) { return UIDT2NUM(OBJ2UID(id)); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::UID.from_name;F;7@;@;T;;;0;@;{;IC; "Get the user ID by the _name_. If the user is not found, +ArgumentError+ will be raised. Process::UID.from_name("root") #=> 0 Process::UID.from_name("nosuchuser") #=> can't find user for nosuchuser (ArgumentError);T;[o;= ;>I" overload;F;?0;;;@0;:I"!Process::UID.from_name(name);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" name;T0;$@;![;"I"Get the user ID by the _name_. If the user is not found, +ArgumentError+ will be raised. Process::UID.from_name("root") #=> 0 Process::UID.from_name("nosuchuser") #=> can't find user for nosuchuser (ArgumentError) @overload Process::UID.from_name(name);T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ ib#;F;:UID;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I"Process::UID;Fo;;IC;[o;4;5F;6;;;;&I"Process::GID#rid;F;7[;[[@ i];T;;;0;[;{;IC; "LReturns the (real) group ID for this process. Process.gid #=> 500 ;T;[o;= ;>I" overload;F;?0;;-;@0;:I"gid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;~;@0;:I"Process::GID.rid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.getgid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the (real) group ID for this process. Process.gid #=> 500 @overload gid @return [Integer] @overload Process::GID.rid @return [Integer] @overload Process::Sys.getgid @return [Integer];T;#0;$@;.F;C0;%@;9I"cstatic VALUE proc_getgid(VALUE obj) { rb_gid_t gid = getgid(); return GIDT2NUM(gid); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::GID.rid;F;7@;@;T;;;0;@;{;IC; "LReturns the (real) group ID for this process. Process.gid #=> 500;T;[o;= ;>I" overload;F;?0;;-;@0;:I"gid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;~;@0;:I"Process::GID.rid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.getgid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"@E;#0;$@;.F;/o;0;1T;2iR;3i\;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process::GID#eid;F;7[;[[@ i;T;;;0;[;{;IC; "pReturns the effective group ID for this process. Not available on all platforms. Process.egid #=> 500 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" egid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"Process::GID.eid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.geteid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the effective group ID for this process. Not available on all platforms. Process.egid #=> 500 @overload egid @return [Integer] @overload Process::GID.eid @return [Integer] @overload Process::Sys.geteid @return [Integer];T;#0;$@;.F;C0;%@;9I"hstatic VALUE proc_getegid(VALUE obj) { rb_gid_t egid = getegid(); return GIDT2NUM(egid); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::GID.eid;F;7@;@;T;;;0;@!;{;IC; "pReturns the effective group ID for this process. Not available on all platforms. Process.egid #=> 500;T;[o;= ;>I" overload;F;?0;;;@0;:I" egid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@P;![;"I"@return [Integer];T;#0;$@P;.F;Bi;C0;7[;$@Po;= ;>I" overload;F;?0;;;@0;:I"Process::GID.eid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@P;![;"I"@return [Integer];T;#0;$@P;.F;Bi;C0;7[;$@Po;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.geteid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@P;![;"I"@return [Integer];T;#0;$@P;.F;Bi;C0;7[;$@P;![;"@k;#0;$@P;.F;/o;0;1T;2i;3i;Bi;%@;9@N;:@O;;To;4;5F;6;;;;&I""Process::GID#change_privilege;F;7[[I"id;T0;[[@ i;T;;;0;[;{;IC; "(Change the current process's real and effective group ID to that specified by _group_. Returns the new group ID. Not available on all platforms. [Process.gid, Process.egid] #=> [0, 0] Process::GID.change_privilege(33) #=> 33 [Process.gid, Process.egid] #=> [33, 33] ;T;[o;= ;>I" overload;F;?0;:"Process::GID.change_privilege;@0;:I")Process::GID.change_privilege(group);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@~;![;"I"@return [Integer];T;#0;$@~;.F;Bi;C0;7[[I" group;T0;$@~;![;"I"lChange the current process's real and effective group ID to that specified by _group_. Returns the new group ID. Not available on all platforms. [Process.gid, Process.egid] #=> [0, 0] Process::GID.change_privilege(33) #=> 33 [Process.gid, Process.egid] #=> [33, 33] @overload Process::GID.change_privilege(group) @return [Integer];T;#0;$@~;.F;C0;%@;9I"static VALUE p_gid_change_privilege(VALUE obj, VALUE id) { rb_gid_t gid; check_gid_switch(); gid = OBJ2GID(id); if (geteuid() == 0) { /* root-user */ #if defined(HAVE_SETRESGID) if (setresgid(gid, gid, gid) < 0) rb_sys_fail(0); SAVED_GROUP_ID = gid; #elif defined HAVE_SETGID if (setgid(gid) < 0) rb_sys_fail(0); SAVED_GROUP_ID = gid; #elif defined(HAVE_SETREGID) && !defined(OBSOLETE_SETREGID) if (getgid() == gid) { if (SAVED_GROUP_ID == gid) { if (setregid(-1, gid) < 0) rb_sys_fail(0); } else { if (gid == 0) { /* (r,e,s) == (root, y, x) */ if (setregid(-1, SAVED_GROUP_ID) < 0) rb_sys_fail(0); if (setregid(SAVED_GROUP_ID, 0) < 0) rb_sys_fail(0); SAVED_GROUP_ID = 0; /* (r,e,s) == (x, root, root) */ if (setregid(gid, gid) < 0) rb_sys_fail(0); SAVED_GROUP_ID = gid; } else { /* (r,e,s) == (z, y, x) */ if (setregid(0, 0) < 0) rb_sys_fail(0); SAVED_GROUP_ID = 0; if (setregid(gid, gid) < 0) rb_sys_fail(0); SAVED_GROUP_ID = gid; } } } else { if (setregid(gid, gid) < 0) rb_sys_fail(0); SAVED_GROUP_ID = gid; } #elif defined(HAVE_SETRGID) && defined (HAVE_SETEGID) if (getgid() == gid) { if (SAVED_GROUP_ID == gid) { if (setegid(gid) < 0) rb_sys_fail(0); } else { if (gid == 0) { if (setegid(gid) < 0) rb_sys_fail(0); if (setrgid(SAVED_GROUP_ID) < 0) rb_sys_fail(0); SAVED_GROUP_ID = 0; if (setrgid(0) < 0) rb_sys_fail(0); } else { if (setrgid(0) < 0) rb_sys_fail(0); SAVED_GROUP_ID = 0; if (setegid(gid) < 0) rb_sys_fail(0); if (setrgid(gid) < 0) rb_sys_fail(0); SAVED_GROUP_ID = gid; } } } else { if (setegid(gid) < 0) rb_sys_fail(0); if (setrgid(gid) < 0) rb_sys_fail(0); SAVED_GROUP_ID = gid; } #else rb_notimplement(); #endif } else { /* unprivileged user */ #if defined(HAVE_SETRESGID) if (setresgid((getgid() == gid)? (rb_gid_t)-1: gid, (getegid() == gid)? (rb_gid_t)-1: gid, (SAVED_GROUP_ID == gid)? (rb_gid_t)-1: gid) < 0) rb_sys_fail(0); SAVED_GROUP_ID = gid; #elif defined(HAVE_SETREGID) && !defined(OBSOLETE_SETREGID) if (SAVED_GROUP_ID == gid) { if (setregid((getgid() == gid)? (rb_uid_t)-1: gid, (getegid() == gid)? (rb_uid_t)-1: gid) < 0) rb_sys_fail(0); } else if (getgid() != gid) { if (setregid(gid, (getegid() == gid)? (rb_uid_t)-1: gid) < 0) rb_sys_fail(0); SAVED_GROUP_ID = gid; } else if (/* getgid() == gid && */ getegid() != gid) { if (setregid(getegid(), gid) < 0) rb_sys_fail(0); SAVED_GROUP_ID = gid; if (setregid(gid, -1) < 0) rb_sys_fail(0); } else { /* getgid() == gid && getegid() == gid */ if (setregid(-1, SAVED_GROUP_ID) < 0) rb_sys_fail(0); if (setregid(SAVED_GROUP_ID, gid) < 0) rb_sys_fail(0); SAVED_GROUP_ID = gid; if (setregid(gid, -1) < 0) rb_sys_fail(0); } #elif defined(HAVE_SETRGID) && defined(HAVE_SETEGID) if (SAVED_GROUP_ID == gid) { if (getegid() != gid && setegid(gid) < 0) rb_sys_fail(0); if (getgid() != gid && setrgid(gid) < 0) rb_sys_fail(0); } else if (/* SAVED_GROUP_ID != gid && */ getegid() == gid) { if (getgid() != gid) { if (setrgid(gid) < 0) rb_sys_fail(0); SAVED_GROUP_ID = gid; } else { if (setrgid(SAVED_GROUP_ID) < 0) rb_sys_fail(0); SAVED_GROUP_ID = gid; if (setrgid(gid) < 0) rb_sys_fail(0); } } else if (/* getegid() != gid && */ getgid() == gid) { if (setegid(gid) < 0) rb_sys_fail(0); if (setrgid(SAVED_GROUP_ID) < 0) rb_sys_fail(0); SAVED_GROUP_ID = gid; if (setrgid(gid) < 0) rb_sys_fail(0); } else { rb_syserr_fail(EPERM, 0); } #elif defined HAVE_44BSD_SETGID if (getgid() == gid) { /* (r,e,s)==(gid,?,?) ==> (gid,gid,gid) */ if (setgid(gid) < 0) rb_sys_fail(0); SAVED_GROUP_ID = gid; } else { rb_syserr_fail(EPERM, 0); } #elif defined HAVE_SETEGID if (getgid() == gid && SAVED_GROUP_ID == gid) { if (setegid(gid) < 0) rb_sys_fail(0); } else { rb_syserr_fail(EPERM, 0); } #elif defined HAVE_SETGID if (getgid() == gid && SAVED_GROUP_ID == gid) { if (setgid(gid) < 0) rb_sys_fail(0); } else { rb_syserr_fail(EPERM, 0); } #else (void)gid; rb_notimplement(); #endif } return id; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I""Process::GID.change_privilege;F;7@;@;T;;;0;@;{;IC; "(Change the current process's real and effective group ID to that specified by _group_. Returns the new group ID. Not available on all platforms. [Process.gid, Process.egid] #=> [0, 0] Process::GID.change_privilege(33) #=> 33 [Process.gid, Process.egid] #=> [33, 33];T;[o;= ;>I" overload;F;?0;;;@0;:I")Process::GID.change_privilege(group);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I" group;T0;$@;![;"I"mChange the current process's real and effective group ID to that specified by _group_. Returns the new group ID. Not available on all platforms. [Process.gid, Process.egid] #=> [0, 0] Process::GID.change_privilege(33) #=> 33 [Process.gid, Process.egid] #=> [33, 33] @overload Process::GID.change_privilege(group) @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"!Process::GID#grant_privilege;F;7[[I"id;T0;[[@ i};T;;;0;[;{;IC; "?Set the effective group ID, and if possible, the saved group ID of the process to the given _group_. Returns the new effective group ID. Not available on all platforms. [Process.gid, Process.egid] #=> [0, 0] Process::GID.grant_privilege(31) #=> 33 [Process.gid, Process.egid] #=> [0, 33] ;T;[o;= ;>I" overload;F;?0;:!Process::GID.grant_privilege;@0;:I"(Process::GID.grant_privilege(group);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I" group;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"Process::GID.eid = group;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I";TI" group;T;$@;![;"I"Set the effective group ID, and if possible, the saved group ID of the process to the given _group_. Returns the new effective group ID. Not available on all platforms. [Process.gid, Process.egid] #=> [0, 0] Process::GID.grant_privilege(31) #=> 33 [Process.gid, Process.egid] #=> [0, 33] @overload Process::GID.grant_privilege(group) @return [Integer] @overload Process::GID.eid = group @return [Integer];T;#0;$@;.F;C0;%@;9I"qstatic VALUE p_gid_grant_privilege(VALUE obj, VALUE id) { rb_setegid_core(OBJ2GID(id)); return id; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"!Process::GID.grant_privilege;F;7@;@;T;;;0;@;{;IC; "?Set the effective group ID, and if possible, the saved group ID of the process to the given _group_. Returns the new effective group ID. Not available on all platforms. [Process.gid, Process.egid] #=> [0, 0] Process::GID.grant_privilege(31) #=> 33 [Process.gid, Process.egid] #=> [0, 33];T;[o;= ;>I" overload;F;?0;;;@0;:I"(Process::GID.grant_privilege(group);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I" group;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"Process::GID.eid = group;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I";TI" group;T;$@;![;"I"Set the effective group ID, and if possible, the saved group ID of the process to the given _group_. Returns the new effective group ID. Not available on all platforms. [Process.gid, Process.egid] #=> [0, 0] Process::GID.grant_privilege(31) #=> 33 [Process.gid, Process.egid] #=> [0, 33] @overload Process::GID.grant_privilege(group) @return [Integer] @overload Process::GID.eid = group @return [Integer];T;#0;$@;.F;/o;0;1T;2io;3i{;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process::GID#re_exchange;F;7[;[[@ i;T;;;0;[;{;IC; "Exchange real and effective group IDs and return the new effective group ID. Not available on all platforms. [Process.gid, Process.egid] #=> [0, 33] Process::GID.re_exchange #=> 0 [Process.gid, Process.egid] #=> [33, 0] ;T;[o;= ;>I" overload;F;?0;:Process::GID.re_exchange;@0;:I"Process::GID.re_exchange;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"&Exchange real and effective group IDs and return the new effective group ID. Not available on all platforms. [Process.gid, Process.egid] #=> [0, 33] Process::GID.re_exchange #=> 0 [Process.gid, Process.egid] #=> [33, 0] @overload Process::GID.re_exchange @return [Integer];T;#0;$@;.F;C0;%@;9I"static VALUE p_gid_exchange(VALUE obj) { rb_gid_t gid; #if defined(HAVE_SETRESGID) || (defined(HAVE_SETREGID) && !defined(OBSOLETE_SETREGID)) rb_gid_t egid; #endif check_gid_switch(); gid = getgid(); #if defined(HAVE_SETRESGID) || (defined(HAVE_SETREGID) && !defined(OBSOLETE_SETREGID)) egid = getegid(); #endif #if defined(HAVE_SETRESGID) if (setresgid(egid, gid, gid) < 0) rb_sys_fail(0); SAVED_GROUP_ID = gid; #elif defined(HAVE_SETREGID) && !defined(OBSOLETE_SETREGID) if (setregid(egid,gid) < 0) rb_sys_fail(0); SAVED_GROUP_ID = gid; #else rb_notimplement(); #endif return GIDT2NUM(gid); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::GID.re_exchange;F;7@ ;@ ;T;;;0;@ ;{;IC; "Exchange real and effective group IDs and return the new effective group ID. Not available on all platforms. [Process.gid, Process.egid] #=> [0, 33] Process::GID.re_exchange #=> 0 [Process.gid, Process.egid] #=> [33, 0];T;[o;= ;>I" overload;F;?0;;;@0;:I"Process::GID.re_exchange;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@";![;"I"@return [Integer];T;#0;$@";.F;Bi;C0;7[;$@";![;"I"'Exchange real and effective group IDs and return the new effective group ID. Not available on all platforms. [Process.gid, Process.egid] #=> [0, 33] Process::GID.re_exchange #=> 0 [Process.gid, Process.egid] #=> [33, 0] @overload Process::GID.re_exchange @return [Integer];T;#0;$@";.F;/o;0;1T;2i;3i;Bi;%@;9@ ;:@!;;To;4;5F;6;;;;&I""Process::GID#re_exchangeable?;F;7[;[[@ i;T;;;0;[;{;IC; "nReturns +true+ if the real and effective group IDs of a process may be exchanged on the current platform. ;T;[o;= ;>I" overload;F;?0;:"Process::GID.re_exchangeable?;@0;:I""Process::GID.re_exchangeable?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@7;![;"I"@return [Boolean];T;#0;$@7;.F;Bi;C0;7[;$@7;![;"I"Returns +true+ if the real and effective group IDs of a process may be exchanged on the current platform. @overload Process::GID.re_exchangeable? @return [Boolean];T;#0;$@7;.F;C0;%@;9I"static VALUE p_gid_exchangeable(VALUE _) { #if defined(HAVE_SETRESGID) return Qtrue; #elif defined(HAVE_SETREGID) && !defined(OBSOLETE_SETREGID) return Qtrue; #else return Qfalse; #endif };T;:I"static VALUE;T;;To;4;5T;6;;;;&I""Process::GID.re_exchangeable?;F;7@9;@:;T;;;0;@<;{;IC; "nReturns +true+ if the real and effective group IDs of a process may be exchanged on the current platform.;T;[o;= ;>I" overload;F;?0;;;@0;:I""Process::GID.re_exchangeable?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Q;![;"I"@return [Boolean];T;#0;$@Q;.F;Bi;C0;7[;$@Q;![;"I"Returns +true+ if the real and effective group IDs of a process may be exchanged on the current platform. @overload Process::GID.re_exchangeable? @return [Boolean];T;#0;$@Q;.F;/o;0;1T;2i;3i;Bi;%@;9@O;:@P;;To;4;5F;6;;;;&I" Process::GID#sid_available?;F;7[;[[@ i~;T;;;0;[;{;IC; "MReturns +true+ if the current platform has saved group ID functionality. ;T;[o;= ;>I" overload;F;?0;: Process::GID.sid_available?;@0;:I" Process::GID.sid_available?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@f;![;"I"@return [Boolean];T;#0;$@f;.F;Bi;C0;7[;$@f;![;"I"Returns +true+ if the current platform has saved group ID functionality. @overload Process::GID.sid_available? @return [Boolean];T;#0;$@f;.F;C0;%@;9I"static VALUE p_gid_have_saved_id(VALUE _) { #if defined(HAVE_SETRESGID) || defined(HAVE_SETEGID) || defined(_POSIX_SAVED_IDS) return Qtrue; #else return Qfalse; #endif };T;:I"static VALUE;T;;To;4;5T;6;;;;&I" Process::GID.sid_available?;F;7@h;@i;T;;;0;@k;{;IC; "MReturns +true+ if the current platform has saved group ID functionality.;T;[o;= ;>I" overload;F;?0;;;@0;:I" Process::GID.sid_available?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns +true+ if the current platform has saved group ID functionality. @overload Process::GID.sid_available? @return [Boolean];T;#0;$@;.F;/o;0;1T;2iu;3i{;Bi;%@;9@~;:@;;To;4;5F;6;;;;&I"Process::GID#switch;F;7[;[[@ i;T;;;0;[;{;IC; " ;T;[;![;"I";F;#0;$@;.F;C0;%@;9I"sstatic VALUE p_gid_switch(VALUE obj) { rb_gid_t gid, egid; check_gid_switch(); gid = getgid(); egid = getegid(); if (gid == egid) { rb_syserr_fail(EPERM, 0); } p_gid_exchange(obj); if (rb_block_given_p()) { under_gid_switch = 1; return rb_ensure(rb_yield, Qnil, p_gid_sw_ensure, obj); } else { return GIDT2NUM(egid); } };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::GID.switch;F;7@;@;T;;;0;@;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process::GID#from_name;F;7[[I"id;T0;[[@ i:;T;;;0;[;{;IC; "Get the group ID by the _name_. If the group is not found, +ArgumentError+ will be raised. Process::GID.from_name("wheel") #=> 0 Process::GID.from_name("nosuchgroup") #=> can't find group for nosuchgroup (ArgumentError) ;T;[o;= ;>I" overload;F;?0;:Process::GID.from_name;@0;:I"!Process::GID.from_name(name);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" name;T0;$@;![;"I" Get the group ID by the _name_. If the group is not found, +ArgumentError+ will be raised. Process::GID.from_name("wheel") #=> 0 Process::GID.from_name("nosuchgroup") #=> can't find group for nosuchgroup (ArgumentError) @overload Process::GID.from_name(name) ;T;#0;$@;.F;C0;%@;9I"]static VALUE p_gid_from_name(VALUE self, VALUE id) { return GIDT2NUM(OBJ2GID(id)); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::GID.from_name;F;7@;@;T;;;0;@;{;IC; "Get the group ID by the _name_. If the group is not found, +ArgumentError+ will be raised. Process::GID.from_name("wheel") #=> 0 Process::GID.from_name("nosuchgroup") #=> can't find group for nosuchgroup (ArgumentError);T;[o;= ;>I" overload;F;?0;;;@0;:I"!Process::GID.from_name(name);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" name;T0;$@;![;"I" Get the group ID by the _name_. If the group is not found, +ArgumentError+ will be raised. Process::GID.from_name("wheel") #=> 0 Process::GID.from_name("nosuchgroup") #=> can't find group for nosuchgroup (ArgumentError) @overload Process::GID.from_name(name);T;#0;$@;.F;/o;0;1T;2i/;3i6;Bi;%@;9@;:@;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ ic#;F;:GID;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I"Process::GID;Fo;;IC;[#o;4;5F;6;;;;&I"Process::Sys#getuid;F;7[;[[@ i;T;: getuid;0;[;{;IC; "JReturns the (real) user ID of this process. Process.uid #=> 501 ;T;[o;= ;>I" overload;F;?0;;,;@0;:I"uid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;{;@0;:I"Process::UID.rid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;|;@0;:I"Process::Sys.getuid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the (real) user ID of this process. Process.uid #=> 501 @overload uid @return [Integer] @overload Process::UID.rid @return [Integer] @overload Process::Sys.getuid @return [Integer];T;#0;$@;.F;C0;%@;9I"cstatic VALUE proc_getuid(VALUE obj) { rb_uid_t uid = getuid(); return UIDT2NUM(uid); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::Sys.getuid;F;7@;@;T;;;0;@;{;IC; "JReturns the (real) user ID of this process. Process.uid #=> 501;T;[o;= ;>I" overload;F;?0;;,;@0;:I"uid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;{;@0;:I"Process::UID.rid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;|;@0;:I"Process::Sys.getuid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process::Sys#geteuid;F;7[;[[@ i;T;: geteuid;0;[;{;IC; "OReturns the effective user ID for this process. Process.euid #=> 501 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" euid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@F;![;"I"@return [Integer];T;#0;$@F;.F;Bi;C0;7[;$@Fo;= ;>I" overload;F;?0;;;@0;:I"Process::UID.eid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@F;![;"I"@return [Integer];T;#0;$@F;.F;Bi;C0;7[;$@Fo;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.geteuid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@F;![;"I"@return [Integer];T;#0;$@F;.F;Bi;C0;7[;$@F;![;"I"Returns the effective user ID for this process. Process.euid #=> 501 @overload euid @return [Integer] @overload Process::UID.eid @return [Integer] @overload Process::Sys.geteuid @return [Integer];T;#0;$@F;.F;C0;%@;9I"gstatic VALUE proc_geteuid(VALUE obj) { rb_uid_t euid = geteuid(); return UIDT2NUM(euid); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::Sys.geteuid;F;7@H;@I;T;;;0;@K;{;IC; "OReturns the effective user ID for this process. Process.euid #=> 501;T;[o;= ;>I" overload;F;?0;;;@0;:I" euid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@z;![;"I"@return [Integer];T;#0;$@z;.F;Bi;C0;7[;$@zo;= ;>I" overload;F;?0;;;@0;:I"Process::UID.eid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@z;![;"I"@return [Integer];T;#0;$@z;.F;Bi;C0;7[;$@zo;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.geteuid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@z;![;"I"@return [Integer];T;#0;$@z;.F;Bi;C0;7[;$@z;![;"@ݻ;#0;$@z;.F;/o;0;1T;2i;3i;Bi;%@;9@x;:@y;;To;4;5F;6;;;;&I"Process::Sys#getgid;F;7[;[[@ i];T;: getgid;0;[;{;IC; "LReturns the (real) group ID for this process. Process.gid #=> 500 ;T;[o;= ;>I" overload;F;?0;;-;@0;:I"gid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;~;@0;:I"Process::GID.rid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.getgid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the (real) group ID for this process. Process.gid #=> 500 @overload gid @return [Integer] @overload Process::GID.rid @return [Integer] @overload Process::Sys.getgid @return [Integer];T;#0;$@;.F;C0;%@;9I"cstatic VALUE proc_getgid(VALUE obj) { rb_gid_t gid = getgid(); return GIDT2NUM(gid); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::Sys.getgid;F;7@;@;T;;;0;@;{;IC; "LReturns the (real) group ID for this process. Process.gid #=> 500;T;[o;= ;>I" overload;F;?0;;-;@0;:I"gid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;~;@0;:I"Process::GID.rid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.getgid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"@E;#0;$@;.F;/o;0;1T;2iR;3i\;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process::Sys#getegid;F;7[;[[@ i;T;: getegid;0;[;{;IC; "pReturns the effective group ID for this process. Not available on all platforms. Process.egid #=> 500 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" egid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;;;@0;:I"Process::GID.eid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.geteid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Returns the effective group ID for this process. Not available on all platforms. Process.egid #=> 500 @overload egid @return [Integer] @overload Process::GID.eid @return [Integer] @overload Process::Sys.geteid @return [Integer];T;#0;$@ ;.F;C0;%@;9I"hstatic VALUE proc_getegid(VALUE obj) { rb_gid_t egid = getegid(); return GIDT2NUM(egid); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::Sys.getegid;F;7@ ;@ ;T;;;0;@;{;IC; "pReturns the effective group ID for this process. Not available on all platforms. Process.egid #=> 500;T;[o;= ;>I" overload;F;?0;;;@0;:I" egid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@>;![;"I"@return [Integer];T;#0;$@>;.F;Bi;C0;7[;$@>o;= ;>I" overload;F;?0;;;@0;:I"Process::GID.eid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@>;![;"I"@return [Integer];T;#0;$@>;.F;Bi;C0;7[;$@>o;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.geteid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@>;![;"I"@return [Integer];T;#0;$@>;.F;Bi;C0;7[;$@>;![;"@k;#0;$@>;.F;/o;0;1T;2i;3i;Bi;%@;9@<;:@=;;To;4;5F;6;;;;&I"Process::Sys#setuid;F;7[[I"id;T0;[[@ iL;T;: setuid;0;[;{;IC; "VSet the user ID of the current process to _user_. Not available on all platforms. ;T;[o;= ;>I" overload;F;?0;:Process::Sys.setuid;@0;:I"Process::Sys.setuid(user);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@l;![;"I"@return [nil];T;#0;$@l;.F;Bi;C0;7[[I" user;T0;$@l;![;"I"Set the user ID of the current process to _user_. Not available on all platforms. @overload Process::Sys.setuid(user) @return [nil];T;#0;$@l;.F;C0;%@;9I"static VALUE p_sys_setuid(VALUE obj, VALUE id) { check_uid_switch(); if (setuid(OBJ2UID(id)) != 0) rb_sys_fail(0); return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::Sys.setuid;F;7@n;@q;T;;;0;@s;{;IC; "VSet the user ID of the current process to _user_. Not available on all platforms.;T;[o;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.setuid(user);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I" user;T0;$@;![;"I"Set the user ID of the current process to _user_. Not available on all platforms. @overload Process::Sys.setuid(user) @return [nil];T;#0;$@;.F;/o;0;1T;2iC;3iI;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process::Sys#setgid;F;7[[I"id;T0;[[@ i;T;: setgid;0;[;{;IC; "XSet the group ID of the current process to _group_. Not available on all platforms. ;T;[o;= ;>I" overload;F;?0;:Process::Sys.setgid;@0;:I"Process::Sys.setgid(group);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I" group;T0;$@;![;"I"Set the group ID of the current process to _group_. Not available on all platforms. @overload Process::Sys.setgid(group) @return [nil];T;#0;$@;.F;C0;%@;9I"static VALUE p_sys_setgid(VALUE obj, VALUE id) { check_gid_switch(); if (setgid(OBJ2GID(id)) != 0) rb_sys_fail(0); return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::Sys.setgid;F;7@;@;T;;;0;@;{;IC; "XSet the group ID of the current process to _group_. Not available on all platforms.;T;[o;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.setgid(group);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I" group;T0;$@;![;"I"Set the group ID of the current process to _group_. Not available on all platforms. @overload Process::Sys.setgid(group) @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process::Sys#setruid;F;7[[I"id;T0;[[@ ib;T;: setruid;0;[;{;IC; "[Set the real user ID of the calling process to _user_. Not available on all platforms. ;T;[o;= ;>I" overload;F;?0;:Process::Sys.setruid;@0;:I"Process::Sys.setruid(user);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I" user;T0;$@;![;"I"Set the real user ID of the calling process to _user_. Not available on all platforms. @overload Process::Sys.setruid(user) @return [nil];T;#0;$@;.F;C0;%@;9I"static VALUE p_sys_setruid(VALUE obj, VALUE id) { check_uid_switch(); if (setruid(OBJ2UID(id)) != 0) rb_sys_fail(0); return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::Sys.setruid;F;7@;@;T;;;0;@;{;IC; "[Set the real user ID of the calling process to _user_. Not available on all platforms.;T;[o;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.setruid(user);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I" user;T0;$@;![;"I"Set the real user ID of the calling process to _user_. Not available on all platforms. @overload Process::Sys.setruid(user) @return [nil];T;#0;$@;.F;/o;0;1T;2iY;3i_;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process::Sys#setrgid;F;7[[I"id;T0;[[@ i;T;: setrgid;0;[;{;IC; "]Set the real group ID of the calling process to _group_. Not available on all platforms. ;T;[o;= ;>I" overload;F;?0;:Process::Sys.setrgid;@0;:I" Process::Sys.setrgid(group);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@ ;![;"I"@return [nil];T;#0;$@ ;.F;Bi;C0;7[[I" group;T0;$@ ;![;"I"Set the real group ID of the calling process to _group_. Not available on all platforms. @overload Process::Sys.setrgid(group) @return [nil];T;#0;$@ ;.F;C0;%@;9I"static VALUE p_sys_setrgid(VALUE obj, VALUE id) { check_gid_switch(); if (setrgid(OBJ2GID(id)) != 0) rb_sys_fail(0); return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::Sys.setrgid;F;7@ ;@;T;;;0;@;{;IC; "]Set the real group ID of the calling process to _group_. Not available on all platforms.;T;[o;= ;>I" overload;F;?0;;;@0;:I" Process::Sys.setrgid(group);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@);![;"I"@return [nil];T;#0;$@);.F;Bi;C0;7[[I" group;T0;$@);![;"I"Set the real group ID of the calling process to _group_. Not available on all platforms. @overload Process::Sys.setrgid(group) @return [nil];T;#0;$@);.F;/o;0;1T;2i;3i;Bi;%@;9@';:@(;;To;4;5F;6;;;;&I"Process::Sys#seteuid;F;7[[I"id;T0;[[@ ix;T;: seteuid;0;[;{;IC; "aSet the effective user ID of the calling process to _user_. Not available on all platforms. ;T;[o;= ;>I" overload;F;?0;:Process::Sys.seteuid;@0;:I"Process::Sys.seteuid(user);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@@;![;"I"@return [nil];T;#0;$@@;.F;Bi;C0;7[[I" user;T0;$@@;![;"I"Set the effective user ID of the calling process to _user_. Not available on all platforms. @overload Process::Sys.seteuid(user) @return [nil];T;#0;$@@;.F;C0;%@;9I"static VALUE p_sys_seteuid(VALUE obj, VALUE id) { check_uid_switch(); if (seteuid(OBJ2UID(id)) != 0) rb_sys_fail(0); return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::Sys.seteuid;F;7@B;@E;T;;;0;@G;{;IC; "aSet the effective user ID of the calling process to _user_. Not available on all platforms.;T;[o;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.seteuid(user);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@^;![;"I"@return [nil];T;#0;$@^;.F;Bi;C0;7[[I" user;T0;$@^;![;"I"Set the effective user ID of the calling process to _user_. Not available on all platforms. @overload Process::Sys.seteuid(user) @return [nil];T;#0;$@^;.F;/o;0;1T;2io;3iu;Bi;%@;9@\;:@];;To;4;5F;6;;;;&I"Process::Sys#setegid;F;7[[I"id;T0;[[@ i;T;: setegid;0;[;{;IC; "cSet the effective group ID of the calling process to _group_. Not available on all platforms. ;T;[o;= ;>I" overload;F;?0;:Process::Sys.setegid;@0;:I" Process::Sys.setegid(group);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@u;![;"I"@return [nil];T;#0;$@u;.F;Bi;C0;7[[I" group;T0;$@u;![;"I"Set the effective group ID of the calling process to _group_. Not available on all platforms. @overload Process::Sys.setegid(group) @return [nil];T;#0;$@u;.F;C0;%@;9I"static VALUE p_sys_setegid(VALUE obj, VALUE id) { check_gid_switch(); if (setegid(OBJ2GID(id)) != 0) rb_sys_fail(0); return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::Sys.setegid;F;7@w;@z;T;;;0;@|;{;IC; "cSet the effective group ID of the calling process to _group_. Not available on all platforms.;T;[o;= ;>I" overload;F;?0;;;@0;:I" Process::Sys.setegid(group);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I" group;T0;$@;![;"I"Set the effective group ID of the calling process to _group_. Not available on all platforms. @overload Process::Sys.setegid(group) @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process::Sys#setreuid;F;7[[I"rid;T0[I"eid;T0;[[@ i;T;: setreuid;0;[;{;IC; "Sets the (user) real and/or effective user IDs of the current process to _rid_ and _eid_, respectively. A value of -1 for either means to leave that ID unchanged. Not available on all platforms. ;T;[o;= ;>I" overload;F;?0;:Process::Sys.setreuid;@0;:I"$Process::Sys.setreuid(rid, eid);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I"rid;T0[I"eid;T0;$@;![;"I" Sets the (user) real and/or effective user IDs of the current process to _rid_ and _eid_, respectively. A value of -1 for either means to leave that ID unchanged. Not available on all platforms. @overload Process::Sys.setreuid(rid, eid) @return [nil];T;#0;$@;.F;C0;%@;9I"static VALUE p_sys_setreuid(VALUE obj, VALUE rid, VALUE eid) { rb_uid_t ruid, euid; PREPARE_GETPWNAM; check_uid_switch(); ruid = OBJ2UID1(rid); euid = OBJ2UID1(eid); FINISH_GETPWNAM; if (setreuid(ruid, euid) != 0) rb_sys_fail(0); return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::Sys.setreuid;F;7@;@;T;;;0;@;{;IC; "Sets the (user) real and/or effective user IDs of the current process to _rid_ and _eid_, respectively. A value of -1 for either means to leave that ID unchanged. Not available on all platforms.;T;[o;= ;>I" overload;F;?0;;;@0;:I"$Process::Sys.setreuid(rid, eid);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I"rid;T0[I"eid;T0;$@;![;"I" Sets the (user) real and/or effective user IDs of the current process to _rid_ and _eid_, respectively. A value of -1 for either means to leave that ID unchanged. Not available on all platforms. @overload Process::Sys.setreuid(rid, eid) @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process::Sys#setregid;F;7[[I"rid;T0[I"eid;T0;[[@ i ;T;: setregid;0;[;{;IC; "Sets the (group) real and/or effective group IDs of the current process to rid and eid, respectively. A value of -1 for either means to leave that ID unchanged. Not available on all platforms. ;T;[o;= ;>I" overload;F;?0;:Process::Sys.setregid;@0;:I"$Process::Sys.setregid(rid, eid);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I"rid;T0[I"eid;T0;$@;![;"I"Sets the (group) real and/or effective group IDs of the current process to rid and eid, respectively. A value of -1 for either means to leave that ID unchanged. Not available on all platforms. @overload Process::Sys.setregid(rid, eid) @return [nil];T;#0;$@;.F;C0;%@;9I"static VALUE p_sys_setregid(VALUE obj, VALUE rid, VALUE eid) { rb_gid_t rgid, egid; check_gid_switch(); rgid = OBJ2GID(rid); egid = OBJ2GID(eid); if (setregid(rgid, egid) != 0) rb_sys_fail(0); return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::Sys.setregid;F;7@;@;T;;;0;@;{;IC; "Sets the (group) real and/or effective group IDs of the current process to rid and eid, respectively. A value of -1 for either means to leave that ID unchanged. Not available on all platforms.;T;[o;= ;>I" overload;F;?0;;;@0;:I"$Process::Sys.setregid(rid, eid);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I"rid;T0[I"eid;T0;$@;![;"I"Sets the (group) real and/or effective group IDs of the current process to rid and eid, respectively. A value of -1 for either means to leave that ID unchanged. Not available on all platforms. @overload Process::Sys.setregid(rid, eid) @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i ;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process::Sys#setresuid;F;7[[I"rid;T0[I"eid;T0[I"sid;T0;[[@ i;T;:setresuid;0;[;{;IC; "Sets the (user) real, effective, and saved user IDs of the current process to _rid_, _eid_, and _sid_ respectively. A value of -1 for any value means to leave that ID unchanged. Not available on all platforms. ;T;[o;= ;>I" overload;F;?0;:Process::Sys.setresuid;@0;:I"*Process::Sys.setresuid(rid, eid, sid);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@ ;![;"I"@return [nil];T;#0;$@ ;.F;Bi;C0;7[[I"rid;T0[I"eid;T0[I"sid;T0;$@ ;![;"I"Sets the (user) real, effective, and saved user IDs of the current process to _rid_, _eid_, and _sid_ respectively. A value of -1 for any value means to leave that ID unchanged. Not available on all platforms. @overload Process::Sys.setresuid(rid, eid, sid) @return [nil];T;#0;$@ ;.F;C0;%@;9I"Gstatic VALUE p_sys_setresuid(VALUE obj, VALUE rid, VALUE eid, VALUE sid) { rb_uid_t ruid, euid, suid; PREPARE_GETPWNAM; check_uid_switch(); ruid = OBJ2UID1(rid); euid = OBJ2UID1(eid); suid = OBJ2UID1(sid); FINISH_GETPWNAM; if (setresuid(ruid, euid, suid) != 0) rb_sys_fail(0); return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::Sys.setresuid;F;7@";@);T;;;0;@+;{;IC; "Sets the (user) real, effective, and saved user IDs of the current process to _rid_, _eid_, and _sid_ respectively. A value of -1 for any value means to leave that ID unchanged. Not available on all platforms.;T;[o;= ;>I" overload;F;?0;;;@0;:I"*Process::Sys.setresuid(rid, eid, sid);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@F;![;"I"@return [nil];T;#0;$@F;.F;Bi;C0;7[[I"rid;T0[I"eid;T0[I"sid;T0;$@F;![;"I"!Sets the (user) real, effective, and saved user IDs of the current process to _rid_, _eid_, and _sid_ respectively. A value of -1 for any value means to leave that ID unchanged. Not available on all platforms. @overload Process::Sys.setresuid(rid, eid, sid) @return [nil];T;#0;$@F;.F;/o;0;1T;2i;3i;Bi;%@;9@D;:@E;;To;4;5F;6;;;;&I"Process::Sys#setresgid;F;7[[I"rid;T0[I"eid;T0[I"sid;T0;[[@ i&;T;:setresgid;0;[;{;IC; "Sets the (group) real, effective, and saved user IDs of the current process to rid, eid, and sid respectively. A value of -1 for any value means to leave that ID unchanged. Not available on all platforms. ;T;[o;= ;>I" overload;F;?0;:Process::Sys.setresgid;@0;:I"*Process::Sys.setresgid(rid, eid, sid);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@a;![;"I"@return [nil];T;#0;$@a;.F;Bi;C0;7[[I"rid;T0[I"eid;T0[I"sid;T0;$@a;![;"I"5Sets the (group) real, effective, and saved user IDs of the current process to rid, eid, and sid respectively. A value of -1 for any value means to leave that ID unchanged. Not available on all platforms. @overload Process::Sys.setresgid(rid, eid, sid) @return [nil];T;#0;$@a;.F;C0;%@;9I"static VALUE p_sys_setresgid(VALUE obj, VALUE rid, VALUE eid, VALUE sid) { rb_gid_t rgid, egid, sgid; check_gid_switch(); rgid = OBJ2GID(rid); egid = OBJ2GID(eid); sgid = OBJ2GID(sid); if (setresgid(rgid, egid, sgid) != 0) rb_sys_fail(0); return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::Sys.setresgid;F;7@c;@j;T;;;0;@l;{;IC; "Sets the (group) real, effective, and saved user IDs of the current process to rid, eid, and sid respectively. A value of -1 for any value means to leave that ID unchanged. Not available on all platforms.;T;[o;= ;>I" overload;F;?0;;;@0;:I"*Process::Sys.setresgid(rid, eid, sid);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I"rid;T0[I"eid;T0[I"sid;T0;$@;![;"I"7Sets the (group) real, effective, and saved user IDs of the current process to rid, eid, and sid respectively. A value of -1 for any value means to leave that ID unchanged. Not available on all platforms. @overload Process::Sys.setresgid(rid, eid, sid) @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i#;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process::Sys#issetugid;F;7[;[[@ iC;T;:issetugid;0;[;{;IC; "Returns +true+ if the process was created as a result of an execve(2) system call which had either of the setuid or setgid bits set (and extra privileges were given as a result) or if it has changed any of its real, effective or saved user or group IDs since it began execution. ;T;[o;= ;>I" overload;F;?0;:Process::Sys.issetugid;@0;:I"Process::Sys.issetugid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"LReturns +true+ if the process was created as a result of an execve(2) system call which had either of the setuid or setgid bits set (and extra privileges were given as a result) or if it has changed any of its real, effective or saved user or group IDs since it began execution. @overload Process::Sys.issetugid @return [Boolean];T;#0;$@;.F;C0;%@;9I"}static VALUE p_sys_issetugid(VALUE obj) { if (issetugid()) { return Qtrue; } else { return Qfalse; } };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process::Sys.issetugid;F;7@;@;T;;;0;@;{;IC; "Returns +true+ if the process was created as a result of an execve(2) system call which had either of the setuid or setgid bits set (and extra privileges were given as a result) or if it has changed any of its real, effective or saved user or group IDs since it began execution.;T;[o;= ;>I" overload;F;?0;;;@0;:I"Process::Sys.issetugid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"NReturns +true+ if the process was created as a result of an execve(2) system call which had either of the setuid or setgid bits set (and extra privileges were given as a result) or if it has changed any of its real, effective or saved user or group IDs since it began execution. @overload Process::Sys.issetugid @return [Boolean];T;#0;$@;.F;/o;0;1T;2i7;3i@;Bi;%@;9@;:@;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ i~#;F;:Sys;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I"Process::Sys;Fo;4;5F;6;;;;&I"Process#argv0;F;7[;[[I" ruby.c;Ti ;T;: argv0;0;[;{;IC; "Returns the name of the script being executed. The value is not affected by assigning a new value to $0. This method first appeared in Ruby 2.1 to serve as a global variable free means to get the script name. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" argv0;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the name of the script being executed. The value is not affected by assigning a new value to $0. This method first appeared in Ruby 2.1 to serve as a global variable free means to get the script name. @overload argv0 ;T;#0;$@;.F;C0;%@;9I"Lstatic VALUE proc_argv0(VALUE process) { return rb_orig_progname; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.argv0;F;7@;@;T;;;0;@;{;IC; "Returns the name of the script being executed. The value is not affected by assigning a new value to $0. This method first appeared in Ruby 2.1 to serve as a global variable free means to get the script name.;T;[o;= ;>I" overload;F;?0;;;@0;:I" argv0;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the name of the script being executed. The value is not affected by assigning a new value to $0. This method first appeared in Ruby 2.1 to serve as a global variable free means to get the script name. @overload argv0;T;#0;$@;.F;/o;0;1T;2i ;3i ;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Process#setproctitle;F;7[[I" title;T0;[[@i ;T;:setproctitle;0;[;{;IC; "Sets the process title that appears on the ps(1) command. Not necessarily effective on all platforms. No exception will be raised regardless of the result, nor will NotImplementedError be raised even if the platform does not support the feature. Calling this method does not affect the value of $0. Process.setproctitle('myapp: worker #%d' % worker_id) This method first appeared in Ruby 2.1 to serve as a global variable free means to change the process title. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"setproctitle(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I" string;T0;$@;![;"I"Sets the process title that appears on the ps(1) command. Not necessarily effective on all platforms. No exception will be raised regardless of the result, nor will NotImplementedError be raised even if the platform does not support the feature. Calling this method does not affect the value of $0. Process.setproctitle('myapp: worker #%d' % worker_id) This method first appeared in Ruby 2.1 to serve as a global variable free means to change the process title. @overload setproctitle(string) @return [String];T;#0;$@;.F;C0;%@;9I"hstatic VALUE proc_setproctitle(VALUE process, VALUE title) { return ruby_setproctitle(title); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Process.setproctitle;F;7@;@ ;T;;;0;@ ;{;IC; "Sets the process title that appears on the ps(1) command. Not necessarily effective on all platforms. No exception will be raised regardless of the result, nor will NotImplementedError be raised even if the platform does not support the feature. Calling this method does not affect the value of $0. Process.setproctitle('myapp: worker #%d' % worker_id) This method first appeared in Ruby 2.1 to serve as a global variable free means to change the process title.;T;[o;= ;>I" overload;F;?0;;;@0;:I"setproctitle(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@$;![;"I"@return [String];T;#0;$@$;.F;Bi;C0;7[[I" string;T0;$@$;![;"I" Sets the process title that appears on the ps(1) command. Not necessarily effective on all platforms. No exception will be raised regardless of the result, nor will NotImplementedError be raised even if the platform does not support the feature. Calling this method does not affect the value of $0. Process.setproctitle('myapp: worker #%d' % worker_id) This method first appeared in Ruby 2.1 to serve as a global variable free means to change the process title. @overload setproctitle(string) @return [String];T;#0;$@$;.F;/o;0;1T;2i ;3i ;Bi;%@;9@";:@#;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ i[@ i!;T;;O;;;;;[;{;IC; "The module contains several groups of functionality for handling OS processes: * Low-level property introspection and management of the current process, like Process.argv0, Process.pid; * Low-level introspection of other processes, like Process.getpgid, Process.getpriority; * Management of the current process: Process.abort, Process.exit, Process.daemon, etc. (for convenience, most of those are also available as global functions and module functions of Kernel); * Creation and management of child processes: Process.fork, Process.spawn, and related methods; * Management of low-level system clock: Process.times and Process.clock_gettime, which could be important for proper benchmarking and other elapsed time measurement tasks.;T;[;![;"I" The module contains several groups of functionality for handling OS processes: * Low-level property introspection and management of the current process, like Process.argv0, Process.pid; * Low-level introspection of other processes, like Process.getpgid, Process.getpriority; * Management of the current process: Process.abort, Process.exit, Process.daemon, etc. (for convenience, most of those are also available as global functions and module functions of Kernel); * Creation and management of child processes: Process.fork, Process.spawn, and related methods; * Management of low-level system clock: Process.times and Process.clock_gettime, which could be important for proper benchmarking and other elapsed time measurement tasks. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;&I" Process;Fo; ;IC;[o;4;5F;6;;;;&I"NilClass#to_s;F;7[;[[@I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[;![;"I";T;#0;$@O;.F;Bi;C0;7[;$@O;![;"I"6Always returns the empty string. @overload to_s;T;#0;$@O;.F;/o;0;1T;2i;3i;%@M;9I"VMJIT_FUNC_EXPORTED VALUE rb_nil_to_s(VALUE obj) { return rb_cNilClass_to_s; };T;:I"MJIT_FUNC_EXPORTED VALUE;T;;To;4;5F;6;;;;&I"NilClass#to_a;F;7[;[[@ [] Always returns an empty array. nil.to_a #=> [] ;T;[;![;"I"_ call-seq: nil.to_a -> [] Always returns an empty array. nil.to_a #=> [] ;T;#0;$@e;.F;/o;0;1T;2i;3i;%@M;9I"Dstatic VALUE nil_to_a(VALUE obj) { return rb_ary_new2(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"NilClass#to_h;F;7[;[[@ {} Always returns an empty hash. nil.to_h #=> {} ;T;[;![;"I"^ call-seq: nil.to_h -> {} Always returns an empty hash. nil.to_h #=> {} ;T;#0;$@s;.F;/o;0;1T;2i;3i;%@M;9I"Cstatic VALUE nil_to_h(VALUE obj) { return rb_hash_new(); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"NilClass#inspect;F;7[;[[@I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"9Always returns the string "nil". @overload inspect;T;#0;$@;.F;/o;0;1T;2i ;3i;%@M;9I"Sstatic VALUE nil_inspect(VALUE obj) { return rb_usascii_str_new2("nil"); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"NilClass#=~;F;7[[I" obj2;T0;[[@I" overload;F;?0;;T;@0;:I"=~(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I" other;T0;$@;![;"I"XDummy pattern matching -- always returns nil. @overload =~(other) @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@M;9I"Hstatic VALUE nil_match(VALUE obj1, VALUE obj2) { return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"NilClass#&;F;7[[I" obj2;T0;[[@false. obj is always evaluated as it is the argument to a method call---there is no short-circuit evaluation in this case. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I" &(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" false;T;$@;![;"I"@return [false];T;#0;$@;.F;Bi;C0;7[[I"obj;T0;$@o;= ;>I" overload;F;?0;;E;@0;:I" &(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" false;T;$@;![;"I"@return [false];T;#0;$@;.F;Bi;C0;7[[I"obj;T0;$@;![;"I"And---Returns false. obj is always evaluated as it is the argument to a method call---there is no short-circuit evaluation in this case. @overload &(obj) @return [false] @overload &(obj) @return [false];T;#0;$@;.F;/o;0;1T;2i;3i;%@M;9I"Istatic VALUE false_and(VALUE obj, VALUE obj2) { return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"NilClass#|;F;7[;[;F;:|;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@M;;To;4;5F;6;;;;&I"NilClass#^;F;7[;[;F;:^;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@M;;To;4;5F;6;;;;&I"NilClass#===;F;7[;[;F;;S;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@M;;To;4;5F;6;;;;&I"NilClass#nil?;F;7[;[[@nil responds true to nil?.;T;[o;= ;>I" overload;F;?0;;R;@0;:I" nil?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;T;$@;![;"I"@return [true];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"rOnly the object nil responds true to nil?. @overload nil? @return [true];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@M;9I":static VALUE rb_true(VALUE obj) { return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"NilClass#to_c;F;7[;[[@ i;T;: to_c;0;[;{;IC; "Returns zero as a complex. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_c;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"0Returns zero as a complex. @overload to_c;T;#0;$@;.F;/o;0;1T;2i;3i;%@M;9I"Wstatic VALUE nilclass_to_c(VALUE self) { return rb_complex_new1(INT2FIX(0)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"NilClass#to_r;F;7[;[[@riQ;T;: to_r;0;[;{;IC; " Returns zero as a rational. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_r;T;IC; ";T;[;![;"I";T;#0;$@0;.F;Bi;C0;7[;$@0;![;"I"1Returns zero as a rational. @overload to_r;T;#0;$@0;.F;/o;0;1T;2iK;3iN;%@M;9I"Xstatic VALUE nilclass_to_r(VALUE self) { return rb_rational_new1(INT2FIX(0)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"NilClass#rationalize;F;7[[@90;[[@ri^;T;:rationalize;0;[;{;IC; "PReturns zero as a rational. The optional argument +eps+ is always ignored. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"rationalize([eps]);T;IC; ";T;[;![;"I";T;#0;$@F;.F;Bi;C0;7[[I" [eps];T0;$@F;![;"I"oReturns zero as a rational. The optional argument +eps+ is always ignored. @overload rationalize([eps]);T;#0;$@F;.F;/o;0;1T;2iW;3i[;%@M;9I"static VALUE nilclass_rationalize(int argc, VALUE *argv, VALUE self) { rb_check_arity(argc, 0, 1); return nilclass_to_r(self); };T;:I"static VALUE;T;;T; @M; IC;[; @M; IC;[; @M; IC;{;IC;{;T;IC;{;T;T;{;[;[[@nil.;T;[;![;"I"; The class of the singleton object nil. ;T;#0;$@M;.F;/o;0;1T;2i;3i;Bi;%@;&I" NilClass;F;'@o; ;IC;[ o;4;5F;6;;;;&I"TrueClass#to_s;F;7[;[[@The string representation of true is "true". ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[;![;"I";T;#0;$@s;.F;Bi;C0;7[;$@s;![;"I"OThe string representation of true is "true". @overload to_s;T;#0;$o;4;5F;6;;;;&I"TrueClass#inspect;F;7[;[[@false if obj is nil or false, true otherwise. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I" &(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"obj;T0;$@;![;"I"And---Returns false if obj is nil or false, true otherwise. @overload &(obj) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i=;3iB;%@q;9I"Tstatic VALUE true_and(VALUE obj, VALUE obj2) { return RBOOL(RTEST(obj2)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"TrueClass#|;F;7[[I" obj2;T0;[[@true. As obj is an argument to a method call, it is always evaluated; there is no short-circuit evaluation in this case. true | puts("or") true || puts("logical or") produces: or ;T;[o;= ;>I" overload;F;?0;;;@0;:I" |(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;T;$@;![;"I"@return [true];T;#0;$@;.F;Bi;C0;7[[I"obj;T0;$@;![;"I" Or---Returns true. As obj is an argument to a method call, it is always evaluated; there is no short-circuit evaluation in this case. true | puts("or") true || puts("logical or") produces: or @overload |(obj) @return [true];T;#0;$@;.F;/o;0;1T;2iK;3iX;%@q;9I"Fstatic VALUE true_or(VALUE obj, VALUE obj2) { return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"TrueClass#^;F;7[[I" obj2;T0;[[@true if obj is nil or false, false otherwise. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" ^(obj);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"obj;T0;$@;![;"I"Exclusive Or---Returns true if obj is nil or false, false otherwise. @overload ^(obj);T;#0;$@;.F;/o;0;1T;2ib;3ig;%@q;9I"Zstatic VALUE true_xor(VALUE obj, VALUE obj2) { return RTEST(obj2)?Qfalse:Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"TrueClass#===;F;7[;[;F;;S;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@q;;T; @q; IC;[; @q; IC;[; @q; IC;{;IC;{;T;IC;{;T;T;{@;G;[;[[@true is the only instance of class TrueClass and represents a logically true value in boolean expressions. The class provides operators allowing true to be used in logical expressions.;T;[;![;"I"3********************************************************************* The global value true is the only instance of class TrueClass and represents a logically true value in boolean expressions. The class provides operators allowing true to be used in logical expressions. ;T;#0;$@q;.F;/o;0;1T;2i%;3i+;Bi;%@;&I"TrueClass;F;'@o; ;IC;[ o;4;5F;6;;;;&I"FalseClass#to_s;F;7[;[[@false is "false". ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"QThe string representation of false is "false". @overload to_s;T;#0;$o;4;5F;6;;;;&I"FalseClass#inspect;F;7[;[[@false. obj is always evaluated as it is the argument to a method call---there is no short-circuit evaluation in this case. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I" &(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" false;T;$@$;![;"I"@return [false];T;#0;$@$;.F;Bi;C0;7[[I"obj;T0;$@$o;= ;>I" overload;F;?0;;E;@0;:I" &(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" false;T;$@$;![;"I"@return [false];T;#0;$@$;.F;Bi;C0;7[[I"obj;T0;$@$;![;"@;#0;$@$;.F;/o;0;1T;2i;3i;%@;9I"Istatic VALUE false_and(VALUE obj, VALUE obj2) { return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"FalseClass#|;F;7[;[;F;;;;;[;{;IC; " ;T;[;![;"@;#0;$@Q;%@;;To;4;5F;6;;;;&I"FalseClass#^;F;7[;[;F;;;;;[;{;IC; " ;T;[;![;"@;#0;$@Z;%@;;To;4;5F;6;;;;&I"FalseClass#===;F;7[;[;F;;S;;;[;{;IC; " ;T;[;![;"@;#0;$@c;%@;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{@;G;[;[[@false is the only instance of class FalseClass and represents a logically false value in boolean expressions. The class provides operators allowing false to participate correctly in logical expressions.;T;[;![;"I" The global value false is the only instance of class FalseClass and represents a logically false value in boolean expressions. The class provides operators allowing false to participate correctly in logical expressions. ;T;#0;$@;.F;/o;0;1T;2ir;3ix;Bi;%@;&I"FalseClass;F;'@o; ;IC;[ o;4;5F;6;;;;&I"Class#inherited;F;7[;[;F;:inherited;;;[;{;IC; "Ncall-seq: inherited(subclass) Callback invoked whenever a subclass of the current class is created. Example: class Foo def self.inherited(subclass) puts "New subclass: #{subclass}" end end class Bar < Foo end class Baz < Bar end produces: New subclass: Bar New subclass: Baz ;T;[;![;"I"P call-seq: inherited(subclass) Callback invoked whenever a subclass of the current class is created. Example: class Foo def self.inherited(subclass) puts "New subclass: #{subclass}" end end class Bar < Foo end class Baz < Bar end produces: New subclass: Bar New subclass: Baz ;T;#0;$@;.F;/o;0;1T;2i5;3iM;%@~;;To;4;5F;6;;;;&I"Class#allocate;F;7[;[[@class's class and does not call initialize on the new instance. The returned object must be an instance of class. klass = Class.new do def initialize(*args) @initialized = true end def initialized? @initialized || false end end klass.allocate.initialized? #=> false ;T;[o;= ;>I" overload;F;?0;;;@0;:I"allocate();T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Allocates space for a new object of class's class and does not call initialize on the new instance. The returned object must be an instance of class. klass = Class.new do def initialize(*args) @initialized = true end def initialized? @initialized || false end end klass.allocate.initialized? #=> false @overload allocate() @return [Object];T;#0;$@;.F;/o;0;1T;2ig;3iz;%@~;9I"Lstatic VALUE rb_class_alloc_m(VALUE klass) { rb_alloc_func_t allocator = class_get_alloc_func(klass); if (!rb_obj_respond_to(klass, rb_intern("allocate"), 1)) { rb_raise(rb_eTypeError, "calling %"PRIsVALUE".allocate is prohibited", klass); } return class_call_alloc_func(allocator, klass); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Class#new;F;7[[@90;[[@class's class, then invokes that object's #initialize method, passing it args. This is the method that ends up getting called whenever an object is constructed using .new. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(args, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I" args;T0[I"...;T0;$@;![;"I" Calls #allocate to create a new object of class's class, then invokes that object's #initialize method, passing it args. This is the method that ends up getting called whenever an object is constructed using .new. @overload new(args, ...) @return [Object];T;#0;$@;.F;/o;0;1T;2i;3i;%@~;9I"VALUE rb_class_new_instance_pass_kw(int argc, const VALUE *argv, VALUE klass) { VALUE obj; obj = rb_class_alloc(klass); rb_obj_call_init_kw(obj, argc, argv, RB_PASS_CALLED_KEYWORDS); return obj; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Class#initialize;F;7[[@90;[[@ #<#:0x100376b98> a.meth1 #=> "hello" a.meth2 #=> "bye" Assign the class to a constant (name starting uppercase) if you want to treat it like a regular class. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(super_class=Object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Class;T;$@;![;"I"@return [Class];T;#0;$@;.F;Bi;C0;7[[I"super_class;TI" Object;T;$@o;= ;>I" overload;F;?0;;E;@0;:I"new(super_class=Object);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"mod;T;$@o;A ;>I" return;F;?I";T;0;@[I" Class;T;$@;![;"I"!@yield [mod] @return [Class];T;#0;$@;.F;Bi;C0;7[[I"super_class;TI" Object;T;$@;![;"I"Creates a new anonymous (unnamed) class with the given superclass (or Object if no parameter is given). You can give a class a name by assigning the class object to a constant. If a block is given, it is passed the class object, and the block is evaluated in the context of this class like #class_eval. fred = Class.new do def meth1 "hello" end def meth2 "bye" end end a = fred.new #=> #<#:0x100376b98> a.meth1 #=> "hello" a.meth2 #=> "bye" Assign the class to a constant (name starting uppercase) if you want to treat it like a regular class. @overload new(super_class=Object) @return [Class] @overload new(super_class=Object) @yield [mod] @return [Class];T;#0;$@;.F;/o;0;1T;2i$;3iA;%@~;9I"static VALUE rb_class_initialize(int argc, VALUE *argv, VALUE klass) { VALUE super; if (RCLASS_SUPER(klass) != 0 || klass == rb_cBasicObject) { rb_raise(rb_eTypeError, "already initialized class"); } if (rb_check_arity(argc, 0, 1) == 0) { super = rb_cObject; } else { super = argv[0]; rb_check_inheritable(super); if (super != rb_cBasicObject && !RCLASS_SUPER(super)) { rb_raise(rb_eTypeError, "can't inherit uninitialized class"); } } RCLASS_SET_SUPER(klass, super); rb_make_metaclass(klass, RBASIC(super)->klass); rb_class_inherited(super, klass); rb_mod_initialize_exec(klass); return klass; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Class#superclass;F;7[;[[@class, or nil. File.superclass #=> IO IO.superclass #=> Object Object.superclass #=> BasicObject class Foo; end class Bar < Foo; end Bar.superclass #=> Foo Returns nil when the given class does not have a parent class: BasicObject.superclass #=> nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I"superclass;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the superclass of class, or nil. File.superclass #=> IO IO.superclass #=> Object Object.superclass #=> BasicObject class Foo; end class Bar < Foo; end Bar.superclass #=> Foo Returns nil when the given class does not have a parent class: BasicObject.superclass #=> nil @overload superclass @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@~;9I"LVALUE rb_class_superclass(VALUE klass) { VALUE super = RCLASS_SUPER(klass); if (!super) { if (klass == rb_cBasicObject) return Qnil; rb_raise(rb_eTypeError, "uninitialized class"); } while (RB_TYPE_P(super, T_ICLASS)) { super = RCLASS_SUPER(super); } if (!super) { return Qnil; } return super; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Class#subclasses;F;7[;[[@ni;T;:subclasses;0;[;{;IC; "OReturns an array of classes where the receiver is the direct superclass of the class, excluding singleton classes. The order of the returned array is not defined. class A; end class B < A; end class C < B; end class D < A; end A.subclasses #=> [D, B] B.subclasses #=> [C] C.subclasses #=> [] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"subclasses;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"xReturns an array of classes where the receiver is the direct superclass of the class, excluding singleton classes. The order of the returned array is not defined. class A; end class B < A; end class C < B; end class D < A; end A.subclasses #=> [D, B] B.subclasses #=> [C] C.subclasses #=> [] @overload subclasses @return [Array];T;#0;$@;.F;/o;0;1T;2i;3i;%@~;9I"ZVALUE rb_class_subclasses(VALUE klass) { return class_descendants(klass, true); };T;:I" VALUE;T;;T; @~; IC;[; @~; IC;[; @~; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Name.new is called to create a new object, the #new method in Class is run by default. This can be demonstrated by overriding #new in Class: class Class alias old_new new def new(*args) print "Creating a new ", self.name, "\n" old_new(*args) end end class Name end n = Name.new produces: Creating a new Name Classes, modules, and objects are interrelated. In the diagram that follows, the vertical arrows represent inheritance, and the parentheses metaclasses. All metaclasses are instances of the class `Class'. +---------+ +-... | | | BasicObject-----|-->(BasicObject)-------|-... ^ | ^ | | | | | Object---------|----->(Object)---------|-... ^ | ^ | | | | | +-------+ | +--------+ | | | | | | | | Module-|---------|--->(Module)-|-... | ^ | | ^ | | | | | | | | Class-|---------|---->(Class)-|-... | ^ | | ^ | | +---+ | +----+ | | obj--->OtherClass---------->(OtherClass)-----------...;T;[;![;"I"P Classes in Ruby are first-class objects---each is an instance of class Class. Typically, you create a new class by using: class Name # some code describing the class behavior end When a new class is created, an object of type Class is initialized and assigned to a global constant (Name in this case). When Name.new is called to create a new object, the #new method in Class is run by default. This can be demonstrated by overriding #new in Class: class Class alias old_new new def new(*args) print "Creating a new ", self.name, "\n" old_new(*args) end end class Name end n = Name.new produces: Creating a new Name Classes, modules, and objects are interrelated. In the diagram that follows, the vertical arrows represent inheritance, and the parentheses metaclasses. All metaclasses are instances of the class `Class'. +---------+ +-... | | | BasicObject-----|-->(BasicObject)-------|-... ^ | ^ | | | | | Object---------|----->(Object)---------|-... ^ | ^ | | | | | +-------+ | +--------+ | | | | | | | | Module-|---------|--->(Module)-|-... | ^ | | ^ | | | | | | | | Class-|---------|---->(Class)-|-... | ^ | | ^ | | +---+ | +----+ | | obj--->OtherClass---------->(OtherClass)-----------... ;T;#0;$@~;.F;/o;0;1T;2i;3i6;Bi;%@;&I" Class;F;'@A7@o; ;IC;[o;4;5F;6;;;;&I"Refinement#import_methods;T;7[[@90;[[@ni;T;:import_methods;0;[;{;IC; "call-seq: import_methods(module, ...) -> self Imports methods from modules. Unlike Module#include, Refinement#import_methods copies methods and adds them into the refinement, so the refinement is activated in the imported methods. Note that due to method copying, only methods defined in Ruby code can be imported. module StrUtils def indent(level) ' ' * level + self end end module M refine String do import_methods StrUtils end end using M "foo".indent(3) #=> " foo" module M refine String do import_methods Enumerable # Can't import method which is not defined with Ruby code: Enumerable#drop end end ;T;[;![;"I" call-seq: import_methods(module, ...) -> self Imports methods from modules. Unlike Module#include, Refinement#import_methods copies methods and adds them into the refinement, so the refinement is activated in the imported methods. Note that due to method copying, only methods defined in Ruby code can be imported. module StrUtils def indent(level) ' ' * level + self end end module M refine String do import_methods StrUtils end end using M "foo".indent(3) #=> " foo" module M refine String do import_methods Enumerable # Can't import method which is not defined with Ruby code: Enumerable#drop end end ;T;#0;$@E;.F;/o;0;1T;2i;3i;%o;( ;)0;*0;+0;:Refinement;%@;-@C;0;9I"Xstatic VALUE refinement_import_methods(int argc, VALUE *argv, VALUE refinement) { };T;:I"static VALUE;T;;T; @C; IC;[; @C; IC;[; @C; IC;{;IC;{;T;IC;{;T;T;{;[;[ [@ {:foo=>0, :bar=>1, :baz=>2} When the single given argument is an \Array of 2-element Arrays, returns a new \Hash object wherein each 2-element array forms a key-value entry: Hash[ [ [:foo, 0], [:bar, 1] ] ] # => {:foo=>0, :bar=>1} When the argument count is an even number; returns a new \Hash object wherein each successive pair of arguments has become a key-value entry: Hash[:foo, 0, :bar, 1] # => {:foo=>0, :bar=>1} Raises an exception if the argument list does not conform to any of the above. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I" Hash[];T;IC; ";T;[;![;"I";T;#0;$@l;.F;Bi;C0;7[;$@lo;= ;>I" overload;F;?0;;;@0;:I" [](hash);T;IC; ";T;[;![;"I";T;#0;$@l;.F;Bi;C0;7[[I" hash;T0;$@lo;= ;>I" overload;F;?0;;;@0;:I"[]( [*2_element_arrays);T;IC; ";T;[;![;"I";T;#0;$@l;.F;Bi;C0;7[[I"[*2_element_arrays);T0;$@lo;= ;>I" overload;F;?0;;;@0;:I"[](*objects);T;IC; ";T;[;![;"I";T;#0;$@l;.F;Bi;C0;7[[I" *objects;T0;$@l;![;"I"Returns a new \Hash object populated with the given objects, if any. See Hash::new. With no argument, returns a new empty \Hash. When the single given argument is a \Hash, returns a new \Hash populated with the entries from the given \Hash, excluding the default value or proc. h = {foo: 0, bar: 1, baz: 2} Hash[h] # => {:foo=>0, :bar=>1, :baz=>2} When the single given argument is an \Array of 2-element Arrays, returns a new \Hash object wherein each 2-element array forms a key-value entry: Hash[ [ [:foo, 0], [:bar, 1] ] ] # => {:foo=>0, :bar=>1} When the argument count is an even number; returns a new \Hash object wherein each successive pair of arguments has become a key-value entry: Hash[:foo, 0, :bar, 1] # => {:foo=>0, :bar=>1} Raises an exception if the argument list does not conform to any of the above. @overload Hash[] @overload [](hash) @overload []( [*2_element_arrays) @overload [](*objects);T;#0;$@l;.F;/o;0;1T;2i;3i2;%@j;9I"static VALUE rb_hash_s_create(int argc, VALUE *argv, VALUE klass) { VALUE hash, tmp; if (argc == 1) { tmp = rb_hash_s_try_convert(Qnil, argv[0]); if (!NIL_P(tmp)) { hash = hash_alloc(klass); hash_copy(hash, tmp); return hash; } tmp = rb_check_array_type(argv[0]); if (!NIL_P(tmp)) { long i; hash = hash_alloc(klass); for (i = 0; i < RARRAY_LEN(tmp); ++i) { VALUE e = RARRAY_AREF(tmp, i); VALUE v = rb_check_array_type(e); VALUE key, val = Qnil; if (NIL_P(v)) { rb_raise(rb_eArgError, "wrong element type %s at %ld (expected array)", rb_builtin_class_name(e), i); } switch (RARRAY_LEN(v)) { default: rb_raise(rb_eArgError, "invalid number of elements (%ld for 1..2)", RARRAY_LEN(v)); case 2: val = RARRAY_AREF(v, 1); case 1: key = RARRAY_AREF(v, 0); rb_hash_aset(hash, key, val); } } return hash; } } if (argc % 2 != 0) { rb_raise(rb_eArgError, "odd number of arguments for Hash"); } hash = hash_alloc(klass); rb_hash_bulk_insert(argc, argv, hash); hash_verify(hash); return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash.try_convert;F;7[[I" hash;T0;[[@i;T;;v;0;[;{;IC; "If +obj+ is a \Hash object, returns +obj+. Otherwise if +obj+ responds to :to_hash, calls obj.to_hash and returns the result. Returns +nil+ if +obj+ does not respond to :to_hash Raises an exception unless obj.to_hash returns a \Hash object. ;T;[o;= ;>I" overload;F;?0;;v;@0;:I"try_convert(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@;![;"I"@return [Object, nil];T;#0;$@;.F;Bi;C0;7[[I"obj;T0;$@;![;"I"LIf +obj+ is a \Hash object, returns +obj+. Otherwise if +obj+ responds to :to_hash, calls obj.to_hash and returns the result. Returns +nil+ if +obj+ does not respond to :to_hash Raises an exception unless obj.to_hash returns a \Hash object. @overload try_convert(obj) @return [Object, nil];T;#0;$@;.F;/o;0;1T;2iv;3i;%@j;9I"istatic VALUE rb_hash_s_try_convert(VALUE dummy, VALUE hash) { return rb_check_hash_type(hash); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#initialize;F;7[[@90;[[@i;T;;D;0;[;{;IC; "rReturns a new empty \Hash object. The initial default value and initial default proc for the new hash depend on which form above was used. See {Default Values}[#class-Hash-label-Default+Values]. If neither an argument nor a block given, initializes both the default value and the default proc to nil: h = Hash.new h.default # => nil h.default_proc # => nil If argument default_value given but no block given, initializes the default value to the given default_value and the default proc to nil: h = Hash.new(false) h.default # => false h.default_proc # => nil If a block given but no argument, stores the block as the default proc and sets the default value to nil: h = Hash.new {|hash, key| "Default value for #{key}" } h.default # => nil h.default_proc.class # => Proc h[:nosuch] # => "Default value for nosuch" ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(default_value = nil);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"default_value;TI"nil;T;$@o;= ;>I" overload;F;?0;;E;@0;:I"new;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" hash;TI"key;T;$@;![;"I"@yield [hash, key];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a new empty \Hash object. The initial default value and initial default proc for the new hash depend on which form above was used. See {Default Values}[#class-Hash-label-Default+Values]. If neither an argument nor a block given, initializes both the default value and the default proc to nil: h = Hash.new h.default # => nil h.default_proc # => nil If argument default_value given but no block given, initializes the default value to the given default_value and the default proc to nil: h = Hash.new(false) h.default # => false h.default_proc # => nil If a block given but no argument, stores the block as the default proc and sets the default value to nil: h = Hash.new {|hash, key| "Default value for #{key}" } h.default # => nil h.default_proc.class # => Proc h[:nosuch] # => "Default value for nosuch" @overload new(default_value = nil) @overload new @yield [hash, key];T;#0;$@;.F;/o;0;1T;2i;3i;%@j;9I"wstatic VALUE rb_hash_initialize(int argc, VALUE *argv, VALUE hash) { VALUE ifnone; rb_hash_modify(hash); if (rb_block_given_p()) { rb_check_arity(argc, 0, 0); ifnone = rb_block_proc(); SET_PROC_DEFAULT(hash, ifnone); } else { rb_check_arity(argc, 0, 1); ifnone = argc == 0 ? Qnil : argv[0]; RHASH_SET_IFNONE(hash, ifnone); } return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#initialize_copy;F;7[[I" hash2;T0;[[@i~ ;T;;];0;[;{;IC; "Replaces the entire contents of +self+ with the contents of +other_hash+; returns +self+: h = {foo: 0, bar: 1, baz: 2} h.replace({bat: 3, bam: 4}) # => {:bat=>3, :bam=>4} ;T;[o;= ;>I" overload;F;?0;: replace;@0;:I"replace(other_hash);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[[I"other_hash;T0;$@;![;"I"Replaces the entire contents of +self+ with the contents of +other_hash+; returns +self+: h = {foo: 0, bar: 1, baz: 2} h.replace({bat: 3, bam: 4}) # => {:bat=>3, :bam=>4} @overload replace(other_hash) @return [self];T;#0;$@;.F;/o;0;1T;2it ;3i{ ;%@j;9I"static VALUE rb_hash_replace(VALUE hash, VALUE hash2) { rb_hash_modify_check(hash); if (hash == hash2) return hash; if (RHASH_ITER_LEV(hash) > 0) { rb_raise(rb_eRuntimeError, "can't replace hash during iteration"); } hash2 = to_hash(hash2); COPY_DEFAULT(hash, hash2); if (RHASH_AR_TABLE_P(hash)) { ar_free_and_clear_table(hash); } else { st_free_table(RHASH_ST_TABLE(hash)); RHASH_ST_CLEAR(hash); } hash_copy(hash, hash2); if (RHASH_EMPTY_P(hash2) && RHASH_ST_TABLE_P(hash2)) { /* ident hash */ RHASH_ST_TABLE_SET(hash, st_init_table_with_size(RHASH_TYPE(hash2), 0)); } rb_gc_writebarrier_remember(hash); return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#rehash;F;7[;[[@i;T;: rehash;0;[;{;IC; "Rebuilds the hash table by recomputing the hash index for each key; returns self. The hash table becomes invalid if the hash value of a key has changed after the entry was created. See {Modifying an Active Hash Key}[#class-Hash-label-Modifying+an+Active+Hash+Key]. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" rehash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"6Rebuilds the hash table by recomputing the hash index for each key; returns self. The hash table becomes invalid if the hash value of a key has changed after the entry was created. See {Modifying an Active Hash Key}[#class-Hash-label-Modifying+an+Active+Hash+Key]. @overload rehash @return [self];T;#0;$@;.F;/o;0;1T;2i;3i;%@j;9I"VALUE rb_hash_rehash(VALUE hash) { VALUE tmp; st_table *tbl; if (RHASH_ITER_LEV(hash) > 0) { rb_raise(rb_eRuntimeError, "rehash during iteration"); } rb_hash_modify_check(hash); if (RHASH_AR_TABLE_P(hash)) { tmp = hash_alloc(0); ar_alloc_table(tmp); rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tmp); ar_free_and_clear_table(hash); ar_copy(hash, tmp); ar_free_and_clear_table(tmp); } else if (RHASH_ST_TABLE_P(hash)) { st_table *old_tab = RHASH_ST_TABLE(hash); tmp = hash_alloc(0); tbl = st_init_table_with_size(old_tab->type, old_tab->num_entries); RHASH_ST_TABLE_SET(tmp, tbl); rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tmp); st_free_table(old_tab); RHASH_ST_TABLE_SET(hash, tbl); RHASH_ST_CLEAR(tmp); } hash_verify(hash); return hash; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Hash#to_hash;F;7[;[[@i ;T;: to_hash;0;[;{;IC; "Returns +self+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_hash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@#;![;"I"@return [self];T;#0;$@#;.F;Bi;C0;7[;$@#;![;"I"9Returns +self+. @overload to_hash @return [self];T;#0;$@#;.F;/o;0;1T;2i ;3i ;%@j;9I"Bstatic VALUE rb_hash_to_hash(VALUE hash) { return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#to_h;F;7[;[[@i ;T;;;0;[;{;IC; "For an instance of \Hash, returns +self+. For a subclass of \Hash, returns a new \Hash containing the content of +self+. When a block is given, returns a new \Hash object whose content is based on the block; the block should return a 2-element \Array object specifying the key-value pair to be included in the returned \Array: h = {foo: 0, bar: 1, baz: 2} h1 = h.to_h {|key, value| [value, key] } h1 # => {0=>:foo, 1=>:bar, 2=>:baz} ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_h;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@>;![;"I"@return [self];T;#0;$@>;.F;Bi;C0;7[;$@>o;= ;>I" overload;F;?0;;;@0;:I" to_h;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;TI" value;T;$@>;![;"I"@yield [key, value];T;#0;$@>;.F;Bi;C0;7[;$@>;![;"I"For an instance of \Hash, returns +self+. For a subclass of \Hash, returns a new \Hash containing the content of +self+. When a block is given, returns a new \Hash object whose content is based on the block; the block should return a 2-element \Array object specifying the key-value pair to be included in the returned \Array: h = {foo: 0, bar: 1, baz: 2} h1 = h.to_h {|key, value| [value, key] } h1 # => {0=>:foo, 1=>:bar, 2=>:baz} @overload to_h @return [self] @overload to_h @yield [key, value];T;#0;$@>;.F;/o;0;1T;2i ;3i ;%@j;9I"&static VALUE rb_hash_to_h(VALUE hash) { if (rb_block_given_p()) { return rb_hash_to_h_block(hash); } if (rb_obj_class(hash) != rb_cHash) { const VALUE flags = RBASIC(hash)->flags; hash = hash_dup(hash, rb_cHash, flags & RHASH_PROC_DEFAULT); } return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#to_a;F;7[;[[@iC ;T;;;0;[;{;IC; "Returns a new \Array of 2-element \Array objects; each nested \Array contains a key-value pair from +self+: h = {foo: 0, bar: 1, baz: 2} h.to_a # => [[:foo, 0], [:bar, 1], [:baz, 2]] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_a;T;IC; ";T;[;![;"I";T;#0;$@g;.F;Bi;C0;7[;$@g;![;"I"Returns a new \Array of 2-element \Array objects; each nested \Array contains a key-value pair from +self+: h = {foo: 0, bar: 1, baz: 2} h.to_a # => [[:foo, 0], [:bar, 1], [:baz, 2]] @overload to_a;T;#0;$@g;.F;/o;0;1T;2i9 ;3i? ;%@j;9I"static VALUE rb_hash_to_a(VALUE hash) { VALUE ary; ary = rb_ary_new_capa(RHASH_SIZE(hash)); rb_hash_foreach(hash, to_a_i, ary); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#inspect;F;7[;[[@iz ;T;;J;0;[;{;IC; "Returns a new \String containing the hash entries: h = {foo: 0, bar: 1, baz: 2} h.inspect # => "{:foo=>0, :bar=>1, :baz=>2}" Hash#to_s is an alias for Hash#inspect. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[;![;"I";T;#0;$@};.F;Bi;C0;7[;$@};![;"I"Returns a new \String containing the hash entries: h = {foo: 0, bar: 1, baz: 2} h.inspect # => "{:foo=>0, :bar=>1, :baz=>2}" Hash#to_s is an alias for Hash#inspect. @overload inspect;T;#0;$o;4;5F;6;;;;&I"Hash#to_s;F;7[;[[@i;F;;G;;;[;{;@;%@j;9I"static VALUE rb_hash_inspect(VALUE hash) { if (RHASH_EMPTY_P(hash)) return rb_usascii_str_new2("{}"); return rb_exec_recursive(inspect_hash, hash, 0); };T;:I"static VALUE;T;.F;/o;0;1T;2io ;3iv ;%@j;9I"static VALUE rb_hash_inspect(VALUE hash) { if (RHASH_EMPTY_P(hash)) return rb_usascii_str_new2("{}"); return rb_exec_recursive(inspect_hash, hash, 0); };T;:@;;T@o;4;5F;6;;;;&I"Hash#to_proc;F;7[;[[@iT;T;: to_proc;0;[;{;IC; "Returns a \Proc object that maps a key to its value: h = {foo: 0, bar: 1, baz: 2} proc = h.to_proc proc.class # => Proc proc.call(:foo) # => 0 proc.call(:bar) # => 1 proc.call(:nosuch) # => nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_proc;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@;![;"I"@return [Proc];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a \Proc object that maps a key to its value: h = {foo: 0, bar: 1, baz: 2} proc = h.to_proc proc.class # => Proc proc.call(:foo) # => 0 proc.call(:bar) # => 1 proc.call(:nosuch) # => nil @overload to_proc @return [Proc];T;#0;$@;.F;/o;0;1T;2iH;3iR;%@j;9I"lstatic VALUE rb_hash_to_proc(VALUE hash) { return rb_func_lambda_new(hash_proc_call, hash, 1, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Hash#==;F;7[[I" hash2;T0;[[@i;T;;F;0;[;{;IC; "vReturns +true+ if all of the following are true: * +object+ is a \Hash object. * +hash+ and +object+ have the same keys (regardless of order). * For each key +key+, hash[key] == object[key]. Otherwise, returns +false+. Equal: h1 = {foo: 0, bar: 1, baz: 2} h2 = {foo: 0, bar: 1, baz: 2} h1 == h2 # => true h3 = {baz: 2, bar: 1, foo: 0} h1 == h3 # => true ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" object;T0;$@;![;"I"Returns +true+ if all of the following are true: * +object+ is a \Hash object. * +hash+ and +object+ have the same keys (regardless of order). * For each key +key+, hash[key] == object[key]. Otherwise, returns +false+. Equal: h1 = {foo: 0, bar: 1, baz: 2} h2 = {foo: 0, bar: 1, baz: 2} h1 == h2 # => true h3 = {baz: 2, bar: 1, foo: 0} h1 == h3 # => true @overload ==(object) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;%@j;9I"istatic VALUE rb_hash_equal(VALUE hash1, VALUE hash2) { return hash_equal(hash1, hash2, FALSE); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Hash#[];F;7[[I"key;T0;[[@i*;T;;;0;[;{;IC; " Returns the value associated with the given +key+, if found: h = {foo: 0, bar: 1, baz: 2} h[:foo] # => 0 If +key+ is not found, returns a default value (see {Default Values}[#class-Hash-label-Default+Values]): h = {foo: 0, bar: 1, baz: 2} h[:nosuch] # => nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I" [](key);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"key;T0;$@;![;"I"Returns the value associated with the given +key+, if found: h = {foo: 0, bar: 1, baz: 2} h[:foo] # => 0 If +key+ is not found, returns a default value (see {Default Values}[#class-Hash-label-Default+Values]): h = {foo: 0, bar: 1, baz: 2} h[:nosuch] # => nil @overload [](key);T;#0;$@;.F;/o;0;1T;2i;3i&;%@j;9I"VALUE rb_hash_aref(VALUE hash, VALUE key) { st_data_t val; if (hash_stlike_lookup(hash, key, &val)) { return (VALUE)val; } else { return rb_hash_default_value(hash, key); } };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Hash#hash;F;7[;[[@i;T;;X;0;[;{;IC; "Returns the \Integer hash-code for the hash. Two \Hash objects have the same hash-code if their content is the same (regardless or order): h1 = {foo: 0, bar: 1, baz: 2} h2 = {baz: 2, bar: 1, foo: 0} h2.hash == h1.hash # => true h2.eql? h1 # => true ;T;[o;= ;>I" overload;F;?0;;X;@0;:I" hash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"&Returns the \Integer hash-code for the hash. Two \Hash objects have the same hash-code if their content is the same (regardless or order): h1 = {foo: 0, bar: 1, baz: 2} h2 = {baz: 2, bar: 1, foo: 0} h2.hash == h1.hash # => true h2.eql? h1 # => true @overload hash @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@j;9I"0static VALUE rb_hash_hash(VALUE hash) { st_index_t size = RHASH_SIZE(hash); st_index_t hval = rb_hash_start(size); hval = rb_hash_uint(hval, (st_index_t)rb_hash_hash); if (size) { rb_hash_foreach(hash, hash_i, (VALUE)&hval); } hval = rb_hash_end(hval); return ST2FIX(hval); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#eql?;F;7[[I" hash2;T0;[[@i;T;;V;0;[;{;IC; "yReturns +true+ if all of the following are true: * +object+ is a \Hash object. * +hash+ and +object+ have the same keys (regardless of order). * For each key +key+, h[key] eql? object[key]. Otherwise, returns +false+. Equal: h1 = {foo: 0, bar: 1, baz: 2} h2 = {foo: 0, bar: 1, baz: 2} h1.eql? h2 # => true h3 = {baz: 2, bar: 1, foo: 0} h1.eql? h3 # => true;T;[o;= ;>I" overload;F;?0;;V;@0;:I"eql? object;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ ;![;"I"@return [Boolean];T;#0;$@ ;.F;Bi;C0;7[[I" object;T0;$@ ;![;"I"Returns +true+ if all of the following are true: * +object+ is a \Hash object. * +hash+ and +object+ have the same keys (regardless of order). * For each key +key+, h[key] eql? object[key]. Otherwise, returns +false+. Equal: h1 = {foo: 0, bar: 1, baz: 2} h2 = {foo: 0, bar: 1, baz: 2} h1.eql? h2 # => true h3 = {baz: 2, bar: 1, foo: 0} h1.eql? h3 # => true @overload eql? object @return [Boolean];T;#0;$@ ;.F;/o;0;1T;2i;3i;Bi;%@j;9I"fstatic VALUE rb_hash_eql(VALUE hash1, VALUE hash2) { return hash_equal(hash1, hash2, TRUE); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#fetch;F;7[[@90;[[@ia;T;;9;0;[;{;IC; " Returns the value for the given +key+, if found. h = {foo: 0, bar: 1, baz: 2} h.fetch(:bar) # => 1 If +key+ is not found and no block was given, returns +default_value+: {}.fetch(:nosuch, :default) # => :default If +key+ is not found and a block was given, yields +key+ to the block and returns the block's return value: {}.fetch(:nosuch) {|key| "No key #{key}"} # => "No key nosuch" Raises KeyError if neither +default_value+ nor a block was given. Note that this method does not use the values of either #default or #default_proc. ;T;[o;= ;>I" overload;F;?0;;9;@0;:I"fetch(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@);![;"I"@return [Object];T;#0;$@);.F;Bi;C0;7[[I"key;T0;$@)o;= ;>I" overload;F;?0;;9;@0;:I"fetch(key, default_value);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@);![;"I"@return [Object];T;#0;$@);.F;Bi;C0;7[[I"key;T0[I"default_value;T0;$@)o;= ;>I" overload;F;?0;;9;@0;:I"fetch(key);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;T;$@)o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@);![;"I""@yield [key] @return [Object];T;#0;$@);.F;Bi;C0;7[[I"key;T0;$@);![;"I"Returns the value for the given +key+, if found. h = {foo: 0, bar: 1, baz: 2} h.fetch(:bar) # => 1 If +key+ is not found and no block was given, returns +default_value+: {}.fetch(:nosuch, :default) # => :default If +key+ is not found and a block was given, yields +key+ to the block and returns the block's return value: {}.fetch(:nosuch) {|key| "No key #{key}"} # => "No key nosuch" Raises KeyError if neither +default_value+ nor a block was given. Note that this method does not use the values of either #default or #default_proc. @overload fetch(key) @return [Object] @overload fetch(key, default_value) @return [Object] @overload fetch(key) @yield [key] @return [Object];T;#0;$@);.F;/o;0;1T;2iJ;3ia;%@j;9I"Qstatic VALUE rb_hash_fetch_m(int argc, VALUE *argv, VALUE hash) { VALUE key; st_data_t val; long block_given; rb_check_arity(argc, 1, 2); key = argv[0]; block_given = rb_block_given_p(); if (block_given && argc == 2) { rb_warn("block supersedes default value argument"); } if (hash_stlike_lookup(hash, key, &val)) { return (VALUE)val; } else { if (block_given) { return rb_yield(key); } else if (argc == 1) { VALUE desc = rb_protect(rb_inspect, key, 0); if (NIL_P(desc)) { desc = rb_any_to_s(key); } desc = rb_str_ellipsize(desc, 65); rb_key_err_raise(rb_sprintf("key not found: %"PRIsVALUE, desc), hash, key); } else { return argv[1]; } } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Hash#[]=;F;7[;[;F;;8;;;[;{;IC; " ;T;[;![;"@;#0;$@l;%@j;;To;4;5F;6;;;;&I"Hash#store;F;7[;[;F;: store;;;[;{;IC; " ;T;[;![;"@;#0;$@u;%@j;;To;4;5F;6;;;;&I"Hash#default;F;7[[@90;[[@i;T;: default;0;[;{;IC; "Returns the default value for the given +key+. The returned value will be determined either by the default proc or by the default value. See {Default Values}[#class-Hash-label-Default+Values]. With no argument, returns the current default value: h = {} h.default # => nil If +key+ is given, returns the default value for +key+, regardless of whether that key exists: h = Hash.new { |hash, key| hash[key] = "No key #{key}"} h[:foo] = "Hello" h.default(:foo) # => "No key foo" ;T;[o;= ;>I" overload;F;?0;;;@0;:I" default;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@~;![;"I"@return [Object];T;#0;$@~;.F;Bi;C0;7[;$@~o;= ;>I" overload;F;?0;;;@0;:I"default(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@~;![;"I"@return [Object];T;#0;$@~;.F;Bi;C0;7[[I"key;T0;$@~;![;"I"7Returns the default value for the given +key+. The returned value will be determined either by the default proc or by the default value. See {Default Values}[#class-Hash-label-Default+Values]. With no argument, returns the current default value: h = {} h.default # => nil If +key+ is given, returns the default value for +key+, regardless of whether that key exists: h = Hash.new { |hash, key| hash[key] = "No key #{key}"} h[:foo] = "Hello" h.default(:foo) # => "No key foo" @overload default @return [Object] @overload default(key) @return [Object];T;#0;$@~;.F;/o;0;1T;2i;3i;%@j;9I",static VALUE rb_hash_default(int argc, VALUE *argv, VALUE hash) { VALUE ifnone; rb_check_arity(argc, 0, 1); ifnone = RHASH_IFNONE(hash); if (FL_TEST(hash, RHASH_PROC_DEFAULT)) { if (argc == 0) return Qnil; return call_default_proc(ifnone, hash, argv[0]); } return ifnone; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#default=;F;7[[I" ifnone;T0;[[@i;T;: default=;0;[;{;IC; "Sets the default value to +value+; returns +value+: h = {} h.default # => nil h.default = false # => false h.default # => false See {Default Values}[#class-Hash-label-Default+Values]. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"default=(value);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I" value;T0;$@;![;"I"Sets the default value to +value+; returns +value+: h = {} h.default # => nil h.default = false # => false h.default # => false See {Default Values}[#class-Hash-label-Default+Values]. @overload default=(value) @return [Object];T;#0;$@;.F;/o;0;1T;2i;3i;%@j;9I"static VALUE rb_hash_set_default(VALUE hash, VALUE ifnone) { rb_hash_modify_check(hash); SET_DEFAULT(hash, ifnone); return ifnone; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#default_proc;F;7[;[[@i;T;:default_proc;0;[;{;IC; "Returns the default proc for +self+ (see {Default Values}[#class-Hash-label-Default+Values]): h = {} h.default_proc # => nil h.default_proc = proc {|hash, key| "Default value for #{key}" } h.default_proc.class # => Proc ;T;[o;= ;>I" overload;F;?0;;;@0;:I"default_proc;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;TI"nil;T;$@;![;"I"@return [Proc, nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the default proc for +self+ (see {Default Values}[#class-Hash-label-Default+Values]): h = {} h.default_proc # => nil h.default_proc = proc {|hash, key| "Default value for #{key}" } h.default_proc.class # => Proc @overload default_proc @return [Proc, nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@j;9I"static VALUE rb_hash_default_proc(VALUE hash) { if (FL_TEST(hash, RHASH_PROC_DEFAULT)) { return RHASH_IFNONE(hash); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#default_proc=;F;7[[I" proc;T0;[[@i;T;:default_proc=;0;[;{;IC; "Sets the default proc for +self+ to +proc+: (see {Default Values}[#class-Hash-label-Default+Values]): h = {} h.default_proc # => nil h.default_proc = proc { |hash, key| "Default value for #{key}" } h.default_proc.class # => Proc h.default_proc = nil h.default_proc # => nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I"default_proc=(proc);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@;![;"I"@return [Proc];T;#0;$@;.F;Bi;C0;7[[I" proc;T0;$@;![;"I"NSets the default proc for +self+ to +proc+: (see {Default Values}[#class-Hash-label-Default+Values]): h = {} h.default_proc # => nil h.default_proc = proc { |hash, key| "Default value for #{key}" } h.default_proc.class # => Proc h.default_proc = nil h.default_proc # => nil @overload default_proc=(proc) @return [Proc];T;#0;$@;.F;/o;0;1T;2i;3i;%@j;9I"VALUE rb_hash_set_default_proc(VALUE hash, VALUE proc) { VALUE b; rb_hash_modify_check(hash); if (NIL_P(proc)) { SET_DEFAULT(hash, proc); return proc; } b = rb_check_convert_type_with_id(proc, T_DATA, "Proc", idTo_proc); if (NIL_P(b) || !rb_obj_is_proc(b)) { rb_raise(rb_eTypeError, "wrong default_proc type %s (expected Proc)", rb_obj_classname(proc)); } proc = b; SET_PROC_DEFAULT(hash, proc); return proc; };T;:I" VALUE;T;;To;4;5F;6;;;;&I" Hash#key;F;7[[I" value;T0;[[@i ;T;:key;0;[;{;IC; "Returns the key for the first-found entry with the given +value+ (see {Entry Order}[#class-Hash-label-Entry+Order]): h = {foo: 0, bar: 2, baz: 2} h.key(0) # => :foo h.key(2) # => :bar Returns +nil+ if so such value is found. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"key(value);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I" value;T0;$@;![;"I"Returns the key for the first-found entry with the given +value+ (see {Entry Order}[#class-Hash-label-Entry+Order]): h = {foo: 0, bar: 2, baz: 2} h.key(0) # => :foo h.key(2) # => :bar Returns +nil+ if so such value is found. @overload key(value) @return [nil];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@j;9I"static VALUE rb_hash_key(VALUE hash, VALUE value) { VALUE args[2]; args[0] = value; args[1] = Qnil; rb_hash_foreach(hash, key_i, (VALUE)args); return args[1]; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#size;F;7[;[[@i ;T;;;0;[;{;IC; "}Returns the count of entries in +self+: {foo: 0, bar: 1, baz: 2}.length # => 3 Hash#length is an alias for Hash#size. ;T;[o;= ;>I" overload;F;?0;;b;@0;:I" length;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@";![;"I"@return [Integer];T;#0;$@";.F;Bi;C0;7[;$@"o;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@";![;"I"@return [Integer];T;#0;$@";.F;Bi;C0;7[;$@";![;"I"Returns the count of entries in +self+: {foo: 0, bar: 1, baz: 2}.length # => 3 Hash#length is an alias for Hash#size. @overload length @return [Integer] @overload size @return [Integer];T;#0;$@";.F;/o;0;1T;2i ;3i ;%@j;9I"MVALUE rb_hash_size(VALUE hash) { return INT2FIX(RHASH_SIZE(hash)); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Hash#length;F;7[;[[@i ;T;;b;0;[;{;IC; "}Returns the count of entries in +self+: {foo: 0, bar: 1, baz: 2}.length # => 3 Hash#length is an alias for Hash#size. ;T;[o;= ;>I" overload;F;?0;;b;@0;:I" length;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@J;![;"I"@return [Integer];T;#0;$@J;.F;Bi;C0;7[;$@Jo;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@J;![;"I"@return [Integer];T;#0;$@J;.F;Bi;C0;7[;$@J;![;"@F;#0;$@J;.F;/o;0;1T;2i ;3i ;%@j;9I"MVALUE rb_hash_size(VALUE hash) { return INT2FIX(RHASH_SIZE(hash)); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Hash#empty?;F;7[;[[@i ;T;;;0;[;{;IC; "Returns +true+ if there are no hash entries, +false+ otherwise: {}.empty? # => true {foo: 0, bar: 1, baz: 2}.empty? # => false;T;[o;= ;>I" overload;F;?0;;;@0;:I" empty?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@q;![;"I"@return [Boolean];T;#0;$@q;.F;Bi;C0;7[;$@q;![;"I"Returns +true+ if there are no hash entries, +false+ otherwise: {}.empty? # => true {foo: 0, bar: 1, baz: 2}.empty? # => false @overload empty? @return [Boolean];T;#0;$@q;.F;/o;0;1T;2i ;3i ;Bi;%@j;9I"Xstatic VALUE rb_hash_empty_p(VALUE hash) { return RBOOL(RHASH_EMPTY_P(hash)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#each_value;F;7[;[[@i ;T;;;0;[;{;IC; "Calls the given block with each value; returns +self+: h = {foo: 0, bar: 1, baz: 2} h.each_value {|value| puts value } # => {:foo=>0, :bar=>1, :baz=>2} Output: 0 1 2 Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.each_value # => #0, :bar=>1, :baz=>2}:each_value> h1 = e.each {|value| puts value } h1 # => {:foo=>0, :bar=>1, :baz=>2} Output: 0 1 2 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"each_value;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" value;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I""@yield [value] @return [self];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"each_value;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Calls the given block with each value; returns +self+: h = {foo: 0, bar: 1, baz: 2} h.each_value {|value| puts value } # => {:foo=>0, :bar=>1, :baz=>2} Output: 0 1 2 Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.each_value # => #0, :bar=>1, :baz=>2}:each_value> h1 = e.each {|value| puts value } h1 # => {:foo=>0, :bar=>1, :baz=>2} Output: 0 1 2 @overload each_value @yield [value] @return [self] @overload each_value;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@j;9I"static VALUE rb_hash_each_value(VALUE hash) { RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); rb_hash_foreach(hash, each_value_i, 0); return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#each_key;F;7[;[[@i ;T;;;0;[;{;IC; "Calls the given block with each key; returns +self+: h = {foo: 0, bar: 1, baz: 2} h.each_key {|key| puts key } # => {:foo=>0, :bar=>1, :baz=>2} Output: foo bar baz Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.each_key # => #0, :bar=>1, :baz=>2}:each_key> h1 = e.each {|key| puts key } h1 # => {:foo=>0, :bar=>1, :baz=>2} Output: foo bar baz ;T;[o;= ;>I" overload;F;?0;;;@0;:I" each_key;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I" @yield [key] @return [self];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" each_key;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Calls the given block with each key; returns +self+: h = {foo: 0, bar: 1, baz: 2} h.each_key {|key| puts key } # => {:foo=>0, :bar=>1, :baz=>2} Output: foo bar baz Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.each_key # => #0, :bar=>1, :baz=>2}:each_key> h1 = e.each {|key| puts key } h1 # => {:foo=>0, :bar=>1, :baz=>2} Output: foo bar baz @overload each_key @yield [key] @return [self] @overload each_key;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@j;9I"static VALUE rb_hash_each_key(VALUE hash) { RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); rb_hash_foreach(hash, each_key_i, 0); return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#each_pair;F;7[;[[@i< ;T;;;0;[;{;IC; "Hash#each is an alias for Hash#each_pair. Calls the given block with each key-value pair; returns +self+: h = {foo: 0, bar: 1, baz: 2} h.each_pair {|key, value| puts "#{key}: #{value}"} # => {:foo=>0, :bar=>1, :baz=>2} Output: foo: 0 bar: 1 baz: 2 Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.each_pair # => #0, :bar=>1, :baz=>2}:each_pair> h1 = e.each {|key, value| puts "#{key}: #{value}"} h1 # => {:foo=>0, :bar=>1, :baz=>2} Output: foo: 0 bar: 1 baz: 2 ;T;[ o;= ;>I" overload;F;?0;;;@0;:I" each;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;TI" value;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"'@yield [key, value] @return [self];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"each_pair;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;TI" value;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"'@yield [key, value] @return [self];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" each;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"each_pair;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Hash#each is an alias for Hash#each_pair. Calls the given block with each key-value pair; returns +self+: h = {foo: 0, bar: 1, baz: 2} h.each_pair {|key, value| puts "#{key}: #{value}"} # => {:foo=>0, :bar=>1, :baz=>2} Output: foo: 0 bar: 1 baz: 2 Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.each_pair # => #0, :bar=>1, :baz=>2}:each_pair> h1 = e.each {|key, value| puts "#{key}: #{value}"} h1 # => {:foo=>0, :bar=>1, :baz=>2} Output: foo: 0 bar: 1 baz: 2 @overload each @yield [key, value] @return [self] @overload each_pair @yield [key, value] @return [self] @overload each @overload each_pair;T;#0;$@;.F;/o;0;1T;2i ;3i< ;%@j;9I"static VALUE rb_hash_each_pair(VALUE hash) { RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); if (rb_block_pair_yield_optimizable()) rb_hash_foreach(hash, each_pair_i_fast, 0); else rb_hash_foreach(hash, each_pair_i, 0); return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#each;F;7[;[[@i< ;T;;;0;[;{;IC; "Hash#each is an alias for Hash#each_pair. Calls the given block with each key-value pair; returns +self+: h = {foo: 0, bar: 1, baz: 2} h.each_pair {|key, value| puts "#{key}: #{value}"} # => {:foo=>0, :bar=>1, :baz=>2} Output: foo: 0 bar: 1 baz: 2 Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.each_pair # => #0, :bar=>1, :baz=>2}:each_pair> h1 = e.each {|key, value| puts "#{key}: #{value}"} h1 # => {:foo=>0, :bar=>1, :baz=>2} Output: foo: 0 bar: 1 baz: 2 ;T;[ o;= ;>I" overload;F;?0;;;@0;:I" each;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;TI" value;T;$@ o;A ;>I" return;F;?I";T;0;@[I" self;T;$@ ;![;"I"'@yield [key, value] @return [self];T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;;;@0;:I"each_pair;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;TI" value;T;$@ o;A ;>I" return;F;?I";T;0;@[I" self;T;$@ ;![;"I"'@yield [key, value] @return [self];T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;;;@0;:I" each;T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;;;@0;:I"each_pair;T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"@;#0;$@ ;.F;/o;0;1T;2i ;3i< ;%@j;9I"static VALUE rb_hash_each_pair(VALUE hash) { RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); if (rb_block_pair_yield_optimizable()) rb_hash_foreach(hash, each_pair_i_fast, 0); else rb_hash_foreach(hash, each_pair_i, 0); return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#transform_keys;F;7[[@90;[[@i ;T;:transform_keys;0;[;{;IC; "Returns a new \Hash object; each entry has: * A key provided by the block. * The value from +self+. An optional hash argument can be provided to map keys to new keys. Any key not given will be mapped using the provided block, or remain the same if no block is given. Transform keys: h = {foo: 0, bar: 1, baz: 2} h1 = h.transform_keys {|key| key.to_s } h1 # => {"foo"=>0, "bar"=>1, "baz"=>2} h.transform_keys(foo: :bar, bar: :foo) #=> {bar: 0, foo: 1, baz: 2} h.transform_keys(foo: :hello, &:to_s) #=> {:hello=>0, "bar"=>1, "baz"=>2} Overwrites values for duplicate keys: h = {foo: 0, bar: 1, baz: 2} h1 = h.transform_keys {|key| :bat } h1 # => {:bat=>2} Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.transform_keys # => #0, :bar=>1, :baz=>2}:transform_keys> h1 = e.each { |key| key.to_s } h1 # => {"foo"=>0, "bar"=>1, "baz"=>2} ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"transform_keys;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;T;$@c;![;"I"@yield [key];T;#0;$@c;.F;Bi;C0;7[;$@co;= ;>I" overload;F;?0;;;@0;:I"transform_keys(hash2);T;IC; ";T;[;![;"I";T;#0;$@c;.F;Bi;C0;7[[I" hash2;T0;$@co;= ;>I" overload;F;?0;;;@0;:I"transform_keys(hash2);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"other_key;T;$@c;![;"I"@yield [other_key];T;#0;$@c;.F;Bi;C0;7[[I" hash2;T0;$@co;= ;>I" overload;F;?0;;;@0;:I"transform_keys;T;IC; ";T;[;![;"I";T;#0;$@c;.F;Bi;C0;7[;$@c;![;"I"9Returns a new \Hash object; each entry has: * A key provided by the block. * The value from +self+. An optional hash argument can be provided to map keys to new keys. Any key not given will be mapped using the provided block, or remain the same if no block is given. Transform keys: h = {foo: 0, bar: 1, baz: 2} h1 = h.transform_keys {|key| key.to_s } h1 # => {"foo"=>0, "bar"=>1, "baz"=>2} h.transform_keys(foo: :bar, bar: :foo) #=> {bar: 0, foo: 1, baz: 2} h.transform_keys(foo: :hello, &:to_s) #=> {:hello=>0, "bar"=>1, "baz"=>2} Overwrites values for duplicate keys: h = {foo: 0, bar: 1, baz: 2} h1 = h.transform_keys {|key| :bat } h1 # => {:bat=>2} Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.transform_keys # => #0, :bar=>1, :baz=>2}:transform_keys> h1 = e.each { |key| key.to_s } h1 # => {"foo"=>0, "bar"=>1, "baz"=>2} @overload transform_keys @yield [key] @overload transform_keys(hash2) @overload transform_keys(hash2) @yield [other_key] @overload transform_keys;T;#0;$@c;.F;/o;0;1T;2ie ;3i ;%@j;9I"static VALUE rb_hash_transform_keys(int argc, VALUE *argv, VALUE hash) { VALUE result; struct transform_keys_args transarg = {0}; argc = rb_check_arity(argc, 0, 1); if (argc > 0) { transarg.trans = to_hash(argv[0]); transarg.block_given = rb_block_given_p(); } else { RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); } result = rb_hash_new(); if (!RHASH_EMPTY_P(hash)) { if (transarg.trans) { transarg.result = result; rb_hash_foreach(hash, transform_keys_hash_i, (VALUE)&transarg); } else { rb_hash_foreach(hash, transform_keys_i, result); } } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#transform_keys!;F;7[[@90;[[@i ;T;:transform_keys!;0;[;{;IC; "dSame as Hash#transform_keys but modifies the receiver in place instead of returning a new hash. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"transform_keys!;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I" @yield [key] @return [self];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"transform_keys!(hash2);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[[I" hash2;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"transform_keys!(hash2);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"other_key;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"&@yield [other_key] @return [self];T;#0;$@;.F;Bi;C0;7[[I" hash2;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"transform_keys!;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I".Same as Hash#transform_keys but modifies the receiver in place instead of returning a new hash. @overload transform_keys! @yield [key] @return [self] @overload transform_keys!(hash2) @return [self] @overload transform_keys!(hash2) @yield [other_key] @return [self] @overload transform_keys!;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@j;9I"static VALUE rb_hash_transform_keys_bang(int argc, VALUE *argv, VALUE hash) { VALUE trans = 0; int block_given = 0; argc = rb_check_arity(argc, 0, 1); if (argc > 0) { trans = to_hash(argv[0]); block_given = rb_block_given_p(); } else { RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); } rb_hash_modify_check(hash); if (!RHASH_TABLE_EMPTY_P(hash)) { long i; VALUE new_keys = hash_alloc(0); VALUE pairs = rb_ary_tmp_new(RHASH_SIZE(hash) * 2); rb_hash_foreach(hash, flatten_i, pairs); for (i = 0; i < RARRAY_LEN(pairs); i += 2) { VALUE key = RARRAY_AREF(pairs, i), new_key, val; if (!trans) { new_key = rb_yield(key); } else if ((new_key = rb_hash_lookup2(trans, key, Qundef)) != Qundef) { /* use the transformed key */ } else if (block_given) { new_key = rb_yield(key); } else { new_key = key; } val = RARRAY_AREF(pairs, i+1); if (!hash_stlike_lookup(new_keys, key, NULL)) { rb_hash_stlike_delete(hash, &key, NULL); } rb_hash_aset(hash, new_key, val); rb_hash_aset(new_keys, new_key, Qnil); } rb_ary_clear(pairs); rb_hash_clear(new_keys); } return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#transform_values;F;7[;[[@i ;T;:transform_values;0;[;{;IC; "Returns a new \Hash object; each entry has: * A key from +self+. * A value provided by the block. Transform values: h = {foo: 0, bar: 1, baz: 2} h1 = h.transform_values {|value| value * 100} h1 # => {:foo=>0, :bar=>100, :baz=>200} Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.transform_values # => #0, :bar=>1, :baz=>2}:transform_values> h1 = e.each { |value| value * 100} h1 # => {:foo=>0, :bar=>100, :baz=>200} ;T;[o;= ;>I" overload;F;?0;;;@0;:I"transform_values;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" value;T;$@;![;"I"@yield [value];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"transform_values;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I",Returns a new \Hash object; each entry has: * A key from +self+. * A value provided by the block. Transform values: h = {foo: 0, bar: 1, baz: 2} h1 = h.transform_values {|value| value * 100} h1 # => {:foo=>0, :bar=>100, :baz=>200} Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.transform_values # => #0, :bar=>1, :baz=>2}:transform_values> h1 = e.each { |value| value * 100} h1 # => {:foo=>0, :bar=>100, :baz=>200} @overload transform_values @yield [value] @overload transform_values;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@j;9I"static VALUE rb_hash_transform_values(VALUE hash) { VALUE result; RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); result = hash_dup_with_compare_by_id(hash); SET_DEFAULT(result, Qnil); if (!RHASH_EMPTY_P(hash)) { rb_hash_stlike_foreach_with_replace(result, transform_values_foreach_func, transform_values_foreach_replace, result); } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#transform_values!;F;7[;[[@i% ;T;:transform_values!;0;[;{;IC; "Returns +self+, whose keys are unchanged, and whose values are determined by the given block. h = {foo: 0, bar: 1, baz: 2} h.transform_values! {|value| value * 100} # => {:foo=>0, :bar=>100, :baz=>200} Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.transform_values! # => #0, :bar=>100, :baz=>200}:transform_values!> h1 = e.each {|value| value * 100} h1 # => {:foo=>0, :bar=>100, :baz=>200} ;T;[o;= ;>I" overload;F;?0;;;@0;:I"transform_values!;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" value;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I""@yield [value] @return [self];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"transform_values!;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"$Returns +self+, whose keys are unchanged, and whose values are determined by the given block. h = {foo: 0, bar: 1, baz: 2} h.transform_values! {|value| value * 100} # => {:foo=>0, :bar=>100, :baz=>200} Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.transform_values! # => #0, :bar=>100, :baz=>200}:transform_values!> h1 = e.each {|value| value * 100} h1 # => {:foo=>0, :bar=>100, :baz=>200} @overload transform_values! @yield [value] @return [self] @overload transform_values!;T;#0;$@;.F;/o;0;1T;2i ;3i$ ;%@j;9I"Lstatic VALUE rb_hash_transform_values_bang(VALUE hash) { RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); rb_hash_modify_check(hash); if (!RHASH_TABLE_EMPTY_P(hash)) { rb_hash_stlike_foreach_with_replace(hash, transform_values_foreach_func, transform_values_foreach_replace, hash); } return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#keys;F;7[;[[@i ;T;;;;0;[;{;IC; "xReturns a new \Array containing all keys in +self+: h = {foo: 0, bar: 1, baz: 2} h.keys # => [:foo, :bar, :baz] ;T;[o;= ;>I" overload;F;?0;;;;@0;:I" keys;T;IC; ";T;[;![;"I";T;#0;$@7;.F;Bi;C0;7[;$@7;![;"I"Returns a new \Array containing all keys in +self+: h = {foo: 0, bar: 1, baz: 2} h.keys # => [:foo, :bar, :baz] @overload keys;T;#0;$@7;.F;/o;0;1T;2i ;3i ;%@j;9I"MJIT_FUNC_EXPORTED VALUE rb_hash_keys(VALUE hash) { st_index_t size = RHASH_SIZE(hash); VALUE keys = rb_ary_new_capa(size); if (size == 0) return keys; if (ST_DATA_COMPATIBLE_P(VALUE)) { RARRAY_PTR_USE_TRANSIENT(keys, ptr, { if (RHASH_AR_TABLE_P(hash)) { size = ar_keys(hash, ptr, size); } else { st_table *table = RHASH_ST_TABLE(hash); size = st_keys(table, ptr, size); } }); rb_gc_writebarrier_remember(keys); rb_ary_set_len(keys, size); } else { rb_hash_foreach(hash, keys_i, keys); } return keys; };T;:I"MJIT_FUNC_EXPORTED VALUE;T;;To;4;5F;6;;;;&I"Hash#values;F;7[;[[@i ;T;;;0;[;{;IC; "sReturns a new \Array containing all values in +self+: h = {foo: 0, bar: 1, baz: 2} h.values # => [0, 1, 2] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" values;T;IC; ";T;[;![;"I";T;#0;$@M;.F;Bi;C0;7[;$@M;![;"I"Returns a new \Array containing all values in +self+: h = {foo: 0, bar: 1, baz: 2} h.values # => [0, 1, 2] @overload values;T;#0;$@M;.F;/o;0;1T;2i;3i;%@j;9I",VALUE rb_hash_values(VALUE hash) { VALUE values; st_index_t size = RHASH_SIZE(hash); values = rb_ary_new_capa(size); if (size == 0) return values; if (ST_DATA_COMPATIBLE_P(VALUE)) { if (RHASH_AR_TABLE_P(hash)) { rb_gc_writebarrier_remember(values); RARRAY_PTR_USE_TRANSIENT(values, ptr, { size = ar_values(hash, ptr, size); }); } else if (RHASH_ST_TABLE_P(hash)) { st_table *table = RHASH_ST_TABLE(hash); rb_gc_writebarrier_remember(values); RARRAY_PTR_USE_TRANSIENT(values, ptr, { size = st_values(table, ptr, size); }); } rb_ary_set_len(values, size); } else { rb_hash_foreach(hash, values_i, values); } return values; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Hash#values_at;F;7[[@90;[[@iw ;T;;;0;[;{;IC; "Returns a new \Array containing values for the given +keys+: h = {foo: 0, bar: 1, baz: 2} h.values_at(:baz, :foo) # => [2, 0] The {default values}[#class-Hash-label-Default+Values] are returned for any keys that are not found: h.values_at(:hello, :foo) # => [nil, 0] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"values_at(*keys);T;IC; ";T;[;![;"I";T;#0;$@c;.F;Bi;C0;7[[I" *keys;T0;$@c;![;"I".Returns a new \Array containing values for the given +keys+: h = {foo: 0, bar: 1, baz: 2} h.values_at(:baz, :foo) # => [2, 0] The {default values}[#class-Hash-label-Default+Values] are returned for any keys that are not found: h.values_at(:hello, :foo) # => [nil, 0] @overload values_at(*keys);T;#0;$@c;.F;/o;0;1T;2ij ;3is ;%@j;9I"static VALUE rb_hash_values_at(int argc, VALUE *argv, VALUE hash) { VALUE result = rb_ary_new2(argc); long i; for (i=0; i [2, 0] Returns a new empty \Array if no arguments given. When a block is given, calls the block with each missing key, treating the block's return value as the value for that key: h = {foo: 0, bar: 1, baz: 2} values = h.fetch_values(:bar, :foo, :bad, :bam) {|key| key.to_s} values # => [1, 0, "bad", "bam"] When no block is given, raises an exception if any given key is not found. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"fetch_values(*keys);T;IC; ";T;[;![;"I";T;#0;$@|;.F;Bi;C0;7[[I" *keys;T0;$@|o;= ;>I" overload;F;?0;;;@0;:I"fetch_values(*keys);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;T;$@|;![;"I"@yield [key];T;#0;$@|;.F;Bi;C0;7[[I" *keys;T0;$@|;![;"I"eReturns a new \Array containing the values associated with the given keys *keys: h = {foo: 0, bar: 1, baz: 2} h.fetch_values(:baz, :foo) # => [2, 0] Returns a new empty \Array if no arguments given. When a block is given, calls the block with each missing key, treating the block's return value as the value for that key: h = {foo: 0, bar: 1, baz: 2} values = h.fetch_values(:bar, :foo, :bad, :bam) {|key| key.to_s} values # => [1, 0, "bad", "bam"] When no block is given, raises an exception if any given key is not found. @overload fetch_values(*keys) @overload fetch_values(*keys) @yield [key];T;#0;$@|;.F;/o;0;1T;2i ;3i ;%@j;9I"static VALUE rb_hash_fetch_values(int argc, VALUE *argv, VALUE hash) { VALUE result = rb_ary_new2(argc); long i; for (i=0; i [:foo, 0] h # => {:bar=>1, :baz=>2} Returns the default value if the hash is empty (see {Default Values}[#class-Hash-label-Default+Values]). ;T;[o;= ;>I" overload;F;?0;;a;@0;:I" shift;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"sRemoves the first hash entry (see {Entry Order}[#class-Hash-label-Entry+Order]); returns a 2-element \Array containing the removed key and value: h = {foo: 0, bar: 1, baz: 2} h.shift # => [:foo, 0] h # => {:bar=>1, :baz=>2} Returns the default value if the hash is empty (see {Default Values}[#class-Hash-label-Default+Values]). @overload shift @return [Array];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@j;9I"static VALUE rb_hash_shift(VALUE hash) { struct shift_var var; rb_hash_modify_check(hash); if (RHASH_AR_TABLE_P(hash)) { var.key = Qundef; if (RHASH_ITER_LEV(hash) == 0) { if (ar_shift(hash, &var.key, &var.val)) { return rb_assoc_new(var.key, var.val); } } else { rb_hash_foreach(hash, shift_i_safe, (VALUE)&var); if (var.key != Qundef) { rb_hash_delete_entry(hash, var.key); return rb_assoc_new(var.key, var.val); } } } if (RHASH_ST_TABLE_P(hash)) { var.key = Qundef; if (RHASH_ITER_LEV(hash) == 0) { if (st_shift(RHASH_ST_TABLE(hash), &var.key, &var.val)) { return rb_assoc_new(var.key, var.val); } } else { rb_hash_foreach(hash, shift_i_safe, (VALUE)&var); if (var.key != Qundef) { rb_hash_delete_entry(hash, var.key); return rb_assoc_new(var.key, var.val); } } } return rb_hash_default_value(hash, Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#delete;F;7[[I"key;T0;[[@ij ;T;;\;0;[;{;IC; "Deletes the entry for the given +key+ and returns its associated value. If no block is given and +key+ is found, deletes the entry and returns the associated value: h = {foo: 0, bar: 1, baz: 2} h.delete(:bar) # => 1 h # => {:foo=>0, :baz=>2} If no block given and +key+ is not found, returns +nil+. If a block is given and +key+ is found, ignores the block, deletes the entry, and returns the associated value: h = {foo: 0, bar: 1, baz: 2} h.delete(:baz) { |key| raise 'Will never happen'} # => 2 h # => {:foo=>0, :bar=>1} If a block is given and +key+ is not found, calls the block and returns the block's return value: h = {foo: 0, bar: 1, baz: 2} h.delete(:nosuch) { |key| "Key #{key} not found" } # => "Key nosuch not found" h # => {:foo=>0, :bar=>1, :baz=>2} ;T;[o;= ;>I" overload;F;?0;;\;@0;:I"delete(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I"key;T0;$@o;= ;>I" overload;F;?0;;\;@0;:I"delete(key);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;T;$@o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I""@yield [key] @return [Object];T;#0;$@;.F;Bi;C0;7[[I"key;T0;$@;![;"I"qDeletes the entry for the given +key+ and returns its associated value. If no block is given and +key+ is found, deletes the entry and returns the associated value: h = {foo: 0, bar: 1, baz: 2} h.delete(:bar) # => 1 h # => {:foo=>0, :baz=>2} If no block given and +key+ is not found, returns +nil+. If a block is given and +key+ is found, ignores the block, deletes the entry, and returns the associated value: h = {foo: 0, bar: 1, baz: 2} h.delete(:baz) { |key| raise 'Will never happen'} # => 2 h # => {:foo=>0, :bar=>1} If a block is given and +key+ is not found, calls the block and returns the block's return value: h = {foo: 0, bar: 1, baz: 2} h.delete(:nosuch) { |key| "Key #{key} not found" } # => "Key nosuch not found" h # => {:foo=>0, :bar=>1, :baz=>2} @overload delete(key) @return [nil] @overload delete(key) @yield [key] @return [Object];T;#0;$@;.F;/o;0;1T;2iO ;3ii ;%@j;9I"'static VALUE rb_hash_delete_m(VALUE hash, VALUE key) { VALUE val; rb_hash_modify_check(hash); val = rb_hash_delete_entry(hash, key); if (val != Qundef) { return val; } else { if (rb_block_given_p()) { return rb_yield(key); } else { return Qnil; } } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#delete_if;F;7[;[[@i ;T;:delete_if;0;[;{;IC; "If a block given, calls the block with each key-value pair; deletes each entry for which the block returns a truthy value; returns +self+: h = {foo: 0, bar: 1, baz: 2} h.delete_if {|key, value| value > 0 } # => {:foo=>0} If no block given, returns a new \Enumerator: h = {foo: 0, bar: 1, baz: 2} e = h.delete_if # => #0, :bar=>1, :baz=>2}:delete_if> e.each { |key, value| value > 0 } # => {:foo=>0} ;T;[o;= ;>I" overload;F;?0;;;@0;:I"delete_if;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;TI" value;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"'@yield [key, value] @return [self];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"delete_if;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"If a block given, calls the block with each key-value pair; deletes each entry for which the block returns a truthy value; returns +self+: h = {foo: 0, bar: 1, baz: 2} h.delete_if {|key, value| value > 0 } # => {:foo=>0} If no block given, returns a new \Enumerator: h = {foo: 0, bar: 1, baz: 2} e = h.delete_if # => #0, :bar=>1, :baz=>2}:delete_if> e.each { |key, value| value > 0 } # => {:foo=>0} @overload delete_if @yield [key, value] @return [self] @overload delete_if;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@j;9I"VALUE rb_hash_delete_if(VALUE hash) { RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); rb_hash_modify_check(hash); if (!RHASH_TABLE_EMPTY_P(hash)) { rb_hash_foreach(hash, delete_if_i, hash); } return hash; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Hash#keep_if;F;7[;[[@i ;T;: keep_if;0;[;{;IC; "Calls the block for each key-value pair; retains the entry if the block returns a truthy value; otherwise deletes the entry; returns +self+. h = {foo: 0, bar: 1, baz: 2} h.keep_if { |key, value| key.start_with?('b') } # => {:bar=>1, :baz=>2} Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.keep_if # => #0, :bar=>1, :baz=>2}:keep_if> e.each { |key, value| key.start_with?('b') } # => {:bar=>1, :baz=>2} ;T;[o;= ;>I" overload;F;?0;;;@0;:I" keep_if;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;TI" value;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"'@yield [key, value] @return [self];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" keep_if;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Calls the block for each key-value pair; retains the entry if the block returns a truthy value; otherwise deletes the entry; returns +self+. h = {foo: 0, bar: 1, baz: 2} h.keep_if { |key, value| key.start_with?('b') } # => {:bar=>1, :baz=>2} Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.keep_if # => #0, :bar=>1, :baz=>2}:keep_if> e.each { |key, value| key.start_with?('b') } # => {:bar=>1, :baz=>2} @overload keep_if @yield [key, value] @return [self] @overload keep_if;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@j;9I"static VALUE rb_hash_keep_if(VALUE hash) { RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); rb_hash_modify_check(hash); if (!RHASH_TABLE_EMPTY_P(hash)) { rb_hash_foreach(hash, keep_if_i, hash); } return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#select;F;7[;[[@i ;T;;;0;[;{;IC; "Hash#filter is an alias for Hash#select. Returns a new \Hash object whose entries are those for which the block returns a truthy value: h = {foo: 0, bar: 1, baz: 2} h.select {|key, value| value < 2 } # => {:foo=>0, :bar=>1} Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.select # => #0, :bar=>1, :baz=>2}:select> e.each {|key, value| value < 2 } # => {:foo=>0, :bar=>1} ;T;[o;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;TI" value;T;$@D;![;"I"@yield [key, value];T;#0;$@D;.F;Bi;C0;7[;$@Do;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[;![;"I";T;#0;$@D;.F;Bi;C0;7[;$@D;![;"I"Hash#filter is an alias for Hash#select. Returns a new \Hash object whose entries are those for which the block returns a truthy value: h = {foo: 0, bar: 1, baz: 2} h.select {|key, value| value < 2 } # => {:foo=>0, :bar=>1} Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.select # => #0, :bar=>1, :baz=>2}:select> e.each {|key, value| value < 2 } # => {:foo=>0, :bar=>1} @overload select @yield [key, value] @overload select;T;#0;$@D;.F;/o;0;1T;2i ;3i ;%@j;9I" static VALUE rb_hash_select(VALUE hash) { VALUE result; RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); result = hash_dup_with_compare_by_id(hash); if (!RHASH_EMPTY_P(hash)) { rb_hash_foreach(result, keep_if_i, result); } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#select!;F;7[;[[@i ;T;: select!;0;[;{;IC; "Hash#filter! is an alias for Hash#select!. Returns +self+, whose entries are those for which the block returns a truthy value: h = {foo: 0, bar: 1, baz: 2} h.select! {|key, value| value < 2 } => {:foo=>0, :bar=>1} Returns +nil+ if no entries were removed. Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.select! # => #0, :bar=>1, :baz=>2}:select!> e.each { |key, value| value < 2 } # => {:foo=>0, :bar=>1} ;T;[o;= ;>I" overload;F;?0;;;@0;:I" select!;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;TI" value;T;$@ho;A ;>I" return;F;?I";T;0;@[I" self;TI"nil;T;$@h;![;"I",@yield [key, value] @return [self, nil];T;#0;$@h;.F;Bi;C0;7[;$@ho;= ;>I" overload;F;?0;;;@0;:I" select!;T;IC; ";T;[;![;"I";T;#0;$@h;.F;Bi;C0;7[;$@h;![;"I"*Hash#filter! is an alias for Hash#select!. Returns +self+, whose entries are those for which the block returns a truthy value: h = {foo: 0, bar: 1, baz: 2} h.select! {|key, value| value < 2 } => {:foo=>0, :bar=>1} Returns +nil+ if no entries were removed. Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.select! # => #0, :bar=>1, :baz=>2}:select!> e.each { |key, value| value < 2 } # => {:foo=>0, :bar=>1} @overload select! @yield [key, value] @return [self, nil] @overload select!;T;#0;$@h;.F;/o;0;1T;2i ;3i ;%@j;9I"8static VALUE rb_hash_select_bang(VALUE hash) { st_index_t n; RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); rb_hash_modify_check(hash); n = RHASH_SIZE(hash); if (!n) return Qnil; rb_hash_foreach(hash, keep_if_i, hash); if (n == RHASH_SIZE(hash)) return Qnil; return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#filter;F;7[;[[@i ;T;;;0;[;{;IC; "Hash#filter is an alias for Hash#select. Returns a new \Hash object whose entries are those for which the block returns a truthy value: h = {foo: 0, bar: 1, baz: 2} h.select {|key, value| value < 2 } # => {:foo=>0, :bar=>1} Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.select # => #0, :bar=>1, :baz=>2}:select> e.each {|key, value| value < 2 } # => {:foo=>0, :bar=>1} ;T;[o;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;TI" value;T;$@;![;"I"@yield [key, value];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"@d;#0;$@;.F;/o;0;1T;2i ;3i ;%@j;9I" static VALUE rb_hash_select(VALUE hash) { VALUE result; RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); result = hash_dup_with_compare_by_id(hash); if (!RHASH_EMPTY_P(hash)) { rb_hash_foreach(result, keep_if_i, result); } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#filter!;F;7[;[[@i ;T;: filter!;0;[;{;IC; "Hash#filter! is an alias for Hash#select!. Returns +self+, whose entries are those for which the block returns a truthy value: h = {foo: 0, bar: 1, baz: 2} h.select! {|key, value| value < 2 } => {:foo=>0, :bar=>1} Returns +nil+ if no entries were removed. Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.select! # => #0, :bar=>1, :baz=>2}:select!> e.each { |key, value| value < 2 } # => {:foo=>0, :bar=>1} ;T;[o;= ;>I" overload;F;?0;;;@0;:I" select!;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;TI" value;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;TI"nil;T;$@;![;"I",@yield [key, value] @return [self, nil];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" select!;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2i ;3i ;%@j;9I"8static VALUE rb_hash_select_bang(VALUE hash) { st_index_t n; RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); rb_hash_modify_check(hash); n = RHASH_SIZE(hash); if (!n) return Qnil; rb_hash_foreach(hash, keep_if_i, hash); if (n == RHASH_SIZE(hash)) return Qnil; return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#reject;F;7[;[[@i" ;T;;;0;[;{;IC; "Returns a new \Hash object whose entries are all those from +self+ for which the block returns +false+ or +nil+: h = {foo: 0, bar: 1, baz: 2} h1 = h.reject {|key, value| key.start_with?('b') } h1 # => {:foo=>0} Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.reject # => #0, :bar=>1, :baz=>2}:reject> h1 = e.each {|key, value| key.start_with?('b') } h1 # => {:foo=>0} ;T;[o;= ;>I" overload;F;?0;;;@0;:I" reject;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;TI" value;T;$@;![;"I"@yield [key, value];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" reject;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a new \Hash object whose entries are all those from +self+ for which the block returns +false+ or +nil+: h = {foo: 0, bar: 1, baz: 2} h1 = h.reject {|key, value| key.start_with?('b') } h1 # => {:foo=>0} Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.reject # => #0, :bar=>1, :baz=>2}:reject> h1 = e.each {|key, value| key.start_with?('b') } h1 # => {:foo=>0} @overload reject @yield [key, value] @overload reject;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@j;9I"static VALUE rb_hash_reject(VALUE hash) { VALUE result; RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); result = hash_dup_with_compare_by_id(hash); if (!RHASH_EMPTY_P(hash)) { rb_hash_foreach(result, delete_if_i, result); } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#reject!;F;7[;[[@i ;T;: reject!;0;[;{;IC; "Returns +self+, whose remaining entries are those for which the block returns +false+ or +nil+: h = {foo: 0, bar: 1, baz: 2} h.reject! {|key, value| value < 2 } # => {:baz=>2} Returns +nil+ if no entries are removed. Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.reject! # => #0, :bar=>1, :baz=>2}:reject!> e.each {|key, value| key.start_with?('b') } # => {:foo=>0} ;T;[o;= ;>I" overload;F;?0;;;@0;:I" reject!;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;TI" value;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;TI"nil;T;$@;![;"I",@yield [key, value] @return [self, nil];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" reject!;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns +self+, whose remaining entries are those for which the block returns +false+ or +nil+: h = {foo: 0, bar: 1, baz: 2} h.reject! {|key, value| value < 2 } # => {:baz=>2} Returns +nil+ if no entries are removed. Returns a new \Enumerator if no block given: h = {foo: 0, bar: 1, baz: 2} e = h.reject! # => #0, :bar=>1, :baz=>2}:reject!> e.each {|key, value| key.start_with?('b') } # => {:foo=>0} @overload reject! @yield [key, value] @return [self, nil] @overload reject!;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@j;9I"4static VALUE rb_hash_reject_bang(VALUE hash) { st_index_t n; RETURN_SIZED_ENUMERATOR(hash, 0, 0, hash_enum_size); rb_hash_modify(hash); n = RHASH_SIZE(hash); if (!n) return Qnil; rb_hash_foreach(hash, delete_if_i, hash); if (n == RHASH_SIZE(hash)) return Qnil; return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#slice;F;7[[@90;[[@i: ;T;;;0;[;{;IC; "Returns a new \Hash object containing the entries for the given +keys+: h = {foo: 0, bar: 1, baz: 2} h.slice(:baz, :foo) # => {:baz=>2, :foo=>0} Any given +keys+ that are not found are ignored. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"slice(*keys);T;IC; ";T;[;![;"I";T;#0;$@,;.F;Bi;C0;7[[I" *keys;T0;$@,;![;"I"Returns a new \Hash object containing the entries for the given +keys+: h = {foo: 0, bar: 1, baz: 2} h.slice(:baz, :foo) # => {:baz=>2, :foo=>0} Any given +keys+ that are not found are ignored. @overload slice(*keys);T;#0;$@,;.F;/o;0;1T;2i/ ;3i6 ;%@j;9I"static VALUE rb_hash_slice(int argc, VALUE *argv, VALUE hash) { int i; VALUE key, value, result; if (argc == 0 || RHASH_EMPTY_P(hash)) { return copy_compare_by_id(rb_hash_new(), hash); } result = copy_compare_by_id(rb_hash_new_with_size(argc), hash); for (i = 0; i < argc; i++) { key = argv[i]; value = rb_hash_lookup2(hash, key, Qundef); if (value != Qundef) rb_hash_aset(result, key, value); } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#except;F;7[[@90;[[@iZ ;T;: except;0;[;{;IC; "Returns a new \Hash excluding entries for the given +keys+: h = { a: 100, b: 200, c: 300 } h.except(:a) #=> {:b=>200, :c=>300} Any given +keys+ that are not found are ignored. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"except(*keys);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@E;![;"I"@return [Hash];T;#0;$@E;.F;Bi;C0;7[[I" *keys;T0;$@E;![;"I"Returns a new \Hash excluding entries for the given +keys+: h = { a: 100, b: 200, c: 300 } h.except(:a) #=> {:b=>200, :c=>300} Any given +keys+ that are not found are ignored. @overload except(*keys) @return [Hash];T;#0;$@E;.F;/o;0;1T;2iO ;3iW ;%@j;9I" static VALUE rb_hash_except(int argc, VALUE *argv, VALUE hash) { int i; VALUE key, result; result = hash_dup_with_compare_by_id(hash); for (i = 0; i < argc; i++) { key = argv[i]; rb_hash_delete(result, key); } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#clear;F;7[;[[@i ;T;;;0;[;{;IC; ".Removes all hash entries; returns +self+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" clear;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@c;![;"I"@return [self];T;#0;$@c;.F;Bi;C0;7[;$@c;![;"I"QRemoves all hash entries; returns +self+. @overload clear @return [self];T;#0;$@c;.F;/o;0;1T;2i ;3i ;%@j;9I")VALUE rb_hash_clear(VALUE hash) { rb_hash_modify_check(hash); if (RHASH_ITER_LEV(hash) > 0) { rb_hash_foreach(hash, clear_i, 0); } else if (RHASH_AR_TABLE_P(hash)) { ar_clear(hash); } else { st_clear(RHASH_ST_TABLE(hash)); } return hash; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Hash#invert;F;7[;[[@i;T;: invert;0;[;{;IC; "&Returns a new \Hash object with the each key-value pair inverted: h = {foo: 0, bar: 1, baz: 2} h1 = h.invert h1 # => {0=>:foo, 1=>:bar, 2=>:baz} Overwrites any repeated new keys: (see {Entry Order}[#class-Hash-label-Entry+Order]): h = {foo: 0, bar: 0, baz: 0} h.invert # => {0=>:baz} ;T;[o;= ;>I" overload;F;?0;;;@0;:I" invert;T;IC; ";T;[;![;"I";T;#0;$@~;.F;Bi;C0;7[;$@~;![;"I"9Returns a new \Hash object with the each key-value pair inverted: h = {foo: 0, bar: 1, baz: 2} h1 = h.invert h1 # => {0=>:foo, 1=>:bar, 2=>:baz} Overwrites any repeated new keys: (see {Entry Order}[#class-Hash-label-Entry+Order]): h = {foo: 0, bar: 0, baz: 0} h.invert # => {0=>:baz} @overload invert;T;#0;$@~;.F;/o;0;1T;2i;3i;%@j;9I"static VALUE rb_hash_invert(VALUE hash) { VALUE h = rb_hash_new_with_size(RHASH_SIZE(hash)); rb_hash_foreach(hash, rb_hash_invert_i, h); return h; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#update;F;7[[@90;[[@i;T;; ;0;[;{;IC; "_Merges each of +other_hashes+ into +self+; returns +self+. Each argument in +other_hashes+ must be a \Hash. \Method #update is an alias for \#merge!. With arguments and no block: * Returns +self+, after the given hashes are merged into it. * The given hashes are merged left to right. * Each new entry is added at the end. * Each duplicate-key entry's value overwrites the previous value. Example: h = {foo: 0, bar: 1, baz: 2} h1 = {bat: 3, bar: 4} h2 = {bam: 5, bat:6} h.merge!(h1, h2) # => {:foo=>0, :bar=>4, :baz=>2, :bat=>6, :bam=>5} With arguments and a block: * Returns +self+, after the given hashes are merged. * The given hashes are merged left to right. * Each new-key entry is added at the end. * For each duplicate key: * Calls the block with the key and the old and new values. * The block's return value becomes the new value for the entry. Example: h = {foo: 0, bar: 1, baz: 2} h1 = {bat: 3, bar: 4} h2 = {bam: 5, bat:6} h3 = h.merge!(h1, h2) { |key, old_value, new_value| old_value + new_value } h3 # => {:foo=>0, :bar=>5, :baz=>2, :bat=>9, :bam=>5} With no arguments: * Returns +self+, unmodified. * The block, if given, is ignored. Example: h = {foo: 0, bar: 1, baz: 2} h.merge # => {:foo=>0, :bar=>1, :baz=>2} h1 = h.merge! { |key, old_value, new_value| raise 'Cannot happen' } h1 # => {:foo=>0, :bar=>1, :baz=>2} ;T;[o;= ;>I" overload;F;?0;: merge!;@0;:I" merge!;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"merge!(*other_hashes);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[[I"*other_hashes;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"merge!(*other_hashes);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;TI"old_value;TI"new_value;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"6@yield [key, old_value, new_value] @return [self];T;#0;$@;.F;Bi;C0;7[[I"*other_hashes;T0;$@;![;"I" Merges each of +other_hashes+ into +self+; returns +self+. Each argument in +other_hashes+ must be a \Hash. \Method #update is an alias for \#merge!. With arguments and no block: * Returns +self+, after the given hashes are merged into it. * The given hashes are merged left to right. * Each new entry is added at the end. * Each duplicate-key entry's value overwrites the previous value. Example: h = {foo: 0, bar: 1, baz: 2} h1 = {bat: 3, bar: 4} h2 = {bam: 5, bat:6} h.merge!(h1, h2) # => {:foo=>0, :bar=>4, :baz=>2, :bat=>6, :bam=>5} With arguments and a block: * Returns +self+, after the given hashes are merged. * The given hashes are merged left to right. * Each new-key entry is added at the end. * For each duplicate key: * Calls the block with the key and the old and new values. * The block's return value becomes the new value for the entry. Example: h = {foo: 0, bar: 1, baz: 2} h1 = {bat: 3, bar: 4} h2 = {bam: 5, bat:6} h3 = h.merge!(h1, h2) { |key, old_value, new_value| old_value + new_value } h3 # => {:foo=>0, :bar=>5, :baz=>2, :bat=>9, :bam=>5} With no arguments: * Returns +self+, unmodified. * The block, if given, is ignored. Example: h = {foo: 0, bar: 1, baz: 2} h.merge # => {:foo=>0, :bar=>1, :baz=>2} h1 = h.merge! { |key, old_value, new_value| raise 'Cannot happen' } h1 # => {:foo=>0, :bar=>1, :baz=>2} @overload merge! @return [self] @overload merge!(*other_hashes) @return [self] @overload merge!(*other_hashes) @yield [key, old_value, new_value] @return [self];T;#0;$@;.F;/o;0;1T;2iM;3i;%@j;9I"static VALUE rb_hash_update(int argc, VALUE *argv, VALUE self) { int i; bool block_given = rb_block_given_p(); rb_hash_modify(self); for (i = 0; i < argc; i++){ VALUE hash = to_hash(argv[i]); if (block_given) { rb_hash_foreach(hash, rb_hash_update_block_i, self); } else { rb_hash_foreach(hash, rb_hash_update_i, self); } } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#replace;F;7[[I" hash2;T0;[[@i~ ;T;;;0;[;{;IC; "Replaces the entire contents of +self+ with the contents of +other_hash+; returns +self+: h = {foo: 0, bar: 1, baz: 2} h.replace({bat: 3, bam: 4}) # => {:bat=>3, :bam=>4} ;T;[o;= ;>I" overload;F;?0;;;@0;:I"replace(other_hash);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[[I"other_hash;T0;$@;![;"@;#0;$@;.F;/o;0;1T;2it ;3i{ ;%@j;9I"static VALUE rb_hash_replace(VALUE hash, VALUE hash2) { rb_hash_modify_check(hash); if (hash == hash2) return hash; if (RHASH_ITER_LEV(hash) > 0) { rb_raise(rb_eRuntimeError, "can't replace hash during iteration"); } hash2 = to_hash(hash2); COPY_DEFAULT(hash, hash2); if (RHASH_AR_TABLE_P(hash)) { ar_free_and_clear_table(hash); } else { st_free_table(RHASH_ST_TABLE(hash)); RHASH_ST_CLEAR(hash); } hash_copy(hash, hash2); if (RHASH_EMPTY_P(hash2) && RHASH_ST_TABLE_P(hash2)) { /* ident hash */ RHASH_ST_TABLE_SET(hash, st_init_table_with_size(RHASH_TYPE(hash2), 0)); } rb_gc_writebarrier_remember(hash); return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#merge!;F;7[[@90;[[@i;T;;;0;[;{;IC; "_Merges each of +other_hashes+ into +self+; returns +self+. Each argument in +other_hashes+ must be a \Hash. \Method #update is an alias for \#merge!. With arguments and no block: * Returns +self+, after the given hashes are merged into it. * The given hashes are merged left to right. * Each new entry is added at the end. * Each duplicate-key entry's value overwrites the previous value. Example: h = {foo: 0, bar: 1, baz: 2} h1 = {bat: 3, bar: 4} h2 = {bam: 5, bat:6} h.merge!(h1, h2) # => {:foo=>0, :bar=>4, :baz=>2, :bat=>6, :bam=>5} With arguments and a block: * Returns +self+, after the given hashes are merged. * The given hashes are merged left to right. * Each new-key entry is added at the end. * For each duplicate key: * Calls the block with the key and the old and new values. * The block's return value becomes the new value for the entry. Example: h = {foo: 0, bar: 1, baz: 2} h1 = {bat: 3, bar: 4} h2 = {bam: 5, bat:6} h3 = h.merge!(h1, h2) { |key, old_value, new_value| old_value + new_value } h3 # => {:foo=>0, :bar=>5, :baz=>2, :bat=>9, :bam=>5} With no arguments: * Returns +self+, unmodified. * The block, if given, is ignored. Example: h = {foo: 0, bar: 1, baz: 2} h.merge # => {:foo=>0, :bar=>1, :baz=>2} h1 = h.merge! { |key, old_value, new_value| raise 'Cannot happen' } h1 # => {:foo=>0, :bar=>1, :baz=>2} ;T;[o;= ;>I" overload;F;?0;;;@0;:I" merge!;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"merge!(*other_hashes);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[[I"*other_hashes;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"merge!(*other_hashes);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;TI"old_value;TI"new_value;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"6@yield [key, old_value, new_value] @return [self];T;#0;$@;.F;Bi;C0;7[[I"*other_hashes;T0;$@;![;"@;#0;$@;.F;/o;0;1T;2iM;3i;%@j;9I"static VALUE rb_hash_update(int argc, VALUE *argv, VALUE self) { int i; bool block_given = rb_block_given_p(); rb_hash_modify(self); for (i = 0; i < argc; i++){ VALUE hash = to_hash(argv[i]); if (block_given) { rb_hash_foreach(hash, rb_hash_update_block_i, self); } else { rb_hash_foreach(hash, rb_hash_update_i, self); } } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#merge;F;7[[@90;[[@i;T;: merge;0;[;{;IC; "eReturns the new \Hash formed by merging each of +other_hashes+ into a copy of +self+. Each argument in +other_hashes+ must be a \Hash. --- With arguments and no block: * Returns the new \Hash object formed by merging each successive \Hash in +other_hashes+ into +self+. * Each new-key entry is added at the end. * Each duplicate-key entry's value overwrites the previous value. Example: h = {foo: 0, bar: 1, baz: 2} h1 = {bat: 3, bar: 4} h2 = {bam: 5, bat:6} h.merge(h1, h2) # => {:foo=>0, :bar=>4, :baz=>2, :bat=>6, :bam=>5} With arguments and a block: * Returns a new \Hash object that is the merge of +self+ and each given hash. * The given hashes are merged left to right. * Each new-key entry is added at the end. * For each duplicate key: * Calls the block with the key and the old and new values. * The block's return value becomes the new value for the entry. Example: h = {foo: 0, bar: 1, baz: 2} h1 = {bat: 3, bar: 4} h2 = {bam: 5, bat:6} h3 = h.merge(h1, h2) { |key, old_value, new_value| old_value + new_value } h3 # => {:foo=>0, :bar=>5, :baz=>2, :bat=>9, :bam=>5} With no arguments: * Returns a copy of +self+. * The block, if given, is ignored. Example: h = {foo: 0, bar: 1, baz: 2} h.merge # => {:foo=>0, :bar=>1, :baz=>2} h1 = h.merge { |key, old_value, new_value| raise 'Cannot happen' } h1 # => {:foo=>0, :bar=>1, :baz=>2} ;T;[o;= ;>I" overload;F;?0;;;@0;:I" merge;T;IC; ";T;[;![;"I";T;#0;$@3;.F;Bi;C0;7[;$@3o;= ;>I" overload;F;?0;;;@0;:I"merge(*other_hashes);T;IC; ";T;[;![;"I";T;#0;$@3;.F;Bi;C0;7[[I"*other_hashes;T0;$@3o;= ;>I" overload;F;?0;;;@0;:I"merge(*other_hashes);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;TI"old_value;TI"new_value;T;$@3;![;"I"'@yield [key, old_value, new_value];T;#0;$@3;.F;Bi;C0;7[[I"*other_hashes;T0;$@3;![;"I"Returns the new \Hash formed by merging each of +other_hashes+ into a copy of +self+. Each argument in +other_hashes+ must be a \Hash. --- With arguments and no block: * Returns the new \Hash object formed by merging each successive \Hash in +other_hashes+ into +self+. * Each new-key entry is added at the end. * Each duplicate-key entry's value overwrites the previous value. Example: h = {foo: 0, bar: 1, baz: 2} h1 = {bat: 3, bar: 4} h2 = {bam: 5, bat:6} h.merge(h1, h2) # => {:foo=>0, :bar=>4, :baz=>2, :bat=>6, :bam=>5} With arguments and a block: * Returns a new \Hash object that is the merge of +self+ and each given hash. * The given hashes are merged left to right. * Each new-key entry is added at the end. * For each duplicate key: * Calls the block with the key and the old and new values. * The block's return value becomes the new value for the entry. Example: h = {foo: 0, bar: 1, baz: 2} h1 = {bat: 3, bar: 4} h2 = {bam: 5, bat:6} h3 = h.merge(h1, h2) { |key, old_value, new_value| old_value + new_value } h3 # => {:foo=>0, :bar=>5, :baz=>2, :bat=>9, :bam=>5} With no arguments: * Returns a copy of +self+. * The block, if given, is ignored. Example: h = {foo: 0, bar: 1, baz: 2} h.merge # => {:foo=>0, :bar=>1, :baz=>2} h1 = h.merge { |key, old_value, new_value| raise 'Cannot happen' } h1 # => {:foo=>0, :bar=>1, :baz=>2} @overload merge @overload merge(*other_hashes) @overload merge(*other_hashes) @yield [key, old_value, new_value];T;#0;$@3;.F;/o;0;1T;2i;3i;%@j;9I"static VALUE rb_hash_merge(int argc, VALUE *argv, VALUE self) { return rb_hash_update(argc, argv, copy_compare_by_id(rb_hash_dup(self), self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#assoc;F;7[[I"key;T0;[[@i.;T;: assoc;0;[;{;IC; "If the given +key+ is found, returns a 2-element \Array containing that key and its value: h = {foo: 0, bar: 1, baz: 2} h.assoc(:bar) # => [:bar, 1] Returns +nil+ if key +key+ is not found. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"assoc(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@e;![;"I"@return [nil];T;#0;$@e;.F;Bi;C0;7[[I"key;T0;$@e;![;"I"If the given +key+ is found, returns a 2-element \Array containing that key and its value: h = {foo: 0, bar: 1, baz: 2} h.assoc(:bar) # => [:bar, 1] Returns +nil+ if key +key+ is not found. @overload assoc(key) @return [nil];T;#0;$@e;.F;/o;0;1T;2i#;3i+;%@j;9I"static VALUE rb_hash_assoc(VALUE hash, VALUE key) { st_table *table; const struct st_hash_type *orighash; VALUE args[2]; if (RHASH_EMPTY_P(hash)) return Qnil; ar_force_convert_table(hash, __FILE__, __LINE__); HASH_ASSERT(RHASH_ST_TABLE_P(hash)); table = RHASH_ST_TABLE(hash); orighash = table->type; if (orighash != &identhash) { VALUE value; struct reset_hash_type_arg ensure_arg; struct st_hash_type assochash; assochash.compare = assoc_cmp; assochash.hash = orighash->hash; table->type = &assochash; args[0] = hash; args[1] = key; ensure_arg.hash = hash; ensure_arg.orighash = orighash; value = rb_ensure(lookup2_call, (VALUE)&args, reset_hash_type, (VALUE)&ensure_arg); if (value != Qundef) return rb_assoc_new(key, value); } args[0] = key; args[1] = Qnil; rb_hash_foreach(hash, assoc_i, (VALUE)args); return args[1]; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#rassoc;F;7[[I"obj;T0;[[@ik;T;: rassoc;0;[;{;IC; "Returns a new 2-element \Array consisting of the key and value of the first-found entry whose value is == to value (see {Entry Order}[#class-Hash-label-Entry+Order]): h = {foo: 0, bar: 1, baz: 1} h.rassoc(1) # => [:bar, 1] Returns +nil+ if no such value found. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"rassoc(value);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I" value;T0;$@;![;"I"<Returns a new 2-element \Array consisting of the key and value of the first-found entry whose value is == to value (see {Entry Order}[#class-Hash-label-Entry+Order]): h = {foo: 0, bar: 1, baz: 1} h.rassoc(1) # => [:bar, 1] Returns +nil+ if no such value found. @overload rassoc(value) @return [nil];T;#0;$@;.F;/o;0;1T;2i^;3ih;%@j;9I"static VALUE rb_hash_rassoc(VALUE hash, VALUE obj) { VALUE args[2]; args[0] = obj; args[1] = Qnil; rb_hash_foreach(hash, rassoc_i, (VALUE)args); return args[1]; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#flatten;F;7[[@90;[[@i;T;: flatten;0;[;{;IC; "Returns a new \Array object that is a 1-dimensional flattening of +self+. --- By default, nested Arrays are not flattened: h = {foo: 0, bar: [:bat, 3], baz: 2} h.flatten # => [:foo, 0, :bar, [:bat, 3], :baz, 2] Takes the depth of recursive flattening from \Integer argument +level+: h = {foo: 0, bar: [:bat, [:baz, [:bat, ]]]} h.flatten(1) # => [:foo, 0, :bar, [:bat, [:baz, [:bat]]]] h.flatten(2) # => [:foo, 0, :bar, :bat, [:baz, [:bat]]] h.flatten(3) # => [:foo, 0, :bar, :bat, :baz, [:bat]] h.flatten(4) # => [:foo, 0, :bar, :bat, :baz, :bat] When +level+ is negative, flattens all nested Arrays: h = {foo: 0, bar: [:bat, [:baz, [:bat, ]]]} h.flatten(-1) # => [:foo, 0, :bar, :bat, :baz, :bat] h.flatten(-2) # => [:foo, 0, :bar, :bat, :baz, :bat] When +level+ is zero, returns the equivalent of #to_a : h = {foo: 0, bar: [:bat, 3], baz: 2} h.flatten(0) # => [[:foo, 0], [:bar, [:bat, 3]], [:baz, 2]] h.flatten(0) == h.to_a # => true ;T;[o;= ;>I" overload;F;?0;;;@0;:I" flatten;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"flatten(level);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" level;T0;$@;![;"I"Returns a new \Array object that is a 1-dimensional flattening of +self+. --- By default, nested Arrays are not flattened: h = {foo: 0, bar: [:bat, 3], baz: 2} h.flatten # => [:foo, 0, :bar, [:bat, 3], :baz, 2] Takes the depth of recursive flattening from \Integer argument +level+: h = {foo: 0, bar: [:bat, [:baz, [:bat, ]]]} h.flatten(1) # => [:foo, 0, :bar, [:bat, [:baz, [:bat]]]] h.flatten(2) # => [:foo, 0, :bar, :bat, [:baz, [:bat]]] h.flatten(3) # => [:foo, 0, :bar, :bat, :baz, [:bat]] h.flatten(4) # => [:foo, 0, :bar, :bat, :baz, :bat] When +level+ is negative, flattens all nested Arrays: h = {foo: 0, bar: [:bat, [:baz, [:bat, ]]]} h.flatten(-1) # => [:foo, 0, :bar, :bat, :baz, :bat] h.flatten(-2) # => [:foo, 0, :bar, :bat, :baz, :bat] When +level+ is zero, returns the equivalent of #to_a : h = {foo: 0, bar: [:bat, 3], baz: 2} h.flatten(0) # => [[:foo, 0], [:bar, [:bat, 3]], [:baz, 2]] h.flatten(0) == h.to_a # => true @overload flatten @overload flatten(level);T;#0;$@;.F;/o;0;1T;2i;3i;%@j;9I"static VALUE rb_hash_flatten(int argc, VALUE *argv, VALUE hash) { VALUE ary; rb_check_arity(argc, 0, 1); if (argc) { int level = NUM2INT(argv[0]); if (level == 0) return rb_hash_to_a(hash); ary = rb_ary_new_capa(RHASH_SIZE(hash) * 2); rb_hash_foreach(hash, flatten_i, ary); level--; if (level > 0) { VALUE ary_flatten_level = INT2FIX(level); rb_funcallv(ary, id_flatten_bang, 1, &ary_flatten_level); } else if (level < 0) { /* flatten recursively */ rb_funcallv(ary, id_flatten_bang, 0, 0); } } else { ary = rb_ary_new_capa(RHASH_SIZE(hash) * 2); rb_hash_foreach(hash, flatten_i, ary); } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#compact;F;7[;[[@i;T;;;0;[;{;IC; "Returns a copy of +self+ with all +nil+-valued entries removed: h = {foo: 0, bar: nil, baz: 2, bat: nil} h1 = h.compact h1 # => {:foo=>0, :baz=>2} ;T;[o;= ;>I" overload;F;?0;;;@0;:I" compact;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a copy of +self+ with all +nil+-valued entries removed: h = {foo: 0, bar: nil, baz: 2, bat: nil} h1 = h.compact h1 # => {:foo=>0, :baz=>2} @overload compact;T;#0;$@;.F;/o;0;1T;2i;3i;%@j;9I"static VALUE rb_hash_compact(VALUE hash) { VALUE result = rb_hash_new(); if (!RHASH_EMPTY_P(hash)) { rb_hash_foreach(hash, set_if_not_nil, result); } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#compact!;F;7[;[[@i;T;: compact!;0;[;{;IC; "Returns +self+ with all its +nil+-valued entries removed (in place): h = {foo: 0, bar: nil, baz: 2, bat: nil} h.compact! # => {:foo=>0, :baz=>2} Returns +nil+ if no entries were removed. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" compact!;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;TI"nil;T;$@;![;"I"@return [self, nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns +self+ with all its +nil+-valued entries removed (in place): h = {foo: 0, bar: nil, baz: 2, bat: nil} h.compact! # => {:foo=>0, :baz=>2} Returns +nil+ if no entries were removed. @overload compact! @return [self, nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@j;9I"static VALUE rb_hash_compact_bang(VALUE hash) { st_index_t n; rb_hash_modify_check(hash); n = RHASH_SIZE(hash); if (n) { rb_hash_foreach(hash, delete_if_nil, hash); if (n != RHASH_SIZE(hash)) return hash; } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#include?;F;7[[I"key;T0;[[@i8;T;;;0;[;{;IC; "Methods #has_key?, #key?, and #member? are aliases for \#include?. Returns +true+ if +key+ is a key in +self+, otherwise +false+.;T;[ o;= ;>I" overload;F;?0;;;@0;:I"include?(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"key;T0;$@o;= ;>I" overload;F;?0;: has_key?;@0;:I"has_key?(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"key;T0;$@o;= ;>I" overload;F;?0;;:;@0;:I"key?(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"key;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"member?(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"key;T0;$@;![;"I"/Methods #has_key?, #key?, and #member? are aliases for \#include?. Returns +true+ if +key+ is a key in +self+, otherwise +false+. @overload include?(key) @return [Boolean] @overload has_key?(key) @return [Boolean] @overload key?(key) @return [Boolean] @overload member?(key) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i,;3i8;Bi;%@j;9I"MJIT_FUNC_EXPORTED VALUE rb_hash_has_key(VALUE hash, VALUE key) { return RBOOL(hash_stlike_lookup(hash, key, NULL)); };T;:I"MJIT_FUNC_EXPORTED VALUE;T;;To;4;5F;6;;;;&I"Hash#member?;F;7[[I"key;T0;[[@i8;T;;;0;[;{;IC; "Methods #has_key?, #key?, and #member? are aliases for \#include?. Returns +true+ if +key+ is a key in +self+, otherwise +false+.;T;[ o;= ;>I" overload;F;?0;;;@0;:I"include?(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@B;![;"I"@return [Boolean];T;#0;$@B;.F;Bi;C0;7[[I"key;T0;$@Bo;= ;>I" overload;F;?0;; ;@0;:I"has_key?(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@B;![;"I"@return [Boolean];T;#0;$@B;.F;Bi;C0;7[[I"key;T0;$@Bo;= ;>I" overload;F;?0;;:;@0;:I"key?(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@B;![;"I"@return [Boolean];T;#0;$@B;.F;Bi;C0;7[[I"key;T0;$@Bo;= ;>I" overload;F;?0;;;@0;:I"member?(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@B;![;"I"@return [Boolean];T;#0;$@B;.F;Bi;C0;7[[I"key;T0;$@B;![;"@>;#0;$@B;.F;/o;0;1T;2i,;3i8;Bi;%@j;9I"MJIT_FUNC_EXPORTED VALUE rb_hash_has_key(VALUE hash, VALUE key) { return RBOOL(hash_stlike_lookup(hash, key, NULL)); };T;:I"MJIT_FUNC_EXPORTED VALUE;T;;To;4;5F;6;;;;&I"Hash#has_key?;F;7[[I"key;T0;[[@i8;T;; ;0;[;{;IC; "Methods #has_key?, #key?, and #member? are aliases for \#include?. Returns +true+ if +key+ is a key in +self+, otherwise +false+.;T;[ o;= ;>I" overload;F;?0;;;@0;:I"include?(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"key;T0;$@o;= ;>I" overload;F;?0;; ;@0;:I"has_key?(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"key;T0;$@o;= ;>I" overload;F;?0;;:;@0;:I"key?(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"key;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"member?(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"key;T0;$@;![;"@>;#0;$@;.F;/o;0;1T;2i,;3i8;Bi;%@j;9I"MJIT_FUNC_EXPORTED VALUE rb_hash_has_key(VALUE hash, VALUE key) { return RBOOL(hash_stlike_lookup(hash, key, NULL)); };T;:I"MJIT_FUNC_EXPORTED VALUE;T;;To;4;5F;6;;;;&I"Hash#has_value?;F;7[[I"val;T0;[[@iT;T;:has_value?;0;[;{;IC; "uMethod #value? is an alias for \#has_value?. Returns +true+ if +value+ is a value in +self+, otherwise +false+.;T;[o;= ;>I" overload;F;?0;; ;@0;:I"has_value?(value);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" value;T0;$@o;= ;>I" overload;F;?0;: value?;@0;:I"value?(value);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" value;T0;$@;![;"I"Method #value? is an alias for \#has_value?. Returns +true+ if +value+ is a value in +self+, otherwise +false+. @overload has_value?(value) @return [Boolean] @overload value?(value) @return [Boolean];T;#0;$@;.F;/o;0;1T;2iJ;3iR;Bi;%@j;9I"static VALUE rb_hash_has_value(VALUE hash, VALUE val) { VALUE data[2]; data[0] = Qfalse; data[1] = val; rb_hash_foreach(hash, rb_hash_search_value, (VALUE)data); return data[0]; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#key?;F;7[[I"key;T0;[[@i8;T;;:;0;[;{;IC; "Methods #has_key?, #key?, and #member? are aliases for \#include?. Returns +true+ if +key+ is a key in +self+, otherwise +false+.;T;[ o;= ;>I" overload;F;?0;;;@0;:I"include?(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"key;T0;$@o;= ;>I" overload;F;?0;; ;@0;:I"has_key?(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"key;T0;$@o;= ;>I" overload;F;?0;;:;@0;:I"key?(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"key;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"member?(key);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"key;T0;$@;![;"@>;#0;$@;.F;/o;0;1T;2i,;3i8;Bi;%@j;9I"MJIT_FUNC_EXPORTED VALUE rb_hash_has_key(VALUE hash, VALUE key) { return RBOOL(hash_stlike_lookup(hash, key, NULL)); };T;:I"MJIT_FUNC_EXPORTED VALUE;T;;To;4;5F;6;;;;&I"Hash#value?;F;7[[I"val;T0;[[@iT;T;; ;0;[;{;IC; "uMethod #value? is an alias for \#has_value?. Returns +true+ if +value+ is a value in +self+, otherwise +false+.;T;[o;= ;>I" overload;F;?0;; ;@0;:I"has_value?(value);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Q;![;"I"@return [Boolean];T;#0;$@Q;.F;Bi;C0;7[[I" value;T0;$@Qo;= ;>I" overload;F;?0;; ;@0;:I"value?(value);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Q;![;"I"@return [Boolean];T;#0;$@Q;.F;Bi;C0;7[[I" value;T0;$@Q;![;"@;#0;$@Q;.F;/o;0;1T;2iJ;3iR;Bi;%@j;9I"static VALUE rb_hash_has_value(VALUE hash, VALUE val) { VALUE data[2]; data[0] = Qfalse; data[1] = val; rb_hash_foreach(hash, rb_hash_search_value, (VALUE)data); return data[0]; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#compare_by_identity;F;7[;[[@i;T;:compare_by_identity;0;[;{;IC; "NSets +self+ to consider only identity in comparing keys; two keys are considered the same only if they are the same object; returns +self+. By default, these two object are considered to be the same key, so +s1+ will overwrite +s0+: s0 = 'x' s1 = 'x' h = {} h.compare_by_identity? # => false h[s0] = 0 h[s1] = 1 h # => {"x"=>1} After calling \#compare_by_identity, the keys are considered to be different, and therefore do not overwrite each other: h = {} h.compare_by_identity # => {} h.compare_by_identity? # => true h[s0] = 0 h[s1] = 1 h # => {"x"=>0, "x"=>1} ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"compare_by_identity;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@~;![;"I"@return [self];T;#0;$@~;.F;Bi;C0;7[;$@~;![;"I"Sets +self+ to consider only identity in comparing keys; two keys are considered the same only if they are the same object; returns +self+. By default, these two object are considered to be the same key, so +s1+ will overwrite +s0+: s0 = 'x' s1 = 'x' h = {} h.compare_by_identity? # => false h[s0] = 0 h[s1] = 1 h # => {"x"=>1} After calling \#compare_by_identity, the keys are considered to be different, and therefore do not overwrite each other: h = {} h.compare_by_identity # => {} h.compare_by_identity? # => true h[s0] = 0 h[s1] = 1 h # => {"x"=>0, "x"=>1} @overload compare_by_identity @return [self];T;#0;$@~;.F;/o;0;1T;2i;3i;%@j;9I"DVALUE rb_hash_compare_by_id(VALUE hash) { VALUE tmp; st_table *identtable; if (rb_hash_compare_by_id_p(hash)) return hash; rb_hash_modify_check(hash); ar_force_convert_table(hash, __FILE__, __LINE__); HASH_ASSERT(RHASH_ST_TABLE_P(hash)); tmp = hash_alloc(0); identtable = rb_init_identtable_with_size(RHASH_SIZE(hash)); RHASH_ST_TABLE_SET(tmp, identtable); rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tmp); st_free_table(RHASH_ST_TABLE(hash)); RHASH_ST_TABLE_SET(hash, identtable); RHASH_ST_CLEAR(tmp); return hash; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Hash#compare_by_identity?;F;7[;[[@i=;T;:compare_by_identity?;0;[;{;IC; "OReturns +true+ if #compare_by_identity has been called, +false+ otherwise.;T;[o;= ;>I" overload;F;?0;; ;@0;:I"compare_by_identity?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns +true+ if #compare_by_identity has been called, +false+ otherwise. @overload compare_by_identity? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i6;3i:;Bi;%@j;9I"MJIT_FUNC_EXPORTED VALUE rb_hash_compare_by_id_p(VALUE hash) { return RBOOL(RHASH_ST_TABLE_P(hash) && RHASH_ST_TABLE(hash)->type == &identhash); };T;:I"MJIT_FUNC_EXPORTED VALUE;T;;To;4;5F;6;;;;&I"Hash#any?;F;7[[@90;[[@i;T;;;0;[;{;IC; "Returns +true+ if any element satisfies a given criterion; +false+ otherwise. With no argument and no block, returns +true+ if +self+ is non-empty; +false+ if empty. With argument +object+ and no block, returns +true+ if for any key +key+ h.assoc(key) == object: h = {foo: 0, bar: 1, baz: 2} h.any?([:bar, 1]) # => true h.any?([:bar, 0]) # => false h.any?([:baz, 1]) # => false With no argument and a block, calls the block with each key-value pair; returns +true+ if the block returns any truthy value, +false+ otherwise: h = {foo: 0, bar: 1, baz: 2} h.any? {|key, value| value < 3 } # => true h.any? {|key, value| value > 3 } # => false;T;[o;= ;>I" overload;F;?0;;;@0;:I" any?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"any?(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" object;T0;$@o;= ;>I" overload;F;?0;;;@0;:I" any?;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"key;TI" value;T;$@o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"*@yield [key, value] @return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns +true+ if any element satisfies a given criterion; +false+ otherwise. With no argument and no block, returns +true+ if +self+ is non-empty; +false+ if empty. With argument +object+ and no block, returns +true+ if for any key +key+ h.assoc(key) == object: h = {foo: 0, bar: 1, baz: 2} h.any?([:bar, 1]) # => true h.any?([:bar, 0]) # => false h.any?([:baz, 1]) # => false With no argument and a block, calls the block with each key-value pair; returns +true+ if the block returns any truthy value, +false+ otherwise: h = {foo: 0, bar: 1, baz: 2} h.any? {|key, value| value < 3 } # => true h.any? {|key, value| value > 3 } # => false @overload any? @return [Boolean] @overload any?(object) @return [Boolean] @overload any? @yield [key, value] @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@j;9I"static VALUE rb_hash_any_p(int argc, VALUE *argv, VALUE hash) { VALUE args[2]; args[0] = Qfalse; rb_check_arity(argc, 0, 1); if (RHASH_EMPTY_P(hash)) return Qfalse; if (argc) { if (rb_block_given_p()) { rb_warn("given block not used"); } args[1] = argv[0]; rb_hash_foreach(hash, any_p_i_pattern, (VALUE)args); } else { if (!rb_block_given_p()) { /* yields pairs, never false */ return Qtrue; } if (rb_block_pair_yield_optimizable()) rb_hash_foreach(hash, any_p_i_fast, (VALUE)args); else rb_hash_foreach(hash, any_p_i, (VALUE)args); } return args[0]; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Hash#dig;F;7[[@90;[[@i;T;:dig;0;[;{;IC; "Finds and returns the object in nested objects that is specified by +key+ and +identifiers+. The nested objects may be instances of various classes. See {Dig Methods}[rdoc-ref:dig_methods.rdoc]. Nested Hashes: h = {foo: {bar: {baz: 2}}} h.dig(:foo) # => {:bar=>{:baz=>2}} h.dig(:foo, :bar) # => {:baz=>2} h.dig(:foo, :bar, :baz) # => 2 h.dig(:foo, :bar, :BAZ) # => nil Nested Hashes and Arrays: h = {foo: {bar: [:a, :b, :c]}} h.dig(:foo, :bar, 2) # => :c This method will use the {default values}[#class-Hash-label-Default+Values] for keys that are not present: h = {foo: {bar: [:a, :b, :c]}} h.dig(:hello) # => nil h.default_proc = -> (hash, _key) { hash } h.dig(:hello, :world) # => h h.dig(:hello, :world, :foo, :bar, 2) # => :c ;T;[o;= ;>I" overload;F;?0;;;@0;:I"dig(key, *identifiers);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I"key;T0[I"*identifiers;T0;$@;![;"I",Finds and returns the object in nested objects that is specified by +key+ and +identifiers+. The nested objects may be instances of various classes. See {Dig Methods}[rdoc-ref:dig_methods.rdoc]. Nested Hashes: h = {foo: {bar: {baz: 2}}} h.dig(:foo) # => {:bar=>{:baz=>2}} h.dig(:foo, :bar) # => {:baz=>2} h.dig(:foo, :bar, :baz) # => 2 h.dig(:foo, :bar, :BAZ) # => nil Nested Hashes and Arrays: h = {foo: {bar: [:a, :b, :c]}} h.dig(:foo, :bar, 2) # => :c This method will use the {default values}[#class-Hash-label-Default+Values] for keys that are not present: h = {foo: {bar: [:a, :b, :c]}} h.dig(:hello) # => nil h.default_proc = -> (hash, _key) { hash } h.dig(:hello, :world) # => h h.dig(:hello, :world, :foo, :bar, 2) # => :c @overload dig(key, *identifiers) @return [Object];T;#0;$@;.F;/o;0;1T;2i;3i;%@j;9I"static VALUE rb_hash_dig(int argc, VALUE *argv, VALUE self) { rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS); self = rb_hash_aref(self, *argv); if (!--argc) return self; ++argv; return rb_obj_dig(argc, argv, self, Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Hash#<=;F;7[[I" other;T0;[[@i;T;;;0;[;{;IC; "Returns +true+ if +hash+ is a subset of +other_hash+, +false+ otherwise: h1 = {foo: 0, bar: 1} h2 = {foo: 0, bar: 1, baz: 2} h1 <= h2 # => true h2 <= h1 # => false h1 <= h1 # => true ;T;[o;= ;>I" overload;F;?0;;;@0;:I"<=(other_hash);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"other_hash;T0;$@;![;"I"Returns +true+ if +hash+ is a subset of +other_hash+, +false+ otherwise: h1 = {foo: 0, bar: 1} h2 = {foo: 0, bar: 1, baz: 2} h1 <= h2 # => true h2 <= h1 # => false h1 <= h1 # => true @overload <=(other_hash) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;%@j;9I"static VALUE rb_hash_le(VALUE hash, VALUE other) { other = to_hash(other); if (RHASH_SIZE(hash) > RHASH_SIZE(other)) return Qfalse; return hash_le(hash, other); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Hash#<;F;7[[I" other;T0;[[@i;T;;;0;[;{;IC; "Returns +true+ if +hash+ is a proper subset of +other_hash+, +false+ otherwise: h1 = {foo: 0, bar: 1} h2 = {foo: 0, bar: 1, baz: 2} h1 < h2 # => true h2 < h1 # => false h1 < h1 # => false ;T;[o;= ;>I" overload;F;?0;;;@0;:I"<(other_hash);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@1;![;"I"@return [Boolean];T;#0;$@1;.F;Bi;C0;7[[I"other_hash;T0;$@1;![;"I"Returns +true+ if +hash+ is a proper subset of +other_hash+, +false+ otherwise: h1 = {foo: 0, bar: 1} h2 = {foo: 0, bar: 1, baz: 2} h1 < h2 # => true h2 < h1 # => false h1 < h1 # => false @overload <(other_hash) @return [Boolean];T;#0;$@1;.F;/o;0;1T;2i;3i;%@j;9I"static VALUE rb_hash_lt(VALUE hash, VALUE other) { other = to_hash(other); if (RHASH_SIZE(hash) >= RHASH_SIZE(other)) return Qfalse; return hash_le(hash, other); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Hash#>=;F;7[[I" other;T0;[[@i&;T;;;0;[;{;IC; "Returns +true+ if +hash+ is a superset of +other_hash+, +false+ otherwise: h1 = {foo: 0, bar: 1, baz: 2} h2 = {foo: 0, bar: 1} h1 >= h2 # => true h2 >= h1 # => false h1 >= h1 # => true ;T;[o;= ;>I" overload;F;?0;;;@0;:I">=(other_hash);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@P;![;"I"@return [Boolean];T;#0;$@P;.F;Bi;C0;7[[I"other_hash;T0;$@P;![;"I"Returns +true+ if +hash+ is a superset of +other_hash+, +false+ otherwise: h1 = {foo: 0, bar: 1, baz: 2} h2 = {foo: 0, bar: 1} h1 >= h2 # => true h2 >= h1 # => false h1 >= h1 # => true @overload >=(other_hash) @return [Boolean];T;#0;$@P;.F;/o;0;1T;2i;3i$;%@j;9I"static VALUE rb_hash_ge(VALUE hash, VALUE other) { other = to_hash(other); if (RHASH_SIZE(hash) < RHASH_SIZE(other)) return Qfalse; return hash_le(other, hash); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Hash#>;F;7[[I" other;T0;[[@i9;T;;;0;[;{;IC; "Returns +true+ if +hash+ is a proper superset of +other_hash+, +false+ otherwise: h1 = {foo: 0, bar: 1, baz: 2} h2 = {foo: 0, bar: 1} h1 > h2 # => true h2 > h1 # => false h1 > h1 # => false ;T;[o;= ;>I" overload;F;?0;;;@0;:I">(other_hash);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@o;![;"I"@return [Boolean];T;#0;$@o;.F;Bi;C0;7[[I"other_hash;T0;$@o;![;"I"Returns +true+ if +hash+ is a proper superset of +other_hash+, +false+ otherwise: h1 = {foo: 0, bar: 1, baz: 2} h2 = {foo: 0, bar: 1} h1 > h2 # => true h2 > h1 # => false h1 > h1 # => false @overload >(other_hash) @return [Boolean];T;#0;$@o;.F;/o;0;1T;2i.;3i7;%@j;9I"static VALUE rb_hash_gt(VALUE hash, VALUE other) { other = to_hash(other); if (RHASH_SIZE(hash) <= RHASH_SIZE(other)) return Qfalse; return hash_le(other, hash); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash#deconstruct_keys;F;7[[I" keys;T0;[[@iZ;T;:deconstruct_keys;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@j;9I"Wstatic VALUE rb_hash_deconstruct_keys(VALUE hash, VALUE keys) { return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash.ruby2_keywords_hash?;F;7[[I" hash;T0;[[@i;T;:ruby2_keywords_hash?;0;[;{;IC; "SChecks if a given hash is flagged by Module#ruby2_keywords (or Proc#ruby2_keywords). This method is not for casual use; debugging, researching, and some truly necessary cases like serialization of arguments. ruby2_keywords def foo(*args) Hash.ruby2_keywords_hash?(args.last) end foo(k: 1) #=> true foo({k: 1}) #=> false;T;[o;= ;>I" overload;F;?0;;;@0;:I"ruby2_keywords_hash?(hash);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" hash;T0;$@;![;"I"Checks if a given hash is flagged by Module#ruby2_keywords (or Proc#ruby2_keywords). This method is not for casual use; debugging, researching, and some truly necessary cases like serialization of arguments. ruby2_keywords def foo(*args) Hash.ruby2_keywords_hash?(args.last) end foo(k: 1) #=> true foo({k: 1}) #=> false @overload ruby2_keywords_hash?(hash) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@j;9I"static VALUE rb_hash_s_ruby2_keywords_hash_p(VALUE dummy, VALUE hash) { Check_Type(hash, T_HASH); return RBOOL(RHASH(hash)->basic.flags & RHASH_PASS_AS_KEYWORDS); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Hash.ruby2_keywords_hash;F;7[[I" hash;T0;[[@i;T;:ruby2_keywords_hash;0;[;{;IC; "<Duplicates a given hash and adds a ruby2_keywords flag. This method is not for casual use; debugging, researching, and some truly necessary cases like deserialization of arguments. h = {k: 1} h = Hash.ruby2_keywords_hash(h) def foo(k: 42) k end foo(*[h]) #=> 1 with neither a warning or an error ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ruby2_keywords_hash(hash);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@;![;"I"@return [Hash];T;#0;$@;.F;Bi;C0;7[[I" hash;T0;$@;![;"I"sDuplicates a given hash and adds a ruby2_keywords flag. This method is not for casual use; debugging, researching, and some truly necessary cases like deserialization of arguments. h = {k: 1} h = Hash.ruby2_keywords_hash(h) def foo(k: 42) k end foo(*[h]) #=> 1 with neither a warning or an error @overload ruby2_keywords_hash(hash) @return [Hash];T;#0;$@;.F;/o;0;1T;2i;3i;%@j;9I"static VALUE rb_hash_s_ruby2_keywords_hash(VALUE dummy, VALUE hash) { Check_Type(hash, T_HASH); hash = rb_hash_dup(hash); RHASH(hash)->basic.flags |= RHASH_PASS_AS_KEYWORDS; return hash; };T;:I"static VALUE;T;;T; @j; IC;[; @j; IC;[o;( ;)0;*0;+0;;;%@;-@y,;0; @j; IC;{;IC;{;T;IC;{;T;T;{@;J;[;[[@i;F;;;;;;;[;{;IC; "9A \Hash maps each of its unique keys to a specific value. A \Hash has certain similarities to an \Array, but: - An \Array index is always an \Integer. - A \Hash key can be (almost) any object. === \Hash \Data Syntax The older syntax for \Hash data uses the "hash rocket," =>: h = {:foo => 0, :bar => 1, :baz => 2} h # => {:foo=>0, :bar=>1, :baz=>2} Alternatively, but only for a \Hash key that's a \Symbol, you can use a newer JSON-style syntax, where each bareword becomes a \Symbol: h = {foo: 0, bar: 1, baz: 2} h # => {:foo=>0, :bar=>1, :baz=>2} You can also use a \String in place of a bareword: h = {'foo': 0, 'bar': 1, 'baz': 2} h # => {:foo=>0, :bar=>1, :baz=>2} And you can mix the styles: h = {foo: 0, :bar => 1, 'baz': 2} h # => {:foo=>0, :bar=>1, :baz=>2} But it's an error to try the JSON-style syntax for a key that's not a bareword or a String: # Raises SyntaxError (syntax error, unexpected ':', expecting =>): h = {0: 'zero'} Hash value can be omitted, meaning that value will be fetched from the context by the name of the key: x = 0 y = 100 h = {x:, y:} h # => {:x=>0, :y=>100} === Common Uses You can use a \Hash to give names to objects: person = {name: 'Matz', language: 'Ruby'} person # => {:name=>"Matz", :language=>"Ruby"} You can use a \Hash to give names to method arguments: def some_method(hash) p hash end some_method({foo: 0, bar: 1, baz: 2}) # => {:foo=>0, :bar=>1, :baz=>2} Note: when the last argument in a method call is a \Hash, the curly braces may be omitted: some_method(foo: 0, bar: 1, baz: 2) # => {:foo=>0, :bar=>1, :baz=>2} You can use a \Hash to initialize an object: class Dev attr_accessor :name, :language def initialize(hash) self.name = hash[:name] self.language = hash[:language] end end matz = Dev.new(name: 'Matz', language: 'Ruby') matz # => # === Creating a \Hash You can create a \Hash object explicitly with: - A {hash literal}[doc/syntax/literals_rdoc.html#label-Hash+Literals]. You can convert certain objects to Hashes with: - \Method {Hash}[Kernel.html#method-i-Hash]. You can create a \Hash by calling method Hash.new. Create an empty Hash: h = Hash.new h # => {} h.class # => Hash You can create a \Hash by calling method Hash.[]. Create an empty Hash: h = Hash[] h # => {} Create a \Hash with initial entries: h = Hash[foo: 0, bar: 1, baz: 2] h # => {:foo=>0, :bar=>1, :baz=>2} You can create a \Hash by using its literal form (curly braces). Create an empty \Hash: h = {} h # => {} Create a \Hash with initial entries: h = {foo: 0, bar: 1, baz: 2} h # => {:foo=>0, :bar=>1, :baz=>2} === \Hash Value Basics The simplest way to retrieve a \Hash value (instance method #[]): h = {foo: 0, bar: 1, baz: 2} h[:foo] # => 0 The simplest way to create or update a \Hash value (instance method #[]=): h = {foo: 0, bar: 1, baz: 2} h[:bat] = 3 # => 3 h # => {:foo=>0, :bar=>1, :baz=>2, :bat=>3} h[:foo] = 4 # => 4 h # => {:foo=>4, :bar=>1, :baz=>2, :bat=>3} The simplest way to delete a \Hash entry (instance method #delete): h = {foo: 0, bar: 1, baz: 2} h.delete(:bar) # => 1 h # => {:foo=>0, :baz=>2} === Entry Order A \Hash object presents its entries in the order of their creation. This is seen in: - Iterative methods such as each, each_key, each_pair, each_value. - Other order-sensitive methods such as shift, keys, values. - The \String returned by method inspect. A new \Hash has its initial ordering per the given entries: h = Hash[foo: 0, bar: 1] h # => {:foo=>0, :bar=>1} New entries are added at the end: h[:baz] = 2 h # => {:foo=>0, :bar=>1, :baz=>2} Updating a value does not affect the order: h[:baz] = 3 h # => {:foo=>0, :bar=>1, :baz=>3} But re-creating a deleted entry can affect the order: h.delete(:foo) h[:foo] = 5 h # => {:bar=>1, :baz=>3, :foo=>5} === \Hash Keys ==== \Hash Key Equivalence Two objects are treated as the same \hash key when their hash value is identical and the two objects are eql? to each other. ==== Modifying an Active \Hash Key Modifying a \Hash key while it is in use damages the hash's index. This \Hash has keys that are Arrays: a0 = [ :foo, :bar ] a1 = [ :baz, :bat ] h = {a0 => 0, a1 => 1} h.include?(a0) # => true h[a0] # => 0 a0.hash # => 110002110 Modifying array element a0[0] changes its hash value: a0[0] = :bam a0.hash # => 1069447059 And damages the \Hash index: h.include?(a0) # => false h[a0] # => nil You can repair the hash index using method +rehash+: h.rehash # => {[:bam, :bar]=>0, [:baz, :bat]=>1} h.include?(a0) # => true h[a0] # => 0 A \String key is always safe. That's because an unfrozen \String passed as a key will be replaced by a duplicated and frozen \String: s = 'foo' s.frozen? # => false h = {s => 0} first_key = h.keys.first first_key.frozen? # => true ==== User-Defined \Hash Keys To be useable as a \Hash key, objects must implement the methods hash and eql?. Note: this requirement does not apply if the \Hash uses #compare_by_identity since comparison will then rely on the keys' object id instead of hash and eql?. \Object defines basic implementation for hash and eq? that makes each object a distinct key. Typically, user-defined classes will want to override these methods to provide meaningful behavior, or for example inherit \Struct that has useful definitions for these. A typical implementation of hash is based on the object's data while eql? is usually aliased to the overridden == method: class Book attr_reader :author, :title def initialize(author, title) @author = author @title = title end def ==(other) self.class === other && other.author == @author && other.title == @title end alias eql? == def hash @author.hash ^ @title.hash # XOR end end book1 = Book.new 'matz', 'Ruby in a Nutshell' book2 = Book.new 'matz', 'Ruby in a Nutshell' reviews = {} reviews[book1] = 'Great reference!' reviews[book2] = 'Nice and compact!' reviews.length #=> 1 === Default Values The methods #[], #values_at and #dig need to return the value associated to a certain key. When that key is not found, that value will be determined by its default proc (if any) or else its default (initially `nil`). You can retrieve the default value with method #default: h = Hash.new h.default # => nil You can set the default value by passing an argument to method Hash.new or with method #default= h = Hash.new(-1) h.default # => -1 h.default = 0 h.default # => 0 This default value is returned for #[], #values_at and #dig when a key is not found: counts = {foo: 42} counts.default # => nil (default) counts[:foo] = 42 counts[:bar] # => nil counts.default = 0 counts[:bar] # => 0 counts.values_at(:foo, :bar, :baz) # => [42, 0, 0] counts.dig(:bar) # => 0 Note that the default value is used without being duplicated. It is not advised to set the default value to a mutable object: synonyms = Hash.new([]) synonyms[:hello] # => [] synonyms[:hello] << :hi # => [:hi], but this mutates the default! synonyms.default # => [:hi] synonyms[:world] << :universe synonyms[:world] # => [:hi, :universe], oops synonyms.keys # => [], oops To use a mutable object as default, it is recommended to use a default proc ==== Default \Proc When the default proc for a \Hash is set (i.e., not +nil+), the default value returned by method #[] is determined by the default proc alone. You can retrieve the default proc with method #default_proc: h = Hash.new h.default_proc # => nil You can set the default proc by calling Hash.new with a block or calling the method #default_proc= h = Hash.new { |hash, key| "Default value for #{key}" } h.default_proc.class # => Proc h.default_proc = proc { |hash, key| "Default value for #{key.inspect}" } h.default_proc.class # => Proc When the default proc is set (i.e., not +nil+) and method #[] is called with with a non-existent key, #[] calls the default proc with both the \Hash object itself and the missing key, then returns the proc's return value: h = Hash.new { |hash, key| "Default value for #{key}" } h[:nosuch] # => "Default value for nosuch" Note that in the example above no entry for key +:nosuch+ is created: h.include?(:nosuch) # => false However, the proc itself can add a new entry: synonyms = Hash.new { |hash, key| hash[key] = [] } synonyms.include?(:hello) # => false synonyms[:hello] << :hi # => [:hi] synonyms[:world] << :universe # => [:universe] synonyms.keys # => [:hello, :world] Note that setting the default proc will clear the default value and vice versa. === What's Here First, what's elsewhere. \Class \Hash: - Inherits from {class Object}[Object.html#class-Object-label-What-27s+Here]. - Includes {module Enumerable}[Enumerable.html#module-Enumerable-label-What-27s+Here], which provides dozens of additional methods. Here, class \Hash provides methods that are useful for: - {Creating a Hash}[#class-Hash-label-Methods+for+Creating+a+Hash] - {Setting Hash State}[#class-Hash-label-Methods+for+Setting+Hash+State] - {Querying}[#class-Hash-label-Methods+for+Querying] - {Comparing}[#class-Hash-label-Methods+for+Comparing] - {Fetching}[#class-Hash-label-Methods+for+Fetching] - {Assigning}[#class-Hash-label-Methods+for+Assigning] - {Deleting}[#class-Hash-label-Methods+for+Deleting] - {Iterating}[#class-Hash-label-Methods+for+Iterating] - {Converting}[#class-Hash-label-Methods+for+Converting] - {Transforming Keys and Values}[#class-Hash-label-Methods+for+Transforming+Keys+and+Values] - {And more....}[#class-Hash-label-Other+Methods] \Class \Hash also includes methods from module Enumerable. ==== Methods for Creating a \Hash ::[]:: Returns a new hash populated with given objects. ::new:: Returns a new empty hash. ::try_convert:: Returns a new hash created from a given object. ==== Methods for Setting \Hash State #compare_by_identity:: Sets +self+ to consider only identity in comparing keys. #default=:: Sets the default to a given value. #default_proc=:: Sets the default proc to a given proc. #rehash:: Rebuilds the hash table by recomputing the hash index for each key. ==== Methods for Querying #any?:: Returns whether any element satisfies a given criterion. #compare_by_identity?:: Returns whether the hash considers only identity when comparing keys. #default:: Returns the default value, or the default value for a given key. #default_proc:: Returns the default proc. #empty?:: Returns whether there are no entries. #eql?:: Returns whether a given object is equal to +self+. #hash:: Returns the integer hash code. #has_value?:: Returns whether a given object is a value in +self+. #include?, #has_key?, #member?, #key?:: Returns whether a given object is a key in +self+. #length, #size:: Returns the count of entries. #value?:: Returns whether a given object is a value in +self+. ==== Methods for Comparing {#<}[#method-i-3C]:: Returns whether +self+ is a proper subset of a given object. {#<=}[#method-i-3C-3D]:: Returns whether +self+ is a subset of a given object. {#==}[#method-i-3D-3D]:: Returns whether a given object is equal to +self+. {#>}[#method-i-3E]:: Returns whether +self+ is a proper superset of a given object {#>=}[#method-i-3E-3D]:: Returns whether +self+ is a proper superset of a given object. ==== Methods for Fetching #[]:: Returns the value associated with a given key. #assoc:: Returns a 2-element array containing a given key and its value. #dig:: Returns the object in nested objects that is specified by a given key and additional arguments. #fetch:: Returns the value for a given key. #fetch_values:: Returns array containing the values associated with given keys. #key:: Returns the key for the first-found entry with a given value. #keys:: Returns an array containing all keys in +self+. #rassoc:: Returns a 2-element array consisting of the key and value of the first-found entry having a given value. #values:: Returns an array containing all values in +self+/ #values_at:: Returns an array containing values for given keys. ==== Methods for Assigning #[]=, #store:: Associates a given key with a given value. #merge:: Returns the hash formed by merging each given hash into a copy of +self+. #merge!, #update:: Merges each given hash into +self+. #replace:: Replaces the entire contents of +self+ with the contents of a givan hash. ==== Methods for Deleting These methods remove entries from +self+: #clear:: Removes all entries from +self+. #compact!:: Removes all +nil+-valued entries from +self+. #delete:: Removes the entry for a given key. #delete_if:: Removes entries selected by a given block. #filter!, #select!:: Keep only those entries selected by a given block. #keep_if:: Keep only those entries selected by a given block. #reject!:: Removes entries selected by a given block. #shift:: Removes and returns the first entry. These methods return a copy of +self+ with some entries removed: #compact:: Returns a copy of +self+ with all +nil+-valued entries removed. #except:: Returns a copy of +self+ with entries removed for specified keys. #filter, #select:: Returns a copy of +self+ with only those entries selected by a given block. #reject:: Returns a copy of +self+ with entries removed as specified by a given block. #slice:: Returns a hash containing the entries for given keys. ==== Methods for Iterating #each, #each_pair:: Calls a given block with each key-value pair. #each_key:: Calls a given block with each key. #each_value:: Calls a given block with each value. ==== Methods for Converting #inspect, #to_s:: Returns a new String containing the hash entries. #to_a:: Returns a new array of 2-element arrays; each nested array contains a key-value pair from +self+. #to_h:: Returns +self+ if a \Hash; if a subclass of \Hash, returns a \Hash containing the entries from +self+. #to_hash:: Returns +self+. #to_proc:: Returns a proc that maps a given key to its value. ==== Methods for Transforming Keys and Values #transform_keys:: Returns a copy of +self+ with modified keys. #transform_keys!:: Modifies keys in +self+ #transform_values:: Returns a copy of +self+ with modified values. #transform_values!:: Modifies values in +self+. ==== Other Methods #flatten:: Returns an array that is a 1-dimensional flattening of +self+. #invert:: Returns a hash with the each key-value pair inverted.;T;[;![;"I"9A \Hash maps each of its unique keys to a specific value. A \Hash has certain similarities to an \Array, but: - An \Array index is always an \Integer. - A \Hash key can be (almost) any object. === \Hash \Data Syntax The older syntax for \Hash data uses the "hash rocket," =>: h = {:foo => 0, :bar => 1, :baz => 2} h # => {:foo=>0, :bar=>1, :baz=>2} Alternatively, but only for a \Hash key that's a \Symbol, you can use a newer JSON-style syntax, where each bareword becomes a \Symbol: h = {foo: 0, bar: 1, baz: 2} h # => {:foo=>0, :bar=>1, :baz=>2} You can also use a \String in place of a bareword: h = {'foo': 0, 'bar': 1, 'baz': 2} h # => {:foo=>0, :bar=>1, :baz=>2} And you can mix the styles: h = {foo: 0, :bar => 1, 'baz': 2} h # => {:foo=>0, :bar=>1, :baz=>2} But it's an error to try the JSON-style syntax for a key that's not a bareword or a String: # Raises SyntaxError (syntax error, unexpected ':', expecting =>): h = {0: 'zero'} Hash value can be omitted, meaning that value will be fetched from the context by the name of the key: x = 0 y = 100 h = {x:, y:} h # => {:x=>0, :y=>100} === Common Uses You can use a \Hash to give names to objects: person = {name: 'Matz', language: 'Ruby'} person # => {:name=>"Matz", :language=>"Ruby"} You can use a \Hash to give names to method arguments: def some_method(hash) p hash end some_method({foo: 0, bar: 1, baz: 2}) # => {:foo=>0, :bar=>1, :baz=>2} Note: when the last argument in a method call is a \Hash, the curly braces may be omitted: some_method(foo: 0, bar: 1, baz: 2) # => {:foo=>0, :bar=>1, :baz=>2} You can use a \Hash to initialize an object: class Dev attr_accessor :name, :language def initialize(hash) self.name = hash[:name] self.language = hash[:language] end end matz = Dev.new(name: 'Matz', language: 'Ruby') matz # => # === Creating a \Hash You can create a \Hash object explicitly with: - A {hash literal}[doc/syntax/literals_rdoc.html#label-Hash+Literals]. You can convert certain objects to Hashes with: - \Method {Hash}[Kernel.html#method-i-Hash]. You can create a \Hash by calling method Hash.new. Create an empty Hash: h = Hash.new h # => {} h.class # => Hash You can create a \Hash by calling method Hash.[]. Create an empty Hash: h = Hash[] h # => {} Create a \Hash with initial entries: h = Hash[foo: 0, bar: 1, baz: 2] h # => {:foo=>0, :bar=>1, :baz=>2} You can create a \Hash by using its literal form (curly braces). Create an empty \Hash: h = {} h # => {} Create a \Hash with initial entries: h = {foo: 0, bar: 1, baz: 2} h # => {:foo=>0, :bar=>1, :baz=>2} === \Hash Value Basics The simplest way to retrieve a \Hash value (instance method #[]): h = {foo: 0, bar: 1, baz: 2} h[:foo] # => 0 The simplest way to create or update a \Hash value (instance method #[]=): h = {foo: 0, bar: 1, baz: 2} h[:bat] = 3 # => 3 h # => {:foo=>0, :bar=>1, :baz=>2, :bat=>3} h[:foo] = 4 # => 4 h # => {:foo=>4, :bar=>1, :baz=>2, :bat=>3} The simplest way to delete a \Hash entry (instance method #delete): h = {foo: 0, bar: 1, baz: 2} h.delete(:bar) # => 1 h # => {:foo=>0, :baz=>2} === Entry Order A \Hash object presents its entries in the order of their creation. This is seen in: - Iterative methods such as each, each_key, each_pair, each_value. - Other order-sensitive methods such as shift, keys, values. - The \String returned by method inspect. A new \Hash has its initial ordering per the given entries: h = Hash[foo: 0, bar: 1] h # => {:foo=>0, :bar=>1} New entries are added at the end: h[:baz] = 2 h # => {:foo=>0, :bar=>1, :baz=>2} Updating a value does not affect the order: h[:baz] = 3 h # => {:foo=>0, :bar=>1, :baz=>3} But re-creating a deleted entry can affect the order: h.delete(:foo) h[:foo] = 5 h # => {:bar=>1, :baz=>3, :foo=>5} === \Hash Keys ==== \Hash Key Equivalence Two objects are treated as the same \hash key when their hash value is identical and the two objects are eql? to each other. ==== Modifying an Active \Hash Key Modifying a \Hash key while it is in use damages the hash's index. This \Hash has keys that are Arrays: a0 = [ :foo, :bar ] a1 = [ :baz, :bat ] h = {a0 => 0, a1 => 1} h.include?(a0) # => true h[a0] # => 0 a0.hash # => 110002110 Modifying array element a0[0] changes its hash value: a0[0] = :bam a0.hash # => 1069447059 And damages the \Hash index: h.include?(a0) # => false h[a0] # => nil You can repair the hash index using method +rehash+: h.rehash # => {[:bam, :bar]=>0, [:baz, :bat]=>1} h.include?(a0) # => true h[a0] # => 0 A \String key is always safe. That's because an unfrozen \String passed as a key will be replaced by a duplicated and frozen \String: s = 'foo' s.frozen? # => false h = {s => 0} first_key = h.keys.first first_key.frozen? # => true ==== User-Defined \Hash Keys To be useable as a \Hash key, objects must implement the methods hash and eql?. Note: this requirement does not apply if the \Hash uses #compare_by_identity since comparison will then rely on the keys' object id instead of hash and eql?. \Object defines basic implementation for hash and eq? that makes each object a distinct key. Typically, user-defined classes will want to override these methods to provide meaningful behavior, or for example inherit \Struct that has useful definitions for these. A typical implementation of hash is based on the object's data while eql? is usually aliased to the overridden == method: class Book attr_reader :author, :title def initialize(author, title) @author = author @title = title end def ==(other) self.class === other && other.author == @author && other.title == @title end alias eql? == def hash @author.hash ^ @title.hash # XOR end end book1 = Book.new 'matz', 'Ruby in a Nutshell' book2 = Book.new 'matz', 'Ruby in a Nutshell' reviews = {} reviews[book1] = 'Great reference!' reviews[book2] = 'Nice and compact!' reviews.length #=> 1 === Default Values The methods #[], #values_at and #dig need to return the value associated to a certain key. When that key is not found, that value will be determined by its default proc (if any) or else its default (initially `nil`). You can retrieve the default value with method #default: h = Hash.new h.default # => nil You can set the default value by passing an argument to method Hash.new or with method #default= h = Hash.new(-1) h.default # => -1 h.default = 0 h.default # => 0 This default value is returned for #[], #values_at and #dig when a key is not found: counts = {foo: 42} counts.default # => nil (default) counts[:foo] = 42 counts[:bar] # => nil counts.default = 0 counts[:bar] # => 0 counts.values_at(:foo, :bar, :baz) # => [42, 0, 0] counts.dig(:bar) # => 0 Note that the default value is used without being duplicated. It is not advised to set the default value to a mutable object: synonyms = Hash.new([]) synonyms[:hello] # => [] synonyms[:hello] << :hi # => [:hi], but this mutates the default! synonyms.default # => [:hi] synonyms[:world] << :universe synonyms[:world] # => [:hi, :universe], oops synonyms.keys # => [], oops To use a mutable object as default, it is recommended to use a default proc ==== Default \Proc When the default proc for a \Hash is set (i.e., not +nil+), the default value returned by method #[] is determined by the default proc alone. You can retrieve the default proc with method #default_proc: h = Hash.new h.default_proc # => nil You can set the default proc by calling Hash.new with a block or calling the method #default_proc= h = Hash.new { |hash, key| "Default value for #{key}" } h.default_proc.class # => Proc h.default_proc = proc { |hash, key| "Default value for #{key.inspect}" } h.default_proc.class # => Proc When the default proc is set (i.e., not +nil+) and method #[] is called with with a non-existent key, #[] calls the default proc with both the \Hash object itself and the missing key, then returns the proc's return value: h = Hash.new { |hash, key| "Default value for #{key}" } h[:nosuch] # => "Default value for nosuch" Note that in the example above no entry for key +:nosuch+ is created: h.include?(:nosuch) # => false However, the proc itself can add a new entry: synonyms = Hash.new { |hash, key| hash[key] = [] } synonyms.include?(:hello) # => false synonyms[:hello] << :hi # => [:hi] synonyms[:world] << :universe # => [:universe] synonyms.keys # => [:hello, :world] Note that setting the default proc will clear the default value and vice versa. === What's Here First, what's elsewhere. \Class \Hash: - Inherits from {class Object}[Object.html#class-Object-label-What-27s+Here]. - Includes {module Enumerable}[Enumerable.html#module-Enumerable-label-What-27s+Here], which provides dozens of additional methods. Here, class \Hash provides methods that are useful for: - {Creating a Hash}[#class-Hash-label-Methods+for+Creating+a+Hash] - {Setting Hash State}[#class-Hash-label-Methods+for+Setting+Hash+State] - {Querying}[#class-Hash-label-Methods+for+Querying] - {Comparing}[#class-Hash-label-Methods+for+Comparing] - {Fetching}[#class-Hash-label-Methods+for+Fetching] - {Assigning}[#class-Hash-label-Methods+for+Assigning] - {Deleting}[#class-Hash-label-Methods+for+Deleting] - {Iterating}[#class-Hash-label-Methods+for+Iterating] - {Converting}[#class-Hash-label-Methods+for+Converting] - {Transforming Keys and Values}[#class-Hash-label-Methods+for+Transforming+Keys+and+Values] - {And more....}[#class-Hash-label-Other+Methods] \Class \Hash also includes methods from module Enumerable. ==== Methods for Creating a \Hash ::[]:: Returns a new hash populated with given objects. ::new:: Returns a new empty hash. ::try_convert:: Returns a new hash created from a given object. ==== Methods for Setting \Hash State #compare_by_identity:: Sets +self+ to consider only identity in comparing keys. #default=:: Sets the default to a given value. #default_proc=:: Sets the default proc to a given proc. #rehash:: Rebuilds the hash table by recomputing the hash index for each key. ==== Methods for Querying #any?:: Returns whether any element satisfies a given criterion. #compare_by_identity?:: Returns whether the hash considers only identity when comparing keys. #default:: Returns the default value, or the default value for a given key. #default_proc:: Returns the default proc. #empty?:: Returns whether there are no entries. #eql?:: Returns whether a given object is equal to +self+. #hash:: Returns the integer hash code. #has_value?:: Returns whether a given object is a value in +self+. #include?, #has_key?, #member?, #key?:: Returns whether a given object is a key in +self+. #length, #size:: Returns the count of entries. #value?:: Returns whether a given object is a value in +self+. ==== Methods for Comparing {#<}[#method-i-3C]:: Returns whether +self+ is a proper subset of a given object. {#<=}[#method-i-3C-3D]:: Returns whether +self+ is a subset of a given object. {#==}[#method-i-3D-3D]:: Returns whether a given object is equal to +self+. {#>}[#method-i-3E]:: Returns whether +self+ is a proper superset of a given object {#>=}[#method-i-3E-3D]:: Returns whether +self+ is a proper superset of a given object. ==== Methods for Fetching #[]:: Returns the value associated with a given key. #assoc:: Returns a 2-element array containing a given key and its value. #dig:: Returns the object in nested objects that is specified by a given key and additional arguments. #fetch:: Returns the value for a given key. #fetch_values:: Returns array containing the values associated with given keys. #key:: Returns the key for the first-found entry with a given value. #keys:: Returns an array containing all keys in +self+. #rassoc:: Returns a 2-element array consisting of the key and value of the first-found entry having a given value. #values:: Returns an array containing all values in +self+/ #values_at:: Returns an array containing values for given keys. ==== Methods for Assigning #[]=, #store:: Associates a given key with a given value. #merge:: Returns the hash formed by merging each given hash into a copy of +self+. #merge!, #update:: Merges each given hash into +self+. #replace:: Replaces the entire contents of +self+ with the contents of a givan hash. ==== Methods for Deleting These methods remove entries from +self+: #clear:: Removes all entries from +self+. #compact!:: Removes all +nil+-valued entries from +self+. #delete:: Removes the entry for a given key. #delete_if:: Removes entries selected by a given block. #filter!, #select!:: Keep only those entries selected by a given block. #keep_if:: Keep only those entries selected by a given block. #reject!:: Removes entries selected by a given block. #shift:: Removes and returns the first entry. These methods return a copy of +self+ with some entries removed: #compact:: Returns a copy of +self+ with all +nil+-valued entries removed. #except:: Returns a copy of +self+ with entries removed for specified keys. #filter, #select:: Returns a copy of +self+ with only those entries selected by a given block. #reject:: Returns a copy of +self+ with entries removed as specified by a given block. #slice:: Returns a hash containing the entries for given keys. ==== Methods for Iterating #each, #each_pair:: Calls a given block with each key-value pair. #each_key:: Calls a given block with each key. #each_value:: Calls a given block with each value. ==== Methods for Converting #inspect, #to_s:: Returns a new String containing the hash entries. #to_a:: Returns a new array of 2-element arrays; each nested array contains a key-value pair from +self+. #to_h:: Returns +self+ if a \Hash; if a subclass of \Hash, returns a \Hash containing the entries from +self+. #to_hash:: Returns +self+. #to_proc:: Returns a proc that maps a given key to its value. ==== Methods for Transforming Keys and Values #transform_keys:: Returns a copy of +self+ with modified keys. #transform_keys!:: Modifies keys in +self+ #transform_values:: Returns a copy of +self+ with modified values. #transform_values!:: Modifies values in +self+. ==== Other Methods #flatten:: Returns an array that is a 1-dimensional flattening of +self+. #invert:: Returns a hash with the each key-value pair inverted. ;T;#0;$@j;.F;/o;0;1T;2i ;3i;Bi;%@;&I" Hash;F;'@o; ;IC;[qo;4;5F;6;;;;&I" Array.[];F;7[[@90;[[I" array.c;Tio;T;;;0;[;{;IC; "Returns a new array populated with the given objects. Array.[]( 1, 'a', /^A/) # => [1, "a", /^A/] Array[ 1, 'a', /^A/ ] # => [1, "a", /^A/] [ 1, 'a', /^A/ ] # => [1, "a", /^A/] ;T;[;![;"I"Returns a new array populated with the given objects. Array.[]( 1, 'a', /^A/) # => [1, "a", /^A/] Array[ 1, 'a', /^A/ ] # => [1, "a", /^A/] [ 1, 'a', /^A/ ] # => [1, "a", /^A/] ;T;#0;$@;.F;/o;0;1T;2ig;3il;%@;9I"static VALUE rb_ary_s_create(int argc, VALUE *argv, VALUE klass) { VALUE ary = ary_new(klass, argc); if (argc > 0 && argv) { ary_memcpy(ary, 0, argc, argv); ARY_SET_LEN(ary, argc); } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array.try_convert;F;7[[I"ary;T0;[[@i;T;;v;0;[;{;IC; ")If +object+ is an \Array object, returns +object+. Otherwise if +object+ responds to :to_ary, calls object.to_ary and returns the result. Returns +nil+ if +object+ does not respond to :to_ary Raises an exception unless object.to_ary returns an \Array object. ;T;[o;= ;>I" overload;F;?0;;v;@0;:I"try_convert(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@;![;"I"@return [Object, nil];T;#0;$@;.F;Bi;C0;7[[I" object;T0;$@;![;"I"aIf +object+ is an \Array object, returns +object+. Otherwise if +object+ responds to :to_ary, calls object.to_ary and returns the result. Returns +nil+ if +object+ does not respond to :to_ary Raises an exception unless object.to_ary returns an \Array object. @overload try_convert(object) @return [Object, nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"gstatic VALUE rb_ary_s_try_convert(VALUE dummy, VALUE ary) { return rb_check_array_type(ary); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#initialize;F;7[[@90;[[@i.;T;;D;0;[;{;IC; "'Returns a new \Array. With no block and no arguments, returns a new empty \Array object. With no block and a single \Array argument +array+, returns a new \Array formed from +array+: a = Array.new([:foo, 'bar', 2]) a.class # => Array a # => [:foo, "bar", 2] With no block and a single \Integer argument +size+, returns a new \Array of the given size whose elements are all +nil+: a = Array.new(3) a # => [nil, nil, nil] With no block and arguments +size+ and +default_value+, returns an \Array of the given size; each element is that same +default_value+: a = Array.new(3, 'x') a # => ['x', 'x', 'x'] With a block and argument +size+, returns an \Array of the given size; the block is called with each successive integer +index+; the element for that +index+ is the return value from the block: a = Array.new(3) {|index| "Element #{index}" } a # => ["Element 0", "Element 1", "Element 2"] Raises ArgumentError if +size+ is negative. With a block and no argument, or a single argument +0+, ignores the block and returns a new empty \Array. ;T;[ o;= ;>I" overload;F;?0;;E;@0;:I"new;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;E;@0;:I"new(array);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" array;T0;$@o;= ;>I" overload;F;?0;;E;@0;:I"new(size);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" size;T0;$@o;= ;>I" overload;F;?0;;E;@0;:I"new(size, default_value);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" size;T0[I"default_value;T0;$@o;= ;>I" overload;F;?0;;E;@0;:I"new(size);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" index;T;$@;![;"I"@yield [index];T;#0;$@;.F;Bi;C0;7[[I" size;T0;$@;![;"I"Returns a new \Array. With no block and no arguments, returns a new empty \Array object. With no block and a single \Array argument +array+, returns a new \Array formed from +array+: a = Array.new([:foo, 'bar', 2]) a.class # => Array a # => [:foo, "bar", 2] With no block and a single \Integer argument +size+, returns a new \Array of the given size whose elements are all +nil+: a = Array.new(3) a # => [nil, nil, nil] With no block and arguments +size+ and +default_value+, returns an \Array of the given size; each element is that same +default_value+: a = Array.new(3, 'x') a # => ['x', 'x', 'x'] With a block and argument +size+, returns an \Array of the given size; the block is called with each successive integer +index+; the element for that +index+ is the return value from the block: a = Array.new(3) {|index| "Element #{index}" } a # => ["Element 0", "Element 1", "Element 2"] Raises ArgumentError if +size+ is negative. With a block and no argument, or a single argument +0+, ignores the block and returns a new empty \Array. @overload new @overload new(array) @overload new(size) @overload new(size, default_value) @overload new(size) @yield [index];T;#0;$@;.F;/o;0;1T;2i;3i+;%@;9I"static VALUE rb_ary_initialize(int argc, VALUE *argv, VALUE ary) { long len; VALUE size, val; rb_ary_modify(ary); if (argc == 0) { if (ARY_OWNS_HEAP_P(ary) && ARY_HEAP_PTR(ary) != NULL) { ary_heap_free(ary); } rb_ary_unshare_safe(ary); FL_SET_EMBED(ary); ARY_SET_EMBED_LEN(ary, 0); if (rb_block_given_p()) { rb_warning("given block not used"); } return ary; } rb_scan_args(argc, argv, "02", &size, &val); if (argc == 1 && !FIXNUM_P(size)) { val = rb_check_array_type(size); if (!NIL_P(val)) { rb_ary_replace(ary, val); return ary; } } len = NUM2LONG(size); /* NUM2LONG() may call size.to_int, ary can be frozen, modified, etc */ if (len < 0) { rb_raise(rb_eArgError, "negative array size"); } if (len > ARY_MAX_SIZE) { rb_raise(rb_eArgError, "array size too big"); } /* recheck after argument conversion */ rb_ary_modify(ary); ary_resize_capa(ary, len); if (rb_block_given_p()) { long i; if (argc == 2) { rb_warn("block supersedes default value argument"); } for (i=0; i;T;;];0;[;{;IC; "Replaces the content of +self+ with the content of +other_array+; returns +self+: a = [:foo, 'bar', 2] a.replace(['foo', :bar, 3]) # => ["foo", :bar, 3] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"replace(other_array);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@d;![;"I"@return [self];T;#0;$@d;.F;Bi;C0;7[[I"other_array;T0;$@d;![;"I"Replaces the content of +self+ with the content of +other_array+; returns +self+: a = [:foo, 'bar', 2] a.replace(['foo', :bar, 3]) # => ["foo", :bar, 3] @overload replace(other_array) @return [self];T;#0;$@d;.F;/o;0;1T;2i5;3i;;%@;9I"IVALUE rb_ary_replace(VALUE copy, VALUE orig) { rb_ary_modify_check(copy); orig = to_ary(orig); if (copy == orig) return copy; if (RARRAY_LEN(orig) <= RARRAY_EMBED_LEN_MAX) { VALUE shared_root = 0; if (ARY_OWNS_HEAP_P(copy)) { ary_heap_free(copy); } else if (ARY_SHARED_P(copy)) { shared_root = ARY_SHARED_ROOT(copy); FL_UNSET_SHARED(copy); } FL_SET_EMBED(copy); ary_memcpy(copy, 0, RARRAY_LEN(orig), RARRAY_CONST_PTR_TRANSIENT(orig)); if (shared_root) { rb_ary_decrement_share(shared_root); } ARY_SET_LEN(copy, RARRAY_LEN(orig)); } else { VALUE shared_root = ary_make_shared(orig); if (ARY_OWNS_HEAP_P(copy)) { ary_heap_free(copy); } else { rb_ary_unshare_safe(copy); } FL_UNSET_EMBED(copy); ARY_SET_PTR(copy, ARY_HEAP_PTR(orig)); ARY_SET_LEN(copy, ARY_HEAP_LEN(orig)); rb_ary_set_shared(copy, shared_root); } ary_verify(copy); return copy; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Array#inspect;F;7[;[[@iC ;T;;J;0;[;{;IC; "Returns the new \String formed by calling method #inspect on each array element: a = [:foo, 'bar', 2] a.inspect # => "[:foo, \"bar\", 2]" Array#to_s is an alias for Array#inspect. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the new \String formed by calling method #inspect on each array element: a = [:foo, 'bar', 2] a.inspect # => "[:foo, \"bar\", 2]" Array#to_s is an alias for Array#inspect. @overload inspect;T;#0;$o;4;5F;6;;;;&I"Array#to_s;F;7[;[[@iQ ;F;;G;;;[;{;@;%@;9I"static VALUE rb_ary_inspect(VALUE ary) { if (RARRAY_LEN(ary) == 0) return rb_usascii_str_new2("[]"); return rb_exec_recursive(inspect_ary, ary, 0); };T;:I"static VALUE;T;.F;/o;0;1T;2i7 ;3i? ;%@;9I"static VALUE rb_ary_inspect(VALUE ary) { if (RARRAY_LEN(ary) == 0) return rb_usascii_str_new2("[]"); return rb_exec_recursive(inspect_ary, ary, 0); };T;:@;;T@o;4;5F;6;;;;&I"Array#to_a;F;7[;[[@ib ;T;;;0;[;{;IC; "When +self+ is an instance of \Array, returns +self+: a = [:foo, 'bar', 2] a.to_a # => [:foo, "bar", 2] Otherwise, returns a new \Array containing the elements of +self+: class MyArray < Array; end a = MyArray.new(['foo', 'bar', 'two']) a.instance_of?(Array) # => false a.kind_of?(Array) # => true a1 = a.to_a a1 # => ["foo", "bar", "two"] a1.class # => Array # Not MyArray ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_a;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"When +self+ is an instance of \Array, returns +self+: a = [:foo, 'bar', 2] a.to_a # => [:foo, "bar", 2] Otherwise, returns a new \Array containing the elements of +self+: class MyArray < Array; end a = MyArray.new(['foo', 'bar', 'two']) a.instance_of?(Array) # => false a.kind_of?(Array) # => true a1 = a.to_a a1 # => ["foo", "bar", "two"] a1.class # => Array # Not MyArray @overload to_a @return [self];T;#0;$@;.F;/o;0;1T;2iP ;3i_ ;%@;9I"static VALUE rb_ary_to_a(VALUE ary) { if (rb_obj_class(ary) != rb_cArray) { VALUE dup = rb_ary_new2(RARRAY_LEN(ary)); rb_ary_replace(dup, ary); return dup; } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#to_h;F;7[;[[@i ;T;;;0;[;{;IC; "Returns a new \Hash formed from +self+. When a block is given, calls the block with each array element; the block must return a 2-element \Array whose two elements form a key-value pair in the returned \Hash: a = ['foo', :bar, 1, [2, 3], {baz: 4}] h = a.to_h {|item| [item, item] } h # => {"foo"=>"foo", :bar=>:bar, 1=>1, [2, 3]=>[2, 3], {:baz=>4}=>{:baz=>4}} When no block is given, +self+ must be an \Array of 2-element sub-arrays, each sub-array is formed into a key-value pair in the new \Hash: [].to_h # => {} a = [['foo', 'zero'], ['bar', 'one'], ['baz', 'two']] h = a.to_h h # => {"foo"=>"zero", "bar"=>"one", "baz"=>"two"} ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_h;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" to_h;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" item;T;$@;![;"I"@yield [item];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a new \Hash formed from +self+. When a block is given, calls the block with each array element; the block must return a 2-element \Array whose two elements form a key-value pair in the returned \Hash: a = ['foo', :bar, 1, [2, 3], {baz: 4}] h = a.to_h {|item| [item, item] } h # => {"foo"=>"foo", :bar=>:bar, 1=>1, [2, 3]=>[2, 3], {:baz=>4}=>{:baz=>4}} When no block is given, +self+ must be an \Array of 2-element sub-arrays, each sub-array is formed into a key-value pair in the new \Hash: [].to_h # => {} a = [['foo', 'zero'], ['bar', 'one'], ['baz', 'two']] h = a.to_h h # => {"foo"=>"zero", "bar"=>"one", "baz"=>"two"} @overload to_h @overload to_h @yield [item];T;#0;$@;.F;/o;0;1T;2im ;3i ;%@;9I"static VALUE rb_ary_to_h(VALUE ary) { long i; VALUE hash = rb_hash_new_with_size(RARRAY_LEN(ary)); int block_given = rb_block_given_p(); for (i=0; iI" overload;F;?0;;;@0;:I" to_ary;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"8Returns +self+. @overload to_ary @return [self];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"@static VALUE rb_ary_to_ary_m(VALUE ary) { return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Array#==;F;7[[I" ary2;T0;[[@id;T;;F;0;[;{;IC; "eReturns +true+ if both array.size == other_array.size and for each index +i+ in +array+, array[i] == other_array[i]: a0 = [:foo, 'bar', 2] a1 = [:foo, 'bar', 2.0] a1 == a0 # => true [] == [] # => true Otherwise, returns +false+. This method is different from method Array#eql?, which compares elements using Object#eql?. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(other_array);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"other_array;T0;$@;![;"I"Returns +true+ if both array.size == other_array.size and for each index +i+ in +array+, array[i] == other_array[i]: a0 = [:foo, 'bar', 2] a1 = [:foo, 'bar', 2.0] a1 == a0 # => true [] == [] # => true Otherwise, returns +false+. This method is different from method Array#eql?, which compares elements using Object#eql?. @overload ==(other_array) @return [Boolean];T;#0;$@;.F;/o;0;1T;2iS;3ia;%@;9I"static VALUE rb_ary_equal(VALUE ary1, VALUE ary2) { if (ary1 == ary2) return Qtrue; if (!RB_TYPE_P(ary2, T_ARRAY)) { if (!rb_respond_to(ary2, idTo_ary)) { return Qfalse; } return rb_equal(ary2, ary1); } if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse; if (RARRAY_CONST_PTR_TRANSIENT(ary1) == RARRAY_CONST_PTR_TRANSIENT(ary2)) return Qtrue; return rb_exec_recursive_paired(recursive_equal, ary1, ary2, ary2); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#eql?;F;7[[I" ary2;T0;[[@i;T;;V;0;[;{;IC; "aReturns +true+ if +self+ and +other_array+ are the same size, and if, for each index +i+ in +self+, self[i].eql? other_array[i]: a0 = [:foo, 'bar', 2] a1 = [:foo, 'bar', 2] a1.eql?(a0) # => true Otherwise, returns +false+. This method is different from method {Array#==}[#method-i-3D-3D], which compares using method Object#==.;T;[o;= ;>I" overload;F;?0;;V;@0;:I"eql? other_array;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"other_array;T0;$@;![;"I"Returns +true+ if +self+ and +other_array+ are the same size, and if, for each index +i+ in +self+, self[i].eql? other_array[i]: a0 = [:foo, 'bar', 2] a1 = [:foo, 'bar', 2] a1.eql?(a0) # => true Otherwise, returns +false+. This method is different from method {Array#==}[#method-i-3D-3D], which compares using method Object#==. @overload eql? other_array @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"hstatic VALUE rb_ary_eql(VALUE ary1, VALUE ary2) { if (ary1 == ary2) return Qtrue; if (!RB_TYPE_P(ary2, T_ARRAY)) return Qfalse; if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse; if (RARRAY_CONST_PTR_TRANSIENT(ary1) == RARRAY_CONST_PTR_TRANSIENT(ary2)) return Qtrue; return rb_exec_recursive_paired(recursive_eql, ary1, ary2, ary2); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#hash;F;7[;[[@i;T;;X;0;[;{;IC; "Returns the integer hash value for +self+. Two arrays with the same content will have the same hash code (and will compare using eql?): [0, 1, 2].hash == [0, 1, 2].hash # => true [0, 1, 2].hash == [0, 1, 3].hash # => false ;T;[o;= ;>I" overload;F;?0;;X;@0;:I" hash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@8;![;"I"@return [Integer];T;#0;$@8;.F;Bi;C0;7[;$@8;![;"I"Returns the integer hash value for +self+. Two arrays with the same content will have the same hash code (and will compare using eql?): [0, 1, 2].hash == [0, 1, 2].hash # => true [0, 1, 2].hash == [0, 1, 3].hash # => false @overload hash @return [Integer];T;#0;$@8;.F;/o;0;1T;2i;3i;%@;9I"Ostatic VALUE rb_ary_hash(VALUE ary) { long i; st_index_t h; VALUE n; h = rb_hash_start(RARRAY_LEN(ary)); h = rb_hash_uint(h, (st_index_t)rb_ary_hash); for (i=0; i :foo a[2] # => 2 a # => [:foo, "bar", 2] If +index+ is negative, counts relative to the end of +self+: a = [:foo, 'bar', 2] a[-1] # => 2 a[-2] # => "bar" If +index+ is out of range, returns +nil+. When two \Integer arguments +start+ and +length+ are given, returns a new \Array of size +length+ containing successive elements beginning at offset +start+: a = [:foo, 'bar', 2] a[0, 2] # => [:foo, "bar"] a[1, 2] # => ["bar", 2] If start + length is greater than self.length, returns all elements from offset +start+ to the end: a = [:foo, 'bar', 2] a[0, 4] # => [:foo, "bar", 2] a[1, 3] # => ["bar", 2] a[2, 2] # => [2] If start == self.size and length >= 0, returns a new empty \Array. If +length+ is negative, returns +nil+. When a single \Range argument +range+ is given, treats range.min as +start+ above and range.size as +length+ above: a = [:foo, 'bar', 2] a[0..1] # => [:foo, "bar"] a[1..2] # => ["bar", 2] Special case: If range.start == a.size, returns a new empty \Array. If range.end is negative, calculates the end index from the end: a = [:foo, 'bar', 2] a[0..-1] # => [:foo, "bar", 2] a[0..-2] # => [:foo, "bar"] a[0..-3] # => [:foo] If range.start is negative, calculates the start index from the end: a = [:foo, 'bar', 2] a[-1..2] # => [2] a[-2..2] # => ["bar", 2] a[-3..2] # => [:foo, "bar", 2] If range.start is larger than the array size, returns +nil+. a = [:foo, 'bar', 2] a[4..1] # => nil a[4..0] # => nil a[4..-1] # => nil When a single Enumerator::ArithmeticSequence argument +aseq+ is given, returns an Array of elements corresponding to the indexes produced by the sequence. a = ['--', 'data1', '--', 'data2', '--', 'data3'] a[(1..).step(2)] # => ["data1", "data2", "data3"] Unlike slicing with range, if the start or the end of the arithmetic sequence is larger than array size, throws RangeError. a = ['--', 'data1', '--', 'data2', '--', 'data3'] a[(1..11).step(2)] # RangeError (((1..11).step(2)) out of range) a[(7..).step(2)] # RangeError (((7..).step(2)) out of range) If given a single argument, and its type is not one of the listed, tries to convert it to Integer, and raises if it is impossible: a = [:foo, 'bar', 2] # Raises TypeError (no implicit conversion of Symbol into Integer): a[:foo] Array#slice is an alias for Array#[]. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"[](index);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@S;![;"I"@return [Object, nil];T;#0;$@S;.F;Bi;C0;7[[I" index;T0;$@So;= ;>I" overload;F;?0;;;@0;:I"[](start, length);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@S;![;"I"@return [Object, nil];T;#0;$@S;.F;Bi;C0;7[[I" start;T0[I" length;T0;$@So;= ;>I" overload;F;?0;;;@0;:I"[](range);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@S;![;"I"@return [Object, nil];T;#0;$@S;.F;Bi;C0;7[[I" range;T0;$@So;= ;>I" overload;F;?0;;;@0;:I" [](aseq);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@S;![;"I"@return [Object, nil];T;#0;$@S;.F;Bi;C0;7[[I" aseq;T0;$@So;= ;>I" overload;F;?0;;;@0;:I"slice(index);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@S;![;"I"@return [Object, nil];T;#0;$@S;.F;Bi;C0;7[[I" index;T0;$@So;= ;>I" overload;F;?0;;;@0;:I"slice(start, length);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@S;![;"I"@return [Object, nil];T;#0;$@S;.F;Bi;C0;7[[I" start;T0[I" length;T0;$@So;= ;>I" overload;F;?0;;;@0;:I"slice(range);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@S;![;"I"@return [Object, nil];T;#0;$@S;.F;Bi;C0;7[[I" range;T0;$@So;= ;>I" overload;F;?0;;;@0;:I"slice(aseq);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@S;![;"I"@return [Object, nil];T;#0;$@S;.F;Bi;C0;7[[I" aseq;T0;$@S;![;"I" Returns elements from +self+; does not modify +self+. When a single \Integer argument +index+ is given, returns the element at offset +index+: a = [:foo, 'bar', 2] a[0] # => :foo a[2] # => 2 a # => [:foo, "bar", 2] If +index+ is negative, counts relative to the end of +self+: a = [:foo, 'bar', 2] a[-1] # => 2 a[-2] # => "bar" If +index+ is out of range, returns +nil+. When two \Integer arguments +start+ and +length+ are given, returns a new \Array of size +length+ containing successive elements beginning at offset +start+: a = [:foo, 'bar', 2] a[0, 2] # => [:foo, "bar"] a[1, 2] # => ["bar", 2] If start + length is greater than self.length, returns all elements from offset +start+ to the end: a = [:foo, 'bar', 2] a[0, 4] # => [:foo, "bar", 2] a[1, 3] # => ["bar", 2] a[2, 2] # => [2] If start == self.size and length >= 0, returns a new empty \Array. If +length+ is negative, returns +nil+. When a single \Range argument +range+ is given, treats range.min as +start+ above and range.size as +length+ above: a = [:foo, 'bar', 2] a[0..1] # => [:foo, "bar"] a[1..2] # => ["bar", 2] Special case: If range.start == a.size, returns a new empty \Array. If range.end is negative, calculates the end index from the end: a = [:foo, 'bar', 2] a[0..-1] # => [:foo, "bar", 2] a[0..-2] # => [:foo, "bar"] a[0..-3] # => [:foo] If range.start is negative, calculates the start index from the end: a = [:foo, 'bar', 2] a[-1..2] # => [2] a[-2..2] # => ["bar", 2] a[-3..2] # => [:foo, "bar", 2] If range.start is larger than the array size, returns +nil+. a = [:foo, 'bar', 2] a[4..1] # => nil a[4..0] # => nil a[4..-1] # => nil When a single Enumerator::ArithmeticSequence argument +aseq+ is given, returns an Array of elements corresponding to the indexes produced by the sequence. a = ['--', 'data1', '--', 'data2', '--', 'data3'] a[(1..).step(2)] # => ["data1", "data2", "data3"] Unlike slicing with range, if the start or the end of the arithmetic sequence is larger than array size, throws RangeError. a = ['--', 'data1', '--', 'data2', '--', 'data3'] a[(1..11).step(2)] # RangeError (((1..11).step(2)) out of range) a[(7..).step(2)] # RangeError (((7..).step(2)) out of range) If given a single argument, and its type is not one of the listed, tries to convert it to Integer, and raises if it is impossible: a = [:foo, 'bar', 2] # Raises TypeError (no implicit conversion of Symbol into Integer): a[:foo] Array#slice is an alias for Array#[]. @overload [](index) @return [Object, nil] @overload [](start, length) @return [Object, nil] @overload [](range) @return [Object, nil] @overload [](aseq) @return [Object, nil] @overload slice(index) @return [Object, nil] @overload slice(start, length) @return [Object, nil] @overload slice(range) @return [Object, nil] @overload slice(aseq) @return [Object, nil];T;#0;$@S;.F;/o;0;1T;2i;3i;%@;9I"VALUE rb_ary_aref(int argc, const VALUE *argv, VALUE ary) { rb_check_arity(argc, 1, 2); if (argc == 2) { return rb_ary_aref2(ary, argv[0], argv[1]); } return rb_ary_aref1(ary, argv[0]); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Array#[]=;F;7[[@90;[[@iS ;T;;8;0;[;{;IC; " Assigns elements in +self+; returns the given +object+. When \Integer argument +index+ is given, assigns +object+ to an element in +self+. If +index+ is non-negative, assigns +object+ the element at offset +index+: a = [:foo, 'bar', 2] a[0] = 'foo' # => "foo" a # => ["foo", "bar", 2] If +index+ is greater than self.length, extends the array: a = [:foo, 'bar', 2] a[7] = 'foo' # => "foo" a # => [:foo, "bar", 2, nil, nil, nil, nil, "foo"] If +index+ is negative, counts backwards from the end of the array: a = [:foo, 'bar', 2] a[-1] = 'two' # => "two" a # => [:foo, "bar", "two"] When \Integer arguments +start+ and +length+ are given and +object+ is not an \Array, removes length - 1 elements beginning at offset +start+, and assigns +object+ at offset +start+: a = [:foo, 'bar', 2] a[0, 2] = 'foo' # => "foo" a # => ["foo", 2] If +start+ is negative, counts backwards from the end of the array: a = [:foo, 'bar', 2] a[-2, 2] = 'foo' # => "foo" a # => [:foo, "foo"] If +start+ is non-negative and outside the array ( >= self.size), extends the array with +nil+, assigns +object+ at offset +start+, and ignores +length+: a = [:foo, 'bar', 2] a[6, 50] = 'foo' # => "foo" a # => [:foo, "bar", 2, nil, nil, nil, "foo"] If +length+ is zero, shifts elements at and following offset +start+ and assigns +object+ at offset +start+: a = [:foo, 'bar', 2] a[1, 0] = 'foo' # => "foo" a # => [:foo, "foo", "bar", 2] If +length+ is too large for the existing array, does not extend the array: a = [:foo, 'bar', 2] a[1, 5] = 'foo' # => "foo" a # => [:foo, "foo"] When \Range argument +range+ is given and +object+ is an \Array, removes length - 1 elements beginning at offset +start+, and assigns +object+ at offset +start+: a = [:foo, 'bar', 2] a[0..1] = 'foo' # => "foo" a # => ["foo", 2] if range.begin is negative, counts backwards from the end of the array: a = [:foo, 'bar', 2] a[-2..2] = 'foo' # => "foo" a # => [:foo, "foo"] If the array length is less than range.begin, assigns +object+ at offset range.begin, and ignores +length+: a = [:foo, 'bar', 2] a[6..50] = 'foo' # => "foo" a # => [:foo, "bar", 2, nil, nil, nil, "foo"] If range.end is zero, shifts elements at and following offset +start+ and assigns +object+ at offset +start+: a = [:foo, 'bar', 2] a[1..0] = 'foo' # => "foo" a # => [:foo, "foo", "bar", 2] If range.end is negative, assigns +object+ at offset +start+, retains range.end.abs -1 elements past that, and removes those beyond: a = [:foo, 'bar', 2] a[1..-1] = 'foo' # => "foo" a # => [:foo, "foo"] a = [:foo, 'bar', 2] a[1..-2] = 'foo' # => "foo" a # => [:foo, "foo", 2] a = [:foo, 'bar', 2] a[1..-3] = 'foo' # => "foo" a # => [:foo, "foo", "bar", 2] a = [:foo, 'bar', 2] If range.end is too large for the existing array, replaces array elements, but does not extend the array with +nil+ values: a = [:foo, 'bar', 2] a[1..5] = 'foo' # => "foo" a # => [:foo, "foo"] ;T;[o;= ;>I" overload;F;?0;;8;@0;:I"[]=(index);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I" index;T0;$@o;= ;>I" overload;F;?0;;8;@0;:I"[]=(start, length);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I" start;T0[I" length;T0;$@o;= ;>I" overload;F;?0;;8;@0;:I"[]=(range);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I" range;T0;$@;![;"I" Assigns elements in +self+; returns the given +object+. When \Integer argument +index+ is given, assigns +object+ to an element in +self+. If +index+ is non-negative, assigns +object+ the element at offset +index+: a = [:foo, 'bar', 2] a[0] = 'foo' # => "foo" a # => ["foo", "bar", 2] If +index+ is greater than self.length, extends the array: a = [:foo, 'bar', 2] a[7] = 'foo' # => "foo" a # => [:foo, "bar", 2, nil, nil, nil, nil, "foo"] If +index+ is negative, counts backwards from the end of the array: a = [:foo, 'bar', 2] a[-1] = 'two' # => "two" a # => [:foo, "bar", "two"] When \Integer arguments +start+ and +length+ are given and +object+ is not an \Array, removes length - 1 elements beginning at offset +start+, and assigns +object+ at offset +start+: a = [:foo, 'bar', 2] a[0, 2] = 'foo' # => "foo" a # => ["foo", 2] If +start+ is negative, counts backwards from the end of the array: a = [:foo, 'bar', 2] a[-2, 2] = 'foo' # => "foo" a # => [:foo, "foo"] If +start+ is non-negative and outside the array ( >= self.size), extends the array with +nil+, assigns +object+ at offset +start+, and ignores +length+: a = [:foo, 'bar', 2] a[6, 50] = 'foo' # => "foo" a # => [:foo, "bar", 2, nil, nil, nil, "foo"] If +length+ is zero, shifts elements at and following offset +start+ and assigns +object+ at offset +start+: a = [:foo, 'bar', 2] a[1, 0] = 'foo' # => "foo" a # => [:foo, "foo", "bar", 2] If +length+ is too large for the existing array, does not extend the array: a = [:foo, 'bar', 2] a[1, 5] = 'foo' # => "foo" a # => [:foo, "foo"] When \Range argument +range+ is given and +object+ is an \Array, removes length - 1 elements beginning at offset +start+, and assigns +object+ at offset +start+: a = [:foo, 'bar', 2] a[0..1] = 'foo' # => "foo" a # => ["foo", 2] if range.begin is negative, counts backwards from the end of the array: a = [:foo, 'bar', 2] a[-2..2] = 'foo' # => "foo" a # => [:foo, "foo"] If the array length is less than range.begin, assigns +object+ at offset range.begin, and ignores +length+: a = [:foo, 'bar', 2] a[6..50] = 'foo' # => "foo" a # => [:foo, "bar", 2, nil, nil, nil, "foo"] If range.end is zero, shifts elements at and following offset +start+ and assigns +object+ at offset +start+: a = [:foo, 'bar', 2] a[1..0] = 'foo' # => "foo" a # => [:foo, "foo", "bar", 2] If range.end is negative, assigns +object+ at offset +start+, retains range.end.abs -1 elements past that, and removes those beyond: a = [:foo, 'bar', 2] a[1..-1] = 'foo' # => "foo" a # => [:foo, "foo"] a = [:foo, 'bar', 2] a[1..-2] = 'foo' # => "foo" a # => [:foo, "foo", 2] a = [:foo, 'bar', 2] a[1..-3] = 'foo' # => "foo" a # => [:foo, "foo", "bar", 2] a = [:foo, 'bar', 2] If range.end is too large for the existing array, replaces array elements, but does not extend the array with +nil+ values: a = [:foo, 'bar', 2] a[1..5] = 'foo' # => "foo" a # => [:foo, "foo"] @overload []=(index) @return [Object] @overload []=(start, length) @return [Object] @overload []=(range) @return [Object];T;#0;$@;.F;/o;0;1T;2i;3iR ;%@;9I"static VALUE rb_ary_aset(int argc, VALUE *argv, VALUE ary) { long offset, beg, len; rb_check_arity(argc, 2, 3); rb_ary_modify_check(ary); if (argc == 3) { beg = NUM2LONG(argv[0]); len = NUM2LONG(argv[1]); return ary_aset_by_rb_ary_splice(ary, beg, len, argv[2]); } if (FIXNUM_P(argv[0])) { offset = FIX2LONG(argv[0]); return ary_aset_by_rb_ary_store(ary, offset, argv[1]); } if (rb_range_beg_len(argv[0], &beg, &len, RARRAY_LEN(ary), 1)) { /* check if idx is Range */ return ary_aset_by_rb_ary_splice(ary, beg, len, argv[1]); } offset = NUM2LONG(argv[0]); return ary_aset_by_rb_ary_store(ary, offset, argv[1]); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Array#at;F;7[[I"pos;T0;[[@iE;T;:at;0;[;{;IC; "Returns the element at \Integer offset +index+; does not modify +self+. a = [:foo, 'bar', 2] a.at(0) # => :foo a.at(2) # => 2 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"at(index);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@$;![;"I"@return [Object];T;#0;$@$;.F;Bi;C0;7[[I" index;T0;$@$;![;"I"Returns the element at \Integer offset +index+; does not modify +self+. a = [:foo, 'bar', 2] a.at(0) # => :foo a.at(2) # => 2 @overload at(index) @return [Object];T;#0;$@$;.F;/o;0;1T;2i;;3iB;%@;9I"[VALUE rb_ary_at(VALUE ary, VALUE pos) { return rb_ary_entry(ary, NUM2LONG(pos)); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Array#fetch;F;7[[@90;[[@i;T;;9;0;[;{;IC; "=Returns the element at offset +index+. With the single \Integer argument +index+, returns the element at offset +index+: a = [:foo, 'bar', 2] a.fetch(1) # => "bar" If +index+ is negative, counts from the end of the array: a = [:foo, 'bar', 2] a.fetch(-1) # => 2 a.fetch(-2) # => "bar" With arguments +index+ and +default_value+, returns the element at offset +index+ if index is in range, otherwise returns +default_value+: a = [:foo, 'bar', 2] a.fetch(1, nil) # => "bar" With argument +index+ and a block, returns the element at offset +index+ if index is in range (and the block is not called); otherwise calls the block with index and returns its return value: a = [:foo, 'bar', 2] a.fetch(1) {|index| raise 'Cannot happen' } # => "bar" a.fetch(50) {|index| "Value for #{index}" } # => "Value for 50" ;T;[o;= ;>I" overload;F;?0;;9;@0;:I"fetch(index);T;IC; ";T;[;![;"I";T;#0;$@C;.F;Bi;C0;7[[I" index;T0;$@Co;= ;>I" overload;F;?0;;9;@0;:I" fetch(index, default_value);T;IC; ";T;[;![;"I";T;#0;$@C;.F;Bi;C0;7[[I" index;T0[I"default_value;T0;$@Co;= ;>I" overload;F;?0;;9;@0;:I"fetch(index);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" index;T;$@C;![;"I"@yield [index];T;#0;$@C;.F;Bi;C0;7[[I" index;T0;$@C;![;"I"Returns the element at offset +index+. With the single \Integer argument +index+, returns the element at offset +index+: a = [:foo, 'bar', 2] a.fetch(1) # => "bar" If +index+ is negative, counts from the end of the array: a = [:foo, 'bar', 2] a.fetch(-1) # => 2 a.fetch(-2) # => "bar" With arguments +index+ and +default_value+, returns the element at offset +index+ if index is in range, otherwise returns +default_value+: a = [:foo, 'bar', 2] a.fetch(1, nil) # => "bar" With argument +index+ and a block, returns the element at offset +index+ if index is in range (and the block is not called); otherwise calls the block with index and returns its return value: a = [:foo, 'bar', 2] a.fetch(1) {|index| raise 'Cannot happen' } # => "bar" a.fetch(50) {|index| "Value for #{index}" } # => "Value for 50" @overload fetch(index) @overload fetch(index, default_value) @overload fetch(index) @yield [index];T;#0;$@C;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_ary_fetch(int argc, VALUE *argv, VALUE ary) { VALUE pos, ifnone; long block_given; long idx; rb_scan_args(argc, argv, "11", &pos, &ifnone); block_given = rb_block_given_p(); if (block_given && argc == 2) { rb_warn("block supersedes default value argument"); } idx = NUM2LONG(pos); if (idx < 0) { idx += RARRAY_LEN(ary); } if (idx < 0 || RARRAY_LEN(ary) <= idx) { if (block_given) return rb_yield(pos); if (argc == 1) { rb_raise(rb_eIndexError, "index %ld outside of array bounds: %ld...%ld", idx - (idx < 0 ? RARRAY_LEN(ary) : 0), -RARRAY_LEN(ary), RARRAY_LEN(ary)); } return ifnone; } return RARRAY_AREF(ary, idx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#first;F;7[[@90;[[@ih;T;;;0;[;{;IC; "IReturns elements from +self+; does not modify +self+. When no argument is given, returns the first element: a = [:foo, 'bar', 2] a.first # => :foo a # => [:foo, "bar", 2] If +self+ is empty, returns +nil+. When non-negative \Integer argument +n+ is given, returns the first +n+ elements in a new \Array: a = [:foo, 'bar', 2] a.first(2) # => [:foo, "bar"] If n >= array.size, returns all elements: a = [:foo, 'bar', 2] a.first(50) # => [:foo, "bar", 2] If n == 0 returns an new empty \Array: a = [:foo, 'bar', 2] a.first(0) # [] Related: #last. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" first;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@w;![;"I"@return [Object, nil];T;#0;$@w;.F;Bi;C0;7[;$@wo;= ;>I" overload;F;?0;;;@0;:I" first(n);T;IC; ";T;[;![;"I";T;#0;$@w;.F;Bi;C0;7[[I"n;T0;$@w;![;"I"Returns elements from +self+; does not modify +self+. When no argument is given, returns the first element: a = [:foo, 'bar', 2] a.first # => :foo a # => [:foo, "bar", 2] If +self+ is empty, returns +nil+. When non-negative \Integer argument +n+ is given, returns the first +n+ elements in a new \Array: a = [:foo, 'bar', 2] a.first(2) # => [:foo, "bar"] If n >= array.size, returns all elements: a = [:foo, 'bar', 2] a.first(50) # => [:foo, "bar", 2] If n == 0 returns an new empty \Array: a = [:foo, 'bar', 2] a.first(0) # [] Related: #last. @overload first @return [Object, nil] @overload first(n);T;#0;$@w;.F;/o;0;1T;2iK;3if;%@;9I"static VALUE rb_ary_first(int argc, VALUE *argv, VALUE ary) { if (argc == 0) { if (RARRAY_LEN(ary) == 0) return Qnil; return RARRAY_AREF(ary, 0); } else { return ary_take_first_or_last(argc, argv, ary, ARY_TAKE_FIRST); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#last;F;7[[@90;[[@i;T;: last;0;[;{;IC; "@Returns elements from +self+; +self+ is not modified. When no argument is given, returns the last element: a = [:foo, 'bar', 2] a.last # => 2 a # => [:foo, "bar", 2] If +self+ is empty, returns +nil+. When non-negative \Innteger argument +n+ is given, returns the last +n+ elements in a new \Array: a = [:foo, 'bar', 2] a.last(2) # => ["bar", 2] If n >= array.size, returns all elements: a = [:foo, 'bar', 2] a.last(50) # => [:foo, "bar", 2] If n == 0, returns an new empty \Array: a = [:foo, 'bar', 2] a.last(0) # [] Related: #first. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" last;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@;![;"I"@return [Object, nil];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" last(n);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"n;T0;$@;![;"I"{Returns elements from +self+; +self+ is not modified. When no argument is given, returns the last element: a = [:foo, 'bar', 2] a.last # => 2 a # => [:foo, "bar", 2] If +self+ is empty, returns +nil+. When non-negative \Innteger argument +n+ is given, returns the last +n+ elements in a new \Array: a = [:foo, 'bar', 2] a.last(2) # => ["bar", 2] If n >= array.size, returns all elements: a = [:foo, 'bar', 2] a.last(50) # => [:foo, "bar", 2] If n == 0, returns an new empty \Array: a = [:foo, 'bar', 2] a.last(0) # [] Related: #first. @overload last @return [Object, nil] @overload last(n);T;#0;$@;.F;/o;0;1T;2it;3i;%@;9I"VALUE rb_ary_last(int argc, const VALUE *argv, VALUE ary) { if (argc == 0) { long len = RARRAY_LEN(ary); if (len == 0) return Qnil; return RARRAY_AREF(ary, len-1); } else { return ary_take_first_or_last(argc, argv, ary, ARY_TAKE_LAST); } };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Array#concat;F;7[[@90;[[@i;T;;;0;[;{;IC; "Adds to +array+ all elements from each \Array in +other_arrays+; returns +self+: a = [0, 1] a.concat([2, 3], [4, 5]) # => [0, 1, 2, 3, 4, 5] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"concat(*other_arrays);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[[I"*other_arrays;T0;$@;![;"I"Adds to +array+ all elements from each \Array in +other_arrays+; returns +self+: a = [0, 1] a.concat([2, 3], [4, 5]) # => [0, 1, 2, 3, 4, 5] @overload concat(*other_arrays) @return [self];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"kstatic VALUE rb_ary_concat_multi(int argc, VALUE *argv, VALUE ary) { rb_ary_modify_check(ary); if (argc == 1) { rb_ary_concat(ary, argv[0]); } else if (argc > 1) { int i; VALUE args = rb_ary_tmp_new(argc); for (i = 0; i < argc; i++) { rb_ary_concat(args, argv[i]); } ary_append(ary, args); } ary_verify(ary); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#union;F;7[[@90;[[@iX;T;: union;0;[;{;IC; "Returns a new \Array that is the union of +self+ and all given Arrays +other_arrays+; duplicates are removed; order is preserved; items are compared using eql?: [0, 1, 2, 3].union([4, 5], [6, 7]) # => [0, 1, 2, 3, 4, 5, 6, 7] [0, 1, 1].union([2, 1], [3, 1]) # => [0, 1, 2, 3] [0, 1, 2, 3].union([3, 2], [1, 0]) # => [0, 1, 2, 3] Returns a copy of +self+ if no arguments given. Related: Array#|. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"union(*other_arrays);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"*other_arrays;T0;$@;![;"I"Returns a new \Array that is the union of +self+ and all given Arrays +other_arrays+; duplicates are removed; order is preserved; items are compared using eql?: [0, 1, 2, 3].union([4, 5], [6, 7]) # => [0, 1, 2, 3, 4, 5, 6, 7] [0, 1, 1].union([2, 1], [3, 1]) # => [0, 1, 2, 3] [0, 1, 2, 3].union([3, 2], [1, 0]) # => [0, 1, 2, 3] Returns a copy of +self+ if no arguments given. Related: Array#|. @overload union(*other_arrays);T;#0;$@;.F;/o;0;1T;2iI;3iT;%@;9I"static VALUE rb_ary_union_multi(int argc, VALUE *argv, VALUE ary) { int i; long sum; VALUE hash, ary_union; sum = RARRAY_LEN(ary); for (i = 0; i < argc; i++) { argv[i] = to_ary(argv[i]); sum += RARRAY_LEN(argv[i]); } if (sum <= SMALL_ARRAY_LEN) { ary_union = rb_ary_new(); rb_ary_union(ary_union, ary); for (i = 0; i < argc; i++) rb_ary_union(ary_union, argv[i]); return ary_union; } hash = ary_make_hash(ary); for (i = 0; i < argc; i++) rb_ary_union_hash(hash, argv[i]); ary_union = rb_hash_values(hash); ary_recycle_hash(hash); return ary_union; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#difference;F;7[[@90;[[@i;T;:difference;0;[;{;IC; "Returns a new \Array containing only those elements from +self+ that are not found in any of the Arrays +other_arrays+; items are compared using eql?; order from +self+ is preserved: [0, 1, 1, 2, 1, 1, 3, 1, 1].difference([1]) # => [0, 2, 3] [0, 1, 2, 3].difference([3, 0], [1, 3]) # => [2] [0, 1, 2].difference([4]) # => [0, 1, 2] Returns a copy of +self+ if no arguments given. Related: Array#-. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"difference(*other_arrays);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"*other_arrays;T0;$@;![;"I"Returns a new \Array containing only those elements from +self+ that are not found in any of the Arrays +other_arrays+; items are compared using eql?; order from +self+ is preserved: [0, 1, 1, 2, 1, 1, 3, 1, 1].difference([1]) # => [0, 2, 3] [0, 1, 2, 3].difference([3, 0], [1, 3]) # => [2] [0, 1, 2].difference([4]) # => [0, 1, 2] Returns a copy of +self+ if no arguments given. Related: Array#-. @overload difference(*other_arrays);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_ary_difference_multi(int argc, VALUE *argv, VALUE ary) { VALUE ary_diff; long i, length; volatile VALUE t0; bool *is_hash = ALLOCV_N(bool, t0, argc); ary_diff = rb_ary_new(); length = RARRAY_LEN(ary); for (i = 0; i < argc; i++) { argv[i] = to_ary(argv[i]); is_hash[i] = (length > SMALL_ARRAY_LEN && RARRAY_LEN(argv[i]) > SMALL_ARRAY_LEN); if (is_hash[i]) argv[i] = ary_make_hash(argv[i]); } for (i = 0; i < RARRAY_LEN(ary); i++) { int j; VALUE elt = rb_ary_elt(ary, i); for (j = 0; j < argc; j++) { if (is_hash[j]) { if (rb_hash_stlike_lookup(argv[j], RARRAY_AREF(ary, i), NULL)) break; } else { if (rb_ary_includes_by_eql(argv[j], elt)) break; } } if (j == argc) rb_ary_push(ary_diff, elt); } ALLOCV_END(t0); return ary_diff; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#intersection;F;7[[@90;[[@i;T;:intersection;0;[;{;IC; "Returns a new \Array containing each element found both in +self+ and in all of the given Arrays +other_arrays+; duplicates are omitted; items are compared using eql?: [0, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1] [0, 0, 1, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1] Preserves order from +self+: [0, 1, 2].intersection([2, 1, 0]) # => [0, 1, 2] Returns a copy of +self+ if no arguments given. Related: Array#&. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" intersection(*other_arrays);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"*other_arrays;T0;$@;![;"I"Returns a new \Array containing each element found both in +self+ and in all of the given Arrays +other_arrays+; duplicates are omitted; items are compared using eql?: [0, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1] [0, 0, 1, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1] Preserves order from +self+: [0, 1, 2].intersection([2, 1, 0]) # => [0, 1, 2] Returns a copy of +self+ if no arguments given. Related: Array#&. @overload intersection(*other_arrays);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_ary_intersection_multi(int argc, VALUE *argv, VALUE ary) { VALUE result = rb_ary_dup(ary); int i; for (i = 0; i < argc; i++) { result = rb_ary_and(result, argv[i]); } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#intersect?;F;7[[I" ary2;T0;[[@i;T;:intersect?;0;[;{;IC; "Returns +true+ if the array and +other_ary+ have at least one element in common, otherwise returns +false+. a = [ 1, 2, 3 ] b = [ 3, 4, 5 ] c = [ 5, 6, 7 ] a.intersect?(b) #=> true a.intersect?(c) #=> false;T;[o;= ;>I" overload;F;?0;;;@0;:I"intersect?(other_ary);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@.;![;"I"@return [Boolean];T;#0;$@.;.F;Bi;C0;7[[I"other_ary;T0;$@.;![;"I"Returns +true+ if the array and +other_ary+ have at least one element in common, otherwise returns +false+. a = [ 1, 2, 3 ] b = [ 3, 4, 5 ] c = [ 5, 6, 7 ] a.intersect?(b) #=> true a.intersect?(c) #=> false @overload intersect?(other_ary) @return [Boolean];T;#0;$@.;.F;/o;0;1T;2iv;3i;Bi;%@;9I"static VALUE rb_ary_intersect_p(VALUE ary1, VALUE ary2) { VALUE hash, v, result, shorter, longer; st_data_t vv; long i; ary2 = to_ary(ary2); if (RARRAY_LEN(ary1) == 0 || RARRAY_LEN(ary2) == 0) return Qfalse; if (RARRAY_LEN(ary1) <= SMALL_ARRAY_LEN && RARRAY_LEN(ary2) <= SMALL_ARRAY_LEN) { for (i=0; i RARRAY_LEN(ary2)) { longer = ary1; shorter = ary2; } hash = ary_make_hash(shorter); result = Qfalse; for (i=0; i [:foo, "bar", 2, :baz] Appends +object+ as one element, even if it is another \Array: a = [:foo, 'bar', 2] a1 = a << [3, 4] a1 # => [:foo, "bar", 2, [3, 4]] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"<<(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@M;![;"I"@return [self];T;#0;$@M;.F;Bi;C0;7[[I" object;T0;$@M;![;"I"Appends +object+ to +self+; returns +self+: a = [:foo, 'bar', 2] a << :baz # => [:foo, "bar", 2, :baz] Appends +object+ as one element, even if it is another \Array: a = [:foo, 'bar', 2] a1 = a << [3, 4] a1 # => [:foo, "bar", 2, [3, 4]] @overload <<(object) @return [self];T;#0;$@M;.F;/o;0;1T;2i ;3i;%@;9I"9VALUE rb_ary_push(VALUE ary, VALUE item) { long idx = RARRAY_LEN((ary_verify(ary), ary)); VALUE target_ary = ary_ensure_room_for_push(ary, 1); RARRAY_PTR_USE_TRANSIENT(ary, ptr, { RB_OBJ_WRITE(target_ary, &ptr[idx], item); }); ARY_SET_LEN(ary, idx + 1); ary_verify(ary); return ary; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Array#push;F;7[[@90;[[@iF;T;;];0;[;{;IC; "Appends trailing elements. Appends each argument in +objects+ to +self+; returns +self+: a = [:foo, 'bar', 2] a.push(:baz, :bat) # => [:foo, "bar", 2, :baz, :bat] Appends each argument as one element, even if it is another \Array: a = [:foo, 'bar', 2] a1 = a.push([:baz, :bat], [:bam, :bad]) a1 # => [:foo, "bar", 2, [:baz, :bat], [:bam, :bad]] Array#append is an alias for \Array#push. Related: #pop, #shift, #unshift. ;T;[o;= ;>I" overload;F;?0;;];@0;:I"push(*objects);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@l;![;"I"@return [self];T;#0;$@l;.F;Bi;C0;7[[I" *objects;T0;$@l;![;"I"Appends trailing elements. Appends each argument in +objects+ to +self+; returns +self+: a = [:foo, 'bar', 2] a.push(:baz, :bat) # => [:foo, "bar", 2, :baz, :bat] Appends each argument as one element, even if it is another \Array: a = [:foo, 'bar', 2] a1 = a.push([:baz, :bat], [:bam, :bad]) a1 # => [:foo, "bar", 2, [:baz, :bat], [:bam, :bad]] Array#append is an alias for \Array#push. Related: #pop, #shift, #unshift. @overload push(*objects) @return [self];T;#0;$o;4;5F;6;;;;&I"Array#append;F;7[;[[@ig ;F;: append;;;[;{;@t;%@;9I"mstatic VALUE rb_ary_push_m(int argc, VALUE *argv, VALUE ary) { return rb_ary_cat(ary, argv, argc); };T;:I"static VALUE;T;.F;/o;0;1T;2i2;3iC;%@;9I"mstatic VALUE rb_ary_push_m(int argc, VALUE *argv, VALUE ary) { return rb_ary_cat(ary, argv, argc); };T;:@;;T@o;4;5F;6;;;;&I"Array#pop;F;7[[@90;[[@i{;T;;_;0;[;{;IC; "9Removes and returns trailing elements. When no argument is given and +self+ is not empty, removes and returns the last element: a = [:foo, 'bar', 2] a.pop # => 2 a # => [:foo, "bar"] Returns +nil+ if the array is empty. When a non-negative \Integer argument +n+ is given and is in range, removes and returns the last +n+ elements in a new \Array: a = [:foo, 'bar', 2] a.pop(2) # => ["bar", 2] If +n+ is positive and out of range, removes and returns all elements: a = [:foo, 'bar', 2] a.pop(50) # => [:foo, "bar", 2] Related: #push, #shift, #unshift. ;T;[o;= ;>I" overload;F;?0;;_;@0;:I"pop;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@;![;"I"@return [Object, nil];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;_;@0;:I" pop(n);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"n;T0;$@;![;"I"rRemoves and returns trailing elements. When no argument is given and +self+ is not empty, removes and returns the last element: a = [:foo, 'bar', 2] a.pop # => 2 a # => [:foo, "bar"] Returns +nil+ if the array is empty. When a non-negative \Integer argument +n+ is given and is in range, removes and returns the last +n+ elements in a new \Array: a = [:foo, 'bar', 2] a.pop(2) # => ["bar", 2] If +n+ is positive and out of range, removes and returns all elements: a = [:foo, 'bar', 2] a.pop(50) # => [:foo, "bar", 2] Related: #push, #shift, #unshift. @overload pop @return [Object, nil] @overload pop(n);T;#0;$@;.F;/o;0;1T;2i_;3ix;%@;9I"Bstatic VALUE rb_ary_pop_m(int argc, VALUE *argv, VALUE ary) { VALUE result; if (argc == 0) { return rb_ary_pop(ary); } rb_ary_modify_check(ary); result = ary_take_first_or_last(argc, argv, ary, ARY_TAKE_LAST); ARY_INCREASE_LEN(ary, -RARRAY_LEN(result)); ary_verify(ary); return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#shift;F;7[[@90;[[@i;T;;a;0;[;{;IC; "Removes and returns leading elements. When no argument is given, removes and returns the first element: a = [:foo, 'bar', 2] a.shift # => :foo a # => ['bar', 2] Returns +nil+ if +self+ is empty. When positive \Integer argument +n+ is given, removes the first +n+ elements; returns those elements in a new \Array: a = [:foo, 'bar', 2] a.shift(2) # => [:foo, 'bar'] a # => [2] If +n+ is as large as or larger than self.length, removes all elements; returns those elements in a new \Array: a = [:foo, 'bar', 2] a.shift(3) # => [:foo, 'bar', 2] If +n+ is zero, returns a new empty \Array; +self+ is unmodified. Related: #push, #pop, #unshift. ;T;[o;= ;>I" overload;F;?0;;a;@0;:I" shift;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@;![;"I"@return [Object, nil];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;a;@0;:I" shift(n);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"n;T0;$@;![;"I"Removes and returns leading elements. When no argument is given, removes and returns the first element: a = [:foo, 'bar', 2] a.shift # => :foo a # => ['bar', 2] Returns +nil+ if +self+ is empty. When positive \Integer argument +n+ is given, removes the first +n+ elements; returns those elements in a new \Array: a = [:foo, 'bar', 2] a.shift(2) # => [:foo, 'bar'] a # => [2] If +n+ is as large as or larger than self.length, removes all elements; returns those elements in a new \Array: a = [:foo, 'bar', 2] a.shift(3) # => [:foo, 'bar', 2] If +n+ is zero, returns a new empty \Array; +self+ is unmodified. Related: #push, #pop, #unshift. @overload shift @return [Object, nil] @overload shift(n);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"Estatic VALUE rb_ary_shift_m(int argc, VALUE *argv, VALUE ary) { VALUE result; long n; if (argc == 0) { return rb_ary_shift(ary); } rb_ary_modify_check(ary); result = ary_take_first_or_last(argc, argv, ary, ARY_TAKE_FIRST); n = RARRAY_LEN(result); rb_ary_behead(ary,n); return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#unshift;F;7[[@90;[[@ik;T;: unshift;0;[;{;IC; "Prepends the given +objects+ to +self+: a = [:foo, 'bar', 2] a.unshift(:bam, :bat) # => [:bam, :bat, :foo, "bar", 2] Array#prepend is an alias for Array#unshift. Related: #push, #pop, #shift. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"unshift(*objects);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[[I" *objects;T0;$@;![;"I"Prepends the given +objects+ to +self+: a = [:foo, 'bar', 2] a.unshift(:bam, :bat) # => [:bam, :bat, :foo, "bar", 2] Array#prepend is an alias for Array#unshift. Related: #push, #pop, #shift. @overload unshift(*objects) @return [self];T;#0;$o;4;5F;6;;;;&I"Array#prepend;F;7[;[[@ik ;F;;;;;[;{;@;%@;9I"Zstatic VALUE rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary) { long len = RARRAY_LEN(ary); VALUE target_ary; if (argc == 0) { rb_ary_modify_check(ary); return ary; } target_ary = ary_ensure_room_for_unshift(ary, argc); ary_memcpy0(ary, 0, argc, argv, target_ary); ARY_SET_LEN(ary, len + argc); return ary; };T;:I"static VALUE;T;.F;/o;0;1T;2i^;3ih;%@;9I"Zstatic VALUE rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary) { long len = RARRAY_LEN(ary); VALUE target_ary; if (argc == 0) { rb_ary_modify_check(ary); return ary; } target_ary = ary_ensure_room_for_unshift(ary, argc); ary_memcpy0(ary, 0, argc, argv, target_ary); ARY_SET_LEN(ary, len + argc); return ary; };T;:@;;T@o;4;5F;6;;;;&I"Array#insert;F;7[[@90;[[@i ;T;: insert;0;[;{;IC; " Inserts given +objects+ before or after the element at \Integer index +offset+; returns +self+. When +index+ is non-negative, inserts all given +objects+ before the element at offset +index+: a = [:foo, 'bar', 2] a.insert(1, :bat, :bam) # => [:foo, :bat, :bam, "bar", 2] Extends the array if +index+ is beyond the array (index >= self.size): a = [:foo, 'bar', 2] a.insert(5, :bat, :bam) a # => [:foo, "bar", 2, nil, nil, :bat, :bam] Does nothing if no objects given: a = [:foo, 'bar', 2] a.insert(1) a.insert(50) a.insert(-50) a # => [:foo, "bar", 2] When +index+ is negative, inserts all given +objects+ _after_ the element at offset index+self.size: a = [:foo, 'bar', 2] a.insert(-2, :bat, :bam) a # => [:foo, "bar", :bat, :bam, 2] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"insert(index, *objects);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[[I" index;T0[I" *objects;T0;$@;![;"I"BInserts given +objects+ before or after the element at \Integer index +offset+; returns +self+. When +index+ is non-negative, inserts all given +objects+ before the element at offset +index+: a = [:foo, 'bar', 2] a.insert(1, :bat, :bam) # => [:foo, :bat, :bam, "bar", 2] Extends the array if +index+ is beyond the array (index >= self.size): a = [:foo, 'bar', 2] a.insert(5, :bat, :bam) a # => [:foo, "bar", 2, nil, nil, :bat, :bam] Does nothing if no objects given: a = [:foo, 'bar', 2] a.insert(1) a.insert(50) a.insert(-50) a # => [:foo, "bar", 2] When +index+ is negative, inserts all given +objects+ _after_ the element at offset index+self.size: a = [:foo, 'bar', 2] a.insert(-2, :bat, :bam) a # => [:foo, "bar", :bat, :bam, 2] @overload insert(index, *objects) @return [self];T;#0;$@;.F;/o;0;1T;2il ;3i ;%@;9I"static VALUE rb_ary_insert(int argc, VALUE *argv, VALUE ary) { long pos; rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS); rb_ary_modify_check(ary); pos = NUM2LONG(argv[0]); if (argc == 1) return ary; if (pos == -1) { pos = RARRAY_LEN(ary); } else if (pos < 0) { long minpos = -RARRAY_LEN(ary) - 1; if (pos < minpos) { rb_raise(rb_eIndexError, "index %ld too small for array; minimum: %ld", pos, minpos); } pos++; } rb_ary_splice(ary, pos, 0, argv + 1, argc - 1); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#each;F;7[;[[@i ;T;;;0;[;{;IC; "Iterates over array elements. When a block given, passes each successive array element to the block; returns +self+: a = [:foo, 'bar', 2] a.each {|element| puts "#{element.class} #{element}" } Output: Symbol foo String bar Integer 2 Allows the array to be modified during iteration: a = [:foo, 'bar', 2] a.each {|element| puts element; a.clear if element.to_s.start_with?('b') } Output: foo bar When no block given, returns a new \Enumerator: a = [:foo, 'bar', 2] e = a.each e # => # a1 = e.each {|element| puts "#{element.class} #{element}" } Output: Symbol foo String bar Integer 2 Related: #each_index, #reverse_each. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" each;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@&o;A ;>I" return;F;?I";T;0;@[I" self;T;$@&;![;"I"$@yield [element] @return [self];T;#0;$@&;.F;Bi;C0;7[;$@&o;= ;>I" overload;F;?0;;;@0;:I" each;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@&;![;"I"@return [Enumerator];T;#0;$@&;.F;Bi;C0;7[;$@&;![;"I"Iterates over array elements. When a block given, passes each successive array element to the block; returns +self+: a = [:foo, 'bar', 2] a.each {|element| puts "#{element.class} #{element}" } Output: Symbol foo String bar Integer 2 Allows the array to be modified during iteration: a = [:foo, 'bar', 2] a.each {|element| puts element; a.clear if element.to_s.start_with?('b') } Output: foo bar When no block given, returns a new \Enumerator: a = [:foo, 'bar', 2] e = a.each e # => # a1 = e.each {|element| puts "#{element.class} #{element}" } Output: Symbol foo String bar Integer 2 Related: #each_index, #reverse_each. @overload each @yield [element] @return [self] @overload each @return [Enumerator];T;#0;$@&;.F;/o;0;1T;2i ;3i ;%@;9I"VALUE rb_ary_each(VALUE ary) { long i; ary_verify(ary); RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length); for (i=0; i 0 } Output: 0 1 When no block given, returns a new \Enumerator: a = [:foo, 'bar', 2] e = a.each_index e # => # a1 = e.each {|index| puts "#{index} #{a[index]}"} Output: 0 foo 1 bar 2 2 Related: #each, #reverse_each. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"each_index;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" index;T;$@So;A ;>I" return;F;?I";T;0;@[I" self;T;$@S;![;"I""@yield [index] @return [self];T;#0;$@S;.F;Bi;C0;7[;$@So;= ;>I" overload;F;?0;;;@0;:I"each_index;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@S;![;"I"@return [Enumerator];T;#0;$@S;.F;Bi;C0;7[;$@S;![;"I"Iterates over array indexes. When a block given, passes each successive array index to the block; returns +self+: a = [:foo, 'bar', 2] a.each_index {|index| puts "#{index} #{a[index]}" } Output: 0 foo 1 bar 2 2 Allows the array to be modified during iteration: a = [:foo, 'bar', 2] a.each_index {|index| puts index; a.clear if index > 0 } Output: 0 1 When no block given, returns a new \Enumerator: a = [:foo, 'bar', 2] e = a.each_index e # => # a1 = e.each {|index| puts "#{index} #{a[index]}"} Output: 0 foo 1 bar 2 2 Related: #each, #reverse_each. @overload each_index @yield [index] @return [self] @overload each_index @return [Enumerator];T;#0;$@S;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE rb_ary_each_index(VALUE ary) { long i; RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length); for (i=0; i # a1 = e.each {|element| puts "#{element.class} #{element}" } Output: Integer 2 String bar Symbol foo Related: #each, #each_index. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"reverse_each;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"$@yield [element] @return [self];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"reverse_each;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@;![;"I"@return [Enumerator];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"DIterates backwards over array elements. When a block given, passes, in reverse order, each element to the block; returns +self+: a = [:foo, 'bar', 2] a.reverse_each {|element| puts "#{element.class} #{element}" } Output: Integer 2 String bar Symbol foo Allows the array to be modified during iteration: a = [:foo, 'bar', 2] a.reverse_each {|element| puts element; a.clear if element.to_s.start_with?('b') } Output: 2 bar When no block given, returns a new \Enumerator: a = [:foo, 'bar', 2] e = a.reverse_each e # => # a1 = e.each {|element| puts "#{element.class} #{element}" } Output: Integer 2 String bar Symbol foo Related: #each, #each_index. @overload reverse_each @yield [element] @return [self] @overload reverse_each @return [Enumerator];T;#0;$@;.F;/o;0;1T;2i ;3i7 ;%@;9I"*static VALUE rb_ary_reverse_each(VALUE ary) { long len; RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length); len = RARRAY_LEN(ary); while (len--) { long nlen; rb_yield(RARRAY_AREF(ary, len)); nlen = RARRAY_LEN(ary); if (nlen < len) { len = nlen; } } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#length;F;7[;[[@iQ ;T;;b;0;[;{;IC; "-Returns the count of elements in +self+. ;T;[o;= ;>I" overload;F;?0;;b;@0;:I" length;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"TReturns the count of elements in +self+. @overload length @return [Integer];T;#0;$@;.F;/o;0;1T;2iJ ;3iN ;%@;9I"hstatic VALUE rb_ary_length(VALUE ary) { long len = RARRAY_LEN(ary); return LONG2NUM(len); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#size;F;7[;[[@iQ ;T;;;0;[;{;IC; "-Returns the count of elements in +self+. ;T;[o;= ;>I" overload;F;?0;;b;@0;:I" length;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2iJ ;3iN ;%@;9I"hstatic VALUE rb_ary_length(VALUE ary) { long len = RARRAY_LEN(ary); return LONG2NUM(len); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#empty?;F;7[;[[@i` ;T;;;0;[;{;IC; "RReturns +true+ if the count of elements in +self+ is zero, +false+ otherwise.;T;[o;= ;>I" overload;F;?0;;;@0;:I" empty?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"yReturns +true+ if the count of elements in +self+ is zero, +false+ otherwise. @overload empty? @return [Boolean];T;#0;$@;.F;/o;0;1T;2iX ;3i] ;Bi;%@;9I"Wstatic VALUE rb_ary_empty_p(VALUE ary) { return RBOOL(RARRAY_LEN(ary) == 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#find_index;F;7[[@90;[[@i;T;;;0;[;{;IC; "XReturns the index of a specified element. When argument +object+ is given but no block, returns the index of the first element +element+ for which object == element: a = [:foo, 'bar', 2, 'bar'] a.index('bar') # => 1 Returns +nil+ if no such element found. When both argument +object+ and a block are given, calls the block with each successive element; returns the index of the first element for which the block returns a truthy value: a = [:foo, 'bar', 2, 'bar'] a.index {|element| element == 'bar' } # => 1 Returns +nil+ if the block never returns a truthy value. When neither an argument nor a block is given, returns a new Enumerator: a = [:foo, 'bar', 2] e = a.index e # => # e.each {|element| element == 'bar' } # => 1 Array#find_index is an alias for Array#index. Related: #rindex. ;T;[o;= ;>I" overload;F;?0;: index;@0;:I"index(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@;![;"I"@return [Integer, nil];T;#0;$@;.F;Bi;C0;7[[I" object;T0;$@o;= ;>I" overload;F;?0;;;@0;:I" index;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@;![;"I",@yield [element] @return [Integer, nil];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" index;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the index of a specified element. When argument +object+ is given but no block, returns the index of the first element +element+ for which object == element: a = [:foo, 'bar', 2, 'bar'] a.index('bar') # => 1 Returns +nil+ if no such element found. When both argument +object+ and a block are given, calls the block with each successive element; returns the index of the first element for which the block returns a truthy value: a = [:foo, 'bar', 2, 'bar'] a.index {|element| element == 'bar' } # => 1 Returns +nil+ if the block never returns a truthy value. When neither an argument nor a block is given, returns a new Enumerator: a = [:foo, 'bar', 2] e = a.index e # => # e.each {|element| element == 'bar' } # => 1 Array#find_index is an alias for Array#index. Related: #rindex. @overload index(object) @return [Integer, nil] @overload index @yield [element] @return [Integer, nil] @overload index;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_ary_index(int argc, VALUE *argv, VALUE ary) { VALUE val; long i; if (argc == 0) { RETURN_ENUMERATOR(ary, 0, 0); for (i=0; iobject == element: a = [:foo, 'bar', 2, 'bar'] a.index('bar') # => 1 Returns +nil+ if no such element found. When both argument +object+ and a block are given, calls the block with each successive element; returns the index of the first element for which the block returns a truthy value: a = [:foo, 'bar', 2, 'bar'] a.index {|element| element == 'bar' } # => 1 Returns +nil+ if the block never returns a truthy value. When neither an argument nor a block is given, returns a new Enumerator: a = [:foo, 'bar', 2] e = a.index e # => # e.each {|element| element == 'bar' } # => 1 Array#find_index is an alias for Array#index. Related: #rindex. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"index(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@7;![;"I"@return [Integer, nil];T;#0;$@7;.F;Bi;C0;7[[I" object;T0;$@7o;= ;>I" overload;F;?0;;;@0;:I" index;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@7o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@7;![;"I",@yield [element] @return [Integer, nil];T;#0;$@7;.F;Bi;C0;7[;$@7o;= ;>I" overload;F;?0;;;@0;:I" index;T;IC; ";T;[;![;"I";T;#0;$@7;.F;Bi;C0;7[;$@7;![;"@3;#0;$@7;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_ary_index(int argc, VALUE *argv, VALUE ary) { VALUE val; long i; if (argc == 0) { RETURN_ENUMERATOR(ary, 0, 0); for (i=0; iobject == element. When argument +object+ is given but no block, returns the index of the last such element found: a = [:foo, 'bar', 2, 'bar'] a.rindex('bar') # => 3 Returns +nil+ if no such object found. When a block is given but no argument, calls the block with each successive element; returns the index of the last element for which the block returns a truthy value: a = [:foo, 'bar', 2, 'bar'] a.rindex {|element| element == 'bar' } # => 3 Returns +nil+ if the block never returns a truthy value. When neither an argument nor a block is given, returns a new \Enumerator: a = [:foo, 'bar', 2, 'bar'] e = a.rindex e # => # e.each {|element| element == 'bar' } # => 3 Related: #index. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"rindex(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@p;![;"I"@return [Integer, nil];T;#0;$@p;.F;Bi;C0;7[[I" object;T0;$@po;= ;>I" overload;F;?0;;;@0;:I" rindex;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@po;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@p;![;"I",@yield [element] @return [Integer, nil];T;#0;$@p;.F;Bi;C0;7[;$@po;= ;>I" overload;F;?0;;;@0;:I" rindex;T;IC; ";T;[;![;"I";T;#0;$@p;.F;Bi;C0;7[;$@p;![;"I"Returns the index of the last element for which object == element. When argument +object+ is given but no block, returns the index of the last such element found: a = [:foo, 'bar', 2, 'bar'] a.rindex('bar') # => 3 Returns +nil+ if no such object found. When a block is given but no argument, calls the block with each successive element; returns the index of the last element for which the block returns a truthy value: a = [:foo, 'bar', 2, 'bar'] a.rindex {|element| element == 'bar' } # => 3 Returns +nil+ if the block never returns a truthy value. When neither an argument nor a block is given, returns a new \Enumerator: a = [:foo, 'bar', 2, 'bar'] e = a.rindex e # => # e.each {|element| element == 'bar' } # => 3 Related: #index. @overload rindex(object) @return [Integer, nil] @overload rindex @yield [element] @return [Integer, nil] @overload rindex;T;#0;$@p;.F;/o;0;1T;2i;3i9;%@;9I"{static VALUE rb_ary_rindex(int argc, VALUE *argv, VALUE ary) { VALUE val; long i = RARRAY_LEN(ary), len; if (argc == 0) { RETURN_ENUMERATOR(ary, 0, 0); while (i--) { if (RTEST(rb_yield(RARRAY_AREF(ary, i)))) return LONG2NUM(i); if (i > (len = RARRAY_LEN(ary))) { i = len; } } return Qnil; } rb_check_arity(argc, 0, 1); val = argv[0]; if (rb_block_given_p()) rb_warn("given block not used"); while (i--) { VALUE e = RARRAY_AREF(ary, i); if (rb_equal(e, val)) { return LONG2NUM(i); } if (i > RARRAY_LEN(ary)) { break; } } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#join;F;7[[@90;[[@i ;T;;4;0;[;{;IC; "vReturns the new \String formed by joining the array elements after conversion. For each element +element+ - Uses element.to_s if +element+ is not a kind_of?(Array). - Uses recursive element.join(separator) if +element+ is a kind_of?(Array). With no argument, joins using the output field separator, $,: a = [:foo, 'bar', 2] $, # => nil a.join # => "foobar2" With \string argument +separator+, joins using that separator: a = [:foo, 'bar', 2] a.join("\n") # => "foo\nbar\n2" Joins recursively for nested Arrays: a = [:foo, [:bar, [:baz, :bat]]] a.join # => "foobarbazbat" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"->new_string;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;4;@0;:I"join(separator = $,);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"separator;TI"$,;T;$@;![;"I"Returns the new \String formed by joining the array elements after conversion. For each element +element+ - Uses element.to_s if +element+ is not a kind_of?(Array). - Uses recursive element.join(separator) if +element+ is a kind_of?(Array). With no argument, joins using the output field separator, $,: a = [:foo, 'bar', 2] $, # => nil a.join # => "foobar2" With \string argument +separator+, joins using that separator: a = [:foo, 'bar', 2] a.join("\n") # => "foo\nbar\n2" Joins recursively for nested Arrays: a = [:foo, [:bar, [:baz, :bat]]] a.join # => "foobarbazbat" @overload ->new_string @overload join(separator = $,);T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"Vstatic VALUE rb_ary_join_m(int argc, VALUE *argv, VALUE ary) { VALUE sep; if (rb_check_arity(argc, 0, 1) == 0 || NIL_P(sep = argv[0])) { sep = rb_output_fs; if (!NIL_P(sep)) { rb_category_warn(RB_WARN_CATEGORY_DEPRECATED, "$, is set to non-nil value"); } } return rb_ary_join(ary, sep); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#reverse;F;7[;[[@i ;T;: reverse;0;[;{;IC; "Returns a new \Array with the elements of +self+ in reverse order. a = ['foo', 'bar', 'two'] a1 = a.reverse a1 # => ["two", "bar", "foo"] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" reverse;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a new \Array with the elements of +self+ in reverse order. a = ['foo', 'bar', 'two'] a1 = a.reverse a1 # => ["two", "bar", "foo"] @overload reverse;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"hstatic VALUE rb_ary_reverse_m(VALUE ary) { long len = RARRAY_LEN(ary); VALUE dup = rb_ary_new2(len); if (len > 0) { const VALUE *p1 = RARRAY_CONST_PTR_TRANSIENT(ary); VALUE *p2 = (VALUE *)RARRAY_CONST_PTR_TRANSIENT(dup) + len - 1; do *p2-- = *p1++; while (--len > 0); } ARY_SET_LEN(dup, RARRAY_LEN(ary)); return dup; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#reverse!;F;7[;[[@i ;T;: reverse!;0;[;{;IC; "bReverses +self+ in place: a = ['foo', 'bar', 'two'] a.reverse! # => ["two", "bar", "foo"] ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" reverse!;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Reverses +self+ in place: a = ['foo', 'bar', 'two'] a.reverse! # => ["two", "bar", "foo"] @overload reverse! @return [self];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"Tstatic VALUE rb_ary_reverse_bang(VALUE ary) { return rb_ary_reverse(ary); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#rotate;F;7[[@90;[[@im ;T;: rotate;0;[;{;IC; "CReturns a new \Array formed from +self+ with elements rotated from one end to the other. When no argument given, returns a new \Array that is like +self+, except that the first element has been rotated to the last position: a = [:foo, 'bar', 2, 'bar'] a1 = a.rotate a1 # => ["bar", 2, "bar", :foo] When given a non-negative \Integer +count+, returns a new \Array with +count+ elements rotated from the beginning to the end: a = [:foo, 'bar', 2] a1 = a.rotate(2) a1 # => [2, :foo, "bar"] If +count+ is large, uses count % array.size as the count: a = [:foo, 'bar', 2] a1 = a.rotate(20) a1 # => [2, :foo, "bar"] If +count+ is zero, returns a copy of +self+, unmodified: a = [:foo, 'bar', 2] a1 = a.rotate(0) a1 # => [:foo, "bar", 2] When given a negative \Integer +count+, rotates in the opposite direction, from end to beginning: a = [:foo, 'bar', 2] a1 = a.rotate(-2) a1 # => ["bar", 2, :foo] If +count+ is small (far from zero), uses count % array.size as the count: a = [:foo, 'bar', 2] a1 = a.rotate(-5) a1 # => ["bar", 2, :foo] ;T;[o;= ;>I" overload;F;?0;;!;@0;:I" rotate;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;!;@0;:I"rotate(count);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" count;T0;$@;![;"I"nReturns a new \Array formed from +self+ with elements rotated from one end to the other. When no argument given, returns a new \Array that is like +self+, except that the first element has been rotated to the last position: a = [:foo, 'bar', 2, 'bar'] a1 = a.rotate a1 # => ["bar", 2, "bar", :foo] When given a non-negative \Integer +count+, returns a new \Array with +count+ elements rotated from the beginning to the end: a = [:foo, 'bar', 2] a1 = a.rotate(2) a1 # => [2, :foo, "bar"] If +count+ is large, uses count % array.size as the count: a = [:foo, 'bar', 2] a1 = a.rotate(20) a1 # => [2, :foo, "bar"] If +count+ is zero, returns a copy of +self+, unmodified: a = [:foo, 'bar', 2] a1 = a.rotate(0) a1 # => [:foo, "bar", 2] When given a negative \Integer +count+, rotates in the opposite direction, from end to beginning: a = [:foo, 'bar', 2] a1 = a.rotate(-2) a1 # => ["bar", 2, :foo] If +count+ is small (far from zero), uses count % array.size as the count: a = [:foo, 'bar', 2] a1 = a.rotate(-5) a1 # => ["bar", 2, :foo] @overload rotate @overload rotate(count);T;#0;$@;.F;/o;0;1T;2iC ;3ii ;%@;9I"static VALUE rb_ary_rotate_m(int argc, VALUE *argv, VALUE ary) { VALUE rotated; const VALUE *ptr; long len; long cnt = (rb_check_arity(argc, 0, 1) ? NUM2LONG(argv[0]) : 1); len = RARRAY_LEN(ary); rotated = rb_ary_new2(len); if (len > 0) { cnt = rotate_count(cnt, len); ptr = RARRAY_CONST_PTR_TRANSIENT(ary); len -= cnt; ary_memcpy(rotated, 0, len, ptr + cnt); ary_memcpy(rotated, len, cnt, ptr); } ARY_SET_LEN(rotated, RARRAY_LEN(ary)); return rotated; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#rotate!;F;7[[@90;[[@i; ;T;: rotate!;0;[;{;IC; "Rotates +self+ in place by moving elements from one end to the other; returns +self+. When no argument given, rotates the first element to the last position: a = [:foo, 'bar', 2, 'bar'] a.rotate! # => ["bar", 2, "bar", :foo] When given a non-negative \Integer +count+, rotates +count+ elements from the beginning to the end: a = [:foo, 'bar', 2] a.rotate!(2) a # => [2, :foo, "bar"] If +count+ is large, uses count % array.size as the count: a = [:foo, 'bar', 2] a.rotate!(20) a # => [2, :foo, "bar"] If +count+ is zero, returns +self+ unmodified: a = [:foo, 'bar', 2] a.rotate!(0) a # => [:foo, "bar", 2] When given a negative Integer +count+, rotates in the opposite direction, from end to beginning: a = [:foo, 'bar', 2] a.rotate!(-2) a # => ["bar", 2, :foo] If +count+ is small (far from zero), uses count % array.size as the count: a = [:foo, 'bar', 2] a.rotate!(-5) a # => ["bar", 2, :foo] ;T;[o;= ;>I" overload;F;?0;;";@0;:I" rotate!;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;";@0;:I"rotate!(count);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"@return [self];T;#0;$@;.F;Bi;C0;7[[I" count;T0;$@;![;"I"Rotates +self+ in place by moving elements from one end to the other; returns +self+. When no argument given, rotates the first element to the last position: a = [:foo, 'bar', 2, 'bar'] a.rotate! # => ["bar", 2, "bar", :foo] When given a non-negative \Integer +count+, rotates +count+ elements from the beginning to the end: a = [:foo, 'bar', 2] a.rotate!(2) a # => [2, :foo, "bar"] If +count+ is large, uses count % array.size as the count: a = [:foo, 'bar', 2] a.rotate!(20) a # => [2, :foo, "bar"] If +count+ is zero, returns +self+ unmodified: a = [:foo, 'bar', 2] a.rotate!(0) a # => [:foo, "bar", 2] When given a negative Integer +count+, rotates in the opposite direction, from end to beginning: a = [:foo, 'bar', 2] a.rotate!(-2) a # => ["bar", 2, :foo] If +count+ is small (far from zero), uses count % array.size as the count: a = [:foo, 'bar', 2] a.rotate!(-5) a # => ["bar", 2, :foo] @overload rotate! @return [self] @overload rotate!(count) @return [self];T;#0;$@;.F;/o;0;1T;2i ;3i9 ;%@;9I"static VALUE rb_ary_rotate_bang(int argc, VALUE *argv, VALUE ary) { long n = (rb_check_arity(argc, 0, 1) ? NUM2LONG(argv[0]) : 1); rb_ary_rotate(ary, n); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#sort;F;7[;[[@iM ;T;;;0;[;{;IC; "Returns a new \Array whose elements are those from +self+, sorted. With no block, compares elements using operator <=> (see Comparable): a = 'abcde'.split('').shuffle a # => ["e", "b", "d", "a", "c"] a1 = a.sort a1 # => ["a", "b", "c", "d", "e"] With a block, calls the block with each element pair; for each element pair +a+ and +b+, the block should return an integer: - Negative when +b+ is to follow +a+. - Zero when +a+ and +b+ are equivalent. - Positive when +a+ is to follow +b+. Example: a = 'abcde'.split('').shuffle a # => ["e", "b", "d", "a", "c"] a1 = a.sort {|a, b| a <=> b } a1 # => ["a", "b", "c", "d", "e"] a2 = a.sort {|a, b| b <=> a } a2 # => ["e", "d", "c", "b", "a"] When the block returns zero, the order for +a+ and +b+ is indeterminate, and may be unstable: a = 'abcde'.split('').shuffle a # => ["e", "b", "d", "a", "c"] a1 = a.sort {|a, b| 0 } a1 # => ["c", "e", "b", "d", "a"] Related: Enumerable#sort_by. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" sort;T;IC; ";T;[;![;"I";T;#0;$@I;.F;Bi;C0;7[;$@Io;= ;>I" overload;F;?0;;;@0;:I" sort;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"a;TI"b;T;$@I;![;"I"@yield [a, b];T;#0;$@I;.F;Bi;C0;7[;$@I;![;"I"Returns a new \Array whose elements are those from +self+, sorted. With no block, compares elements using operator <=> (see Comparable): a = 'abcde'.split('').shuffle a # => ["e", "b", "d", "a", "c"] a1 = a.sort a1 # => ["a", "b", "c", "d", "e"] With a block, calls the block with each element pair; for each element pair +a+ and +b+, the block should return an integer: - Negative when +b+ is to follow +a+. - Zero when +a+ and +b+ are equivalent. - Positive when +a+ is to follow +b+. Example: a = 'abcde'.split('').shuffle a # => ["e", "b", "d", "a", "c"] a1 = a.sort {|a, b| a <=> b } a1 # => ["a", "b", "c", "d", "e"] a2 = a.sort {|a, b| b <=> a } a2 # => ["e", "d", "c", "b", "a"] When the block returns zero, the order for +a+ and +b+ is indeterminate, and may be unstable: a = 'abcde'.split('').shuffle a # => ["e", "b", "d", "a", "c"] a1 = a.sort {|a, b| 0 } a1 # => ["c", "e", "b", "d", "a"] Related: Enumerable#sort_by. @overload sort @overload sort @yield [a, b];T;#0;$@I;.F;/o;0;1T;2i' ;3iJ ;%@;9I"kVALUE rb_ary_sort(VALUE ary) { ary = rb_ary_dup(ary); rb_ary_sort_bang(ary); return ary; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Array#sort!;F;7[;[[@i ;T;: sort!;0;[;{;IC; "Returns +self+ with its elements sorted in place. With no block, compares elements using operator <=> (see Comparable): a = 'abcde'.split('').shuffle a # => ["e", "b", "d", "a", "c"] a.sort! a # => ["a", "b", "c", "d", "e"] With a block, calls the block with each element pair; for each element pair +a+ and +b+, the block should return an integer: - Negative when +b+ is to follow +a+. - Zero when +a+ and +b+ are equivalent. - Positive when +a+ is to follow +b+. Example: a = 'abcde'.split('').shuffle a # => ["e", "b", "d", "a", "c"] a.sort! {|a, b| a <=> b } a # => ["a", "b", "c", "d", "e"] a.sort! {|a, b| b <=> a } a # => ["e", "d", "c", "b", "a"] When the block returns zero, the order for +a+ and +b+ is indeterminate, and may be unstable: a = 'abcde'.split('').shuffle a # => ["e", "b", "d", "a", "c"] a.sort! {|a, b| 0 } a # => ["d", "e", "c", "a", "b"] ;T;[o;= ;>I" overload;F;?0;;#;@0;:I" sort!;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@m;![;"I"@return [self];T;#0;$@m;.F;Bi;C0;7[;$@mo;= ;>I" overload;F;?0;;#;@0;:I" sort!;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"a;TI"b;T;$@mo;A ;>I" return;F;?I";T;0;@[I" self;T;$@m;![;"I"!@yield [a, b] @return [self];T;#0;$@m;.F;Bi;C0;7[;$@m;![;"I"Returns +self+ with its elements sorted in place. With no block, compares elements using operator <=> (see Comparable): a = 'abcde'.split('').shuffle a # => ["e", "b", "d", "a", "c"] a.sort! a # => ["a", "b", "c", "d", "e"] With a block, calls the block with each element pair; for each element pair +a+ and +b+, the block should return an integer: - Negative when +b+ is to follow +a+. - Zero when +a+ and +b+ are equivalent. - Positive when +a+ is to follow +b+. Example: a = 'abcde'.split('').shuffle a # => ["e", "b", "d", "a", "c"] a.sort! {|a, b| a <=> b } a # => ["a", "b", "c", "d", "e"] a.sort! {|a, b| b <=> a } a # => ["e", "d", "c", "b", "a"] When the block returns zero, the order for +a+ and +b+ is indeterminate, and may be unstable: a = 'abcde'.split('').shuffle a # => ["e", "b", "d", "a", "c"] a.sort! {|a, b| 0 } a # => ["d", "e", "c", "a", "b"] @overload sort! @return [self] @overload sort! @yield [a, b] @return [self];T;#0;$@m;.F;/o;0;1T;2i ;3i ;%@;9I"VALUE rb_ary_sort_bang(VALUE ary) { rb_ary_modify(ary); assert(!ARY_SHARED_P(ary)); if (RARRAY_LEN(ary) > 1) { VALUE tmp = ary_make_substitution(ary); /* only ary refers tmp */ struct ary_sort_data data; long len = RARRAY_LEN(ary); RBASIC_CLEAR_CLASS(tmp); data.ary = tmp; data.receiver = ary; data.cmp_opt.opt_methods = 0; data.cmp_opt.opt_inited = 0; RARRAY_PTR_USE(tmp, ptr, { ruby_qsort(ptr, len, sizeof(VALUE), rb_block_given_p()?sort_1:sort_2, &data); }); /* WB: no new reference */ rb_ary_modify(ary); if (ARY_EMBED_P(tmp)) { if (ARY_SHARED_P(ary)) { /* ary might be destructively operated in the given block */ rb_ary_unshare(ary); FL_SET_EMBED(ary); } ary_memcpy(ary, 0, ARY_EMBED_LEN(tmp), ARY_EMBED_PTR(tmp)); ARY_SET_LEN(ary, ARY_EMBED_LEN(tmp)); } else { if (!ARY_EMBED_P(ary) && ARY_HEAP_PTR(ary) == ARY_HEAP_PTR(tmp)) { FL_UNSET_SHARED(ary); ARY_SET_CAPA(ary, RARRAY_LEN(tmp)); } else { assert(!ARY_SHARED_P(tmp)); if (ARY_EMBED_P(ary)) { FL_UNSET_EMBED(ary); } else if (ARY_SHARED_P(ary)) { /* ary might be destructively operated in the given block */ rb_ary_unshare(ary); } else { ary_heap_free(ary); } ARY_SET_PTR(ary, ARY_HEAP_PTR(tmp)); ARY_SET_HEAP_LEN(ary, len); ARY_SET_CAPA(ary, ARY_HEAP_LEN(tmp)); } /* tmp was lost ownership for the ptr */ FL_UNSET(tmp, FL_FREEZE); FL_SET_EMBED(tmp); ARY_SET_EMBED_LEN(tmp, 0); FL_SET(tmp, FL_FREEZE); } /* tmp will be GC'ed. */ RBASIC_SET_CLASS_RAW(tmp, rb_cArray); /* rb_cArray must be marked */ } ary_verify(ary); return ary; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Array#sort_by!;F;7[;[[@i ;T;: sort_by!;0;[;{;IC; "XSorts the elements of +self+ in place, using an ordering determined by the block; returns self. Calls the block with each successive element; sorts elements based on the values returned from the block. For duplicates returned by the block, the ordering is indeterminate, and may be unstable. This example sorts strings based on their sizes: a = ['aaaa', 'bbb', 'cc', 'd'] a.sort_by! {|element| element.size } a # => ["d", "cc", "bbb", "aaaa"] Returns a new \Enumerator if no block given: a = ['aaaa', 'bbb', 'cc', 'd'] a.sort_by! # => # ;T;[o;= ;>I" overload;F;?0;;$;@0;:I" sort_by!;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"$@yield [element] @return [self];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;$;@0;:I" sort_by!;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Sorts the elements of +self+ in place, using an ordering determined by the block; returns self. Calls the block with each successive element; sorts elements based on the values returned from the block. For duplicates returned by the block, the ordering is indeterminate, and may be unstable. This example sorts strings based on their sizes: a = ['aaaa', 'bbb', 'cc', 'd'] a.sort_by! {|element| element.size } a # => ["d", "cc", "bbb", "aaaa"] Returns a new \Enumerator if no block given: a = ['aaaa', 'bbb', 'cc', 'd'] a.sort_by! # => # @overload sort_by! @yield [element] @return [self] @overload sort_by!;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE rb_ary_sort_by_bang(VALUE ary) { VALUE sorted; RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length); rb_ary_modify(ary); sorted = rb_block_call(ary, rb_intern("sort_by"), 0, 0, sort_by_i, 0); rb_ary_replace(ary, sorted); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#collect;F;7[;[[@i ;T;;;0;[;{;IC; "Calls the block, if given, with each element of +self+; returns a new \Array whose elements are the return values from the block: a = [:foo, 'bar', 2] a1 = a.map {|element| element.class } a1 # => [Symbol, String, Integer] Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2] a1 = a.map a1 # => # Array#collect is an alias for Array#map. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"map;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@;![;"I"@yield [element];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"map;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Calls the block, if given, with each element of +self+; returns a new \Array whose elements are the return values from the block: a = [:foo, 'bar', 2] a1 = a.map {|element| element.class } a1 # => [Symbol, String, Integer] Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2] a1 = a.map a1 # => # Array#collect is an alias for Array#map. @overload map @yield [element] @overload map;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"2static VALUE rb_ary_collect(VALUE ary) { long i; VALUE collect; RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length); collect = rb_ary_new2(RARRAY_LEN(ary)); for (i = 0; i < RARRAY_LEN(ary); i++) { rb_ary_push(collect, rb_yield(RARRAY_AREF(ary, i))); } return collect; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#collect!;F;7[;[[@i;T;: collect!;0;[;{;IC; "jCalls the block, if given, with each element; replaces the element with the block's return value: a = [:foo, 'bar', 2] a.map! { |element| element.class } # => [Symbol, String, Integer] Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2] a1 = a.map! a1 # => # Array#collect! is an alias for Array#map!. ;T;[o;= ;>I" overload;F;?0;: map!;@0;:I" map!;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"$@yield [element] @return [self];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;&;@0;:I" map!;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Calls the block, if given, with each element; replaces the element with the block's return value: a = [:foo, 'bar', 2] a.map! { |element| element.class } # => [Symbol, String, Integer] Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2] a1 = a.map! a1 # => # Array#collect! is an alias for Array#map!. @overload map! @yield [element] @return [self] @overload map!;T;#0;$@;.F;/o;0;1T;2i ;3i;%@;9I"static VALUE rb_ary_collect_bang(VALUE ary) { long i; RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length); rb_ary_modify(ary); for (i = 0; i < RARRAY_LEN(ary); i++) { rb_ary_store(ary, i, rb_yield(RARRAY_AREF(ary, i))); } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#map;F;7[;[[@i ;T;;;0;[;{;IC; "Calls the block, if given, with each element of +self+; returns a new \Array whose elements are the return values from the block: a = [:foo, 'bar', 2] a1 = a.map {|element| element.class } a1 # => [Symbol, String, Integer] Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2] a1 = a.map a1 # => # Array#collect is an alias for Array#map. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"map;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@;![;"I"@yield [element];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"map;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"2static VALUE rb_ary_collect(VALUE ary) { long i; VALUE collect; RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length); collect = rb_ary_new2(RARRAY_LEN(ary)); for (i = 0; i < RARRAY_LEN(ary); i++) { rb_ary_push(collect, rb_yield(RARRAY_AREF(ary, i))); } return collect; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#map!;F;7[;[[@i;T;;&;0;[;{;IC; "jCalls the block, if given, with each element; replaces the element with the block's return value: a = [:foo, 'bar', 2] a.map! { |element| element.class } # => [Symbol, String, Integer] Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2] a1 = a.map! a1 # => # Array#collect! is an alias for Array#map!. ;T;[o;= ;>I" overload;F;?0;;&;@0;:I" map!;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@0o;A ;>I" return;F;?I";T;0;@[I" self;T;$@0;![;"I"$@yield [element] @return [self];T;#0;$@0;.F;Bi;C0;7[;$@0o;= ;>I" overload;F;?0;;&;@0;:I" map!;T;IC; ";T;[;![;"I";T;#0;$@0;.F;Bi;C0;7[;$@0;![;"@ ;#0;$@0;.F;/o;0;1T;2i ;3i;%@;9I"static VALUE rb_ary_collect_bang(VALUE ary) { long i; RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length); rb_ary_modify(ary); for (i = 0; i < RARRAY_LEN(ary); i++) { rb_ary_store(ary, i, rb_yield(RARRAY_AREF(ary, i))); } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#select;F;7[;[[@i;T;;;0;[;{;IC; "Calls the block, if given, with each element of +self+; returns a new \Array containing those elements of +self+ for which the block returns a truthy value: a = [:foo, 'bar', 2, :bam] a1 = a.select {|element| element.to_s.start_with?('b') } a1 # => ["bar", :bam] Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2, :bam] a.select # => # Array#filter is an alias for Array#select. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@W;![;"I"@yield [element];T;#0;$@W;.F;Bi;C0;7[;$@Wo;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[;![;"I";T;#0;$@W;.F;Bi;C0;7[;$@W;![;"I"Calls the block, if given, with each element of +self+; returns a new \Array containing those elements of +self+ for which the block returns a truthy value: a = [:foo, 'bar', 2, :bam] a1 = a.select {|element| element.to_s.start_with?('b') } a1 # => ["bar", :bam] Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2, :bam] a.select # => # Array#filter is an alias for Array#select. @overload select @yield [element] @overload select;T;#0;$@W;.F;/o;0;1T;2ix;3i;%@;9I"Ostatic VALUE rb_ary_select(VALUE ary) { VALUE result; long i; RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length); result = rb_ary_new2(RARRAY_LEN(ary)); for (i = 0; i < RARRAY_LEN(ary); i++) { if (RTEST(rb_yield(RARRAY_AREF(ary, i)))) { rb_ary_push(result, rb_ary_elt(ary, i)); } } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#select!;F;7[;[[@i;T;;;0;[;{;IC; "Calls the block, if given with each element of +self+; removes from +self+ those elements for which the block returns +false+ or +nil+. Returns +self+ if any elements were removed: a = [:foo, 'bar', 2, :bam] a.select! {|element| element.to_s.start_with?('b') } # => ["bar", :bam] Returns +nil+ if no elements were removed. Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2, :bam] a.select! # => # Array#filter! is an alias for Array#select!. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" select!;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@zo;A ;>I" return;F;?I";T;0;@[I" self;TI"nil;T;$@z;![;"I")@yield [element] @return [self, nil];T;#0;$@z;.F;Bi;C0;7[;$@zo;= ;>I" overload;F;?0;;;@0;:I" select!;T;IC; ";T;[;![;"I";T;#0;$@z;.F;Bi;C0;7[;$@z;![;"I"PCalls the block, if given with each element of +self+; removes from +self+ those elements for which the block returns +false+ or +nil+. Returns +self+ if any elements were removed: a = [:foo, 'bar', 2, :bam] a.select! {|element| element.to_s.start_with?('b') } # => ["bar", :bam] Returns +nil+ if no elements were removed. Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2, :bam] a.select! # => # Array#filter! is an alias for Array#select!. @overload select! @yield [element] @return [self, nil] @overload select!;T;#0;$@z;.F;/o;0;1T;2i;3i;%@;9I".static VALUE rb_ary_select_bang(VALUE ary) { struct select_bang_arg args; RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length); rb_ary_modify(ary); args.ary = ary; args.len[0] = args.len[1] = 0; return rb_ensure(select_bang_i, (VALUE)&args, select_bang_ensure, (VALUE)&args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#filter;F;7[;[[@i;T;;;0;[;{;IC; "Calls the block, if given, with each element of +self+; returns a new \Array containing those elements of +self+ for which the block returns a truthy value: a = [:foo, 'bar', 2, :bam] a1 = a.select {|element| element.to_s.start_with?('b') } a1 # => ["bar", :bam] Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2, :bam] a.select # => # Array#filter is an alias for Array#select. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@;![;"I"@yield [element];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"@v;#0;$@;.F;/o;0;1T;2ix;3i;%@;9I"Ostatic VALUE rb_ary_select(VALUE ary) { VALUE result; long i; RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length); result = rb_ary_new2(RARRAY_LEN(ary)); for (i = 0; i < RARRAY_LEN(ary); i++) { if (RTEST(rb_yield(RARRAY_AREF(ary, i)))) { rb_ary_push(result, rb_ary_elt(ary, i)); } } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#filter!;F;7[;[[@i;T;;;0;[;{;IC; "Calls the block, if given with each element of +self+; removes from +self+ those elements for which the block returns +false+ or +nil+. Returns +self+ if any elements were removed: a = [:foo, 'bar', 2, :bam] a.select! {|element| element.to_s.start_with?('b') } # => ["bar", :bam] Returns +nil+ if no elements were removed. Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2, :bam] a.select! # => # Array#filter! is an alias for Array#select!. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" select!;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;TI"nil;T;$@;![;"I")@yield [element] @return [self, nil];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" select!;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2i;3i;%@;9I".static VALUE rb_ary_select_bang(VALUE ary) { struct select_bang_arg args; RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length); rb_ary_modify(ary); args.ary = ary; args.len[0] = args.len[1] = 0; return rb_ensure(select_bang_i, (VALUE)&args, select_bang_ensure, (VALUE)&args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#keep_if;F;7[;[[@i;T;;;0;[;{;IC; "_Retains those elements for which the block returns a truthy value; deletes all other elements; returns +self+: a = [:foo, 'bar', 2, :bam] a.keep_if {|element| element.to_s.start_with?('b') } # => ["bar", :bam] Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2, :bam] a.keep_if # => # ;T;[o;= ;>I" overload;F;?0;;;@0;:I" keep_if;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"$@yield [element] @return [self];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" keep_if;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Retains those elements for which the block returns a truthy value; deletes all other elements; returns +self+: a = [:foo, 'bar', 2, :bam] a.keep_if {|element| element.to_s.start_with?('b') } # => ["bar", :bam] Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2, :bam] a.keep_if # => # @overload keep_if @yield [element] @return [self] @overload keep_if;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_ary_keep_if(VALUE ary) { RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length); rb_ary_select_bang(ary); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#values_at;F;7[[@90;[[@ik;T;;;0;[;{;IC; " Returns a new \Array whose elements are the elements of +self+ at the given \Integer or \Range +indexes+. For each positive +index+, returns the element at offset +index+: a = [:foo, 'bar', 2] a.values_at(0, 2) # => [:foo, 2] a.values_at(0..1) # => [:foo, "bar"] The given +indexes+ may be in any order, and may repeat: a = [:foo, 'bar', 2] a.values_at(2, 0, 1, 0, 2) # => [2, :foo, "bar", :foo, 2] a.values_at(1, 0..2) # => ["bar", :foo, "bar", 2] Assigns +nil+ for an +index+ that is too large: a = [:foo, 'bar', 2] a.values_at(0, 3, 1, 3) # => [:foo, nil, "bar", nil] Returns a new empty \Array if no arguments given. For each negative +index+, counts backward from the end of the array: a = [:foo, 'bar', 2] a.values_at(-1, -3) # => [2, :foo] Assigns +nil+ for an +index+ that is too small: a = [:foo, 'bar', 2] a.values_at(0, -5, 1, -6, 2) # => [:foo, nil, "bar", nil, 2] The given +indexes+ may have a mixture of signs: a = [:foo, 'bar', 2] a.values_at(0, -2, 1, -1) # => [:foo, "bar", "bar", 2] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"values_at(*indexes);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" *indexes;T0;$@;![;"I",Returns a new \Array whose elements are the elements of +self+ at the given \Integer or \Range +indexes+. For each positive +index+, returns the element at offset +index+: a = [:foo, 'bar', 2] a.values_at(0, 2) # => [:foo, 2] a.values_at(0..1) # => [:foo, "bar"] The given +indexes+ may be in any order, and may repeat: a = [:foo, 'bar', 2] a.values_at(2, 0, 1, 0, 2) # => [2, :foo, "bar", :foo, 2] a.values_at(1, 0..2) # => ["bar", :foo, "bar", 2] Assigns +nil+ for an +index+ that is too large: a = [:foo, 'bar', 2] a.values_at(0, 3, 1, 3) # => [:foo, nil, "bar", nil] Returns a new empty \Array if no arguments given. For each negative +index+, counts backward from the end of the array: a = [:foo, 'bar', 2] a.values_at(-1, -3) # => [2, :foo] Assigns +nil+ for an +index+ that is too small: a = [:foo, 'bar', 2] a.values_at(0, -5, 1, -6, 2) # => [:foo, nil, "bar", nil, 2] The given +indexes+ may have a mixture of signs: a = [:foo, 'bar', 2] a.values_at(0, -2, 1, -1) # => [:foo, "bar", "bar", 2] @overload values_at(*indexes);T;#0;$@;.F;/o;0;1T;2iG;3ig;%@;9I"static VALUE rb_ary_values_at(int argc, VALUE *argv, VALUE ary) { long i, olen = RARRAY_LEN(ary); VALUE result = rb_ary_new_capa(argc); for (i = 0; i < argc; ++i) { append_values_at_single(result, ary, olen, argv[i]); } RB_GC_GUARD(ary); return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#delete;F;7[[I" item;T0;[[@i.;T;;\;0;[;{;IC; "Removes zero or more elements from +self+; returns +self+. When no block is given, removes from +self+ each element +ele+ such that ele == obj; returns the last deleted element: s1 = 'bar'; s2 = 'bar' a = [:foo, s1, 2, s2] a.delete('bar') # => "bar" a # => [:foo, 2] Returns +nil+ if no elements removed. When a block is given, removes from +self+ each element +ele+ such that ele == obj. If any such elements are found, ignores the block and returns the last deleted element: s1 = 'bar'; s2 = 'bar' a = [:foo, s1, 2, s2] deleted_obj = a.delete('bar') {|obj| fail 'Cannot happen' } a # => [:foo, 2] If no such elements are found, returns the block's return value: a = [:foo, 'bar', 2] a.delete(:nosuch) {|obj| "#{obj} not found" } # => "nosuch not found" ;T;[o;= ;>I" overload;F;?0;;\;@0;:I"delete(obj);T;IC; ";T;[;![;"I";T;#0;$@.;.F;Bi;C0;7[[I"obj;T0;$@.o;= ;>I" overload;F;?0;;\;@0;:I"delete(obj);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" nosuch;T;$@.;![;"I"@yield [nosuch];T;#0;$@.;.F;Bi;C0;7[[I"obj;T0;$@.;![;"I"]Removes zero or more elements from +self+; returns +self+. When no block is given, removes from +self+ each element +ele+ such that ele == obj; returns the last deleted element: s1 = 'bar'; s2 = 'bar' a = [:foo, s1, 2, s2] a.delete('bar') # => "bar" a # => [:foo, 2] Returns +nil+ if no elements removed. When a block is given, removes from +self+ each element +ele+ such that ele == obj. If any such elements are found, ignores the block and returns the last deleted element: s1 = 'bar'; s2 = 'bar' a = [:foo, s1, 2, s2] deleted_obj = a.delete('bar') {|obj| fail 'Cannot happen' } a # => [:foo, 2] If no such elements are found, returns the block's return value: a = [:foo, 'bar', 2] a.delete(:nosuch) {|obj| "#{obj} not found" } # => "nosuch not found" @overload delete(obj) @overload delete(obj) @yield [nosuch];T;#0;$@.;.F;/o;0;1T;2i;3i+;%@;9I"VALUE rb_ary_delete(VALUE ary, VALUE item) { VALUE v = item; long i1, i2; for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) { VALUE e = RARRAY_AREF(ary, i1); if (rb_equal(e, item)) { v = e; continue; } if (i1 != i2) { rb_ary_store(ary, i2, e); } i2++; } if (RARRAY_LEN(ary) == i2) { if (rb_block_given_p()) { return rb_yield(item); } return Qnil; } ary_resize_smaller(ary, i2); ary_verify(ary); return v; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Array#delete_at;F;7[[I"pos;T0;[[@i;T;:delete_at;0;[;{;IC; "Deletes an element from +self+, per the given \Integer +index+. When +index+ is non-negative, deletes the element at offset +index+: a = [:foo, 'bar', 2] a.delete_at(1) # => "bar" a # => [:foo, 2] If index is too large, returns +nil+. When +index+ is negative, counts backward from the end of the array: a = [:foo, 'bar', 2] a.delete_at(-2) # => "bar" a # => [:foo, 2] If +index+ is too small (far from zero), returns nil. ;T;[o;= ;>I" overload;F;?0;;';@0;:I"delete_at(index);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@W;![;"I"@return [nil];T;#0;$@W;.F;Bi;C0;7[[I" index;T0;$@W;![;"I"Deletes an element from +self+, per the given \Integer +index+. When +index+ is non-negative, deletes the element at offset +index+: a = [:foo, 'bar', 2] a.delete_at(1) # => "bar" a # => [:foo, 2] If index is too large, returns +nil+. When +index+ is negative, counts backward from the end of the array: a = [:foo, 'bar', 2] a.delete_at(-2) # => "bar" a # => [:foo, 2] If +index+ is too small (far from zero), returns nil. @overload delete_at(index) @return [nil];T;#0;$@W;.F;/o;0;1T;2iz;3i;%@;9I"ostatic VALUE rb_ary_delete_at_m(VALUE ary, VALUE pos) { return rb_ary_delete_at(ary, NUM2LONG(pos)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#delete_if;F;7[;[[@i;T;;;0;[;{;IC; "BRemoves each element in +self+ for which the block returns a truthy value; returns +self+: a = [:foo, 'bar', 2, 'bat'] a.delete_if {|element| element.to_s.start_with?('b') } # => [:foo, 2] Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2] a.delete_if # => # ;T;[o;= ;>I" overload;F;?0;;;@0;:I"delete_if;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@vo;A ;>I" return;F;?I";T;0;@[I" self;T;$@v;![;"I"$@yield [element] @return [self];T;#0;$@v;.F;Bi;C0;7[;$@vo;= ;>I" overload;F;?0;;;@0;:I"delete_if;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@v;![;"I"@return [Enumerator];T;#0;$@v;.F;Bi;C0;7[;$@v;![;"I"Removes each element in +self+ for which the block returns a truthy value; returns +self+: a = [:foo, 'bar', 2, 'bat'] a.delete_if {|element| element.to_s.start_with?('b') } # => [:foo, 2] Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2] a.delete_if # => # @overload delete_if @yield [element] @return [self] @overload delete_if @return [Enumerator];T;#0;$@v;.F;/o;0;1T;2iq;3i;%@;9I"static VALUE rb_ary_delete_if(VALUE ary) { ary_verify(ary); RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length); ary_reject_bang(ary); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#reject;F;7[;[[@if;T;;;0;[;{;IC; "VReturns a new \Array whose elements are all those from +self+ for which the block returns +false+ or +nil+: a = [:foo, 'bar', 2, 'bat'] a1 = a.reject {|element| element.to_s.start_with?('b') } a1 # => [:foo, 2] Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2] a.reject # => # ;T;[o;= ;>I" overload;F;?0;;;@0;:I" reject;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@;![;"I"@yield [element];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" reject;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a new \Array whose elements are all those from +self+ for which the block returns +false+ or +nil+: a = [:foo, 'bar', 2, 'bat'] a1 = a.reject {|element| element.to_s.start_with?('b') } a1 # => [:foo, 2] Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2] a.reject # => # @overload reject @yield [element] @overload reject;T;#0;$@;.F;/o;0;1T;2iV;3ic;%@;9I"static VALUE rb_ary_reject(VALUE ary) { VALUE rejected_ary; RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length); rejected_ary = rb_ary_new(); ary_reject(ary, rejected_ary); return rejected_ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#reject!;F;7[;[[@iN;T;;;0;[;{;IC; "rRemoves each element for which the block returns a truthy value. Returns +self+ if any elements removed: a = [:foo, 'bar', 2, 'bat'] a.reject! {|element| element.to_s.start_with?('b') } # => [:foo, 2] Returns +nil+ if no elements removed. Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2] a.reject! # => # ;T;[o;= ;>I" overload;F;?0;;;@0;:I" reject!;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;TI"nil;T;$@;![;"I")@yield [element] @return [self, nil];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" reject!;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Removes each element for which the block returns a truthy value. Returns +self+ if any elements removed: a = [:foo, 'bar', 2, 'bat'] a.reject! {|element| element.to_s.start_with?('b') } # => [:foo, 2] Returns +nil+ if no elements removed. Returns a new \Enumerator if no block given: a = [:foo, 'bar', 2] a.reject! # => # @overload reject! @yield [element] @return [self, nil] @overload reject!;T;#0;$@;.F;/o;0;1T;2i<;3iL;%@;9I"static VALUE rb_ary_reject_bang(VALUE ary) { RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length); rb_ary_modify(ary); return ary_reject_bang(ary); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#zip;F;7[[@90;[[@i;T;;;0;[;{;IC; "UWhen no block given, returns a new \Array +new_array+ of size self.size whose elements are Arrays. Each nested array new_array[n] is of size other_arrays.size+1, and contains: - The _nth_ element of +self+. - The _nth_ element of each of the +other_arrays+. If all +other_arrays+ and +self+ are the same size: a = [:a0, :a1, :a2, :a3] b = [:b0, :b1, :b2, :b3] c = [:c0, :c1, :c2, :c3] d = a.zip(b, c) d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] If any array in +other_arrays+ is smaller than +self+, fills to self.size with +nil+: a = [:a0, :a1, :a2, :a3] b = [:b0, :b1, :b2] c = [:c0, :c1] d = a.zip(b, c) d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] If any array in +other_arrays+ is larger than +self+, its trailing elements are ignored: a = [:a0, :a1, :a2, :a3] b = [:b0, :b1, :b2, :b3, :b4] c = [:c0, :c1, :c2, :c3, :c4, :c5] d = a.zip(b, c) d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] When a block is given, calls the block with each of the sub-arrays (formed as above); returns nil a = [:a0, :a1, :a2, :a3] b = [:b0, :b1, :b2, :b3] c = [:c0, :c1, :c2, :c3] a.zip(b, c) {|sub_array| p sub_array} # => nil Output: [:a0, :b0, :c0] [:a1, :b1, :c1] [:a2, :b2, :c2] [:a3, :b3, :c3] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"zip(*other_arrays);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"*other_arrays;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"zip(*other_arrays);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"other_array;T;$@o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"'@yield [other_array] @return [nil];T;#0;$@;.F;Bi;C0;7[[I"*other_arrays;T0;$@;![;"I"When no block given, returns a new \Array +new_array+ of size self.size whose elements are Arrays. Each nested array new_array[n] is of size other_arrays.size+1, and contains: - The _nth_ element of +self+. - The _nth_ element of each of the +other_arrays+. If all +other_arrays+ and +self+ are the same size: a = [:a0, :a1, :a2, :a3] b = [:b0, :b1, :b2, :b3] c = [:c0, :c1, :c2, :c3] d = a.zip(b, c) d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] If any array in +other_arrays+ is smaller than +self+, fills to self.size with +nil+: a = [:a0, :a1, :a2, :a3] b = [:b0, :b1, :b2] c = [:c0, :c1] d = a.zip(b, c) d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, nil], [:a3, nil, nil]] If any array in +other_arrays+ is larger than +self+, its trailing elements are ignored: a = [:a0, :a1, :a2, :a3] b = [:b0, :b1, :b2, :b3, :b4] c = [:c0, :c1, :c2, :c3, :c4, :c5] d = a.zip(b, c) d # => [[:a0, :b0, :c0], [:a1, :b1, :c1], [:a2, :b2, :c2], [:a3, :b3, :c3]] When a block is given, calls the block with each of the sub-arrays (formed as above); returns nil a = [:a0, :a1, :a2, :a3] b = [:b0, :b1, :b2, :b3] c = [:c0, :c1, :c2, :c3] a.zip(b, c) {|sub_array| p sub_array} # => nil Output: [:a0, :b0, :c0] [:a1, :b1, :c1] [:a2, :b2, :c2] [:a3, :b3, :c3] @overload zip(*other_arrays) @overload zip(*other_arrays) @yield [other_array] @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"Vstatic VALUE rb_ary_zip(int argc, VALUE *argv, VALUE ary) { int i, j; long len = RARRAY_LEN(ary); VALUE result = Qnil; for (i=0; i 1) { VALUE work, *tmp; tmp = ALLOCV_N(VALUE, work, argc+1); for (i=0; i [[:a0, :b0, :c0], [:a1, :b1, :c1]] ;T;[o;= ;>I" overload;F;?0;;(;@0;:I"transpose;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Transposes the rows and columns in an \Array of Arrays; the nested Arrays must all be the same size: a = [[:a0, :a1], [:b0, :b1], [:c0, :c1]] a.transpose # => [[:a0, :b0, :c0], [:a1, :b1, :c1]] @overload transpose;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_ary_transpose(VALUE ary) { long elen = -1, alen, i, j; VALUE tmp, result = 0; alen = RARRAY_LEN(ary); if (alen == 0) return rb_ary_dup(ary); for (i=0; i;T;;;0;[;{;IC; "Replaces the content of +self+ with the content of +other_array+; returns +self+: a = [:foo, 'bar', 2] a.replace(['foo', :bar, 3]) # => ["foo", :bar, 3] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"replace(other_array);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@2;![;"I"@return [self];T;#0;$@2;.F;Bi;C0;7[[I"other_array;T0;$@2;![;"@;#0;$@2;.F;/o;0;1T;2i5;3i;;%@;9I"IVALUE rb_ary_replace(VALUE copy, VALUE orig) { rb_ary_modify_check(copy); orig = to_ary(orig); if (copy == orig) return copy; if (RARRAY_LEN(orig) <= RARRAY_EMBED_LEN_MAX) { VALUE shared_root = 0; if (ARY_OWNS_HEAP_P(copy)) { ary_heap_free(copy); } else if (ARY_SHARED_P(copy)) { shared_root = ARY_SHARED_ROOT(copy); FL_UNSET_SHARED(copy); } FL_SET_EMBED(copy); ary_memcpy(copy, 0, RARRAY_LEN(orig), RARRAY_CONST_PTR_TRANSIENT(orig)); if (shared_root) { rb_ary_decrement_share(shared_root); } ARY_SET_LEN(copy, RARRAY_LEN(orig)); } else { VALUE shared_root = ary_make_shared(orig); if (ARY_OWNS_HEAP_P(copy)) { ary_heap_free(copy); } else { rb_ary_unshare_safe(copy); } FL_UNSET_EMBED(copy); ARY_SET_PTR(copy, ARY_HEAP_PTR(orig)); ARY_SET_LEN(copy, ARY_HEAP_LEN(orig)); rb_ary_set_shared(copy, shared_root); } ary_verify(copy); return copy; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Array#clear;F;7[;[[@ip;T;;;0;[;{;IC; "ORemoves all elements from +self+: a = [:foo, 'bar', 2] a.clear # => [] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" clear;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@P;![;"I"@return [self];T;#0;$@P;.F;Bi;C0;7[;$@P;![;"I"rRemoves all elements from +self+: a = [:foo, 'bar', 2] a.clear # => [] @overload clear @return [self];T;#0;$@P;.F;/o;0;1T;2ig;3im;%@;9I"VALUE rb_ary_clear(VALUE ary) { rb_ary_modify_check(ary); if (ARY_SHARED_P(ary)) { if (!ARY_EMBED_P(ary)) { rb_ary_unshare(ary); FL_SET_EMBED(ary); ARY_SET_EMBED_LEN(ary, 0); } } else { ARY_SET_LEN(ary, 0); if (ARY_DEFAULT_SIZE * 2 < ARY_CAPA(ary)) { ary_resize_capa(ary, ARY_DEFAULT_SIZE * 2); } } ary_verify(ary); return ary; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Array#fill;F;7[[@90;[[@i.;T;: fill;0;[;{;IC; "Replaces specified elements in +self+ with specified objects; returns +self+. With argument +obj+ and no block given, replaces all elements with that one object: a = ['a', 'b', 'c', 'd'] a # => ["a", "b", "c", "d"] a.fill(:X) # => [:X, :X, :X, :X] With arguments +obj+ and \Integer +start+, and no block given, replaces elements based on the given start. If +start+ is in range (0 <= start < array.size), replaces all elements from offset +start+ through the end: a = ['a', 'b', 'c', 'd'] a.fill(:X, 2) # => ["a", "b", :X, :X] If +start+ is too large (start >= array.size), does nothing: a = ['a', 'b', 'c', 'd'] a.fill(:X, 4) # => ["a", "b", "c", "d"] a = ['a', 'b', 'c', 'd'] a.fill(:X, 5) # => ["a", "b", "c", "d"] If +start+ is negative, counts from the end (starting index is start + array.size): a = ['a', 'b', 'c', 'd'] a.fill(:X, -2) # => ["a", "b", :X, :X] If +start+ is too small (less than and far from zero), replaces all elements: a = ['a', 'b', 'c', 'd'] a.fill(:X, -6) # => [:X, :X, :X, :X] a = ['a', 'b', 'c', 'd'] a.fill(:X, -50) # => [:X, :X, :X, :X] With arguments +obj+, \Integer +start+, and \Integer +length+, and no block given, replaces elements based on the given +start+ and +length+. If +start+ is in range, replaces +length+ elements beginning at offset +start+: a = ['a', 'b', 'c', 'd'] a.fill(:X, 1, 1) # => ["a", :X, "c", "d"] If +start+ is negative, counts from the end: a = ['a', 'b', 'c', 'd'] a.fill(:X, -2, 1) # => ["a", "b", :X, "d"] If +start+ is large (start >= array.size), extends +self+ with +nil+: a = ['a', 'b', 'c', 'd'] a.fill(:X, 5, 0) # => ["a", "b", "c", "d", nil] a = ['a', 'b', 'c', 'd'] a.fill(:X, 5, 2) # => ["a", "b", "c", "d", nil, :X, :X] If +length+ is zero or negative, replaces no elements: a = ['a', 'b', 'c', 'd'] a.fill(:X, 1, 0) # => ["a", "b", "c", "d"] a.fill(:X, 1, -1) # => ["a", "b", "c", "d"] With arguments +obj+ and \Range +range+, and no block given, replaces elements based on the given range. If the range is positive and ascending (0 < range.begin <= range.end), replaces elements from range.begin to range.end: a = ['a', 'b', 'c', 'd'] a.fill(:X, (1..1)) # => ["a", :X, "c", "d"] If range.first is negative, replaces no elements: a = ['a', 'b', 'c', 'd'] a.fill(:X, (-1..1)) # => ["a", "b", "c", "d"] If range.last is negative, counts from the end: a = ['a', 'b', 'c', 'd'] a.fill(:X, (0..-2)) # => [:X, :X, :X, "d"] a = ['a', 'b', 'c', 'd'] a.fill(:X, (1..-2)) # => ["a", :X, :X, "d"] If range.last and range.last are both negative, both count from the end of the array: a = ['a', 'b', 'c', 'd'] a.fill(:X, (-1..-1)) # => ["a", "b", "c", :X] a = ['a', 'b', 'c', 'd'] a.fill(:X, (-2..-2)) # => ["a", "b", :X, "d"] With no arguments and a block given, calls the block with each index; replaces the corresponding element with the block's return value: a = ['a', 'b', 'c', 'd'] a.fill { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "new_3"] With argument +start+ and a block given, calls the block with each index from offset +start+ to the end; replaces the corresponding element with the block's return value: If start is in range (0 <= start < array.size), replaces from offset +start+ to the end: a = ['a', 'b', 'c', 'd'] a.fill(1) { |index| "new_#{index}" } # => ["a", "new_1", "new_2", "new_3"] If +start+ is too large(start >= array.size), does nothing: a = ['a', 'b', 'c', 'd'] a.fill(4) { |index| fail 'Cannot happen' } # => ["a", "b", "c", "d"] a = ['a', 'b', 'c', 'd'] a.fill(4) { |index| fail 'Cannot happen' } # => ["a", "b", "c", "d"] If +start+ is negative, counts from the end: a = ['a', 'b', 'c', 'd'] a.fill(-2) { |index| "new_#{index}" } # => ["a", "b", "new_2", "new_3"] If start is too small (start <= -array.size, replaces all elements: a = ['a', 'b', 'c', 'd'] a.fill(-6) { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "new_3"] a = ['a', 'b', 'c', 'd'] a.fill(-50) { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "new_3"] With arguments +start+ and +length+, and a block given, calls the block for each index specified by start length; replaces the corresponding element with the block's return value. If +start+ is in range, replaces +length+ elements beginning at offset +start+: a = ['a', 'b', 'c', 'd'] a.fill(1, 1) { |index| "new_#{index}" } # => ["a", "new_1", "c", "d"] If start is negative, counts from the end: a = ['a', 'b', 'c', 'd'] a.fill(-2, 1) { |index| "new_#{index}" } # => ["a", "b", "new_2", "d"] If +start+ is large (start >= array.size), extends +self+ with +nil+: a = ['a', 'b', 'c', 'd'] a.fill(5, 0) { |index| "new_#{index}" } # => ["a", "b", "c", "d", nil] a = ['a', 'b', 'c', 'd'] a.fill(5, 2) { |index| "new_#{index}" } # => ["a", "b", "c", "d", nil, "new_5", "new_6"] If +length+ is zero or less, replaces no elements: a = ['a', 'b', 'c', 'd'] a.fill(1, 0) { |index| "new_#{index}" } # => ["a", "b", "c", "d"] a.fill(1, -1) { |index| "new_#{index}" } # => ["a", "b", "c", "d"] With arguments +obj+ and +range+, and a block given, calls the block with each index in the given range; replaces the corresponding element with the block's return value. If the range is positive and ascending (range 0 < range.begin <= range.end, replaces elements from range.begin to range.end: a = ['a', 'b', 'c', 'd'] a.fill(1..1) { |index| "new_#{index}" } # => ["a", "new_1", "c", "d"] If +range.first+ is negative, does nothing: a = ['a', 'b', 'c', 'd'] a.fill(-1..1) { |index| fail 'Cannot happen' } # => ["a", "b", "c", "d"] If range.last is negative, counts from the end: a = ['a', 'b', 'c', 'd'] a.fill(0..-2) { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "d"] a = ['a', 'b', 'c', 'd'] a.fill(1..-2) { |index| "new_#{index}" } # => ["a", "new_1", "new_2", "d"] If range.first and range.last are both negative, both count from the end: a = ['a', 'b', 'c', 'd'] a.fill(-1..-1) { |index| "new_#{index}" } # => ["a", "b", "c", "new_3"] a = ['a', 'b', 'c', 'd'] a.fill(-2..-2) { |index| "new_#{index}" } # => ["a", "b", "new_2", "d"] ;T;[ o;= ;>I" overload;F;?0;;);@0;:I"fill(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@k;![;"I"@return [self];T;#0;$@k;.F;Bi;C0;7[[I"obj;T0;$@ko;= ;>I" overload;F;?0;;);@0;:I"fill(obj, start);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@k;![;"I"@return [self];T;#0;$@k;.F;Bi;C0;7[[I"obj;T0[I" start;T0;$@ko;= ;>I" overload;F;?0;;);@0;:I"fill(obj, start, length);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@k;![;"I"@return [self];T;#0;$@k;.F;Bi;C0;7[[I"obj;T0[I" start;T0[I" length;T0;$@ko;= ;>I" overload;F;?0;;);@0;:I"fill(obj, range);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@k;![;"I"@return [self];T;#0;$@k;.F;Bi;C0;7[[I"obj;T0[I" range;T0;$@ko;= ;>I" overload;F;?0;;);@0;:I" fill;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" index;T;$@ko;A ;>I" return;F;?I";T;0;@[I" self;T;$@k;![;"I""@yield [index] @return [self];T;#0;$@k;.F;Bi;C0;7[;$@ko;= ;>I" overload;F;?0;;);@0;:I"fill(start);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" index;T;$@ko;A ;>I" return;F;?I";T;0;@[I" self;T;$@k;![;"I""@yield [index] @return [self];T;#0;$@k;.F;Bi;C0;7[[I" start;T0;$@ko;= ;>I" overload;F;?0;;);@0;:I"fill(start, length);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" index;T;$@ko;A ;>I" return;F;?I";T;0;@[I" self;T;$@k;![;"I""@yield [index] @return [self];T;#0;$@k;.F;Bi;C0;7[[I" start;T0[I" length;T0;$@ko;= ;>I" overload;F;?0;;);@0;:I"fill(range);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" index;T;$@ko;A ;>I" return;F;?I";T;0;@[I" self;T;$@k;![;"I""@yield [index] @return [self];T;#0;$@k;.F;Bi;C0;7[[I" range;T0;$@k;![;"I"nReplaces specified elements in +self+ with specified objects; returns +self+. With argument +obj+ and no block given, replaces all elements with that one object: a = ['a', 'b', 'c', 'd'] a # => ["a", "b", "c", "d"] a.fill(:X) # => [:X, :X, :X, :X] With arguments +obj+ and \Integer +start+, and no block given, replaces elements based on the given start. If +start+ is in range (0 <= start < array.size), replaces all elements from offset +start+ through the end: a = ['a', 'b', 'c', 'd'] a.fill(:X, 2) # => ["a", "b", :X, :X] If +start+ is too large (start >= array.size), does nothing: a = ['a', 'b', 'c', 'd'] a.fill(:X, 4) # => ["a", "b", "c", "d"] a = ['a', 'b', 'c', 'd'] a.fill(:X, 5) # => ["a", "b", "c", "d"] If +start+ is negative, counts from the end (starting index is start + array.size): a = ['a', 'b', 'c', 'd'] a.fill(:X, -2) # => ["a", "b", :X, :X] If +start+ is too small (less than and far from zero), replaces all elements: a = ['a', 'b', 'c', 'd'] a.fill(:X, -6) # => [:X, :X, :X, :X] a = ['a', 'b', 'c', 'd'] a.fill(:X, -50) # => [:X, :X, :X, :X] With arguments +obj+, \Integer +start+, and \Integer +length+, and no block given, replaces elements based on the given +start+ and +length+. If +start+ is in range, replaces +length+ elements beginning at offset +start+: a = ['a', 'b', 'c', 'd'] a.fill(:X, 1, 1) # => ["a", :X, "c", "d"] If +start+ is negative, counts from the end: a = ['a', 'b', 'c', 'd'] a.fill(:X, -2, 1) # => ["a", "b", :X, "d"] If +start+ is large (start >= array.size), extends +self+ with +nil+: a = ['a', 'b', 'c', 'd'] a.fill(:X, 5, 0) # => ["a", "b", "c", "d", nil] a = ['a', 'b', 'c', 'd'] a.fill(:X, 5, 2) # => ["a", "b", "c", "d", nil, :X, :X] If +length+ is zero or negative, replaces no elements: a = ['a', 'b', 'c', 'd'] a.fill(:X, 1, 0) # => ["a", "b", "c", "d"] a.fill(:X, 1, -1) # => ["a", "b", "c", "d"] With arguments +obj+ and \Range +range+, and no block given, replaces elements based on the given range. If the range is positive and ascending (0 < range.begin <= range.end), replaces elements from range.begin to range.end: a = ['a', 'b', 'c', 'd'] a.fill(:X, (1..1)) # => ["a", :X, "c", "d"] If range.first is negative, replaces no elements: a = ['a', 'b', 'c', 'd'] a.fill(:X, (-1..1)) # => ["a", "b", "c", "d"] If range.last is negative, counts from the end: a = ['a', 'b', 'c', 'd'] a.fill(:X, (0..-2)) # => [:X, :X, :X, "d"] a = ['a', 'b', 'c', 'd'] a.fill(:X, (1..-2)) # => ["a", :X, :X, "d"] If range.last and range.last are both negative, both count from the end of the array: a = ['a', 'b', 'c', 'd'] a.fill(:X, (-1..-1)) # => ["a", "b", "c", :X] a = ['a', 'b', 'c', 'd'] a.fill(:X, (-2..-2)) # => ["a", "b", :X, "d"] With no arguments and a block given, calls the block with each index; replaces the corresponding element with the block's return value: a = ['a', 'b', 'c', 'd'] a.fill { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "new_3"] With argument +start+ and a block given, calls the block with each index from offset +start+ to the end; replaces the corresponding element with the block's return value: If start is in range (0 <= start < array.size), replaces from offset +start+ to the end: a = ['a', 'b', 'c', 'd'] a.fill(1) { |index| "new_#{index}" } # => ["a", "new_1", "new_2", "new_3"] If +start+ is too large(start >= array.size), does nothing: a = ['a', 'b', 'c', 'd'] a.fill(4) { |index| fail 'Cannot happen' } # => ["a", "b", "c", "d"] a = ['a', 'b', 'c', 'd'] a.fill(4) { |index| fail 'Cannot happen' } # => ["a", "b", "c", "d"] If +start+ is negative, counts from the end: a = ['a', 'b', 'c', 'd'] a.fill(-2) { |index| "new_#{index}" } # => ["a", "b", "new_2", "new_3"] If start is too small (start <= -array.size, replaces all elements: a = ['a', 'b', 'c', 'd'] a.fill(-6) { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "new_3"] a = ['a', 'b', 'c', 'd'] a.fill(-50) { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "new_3"] With arguments +start+ and +length+, and a block given, calls the block for each index specified by start length; replaces the corresponding element with the block's return value. If +start+ is in range, replaces +length+ elements beginning at offset +start+: a = ['a', 'b', 'c', 'd'] a.fill(1, 1) { |index| "new_#{index}" } # => ["a", "new_1", "c", "d"] If start is negative, counts from the end: a = ['a', 'b', 'c', 'd'] a.fill(-2, 1) { |index| "new_#{index}" } # => ["a", "b", "new_2", "d"] If +start+ is large (start >= array.size), extends +self+ with +nil+: a = ['a', 'b', 'c', 'd'] a.fill(5, 0) { |index| "new_#{index}" } # => ["a", "b", "c", "d", nil] a = ['a', 'b', 'c', 'd'] a.fill(5, 2) { |index| "new_#{index}" } # => ["a", "b", "c", "d", nil, "new_5", "new_6"] If +length+ is zero or less, replaces no elements: a = ['a', 'b', 'c', 'd'] a.fill(1, 0) { |index| "new_#{index}" } # => ["a", "b", "c", "d"] a.fill(1, -1) { |index| "new_#{index}" } # => ["a", "b", "c", "d"] With arguments +obj+ and +range+, and a block given, calls the block with each index in the given range; replaces the corresponding element with the block's return value. If the range is positive and ascending (range 0 < range.begin <= range.end, replaces elements from range.begin to range.end: a = ['a', 'b', 'c', 'd'] a.fill(1..1) { |index| "new_#{index}" } # => ["a", "new_1", "c", "d"] If +range.first+ is negative, does nothing: a = ['a', 'b', 'c', 'd'] a.fill(-1..1) { |index| fail 'Cannot happen' } # => ["a", "b", "c", "d"] If range.last is negative, counts from the end: a = ['a', 'b', 'c', 'd'] a.fill(0..-2) { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "d"] a = ['a', 'b', 'c', 'd'] a.fill(1..-2) { |index| "new_#{index}" } # => ["a", "new_1", "new_2", "d"] If range.first and range.last are both negative, both count from the end: a = ['a', 'b', 'c', 'd'] a.fill(-1..-1) { |index| "new_#{index}" } # => ["a", "b", "c", "new_3"] a = ['a', 'b', 'c', 'd'] a.fill(-2..-2) { |index| "new_#{index}" } # => ["a", "b", "new_2", "d"] @overload fill(obj) @return [self] @overload fill(obj, start) @return [self] @overload fill(obj, start, length) @return [self] @overload fill(obj, range) @return [self] @overload fill @yield [index] @return [self] @overload fill(start) @yield [index] @return [self] @overload fill(start, length) @yield [index] @return [self] @overload fill(range) @yield [index] @return [self];T;#0;$@k;.F;/o;0;1T;2i;3i6;%@;9I"Cstatic VALUE rb_ary_fill(int argc, VALUE *argv, VALUE ary) { VALUE item = Qundef, arg1, arg2; long beg = 0, end = 0, len = 0; if (rb_block_given_p()) { rb_scan_args(argc, argv, "02", &arg1, &arg2); argc += 1; /* hackish */ } else { rb_scan_args(argc, argv, "12", &item, &arg1, &arg2); } switch (argc) { case 1: beg = 0; len = RARRAY_LEN(ary); break; case 2: if (rb_range_beg_len(arg1, &beg, &len, RARRAY_LEN(ary), 1)) { break; } /* fall through */ case 3: beg = NIL_P(arg1) ? 0 : NUM2LONG(arg1); if (beg < 0) { beg = RARRAY_LEN(ary) + beg; if (beg < 0) beg = 0; } len = NIL_P(arg2) ? RARRAY_LEN(ary) - beg : NUM2LONG(arg2); break; } rb_ary_modify(ary); if (len < 0) { return ary; } if (beg >= ARY_MAX_SIZE || len > ARY_MAX_SIZE - beg) { rb_raise(rb_eArgError, "argument too big"); } end = beg + len; if (RARRAY_LEN(ary) < end) { if (end >= ARY_CAPA(ary)) { ary_resize_capa(ary, end); } ary_mem_clear(ary, RARRAY_LEN(ary), end - RARRAY_LEN(ary)); ARY_SET_LEN(ary, end); } if (item == Qundef) { VALUE v; long i; for (i=beg; i=RARRAY_LEN(ary)) break; ARY_SET(ary, i, v); } } else { ary_memfill(ary, beg, len, item); } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#include?;F;7[[I" item;T0;[[@i;T;;;0;[;{;IC; "Returns +true+ if for some index +i+ in +self+, obj == self[i]; otherwise +false+: [0, 1, 2].include?(2) # => true [0, 1, 2].include?(3) # => false;T;[o;= ;>I" overload;F;?0;;;@0;:I"include?(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"obj;T0;$@;![;"I"Returns +true+ if for some index +i+ in +self+, obj == self[i]; otherwise +false+: [0, 1, 2].include?(2) # => true [0, 1, 2].include?(3) # => false @overload include?(obj) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"VALUE rb_ary_includes(VALUE ary, VALUE item) { long i; VALUE e; for (i=0; i;F;7[[I" ary2;T0;[[@i;T;;Y;0;[;{;IC; "[Returns -1, 0, or 1 as +self+ is less than, equal to, or greater than +other_array+. For each index +i+ in +self+, evaluates result = self[i] <=> other_array[i]. Returns -1 if any result is -1: [0, 1, 2] <=> [0, 1, 3] # => -1 Returns 1 if any result is 1: [0, 1, 2] <=> [0, 1, 1] # => 1 When all results are zero: - Returns -1 if +array+ is smaller than +other_array+: [0, 1, 2] <=> [0, 1, 2, 3] # => -1 - Returns 1 if +array+ is larger than +other_array+: [0, 1, 2] <=> [0, 1] # => 1 - Returns 0 if +array+ and +other_array+ are the same size: [0, 1, 2] <=> [0, 1, 2] # => 0 ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I"<=>(other_array);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"-1;TI"0;TI"1;T;$@-;![;"I"@return [-1, 0, 1];T;#0;$@-;.F;Bi;C0;7[[I"other_array;T0;$@-;![;"I"Returns -1, 0, or 1 as +self+ is less than, equal to, or greater than +other_array+. For each index +i+ in +self+, evaluates result = self[i] <=> other_array[i]. Returns -1 if any result is -1: [0, 1, 2] <=> [0, 1, 3] # => -1 Returns 1 if any result is 1: [0, 1, 2] <=> [0, 1, 1] # => 1 When all results are zero: - Returns -1 if +array+ is smaller than +other_array+: [0, 1, 2] <=> [0, 1, 2, 3] # => -1 - Returns 1 if +array+ is larger than +other_array+: [0, 1, 2] <=> [0, 1] # => 1 - Returns 0 if +array+ and +other_array+ are the same size: [0, 1, 2] <=> [0, 1, 2] # => 0 @overload <=>(other_array) @return [-1, 0, 1];T;#0;$@-;.F;/o;0;1T;2i;3i;%@;9I"VALUE rb_ary_cmp(VALUE ary1, VALUE ary2) { long len; VALUE v; ary2 = rb_check_array_type(ary2); if (NIL_P(ary2)) return Qnil; if (ary1 == ary2) return INT2FIX(0); v = rb_exec_recursive_paired(recursive_cmp, ary1, ary2, ary2); if (v != Qundef) return v; len = RARRAY_LEN(ary1) - RARRAY_LEN(ary2); if (len == 0) return INT2FIX(0); if (len > 0) return INT2FIX(1); return INT2FIX(-1); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Array#slice;F;7[[@90;[[@i;T;;;0;[;{;IC; "@ Returns elements from +self+; does not modify +self+. When a single \Integer argument +index+ is given, returns the element at offset +index+: a = [:foo, 'bar', 2] a[0] # => :foo a[2] # => 2 a # => [:foo, "bar", 2] If +index+ is negative, counts relative to the end of +self+: a = [:foo, 'bar', 2] a[-1] # => 2 a[-2] # => "bar" If +index+ is out of range, returns +nil+. When two \Integer arguments +start+ and +length+ are given, returns a new \Array of size +length+ containing successive elements beginning at offset +start+: a = [:foo, 'bar', 2] a[0, 2] # => [:foo, "bar"] a[1, 2] # => ["bar", 2] If start + length is greater than self.length, returns all elements from offset +start+ to the end: a = [:foo, 'bar', 2] a[0, 4] # => [:foo, "bar", 2] a[1, 3] # => ["bar", 2] a[2, 2] # => [2] If start == self.size and length >= 0, returns a new empty \Array. If +length+ is negative, returns +nil+. When a single \Range argument +range+ is given, treats range.min as +start+ above and range.size as +length+ above: a = [:foo, 'bar', 2] a[0..1] # => [:foo, "bar"] a[1..2] # => ["bar", 2] Special case: If range.start == a.size, returns a new empty \Array. If range.end is negative, calculates the end index from the end: a = [:foo, 'bar', 2] a[0..-1] # => [:foo, "bar", 2] a[0..-2] # => [:foo, "bar"] a[0..-3] # => [:foo] If range.start is negative, calculates the start index from the end: a = [:foo, 'bar', 2] a[-1..2] # => [2] a[-2..2] # => ["bar", 2] a[-3..2] # => [:foo, "bar", 2] If range.start is larger than the array size, returns +nil+. a = [:foo, 'bar', 2] a[4..1] # => nil a[4..0] # => nil a[4..-1] # => nil When a single Enumerator::ArithmeticSequence argument +aseq+ is given, returns an Array of elements corresponding to the indexes produced by the sequence. a = ['--', 'data1', '--', 'data2', '--', 'data3'] a[(1..).step(2)] # => ["data1", "data2", "data3"] Unlike slicing with range, if the start or the end of the arithmetic sequence is larger than array size, throws RangeError. a = ['--', 'data1', '--', 'data2', '--', 'data3'] a[(1..11).step(2)] # RangeError (((1..11).step(2)) out of range) a[(7..).step(2)] # RangeError (((7..).step(2)) out of range) If given a single argument, and its type is not one of the listed, tries to convert it to Integer, and raises if it is impossible: a = [:foo, 'bar', 2] # Raises TypeError (no implicit conversion of Symbol into Integer): a[:foo] Array#slice is an alias for Array#[]. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"[](index);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@N;![;"I"@return [Object, nil];T;#0;$@N;.F;Bi;C0;7[[I" index;T0;$@No;= ;>I" overload;F;?0;;;@0;:I"[](start, length);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@N;![;"I"@return [Object, nil];T;#0;$@N;.F;Bi;C0;7[[I" start;T0[I" length;T0;$@No;= ;>I" overload;F;?0;;;@0;:I"[](range);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@N;![;"I"@return [Object, nil];T;#0;$@N;.F;Bi;C0;7[[I" range;T0;$@No;= ;>I" overload;F;?0;;;@0;:I" [](aseq);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@N;![;"I"@return [Object, nil];T;#0;$@N;.F;Bi;C0;7[[I" aseq;T0;$@No;= ;>I" overload;F;?0;;;@0;:I"slice(index);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@N;![;"I"@return [Object, nil];T;#0;$@N;.F;Bi;C0;7[[I" index;T0;$@No;= ;>I" overload;F;?0;;;@0;:I"slice(start, length);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@N;![;"I"@return [Object, nil];T;#0;$@N;.F;Bi;C0;7[[I" start;T0[I" length;T0;$@No;= ;>I" overload;F;?0;;;@0;:I"slice(range);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@N;![;"I"@return [Object, nil];T;#0;$@N;.F;Bi;C0;7[[I" range;T0;$@No;= ;>I" overload;F;?0;;;@0;:I"slice(aseq);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@N;![;"I"@return [Object, nil];T;#0;$@N;.F;Bi;C0;7[[I" aseq;T0;$@N;![;"@;#0;$@N;.F;/o;0;1T;2i;3i;%@;9I"VALUE rb_ary_aref(int argc, const VALUE *argv, VALUE ary) { rb_check_arity(argc, 1, 2); if (argc == 2) { return rb_ary_aref2(ary, argv[0], argv[1]); } return rb_ary_aref1(ary, argv[0]); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Array#slice!;F;7[[@90;[[@i;T;: slice!;0;[;{;IC; "GRemoves and returns elements from +self+. When the only argument is an \Integer +n+, removes and returns the _nth_ element in +self+: a = [:foo, 'bar', 2] a.slice!(1) # => "bar" a # => [:foo, 2] If +n+ is negative, counts backwards from the end of +self+: a = [:foo, 'bar', 2] a.slice!(-1) # => 2 a # => [:foo, "bar"] If +n+ is out of range, returns +nil+. When the only arguments are Integers +start+ and +length+, removes +length+ elements from +self+ beginning at offset +start+; returns the deleted objects in a new Array: a = [:foo, 'bar', 2] a.slice!(0, 2) # => [:foo, "bar"] a # => [2] If start + length exceeds the array size, removes and returns all elements from offset +start+ to the end: a = [:foo, 'bar', 2] a.slice!(1, 50) # => ["bar", 2] a # => [:foo] If start == a.size and +length+ is non-negative, returns a new empty \Array. If +length+ is negative, returns +nil+. When the only argument is a \Range object +range+, treats range.min as +start+ above and range.size as +length+ above: a = [:foo, 'bar', 2] a.slice!(1..2) # => ["bar", 2] a # => [:foo] If range.start == a.size, returns a new empty \Array. If range.start is larger than the array size, returns +nil+. If range.end is negative, counts backwards from the end of the array: a = [:foo, 'bar', 2] a.slice!(0..-2) # => [:foo, "bar"] a # => [2] If range.start is negative, calculates the start index backwards from the end of the array: a = [:foo, 'bar', 2] a.slice!(-2..2) # => ["bar", 2] a # => [:foo] ;T;[o;= ;>I" overload;F;?0;;*;@0;:I"slice!(n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@;![;"I"@return [Object, nil];T;#0;$@;.F;Bi;C0;7[[I"n;T0;$@o;= ;>I" overload;F;?0;;*;@0;:I"slice!(start, length);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I" start;T0[I" length;T0;$@o;= ;>I" overload;F;?0;;*;@0;:I"slice!(range);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I" range;T0;$@;![;"I"Removes and returns elements from +self+. When the only argument is an \Integer +n+, removes and returns the _nth_ element in +self+: a = [:foo, 'bar', 2] a.slice!(1) # => "bar" a # => [:foo, 2] If +n+ is negative, counts backwards from the end of +self+: a = [:foo, 'bar', 2] a.slice!(-1) # => 2 a # => [:foo, "bar"] If +n+ is out of range, returns +nil+. When the only arguments are Integers +start+ and +length+, removes +length+ elements from +self+ beginning at offset +start+; returns the deleted objects in a new Array: a = [:foo, 'bar', 2] a.slice!(0, 2) # => [:foo, "bar"] a # => [2] If start + length exceeds the array size, removes and returns all elements from offset +start+ to the end: a = [:foo, 'bar', 2] a.slice!(1, 50) # => ["bar", 2] a # => [:foo] If start == a.size and +length+ is non-negative, returns a new empty \Array. If +length+ is negative, returns +nil+. When the only argument is a \Range object +range+, treats range.min as +start+ above and range.size as +length+ above: a = [:foo, 'bar', 2] a.slice!(1..2) # => ["bar", 2] a # => [:foo] If range.start == a.size, returns a new empty \Array. If range.start is larger than the array size, returns +nil+. If range.end is negative, counts backwards from the end of the array: a = [:foo, 'bar', 2] a.slice!(0..-2) # => [:foo, "bar"] a # => [2] If range.start is negative, calculates the start index backwards from the end of the array: a = [:foo, 'bar', 2] a.slice!(-2..2) # => ["bar", 2] a # => [:foo] @overload slice!(n) @return [Object, nil] @overload slice!(start, length) @return [nil] @overload slice!(range) @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_ary_slice_bang(int argc, VALUE *argv, VALUE ary) { VALUE arg1; long pos, len; rb_ary_modify_check(ary); rb_check_arity(argc, 1, 2); arg1 = argv[0]; if (argc == 2) { pos = NUM2LONG(argv[0]); len = NUM2LONG(argv[1]); return ary_slice_bang_by_rb_ary_splice(ary, pos, len); } if (!FIXNUM_P(arg1)) { switch (rb_range_beg_len(arg1, &pos, &len, RARRAY_LEN(ary), 0)) { case Qtrue: /* valid range */ return ary_slice_bang_by_rb_ary_splice(ary, pos, len); case Qnil: /* invalid range */ return Qnil; default: /* not a range */ break; } } return rb_ary_delete_at(ary, NUM2LONG(arg1)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#assoc;F;7[[I"key;T0;[[@i;T;;;0;[;{;IC; "Returns the first element in +self+ that is an \Array whose first element == +obj+: a = [{foo: 0}, [2, 4], [4, 5, 6], [4, 5]] a.assoc(4) # => [4, 5, 6] Returns +nil+ if no such element is found. Related: #rassoc. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"assoc(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I"obj;T0;$@;![;"I" Returns the first element in +self+ that is an \Array whose first element == +obj+: a = [{foo: 0}, [2, 4], [4, 5, 6], [4, 5]] a.assoc(4) # => [4, 5, 6] Returns +nil+ if no such element is found. Related: #rassoc. @overload assoc(obj) @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"VALUE rb_ary_assoc(VALUE ary, VALUE key) { long i; VALUE v; for (i = 0; i < RARRAY_LEN(ary); ++i) { v = rb_check_array_type(RARRAY_AREF(ary, i)); if (!NIL_P(v) && RARRAY_LEN(v) > 0 && rb_equal(RARRAY_AREF(v, 0), key)) return v; } return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Array#rassoc;F;7[[I" value;T0;[[@i!;T;;;0;[;{;IC; "Returns the first element in +self+ that is an \Array whose second element == +obj+: a = [{foo: 0}, [2, 4], [4, 5, 6], [4, 5]] a.rassoc(4) # => [2, 4] Returns +nil+ if no such element is found. Related: #assoc. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"rassoc(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@>;![;"I"@return [nil];T;#0;$@>;.F;Bi;C0;7[[I"obj;T0;$@>;![;"I" Returns the first element in +self+ that is an \Array whose second element == +obj+: a = [{foo: 0}, [2, 4], [4, 5, 6], [4, 5]] a.rassoc(4) # => [2, 4] Returns +nil+ if no such element is found. Related: #assoc. @overload rassoc(obj) @return [nil];T;#0;$@>;.F;/o;0;1T;2i;3i;%@;9I"VALUE rb_ary_rassoc(VALUE ary, VALUE value) { long i; VALUE v; for (i = 0; i < RARRAY_LEN(ary); ++i) { v = RARRAY_AREF(ary, i); if (RB_TYPE_P(v, T_ARRAY) && RARRAY_LEN(v) > 1 && rb_equal(RARRAY_AREF(v, 1), value)) return v; } return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I" Array#+;F;7[[I"y;T0;[[@iz;T;;;0;[;{;IC; "Returns a new \Array containing all elements of +array+ followed by all elements of +other_array+: a = [0, 1] + [2, 3] a # => [0, 1, 2, 3] Related: #concat. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"+(other_array);T;IC; ";T;[;![;"I";T;#0;$@];.F;Bi;C0;7[[I"other_array;T0;$@];![;"I"Returns a new \Array containing all elements of +array+ followed by all elements of +other_array+: a = [0, 1] + [2, 3] a # => [0, 1, 2, 3] Related: #concat. @overload +(other_array);T;#0;$@];.F;/o;0;1T;2in;3iv;%@;9I"hVALUE rb_ary_plus(VALUE x, VALUE y) { VALUE z; long len, xlen, ylen; y = to_ary(y); xlen = RARRAY_LEN(x); ylen = RARRAY_LEN(y); len = xlen + ylen; z = rb_ary_new2(len); ary_memcpy(z, 0, xlen, RARRAY_CONST_PTR_TRANSIENT(x)); ary_memcpy(z, xlen, ylen, RARRAY_CONST_PTR_TRANSIENT(y)); ARY_SET_LEN(z, len); return z; };T;:I" VALUE;T;;To;4;5F;6;;;;&I" Array#*;F;7[[I" times;T0;[[@i;T;;;0;[;{;IC; "VWhen non-negative argument \Integer +n+ is given, returns a new \Array built by concatenating the +n+ copies of +self+: a = ['x', 'y'] a * 3 # => ["x", "y", "x", "y", "x", "y"] When \String argument +string_separator+ is given, equivalent to array.join(string_separator): [0, [0, 1], {foo: 0}] * ', ' # => "0, 0, 1, {:foo=>0}" ;T;[o;= ;>I" overload;F;?0;;;@0;:I" *(n);T;IC; ";T;[;![;"I";T;#0;$@w;.F;Bi;C0;7[[I"n;T0;$@wo;= ;>I" overload;F;?0;;;@0;:I"*(string_separator);T;IC; ";T;[;![;"I";T;#0;$@w;.F;Bi;C0;7[[I"string_separator;T0;$@w;![;"I"When non-negative argument \Integer +n+ is given, returns a new \Array built by concatenating the +n+ copies of +self+: a = ['x', 'y'] a * 3 # => ["x", "y", "x", "y", "x", "y"] When \String argument +string_separator+ is given, equivalent to array.join(string_separator): [0, [0, 1], {foo: 0}] * ', ' # => "0, 0, 1, {:foo=>0}" @overload *(n) @overload *(string_separator);T;#0;$@w;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_ary_times(VALUE ary, VALUE times) { VALUE ary2, tmp; const VALUE *ptr; long t, len; tmp = rb_check_string_type(times); if (!NIL_P(tmp)) { return rb_ary_join(ary, tmp); } len = NUM2LONG(times); if (len == 0) { ary2 = ary_new(rb_cArray, 0); goto out; } if (len < 0) { rb_raise(rb_eArgError, "negative argument"); } if (ARY_MAX_SIZE/len < RARRAY_LEN(ary)) { rb_raise(rb_eArgError, "argument too big"); } len *= RARRAY_LEN(ary); ary2 = ary_new(rb_cArray, len); ARY_SET_LEN(ary2, len); ptr = RARRAY_CONST_PTR_TRANSIENT(ary); t = RARRAY_LEN(ary); if (0 < t) { ary_memcpy(ary2, 0, t, ptr); while (t <= len/2) { ary_memcpy(ary2, t, t, RARRAY_CONST_PTR_TRANSIENT(ary2)); t *= 2; } if (t < len) { ary_memcpy(ary2, t, len-t, RARRAY_CONST_PTR_TRANSIENT(ary2)); } } out: return ary2; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Array#-;F;7[[I" ary2;T0;[[@ic;T;;;0;[;{;IC; "MReturns a new \Array containing only those elements from +array+ that are not found in \Array +other_array+; items are compared using eql?; the order from +array+ is preserved: [0, 1, 1, 2, 1, 1, 3, 1, 1] - [1] # => [0, 2, 3] [0, 1, 2, 3] - [3, 0] # => [1, 2] [0, 1, 2] - [4] # => [0, 1, 2] Related: Array#difference. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"-(other_array);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"other_array;T0;$@;![;"I"hReturns a new \Array containing only those elements from +array+ that are not found in \Array +other_array+; items are compared using eql?; the order from +array+ is preserved: [0, 1, 1, 2, 1, 1, 3, 1, 1] - [1] # => [0, 2, 3] [0, 1, 2, 3] - [3, 0] # => [1, 2] [0, 1, 2] - [4] # => [0, 1, 2] Related: Array#difference. @overload -(other_array);T;#0;$@;.F;/o;0;1T;2iT;3i_;%@;9I"static VALUE rb_ary_diff(VALUE ary1, VALUE ary2) { VALUE ary3; VALUE hash; long i; ary2 = to_ary(ary2); if (RARRAY_LEN(ary2) == 0) { return ary_make_shared_copy(ary1); } ary3 = rb_ary_new(); if (RARRAY_LEN(ary1) <= SMALL_ARRAY_LEN || RARRAY_LEN(ary2) <= SMALL_ARRAY_LEN) { for (i=0; ieql?: [0, 1, 2, 3] & [1, 2] # => [1, 2] [0, 1, 0, 1] & [0, 1] # => [0, 1] Preserves order from +array+: [0, 1, 2] & [3, 2, 1, 0] # => [0, 1, 2] Related: Array#intersection. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"&(other_array);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"other_array;T0;$@;![;"I"fReturns a new \Array containing each element found in both +array+ and \Array +other_array+; duplicates are omitted; items are compared using eql?: [0, 1, 2, 3] & [1, 2] # => [1, 2] [0, 1, 0, 1] & [0, 1] # => [0, 1] Preserves order from +array+: [0, 1, 2] & [3, 2, 1, 0] # => [0, 1, 2] Related: Array#intersection. @overload &(other_array);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_ary_and(VALUE ary1, VALUE ary2) { VALUE hash, ary3, v; st_data_t vv; long i; ary2 = to_ary(ary2); ary3 = rb_ary_new(); if (RARRAY_LEN(ary1) == 0 || RARRAY_LEN(ary2) == 0) return ary3; if (RARRAY_LEN(ary1) <= SMALL_ARRAY_LEN && RARRAY_LEN(ary2) <= SMALL_ARRAY_LEN) { for (i=0; ieql?: [0, 1] | [2, 3] # => [0, 1, 2, 3] [0, 1, 1] | [2, 2, 3] # => [0, 1, 2, 3] [0, 1, 2] | [3, 2, 1, 0] # => [0, 1, 2, 3] Related: Array#union. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"|(other_array);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"other_array;T0;$@;![;"I"7Returns the union of +array+ and \Array +other_array+; duplicates are removed; order is preserved; items are compared using eql?: [0, 1] | [2, 3] # => [0, 1, 2, 3] [0, 1, 1] | [2, 2, 3] # => [0, 1, 2, 3] [0, 1, 2] | [3, 2, 1, 0] # => [0, 1, 2, 3] Related: Array#union. @overload |(other_array);T;#0;$@;.F;/o;0;1T;2i&;3i0;%@;9I"static VALUE rb_ary_or(VALUE ary1, VALUE ary2) { VALUE hash, ary3; ary2 = to_ary(ary2); if (RARRAY_LEN(ary1) + RARRAY_LEN(ary2) <= SMALL_ARRAY_LEN) { ary3 = rb_ary_new(); rb_ary_union(ary3, ary1); rb_ary_union(ary3, ary2); return ary3; } hash = ary_make_hash(ary1); rb_ary_union_hash(hash, ary2); ary3 = rb_hash_values(hash); ary_recycle_hash(hash); return ary3; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#max;F;7[[@90;[[@i';T;;e;0;[;{;IC; ""Returns one of the following: - The maximum-valued element from +self+. - A new \Array of maximum-valued elements selected from +self+. When no block is given, each element in +self+ must respond to method <=> with an \Integer. With no argument and no block, returns the element in +self+ having the maximum value per method <=>: [0, 1, 2].max # => 2 With an argument \Integer +n+ and no block, returns a new \Array with at most +n+ elements, in descending order per method <=>: [0, 1, 2, 3].max(3) # => [3, 2, 1] [0, 1, 2, 3].max(6) # => [3, 2, 1, 0] When a block is given, the block must return an \Integer. With a block and no argument, calls the block self.size-1 times to compare elements; returns the element having the maximum value per the block: ['0', '00', '000'].max {|a, b| a.size <=> b.size } # => "000" With an argument +n+ and a block, returns a new \Array with at most +n+ elements, in descending order per the block: ['0', '00', '000'].max(2) {|a, b| a.size <=> b.size } # => ["000", "00"] ;T;[ o;= ;>I" overload;F;?0;;e;@0;:I"max;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;e;@0;:I"max;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"a;TI"b;T;$@;![;"I"@yield [a, b];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;e;@0;:I" max(n);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"n;T0;$@o;= ;>I" overload;F;?0;;e;@0;:I" max(n);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"a;TI"b;T;$@;![;"I"@yield [a, b];T;#0;$@;.F;Bi;C0;7[[I"n;T0;$@;![;"I"Returns one of the following: - The maximum-valued element from +self+. - A new \Array of maximum-valued elements selected from +self+. When no block is given, each element in +self+ must respond to method <=> with an \Integer. With no argument and no block, returns the element in +self+ having the maximum value per method <=>: [0, 1, 2].max # => 2 With an argument \Integer +n+ and no block, returns a new \Array with at most +n+ elements, in descending order per method <=>: [0, 1, 2, 3].max(3) # => [3, 2, 1] [0, 1, 2, 3].max(6) # => [3, 2, 1, 0] When a block is given, the block must return an \Integer. With a block and no argument, calls the block self.size-1 times to compare elements; returns the element having the maximum value per the block: ['0', '00', '000'].max {|a, b| a.size <=> b.size } # => "000" With an argument +n+ and a block, returns a new \Array with at most +n+ elements, in descending order per the block: ['0', '00', '000'].max(2) {|a, b| a.size <=> b.size } # => ["000", "00"] @overload max @overload max @yield [a, b] @overload max(n) @overload max(n) @yield [a, b];T;#0;$@;.F;/o;0;1T;2i;3i&;%@;9I"static VALUE rb_ary_max(int argc, VALUE *argv, VALUE ary) { struct cmp_opt_data cmp_opt = { 0, 0 }; VALUE result = Qundef, v; VALUE num; long i; if (rb_check_arity(argc, 0, 1) && !NIL_P(num = argv[0])) return rb_nmin_run(ary, num, 0, 1, 1); const long n = RARRAY_LEN(ary); if (rb_block_given_p()) { for (i = 0; i < RARRAY_LEN(ary); i++) { v = RARRAY_AREF(ary, i); if (result == Qundef || rb_cmpint(rb_yield_values(2, v, result), v, result) > 0) { result = v; } } } else if (n > 0) { result = RARRAY_AREF(ary, 0); if (n > 1) { if (FIXNUM_P(result) && CMP_OPTIMIZABLE(cmp_opt, Integer)) { return ary_max_opt_fixnum(ary, 1, result); } else if (STRING_P(result) && CMP_OPTIMIZABLE(cmp_opt, String)) { return ary_max_opt_string(ary, 1, result); } else if (RB_FLOAT_TYPE_P(result) && CMP_OPTIMIZABLE(cmp_opt, Float)) { return ary_max_opt_float(ary, 1, result); } else { return ary_max_generic(ary, 1, result); } } } if (result == Qundef) return Qnil; return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#min;F;7[[@90;[[@i;T;;;0;[;{;IC; "Returns one of the following: - The minimum-valued element from +self+. - A new \Array of minimum-valued elements selected from +self+. When no block is given, each element in +self+ must respond to method <=> with an \Integer. With no argument and no block, returns the element in +self+ having the minimum value per method <=>: [0, 1, 2].min # => 0 With \Integer argument +n+ and no block, returns a new \Array with at most +n+ elements, in ascending order per method <=>: [0, 1, 2, 3].min(3) # => [0, 1, 2] [0, 1, 2, 3].min(6) # => [0, 1, 2, 3] When a block is given, the block must return an Integer. With a block and no argument, calls the block self.size-1 times to compare elements; returns the element having the minimum value per the block: ['0', '00', '000'].min { |a, b| a.size <=> b.size } # => "0" With an argument +n+ and a block, returns a new \Array with at most +n+ elements, in ascending order per the block: ['0', '00', '000'].min(2) {|a, b| a.size <=> b.size } # => ["0", "00"] ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"min;T;IC; ";T;[;![;"I";T;#0;$@(;.F;Bi;C0;7[;$@(o;= ;>I" overload;F;?0;;;@0;:I"min;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"a;TI"b;T;$@(;![;"I"@yield [a, b];T;#0;$@(;.F;Bi;C0;7[;$@(o;= ;>I" overload;F;?0;;;@0;:I" min(n);T;IC; ";T;[;![;"I";T;#0;$@(;.F;Bi;C0;7[[I"n;T0;$@(o;= ;>I" overload;F;?0;;;@0;:I" min(n);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"a;TI"b;T;$@(;![;"I"@yield [a, b];T;#0;$@(;.F;Bi;C0;7[[I"n;T0;$@(;![;"I"yReturns one of the following: - The minimum-valued element from +self+. - A new \Array of minimum-valued elements selected from +self+. When no block is given, each element in +self+ must respond to method <=> with an \Integer. With no argument and no block, returns the element in +self+ having the minimum value per method <=>: [0, 1, 2].min # => 0 With \Integer argument +n+ and no block, returns a new \Array with at most +n+ elements, in ascending order per method <=>: [0, 1, 2, 3].min(3) # => [0, 1, 2] [0, 1, 2, 3].min(6) # => [0, 1, 2, 3] When a block is given, the block must return an Integer. With a block and no argument, calls the block self.size-1 times to compare elements; returns the element having the minimum value per the block: ['0', '00', '000'].min { |a, b| a.size <=> b.size } # => "0" With an argument +n+ and a block, returns a new \Array with at most +n+ elements, in ascending order per the block: ['0', '00', '000'].min(2) {|a, b| a.size <=> b.size } # => ["0", "00"] @overload min @overload min @yield [a, b] @overload min(n) @overload min(n) @yield [a, b];T;#0;$@(;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_ary_min(int argc, VALUE *argv, VALUE ary) { struct cmp_opt_data cmp_opt = { 0, 0 }; VALUE result = Qundef, v; VALUE num; long i; if (rb_check_arity(argc, 0, 1) && !NIL_P(num = argv[0])) return rb_nmin_run(ary, num, 0, 0, 1); const long n = RARRAY_LEN(ary); if (rb_block_given_p()) { for (i = 0; i < RARRAY_LEN(ary); i++) { v = RARRAY_AREF(ary, i); if (result == Qundef || rb_cmpint(rb_yield_values(2, v, result), v, result) < 0) { result = v; } } } else if (n > 0) { result = RARRAY_AREF(ary, 0); if (n > 1) { if (FIXNUM_P(result) && CMP_OPTIMIZABLE(cmp_opt, Integer)) { return ary_min_opt_fixnum(ary, 1, result); } else if (STRING_P(result) && CMP_OPTIMIZABLE(cmp_opt, String)) { return ary_min_opt_string(ary, 1, result); } else if (RB_FLOAT_TYPE_P(result) && CMP_OPTIMIZABLE(cmp_opt, Float)) { return ary_min_opt_float(ary, 1, result); } else { return ary_min_generic(ary, 1, result); } } } if (result == Qundef) return Qnil; return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#minmax;F;7[;[[@i;T;;;0;[;{;IC; "Returns a new 2-element \Array containing the minimum and maximum values from +self+, either per method <=> or per a given block:. When no block is given, each element in +self+ must respond to method <=> with an \Integer; returns a new 2-element \Array containing the minimum and maximum values from +self+, per method <=>: [0, 1, 2].minmax # => [0, 2] When a block is given, the block must return an \Integer; the block is called self.size-1 times to compare elements; returns a new 2-element \Array containing the minimum and maximum values from +self+, per the block: ['0', '00', '000'].minmax {|a, b| a.size <=> b.size } # => ["0", "000"] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" minmax;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@g;![;"I"@return [Array];T;#0;$@g;.F;Bi;C0;7[;$@go;= ;>I" overload;F;?0;;;@0;:I" minmax;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"a;TI"b;T;$@go;A ;>I" return;F;?I";T;0;@[I" Array;T;$@g;![;"I""@yield [a, b] @return [Array];T;#0;$@g;.F;Bi;C0;7[;$@g;![;"I"Returns a new 2-element \Array containing the minimum and maximum values from +self+, either per method <=> or per a given block:. When no block is given, each element in +self+ must respond to method <=> with an \Integer; returns a new 2-element \Array containing the minimum and maximum values from +self+, per method <=>: [0, 1, 2].minmax # => [0, 2] When a block is given, the block must return an \Integer; the block is called self.size-1 times to compare elements; returns a new 2-element \Array containing the minimum and maximum values from +self+, per the block: ['0', '00', '000'].minmax {|a, b| a.size <=> b.size } # => ["0", "000"] @overload minmax @return [Array] @overload minmax @yield [a, b] @return [Array];T;#0;$@g;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_ary_minmax(VALUE ary) { if (rb_block_given_p()) { return rb_call_super(0, NULL); } return rb_assoc_new(rb_ary_min(0, 0, ary), rb_ary_max(0, 0, ary)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#uniq;F;7[;[[@ie;T;;;0;[;{;IC; "2Returns a new \Array containing those elements from +self+ that are not duplicates, the first occurrence always being retained. With no block given, identifies and omits duplicates using method eql? to compare. a = [0, 0, 1, 1, 2, 2] a.uniq # => [0, 1, 2] With a block given, calls the block for each element; identifies (using method eql?) and omits duplicate values, that is, those elements for which the block returns the same value: a = ['a', 'aa', 'aaa', 'b', 'bb', 'bbb'] a.uniq {|element| element.size } # => ["a", "aa", "aaa"] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" uniq;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" uniq;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@;![;"I"@yield [element];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"eReturns a new \Array containing those elements from +self+ that are not duplicates, the first occurrence always being retained. With no block given, identifies and omits duplicates using method eql? to compare. a = [0, 0, 1, 1, 2, 2] a.uniq # => [0, 1, 2] With a block given, calls the block for each element; identifies (using method eql?) and omits duplicate values, that is, those elements for which the block returns the same value: a = ['a', 'aa', 'aaa', 'b', 'bb', 'bbb'] a.uniq {|element| element.size } # => ["a", "aa", "aaa"] @overload uniq @overload uniq @yield [element];T;#0;$@;.F;/o;0;1T;2iQ;3ib;%@;9I"static VALUE rb_ary_uniq(VALUE ary) { VALUE hash, uniq; if (RARRAY_LEN(ary) <= 1) { hash = 0; uniq = rb_ary_dup(ary); } else if (rb_block_given_p()) { hash = ary_make_hash_by(ary); uniq = rb_hash_values(hash); } else { hash = ary_make_hash(ary); uniq = rb_hash_values(hash); } if (hash) { ary_recycle_hash(hash); } return uniq; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#uniq!;F;7[;[[@i2;T;: uniq!;0;[;{;IC; "Removes duplicate elements from +self+, the first occurrence always being retained; returns +self+ if any elements removed, +nil+ otherwise. With no block given, identifies and removes elements using method eql? to compare. Returns +self+ if any elements removed: a = [0, 0, 1, 1, 2, 2] a.uniq! # => [0, 1, 2] Returns +nil+ if no elements removed. With a block given, calls the block for each element; identifies (using method eql?) and removes elements for which the block returns duplicate values. Returns +self+ if any elements removed: a = ['a', 'aa', 'aaa', 'b', 'bb', 'bbb'] a.uniq! {|element| element.size } # => ['a', 'aa', 'aaa'] Returns +nil+ if no elements removed. ;T;[o;= ;>I" overload;F;?0;;+;@0;:I" uniq!;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;TI"nil;T;$@;![;"I"@return [self, nil];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;+;@0;:I" uniq!;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;TI"nil;T;$@;![;"I")@yield [element] @return [self, nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"%Removes duplicate elements from +self+, the first occurrence always being retained; returns +self+ if any elements removed, +nil+ otherwise. With no block given, identifies and removes elements using method eql? to compare. Returns +self+ if any elements removed: a = [0, 0, 1, 1, 2, 2] a.uniq! # => [0, 1, 2] Returns +nil+ if no elements removed. With a block given, calls the block for each element; identifies (using method eql?) and removes elements for which the block returns duplicate values. Returns +self+ if any elements removed: a = ['a', 'aa', 'aaa', 'b', 'bb', 'bbb'] a.uniq! {|element| element.size } # => ['a', 'aa', 'aaa'] Returns +nil+ if no elements removed. @overload uniq! @return [self, nil] @overload uniq! @yield [element] @return [self, nil];T;#0;$@;.F;/o;0;1T;2i;3i2;%@;9I"xstatic VALUE rb_ary_uniq_bang(VALUE ary) { VALUE hash; long hash_size; rb_ary_modify_check(ary); if (RARRAY_LEN(ary) <= 1) return Qnil; if (rb_block_given_p()) hash = ary_make_hash_by(ary); else hash = ary_make_hash(ary); hash_size = RHASH_SIZE(hash); if (RARRAY_LEN(ary) == hash_size) { return Qnil; } rb_ary_modify_check(ary); ARY_SET_LEN(ary, 0); if (ARY_SHARED_P(ary) && !ARY_EMBED_P(ary)) { rb_ary_unshare(ary); FL_SET_EMBED(ary); } ary_resize_capa(ary, hash_size); rb_hash_foreach(hash, push_value, ary); ary_recycle_hash(hash); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#compact;F;7[;[[@i;T;;;0;[;{;IC; "Returns a new \Array containing all non-+nil+ elements from +self+: a = [nil, 0, nil, 1, nil, 2, nil] a.compact # => [0, 1, 2] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" compact;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a new \Array containing all non-+nil+ elements from +self+: a = [nil, 0, nil, 1, nil, 2, nil] a.compact # => [0, 1, 2] @overload compact;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"xstatic VALUE rb_ary_compact(VALUE ary) { ary = rb_ary_dup(ary); rb_ary_compact_bang(ary); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#compact!;F;7[;[[@i;T;;;0;[;{;IC; "fRemoves all +nil+ elements from +self+. Returns +self+ if any elements removed, otherwise +nil+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" compact!;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;TI"nil;T;$@;![;"I"@return [self, nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Removes all +nil+ elements from +self+. Returns +self+ if any elements removed, otherwise +nil+. @overload compact! @return [self, nil];T;#0;$@;.F;/o;0;1T;2i};3i;%@;9I"static VALUE rb_ary_compact_bang(VALUE ary) { VALUE *p, *t, *end; long n; rb_ary_modify(ary); p = t = (VALUE *)RARRAY_CONST_PTR_TRANSIENT(ary); /* WB: no new reference */ end = p + RARRAY_LEN(ary); while (t < end) { if (NIL_P(*t)) t++; else *p++ = *t++; } n = p - RARRAY_CONST_PTR_TRANSIENT(ary); if (RARRAY_LEN(ary) == n) { return Qnil; } ary_resize_smaller(ary, n); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#flatten;F;7[[@90;[[@i;T;;;0;[;{;IC; "Returns a new \Array that is a recursive flattening of +self+: - Each non-Array element is unchanged. - Each \Array is replaced by its individual elements. With non-negative \Integer argument +level+, flattens recursively through +level+ levels: a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten(0) # => [0, [1, [2, 3], 4], 5] a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten(1) # => [0, 1, [2, 3], 4, 5] a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten(2) # => [0, 1, 2, 3, 4, 5] a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten(3) # => [0, 1, 2, 3, 4, 5] With no argument, a +nil+ argument, or with negative argument +level+, flattens all levels: a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten # => [0, 1, 2, 3, 4, 5] [0, 1, 2].flatten # => [0, 1, 2] a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten(-1) # => [0, 1, 2, 3, 4, 5] a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten(-2) # => [0, 1, 2, 3, 4, 5] [0, 1, 2].flatten(-1) # => [0, 1, 2] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" flatten;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"flatten(level);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" level;T0;$@;![;"I"Returns a new \Array that is a recursive flattening of +self+: - Each non-Array element is unchanged. - Each \Array is replaced by its individual elements. With non-negative \Integer argument +level+, flattens recursively through +level+ levels: a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten(0) # => [0, [1, [2, 3], 4], 5] a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten(1) # => [0, 1, [2, 3], 4, 5] a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten(2) # => [0, 1, 2, 3, 4, 5] a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten(3) # => [0, 1, 2, 3, 4, 5] With no argument, a +nil+ argument, or with negative argument +level+, flattens all levels: a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten # => [0, 1, 2, 3, 4, 5] [0, 1, 2].flatten # => [0, 1, 2] a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten(-1) # => [0, 1, 2, 3, 4, 5] a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten(-2) # => [0, 1, 2, 3, 4, 5] [0, 1, 2].flatten(-1) # => [0, 1, 2] @overload flatten @overload flatten(level);T;#0;$@;.F;/o;0;1T;2ir;3i;%@;9I"static VALUE rb_ary_flatten(int argc, VALUE *argv, VALUE ary) { int level = -1; VALUE result; if (rb_check_arity(argc, 0, 1) && !NIL_P(argv[0])) { level = NUM2INT(argv[0]); if (level == 0) return ary_make_shared_copy(ary); } result = flatten(ary, level); if (result == ary) { result = ary_make_shared_copy(ary); } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#flatten!;F;7[[@90;[[@i\;T;: flatten!;0;[;{;IC; "IReplaces each nested \Array in +self+ with the elements from that \Array; returns +self+ if any changes, +nil+ otherwise. With non-negative \Integer argument +level+, flattens recursively through +level+ levels: a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten!(1) # => [0, 1, [2, 3], 4, 5] a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten!(2) # => [0, 1, 2, 3, 4, 5] a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten!(3) # => [0, 1, 2, 3, 4, 5] [0, 1, 2].flatten!(1) # => nil With no argument, a +nil+ argument, or with negative argument +level+, flattens all levels: a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten! # => [0, 1, 2, 3, 4, 5] [0, 1, 2].flatten! # => nil a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten!(-1) # => [0, 1, 2, 3, 4, 5] a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten!(-2) # => [0, 1, 2, 3, 4, 5] [0, 1, 2].flatten!(-1) # => nil ;T;[o;= ;>I" overload;F;?0;;,;@0;:I" flatten!;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;TI"nil;T;$@:;![;"I"@return [self, nil];T;#0;$@:;.F;Bi;C0;7[;$@:o;= ;>I" overload;F;?0;;,;@0;:I"flatten!(level);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;TI"nil;T;$@:;![;"I"@return [self, nil];T;#0;$@:;.F;Bi;C0;7[[I" level;T0;$@:;![;"I"Replaces each nested \Array in +self+ with the elements from that \Array; returns +self+ if any changes, +nil+ otherwise. With non-negative \Integer argument +level+, flattens recursively through +level+ levels: a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten!(1) # => [0, 1, [2, 3], 4, 5] a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten!(2) # => [0, 1, 2, 3, 4, 5] a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten!(3) # => [0, 1, 2, 3, 4, 5] [0, 1, 2].flatten!(1) # => nil With no argument, a +nil+ argument, or with negative argument +level+, flattens all levels: a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten! # => [0, 1, 2, 3, 4, 5] [0, 1, 2].flatten! # => nil a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten!(-1) # => [0, 1, 2, 3, 4, 5] a = [ 0, [ 1, [2, 3], 4 ], 5 ] a.flatten!(-2) # => [0, 1, 2, 3, 4, 5] [0, 1, 2].flatten!(-1) # => nil @overload flatten! @return [self, nil] @overload flatten!(level) @return [self, nil];T;#0;$@:;.F;/o;0;1T;2i@;3iZ;%@;9I"static VALUE rb_ary_flatten_bang(int argc, VALUE *argv, VALUE ary) { int mod = 0, level = -1; VALUE result, lv; lv = (rb_check_arity(argc, 0, 1) ? argv[0] : Qnil); rb_ary_modify_check(ary); if (!NIL_P(lv)) level = NUM2INT(lv); if (level == 0) return Qnil; result = flatten(ary, level); if (result == ary) { return Qnil; } if (!(mod = ARY_EMBED_P(result))) rb_obj_freeze(result); rb_ary_replace(ary, result); if (mod) ARY_SET_EMBED_LEN(result, 0); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#count;F;7[[@90;[[@i;T;;;0;[;{;IC; "fReturns a count of specified elements. With no argument and no block, returns the count of all elements: [0, 1, 2].count # => 3 [].count # => 0 With argument +obj+, returns the count of elements == to +obj+: [0, 1, 2, 0.0].count(0) # => 2 [0, 1, 2].count(3) # => 0 With no argument and a block given, calls the block with each element; returns the count of elements for which the block returns a truthy value: [0, 1, 2, 3].count {|element| element > 1} # => 2 With argument +obj+ and a block given, issues a warning, ignores the block, and returns the count of elements == to +obj+: ;T;[o;= ;>I" overload;F;?0;;;@0;:I" count;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@g;![;"I"@return [Integer];T;#0;$@g;.F;Bi;C0;7[;$@go;= ;>I" overload;F;?0;;;@0;:I"count(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@g;![;"I"@return [Integer];T;#0;$@g;.F;Bi;C0;7[[I"obj;T0;$@go;= ;>I" overload;F;?0;;;@0;:I" count;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@go;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@g;![;"I"'@yield [element] @return [Integer];T;#0;$@g;.F;Bi;C0;7[;$@g;![;"I"Returns a count of specified elements. With no argument and no block, returns the count of all elements: [0, 1, 2].count # => 3 [].count # => 0 With argument +obj+, returns the count of elements == to +obj+: [0, 1, 2, 0.0].count(0) # => 2 [0, 1, 2].count(3) # => 0 With no argument and a block given, calls the block with each element; returns the count of elements for which the block returns a truthy value: [0, 1, 2, 3].count {|element| element > 1} # => 2 With argument +obj+ and a block given, issues a warning, ignores the block, and returns the count of elements == to +obj+: @overload count @return [Integer] @overload count(obj) @return [Integer] @overload count @yield [element] @return [Integer];T;#0;$@g;.F;/o;0;1T;2i;3i;%@;9I"'static VALUE rb_ary_count(int argc, VALUE *argv, VALUE ary) { long i, n = 0; if (rb_check_arity(argc, 0, 1) == 0) { VALUE v; if (!rb_block_given_p()) return LONG2NUM(RARRAY_LEN(ary)); for (i = 0; i < RARRAY_LEN(ary); i++) { v = RARRAY_AREF(ary, i); if (RTEST(rb_yield(v))) n++; } } else { VALUE obj = argv[0]; if (rb_block_given_p()) { rb_warn("given block not used"); } for (i = 0; i < RARRAY_LEN(ary); i++) { if (rb_equal(RARRAY_AREF(ary, i), obj)) n++; } } return LONG2NUM(n); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#cycle;F;7[[@90;[[@ix;T;;;0;[;{;IC; "OWhen called with positive \Integer argument +count+ and a block, calls the block with each element, then does so again, until it has done so +count+ times; returns +nil+: output = [] [0, 1].cycle(2) {|element| output.push(element) } # => nil output # => [0, 1, 0, 1] If +count+ is zero or negative, does not call the block: [0, 1].cycle(0) {|element| fail 'Cannot happen' } # => nil [0, 1].cycle(-1) {|element| fail 'Cannot happen' } # => nil When a block is given, and argument is omitted or +nil+, cycles forever: # Prints 0 and 1 forever. [0, 1].cycle {|element| puts element } [0, 1].cycle(nil) {|element| puts element } When no block is given, returns a new \Enumerator: [0, 1].cycle(2) # => # [0, 1].cycle # => # => # [0, 1].cycle.first(5) # => [0, 1, 0, 1, 0] ;T;[ o;= ;>I" overload;F;?0;;;@0;:I" cycle;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"#@yield [element] @return [nil];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"cycle(count);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"#@yield [element] @return [nil];T;#0;$@;.F;Bi;C0;7[[I" count;T0;$@o;= ;>I" overload;F;?0;;;@0;:I" cycle;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"cycle(count);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" count;T0;$@;![;"I"When called with positive \Integer argument +count+ and a block, calls the block with each element, then does so again, until it has done so +count+ times; returns +nil+: output = [] [0, 1].cycle(2) {|element| output.push(element) } # => nil output # => [0, 1, 0, 1] If +count+ is zero or negative, does not call the block: [0, 1].cycle(0) {|element| fail 'Cannot happen' } # => nil [0, 1].cycle(-1) {|element| fail 'Cannot happen' } # => nil When a block is given, and argument is omitted or +nil+, cycles forever: # Prints 0 and 1 forever. [0, 1].cycle {|element| puts element } [0, 1].cycle(nil) {|element| puts element } When no block is given, returns a new \Enumerator: [0, 1].cycle(2) # => # [0, 1].cycle # => # => # [0, 1].cycle.first(5) # => [0, 1, 0, 1, 0] @overload cycle @yield [element] @return [nil] @overload cycle(count) @yield [element] @return [nil] @overload cycle @overload cycle(count);T;#0;$@;.F;/o;0;1T;2i[;3iy;%@;9I"static VALUE rb_ary_cycle(int argc, VALUE *argv, VALUE ary) { long n, i; rb_check_arity(argc, 0, 1); RETURN_SIZED_ENUMERATOR(ary, argc, argv, rb_ary_cycle_size); if (argc == 0 || NIL_P(argv[0])) { n = -1; } else { n = NUM2LONG(argv[0]); if (n <= 0) return Qnil; } while (RARRAY_LEN(ary) > 0 && (n < 0 || 0 < n--)) { for (i=0; i0 < n <= self.size) are given, calls the block with all +n+-tuple permutations of +self+. Example: a = [0, 1, 2] a.permutation(2) {|permutation| p permutation } Output: [0, 1] [0, 2] [1, 0] [1, 2] [2, 0] [2, 1] Another example: a = [0, 1, 2] a.permutation(3) {|permutation| p permutation } Output: [0, 1, 2] [0, 2, 1] [1, 0, 2] [1, 2, 0] [2, 0, 1] [2, 1, 0] When +n+ is zero, calls the block once with a new empty \Array: a = [0, 1, 2] a.permutation(0) {|permutation| p permutation } Output: [] When +n+ is out of range (negative or larger than self.size), does not call the block: a = [0, 1, 2] a.permutation(-1) {|permutation| fail 'Cannot happen' } a.permutation(4) {|permutation| fail 'Cannot happen' } When a block given but no argument, behaves the same as a.permutation(a.size): a = [0, 1, 2] a.permutation {|permutation| p permutation } Output: [0, 1, 2] [0, 2, 1] [1, 0, 2] [1, 2, 0] [2, 0, 1] [2, 1, 0] Returns a new \Enumerator if no block given: a = [0, 1, 2] a.permutation # => # a.permutation(2) # => # ;T;[ o;= ;>I" overload;F;?0;;-;@0;:I"permutation;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"$@yield [element] @return [self];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;-;@0;:I"permutation(n);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"$@yield [element] @return [self];T;#0;$@;.F;Bi;C0;7[[I"n;T0;$@o;= ;>I" overload;F;?0;;-;@0;:I"permutation;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;-;@0;:I"permutation(n);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"n;T0;$@;![;"I"When invoked with a block, yield all permutations of elements of +self+; returns +self+. The order of permutations is indeterminate. When a block and an in-range positive \Integer argument +n+ (0 < n <= self.size) are given, calls the block with all +n+-tuple permutations of +self+. Example: a = [0, 1, 2] a.permutation(2) {|permutation| p permutation } Output: [0, 1] [0, 2] [1, 0] [1, 2] [2, 0] [2, 1] Another example: a = [0, 1, 2] a.permutation(3) {|permutation| p permutation } Output: [0, 1, 2] [0, 2, 1] [1, 0, 2] [1, 2, 0] [2, 0, 1] [2, 1, 0] When +n+ is zero, calls the block once with a new empty \Array: a = [0, 1, 2] a.permutation(0) {|permutation| p permutation } Output: [] When +n+ is out of range (negative or larger than self.size), does not call the block: a = [0, 1, 2] a.permutation(-1) {|permutation| fail 'Cannot happen' } a.permutation(4) {|permutation| fail 'Cannot happen' } When a block given but no argument, behaves the same as a.permutation(a.size): a = [0, 1, 2] a.permutation {|permutation| p permutation } Output: [0, 1, 2] [0, 2, 1] [1, 0, 2] [1, 2, 0] [2, 0, 1] [2, 1, 0] Returns a new \Enumerator if no block given: a = [0, 1, 2] a.permutation # => # a.permutation(2) # => # @overload permutation @yield [element] @return [self] @overload permutation(n) @yield [element] @return [self] @overload permutation @overload permutation(n);T;#0;$@;.F;/o;0;1T;2i;3iG;%@;9I"static VALUE rb_ary_permutation(int argc, VALUE *argv, VALUE ary) { long r, n, i; n = RARRAY_LEN(ary); /* Array length */ RETURN_SIZED_ENUMERATOR(ary, argc, argv, rb_ary_permutation_size); /* Return enumerator if no block */ r = n; if (rb_check_arity(argc, 0, 1) && !NIL_P(argv[0])) r = NUM2LONG(argv[0]); /* Permutation size from argument */ if (r < 0 || n < r) { /* no permutations: yield nothing */ } else if (r == 0) { /* exactly one permutation: the zero-length array */ rb_yield(rb_ary_new2(0)); } else if (r == 1) { /* this is a special, easy case */ for (i = 0; i < RARRAY_LEN(ary); i++) { rb_yield(rb_ary_new3(1, RARRAY_AREF(ary, i))); } } else { /* this is the general case */ volatile VALUE t0; long *p = ALLOCV_N(long, t0, r+roomof(n, sizeof(long))); char *used = (char*)(p + r); VALUE ary0 = ary_make_shared_copy(ary); /* private defensive copy of ary */ RBASIC_CLEAR_CLASS(ary0); MEMZERO(used, char, n); /* initialize array */ permute0(n, r, p, used, ary0); /* compute and yield permutations */ ALLOCV_END(t0); RBASIC_SET_CLASS_RAW(ary0, rb_cArray); } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#combination;F;7[[I"num;T0;[[@i;T;:combination;0;[;{;IC; "Calls the block, if given, with combinations of elements of +self+; returns +self+. The order of combinations is indeterminate. When a block and an in-range positive \Integer argument +n+ (0 < n <= self.size) are given, calls the block with all +n+-tuple combinations of +self+. Example: a = [0, 1, 2] a.combination(2) {|combination| p combination } Output: [0, 1] [0, 2] [1, 2] Another example: a = [0, 1, 2] a.combination(3) {|combination| p combination } Output: [0, 1, 2] When +n+ is zero, calls the block once with a new empty \Array: a = [0, 1, 2] a1 = a.combination(0) {|combination| p combination } Output: [] When +n+ is out of range (negative or larger than self.size), does not call the block: a = [0, 1, 2] a.combination(-1) {|combination| fail 'Cannot happen' } a.combination(4) {|combination| fail 'Cannot happen' } Returns a new \Enumerator if no block given: a = [0, 1, 2] a.combination(2) # => # ;T;[o;= ;>I" overload;F;?0;;.;@0;:I"combination(n);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@2o;A ;>I" return;F;?I";T;0;@[I" self;T;$@2;![;"I"$@yield [element] @return [self];T;#0;$@2;.F;Bi;C0;7[[I"n;T0;$@2o;= ;>I" overload;F;?0;;.;@0;:I"combination(n);T;IC; ";T;[;![;"I";T;#0;$@2;.F;Bi;C0;7[[I"n;T0;$@2;![;"I"FCalls the block, if given, with combinations of elements of +self+; returns +self+. The order of combinations is indeterminate. When a block and an in-range positive \Integer argument +n+ (0 < n <= self.size) are given, calls the block with all +n+-tuple combinations of +self+. Example: a = [0, 1, 2] a.combination(2) {|combination| p combination } Output: [0, 1] [0, 2] [1, 2] Another example: a = [0, 1, 2] a.combination(3) {|combination| p combination } Output: [0, 1, 2] When +n+ is zero, calls the block once with a new empty \Array: a = [0, 1, 2] a1 = a.combination(0) {|combination| p combination } Output: [] When +n+ is out of range (negative or larger than self.size), does not call the block: a = [0, 1, 2] a.combination(-1) {|combination| fail 'Cannot happen' } a.combination(4) {|combination| fail 'Cannot happen' } Returns a new \Enumerator if no block given: a = [0, 1, 2] a.combination(2) # => # @overload combination(n) @yield [element] @return [self] @overload combination(n);T;#0;$@2;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_ary_combination(VALUE ary, VALUE num) { long i, n, len; n = NUM2LONG(num); RETURN_SIZED_ENUMERATOR(ary, 1, &num, rb_ary_combination_size); len = RARRAY_LEN(ary); if (n < 0 || len < n) { /* yield nothing */ } else if (n == 0) { rb_yield(rb_ary_new2(0)); } else if (n == 1) { for (i = 0; i < RARRAY_LEN(ary); i++) { rb_yield(rb_ary_new3(1, RARRAY_AREF(ary, i))); } } else { VALUE ary0 = ary_make_shared_copy(ary); /* private defensive copy of ary */ volatile VALUE t0; long *stack = ALLOCV_N(long, t0, n+1); RBASIC_CLEAR_CLASS(ary0); combinate0(len, n, stack, ary0); ALLOCV_END(t0); RBASIC_SET_CLASS_RAW(ary0, rb_cArray); } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#repeated_permutation;F;7[[I"num;T0;[[@i>;T;:repeated_permutation;0;[;{;IC; "6Calls the block with each repeated permutation of length +n+ of the elements of +self+; each permutation is an \Array; returns +self+. The order of the permutations is indeterminate. When a block and a positive \Integer argument +n+ are given, calls the block with each +n+-tuple repeated permutation of the elements of +self+. The number of permutations is self.size**n. +n+ = 1: a = [0, 1, 2] a.repeated_permutation(1) {|permutation| p permutation } Output: [0] [1] [2] +n+ = 2: a.repeated_permutation(2) {|permutation| p permutation } Output: [0, 0] [0, 1] [0, 2] [1, 0] [1, 1] [1, 2] [2, 0] [2, 1] [2, 2] If +n+ is zero, calls the block once with an empty \Array. If +n+ is negative, does not call the block: a.repeated_permutation(-1) {|permutation| fail 'Cannot happen' } Returns a new \Enumerator if no block given: a = [0, 1, 2] a.repeated_permutation(2) # => # Using Enumerators, it's convenient to show the permutations and counts for some values of +n+: e = a.repeated_permutation(0) e.size # => 1 e.to_a # => [[]] e = a.repeated_permutation(1) e.size # => 3 e.to_a # => [[0], [1], [2]] e = a.repeated_permutation(2) e.size # => 9 e.to_a # => [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]] ;T;[o;= ;>I" overload;F;?0;;/;@0;:I"repeated_permutation(n);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"permutation;T;$@`o;A ;>I" return;F;?I";T;0;@[I" self;T;$@`;![;"I"(@yield [permutation] @return [self];T;#0;$@`;.F;Bi;C0;7[[I"n;T0;$@`o;= ;>I" overload;F;?0;;/;@0;:I"repeated_permutation(n);T;IC; ";T;[;![;"I";T;#0;$@`;.F;Bi;C0;7[[I"n;T0;$@`;![;"I"Calls the block with each repeated permutation of length +n+ of the elements of +self+; each permutation is an \Array; returns +self+. The order of the permutations is indeterminate. When a block and a positive \Integer argument +n+ are given, calls the block with each +n+-tuple repeated permutation of the elements of +self+. The number of permutations is self.size**n. +n+ = 1: a = [0, 1, 2] a.repeated_permutation(1) {|permutation| p permutation } Output: [0] [1] [2] +n+ = 2: a.repeated_permutation(2) {|permutation| p permutation } Output: [0, 0] [0, 1] [0, 2] [1, 0] [1, 1] [1, 2] [2, 0] [2, 1] [2, 2] If +n+ is zero, calls the block once with an empty \Array. If +n+ is negative, does not call the block: a.repeated_permutation(-1) {|permutation| fail 'Cannot happen' } Returns a new \Enumerator if no block given: a = [0, 1, 2] a.repeated_permutation(2) # => # Using Enumerators, it's convenient to show the permutations and counts for some values of +n+: e = a.repeated_permutation(0) e.size # => 1 e.to_a # => [[]] e = a.repeated_permutation(1) e.size # => 3 e.to_a # => [[0], [1], [2]] e = a.repeated_permutation(2) e.size # => 9 e.to_a # => [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]] @overload repeated_permutation(n) @yield [permutation] @return [self] @overload repeated_permutation(n);T;#0;$@`;.F;/o;0;1T;2i;3i=;%@;9I"static VALUE rb_ary_repeated_permutation(VALUE ary, VALUE num) { long r, n, i; n = RARRAY_LEN(ary); /* Array length */ RETURN_SIZED_ENUMERATOR(ary, 1, &num, rb_ary_repeated_permutation_size); /* Return Enumerator if no block */ r = NUM2LONG(num); /* Permutation size from argument */ if (r < 0) { /* no permutations: yield nothing */ } else if (r == 0) { /* exactly one permutation: the zero-length array */ rb_yield(rb_ary_new2(0)); } else if (r == 1) { /* this is a special, easy case */ for (i = 0; i < RARRAY_LEN(ary); i++) { rb_yield(rb_ary_new3(1, RARRAY_AREF(ary, i))); } } else { /* this is the general case */ volatile VALUE t0; long *p = ALLOCV_N(long, t0, r); VALUE ary0 = ary_make_shared_copy(ary); /* private defensive copy of ary */ RBASIC_CLEAR_CLASS(ary0); rpermute0(n, r, p, ary0); /* compute and yield repeated permutations */ ALLOCV_END(t0); RBASIC_SET_CLASS_RAW(ary0, rb_cArray); } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#repeated_combination;F;7[[I"num;T0;[[@i;T;:repeated_combination;0;[;{;IC; "Calls the block with each repeated combination of length +n+ of the elements of +self+; each combination is an \Array; returns +self+. The order of the combinations is indeterminate. When a block and a positive \Integer argument +n+ are given, calls the block with each +n+-tuple repeated combination of the elements of +self+. The number of combinations is (n+1)(n+2)/2. +n+ = 1: a = [0, 1, 2] a.repeated_combination(1) {|combination| p combination } Output: [0] [1] [2] +n+ = 2: a.repeated_combination(2) {|combination| p combination } Output: [0, 0] [0, 1] [0, 2] [1, 1] [1, 2] [2, 2] If +n+ is zero, calls the block once with an empty \Array. If +n+ is negative, does not call the block: a.repeated_combination(-1) {|combination| fail 'Cannot happen' } Returns a new \Enumerator if no block given: a = [0, 1, 2] a.repeated_combination(2) # => # Using Enumerators, it's convenient to show the combinations and counts for some values of +n+: e = a.repeated_combination(0) e.size # => 1 e.to_a # => [[]] e = a.repeated_combination(1) e.size # => 3 e.to_a # => [[0], [1], [2]] e = a.repeated_combination(2) e.size # => 6 e.to_a # => [[0, 0], [0, 1], [0, 2], [1, 1], [1, 2], [2, 2]] ;T;[o;= ;>I" overload;F;?0;;0;@0;:I"repeated_combination(n);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"combination;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"(@yield [combination] @return [self];T;#0;$@;.F;Bi;C0;7[[I"n;T0;$@o;= ;>I" overload;F;?0;;0;@0;:I"repeated_combination(n);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"n;T0;$@;![;"I"qCalls the block with each repeated combination of length +n+ of the elements of +self+; each combination is an \Array; returns +self+. The order of the combinations is indeterminate. When a block and a positive \Integer argument +n+ are given, calls the block with each +n+-tuple repeated combination of the elements of +self+. The number of combinations is (n+1)(n+2)/2. +n+ = 1: a = [0, 1, 2] a.repeated_combination(1) {|combination| p combination } Output: [0] [1] [2] +n+ = 2: a.repeated_combination(2) {|combination| p combination } Output: [0, 0] [0, 1] [0, 2] [1, 1] [1, 2] [2, 2] If +n+ is zero, calls the block once with an empty \Array. If +n+ is negative, does not call the block: a.repeated_combination(-1) {|combination| fail 'Cannot happen' } Returns a new \Enumerator if no block given: a = [0, 1, 2] a.repeated_combination(2) # => # Using Enumerators, it's convenient to show the combinations and counts for some values of +n+: e = a.repeated_combination(0) e.size # => 1 e.to_a # => [[]] e = a.repeated_combination(1) e.size # => 3 e.to_a # => [[0], [1], [2]] e = a.repeated_combination(2) e.size # => 6 e.to_a # => [[0, 0], [0, 1], [0, 2], [1, 1], [1, 2], [2, 2]] @overload repeated_combination(n) @yield [combination] @return [self] @overload repeated_combination(n);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_ary_repeated_combination(VALUE ary, VALUE num) { long n, i, len; n = NUM2LONG(num); /* Combination size from argument */ RETURN_SIZED_ENUMERATOR(ary, 1, &num, rb_ary_repeated_combination_size); /* Return enumerator if no block */ len = RARRAY_LEN(ary); if (n < 0) { /* yield nothing */ } else if (n == 0) { rb_yield(rb_ary_new2(0)); } else if (n == 1) { for (i = 0; i < RARRAY_LEN(ary); i++) { rb_yield(rb_ary_new3(1, RARRAY_AREF(ary, i))); } } else if (len == 0) { /* yield nothing */ } else { volatile VALUE t0; long *p = ALLOCV_N(long, t0, n); VALUE ary0 = ary_make_shared_copy(ary); /* private defensive copy of ary */ RBASIC_CLEAR_CLASS(ary0); rcombinate0(len, n, p, n, ary0); /* compute and yield repeated combinations */ ALLOCV_END(t0); RBASIC_SET_CLASS_RAW(ary0, rb_cArray); } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#product;F;7[[@90;[[@i ;T;: product;0;[;{;IC; "yComputes and returns or yields all combinations of elements from all the Arrays, including both +self+ and +other_arrays+. - The number of combinations is the product of the sizes of all the arrays, including both +self+ and +other_arrays+. - The order of the returned combinations is indeterminate. When no block is given, returns the combinations as an \Array of Arrays: a = [0, 1, 2] a1 = [3, 4] a2 = [5, 6] p = a.product(a1) p.size # => 6 # a.size * a1.size p # => [[0, 3], [0, 4], [1, 3], [1, 4], [2, 3], [2, 4]] p = a.product(a1, a2) p.size # => 12 # a.size * a1.size * a2.size p # => [[0, 3, 5], [0, 3, 6], [0, 4, 5], [0, 4, 6], [1, 3, 5], [1, 3, 6], [1, 4, 5], [1, 4, 6], [2, 3, 5], [2, 3, 6], [2, 4, 5], [2, 4, 6]] If any argument is an empty \Array, returns an empty \Array. If no argument is given, returns an \Array of 1-element Arrays, each containing an element of +self+: a.product # => [[0], [1], [2]] When a block is given, yields each combination as an \Array; returns +self+: a.product(a1) {|combination| p combination } Output: [0, 3] [0, 4] [1, 3] [1, 4] [2, 3] [2, 4] If any argument is an empty \Array, does not call the block: a.product(a1, a2, []) {|combination| fail 'Cannot happen' } If no argument is given, yields each element of +self+ as a 1-element \Array: a.product {|combination| p combination } Output: [0] [1] [2] ;T;[o;= ;>I" overload;F;?0;;1;@0;:I"product(*other_arrays);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"*other_arrays;T0;$@o;= ;>I" overload;F;?0;;1;@0;:I"product(*other_arrays);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"combination;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"(@yield [combination] @return [self];T;#0;$@;.F;Bi;C0;7[[I"*other_arrays;T0;$@;![;"I"Computes and returns or yields all combinations of elements from all the Arrays, including both +self+ and +other_arrays+. - The number of combinations is the product of the sizes of all the arrays, including both +self+ and +other_arrays+. - The order of the returned combinations is indeterminate. When no block is given, returns the combinations as an \Array of Arrays: a = [0, 1, 2] a1 = [3, 4] a2 = [5, 6] p = a.product(a1) p.size # => 6 # a.size * a1.size p # => [[0, 3], [0, 4], [1, 3], [1, 4], [2, 3], [2, 4]] p = a.product(a1, a2) p.size # => 12 # a.size * a1.size * a2.size p # => [[0, 3, 5], [0, 3, 6], [0, 4, 5], [0, 4, 6], [1, 3, 5], [1, 3, 6], [1, 4, 5], [1, 4, 6], [2, 3, 5], [2, 3, 6], [2, 4, 5], [2, 4, 6]] If any argument is an empty \Array, returns an empty \Array. If no argument is given, returns an \Array of 1-element Arrays, each containing an element of +self+: a.product # => [[0], [1], [2]] When a block is given, yields each combination as an \Array; returns +self+: a.product(a1) {|combination| p combination } Output: [0, 3] [0, 4] [1, 3] [1, 4] [2, 3] [2, 4] If any argument is an empty \Array, does not call the block: a.product(a1, a2, []) {|combination| fail 'Cannot happen' } If no argument is given, yields each element of +self+ as a 1-element \Array: a.product {|combination| p combination } Output: [0] [1] [2] @overload product(*other_arrays) @overload product(*other_arrays) @yield [combination] @return [self];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"5 static VALUE rb_ary_product(int argc, VALUE *argv, VALUE ary) { int n = argc+1; /* How many arrays we're operating on */ volatile VALUE t0 = tmpary(n); volatile VALUE t1 = Qundef; VALUE *arrays = RARRAY_PTR(t0); /* The arrays we're computing the product of */ int *counters = ALLOCV_N(int, t1, n); /* The current position in each one */ VALUE result = Qnil; /* The array we'll be returning, when no block given */ long i,j; long resultlen = 1; RBASIC_CLEAR_CLASS(t0); /* initialize the arrays of arrays */ ARY_SET_LEN(t0, n); arrays[0] = ary; for (i = 1; i < n; i++) arrays[i] = Qnil; for (i = 1; i < n; i++) arrays[i] = to_ary(argv[i-1]); /* initialize the counters for the arrays */ for (i = 0; i < n; i++) counters[i] = 0; /* Otherwise, allocate and fill in an array of results */ if (rb_block_given_p()) { /* Make defensive copies of arrays; exit if any is empty */ for (i = 0; i < n; i++) { if (RARRAY_LEN(arrays[i]) == 0) goto done; arrays[i] = ary_make_shared_copy(arrays[i]); } } else { /* Compute the length of the result array; return [] if any is empty */ for (i = 0; i < n; i++) { long k = RARRAY_LEN(arrays[i]); if (k == 0) { result = rb_ary_new2(0); goto done; } if (MUL_OVERFLOW_LONG_P(resultlen, k)) rb_raise(rb_eRangeError, "too big to product"); resultlen *= k; } result = rb_ary_new2(resultlen); } for (;;) { int m; /* fill in one subarray */ VALUE subarray = rb_ary_new2(n); for (j = 0; j < n; j++) { rb_ary_push(subarray, rb_ary_entry(arrays[j], counters[j])); } /* put it on the result array */ if (NIL_P(result)) { FL_SET(t0, FL_USER5); rb_yield(subarray); if (! FL_TEST(t0, FL_USER5)) { rb_raise(rb_eRuntimeError, "product reentered"); } else { FL_UNSET(t0, FL_USER5); } } else { rb_ary_push(result, subarray); } /* * Increment the last counter. If it overflows, reset to 0 * and increment the one before it. */ m = n-1; counters[m]++; while (counters[m] == RARRAY_LEN(arrays[m])) { counters[m] = 0; /* If the first counter overflows, we are done */ if (--m < 0) goto done; counters[m]++; } } done: tmpary_discard(t0); ALLOCV_END(t1); return NIL_P(result) ? ary : result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#take;F;7[[I"n;T0;[[@ir;T;;;0;[;{;IC; "Returns a new \Array containing the first +n+ element of +self+, where +n+ is a non-negative \Integer; does not modify +self+. Examples: a = [0, 1, 2, 3, 4, 5] a.take(1) # => [0] a.take(2) # => [0, 1] a.take(50) # => [0, 1, 2, 3, 4, 5] a # => [0, 1, 2, 3, 4, 5] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" take(n);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"n;T0;$@;![;"I"$Returns a new \Array containing the first +n+ element of +self+, where +n+ is a non-negative \Integer; does not modify +self+. Examples: a = [0, 1, 2, 3, 4, 5] a.take(1) # => [0] a.take(2) # => [0, 1] a.take(50) # => [0, 1, 2, 3, 4, 5] a # => [0, 1, 2, 3, 4, 5] @overload take(n);T;#0;$@;.F;/o;0;1T;2ib;3in;%@;9I"static VALUE rb_ary_take(VALUE obj, VALUE n) { long len = NUM2LONG(n); if (len < 0) { rb_raise(rb_eArgError, "attempt to take negative size"); } return rb_ary_subseq(obj, 0, len); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#take_while;F;7[;[[@i;T;;;0;[;{;IC; "EReturns a new \Array containing zero or more leading elements of +self+; does not modify +self+. With a block given, calls the block with each successive element of +self+; stops if the block returns +false+ or +nil+; returns a new Array containing those elements for which the block returned a truthy value: a = [0, 1, 2, 3, 4, 5] a.take_while {|element| element < 3 } # => [0, 1, 2] a.take_while {|element| true } # => [0, 1, 2, 3, 4, 5] a # => [0, 1, 2, 3, 4, 5] With no block given, returns a new \Enumerator: [0, 1].take_while # => # ;T;[o;= ;>I" overload;F;?0;;;@0;:I"take_while;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@;![;"I"@yield [element];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"take_while;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a new \Array containing zero or more leading elements of +self+; does not modify +self+. With a block given, calls the block with each successive element of +self+; stops if the block returns +false+ or +nil+; returns a new Array containing those elements for which the block returned a truthy value: a = [0, 1, 2, 3, 4, 5] a.take_while {|element| element < 3 } # => [0, 1, 2] a.take_while {|element| true } # => [0, 1, 2, 3, 4, 5] a # => [0, 1, 2, 3, 4, 5] With no block given, returns a new \Enumerator: [0, 1].take_while # => # @overload take_while @yield [element] @overload take_while;T;#0;$@;.F;/o;0;1T;2i|;3i;%@;9I"static VALUE rb_ary_take_while(VALUE ary) { long i; RETURN_ENUMERATOR(ary, 0, 0); for (i = 0; i < RARRAY_LEN(ary); i++) { if (!RTEST(rb_yield(RARRAY_AREF(ary, i)))) break; } return rb_ary_take(ary, LONG2FIX(i)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#drop;F;7[[I"n;T0;[[@i;T;;;0;[;{;IC; " Returns a new \Array containing all but the first +n+ element of +self+, where +n+ is a non-negative \Integer; does not modify +self+. Examples: a = [0, 1, 2, 3, 4, 5] a.drop(0) # => [0, 1, 2, 3, 4, 5] a.drop(1) # => [1, 2, 3, 4, 5] a.drop(2) # => [2, 3, 4, 5] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" drop(n);T;IC; ";T;[;![;"I";T;#0;$@&;.F;Bi;C0;7[[I"n;T0;$@&;![;"I"!Returns a new \Array containing all but the first +n+ element of +self+, where +n+ is a non-negative \Integer; does not modify +self+. Examples: a = [0, 1, 2, 3, 4, 5] a.drop(0) # => [0, 1, 2, 3, 4, 5] a.drop(1) # => [1, 2, 3, 4, 5] a.drop(2) # => [2, 3, 4, 5] @overload drop(n);T;#0;$@&;.F;/o;0;1T;2i;3i;%@;9I"*static VALUE rb_ary_drop(VALUE ary, VALUE n) { VALUE result; long pos = NUM2LONG(n); if (pos < 0) { rb_raise(rb_eArgError, "attempt to drop negative size"); } result = rb_ary_subseq(ary, pos, RARRAY_LEN(ary)); if (NIL_P(result)) result = rb_ary_new(); return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#drop_while;F;7[;[[@i;T;;;0;[;{;IC; "Returns a new \Array containing zero or more trailing elements of +self+; does not modify +self+. With a block given, calls the block with each successive element of +self+; stops if the block returns +false+ or +nil+; returns a new Array _omitting_ those elements for which the block returned a truthy value: a = [0, 1, 2, 3, 4, 5] a.drop_while {|element| element < 3 } # => [3, 4, 5] With no block given, returns a new \Enumerator: [0, 1].drop_while # => # => # ;T;[o;= ;>I" overload;F;?0;;;@0;:I"drop_while;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@@;![;"I"@yield [element];T;#0;$@@;.F;Bi;C0;7[;$@@o;= ;>I" overload;F;?0;;;@0;:I"drop_while;T;IC; ";T;[;![;"I";T;#0;$@@;.F;Bi;C0;7[;$@@;![;"I"5Returns a new \Array containing zero or more trailing elements of +self+; does not modify +self+. With a block given, calls the block with each successive element of +self+; stops if the block returns +false+ or +nil+; returns a new Array _omitting_ those elements for which the block returned a truthy value: a = [0, 1, 2, 3, 4, 5] a.drop_while {|element| element < 3 } # => [3, 4, 5] With no block given, returns a new \Enumerator: [0, 1].drop_while # => # => # @overload drop_while @yield [element] @overload drop_while;T;#0;$@@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_ary_drop_while(VALUE ary) { long i; RETURN_ENUMERATOR(ary, 0, 0); for (i = 0; i < RARRAY_LEN(ary); i++) { if (!RTEST(rb_yield(RARRAY_AREF(ary, i)))) break; } return rb_ary_drop(ary, LONG2FIX(i)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#bsearch;F;7[;[[@ia ;T;: bsearch;0;[;{;IC; "pReturns an element from +self+ selected by a binary search. See {Binary Searching}[rdoc-ref:bsearch.rdoc]. ;T;[o;= ;>I" overload;F;?0;;2;@0;:I" bsearch;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@co;A ;>I" return;F;?I";T;0;@[I" Object;T;$@c;![;"I"&@yield [element] @return [Object];T;#0;$@c;.F;Bi;C0;7[;$@co;= ;>I" overload;F;?0;;2;@0;:I" bsearch;T;IC; ";T;[;![;"I";T;#0;$@c;.F;Bi;C0;7[;$@c;![;"I"Returns an element from +self+ selected by a binary search. See {Binary Searching}[rdoc-ref:bsearch.rdoc]. @overload bsearch @yield [element] @return [Object] @overload bsearch;T;#0;$@c;.F;/o;0;1T;2iW ;3i_ ;%@;9I"static VALUE rb_ary_bsearch(VALUE ary) { VALUE index_result = rb_ary_bsearch_index(ary); if (FIXNUM_P(index_result)) { return rb_ary_entry(ary, FIX2LONG(index_result)); } return index_result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#bsearch_index;F;7[;[[@iu ;T;:bsearch_index;0;[;{;IC; "|Searches +self+ as described at method #bsearch, but returns the _index_ of the found element instead of the element itself. ;T;[o;= ;>I" overload;F;?0;;3;@0;:I"bsearch_index;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@;![;"I",@yield [element] @return [Integer, nil];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;3;@0;:I"bsearch_index;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Searches +self+ as described at method #bsearch, but returns the _index_ of the found element instead of the element itself. @overload bsearch_index @yield [element] @return [Integer, nil] @overload bsearch_index;T;#0;$@;.F;/o;0;1T;2il ;3is ;%@;9I"<static VALUE rb_ary_bsearch_index(VALUE ary) { long low = 0, high = RARRAY_LEN(ary), mid; int smaller = 0, satisfied = 0; VALUE v, val; RETURN_ENUMERATOR(ary, 0, 0); while (low < high) { mid = low + ((high - low) / 2); val = rb_ary_entry(ary, mid); v = rb_yield(val); if (FIXNUM_P(v)) { if (v == INT2FIX(0)) return INT2FIX(mid); smaller = (SIGNED_VALUE)v < 0; /* Fixnum preserves its sign-bit */ } else if (v == Qtrue) { satisfied = 1; smaller = 1; } else if (!RTEST(v)) { smaller = 0; } else if (rb_obj_is_kind_of(v, rb_cNumeric)) { const VALUE zero = INT2FIX(0); switch (rb_cmpint(rb_funcallv(v, id_cmp, 1, &zero), v, zero)) { case 0: return INT2FIX(mid); case 1: smaller = 1; break; case -1: smaller = 0; } } else { rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE " (must be numeric, true, false or nil)", rb_obj_class(v)); } if (smaller) { high = mid; } else { low = mid + 1; } } if (!satisfied) return Qnil; return INT2FIX(low); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#any?;F;7[[@90;[[@i;T;;;0;[;{;IC; "-Returns +true+ if any element of +self+ meets a given criterion. With no block given and no argument, returns +true+ if +self+ has any truthy element, +false+ otherwise: [nil, 0, false].any? # => true [nil, false].any? # => false [].any? # => false With a block given and no argument, calls the block with each element in +self+; returns +true+ if the block returns any truthy value, +false+ otherwise: [0, 1, 2].any? {|element| element > 1 } # => true [0, 1, 2].any? {|element| element > 2 } # => false If argument +obj+ is given, returns +true+ if +obj+.=== any element, +false+ otherwise: ['food', 'drink'].any?(/foo/) # => true ['food', 'drink'].any?(/bar/) # => false [].any?(/foo/) # => false [0, 1, 2].any?(1) # => true [0, 1, 2].any?(3) # => false Related: Enumerable#any?;T;[o;= ;>I" overload;F;?0;;;@0;:I" any?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" any?;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"'@yield [element] @return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"any?(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"obj;T0;$@;![;"I"Returns +true+ if any element of +self+ meets a given criterion. With no block given and no argument, returns +true+ if +self+ has any truthy element, +false+ otherwise: [nil, 0, false].any? # => true [nil, false].any? # => false [].any? # => false With a block given and no argument, calls the block with each element in +self+; returns +true+ if the block returns any truthy value, +false+ otherwise: [0, 1, 2].any? {|element| element > 1 } # => true [0, 1, 2].any? {|element| element > 2 } # => false If argument +obj+ is given, returns +true+ if +obj+.=== any element, +false+ otherwise: ['food', 'drink'].any?(/foo/) # => true ['food', 'drink'].any?(/bar/) # => false [].any?(/foo/) # => false [0, 1, 2].any?(1) # => true [0, 1, 2].any?(3) # => false Related: Enumerable#any? @overload any? @return [Boolean] @overload any? @yield [element] @return [Boolean] @overload any?(obj) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE rb_ary_any_p(int argc, VALUE *argv, VALUE ary) { long i, len = RARRAY_LEN(ary); rb_check_arity(argc, 0, 1); if (!len) return Qfalse; if (argc) { if (rb_block_given_p()) { rb_warn("given block not used"); } for (i = 0; i < RARRAY_LEN(ary); ++i) { if (RTEST(rb_funcall(argv[0], idEqq, 1, RARRAY_AREF(ary, i)))) return Qtrue; } } else if (!rb_block_given_p()) { for (i = 0; i < len; ++i) { if (RTEST(RARRAY_AREF(ary, i))) return Qtrue; } } else { for (i = 0; i < RARRAY_LEN(ary); ++i) { if (RTEST(rb_yield(RARRAY_AREF(ary, i)))) return Qtrue; } } return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#all?;F;7[[@90;[[@i.;T;;;0;[;{;IC; "9Returns +true+ if all elements of +self+ meet a given criterion. With no block given and no argument, returns +true+ if +self+ contains only truthy elements, +false+ otherwise: [0, 1, :foo].all? # => true [0, nil, 2].all? # => false [].all? # => true With a block given and no argument, calls the block with each element in +self+; returns +true+ if the block returns only truthy values, +false+ otherwise: [0, 1, 2].all? { |element| element < 3 } # => true [0, 1, 2].all? { |element| element < 2 } # => false If argument +obj+ is given, returns +true+ if obj.=== every element, +false+ otherwise: ['food', 'fool', 'foot'].all?(/foo/) # => true ['food', 'drink'].all?(/bar/) # => false [].all?(/foo/) # => true [0, 0, 0].all?(0) # => true [0, 1, 2].all?(1) # => false Related: Enumerable#all?;T;[o;= ;>I" overload;F;?0;;;@0;:I" all?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" all?;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"'@yield [element] @return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"all?(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"obj;T0;$@;![;"I"Returns +true+ if all elements of +self+ meet a given criterion. With no block given and no argument, returns +true+ if +self+ contains only truthy elements, +false+ otherwise: [0, 1, :foo].all? # => true [0, nil, 2].all? # => false [].all? # => true With a block given and no argument, calls the block with each element in +self+; returns +true+ if the block returns only truthy values, +false+ otherwise: [0, 1, 2].all? { |element| element < 3 } # => true [0, 1, 2].all? { |element| element < 2 } # => false If argument +obj+ is given, returns +true+ if obj.=== every element, +false+ otherwise: ['food', 'fool', 'foot'].all?(/foo/) # => true ['food', 'drink'].all?(/bar/) # => false [].all?(/foo/) # => true [0, 0, 0].all?(0) # => true [0, 1, 2].all?(1) # => false Related: Enumerable#all? @overload all? @return [Boolean] @overload all? @yield [element] @return [Boolean] @overload all?(obj) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i.;Bi;%@;9I"static VALUE rb_ary_all_p(int argc, VALUE *argv, VALUE ary) { long i, len = RARRAY_LEN(ary); rb_check_arity(argc, 0, 1); if (!len) return Qtrue; if (argc) { if (rb_block_given_p()) { rb_warn("given block not used"); } for (i = 0; i < RARRAY_LEN(ary); ++i) { if (!RTEST(rb_funcall(argv[0], idEqq, 1, RARRAY_AREF(ary, i)))) return Qfalse; } } else if (!rb_block_given_p()) { for (i = 0; i < len; ++i) { if (!RTEST(RARRAY_AREF(ary, i))) return Qfalse; } } else { for (i = 0; i < RARRAY_LEN(ary); ++i) { if (!RTEST(rb_yield(RARRAY_AREF(ary, i)))) return Qfalse; } } return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#none?;F;7[[@90;[[@ig;T;;;0;[;{;IC; "0Returns +true+ if no element of +self+ meet a given criterion. With no block given and no argument, returns +true+ if +self+ has no truthy elements, +false+ otherwise: [nil, false].none? # => true [nil, 0, false].none? # => false [].none? # => true With a block given and no argument, calls the block with each element in +self+; returns +true+ if the block returns no truthy value, +false+ otherwise: [0, 1, 2].none? {|element| element > 3 } # => true [0, 1, 2].none? {|element| element > 1 } # => false If argument +obj+ is given, returns +true+ if obj.=== no element, +false+ otherwise: ['food', 'drink'].none?(/bar/) # => true ['food', 'drink'].none?(/foo/) # => false [].none?(/foo/) # => true [0, 1, 2].none?(3) # => true [0, 1, 2].none?(1) # => false Related: Enumerable#none?;T;[o;= ;>I" overload;F;?0;;;@0;:I" none?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@.;![;"I"@return [Boolean];T;#0;$@.;.F;Bi;C0;7[;$@.o;= ;>I" overload;F;?0;;;@0;:I" none?;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@.o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@.;![;"I"'@yield [element] @return [Boolean];T;#0;$@.;.F;Bi;C0;7[;$@.o;= ;>I" overload;F;?0;;;@0;:I"none?(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@.;![;"I"@return [Boolean];T;#0;$@.;.F;Bi;C0;7[[I"obj;T0;$@.;![;"I"Returns +true+ if no element of +self+ meet a given criterion. With no block given and no argument, returns +true+ if +self+ has no truthy elements, +false+ otherwise: [nil, false].none? # => true [nil, 0, false].none? # => false [].none? # => true With a block given and no argument, calls the block with each element in +self+; returns +true+ if the block returns no truthy value, +false+ otherwise: [0, 1, 2].none? {|element| element > 3 } # => true [0, 1, 2].none? {|element| element > 1 } # => false If argument +obj+ is given, returns +true+ if obj.=== no element, +false+ otherwise: ['food', 'drink'].none?(/bar/) # => true ['food', 'drink'].none?(/foo/) # => false [].none?(/foo/) # => true [0, 1, 2].none?(3) # => true [0, 1, 2].none?(1) # => false Related: Enumerable#none? @overload none? @return [Boolean] @overload none? @yield [element] @return [Boolean] @overload none?(obj) @return [Boolean];T;#0;$@.;.F;/o;0;1T;2iJ;3ig;Bi;%@;9I"static VALUE rb_ary_none_p(int argc, VALUE *argv, VALUE ary) { long i, len = RARRAY_LEN(ary); rb_check_arity(argc, 0, 1); if (!len) return Qtrue; if (argc) { if (rb_block_given_p()) { rb_warn("given block not used"); } for (i = 0; i < RARRAY_LEN(ary); ++i) { if (RTEST(rb_funcall(argv[0], idEqq, 1, RARRAY_AREF(ary, i)))) return Qfalse; } } else if (!rb_block_given_p()) { for (i = 0; i < len; ++i) { if (RTEST(RARRAY_AREF(ary, i))) return Qfalse; } } else { for (i = 0; i < RARRAY_LEN(ary); ++i) { if (RTEST(rb_yield(RARRAY_AREF(ary, i)))) return Qfalse; } } return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#one?;F;7[[@90;[[@i;T;;;0;[;{;IC; "Returns +true+ if exactly one element of +self+ meets a given criterion. With no block given and no argument, returns +true+ if +self+ has exactly one truthy element, +false+ otherwise: [nil, 0].one? # => true [0, 0].one? # => false [nil, nil].one? # => false [].one? # => false With a block given and no argument, calls the block with each element in +self+; returns +true+ if the block a truthy value for exactly one element, +false+ otherwise: [0, 1, 2].one? {|element| element > 0 } # => false [0, 1, 2].one? {|element| element > 1 } # => true [0, 1, 2].one? {|element| element > 2 } # => false If argument +obj+ is given, returns +true+ if obj.=== exactly one element, +false+ otherwise: [0, 1, 2].one?(0) # => true [0, 0, 1].one?(0) # => false [1, 1, 2].one?(0) # => false ['food', 'drink'].one?(/bar/) # => false ['food', 'drink'].one?(/foo/) # => true [].one?(/foo/) # => false Related: Enumerable#one?;T;[o;= ;>I" overload;F;?0;;;@0;:I" one?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@k;![;"I"@return [Boolean];T;#0;$@k;.F;Bi;C0;7[;$@ko;= ;>I" overload;F;?0;;;@0;:I" one?;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@ko;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@k;![;"I"'@yield [element] @return [Boolean];T;#0;$@k;.F;Bi;C0;7[;$@ko;= ;>I" overload;F;?0;;;@0;:I"one?(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@k;![;"I"@return [Boolean];T;#0;$@k;.F;Bi;C0;7[[I"obj;T0;$@k;![;"I"8Returns +true+ if exactly one element of +self+ meets a given criterion. With no block given and no argument, returns +true+ if +self+ has exactly one truthy element, +false+ otherwise: [nil, 0].one? # => true [0, 0].one? # => false [nil, nil].one? # => false [].one? # => false With a block given and no argument, calls the block with each element in +self+; returns +true+ if the block a truthy value for exactly one element, +false+ otherwise: [0, 1, 2].one? {|element| element > 0 } # => false [0, 1, 2].one? {|element| element > 1 } # => true [0, 1, 2].one? {|element| element > 2 } # => false If argument +obj+ is given, returns +true+ if obj.=== exactly one element, +false+ otherwise: [0, 1, 2].one?(0) # => true [0, 0, 1].one?(0) # => false [1, 1, 2].one?(0) # => false ['food', 'drink'].one?(/bar/) # => false ['food', 'drink'].one?(/foo/) # => true [].one?(/foo/) # => false Related: Enumerable#one? @overload one? @return [Boolean] @overload one? @yield [element] @return [Boolean] @overload one?(obj) @return [Boolean];T;#0;$@k;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE rb_ary_one_p(int argc, VALUE *argv, VALUE ary) { long i, len = RARRAY_LEN(ary); VALUE result = Qfalse; rb_check_arity(argc, 0, 1); if (!len) return Qfalse; if (argc) { if (rb_block_given_p()) { rb_warn("given block not used"); } for (i = 0; i < RARRAY_LEN(ary); ++i) { if (RTEST(rb_funcall(argv[0], idEqq, 1, RARRAY_AREF(ary, i)))) { if (result) return Qfalse; result = Qtrue; } } } else if (!rb_block_given_p()) { for (i = 0; i < len; ++i) { if (RTEST(RARRAY_AREF(ary, i))) { if (result) return Qfalse; result = Qtrue; } } } else { for (i = 0; i < RARRAY_LEN(ary); ++i) { if (RTEST(rb_yield(RARRAY_AREF(ary, i)))) { if (result) return Qfalse; result = Qtrue; } } } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#dig;F;7[[@90;[[@i;T;;;0;[;{;IC; "xFinds and returns the object in nested objects that is specified by +index+ and +identifiers+. The nested objects may be instances of various classes. See {Dig Methods}[rdoc-ref:dig_methods.rdoc]. Examples: a = [:foo, [:bar, :baz, [:bat, :bam]]] a.dig(1) # => [:bar, :baz, [:bat, :bam]] a.dig(1, 2) # => [:bat, :bam] a.dig(1, 2, 0) # => :bat a.dig(1, 2, 3) # => nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I"dig(index, *identifiers);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I" index;T0[I"*identifiers;T0;$@;![;"I"Finds and returns the object in nested objects that is specified by +index+ and +identifiers+. The nested objects may be instances of various classes. See {Dig Methods}[rdoc-ref:dig_methods.rdoc]. Examples: a = [:foo, [:bar, :baz, [:bat, :bam]]] a.dig(1) # => [:bar, :baz, [:bat, :bam]] a.dig(1, 2) # => [:bat, :bam] a.dig(1, 2, 0) # => :bat a.dig(1, 2, 3) # => nil @overload dig(index, *identifiers) @return [Object];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_ary_dig(int argc, VALUE *argv, VALUE self) { rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS); self = rb_ary_at(self, *argv); if (!--argc) return self; ++argv; return rb_obj_dig(argc, argv, self, Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#sum;F;7[[@90;[[@i;T;;;0;[;{;IC; "When no block is given, returns the object equivalent to: sum = init array.each {|element| sum += element } sum For example, [e1, e2, e3].sum returns init + e1 + e2 + e3. Examples: a = [0, 1, 2, 3] a.sum # => 6 a.sum(100) # => 106 The elements need not be numeric, but must be +-compatible with each other and with +init+: a = ['abc', 'def', 'ghi'] a.sum('jkl') # => "jklabcdefghi" When a block is given, it is called with each element and the block's return value (instead of the element itself) is used as the addend: a = ['zero', 1, :two] s = a.sum('Coerced and concatenated: ') {|element| element.to_s } s # => "Coerced and concatenated: zero1two" Notes: - Array#join and Array#flatten may be faster than Array#sum for an \Array of Strings or an \Array of Arrays. - Array#sum method may not respect method redefinition of "+" methods such as Integer#+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"sum(init = 0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I" init;TI"0;T;$@o;= ;>I" overload;F;?0;;;@0;:I"sum(init = 0);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"&@yield [element] @return [Object];T;#0;$@;.F;Bi;C0;7[[I" init;TI"0;T;$@;![;"I" When no block is given, returns the object equivalent to: sum = init array.each {|element| sum += element } sum For example, [e1, e2, e3].sum returns init + e1 + e2 + e3. Examples: a = [0, 1, 2, 3] a.sum # => 6 a.sum(100) # => 106 The elements need not be numeric, but must be +-compatible with each other and with +init+: a = ['abc', 'def', 'ghi'] a.sum('jkl') # => "jklabcdefghi" When a block is given, it is called with each element and the block's return value (instead of the element itself) is used as the addend: a = ['zero', 1, :two] s = a.sum('Coerced and concatenated: ') {|element| element.to_s } s # => "Coerced and concatenated: zero1two" Notes: - Array#join and Array#flatten may be faster than Array#sum for an \Array of Strings or an \Array of Arrays. - Array#sum method may not respect method redefinition of "+" methods such as Integer#+. @overload sum(init = 0) @return [Object] @overload sum(init = 0) @yield [element] @return [Object];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I" static VALUE rb_ary_sum(int argc, VALUE *argv, VALUE ary) { VALUE e, v, r; long i, n; int block_given; v = (rb_check_arity(argc, 0, 1) ? argv[0] : LONG2FIX(0)); block_given = rb_block_given_p(); if (RARRAY_LEN(ary) == 0) return v; n = 0; r = Qundef; for (i = 0; i < RARRAY_LEN(ary); i++) { e = RARRAY_AREF(ary, i); if (block_given) e = rb_yield(e); if (FIXNUM_P(e)) { n += FIX2LONG(e); /* should not overflow long type */ if (!FIXABLE(n)) { v = rb_big_plus(LONG2NUM(n), v); n = 0; } } else if (RB_BIGNUM_TYPE_P(e)) v = rb_big_plus(e, v); else if (RB_TYPE_P(e, T_RATIONAL)) { if (r == Qundef) r = e; else r = rb_rational_plus(r, e); } else goto not_exact; } v = finish_exact_sum(n, r, v, argc!=0); return v; not_exact: v = finish_exact_sum(n, r, v, i!=0); if (RB_FLOAT_TYPE_P(e)) { /* * Kahan-Babuska balancing compensated summation algorithm * See https://link.springer.com/article/10.1007/s00607-005-0139-x */ double f, c; double x, t; f = NUM2DBL(v); c = 0.0; goto has_float_value; for (; i < RARRAY_LEN(ary); i++) { e = RARRAY_AREF(ary, i); if (block_given) e = rb_yield(e); if (RB_FLOAT_TYPE_P(e)) has_float_value: x = RFLOAT_VALUE(e); else if (FIXNUM_P(e)) x = FIX2LONG(e); else if (RB_BIGNUM_TYPE_P(e)) x = rb_big2dbl(e); else if (RB_TYPE_P(e, T_RATIONAL)) x = rb_num2dbl(e); else goto not_float; if (isnan(f)) continue; if (isnan(x)) { f = x; continue; } if (isinf(x)) { if (isinf(f) && signbit(x) != signbit(f)) f = NAN; else f = x; continue; } if (isinf(f)) continue; t = f + x; if (fabs(f) >= fabs(x)) c += ((f - t) + x); else c += ((x - t) + f); f = t; } f += c; return DBL2NUM(f); not_float: v = DBL2NUM(f); } goto has_some_value; for (; i < RARRAY_LEN(ary); i++) { e = RARRAY_AREF(ary, i); if (block_given) e = rb_yield(e); has_some_value: v = rb_funcall(v, idPLUS, 1, e); } return v; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Array#deconstruct;F;7[;[[@i;T;:deconstruct;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"Cstatic VALUE rb_ary_deconstruct(VALUE ary) { return ary; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[o;( ;)0;*0;+0;;;%@;-@y,;0; @; IC;{;IC;{;T;IC;{;T;T;{@;J@;]@;;[;[[@iG ;F;;;;;;;[;{;IC; "bCAn \Array is an ordered, integer-indexed collection of objects, called _elements_. Any object may be an \Array element. == \Array Indexes \Array indexing starts at 0, as in C or Java. A positive index is an offset from the first element: - Index 0 indicates the first element. - Index 1 indicates the second element. - ... A negative index is an offset, backwards, from the end of the array: - Index -1 indicates the last element. - Index -2 indicates the next-to-last element. - ... A non-negative index is in range if it is smaller than the size of the array. For a 3-element array: - Indexes 0 through 2 are in range. - Index 3 is out of range. A negative index is in range if its absolute value is not larger than the size of the array. For a 3-element array: - Indexes -1 through -3 are in range. - Index -4 is out of range. == Creating Arrays You can create an \Array object explicitly with: - An {array literal}[doc/syntax/literals_rdoc.html#label-Array+Literals]. You can convert certain objects to Arrays with: - \Method {Array}[Kernel.html#method-i-Array]. An \Array can contain different types of objects. For example, the array below contains an Integer, a String and a Float: ary = [1, "two", 3.0] #=> [1, "two", 3.0] An array can also be created by calling Array.new with zero, one (the initial size of the Array) or two arguments (the initial size and a default object). ary = Array.new #=> [] Array.new(3) #=> [nil, nil, nil] Array.new(3, true) #=> [true, true, true] Note that the second argument populates the array with references to the same object. Therefore, it is only recommended in cases when you need to instantiate arrays with natively immutable objects such as Symbols, numbers, true or false. To create an array with separate objects a block can be passed instead. This method is safe to use with mutable objects such as hashes, strings or other arrays: Array.new(4) {Hash.new} #=> [{}, {}, {}, {}] Array.new(4) {|i| i.to_s } #=> ["0", "1", "2", "3"] This is also a quick way to build up multi-dimensional arrays: empty_table = Array.new(3) {Array.new(3)} #=> [[nil, nil, nil], [nil, nil, nil], [nil, nil, nil]] An array can also be created by using the Array() method, provided by Kernel, which tries to call #to_ary, then #to_a on its argument. Array({:a => "a", :b => "b"}) #=> [[:a, "a"], [:b, "b"]] == Example Usage In addition to the methods it mixes in through the Enumerable module, the Array class has proprietary methods for accessing, searching and otherwise manipulating arrays. Some of the more common ones are illustrated below. == Accessing Elements Elements in an array can be retrieved using the Array#[] method. It can take a single integer argument (a numeric index), a pair of arguments (start and length) or a range. Negative indices start counting from the end, with -1 being the last element. arr = [1, 2, 3, 4, 5, 6] arr[2] #=> 3 arr[100] #=> nil arr[-3] #=> 4 arr[2, 3] #=> [3, 4, 5] arr[1..4] #=> [2, 3, 4, 5] arr[1..-3] #=> [2, 3, 4] Another way to access a particular array element is by using the #at method arr.at(0) #=> 1 The #slice method works in an identical manner to Array#[]. To raise an error for indices outside of the array bounds or else to provide a default value when that happens, you can use #fetch. arr = ['a', 'b', 'c', 'd', 'e', 'f'] arr.fetch(100) #=> IndexError: index 100 outside of array bounds: -6...6 arr.fetch(100, "oops") #=> "oops" The special methods #first and #last will return the first and last elements of an array, respectively. arr.first #=> 1 arr.last #=> 6 To return the first +n+ elements of an array, use #take arr.take(3) #=> [1, 2, 3] #drop does the opposite of #take, by returning the elements after +n+ elements have been dropped: arr.drop(3) #=> [4, 5, 6] == Obtaining Information about an Array Arrays keep track of their own length at all times. To query an array about the number of elements it contains, use #length, #count or #size. browsers = ['Chrome', 'Firefox', 'Safari', 'Opera', 'IE'] browsers.length #=> 5 browsers.count #=> 5 To check whether an array contains any elements at all browsers.empty? #=> false To check whether a particular item is included in the array browsers.include?('Konqueror') #=> false == Adding Items to Arrays Items can be added to the end of an array by using either #push or #<< arr = [1, 2, 3, 4] arr.push(5) #=> [1, 2, 3, 4, 5] arr << 6 #=> [1, 2, 3, 4, 5, 6] #unshift will add a new item to the beginning of an array. arr.unshift(0) #=> [0, 1, 2, 3, 4, 5, 6] With #insert you can add a new element to an array at any position. arr.insert(3, 'apple') #=> [0, 1, 2, 'apple', 3, 4, 5, 6] Using the #insert method, you can also insert multiple values at once: arr.insert(3, 'orange', 'pear', 'grapefruit') #=> [0, 1, 2, "orange", "pear", "grapefruit", "apple", 3, 4, 5, 6] == Removing Items from an Array The method #pop removes the last element in an array and returns it: arr = [1, 2, 3, 4, 5, 6] arr.pop #=> 6 arr #=> [1, 2, 3, 4, 5] To retrieve and at the same time remove the first item, use #shift: arr.shift #=> 1 arr #=> [2, 3, 4, 5] To delete an element at a particular index: arr.delete_at(2) #=> 4 arr #=> [2, 3, 5] To delete a particular element anywhere in an array, use #delete: arr = [1, 2, 2, 3] arr.delete(2) #=> 2 arr #=> [1,3] A useful method if you need to remove +nil+ values from an array is #compact: arr = ['foo', 0, nil, 'bar', 7, 'baz', nil] arr.compact #=> ['foo', 0, 'bar', 7, 'baz'] arr #=> ['foo', 0, nil, 'bar', 7, 'baz', nil] arr.compact! #=> ['foo', 0, 'bar', 7, 'baz'] arr #=> ['foo', 0, 'bar', 7, 'baz'] Another common need is to remove duplicate elements from an array. It has the non-destructive #uniq, and destructive method #uniq! arr = [2, 5, 6, 556, 6, 6, 8, 9, 0, 123, 556] arr.uniq #=> [2, 5, 6, 556, 8, 9, 0, 123] == Iterating over Arrays Like all classes that include the Enumerable module, Array has an each method, which defines what elements should be iterated over and how. In case of Array's #each, all elements in the Array instance are yielded to the supplied block in sequence. Note that this operation leaves the array unchanged. arr = [1, 2, 3, 4, 5] arr.each {|a| print a -= 10, " "} # prints: -9 -8 -7 -6 -5 #=> [1, 2, 3, 4, 5] Another sometimes useful iterator is #reverse_each which will iterate over the elements in the array in reverse order. words = %w[first second third fourth fifth sixth] str = "" words.reverse_each {|word| str += "#{word} "} p str #=> "sixth fifth fourth third second first " The #map method can be used to create a new array based on the original array, but with the values modified by the supplied block: arr.map {|a| 2*a} #=> [2, 4, 6, 8, 10] arr #=> [1, 2, 3, 4, 5] arr.map! {|a| a**2} #=> [1, 4, 9, 16, 25] arr #=> [1, 4, 9, 16, 25] == Selecting Items from an Array Elements can be selected from an array according to criteria defined in a block. The selection can happen in a destructive or a non-destructive manner. While the destructive operations will modify the array they were called on, the non-destructive methods usually return a new array with the selected elements, but leave the original array unchanged. === Non-destructive Selection arr = [1, 2, 3, 4, 5, 6] arr.select {|a| a > 3} #=> [4, 5, 6] arr.reject {|a| a < 3} #=> [3, 4, 5, 6] arr.drop_while {|a| a < 4} #=> [4, 5, 6] arr #=> [1, 2, 3, 4, 5, 6] === Destructive Selection #select! and #reject! are the corresponding destructive methods to #select and #reject Similar to #select vs. #reject, #delete_if and #keep_if have the exact opposite result when supplied with the same block: arr.delete_if {|a| a < 4} #=> [4, 5, 6] arr #=> [4, 5, 6] arr = [1, 2, 3, 4, 5, 6] arr.keep_if {|a| a < 4} #=> [1, 2, 3] arr #=> [1, 2, 3] == What's Here First, what's elsewhere. \Class \Array: - Inherits from {class Object}[Object.html#class-Object-label-What-27s+Here]. - Includes {module Enumerable}[Enumerable.html#module-Enumerable-label-What-27s+Here], which provides dozens of additional methods. Here, class \Array provides methods that are useful for: - {Creating an Array}[#class-Array-label-Methods+for+Creating+an+Array] - {Querying}[#class-Array-label-Methods+for+Querying] - {Comparing}[#class-Array-label-Methods+for+Comparing] - {Fetching}[#class-Array-label-Methods+for+Fetching] - {Assigning}[#class-Array-label-Methods+for+Assigning] - {Deleting}[#class-Array-label-Methods+for+Deleting] - {Combining}[#class-Array-label-Methods+for+Combining] - {Iterating}[#class-Array-label-Methods+for+Iterating] - {Converting}[#class-Array-label-Methods+for+Converting] - {And more....}[#class-Array-label-Other+Methods] === Methods for Creating an Array ::[]:: Returns a new array populated with given objects. ::new:: Returns a new array. ::try_convert:: Returns a new array created from a given object. === Methods for Querying #length, #size:: Returns the count of elements. #include?:: Returns whether any element == a given object. #empty?:: Returns whether there are no elements. #all?:: Returns whether all elements meet a given criterion. #any?:: Returns whether any element meets a given criterion. #none?:: Returns whether no element == a given object. #one?:: Returns whether exactly one element == a given object. #count:: Returns the count of elements that meet a given criterion. #find_index, #index:: Returns the index of the first element that meets a given criterion. #rindex:: Returns the index of the last element that meets a given criterion. #hash:: Returns the integer hash code. === Methods for Comparing {#<=>}[#method-i-3C-3D-3E]:: Returns -1, 0, or 1 as +self+ is less than, equal to, or greater than a given object. {#==}[#method-i-3D-3D]:: Returns whether each element in +self+ is == to the corresponding element in a given object. #eql?:: Returns whether each element in +self+ is eql? to the corresponding element in a given object. === Methods for Fetching These methods do not modify +self+. #[]:: Returns one or more elements. #fetch:: Returns the element at a given offset. #first:: Returns one or more leading elements. #last:: Returns one or more trailing elements. #max:: Returns one or more maximum-valued elements, as determined by <=> or a given block. #max:: Returns one or more minimum-valued elements, as determined by <=> or a given block. #minmax:: Returns the minimum-valued and maximum-valued elements, as determined by <=> or a given block. #assoc:: Returns the first element that is an array whose first element == a given object. #rassoc:: Returns the first element that is an array whose second element == a given object. #at:: Returns the element at a given offset. #values_at:: Returns the elements at given offsets. #dig:: Returns the object in nested objects that is specified by a given index and additional arguments. #drop:: Returns trailing elements as determined by a given index. #take:: Returns leading elements as determined by a given index. #drop_while:: Returns trailing elements as determined by a given block. #take_while:: Returns leading elements as determined by a given block. #slice:: Returns consecutive elements as determined by a given argument. #sort:: Returns all elements in an order determined by <=> or a given block. #reverse:: Returns all elements in reverse order. #compact:: Returns an array containing all non-+nil+ elements. #select, #filter:: Returns an array containing elements selected by a given block. #uniq:: Returns an array containing non-duplicate elements. #rotate:: Returns all elements with some rotated from one end to the other. #bsearch:: Returns an element selected via a binary search as determined by a given block. #bsearch_index:: Returns the index of an element selected via a binary search as determined by a given block. #sample:: Returns one or more random elements. #shuffle:: Returns elements in a random order. === Methods for Assigning These methods add, replace, or reorder elements in +self+. #[]=:: Assigns specified elements with a given object. #push, #append, #<<:: Appends trailing elements. #unshift, #prepend:: Prepends leading elements. #insert:: Inserts given objects at a given offset; does not replace elements. #concat:: Appends all elements from given arrays. #fill:: Replaces specified elements with specified objects. #replace:: Replaces the content of +self+ with the content of a given array. #reverse!:: Replaces +self+ with its elements reversed. #rotate!:: Replaces +self+ with its elements rotated. #shuffle!:: Replaces +self+ with its elements in random order. #sort!:: Replaces +self+ with its elements sorted, as determined by <=> or a given block. #sort_by!:: Replaces +self+ with its elements sorted, as determined by a given block. === Methods for Deleting Each of these methods removes elements from +self+: #pop:: Removes and returns the last element. #shift:: Removes and returns the first element. #compact!:: Removes all non-+nil+ elements. #delete:: Removes elements equal to a given object. #delete_at:: Removes the element at a given offset. #delete_if:: Removes elements specified by a given block. #keep_if:: Removes elements not specified by a given block. #reject!:: Removes elements specified by a given block. #select!, #filter!:: Removes elements not specified by a given block. #slice!:: Removes and returns a sequence of elements. #uniq!:: Removes duplicates. === Methods for Combining {#&}[#method-i-26]:: Returns an array containing elements found both in +self+ and a given array. #intersection:: Returns an array containing elements found both in +self+ and in each given array. #+:: Returns an array containing all elements of +self+ followed by all elements of a given array. #-:: Returns an array containiing all elements of +self+ that are not found in a given array. {#|}[#method-i-7C]:: Returns an array containing all elements of +self+ and all elements of a given array, duplicates removed. #union:: Returns an array containing all elements of +self+ and all elements of given arrays, duplicates removed. #difference:: Returns an array containing all elements of +self+ that are not found in any of the given arrays.. #product:: Returns or yields all combinations of elements from +self+ and given arrays. === Methods for Iterating #each:: Passes each element to a given block. #reverse_each:: Passes each element, in reverse order, to a given block. #each_index:: Passes each element index to a given block. #cycle:: Calls a given block with each element, then does so again, for a specified number of times, or forever. #combination:: Calls a given block with combinations of elements of +self+; a combination does not use the same element more than once. #permutation:: Calls a given block with permutations of elements of +self+; a permutation does not use the same element more than once. #repeated_combination:: Calls a given block with combinations of elements of +self+; a combination may use the same element more than once. #repeated_permutation:: Calls a given block with permutations of elements of +self+; a permutation may use the same element more than once. === Methods for Converting #map, #collect:: Returns an array containing the block return-value for each element. #map!, #collect!:: Replaces each element with a block return-value. #flatten:: Returns an array that is a recursive flattening of +self+. #flatten!:: Replaces each nested array in +self+ with the elements from that array. #inspect, #to_s:: Returns a new String containing the elements. #join:: Returns a newsString containing the elements joined by the field separator. #to_a:: Returns +self+ or a new array containing all elements. #to_ary:: Returns +self+. #to_h:: Returns a new hash formed from the elements. #transpose:: Transposes +self+, which must be an array of arrays. #zip:: Returns a new array of arrays containing +self+ and given arrays; follow the link for details. === Other Methods #*:: Returns one of the following: - With integer argument +n+, a new array that is the concatenation of +n+ copies of +self+. - With string argument +field_separator+, a new string that is equivalent to join(field_separator). #abbrev:: Returns a hash of unambiguous abbreviations for elements. #pack:: Packs the elements into a binary sequence. #sum:: Returns a sum of elements according to either + or a given block. ;T;[;![;"I"cCAn \Array is an ordered, integer-indexed collection of objects, called _elements_. Any object may be an \Array element. == \Array Indexes \Array indexing starts at 0, as in C or Java. A positive index is an offset from the first element: - Index 0 indicates the first element. - Index 1 indicates the second element. - ... A negative index is an offset, backwards, from the end of the array: - Index -1 indicates the last element. - Index -2 indicates the next-to-last element. - ... A non-negative index is in range if it is smaller than the size of the array. For a 3-element array: - Indexes 0 through 2 are in range. - Index 3 is out of range. A negative index is in range if its absolute value is not larger than the size of the array. For a 3-element array: - Indexes -1 through -3 are in range. - Index -4 is out of range. == Creating Arrays You can create an \Array object explicitly with: - An {array literal}[doc/syntax/literals_rdoc.html#label-Array+Literals]. You can convert certain objects to Arrays with: - \Method {Array}[Kernel.html#method-i-Array]. An \Array can contain different types of objects. For example, the array below contains an Integer, a String and a Float: ary = [1, "two", 3.0] #=> [1, "two", 3.0] An array can also be created by calling Array.new with zero, one (the initial size of the Array) or two arguments (the initial size and a default object). ary = Array.new #=> [] Array.new(3) #=> [nil, nil, nil] Array.new(3, true) #=> [true, true, true] Note that the second argument populates the array with references to the same object. Therefore, it is only recommended in cases when you need to instantiate arrays with natively immutable objects such as Symbols, numbers, true or false. To create an array with separate objects a block can be passed instead. This method is safe to use with mutable objects such as hashes, strings or other arrays: Array.new(4) {Hash.new} #=> [{}, {}, {}, {}] Array.new(4) {|i| i.to_s } #=> ["0", "1", "2", "3"] This is also a quick way to build up multi-dimensional arrays: empty_table = Array.new(3) {Array.new(3)} #=> [[nil, nil, nil], [nil, nil, nil], [nil, nil, nil]] An array can also be created by using the Array() method, provided by Kernel, which tries to call #to_ary, then #to_a on its argument. Array({:a => "a", :b => "b"}) #=> [[:a, "a"], [:b, "b"]] == Example Usage In addition to the methods it mixes in through the Enumerable module, the Array class has proprietary methods for accessing, searching and otherwise manipulating arrays. Some of the more common ones are illustrated below. == Accessing Elements Elements in an array can be retrieved using the Array#[] method. It can take a single integer argument (a numeric index), a pair of arguments (start and length) or a range. Negative indices start counting from the end, with -1 being the last element. arr = [1, 2, 3, 4, 5, 6] arr[2] #=> 3 arr[100] #=> nil arr[-3] #=> 4 arr[2, 3] #=> [3, 4, 5] arr[1..4] #=> [2, 3, 4, 5] arr[1..-3] #=> [2, 3, 4] Another way to access a particular array element is by using the #at method arr.at(0) #=> 1 The #slice method works in an identical manner to Array#[]. To raise an error for indices outside of the array bounds or else to provide a default value when that happens, you can use #fetch. arr = ['a', 'b', 'c', 'd', 'e', 'f'] arr.fetch(100) #=> IndexError: index 100 outside of array bounds: -6...6 arr.fetch(100, "oops") #=> "oops" The special methods #first and #last will return the first and last elements of an array, respectively. arr.first #=> 1 arr.last #=> 6 To return the first +n+ elements of an array, use #take arr.take(3) #=> [1, 2, 3] #drop does the opposite of #take, by returning the elements after +n+ elements have been dropped: arr.drop(3) #=> [4, 5, 6] == Obtaining Information about an Array Arrays keep track of their own length at all times. To query an array about the number of elements it contains, use #length, #count or #size. browsers = ['Chrome', 'Firefox', 'Safari', 'Opera', 'IE'] browsers.length #=> 5 browsers.count #=> 5 To check whether an array contains any elements at all browsers.empty? #=> false To check whether a particular item is included in the array browsers.include?('Konqueror') #=> false == Adding Items to Arrays Items can be added to the end of an array by using either #push or #<< arr = [1, 2, 3, 4] arr.push(5) #=> [1, 2, 3, 4, 5] arr << 6 #=> [1, 2, 3, 4, 5, 6] #unshift will add a new item to the beginning of an array. arr.unshift(0) #=> [0, 1, 2, 3, 4, 5, 6] With #insert you can add a new element to an array at any position. arr.insert(3, 'apple') #=> [0, 1, 2, 'apple', 3, 4, 5, 6] Using the #insert method, you can also insert multiple values at once: arr.insert(3, 'orange', 'pear', 'grapefruit') #=> [0, 1, 2, "orange", "pear", "grapefruit", "apple", 3, 4, 5, 6] == Removing Items from an Array The method #pop removes the last element in an array and returns it: arr = [1, 2, 3, 4, 5, 6] arr.pop #=> 6 arr #=> [1, 2, 3, 4, 5] To retrieve and at the same time remove the first item, use #shift: arr.shift #=> 1 arr #=> [2, 3, 4, 5] To delete an element at a particular index: arr.delete_at(2) #=> 4 arr #=> [2, 3, 5] To delete a particular element anywhere in an array, use #delete: arr = [1, 2, 2, 3] arr.delete(2) #=> 2 arr #=> [1,3] A useful method if you need to remove +nil+ values from an array is #compact: arr = ['foo', 0, nil, 'bar', 7, 'baz', nil] arr.compact #=> ['foo', 0, 'bar', 7, 'baz'] arr #=> ['foo', 0, nil, 'bar', 7, 'baz', nil] arr.compact! #=> ['foo', 0, 'bar', 7, 'baz'] arr #=> ['foo', 0, 'bar', 7, 'baz'] Another common need is to remove duplicate elements from an array. It has the non-destructive #uniq, and destructive method #uniq! arr = [2, 5, 6, 556, 6, 6, 8, 9, 0, 123, 556] arr.uniq #=> [2, 5, 6, 556, 8, 9, 0, 123] == Iterating over Arrays Like all classes that include the Enumerable module, Array has an each method, which defines what elements should be iterated over and how. In case of Array's #each, all elements in the Array instance are yielded to the supplied block in sequence. Note that this operation leaves the array unchanged. arr = [1, 2, 3, 4, 5] arr.each {|a| print a -= 10, " "} # prints: -9 -8 -7 -6 -5 #=> [1, 2, 3, 4, 5] Another sometimes useful iterator is #reverse_each which will iterate over the elements in the array in reverse order. words = %w[first second third fourth fifth sixth] str = "" words.reverse_each {|word| str += "#{word} "} p str #=> "sixth fifth fourth third second first " The #map method can be used to create a new array based on the original array, but with the values modified by the supplied block: arr.map {|a| 2*a} #=> [2, 4, 6, 8, 10] arr #=> [1, 2, 3, 4, 5] arr.map! {|a| a**2} #=> [1, 4, 9, 16, 25] arr #=> [1, 4, 9, 16, 25] == Selecting Items from an Array Elements can be selected from an array according to criteria defined in a block. The selection can happen in a destructive or a non-destructive manner. While the destructive operations will modify the array they were called on, the non-destructive methods usually return a new array with the selected elements, but leave the original array unchanged. === Non-destructive Selection arr = [1, 2, 3, 4, 5, 6] arr.select {|a| a > 3} #=> [4, 5, 6] arr.reject {|a| a < 3} #=> [3, 4, 5, 6] arr.drop_while {|a| a < 4} #=> [4, 5, 6] arr #=> [1, 2, 3, 4, 5, 6] === Destructive Selection #select! and #reject! are the corresponding destructive methods to #select and #reject Similar to #select vs. #reject, #delete_if and #keep_if have the exact opposite result when supplied with the same block: arr.delete_if {|a| a < 4} #=> [4, 5, 6] arr #=> [4, 5, 6] arr = [1, 2, 3, 4, 5, 6] arr.keep_if {|a| a < 4} #=> [1, 2, 3] arr #=> [1, 2, 3] == What's Here First, what's elsewhere. \Class \Array: - Inherits from {class Object}[Object.html#class-Object-label-What-27s+Here]. - Includes {module Enumerable}[Enumerable.html#module-Enumerable-label-What-27s+Here], which provides dozens of additional methods. Here, class \Array provides methods that are useful for: - {Creating an Array}[#class-Array-label-Methods+for+Creating+an+Array] - {Querying}[#class-Array-label-Methods+for+Querying] - {Comparing}[#class-Array-label-Methods+for+Comparing] - {Fetching}[#class-Array-label-Methods+for+Fetching] - {Assigning}[#class-Array-label-Methods+for+Assigning] - {Deleting}[#class-Array-label-Methods+for+Deleting] - {Combining}[#class-Array-label-Methods+for+Combining] - {Iterating}[#class-Array-label-Methods+for+Iterating] - {Converting}[#class-Array-label-Methods+for+Converting] - {And more....}[#class-Array-label-Other+Methods] === Methods for Creating an Array ::[]:: Returns a new array populated with given objects. ::new:: Returns a new array. ::try_convert:: Returns a new array created from a given object. === Methods for Querying #length, #size:: Returns the count of elements. #include?:: Returns whether any element == a given object. #empty?:: Returns whether there are no elements. #all?:: Returns whether all elements meet a given criterion. #any?:: Returns whether any element meets a given criterion. #none?:: Returns whether no element == a given object. #one?:: Returns whether exactly one element == a given object. #count:: Returns the count of elements that meet a given criterion. #find_index, #index:: Returns the index of the first element that meets a given criterion. #rindex:: Returns the index of the last element that meets a given criterion. #hash:: Returns the integer hash code. === Methods for Comparing {#<=>}[#method-i-3C-3D-3E]:: Returns -1, 0, or 1 as +self+ is less than, equal to, or greater than a given object. {#==}[#method-i-3D-3D]:: Returns whether each element in +self+ is == to the corresponding element in a given object. #eql?:: Returns whether each element in +self+ is eql? to the corresponding element in a given object. === Methods for Fetching These methods do not modify +self+. #[]:: Returns one or more elements. #fetch:: Returns the element at a given offset. #first:: Returns one or more leading elements. #last:: Returns one or more trailing elements. #max:: Returns one or more maximum-valued elements, as determined by <=> or a given block. #max:: Returns one or more minimum-valued elements, as determined by <=> or a given block. #minmax:: Returns the minimum-valued and maximum-valued elements, as determined by <=> or a given block. #assoc:: Returns the first element that is an array whose first element == a given object. #rassoc:: Returns the first element that is an array whose second element == a given object. #at:: Returns the element at a given offset. #values_at:: Returns the elements at given offsets. #dig:: Returns the object in nested objects that is specified by a given index and additional arguments. #drop:: Returns trailing elements as determined by a given index. #take:: Returns leading elements as determined by a given index. #drop_while:: Returns trailing elements as determined by a given block. #take_while:: Returns leading elements as determined by a given block. #slice:: Returns consecutive elements as determined by a given argument. #sort:: Returns all elements in an order determined by <=> or a given block. #reverse:: Returns all elements in reverse order. #compact:: Returns an array containing all non-+nil+ elements. #select, #filter:: Returns an array containing elements selected by a given block. #uniq:: Returns an array containing non-duplicate elements. #rotate:: Returns all elements with some rotated from one end to the other. #bsearch:: Returns an element selected via a binary search as determined by a given block. #bsearch_index:: Returns the index of an element selected via a binary search as determined by a given block. #sample:: Returns one or more random elements. #shuffle:: Returns elements in a random order. === Methods for Assigning These methods add, replace, or reorder elements in +self+. #[]=:: Assigns specified elements with a given object. #push, #append, #<<:: Appends trailing elements. #unshift, #prepend:: Prepends leading elements. #insert:: Inserts given objects at a given offset; does not replace elements. #concat:: Appends all elements from given arrays. #fill:: Replaces specified elements with specified objects. #replace:: Replaces the content of +self+ with the content of a given array. #reverse!:: Replaces +self+ with its elements reversed. #rotate!:: Replaces +self+ with its elements rotated. #shuffle!:: Replaces +self+ with its elements in random order. #sort!:: Replaces +self+ with its elements sorted, as determined by <=> or a given block. #sort_by!:: Replaces +self+ with its elements sorted, as determined by a given block. === Methods for Deleting Each of these methods removes elements from +self+: #pop:: Removes and returns the last element. #shift:: Removes and returns the first element. #compact!:: Removes all non-+nil+ elements. #delete:: Removes elements equal to a given object. #delete_at:: Removes the element at a given offset. #delete_if:: Removes elements specified by a given block. #keep_if:: Removes elements not specified by a given block. #reject!:: Removes elements specified by a given block. #select!, #filter!:: Removes elements not specified by a given block. #slice!:: Removes and returns a sequence of elements. #uniq!:: Removes duplicates. === Methods for Combining {#&}[#method-i-26]:: Returns an array containing elements found both in +self+ and a given array. #intersection:: Returns an array containing elements found both in +self+ and in each given array. #+:: Returns an array containing all elements of +self+ followed by all elements of a given array. #-:: Returns an array containiing all elements of +self+ that are not found in a given array. {#|}[#method-i-7C]:: Returns an array containing all elements of +self+ and all elements of a given array, duplicates removed. #union:: Returns an array containing all elements of +self+ and all elements of given arrays, duplicates removed. #difference:: Returns an array containing all elements of +self+ that are not found in any of the given arrays.. #product:: Returns or yields all combinations of elements from +self+ and given arrays. === Methods for Iterating #each:: Passes each element to a given block. #reverse_each:: Passes each element, in reverse order, to a given block. #each_index:: Passes each element index to a given block. #cycle:: Calls a given block with each element, then does so again, for a specified number of times, or forever. #combination:: Calls a given block with combinations of elements of +self+; a combination does not use the same element more than once. #permutation:: Calls a given block with permutations of elements of +self+; a permutation does not use the same element more than once. #repeated_combination:: Calls a given block with combinations of elements of +self+; a combination may use the same element more than once. #repeated_permutation:: Calls a given block with permutations of elements of +self+; a permutation may use the same element more than once. === Methods for Converting #map, #collect:: Returns an array containing the block return-value for each element. #map!, #collect!:: Replaces each element with a block return-value. #flatten:: Returns an array that is a recursive flattening of +self+. #flatten!:: Replaces each nested array in +self+ with the elements from that array. #inspect, #to_s:: Returns a new String containing the elements. #join:: Returns a newsString containing the elements joined by the field separator. #to_a:: Returns +self+ or a new array containing all elements. #to_ary:: Returns +self+. #to_h:: Returns a new hash formed from the elements. #transpose:: Transposes +self+, which must be an array of arrays. #zip:: Returns a new array of arrays containing +self+ and given arrays; follow the link for details. === Other Methods #*:: Returns one of the following: - With integer argument +n+, a new array that is the concatenation of +n+ copies of +self+. - With string argument +field_separator+, a new string that is equivalent to join(field_separator). #abbrev:: Returns a hash of unambiguous abbreviations for elements. #pack:: Packs the elements into a binary sequence. #sum:: Returns a sum of elements according to either + or a given block. ;T;#0;$@;.F;/o;0;1T;2i;3iA ;%@;&I" Array;F;'@o; ;IC;[o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"ext/date/date_core.c;Ti&%;F;;;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"Date::Error;F;'o;( ;)0;*0;+0;:ArgumentError;%@;-o; ;IC;[; @/; IC;[; @/; IC;[; @/; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i [@)iT ;T;;5;;;;;[;{;IC; "Raised when the arguments are wrong and there isn't a more specific Exception class. Ex: passing the wrong number of arguments [1, 2, 3].first(4, 5) raises the exception: ArgumentError: wrong number of arguments (given 2, expected 1) Ex: passing an argument that is not acceptable: [1, 2, 3].first(-4) raises the exception: ArgumentError: negative array size ;T;[;![;"I" Raised when the arguments are wrong and there isn't a more specific Exception class. Ex: passing the wrong number of arguments [1, 2, 3].first(4, 5) raises the exception: ArgumentError: wrong number of arguments (given 2, expected 1) Ex: passing an argument that is not acceptable: [1, 2, 3].first(-4) raises the exception: ArgumentError: negative array size ;T;#0;$@/;.F;/o;0;1T;2i ;3i ;%@;&I"ArgumentError;F;'@;;o;u;[[@'i-%;F;:MONTHNAMES;;w;;;[;{;IC; "SAn array of strings of full month names in English. The first element is nil. ;T;[;![;"I"TAn array of strings of full month names in English. The first element is nil. ;T;#0;$@C;.F;/o;0;1T;2i*%;3i,%;%@;&I"Date::MONTHNAMES;F;xI""mk_ary_of_str(13, monthnames);To;u;[[@'i2%;F;:ABBR_MONTHNAMES;;w;;;[;{;IC; "ZAn array of strings of abbreviated month names in English. The first element is nil. ;T;[;![;"I"[An array of strings of abbreviated month names in English. The first element is nil. ;T;#0;$@O;.F;/o;0;1T;2i/%;3i1%;%@;&I"Date::ABBR_MONTHNAMES;F;xI"'mk_ary_of_str(13, abbr_monthnames);To;u;[[@'i8%;F;: DAYNAMES;;w;;;[;{;IC; "aAn array of strings of the full names of days of the week in English. The first is "Sunday". ;T;[;![;"I"bAn array of strings of the full names of days of the week in English. The first is "Sunday". ;T;#0;$@[;.F;/o;0;1T;2i5%;3i7%;%@;&I"Date::DAYNAMES;F;xI"mk_ary_of_str(7, daynames);To;u;[[@'i=%;F;:ABBR_DAYNAMES;;w;;;[;{;IC; "RAn array of strings of abbreviated day names in English. The first is "Sun". ;T;[;![;"I"SAn array of strings of abbreviated day names in English. The first is "Sun". ;T;#0;$@g;.F;/o;0;1T;2i:%;3i<%;%@;&I"Date::ABBR_DAYNAMES;F;xI"$mk_ary_of_str(7, abbr_daynames);To;u;[[@'iB%;F;: ITALY;;w;;;[;{;IC; "_The Julian day number of the day of calendar reform for Italy and some catholic countries. ;T;[;![;"I"`The Julian day number of the day of calendar reform for Italy and some catholic countries. ;T;#0;$@s;.F;/o;0;1T;2i?%;3iA%;%@;&I"Date::ITALY;F;xI"INT2FIX(ITALY);To;u;[[@'iG%;F;: ENGLAND;;w;;;[;{;IC; "VThe Julian day number of the day of calendar reform for England and her colonies. ;T;[;![;"I"WThe Julian day number of the day of calendar reform for England and her colonies. ;T;#0;$@;.F;/o;0;1T;2iD%;3iF%;%@;&I"Date::ENGLAND;F;xI"INT2FIX(ENGLAND);To;u;[[@'iL%;F;: JULIAN;;w;;;[;{;IC; "[The Julian day number of the day of calendar reform for the proleptic Julian calendar. ;T;[;![;"I"\The Julian day number of the day of calendar reform for the proleptic Julian calendar. ;T;#0;$@;.F;/o;0;1T;2iI%;3iK%;%@;&I"Date::JULIAN;F;xI"DBL2NUM(JULIAN);To;u;[[@'iQ%;F;:GREGORIAN;;w;;;[;{;IC; "^The Julian day number of the day of calendar reform for the proleptic Gregorian calendar. ;T;[;![;"I"_The Julian day number of the day of calendar reform for the proleptic Gregorian calendar. ;T;#0;$@;.F;/o;0;1T;2iN%;3iP%;%@;&I"Date::GREGORIAN;F;xI"DBL2NUM(GREGORIAN);To;4;5F;6;;;;&I"Date.valid_jd?;F;7[[@90;[[@'i ;T;:valid_jd?;0;[;{;IC; "rJust returns true. It's nonsense, but is for symmetry. Date.valid_jd?(2451944) #=> true See also ::jd.;T;[o;= ;>I" overload;F;?0;;>;@0;:I"'valid_jd?(jd[, start=Date::ITALY]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I"jd[, start;TI"Date::ITALY];T;$@;![;"I"Just returns true. It's nonsense, but is for symmetry. Date.valid_jd?(2451944) #=> true See also ::jd. @overload valid_jd?(jd[, start=Date::ITALY]) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i ;3i ;Bi;%@;9I"{static VALUE date_s_valid_jd_p(int argc, VALUE *argv, VALUE klass) { VALUE vjd, vsg; VALUE argv2[2]; rb_scan_args(argc, argv, "11", &vjd, &vsg); RETURN_FALSE_UNLESS_NUMERIC(vjd); argv2[0] = vjd; if (argc < 2) argv2[1] = INT2FIX(DEFAULT_SG); else argv2[1] = vsg; if (NIL_P(valid_jd_sub(2, argv2, klass, 0))) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.valid_ordinal?;F;7[[@90;[[@'i^ ;T;:valid_ordinal?;0;[;{;IC; "Returns true if the given ordinal date is valid, and false if not. Date.valid_ordinal?(2001,34) #=> true Date.valid_ordinal?(2001,366) #=> false See also ::jd and ::ordinal.;T;[o;= ;>I" overload;F;?0;;?;@0;:I"4valid_ordinal?(year, yday[, start=Date::ITALY]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" year;T0[I"yday[, start;TI"Date::ITALY];T;$@;![;"I"Returns true if the given ordinal date is valid, and false if not. Date.valid_ordinal?(2001,34) #=> true Date.valid_ordinal?(2001,366) #=> false See also ::jd and ::ordinal. @overload valid_ordinal?(year, yday[, start=Date::ITALY]) @return [Boolean];T;#0;$@;.F;/o;0;1T;2iS ;3i\ ;Bi;%@;9I"static VALUE date_s_valid_ordinal_p(int argc, VALUE *argv, VALUE klass) { VALUE vy, vd, vsg; VALUE argv2[3]; rb_scan_args(argc, argv, "21", &vy, &vd, &vsg); RETURN_FALSE_UNLESS_NUMERIC(vy); RETURN_FALSE_UNLESS_NUMERIC(vd); argv2[0] = vy; argv2[1] = vd; if (argc < 3) argv2[2] = INT2FIX(DEFAULT_SG); else argv2[2] = vsg; if (NIL_P(valid_ordinal_sub(3, argv2, klass, 0))) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.valid_civil?;F;7[[@90;[[@'i ;T;:valid_civil?;0;[;{;IC; "9Returns true if the given calendar date is valid, and false if not. Valid in this context is whether the arguments passed to this method would be accepted by ::new. Date.valid_date?(2001,2,3) #=> true Date.valid_date?(2001,2,29) #=> false Date.valid_date?(2001,2,-1) #=> true See also ::jd and ::civil.;T;[o;= ;>I" overload;F;?0;;@;@0;:I"9valid_civil?(year, month, mday[, start=Date::ITALY]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" year;T0[I" month;T0[I"mday[, start;TI"Date::ITALY];T;$@o;= ;>I" overload;F;?0;:valid_date?;@0;:I"8valid_date?(year, month, mday[, start=Date::ITALY]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" year;T0[I" month;T0[I"mday[, start;TI"Date::ITALY];T;$@;![;"I"Returns true if the given calendar date is valid, and false if not. Valid in this context is whether the arguments passed to this method would be accepted by ::new. Date.valid_date?(2001,2,3) #=> true Date.valid_date?(2001,2,29) #=> false Date.valid_date?(2001,2,-1) #=> true See also ::jd and ::civil. @overload valid_civil?(year, month, mday[, start=Date::ITALY]) @return [Boolean] @overload valid_date?(year, month, mday[, start=Date::ITALY]) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i ;3i ;Bi;%@;9I"static VALUE date_s_valid_civil_p(int argc, VALUE *argv, VALUE klass) { VALUE vy, vm, vd, vsg; VALUE argv2[4]; rb_scan_args(argc, argv, "31", &vy, &vm, &vd, &vsg); RETURN_FALSE_UNLESS_NUMERIC(vy); RETURN_FALSE_UNLESS_NUMERIC(vm); RETURN_FALSE_UNLESS_NUMERIC(vd); argv2[0] = vy; argv2[1] = vm; argv2[2] = vd; if (argc < 4) argv2[3] = INT2FIX(DEFAULT_SG); else argv2[3] = vsg; if (NIL_P(valid_civil_sub(4, argv2, klass, 0))) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.valid_date?;F;7[[@90;[[@'i ;T;;A;0;[;{;IC; "9Returns true if the given calendar date is valid, and false if not. Valid in this context is whether the arguments passed to this method would be accepted by ::new. Date.valid_date?(2001,2,3) #=> true Date.valid_date?(2001,2,29) #=> false Date.valid_date?(2001,2,-1) #=> true See also ::jd and ::civil.;T;[o;= ;>I" overload;F;?0;;@;@0;:I"9valid_civil?(year, month, mday[, start=Date::ITALY]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" year;T0[I" month;T0[I"mday[, start;TI"Date::ITALY];T;$@o;= ;>I" overload;F;?0;;A;@0;:I"8valid_date?(year, month, mday[, start=Date::ITALY]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" year;T0[I" month;T0[I"mday[, start;TI"Date::ITALY];T;$@;![;"@;#0;$@;.F;/o;0;1T;2i ;3i ;Bi;%@;9I"static VALUE date_s_valid_civil_p(int argc, VALUE *argv, VALUE klass) { VALUE vy, vm, vd, vsg; VALUE argv2[4]; rb_scan_args(argc, argv, "31", &vy, &vm, &vd, &vsg); RETURN_FALSE_UNLESS_NUMERIC(vy); RETURN_FALSE_UNLESS_NUMERIC(vm); RETURN_FALSE_UNLESS_NUMERIC(vd); argv2[0] = vy; argv2[1] = vm; argv2[2] = vd; if (argc < 4) argv2[3] = INT2FIX(DEFAULT_SG); else argv2[3] = vsg; if (NIL_P(valid_civil_sub(4, argv2, klass, 0))) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.valid_commercial?;F;7[[@90;[[@'i ;T;:valid_commercial?;0;[;{;IC; "Returns true if the given week date is valid, and false if not. Date.valid_commercial?(2001,5,6) #=> true Date.valid_commercial?(2001,5,8) #=> false See also ::jd and ::commercial.;T;[o;= ;>I" overload;F;?0;;B;@0;:I"Avalid_commercial?(cwyear, cweek, cwday[, start=Date::ITALY]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@P;![;"I"@return [Boolean];T;#0;$@P;.F;Bi;C0;7[[I" cwyear;T0[I" cweek;T0[I"cwday[, start;TI"Date::ITALY];T;$@P;![;"I"Returns true if the given week date is valid, and false if not. Date.valid_commercial?(2001,5,6) #=> true Date.valid_commercial?(2001,5,8) #=> false See also ::jd and ::commercial. @overload valid_commercial?(cwyear, cweek, cwday[, start=Date::ITALY]) @return [Boolean];T;#0;$@P;.F;/o;0;1T;2i ;3i ;Bi;%@;9I" static VALUE date_s_valid_commercial_p(int argc, VALUE *argv, VALUE klass) { VALUE vy, vw, vd, vsg; VALUE argv2[4]; rb_scan_args(argc, argv, "31", &vy, &vw, &vd, &vsg); RETURN_FALSE_UNLESS_NUMERIC(vy); RETURN_FALSE_UNLESS_NUMERIC(vw); RETURN_FALSE_UNLESS_NUMERIC(vd); argv2[0] = vy; argv2[1] = vw; argv2[2] = vd; if (argc < 4) argv2[3] = INT2FIX(DEFAULT_SG); else argv2[3] = vsg; if (NIL_P(valid_commercial_sub(4, argv2, klass, 0))) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.julian_leap?;F;7[[I"y;T0;[[@'il ;T;:julian_leap?;0;[;{;IC; "Returns true if the given year is a leap year of the proleptic Julian calendar. Date.julian_leap?(1900) #=> true Date.julian_leap?(1901) #=> false;T;[o;= ;>I" overload;F;?0;;C;@0;:I"julian_leap?(year);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@s;![;"I"@return [Boolean];T;#0;$@s;.F;Bi;C0;7[[I" year;T0;$@s;![;"I"Returns true if the given year is a leap year of the proleptic Julian calendar. Date.julian_leap?(1900) #=> true Date.julian_leap?(1901) #=> false @overload julian_leap?(year) @return [Boolean];T;#0;$@s;.F;/o;0;1T;2ib ;3ij ;Bi;%@;9I"static VALUE date_s_julian_leap_p(VALUE klass, VALUE y) { VALUE nth; int ry; check_numeric(y, "year"); decode_year(y, +1, &nth, &ry); return f_boolcast(c_julian_leap_p(ry)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.gregorian_leap?;F;7[[I"y;T0;[[@'i ;T;:gregorian_leap?;0;[;{;IC; "Returns true if the given year is a leap year of the proleptic Gregorian calendar. Date.gregorian_leap?(1900) #=> false Date.gregorian_leap?(2000) #=> true;T;[o;= ;>I" overload;F;?0;;D;@0;:I"gregorian_leap?(year);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" year;T0;$@o;= ;>I" overload;F;?0;: leap?;@0;:I"leap?(year);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" year;T0;$@;![;"I"Returns true if the given year is a leap year of the proleptic Gregorian calendar. Date.gregorian_leap?(1900) #=> false Date.gregorian_leap?(2000) #=> true @overload gregorian_leap?(year) @return [Boolean] @overload leap?(year) @return [Boolean];T;#0;$@;.F;/o;0;1T;2iw ;3i ;Bi;%@;9I"static VALUE date_s_gregorian_leap_p(VALUE klass, VALUE y) { VALUE nth; int ry; check_numeric(y, "year"); decode_year(y, -1, &nth, &ry); return f_boolcast(c_gregorian_leap_p(ry)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.leap?;F;7[[I"y;T0;[[@'i ;T;;E;0;[;{;IC; "Returns true if the given year is a leap year of the proleptic Gregorian calendar. Date.gregorian_leap?(1900) #=> false Date.gregorian_leap?(2000) #=> true;T;[o;= ;>I" overload;F;?0;;D;@0;:I"gregorian_leap?(year);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" year;T0;$@o;= ;>I" overload;F;?0;;E;@0;:I"leap?(year);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" year;T0;$@;![;"@;#0;$@;.F;/o;0;1T;2iw ;3i ;Bi;%@;9I"static VALUE date_s_gregorian_leap_p(VALUE klass, VALUE y) { VALUE nth; int ry; check_numeric(y, "year"); decode_year(y, -1, &nth, &ry); return f_boolcast(c_gregorian_leap_p(ry)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.new!;F;7[[@90;[[@'i ;T;: new!;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE date_s_new_bang(int argc, VALUE *argv, VALUE klass) { VALUE ajd, of, sg, nth, sf; int jd, df, rof; double rsg; rb_scan_args(argc, argv, "03", &ajd, &of, &sg); switch (argc) { case 0: ajd = INT2FIX(0); case 1: of = INT2FIX(0); case 2: sg = INT2FIX(DEFAULT_SG); } old_to_new(ajd, of, sg, &nth, &jd, &df, &sf, &rof, &rsg); if (!df && f_zero_p(sf) && !rof) return d_simple_new_internal(klass, nth, jd, rsg, 0, 0, 0, HAVE_JD); else return d_complex_new_internal(klass, nth, jd, df, sf, rof, rsg, 0, 0, 0, 0, 0, 0, HAVE_JD | HAVE_DF); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Date.jd;F;7[[@90;[[@'i ;T;:jd;0;[;{;IC; "Creates a date object denoting the given chronological Julian day number. Date.jd(2451944) #=> # Date.jd(2451945) #=> # Date.jd(0) #=> # See also ::new. ;T;[o;= ;>I" overload;F;?0;;G;@0;:I"$jd([jd=0[, start=Date::ITALY]]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"[jd;TI"0[, start=Date::ITALY]];T;$@;![;"I"Creates a date object denoting the given chronological Julian day number. Date.jd(2451944) #=> # Date.jd(2451945) #=> # Date.jd(0) #=> # See also ::new. @overload jd([jd=0[, start=Date::ITALY]]);T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I";static VALUE date_s_jd(int argc, VALUE *argv, VALUE klass) { VALUE vjd, vsg, jd, fr, fr2, ret; double sg; rb_scan_args(argc, argv, "02", &vjd, &vsg); jd = INT2FIX(0); fr2 = INT2FIX(0); sg = DEFAULT_SG; switch (argc) { case 2: val2sg(vsg, sg); case 1: check_numeric(vjd, "jd"); num2num_with_frac(jd, positive_inf); } { VALUE nth; int rjd; decode_jd(jd, &nth, &rjd); ret = d_simple_new_internal(klass, nth, rjd, sg, 0, 0, 0, HAVE_JD); } add_frac(); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.ordinal;F;7[[@90;[[@'i ;T;: ordinal;0;[;{;IC; "xCreates a date object denoting the given ordinal date. The day of year should be a negative or a positive number (as a relative day from the end of year when negative). It should not be zero. Date.ordinal(2001) #=> # Date.ordinal(2001,34) #=> # Date.ordinal(2001,-1) #=> # See also ::jd and ::new. ;T;[o;= ;>I" overload;F;?0;;H;@0;:I"9ordinal([year=-4712[, yday=1[, start=Date::ITALY]]]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" [year;TI"*-4712[, yday=1[, start=Date::ITALY]]];T;$@;![;"I"Creates a date object denoting the given ordinal date. The day of year should be a negative or a positive number (as a relative day from the end of year when negative). It should not be zero. Date.ordinal(2001) #=> # Date.ordinal(2001,34) #=> # Date.ordinal(2001,-1) #=> # See also ::jd and ::new. @overload ordinal([year=-4712[, yday=1[, start=Date::ITALY]]]);T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I" static VALUE date_s_ordinal(int argc, VALUE *argv, VALUE klass) { VALUE vy, vd, vsg, y, fr, fr2, ret; int d; double sg; rb_scan_args(argc, argv, "03", &vy, &vd, &vsg); y = INT2FIX(-4712); d = 1; fr2 = INT2FIX(0); sg = DEFAULT_SG; switch (argc) { case 3: val2sg(vsg, sg); case 2: check_numeric(vd, "yday"); num2int_with_frac(d, positive_inf); case 1: check_numeric(vy, "year"); y = vy; } { VALUE nth; int ry, rd, rjd, ns; if (!valid_ordinal_p(y, d, sg, &nth, &ry, &rd, &rjd, &ns)) rb_raise(eDateError, "invalid date"); ret = d_simple_new_internal(klass, nth, rjd, sg, 0, 0, 0, HAVE_JD); } add_frac(); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.civil;F;7[[@90;[[@'iX ;T;: civil;0;[;{;IC; "WCreates a date object denoting the given calendar date. In this class, BCE years are counted astronomically. Thus, the year before the year 1 is the year zero, and the year preceding the year zero is the year -1. The month and the day of month should be a negative or a positive number (as a relative month/day from the end of year/month when negative). They should not be zero. The last argument should be a Julian day number which denotes the day of calendar reform. Date::ITALY (2299161=1582-10-15), Date::ENGLAND (2361222=1752-09-14), Date::GREGORIAN (the proleptic Gregorian calendar) and Date::JULIAN (the proleptic Julian calendar) can be specified as a day of calendar reform. Date.new(2001) #=> # Date.new(2001,2,3) #=> # Date.new(2001,2,-1) #=> # See also ::jd. ;T;[o;= ;>I" overload;F;?0;;I;@0;:I"Bcivil([year=-4712[, month=1[, mday=1[, start=Date::ITALY]]]]);T;IC; ";T;[;![;"I";T;#0;$@.;.F;Bi;C0;7[[I" [year;TI"5-4712[, month=1[, mday=1[, start=Date::ITALY]]]];T;$@.o;= ;>I" overload;F;?0;;E;@0;:I"@new([year=-4712[, month=1[, mday=1[, start=Date::ITALY]]]]);T;IC; ";T;[;![;"I";T;#0;$@.;.F;Bi;C0;7[[I" [year;TI"5-4712[, month=1[, mday=1[, start=Date::ITALY]]]];T;$@.;![;"I"Creates a date object denoting the given calendar date. In this class, BCE years are counted astronomically. Thus, the year before the year 1 is the year zero, and the year preceding the year zero is the year -1. The month and the day of month should be a negative or a positive number (as a relative month/day from the end of year/month when negative). They should not be zero. The last argument should be a Julian day number which denotes the day of calendar reform. Date::ITALY (2299161=1582-10-15), Date::ENGLAND (2361222=1752-09-14), Date::GREGORIAN (the proleptic Gregorian calendar) and Date::JULIAN (the proleptic Julian calendar) can be specified as a day of calendar reform. Date.new(2001) #=> # Date.new(2001,2,3) #=> # Date.new(2001,2,-1) #=> # See also ::jd. @overload civil([year=-4712[, month=1[, mday=1[, start=Date::ITALY]]]]) @overload new([year=-4712[, month=1[, mday=1[, start=Date::ITALY]]]]);T;#0;$@.;.F;/o;0;1T;2i? ;3iU ;%@;9I"static VALUE date_s_civil(int argc, VALUE *argv, VALUE klass) { return date_initialize(argc, argv, d_lite_s_alloc_simple(klass)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.commercial;F;7[[@90;[[@'i ;T;:commercial;0;[;{;IC; "Creates a date object denoting the given week date. The week and the day of week should be a negative or a positive number (as a relative week/day from the end of year/week when negative). They should not be zero. Date.commercial(2001) #=> # Date.commercial(2002) #=> # Date.commercial(2001,5,6) #=> # See also ::jd and ::new. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I"Jcommercial([cwyear=-4712[, cweek=1[, cwday=1[, start=Date::ITALY]]]]);T;IC; ";T;[;![;"I";T;#0;$@S;.F;Bi;C0;7[[I" [cwyear;TI"6-4712[, cweek=1[, cwday=1[, start=Date::ITALY]]]];T;$@S;![;"I"Creates a date object denoting the given week date. The week and the day of week should be a negative or a positive number (as a relative week/day from the end of year/week when negative). They should not be zero. Date.commercial(2001) #=> # Date.commercial(2002) #=> # Date.commercial(2001,5,6) #=> # See also ::jd and ::new. @overload commercial([cwyear=-4712[, cweek=1[, cwday=1[, start=Date::ITALY]]]]);T;#0;$@S;.F;/o;0;1T;2i ;3i ;%@;9I"kstatic VALUE date_s_commercial(int argc, VALUE *argv, VALUE klass) { VALUE vy, vw, vd, vsg, y, fr, fr2, ret; int w, d; double sg; rb_scan_args(argc, argv, "04", &vy, &vw, &vd, &vsg); y = INT2FIX(-4712); w = 1; d = 1; fr2 = INT2FIX(0); sg = DEFAULT_SG; switch (argc) { case 4: val2sg(vsg, sg); case 3: check_numeric(vd, "cwday"); num2int_with_frac(d, positive_inf); case 2: check_numeric(vw, "cweek"); w = NUM2INT(vw); case 1: check_numeric(vy, "year"); y = vy; } { VALUE nth; int ry, rw, rd, rjd, ns; if (!valid_commercial_p(y, w, d, sg, &nth, &ry, &rw, &rd, &rjd, &ns)) rb_raise(eDateError, "invalid date"); ret = d_simple_new_internal(klass, nth, rjd, sg, 0, 0, 0, HAVE_JD); } add_frac(); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.weeknum;F;7[[@90;[[@'i ;T;: weeknum;0;[;{;IC; " ;T;[;![;"@;#0;$@m;%@;9I"@static VALUE date_s_weeknum(int argc, VALUE *argv, VALUE klass) { VALUE vy, vw, vd, vf, vsg, y, fr, fr2, ret; int w, d, f; double sg; rb_scan_args(argc, argv, "05", &vy, &vw, &vd, &vf, &vsg); y = INT2FIX(-4712); w = 0; d = 1; f = 0; fr2 = INT2FIX(0); sg = DEFAULT_SG; switch (argc) { case 5: val2sg(vsg, sg); case 4: f = NUM2INT(vf); case 3: num2int_with_frac(d, positive_inf); case 2: w = NUM2INT(vw); case 1: y = vy; } { VALUE nth; int ry, rw, rd, rjd, ns; if (!valid_weeknum_p(y, w, d, f, sg, &nth, &ry, &rw, &rd, &rjd, &ns)) rb_raise(eDateError, "invalid date"); ret = d_simple_new_internal(klass, nth, rjd, sg, 0, 0, 0, HAVE_JD); } add_frac(); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.nth_kday;F;7[[@90;[[@'i;T;: nth_kday;0;[;{;IC; " ;T;[;![;"@;#0;$@z;%@;9I"Nstatic VALUE date_s_nth_kday(int argc, VALUE *argv, VALUE klass) { VALUE vy, vm, vn, vk, vsg, y, fr, fr2, ret; int m, n, k; double sg; rb_scan_args(argc, argv, "05", &vy, &vm, &vn, &vk, &vsg); y = INT2FIX(-4712); m = 1; n = 1; k = 1; fr2 = INT2FIX(0); sg = DEFAULT_SG; switch (argc) { case 5: val2sg(vsg, sg); case 4: num2int_with_frac(k, positive_inf); case 3: n = NUM2INT(vn); case 2: m = NUM2INT(vm); case 1: y = vy; } { VALUE nth; int ry, rm, rn, rk, rjd, ns; if (!valid_nth_kday_p(y, m, n, k, sg, &nth, &ry, &rm, &rn, &rk, &rjd, &ns)) rb_raise(eDateError, "invalid date"); ret = d_simple_new_internal(klass, nth, rjd, sg, 0, 0, 0, HAVE_JD); } add_frac(); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.today;F;7[[@90;[[@'i_;T;: today;0;[;{;IC; "aCreates a date object denoting the present day. Date.today #=> # ;T;[o;= ;>I" overload;F;?0;;M;@0;:I"today([start=Date::ITALY]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" [start;TI"Date::ITALY];T;$@;![;"I"Creates a date object denoting the present day. Date.today #=> # @overload today([start=Date::ITALY]);T;#0;$@;.F;/o;0;1T;2iW;3i\;%@;9I"static VALUE date_s_today(int argc, VALUE *argv, VALUE klass) { VALUE vsg, nth, ret; double sg; time_t t; struct tm tm; int y, ry, m, d; rb_scan_args(argc, argv, "01", &vsg); if (argc < 1) sg = DEFAULT_SG; else val2sg(vsg, sg); if (time(&t) == -1) rb_sys_fail("time"); tzset(); if (!localtime_r(&t, &tm)) rb_sys_fail("localtime"); y = tm.tm_year + 1900; m = tm.tm_mon + 1; d = tm.tm_mday; decode_year(INT2FIX(y), -1, &nth, &ry); ret = d_simple_new_internal(klass, nth, 0, GREGORIAN, ry, m, d, HAVE_CIVIL); { get_d1(ret); set_sg(dat, sg); } return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date._strptime;F;7[[@90;[[@'i;T;:_strptime;0;[;{;IC; "8Parses the given representation of date and time with the given template, and returns a hash of parsed elements. _strptime does not support specification of flags and width unlike strftime. Date._strptime('2001-02-03', '%Y-%m-%d') #=> {:year=>2001, :mon=>2, :mday=>3} See also strptime(3) and #strftime. ;T;[o;= ;>I" overload;F;?0;;N;@0;:I"%_strptime(string[, format='%F']);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@;![;"I"@return [Hash];T;#0;$@;.F;Bi;C0;7[[I"string[, format;TI" '%F'];T;$@;![;"I"vParses the given representation of date and time with the given template, and returns a hash of parsed elements. _strptime does not support specification of flags and width unlike strftime. Date._strptime('2001-02-03', '%Y-%m-%d') #=> {:year=>2001, :mon=>2, :mday=>3} See also strptime(3) and #strftime. @overload _strptime(string[, format='%F']) @return [Hash];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE date_s__strptime(int argc, VALUE *argv, VALUE klass) { return date_s__strptime_internal(argc, argv, klass, "%F"); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.strptime;F;7[[@90;[[@'i;T;: strptime;0;[;{;IC; "Parses the given representation of date and time with the given template, and creates a date object. strptime does not support specification of flags and width unlike strftime. Date.strptime('2001-02-03', '%Y-%m-%d') #=> # Date.strptime('03-02-2001', '%d-%m-%Y') #=> # Date.strptime('2001-034', '%Y-%j') #=> # Date.strptime('2001-W05-6', '%G-W%V-%u') #=> # Date.strptime('2001 04 6', '%Y %U %w') #=> # Date.strptime('2001 05 6', '%Y %W %u') #=> # Date.strptime('sat3feb01', '%a%d%b%y') #=> # See also strptime(3) and #strftime. ;T;[o;= ;>I" overload;F;?0;;O;@0;:I"Istrptime([string='-4712-01-01'[, format='%F'[, start=Date::ITALY]]]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" [string;TI"7'-4712-01-01'[, format='%F'[, start=Date::ITALY]]];T;$@;![;"I"Parses the given representation of date and time with the given template, and creates a date object. strptime does not support specification of flags and width unlike strftime. Date.strptime('2001-02-03', '%Y-%m-%d') #=> # Date.strptime('03-02-2001', '%d-%m-%Y') #=> # Date.strptime('2001-034', '%Y-%j') #=> # Date.strptime('2001-W05-6', '%G-W%V-%u') #=> # Date.strptime('2001 04 6', '%Y %U %w') #=> # Date.strptime('2001 05 6', '%Y %W %u') #=> # Date.strptime('sat3feb01', '%a%d%b%y') #=> # See also strptime(3) and #strftime. @overload strptime([string='-4712-01-01'[, format='%F'[, start=Date::ITALY]]]);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE date_s_strptime(int argc, VALUE *argv, VALUE klass) { VALUE str, fmt, sg; rb_scan_args(argc, argv, "03", &str, &fmt, &sg); switch (argc) { case 0: str = rb_str_new2("-4712-01-01"); case 1: fmt = rb_str_new2("%F"); case 2: sg = INT2FIX(DEFAULT_SG); } { VALUE argv2[2], hash; argv2[0] = str; argv2[1] = fmt; hash = date_s__strptime(2, argv2, klass); return d_new_by_frags(klass, hash, sg); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date._parse;F;7[[@90;[[@'i/;T;: _parse;0;[;{;IC; "Parses the given representation of date and time, and returns a hash of parsed elements. This method *does not* function as a validator. If the input string does not match valid formats strictly, you may get a cryptic result. Should consider to use `Date._strptime` or `DateTime._strptime` instead of this method as possible. If the optional second argument is true and the detected year is in the range "00" to "99", considers the year a 2-digit form and makes it full. Date._parse('2001-02-03') #=> {:year=>2001, :mon=>2, :mday=>3} Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;P;@0;:I",_parse(string[, comp=true], limit: 128);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@;![;"I"@return [Hash];T;#0;$@;.F;Bi;C0;7[[I"string[, comp;TI" true];T[I" limit:;TI"128;T;$@;![;"I" Parses the given representation of date and time, and returns a hash of parsed elements. This method *does not* function as a validator. If the input string does not match valid formats strictly, you may get a cryptic result. Should consider to use `Date._strptime` or `DateTime._strptime` instead of this method as possible. If the optional second argument is true and the detected year is in the range "00" to "99", considers the year a 2-digit form and makes it full. Date._parse('2001-02-03') #=> {:year=>2001, :mon=>2, :mday=>3} Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload _parse(string[, comp=true], limit: 128) @return [Hash];T;#0;$@;.F;/o;0;1T;2i;3i-;%@;9I"}static VALUE date_s__parse(int argc, VALUE *argv, VALUE klass) { return date_s__parse_internal(argc, argv, klass); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.parse;F;7[[@90;[[@'iM;T;;+;0;[;{;IC; "Parses the given representation of date and time, and creates a date object. This method *does not* function as a validator. If the input string does not match valid formats strictly, you may get a cryptic result. Should consider to use `Date.strptime` instead of this method as possible. If the optional second argument is true and the detected year is in the range "00" to "99", considers the year a 2-digit form and makes it full. Date.parse('2001-02-03') #=> # Date.parse('20010203') #=> # Date.parse('3rd Feb 2001') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;+;@0;:I"Nparse(string='-4712-01-01'[, comp=true[, start=Date::ITALY]], limit: 128);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;TI"4'-4712-01-01'[, comp=true[, start=Date::ITALY]];T[I" limit:;TI"128;T;$@;![;"I"^Parses the given representation of date and time, and creates a date object. This method *does not* function as a validator. If the input string does not match valid formats strictly, you may get a cryptic result. Should consider to use `Date.strptime` instead of this method as possible. If the optional second argument is true and the detected year is in the range "00" to "99", considers the year a 2-digit form and makes it full. Date.parse('2001-02-03') #=> # Date.parse('20010203') #=> # Date.parse('3rd Feb 2001') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload parse(string='-4712-01-01'[, comp=true[, start=Date::ITALY]], limit: 128);T;#0;$@;.F;/o;0;1T;2i5;3iJ;%@;9I"<static VALUE date_s_parse(int argc, VALUE *argv, VALUE klass) { VALUE str, comp, sg, opt; rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt); if (!NIL_P(opt)) argc--; switch (argc) { case 0: str = rb_str_new2("-4712-01-01"); case 1: comp = Qtrue; case 2: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 2; VALUE argv2[3]; argv2[0] = str; argv2[1] = comp; if (!NIL_P(opt)) argv2[argc2++] = opt; VALUE hash = date_s__parse(argc2, argv2, klass); return d_new_by_frags(klass, hash, sg); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date._iso8601;F;7[[@90;[[@'iz;T;: _iso8601;0;[;{;IC; "Returns a hash of parsed elements. Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;Q;@0;:I"!_iso8601(string, limit: 128);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@;![;"I"@return [Hash];T;#0;$@;.F;Bi;C0;7[[I" string;T0[I" limit:;TI"128;T;$@;![;"I"Returns a hash of parsed elements. Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload _iso8601(string, limit: 128) @return [Hash];T;#0;$@;.F;/o;0;1T;2ip;3ix;%@;9I"static VALUE date_s__iso8601(int argc, VALUE *argv, VALUE klass) { VALUE str, opt; rb_scan_args(argc, argv, "1:", &str, &opt); check_limit(str, opt); return date__iso8601(str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.iso8601;F;7[[@90;[[@'i;T;: iso8601;0;[;{;IC; "Creates a new Date object by parsing from a string according to some typical ISO 8601 formats. Date.iso8601('2001-02-03') #=> # Date.iso8601('20010203') #=> # Date.iso8601('2001-W05-6') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;R;@0;:I"Ciso8601(string='-4712-01-01'[, start=Date::ITALY], limit: 128);T;IC; ";T;[;![;"I";T;#0;$@:;.F;Bi;C0;7[[I" string;TI"''-4712-01-01'[, start=Date::ITALY];T[I" limit:;TI"128;T;$@:;![;"I"Creates a new Date object by parsing from a string according to some typical ISO 8601 formats. Date.iso8601('2001-02-03') #=> # Date.iso8601('20010203') #=> # Date.iso8601('2001-W05-6') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload iso8601(string='-4712-01-01'[, start=Date::ITALY], limit: 128);T;#0;$@:;.F;/o;0;1T;2i;3i;%@;9I"static VALUE date_s_iso8601(int argc, VALUE *argv, VALUE klass) { VALUE str, sg, opt; rb_scan_args(argc, argv, "02:", &str, &sg, &opt); if (!NIL_P(opt)) argc--; switch (argc) { case 0: str = rb_str_new2("-4712-01-01"); case 1: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 1; VALUE argv2[2]; argv2[0] = str; if (!NIL_P(opt)) argv2[argc2++] = opt; VALUE hash = date_s__iso8601(argc2, argv2, klass); return d_new_by_frags(klass, hash, sg); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date._rfc3339;F;7[[@90;[[@'i;T;: _rfc3339;0;[;{;IC; "Returns a hash of parsed elements. Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;S;@0;:I"!_rfc3339(string, limit: 128);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@W;![;"I"@return [Hash];T;#0;$@W;.F;Bi;C0;7[[I" string;T0[I" limit:;TI"128;T;$@W;![;"I"Returns a hash of parsed elements. Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload _rfc3339(string, limit: 128) @return [Hash];T;#0;$@W;.F;/o;0;1T;2i;3i;%@;9I"static VALUE date_s__rfc3339(int argc, VALUE *argv, VALUE klass) { VALUE str, opt; rb_scan_args(argc, argv, "1:", &str, &opt); check_limit(str, opt); return date__rfc3339(str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.rfc3339;F;7[[@90;[[@'i;T;: rfc3339;0;[;{;IC; "PCreates a new Date object by parsing from a string according to some typical RFC 3339 formats. Date.rfc3339('2001-02-03T04:05:06+07:00') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;T;@0;:I"Rrfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128);T;IC; ";T;[;![;"I";T;#0;$@x;.F;Bi;C0;7[[I" string;TI"6'-4712-01-01T00:00:00+00:00'[, start=Date::ITALY];T[I" limit:;TI"128;T;$@x;![;"I"Creates a new Date object by parsing from a string according to some typical RFC 3339 formats. Date.rfc3339('2001-02-03T04:05:06+07:00') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128);T;#0;$@x;.F;/o;0;1T;2i;3i;%@;9I"static VALUE date_s_rfc3339(int argc, VALUE *argv, VALUE klass) { VALUE str, sg, opt; rb_scan_args(argc, argv, "02:", &str, &sg, &opt); if (!NIL_P(opt)) argc--; switch (argc) { case 0: str = rb_str_new2("-4712-01-01T00:00:00+00:00"); case 1: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 1; VALUE argv2[2]; argv2[0] = str; if (!NIL_P(opt)) argv2[argc2++] = opt; VALUE hash = date_s__rfc3339(argc2, argv2, klass); return d_new_by_frags(klass, hash, sg); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date._xmlschema;F;7[[@90;[[@'i;T;:_xmlschema;0;[;{;IC; "Returns a hash of parsed elements. Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;U;@0;:I"#_xmlschema(string, limit: 128);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@;![;"I"@return [Hash];T;#0;$@;.F;Bi;C0;7[[I" string;T0[I" limit:;TI"128;T;$@;![;"I"Returns a hash of parsed elements. Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload _xmlschema(string, limit: 128) @return [Hash];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE date_s__xmlschema(int argc, VALUE *argv, VALUE klass) { VALUE str, opt; rb_scan_args(argc, argv, "1:", &str, &opt); check_limit(str, opt); return date__xmlschema(str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.xmlschema;F;7[[@90;[[@'i ;T;:xmlschema;0;[;{;IC; "ECreates a new Date object by parsing from a string according to some typical XML Schema formats. Date.xmlschema('2001-02-03') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;V;@0;:I"Exmlschema(string='-4712-01-01'[, start=Date::ITALY], limit: 128);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;TI"''-4712-01-01'[, start=Date::ITALY];T[I" limit:;TI"128;T;$@;![;"I"Creates a new Date object by parsing from a string according to some typical XML Schema formats. Date.xmlschema('2001-02-03') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload xmlschema(string='-4712-01-01'[, start=Date::ITALY], limit: 128);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE date_s_xmlschema(int argc, VALUE *argv, VALUE klass) { VALUE str, sg, opt; rb_scan_args(argc, argv, "02:", &str, &sg, &opt); if (!NIL_P(opt)) argc--; switch (argc) { case 0: str = rb_str_new2("-4712-01-01"); case 1: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 1; VALUE argv2[2]; argv2[0] = str; if (!NIL_P(opt)) argv2[argc2++] = opt; VALUE hash = date_s__xmlschema(argc2, argv2, klass); return d_new_by_frags(klass, hash, sg); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date._rfc2822;F;7[[@90;[[@'i.;T;: _rfc2822;0;[;{;IC; "Returns a hash of parsed elements. Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;W;@0;:I"!_rfc2822(string, limit: 128);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@;![;"I"@return [Hash];T;#0;$@;.F;Bi;C0;7[[I" string;T0[I" limit:;TI"128;T;$@o;= ;>I" overload;F;?0;: _rfc822;@0;:I" _rfc822(string, limit: 128);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@;![;"I"@return [Hash];T;#0;$@;.F;Bi;C0;7[[I" string;T0[I" limit:;TI"128;T;$@;![;"I";Returns a hash of parsed elements. Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload _rfc2822(string, limit: 128) @return [Hash] @overload _rfc822(string, limit: 128) @return [Hash];T;#0;$@;.F;/o;0;1T;2i#;3i-;%@;9I"static VALUE date_s__rfc2822(int argc, VALUE *argv, VALUE klass) { VALUE str, opt; rb_scan_args(argc, argv, "1:", &str, &opt); check_limit(str, opt); return date__rfc2822(str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date._rfc822;F;7[[@90;[[@'i.;T;;X;0;[;{;IC; "Returns a hash of parsed elements. Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;W;@0;:I"!_rfc2822(string, limit: 128);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@;![;"I"@return [Hash];T;#0;$@;.F;Bi;C0;7[[I" string;T0[I" limit:;TI"128;T;$@o;= ;>I" overload;F;?0;;X;@0;:I" _rfc822(string, limit: 128);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@;![;"I"@return [Hash];T;#0;$@;.F;Bi;C0;7[[I" string;T0[I" limit:;TI"128;T;$@;![;"@;#0;$@;.F;/o;0;1T;2i#;3i-;%@;9I"static VALUE date_s__rfc2822(int argc, VALUE *argv, VALUE klass) { VALUE str, opt; rb_scan_args(argc, argv, "1:", &str, &opt); check_limit(str, opt); return date__rfc2822(str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.rfc2822;F;7[[@90;[[@'iH;T;: rfc2822;0;[;{;IC; "ZCreates a new Date object by parsing from a string according to some typical RFC 2822 formats. Date.rfc2822('Sat, 3 Feb 2001 00:00:00 +0000') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I"Wrfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128);T;IC; ";T;[;![;"I";T;#0;$@8;.F;Bi;C0;7[[I" string;TI";'Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY];T[I" limit:;TI"128;T;$@8o;= ;>I" overload;F;?0;: rfc822;@0;:I"Vrfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128);T;IC; ";T;[;![;"I";T;#0;$@8;.F;Bi;C0;7[[I" string;TI";'Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY];T[I" limit:;TI"128;T;$@8;![;"I"Creates a new Date object by parsing from a string according to some typical RFC 2822 formats. Date.rfc2822('Sat, 3 Feb 2001 00:00:00 +0000') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) @overload rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128);T;#0;$@8;.F;/o;0;1T;2i9;3iE;%@;9I"static VALUE date_s_rfc2822(int argc, VALUE *argv, VALUE klass) { VALUE str, sg, opt; rb_scan_args(argc, argv, "02:", &str, &sg, &opt); switch (argc) { case 0: str = rb_str_new2("Mon, 1 Jan -4712 00:00:00 +0000"); case 1: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 1; VALUE argv2[2]; argv2[0] = str; if (!NIL_P(opt)) argv2[argc2++] = opt; VALUE hash = date_s__rfc2822(argc2, argv2, klass); return d_new_by_frags(klass, hash, sg); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.rfc822;F;7[[@90;[[@'iH;T;;Z;0;[;{;IC; "ZCreates a new Date object by parsing from a string according to some typical RFC 2822 formats. Date.rfc2822('Sat, 3 Feb 2001 00:00:00 +0000') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I"Wrfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128);T;IC; ";T;[;![;"I";T;#0;$@c;.F;Bi;C0;7[[I" string;TI";'Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY];T[I" limit:;TI"128;T;$@co;= ;>I" overload;F;?0;;Z;@0;:I"Vrfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128);T;IC; ";T;[;![;"I";T;#0;$@c;.F;Bi;C0;7[[I" string;TI";'Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY];T[I" limit:;TI"128;T;$@c;![;"@_;#0;$@c;.F;/o;0;1T;2i9;3iE;%@;9I"static VALUE date_s_rfc2822(int argc, VALUE *argv, VALUE klass) { VALUE str, sg, opt; rb_scan_args(argc, argv, "02:", &str, &sg, &opt); switch (argc) { case 0: str = rb_str_new2("Mon, 1 Jan -4712 00:00:00 +0000"); case 1: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 1; VALUE argv2[2]; argv2[0] = str; if (!NIL_P(opt)) argv2[argc2++] = opt; VALUE hash = date_s__rfc2822(argc2, argv2, klass); return d_new_by_frags(klass, hash, sg); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date._httpdate;F;7[[@90;[[@'ij;T;:_httpdate;0;[;{;IC; "Returns a hash of parsed elements. Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;[;@0;:I""_httpdate(string, limit: 128);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@;![;"I"@return [Hash];T;#0;$@;.F;Bi;C0;7[[I" string;T0[I" limit:;TI"128;T;$@;![;"I"Returns a hash of parsed elements. Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload _httpdate(string, limit: 128) @return [Hash];T;#0;$@;.F;/o;0;1T;2i`;3ih;%@;9I"static VALUE date_s__httpdate(int argc, VALUE *argv, VALUE klass) { VALUE str, opt; rb_scan_args(argc, argv, "1:", &str, &opt); check_limit(str, opt); return date__httpdate(str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.httpdate;F;7[[@90;[[@'i;T;: httpdate;0;[;{;IC; "QCreates a new Date object by parsing from a string according to some RFC 2616 format. Date.httpdate('Sat, 03 Feb 2001 00:00:00 GMT') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;\;@0;:I"Whttpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY], limit: 128);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;TI":'Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY];T[I" limit:;TI"128;T;$@;![;"I"Creates a new Date object by parsing from a string according to some RFC 2616 format. Date.httpdate('Sat, 03 Feb 2001 00:00:00 GMT') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY], limit: 128);T;#0;$@;.F;/o;0;1T;2iu;3i;%@;9I"static VALUE date_s_httpdate(int argc, VALUE *argv, VALUE klass) { VALUE str, sg, opt; rb_scan_args(argc, argv, "02:", &str, &sg, &opt); switch (argc) { case 0: str = rb_str_new2("Mon, 01 Jan -4712 00:00:00 GMT"); case 1: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 1; VALUE argv2[2]; argv2[0] = str; if (!NIL_P(opt)) argv2[argc2++] = opt; VALUE hash = date_s__httpdate(argc2, argv2, klass); return d_new_by_frags(klass, hash, sg); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date._jisx0301;F;7[[@90;[[@'i;T;:_jisx0301;0;[;{;IC; "Returns a hash of parsed elements. Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;];@0;:I""_jisx0301(string, limit: 128);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@;![;"I"@return [Hash];T;#0;$@;.F;Bi;C0;7[[I" string;T0[I" limit:;TI"128;T;$@;![;"I"Returns a hash of parsed elements. Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload _jisx0301(string, limit: 128) @return [Hash];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE date_s__jisx0301(int argc, VALUE *argv, VALUE klass) { VALUE str, opt; rb_scan_args(argc, argv, "1:", &str, &opt); check_limit(str, opt); return date__jisx0301(str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.jisx0301;F;7[[@90;[[@'i;T;: jisx0301;0;[;{;IC; "Creates a new Date object by parsing from a string according to some typical JIS X 0301 formats. Date.jisx0301('H13.02.03') #=> # For no-era year, legacy format, Heisei is assumed. Date.jisx0301('13.02.03') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;^;@0;:I"Djisx0301(string='-4712-01-01'[, start=Date::ITALY], limit: 128);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;TI"''-4712-01-01'[, start=Date::ITALY];T[I" limit:;TI"128;T;$@;![;"I"Creates a new Date object by parsing from a string according to some typical JIS X 0301 formats. Date.jisx0301('H13.02.03') #=> # For no-era year, legacy format, Heisei is assumed. Date.jisx0301('13.02.03') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload jisx0301(string='-4712-01-01'[, start=Date::ITALY], limit: 128);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE date_s_jisx0301(int argc, VALUE *argv, VALUE klass) { VALUE str, sg, opt; rb_scan_args(argc, argv, "02:", &str, &sg, &opt); if (!NIL_P(opt)) argc--; switch (argc) { case 0: str = rb_str_new2("-4712-01-01"); case 1: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 1; VALUE argv2[2]; argv2[0] = str; if (!NIL_P(opt)) argv2[argc2++] = opt; VALUE hash = date_s__jisx0301(argc2, argv2, klass); return d_new_by_frags(klass, hash, sg); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#initialize;F;7[[@90;[[@'i^ ;T;;D;0;[;{;IC; " ;T;[;![;"@;#0;$@ ;%@;9I"static VALUE date_initialize(int argc, VALUE *argv, VALUE self) { VALUE vy, vm, vd, vsg, y, fr, fr2, ret; int m, d; double sg; struct SimpleDateData *dat = rb_check_typeddata(self, &d_lite_type); if (!simple_dat_p(dat)) { rb_raise(rb_eTypeError, "Date expected"); } rb_scan_args(argc, argv, "04", &vy, &vm, &vd, &vsg); y = INT2FIX(-4712); m = 1; d = 1; fr2 = INT2FIX(0); sg = DEFAULT_SG; switch (argc) { case 4: val2sg(vsg, sg); case 3: check_numeric(vd, "day"); num2int_with_frac(d, positive_inf); case 2: check_numeric(vm, "month"); m = NUM2INT(vm); case 1: check_numeric(vy, "year"); y = vy; } if (guess_style(y, sg) < 0) { VALUE nth; int ry, rm, rd; if (!valid_gregorian_p(y, m, d, &nth, &ry, &rm, &rd)) rb_raise(eDateError, "invalid date"); set_to_simple(self, dat, nth, 0, sg, ry, rm, rd, HAVE_CIVIL); } else { VALUE nth; int ry, rm, rd, rjd, ns; if (!valid_civil_p(y, m, d, sg, &nth, &ry, &rm, &rd, &rjd, &ns)) rb_raise(eDateError, "invalid date"); set_to_simple(self, dat, nth, rjd, sg, ry, rm, rd, HAVE_JD | HAVE_CIVIL); } ret = self; add_frac(); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#initialize_copy;F;7[[I" date;T0;[[@'iR;T;;];0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2iQ;3iQ;%@;9I"Ostatic VALUE d_lite_initialize_copy(VALUE copy, VALUE date) { rb_check_frozen(copy); if (copy == date) return copy; { get_d2(copy, date); if (simple_dat_p(bdat)) { if (simple_dat_p(adat)) { adat->s = bdat->s; } else { adat->c.flags = bdat->s.flags | COMPLEX_DAT; adat->c.nth = bdat->s.nth; adat->c.jd = bdat->s.jd; adat->c.df = 0; adat->c.sf = INT2FIX(0); adat->c.of = 0; adat->c.sg = bdat->s.sg; adat->c.year = bdat->s.year; #ifndef USE_PACK adat->c.mon = bdat->s.mon; adat->c.mday = bdat->s.mday; adat->c.hour = bdat->s.hour; adat->c.min = bdat->s.min; adat->c.sec = bdat->s.sec; #else adat->c.pc = bdat->s.pc; #endif } } else { if (!complex_dat_p(adat)) rb_raise(rb_eArgError, "cannot load complex into simple"); adat->c = bdat->c; } } return copy; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#fill;F;7[;[[@'i;T;;);0;[;{;IC; " ;T;[;![;"@;#0;$@&;%@;9I"static VALUE d_lite_fill(VALUE self) { get_d1(self); if (simple_dat_p(dat)) { get_s_jd(dat); get_s_civil(dat); } else { get_c_jd(dat); get_c_civil(dat); get_c_df(dat); get_c_time(dat); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Date#ajd;F;7[;[[@'i;T;:ajd;0;[;{;IC; "Returns the astronomical Julian day number. This is a fractional number, which is not adjusted by the offset. DateTime.new(2001,2,3,4,5,6,'+7').ajd #=> (11769328217/4800) DateTime.new(2001,2,2,14,5,6,'-7').ajd #=> (11769328217/4800) ;T;[o;= ;>I" overload;F;?0;;_;@0;:I"ajd;T;IC; ";T;[;![;"I";T;#0;$@2;.F;Bi;C0;7[;$@2;![;"I"Returns the astronomical Julian day number. This is a fractional number, which is not adjusted by the offset. DateTime.new(2001,2,3,4,5,6,'+7').ajd #=> (11769328217/4800) DateTime.new(2001,2,2,14,5,6,'-7').ajd #=> (11769328217/4800) @overload ajd;T;#0;$@2;.F;/o;0;1T;2i;3i;%@;9I"Ustatic VALUE d_lite_ajd(VALUE self) { get_d1(self); return m_ajd(dat); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#amjd;F;7[;[[@'i;T;: amjd;0;[;{;IC; "Returns the astronomical modified Julian day number. This is a fractional number, which is not adjusted by the offset. DateTime.new(2001,2,3,4,5,6,'+7').amjd #=> (249325817/4800) DateTime.new(2001,2,2,14,5,6,'-7').amjd #=> (249325817/4800) ;T;[o;= ;>I" overload;F;?0;;`;@0;:I" amjd;T;IC; ";T;[;![;"I";T;#0;$@H;.F;Bi;C0;7[;$@H;![;"I"Returns the astronomical modified Julian day number. This is a fractional number, which is not adjusted by the offset. DateTime.new(2001,2,3,4,5,6,'+7').amjd #=> (249325817/4800) DateTime.new(2001,2,2,14,5,6,'-7').amjd #=> (249325817/4800) @overload amjd;T;#0;$@H;.F;/o;0;1T;2i;3i;%@;9I"Wstatic VALUE d_lite_amjd(VALUE self) { get_d1(self); return m_amjd(dat); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Date#jd;F;7[;[[@'i;T;;G;0;[;{;IC; "Returns the Julian day number. This is a whole number, which is adjusted by the offset as the local time. DateTime.new(2001,2,3,4,5,6,'+7').jd #=> 2451944 DateTime.new(2001,2,3,4,5,6,'-7').jd #=> 2451944 ;T;[o;= ;>I" overload;F;?0;;G;@0;:I"jd;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@^;![;"I"@return [Integer];T;#0;$@^;.F;Bi;C0;7[;$@^;![;"I"Returns the Julian day number. This is a whole number, which is adjusted by the offset as the local time. DateTime.new(2001,2,3,4,5,6,'+7').jd #=> 2451944 DateTime.new(2001,2,3,4,5,6,'-7').jd #=> 2451944 @overload jd @return [Integer];T;#0;$@^;.F;/o;0;1T;2i;3i;%@;9I"^static VALUE d_lite_jd(VALUE self) { get_d1(self); return m_real_local_jd(dat); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Date#mjd;F;7[;[[@'i;T;:mjd;0;[;{;IC; "Returns the modified Julian day number. This is a whole number, which is adjusted by the offset as the local time. DateTime.new(2001,2,3,4,5,6,'+7').mjd #=> 51943 DateTime.new(2001,2,3,4,5,6,'-7').mjd #=> 51943 ;T;[o;= ;>I" overload;F;?0;;a;@0;:I"mjd;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@y;![;"I"@return [Integer];T;#0;$@y;.F;Bi;C0;7[;$@y;![;"I"Returns the modified Julian day number. This is a whole number, which is adjusted by the offset as the local time. DateTime.new(2001,2,3,4,5,6,'+7').mjd #=> 51943 DateTime.new(2001,2,3,4,5,6,'-7').mjd #=> 51943 @overload mjd @return [Integer];T;#0;$@y;.F;/o;0;1T;2i;3i;%@;9I"xstatic VALUE d_lite_mjd(VALUE self) { get_d1(self); return f_sub(m_real_local_jd(dat), INT2FIX(2400001)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Date#ld;F;7[;[[@'i;T;:ld;0;[;{;IC; "Returns the Lilian day number. This is a whole number, which is adjusted by the offset as the local time. Date.new(2001,2,3).ld #=> 152784 ;T;[o;= ;>I" overload;F;?0;;b;@0;:I"ld;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the Lilian day number. This is a whole number, which is adjusted by the offset as the local time. Date.new(2001,2,3).ld #=> 152784 @overload ld @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"wstatic VALUE d_lite_ld(VALUE self) { get_d1(self); return f_sub(m_real_local_jd(dat), INT2FIX(2299160)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#year;F;7[;[[@'i;T;: year;0;[;{;IC; "`Returns the year. Date.new(2001,2,3).year #=> 2001 (Date.new(1,1,1) - 1).year #=> 0 ;T;[o;= ;>I" overload;F;?0;;c;@0;:I" year;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the year. Date.new(2001,2,3).year #=> 2001 (Date.new(1,1,1) - 1).year #=> 0 @overload year @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"\static VALUE d_lite_year(VALUE self) { get_d1(self); return m_real_year(dat); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#yday;F;7[;[[@'i;T;: yday;0;[;{;IC; "MReturns the day of the year (1-366). Date.new(2001,2,3).yday #=> 34 ;T;[o;= ;>I" overload;F;?0;;d;@0;:I" yday;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@;![;"I"@return [Fixnum];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"qReturns the day of the year (1-366). Date.new(2001,2,3).yday #=> 34 @overload yday @return [Fixnum];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"`static VALUE d_lite_yday(VALUE self) { get_d1(self); return INT2FIX(m_yday(dat)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Date#mon;F;7[;[[@'i;T;:mon;0;[;{;IC; "@Returns the month (1-12). Date.new(2001,2,3).mon #=> 2 ;T;[o;= ;>I" overload;F;?0;;e;@0;:I"mon;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@;![;"I"@return [Fixnum];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;: month;@0;:I" month;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@;![;"I"@return [Fixnum];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the month (1-12). Date.new(2001,2,3).mon #=> 2 @overload mon @return [Fixnum] @overload month @return [Fixnum];T;#0;$@;.F;/o;0;1T;2i;3i ;%@;9I"^static VALUE d_lite_mon(VALUE self) { get_d1(self); return INT2FIX(m_mon(dat)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#month;F;7[;[[@'i;T;;f;0;[;{;IC; "@Returns the month (1-12). Date.new(2001,2,3).mon #=> 2 ;T;[o;= ;>I" overload;F;?0;;e;@0;:I"mon;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@ ;![;"I"@return [Fixnum];T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;;f;@0;:I" month;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@ ;![;"I"@return [Fixnum];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"@ ;#0;$@ ;.F;/o;0;1T;2i;3i ;%@;9I"^static VALUE d_lite_mon(VALUE self) { get_d1(self); return INT2FIX(m_mon(dat)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#mday;F;7[;[[@'i;T;: mday;0;[;{;IC; "LReturns the day of the month (1-31). Date.new(2001,2,3).mday #=> 3 ;T;[o;= ;>I" overload;F;?0;;g;@0;:I" mday;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@4;![;"I"@return [Fixnum];T;#0;$@4;.F;Bi;C0;7[;$@4o;= ;>I" overload;F;?0;:day;@0;:I"day;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@4;![;"I"@return [Fixnum];T;#0;$@4;.F;Bi;C0;7[;$@4;![;"I"Returns the day of the month (1-31). Date.new(2001,2,3).mday #=> 3 @overload mday @return [Fixnum] @overload day @return [Fixnum];T;#0;$@4;.F;/o;0;1T;2i;3i;%@;9I"`static VALUE d_lite_mday(VALUE self) { get_d1(self); return INT2FIX(m_mday(dat)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Date#day;F;7[;[[@'i;T;;h;0;[;{;IC; "LReturns the day of the month (1-31). Date.new(2001,2,3).mday #=> 3 ;T;[o;= ;>I" overload;F;?0;;g;@0;:I" mday;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@\;![;"I"@return [Fixnum];T;#0;$@\;.F;Bi;C0;7[;$@\o;= ;>I" overload;F;?0;;h;@0;:I"day;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@\;![;"I"@return [Fixnum];T;#0;$@\;.F;Bi;C0;7[;$@\;![;"@X;#0;$@\;.F;/o;0;1T;2i;3i;%@;9I"`static VALUE d_lite_mday(VALUE self) { get_d1(self); return INT2FIX(m_mday(dat)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#day_fraction;F;7[;[[@'i-;T;:day_fraction;0;[;{;IC; "aReturns the fractional part of the day. DateTime.new(2001,2,3,12).day_fraction #=> (1/2) ;T;[o;= ;>I" overload;F;?0;;i;@0;:I"day_fraction;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"zReturns the fractional part of the day. DateTime.new(2001,2,3,12).day_fraction #=> (1/2) @overload day_fraction;T;#0;$@;.F;/o;0;1T;2i%;3i*;%@;9I"static VALUE d_lite_day_fraction(VALUE self) { get_d1(self); if (simple_dat_p(dat)) return INT2FIX(0); return m_fr(dat); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#cwyear;F;7[;[[@'i?;T;: cwyear;0;[;{;IC; "yReturns the calendar week based year. Date.new(2001,2,3).cwyear #=> 2001 Date.new(2000,1,1).cwyear #=> 1999 ;T;[o;= ;>I" overload;F;?0;;j;@0;:I" cwyear;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the calendar week based year. Date.new(2001,2,3).cwyear #=> 2001 Date.new(2000,1,1).cwyear #=> 1999 @overload cwyear @return [Integer];T;#0;$@;.F;/o;0;1T;2i6;3i=;%@;9I"`static VALUE d_lite_cwyear(VALUE self) { get_d1(self); return m_real_cwyear(dat); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#cweek;F;7[;[[@'iN;T;: cweek;0;[;{;IC; "QReturns the calendar week number (1-53). Date.new(2001,2,3).cweek #=> 5 ;T;[o;= ;>I" overload;F;?0;;k;@0;:I" cweek;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@;![;"I"@return [Fixnum];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"vReturns the calendar week number (1-53). Date.new(2001,2,3).cweek #=> 5 @overload cweek @return [Fixnum];T;#0;$@;.F;/o;0;1T;2iF;3iL;%@;9I"bstatic VALUE d_lite_cweek(VALUE self) { get_d1(self); return INT2FIX(m_cweek(dat)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#cwday;F;7[;[[@'i];T;: cwday;0;[;{;IC; "]Returns the day of calendar week (1-7, Monday is 1). Date.new(2001,2,3).cwday #=> 6 ;T;[o;= ;>I" overload;F;?0;;l;@0;:I" cwday;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@;![;"I"@return [Fixnum];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"}Returns the day of calendar week (1-7, Monday is 1). Date.new(2001,2,3).cwday #=> 6 @overload cwday @return [Fixnum];T;#0;$@;.F;/o;0;1T;2iU;3i[;%@;9I"bstatic VALUE d_lite_cwday(VALUE self) { get_d1(self); return INT2FIX(m_cwday(dat)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#wnum0;F;7[;[[@'ie;T;: wnum0;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"bstatic VALUE d_lite_wnum0(VALUE self) { get_d1(self); return INT2FIX(m_wnum0(dat)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#wnum1;F;7[;[[@'il;T;: wnum1;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"bstatic VALUE d_lite_wnum1(VALUE self) { get_d1(self); return INT2FIX(m_wnum1(dat)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#wday;F;7[;[[@'i|;T;: wday;0;[;{;IC; "VReturns the day of week (0-6, Sunday is zero). Date.new(2001,2,3).wday #=> 6 ;T;[o;= ;>I" overload;F;?0;;o;@0;:I" wday;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@;![;"I"@return [Fixnum];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"zReturns the day of week (0-6, Sunday is zero). Date.new(2001,2,3).wday #=> 6 @overload wday @return [Fixnum];T;#0;$@;.F;/o;0;1T;2it;3iz;%@;9I"`static VALUE d_lite_wday(VALUE self) { get_d1(self); return INT2FIX(m_wday(dat)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#sunday?;F;7[;[[@'i;T;: sunday?;0;[;{;IC; "(Returns true if the date is Sunday.;T;[o;= ;>I" overload;F;?0;;p;@0;:I" sunday?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"PReturns true if the date is Sunday. @overload sunday? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"lstatic VALUE d_lite_sunday_p(VALUE self) { get_d1(self); return f_boolcast(m_wday(dat) == 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#monday?;F;7[;[[@'i;T;: monday?;0;[;{;IC; "(Returns true if the date is Monday.;T;[o;= ;>I" overload;F;?0;;q;@0;:I" monday?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@8;![;"I"@return [Boolean];T;#0;$@8;.F;Bi;C0;7[;$@8;![;"I"PReturns true if the date is Monday. @overload monday? @return [Boolean];T;#0;$@8;.F;/o;0;1T;2i;3i;Bi;%@;9I"lstatic VALUE d_lite_monday_p(VALUE self) { get_d1(self); return f_boolcast(m_wday(dat) == 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#tuesday?;F;7[;[[@'i;T;: tuesday?;0;[;{;IC; ")Returns true if the date is Tuesday.;T;[o;= ;>I" overload;F;?0;;r;@0;:I" tuesday?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@S;![;"I"@return [Boolean];T;#0;$@S;.F;Bi;C0;7[;$@S;![;"I"RReturns true if the date is Tuesday. @overload tuesday? @return [Boolean];T;#0;$@S;.F;/o;0;1T;2i;3i;Bi;%@;9I"mstatic VALUE d_lite_tuesday_p(VALUE self) { get_d1(self); return f_boolcast(m_wday(dat) == 2); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#wednesday?;F;7[;[[@'i;T;:wednesday?;0;[;{;IC; "+Returns true if the date is Wednesday.;T;[o;= ;>I" overload;F;?0;;s;@0;:I"wednesday?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@n;![;"I"@return [Boolean];T;#0;$@n;.F;Bi;C0;7[;$@n;![;"I"VReturns true if the date is Wednesday. @overload wednesday? @return [Boolean];T;#0;$@n;.F;/o;0;1T;2i;3i;Bi;%@;9I"ostatic VALUE d_lite_wednesday_p(VALUE self) { get_d1(self); return f_boolcast(m_wday(dat) == 3); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#thursday?;F;7[;[[@'i;T;:thursday?;0;[;{;IC; "*Returns true if the date is Thursday.;T;[o;= ;>I" overload;F;?0;;t;@0;:I"thursday?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"TReturns true if the date is Thursday. @overload thursday? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"nstatic VALUE d_lite_thursday_p(VALUE self) { get_d1(self); return f_boolcast(m_wday(dat) == 4); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#friday?;F;7[;[[@'i;T;: friday?;0;[;{;IC; "(Returns true if the date is Friday.;T;[o;= ;>I" overload;F;?0;;u;@0;:I" friday?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"PReturns true if the date is Friday. @overload friday? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"lstatic VALUE d_lite_friday_p(VALUE self) { get_d1(self); return f_boolcast(m_wday(dat) == 5); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#saturday?;F;7[;[[@'i;T;:saturday?;0;[;{;IC; "*Returns true if the date is Saturday.;T;[o;= ;>I" overload;F;?0;;v;@0;:I"saturday?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"TReturns true if the date is Saturday. @overload saturday? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"nstatic VALUE d_lite_saturday_p(VALUE self) { get_d1(self); return f_boolcast(m_wday(dat) == 6); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#nth_kday?;F;7[[I"n;T0[I"k;T0;[[@'i;T;:nth_kday?;0;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"@;#0;$@;Bi;%@;9I"]static VALUE d_lite_nth_kday_p(VALUE self, VALUE n, VALUE k) { int rjd, ns; get_d1(self); if (NUM2INT(k) != m_wday(dat)) return Qfalse; c_nth_kday_to_jd(m_year(dat), m_mon(dat), NUM2INT(n), NUM2INT(k), m_virtual_sg(dat), /* !=m_sg() */ &rjd, &ns); if (m_local_jd(dat) != rjd) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#hour;F;7[;[[@'io$;T;: hour;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"Astatic VALUE d_lite_zero(VALUE x) { return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Date#min;F;7[;[[@'io$;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"Astatic VALUE d_lite_zero(VALUE x) { return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#minute;F;7[;[[@'io$;T;: minute;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"Astatic VALUE d_lite_zero(VALUE x) { return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Date#sec;F;7[;[[@'io$;T;:sec;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"Astatic VALUE d_lite_zero(VALUE x) { return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#second;F;7[;[[@'io$;T;: second;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"Astatic VALUE d_lite_zero(VALUE x) { return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#julian?;F;7[;[[@'iX;T;: julian?;0;[;{;IC; "Returns true if the date is before the day of calendar reform. Date.new(1582,10,15).julian? #=> false (Date.new(1582,10,15) - 1).julian? #=> true;T;[o;= ;>I" overload;F;?0;;|;@0;:I" julian?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@);![;"I"@return [Boolean];T;#0;$@);.F;Bi;C0;7[;$@);![;"I"Returns true if the date is before the day of calendar reform. Date.new(1582,10,15).julian? #=> false (Date.new(1582,10,15) - 1).julian? #=> true @overload julian? @return [Boolean];T;#0;$@);.F;/o;0;1T;2iO;3iV;Bi;%@;9I"kstatic VALUE d_lite_julian_p(VALUE self) { get_d1(self); return f_boolcast(m_julian_p(dat)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#gregorian?;F;7[;[[@'ih;T;:gregorian?;0;[;{;IC; "Returns true if the date is on or after the day of calendar reform. Date.new(1582,10,15).gregorian? #=> true (Date.new(1582,10,15) - 1).gregorian? #=> false;T;[o;= ;>I" overload;F;?0;;};@0;:I"gregorian?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@D;![;"I"@return [Boolean];T;#0;$@D;.F;Bi;C0;7[;$@D;![;"I"Returns true if the date is on or after the day of calendar reform. Date.new(1582,10,15).gregorian? #=> true (Date.new(1582,10,15) - 1).gregorian? #=> false @overload gregorian? @return [Boolean];T;#0;$@D;.F;/o;0;1T;2i_;3if;Bi;%@;9I"qstatic VALUE d_lite_gregorian_p(VALUE self) { get_d1(self); return f_boolcast(m_gregorian_p(dat)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#leap?;F;7[;[[@'ix;T;;E;0;[;{;IC; "qReturns true if the year is a leap year. Date.new(2000).leap? #=> true Date.new(2001).leap? #=> false;T;[o;= ;>I" overload;F;?0;;E;@0;:I" leap?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@_;![;"I"@return [Boolean];T;#0;$@_;.F;Bi;C0;7[;$@_;![;"I"Returns true if the year is a leap year. Date.new(2000).leap? #=> true Date.new(2001).leap? #=> false @overload leap? @return [Boolean];T;#0;$@_;.F;/o;0;1T;2io;3iv;Bi;%@;9I"Sstatic VALUE d_lite_leap_p(VALUE self) { int rjd, ns, ry, rm, rd; get_d1(self); if (m_gregorian_p(dat)) return f_boolcast(c_gregorian_leap_p(m_year(dat))); c_civil_to_jd(m_year(dat), 3, 1, m_virtual_sg(dat), &rjd, &ns); c_jd_to_civil(rjd - 1, m_virtual_sg(dat), &ry, &rm, &rd); return f_boolcast(rd == 29); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#start;F;7[;[[@'i;T;;$;0;[;{;IC; "Returns the Julian day number denoting the day of calendar reform. Date.new(2001,2,3).start #=> 2299161.0 Date.new(2001,2,3,Date::GREGORIAN).start #=> -Infinity ;T;[o;= ;>I" overload;F;?0;;$;@0;:I" start;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@z;![;"I"@return [Float];T;#0;$@z;.F;Bi;C0;7[;$@z;![;"I"Returns the Julian day number denoting the day of calendar reform. Date.new(2001,2,3).start #=> 2299161.0 Date.new(2001,2,3,Date::GREGORIAN).start #=> -Infinity @overload start @return [Float];T;#0;$@z;.F;/o;0;1T;2i;3i;%@;9I"_static VALUE d_lite_start(VALUE self) { get_d1(self); return DBL2NUM(m_sg(dat)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#new_start;F;7[[@90;[[@'i;T;:new_start;0;[;{;IC; "Duplicates self and resets its day of calendar reform. d = Date.new(1582,10,15) d.new_start(Date::JULIAN) #=> # ;T;[o;= ;>I" overload;F;?0;;~;@0;:I"#new_start([start=Date::ITALY]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" [start;TI"Date::ITALY];T;$@;![;"I"Duplicates self and resets its day of calendar reform. d = Date.new(1582,10,15) d.new_start(Date::JULIAN) #=> # @overload new_start([start=Date::ITALY]);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE d_lite_new_start(int argc, VALUE *argv, VALUE self) { VALUE vsg; double sg; rb_scan_args(argc, argv, "01", &vsg); sg = DEFAULT_SG; if (argc >= 1) val2sg(vsg, sg); return dup_obj_with_new_start(self, sg); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#italy;F;7[;[[@'i;T;: italy;0;[;{;IC; "9This method is equivalent to new_start(Date::ITALY). ;T;[o;= ;>I" overload;F;?0;;;@0;:I" italy;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"KThis method is equivalent to new_start(Date::ITALY). @overload italy;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"^static VALUE d_lite_italy(VALUE self) { return dup_obj_with_new_start(self, ITALY); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#england;F;7[;[[@'i;T;: england;0;[;{;IC; ";This method is equivalent to new_start(Date::ENGLAND). ;T;[o;= ;>I" overload;F;?0;;;@0;:I" england;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"OThis method is equivalent to new_start(Date::ENGLAND). @overload england;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"bstatic VALUE d_lite_england(VALUE self) { return dup_obj_with_new_start(self, ENGLAND); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#julian;F;7[;[[@'i;T;: julian;0;[;{;IC; ":This method is equivalent to new_start(Date::JULIAN). ;T;[o;= ;>I" overload;F;?0;;;@0;:I" julian;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"MThis method is equivalent to new_start(Date::JULIAN). @overload julian;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"`static VALUE d_lite_julian(VALUE self) { return dup_obj_with_new_start(self, JULIAN); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#gregorian;F;7[;[[@'i;T;:gregorian;0;[;{;IC; "=This method is equivalent to new_start(Date::GREGORIAN). ;T;[o;= ;>I" overload;F;?0;;;@0;:I"gregorian;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"SThis method is equivalent to new_start(Date::GREGORIAN). @overload gregorian;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"fstatic VALUE d_lite_gregorian(VALUE self) { return dup_obj_with_new_start(self, GREGORIAN); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Date#+;F;7[[I" other;T0;[[@'iS;T;;;0;[;{;IC; "Returns a date object pointing +other+ days after self. The other should be a numeric value. If the other is a fractional number, assumes its precision is at most nanosecond. Date.new(2001,2,3) + 1 #=> # DateTime.new(2001,2,3) + Rational(1,2) #=> # DateTime.new(2001,2,3) + Rational(-1,2) #=> # DateTime.jd(0,12) + DateTime.new(2001,2,3).ajd #=> # ;T;[o;= ;>I" overload;F;?0;;;@0;:I" +(other);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" other;T0;$@;![;"I"Returns a date object pointing +other+ days after self. The other should be a numeric value. If the other is a fractional number, assumes its precision is at most nanosecond. Date.new(2001,2,3) + 1 #=> # DateTime.new(2001,2,3) + Rational(1,2) #=> # DateTime.new(2001,2,3) + Rational(-1,2) #=> # DateTime.jd(0,12) + DateTime.new(2001,2,3).ajd #=> # @overload +(other);T;#0;$@;.F;/o;0;1T;2iC;3iP;%@;9I"static VALUE d_lite_plus(VALUE self, VALUE other) { int try_rational = 1; get_d1(self); again: switch (TYPE(other)) { case T_FIXNUM: { VALUE nth; long t; int jd; nth = m_nth(dat); t = FIX2LONG(other); if (DIV(t, CM_PERIOD)) { nth = f_add(nth, INT2FIX(DIV(t, CM_PERIOD))); t = MOD(t, CM_PERIOD); } if (!t) jd = m_jd(dat); else { jd = m_jd(dat) + (int)t; canonicalize_jd(nth, jd); } if (simple_dat_p(dat)) return d_simple_new_internal(rb_obj_class(self), nth, jd, dat->s.sg, 0, 0, 0, (dat->s.flags | HAVE_JD) & ~HAVE_CIVIL); else return d_complex_new_internal(rb_obj_class(self), nth, jd, dat->c.df, dat->c.sf, dat->c.of, dat->c.sg, 0, 0, 0, #ifndef USE_PACK dat->c.hour, dat->c.min, dat->c.sec, #else EX_HOUR(dat->c.pc), EX_MIN(dat->c.pc), EX_SEC(dat->c.pc), #endif (dat->c.flags | HAVE_JD) & ~HAVE_CIVIL); } break; case T_BIGNUM: { VALUE nth; int jd, s; if (f_positive_p(other)) s = +1; else { s = -1; other = f_negate(other); } nth = f_idiv(other, INT2FIX(CM_PERIOD)); jd = FIX2INT(f_mod(other, INT2FIX(CM_PERIOD))); if (s < 0) { nth = f_negate(nth); jd = -jd; } if (!jd) jd = m_jd(dat); else { jd = m_jd(dat) + jd; canonicalize_jd(nth, jd); } if (f_zero_p(nth)) nth = m_nth(dat); else nth = f_add(m_nth(dat), nth); if (simple_dat_p(dat)) return d_simple_new_internal(rb_obj_class(self), nth, jd, dat->s.sg, 0, 0, 0, (dat->s.flags | HAVE_JD) & ~HAVE_CIVIL); else return d_complex_new_internal(rb_obj_class(self), nth, jd, dat->c.df, dat->c.sf, dat->c.of, dat->c.sg, 0, 0, 0, #ifndef USE_PACK dat->c.hour, dat->c.min, dat->c.sec, #else EX_HOUR(dat->c.pc), EX_MIN(dat->c.pc), EX_SEC(dat->c.pc), #endif (dat->c.flags | HAVE_JD) & ~HAVE_CIVIL); } break; case T_FLOAT: { double jd, o, tmp; int s, df; VALUE nth, sf; o = RFLOAT_VALUE(other); if (o > 0) s = +1; else { s = -1; o = -o; } o = modf(o, &tmp); if (!floor(tmp / CM_PERIOD)) { nth = INT2FIX(0); jd = (int)tmp; } else { double i, f; f = modf(tmp / CM_PERIOD, &i); nth = f_floor(DBL2NUM(i)); jd = (int)(f * CM_PERIOD); } o *= DAY_IN_SECONDS; o = modf(o, &tmp); df = (int)tmp; o *= SECOND_IN_NANOSECONDS; sf = INT2FIX((int)round(o)); if (s < 0) { jd = -jd; df = -df; sf = f_negate(sf); } if (f_zero_p(sf)) sf = m_sf(dat); else { sf = f_add(m_sf(dat), sf); if (f_lt_p(sf, INT2FIX(0))) { df -= 1; sf = f_add(sf, INT2FIX(SECOND_IN_NANOSECONDS)); } else if (f_ge_p(sf, INT2FIX(SECOND_IN_NANOSECONDS))) { df += 1; sf = f_sub(sf, INT2FIX(SECOND_IN_NANOSECONDS)); } } if (!df) df = m_df(dat); else { df = m_df(dat) + df; if (df < 0) { jd -= 1; df += DAY_IN_SECONDS; } else if (df >= DAY_IN_SECONDS) { jd += 1; df -= DAY_IN_SECONDS; } } if (!jd) jd = m_jd(dat); else { jd = m_jd(dat) + jd; canonicalize_jd(nth, jd); } if (f_zero_p(nth)) nth = m_nth(dat); else nth = f_add(m_nth(dat), nth); if (!df && f_zero_p(sf) && !m_of(dat)) return d_simple_new_internal(rb_obj_class(self), nth, (int)jd, m_sg(dat), 0, 0, 0, (dat->s.flags | HAVE_JD) & ~(HAVE_CIVIL | HAVE_TIME | COMPLEX_DAT)); else return d_complex_new_internal(rb_obj_class(self), nth, (int)jd, df, sf, m_of(dat), m_sg(dat), 0, 0, 0, 0, 0, 0, (dat->c.flags | HAVE_JD | HAVE_DF) & ~(HAVE_CIVIL | HAVE_TIME)); } break; default: expect_numeric(other); other = f_to_r(other); if (!k_rational_p(other)) { if (!try_rational) Check_Type(other, T_RATIONAL); try_rational = 0; goto again; } /* fall through */ case T_RATIONAL: { VALUE nth, sf, t; int jd, df, s; if (wholenum_p(other)) { other = rb_rational_num(other); goto again; } if (f_positive_p(other)) s = +1; else { s = -1; other = f_negate(other); } nth = f_idiv(other, INT2FIX(CM_PERIOD)); t = f_mod(other, INT2FIX(CM_PERIOD)); jd = FIX2INT(f_idiv(t, INT2FIX(1))); t = f_mod(t, INT2FIX(1)); t = f_mul(t, INT2FIX(DAY_IN_SECONDS)); df = FIX2INT(f_idiv(t, INT2FIX(1))); t = f_mod(t, INT2FIX(1)); sf = f_mul(t, INT2FIX(SECOND_IN_NANOSECONDS)); if (s < 0) { nth = f_negate(nth); jd = -jd; df = -df; sf = f_negate(sf); } if (f_zero_p(sf)) sf = m_sf(dat); else { sf = f_add(m_sf(dat), sf); if (f_lt_p(sf, INT2FIX(0))) { df -= 1; sf = f_add(sf, INT2FIX(SECOND_IN_NANOSECONDS)); } else if (f_ge_p(sf, INT2FIX(SECOND_IN_NANOSECONDS))) { df += 1; sf = f_sub(sf, INT2FIX(SECOND_IN_NANOSECONDS)); } } if (!df) df = m_df(dat); else { df = m_df(dat) + df; if (df < 0) { jd -= 1; df += DAY_IN_SECONDS; } else if (df >= DAY_IN_SECONDS) { jd += 1; df -= DAY_IN_SECONDS; } } if (!jd) jd = m_jd(dat); else { jd = m_jd(dat) + jd; canonicalize_jd(nth, jd); } if (f_zero_p(nth)) nth = m_nth(dat); else nth = f_add(m_nth(dat), nth); if (!df && f_zero_p(sf) && !m_of(dat)) return d_simple_new_internal(rb_obj_class(self), nth, jd, m_sg(dat), 0, 0, 0, (dat->s.flags | HAVE_JD) & ~(HAVE_CIVIL | HAVE_TIME | COMPLEX_DAT)); else return d_complex_new_internal(rb_obj_class(self), nth, jd, df, sf, m_of(dat), m_sg(dat), 0, 0, 0, 0, 0, 0, (dat->c.flags | HAVE_JD | HAVE_DF) & ~(HAVE_CIVIL | HAVE_TIME)); } break; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Date#-;F;7[[I" other;T0;[[@'i;T;;;0;[;{;IC; "Returns the difference between the two dates if the other is a date object. If the other is a numeric value, returns a date object pointing +other+ days before self. If the other is a fractional number, assumes its precision is at most nanosecond. Date.new(2001,2,3) - 1 #=> # DateTime.new(2001,2,3) - Rational(1,2) #=> # Date.new(2001,2,3) - Date.new(2001) #=> (33/1) DateTime.new(2001,2,3) - DateTime.new(2001,2,2,12) #=> (1/2) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" -(other);T;IC; ";T;[;![;"I";T;#0;$@!;.F;Bi;C0;7[[I" other;T0;$@!;![;"I"Returns the difference between the two dates if the other is a date object. If the other is a numeric value, returns a date object pointing +other+ days before self. If the other is a fractional number, assumes its precision is at most nanosecond. Date.new(2001,2,3) - 1 #=> # DateTime.new(2001,2,3) - Rational(1,2) #=> # Date.new(2001,2,3) - Date.new(2001) #=> (33/1) DateTime.new(2001,2,3) - DateTime.new(2001,2,2,12) #=> (1/2) @overload -(other);T;#0;$@!;.F;/o;0;1T;2i;3i;%@;9I"static VALUE d_lite_minus(VALUE self, VALUE other) { if (k_date_p(other)) return minus_dd(self, other); switch (TYPE(other)) { case T_FIXNUM: return d_lite_plus(self, LONG2NUM(-FIX2LONG(other))); case T_FLOAT: return d_lite_plus(self, DBL2NUM(-RFLOAT_VALUE(other))); default: expect_numeric(other); /* fall through */ case T_BIGNUM: case T_RATIONAL: return d_lite_plus(self, f_negate(other)); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#next_day;F;7[[@90;[[@'i;T;: next_day;0;[;{;IC; "(This method is equivalent to d + n. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"next_day([n=1]);T;IC; ";T;[;![;"I";T;#0;$@;;.F;Bi;C0;7[[I"[n;TI"1];T;$@;;![;"I"DThis method is equivalent to d + n. @overload next_day([n=1]);T;#0;$@;;.F;/o;0;1T;2i;3i;%@;9I"static VALUE d_lite_next_day(int argc, VALUE *argv, VALUE self) { VALUE n; rb_scan_args(argc, argv, "01", &n); if (argc < 1) n = INT2FIX(1); return d_lite_plus(self, n); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#prev_day;F;7[[@90;[[@'i;T;: prev_day;0;[;{;IC; "(This method is equivalent to d - n. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"prev_day([n=1]);T;IC; ";T;[;![;"I";T;#0;$@U;.F;Bi;C0;7[[I"[n;TI"1];T;$@U;![;"I"DThis method is equivalent to d - n. @overload prev_day([n=1]);T;#0;$@U;.F;/o;0;1T;2i;3i;%@;9I"static VALUE d_lite_prev_day(int argc, VALUE *argv, VALUE self) { VALUE n; rb_scan_args(argc, argv, "01", &n); if (argc < 1) n = INT2FIX(1); return d_lite_minus(self, n); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#next;F;7[;[[@'i;T;: next;0;[;{;IC; "6Returns a date object denoting the following day. ;T;[o;= ;>I" overload;F;?0;: succ;@0;:I" succ;T;IC; ";T;[;![;"I";T;#0;$@o;.F;Bi;C0;7[;$@oo;= ;>I" overload;F;?0;;;@0;:I" next;T;IC; ";T;[;![;"I";T;#0;$@o;.F;Bi;C0;7[;$@o;![;"I"VReturns a date object denoting the following day. @overload succ @overload next;T;#0;$@o;.F;/o;0;1T;2i;3i;%@;9I"astatic VALUE d_lite_next(VALUE self) { return d_lite_next_day(0, (VALUE *)NULL, self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#succ;F;7[;[[@'i;T;;;0;[;{;IC; "6Returns a date object denoting the following day. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" succ;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" next;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"astatic VALUE d_lite_next(VALUE self) { return d_lite_next_day(0, (VALUE *)NULL, self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Date#>>;F;7[[I" other;T0;[[@'i2;T;;;0;[;{;IC; "Returns a date object pointing +n+ months after self. The argument +n+ should be a numeric value. Date.new(2001,2,3) >> 1 #=> # Date.new(2001,2,3) >> -2 #=> # When the same day does not exist for the corresponding month, the last day of the month is used instead: Date.new(2001,1,28) >> 1 #=> # Date.new(2001,1,31) >> 1 #=> # This also results in the following, possibly unexpected, behavior: Date.new(2001,1,31) >> 2 #=> # Date.new(2001,1,31) >> 1 >> 1 #=> # Date.new(2001,1,31) >> 1 >> -1 #=> # ;T;[o;= ;>I" overload;F;?0;;;@0;:I" >>(n);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"n;T0;$@;![;"I"Returns a date object pointing +n+ months after self. The argument +n+ should be a numeric value. Date.new(2001,2,3) >> 1 #=> # Date.new(2001,2,3) >> -2 #=> # When the same day does not exist for the corresponding month, the last day of the month is used instead: Date.new(2001,1,28) >> 1 #=> # Date.new(2001,1,31) >> 1 #=> # This also results in the following, possibly unexpected, behavior: Date.new(2001,1,31) >> 2 #=> # Date.new(2001,1,31) >> 1 >> 1 #=> # Date.new(2001,1,31) >> 1 >> -1 #=> # @overload >>(n);T;#0;$@;.F;/o;0;1T;2i;3i/;%@;9I" static VALUE d_lite_rshift(VALUE self, VALUE other) { VALUE t, y, nth, rjd2; int m, d, rjd; double sg; get_d1(self); t = f_add3(f_mul(m_real_year(dat), INT2FIX(12)), INT2FIX(m_mon(dat) - 1), other); if (FIXNUM_P(t)) { long it = FIX2LONG(t); y = LONG2NUM(DIV(it, 12)); it = MOD(it, 12); m = (int)it + 1; } else { y = f_idiv(t, INT2FIX(12)); t = f_mod(t, INT2FIX(12)); m = FIX2INT(t) + 1; } d = m_mday(dat); sg = m_sg(dat); while (1) { int ry, rm, rd, ns; if (valid_civil_p(y, m, d, sg, &nth, &ry, &rm, &rd, &rjd, &ns)) break; if (--d < 1) rb_raise(eDateError, "invalid date"); } encode_jd(nth, rjd, &rjd2); return d_lite_plus(self, f_sub(rjd2, m_real_local_jd(dat))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Date#<<;F;7[[I" other;T0;[[@'ip;T;;;0;[;{;IC; "Returns a date object pointing +n+ months before self. The argument +n+ should be a numeric value. Date.new(2001,2,3) << 1 #=> # Date.new(2001,2,3) << -2 #=> # When the same day does not exist for the corresponding month, the last day of the month is used instead: Date.new(2001,3,28) << 1 #=> # Date.new(2001,3,31) << 1 #=> # This also results in the following, possibly unexpected, behavior: Date.new(2001,3,31) << 2 #=> # Date.new(2001,3,31) << 1 << 1 #=> # Date.new(2001,3,31) << 1 << -1 #=> # ;T;[o;= ;>I" overload;F;?0;;;@0;:I" <<(n);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"n;T0;$@;![;"I"Returns a date object pointing +n+ months before self. The argument +n+ should be a numeric value. Date.new(2001,2,3) << 1 #=> # Date.new(2001,2,3) << -2 #=> # When the same day does not exist for the corresponding month, the last day of the month is used instead: Date.new(2001,3,28) << 1 #=> # Date.new(2001,3,31) << 1 #=> # This also results in the following, possibly unexpected, behavior: Date.new(2001,3,31) << 2 #=> # Date.new(2001,3,31) << 1 << 1 #=> # Date.new(2001,3,31) << 1 << -1 #=> # @overload <<(n);T;#0;$@;.F;/o;0;1T;2iY;3im;%@;9I"static VALUE d_lite_lshift(VALUE self, VALUE other) { expect_numeric(other); return d_lite_rshift(self, f_negate(other)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#next_month;F;7[[@90;[[@'i;T;:next_month;0;[;{;IC; "DThis method is equivalent to d >> n. See Date#>> for examples. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"next_month([n=1]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"[n;TI"1];T;$@;![;"I"bThis method is equivalent to d >> n. See Date#>> for examples. @overload next_month([n=1]);T;#0;$@;.F;/o;0;1T;2iw;3i|;%@;9I"static VALUE d_lite_next_month(int argc, VALUE *argv, VALUE self) { VALUE n; rb_scan_args(argc, argv, "01", &n); if (argc < 1) n = INT2FIX(1); return d_lite_rshift(self, n); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#prev_month;F;7[[@90;[[@'i;T;:prev_month;0;[;{;IC; "DThis method is equivalent to d << n. See Date#<< for examples. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"prev_month([n=1]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"[n;TI"1];T;$@;![;"I"bThis method is equivalent to d << n. See Date#<< for examples. @overload prev_month([n=1]);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE d_lite_prev_month(int argc, VALUE *argv, VALUE self) { VALUE n; rb_scan_args(argc, argv, "01", &n); if (argc < 1) n = INT2FIX(1); return d_lite_lshift(self, n); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#next_year;F;7[[@90;[[@'i;T;:next_year;0;[;{;IC; "This method is equivalent to d >> (n * 12). Date.new(2001,2,3).next_year #=> # Date.new(2008,2,29).next_year #=> # Date.new(2008,2,29).next_year(4) #=> # See also Date#>>. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"next_year([n=1]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"[n;TI"1];T;$@;![;"I"This method is equivalent to d >> (n * 12). Date.new(2001,2,3).next_year #=> # Date.new(2008,2,29).next_year #=> # Date.new(2008,2,29).next_year(4) #=> # See also Date#>>. @overload next_year([n=1]);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE d_lite_next_year(int argc, VALUE *argv, VALUE self) { VALUE n; rb_scan_args(argc, argv, "01", &n); if (argc < 1) n = INT2FIX(1); return d_lite_rshift(self, f_mul(n, INT2FIX(12))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#prev_year;F;7[[@90;[[@'i;T;:prev_year;0;[;{;IC; "This method is equivalent to d << (n * 12). Date.new(2001,2,3).prev_year #=> # Date.new(2008,2,29).prev_year #=> # Date.new(2008,2,29).prev_year(4) #=> # See also Date#<<. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"prev_year([n=1]);T;IC; ";T;[;![;"I";T;#0;$@,;.F;Bi;C0;7[[I"[n;TI"1];T;$@,;![;"I"This method is equivalent to d << (n * 12). Date.new(2001,2,3).prev_year #=> # Date.new(2008,2,29).prev_year #=> # Date.new(2008,2,29).prev_year(4) #=> # See also Date#<<. @overload prev_year([n=1]);T;#0;$@,;.F;/o;0;1T;2i;3i;%@;9I"static VALUE d_lite_prev_year(int argc, VALUE *argv, VALUE self) { VALUE n; rb_scan_args(argc, argv, "01", &n); if (argc < 1) n = INT2FIX(1); return d_lite_lshift(self, f_mul(n, INT2FIX(12))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#step;F;7[[@90;[[@'i;T;: step;0;[;{;IC; "Iterates evaluation of the given block, which takes a date object. The limit should be a date object. Date.new(2001).step(Date.new(2001,-1,-1)).select{|d| d.sunday?}.size #=> 52 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"step(limit[, step=1]);T;IC; ";T;[;![;"I";T;#0;$@F;.F;Bi;C0;7[[I"limit[, step;TI"1];T;$@Fo;= ;>I" overload;F;?0;;;@0;:I"step(limit[, step=1]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" date;T;$@Fo;A ;>I" return;F;?I";T;0;@[I" self;T;$@F;![;"I"!@yield [date] @return [self];T;#0;$@F;.F;Bi;C0;7[[I"limit[, step;TI"1];T;$@F;![;"I"Iterates evaluation of the given block, which takes a date object. The limit should be a date object. Date.new(2001).step(Date.new(2001,-1,-1)).select{|d| d.sunday?}.size #=> 52 @overload step(limit[, step=1]) @overload step(limit[, step=1]) @yield [date] @return [self];T;#0;$@F;.F;/o;0;1T;2i;3i;%@;9I"static VALUE d_lite_step(int argc, VALUE *argv, VALUE self) { VALUE limit, step, date; int c; rb_scan_args(argc, argv, "11", &limit, &step); if (argc < 2) step = INT2FIX(1); #if 0 if (f_zero_p(step)) rb_raise(rb_eArgError, "step can't be 0"); #endif RETURN_ENUMERATOR(self, argc, argv); date = self; c = f_cmp(step, INT2FIX(0)); if (c < 0) { while (FIX2INT(d_lite_cmp(date, limit)) >= 0) { rb_yield(date); date = d_lite_plus(date, step); } } else if (c == 0) { while (1) rb_yield(date); } else /* if (c > 0) */ { while (FIX2INT(d_lite_cmp(date, limit)) <= 0) { rb_yield(date); date = d_lite_plus(date, step); } } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#upto;F;7[[I"max;T0;[[@'i;T;: upto;0;[;{;IC; ";This method is equivalent to step(max, 1){|date| ...}. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"upto(max);T;IC; ";T;[;![;"I";T;#0;$@u;.F;Bi;C0;7[[I"max;T0;$@uo;= ;>I" overload;F;?0;;;@0;:I"upto(max);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" date;T;$@uo;A ;>I" return;F;?I";T;0;@[I" self;T;$@u;![;"I"!@yield [date] @return [self];T;#0;$@u;.F;Bi;C0;7[[I"max;T0;$@u;![;"I"This method is equivalent to step(max, 1){|date| ...}. @overload upto(max) @overload upto(max) @yield [date] @return [self];T;#0;$@u;.F;/o;0;1T;2i;3i;%@;9I"static VALUE d_lite_upto(VALUE self, VALUE max) { VALUE date; RETURN_ENUMERATOR(self, 1, &max); date = self; while (FIX2INT(d_lite_cmp(date, max)) <= 0) { rb_yield(date); date = d_lite_plus(date, INT2FIX(1)); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#downto;F;7[[I"min;T0;[[@'i;T;: downto;0;[;{;IC; "I" overload;F;?0;;;@0;:I"downto(min);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"min;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"downto(min);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" date;T;$@o;A ;>I" return;F;?I";T;0;@[I" self;T;$@;![;"I"!@yield [date] @return [self];T;#0;$@;.F;Bi;C0;7[[I"min;T0;$@;![;"I"This method is equivalent to step(min, -1){|date| ...}. @overload downto(min) @overload downto(min) @yield [date] @return [self];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE d_lite_downto(VALUE self, VALUE min) { VALUE date; RETURN_ENUMERATOR(self, 1, &min); date = self; while (FIX2INT(d_lite_cmp(date, min)) >= 0) { rb_yield(date); date = d_lite_plus(date, INT2FIX(-1)); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Date#<=>;F;7[[I" other;T0;[[@'i;T;;Y;0;[;{;IC; "Compares the two dates and returns -1, zero, 1 or nil. The other should be a date object or a numeric value as an astronomical Julian day number. Date.new(2001,2,3) <=> Date.new(2001,2,4) #=> -1 Date.new(2001,2,3) <=> Date.new(2001,2,3) #=> 0 Date.new(2001,2,3) <=> Date.new(2001,2,2) #=> 1 Date.new(2001,2,3) <=> Object.new #=> nil Date.new(2001,2,3) <=> Rational(4903887,2) #=> 0 See also Comparable. ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I"<=>(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[ I"-1;TI"0;TI"+1;TI"nil;T;$@;![;"I"@return [-1, 0, +1, nil];T;#0;$@;.F;Bi;C0;7[[I" other;T0;$@;![;"I"Compares the two dates and returns -1, zero, 1 or nil. The other should be a date object or a numeric value as an astronomical Julian day number. Date.new(2001,2,3) <=> Date.new(2001,2,4) #=> -1 Date.new(2001,2,3) <=> Date.new(2001,2,3) #=> 0 Date.new(2001,2,3) <=> Date.new(2001,2,2) #=> 1 Date.new(2001,2,3) <=> Object.new #=> nil Date.new(2001,2,3) <=> Rational(4903887,2) #=> 0 See also Comparable. @overload <=>(other) @return [-1, 0, +1, nil];T;#0;$@;.F;/o;0;1T;2ip;3i~;%@;9I"static VALUE d_lite_cmp(VALUE self, VALUE other) { if (!k_date_p(other)) return cmp_gen(self, other); { get_d2(self, other); if (!(simple_dat_p(adat) && simple_dat_p(bdat) && m_gregorian_p(adat) == m_gregorian_p(bdat))) return cmp_dd(self, other); { VALUE a_nth, b_nth; int a_jd, b_jd; m_canonicalize_jd(self, adat); m_canonicalize_jd(other, bdat); a_nth = m_nth(adat); b_nth = m_nth(bdat); if (f_eqeq_p(a_nth, b_nth)) { a_jd = m_jd(adat); b_jd = m_jd(bdat); if (a_jd == b_jd) { return INT2FIX(0); } else if (a_jd < b_jd) { return INT2FIX(-1); } else { return INT2FIX(1); } } else if (f_lt_p(a_nth, b_nth)) { return INT2FIX(-1); } else { return INT2FIX(1); } } } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Date#===;F;7[[I" other;T0;[[@'i;T;;S;0;[;{;IC; "Returns true if they are the same day. Date.new(2001,2,3) === Date.new(2001,2,3) #=> true Date.new(2001,2,3) === Date.new(2001,2,4) #=> false DateTime.new(2001,2,3) === DateTime.new(2001,2,3,12) #=> true DateTime.new(2001,2,3) === DateTime.new(2001,2,3,0,0,0,'+24:00') #=> true DateTime.new(2001,2,3) === DateTime.new(2001,2,4,0,0,0,'+24:00') #=> false ;T;[o;= ;>I" overload;F;?0;;S;@0;:I"===(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" other;T0;$@;![;"I"Returns true if they are the same day. Date.new(2001,2,3) === Date.new(2001,2,3) #=> true Date.new(2001,2,3) === Date.new(2001,2,4) #=> false DateTime.new(2001,2,3) === DateTime.new(2001,2,3,12) #=> true DateTime.new(2001,2,3) === DateTime.new(2001,2,3,0,0,0,'+24:00') #=> true DateTime.new(2001,2,3) === DateTime.new(2001,2,4,0,0,0,'+24:00') #=> false @overload ===(other) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"2static VALUE d_lite_equal(VALUE self, VALUE other) { if (!k_date_p(other)) return equal_gen(self, other); { get_d2(self, other); if (!(m_gregorian_p(adat) == m_gregorian_p(bdat))) return equal_gen(self, other); { VALUE a_nth, b_nth; int a_jd, b_jd; m_canonicalize_jd(self, adat); m_canonicalize_jd(other, bdat); a_nth = m_nth(adat); b_nth = m_nth(bdat); a_jd = m_local_jd(adat); b_jd = m_local_jd(bdat); if (f_eqeq_p(a_nth, b_nth) && a_jd == b_jd) return Qtrue; return Qfalse; } } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#eql?;F;7[[I" other;T0;[[@'i;T;;V;0;[;{;IC; " :nodoc:;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE d_lite_eql_p(VALUE self, VALUE other) { if (!k_date_p(other)) return Qfalse; return f_zero_p(d_lite_cmp(self, other)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#hash;F;7[;[[@'i;T;;X;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@%;.F;/o;0;1T;2i;3i;%@;9I"static VALUE d_lite_hash(VALUE self) { st_index_t v, h[4]; get_d1(self); h[0] = m_nth(dat); h[1] = m_jd(dat); h[2] = m_df(dat); h[3] = m_sf(dat); v = rb_memhash(h, sizeof(h)); return ST2FIX(v); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#to_s;F;7[;[[@'i ;T;;G;0;[;{;IC; "Returns a string in an ISO 8601 format. (This method doesn't use the expanded representations.) Date.new(2001,2,3).to_s #=> "2001-02-03" ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@3;![;"I"@return [String];T;#0;$@3;.F;Bi;C0;7[;$@3;![;"I"Returns a string in an ISO 8601 format. (This method doesn't use the expanded representations.) Date.new(2001,2,3).to_s #=> "2001-02-03" @overload to_s @return [String];T;#0;$@3;.F;/o;0;1T;2i;3i ;%@;9I"^static VALUE d_lite_to_s(VALUE self) { return strftimev("%Y-%m-%d", self, set_tmx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#inspect_raw;F;7[;[[@'iE;T;:inspect_raw;0;[;{;IC; " ;T;[;![;"@;#0;$@N;%@;9I"zstatic VALUE d_lite_inspect_raw(VALUE self) { get_d1(self); return mk_inspect_raw(dat, rb_obj_class(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#inspect;F;7[;[[@'ic;T;;J;0;[;{;IC; "Returns the value as a string for inspection. Date.new(2001,2,3).inspect #=> "#" DateTime.new(2001,2,3,4,5,6,'-7').inspect #=> "#" ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@Z;![;"I"@return [String];T;#0;$@Z;.F;Bi;C0;7[;$@Z;![;"I"Returns the value as a string for inspection. Date.new(2001,2,3).inspect #=> "#" DateTime.new(2001,2,3,4,5,6,'-7').inspect #=> "#" @overload inspect @return [String];T;#0;$@Z;.F;/o;0;1T;2iX;3ia;%@;9I"xstatic VALUE d_lite_inspect(VALUE self) { get_d1(self); return mk_inspect(dat, rb_obj_class(self), self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#strftime;F;7[[@90;[[@'i;T;: strftime;0;[;{;IC; ", Formats date according to the directives in the given format string. The directives begin with a percent (%) character. Any text not listed as a directive will be passed through to the output string. A directive consists of a percent (%) character, zero or more flags, an optional minimum field width, an optional modifier, and a conversion specifier as follows. % Flags: - don't pad a numerical output. _ use spaces for padding. 0 use zeros for padding. ^ upcase the result string. # change case. The minimum field width specifies the minimum width. The modifiers are "E", "O", ":", "::" and ":::". "E" and "O" are ignored. No effect to result currently. Format directives: Date (Year, Month, Day): %Y - Year with century (can be negative, 4 digits at least) -0001, 0000, 1995, 2009, 14292, etc. %C - year / 100 (round down. 20 in 2009) %y - year % 100 (00..99) %m - Month of the year, zero-padded (01..12) %_m blank-padded ( 1..12) %-m no-padded (1..12) %B - The full month name (``January'') %^B uppercased (``JANUARY'') %b - The abbreviated month name (``Jan'') %^b uppercased (``JAN'') %h - Equivalent to %b %d - Day of the month, zero-padded (01..31) %-d no-padded (1..31) %e - Day of the month, blank-padded ( 1..31) %j - Day of the year (001..366) Time (Hour, Minute, Second, Subsecond): %H - Hour of the day, 24-hour clock, zero-padded (00..23) %k - Hour of the day, 24-hour clock, blank-padded ( 0..23) %I - Hour of the day, 12-hour clock, zero-padded (01..12) %l - Hour of the day, 12-hour clock, blank-padded ( 1..12) %P - Meridian indicator, lowercase (``am'' or ``pm'') %p - Meridian indicator, uppercase (``AM'' or ``PM'') %M - Minute of the hour (00..59) %S - Second of the minute (00..60) %L - Millisecond of the second (000..999) %N - Fractional seconds digits, default is 9 digits (nanosecond) %3N millisecond (3 digits) %15N femtosecond (15 digits) %6N microsecond (6 digits) %18N attosecond (18 digits) %9N nanosecond (9 digits) %21N zeptosecond (21 digits) %12N picosecond (12 digits) %24N yoctosecond (24 digits) Time zone: %z - Time zone as hour and minute offset from UTC (e.g. +0900) %:z - hour and minute offset from UTC with a colon (e.g. +09:00) %::z - hour, minute and second offset from UTC (e.g. +09:00:00) %:::z - hour, minute and second offset from UTC (e.g. +09, +09:30, +09:30:30) %Z - Equivalent to %:z (e.g. +09:00) Weekday: %A - The full weekday name (``Sunday'') %^A uppercased (``SUNDAY'') %a - The abbreviated name (``Sun'') %^a uppercased (``SUN'') %u - Day of the week (Monday is 1, 1..7) %w - Day of the week (Sunday is 0, 0..6) ISO 8601 week-based year and week number: The week 1 of YYYY starts with a Monday and includes YYYY-01-04. The days in the year before the first week are in the last week of the previous year. %G - The week-based year %g - The last 2 digits of the week-based year (00..99) %V - Week number of the week-based year (01..53) Week number: The week 1 of YYYY starts with a Sunday or Monday (according to %U or %W). The days in the year before the first week are in week 0. %U - Week number of the year. The week starts with Sunday. (00..53) %W - Week number of the year. The week starts with Monday. (00..53) Seconds since the Unix Epoch: %s - Number of seconds since 1970-01-01 00:00:00 UTC. %Q - Number of milliseconds since 1970-01-01 00:00:00 UTC. Literal string: %n - Newline character (\n) %t - Tab character (\t) %% - Literal ``%'' character Combination: %c - date and time (%a %b %e %T %Y) %D - Date (%m/%d/%y) %F - The ISO 8601 date format (%Y-%m-%d) %v - VMS date (%e-%^b-%Y) %x - Same as %D %X - Same as %T %r - 12-hour time (%I:%M:%S %p) %R - 24-hour time (%H:%M) %T - 24-hour time (%H:%M:%S) %+ - date(1) (%a %b %e %H:%M:%S %Z %Y) This method is similar to the strftime() function defined in ISO C and POSIX. Several directives (%a, %A, %b, %B, %c, %p, %r, %x, %X, %E*, %O* and %Z) are locale dependent in the function. However, this method is locale independent. So, the result may differ even if the same format string is used in other systems such as C. It is good practice to avoid %x and %X because there are corresponding locale independent representations, %D and %T. Examples: d = DateTime.new(2007,11,19,8,37,48,"-06:00") #=> # d.strftime("Printed on %m/%d/%Y") #=> "Printed on 11/19/2007" d.strftime("at %I:%M%p") #=> "at 08:37AM" Various ISO 8601 formats: %Y%m%d => 20071119 Calendar date (basic) %F => 2007-11-19 Calendar date (extended) %Y-%m => 2007-11 Calendar date, reduced accuracy, specific month %Y => 2007 Calendar date, reduced accuracy, specific year %C => 20 Calendar date, reduced accuracy, specific century %Y%j => 2007323 Ordinal date (basic) %Y-%j => 2007-323 Ordinal date (extended) %GW%V%u => 2007W471 Week date (basic) %G-W%V-%u => 2007-W47-1 Week date (extended) %GW%V => 2007W47 Week date, reduced accuracy, specific week (basic) %G-W%V => 2007-W47 Week date, reduced accuracy, specific week (extended) %H%M%S => 083748 Local time (basic) %T => 08:37:48 Local time (extended) %H%M => 0837 Local time, reduced accuracy, specific minute (basic) %H:%M => 08:37 Local time, reduced accuracy, specific minute (extended) %H => 08 Local time, reduced accuracy, specific hour %H%M%S,%L => 083748,000 Local time with decimal fraction, comma as decimal sign (basic) %T,%L => 08:37:48,000 Local time with decimal fraction, comma as decimal sign (extended) %H%M%S.%L => 083748.000 Local time with decimal fraction, full stop as decimal sign (basic) %T.%L => 08:37:48.000 Local time with decimal fraction, full stop as decimal sign (extended) %H%M%S%z => 083748-0600 Local time and the difference from UTC (basic) %T%:z => 08:37:48-06:00 Local time and the difference from UTC (extended) %Y%m%dT%H%M%S%z => 20071119T083748-0600 Date and time of day for calendar date (basic) %FT%T%:z => 2007-11-19T08:37:48-06:00 Date and time of day for calendar date (extended) %Y%jT%H%M%S%z => 2007323T083748-0600 Date and time of day for ordinal date (basic) %Y-%jT%T%:z => 2007-323T08:37:48-06:00 Date and time of day for ordinal date (extended) %GW%V%uT%H%M%S%z => 2007W471T083748-0600 Date and time of day for week date (basic) %G-W%V-%uT%T%:z => 2007-W47-1T08:37:48-06:00 Date and time of day for week date (extended) %Y%m%dT%H%M => 20071119T0837 Calendar date and local time (basic) %FT%R => 2007-11-19T08:37 Calendar date and local time (extended) %Y%jT%H%MZ => 2007323T0837Z Ordinal date and UTC of day (basic) %Y-%jT%RZ => 2007-323T08:37Z Ordinal date and UTC of day (extended) %GW%V%uT%H%M%z => 2007W471T0837-0600 Week date and local time and difference from UTC (basic) %G-W%V-%uT%R%:z => 2007-W47-1T08:37-06:00 Week date and local time and difference from UTC (extended) See also strftime(3) and ::strptime. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"strftime([format='%F']);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@u;![;"I"@return [String];T;#0;$@u;.F;Bi;C0;7[[I" [format;TI" '%F'];T;$@u;![;"I"c Formats date according to the directives in the given format string. The directives begin with a percent (%) character. Any text not listed as a directive will be passed through to the output string. A directive consists of a percent (%) character, zero or more flags, an optional minimum field width, an optional modifier, and a conversion specifier as follows. % Flags: - don't pad a numerical output. _ use spaces for padding. 0 use zeros for padding. ^ upcase the result string. # change case. The minimum field width specifies the minimum width. The modifiers are "E", "O", ":", "::" and ":::". "E" and "O" are ignored. No effect to result currently. Format directives: Date (Year, Month, Day): %Y - Year with century (can be negative, 4 digits at least) -0001, 0000, 1995, 2009, 14292, etc. %C - year / 100 (round down. 20 in 2009) %y - year % 100 (00..99) %m - Month of the year, zero-padded (01..12) %_m blank-padded ( 1..12) %-m no-padded (1..12) %B - The full month name (``January'') %^B uppercased (``JANUARY'') %b - The abbreviated month name (``Jan'') %^b uppercased (``JAN'') %h - Equivalent to %b %d - Day of the month, zero-padded (01..31) %-d no-padded (1..31) %e - Day of the month, blank-padded ( 1..31) %j - Day of the year (001..366) Time (Hour, Minute, Second, Subsecond): %H - Hour of the day, 24-hour clock, zero-padded (00..23) %k - Hour of the day, 24-hour clock, blank-padded ( 0..23) %I - Hour of the day, 12-hour clock, zero-padded (01..12) %l - Hour of the day, 12-hour clock, blank-padded ( 1..12) %P - Meridian indicator, lowercase (``am'' or ``pm'') %p - Meridian indicator, uppercase (``AM'' or ``PM'') %M - Minute of the hour (00..59) %S - Second of the minute (00..60) %L - Millisecond of the second (000..999) %N - Fractional seconds digits, default is 9 digits (nanosecond) %3N millisecond (3 digits) %15N femtosecond (15 digits) %6N microsecond (6 digits) %18N attosecond (18 digits) %9N nanosecond (9 digits) %21N zeptosecond (21 digits) %12N picosecond (12 digits) %24N yoctosecond (24 digits) Time zone: %z - Time zone as hour and minute offset from UTC (e.g. +0900) %:z - hour and minute offset from UTC with a colon (e.g. +09:00) %::z - hour, minute and second offset from UTC (e.g. +09:00:00) %:::z - hour, minute and second offset from UTC (e.g. +09, +09:30, +09:30:30) %Z - Equivalent to %:z (e.g. +09:00) Weekday: %A - The full weekday name (``Sunday'') %^A uppercased (``SUNDAY'') %a - The abbreviated name (``Sun'') %^a uppercased (``SUN'') %u - Day of the week (Monday is 1, 1..7) %w - Day of the week (Sunday is 0, 0..6) ISO 8601 week-based year and week number: The week 1 of YYYY starts with a Monday and includes YYYY-01-04. The days in the year before the first week are in the last week of the previous year. %G - The week-based year %g - The last 2 digits of the week-based year (00..99) %V - Week number of the week-based year (01..53) Week number: The week 1 of YYYY starts with a Sunday or Monday (according to %U or %W). The days in the year before the first week are in week 0. %U - Week number of the year. The week starts with Sunday. (00..53) %W - Week number of the year. The week starts with Monday. (00..53) Seconds since the Unix Epoch: %s - Number of seconds since 1970-01-01 00:00:00 UTC. %Q - Number of milliseconds since 1970-01-01 00:00:00 UTC. Literal string: %n - Newline character (\n) %t - Tab character (\t) %% - Literal ``%'' character Combination: %c - date and time (%a %b %e %T %Y) %D - Date (%m/%d/%y) %F - The ISO 8601 date format (%Y-%m-%d) %v - VMS date (%e-%^b-%Y) %x - Same as %D %X - Same as %T %r - 12-hour time (%I:%M:%S %p) %R - 24-hour time (%H:%M) %T - 24-hour time (%H:%M:%S) %+ - date(1) (%a %b %e %H:%M:%S %Z %Y) This method is similar to the strftime() function defined in ISO C and POSIX. Several directives (%a, %A, %b, %B, %c, %p, %r, %x, %X, %E*, %O* and %Z) are locale dependent in the function. However, this method is locale independent. So, the result may differ even if the same format string is used in other systems such as C. It is good practice to avoid %x and %X because there are corresponding locale independent representations, %D and %T. Examples: d = DateTime.new(2007,11,19,8,37,48,"-06:00") #=> # d.strftime("Printed on %m/%d/%Y") #=> "Printed on 11/19/2007" d.strftime("at %I:%M%p") #=> "at 08:37AM" Various ISO 8601 formats: %Y%m%d => 20071119 Calendar date (basic) %F => 2007-11-19 Calendar date (extended) %Y-%m => 2007-11 Calendar date, reduced accuracy, specific month %Y => 2007 Calendar date, reduced accuracy, specific year %C => 20 Calendar date, reduced accuracy, specific century %Y%j => 2007323 Ordinal date (basic) %Y-%j => 2007-323 Ordinal date (extended) %GW%V%u => 2007W471 Week date (basic) %G-W%V-%u => 2007-W47-1 Week date (extended) %GW%V => 2007W47 Week date, reduced accuracy, specific week (basic) %G-W%V => 2007-W47 Week date, reduced accuracy, specific week (extended) %H%M%S => 083748 Local time (basic) %T => 08:37:48 Local time (extended) %H%M => 0837 Local time, reduced accuracy, specific minute (basic) %H:%M => 08:37 Local time, reduced accuracy, specific minute (extended) %H => 08 Local time, reduced accuracy, specific hour %H%M%S,%L => 083748,000 Local time with decimal fraction, comma as decimal sign (basic) %T,%L => 08:37:48,000 Local time with decimal fraction, comma as decimal sign (extended) %H%M%S.%L => 083748.000 Local time with decimal fraction, full stop as decimal sign (basic) %T.%L => 08:37:48.000 Local time with decimal fraction, full stop as decimal sign (extended) %H%M%S%z => 083748-0600 Local time and the difference from UTC (basic) %T%:z => 08:37:48-06:00 Local time and the difference from UTC (extended) %Y%m%dT%H%M%S%z => 20071119T083748-0600 Date and time of day for calendar date (basic) %FT%T%:z => 2007-11-19T08:37:48-06:00 Date and time of day for calendar date (extended) %Y%jT%H%M%S%z => 2007323T083748-0600 Date and time of day for ordinal date (basic) %Y-%jT%T%:z => 2007-323T08:37:48-06:00 Date and time of day for ordinal date (extended) %GW%V%uT%H%M%S%z => 2007W471T083748-0600 Date and time of day for week date (basic) %G-W%V-%uT%T%:z => 2007-W47-1T08:37:48-06:00 Date and time of day for week date (extended) %Y%m%dT%H%M => 20071119T0837 Calendar date and local time (basic) %FT%R => 2007-11-19T08:37 Calendar date and local time (extended) %Y%jT%H%MZ => 2007323T0837Z Ordinal date and UTC of day (basic) %Y-%jT%RZ => 2007-323T08:37Z Ordinal date and UTC of day (extended) %GW%V%uT%H%M%z => 2007W471T0837-0600 Week date and local time and difference from UTC (basic) %G-W%V-%uT%R%:z => 2007-W47-1T08:37-06:00 Week date and local time and difference from UTC (extended) See also strftime(3) and ::strptime. @overload strftime([format='%F']) @return [String];T;#0;$@u;.F;/o;0;1T;2i;3i;%@;9I"static VALUE d_lite_strftime(int argc, VALUE *argv, VALUE self) { return date_strftime_internal(argc, argv, self, "%Y-%m-%d", set_tmx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#asctime;F;7[;[[@'i;T;: asctime;0;[;{;IC; "Returns a string in asctime(3) format (but without "\n\0" at the end). This method is equivalent to strftime('%c'). See also asctime(3) or ctime(3). ;T;[o;= ;>I" overload;F;?0;;;@0;:I" asctime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;5;@0;:I" ctime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a string in asctime(3) format (but without "\n\0" at the end). This method is equivalent to strftime('%c'). See also asctime(3) or ctime(3). @overload asctime @return [String] @overload ctime @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"mstatic VALUE d_lite_asctime(VALUE self) { return strftimev("%a %b %e %H:%M:%S %Y", self, set_tmx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#ctime;F;7[;[[@'i;T;;5;0;[;{;IC; "Returns a string in asctime(3) format (but without "\n\0" at the end). This method is equivalent to strftime('%c'). See also asctime(3) or ctime(3). ;T;[o;= ;>I" overload;F;?0;;;@0;:I" asctime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;5;@0;:I" ctime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"mstatic VALUE d_lite_asctime(VALUE self) { return strftimev("%a %b %e %H:%M:%S %Y", self, set_tmx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#iso8601;F;7[;[[@'i;T;;R;0;[;{;IC; "1This method is equivalent to strftime('%F'). ;T;[o;= ;>I" overload;F;?0;;R;@0;:I" iso8601;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;V;@0;:I"xmlschema;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"This method is equivalent to strftime('%F'). @overload iso8601 @return [String] @overload xmlschema @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"astatic VALUE d_lite_iso8601(VALUE self) { return strftimev("%Y-%m-%d", self, set_tmx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#xmlschema;F;7[;[[@'i;T;;V;0;[;{;IC; "1This method is equivalent to strftime('%F'). ;T;[o;= ;>I" overload;F;?0;;R;@0;:I" iso8601;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;;V;@0;:I"xmlschema;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"@;#0;$@ ;.F;/o;0;1T;2i;3i;%@;9I"astatic VALUE d_lite_iso8601(VALUE self) { return strftimev("%Y-%m-%d", self, set_tmx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#rfc3339;F;7[;[[@'i;T;;T;0;[;{;IC; "7This method is equivalent to strftime('%FT%T%:z'). ;T;[o;= ;>I" overload;F;?0;;T;@0;:I" rfc3339;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@2;![;"I"@return [String];T;#0;$@2;.F;Bi;C0;7[;$@2;![;"I"^This method is equivalent to strftime('%FT%T%:z'). @overload rfc3339 @return [String];T;#0;$@2;.F;/o;0;1T;2i;3i;%@;9I"mstatic VALUE d_lite_rfc3339(VALUE self) { return strftimev("%Y-%m-%dT%H:%M:%S%:z", self, set_tmx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#rfc2822;F;7[;[[@'i;T;;Y;0;[;{;IC; "BThis method is equivalent to strftime('%a, %-d %b %Y %T %z'). ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I" rfc2822;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@M;![;"I"@return [String];T;#0;$@M;.F;Bi;C0;7[;$@Mo;= ;>I" overload;F;?0;;Z;@0;:I" rfc822;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@M;![;"I"@return [String];T;#0;$@M;.F;Bi;C0;7[;$@M;![;"I"This method is equivalent to strftime('%a, %-d %b %Y %T %z'). @overload rfc2822 @return [String] @overload rfc822 @return [String];T;#0;$@M;.F;/o;0;1T;2i;3i ;%@;9I"lstatic VALUE d_lite_rfc2822(VALUE self) { return strftimev("%a, %-d %b %Y %T %z", self, set_tmx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#rfc822;F;7[;[[@'i;T;;Z;0;[;{;IC; "BThis method is equivalent to strftime('%a, %-d %b %Y %T %z'). ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I" rfc2822;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@u;![;"I"@return [String];T;#0;$@u;.F;Bi;C0;7[;$@uo;= ;>I" overload;F;?0;;Z;@0;:I" rfc822;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@u;![;"I"@return [String];T;#0;$@u;.F;Bi;C0;7[;$@u;![;"@q;#0;$@u;.F;/o;0;1T;2i;3i ;%@;9I"lstatic VALUE d_lite_rfc2822(VALUE self) { return strftimev("%a, %-d %b %Y %T %z", self, set_tmx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#httpdate;F;7[;[[@'i;T;;\;0;[;{;IC; "UThis method is equivalent to strftime('%a, %d %b %Y %T GMT'). See also RFC 2616. ;T;[o;= ;>I" overload;F;?0;;\;@0;:I" httpdate;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"}This method is equivalent to strftime('%a, %d %b %Y %T GMT'). See also RFC 2616. @overload httpdate @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE d_lite_httpdate(VALUE self) { volatile VALUE dup = dup_obj_with_new_offset(self, 0); return strftimev("%a, %d %b %Y %T GMT", dup, set_tmx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#jisx0301;F;7[;[[@'iR;T;;^;0;[;{;IC; "]Returns a string in a JIS X 0301 format. Date.new(2001,2,3).jisx0301 #=> "H13.02.03" ;T;[o;= ;>I" overload;F;?0;;^;@0;:I" jisx0301;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a string in a JIS X 0301 format. Date.new(2001,2,3).jisx0301 #=> "H13.02.03" @overload jisx0301 @return [String];T;#0;$@;.F;/o;0;1T;2iJ;3iP;%@;9I"static VALUE d_lite_jisx0301(VALUE self) { char fmtbuf[JISX0301_DATE_SIZE]; const char *fmt; get_d1(self); fmt = jisx0301_date_format(fmtbuf, sizeof(fmtbuf), m_real_local_jd(dat), m_real_year(dat)); return strftimev(fmt, self, set_tmx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#marshal_dump_old;F;7[;[[@'i`;T;:marshal_dump_old;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I""static VALUE d_lite_marshal_dump_old(VALUE self) { VALUE a; get_d1(self); a = rb_ary_new3(3, m_ajd(dat), m_of_in_day(dat), DBL2NUM(m_sg(dat))); if (FL_TEST(self, FL_EXIVAR)) { rb_copy_generic_ivar(a, self); FL_SET(a, FL_EXIVAR); } return a; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#marshal_dump;F;7[;[[@'iv;T;;[;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2iu;3iu;%@;9I"estatic VALUE d_lite_marshal_dump(VALUE self) { VALUE a; get_d1(self); a = rb_ary_new3(6, m_nth(dat), INT2FIX(m_jd(dat)), INT2FIX(m_df(dat)), m_sf(dat), INT2FIX(m_of(dat)), DBL2NUM(m_sg(dat))); if (FL_TEST(self, FL_EXIVAR)) { rb_copy_generic_ivar(a, self); FL_SET(a, FL_EXIVAR); } return a; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#marshal_load;F;7[[I"a;T0;[[@'i;T;:marshal_load;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"kstatic VALUE d_lite_marshal_load(VALUE self, VALUE a) { VALUE nth, sf; int jd, df, of; double sg; get_d1(self); rb_check_frozen(self); if (!RB_TYPE_P(a, T_ARRAY)) rb_raise(rb_eTypeError, "expected an array"); switch (RARRAY_LEN(a)) { case 2: /* 1.6.x */ case 3: /* 1.8.x, 1.9.2 */ { VALUE ajd, vof, vsg; if (RARRAY_LEN(a) == 2) { ajd = f_sub(RARRAY_AREF(a, 0), half_days_in_day); vof = INT2FIX(0); vsg = RARRAY_AREF(a, 1); if (!k_numeric_p(vsg)) vsg = DBL2NUM(RTEST(vsg) ? GREGORIAN : JULIAN); } else { ajd = RARRAY_AREF(a, 0); vof = RARRAY_AREF(a, 1); vsg = RARRAY_AREF(a, 2); } old_to_new(ajd, vof, vsg, &nth, &jd, &df, &sf, &of, &sg); } break; case 6: { nth = RARRAY_AREF(a, 0); jd = NUM2INT(RARRAY_AREF(a, 1)); df = NUM2INT(RARRAY_AREF(a, 2)); sf = RARRAY_AREF(a, 3); of = NUM2INT(RARRAY_AREF(a, 4)); sg = NUM2DBL(RARRAY_AREF(a, 5)); } break; default: rb_raise(rb_eTypeError, "invalid size"); break; } if (simple_dat_p(dat)) { if (df || !f_zero_p(sf) || of) { /* loading a fractional date; promote to complex */ dat = ruby_xrealloc(dat, sizeof(struct ComplexDateData)); RTYPEDDATA(self)->data = dat; goto complex_data; } set_to_simple(self, &dat->s, nth, jd, sg, 0, 0, 0, HAVE_JD); } else { complex_data: set_to_complex(self, &dat->c, nth, jd, df, sf, of, sg, 0, 0, 0, 0, 0, 0, HAVE_JD | HAVE_DF); } if (FL_TEST(a, FL_EXIVAR)) { rb_copy_generic_ivar(self, a); FL_SET(self, FL_EXIVAR); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date._load;F;7[[I"s;T0;[[@'i;T;: _load;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE date_s__load(VALUE klass, VALUE s) { VALUE a, obj; a = rb_marshal_load(s); obj = d_lite_s_alloc(klass); return d_lite_marshal_load(obj, a); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#to_time;F;7[;[[@'i";T;: to_time;0;[;{;IC; "Returns a Time object which denotes self. If self is a julian date, convert it to a gregorian date before converting it to Time. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_time;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@ ;![;"I"@return [Time];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Returns a Time object which denotes self. If self is a julian date, convert it to a gregorian date before converting it to Time. @overload to_time @return [Time];T;#0;$@ ;.F;/o;0;1T;2i";3i";%@;9I".static VALUE date_to_time(VALUE self) { get_d1a(self); if (m_julian_p(adat)) { VALUE tmp = d_lite_gregorian(self); get_d1b(tmp); adat = bdat; } return f_local3(rb_cTime, m_real_year(adat), INT2FIX(m_mon(adat)), INT2FIX(m_mday(adat))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#to_date;F;7[;[[@'i";T;: to_date;0;[;{;IC; "Returns self. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_date;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@';![;"I"@return [self];T;#0;$@';.F;Bi;C0;7[;$@';![;"I"7Returns self. @overload to_date @return [self];T;#0;$@';.F;/o;0;1T;2i";3i";%@;9I"?static VALUE date_to_date(VALUE self) { return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date#to_datetime;F;7[;[[@'i";T;:to_datetime;0;[;{;IC; "2Returns a DateTime object which denotes self. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"to_datetime;T;IC; ";T;[;![;"I";T;#0;$@B;.F;Bi;C0;7[;$@B;![;"I"JReturns a DateTime object which denotes self. @overload to_datetime;T;#0;$@B;.F;/o;0;1T;2i";3i";%@;9I"static VALUE date_to_datetime(VALUE self) { get_d1a(self); if (simple_dat_p(adat)) { VALUE new = d_lite_s_alloc_simple(cDateTime); { get_d1b(new); bdat->s = adat->s; return new; } } else { VALUE new = d_lite_s_alloc_complex(cDateTime); { get_d1b(new); bdat->c = adat->c; bdat->c.df = 0; RB_OBJ_WRITE(new, &bdat->c.sf, INT2FIX(0)); #ifndef USE_PACK bdat->c.hour = 0; bdat->c.min = 0; bdat->c.sec = 0; #else bdat->c.pc = PACK5(EX_MON(adat->c.pc), EX_MDAY(adat->c.pc), 0, 0, 0); bdat->c.flags |= HAVE_DF | HAVE_TIME; #endif return new; } } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.test_civil;F;7[;[[@'i2#;T;:test_civil;0;[;{;IC; " tests ;T;[;![;"I" tests;T;#0;$@X;.F;/o;0;1T;2i&;3i&;%@;9I"static VALUE date_s_test_civil(VALUE klass) { if (!test_civil(MIN_JD, MIN_JD + 366, GREGORIAN)) return Qfalse; if (!test_civil(2305814, 2598007, GREGORIAN)) return Qfalse; if (!test_civil(MAX_JD - 366, MAX_JD, GREGORIAN)) return Qfalse; if (!test_civil(MIN_JD, MIN_JD + 366, ITALY)) return Qfalse; if (!test_civil(2305814, 2598007, ITALY)) return Qfalse; if (!test_civil(MAX_JD - 366, MAX_JD, ITALY)) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.test_ordinal;F;7[;[[@'iZ#;T;:test_ordinal;0;[;{;IC; " ;T;[;![;"@;#0;$@f;%@;9I"static VALUE date_s_test_ordinal(VALUE klass) { if (!test_ordinal(MIN_JD, MIN_JD + 366, GREGORIAN)) return Qfalse; if (!test_ordinal(2305814, 2598007, GREGORIAN)) return Qfalse; if (!test_ordinal(MAX_JD - 366, MAX_JD, GREGORIAN)) return Qfalse; if (!test_ordinal(MIN_JD, MIN_JD + 366, ITALY)) return Qfalse; if (!test_ordinal(2305814, 2598007, ITALY)) return Qfalse; if (!test_ordinal(MAX_JD - 366, MAX_JD, ITALY)) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.test_commercial;F;7[;[[@'i#;T;:test_commercial;0;[;{;IC; " ;T;[;![;"@;#0;$@r;%@;9I"static VALUE date_s_test_commercial(VALUE klass) { if (!test_commercial(MIN_JD, MIN_JD + 366, GREGORIAN)) return Qfalse; if (!test_commercial(2305814, 2598007, GREGORIAN)) return Qfalse; if (!test_commercial(MAX_JD - 366, MAX_JD, GREGORIAN)) return Qfalse; if (!test_commercial(MIN_JD, MIN_JD + 366, ITALY)) return Qfalse; if (!test_commercial(2305814, 2598007, ITALY)) return Qfalse; if (!test_commercial(MAX_JD - 366, MAX_JD, ITALY)) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.test_weeknum;F;7[;[[@'i#;T;:test_weeknum;0;[;{;IC; " ;T;[;![;"@;#0;$@~;%@;9I"*static VALUE date_s_test_weeknum(VALUE klass) { int f; for (f = 0; f <= 1; f++) { if (!test_weeknum(MIN_JD, MIN_JD + 366, f, GREGORIAN)) return Qfalse; if (!test_weeknum(2305814, 2598007, f, GREGORIAN)) return Qfalse; if (!test_weeknum(MAX_JD - 366, MAX_JD, f, GREGORIAN)) return Qfalse; if (!test_weeknum(MIN_JD, MIN_JD + 366, f, ITALY)) return Qfalse; if (!test_weeknum(2305814, 2598007, f, ITALY)) return Qfalse; if (!test_weeknum(MAX_JD - 366, MAX_JD, f, ITALY)) return Qfalse; } return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.test_nth_kday;F;7[;[[@'i#;T;:test_nth_kday;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE date_s_test_nth_kday(VALUE klass) { if (!test_nth_kday(MIN_JD, MIN_JD + 366, GREGORIAN)) return Qfalse; if (!test_nth_kday(2305814, 2598007, GREGORIAN)) return Qfalse; if (!test_nth_kday(MAX_JD - 366, MAX_JD, GREGORIAN)) return Qfalse; if (!test_nth_kday(MIN_JD, MIN_JD + 366, ITALY)) return Qfalse; if (!test_nth_kday(2305814, 2598007, ITALY)) return Qfalse; if (!test_nth_kday(MAX_JD - 366, MAX_JD, ITALY)) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.test_unit_conv;F;7[;[[@'i$;T;:test_unit_conv;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"Sstatic VALUE date_s_test_unit_conv(VALUE klass) { if (!test_unit_v2v_iter(sec_to_day, day_to_sec)) return Qfalse; if (!test_unit_v2v_iter(ms_to_sec, sec_to_ms)) return Qfalse; if (!test_unit_v2v_iter(ns_to_day, day_to_ns)) return Qfalse; if (!test_unit_v2v_iter(ns_to_sec, sec_to_ns)) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Date.test_all;F;7[;[[@'i-$;T;: test_all;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE date_s_test_all(VALUE klass) { if (date_s_test_civil(klass) == Qfalse) return Qfalse; if (date_s_test_ordinal(klass) == Qfalse) return Qfalse; if (date_s_test_commercial(klass) == Qfalse) return Qfalse; if (date_s_test_weeknum(klass) == Qfalse) return Qfalse; if (date_s_test_nth_kday(klass) == Qfalse) return Qfalse; if (date_s_test_unit_conv(klass) == Qfalse) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[o;( ;)0;*0;+0;;;%@;-@?_;0; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@'i%%;F;: Date;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I" Date;F;'@o; ;IC;[*o;4;5F;6;;;;&I"DateTime.jd;F;7[[@90;[[@'i;T;;G;0;[;{;IC; "0Creates a DateTime object denoting the given chronological Julian day number. DateTime.jd(2451944) #=> # DateTime.jd(2451945) #=> # DateTime.jd(Rational('0.5')) #=> # ;T;[o;= ;>I" overload;F;?0;;G;@0;:I"Rjd([jd=0[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"[jd;TI"J0[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]];T;$@;![;"I"Creates a DateTime object denoting the given chronological Julian day number. DateTime.jd(2451944) #=> # DateTime.jd(2451945) #=> # DateTime.jd(Rational('0.5')) #=> # @overload jd([jd=0[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE datetime_s_jd(int argc, VALUE *argv, VALUE klass) { VALUE vjd, vh, vmin, vs, vof, vsg, jd, fr, fr2, ret; int h, min, s, rof; double sg; rb_scan_args(argc, argv, "06", &vjd, &vh, &vmin, &vs, &vof, &vsg); jd = INT2FIX(0); h = min = s = 0; fr2 = INT2FIX(0); rof = 0; sg = DEFAULT_SG; switch (argc) { case 6: val2sg(vsg, sg); case 5: val2off(vof, rof); case 4: check_numeric(vs, "second"); num2int_with_frac(s, positive_inf); case 3: check_numeric(vmin, "minute"); num2int_with_frac(min, 3); case 2: check_numeric(vh, "hour"); num2int_with_frac(h, 2); case 1: check_numeric(vjd, "jd"); num2num_with_frac(jd, 1); } { VALUE nth; int rh, rmin, rs, rjd, rjd2; if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs)) rb_raise(eDateError, "invalid date"); canon24oc(); decode_jd(jd, &nth, &rjd); rjd2 = jd_local_to_utc(rjd, time_to_df(rh, rmin, rs), rof); ret = d_complex_new_internal(klass, nth, rjd2, 0, INT2FIX(0), rof, sg, 0, 0, 0, rh, rmin, rs, HAVE_JD | HAVE_TIME); } add_frac(); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime.ordinal;F;7[[@90;[[@'i:;T;;H;0;[;{;IC; "CCreates a DateTime object denoting the given ordinal date. DateTime.ordinal(2001,34) #=> # DateTime.ordinal(2001,34,4,5,6,'+7') #=> # DateTime.ordinal(2001,-332,-20,-55,-54,'+7') #=> # ;T;[o;= ;>I" overload;F;?0;;H;@0;:I"gordinal([year=-4712[, yday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" [year;TI"X-4712[, yday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]];T;$@;![;"I"Creates a DateTime object denoting the given ordinal date. DateTime.ordinal(2001,34) #=> # DateTime.ordinal(2001,34,4,5,6,'+7') #=> # DateTime.ordinal(2001,-332,-20,-55,-54,'+7') #=> # @overload ordinal([year=-4712[, yday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]);T;#0;$@;.F;/o;0;1T;2i.;3i7;%@;9I"static VALUE datetime_s_ordinal(int argc, VALUE *argv, VALUE klass) { VALUE vy, vd, vh, vmin, vs, vof, vsg, y, fr, fr2, ret; int d, h, min, s, rof; double sg; rb_scan_args(argc, argv, "07", &vy, &vd, &vh, &vmin, &vs, &vof, &vsg); y = INT2FIX(-4712); d = 1; h = min = s = 0; fr2 = INT2FIX(0); rof = 0; sg = DEFAULT_SG; switch (argc) { case 7: val2sg(vsg, sg); case 6: val2off(vof, rof); case 5: check_numeric(vs, "second"); num2int_with_frac(s, positive_inf); case 4: check_numeric(vmin, "minute"); num2int_with_frac(min, 4); case 3: check_numeric(vh, "hour"); num2int_with_frac(h, 3); case 2: check_numeric(vd, "yday"); num2int_with_frac(d, 2); case 1: check_numeric(vy, "year"); y = vy; } { VALUE nth; int ry, rd, rh, rmin, rs, rjd, rjd2, ns; if (!valid_ordinal_p(y, d, sg, &nth, &ry, &rd, &rjd, &ns)) rb_raise(eDateError, "invalid date"); if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs)) rb_raise(eDateError, "invalid date"); canon24oc(); rjd2 = jd_local_to_utc(rjd, time_to_df(rh, rmin, rs), rof); ret = d_complex_new_internal(klass, nth, rjd2, 0, INT2FIX(0), rof, sg, 0, 0, 0, rh, rmin, rs, HAVE_JD | HAVE_TIME); } add_frac(); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime.civil;F;7[[@90;[[@'i;T;;I;0;[;{;IC; "=Creates a DateTime object denoting the given calendar date. DateTime.new(2001,2,3) #=> # DateTime.new(2001,2,3,4,5,6,'+7') #=> # DateTime.new(2001,-11,-26,-20,-55,-54,'+7') #=> # ;T;[o;= ;>I" overload;F;?0;;I;@0;:I"pcivil([year=-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" [year;TI"c-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]];T;$@o;= ;>I" overload;F;?0;;E;@0;:I"nnew([year=-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" [year;TI"c-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]];T;$@;![;"I")Creates a DateTime object denoting the given calendar date. DateTime.new(2001,2,3) #=> # DateTime.new(2001,2,3,4,5,6,'+7') #=> # DateTime.new(2001,-11,-26,-20,-55,-54,'+7') #=> # @overload civil([year=-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]]) @overload new([year=-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]]);T;#0;$@;.F;/o;0;1T;2i~;3i;%@;9I"static VALUE datetime_s_civil(int argc, VALUE *argv, VALUE klass) { return datetime_initialize(argc, argv, d_lite_s_alloc_complex(klass)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime.new;F;7[[@90;[[@'i;T;;E;0;[;{;IC; "=Creates a DateTime object denoting the given calendar date. DateTime.new(2001,2,3) #=> # DateTime.new(2001,2,3,4,5,6,'+7') #=> # DateTime.new(2001,-11,-26,-20,-55,-54,'+7') #=> # ;T;[o;= ;>I" overload;F;?0;;I;@0;:I"pcivil([year=-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" [year;TI"c-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]];T;$@o;= ;>I" overload;F;?0;;E;@0;:I"nnew([year=-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" [year;TI"c-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]];T;$@;![;"@;#0;$@;.F;/o;0;1T;2i~;3i;%@;9I"static VALUE datetime_s_civil(int argc, VALUE *argv, VALUE klass) { return datetime_initialize(argc, argv, d_lite_s_alloc_complex(klass)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime.commercial;F;7[[@90;[[@'i;T;;J;0;[;{;IC; ".Creates a DateTime object denoting the given week date. DateTime.commercial(2001) #=> # DateTime.commercial(2002) #=> # DateTime.commercial(2001,5,6,4,5,6,'+7') #=> # ;T;[o;= ;>I" overload;F;?0;;J;@0;:I"xcommercial([cwyear=-4712[, cweek=1[, cwday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]]);T;IC; ";T;[;![;"I";T;#0;$@=;.F;Bi;C0;7[[I" [cwyear;TI"d-4712[, cweek=1[, cwday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]];T;$@=;![;"I"Creates a DateTime object denoting the given week date. DateTime.commercial(2001) #=> # DateTime.commercial(2002) #=> # DateTime.commercial(2001,5,6,4,5,6,'+7') #=> # @overload commercial([cwyear=-4712[, cweek=1[, cwday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]]);T;#0;$@=;.F;/o;0;1T;2i;3i;%@;9I"static VALUE datetime_s_commercial(int argc, VALUE *argv, VALUE klass) { VALUE vy, vw, vd, vh, vmin, vs, vof, vsg, y, fr, fr2, ret; int w, d, h, min, s, rof; double sg; rb_scan_args(argc, argv, "08", &vy, &vw, &vd, &vh, &vmin, &vs, &vof, &vsg); y = INT2FIX(-4712); w = 1; d = 1; h = min = s = 0; fr2 = INT2FIX(0); rof = 0; sg = DEFAULT_SG; switch (argc) { case 8: val2sg(vsg, sg); case 7: val2off(vof, rof); case 6: check_numeric(vs, "second"); num2int_with_frac(s, positive_inf); case 5: check_numeric(vmin, "minute"); num2int_with_frac(min, 5); case 4: check_numeric(vh, "hour"); num2int_with_frac(h, 4); case 3: check_numeric(vd, "cwday"); num2int_with_frac(d, 3); case 2: check_numeric(vw, "cweek"); w = NUM2INT(vw); case 1: check_numeric(vy, "year"); y = vy; } { VALUE nth; int ry, rw, rd, rh, rmin, rs, rjd, rjd2, ns; if (!valid_commercial_p(y, w, d, sg, &nth, &ry, &rw, &rd, &rjd, &ns)) rb_raise(eDateError, "invalid date"); if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs)) rb_raise(eDateError, "invalid date"); canon24oc(); rjd2 = jd_local_to_utc(rjd, time_to_df(rh, rmin, rs), rof); ret = d_complex_new_internal(klass, nth, rjd2, 0, INT2FIX(0), rof, sg, 0, 0, 0, rh, rmin, rs, HAVE_JD | HAVE_TIME); } add_frac(); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime.weeknum;F;7[[@90;[[@'iG;T;;K;0;[;{;IC; " ;T;[;![;"@;#0;$@W;%@;9I"Vstatic VALUE datetime_s_weeknum(int argc, VALUE *argv, VALUE klass) { VALUE vy, vw, vd, vf, vh, vmin, vs, vof, vsg, y, fr, fr2, ret; int w, d, f, h, min, s, rof; double sg; rb_scan_args(argc, argv, "09", &vy, &vw, &vd, &vf, &vh, &vmin, &vs, &vof, &vsg); y = INT2FIX(-4712); w = 0; d = 1; f = 0; h = min = s = 0; fr2 = INT2FIX(0); rof = 0; sg = DEFAULT_SG; switch (argc) { case 9: val2sg(vsg, sg); case 8: val2off(vof, rof); case 7: num2int_with_frac(s, positive_inf); case 6: num2int_with_frac(min, 6); case 5: num2int_with_frac(h, 5); case 4: f = NUM2INT(vf); case 3: num2int_with_frac(d, 4); case 2: w = NUM2INT(vw); case 1: y = vy; } { VALUE nth; int ry, rw, rd, rh, rmin, rs, rjd, rjd2, ns; if (!valid_weeknum_p(y, w, d, f, sg, &nth, &ry, &rw, &rd, &rjd, &ns)) rb_raise(eDateError, "invalid date"); if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs)) rb_raise(eDateError, "invalid date"); canon24oc(); rjd2 = jd_local_to_utc(rjd, time_to_df(rh, rmin, rs), rof); ret = d_complex_new_internal(klass, nth, rjd2, 0, INT2FIX(0), rof, sg, 0, 0, 0, rh, rmin, rs, HAVE_JD | HAVE_TIME); } add_frac(); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime.nth_kday;F;7[[@90;[[@'i;T;;L;0;[;{;IC; " ;T;[;![;"@;#0;$@d;%@;9I"dstatic VALUE datetime_s_nth_kday(int argc, VALUE *argv, VALUE klass) { VALUE vy, vm, vn, vk, vh, vmin, vs, vof, vsg, y, fr, fr2, ret; int m, n, k, h, min, s, rof; double sg; rb_scan_args(argc, argv, "09", &vy, &vm, &vn, &vk, &vh, &vmin, &vs, &vof, &vsg); y = INT2FIX(-4712); m = 1; n = 1; k = 1; h = min = s = 0; fr2 = INT2FIX(0); rof = 0; sg = DEFAULT_SG; switch (argc) { case 9: val2sg(vsg, sg); case 8: val2off(vof, rof); case 7: num2int_with_frac(s, positive_inf); case 6: num2int_with_frac(min, 6); case 5: num2int_with_frac(h, 5); case 4: num2int_with_frac(k, 4); case 3: n = NUM2INT(vn); case 2: m = NUM2INT(vm); case 1: y = vy; } { VALUE nth; int ry, rm, rn, rk, rh, rmin, rs, rjd, rjd2, ns; if (!valid_nth_kday_p(y, m, n, k, sg, &nth, &ry, &rm, &rn, &rk, &rjd, &ns)) rb_raise(eDateError, "invalid date"); if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs)) rb_raise(eDateError, "invalid date"); canon24oc(); rjd2 = jd_local_to_utc(rjd, time_to_df(rh, rmin, rs), rof); ret = d_complex_new_internal(klass, nth, rjd2, 0, INT2FIX(0), rof, sg, 0, 0, 0, rh, rmin, rs, HAVE_JD | HAVE_TIME); } add_frac(); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime.now;F;7[[@90;[[@'i;T;:now;0;[;{;IC; "zCreates a DateTime object denoting the present time. DateTime.now #=> # ;T;[o;= ;>I" overload;F;?0;;;@0;:I"now([start=Date::ITALY]);T;IC; ";T;[;![;"I";T;#0;$@q;.F;Bi;C0;7[[I" [start;TI"Date::ITALY];T;$@q;![;"I"Creates a DateTime object denoting the present time. DateTime.now #=> # @overload now([start=Date::ITALY]);T;#0;$@q;.F;/o;0;1T;2i;3i;%@;9I"static VALUE datetime_s_now(int argc, VALUE *argv, VALUE klass) { VALUE vsg, nth, ret; double sg; #ifdef HAVE_CLOCK_GETTIME struct timespec ts; #else struct timeval tv; #endif time_t sec; struct tm tm; long sf, of; int y, ry, m, d, h, min, s; rb_scan_args(argc, argv, "01", &vsg); if (argc < 1) sg = DEFAULT_SG; else sg = NUM2DBL(vsg); #ifdef HAVE_CLOCK_GETTIME if (clock_gettime(CLOCK_REALTIME, &ts) == -1) rb_sys_fail("clock_gettime"); sec = ts.tv_sec; #else if (gettimeofday(&tv, NULL) == -1) rb_sys_fail("gettimeofday"); sec = tv.tv_sec; #endif tzset(); if (!localtime_r(&sec, &tm)) rb_sys_fail("localtime"); y = tm.tm_year + 1900; m = tm.tm_mon + 1; d = tm.tm_mday; h = tm.tm_hour; min = tm.tm_min; s = tm.tm_sec; if (s == 60) s = 59; #ifdef HAVE_STRUCT_TM_TM_GMTOFF of = tm.tm_gmtoff; #elif defined(HAVE_TIMEZONE) #if defined(HAVE_ALTZONE) && !defined(_AIX) of = (long)-((tm.tm_isdst > 0) ? altzone : timezone); #else of = (long)-timezone; if (tm.tm_isdst) { time_t sec2; tm.tm_isdst = 0; sec2 = mktime(&tm); of += (long)difftime(sec2, sec); } #endif #elif defined(HAVE_TIMEGM) { time_t sec2; sec2 = timegm(&tm); of = (long)difftime(sec2, sec); } #else { struct tm tm2; time_t sec2; if (!gmtime_r(&sec, &tm2)) rb_sys_fail("gmtime"); tm2.tm_isdst = tm.tm_isdst; sec2 = mktime(&tm2); of = (long)difftime(sec, sec2); } #endif #ifdef HAVE_CLOCK_GETTIME sf = ts.tv_nsec; #else sf = tv.tv_usec * 1000; #endif if (of < -DAY_IN_SECONDS || of > DAY_IN_SECONDS) { of = 0; rb_warning("invalid offset is ignored"); } decode_year(INT2FIX(y), -1, &nth, &ry); ret = d_complex_new_internal(klass, nth, 0, 0, LONG2NUM(sf), (int)of, GREGORIAN, ry, m, d, h, min, s, HAVE_CIVIL | HAVE_TIME); { get_d1(ret); set_sg(dat, sg); } return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime._strptime;F;7[[@90;[[@'i;T;;N;0;[;{;IC; "Parses the given representation of date and time with the given template, and returns a hash of parsed elements. _strptime does not support specification of flags and width unlike strftime. See also strptime(3) and #strftime. ;T;[o;= ;>I" overload;F;?0;;N;@0;:I"*_strptime(string[, format='%FT%T%z']);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@;![;"I"@return [Hash];T;#0;$@;.F;Bi;C0;7[[I"string[, format;TI"'%FT%T%z'];T;$@;![;"I"&Parses the given representation of date and time with the given template, and returns a hash of parsed elements. _strptime does not support specification of flags and width unlike strftime. See also strptime(3) and #strftime. @overload _strptime(string[, format='%FT%T%z']) @return [Hash];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE datetime_s__strptime(int argc, VALUE *argv, VALUE klass) { return date_s__strptime_internal(argc, argv, klass, "%FT%T%z"); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime.strptime;F;7[[@90;[[@'i;T;;O;0;[;{;IC; "OParses the given representation of date and time with the given template, and creates a DateTime object. strptime does not support specification of flags and width unlike strftime. DateTime.strptime('2001-02-03T04:05:06+07:00', '%Y-%m-%dT%H:%M:%S%z') #=> # DateTime.strptime('03-02-2001 04:05:06 PM', '%d-%m-%Y %I:%M:%S %p') #=> # DateTime.strptime('2001-W05-6T04:05:06+07:00', '%G-W%V-%uT%H:%M:%S%z') #=> # DateTime.strptime('2001 04 6 04 05 06 +7', '%Y %U %w %H %M %S %z') #=> # DateTime.strptime('2001 05 6 04 05 06 +7', '%Y %W %u %H %M %S %z') #=> # DateTime.strptime('-1', '%s') #=> # DateTime.strptime('-1000', '%Q') #=> # DateTime.strptime('sat3feb014pm+7', '%a%d%b%y%H%p%z') #=> # See also strptime(3) and #strftime. ;T;[o;= ;>I" overload;F;?0;;O;@0;:I"]strptime([string='-4712-01-01T00:00:00+00:00'[, format='%FT%T%z'[ ,start=Date::ITALY]]]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" [string;TI"K'-4712-01-01T00:00:00+00:00'[, format='%FT%T%z'[ ,start=Date::ITALY]]];T;$@;![;"I"Parses the given representation of date and time with the given template, and creates a DateTime object. strptime does not support specification of flags and width unlike strftime. DateTime.strptime('2001-02-03T04:05:06+07:00', '%Y-%m-%dT%H:%M:%S%z') #=> # DateTime.strptime('03-02-2001 04:05:06 PM', '%d-%m-%Y %I:%M:%S %p') #=> # DateTime.strptime('2001-W05-6T04:05:06+07:00', '%G-W%V-%uT%H:%M:%S%z') #=> # DateTime.strptime('2001 04 6 04 05 06 +7', '%Y %U %w %H %M %S %z') #=> # DateTime.strptime('2001 05 6 04 05 06 +7', '%Y %W %u %H %M %S %z') #=> # DateTime.strptime('-1', '%s') #=> # DateTime.strptime('-1000', '%Q') #=> # DateTime.strptime('sat3feb014pm+7', '%a%d%b%y%H%p%z') #=> # See also strptime(3) and #strftime. @overload strptime([string='-4712-01-01T00:00:00+00:00'[, format='%FT%T%z'[ ,start=Date::ITALY]]]);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE datetime_s_strptime(int argc, VALUE *argv, VALUE klass) { VALUE str, fmt, sg; rb_scan_args(argc, argv, "03", &str, &fmt, &sg); switch (argc) { case 0: str = rb_str_new2("-4712-01-01T00:00:00+00:00"); case 1: fmt = rb_str_new2("%FT%T%z"); case 2: sg = INT2FIX(DEFAULT_SG); } { VALUE argv2[2], hash; argv2[0] = str; argv2[1] = fmt; hash = date_s__strptime(2, argv2, klass); return dt_new_by_frags(klass, hash, sg); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime.parse;F;7[[@90;[[@'i;T;;+;0;[;{;IC; "]Parses the given representation of date and time, and creates a DateTime object. This method *does not* function as a validator. If the input string does not match valid formats strictly, you may get a cryptic result. Should consider to use `DateTime.strptime` instead of this method as possible. If the optional second argument is true and the detected year is in the range "00" to "99", makes it full. DateTime.parse('2001-02-03T04:05:06+07:00') #=> # DateTime.parse('20010203T040506+0700') #=> # DateTime.parse('3rd Feb 2001 04:05:06 PM') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;+;@0;:I"]parse(string='-4712-01-01T00:00:00+00:00'[, comp=true[, start=Date::ITALY]], limit: 128);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;TI"C'-4712-01-01T00:00:00+00:00'[, comp=true[, start=Date::ITALY]];T[I" limit:;TI"128;T;$@;![;"I"Parses the given representation of date and time, and creates a DateTime object. This method *does not* function as a validator. If the input string does not match valid formats strictly, you may get a cryptic result. Should consider to use `DateTime.strptime` instead of this method as possible. If the optional second argument is true and the detected year is in the range "00" to "99", makes it full. DateTime.parse('2001-02-03T04:05:06+07:00') #=> # DateTime.parse('20010203T040506+0700') #=> # DateTime.parse('3rd Feb 2001 04:05:06 PM') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload parse(string='-4712-01-01T00:00:00+00:00'[, comp=true[, start=Date::ITALY]], limit: 128);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"bstatic VALUE datetime_s_parse(int argc, VALUE *argv, VALUE klass) { VALUE str, comp, sg, opt; rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt); if (!NIL_P(opt)) argc--; switch (argc) { case 0: str = rb_str_new2("-4712-01-01T00:00:00+00:00"); case 1: comp = Qtrue; case 2: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 2; VALUE argv2[3]; argv2[0] = str; argv2[1] = comp; argv2[2] = opt; if (!NIL_P(opt)) argc2++; VALUE hash = date_s__parse(argc2, argv2, klass); return dt_new_by_frags(klass, hash, sg); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime.iso8601;F;7[[@90;[[@'i' ;T;;R;0;[;{;IC; "/Creates a new DateTime object by parsing from a string according to some typical ISO 8601 formats. DateTime.iso8601('2001-02-03T04:05:06+07:00') #=> # DateTime.iso8601('20010203T040506+0700') #=> # DateTime.iso8601('2001-W05-6T04:05:06+07:00') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;R;@0;:I"Riso8601(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;TI"6'-4712-01-01T00:00:00+00:00'[, start=Date::ITALY];T[I" limit:;TI"128;T;$@;![;"I"Creates a new DateTime object by parsing from a string according to some typical ISO 8601 formats. DateTime.iso8601('2001-02-03T04:05:06+07:00') #=> # DateTime.iso8601('20010203T040506+0700') #=> # DateTime.iso8601('2001-W05-6T04:05:06+07:00') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload iso8601(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128);T;#0;$@;.F;/o;0;1T;2i ;3i$ ;%@;9I"#static VALUE datetime_s_iso8601(int argc, VALUE *argv, VALUE klass) { VALUE str, sg, opt; rb_scan_args(argc, argv, "02:", &str, &sg, &opt); if (!NIL_P(opt)) argc--; switch (argc) { case 0: str = rb_str_new2("-4712-01-01T00:00:00+00:00"); case 1: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 1; VALUE argv2[2]; argv2[0] = str; argv2[1] = opt; if (!NIL_P(opt)) argc2--; VALUE hash = date_s__iso8601(argc2, argv2, klass); return dt_new_by_frags(klass, hash, sg); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime.rfc3339;F;7[[@90;[[@'iO ;T;;T;0;[;{;IC; "nCreates a new DateTime object by parsing from a string according to some typical RFC 3339 formats. DateTime.rfc3339('2001-02-03T04:05:06+07:00') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;T;@0;:I"Rrfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;TI"6'-4712-01-01T00:00:00+00:00'[, start=Date::ITALY];T[I" limit:;TI"128;T;$@;![;"I"Creates a new DateTime object by parsing from a string according to some typical RFC 3339 formats. DateTime.rfc3339('2001-02-03T04:05:06+07:00') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128);T;#0;$@;.F;/o;0;1T;2iA ;3iL ;%@;9I"#static VALUE datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass) { VALUE str, sg, opt; rb_scan_args(argc, argv, "02:", &str, &sg, &opt); if (!NIL_P(opt)) argc--; switch (argc) { case 0: str = rb_str_new2("-4712-01-01T00:00:00+00:00"); case 1: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 1; VALUE argv2[2]; argv2[0] = str; argv2[1] = opt; if (!NIL_P(opt)) argc2++; VALUE hash = date_s__rfc3339(argc2, argv2, klass); return dt_new_by_frags(klass, hash, sg); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime.xmlschema;F;7[[@90;[[@'iw ;T;;V;0;[;{;IC; "rCreates a new DateTime object by parsing from a string according to some typical XML Schema formats. DateTime.xmlschema('2001-02-03T04:05:06+07:00') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;V;@0;:I"Txmlschema(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;TI"6'-4712-01-01T00:00:00+00:00'[, start=Date::ITALY];T[I" limit:;TI"128;T;$@;![;"I"Creates a new DateTime object by parsing from a string according to some typical XML Schema formats. DateTime.xmlschema('2001-02-03T04:05:06+07:00') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload xmlschema(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128);T;#0;$@;.F;/o;0;1T;2ii ;3it ;%@;9I"'static VALUE datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass) { VALUE str, sg, opt; rb_scan_args(argc, argv, "02:", &str, &sg, &opt); if (!NIL_P(opt)) argc--; switch (argc) { case 0: str = rb_str_new2("-4712-01-01T00:00:00+00:00"); case 1: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 1; VALUE argv2[2]; argv2[0] = str; argv2[1] = opt; if (!NIL_P(opt)) argc2++; VALUE hash = date_s__xmlschema(argc2, argv2, klass); return dt_new_by_frags(klass, hash, sg); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime.rfc2822;F;7[[@90;[[@'i ;T;;Y;0;[;{;IC; "tCreates a new DateTime object by parsing from a string according to some typical RFC 2822 formats. DateTime.rfc2822('Sat, 3 Feb 2001 04:05:06 +0700') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I"Wrfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128);T;IC; ";T;[;![;"I";T;#0;$@8;.F;Bi;C0;7[[I" string;TI";'Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY];T[I" limit:;TI"128;T;$@8o;= ;>I" overload;F;?0;;Z;@0;:I"Vrfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128);T;IC; ";T;[;![;"I";T;#0;$@8;.F;Bi;C0;7[[I" string;TI";'Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY];T[I" limit:;TI"128;T;$@8;![;"I"/Creates a new DateTime object by parsing from a string according to some typical RFC 2822 formats. DateTime.rfc2822('Sat, 3 Feb 2001 04:05:06 +0700') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) @overload rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128);T;#0;$@8;.F;/o;0;1T;2i ;3i ;%@;9I"(static VALUE datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass) { VALUE str, sg, opt; rb_scan_args(argc, argv, "02:", &str, &sg, &opt); if (!NIL_P(opt)) argc--; switch (argc) { case 0: str = rb_str_new2("Mon, 1 Jan -4712 00:00:00 +0000"); case 1: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 1; VALUE argv2[2]; argv2[0] = str; argv2[1] = opt; if (!NIL_P(opt)) argc2++; VALUE hash = date_s__rfc2822(argc2, argv2, klass); return dt_new_by_frags(klass, hash, sg); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime.rfc822;F;7[[@90;[[@'i ;T;;Z;0;[;{;IC; "tCreates a new DateTime object by parsing from a string according to some typical RFC 2822 formats. DateTime.rfc2822('Sat, 3 Feb 2001 04:05:06 +0700') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I"Wrfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128);T;IC; ";T;[;![;"I";T;#0;$@c;.F;Bi;C0;7[[I" string;TI";'Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY];T[I" limit:;TI"128;T;$@co;= ;>I" overload;F;?0;;Z;@0;:I"Vrfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128);T;IC; ";T;[;![;"I";T;#0;$@c;.F;Bi;C0;7[[I" string;TI";'Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY];T[I" limit:;TI"128;T;$@c;![;"@_;#0;$@c;.F;/o;0;1T;2i ;3i ;%@;9I"(static VALUE datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass) { VALUE str, sg, opt; rb_scan_args(argc, argv, "02:", &str, &sg, &opt); if (!NIL_P(opt)) argc--; switch (argc) { case 0: str = rb_str_new2("Mon, 1 Jan -4712 00:00:00 +0000"); case 1: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 1; VALUE argv2[2]; argv2[0] = str; argv2[1] = opt; if (!NIL_P(opt)) argc2++; VALUE hash = date_s__rfc2822(argc2, argv2, klass); return dt_new_by_frags(klass, hash, sg); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime.httpdate;F;7[[@90;[[@'i ;T;;\;0;[;{;IC; "jCreates a new DateTime object by parsing from a string according to some RFC 2616 format. DateTime.httpdate('Sat, 03 Feb 2001 04:05:06 GMT') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;\;@0;:I"Khttpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;TI":'Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY];T;$@;![;"I"Creates a new DateTime object by parsing from a string according to some RFC 2616 format. DateTime.httpdate('Sat, 03 Feb 2001 04:05:06 GMT') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY]);T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I")static VALUE datetime_s_httpdate(int argc, VALUE *argv, VALUE klass) { VALUE str, sg, opt; rb_scan_args(argc, argv, "02:", &str, &sg, &opt); if (!NIL_P(opt)) argc--; switch (argc) { case 0: str = rb_str_new2("Mon, 01 Jan -4712 00:00:00 GMT"); case 1: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 1; VALUE argv2[2]; argv2[0] = str; argv2[1] = opt; if (!NIL_P(opt)) argc2++; VALUE hash = date_s__httpdate(argc2, argv2, klass); return dt_new_by_frags(klass, hash, sg); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime.jisx0301;F;7[[@90;[[@'i ;T;;^;0;[;{;IC; "Creates a new DateTime object by parsing from a string according to some typical JIS X 0301 formats. DateTime.jisx0301('H13.02.03T04:05:06+07:00') #=> # For no-era year, legacy format, Heisei is assumed. DateTime.jisx0301('13.02.03T04:05:06+07:00') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. ;T;[o;= ;>I" overload;F;?0;;^;@0;:I"Sjisx0301(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;TI"6'-4712-01-01T00:00:00+00:00'[, start=Date::ITALY];T[I" limit:;TI"128;T;$@;![;"I"bCreates a new DateTime object by parsing from a string according to some typical JIS X 0301 formats. DateTime.jisx0301('H13.02.03T04:05:06+07:00') #=> # For no-era year, legacy format, Heisei is assumed. DateTime.jisx0301('13.02.03T04:05:06+07:00') #=> # Raise an ArgumentError when the string length is longer than _limit_. You can stop this check by passing `limit: nil`, but note that it may take a long time to parse. @overload jisx0301(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128);T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"%static VALUE datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass) { VALUE str, sg, opt; rb_scan_args(argc, argv, "02:", &str, &sg, &opt); if (!NIL_P(opt)) argc--; switch (argc) { case 0: str = rb_str_new2("-4712-01-01T00:00:00+00:00"); case 1: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 1; VALUE argv2[2]; argv2[0] = str; argv2[1] = opt; if (!NIL_P(opt)) argc2++; VALUE hash = date_s__jisx0301(argc2, argv2, klass); return dt_new_by_frags(klass, hash, sg); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime#hour;F;7[;[[@'i;T;;x;0;[;{;IC; "JReturns the hour (0-23). DateTime.new(2001,2,3,4,5,6).hour #=> 4 ;T;[o;= ;>I" overload;F;?0;;x;@0;:I" hour;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@;![;"I"@return [Fixnum];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"nReturns the hour (0-23). DateTime.new(2001,2,3,4,5,6).hour #=> 4 @overload hour @return [Fixnum];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"`static VALUE d_lite_hour(VALUE self) { get_d1(self); return INT2FIX(m_hour(dat)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime#min;F;7[;[[@'i ;T;;;0;[;{;IC; "KReturns the minute (0-59). DateTime.new(2001,2,3,4,5,6).min #=> 5 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"min;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@;![;"I"@return [Fixnum];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;y;@0;:I" minute;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@;![;"I"@return [Fixnum];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the minute (0-59). DateTime.new(2001,2,3,4,5,6).min #=> 5 @overload min @return [Fixnum] @overload minute @return [Fixnum];T;#0;$@;.F;/o;0;1T;2i;3i ;%@;9I"^static VALUE d_lite_min(VALUE self) { get_d1(self); return INT2FIX(m_min(dat)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime#minute;F;7[;[[@'i ;T;;y;0;[;{;IC; "KReturns the minute (0-59). DateTime.new(2001,2,3,4,5,6).min #=> 5 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"min;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@;![;"I"@return [Fixnum];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;y;@0;:I" minute;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@;![;"I"@return [Fixnum];T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2i;3i ;%@;9I"^static VALUE d_lite_min(VALUE self) { get_d1(self); return INT2FIX(m_min(dat)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime#sec;F;7[;[[@'i;T;;z;0;[;{;IC; "KReturns the second (0-59). DateTime.new(2001,2,3,4,5,6).sec #=> 6 ;T;[o;= ;>I" overload;F;?0;;z;@0;:I"sec;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@.;![;"I"@return [Fixnum];T;#0;$@.;.F;Bi;C0;7[;$@.o;= ;>I" overload;F;?0;;{;@0;:I" second;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@.;![;"I"@return [Fixnum];T;#0;$@.;.F;Bi;C0;7[;$@.;![;"I"Returns the second (0-59). DateTime.new(2001,2,3,4,5,6).sec #=> 6 @overload sec @return [Fixnum] @overload second @return [Fixnum];T;#0;$@.;.F;/o;0;1T;2i;3i;%@;9I"^static VALUE d_lite_sec(VALUE self) { get_d1(self); return INT2FIX(m_sec(dat)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime#second;F;7[;[[@'i;T;;{;0;[;{;IC; "KReturns the second (0-59). DateTime.new(2001,2,3,4,5,6).sec #=> 6 ;T;[o;= ;>I" overload;F;?0;;z;@0;:I"sec;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@V;![;"I"@return [Fixnum];T;#0;$@V;.F;Bi;C0;7[;$@Vo;= ;>I" overload;F;?0;;{;@0;:I" second;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@V;![;"I"@return [Fixnum];T;#0;$@V;.F;Bi;C0;7[;$@V;![;"@R;#0;$@V;.F;/o;0;1T;2i;3i;%@;9I"^static VALUE d_lite_sec(VALUE self) { get_d1(self); return INT2FIX(m_sec(dat)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime#sec_fraction;F;7[;[[@'i*;T;:sec_fraction;0;[;{;IC; "iReturns the fractional part of the second. DateTime.new(2001,2,3,4,5,6.5).sec_fraction #=> (1/2) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"sec_fraction;T;IC; ";T;[;![;"I";T;#0;$@};.F;Bi;C0;7[;$@}o;= ;>I" overload;F;?0;:second_fraction;@0;:I"second_fraction;T;IC; ";T;[;![;"I";T;#0;$@};.F;Bi;C0;7[;$@};![;"I"Returns the fractional part of the second. DateTime.new(2001,2,3,4,5,6.5).sec_fraction #=> (1/2) @overload sec_fraction @overload second_fraction;T;#0;$@};.F;/o;0;1T;2i!;3i';%@;9I"dstatic VALUE d_lite_sec_fraction(VALUE self) { get_d1(self); return m_sf_in_sec(dat); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime#second_fraction;F;7[;[[@'i*;T;;;0;[;{;IC; "iReturns the fractional part of the second. DateTime.new(2001,2,3,4,5,6.5).sec_fraction #=> (1/2) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"sec_fraction;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"second_fraction;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2i!;3i';%@;9I"dstatic VALUE d_lite_sec_fraction(VALUE self) { get_d1(self); return m_sf_in_sec(dat); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime#offset;F;7[;[[@'i9;T;: offset;0;[;{;IC; "JReturns the offset. DateTime.parse('04pm+0730').offset #=> (5/16) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" offset;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"]Returns the offset. DateTime.parse('04pm+0730').offset #=> (5/16) @overload offset;T;#0;$@;.F;/o;0;1T;2i1;3i6;%@;9I"^static VALUE d_lite_offset(VALUE self) { get_d1(self); return m_of_in_day(dat); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime#zone;F;7[;[[@'iH;T;: zone;0;[;{;IC; "MReturns the timezone. DateTime.parse('04pm+0730').zone #=> "+07:30" ;T;[o;= ;>I" overload;F;?0;;;@0;:I" zone;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"qReturns the timezone. DateTime.parse('04pm+0730').zone #=> "+07:30" @overload zone @return [String];T;#0;$@;.F;/o;0;1T;2i@;3iF;%@;9I"Wstatic VALUE d_lite_zone(VALUE self) { get_d1(self); return m_zone(dat); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime#new_offset;F;7[[@90;[[@'i4;T;:new_offset;0;[;{;IC; "Duplicates self and resets its offset. d = DateTime.new(2001,2,3,4,5,6,'-02:00') #=> # d.new_offset('+09:00') #=> # ;T;[o;= ;>I" overload;F;?0;;;@0;:I"new_offset([offset=0]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" [offset;TI"0];T;$@;![;"I"Duplicates self and resets its offset. d = DateTime.new(2001,2,3,4,5,6,'-02:00') #=> # d.new_offset('+09:00') #=> # @overload new_offset([offset=0]);T;#0;$@;.F;/o;0;1T;2i*;3i1;%@;9I"static VALUE d_lite_new_offset(int argc, VALUE *argv, VALUE self) { VALUE vof; int rof; rb_scan_args(argc, argv, "01", &vof); rof = 0; if (argc >= 1) val2off(vof, rof); return dup_obj_with_new_offset(self, rof); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime#to_s;F;7[;[[@'i!;T;;G;0;[;{;IC; "Returns a string in an ISO 8601 format. (This method doesn't use the expanded representations.) DateTime.new(2001,2,3,4,5,6,'-7').to_s #=> "2001-02-03T04:05:06-07:00" ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a string in an ISO 8601 format. (This method doesn't use the expanded representations.) DateTime.new(2001,2,3,4,5,6,'-7').to_s #=> "2001-02-03T04:05:06-07:00" @overload to_s @return [String];T;#0;$@;.F;/o;0;1T;2i!;3i!;%@;9I"kstatic VALUE dt_lite_to_s(VALUE self) { return strftimev("%Y-%m-%dT%H:%M:%S%:z", self, set_tmx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime#strftime;F;7[[@90;[[@'i!;T;;;0;[;{;IC; " Formats date according to the directives in the given format string. The directives begin with a percent (%) character. Any text not listed as a directive will be passed through to the output string. A directive consists of a percent (%) character, zero or more flags, an optional minimum field width, an optional modifier, and a conversion specifier as follows. % Flags: - don't pad a numerical output. _ use spaces for padding. 0 use zeros for padding. ^ upcase the result string. # change case. : use colons for %z. The minimum field width specifies the minimum width. The modifiers are "E" and "O". They are ignored. Format directives: Date (Year, Month, Day): %Y - Year with century (can be negative, 4 digits at least) -0001, 0000, 1995, 2009, 14292, etc. %C - year / 100 (round down. 20 in 2009) %y - year % 100 (00..99) %m - Month of the year, zero-padded (01..12) %_m blank-padded ( 1..12) %-m no-padded (1..12) %B - The full month name (``January'') %^B uppercased (``JANUARY'') %b - The abbreviated month name (``Jan'') %^b uppercased (``JAN'') %h - Equivalent to %b %d - Day of the month, zero-padded (01..31) %-d no-padded (1..31) %e - Day of the month, blank-padded ( 1..31) %j - Day of the year (001..366) Time (Hour, Minute, Second, Subsecond): %H - Hour of the day, 24-hour clock, zero-padded (00..23) %k - Hour of the day, 24-hour clock, blank-padded ( 0..23) %I - Hour of the day, 12-hour clock, zero-padded (01..12) %l - Hour of the day, 12-hour clock, blank-padded ( 1..12) %P - Meridian indicator, lowercase (``am'' or ``pm'') %p - Meridian indicator, uppercase (``AM'' or ``PM'') %M - Minute of the hour (00..59) %S - Second of the minute (00..60) %L - Millisecond of the second (000..999) %N - Fractional seconds digits, default is 9 digits (nanosecond) %3N millisecond (3 digits) %15N femtosecond (15 digits) %6N microsecond (6 digits) %18N attosecond (18 digits) %9N nanosecond (9 digits) %21N zeptosecond (21 digits) %12N picosecond (12 digits) %24N yoctosecond (24 digits) Time zone: %z - Time zone as hour and minute offset from UTC (e.g. +0900) %:z - hour and minute offset from UTC with a colon (e.g. +09:00) %::z - hour, minute and second offset from UTC (e.g. +09:00:00) %:::z - hour, minute and second offset from UTC (e.g. +09, +09:30, +09:30:30) %Z - Equivalent to %:z (e.g. +09:00) Weekday: %A - The full weekday name (``Sunday'') %^A uppercased (``SUNDAY'') %a - The abbreviated name (``Sun'') %^a uppercased (``SUN'') %u - Day of the week (Monday is 1, 1..7) %w - Day of the week (Sunday is 0, 0..6) ISO 8601 week-based year and week number: The week 1 of YYYY starts with a Monday and includes YYYY-01-04. The days in the year before the first week are in the last week of the previous year. %G - The week-based year %g - The last 2 digits of the week-based year (00..99) %V - Week number of the week-based year (01..53) Week number: The week 1 of YYYY starts with a Sunday or Monday (according to %U or %W). The days in the year before the first week are in week 0. %U - Week number of the year. The week starts with Sunday. (00..53) %W - Week number of the year. The week starts with Monday. (00..53) Seconds since the Unix Epoch: %s - Number of seconds since 1970-01-01 00:00:00 UTC. %Q - Number of milliseconds since 1970-01-01 00:00:00 UTC. Literal string: %n - Newline character (\n) %t - Tab character (\t) %% - Literal ``%'' character Combination: %c - date and time (%a %b %e %T %Y) %D - Date (%m/%d/%y) %F - The ISO 8601 date format (%Y-%m-%d) %v - VMS date (%e-%^b-%Y) %x - Same as %D %X - Same as %T %r - 12-hour time (%I:%M:%S %p) %R - 24-hour time (%H:%M) %T - 24-hour time (%H:%M:%S) %+ - date(1) (%a %b %e %H:%M:%S %Z %Y) This method is similar to the strftime() function defined in ISO C and POSIX. Several directives (%a, %A, %b, %B, %c, %p, %r, %x, %X, %E*, %O* and %Z) are locale dependent in the function. However, this method is locale independent. So, the result may differ even if the same format string is used in other systems such as C. It is good practice to avoid %x and %X because there are corresponding locale independent representations, %D and %T. Examples: d = DateTime.new(2007,11,19,8,37,48,"-06:00") #=> # d.strftime("Printed on %m/%d/%Y") #=> "Printed on 11/19/2007" d.strftime("at %I:%M%p") #=> "at 08:37AM" Various ISO 8601 formats: %Y%m%d => 20071119 Calendar date (basic) %F => 2007-11-19 Calendar date (extended) %Y-%m => 2007-11 Calendar date, reduced accuracy, specific month %Y => 2007 Calendar date, reduced accuracy, specific year %C => 20 Calendar date, reduced accuracy, specific century %Y%j => 2007323 Ordinal date (basic) %Y-%j => 2007-323 Ordinal date (extended) %GW%V%u => 2007W471 Week date (basic) %G-W%V-%u => 2007-W47-1 Week date (extended) %GW%V => 2007W47 Week date, reduced accuracy, specific week (basic) %G-W%V => 2007-W47 Week date, reduced accuracy, specific week (extended) %H%M%S => 083748 Local time (basic) %T => 08:37:48 Local time (extended) %H%M => 0837 Local time, reduced accuracy, specific minute (basic) %H:%M => 08:37 Local time, reduced accuracy, specific minute (extended) %H => 08 Local time, reduced accuracy, specific hour %H%M%S,%L => 083748,000 Local time with decimal fraction, comma as decimal sign (basic) %T,%L => 08:37:48,000 Local time with decimal fraction, comma as decimal sign (extended) %H%M%S.%L => 083748.000 Local time with decimal fraction, full stop as decimal sign (basic) %T.%L => 08:37:48.000 Local time with decimal fraction, full stop as decimal sign (extended) %H%M%S%z => 083748-0600 Local time and the difference from UTC (basic) %T%:z => 08:37:48-06:00 Local time and the difference from UTC (extended) %Y%m%dT%H%M%S%z => 20071119T083748-0600 Date and time of day for calendar date (basic) %FT%T%:z => 2007-11-19T08:37:48-06:00 Date and time of day for calendar date (extended) %Y%jT%H%M%S%z => 2007323T083748-0600 Date and time of day for ordinal date (basic) %Y-%jT%T%:z => 2007-323T08:37:48-06:00 Date and time of day for ordinal date (extended) %GW%V%uT%H%M%S%z => 2007W471T083748-0600 Date and time of day for week date (basic) %G-W%V-%uT%T%:z => 2007-W47-1T08:37:48-06:00 Date and time of day for week date (extended) %Y%m%dT%H%M => 20071119T0837 Calendar date and local time (basic) %FT%R => 2007-11-19T08:37 Calendar date and local time (extended) %Y%jT%H%MZ => 2007323T0837Z Ordinal date and UTC of day (basic) %Y-%jT%RZ => 2007-323T08:37Z Ordinal date and UTC of day (extended) %GW%V%uT%H%M%z => 2007W471T0837-0600 Week date and local time and difference from UTC (basic) %G-W%V-%uT%R%:z => 2007-W47-1T08:37-06:00 Week date and local time and difference from UTC (extended) See also strftime(3) and ::strptime. ;T;[o;= ;>I" overload;F;?0;;;@0;:I""strftime([format='%FT%T%:z']);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I" [format;TI"'%FT%T%:z'];T;$@;![;"I"I Formats date according to the directives in the given format string. The directives begin with a percent (%) character. Any text not listed as a directive will be passed through to the output string. A directive consists of a percent (%) character, zero or more flags, an optional minimum field width, an optional modifier, and a conversion specifier as follows. % Flags: - don't pad a numerical output. _ use spaces for padding. 0 use zeros for padding. ^ upcase the result string. # change case. : use colons for %z. The minimum field width specifies the minimum width. The modifiers are "E" and "O". They are ignored. Format directives: Date (Year, Month, Day): %Y - Year with century (can be negative, 4 digits at least) -0001, 0000, 1995, 2009, 14292, etc. %C - year / 100 (round down. 20 in 2009) %y - year % 100 (00..99) %m - Month of the year, zero-padded (01..12) %_m blank-padded ( 1..12) %-m no-padded (1..12) %B - The full month name (``January'') %^B uppercased (``JANUARY'') %b - The abbreviated month name (``Jan'') %^b uppercased (``JAN'') %h - Equivalent to %b %d - Day of the month, zero-padded (01..31) %-d no-padded (1..31) %e - Day of the month, blank-padded ( 1..31) %j - Day of the year (001..366) Time (Hour, Minute, Second, Subsecond): %H - Hour of the day, 24-hour clock, zero-padded (00..23) %k - Hour of the day, 24-hour clock, blank-padded ( 0..23) %I - Hour of the day, 12-hour clock, zero-padded (01..12) %l - Hour of the day, 12-hour clock, blank-padded ( 1..12) %P - Meridian indicator, lowercase (``am'' or ``pm'') %p - Meridian indicator, uppercase (``AM'' or ``PM'') %M - Minute of the hour (00..59) %S - Second of the minute (00..60) %L - Millisecond of the second (000..999) %N - Fractional seconds digits, default is 9 digits (nanosecond) %3N millisecond (3 digits) %15N femtosecond (15 digits) %6N microsecond (6 digits) %18N attosecond (18 digits) %9N nanosecond (9 digits) %21N zeptosecond (21 digits) %12N picosecond (12 digits) %24N yoctosecond (24 digits) Time zone: %z - Time zone as hour and minute offset from UTC (e.g. +0900) %:z - hour and minute offset from UTC with a colon (e.g. +09:00) %::z - hour, minute and second offset from UTC (e.g. +09:00:00) %:::z - hour, minute and second offset from UTC (e.g. +09, +09:30, +09:30:30) %Z - Equivalent to %:z (e.g. +09:00) Weekday: %A - The full weekday name (``Sunday'') %^A uppercased (``SUNDAY'') %a - The abbreviated name (``Sun'') %^a uppercased (``SUN'') %u - Day of the week (Monday is 1, 1..7) %w - Day of the week (Sunday is 0, 0..6) ISO 8601 week-based year and week number: The week 1 of YYYY starts with a Monday and includes YYYY-01-04. The days in the year before the first week are in the last week of the previous year. %G - The week-based year %g - The last 2 digits of the week-based year (00..99) %V - Week number of the week-based year (01..53) Week number: The week 1 of YYYY starts with a Sunday or Monday (according to %U or %W). The days in the year before the first week are in week 0. %U - Week number of the year. The week starts with Sunday. (00..53) %W - Week number of the year. The week starts with Monday. (00..53) Seconds since the Unix Epoch: %s - Number of seconds since 1970-01-01 00:00:00 UTC. %Q - Number of milliseconds since 1970-01-01 00:00:00 UTC. Literal string: %n - Newline character (\n) %t - Tab character (\t) %% - Literal ``%'' character Combination: %c - date and time (%a %b %e %T %Y) %D - Date (%m/%d/%y) %F - The ISO 8601 date format (%Y-%m-%d) %v - VMS date (%e-%^b-%Y) %x - Same as %D %X - Same as %T %r - 12-hour time (%I:%M:%S %p) %R - 24-hour time (%H:%M) %T - 24-hour time (%H:%M:%S) %+ - date(1) (%a %b %e %H:%M:%S %Z %Y) This method is similar to the strftime() function defined in ISO C and POSIX. Several directives (%a, %A, %b, %B, %c, %p, %r, %x, %X, %E*, %O* and %Z) are locale dependent in the function. However, this method is locale independent. So, the result may differ even if the same format string is used in other systems such as C. It is good practice to avoid %x and %X because there are corresponding locale independent representations, %D and %T. Examples: d = DateTime.new(2007,11,19,8,37,48,"-06:00") #=> # d.strftime("Printed on %m/%d/%Y") #=> "Printed on 11/19/2007" d.strftime("at %I:%M%p") #=> "at 08:37AM" Various ISO 8601 formats: %Y%m%d => 20071119 Calendar date (basic) %F => 2007-11-19 Calendar date (extended) %Y-%m => 2007-11 Calendar date, reduced accuracy, specific month %Y => 2007 Calendar date, reduced accuracy, specific year %C => 20 Calendar date, reduced accuracy, specific century %Y%j => 2007323 Ordinal date (basic) %Y-%j => 2007-323 Ordinal date (extended) %GW%V%u => 2007W471 Week date (basic) %G-W%V-%u => 2007-W47-1 Week date (extended) %GW%V => 2007W47 Week date, reduced accuracy, specific week (basic) %G-W%V => 2007-W47 Week date, reduced accuracy, specific week (extended) %H%M%S => 083748 Local time (basic) %T => 08:37:48 Local time (extended) %H%M => 0837 Local time, reduced accuracy, specific minute (basic) %H:%M => 08:37 Local time, reduced accuracy, specific minute (extended) %H => 08 Local time, reduced accuracy, specific hour %H%M%S,%L => 083748,000 Local time with decimal fraction, comma as decimal sign (basic) %T,%L => 08:37:48,000 Local time with decimal fraction, comma as decimal sign (extended) %H%M%S.%L => 083748.000 Local time with decimal fraction, full stop as decimal sign (basic) %T.%L => 08:37:48.000 Local time with decimal fraction, full stop as decimal sign (extended) %H%M%S%z => 083748-0600 Local time and the difference from UTC (basic) %T%:z => 08:37:48-06:00 Local time and the difference from UTC (extended) %Y%m%dT%H%M%S%z => 20071119T083748-0600 Date and time of day for calendar date (basic) %FT%T%:z => 2007-11-19T08:37:48-06:00 Date and time of day for calendar date (extended) %Y%jT%H%M%S%z => 2007323T083748-0600 Date and time of day for ordinal date (basic) %Y-%jT%T%:z => 2007-323T08:37:48-06:00 Date and time of day for ordinal date (extended) %GW%V%uT%H%M%S%z => 2007W471T083748-0600 Date and time of day for week date (basic) %G-W%V-%uT%T%:z => 2007-W47-1T08:37:48-06:00 Date and time of day for week date (extended) %Y%m%dT%H%M => 20071119T0837 Calendar date and local time (basic) %FT%R => 2007-11-19T08:37 Calendar date and local time (extended) %Y%jT%H%MZ => 2007323T0837Z Ordinal date and UTC of day (basic) %Y-%jT%RZ => 2007-323T08:37Z Ordinal date and UTC of day (extended) %GW%V%uT%H%M%z => 2007W471T0837-0600 Week date and local time and difference from UTC (basic) %G-W%V-%uT%R%:z => 2007-W47-1T08:37-06:00 Week date and local time and difference from UTC (extended) See also strftime(3) and ::strptime. @overload strftime([format='%FT%T%:z']) @return [String];T;#0;$@;.F;/o;0;1T;2i!;3i!;%@;9I"static VALUE dt_lite_strftime(int argc, VALUE *argv, VALUE self) { return date_strftime_internal(argc, argv, self, "%Y-%m-%dT%H:%M:%S%:z", set_tmx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime#iso8601;F;7[[@90;[[@'i!;T;;R;0;[;{;IC; "This method is equivalent to strftime('%FT%T%:z'). The optional argument +n+ is the number of digits for fractional seconds. DateTime.parse('2001-02-03T04:05:06.123456789+07:00').iso8601(9) #=> "2001-02-03T04:05:06.123456789+07:00" ;T;[o;= ;>I" overload;F;?0;;R;@0;:I"iso8601([n=0]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@=;![;"I"@return [String];T;#0;$@=;.F;Bi;C0;7[[I"[n;TI"0];T;$@=o;= ;>I" overload;F;?0;;V;@0;:I"xmlschema([n=0]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@=;![;"I"@return [String];T;#0;$@=;.F;Bi;C0;7[[I"[n;TI"0];T;$@=;![;"I"JThis method is equivalent to strftime('%FT%T%:z'). The optional argument +n+ is the number of digits for fractional seconds. DateTime.parse('2001-02-03T04:05:06.123456789+07:00').iso8601(9) #=> "2001-02-03T04:05:06.123456789+07:00" @overload iso8601([n=0]) @return [String] @overload xmlschema([n=0]) @return [String];T;#0;$@=;.F;/o;0;1T;2i!;3i!;%@;9I"static VALUE dt_lite_iso8601(int argc, VALUE *argv, VALUE self) { long n = 0; rb_check_arity(argc, 0, 1); if (argc >= 1) n = NUM2LONG(argv[0]); return rb_str_append(strftimev("%Y-%m-%d", self, set_tmx), iso8601_timediv(self, n)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime#xmlschema;F;7[[@90;[[@'i!;T;;V;0;[;{;IC; "This method is equivalent to strftime('%FT%T%:z'). The optional argument +n+ is the number of digits for fractional seconds. DateTime.parse('2001-02-03T04:05:06.123456789+07:00').iso8601(9) #=> "2001-02-03T04:05:06.123456789+07:00" ;T;[o;= ;>I" overload;F;?0;;R;@0;:I"iso8601([n=0]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@l;![;"I"@return [String];T;#0;$@l;.F;Bi;C0;7[[I"[n;TI"0];T;$@lo;= ;>I" overload;F;?0;;V;@0;:I"xmlschema([n=0]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@l;![;"I"@return [String];T;#0;$@l;.F;Bi;C0;7[[I"[n;TI"0];T;$@l;![;"@h;#0;$@l;.F;/o;0;1T;2i!;3i!;%@;9I"static VALUE dt_lite_iso8601(int argc, VALUE *argv, VALUE self) { long n = 0; rb_check_arity(argc, 0, 1); if (argc >= 1) n = NUM2LONG(argv[0]); return rb_str_append(strftimev("%Y-%m-%d", self, set_tmx), iso8601_timediv(self, n)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime#rfc3339;F;7[[@90;[[@'i ";T;;T;0;[;{;IC; "This method is equivalent to strftime('%FT%T%:z'). The optional argument +n+ is the number of digits for fractional seconds. DateTime.parse('2001-02-03T04:05:06.123456789+07:00').rfc3339(9) #=> "2001-02-03T04:05:06.123456789+07:00" ;T;[o;= ;>I" overload;F;?0;;T;@0;:I"rfc3339([n=0]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I"[n;TI"0];T;$@;![;"I"This method is equivalent to strftime('%FT%T%:z'). The optional argument +n+ is the number of digits for fractional seconds. DateTime.parse('2001-02-03T04:05:06.123456789+07:00').rfc3339(9) #=> "2001-02-03T04:05:06.123456789+07:00" @overload rfc3339([n=0]) @return [String];T;#0;$@;.F;/o;0;1T;2i";3i";%@;9I"vstatic VALUE dt_lite_rfc3339(int argc, VALUE *argv, VALUE self) { return dt_lite_iso8601(argc, argv, self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime#jisx0301;F;7[[@90;[[@'i";T;;^;0;[;{;IC; "Returns a string in a JIS X 0301 format. The optional argument +n+ is the number of digits for fractional seconds. DateTime.parse('2001-02-03T04:05:06.123456789+07:00').jisx0301(9) #=> "H13.02.03T04:05:06.123456789+07:00" ;T;[o;= ;>I" overload;F;?0;;^;@0;:I"jisx0301([n=0]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I"[n;TI"0];T;$@;![;"I"Returns a string in a JIS X 0301 format. The optional argument +n+ is the number of digits for fractional seconds. DateTime.parse('2001-02-03T04:05:06.123456789+07:00').jisx0301(9) #=> "H13.02.03T04:05:06.123456789+07:00" @overload jisx0301([n=0]) @return [String];T;#0;$@;.F;/o;0;1T;2i";3i";%@;9I"static VALUE dt_lite_jisx0301(int argc, VALUE *argv, VALUE self) { long n = 0; rb_check_arity(argc, 0, 1); if (argc >= 1) n = NUM2LONG(argv[0]); return rb_str_append(d_lite_jisx0301(self), iso8601_timediv(self, n)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime#to_time;F;7[;[[@'i";T;;;0;[;{;IC; ".Returns a Time object which denotes self. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_time;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@;![;"I"@return [Time];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"SReturns a Time object which denotes self. @overload to_time @return [Time];T;#0;$@;.F;/o;0;1T;2i";3i";%@;9I"static VALUE datetime_to_time(VALUE self) { volatile VALUE dup = dup_obj(self); { VALUE t; get_d1(dup); t = rb_funcall(rb_cTime, rb_intern("new"), 7, m_real_year(dat), INT2FIX(m_mon(dat)), INT2FIX(m_mday(dat)), INT2FIX(m_hour(dat)), INT2FIX(m_min(dat)), f_add(INT2FIX(m_sec(dat)), m_sf_in_sec(dat)), INT2FIX(m_of(dat))); return t; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime#to_date;F;7[;[[@'i";T;;;0;[;{;IC; ".Returns a Date object which denotes self. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_date;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"BReturns a Date object which denotes self. @overload to_date;T;#0;$@;.F;/o;0;1T;2i";3i";%@;9I"static VALUE datetime_to_date(VALUE self) { get_d1a(self); if (simple_dat_p(adat)) { VALUE new = d_lite_s_alloc_simple(cDate); { get_d1b(new); bdat->s = adat->s; bdat->s.jd = m_local_jd(adat); return new; } } else { VALUE new = d_lite_s_alloc_simple(cDate); { get_d1b(new); copy_complex_to_simple(new, &bdat->s, &adat->c); bdat->s.jd = m_local_jd(adat); bdat->s.flags &= ~(HAVE_DF | HAVE_TIME | COMPLEX_DAT); return new; } } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"DateTime#to_datetime;F;7[;[[@'i#;T;;;0;[;{;IC; "Returns self. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"to_datetime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@ ;![;"I"@return [self];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I";Returns self. @overload to_datetime @return [self];T;#0;$@ ;.F;/o;0;1T;2i #;3i#;%@;9I"Gstatic VALUE datetime_to_datetime(VALUE self) { return self; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@'i&;F;: DateTime;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I" DateTime;F;'@o; ;IC;[Eo;4;5F;6;;;;&I"Time#to_time;F;7[;[[@'i3";T;;;0;[;{;IC; "Returns self. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_time;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@5;![;"I"@return [Time];T;#0;$@5;.F;Bi;C0;7[;$@5;![;"I"7Returns self. @overload to_time @return [Time];T;#0;$@5;.F;/o;0;1T;2i-";3i1";%@3;9I"?static VALUE time_to_time(VALUE self) { return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#to_date;F;7[;[[@'i?";T;;;0;[;{;IC; ".Returns a Date object which denotes self. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_date;T;IC; ";T;[;![;"I";T;#0;$@P;.F;Bi;C0;7[;$@P;![;"I"BReturns a Date object which denotes self. @overload to_date;T;#0;$@P;.F;/o;0;1T;2i9";3i<";%@3;9I"pstatic VALUE time_to_date(VALUE self) { VALUE y, nth, ret; int ry, m, d; y = f_year(self); m = FIX2INT(f_mon(self)); d = FIX2INT(f_mday(self)); decode_year(y, -1, &nth, &ry); ret = d_simple_new_internal(cDate, nth, 0, GREGORIAN, ry, m, d, HAVE_CIVIL); { get_d1(ret); set_sg(dat, DEFAULT_SG); } return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#to_datetime;F;7[;[[@'i]";T;;;0;[;{;IC; "2Returns a DateTime object which denotes self. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"to_datetime;T;IC; ";T;[;![;"I";T;#0;$@f;.F;Bi;C0;7[;$@f;![;"I"JReturns a DateTime object which denotes self. @overload to_datetime;T;#0;$@f;.F;/o;0;1T;2iW";3iZ";%@3;9I"static VALUE time_to_datetime(VALUE self) { VALUE y, sf, nth, ret; int ry, m, d, h, min, s, of; y = f_year(self); m = FIX2INT(f_mon(self)); d = FIX2INT(f_mday(self)); h = FIX2INT(f_hour(self)); min = FIX2INT(f_min(self)); s = FIX2INT(f_sec(self)); if (s == 60) s = 59; sf = sec_to_ns(f_subsec(self)); of = FIX2INT(f_utc_offset(self)); decode_year(y, -1, &nth, &ry); ret = d_complex_new_internal(cDateTime, nth, 0, 0, sf, of, DEFAULT_SG, ry, m, d, h, min, s, HAVE_CIVIL | HAVE_TIME); { get_d1(ret); set_sg(dat, DEFAULT_SG); } return ret; };T;:I"static VALUE;T;;To; ;IC;[; @|; IC;[; @|; IC;[; @|; IC;{;IC;{;T;IC;{;T;T;{;[;[[I" time.c;Ti;T;:tm;;;;;[;{;IC; "/A container class for timezone conversion. ;T;[;![;"I"1 A container class for timezone conversion. ;T;#0;$@|;.F;/o;0;1T;2i;3i;%o;( ;)0;*0;+0;: Time;%@;-@3;0;&I" Time::tm;F;'o;( ;)0;*0;+0;;;%@;-@;0o;4;5F;6;;;;&I" Time.utc;F;7[[@90;[[@i" ;T;:utc;0;[;{;IC; ")Returns a new \Time object based the on given arguments; its timezone is UTC. In the first form (up to seven arguments), argument +year+ is required. Time.utc(2000) # => 2000-01-01 00:00:00 UTC Time.utc(0, 1, 2, 3, 4, 5, 6.5) # => 0000-01-02 03:04:05.0000065 UTC In the second form, all ten arguments are required, though the last four are ignored. This form is useful for creating a time from a 10-element array such as is returned by #to_a. array = Time.now.to_a p array # => [57, 26, 13, 24, 4, 2021, 6, 114, true, "Central Daylight Time"] array[5] = 2000 Time.utc(*array) # => 2000-04-24 13:26:57 UTC Parameters: :include: doc/time/year.rdoc :include: doc/time/mon-min.rdoc :include: doc/time/sec_i.rdoc :include: doc/time/usec.rdoc Alias: Time.gm. Related: Time.local. ;T;[o;= ;>I" overload;F;?0;;;@0;:I">utc(year, month=1, day=1, hour=0, min=0, sec_i=0, usec=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@;![;"I"@return [Time];T;#0;$@;.F;Bi;C0;7[ [I" year;T0[I" month;TI"1;T[I"day;TI"1;T[I" hour;TI"0;T[I"min;TI"0;T[I" sec_i;TI"0;T[I" usec;TI"0;T;$@o;= ;>I" overload;F;?0;;;@0;:I"Hutc(sec_i, min, hour, day, month, year, dummy, dummy, dummy, dummy);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@;![;"I"@return [Time];T;#0;$@;.F;Bi;C0;7[[I" sec_i;T0[I"min;T0[I" hour;T0[I"day;T0[I" month;T0[I" year;T0[I" dummy;T0[I" dummy;T0[I" dummy;T0[I" dummy;T0;$@;![;"I"Returns a new \Time object based the on given arguments; its timezone is UTC. In the first form (up to seven arguments), argument +year+ is required. Time.utc(2000) # => 2000-01-01 00:00:00 UTC Time.utc(0, 1, 2, 3, 4, 5, 6.5) # => 0000-01-02 03:04:05.0000065 UTC In the second form, all ten arguments are required, though the last four are ignored. This form is useful for creating a time from a 10-element array such as is returned by #to_a. array = Time.now.to_a p array # => [57, 26, 13, 24, 4, 2021, 6, 114, true, "Central Daylight Time"] array[5] = 2000 Time.utc(*array) # => 2000-04-24 13:26:57 UTC Parameters: :include: doc/time/year.rdoc :include: doc/time/mon-min.rdoc :include: doc/time/sec_i.rdoc :include: doc/time/usec.rdoc Alias: Time.gm. Related: Time.local. @overload utc(year, month=1, day=1, hour=0, min=0, sec_i=0, usec=0) @return [Time] @overload utc(sec_i, min, hour, day, month, year, dummy, dummy, dummy, dummy) @return [Time];T;#0;$@;.F;/o;0;1T;2i ;3i! ;%@3;9I"static VALUE time_s_mkutc(int argc, VALUE *argv, VALUE klass) { struct vtm vtm; time_arg(argc, argv, &vtm); return time_gmtime(time_new_timew(klass, timegmw(&vtm))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time.local;F;7[[@90;[[@iM ;T;: local;0;[;{;IC; "LReturns a new \Time object based the on given arguments; its timezone is the local timezone. In the first form (up to seven arguments), argument +year+ is required. Time.local(2000) # => 2000-01-01 00:00:00 -0600 Time.local(0, 1, 2, 3, 4, 5, 6.5) # => 0000-01-02 03:04:05.0000065 -0600 In the second form, all ten arguments are required, though the last four are ignored. This form is useful for creating a time from a 10-element array such as those returned by #to_a. array = Time.now.to_a p array # => [57, 26, 13, 24, 4, 2021, 6, 114, true, "Central Daylight Time"] array[5] = 2000 Time.local(*array) # => 2000-04-24 13:26:57 -0500 Parameters: :include: doc/time/year.rdoc :include: doc/time/mon-min.rdoc :include: doc/time/sec_i.rdoc :include: doc/time/usec.rdoc Alias: Time.mktime. Related: Time.utc. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"@local(year, month=1, day=1, hour=0, min=0, sec_i=0, usec=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@;![;"I"@return [Time];T;#0;$@;.F;Bi;C0;7[ [I" year;T0[I" month;TI"1;T[I"day;TI"1;T[I" hour;TI"0;T[I"min;TI"0;T[I" sec_i;TI"0;T[I" usec;TI"0;T;$@o;= ;>I" overload;F;?0;;;@0;:I"Hlocal(sec, min, hour, day, month, year, dummy, dummy, dummy, dummy);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@;![;"I"@return [Time];T;#0;$@;.F;Bi;C0;7[[I"sec;T0[I"min;T0[I" hour;T0[I"day;T0[I" month;T0[I" year;T0[I" dummy;T0[I" dummy;T0[I" dummy;T0[I" dummy;T0;$@;![;"I"Returns a new \Time object based the on given arguments; its timezone is the local timezone. In the first form (up to seven arguments), argument +year+ is required. Time.local(2000) # => 2000-01-01 00:00:00 -0600 Time.local(0, 1, 2, 3, 4, 5, 6.5) # => 0000-01-02 03:04:05.0000065 -0600 In the second form, all ten arguments are required, though the last four are ignored. This form is useful for creating a time from a 10-element array such as those returned by #to_a. array = Time.now.to_a p array # => [57, 26, 13, 24, 4, 2021, 6, 114, true, "Central Daylight Time"] array[5] = 2000 Time.local(*array) # => 2000-04-24 13:26:57 -0500 Parameters: :include: doc/time/year.rdoc :include: doc/time/mon-min.rdoc :include: doc/time/sec_i.rdoc :include: doc/time/usec.rdoc Alias: Time.mktime. Related: Time.utc. @overload local(year, month=1, day=1, hour=0, min=0, sec_i=0, usec=0) @return [Time] @overload local(sec, min, hour, day, month, year, dummy, dummy, dummy, dummy) @return [Time];T;#0;$@;.F;/o;0;1T;2i+ ;3iK ;%@3;9I"static VALUE time_s_mktime(int argc, VALUE *argv, VALUE klass) { struct vtm vtm; time_arg(argc, argv, &vtm); return time_localtime(time_new_timew(klass, timelocalw(&vtm))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#to_i;F;7[;[[@id ;T;;;0;[;{;IC; "Returns the value of _time_ as an integer number of seconds since the Epoch. If _time_ contains subsecond, they are truncated. t = Time.now #=> 2020-07-21 01:41:29.746012609 +0900 t.to_i #=> 1595263289 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_i;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@4;![;"I"@return [Integer];T;#0;$@4;.F;Bi;C0;7[;$@4o;= ;>I" overload;F;?0;: tv_sec;@0;:I" tv_sec;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@4;![;"I"@return [Integer];T;#0;$@4;.F;Bi;C0;7[;$@4;![;"I"/Returns the value of _time_ as an integer number of seconds since the Epoch. If _time_ contains subsecond, they are truncated. t = Time.now #=> 2020-07-21 01:41:29.746012609 +0900 t.to_i #=> 1595263289 @overload to_i @return [Integer] @overload tv_sec @return [Integer];T;#0;$@4;.F;/o;0;1T;2iV ;3ib ;%@3;9I"static VALUE time_to_i(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); return w2v(wdiv(tobj->timew, WINT2FIXWV(TIME_SCALE))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#to_f;F;7[;[[@i ;T;: to_f;0;[;{;IC; "=Returns the value of _time_ as a floating point number of seconds since the Epoch. The return value approximate the exact value in the Time object because floating point numbers cannot represent all rational numbers exactly. t = Time.now #=> 2020-07-20 22:00:29.38740268 +0900 t.to_f #=> 1595250029.3874028 t.to_i #=> 1595250029 Note that IEEE 754 double is not accurate enough to represent the exact number of nanoseconds since the Epoch. (IEEE 754 double has 53bit mantissa. So it can represent exact number of nanoseconds only in 2 ** 53 / 1_000_000_000 / 60 / 60 / 24 = 104.2 days.) When Ruby uses a nanosecond-resolution clock function, such as +clock_gettime+ of POSIX, to obtain the current time, Time#to_f can lose information of a Time object created with +Time.now+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_f;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@\;![;"I"@return [Float];T;#0;$@\;.F;Bi;C0;7[;$@\;![;"I"`Returns the value of _time_ as a floating point number of seconds since the Epoch. The return value approximate the exact value in the Time object because floating point numbers cannot represent all rational numbers exactly. t = Time.now #=> 2020-07-20 22:00:29.38740268 +0900 t.to_f #=> 1595250029.3874028 t.to_i #=> 1595250029 Note that IEEE 754 double is not accurate enough to represent the exact number of nanoseconds since the Epoch. (IEEE 754 double has 53bit mantissa. So it can represent exact number of nanoseconds only in 2 ** 53 / 1_000_000_000 / 60 / 60 / 24 = 104.2 days.) When Ruby uses a nanosecond-resolution clock function, such as +clock_gettime+ of POSIX, to obtain the current time, Time#to_f can lose information of a Time object created with +Time.now+. @overload to_f @return [Float];T;#0;$@\;.F;/o;0;1T;2im ;3i ;%@3;9I"static VALUE time_to_f(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); return rb_Float(rb_time_unmagnify_to_float(tobj->timew)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#to_r;F;7[;[[@i ;T;;;0;[;{;IC; "AReturns the value of _time_ as a rational number of seconds since the Epoch. t = Time.now #=> 2020-07-20 22:03:45.212167333 +0900 t.to_r #=> (1595250225212167333/1000000000) This method is intended to be used to get an accurate value representing the seconds (including subsecond) since the Epoch. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_r;T;IC; ";T;[;![;"I";T;#0;$@w;.F;Bi;C0;7[;$@w;![;"I"RReturns the value of _time_ as a rational number of seconds since the Epoch. t = Time.now #=> 2020-07-20 22:03:45.212167333 +0900 t.to_r #=> (1595250225212167333/1000000000) This method is intended to be used to get an accurate value representing the seconds (including subsecond) since the Epoch. @overload to_r;T;#0;$@w;.F;/o;0;1T;2i ;3i ;%@3;9I"static VALUE time_to_r(VALUE time) { struct time_object *tobj; VALUE v; GetTimeval(time, tobj); v = rb_time_unmagnify_to_rational(tobj->timew); if (!RB_TYPE_P(v, T_RATIONAL)) { v = rb_Rational1(v); } return v; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Time#<=>;F;7[[I" time2;T0;[[@i;T;;Y;0;[;{;IC; "dCompares +time+ with +other_time+. -1, 0, +1 or nil depending on whether +time+ is less than, equal to, or greater than +other_time+. +nil+ is returned if the two values are incomparable. t = Time.now #=> 2007-11-19 08:12:12 -0600 t2 = t + 2592000 #=> 2007-12-19 08:12:12 -0600 t <=> t2 #=> -1 t2 <=> t #=> 1 t = Time.now #=> 2007-11-19 08:13:38 -0600 t2 = t + 0.1 #=> 2007-11-19 08:13:38 -0600 t.nsec #=> 98222999 t2.nsec #=> 198222999 t <=> t2 #=> -1 t2 <=> t #=> 1 t <=> t #=> 0 ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I"<=>(other_time);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[ I"-1;TI"0;TI"+1;TI"nil;T;$@;![;"I"@return [-1, 0, +1, nil];T;#0;$@;.F;Bi;C0;7[[I"other_time;T0;$@;![;"I"Compares +time+ with +other_time+. -1, 0, +1 or nil depending on whether +time+ is less than, equal to, or greater than +other_time+. +nil+ is returned if the two values are incomparable. t = Time.now #=> 2007-11-19 08:12:12 -0600 t2 = t + 2592000 #=> 2007-12-19 08:12:12 -0600 t <=> t2 #=> -1 t2 <=> t #=> 1 t = Time.now #=> 2007-11-19 08:13:38 -0600 t2 = t + 0.1 #=> 2007-11-19 08:13:38 -0600 t.nsec #=> 98222999 t2.nsec #=> 198222999 t <=> t2 #=> -1 t2 <=> t #=> 1 t <=> t #=> 0 @overload <=>(other_time) @return [-1, 0, +1, nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@3;9I"wstatic VALUE time_cmp(VALUE time1, VALUE time2) { struct time_object *tobj1, *tobj2; int n; GetTimeval(time1, tobj1); if (IsTimeval(time2)) { GetTimeval(time2, tobj2); n = wcmp(tobj1->timew, tobj2->timew); } else { return rb_invcmp(time1, time2); } if (n == 0) return INT2FIX(0); if (n > 0) return INT2FIX(1); return INT2FIX(-1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#eql?;F;7[[I" time2;T0;[[@i:;T;;V;0;[;{;IC; "{Returns +true+ if _time_ and +other_time+ are both Time objects with the same seconds (including subsecond) from the Epoch.;T;[o;= ;>I" overload;F;?0;;V;@0;:I"eql?(other_time);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"other_time;T0;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"Returns +true+ if _time_ and +other_time+ are both Time objects with the same seconds (including subsecond) from the Epoch. @overload eql?(other_time);T;#0;$@;.F;/o;0;1T;2i2;3i6;Bi;%@3;9I"static VALUE time_eql(VALUE time1, VALUE time2) { struct time_object *tobj1, *tobj2; GetTimeval(time1, tobj1); if (IsTimeval(time2)) { GetTimeval(time2, tobj2); return rb_equal(w2v(tobj1->timew), w2v(tobj2->timew)); } return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#hash;F;7[;[[@ik;T;;X;0;[;{;IC; "EReturns a hash code for this Time object. See also Object#hash. ;T;[o;= ;>I" overload;F;?0;;X;@0;:I" hash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"jReturns a hash code for this Time object. See also Object#hash. @overload hash @return [Integer];T;#0;$@;.F;/o;0;1T;2ib;3ih;%@3;9I"static VALUE time_hash(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); return rb_hash(w2v(tobj->timew)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#initialize_copy;F;7[[I" time;T0;[[@iu;T;;];0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2it;3it;%@3;9I" static VALUE time_init_copy(VALUE copy, VALUE time) { struct time_object *tobj, *tcopy; if (!OBJ_INIT_COPY(copy, time)) return copy; GetTimeval(time, tobj); GetNewTimeval(copy, tcopy); MEMCPY(tcopy, tobj, struct time_object, 1); return copy; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#localtime;F;7[[@90;[[@i;T;:localtime;0;[;{;IC; "Converts _time_ to local time (using the local time zone in effect at the creation time of _time_) modifying the receiver. If +utc_offset+ is given, it is used instead of the local time. t = Time.utc(2000, "jan", 1, 20, 15, 1) #=> 2000-01-01 20:15:01 UTC t.utc? #=> true t.localtime #=> 2000-01-01 14:15:01 -0600 t.utc? #=> false t.localtime("+09:00") #=> 2000-01-02 05:15:01 +0900 t.utc? #=> false If +utc_offset+ is not given and _time_ is local time, just returns the receiver. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"localtime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@;![;"I"@return [Time];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"localtime(utc_offset);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@;![;"I"@return [Time];T;#0;$@;.F;Bi;C0;7[[I"utc_offset;T0;$@;![;"I"Converts _time_ to local time (using the local time zone in effect at the creation time of _time_) modifying the receiver. If +utc_offset+ is given, it is used instead of the local time. t = Time.utc(2000, "jan", 1, 20, 15, 1) #=> 2000-01-01 20:15:01 UTC t.utc? #=> true t.localtime #=> 2000-01-01 14:15:01 -0600 t.utc? #=> false t.localtime("+09:00") #=> 2000-01-02 05:15:01 +0900 t.utc? #=> false If +utc_offset+ is not given and _time_ is local time, just returns the receiver. @overload localtime @return [Time] @overload localtime(utc_offset) @return [Time];T;#0;$@;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE time_localtime_m(int argc, VALUE *argv, VALUE time) { VALUE off; if (rb_check_arity(argc, 0, 1) && !NIL_P(off = argv[0])) { return time_zonelocal(time, off); } return time_localtime(time); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#gmtime;F;7[;[[@i;T;: gmtime;0;[;{;IC; "aConverts _time_ to UTC (GMT), modifying the receiver. t = Time.now #=> 2007-11-19 08:18:31 -0600 t.gmt? #=> false t.gmtime #=> 2007-11-19 14:18:31 UTC t.gmt? #=> true t = Time.now #=> 2007-11-19 08:18:51 -0600 t.utc? #=> false t.utc #=> 2007-11-19 14:18:51 UTC t.utc? #=> true ;T;[o;= ;>I" overload;F;?0;;;@0;:I" gmtime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@";![;"I"@return [Time];T;#0;$@";.F;Bi;C0;7[;$@"o;= ;>I" overload;F;?0;;;@0;:I"utc;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@";![;"I"@return [Time];T;#0;$@";.F;Bi;C0;7[;$@";![;"I"Converts _time_ to UTC (GMT), modifying the receiver. t = Time.now #=> 2007-11-19 08:18:31 -0600 t.gmt? #=> false t.gmtime #=> 2007-11-19 14:18:31 UTC t.gmt? #=> true t = Time.now #=> 2007-11-19 08:18:51 -0600 t.utc? #=> false t.utc #=> 2007-11-19 14:18:51 UTC t.utc? #=> true @overload gmtime @return [Time] @overload utc @return [Time];T;#0;$@";.F;/o;0;1T;2i;3i;%@3;9I"ustatic VALUE time_gmtime(VALUE time) { struct time_object *tobj; struct vtm vtm; GetTimeval(time, tobj); if (TZMODE_UTC_P(tobj)) { if (tobj->tm_got) return time; } else { time_modify(time); } vtm.zone = str_utc; GMTIMEW(tobj->timew, &vtm); tobj->vtm = vtm; tobj->tm_got = 1; TZMODE_SET_UTC(tobj); return time; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Time#utc;F;7[;[[@i;T;;;0;[;{;IC; "aConverts _time_ to UTC (GMT), modifying the receiver. t = Time.now #=> 2007-11-19 08:18:31 -0600 t.gmt? #=> false t.gmtime #=> 2007-11-19 14:18:31 UTC t.gmt? #=> true t = Time.now #=> 2007-11-19 08:18:51 -0600 t.utc? #=> false t.utc #=> 2007-11-19 14:18:51 UTC t.utc? #=> true ;T;[o;= ;>I" overload;F;?0;;;@0;:I" gmtime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@J;![;"I"@return [Time];T;#0;$@J;.F;Bi;C0;7[;$@Jo;= ;>I" overload;F;?0;;;@0;:I"utc;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@J;![;"I"@return [Time];T;#0;$@J;.F;Bi;C0;7[;$@J;![;"@F;#0;$@J;.F;/o;0;1T;2i;3i;%@3;9I"ustatic VALUE time_gmtime(VALUE time) { struct time_object *tobj; struct vtm vtm; GetTimeval(time, tobj); if (TZMODE_UTC_P(tobj)) { if (tobj->tm_got) return time; } else { time_modify(time); } vtm.zone = str_utc; GMTIMEW(tobj->timew, &vtm); tobj->vtm = vtm; tobj->tm_got = 1; TZMODE_SET_UTC(tobj); return time; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#getlocal;F;7[[@90;[[@iH;T;: getlocal;0;[;{;IC; "vReturns a new Time object representing _time_ in local time (using the local time zone in effect for this process). If +utc_offset+ is given, it is used instead of the local time. +utc_offset+ can be given as a human-readable string (eg. "+09:00") or as a number of seconds (eg. 32400). t = Time.utc(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC t.utc? #=> true l = t.getlocal #=> 2000-01-01 14:15:01 -0600 l.utc? #=> false t == l #=> true j = t.getlocal("+09:00") #=> 2000-01-02 05:15:01 +0900 j.utc? #=> false t == j #=> true k = t.getlocal(9*60*60) #=> 2000-01-02 05:15:01 +0900 k.utc? #=> false t == k #=> true ;T;[o;= ;>I" overload;F;?0;;;@0;:I" getlocal;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@q;![;"I"@return [Time];T;#0;$@q;.F;Bi;C0;7[;$@qo;= ;>I" overload;F;?0;;;@0;:I"getlocal(utc_offset);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@q;![;"I"@return [Time];T;#0;$@q;.F;Bi;C0;7[[I"utc_offset;T0;$@qo;= ;>I" overload;F;?0;;;@0;:I"getlocal(timezone);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@q;![;"I"@return [Time];T;#0;$@q;.F;Bi;C0;7[[I" timezone;T0;$@q;![;"I"Returns a new Time object representing _time_ in local time (using the local time zone in effect for this process). If +utc_offset+ is given, it is used instead of the local time. +utc_offset+ can be given as a human-readable string (eg. "+09:00") or as a number of seconds (eg. 32400). t = Time.utc(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC t.utc? #=> true l = t.getlocal #=> 2000-01-01 14:15:01 -0600 l.utc? #=> false t == l #=> true j = t.getlocal("+09:00") #=> 2000-01-02 05:15:01 +0900 j.utc? #=> false t == j #=> true k = t.getlocal(9*60*60) #=> 2000-01-02 05:15:01 +0900 k.utc? #=> false t == k #=> true @overload getlocal @return [Time] @overload getlocal(utc_offset) @return [Time] @overload getlocal(timezone) @return [Time];T;#0;$@q;.F;/o;0;1T;2i+;3iG;%@3;9I"ustatic VALUE time_getlocaltime(int argc, VALUE *argv, VALUE time) { VALUE off; if (rb_check_arity(argc, 0, 1) && !NIL_P(off = argv[0])) { VALUE zone = off; if (maybe_tzobj_p(zone)) { VALUE t = time_dup(time); if (zone_localtime(off, t)) return t; } if (NIL_P(off = utc_offset_arg(off))) { off = zone; if (NIL_P(zone = find_timezone(time, off))) invalid_utc_offset(off); time = time_dup(time); if (!zone_localtime(zone, time)) invalid_utc_offset(off); return time; } else if (off == UTC_ZONE) { return time_gmtime(time_dup(time)); } validate_utc_offset(off); time = time_dup(time); time_set_utc_offset(time, off); return time_fixoff(time); } return time_localtime(time_dup(time)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#getgm;F;7[;[[@iv;T;: getgm;0;[;{;IC; "JReturns a new Time object representing _time_ in UTC. t = Time.local(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 -0600 t.gmt? #=> false y = t.getgm #=> 2000-01-02 02:15:01 UTC y.gmt? #=> true t == y #=> true ;T;[o;= ;>I" overload;F;?0;;;@0;:I" getgm;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@;![;"I"@return [Time];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;: getutc;@0;:I" getutc;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@;![;"I"@return [Time];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a new Time object representing _time_ in UTC. t = Time.local(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 -0600 t.gmt? #=> false y = t.getgm #=> 2000-01-02 02:15:01 UTC y.gmt? #=> true t == y #=> true @overload getgm @return [Time] @overload getutc @return [Time];T;#0;$@;.F;/o;0;1T;2ih;3it;%@3;9I"Xstatic VALUE time_getgmtime(VALUE time) { return time_gmtime(time_dup(time)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#getutc;F;7[;[[@iv;T;;;0;[;{;IC; "JReturns a new Time object representing _time_ in UTC. t = Time.local(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 -0600 t.gmt? #=> false y = t.getgm #=> 2000-01-02 02:15:01 UTC y.gmt? #=> true t == y #=> true ;T;[o;= ;>I" overload;F;?0;;;@0;:I" getgm;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@;![;"I"@return [Time];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" getutc;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@;![;"I"@return [Time];T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2ih;3it;%@3;9I"Xstatic VALUE time_getgmtime(VALUE time) { return time_gmtime(time_dup(time)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#ctime;F;7[;[[@i;T;;5;0;[;{;IC; "Returns a canonical string representation of _time_. Time.now.asctime #=> "Wed Apr 9 08:56:03 2003" Time.now.ctime #=> "Wed Apr 9 08:56:03 2003" ;T;[o;= ;>I" overload;F;?0;;;@0;:I" asctime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;5;@0;:I" ctime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a canonical string representation of _time_. Time.now.asctime #=> "Wed Apr 9 08:56:03 2003" Time.now.ctime #=> "Wed Apr 9 08:56:03 2003" @overload asctime @return [String] @overload ctime @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@3;9I"sstatic VALUE time_asctime(VALUE time) { return strftimev("%a %b %e %T %Y", time, rb_usascii_encoding()); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#asctime;F;7[;[[@i;T;;;0;[;{;IC; "Returns a canonical string representation of _time_. Time.now.asctime #=> "Wed Apr 9 08:56:03 2003" Time.now.ctime #=> "Wed Apr 9 08:56:03 2003" ;T;[o;= ;>I" overload;F;?0;;;@0;:I" asctime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@";![;"I"@return [String];T;#0;$@";.F;Bi;C0;7[;$@"o;= ;>I" overload;F;?0;;5;@0;:I" ctime;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@";![;"I"@return [String];T;#0;$@";.F;Bi;C0;7[;$@";![;"@;#0;$@";.F;/o;0;1T;2i;3i;%@3;9I"sstatic VALUE time_asctime(VALUE time) { return strftimev("%a %b %e %T %Y", time, rb_usascii_encoding()); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#to_s;F;7[;[[@i;T;;G;0;[;{;IC; "Returns a string representing _time_. Equivalent to calling #strftime with the appropriate format string. t = Time.now t.to_s #=> "2012-11-10 18:16:12 +0100" t.strftime "%Y-%m-%d %H:%M:%S %z" #=> "2012-11-10 18:16:12 +0100" t.utc.to_s #=> "2012-11-10 17:16:12 UTC" t.strftime "%Y-%m-%d %H:%M:%S UTC" #=> "2012-11-10 17:16:12 UTC" ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@I;![;"I"@return [String];T;#0;$@I;.F;Bi;C0;7[;$@I;![;"I"Returns a string representing _time_. Equivalent to calling #strftime with the appropriate format string. t = Time.now t.to_s #=> "2012-11-10 18:16:12 +0100" t.strftime "%Y-%m-%d %H:%M:%S %z" #=> "2012-11-10 18:16:12 +0100" t.utc.to_s #=> "2012-11-10 17:16:12 UTC" t.strftime "%Y-%m-%d %H:%M:%S UTC" #=> "2012-11-10 17:16:12 UTC" @overload to_s @return [String];T;#0;$@I;.F;/o;0;1T;2i;3i;%@3;9I"%static VALUE time_to_s(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); if (TZMODE_UTC_P(tobj)) return strftimev("%Y-%m-%d %H:%M:%S UTC", time, rb_usascii_encoding()); else return strftimev("%Y-%m-%d %H:%M:%S %z", time, rb_usascii_encoding()); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#inspect;F;7[;[[@i;T;;J;0;[;{;IC; "Returns a detailed string representing _time_. Unlike to_s, preserves subsecond in the representation for easier debugging. t = Time.now t.inspect #=> "2012-11-10 18:16:12.261257655 +0100" t.strftime "%Y-%m-%d %H:%M:%S.%N %z" #=> "2012-11-10 18:16:12.261257655 +0100" t.utc.inspect #=> "2012-11-10 17:16:12.261257655 UTC" t.strftime "%Y-%m-%d %H:%M:%S.%N UTC" #=> "2012-11-10 17:16:12.261257655 UTC" ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@d;![;"I"@return [String];T;#0;$@d;.F;Bi;C0;7[;$@d;![;"I"Returns a detailed string representing _time_. Unlike to_s, preserves subsecond in the representation for easier debugging. t = Time.now t.inspect #=> "2012-11-10 18:16:12.261257655 +0100" t.strftime "%Y-%m-%d %H:%M:%S.%N %z" #=> "2012-11-10 18:16:12.261257655 +0100" t.utc.inspect #=> "2012-11-10 17:16:12.261257655 UTC" t.strftime "%Y-%m-%d %H:%M:%S.%N UTC" #=> "2012-11-10 17:16:12.261257655 UTC" @overload inspect @return [String];T;#0;$@d;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE time_inspect(VALUE time) { struct time_object *tobj; VALUE str, subsec; GetTimeval(time, tobj); str = strftimev("%Y-%m-%d %H:%M:%S", time, rb_usascii_encoding()); subsec = w2v(wmod(tobj->timew, WINT2FIXWV(TIME_SCALE))); if (FIXNUM_P(subsec) && FIX2LONG(subsec) == 0) { } else if (FIXNUM_P(subsec) && FIX2LONG(subsec) < TIME_SCALE) { long len; rb_str_catf(str, ".%09ld", FIX2LONG(subsec)); for (len=RSTRING_LEN(str); RSTRING_PTR(str)[len-1] == '0' && len > 0; len--) ; rb_str_resize(str, len); } else { rb_str_cat_cstr(str, " "); subsec = quov(subsec, INT2FIX(TIME_SCALE)); rb_str_concat(str, rb_obj_as_string(subsec)); } if (TZMODE_UTC_P(tobj)) { rb_str_cat_cstr(str, " UTC"); } else { /* ?TODO: subsecond offset */ long off = NUM2LONG(rb_funcall(tobj->vtm.utc_offset, rb_intern("round"), 0)); char sign = (off < 0) ? (off = -off, '-') : '+'; int sec = off % 60; int min = (off /= 60) % 60; off /= 60; rb_str_catf(str, " %c%.2d%.2d", sign, (int)off, min); if (sec) rb_str_catf(str, "%.2d", sec); } return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#to_a;F;7[;[[@io;T;;;0;[;{;IC; "Returns a ten-element _array_ of values for _time_: [sec, min, hour, day, month, year, wday, yday, isdst, zone] See the individual methods for an explanation of the valid ranges of each value. The ten elements can be passed directly to Time.utc or Time.local to create a new Time object. t = Time.now #=> 2007-11-19 08:36:01 -0600 now = t.to_a #=> [1, 36, 8, 19, 11, 2007, 1, 323, false, "CST"] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_a;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a ten-element _array_ of values for _time_: [sec, min, hour, day, month, year, wday, yday, isdst, zone] See the individual methods for an explanation of the valid ranges of each value. The ten elements can be passed directly to Time.utc or Time.local to create a new Time object. t = Time.now #=> 2007-11-19 08:36:01 -0600 now = t.to_a #=> [1, 36, 8, 19, 11, 2007, 1, 323, false, "CST"] @overload to_a @return [Array];T;#0;$@;.F;/o;0;1T;2i^;3il;%@3;9I"static VALUE time_to_a(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); MAKE_TM_ENSURE(time, tobj, tobj->vtm.yday != 0); return rb_ary_new3(10, INT2FIX(tobj->vtm.sec), INT2FIX(tobj->vtm.min), INT2FIX(tobj->vtm.hour), INT2FIX(tobj->vtm.mday), INT2FIX(tobj->vtm.mon), tobj->vtm.year, INT2FIX(tobj->vtm.wday), INT2FIX(tobj->vtm.yday), RBOOL(tobj->vtm.isdst), time_zone(time)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Time#+;F;7[[I" time2;T0;[[@i ;T;;;0;[;{;IC; "Adds some number of seconds (possibly including subsecond) to _time_ and returns that value as a new Time object. t = Time.now #=> 2020-07-20 22:14:43.170490982 +0900 t + (60 * 60 * 24) #=> 2020-07-21 22:14:43.170490982 +0900 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"+(numeric);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@;![;"I"@return [Time];T;#0;$@;.F;Bi;C0;7[[I" numeric;T0;$@;![;"I"Adds some number of seconds (possibly including subsecond) to _time_ and returns that value as a new Time object. t = Time.now #=> 2020-07-20 22:14:43.170490982 +0900 t + (60 * 60 * 24) #=> 2020-07-21 22:14:43.170490982 +0900 @overload +(numeric) @return [Time];T;#0;$@;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE time_plus(VALUE time1, VALUE time2) { struct time_object *tobj; GetTimeval(time1, tobj); if (IsTimeval(time2)) { rb_raise(rb_eTypeError, "time + time?"); } return time_add(tobj, time1, time2, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Time#-;F;7[[I" time2;T0;[[@i&;T;;;0;[;{;IC; "mReturns a difference in seconds as a Float between _time_ and +other_time+, or subtracts the given number of seconds in +numeric+ from _time_. t = Time.now #=> 2020-07-20 22:15:49.302766336 +0900 t2 = t + 2592000 #=> 2020-08-19 22:15:49.302766336 +0900 t2 - t #=> 2592000.0 t2 - 2592000 #=> 2020-07-20 22:15:49.302766336 +0900 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"-(other_time);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"other_time;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"-(numeric);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@;![;"I"@return [Time];T;#0;$@;.F;Bi;C0;7[[I" numeric;T0;$@;![;"I"Returns a difference in seconds as a Float between _time_ and +other_time+, or subtracts the given number of seconds in +numeric+ from _time_. t = Time.now #=> 2020-07-20 22:15:49.302766336 +0900 t2 = t + 2592000 #=> 2020-08-19 22:15:49.302766336 +0900 t2 - t #=> 2592000.0 t2 - 2592000 #=> 2020-07-20 22:15:49.302766336 +0900 @overload -(other_time) @return [Float] @overload -(numeric) @return [Time];T;#0;$@;.F;/o;0;1T;2i;3i$;%@3;9I"Nstatic VALUE time_minus(VALUE time1, VALUE time2) { struct time_object *tobj; GetTimeval(time1, tobj); if (IsTimeval(time2)) { struct time_object *tobj2; GetTimeval(time2, tobj2); return rb_Float(rb_time_unmagnify_to_float(wsub(tobj->timew, tobj2->timew))); } return time_add(tobj, time1, time2, -1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#round;F;7[[@90;[[@ia;T;: round;0;[;{;IC; "yRounds subsecond to a given precision in decimal digits (0 digits by default). It returns a new Time object. +ndigits+ should be zero or a positive integer. t = Time.utc(2010,3,30, 5,43,25.123456789r) t #=> 2010-03-30 05:43:25.123456789 UTC t.round #=> 2010-03-30 05:43:25 UTC t.round(0) #=> 2010-03-30 05:43:25 UTC t.round(1) #=> 2010-03-30 05:43:25.1 UTC t.round(2) #=> 2010-03-30 05:43:25.12 UTC t.round(3) #=> 2010-03-30 05:43:25.123 UTC t.round(4) #=> 2010-03-30 05:43:25.1235 UTC t = Time.utc(1999,12,31, 23,59,59) (t + 0.4).round #=> 1999-12-31 23:59:59 UTC (t + 0.49).round #=> 1999-12-31 23:59:59 UTC (t + 0.5).round #=> 2000-01-01 00:00:00 UTC (t + 1.4).round #=> 2000-01-01 00:00:00 UTC (t + 1.49).round #=> 2000-01-01 00:00:00 UTC (t + 1.5).round #=> 2000-01-01 00:00:01 UTC t = Time.utc(1999,12,31, 23,59,59) #=> 1999-12-31 23:59:59 UTC (t + 0.123456789).round(4).iso8601(6) #=> 1999-12-31 23:59:59.1235 UTC ;T;[o;= ;>I" overload;F;?0;;;@0;:I"round([ndigits]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@;![;"I"@return [Time];T;#0;$@;.F;Bi;C0;7[[I"[ndigits];T0;$@;![;"I"Rounds subsecond to a given precision in decimal digits (0 digits by default). It returns a new Time object. +ndigits+ should be zero or a positive integer. t = Time.utc(2010,3,30, 5,43,25.123456789r) t #=> 2010-03-30 05:43:25.123456789 UTC t.round #=> 2010-03-30 05:43:25 UTC t.round(0) #=> 2010-03-30 05:43:25 UTC t.round(1) #=> 2010-03-30 05:43:25.1 UTC t.round(2) #=> 2010-03-30 05:43:25.12 UTC t.round(3) #=> 2010-03-30 05:43:25.123 UTC t.round(4) #=> 2010-03-30 05:43:25.1235 UTC t = Time.utc(1999,12,31, 23,59,59) (t + 0.4).round #=> 1999-12-31 23:59:59 UTC (t + 0.49).round #=> 1999-12-31 23:59:59 UTC (t + 0.5).round #=> 2000-01-01 00:00:00 UTC (t + 1.4).round #=> 2000-01-01 00:00:00 UTC (t + 1.49).round #=> 2000-01-01 00:00:00 UTC (t + 1.5).round #=> 2000-01-01 00:00:01 UTC t = Time.utc(1999,12,31, 23,59,59) #=> 1999-12-31 23:59:59 UTC (t + 0.123456789).round(4).iso8601(6) #=> 1999-12-31 23:59:59.1235 UTC @overload round([ndigits]) @return [Time];T;#0;$@;.F;/o;0;1T;2iD;3i^;%@3;9I"static VALUE time_round(int argc, VALUE *argv, VALUE time) { VALUE ndigits, v, den; struct time_object *tobj; if (!rb_check_arity(argc, 0, 1) || NIL_P(ndigits = argv[0])) den = INT2FIX(1); else den = ndigits_denominator(ndigits); GetTimeval(time, tobj); v = w2v(rb_time_unmagnify(tobj->timew)); v = modv(v, den); if (lt(v, quov(den, INT2FIX(2)))) return time_add(tobj, time, v, -1); else return time_add(tobj, time, subv(den, v), 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#floor;F;7[[@90;[[@i;T;: floor;0;[;{;IC; "Floors subsecond to a given precision in decimal digits (0 digits by default). It returns a new Time object. +ndigits+ should be zero or a positive integer. t = Time.utc(2010,3,30, 5,43,25.123456789r) t #=> 2010-03-30 05:43:25.123456789 UTC t.floor #=> 2010-03-30 05:43:25 UTC t.floor(0) #=> 2010-03-30 05:43:25 UTC t.floor(1) #=> 2010-03-30 05:43:25.1 UTC t.floor(2) #=> 2010-03-30 05:43:25.12 UTC t.floor(3) #=> 2010-03-30 05:43:25.123 UTC t.floor(4) #=> 2010-03-30 05:43:25.1234 UTC t = Time.utc(1999,12,31, 23,59,59) (t + 0.4).floor #=> 1999-12-31 23:59:59 UTC (t + 0.9).floor #=> 1999-12-31 23:59:59 UTC (t + 1.4).floor #=> 2000-01-01 00:00:00 UTC (t + 1.9).floor #=> 2000-01-01 00:00:00 UTC t = Time.utc(1999,12,31, 23,59,59) (t + 0.123456789).floor(4) #=> 1999-12-31 23:59:59.1234 UTC ;T;[o;= ;>I" overload;F;?0;;;@0;:I"floor([ndigits]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@;![;"I"@return [Time];T;#0;$@;.F;Bi;C0;7[[I"[ndigits];T0;$@;![;"I"Floors subsecond to a given precision in decimal digits (0 digits by default). It returns a new Time object. +ndigits+ should be zero or a positive integer. t = Time.utc(2010,3,30, 5,43,25.123456789r) t #=> 2010-03-30 05:43:25.123456789 UTC t.floor #=> 2010-03-30 05:43:25 UTC t.floor(0) #=> 2010-03-30 05:43:25 UTC t.floor(1) #=> 2010-03-30 05:43:25.1 UTC t.floor(2) #=> 2010-03-30 05:43:25.12 UTC t.floor(3) #=> 2010-03-30 05:43:25.123 UTC t.floor(4) #=> 2010-03-30 05:43:25.1234 UTC t = Time.utc(1999,12,31, 23,59,59) (t + 0.4).floor #=> 1999-12-31 23:59:59 UTC (t + 0.9).floor #=> 1999-12-31 23:59:59 UTC (t + 1.4).floor #=> 2000-01-01 00:00:00 UTC (t + 1.9).floor #=> 2000-01-01 00:00:00 UTC t = Time.utc(1999,12,31, 23,59,59) (t + 0.123456789).floor(4) #=> 1999-12-31 23:59:59.1234 UTC @overload floor([ndigits]) @return [Time];T;#0;$@;.F;/o;0;1T;2iv;3i;%@3;9I"static VALUE time_floor(int argc, VALUE *argv, VALUE time) { VALUE ndigits, v, den; struct time_object *tobj; if (!rb_check_arity(argc, 0, 1) || NIL_P(ndigits = argv[0])) den = INT2FIX(1); else den = ndigits_denominator(ndigits); GetTimeval(time, tobj); v = w2v(rb_time_unmagnify(tobj->timew)); v = modv(v, den); return time_add(tobj, time, v, -1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#ceil;F;7[[@90;[[@i;T;: ceil;0;[;{;IC; "Ceils subsecond to a given precision in decimal digits (0 digits by default). It returns a new Time object. +ndigits+ should be zero or a positive integer. t = Time.utc(2010,3,30, 5,43,25.0123456789r) t #=> 2010-03-30 05:43:25 123456789/10000000000 UTC t.ceil #=> 2010-03-30 05:43:26 UTC t.ceil(0) #=> 2010-03-30 05:43:26 UTC t.ceil(1) #=> 2010-03-30 05:43:25.1 UTC t.ceil(2) #=> 2010-03-30 05:43:25.02 UTC t.ceil(3) #=> 2010-03-30 05:43:25.013 UTC t.ceil(4) #=> 2010-03-30 05:43:25.0124 UTC t = Time.utc(1999,12,31, 23,59,59) (t + 0.4).ceil #=> 2000-01-01 00:00:00 UTC (t + 0.9).ceil #=> 2000-01-01 00:00:00 UTC (t + 1.4).ceil #=> 2000-01-01 00:00:01 UTC (t + 1.9).ceil #=> 2000-01-01 00:00:01 UTC t = Time.utc(1999,12,31, 23,59,59) (t + 0.123456789).ceil(4) #=> 1999-12-31 23:59:59.1235 UTC ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ceil([ndigits]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@#;![;"I"@return [Time];T;#0;$@#;.F;Bi;C0;7[[I"[ndigits];T0;$@#;![;"I" Ceils subsecond to a given precision in decimal digits (0 digits by default). It returns a new Time object. +ndigits+ should be zero or a positive integer. t = Time.utc(2010,3,30, 5,43,25.0123456789r) t #=> 2010-03-30 05:43:25 123456789/10000000000 UTC t.ceil #=> 2010-03-30 05:43:26 UTC t.ceil(0) #=> 2010-03-30 05:43:26 UTC t.ceil(1) #=> 2010-03-30 05:43:25.1 UTC t.ceil(2) #=> 2010-03-30 05:43:25.02 UTC t.ceil(3) #=> 2010-03-30 05:43:25.013 UTC t.ceil(4) #=> 2010-03-30 05:43:25.0124 UTC t = Time.utc(1999,12,31, 23,59,59) (t + 0.4).ceil #=> 2000-01-01 00:00:00 UTC (t + 0.9).ceil #=> 2000-01-01 00:00:00 UTC (t + 1.4).ceil #=> 2000-01-01 00:00:01 UTC (t + 1.9).ceil #=> 2000-01-01 00:00:01 UTC t = Time.utc(1999,12,31, 23,59,59) (t + 0.123456789).ceil(4) #=> 1999-12-31 23:59:59.1235 UTC @overload ceil([ndigits]) @return [Time];T;#0;$@#;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE time_ceil(int argc, VALUE *argv, VALUE time) { VALUE ndigits, v, den; struct time_object *tobj; if (!rb_check_arity(argc, 0, 1) || NIL_P(ndigits = argv[0])) den = INT2FIX(1); else den = ndigits_denominator(ndigits); GetTimeval(time, tobj); v = w2v(rb_time_unmagnify(tobj->timew)); v = modv(v, den); if (!rb_equal(v, INT2FIX(0))) { v = subv(den, v); } return time_add(tobj, time, v, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Time#sec;F;7[;[[@i;T;;z;0;[;{;IC; "Returns the second of the minute (0..60) for _time_. *Note:* Seconds range from zero to 60 to allow the system to inject leap seconds. See https://en.wikipedia.org/wiki/Leap_second for further details. t = Time.now #=> 2007-11-19 08:25:02 -0600 t.sec #=> 2 ;T;[o;= ;>I" overload;F;?0;;z;@0;:I"sec;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@A;![;"I"@return [Integer];T;#0;$@A;.F;Bi;C0;7[;$@A;![;"I"7Returns the second of the minute (0..60) for _time_. *Note:* Seconds range from zero to 60 to allow the system to inject leap seconds. See https://en.wikipedia.org/wiki/Leap_second for further details. t = Time.now #=> 2007-11-19 08:25:02 -0600 t.sec #=> 2 @overload sec @return [Integer];T;#0;$@A;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE time_sec(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); MAKE_TM(time, tobj); return INT2FIX(tobj->vtm.sec); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Time#min;F;7[;[[@i;T;;;0;[;{;IC; "|Returns the minute of the hour (0..59) for _time_. t = Time.now #=> 2007-11-19 08:25:51 -0600 t.min #=> 25 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"min;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@\;![;"I"@return [Integer];T;#0;$@\;.F;Bi;C0;7[;$@\;![;"I"Returns the minute of the hour (0..59) for _time_. t = Time.now #=> 2007-11-19 08:25:51 -0600 t.min #=> 25 @overload min @return [Integer];T;#0;$@\;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE time_min(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); MAKE_TM(time, tobj); return INT2FIX(tobj->vtm.min); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#hour;F;7[;[[@i ;T;;x;0;[;{;IC; "}Returns the hour of the day (0..23) for _time_. t = Time.now #=> 2007-11-19 08:26:20 -0600 t.hour #=> 8 ;T;[o;= ;>I" overload;F;?0;;x;@0;:I" hour;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@w;![;"I"@return [Integer];T;#0;$@w;.F;Bi;C0;7[;$@w;![;"I"Returns the hour of the day (0..23) for _time_. t = Time.now #=> 2007-11-19 08:26:20 -0600 t.hour #=> 8 @overload hour @return [Integer];T;#0;$@w;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE time_hour(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); MAKE_TM(time, tobj); return INT2FIX(tobj->vtm.hour); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#mday;F;7[;[[@i;T;;g;0;[;{;IC; "Returns the day of the month (1..31) for _time_. t = Time.now #=> 2007-11-19 08:27:03 -0600 t.day #=> 19 t.mday #=> 19 ;T;[o;= ;>I" overload;F;?0;;h;@0;:I"day;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;g;@0;:I" mday;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the day of the month (1..31) for _time_. t = Time.now #=> 2007-11-19 08:27:03 -0600 t.day #=> 19 t.mday #=> 19 @overload day @return [Integer] @overload mday @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE time_mday(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); MAKE_TM(time, tobj); return INT2FIX(tobj->vtm.mday); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Time#day;F;7[;[[@i;T;;h;0;[;{;IC; "Returns the day of the month (1..31) for _time_. t = Time.now #=> 2007-11-19 08:27:03 -0600 t.day #=> 19 t.mday #=> 19 ;T;[o;= ;>I" overload;F;?0;;h;@0;:I"day;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;g;@0;:I" mday;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE time_mday(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); MAKE_TM(time, tobj); return INT2FIX(tobj->vtm.mday); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Time#mon;F;7[;[[@i5;T;;e;0;[;{;IC; "Returns the month of the year (1..12) for _time_. t = Time.now #=> 2007-11-19 08:27:30 -0600 t.mon #=> 11 t.month #=> 11 ;T;[o;= ;>I" overload;F;?0;;e;@0;:I"mon;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;f;@0;:I" month;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the month of the year (1..12) for _time_. t = Time.now #=> 2007-11-19 08:27:30 -0600 t.mon #=> 11 t.month #=> 11 @overload mon @return [Integer] @overload month @return [Integer];T;#0;$@;.F;/o;0;1T;2i);3i3;%@3;9I"static VALUE time_mon(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); MAKE_TM(time, tobj); return INT2FIX(tobj->vtm.mon); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#month;F;7[;[[@i5;T;;f;0;[;{;IC; "Returns the month of the year (1..12) for _time_. t = Time.now #=> 2007-11-19 08:27:30 -0600 t.mon #=> 11 t.month #=> 11 ;T;[o;= ;>I" overload;F;?0;;e;@0;:I"mon;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;;f;@0;:I" month;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"@;#0;$@ ;.F;/o;0;1T;2i);3i3;%@3;9I"static VALUE time_mon(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); MAKE_TM(time, tobj); return INT2FIX(tobj->vtm.mon); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#year;F;7[;[[@iI;T;;c;0;[;{;IC; "Returns the year for _time_ (including the century). t = Time.now #=> 2007-11-19 08:27:51 -0600 t.year #=> 2007 ;T;[o;= ;>I" overload;F;?0;;c;@0;:I" year;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@0;![;"I"@return [Integer];T;#0;$@0;.F;Bi;C0;7[;$@0;![;"I"Returns the year for _time_ (including the century). t = Time.now #=> 2007-11-19 08:27:51 -0600 t.year #=> 2007 @overload year @return [Integer];T;#0;$@0;.F;/o;0;1T;2i?;3iF;%@3;9I"static VALUE time_year(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); MAKE_TM(time, tobj); return tobj->vtm.year; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#wday;F;7[;[[@ie;T;;o;0;[;{;IC; "XReturns an integer representing the day of the week, 0..6, with Sunday == 0. t = Time.now #=> 2007-11-20 02:35:35 -0600 t.wday #=> 2 t.sunday? #=> false t.monday? #=> false t.tuesday? #=> true t.wednesday? #=> false t.thursday? #=> false t.friday? #=> false t.saturday? #=> false ;T;[o;= ;>I" overload;F;?0;;o;@0;:I" wday;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@K;![;"I"@return [Integer];T;#0;$@K;.F;Bi;C0;7[;$@K;![;"I"}Returns an integer representing the day of the week, 0..6, with Sunday == 0. t = Time.now #=> 2007-11-20 02:35:35 -0600 t.wday #=> 2 t.sunday? #=> false t.monday? #=> false t.tuesday? #=> true t.wednesday? #=> false t.thursday? #=> false t.friday? #=> false t.saturday? #=> false @overload wday @return [Integer];T;#0;$@K;.F;/o;0;1T;2iS;3ib;%@3;9I"static VALUE time_wday(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); MAKE_TM_ENSURE(time, tobj, tobj->vtm.wday != VTM_WDAY_INITVAL); return INT2FIX((int)tobj->vtm.wday); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#yday;F;7[;[[@i;T;;d;0;[;{;IC; "Returns an integer representing the day of the year, 1..366. t = Time.now #=> 2007-11-19 08:32:31 -0600 t.yday #=> 323 ;T;[o;= ;>I" overload;F;?0;;d;@0;:I" yday;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@f;![;"I"@return [Integer];T;#0;$@f;.F;Bi;C0;7[;$@f;![;"I"Returns an integer representing the day of the year, 1..366. t = Time.now #=> 2007-11-19 08:32:31 -0600 t.yday #=> 323 @overload yday @return [Integer];T;#0;$@f;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE time_yday(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); MAKE_TM_ENSURE(time, tobj, tobj->vtm.yday != 0); return INT2FIX(tobj->vtm.yday); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#isdst;F;7[;[[@i;T;: isdst;0;[;{;IC; "xReturns +true+ if _time_ occurs during Daylight Saving Time in its time zone. # CST6CDT: Time.local(2000, 1, 1).zone #=> "CST" Time.local(2000, 1, 1).isdst #=> false Time.local(2000, 1, 1).dst? #=> false Time.local(2000, 7, 1).zone #=> "CDT" Time.local(2000, 7, 1).isdst #=> true Time.local(2000, 7, 1).dst? #=> true # Asia/Tokyo: Time.local(2000, 1, 1).zone #=> "JST" Time.local(2000, 1, 1).isdst #=> false Time.local(2000, 1, 1).dst? #=> false Time.local(2000, 7, 1).zone #=> "JST" Time.local(2000, 7, 1).isdst #=> false Time.local(2000, 7, 1).dst? #=> false ;T;[o;= ;>I" overload;F;?0;;;@0;:I" isdst;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;: dst?;@0;:I" dst?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns +true+ if _time_ occurs during Daylight Saving Time in its time zone. # CST6CDT: Time.local(2000, 1, 1).zone #=> "CST" Time.local(2000, 1, 1).isdst #=> false Time.local(2000, 1, 1).dst? #=> false Time.local(2000, 7, 1).zone #=> "CDT" Time.local(2000, 7, 1).isdst #=> true Time.local(2000, 7, 1).dst? #=> true # Asia/Tokyo: Time.local(2000, 1, 1).zone #=> "JST" Time.local(2000, 1, 1).isdst #=> false Time.local(2000, 1, 1).dst? #=> false Time.local(2000, 7, 1).zone #=> "JST" Time.local(2000, 7, 1).isdst #=> false Time.local(2000, 7, 1).dst? #=> false @overload isdst @return [Boolean] @overload dst? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE time_isdst(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); MAKE_TM(time, tobj); if (tobj->vtm.isdst == VTM_ISDST_INITVAL) { rb_raise(rb_eRuntimeError, "isdst is not set yet"); } return RBOOL(tobj->vtm.isdst); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#dst?;F;7[;[[@i;T;;;0;[;{;IC; "xReturns +true+ if _time_ occurs during Daylight Saving Time in its time zone. # CST6CDT: Time.local(2000, 1, 1).zone #=> "CST" Time.local(2000, 1, 1).isdst #=> false Time.local(2000, 1, 1).dst? #=> false Time.local(2000, 7, 1).zone #=> "CDT" Time.local(2000, 7, 1).isdst #=> true Time.local(2000, 7, 1).dst? #=> true # Asia/Tokyo: Time.local(2000, 1, 1).zone #=> "JST" Time.local(2000, 1, 1).isdst #=> false Time.local(2000, 1, 1).dst? #=> false Time.local(2000, 7, 1).zone #=> "JST" Time.local(2000, 7, 1).isdst #=> false Time.local(2000, 7, 1).dst? #=> false;T;[o;= ;>I" overload;F;?0;;;@0;:I" isdst;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" dst?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@3;9I"static VALUE time_isdst(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); MAKE_TM(time, tobj); if (tobj->vtm.isdst == VTM_ISDST_INITVAL) { rb_raise(rb_eRuntimeError, "isdst is not set yet"); } return RBOOL(tobj->vtm.isdst); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#zone;F;7[;[[@i*;T;;;0;[;{;IC; "Returns the name of the time zone used for _time_. As of Ruby 1.8, returns ``UTC'' rather than ``GMT'' for UTC times. t = Time.gm(2000, "jan", 1, 20, 15, 1) t.zone #=> "UTC" t = Time.local(2000, "jan", 1, 20, 15, 1) t.zone #=> "CST" ;T;[o;= ;>I" overload;F;?0;;;@0;:I" zone;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the name of the time zone used for _time_. As of Ruby 1.8, returns ``UTC'' rather than ``GMT'' for UTC times. t = Time.gm(2000, "jan", 1, 20, 15, 1) t.zone #=> "UTC" t = Time.local(2000, "jan", 1, 20, 15, 1) t.zone #=> "CST" @overload zone @return [String];T;#0;$@;.F;/o;0;1T;2i;3i';%@3;9I"rstatic VALUE time_zone(VALUE time) { struct time_object *tobj; VALUE zone; GetTimeval(time, tobj); MAKE_TM(time, tobj); if (TZMODE_UTC_P(tobj)) { return rb_usascii_str_new_cstr("UTC"); } zone = tobj->vtm.zone; if (NIL_P(zone)) return Qnil; if (RB_TYPE_P(zone, T_STRING)) zone = rb_str_dup(zone); return zone; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#gmtoff;F;7[;[[@iN;T;: gmtoff;0;[;{;IC; "Returns the offset in seconds between the timezone of _time_ and UTC. t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC t.gmt_offset #=> 0 l = t.getlocal #=> 2000-01-01 14:15:01 -0600 l.gmt_offset #=> -21600 ;T;[o;= ;>I" overload;F;?0;:gmt_offset;@0;:I"gmt_offset;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" gmtoff;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;:utc_offset;@0;:I"utc_offset;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the offset in seconds between the timezone of _time_ and UTC. t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC t.gmt_offset #=> 0 l = t.getlocal #=> 2000-01-01 14:15:01 -0600 l.gmt_offset #=> -21600 @overload gmt_offset @return [Integer] @overload gmtoff @return [Integer] @overload utc_offset @return [Integer];T;#0;$@;.F;/o;0;1T;2i?;3iM;%@3;9I"VALUE rb_time_utc_offset(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); if (TZMODE_UTC_P(tobj)) { return INT2FIX(0); } else { MAKE_TM(time, tobj); return tobj->vtm.utc_offset; } };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Time#gmt_offset;F;7[;[[@iN;T;;;0;[;{;IC; "Returns the offset in seconds between the timezone of _time_ and UTC. t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC t.gmt_offset #=> 0 l = t.getlocal #=> 2000-01-01 14:15:01 -0600 l.gmt_offset #=> -21600 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"gmt_offset;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;;;@0;:I" gmtoff;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;;;@0;:I"utc_offset;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"@;#0;$@ ;.F;/o;0;1T;2i?;3iM;%@3;9I"VALUE rb_time_utc_offset(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); if (TZMODE_UTC_P(tobj)) { return INT2FIX(0); } else { MAKE_TM(time, tobj); return tobj->vtm.utc_offset; } };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Time#utc_offset;F;7[;[[@iN;T;;;0;[;{;IC; "Returns the offset in seconds between the timezone of _time_ and UTC. t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC t.gmt_offset #=> 0 l = t.getlocal #=> 2000-01-01 14:15:01 -0600 l.gmt_offset #=> -21600 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"gmt_offset;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@T;![;"I"@return [Integer];T;#0;$@T;.F;Bi;C0;7[;$@To;= ;>I" overload;F;?0;;;@0;:I" gmtoff;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@T;![;"I"@return [Integer];T;#0;$@T;.F;Bi;C0;7[;$@To;= ;>I" overload;F;?0;;;@0;:I"utc_offset;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@T;![;"I"@return [Integer];T;#0;$@T;.F;Bi;C0;7[;$@T;![;"@;#0;$@T;.F;/o;0;1T;2i?;3iM;%@3;9I"VALUE rb_time_utc_offset(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); if (TZMODE_UTC_P(tobj)) { return INT2FIX(0); } else { MAKE_TM(time, tobj); return tobj->vtm.utc_offset; } };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Time#utc?;F;7[;[[@iY;T;: utc?;0;[;{;IC; " Returns +true+ if _time_ represents a time in UTC (GMT). t = Time.now #=> 2007-11-19 08:15:23 -0600 t.utc? #=> false t = Time.gm(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC t.utc? #=> true t = Time.now #=> 2007-11-19 08:16:03 -0600 t.gmt? #=> false t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC t.gmt? #=> true;T;[o;= ;>I" overload;F;?0;;;@0;:I" utc?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;: gmt?;@0;:I" gmt?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"TReturns +true+ if _time_ represents a time in UTC (GMT). t = Time.now #=> 2007-11-19 08:15:23 -0600 t.utc? #=> false t = Time.gm(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC t.utc? #=> true t = Time.now #=> 2007-11-19 08:16:03 -0600 t.gmt? #=> false t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC t.gmt? #=> true @overload utc? @return [Boolean] @overload gmt? @return [Boolean];T;#0;$@;.F;/o;0;1T;2iG;3iW;Bi;%@3;9I"static VALUE time_utc_p(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); return RBOOL(TZMODE_UTC_P(tobj)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#gmt?;F;7[;[[@iY;T;;;0;[;{;IC; " Returns +true+ if _time_ represents a time in UTC (GMT). t = Time.now #=> 2007-11-19 08:15:23 -0600 t.utc? #=> false t = Time.gm(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC t.utc? #=> true t = Time.now #=> 2007-11-19 08:16:03 -0600 t.gmt? #=> false t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC t.gmt? #=> true;T;[o;= ;>I" overload;F;?0;;;@0;:I" utc?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" gmt?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2iG;3iW;Bi;%@3;9I"static VALUE time_utc_p(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); return RBOOL(TZMODE_UTC_P(tobj)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#sunday?;F;7[;[[@i};T;;p;0;[;{;IC; "Returns +true+ if _time_ represents Sunday. t = Time.local(1990, 4, 1) #=> 1990-04-01 00:00:00 -0600 t.sunday? #=> true;T;[o;= ;>I" overload;F;?0;;p;@0;:I" sunday?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns +true+ if _time_ represents Sunday. t = Time.local(1990, 4, 1) #=> 1990-04-01 00:00:00 -0600 t.sunday? #=> true @overload sunday? @return [Boolean];T;#0;$@;.F;/o;0;1T;2is;3iz;Bi;%@3;9I" 2003-08-04 00:00:00 -0500 t.monday? #=> true;T;[o;= ;>I" overload;F;?0;;q;@0;:I" monday?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns +true+ if _time_ represents Monday. t = Time.local(2003, 8, 4) #=> 2003-08-04 00:00:00 -0500 t.monday? #=> true @overload monday? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@3;9I" 1991-02-19 00:00:00 -0600 t.tuesday? #=> true;T;[o;= ;>I" overload;F;?0;;r;@0;:I" tuesday?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ ;![;"I"@return [Boolean];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Returns +true+ if _time_ represents Tuesday. t = Time.local(1991, 2, 19) #=> 1991-02-19 00:00:00 -0600 t.tuesday? #=> true @overload tuesday? @return [Boolean];T;#0;$@ ;.F;/o;0;1T;2i;3i;Bi;%@3;9I"=static VALUE time_tuesday(VALUE time) { wday_p(2); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#wednesday?;F;7[;[[@i;T;;s;0;[;{;IC; "Returns +true+ if _time_ represents Wednesday. t = Time.local(1993, 2, 24) #=> 1993-02-24 00:00:00 -0600 t.wednesday? #=> true;T;[o;= ;>I" overload;F;?0;;s;@0;:I"wednesday?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@(;![;"I"@return [Boolean];T;#0;$@(;.F;Bi;C0;7[;$@(;![;"I"Returns +true+ if _time_ represents Wednesday. t = Time.local(1993, 2, 24) #=> 1993-02-24 00:00:00 -0600 t.wednesday? #=> true @overload wednesday? @return [Boolean];T;#0;$@(;.F;/o;0;1T;2i;3i;Bi;%@3;9I"?static VALUE time_wednesday(VALUE time) { wday_p(3); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#thursday?;F;7[;[[@i;T;;t;0;[;{;IC; "Returns +true+ if _time_ represents Thursday. t = Time.local(1995, 12, 21) #=> 1995-12-21 00:00:00 -0600 t.thursday? #=> true;T;[o;= ;>I" overload;F;?0;;t;@0;:I"thursday?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@C;![;"I"@return [Boolean];T;#0;$@C;.F;Bi;C0;7[;$@C;![;"I"Returns +true+ if _time_ represents Thursday. t = Time.local(1995, 12, 21) #=> 1995-12-21 00:00:00 -0600 t.thursday? #=> true @overload thursday? @return [Boolean];T;#0;$@C;.F;/o;0;1T;2i;3i;Bi;%@3;9I">static VALUE time_thursday(VALUE time) { wday_p(4); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#friday?;F;7[;[[@i;T;;u;0;[;{;IC; "Returns +true+ if _time_ represents Friday. t = Time.local(1987, 12, 18) #=> 1987-12-18 00:00:00 -0600 t.friday? #=> true;T;[o;= ;>I" overload;F;?0;;u;@0;:I" friday?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@^;![;"I"@return [Boolean];T;#0;$@^;.F;Bi;C0;7[;$@^;![;"I"Returns +true+ if _time_ represents Friday. t = Time.local(1987, 12, 18) #=> 1987-12-18 00:00:00 -0600 t.friday? #=> true @overload friday? @return [Boolean];T;#0;$@^;.F;/o;0;1T;2i;3i;Bi;%@3;9I" 2006-06-10 00:00:00 -0500 t.saturday? #=> true;T;[o;= ;>I" overload;F;?0;;v;@0;:I"saturday?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@y;![;"I"@return [Boolean];T;#0;$@y;.F;Bi;C0;7[;$@y;![;"I"Returns +true+ if _time_ represents Saturday. t = Time.local(2006, 6, 10) #=> 2006-06-10 00:00:00 -0500 t.saturday? #=> true @overload saturday? @return [Boolean];T;#0;$@y;.F;/o;0;1T;2i;3i;Bi;%@3;9I">static VALUE time_saturday(VALUE time) { wday_p(6); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#tv_sec;F;7[;[[@id ;T;;;0;[;{;IC; "Returns the value of _time_ as an integer number of seconds since the Epoch. If _time_ contains subsecond, they are truncated. t = Time.now #=> 2020-07-21 01:41:29.746012609 +0900 t.to_i #=> 1595263289 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_i;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" tv_sec;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"@X;#0;$@;.F;/o;0;1T;2iV ;3ib ;%@3;9I"static VALUE time_to_i(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); return w2v(wdiv(tobj->timew, WINT2FIXWV(TIME_SCALE))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#tv_usec;F;7[;[[@i ;T;: tv_usec;0;[;{;IC; "Returns the number of microseconds for the subsecond part of _time_. The result is a non-negative integer less than 10**6. t = Time.now #=> 2020-07-20 22:05:58.459785953 +0900 t.usec #=> 459785 If _time_ has fraction of microsecond (such as nanoseconds), it is truncated. t = Time.new(2000,1,1,0,0,0.666_777_888_999r) t.usec #=> 666777 Time#subsec can be used to obtain the subsecond part exactly. ;T;[o;= ;>I" overload;F;?0;: usec;@0;:I" usec;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" tv_usec;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I" Returns the number of microseconds for the subsecond part of _time_. The result is a non-negative integer less than 10**6. t = Time.now #=> 2020-07-20 22:05:58.459785953 +0900 t.usec #=> 459785 If _time_ has fraction of microsecond (such as nanoseconds), it is truncated. t = Time.new(2000,1,1,0,0,0.666_777_888_999r) t.usec #=> 666777 Time#subsec can be used to obtain the subsecond part exactly. @overload usec @return [Integer] @overload tv_usec @return [Integer];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@3;9I"static VALUE time_usec(VALUE time) { struct time_object *tobj; wideval_t w, q, r; GetTimeval(time, tobj); w = wmod(tobj->timew, WINT2WV(TIME_SCALE)); wmuldivmod(w, WINT2FIXWV(1000000), WINT2FIXWV(TIME_SCALE), &q, &r); return rb_to_int(w2v(q)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#usec;F;7[;[[@i ;T;;;0;[;{;IC; "Returns the number of microseconds for the subsecond part of _time_. The result is a non-negative integer less than 10**6. t = Time.now #=> 2020-07-20 22:05:58.459785953 +0900 t.usec #=> 459785 If _time_ has fraction of microsecond (such as nanoseconds), it is truncated. t = Time.new(2000,1,1,0,0,0.666_777_888_999r) t.usec #=> 666777 Time#subsec can be used to obtain the subsecond part exactly. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" usec;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" tv_usec;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2i ;3i ;%@3;9I"static VALUE time_usec(VALUE time) { struct time_object *tobj; wideval_t w, q, r; GetTimeval(time, tobj); w = wmod(tobj->timew, WINT2WV(TIME_SCALE)); wmuldivmod(w, WINT2FIXWV(1000000), WINT2FIXWV(TIME_SCALE), &q, &r); return rb_to_int(w2v(q)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#tv_nsec;F;7[;[[@i ;T;: tv_nsec;0;[;{;IC; "Returns the number of nanoseconds for the subsecond part of _time_. The result is a non-negative integer less than 10**9. t = Time.now #=> 2020-07-20 22:07:10.963933942 +0900 t.nsec #=> 963933942 If _time_ has fraction of nanosecond (such as picoseconds), it is truncated. t = Time.new(2000,1,1,0,0,0.666_777_888_999r) t.nsec #=> 666777888 Time#subsec can be used to obtain the subsecond part exactly. ;T;[o;= ;>I" overload;F;?0;: nsec;@0;:I" nsec;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;;;@0;:I" tv_nsec;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I" Returns the number of nanoseconds for the subsecond part of _time_. The result is a non-negative integer less than 10**9. t = Time.now #=> 2020-07-20 22:07:10.963933942 +0900 t.nsec #=> 963933942 If _time_ has fraction of nanosecond (such as picoseconds), it is truncated. t = Time.new(2000,1,1,0,0,0.666_777_888_999r) t.nsec #=> 666777888 Time#subsec can be used to obtain the subsecond part exactly. @overload nsec @return [Integer] @overload tv_nsec @return [Integer];T;#0;$@ ;.F;/o;0;1T;2i ;3i ;%@3;9I"static VALUE time_nsec(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); return rb_to_int(w2v(wmulquoll(wmod(tobj->timew, WINT2WV(TIME_SCALE)), 1000000000, TIME_SCALE))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#nsec;F;7[;[[@i ;T;;;0;[;{;IC; "Returns the number of nanoseconds for the subsecond part of _time_. The result is a non-negative integer less than 10**9. t = Time.now #=> 2020-07-20 22:07:10.963933942 +0900 t.nsec #=> 963933942 If _time_ has fraction of nanosecond (such as picoseconds), it is truncated. t = Time.new(2000,1,1,0,0,0.666_777_888_999r) t.nsec #=> 666777888 Time#subsec can be used to obtain the subsecond part exactly. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" nsec;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@2;![;"I"@return [Integer];T;#0;$@2;.F;Bi;C0;7[;$@2o;= ;>I" overload;F;?0;;;@0;:I" tv_nsec;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@2;![;"I"@return [Integer];T;#0;$@2;.F;Bi;C0;7[;$@2;![;"@.;#0;$@2;.F;/o;0;1T;2i ;3i ;%@3;9I"static VALUE time_nsec(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); return rb_to_int(w2v(wmulquoll(wmod(tobj->timew, WINT2WV(TIME_SCALE)), 1000000000, TIME_SCALE))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#subsec;F;7[;[[@i ;T;: subsec;0;[;{;IC; "Returns the subsecond for _time_. The return value can be a rational number. t = Time.now #=> 2020-07-20 15:40:26.867462289 +0900 t.subsec #=> (867462289/1000000000) t = Time.now #=> 2020-07-20 15:40:50.313828595 +0900 t.subsec #=> (62765719/200000000) t = Time.new(2000,1,1,2,3,4) #=> 2000-01-01 02:03:04 +0900 t.subsec #=> 0 Time.new(2000,1,1,0,0,1/3r,"UTC").subsec #=> (1/3) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" subsec;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@Y;![;"I"@return [Numeric];T;#0;$@Y;.F;Bi;C0;7[;$@Y;![;"I"Returns the subsecond for _time_. The return value can be a rational number. t = Time.now #=> 2020-07-20 15:40:26.867462289 +0900 t.subsec #=> (867462289/1000000000) t = Time.now #=> 2020-07-20 15:40:50.313828595 +0900 t.subsec #=> (62765719/200000000) t = Time.new(2000,1,1,2,3,4) #=> 2000-01-01 02:03:04 +0900 t.subsec #=> 0 Time.new(2000,1,1,0,0,1/3r,"UTC").subsec #=> (1/3) @overload subsec @return [Numeric];T;#0;$@Y;.F;/o;0;1T;2i ;3i ;%@3;9I"static VALUE time_subsec(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); return quov(w2v(wmod(tobj->timew, WINT2FIXWV(TIME_SCALE))), INT2FIX(TIME_SCALE)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#strftime;F;7[[I" format;T0;[[@i];T;;;0;[;{;IC; "i Formats _time_ according to the directives in the given format string. The directives begin with a percent (%) character. Any text not listed as a directive will be passed through to the output string. The directive consists of a percent (%) character, zero or more flags, optional minimum field width, optional modifier and a conversion specifier as follows: % Flags: - don't pad a numerical output _ use spaces for padding 0 use zeros for padding ^ upcase the result string # change case : use colons for %z The minimum field width specifies the minimum width. The modifiers are "E" and "O". They are ignored. Format directives: Date (Year, Month, Day): %Y - Year with century if provided, will pad result at least 4 digits. -0001, 0000, 1995, 2009, 14292, etc. %C - year / 100 (rounded down such as 20 in 2009) %y - year % 100 (00..99) %m - Month of the year, zero-padded (01..12) %_m blank-padded ( 1..12) %-m no-padded (1..12) %B - The full month name (``January'') %^B uppercased (``JANUARY'') %b - The abbreviated month name (``Jan'') %^b uppercased (``JAN'') %h - Equivalent to %b %d - Day of the month, zero-padded (01..31) %-d no-padded (1..31) %e - Day of the month, blank-padded ( 1..31) %j - Day of the year (001..366) Time (Hour, Minute, Second, Subsecond): %H - Hour of the day, 24-hour clock, zero-padded (00..23) %k - Hour of the day, 24-hour clock, blank-padded ( 0..23) %I - Hour of the day, 12-hour clock, zero-padded (01..12) %l - Hour of the day, 12-hour clock, blank-padded ( 1..12) %P - Meridian indicator, lowercase (``am'' or ``pm'') %p - Meridian indicator, uppercase (``AM'' or ``PM'') %M - Minute of the hour (00..59) %S - Second of the minute (00..60) %L - Millisecond of the second (000..999) The digits under millisecond are truncated to not produce 1000. %N - Fractional seconds digits, default is 9 digits (nanosecond) %3N millisecond (3 digits) %6N microsecond (6 digits) %9N nanosecond (9 digits) %12N picosecond (12 digits) %15N femtosecond (15 digits) %18N attosecond (18 digits) %21N zeptosecond (21 digits) %24N yoctosecond (24 digits) The digits under the specified length are truncated to avoid carry up. Time zone: %z - Time zone as hour and minute offset from UTC (e.g. +0900) %:z - hour and minute offset from UTC with a colon (e.g. +09:00) %::z - hour, minute and second offset from UTC (e.g. +09:00:00) %Z - Abbreviated time zone name or similar information. (OS dependent) Weekday: %A - The full weekday name (``Sunday'') %^A uppercased (``SUNDAY'') %a - The abbreviated name (``Sun'') %^a uppercased (``SUN'') %u - Day of the week (Monday is 1, 1..7) %w - Day of the week (Sunday is 0, 0..6) ISO 8601 week-based year and week number: The first week of YYYY starts with a Monday and includes YYYY-01-04. The days in the year before the first week are in the last week of the previous year. %G - The week-based year %g - The last 2 digits of the week-based year (00..99) %V - Week number of the week-based year (01..53) Week number: The first week of YYYY that starts with a Sunday or Monday (according to %U or %W). The days in the year before the first week are in week 0. %U - Week number of the year. The week starts with Sunday. (00..53) %W - Week number of the year. The week starts with Monday. (00..53) Seconds since the Epoch: %s - Number of seconds since 1970-01-01 00:00:00 UTC. Literal string: %n - Newline character (\n) %t - Tab character (\t) %% - Literal ``%'' character Combination: %c - date and time (%a %b %e %T %Y) %D - Date (%m/%d/%y) %F - The ISO 8601 date format (%Y-%m-%d) %v - VMS date (%e-%^b-%4Y) %x - Same as %D %X - Same as %T %r - 12-hour time (%I:%M:%S %p) %R - 24-hour time (%H:%M) %T - 24-hour time (%H:%M:%S) This method is similar to strftime() function defined in ISO C and POSIX. While all directives are locale independent since Ruby 1.9, %Z is platform dependent. So, the result may differ even if the same format string is used in other systems such as C. %z is recommended over %Z. %Z doesn't identify the timezone. For example, "CST" is used at America/Chicago (-06:00), America/Havana (-05:00), Asia/Harbin (+08:00), Australia/Darwin (+09:30) and Australia/Adelaide (+10:30). Also, %Z is highly dependent on the operating system. For example, it may generate a non ASCII string on Japanese Windows, i.e. the result can be different to "JST". So the numeric time zone offset, %z, is recommended. Examples: t = Time.new(2007,11,19,8,37,48,"-06:00") #=> 2007-11-19 08:37:48 -0600 t.strftime("Printed on %m/%d/%Y") #=> "Printed on 11/19/2007" t.strftime("at %I:%M %p") #=> "at 08:37 AM" Various ISO 8601 formats: %Y%m%d => 20071119 Calendar date (basic) %F => 2007-11-19 Calendar date (extended) %Y-%m => 2007-11 Calendar date, reduced accuracy, specific month %Y => 2007 Calendar date, reduced accuracy, specific year %C => 20 Calendar date, reduced accuracy, specific century %Y%j => 2007323 Ordinal date (basic) %Y-%j => 2007-323 Ordinal date (extended) %GW%V%u => 2007W471 Week date (basic) %G-W%V-%u => 2007-W47-1 Week date (extended) %GW%V => 2007W47 Week date, reduced accuracy, specific week (basic) %G-W%V => 2007-W47 Week date, reduced accuracy, specific week (extended) %H%M%S => 083748 Local time (basic) %T => 08:37:48 Local time (extended) %H%M => 0837 Local time, reduced accuracy, specific minute (basic) %H:%M => 08:37 Local time, reduced accuracy, specific minute (extended) %H => 08 Local time, reduced accuracy, specific hour %H%M%S,%L => 083748,000 Local time with decimal fraction, comma as decimal sign (basic) %T,%L => 08:37:48,000 Local time with decimal fraction, comma as decimal sign (extended) %H%M%S.%L => 083748.000 Local time with decimal fraction, full stop as decimal sign (basic) %T.%L => 08:37:48.000 Local time with decimal fraction, full stop as decimal sign (extended) %H%M%S%z => 083748-0600 Local time and the difference from UTC (basic) %T%:z => 08:37:48-06:00 Local time and the difference from UTC (extended) %Y%m%dT%H%M%S%z => 20071119T083748-0600 Date and time of day for calendar date (basic) %FT%T%:z => 2007-11-19T08:37:48-06:00 Date and time of day for calendar date (extended) %Y%jT%H%M%S%z => 2007323T083748-0600 Date and time of day for ordinal date (basic) %Y-%jT%T%:z => 2007-323T08:37:48-06:00 Date and time of day for ordinal date (extended) %GW%V%uT%H%M%S%z => 2007W471T083748-0600 Date and time of day for week date (basic) %G-W%V-%uT%T%:z => 2007-W47-1T08:37:48-06:00 Date and time of day for week date (extended) %Y%m%dT%H%M => 20071119T0837 Calendar date and local time (basic) %FT%R => 2007-11-19T08:37 Calendar date and local time (extended) %Y%jT%H%MZ => 2007323T0837Z Ordinal date and UTC of day (basic) %Y-%jT%RZ => 2007-323T08:37Z Ordinal date and UTC of day (extended) %GW%V%uT%H%M%z => 2007W471T0837-0600 Week date and local time and difference from UTC (basic) %G-W%V-%uT%R%:z => 2007-W47-1T08:37-06:00 Week date and local time and difference from UTC (extended) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"strftime( string );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@t;![;"I"@return [String];T;#0;$@t;.F;Bi;C0;7[[I" string;T0;$@t;![;"I" Formats _time_ according to the directives in the given format string. The directives begin with a percent (%) character. Any text not listed as a directive will be passed through to the output string. The directive consists of a percent (%) character, zero or more flags, optional minimum field width, optional modifier and a conversion specifier as follows: % Flags: - don't pad a numerical output _ use spaces for padding 0 use zeros for padding ^ upcase the result string # change case : use colons for %z The minimum field width specifies the minimum width. The modifiers are "E" and "O". They are ignored. Format directives: Date (Year, Month, Day): %Y - Year with century if provided, will pad result at least 4 digits. -0001, 0000, 1995, 2009, 14292, etc. %C - year / 100 (rounded down such as 20 in 2009) %y - year % 100 (00..99) %m - Month of the year, zero-padded (01..12) %_m blank-padded ( 1..12) %-m no-padded (1..12) %B - The full month name (``January'') %^B uppercased (``JANUARY'') %b - The abbreviated month name (``Jan'') %^b uppercased (``JAN'') %h - Equivalent to %b %d - Day of the month, zero-padded (01..31) %-d no-padded (1..31) %e - Day of the month, blank-padded ( 1..31) %j - Day of the year (001..366) Time (Hour, Minute, Second, Subsecond): %H - Hour of the day, 24-hour clock, zero-padded (00..23) %k - Hour of the day, 24-hour clock, blank-padded ( 0..23) %I - Hour of the day, 12-hour clock, zero-padded (01..12) %l - Hour of the day, 12-hour clock, blank-padded ( 1..12) %P - Meridian indicator, lowercase (``am'' or ``pm'') %p - Meridian indicator, uppercase (``AM'' or ``PM'') %M - Minute of the hour (00..59) %S - Second of the minute (00..60) %L - Millisecond of the second (000..999) The digits under millisecond are truncated to not produce 1000. %N - Fractional seconds digits, default is 9 digits (nanosecond) %3N millisecond (3 digits) %6N microsecond (6 digits) %9N nanosecond (9 digits) %12N picosecond (12 digits) %15N femtosecond (15 digits) %18N attosecond (18 digits) %21N zeptosecond (21 digits) %24N yoctosecond (24 digits) The digits under the specified length are truncated to avoid carry up. Time zone: %z - Time zone as hour and minute offset from UTC (e.g. +0900) %:z - hour and minute offset from UTC with a colon (e.g. +09:00) %::z - hour, minute and second offset from UTC (e.g. +09:00:00) %Z - Abbreviated time zone name or similar information. (OS dependent) Weekday: %A - The full weekday name (``Sunday'') %^A uppercased (``SUNDAY'') %a - The abbreviated name (``Sun'') %^a uppercased (``SUN'') %u - Day of the week (Monday is 1, 1..7) %w - Day of the week (Sunday is 0, 0..6) ISO 8601 week-based year and week number: The first week of YYYY starts with a Monday and includes YYYY-01-04. The days in the year before the first week are in the last week of the previous year. %G - The week-based year %g - The last 2 digits of the week-based year (00..99) %V - Week number of the week-based year (01..53) Week number: The first week of YYYY that starts with a Sunday or Monday (according to %U or %W). The days in the year before the first week are in week 0. %U - Week number of the year. The week starts with Sunday. (00..53) %W - Week number of the year. The week starts with Monday. (00..53) Seconds since the Epoch: %s - Number of seconds since 1970-01-01 00:00:00 UTC. Literal string: %n - Newline character (\n) %t - Tab character (\t) %% - Literal ``%'' character Combination: %c - date and time (%a %b %e %T %Y) %D - Date (%m/%d/%y) %F - The ISO 8601 date format (%Y-%m-%d) %v - VMS date (%e-%^b-%4Y) %x - Same as %D %X - Same as %T %r - 12-hour time (%I:%M:%S %p) %R - 24-hour time (%H:%M) %T - 24-hour time (%H:%M:%S) This method is similar to strftime() function defined in ISO C and POSIX. While all directives are locale independent since Ruby 1.9, %Z is platform dependent. So, the result may differ even if the same format string is used in other systems such as C. %z is recommended over %Z. %Z doesn't identify the timezone. For example, "CST" is used at America/Chicago (-06:00), America/Havana (-05:00), Asia/Harbin (+08:00), Australia/Darwin (+09:30) and Australia/Adelaide (+10:30). Also, %Z is highly dependent on the operating system. For example, it may generate a non ASCII string on Japanese Windows, i.e. the result can be different to "JST". So the numeric time zone offset, %z, is recommended. Examples: t = Time.new(2007,11,19,8,37,48,"-06:00") #=> 2007-11-19 08:37:48 -0600 t.strftime("Printed on %m/%d/%Y") #=> "Printed on 11/19/2007" t.strftime("at %I:%M %p") #=> "at 08:37 AM" Various ISO 8601 formats: %Y%m%d => 20071119 Calendar date (basic) %F => 2007-11-19 Calendar date (extended) %Y-%m => 2007-11 Calendar date, reduced accuracy, specific month %Y => 2007 Calendar date, reduced accuracy, specific year %C => 20 Calendar date, reduced accuracy, specific century %Y%j => 2007323 Ordinal date (basic) %Y-%j => 2007-323 Ordinal date (extended) %GW%V%u => 2007W471 Week date (basic) %G-W%V-%u => 2007-W47-1 Week date (extended) %GW%V => 2007W47 Week date, reduced accuracy, specific week (basic) %G-W%V => 2007-W47 Week date, reduced accuracy, specific week (extended) %H%M%S => 083748 Local time (basic) %T => 08:37:48 Local time (extended) %H%M => 0837 Local time, reduced accuracy, specific minute (basic) %H:%M => 08:37 Local time, reduced accuracy, specific minute (extended) %H => 08 Local time, reduced accuracy, specific hour %H%M%S,%L => 083748,000 Local time with decimal fraction, comma as decimal sign (basic) %T,%L => 08:37:48,000 Local time with decimal fraction, comma as decimal sign (extended) %H%M%S.%L => 083748.000 Local time with decimal fraction, full stop as decimal sign (basic) %T.%L => 08:37:48.000 Local time with decimal fraction, full stop as decimal sign (extended) %H%M%S%z => 083748-0600 Local time and the difference from UTC (basic) %T%:z => 08:37:48-06:00 Local time and the difference from UTC (extended) %Y%m%dT%H%M%S%z => 20071119T083748-0600 Date and time of day for calendar date (basic) %FT%T%:z => 2007-11-19T08:37:48-06:00 Date and time of day for calendar date (extended) %Y%jT%H%M%S%z => 2007323T083748-0600 Date and time of day for ordinal date (basic) %Y-%jT%T%:z => 2007-323T08:37:48-06:00 Date and time of day for ordinal date (extended) %GW%V%uT%H%M%S%z => 2007W471T083748-0600 Date and time of day for week date (basic) %G-W%V-%uT%T%:z => 2007-W47-1T08:37:48-06:00 Date and time of day for week date (extended) %Y%m%dT%H%M => 20071119T0837 Calendar date and local time (basic) %FT%R => 2007-11-19T08:37 Calendar date and local time (extended) %Y%jT%H%MZ => 2007323T0837Z Ordinal date and UTC of day (basic) %Y-%jT%RZ => 2007-323T08:37Z Ordinal date and UTC of day (extended) %GW%V%uT%H%M%z => 2007W471T0837-0600 Week date and local time and difference from UTC (basic) %G-W%V-%uT%R%:z => 2007-W47-1T08:37-06:00 Week date and local time and difference from UTC (extended) @overload strftime( string ) @return [String];T;#0;$@t;.F;/o;0;1T;2i;3iZ;%@3;9I"static VALUE time_strftime(VALUE time, VALUE format) { struct time_object *tobj; const char *fmt; long len; rb_encoding *enc; VALUE tmp; GetTimeval(time, tobj); MAKE_TM_ENSURE(time, tobj, tobj->vtm.yday != 0); StringValue(format); if (!rb_enc_str_asciicompat_p(format)) { rb_raise(rb_eArgError, "format should have ASCII compatible encoding"); } tmp = rb_str_tmp_frozen_acquire(format); fmt = RSTRING_PTR(tmp); len = RSTRING_LEN(tmp); enc = rb_enc_get(format); if (len == 0) { rb_warning("strftime called with empty format string"); return rb_enc_str_new(0, 0, enc); } else { VALUE str = rb_strftime_alloc(fmt, len, enc, time, &tobj->vtm, tobj->timew, TZMODE_UTC_P(tobj)); rb_str_tmp_frozen_release(format, tmp); if (!str) rb_raise(rb_eArgError, "invalid format: %"PRIsVALUE, format); return str; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#_dump;F;7[[@90;[[@i;T;;;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2i;3i;%@3;9I"static VALUE time_dump(int argc, VALUE *argv, VALUE time) { VALUE str; rb_check_arity(argc, 0, 1); str = time_mdump(time); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#marshal_dump;F;7[;[[@i;T;;[;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2i;3i;%@3;9I"jstatic VALUE time_mdump(VALUE time) { struct time_object *tobj; unsigned long p, s; char buf[base_dump_size + sizeof(long) + 1]; int i; VALUE str; struct vtm vtm; long year; long usec, nsec; VALUE subsecx, nano, subnano, v, zone; VALUE year_extend = Qnil; const int max_year = 1900+0xffff; GetTimeval(time, tobj); gmtimew(tobj->timew, &vtm); if (FIXNUM_P(vtm.year)) { year = FIX2LONG(vtm.year); if (year > max_year) { year_extend = INT2FIX(year - max_year); year = max_year; } else if (year < 1900) { year_extend = LONG2NUM(1900 - year); year = 1900; } } else { if (rb_int_positive_p(vtm.year)) { year_extend = rb_int_minus(vtm.year, INT2FIX(max_year)); year = max_year; } else { year_extend = rb_int_minus(INT2FIX(1900), vtm.year); year = 1900; } } subsecx = vtm.subsecx; nano = mulquov(subsecx, INT2FIX(1000000000), INT2FIX(TIME_SCALE)); divmodv(nano, INT2FIX(1), &v, &subnano); nsec = FIX2LONG(v); usec = nsec / 1000; nsec = nsec % 1000; nano = addv(LONG2FIX(nsec), subnano); p = 0x1UL << 31 | /* 1 */ TZMODE_UTC_P(tobj) << 30 | /* 1 */ (year-1900) << 14 | /* 16 */ (vtm.mon-1) << 10 | /* 4 */ vtm.mday << 5 | /* 5 */ vtm.hour; /* 5 */ s = (unsigned long)vtm.min << 26 | /* 6 */ vtm.sec << 20 | /* 6 */ usec; /* 20 */ for (i=0; i<4; i++) { buf[i] = (unsigned char)p; p = RSHIFT(p, 8); } for (i=4; i<8; i++) { buf[i] = (unsigned char)s; s = RSHIFT(s, 8); } if (!NIL_P(year_extend)) { /* * Append extended year distance from 1900..(1900+0xffff). In * each cases, there is no sign as the value is positive. The * format is length (marshaled long) + little endian packed * binary (like as Integer). */ size_t ysize = rb_absint_size(year_extend, NULL); char *p, *const buf_year_extend = buf + base_dump_size; if (ysize > LONG_MAX || (i = ruby_marshal_write_long((long)ysize, buf_year_extend)) < 0) { rb_raise(rb_eArgError, "year too %s to marshal: %"PRIsVALUE" UTC", (year == 1900 ? "small" : "big"), vtm.year); } i += base_dump_size; str = rb_str_new(NULL, i + ysize); p = RSTRING_PTR(str); memcpy(p, buf, i); p += i; rb_integer_pack(year_extend, p, ysize, 1, 0, INTEGER_PACK_LITTLE_ENDIAN); } else { str = rb_str_new(buf, base_dump_size); } rb_copy_generic_ivar(str, time); if (!rb_equal(nano, INT2FIX(0))) { if (RB_TYPE_P(nano, T_RATIONAL)) { rb_ivar_set(str, id_nano_num, RRATIONAL(nano)->num); rb_ivar_set(str, id_nano_den, RRATIONAL(nano)->den); } else { rb_ivar_set(str, id_nano_num, nano); rb_ivar_set(str, id_nano_den, INT2FIX(1)); } } if (nsec) { /* submicro is only for Ruby 1.9.1 compatibility */ /* * submicro is formatted in fixed-point packed BCD (without sign). * It represent digits under microsecond. * For nanosecond resolution, 3 digits (2 bytes) are used. * However it can be longer. * Extra digits are ignored for loading. */ char buf[2]; int len = (int)sizeof(buf); buf[1] = (char)((nsec % 10) << 4); nsec /= 10; buf[0] = (char)(nsec % 10); nsec /= 10; buf[0] |= (char)((nsec % 10) << 4); if (buf[1] == 0) len = 1; rb_ivar_set(str, id_submicro, rb_str_new(buf, len)); } if (!TZMODE_UTC_P(tobj)) { VALUE off = rb_time_utc_offset(time), div, mod; divmodv(off, INT2FIX(1), &div, &mod); if (rb_equal(mod, INT2FIX(0))) off = rb_Integer(div); rb_ivar_set(str, id_offset, off); } zone = tobj->vtm.zone; if (maybe_tzobj_p(zone)) { zone = rb_funcallv(zone, id_name, 0, 0); } rb_ivar_set(str, id_zone, zone); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Time#marshal_load;F;7[[I"str;T0;[[@i2;T;;;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2i1;3i1;%@3;9I"static VALUE time_mload(VALUE time, VALUE str) { struct time_object *tobj; unsigned long p, s; time_t sec; long usec; unsigned char *buf; struct vtm vtm; int i, gmt; long nsec; VALUE submicro, nano_num, nano_den, offset, zone, year; wideval_t timew; time_modify(time); #define get_attr(attr, iffound) \ attr = rb_attr_delete(str, id_##attr); \ if (!NIL_P(attr)) { \ iffound; \ } get_attr(nano_num, {}); get_attr(nano_den, {}); get_attr(submicro, {}); get_attr(offset, (offset = rb_rescue(validate_utc_offset, offset, 0, Qnil))); get_attr(zone, (zone = rb_rescue(validate_zone_name, zone, 0, Qnil))); get_attr(year, {}); #undef get_attr rb_copy_generic_ivar(time, str); StringValue(str); buf = (unsigned char *)RSTRING_PTR(str); if (RSTRING_LEN(str) < base_dump_size) { goto invalid_format; } p = s = 0; for (i=0; i<4; i++) { p |= (unsigned long)buf[i]<<(8*i); } for (i=4; i<8; i++) { s |= (unsigned long)buf[i]<<(8*(i-4)); } if ((p & (1UL<<31)) == 0) { gmt = 0; offset = Qnil; sec = p; usec = s; nsec = usec * 1000; timew = wadd(rb_time_magnify(TIMET2WV(sec)), wmulquoll(WINT2FIXWV(usec), TIME_SCALE, 1000000)); } else { p &= ~(1UL<<31); gmt = (int)((p >> 30) & 0x1); if (NIL_P(year)) { year = INT2FIX(((int)(p >> 14) & 0xffff) + 1900); } if (RSTRING_LEN(str) > base_dump_size) { long len = RSTRING_LEN(str) - base_dump_size; long ysize = 0; VALUE year_extend; const char *ybuf = (const char *)(buf += base_dump_size); ysize = ruby_marshal_read_long(&ybuf, len); len -= ybuf - (const char *)buf; if (ysize < 0 || ysize > len) goto invalid_format; year_extend = rb_integer_unpack(ybuf, ysize, 1, 0, INTEGER_PACK_LITTLE_ENDIAN); if (year == INT2FIX(1900)) { year = rb_int_minus(year, year_extend); } else { year = rb_int_plus(year, year_extend); } } unsigned int mon = ((int)(p >> 10) & 0xf); /* 0...12 */ if (mon >= 12) { mon -= 12; year = addv(year, LONG2FIX(1)); } vtm.year = year; vtm.mon = mon + 1; vtm.mday = (int)(p >> 5) & 0x1f; vtm.hour = (int) p & 0x1f; vtm.min = (int)(s >> 26) & 0x3f; vtm.sec = (int)(s >> 20) & 0x3f; vtm.utc_offset = INT2FIX(0); vtm.yday = vtm.wday = 0; vtm.isdst = 0; vtm.zone = str_empty; usec = (long)(s & 0xfffff); nsec = usec * 1000; vtm.subsecx = mulquov(LONG2FIX(nsec), INT2FIX(TIME_SCALE), LONG2FIX(1000000000)); if (nano_num != Qnil) { VALUE nano = quov(num_exact(nano_num), num_exact(nano_den)); vtm.subsecx = addv(vtm.subsecx, mulquov(nano, INT2FIX(TIME_SCALE), LONG2FIX(1000000000))); } else if (submicro != Qnil) { /* for Ruby 1.9.1 compatibility */ unsigned char *ptr; long len; int digit; ptr = (unsigned char*)StringValuePtr(submicro); len = RSTRING_LEN(submicro); nsec = 0; if (0 < len) { if (10 <= (digit = ptr[0] >> 4)) goto end_submicro; nsec += digit * 100; if (10 <= (digit = ptr[0] & 0xf)) goto end_submicro; nsec += digit * 10; } if (1 < len) { if (10 <= (digit = ptr[1] >> 4)) goto end_submicro; nsec += digit; } vtm.subsecx = addv(vtm.subsecx, mulquov(LONG2FIX(nsec), INT2FIX(TIME_SCALE), LONG2FIX(1000000000))); end_submicro: ; } timew = timegmw(&vtm); } GetNewTimeval(time, tobj); tobj->tzmode = TIME_TZMODE_LOCALTIME; tobj->tm_got = 0; tobj->timew = timew; if (gmt) { TZMODE_SET_UTC(tobj); } else if (!NIL_P(offset)) { time_set_utc_offset(time, offset); time_fixoff(time); } if (!NIL_P(zone)) { zone = mload_zone(time, zone); tobj->vtm.zone = zone; zone_localtime(zone, time); } return time; invalid_format: rb_raise(rb_eTypeError, "marshaled time format differ"); UNREACHABLE_RETURN(Qundef); };T;:I"static VALUE;T;;T; @3; IC;[; @3; IC;[o;( ;)0;*0;+0;;;%@;-@?_;0; @3; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i;F;;;;;;;[;{;IC; " ;T;[;![;"I";F;#0;$@3;.F;/o;0;1T;2i;3i;%@;&I" Time;F;'@o; ;IC;["o;4;5F;6;;;;&I"RubyVM.each_builtin;F;7[;[[I"mini_builtin.c;TiR;T;:each_builtin;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"xstatic VALUE each_builtin(VALUE self) { st_foreach(loaded_builtin_table, each_builtin_i, 0); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"RubyVM.stat;F;7[[@90;[[@&i;T;;;0;[;{;IC; "ZReturns a Hash containing implementation-dependent counters inside the VM. This hash includes information about method/constant cache serials: { :global_constant_state=>481, :class_serial=>9029 } The contents of the hash are implementation specific and may be changed in the future. This method is only expected to work on C Ruby. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" stat;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@;![;"I"@return [Hash];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"stat(hsh);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@;![;"I"@return [Hash];T;#0;$@;.F;Bi;C0;7[[I"hsh;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"stat(Symbol);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@;![;"I"@return [Numeric];T;#0;$@;.F;Bi;C0;7[[I" Symbol;T0;$@;![;"I"Returns a Hash containing implementation-dependent counters inside the VM. This hash includes information about method/constant cache serials: { :global_constant_state=>481, :class_serial=>9029 } The contents of the hash are implementation specific and may be changed in the future. This method is only expected to work on C Ruby. @overload stat @return [Hash] @overload stat(hsh) @return [Hash] @overload stat(Symbol) @return [Numeric];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"rstatic VALUE vm_stat(int argc, VALUE *argv, VALUE self) { static VALUE sym_global_constant_state, sym_class_serial, sym_global_cvar_state; VALUE arg = Qnil; VALUE hash = Qnil, key = Qnil; if (rb_check_arity(argc, 0, 1) == 1) { arg = argv[0]; if (SYMBOL_P(arg)) key = arg; else if (RB_TYPE_P(arg, T_HASH)) hash = arg; else rb_raise(rb_eTypeError, "non-hash or symbol given"); } else { hash = rb_hash_new(); } if (sym_global_constant_state == 0) { #define S(s) sym_##s = ID2SYM(rb_intern_const(#s)) S(global_constant_state); S(class_serial); S(global_cvar_state); #undef S } #define SET(name, attr) \ if (key == sym_##name) \ return SERIALT2NUM(attr); \ else if (hash != Qnil) \ rb_hash_aset(hash, sym_##name, SERIALT2NUM(attr)); SET(global_constant_state, ruby_vm_global_constant_state); SET(class_serial, ruby_vm_class_serial); SET(global_cvar_state, ruby_vm_global_cvar_state); #undef SET if (!NIL_P(key)) { /* matched key should return above */ rb_raise(rb_eArgError, "unknown key: %"PRIsVALUE, rb_sym2str(key)); } return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"RubyVM.keep_script_lines;F;7[;[[@&iN ;T;:keep_script_lines;0;[;{;IC; "Return current +keep_script_lines+ status. Now it only returns +true+ of +false+, but it can return other objects in future. Note that this is an API for ruby internal use, debugging, and research. Do not use this for any other purpose. The compatibility is not guaranteed. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"keep_script_lines;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"DReturn current +keep_script_lines+ status. Now it only returns +true+ of +false+, but it can return other objects in future. Note that this is an API for ruby internal use, debugging, and research. Do not use this for any other purpose. The compatibility is not guaranteed. @overload keep_script_lines @return [Boolean];T;#0;$@;.F;/o;0;1T;2iC ;3iL ;%@;9I"cstatic VALUE vm_keep_script_lines(VALUE self) { return RBOOL(ruby_vm_keep_script_lines); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"RubyVM.keep_script_lines=;F;7[[I" flags;T0;[[@&i_ ;T;:keep_script_lines=;0;[;{;IC; "It set +keep_script_lines+ flag. If the flag is set, all loaded scripts are recorded in a interpreter process. Note that this is an API for ruby internal use, debugging, and research. Do not use this for any other purpose. The compatibility is not guaranteed. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"keep_script_lines=(true);T;IC; ";T;[;![;"I";T;#0;$@6;.F;Bi;C0;7[[I" true;T0;$@6;![;"I")It set +keep_script_lines+ flag. If the flag is set, all loaded scripts are recorded in a interpreter process. Note that this is an API for ruby internal use, debugging, and research. Do not use this for any other purpose. The compatibility is not guaranteed. @overload keep_script_lines=(true);T;#0;$@6;.F;/o;0;1T;2iT ;3i\ ;%@;9I"static VALUE vm_keep_script_lines_set(VALUE self, VALUE flags) { ruby_vm_keep_script_lines = RTEST(flags); return flags; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" RubyVM.reset_debug_counters;F;7[;[[I"debug_counter.c;Ti;T;:reset_debug_counters;0;[;{;IC; " ;T;[;![;"@;#0;$@P;%@;9I"rVALUE rb_debug_counter_reset(RB_UNUSED_VAR(VALUE klass)) { ruby_debug_counter_reset(); return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"RubyVM.show_debug_counters;F;7[;[[@Uiw;T;:show_debug_counters;0;[;{;IC; " ;T;[;![;"@;#0;$@];%@;9I"VALUE rb_debug_counter_show(RB_UNUSED_VAR(VALUE klass)) { rb_debug_counter_show_results("show_debug_counters"); ruby_debug_counter_show_at_exit(FALSE); return Qnil; };T;:I" VALUE;T;;To;;IC;[o;4;5F;6;;;;&I"RubyVM::MJIT.enabled?;F;7[;[[@&i ;T;: enabled?;0;[;{;IC; "#Returns true if JIT is enabled;T;[o;A ;>I" return;F;?@;0;@[@L;$@k;![;"I"#Returns true if JIT is enabled;T;#0;$@k;.F;/o;0;1T;2i ;3i ;Bi;%@i;9I"Mstatic VALUE mjit_enabled_p(VALUE _) { return RBOOL(mjit_enabled); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"RubyVM::MJIT.pause;F;7[;[[@&i ;T;: pause;0;[;{;IC; " ;T;[;![;"@;#0;$@|;%@i;9I"static VALUE mjit_pause_m(int argc, VALUE *argv, RB_UNUSED_VAR(VALUE self)) { VALUE options = Qnil; VALUE wait = Qtrue; rb_scan_args(argc, argv, "0:", &options); if (!NIL_P(options)) { static ID keyword_ids[1]; if (!keyword_ids[0]) keyword_ids[0] = rb_intern("wait"); rb_get_kwargs(options, keyword_ids, 0, 1, &wait); } return mjit_pause(RTEST(wait)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"RubyVM::MJIT.resume;F;7[;[[@&i ;T;: resume;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@i;9I"Fstatic VALUE mjit_resume_m(VALUE _) { return mjit_resume(); };T;:I"static VALUE;T;;T; @i; IC;[; @i; IC;[; @i; IC;{;IC;{;T;IC;{;T;T;{;[;[[@&i ;F;: MJIT;;;;;[;{;IC; " ;T;[;![;"@;#0;$@i;Bi;%@;&I"RubyVM::MJIT;Fo;4;5F;6;;;;&I"%RubyVM.USAGE_ANALYSIS_INSN_START;F;7[;[[@&i ;T;:USAGE_ANALYSIS_INSN_START;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"8static VALUE usage_analysis_insn_start(VALUE self);;T;:I"8static VALUE usage_analysis_insn_start(VALUE self);;T;;To;4;5F;6;;;;&I"(RubyVM.USAGE_ANALYSIS_OPERAND_START;F;7[;[[@&i ;T;:!USAGE_ANALYSIS_OPERAND_START;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I";static VALUE usage_analysis_operand_start(VALUE self);;T;:I";static VALUE usage_analysis_operand_start(VALUE self);;T;;To;4;5F;6;;;;&I")RubyVM.USAGE_ANALYSIS_REGISTER_START;F;7[;[[@&i ;T;:"USAGE_ANALYSIS_REGISTER_START;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"static VALUE usage_analysis_register_running(VALUE self);;T;:I">static VALUE usage_analysis_register_running(VALUE self);;T;;To;4;5F;6;;;;&I"%RubyVM.USAGE_ANALYSIS_INSN_CLEAR;F;7[;[[@&i ;T;:USAGE_ANALYSIS_INSN_CLEAR;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"8static VALUE usage_analysis_insn_clear(VALUE self);;T;:I"8static VALUE usage_analysis_insn_clear(VALUE self);;T;;To;4;5F;6;;;;&I"(RubyVM.USAGE_ANALYSIS_OPERAND_CLEAR;F;7[;[[@&i ;T;:!USAGE_ANALYSIS_OPERAND_CLEAR;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I";static VALUE usage_analysis_operand_clear(VALUE self);;T;:I";static VALUE usage_analysis_operand_clear(VALUE self);;T;;To;4;5F;6;;;;&I")RubyVM.USAGE_ANALYSIS_REGISTER_CLEAR;F;7[;[[@&i ;T;:"USAGE_ANALYSIS_REGISTER_CLEAR;0;[;{;IC; " ;T;[;![;"@;#0;$@';%@;9I" #define MAX_NATIVE_TRACE 1024 static void *trace[MAX_NATIVE_TRACE]; int n = (int)backtrace(trace, MAX_NATIVE_TRACE); char **syms = backtrace_symbols(trace, n); int i; if (syms == 0) { rb_memerror(); } for (i=0; ibody->yjit_blocks, version_array_idx) { rb_yjit_block_array_t versions = rb_darray_get(iseq->body->yjit_blocks, version_array_idx); rb_darray_for(versions, block_idx) { block_t *block = rb_darray_get(versions, block_idx); // FIXME: The object craeted here can outlive the block itself VALUE rb_block = TypedData_Wrap_Struct(cYjitBlock, &yjit_block_type, block); rb_ary_push(all_versions, rb_block); } } return all_versions; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"RubyVM::YJIT.blocks_for;F;7@;@;T;;;0;@;{;IC; "Get the address of the code associated with a YJIT::Block ;T;[;![;"I">Get the address of the code associated with a YJIT::Block;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE block_address(VALUE self) { block_t * block; TypedData_Get_Struct(self, block_t, &yjit_block_type, block); return LONG2NUM((intptr_t)block->start_addr); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"RubyVM::YJIT::Block#id;F;7[;[[@i;T;;[;0;[;{;IC; "vReturns a unique integer ID for the block. For example: blocks = blocks_for(iseq) blocks.group_by(&:id) ;T;[o;= ;>I" overload;F;?0;;[;@0;:I"id;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a unique integer ID for the block. For example: blocks = blocks_for(iseq) blocks.group_by(&:id) @overload id;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE block_id(VALUE self) { block_t * block; TypedData_Get_Struct(self, block_t, &yjit_block_type, block); return PTR2NUM(block); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"RubyVM::YJIT::Block#code;F;7[;[[@i;T;: code;0;[;{;IC; "start_addr, block->end_addr - block->start_addr ); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I")RubyVM::YJIT::Block#iseq_start_index;F;7[;[[@i,;T;:iseq_start_index;0;[;{;IC; "YGet the start index in the Instruction Sequence that corresponds to this YJIT::Block ;T;[;![;"I"YGet the start index in the Instruction Sequence that corresponds to this YJIT::Block;T;#0;$@;.F;/o;0;1T;2i*;3i+;%@;9I"static VALUE iseq_start_index(VALUE self) { block_t * block; TypedData_Get_Struct(self, block_t, &yjit_block_type, block); return INT2NUM(block->blockid.idx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'RubyVM::YJIT::Block#iseq_end_index;F;7[;[[@i7;T;:iseq_end_index;0;[;{;IC; "WGet the end index in the Instruction Sequence that corresponds to this YJIT::Block ;T;[;![;"I"WGet the end index in the Instruction Sequence that corresponds to this YJIT::Block;T;#0;$@;.F;/o;0;1T;2i5;3i6;%@;9I"static VALUE iseq_end_index(VALUE self) { block_t * block; TypedData_Get_Struct(self, block_t, &yjit_block_type, block); return INT2NUM(block->end_idx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%RubyVM::YJIT::Block#outgoing_ids;F;7[;[[@i;T;:outgoing_ids;0;[;{;IC; "Returns a list of outgoing ids for the current block. This list can be used in conjunction with Block#id to construct a graph of block objects. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"outgoing_ids;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a list of outgoing ids for the current block. This list can be used in conjunction with Block#id to construct a graph of block objects. @overload outgoing_ids;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE outgoing_ids(VALUE self) { block_t * block; TypedData_Get_Struct(self, block_t, &yjit_block_type, block); VALUE ids = rb_ary_new(); rb_darray_for(block->outgoing, branch_idx) { branch_t *out_branch = rb_darray_get(block->outgoing, branch_idx); for (size_t succ_idx = 0; succ_idx < 2; succ_idx++) { block_t *succ = out_branch->blocks[succ_idx]; if (succ == NULL) continue; rb_ary_push(ids, PTR2NUM(succ)); } } return ids; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i;F;: Block;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I"RubyVM::YJIT::Block;F;'@o; ;IC;[o;4;5F;6;;;;&I" RubyVM::YJIT::Disasm#disasm;F;7[[I" code;T0[I" from;T0;[[@i;T;: disasm;0;[;{;IC; " ;T;[;![;"@;#0;$@$;%@";9I"static VALUE yjit_disasm(VALUE self, VALUE code, VALUE from) { size_t count; csh * handle; cs_insn *insns; TypedData_Get_Struct(self, csh, &yjit_disasm_type, handle); count = cs_disasm(*handle, (uint8_t*)StringValuePtr(code), RSTRING_LEN(code), NUM2ULL(from), 0, &insns); VALUE insn_list = rb_ary_new_capa(count); for (size_t i = 0; i < count; i++) { VALUE vals = rb_ary_new_from_args(3, LONG2NUM(insns[i].address), rb_str_new2(insns[i].mnemonic), rb_str_new2(insns[i].op_str)); rb_ary_push(insn_list, rb_struct_alloc(cYjitDisasmInsn, vals)); } cs_free(insns, count); return insn_list; };T;:I"static VALUE;T;;T; @"; IC;[; @"; IC;[; @"; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i ;F;: Disasm;;;;;[;{;IC; " ;T;[;![;"@;#0;$@";%@;&I"RubyVM::YJIT::Disasm;F;'@; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i;F;: YJIT;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I"RubyVM::YJIT;Fo; ;IC;[!o;4;5F;6;;;;&I"(RubyVM::InstructionSequence#inspect;F;7[;[[I" iseq.c;Ti;T;;J;0;[;{;IC; "qReturns a human-readable string representation of this instruction sequence, including the #label and #path. ;T;[;![;"I"rReturns a human-readable string representation of this instruction sequence, including the #label and #path. ;T;#0;$@T;.F;/o;0;1T;2i;3i;%@R;9I"static VALUE iseqw_inspect(VALUE self) { const rb_iseq_t *iseq = iseqw_check(self); const struct rb_iseq_constant_body *const body = iseq->body; VALUE klass = rb_class_name(rb_obj_class(self)); if (!body->location.label) { return rb_sprintf("#<%"PRIsVALUE": uninitialized>", klass); } else { return rb_sprintf("<%"PRIsVALUE":%"PRIsVALUE"@%"PRIsVALUE":%d>", klass, body->location.label, rb_iseq_path(iseq), FIX2INT(rb_iseq_first_lineno(iseq))); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'RubyVM::InstructionSequence#disasm;F;7[;[[@Yi ;T;;;0;[;{;IC; "Returns the instruction sequence as a +String+ in human readable form. puts RubyVM::InstructionSequence.compile('1 + 2').disasm Produces: == disasm: @>========== 0000 trace 1 ( 1) 0002 putobject 1 0004 putobject 2 0006 opt_plus 0008 leave ;T;[o;= ;>I" overload;F;?0;;;@0;:I" disasm;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@c;![;"I"@return [String];T;#0;$@c;.F;Bi;C0;7[;$@co;= ;>I" overload;F;?0;:disassemble;@0;:I"disassemble;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@c;![;"I"@return [String];T;#0;$@c;.F;Bi;C0;7[;$@c;![;"I"Returns the instruction sequence as a +String+ in human readable form. puts RubyVM::InstructionSequence.compile('1 + 2').disasm Produces: == disasm: @>========== 0000 trace 1 ( 1) 0002 putobject 1 0004 putobject 2 0006 opt_plus 0008 leave @overload disasm @return [String] @overload disassemble @return [String];T;#0;$@c;.F;/o;0;1T;2ir ;3i ;%@R;9I"\static VALUE iseqw_disasm(VALUE self) { return rb_iseq_disasm(iseqw_check(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",RubyVM::InstructionSequence#disassemble;F;7[;[[@Yi ;T;;;0;[;{;IC; "Returns the instruction sequence as a +String+ in human readable form. puts RubyVM::InstructionSequence.compile('1 + 2').disasm Produces: == disasm: @>========== 0000 trace 1 ( 1) 0002 putobject 1 0004 putobject 2 0006 opt_plus 0008 leave ;T;[o;= ;>I" overload;F;?0;;;@0;:I" disasm;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"disassemble;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2ir ;3i ;%@R;9I"\static VALUE iseqw_disasm(VALUE self) { return rb_iseq_disasm(iseqw_check(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%RubyVM::InstructionSequence#to_a;F;7[;[[@Yi;T;;;0;[;{;IC; "Returns an Array with 14 elements representing the instruction sequence with the following data: [magic] A string identifying the data format. Always +YARVInstructionSequence/SimpleDataFormat+. [major_version] The major version of the instruction sequence. [minor_version] The minor version of the instruction sequence. [format_type] A number identifying the data format. Always 1. [misc] A hash containing: [+:arg_size+] the total number of arguments taken by the method or the block (0 if _iseq_ doesn't represent a method or block) [+:local_size+] the number of local variables + 1 [+:stack_max+] used in calculating the stack depth at which a SystemStackError is thrown. [#label] The name of the context (block, method, class, module, etc.) that this instruction sequence belongs to.
if it's at the top level, if it was evaluated from a string. [#path] The relative path to the Ruby file where the instruction sequence was loaded from. if the iseq was evaluated from a string. [#absolute_path] The absolute path to the Ruby file where the instruction sequence was loaded from. +nil+ if the iseq was evaluated from a string. [#first_lineno] The number of the first source line where the instruction sequence was loaded from. [type] The type of the instruction sequence. Valid values are +:top+, +:method+, +:block+, +:class+, +:rescue+, +:ensure+, +:eval+, +:main+, and +plain+. [locals] An array containing the names of all arguments and local variables as symbols. [params] An Hash object containing parameter information. More info about these values can be found in +vm_core.h+. [catch_table] A list of exceptions and control flow operators (rescue, next, redo, break, etc.). [bytecode] An array of arrays containing the instruction names and operands that make up the body of the instruction sequence. Note that this format is MRI specific and version dependent. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_a;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns an Array with 14 elements representing the instruction sequence with the following data: [magic] A string identifying the data format. Always +YARVInstructionSequence/SimpleDataFormat+. [major_version] The major version of the instruction sequence. [minor_version] The minor version of the instruction sequence. [format_type] A number identifying the data format. Always 1. [misc] A hash containing: [+:arg_size+] the total number of arguments taken by the method or the block (0 if _iseq_ doesn't represent a method or block) [+:local_size+] the number of local variables + 1 [+:stack_max+] used in calculating the stack depth at which a SystemStackError is thrown. [#label] The name of the context (block, method, class, module, etc.) that this instruction sequence belongs to.
if it's at the top level, if it was evaluated from a string. [#path] The relative path to the Ruby file where the instruction sequence was loaded from. if the iseq was evaluated from a string. [#absolute_path] The absolute path to the Ruby file where the instruction sequence was loaded from. +nil+ if the iseq was evaluated from a string. [#first_lineno] The number of the first source line where the instruction sequence was loaded from. [type] The type of the instruction sequence. Valid values are +:top+, +:method+, +:block+, +:class+, +:rescue+, +:ensure+, +:eval+, +:main+, and +plain+. [locals] An array containing the names of all arguments and local variables as symbols. [params] An Hash object containing parameter information. More info about these values can be found in +vm_core.h+. [catch_table] A list of exceptions and control flow operators (rescue, next, redo, break, etc.). [bytecode] An array of arrays containing the instruction names and operands that make up the body of the instruction sequence. Note that this format is MRI specific and version dependent. @overload to_a @return [Array];T;#0;$@;.F;/o;0;1T;2id;3i;%@R;9I"~static VALUE iseqw_to_a(VALUE self) { const rb_iseq_t *iseq = iseqw_check(self); return iseq_data_to_ary(iseq); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%RubyVM::InstructionSequence#eval;F;7[;[[@Yi;T;;;0;[;{;IC; "|Evaluates the instruction sequence and returns the result. RubyVM::InstructionSequence.compile("1 + 2").eval #=> 3 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" eval;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Evaluates the instruction sequence and returns the result. RubyVM::InstructionSequence.compile("1 + 2").eval #=> 3 @overload eval @return [Object];T;#0;$@;.F;/o;0;1T;2i;3i;%@R;9I"Xstatic VALUE iseqw_eval(VALUE self) { return rb_iseq_eval(iseqw_check(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*RubyVM::InstructionSequence#to_binary;F;7[[@90;[[@Yi ;T;:to_binary;0;[;{;IC; "Returns serialized iseq binary format data as a String object. A corresponding iseq object is created by RubyVM::InstructionSequence.load_from_binary() method. String extra_data will be saved with binary data. You can access this data with RubyVM::InstructionSequence.load_from_binary_extra_data(binary). Note that the translated binary data is not portable. You can not move this binary data to another machine. You can not use the binary data which is created by another version/another architecture of Ruby. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_binary(extra_data = nil);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"extra_data;TI"nil;T;$@;![;"I"(Returns serialized iseq binary format data as a String object. A corresponding iseq object is created by RubyVM::InstructionSequence.load_from_binary() method. String extra_data will be saved with binary data. You can access this data with RubyVM::InstructionSequence.load_from_binary_extra_data(binary). Note that the translated binary data is not portable. You can not move this binary data to another machine. You can not use the binary data which is created by another version/another architecture of Ruby. @overload to_binary(extra_data = nil);T;#0;$@;.F;/o;0;1T;2i ;3i ;%@R;9I"static VALUE iseqw_to_binary(int argc, VALUE *argv, VALUE self) { VALUE opt = !rb_check_arity(argc, 0, 1) ? Qnil : argv[0]; return rb_iseq_ibf_dump(iseqw_check(self), opt); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"1RubyVM::InstructionSequence.load_from_binary;F;7[[I"str;T0;[[@Yi ;T;:load_from_binary;0;[;{;IC; "5Load an iseq object from binary format String object created by RubyVM::InstructionSequence.to_binary. This loader does not have a verifier, so that loading broken/modified binary causes critical problem. You should not load binary data provided by others. You should use binary data translated by yourself. ;T;[o;= ;>I" overload;F;?0;:1RubyVM::InstructionSequence.load_from_binary;@0;:I"9RubyVM::InstructionSequence.load_from_binary(binary);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" binary;T0;$@;![;"I"vLoad an iseq object from binary format String object created by RubyVM::InstructionSequence.to_binary. This loader does not have a verifier, so that loading broken/modified binary causes critical problem. You should not load binary data provided by others. You should use binary data translated by yourself. @overload RubyVM::InstructionSequence.load_from_binary(binary);T;#0;$@;.F;/o;0;1T;2i;3i ;%@R;9I"rstatic VALUE iseqw_s_load_from_binary(VALUE self, VALUE str) { return iseqw_new(rb_iseq_ibf_load(str)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"I" overload;F;?0;:I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I" binary;T0;$@;![;"I"Load extra data embed into binary format String object. @overload RubyVM::InstructionSequence.load_from_binary_extra_data(binary) @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@R;9I"}static VALUE iseqw_s_load_from_binary_extra_data(VALUE self, VALUE str) { return rb_iseq_ibf_load_extra_data(str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%RubyVM::InstructionSequence#path;F;7[;[[@Yi;T;;O;0;[;{;IC; "Returns the path of this instruction sequence. if the iseq was evaluated from a string. For example, using irb: iseq = RubyVM::InstructionSequence.compile('num = 1 + 2') #=> @> iseq.path #=> "" Using ::compile_file: # /tmp/method.rb def hello puts "hello, world" end # in irb > iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb') > iseq.path #=> /tmp/method.rb ;T;[;![;"I"Returns the path of this instruction sequence. if the iseq was evaluated from a string. For example, using irb: iseq = RubyVM::InstructionSequence.compile('num = 1 + 2') #=> @> iseq.path #=> "" Using ::compile_file: # /tmp/method.rb def hello puts "hello, world" end # in irb > iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb') > iseq.path #=> /tmp/method.rb ;T;#0;$@;;.F;/o;0;1T;2i;3i;%@R;9I"Xstatic VALUE iseqw_path(VALUE self) { return rb_iseq_path(iseqw_check(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I".RubyVM::InstructionSequence#absolute_path;F;7[;[[@Yi;T;;P;0;[;{;IC; "6Returns the absolute path of this instruction sequence. +nil+ if the iseq was evaluated from a string. For example, using ::compile_file: # /tmp/method.rb def hello puts "hello, world" end # in irb > iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb') > iseq.absolute_path #=> /tmp/method.rb ;T;[;![;"I"7Returns the absolute path of this instruction sequence. +nil+ if the iseq was evaluated from a string. For example, using ::compile_file: # /tmp/method.rb def hello puts "hello, world" end # in irb > iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb') > iseq.absolute_path #=> /tmp/method.rb ;T;#0;$@I;.F;/o;0;1T;2i;3i;%@R;9I"estatic VALUE iseqw_absolute_path(VALUE self) { return rb_iseq_realpath(iseqw_check(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&RubyVM::InstructionSequence#label;F;7[;[[@Yi2;T;;M;0;[;{;IC; "Returns the label of this instruction sequence.
if it's at the top level, if it was evaluated from a string. For example, using irb: iseq = RubyVM::InstructionSequence.compile('num = 1 + 2') #=> @> iseq.label #=> "" Using ::compile_file: # /tmp/method.rb def hello puts "hello, world" end # in irb > iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb') > iseq.label #=>
;T;[;![;"I"Returns the label of this instruction sequence.
if it's at the top level, if it was evaluated from a string. For example, using irb: iseq = RubyVM::InstructionSequence.compile('num = 1 + 2') #=> @> iseq.label #=> "" Using ::compile_file: # /tmp/method.rb def hello puts "hello, world" end # in irb > iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb') > iseq.label #=>
;T;#0;$@W;.F;/o;0;1T;2i;3i1;%@R;9I"Zstatic VALUE iseqw_label(VALUE self) { return rb_iseq_label(iseqw_check(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+RubyVM::InstructionSequence#base_label;F;7[;[[@YiL;T;;N;0;[;{;IC; "Returns the base label of this instruction sequence. For example, using irb: iseq = RubyVM::InstructionSequence.compile('num = 1 + 2') #=> @> iseq.base_label #=> "" Using ::compile_file: # /tmp/method.rb def hello puts "hello, world" end # in irb > iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb') > iseq.base_label #=>
;T;[;![;"I"Returns the base label of this instruction sequence. For example, using irb: iseq = RubyVM::InstructionSequence.compile('num = 1 + 2') #=> @> iseq.base_label #=> "" Using ::compile_file: # /tmp/method.rb def hello puts "hello, world" end # in irb > iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb') > iseq.base_label #=>
;T;#0;$@e;.F;/o;0;1T;2i8;3iK;%@R;9I"dstatic VALUE iseqw_base_label(VALUE self) { return rb_iseq_base_label(iseqw_check(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"-RubyVM::InstructionSequence#first_lineno;F;7[;[[@Yi\;T;:first_lineno;0;[;{;IC; "Returns the number of the first source line where the instruction sequence was loaded from. For example, using irb: iseq = RubyVM::InstructionSequence.compile('num = 1 + 2') #=> @> iseq.first_lineno #=> 1 ;T;[;![;"I"Returns the number of the first source line where the instruction sequence was loaded from. For example, using irb: iseq = RubyVM::InstructionSequence.compile('num = 1 + 2') #=> @> iseq.first_lineno #=> 1 ;T;#0;$@s;.F;/o;0;1T;2iR;3i[;%@R;9I"hstatic VALUE iseqw_first_lineno(VALUE self) { return rb_iseq_first_lineno(iseqw_check(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"-RubyVM::InstructionSequence#trace_points;F;7[;[[@Yi ;T;:trace_points;0;[;{;IC; "cReturn trace points in the instruction sequence. Return an array of [line, event_symbol] pair. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"trace_points;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Return trace points in the instruction sequence. Return an array of [line, event_symbol] pair. @overload trace_points @return [Array];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@R;9I"static VALUE iseqw_trace_points(VALUE self) { const rb_iseq_t *iseq = iseqw_check(self); const struct rb_iseq_constant_body *const body = iseq->body; unsigned int i; VALUE ary = rb_ary_new(); for (i=0; iinsns_info.size; i++) { const struct iseq_insn_info_entry *entry = &body->insns_info.body[i]; if (entry->events) { push_event_info(iseq, entry->events, entry->line_no, ary); } } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+RubyVM::InstructionSequence#each_child;F;7[;[[@Yi ;T;:each_child;0;[;{;IC; "Iterate all direct child instruction sequences. Iteration order is implementation/version defined so that people should not rely on the order. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"each_child;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"child_iseq;T;$@;![;"I"@yield [child_iseq];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Iterate all direct child instruction sequences. Iteration order is implementation/version defined so that people should not rely on the order. @overload each_child @yield [child_iseq];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@R;9I"static VALUE iseqw_each_child(VALUE self) { const rb_iseq_t *iseq = iseqw_check(self); iseq_iterate_children(iseq, yield_each_children, NULL); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"-RubyVM::InstructionSequence#marshal_dump;F;7[;[;F;;[;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@R;;To;4;5F;6;;;;&I"-RubyVM::InstructionSequence#marshal_load;F;7[;[;F;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@R;;To;4;5F;6;;;;&I"%RubyVM::InstructionSequence.load;F;7[[@90;[[@Yi.;T;;;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc: ;T;#0;$@;.F;/o;0;1T;2i+;3i,;%@R;9I"static VALUE iseq_s_load(int argc, VALUE *argv, VALUE self) { VALUE data, opt=Qnil; rb_scan_args(argc, argv, "11", &data, &opt); return iseq_load(data, NULL, opt); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(RubyVM::InstructionSequence.compile;F;7[[@90;[[@Yi$;T;: compile;0;[;{;IC; ".Takes +source+, a String of Ruby code and compiles it to an InstructionSequence. Optionally takes +file+, +path+, and +line+ which describe the file path, real path and first line number of the ruby code in +source+ which are metadata attached to the returned +iseq+. +file+ is used for `__FILE__` and exception backtrace. +path+ is used for +require_relative+ base. It is recommended these should be the same full path. +options+, which can be +true+, +false+ or a +Hash+, is used to modify the default behavior of the Ruby iseq compiler. For details regarding valid compile options see ::compile_option=. RubyVM::InstructionSequence.compile("a = 1 + 2") #=> @> path = "test.rb" RubyVM::InstructionSequence.compile(File.read(path), path, File.expand_path(path)) #=> @test.rb:1> path = File.expand_path("test.rb") RubyVM::InstructionSequence.compile(File.read(path), path, path) #=> @/absolute/path/to/test.rb:1> ;T;[o;= ;>I" overload;F;?0;;;@0;:I"7compile(source[, file[, path[, line[, options]]]]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I".source[, file[, path[, line[, options]]]];T0;$@o;= ;>I" overload;F;?0;;E;@0;:I"3new(source[, file[, path[, line[, options]]]]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I".source[, file[, path[, line[, options]]]];T0;$@;![;"I"Takes +source+, a String of Ruby code and compiles it to an InstructionSequence. Optionally takes +file+, +path+, and +line+ which describe the file path, real path and first line number of the ruby code in +source+ which are metadata attached to the returned +iseq+. +file+ is used for `__FILE__` and exception backtrace. +path+ is used for +require_relative+ base. It is recommended these should be the same full path. +options+, which can be +true+, +false+ or a +Hash+, is used to modify the default behavior of the Ruby iseq compiler. For details regarding valid compile options see ::compile_option=. RubyVM::InstructionSequence.compile("a = 1 + 2") #=> @> path = "test.rb" RubyVM::InstructionSequence.compile(File.read(path), path, File.expand_path(path)) #=> @test.rb:1> path = File.expand_path("test.rb") RubyVM::InstructionSequence.compile(File.read(path), path, path) #=> @/absolute/path/to/test.rb:1> @overload compile(source[, file[, path[, line[, options]]]]) @overload new(source[, file[, path[, line[, options]]]]);T;#0;$@;.F;/o;0;1T;2i;3i!;%@R;9I"static VALUE iseqw_s_compile(int argc, VALUE *argv, VALUE self) { VALUE src, file = Qnil, path = Qnil, line = INT2FIX(1), opt = Qnil; int i; i = rb_scan_args(argc, argv, "1*:", &src, NULL, &opt); if (i > 4+NIL_P(opt)) rb_error_arity(argc, 1, 5); switch (i) { case 5: opt = argv[--i]; case 4: line = argv[--i]; case 3: path = argv[--i]; case 2: file = argv[--i]; } if (NIL_P(file)) file = rb_fstring_lit(""); if (NIL_P(path)) path = file; if (NIL_P(line)) line = INT2FIX(1); Check_Type(path, T_STRING); Check_Type(file, T_STRING); return iseqw_new(rb_iseq_compile_with_option(src, file, path, line, opt)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$RubyVM::InstructionSequence.new;F;7[[@90;[[@Yi$;T;;E;0;[;{;IC; ".Takes +source+, a String of Ruby code and compiles it to an InstructionSequence. Optionally takes +file+, +path+, and +line+ which describe the file path, real path and first line number of the ruby code in +source+ which are metadata attached to the returned +iseq+. +file+ is used for `__FILE__` and exception backtrace. +path+ is used for +require_relative+ base. It is recommended these should be the same full path. +options+, which can be +true+, +false+ or a +Hash+, is used to modify the default behavior of the Ruby iseq compiler. For details regarding valid compile options see ::compile_option=. RubyVM::InstructionSequence.compile("a = 1 + 2") #=> @> path = "test.rb" RubyVM::InstructionSequence.compile(File.read(path), path, File.expand_path(path)) #=> @test.rb:1> path = File.expand_path("test.rb") RubyVM::InstructionSequence.compile(File.read(path), path, path) #=> @/absolute/path/to/test.rb:1> ;T;[o;= ;>I" overload;F;?0;;;@0;:I"7compile(source[, file[, path[, line[, options]]]]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I".source[, file[, path[, line[, options]]]];T0;$@o;= ;>I" overload;F;?0;;E;@0;:I"3new(source[, file[, path[, line[, options]]]]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I".source[, file[, path[, line[, options]]]];T0;$@;![;"@;#0;$@;.F;/o;0;1T;2i;3i!;%@R;9I"static VALUE iseqw_s_compile(int argc, VALUE *argv, VALUE self) { VALUE src, file = Qnil, path = Qnil, line = INT2FIX(1), opt = Qnil; int i; i = rb_scan_args(argc, argv, "1*:", &src, NULL, &opt); if (i > 4+NIL_P(opt)) rb_error_arity(argc, 1, 5); switch (i) { case 5: opt = argv[--i]; case 4: line = argv[--i]; case 3: path = argv[--i]; case 2: file = argv[--i]; } if (NIL_P(file)) file = rb_fstring_lit(""); if (NIL_P(path)) path = file; if (NIL_P(line)) line = INT2FIX(1); Check_Type(path, T_STRING); Check_Type(file, T_STRING); return iseqw_new(rb_iseq_compile_with_option(src, file, path, line, opt)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"-RubyVM::InstructionSequence.compile_file;F;7[[@90;[[@YiQ;T;:compile_file;0;[;{;IC; "9Takes +file+, a String with the location of a Ruby source file, reads, parses and compiles the file, and returns +iseq+, the compiled InstructionSequence with source location metadata set. Optionally takes +options+, which can be +true+, +false+ or a +Hash+, to modify the default behavior of the Ruby iseq compiler. For details regarding valid compile options see ::compile_option=. # /tmp/hello.rb puts "Hello, world!" # elsewhere RubyVM::InstructionSequence.compile_file("/tmp/hello.rb") #=> @/tmp/hello.rb> ;T;[o;= ;>I" overload;F;?0;;;@0;:I""compile_file(file[, options]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"file[, options];T0;$@;![;"I"cTakes +file+, a String with the location of a Ruby source file, reads, parses and compiles the file, and returns +iseq+, the compiled InstructionSequence with source location metadata set. Optionally takes +options+, which can be +true+, +false+ or a +Hash+, to modify the default behavior of the Ruby iseq compiler. For details regarding valid compile options see ::compile_option=. # /tmp/hello.rb puts "Hello, world!" # elsewhere RubyVM::InstructionSequence.compile_file("/tmp/hello.rb") #=> @/tmp/hello.rb> @overload compile_file(file[, options]);T;#0;$@;.F;/o;0;1T;2i=;3iN;%@R;9I"*static VALUE iseqw_s_compile_file(int argc, VALUE *argv, VALUE self) { VALUE file, line = INT2FIX(1), opt = Qnil; VALUE parser, f, exc = Qnil, ret; rb_ast_t *ast; rb_compile_option_t option; int i; i = rb_scan_args(argc, argv, "1*:", &file, NULL, &opt); if (i > 1+NIL_P(opt)) rb_error_arity(argc, 1, 2); switch (i) { case 2: opt = argv[--i]; } FilePathValue(file); file = rb_fstring(file); /* rb_io_t->pathv gets frozen anyways */ f = rb_file_open_str(file, "r"); parser = rb_parser_new(); rb_parser_set_context(parser, NULL, FALSE); ast = (rb_ast_t *)rb_parser_load_file(parser, file); if (!ast->body.root) exc = GET_EC()->errinfo; rb_io_close(f); if (!ast->body.root) { rb_ast_dispose(ast); rb_exc_raise(exc); } make_compile_option(&option, opt); ret = iseqw_new(rb_iseq_new_with_opt(&ast->body, rb_fstring_lit("
"), file, rb_realpath_internal(Qnil, file, 1), line, NULL, 0, ISEQ_TYPE_TOP, &option)); rb_ast_dispose(ast); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"/RubyVM::InstructionSequence.compile_option;F;7[;[[@Yi;T;:compile_option;0;[;{;IC; "}Returns a hash of default options used by the Ruby iseq compiler. For details, see InstructionSequence.compile_option=. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"compile_option;T;IC; ";T;[;![;"I";T;#0;$@6;.F;Bi;C0;7[;$@6;![;"I"Returns a hash of default options used by the Ruby iseq compiler. For details, see InstructionSequence.compile_option=. @overload compile_option;T;#0;$@6;.F;/o;0;1T;2i;3i;%@R;9I"{static VALUE iseqw_s_compile_option_get(VALUE self) { return make_compile_option_value(&COMPILE_OPTION_DEFAULT); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"0RubyVM::InstructionSequence.compile_option=;F;7[[I"opt;T0;[[@Yi;T;:compile_option=;0;[;{;IC; "oSets the default values for various optimizations in the Ruby iseq compiler. Possible values for +options+ include +true+, which enables all options, +false+ which disables all options, and +nil+ which leaves all options unchanged. You can also pass a +Hash+ of +options+ that you want to change, any options not present in the hash will be left unchanged. Possible option names (which are keys in +options+) which can be set to +true+ or +false+ include: * +:inline_const_cache+ * +:instructions_unification+ * +:operands_unification+ * +:peephole_optimization+ * +:specialized_instruction+ * +:stack_caching+ * +:tailcall_optimization+ Additionally, +:debug_level+ can be set to an integer. These default options can be overwritten for a single run of the iseq compiler by passing any of the above values as the +options+ parameter to ::new, ::compile and ::compile_file. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"compile_option=(options);T;IC; ";T;[;![;"I";T;#0;$@L;.F;Bi;C0;7[[I" options;T0;$@L;![;"I"Sets the default values for various optimizations in the Ruby iseq compiler. Possible values for +options+ include +true+, which enables all options, +false+ which disables all options, and +nil+ which leaves all options unchanged. You can also pass a +Hash+ of +options+ that you want to change, any options not present in the hash will be left unchanged. Possible option names (which are keys in +options+) which can be set to +true+ or +false+ include: * +:inline_const_cache+ * +:instructions_unification+ * +:operands_unification+ * +:peephole_optimization+ * +:specialized_instruction+ * +:stack_caching+ * +:tailcall_optimization+ Additionally, +:debug_level+ can be set to an integer. These default options can be overwritten for a single run of the iseq compiler by passing any of the above values as the +options+ parameter to ::new, ::compile and ::compile_file. @overload compile_option=(options);T;#0;$@L;.F;/o;0;1T;2iy;3i;%@R;9I"static VALUE iseqw_s_compile_option_set(VALUE self, VALUE opt) { rb_compile_option_t option; make_compile_option(&option, opt); COMPILE_OPTION_DEFAULT = option; return opt; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'RubyVM::InstructionSequence.disasm;F;7[[I" body;T0;[[@Yie ;T;;;0;[;{;IC; "Takes +body+, a Method or Proc object, and returns a String with the human readable instructions for +body+. For a Method object: # /tmp/method.rb def hello puts "hello, world" end puts RubyVM::InstructionSequence.disasm(method(:hello)) Produces: == disasm: ============ 0000 trace 8 ( 1) 0002 trace 1 ( 2) 0004 putself 0005 putstring "hello, world" 0007 send :puts, 1, nil, 8, 0013 trace 16 ( 3) 0015 leave ( 2) For a Proc: # /tmp/proc.rb p = proc { num = 1 + 2 } puts RubyVM::InstructionSequence.disasm(p) Produces: == disasm: @/tmp/proc.rb>=== == catch table | catch type: redo st: 0000 ed: 0012 sp: 0000 cont: 0000 | catch type: next st: 0000 ed: 0012 sp: 0000 cont: 0012 |------------------------------------------------------------------------ local table (size: 2, argc: 0 [opts: 0, rest: -1, post: 0, block: -1] s1) [ 2] num 0000 trace 1 ( 1) 0002 putobject 1 0004 putobject 2 0006 opt_plus 0008 dup 0009 setlocal num, 0 0012 leave ;T;[o;= ;>I" overload;F;?0;;;@0;:I"disasm(body);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@f;![;"I"@return [String];T;#0;$@f;.F;Bi;C0;7[[I" body;T0;$@fo;= ;>I" overload;F;?0;;;@0;:I"disassemble(body);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@f;![;"I"@return [String];T;#0;$@f;.F;Bi;C0;7[[I" body;T0;$@f;![;"I"Takes +body+, a Method or Proc object, and returns a String with the human readable instructions for +body+. For a Method object: # /tmp/method.rb def hello puts "hello, world" end puts RubyVM::InstructionSequence.disasm(method(:hello)) Produces: == disasm: ============ 0000 trace 8 ( 1) 0002 trace 1 ( 2) 0004 putself 0005 putstring "hello, world" 0007 send :puts, 1, nil, 8, 0013 trace 16 ( 3) 0015 leave ( 2) For a Proc: # /tmp/proc.rb p = proc { num = 1 + 2 } puts RubyVM::InstructionSequence.disasm(p) Produces: == disasm: @/tmp/proc.rb>=== == catch table | catch type: redo st: 0000 ed: 0012 sp: 0000 cont: 0000 | catch type: next st: 0000 ed: 0012 sp: 0000 cont: 0012 |------------------------------------------------------------------------ local table (size: 2, argc: 0 [opts: 0, rest: -1, post: 0, block: -1] s1) [ 2] num 0000 trace 1 ( 1) 0002 putobject 1 0004 putobject 2 0006 opt_plus 0008 dup 0009 setlocal num, 0 0012 leave @overload disasm(body) @return [String] @overload disassemble(body) @return [String];T;#0;$@f;.F;/o;0;1T;2i1 ;3id ;%@R;9I"static VALUE iseqw_s_disasm(VALUE klass, VALUE body) { VALUE iseqw = iseqw_s_of(klass, body); return NIL_P(iseqw) ? Qnil : rb_iseq_disasm(iseqw_check(iseqw)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",RubyVM::InstructionSequence.disassemble;F;7[[I" body;T0;[[@Yie ;T;;;0;[;{;IC; "Takes +body+, a Method or Proc object, and returns a String with the human readable instructions for +body+. For a Method object: # /tmp/method.rb def hello puts "hello, world" end puts RubyVM::InstructionSequence.disasm(method(:hello)) Produces: == disasm: ============ 0000 trace 8 ( 1) 0002 trace 1 ( 2) 0004 putself 0005 putstring "hello, world" 0007 send :puts, 1, nil, 8, 0013 trace 16 ( 3) 0015 leave ( 2) For a Proc: # /tmp/proc.rb p = proc { num = 1 + 2 } puts RubyVM::InstructionSequence.disasm(p) Produces: == disasm: @/tmp/proc.rb>=== == catch table | catch type: redo st: 0000 ed: 0012 sp: 0000 cont: 0000 | catch type: next st: 0000 ed: 0012 sp: 0000 cont: 0012 |------------------------------------------------------------------------ local table (size: 2, argc: 0 [opts: 0, rest: -1, post: 0, block: -1] s1) [ 2] num 0000 trace 1 ( 1) 0002 putobject 1 0004 putobject 2 0006 opt_plus 0008 dup 0009 setlocal num, 0 0012 leave ;T;[o;= ;>I" overload;F;?0;;;@0;:I"disasm(body);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I" body;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"disassemble(body);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I" body;T0;$@;![;"@;#0;$@;.F;/o;0;1T;2i1 ;3id ;%@R;9I"static VALUE iseqw_s_disasm(VALUE klass, VALUE body) { VALUE iseqw = iseqw_s_of(klass, body); return NIL_P(iseqw) ? Qnil : rb_iseq_disasm(iseqw_check(iseqw)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#RubyVM::InstructionSequence.of;F;7[[I" body;T0;[[@Yi ;T;:of;0;[;{;IC; "Returns the instruction sequence containing the given proc or method. For example, using irb: # a proc > p = proc { num = 1 + 2 } > RubyVM::InstructionSequence.of(p) > #=> # for a method > def foo(bar); puts bar; end > RubyVM::InstructionSequence.of(method(:foo)) > #=> Using ::compile_file: # /tmp/iseq_of.rb def hello puts "hello, world" end $a_global_proc = proc { str = 'a' + 'b' } # in irb > require '/tmp/iseq_of.rb' # first the method hello > RubyVM::InstructionSequence.of(method(:hello)) > #=> # # then the global proc > RubyVM::InstructionSequence.of($a_global_proc) > #=> # ;T;[;![;"I"Returns the instruction sequence containing the given proc or method. For example, using irb: # a proc > p = proc { num = 1 + 2 } > RubyVM::InstructionSequence.of(p) > #=> # for a method > def foo(bar); puts bar; end > RubyVM::InstructionSequence.of(method(:foo)) > #=> Using ::compile_file: # /tmp/iseq_of.rb def hello puts "hello, world" end $a_global_proc = proc { str = 'a' + 'b' } # in irb > require '/tmp/iseq_of.rb' # first the method hello > RubyVM::InstructionSequence.of(method(:hello)) > #=> # # then the global proc > RubyVM::InstructionSequence.of($a_global_proc) > #=> # ;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@R;9I"static VALUE iseqw_s_of(VALUE klass, VALUE body) { const rb_iseq_t *iseq = NULL; if (rb_obj_is_proc(body)) { iseq = vm_proc_iseq(body); if (!rb_obj_is_iseq((VALUE)iseq)) { iseq = NULL; } } else if (rb_obj_is_method(body)) { iseq = rb_method_iseq(body); } else if (rb_typeddata_is_instance_of(body, &iseqw_data_type)) { return body; } return iseq ? iseqw_new(iseq) : Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"-RubyVM::InstructionSequence#script_lines;F;7[;[[@Yi;T;:script_lines;0;[;{;IC; "(It returns recorded script lines if it is availalble. The script lines are not limited to the iseq range, but are entire lines of the source file. Note that this is an API for ruby internal use, debugging, and research. Do not use this for any other purpose. The compatibility is not guaranteed. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"script_lines;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;TI"nil;T;$@;![;"I"@return [Array, nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"XIt returns recorded script lines if it is availalble. The script lines are not limited to the iseq range, but are entire lines of the source file. Note that this is an API for ruby internal use, debugging, and research. Do not use this for any other purpose. The compatibility is not guaranteed. @overload script_lines @return [Array, nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@R;9I"static VALUE iseqw_script_lines(VALUE self) { const rb_iseq_t *iseq = iseqw_check(self); return iseq->body->variable.script_lines; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*RubyVM::InstructionSequence.iseq_load;T;7[[00[I"opt;T0;[[@Yi;T;:iseq_load;0;[;{;IC; " ;T;[;![;"@;#0;$@;%o;( ;)@;*I" RubyVM::InstructionSequence;T;+0;:InstructionSequence;%o;( ;)0;*0;+0;: RubyVM;%@;-@;0;-@R;0;9I"w static VALUE iseq_load(VALUE data, const rb_iseq_t *parent, VALUE opt) { rb_iseq_t *iseq = iseq_alloc(); VALUE magic, version1, version2, format_type, misc; VALUE name, path, realpath, first_lineno, code_location, node_id; VALUE type, body, locals, params, exception; st_data_t iseq_type; rb_compile_option_t option; int i = 0; rb_code_location_t tmp_loc = { {0, 0}, {-1, -1} }; /* [magic, major_version, minor_version, format_type, misc, * label, path, first_lineno, * type, locals, args, exception_table, body] */ data = CHECK_ARRAY(data); magic = CHECK_STRING(rb_ary_entry(data, i++)); version1 = CHECK_INTEGER(rb_ary_entry(data, i++)); version2 = CHECK_INTEGER(rb_ary_entry(data, i++)); format_type = CHECK_INTEGER(rb_ary_entry(data, i++)); misc = CHECK_HASH(rb_ary_entry(data, i++)); ((void)magic, (void)version1, (void)version2, (void)format_type); name = CHECK_STRING(rb_ary_entry(data, i++)); path = CHECK_STRING(rb_ary_entry(data, i++)); realpath = rb_ary_entry(data, i++); realpath = NIL_P(realpath) ? Qnil : CHECK_STRING(realpath); first_lineno = CHECK_INTEGER(rb_ary_entry(data, i++)); type = CHECK_SYMBOL(rb_ary_entry(data, i++)); locals = CHECK_ARRAY(rb_ary_entry(data, i++)); params = CHECK_HASH(rb_ary_entry(data, i++)); exception = CHECK_ARRAY(rb_ary_entry(data, i++)); body = CHECK_ARRAY(rb_ary_entry(data, i++)); iseq->body->local_iseq = iseq; iseq_type = iseq_type_from_sym(type); if (iseq_type == (enum iseq_type)-1) { rb_raise(rb_eTypeError, "unsupported type: :%"PRIsVALUE, rb_sym2str(type)); } node_id = rb_hash_aref(misc, ID2SYM(rb_intern("node_id"))); code_location = rb_hash_aref(misc, ID2SYM(rb_intern("code_location"))); if (RB_TYPE_P(code_location, T_ARRAY) && RARRAY_LEN(code_location) == 4) { tmp_loc.beg_pos.lineno = NUM2INT(rb_ary_entry(code_location, 0)); tmp_loc.beg_pos.column = NUM2INT(rb_ary_entry(code_location, 1)); tmp_loc.end_pos.lineno = NUM2INT(rb_ary_entry(code_location, 2)); tmp_loc.end_pos.column = NUM2INT(rb_ary_entry(code_location, 3)); } make_compile_option(&option, opt); option.peephole_optimization = FALSE; /* because peephole optimization can modify original iseq */ prepare_iseq_build(iseq, name, path, realpath, first_lineno, &tmp_loc, NUM2INT(node_id), parent, 0, (enum iseq_type)iseq_type, Qnil, &option); rb_iseq_build_from_ary(iseq, misc, locals, params, exception, body); finish_iseq_build(iseq); return iseqw_new(iseq); };T;:I"static VALUE;T;;T; @R; IC;[; @R; IC;[; @R; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Yi[@Yi;T;;;;;;;[;{;IC; "The InstructionSequence class represents a compiled sequence of instructions for the Virtual Machine used in MRI. Not all implementations of Ruby may implement this class, and for the implementations that implement it, the methods defined and behavior of the methods can change in any version. With it, you can get a handle to the instructions that make up a method or a proc, compile strings of Ruby code down to VM instructions, and disassemble instruction sequences to strings for easy inspection. It is mostly useful if you want to learn how YARV works, but it also lets you control various settings for the Ruby iseq compiler. You can find the source for the VM instructions in +insns.def+ in the Ruby source. The instruction sequence results will almost certainly change as Ruby changes, so example output in this documentation may be different from what you see. Of course, this class is MRI specific.;T;[;![;"I" The InstructionSequence class represents a compiled sequence of instructions for the Virtual Machine used in MRI. Not all implementations of Ruby may implement this class, and for the implementations that implement it, the methods defined and behavior of the methods can change in any version. With it, you can get a handle to the instructions that make up a method or a proc, compile strings of Ruby code down to VM instructions, and disassemble instruction sequences to strings for easy inspection. It is mostly useful if you want to learn how YARV works, but it also lets you control various settings for the Ruby iseq compiler. You can find the source for the VM instructions in +insns.def+ in the Ruby source. The instruction sequence results will almost certainly change as Ruby changes, so example output in this documentation may be different from what you see. Of course, this class is MRI specific. ;T;#0;$@R;.F;/o;0;1T;2i;3i;Bi;%@;&I" RubyVM::InstructionSequence;F;'@o;;IC;[o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[I" ast.c;Ti;F;: Node;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"%RubyVM::AbstractSyntaxTree::Node;F;'@; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i;F;:AbstractSyntaxTree;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"RubyVM::AbstractSyntaxTree;F; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@&im [@&ix ;T;;;;;;;[;{;IC; "eThe RubyVM module only exists on MRI. +RubyVM+ is not defined in other Ruby implementations such as JRuby and TruffleRuby. The RubyVM module provides some access to MRI internals. This module is for very limited purposes, such as debugging, prototyping, and research. Normal users must not use it. This module is not portable between Ruby implementations.;T;[;![;"I"g The RubyVM module only exists on MRI. +RubyVM+ is not defined in other Ruby implementations such as JRuby and TruffleRuby. The RubyVM module provides some access to MRI internals. This module is for very limited purposes, such as debugging, prototyping, and research. Normal users must not use it. This module is not portable between Ruby implementations. ;T;#0;$@;.F;/o;0;1T;2im ;3iu ;Bi;%@;&I" RubyVM;F;'@o; ;IC;[; @F; IC;[; @F; IC;[; @F; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Ti4[@TiE7;T;: IOError;;;;;[;{;IC; "Raised when an IO operation fails. File.open("/etc/hosts") {|f| f << "example"} #=> IOError: not opened for writing File.open("/etc/hosts") {|f| f.close; f.read } #=> IOError: closed stream Note that some IO failures raise SystemCallErrors and these are not subclasses of IOError: File.open("does/not/exist") #=> Errno::ENOENT: No such file or directory - does/not/exist ;T;[;![;"I" Raised when an IO operation fails. File.open("/etc/hosts") {|f| f << "example"} #=> IOError: not opened for writing File.open("/etc/hosts") {|f| f.close; f.read } #=> IOError: closed stream Note that some IO failures raise SystemCallErrors and these are not subclasses of IOError: File.open("does/not/exist") #=> Errno::ENOENT: No such file or directory - does/not/exist ;T;#0;$@F;.F;/o;0;1T;2i4;3i5;%@;&I" IOError;F;'o;( ;)0;*0;+0;;,;%@;-@;;o; ;IC;[; @[; IC;[; @[; IC;[; @[; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Ti5[@TiF7;T;: EOFError;;;;;[;{;IC; "YRaised by some IO operations when reaching the end of file. Many IO methods exist in two forms, one that returns +nil+ when the end of file is reached, the other raises +EOFError+. +EOFError+ is a subclass of +IOError+. file = File.open("/etc/hosts") file.read file.gets #=> nil file.readline #=> EOFError: end of file reached ;T;[;![;"I"[ Raised by some IO operations when reaching the end of file. Many IO methods exist in two forms, one that returns +nil+ when the end of file is reached, the other raises +EOFError+. +EOFError+ is a subclass of +IOError+. file = File.open("/etc/hosts") file.read file.gets #=> nil file.readline #=> EOFError: end of file reached ;T;#0;$@[;.F;/o;0;1T;2i5;3i5;%@;&I" EOFError;F;'@F@kL@fo;u;[[@Ti&8;F;: STDIN;;w;;;[;{;IC; "Holds the original stdin ;T;[;![;"I"Holds the original stdin;T;#0;$@o;.F;/o;0;1T;2i%8;3i%8;%@;&I" STDIN;F;xI" rb_stdin;To;u;[[@Ti(8;F;: STDOUT;;w;;;[;{;IC; "Holds the original stdout ;T;[;![;"I"Holds the original stdout;T;#0;$@{;.F;/o;0;1T;2i'8;3i'8;%@;&I" STDOUT;F;xI"rb_stdout;To;u;[[@Ti*8;F;: STDERR;;w;;;[;{;IC; "Holds the original stderr ;T;[;![;"I"Holds the original stderr;T;#0;$@;.F;/o;0;1T;2i)8;3i)8;%@;&I" STDERR;F;xI"rb_stderr;To;u;[[@Ti|8;F;: ARGF;;w;;;[;{;IC; "9$ ruby argf.rb --verbose file1 file2 ARGV #=> ["--verbose", "file1", "file2"] option = ARGV.shift #=> "--verbose" ARGV #=> ["file1", "file2"] You can now use +ARGF+ to work with a concatenation of each of these named files. For instance, +ARGF.read+ will return the contents of _file1_ followed by the contents of _file2_. After a file in +ARGV+ has been read +ARGF+ removes it from the Array. Thus, after all files have been read +ARGV+ will be empty. You can manipulate +ARGV+ yourself to control what +ARGF+ operates on. If you remove a file from +ARGV+, it is ignored by +ARGF+; if you add files to +ARGV+, they are treated as if they were named on the command line. For example: ARGV.replace ["file1"] ARGF.readlines # Returns the contents of file1 as an Array ARGV #=> [] ARGV.replace ["file2", "file3"] ARGF.read # Returns the contents of file2 and file3 If +ARGV+ is empty, +ARGF+ acts as if it contained STDIN, i.e. the data piped to your script. For example: $ echo "glark" | ruby -e 'p ARGF.read' "glark\n" ;T;[;![;"I":$ ruby argf.rb --verbose file1 file2 ARGV #=> ["--verbose", "file1", "file2"] option = ARGV.shift #=> "--verbose" ARGV #=> ["file1", "file2"] You can now use +ARGF+ to work with a concatenation of each of these named files. For instance, +ARGF.read+ will return the contents of _file1_ followed by the contents of _file2_. After a file in +ARGV+ has been read +ARGF+ removes it from the Array. Thus, after all files have been read +ARGV+ will be empty. You can manipulate +ARGV+ yourself to control what +ARGF+ operates on. If you remove a file from +ARGV+, it is ignored by +ARGF+; if you add files to +ARGV+, they are treated as if they were named on the command line. For example: ARGV.replace ["file1"] ARGF.readlines # Returns the contents of file1 as an Array ARGV #=> [] ARGV.replace ["file2", "file3"] ARGF.read # Returns the contents of file2 and file3 If +ARGV+ is empty, +ARGF+ acts as if it contained STDIN, i.e. the data piped to your script. For example: $ echo "glark" | ruby -e 'p ARGF.read' "glark\n" ;T;#0;$@;%@;&I" ARGF;F;xI";+ARGF+ is a stream designed for use in scripts that process files given as command-line arguments or passed in via STDIN. The arguments passed to your script are stored in the +ARGV+ Array, one argument per element. +ARGF+ assumes that any arguments that aren't filenames have been removed from +ARGV+. For example;To;;IC;[1o;4;5F;6;;;;&I"Readline#readline;F;7[[@90;[[I"ext/readline/readline.c;Ti;T;;;0;[;{;IC; "BShows the +prompt+ and reads the inputted line with line editing. The inputted line is added to the history if +add_hist+ is true. Returns nil when the inputted line is empty and user inputs EOF (Presses ^D on UNIX). Raises IOError exception if one of below conditions are satisfied. 1. stdin was closed. 2. stdout was closed. This method supports thread. Switches the thread context when waits inputting line. Supports line edit when inputs line. Provides VI and Emacs editing mode. Default is Emacs editing mode. NOTE: Terminates ruby interpreter and does not return the terminal status after user pressed '^C' when wait inputting line. Give 3 examples that avoid it. * Catches the Interrupt exception by pressed ^C after returns terminal status: require "readline" stty_save = `stty -g`.chomp begin while buf = Readline.readline p buf end rescue Interrupt system("stty", stty_save) exit end end end * Catches the INT signal by pressed ^C after returns terminal status: require "readline" stty_save = `stty -g`.chomp trap("INT") { system "stty", stty_save; exit } while buf = Readline.readline p buf end * Ignores pressing ^C: require "readline" trap("INT", "SIG_IGN") while buf = Readline.readline p buf end Can make as follows with Readline::HISTORY constant. It does not record to the history if the inputted line is empty or the same it as last one. require "readline" while buf = Readline.readline("> ", true) # p Readline::HISTORY.to_a Readline::HISTORY.pop if /^\s*$/ =~ buf begin if Readline::HISTORY[Readline::HISTORY.length-2] == buf Readline::HISTORY.pop end rescue IndexError end # p Readline::HISTORY.to_a print "-> ", buf, "\n" end ;T;[o;= ;>I" overload;F;?0;;;@0;:I",readline(prompt = "", add_hist = false);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@;![;"I"@return [String, nil];T;#0;$@;.F;Bi;C0;7[[I" prompt;TI""";T[I" add_hist;TI" false;T;$@;![;"I"Shows the +prompt+ and reads the inputted line with line editing. The inputted line is added to the history if +add_hist+ is true. Returns nil when the inputted line is empty and user inputs EOF (Presses ^D on UNIX). Raises IOError exception if one of below conditions are satisfied. 1. stdin was closed. 2. stdout was closed. This method supports thread. Switches the thread context when waits inputting line. Supports line edit when inputs line. Provides VI and Emacs editing mode. Default is Emacs editing mode. NOTE: Terminates ruby interpreter and does not return the terminal status after user pressed '^C' when wait inputting line. Give 3 examples that avoid it. * Catches the Interrupt exception by pressed ^C after returns terminal status: require "readline" stty_save = `stty -g`.chomp begin while buf = Readline.readline p buf end rescue Interrupt system("stty", stty_save) exit end end end * Catches the INT signal by pressed ^C after returns terminal status: require "readline" stty_save = `stty -g`.chomp trap("INT") { system "stty", stty_save; exit } while buf = Readline.readline p buf end * Ignores pressing ^C: require "readline" trap("INT", "SIG_IGN") while buf = Readline.readline p buf end Can make as follows with Readline::HISTORY constant. It does not record to the history if the inputted line is empty or the same it as last one. require "readline" while buf = Readline.readline("> ", true) # p Readline::HISTORY.to_a Readline::HISTORY.pop if /^\s*$/ =~ buf begin if Readline::HISTORY[Readline::HISTORY.length-2] == buf Readline::HISTORY.pop end rescue IndexError end # p Readline::HISTORY.to_a print "-> ", buf, "\n" end @overload readline(prompt = "", add_hist = false) @return [String, nil];T;#0;$@;.F;C0;%@;9I"\static VALUE readline_readline(int argc, VALUE *argv, VALUE self) { VALUE tmp, add_hist, result; char *prompt = NULL; char *buff; int status; if (rb_scan_args(argc, argv, "02", &tmp, &add_hist) > 0) { OutputStringValue(tmp); #if USE_INSERT_IGNORE_ESCAPE tmp = insert_ignore_escape(self, tmp); rb_str_locktmp(tmp); #endif prompt = RSTRING_PTR(tmp); } prepare_readline(); #ifdef _WIN32 rl_prep_terminal(1); #endif buff = (char*)rb_protect(readline_get, (VALUE)prompt, &status); #if USE_INSERT_IGNORE_ESCAPE if (prompt) { rb_str_unlocktmp(tmp); } #endif if (status) { #if defined HAVE_RL_CLEANUP_AFTER_SIGNAL /* restore terminal mode and signal handler*/ #if defined HAVE_RL_FREE_LINE_STATE rl_free_line_state(); #endif rl_cleanup_after_signal(); #elif defined HAVE_RL_DEPREP_TERM_FUNCTION /* restore terminal mode */ if (rl_deprep_term_function != NULL) /* NULL in libedit. [ruby-dev:29116] */ (*rl_deprep_term_function)(); else #else rl_deprep_terminal(); #endif rb_jump_tag(status); } if (RTEST(add_hist) && buff) { add_history(buff); } if (buff) { result = rb_locale_str_new_cstr(buff); } else result = Qnil; if (buff) free(buff); return result; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Readline.readline;F;7@;@;T;;;0;@;{;IC; "BShows the +prompt+ and reads the inputted line with line editing. The inputted line is added to the history if +add_hist+ is true. Returns nil when the inputted line is empty and user inputs EOF (Presses ^D on UNIX). Raises IOError exception if one of below conditions are satisfied. 1. stdin was closed. 2. stdout was closed. This method supports thread. Switches the thread context when waits inputting line. Supports line edit when inputs line. Provides VI and Emacs editing mode. Default is Emacs editing mode. NOTE: Terminates ruby interpreter and does not return the terminal status after user pressed '^C' when wait inputting line. Give 3 examples that avoid it. * Catches the Interrupt exception by pressed ^C after returns terminal status: require "readline" stty_save = `stty -g`.chomp begin while buf = Readline.readline p buf end rescue Interrupt system("stty", stty_save) exit end end end * Catches the INT signal by pressed ^C after returns terminal status: require "readline" stty_save = `stty -g`.chomp trap("INT") { system "stty", stty_save; exit } while buf = Readline.readline p buf end * Ignores pressing ^C: require "readline" trap("INT", "SIG_IGN") while buf = Readline.readline p buf end Can make as follows with Readline::HISTORY constant. It does not record to the history if the inputted line is empty or the same it as last one. require "readline" while buf = Readline.readline("> ", true) # p Readline::HISTORY.to_a Readline::HISTORY.pop if /^\s*$/ =~ buf begin if Readline::HISTORY[Readline::HISTORY.length-2] == buf Readline::HISTORY.pop end rescue IndexError end # p Readline::HISTORY.to_a print "-> ", buf, "\n" end;T;[o;= ;>I" overload;F;?0;;;@0;:I",readline(prompt = "", add_hist = false);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@;![;"I"@return [String, nil];T;#0;$@;.F;Bi;C0;7[[I" prompt;TI""";T[I" add_hist;TI" false;T;$@;![;"I"Shows the +prompt+ and reads the inputted line with line editing. The inputted line is added to the history if +add_hist+ is true. Returns nil when the inputted line is empty and user inputs EOF (Presses ^D on UNIX). Raises IOError exception if one of below conditions are satisfied. 1. stdin was closed. 2. stdout was closed. This method supports thread. Switches the thread context when waits inputting line. Supports line edit when inputs line. Provides VI and Emacs editing mode. Default is Emacs editing mode. NOTE: Terminates ruby interpreter and does not return the terminal status after user pressed '^C' when wait inputting line. Give 3 examples that avoid it. * Catches the Interrupt exception by pressed ^C after returns terminal status: require "readline" stty_save = `stty -g`.chomp begin while buf = Readline.readline p buf end rescue Interrupt system("stty", stty_save) exit end end end * Catches the INT signal by pressed ^C after returns terminal status: require "readline" stty_save = `stty -g`.chomp trap("INT") { system "stty", stty_save; exit } while buf = Readline.readline p buf end * Ignores pressing ^C: require "readline" trap("INT", "SIG_IGN") while buf = Readline.readline p buf end Can make as follows with Readline::HISTORY constant. It does not record to the history if the inputted line is empty or the same it as last one. require "readline" while buf = Readline.readline("> ", true) # p Readline::HISTORY.to_a Readline::HISTORY.pop if /^\s*$/ =~ buf begin if Readline::HISTORY[Readline::HISTORY.length-2] == buf Readline::HISTORY.pop end rescue IndexError end # p Readline::HISTORY.to_a print "-> ", buf, "\n" end @overload readline(prompt = "", add_hist = false) @return [String, nil];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Readline.input=;F;7[[I" input;T0;[[@i';T;: input=;0;[;{;IC; "WSpecifies a File object +input+ that is input stream for Readline.readline method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"input=(input);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" input;T0;$@;![;"I"qSpecifies a File object +input+ that is input stream for Readline.readline method. @overload input=(input);T;#0;$@;.F;/o;0;1T;2i ;3i$;%@;9I"static VALUE readline_s_set_input(VALUE self, VALUE input) { rb_io_t *ifp; int fd; FILE *f; if (NIL_P(input)) { clear_rl_instream(); } else { Check_Type(input, T_FILE); GetOpenFile(input, ifp); clear_rl_instream(); fd = rb_cloexec_dup(ifp->fd); if (fd == -1) rb_sys_fail("dup"); f = fdopen(fd, "r"); if (f == NULL) { int save_errno = errno; close(fd); rb_syserr_fail(save_errno, "fdopen"); } rl_instream = readline_rl_instream = f; readline_instream = input; } return input; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Readline.output=;F;7[[I" output;T0;[[@iK;T;: output=;0;[;{;IC; "YSpecifies a File object +output+ that is output stream for Readline.readline method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"output=(output);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" output;T0;$@;![;"I"uSpecifies a File object +output+ that is output stream for Readline.readline method. @overload output=(output);T;#0;$@;.F;/o;0;1T;2iD;3iH;%@;9I"static VALUE readline_s_set_output(VALUE self, VALUE output) { rb_io_t *ofp; int fd; FILE *f; if (NIL_P(output)) { clear_rl_outstream(); } else { Check_Type(output, T_FILE); GetOpenFile(output, ofp); clear_rl_outstream(); fd = rb_cloexec_dup(ofp->fd); if (fd == -1) rb_sys_fail("dup"); f = fdopen(fd, "w"); if (f == NULL) { int save_errno = errno; close(fd); rb_syserr_fail(save_errno, "fdopen"); } rl_outstream = readline_rl_outstream = f; readline_outstream = output; } return output; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Readline.completion_proc=;F;7[[I" proc;T0;[[@iD;T;:completion_proc=;0;[;{;IC; "Specifies a Proc object +proc+ to determine completion behavior. It should take input string and return an array of completion candidates. The default completion is used if +proc+ is nil. The String that is passed to the Proc depends on the Readline.completer_word_break_characters property. By default the word under the cursor is passed to the Proc. For example, if the input is "foo bar" then only "bar" would be passed to the completion Proc. Upon successful completion the Readline.completion_append_character will be appended to the input so the user can start working on their next argument. = Examples == Completion for a Static List require 'readline' LIST = [ 'search', 'download', 'open', 'help', 'history', 'quit', 'url', 'next', 'clear', 'prev', 'past' ].sort comp = proc { |s| LIST.grep(/^#{Regexp.escape(s)}/) } Readline.completion_append_character = " " Readline.completion_proc = comp while line = Readline.readline('> ', true) p line end == Completion For Directory Contents require 'readline' Readline.completion_append_character = " " Readline.completion_proc = Proc.new do |str| Dir[str+'*'].grep(/^#{Regexp.escape(str)}/) end while line = Readline.readline('> ', true) p line end = Autocomplete strategies When working with auto-complete there are some strategies that work well. To get some ideas you can take a look at the completion.rb[https://git.ruby-lang.org/ruby.git/tree/lib/irb/completion.rb] file for irb. The common strategy is to take a list of possible completions and filter it down to those completions that start with the user input. In the above examples Enumerator.grep is used. The input is escaped to prevent Regexp special characters from interfering with the matching. It may also be helpful to use the Abbrev library to generate completions. Raises ArgumentError if +proc+ does not respond to the call method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"completion_proc=(proc);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I" proc;T0;$@ ;![;"I"Specifies a Proc object +proc+ to determine completion behavior. It should take input string and return an array of completion candidates. The default completion is used if +proc+ is nil. The String that is passed to the Proc depends on the Readline.completer_word_break_characters property. By default the word under the cursor is passed to the Proc. For example, if the input is "foo bar" then only "bar" would be passed to the completion Proc. Upon successful completion the Readline.completion_append_character will be appended to the input so the user can start working on their next argument. = Examples == Completion for a Static List require 'readline' LIST = [ 'search', 'download', 'open', 'help', 'history', 'quit', 'url', 'next', 'clear', 'prev', 'past' ].sort comp = proc { |s| LIST.grep(/^#{Regexp.escape(s)}/) } Readline.completion_append_character = " " Readline.completion_proc = comp while line = Readline.readline('> ', true) p line end == Completion For Directory Contents require 'readline' Readline.completion_append_character = " " Readline.completion_proc = Proc.new do |str| Dir[str+'*'].grep(/^#{Regexp.escape(str)}/) end while line = Readline.readline('> ', true) p line end = Autocomplete strategies When working with auto-complete there are some strategies that work well. To get some ideas you can take a look at the completion.rb[https://git.ruby-lang.org/ruby.git/tree/lib/irb/completion.rb] file for irb. The common strategy is to take a list of possible completions and filter it down to those completions that start with the user input. In the above examples Enumerator.grep is used. The input is escaped to prevent Regexp special characters from interfering with the matching. It may also be helpful to use the Abbrev library to generate completions. Raises ArgumentError if +proc+ does not respond to the call method. @overload completion_proc=(proc);T;#0;$@ ;.F;/o;0;1T;2i;3iA;%@;9I"static VALUE readline_s_set_completion_proc(VALUE self, VALUE proc) { mustbe_callable(proc); return rb_ivar_set(mReadline, completion_proc, proc); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Readline.completion_proc;F;7[;[[@iQ;T;:completion_proc;0;[;{;IC; "(Returns the completion Proc object. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"completion_proc;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@- ;![;"I"@return [Proc];T;#0;$@- ;.F;Bi;C0;7[;$@- ;![;"I"UReturns the completion Proc object. @overload completion_proc @return [Proc];T;#0;$@- ;.F;/o;0;1T;2iK;3iO;%@;9I"tstatic VALUE readline_s_get_completion_proc(VALUE self) { return rb_attr_get(mReadline, completion_proc); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%Readline.quoting_detection_proc=;F;7[[I" proc;T0;[[@im;T;:quoting_detection_proc=;0;[;{;IC; "Specifies a Proc object +proc+ to determine if a character in the user's input is escaped. It should take the user's input and the index of the character in question as input, and return a boolean (true if the specified character is escaped). Readline will only call this proc with characters specified in +completer_quote_characters+, to discover if they indicate the end of a quoted argument, or characters specified in +completer_word_break_characters+, to discover if they indicate a break between arguments. If +completer_quote_characters+ is not set, or if the user input doesn't contain one of the +completer_quote_characters+ or a +\+ character, Readline will not attempt to use this proc at all. Raises ArgumentError if +proc+ does not respond to the call method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I""quoting_detection_proc=(proc);T;IC; ";T;[;![;"I";T;#0;$@H ;.F;Bi;C0;7[[I" proc;T0;$@H ;![;"I"1Specifies a Proc object +proc+ to determine if a character in the user's input is escaped. It should take the user's input and the index of the character in question as input, and return a boolean (true if the specified character is escaped). Readline will only call this proc with characters specified in +completer_quote_characters+, to discover if they indicate the end of a quoted argument, or characters specified in +completer_word_break_characters+, to discover if they indicate a break between arguments. If +completer_quote_characters+ is not set, or if the user input doesn't contain one of the +completer_quote_characters+ or a +\+ character, Readline will not attempt to use this proc at all. Raises ArgumentError if +proc+ does not respond to the call method. @overload quoting_detection_proc=(proc);T;#0;$@H ;.F;/o;0;1T;2iX;3ij;%@;9I"static VALUE readline_s_set_quoting_detection_proc(VALUE self, VALUE proc) { mustbe_callable(proc); return rb_ivar_set(mReadline, quoting_detection_proc, proc); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$Readline.quoting_detection_proc;F;7[;[[@iz;T;:quoting_detection_proc;0;[;{;IC; "/Returns the quoting detection Proc object. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"quoting_detection_proc;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@b ;![;"I"@return [Proc];T;#0;$@b ;.F;Bi;C0;7[;$@b ;![;"I"cReturns the quoting detection Proc object. @overload quoting_detection_proc @return [Proc];T;#0;$@b ;.F;/o;0;1T;2it;3ix;%@;9I"}static VALUE readline_s_get_quoting_detection_proc(VALUE self) { return rb_attr_get(mReadline, quoting_detection_proc); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#Readline.completion_case_fold=;F;7[[I"val;T0;[[@i;T;:completion_case_fold=;0;[;{;IC; "6Sets whether or not to ignore case on completion. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" completion_case_fold=(bool);T;IC; ";T;[;![;"I";T;#0;$@} ;.F;Bi;C0;7[[I" bool;T0;$@} ;![;"I"^Sets whether or not to ignore case on completion. @overload completion_case_fold=(bool);T;#0;$@} ;.F;/o;0;1T;2i;3i;%@;9I"static VALUE readline_s_set_completion_case_fold(VALUE self, VALUE val) { return rb_ivar_set(mReadline, completion_case_fold, val); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""Readline.completion_case_fold;F;7[;[[@i;T;:completion_case_fold;0;[;{;IC; "!Returns true if completion ignores case. If no, returns false. NOTE: Returns the same object that is specified by Readline.completion_case_fold= method. require "readline" Readline.completion_case_fold = "This is a String." p Readline.completion_case_fold # => "This is a String." ;T;[o;= ;>I" overload;F;?0;;;@0;:I"completion_case_fold;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ ;![;"I"@return [Boolean];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"VReturns true if completion ignores case. If no, returns false. NOTE: Returns the same object that is specified by Readline.completion_case_fold= method. require "readline" Readline.completion_case_fold = "This is a String." p Readline.completion_case_fold # => "This is a String." @overload completion_case_fold @return [Boolean];T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;9I"~static VALUE readline_s_get_completion_case_fold(VALUE self) { return rb_attr_get(mReadline, completion_case_fold); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Readline.line_buffer;F;7[;[[@i;T;:line_buffer;0;[;{;IC; "%Returns the full line that is being edited. This is useful from within the complete_proc for determining the context of the completion request. The length of +Readline.line_buffer+ and GNU Readline's rl_end are same. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"line_buffer;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"PReturns the full line that is being edited. This is useful from within the complete_proc for determining the context of the completion request. The length of +Readline.line_buffer+ and GNU Readline's rl_end are same. Raises NotImplementedError if the using readline library does not support. @overload line_buffer @return [String];T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;9I"static VALUE readline_s_get_line_buffer(VALUE self) { if (rl_line_buffer == NULL) return Qnil; return rb_locale_str_new_cstr(rl_line_buffer); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Readline.point;F;7[;[[@i;T;: point;0;[;{;IC; "Returns the index of the current cursor position in +Readline.line_buffer+. The index in +Readline.line_buffer+ which matches the start of input-string passed to completion_proc is computed by subtracting the length of input-string from +Readline.point+. start = (the length of input-string) - Readline.point Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" point;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Returns the index of the current cursor position in +Readline.line_buffer+. The index in +Readline.line_buffer+ which matches the start of input-string passed to completion_proc is computed by subtracting the length of input-string from +Readline.point+. start = (the length of input-string) - Readline.point Raises NotImplementedError if the using readline library does not support. @overload point @return [Integer];T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;9I"Tstatic VALUE readline_s_get_point(VALUE self) { return INT2NUM(rl_point); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Readline.point=;F;7[[I"pos;T0;[[@i;T;: point=;0;[;{;IC; "Set the index of the current cursor position in +Readline.line_buffer+. Raises NotImplementedError if the using readline library does not support. See +Readline.point+. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"point=(int);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I"int;T0;$@ ;![;"I"Set the index of the current cursor position in +Readline.line_buffer+. Raises NotImplementedError if the using readline library does not support. See +Readline.point+. @overload point=(int);T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;9I"nstatic VALUE readline_s_set_point(VALUE self, VALUE pos) { rl_point = NUM2INT(pos); return pos; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Readline.set_screen_size;F;7[[I" rows;T0[I" columns;T0;[[@iX;T;:set_screen_size;0;[;{;IC; "Set terminal size to +rows+ and +columns+. See GNU Readline's rl_set_screen_size function. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"#set_screen_size(rows, columns);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@ ;![;"I"@return [self];T;#0;$@ ;.F;Bi;C0;7[[I" rows;T0[I" columns;T0;$@ ;![;"I"Set terminal size to +rows+ and +columns+. See GNU Readline's rl_set_screen_size function. Raises NotImplementedError if the using readline library does not support. @overload set_screen_size(rows, columns) @return [self];T;#0;$@ ;.F;/o;0;1T;2iN;3iV;%@;9I"static VALUE readline_s_set_screen_size(VALUE self, VALUE rows, VALUE columns) { rl_set_screen_size(NUM2INT(rows), NUM2INT(columns)); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Readline.get_screen_size;F;7[;[[@im;T;:get_screen_size;0;[;{;IC; "Returns the terminal's rows and columns. See GNU Readline's rl_get_screen_size function. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"get_screen_size;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@% ;![;"I"@return [Array];T;#0;$@% ;.F;Bi;C0;7[;$@% ;![;"I"Returns the terminal's rows and columns. See GNU Readline's rl_get_screen_size function. Raises NotImplementedError if the using readline library does not support. @overload get_screen_size @return [Array];T;#0;$@% ;.F;/o;0;1T;2ic;3ik;%@;9I"static VALUE readline_s_get_screen_size(VALUE self) { int rows, columns; VALUE res; rl_get_screen_size(&rows, &columns); res = rb_ary_new(); rb_ary_push(res, INT2NUM(rows)); rb_ary_push(res, INT2NUM(columns)); return res; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Readline.vi_editing_mode;F;7[;[[@i;T;:vi_editing_mode;0;[;{;IC; "Specifies VI editing mode. See the manual of GNU Readline for details of VI editing mode. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"vi_editing_mode;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@@ ;![;"I"@return [nil];T;#0;$@@ ;.F;Bi;C0;7[;$@@ ;![;"I"Specifies VI editing mode. See the manual of GNU Readline for details of VI editing mode. Raises NotImplementedError if the using readline library does not support. @overload vi_editing_mode @return [nil];T;#0;$@@ ;.F;/o;0;1T;2i;3i;%@;9I"jstatic VALUE readline_s_vi_editing_mode(VALUE self) { rl_vi_editing_mode(1,0); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Readline.vi_editing_mode?;F;7[;[[@i;T;:vi_editing_mode?;0;[;{;IC; "Returns true if vi mode is active. Returns false if not. Raises NotImplementedError if the using readline library does not support.;T;[o;= ;>I" overload;F;?0;;;@0;:I"vi_editing_mode?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@[ ;![;"I"@return [Boolean];T;#0;$@[ ;.F;Bi;C0;7[;$@[ ;![;"I"Returns true if vi mode is active. Returns false if not. Raises NotImplementedError if the using readline library does not support. @overload vi_editing_mode? @return [Boolean];T;#0;$@[ ;.F;/o;0;1T;2i;3i;Bi;%@;9I"pstatic VALUE readline_s_vi_editing_mode_p(VALUE self) { return rl_editing_mode == 0 ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Readline.emacs_editing_mode;F;7[;[[@i;T;:emacs_editing_mode;0;[;{;IC; "Specifies Emacs editing mode. The default is this mode. See the manual of GNU Readline for details of Emacs editing mode. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"emacs_editing_mode;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@v ;![;"I"@return [nil];T;#0;$@v ;.F;Bi;C0;7[;$@v ;![;"I"Specifies Emacs editing mode. The default is this mode. See the manual of GNU Readline for details of Emacs editing mode. Raises NotImplementedError if the using readline library does not support. @overload emacs_editing_mode @return [nil];T;#0;$@v ;.F;/o;0;1T;2i;3i;%@;9I"pstatic VALUE readline_s_emacs_editing_mode(VALUE self) { rl_emacs_editing_mode(1,0); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Readline.emacs_editing_mode?;F;7[;[[@i;T;:emacs_editing_mode?;0;[;{;IC; "Returns true if emacs mode is active. Returns false if not. Raises NotImplementedError if the using readline library does not support.;T;[o;= ;>I" overload;F;?0;;;@0;:I"emacs_editing_mode?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ ;![;"I"@return [Boolean];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Returns true if emacs mode is active. Returns false if not. Raises NotImplementedError if the using readline library does not support. @overload emacs_editing_mode? @return [Boolean];T;#0;$@ ;.F;/o;0;1T;2i;3i;Bi;%@;9I"sstatic VALUE readline_s_emacs_editing_mode_p(VALUE self) { return rl_editing_mode == 1 ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*Readline.completion_append_character=;F;7[[I"str;T0;[[@i;T;:!completion_append_character=;0;[;{;IC; "Specifies a character to be appended on completion. Nothing will be appended if an empty string ("") or nil is specified. For example: require "readline" Readline.readline("> ", true) Readline.completion_append_character = " " Result: > Input "/var/li". > /var/li Press TAB key. > /var/lib Completes "b" and appends " ". So, you can continuously input "/usr". > /var/lib /usr NOTE: Only one character can be specified. When "string" is specified, sets only "s" that is the first. require "readline" Readline.completion_append_character = "string" p Readline.completion_append_character # => "s" Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"'completion_append_character=(char);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I" char;T0;$@ ;![;"I"Specifies a character to be appended on completion. Nothing will be appended if an empty string ("") or nil is specified. For example: require "readline" Readline.readline("> ", true) Readline.completion_append_character = " " Result: > Input "/var/li". > /var/li Press TAB key. > /var/lib Completes "b" and appends " ". So, you can continuously input "/usr". > /var/lib /usr NOTE: Only one character can be specified. When "string" is specified, sets only "s" that is the first. require "readline" Readline.completion_append_character = "string" p Readline.completion_append_character # => "s" Raises NotImplementedError if the using readline library does not support. @overload completion_append_character=(char);T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;9I"static VALUE readline_s_set_completion_append_character(VALUE self, VALUE str) { if (NIL_P(str)) { rl_completion_append_character = '\0'; } else { OutputStringValue(str); if (RSTRING_LEN(str) == 0) { rl_completion_append_character = '\0'; } else { rl_completion_append_character = RSTRING_PTR(str)[0]; } } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I")Readline.completion_append_character;F;7[;[[@i;T;: completion_append_character;0;[;{;IC; "Returns a string containing a character to be appended on completion. The default is a space (" "). Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" completion_append_character;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Returns a string containing a character to be appended on completion. The default is a space (" "). Raises NotImplementedError if the using readline library does not support. @overload completion_append_character @return [String];T;#0;$@ ;.F;/o;0;1T;2i;3i ;%@;9I"static VALUE readline_s_get_completion_append_character(VALUE self) { char buf[1]; if (rl_completion_append_character == '\0') return Qnil; buf[0] = (char) rl_completion_append_character; return rb_locale_str_new(buf, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(Readline.completion_quote_character;F;7[;[[@i+;T;:completion_quote_character;0;[;{;IC; "dWhen called during a completion (e.g. from within your completion_proc), it will return a string containing the character used to quote the argument being completed, or nil if the argument is unquoted. When called at other times, it will always return nil. Note that Readline.completer_quote_characters must be set, or this method will always return nil. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"completion_quote_character;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"When called during a completion (e.g. from within your completion_proc), it will return a string containing the character used to quote the argument being completed, or nil if the argument is unquoted. When called at other times, it will always return nil. Note that Readline.completer_quote_characters must be set, or this method will always return nil. @overload completion_quote_character @return [String];T;#0;$@ ;.F;/o;0;1T;2i;3i);%@;9I"static VALUE readline_s_get_completion_quote_character(VALUE self) { char buf[1]; if (rl_completion_quote_character == '\0') return Qnil; buf[0] = (char) rl_completion_quote_character; return rb_locale_str_new(buf, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*Readline.basic_word_break_characters=;F;7[[I"str;T0;[[@iE;T;:!basic_word_break_characters=;0;[;{;IC; " Sets the basic list of characters that signal a break between words for the completer routine. The default is the characters which break words for completion in Bash: " \t\n\"\\'`@$><=;|&{(". Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;;@0;:I")basic_word_break_characters=(string);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I" string;T0;$@ ;![;"I"<Sets the basic list of characters that signal a break between words for the completer routine. The default is the characters which break words for completion in Bash: " \t\n\"\\'`@$><=;|&{(". Raises NotImplementedError if the using readline library does not support. @overload basic_word_break_characters=(string);T;#0;$@ ;.F;/o;0;1T;2i;;3iB;%@;9I"tstatic VALUE readline_s_set_basic_word_break_characters(VALUE self, VALUE str) { static char *basic_word_break_characters = NULL; OutputStringValue(str); if (basic_word_break_characters == NULL) { basic_word_break_characters = ALLOC_N(char, RSTRING_LEN(str) + 1); } else { REALLOC_N(basic_word_break_characters, char, RSTRING_LEN(str) + 1); } strncpy(basic_word_break_characters, RSTRING_PTR(str), RSTRING_LEN(str)); basic_word_break_characters[RSTRING_LEN(str)] = '\0'; rl_basic_word_break_characters = basic_word_break_characters; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I")Readline.basic_word_break_characters;F;7[;[[@if;T;: basic_word_break_characters;0;[;{;IC; "Gets the basic list of characters that signal a break between words for the completer routine. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" basic_word_break_characters;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Gets the basic list of characters that signal a break between words for the completer routine. Raises NotImplementedError if the using readline library does not support. @overload basic_word_break_characters @return [String];T;#0;$@ ;.F;/o;0;1T;2i];3id;%@;9I"static VALUE readline_s_get_basic_word_break_characters(VALUE self) { if (rl_basic_word_break_characters == NULL) return Qnil; return rb_locale_str_new_cstr(rl_basic_word_break_characters); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I".Readline.completer_word_break_characters=;F;7[[I"str;T0;[[@i|;T;:%completer_word_break_characters=;0;[;{;IC; "Sets the basic list of characters that signal a break between words for rl_complete_internal(). The default is the value of Readline.basic_word_break_characters. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"-completer_word_break_characters=(string);T;IC; ";T;[;![;"I";T;#0;$@1 ;.F;Bi;C0;7[[I" string;T0;$@1 ;![;"I""Sets the basic list of characters that signal a break between words for rl_complete_internal(). The default is the value of Readline.basic_word_break_characters. Raises NotImplementedError if the using readline library does not support. @overload completer_word_break_characters=(string);T;#0;$@1 ;.F;/o;0;1T;2ir;3iy;%@;9I"static VALUE readline_s_set_completer_word_break_characters(VALUE self, VALUE str) { static char *completer_word_break_characters = NULL; OutputStringValue(str); if (completer_word_break_characters == NULL) { completer_word_break_characters = ALLOC_N(char, RSTRING_LEN(str) + 1); } else { REALLOC_N(completer_word_break_characters, char, RSTRING_LEN(str) + 1); } strncpy(completer_word_break_characters, RSTRING_PTR(str), RSTRING_LEN(str)); completer_word_break_characters[RSTRING_LEN(str)] = '\0'; rl_completer_word_break_characters = completer_word_break_characters; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"-Readline.completer_word_break_characters;F;7[;[[@i;T;:$completer_word_break_characters;0;[;{;IC; "Gets the basic list of characters that signal a break between words for rl_complete_internal(). Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"$completer_word_break_characters;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@K ;![;"I"@return [String];T;#0;$@K ;.F;Bi;C0;7[;$@K ;![;"I"Gets the basic list of characters that signal a break between words for rl_complete_internal(). Raises NotImplementedError if the using readline library does not support. @overload completer_word_break_characters @return [String];T;#0;$@K ;.F;/o;0;1T;2i;3i;%@;9I"static VALUE readline_s_get_completer_word_break_characters(VALUE self) { if (rl_completer_word_break_characters == NULL) return Qnil; return rb_locale_str_new_cstr(rl_completer_word_break_characters); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%Readline.basic_quote_characters=;F;7[[I"str;T0;[[@i;T;:basic_quote_characters=;0;[;{;IC; "Sets a list of quote characters which can cause a word break. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"$basic_quote_characters=(string);T;IC; ";T;[;![;"I";T;#0;$@f ;.F;Bi;C0;7[[I" string;T0;$@f ;![;"I"Sets a list of quote characters which can cause a word break. Raises NotImplementedError if the using readline library does not support. @overload basic_quote_characters=(string);T;#0;$@f ;.F;/o;0;1T;2i;3i;%@;9I"Hstatic VALUE readline_s_set_basic_quote_characters(VALUE self, VALUE str) { static char *basic_quote_characters = NULL; OutputStringValue(str); if (basic_quote_characters == NULL) { basic_quote_characters = ALLOC_N(char, RSTRING_LEN(str) + 1); } else { REALLOC_N(basic_quote_characters, char, RSTRING_LEN(str) + 1); } strncpy(basic_quote_characters, RSTRING_PTR(str), RSTRING_LEN(str)); basic_quote_characters[RSTRING_LEN(str)] = '\0'; rl_basic_quote_characters = basic_quote_characters; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$Readline.basic_quote_characters;F;7[;[[@i;T;:basic_quote_characters;0;[;{;IC; "Gets a list of quote characters which can cause a word break. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"basic_quote_characters;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Gets a list of quote characters which can cause a word break. Raises NotImplementedError if the using readline library does not support. @overload basic_quote_characters @return [String];T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;9I"static VALUE readline_s_get_basic_quote_characters(VALUE self) { if (rl_basic_quote_characters == NULL) return Qnil; return rb_locale_str_new_cstr(rl_basic_quote_characters); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I")Readline.completer_quote_characters=;F;7[[I"str;T0;[[@i';T;: completer_quote_characters=;0;[;{;IC; "TSets a list of characters which can be used to quote a substring of the line. Completion occurs on the entire substring, and within the substring Readline.completer_word_break_characters are treated as any other character, unless they also appear within this list. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"(completer_quote_characters=(string);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I" string;T0;$@ ;![;"I"Sets a list of characters which can be used to quote a substring of the line. Completion occurs on the entire substring, and within the substring Readline.completer_word_break_characters are treated as any other character, unless they also appear within this list. Raises NotImplementedError if the using readline library does not support. @overload completer_quote_characters=(string);T;#0;$@ ;.F;/o;0;1T;2i;3i$;%@;9I"`static VALUE readline_s_set_completer_quote_characters(VALUE self, VALUE str) { static char *completer_quote_characters = NULL; OutputStringValue(str); if (completer_quote_characters == NULL) { completer_quote_characters = ALLOC_N(char, RSTRING_LEN(str) + 1); } else { REALLOC_N(completer_quote_characters, char, RSTRING_LEN(str) + 1); } strncpy(completer_quote_characters, RSTRING_PTR(str), RSTRING_LEN(str)); completer_quote_characters[RSTRING_LEN(str)] = '\0'; rl_completer_quote_characters = completer_quote_characters; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(Readline.completer_quote_characters;F;7[;[[@iH;T;:completer_quote_characters;0;[;{;IC; "Gets a list of characters which can be used to quote a substring of the line. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"completer_quote_characters;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Gets a list of characters which can be used to quote a substring of the line. Raises NotImplementedError if the using readline library does not support. @overload completer_quote_characters @return [String];T;#0;$@ ;.F;/o;0;1T;2i?;3iF;%@;9I"static VALUE readline_s_get_completer_quote_characters(VALUE self) { if (rl_completer_quote_characters == NULL) return Qnil; return rb_locale_str_new_cstr(rl_completer_quote_characters); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(Readline.filename_quote_characters=;F;7[[I"str;T0;[[@i];T;:filename_quote_characters=;0;[;{;IC; "Sets a list of characters that cause a filename to be quoted by the completer when they appear in a completed filename. The default is nil. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"'filename_quote_characters=(string);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I" string;T0;$@ ;![;"I"Sets a list of characters that cause a filename to be quoted by the completer when they appear in a completed filename. The default is nil. Raises NotImplementedError if the using readline library does not support. @overload filename_quote_characters=(string);T;#0;$@ ;.F;/o;0;1T;2iT;3iZ;%@;9I"Wstatic VALUE readline_s_set_filename_quote_characters(VALUE self, VALUE str) { static char *filename_quote_characters = NULL; OutputStringValue(str); if (filename_quote_characters == NULL) { filename_quote_characters = ALLOC_N(char, RSTRING_LEN(str) + 1); } else { REALLOC_N(filename_quote_characters, char, RSTRING_LEN(str) + 1); } strncpy(filename_quote_characters, RSTRING_PTR(str), RSTRING_LEN(str)); filename_quote_characters[RSTRING_LEN(str)] = '\0'; rl_filename_quote_characters = filename_quote_characters; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'Readline.filename_quote_characters;F;7[;[[@i~;T;:filename_quote_characters;0;[;{;IC; "Gets a list of characters that cause a filename to be quoted by the completer when they appear in a completed filename. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"filename_quote_characters;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Gets a list of characters that cause a filename to be quoted by the completer when they appear in a completed filename. Raises NotImplementedError if the using readline library does not support. @overload filename_quote_characters @return [String];T;#0;$@ ;.F;/o;0;1T;2iu;3i|;%@;9I"static VALUE readline_s_get_filename_quote_characters(VALUE self) { if (rl_filename_quote_characters == NULL) return Qnil; return rb_locale_str_new_cstr(rl_filename_quote_characters); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Readline.refresh_line;F;7[;[[@i;T;:refresh_line;0;[;{;IC; ""Clear the current input line. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"refresh_line;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@ ;![;"I"@return [nil];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"KClear the current input line. @overload refresh_line @return [nil];T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;9I"}static VALUE readline_s_refresh_line(VALUE self) { prepare_readline(); rl_refresh_line(0, 0); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Readline.pre_input_hook=;F;7[[I" proc;T0;[[@iw;T;:pre_input_hook=;0;[;{;IC; "ISpecifies a Proc object +proc+ to call after the first prompt has been printed and just before readline starts reading input characters. See GNU Readline's rl_pre_input_hook variable. Raises ArgumentError if +proc+ does not respond to the call method. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"pre_input_hook=(proc);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I" proc;T0;$@ ;![;"I"kSpecifies a Proc object +proc+ to call after the first prompt has been printed and just before readline starts reading input characters. See GNU Readline's rl_pre_input_hook variable. Raises ArgumentError if +proc+ does not respond to the call method. Raises NotImplementedError if the using readline library does not support. @overload pre_input_hook=(proc);T;#0;$@ ;.F;/o;0;1T;2ii;3it;%@;9I"static VALUE readline_s_set_pre_input_hook(VALUE self, VALUE proc) { mustbe_callable(proc); return rb_ivar_set(mReadline, id_pre_input_hook, proc); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Readline.pre_input_hook;F;7[;[[@i;T;:pre_input_hook;0;[;{;IC; "Returns a Proc object +proc+ to call after the first prompt has been printed and just before readline starts reading input characters. The default is nil. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"pre_input_hook;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@: ;![;"I"@return [Proc];T;#0;$@: ;.F;Bi;C0;7[;$@: ;![;"I"Returns a Proc object +proc+ to call after the first prompt has been printed and just before readline starts reading input characters. The default is nil. Raises NotImplementedError if the using readline library does not support. @overload pre_input_hook @return [Proc];T;#0;$@: ;.F;/o;0;1T;2i~;3i;%@;9I"ustatic VALUE readline_s_get_pre_input_hook(VALUE self) { return rb_attr_get(mReadline, id_pre_input_hook); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Readline.insert_text;F;7[[I"str;T0;[[@i;T;:insert_text;0;[;{;IC; "Insert text into the line at the current cursor position. See GNU Readline's rl_insert_text function. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;!;@0;:I"insert_text(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@U ;![;"I"@return [self];T;#0;$@U ;.F;Bi;C0;7[[I" string;T0;$@U ;![;"I"Insert text into the line at the current cursor position. See GNU Readline's rl_insert_text function. Raises NotImplementedError if the using readline library does not support. @overload insert_text(string) @return [self];T;#0;$@U ;.F;/o;0;1T;2i;3i;%@;9I"static VALUE readline_s_insert_text(VALUE self, VALUE str) { OutputStringValue(str); rl_insert_text(RSTRING_PTR(str)); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Readline.delete_text;F;7[[@90;[[@i;T;:delete_text;0;[;{;IC; "Delete text between start and end in the current line. See GNU Readline's rl_delete_text function. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;";@0;:I"#delete_text([start[, length]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@t ;![;"I"@return [self];T;#0;$@t ;.F;Bi;C0;7[[I"[start[, length]];T0;$@t o;= ;>I" overload;F;?0;;";@0;:I"delete_text(start..end);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@t ;![;"I"@return [self];T;#0;$@t ;.F;Bi;C0;7[[I"start..end;T0;$@t o;= ;>I" overload;F;?0;;";@0;:I"delete_text();T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@t ;![;"I"@return [self];T;#0;$@t ;.F;Bi;C0;7[;$@t ;![;"I"GDelete text between start and end in the current line. See GNU Readline's rl_delete_text function. Raises NotImplementedError if the using readline library does not support. @overload delete_text([start[, length]]) @return [self] @overload delete_text(start..end) @return [self] @overload delete_text() @return [self];T;#0;$@t ;.F;/o;0;1T;2i;3i;%@;9I"static VALUE readline_s_delete_text(int argc, VALUE *argv, VALUE self) { rb_check_arity(argc, 0, 2); if (rl_line_buffer) { const char *p, *ptr = rl_line_buffer; long beg = 0, len = strlen(ptr); const char *end = ptr + len; rb_encoding *enc = rb_locale_encoding(); if (argc == 2) { beg = NUM2LONG(argv[0]); len = NUM2LONG(argv[1]); num_pos: p = str_subpos(ptr, end, beg, &len, enc); if (!p) rb_raise(rb_eArgError, "invalid index"); beg = p - ptr; } else if (argc == 1) { len = rb_enc_strlen(ptr, ptr + len, enc); if (!rb_range_beg_len(argv[0], &beg, &len, len, 1)) { beg = NUM2LONG(argv[0]); goto num_pos; } } rl_delete_text(rb_long2int(beg), rb_long2int(beg + len)); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Readline.redisplay;F;7[;[[@i;T;:redisplay;0;[;{;IC; "Change what's displayed on the screen to reflect the current contents. See GNU Readline's rl_redisplay function. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;#;@0;:I"redisplay;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@ ;![;"I"@return [self];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Change what's displayed on the screen to reflect the current contents. See GNU Readline's rl_redisplay function. Raises NotImplementedError if the using readline library does not support. @overload redisplay @return [self];T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;9I"[static VALUE readline_s_redisplay(VALUE self) { rl_redisplay(); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Readline.special_prefixes=;F;7[[I"str;T0;[[@i;T;:special_prefixes=;0;[;{;IC; "Sets the list of characters that are word break characters, but should be left in text when it is passed to the completion function. Programs can use this to help determine what kind of completing to do. For instance, Bash sets this variable to "$@" so that it can complete shell variables and hostnames. See GNU Readline's rl_special_prefixes variable. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;$;@0;:I"special_prefixes=(string);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I" string;T0;$@ ;![;"I"Sets the list of characters that are word break characters, but should be left in text when it is passed to the completion function. Programs can use this to help determine what kind of completing to do. For instance, Bash sets this variable to "$@" so that it can complete shell variables and hostnames. See GNU Readline's rl_special_prefixes variable. Raises NotImplementedError if the using readline library does not support. @overload special_prefixes=(string);T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;9I"static VALUE readline_s_set_special_prefixes(VALUE self, VALUE str) { if (!NIL_P(str)) { OutputStringValue(str); str = rb_str_dup_frozen(str); rb_obj_hide(str); } rb_ivar_set(mReadline, id_special_prefixes, str); if (NIL_P(str)) { rl_special_prefixes = NULL; } else { rl_special_prefixes = RSTRING_PTR(str); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Readline.special_prefixes;F;7[;[[@i;T;:special_prefixes;0;[;{;IC; "Gets the list of characters that are word break characters, but should be left in text when it is passed to the completion function. See GNU Readline's rl_special_prefixes variable. Raises NotImplementedError if the using readline library does not support. ;T;[o;= ;>I" overload;F;?0;;%;@0;:I"special_prefixes;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"2Gets the list of characters that are word break characters, but should be left in text when it is passed to the completion function. See GNU Readline's rl_special_prefixes variable. Raises NotImplementedError if the using readline library does not support. @overload special_prefixes @return [String];T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;9I"/static VALUE readline_s_get_special_prefixes(VALUE self) { VALUE str; if (rl_special_prefixes == NULL) return Qnil; str = rb_ivar_get(mReadline, id_special_prefixes); if (!NIL_P(str)) { str = rb_str_dup_frozen(str); rb_obj_reveal(str, rb_cString); } return str; };T;:I"static VALUE;T;;To;u;[[@i;F;: HISTORY;;w;;;[;{;IC; "The history buffer. It extends Enumerable module, so it behaves just like an array. For example, gets the fifth content that the user input by HISTORY[4]. ;T;[;![;"I"The history buffer. It extends Enumerable module, so it behaves just like an array. For example, gets the fifth content that the user input by HISTORY[4]. ;T;#0;$@ ;.F;/o;0;1T;2i ;3i;%@;&I"Readline::HISTORY;F;xI" history;To;u;[[@i;F;:FILENAME_COMPLETION_PROC;;w;;;[;{;IC; "yThe Object with the call method that is a completion for filename. This is sets by Readline.completion_proc= method. ;T;[;![;"I"zThe Object with the call method that is a completion for filename. This is sets by Readline.completion_proc= method. ;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;&I"'Readline::FILENAME_COMPLETION_PROC;F;xI" fcomp;To;u;[[@i%;F;:USERNAME_COMPLETION_PROC;;w;;;[;{;IC; "zThe Object with the call method that is a completion for usernames. This is sets by Readline.completion_proc= method. ;T;[;![;"I"{The Object with the call method that is a completion for usernames. This is sets by Readline.completion_proc= method. ;T;#0;$@ ;.F;/o;0;1T;2i!;3i#;%@;&I"'Readline::USERNAME_COMPLETION_PROC;F;xI" ucomp;To;u;[[@iH;F;;;;w;;;[;{;IC; "/Version string of GNU Readline or libedit. ;T;[;![;"I"/Version string of GNU Readline or libedit.;T;#0;$@" ;.F;/o;0;1T;2iG;3iG;%@;&I"Readline::VERSION;F;xI" version;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i;F;: Readline;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I" Readline;Fo;u;[[@i ;F;: ARGV;;w;;;[;{;IC; "ARGV contains the command line arguments used to run ruby. A library like OptionParser can be used to process command-line arguments. ;T;[;![;"I"ARGV contains the command line arguments used to run ruby. A library like OptionParser can be used to process command-line arguments. ;T;#0;$@= ;.F;/o;0;1T;2i ;3i ;%@;&I" ARGV;F;xI" rb_argv;To;;IC;[.o;u;[[@diO;F;;;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@K ;%@I ;&I"Etc::VERSION;F;xI"&rb_str_new_cstr(RUBY_ETC_VERSION);To;4;5F;6;;;;&I"Etc#getlogin;F;7[;[[@dif;T;: getlogin;0;[;{;IC; "Ggetlogin -> String Returns the short user name of the currently logged in user. Unfortunately, it is often rather easy to fool ::getlogin. Avoid ::getlogin for security-related purposes. If ::getlogin fails, try ::getpwuid. See the unix manpage for getpwuid(3) for more detail. e.g. Etc.getlogin -> 'guest' ;T;[;![;"I"Ggetlogin -> String Returns the short user name of the currently logged in user. Unfortunately, it is often rather easy to fool ::getlogin. Avoid ::getlogin for security-related purposes. If ::getlogin fails, try ::getpwuid. See the unix manpage for getpwuid(3) for more detail. e.g. Etc.getlogin -> 'guest';T;#0;$@U ;.F;C0;%@I ;9I"static VALUE etc_getlogin(VALUE obj) { char *login; #ifdef HAVE_GETLOGIN login = getlogin(); if (!login) login = getenv("USER"); #else login = getenv("USER"); #endif if (login) { #ifdef _WIN32 rb_encoding *extenc = rb_utf8_encoding(); #else rb_encoding *extenc = rb_locale_encoding(); #endif return rb_external_str_new_with_enc(login, strlen(login), extenc); } return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Etc.getlogin;F;7@W ;@X ;T;;+;0;@Z ;{;IC; "Ggetlogin -> String Returns the short user name of the currently logged in user. Unfortunately, it is often rather easy to fool ::getlogin. Avoid ::getlogin for security-related purposes. If ::getlogin fails, try ::getpwuid. See the unix manpage for getpwuid(3) for more detail. e.g. Etc.getlogin -> 'guest';T;[;![;"I"Igetlogin -> String Returns the short user name of the currently logged in user. Unfortunately, it is often rather easy to fool ::getlogin. Avoid ::getlogin for security-related purposes. If ::getlogin fails, try ::getpwuid. See the unix manpage for getpwuid(3) for more detail. e.g. Etc.getlogin -> 'guest' ;T;#0;$@b ;.F;/o;0;1T;2iW;3ie;Bi;%@I ;9@` ;:@a ;;To;4;5F;6;;;;&I"Etc#getpwuid;F;7[[@90;[[@di;T;: getpwuid;0;[;{;IC; "getpwuid(uid) -> Passwd Returns the /etc/passwd information for the user with the given integer +uid+. The information is returned as a Passwd struct. If +uid+ is omitted, the value from Passwd[:uid] is returned instead. See the unix manpage for getpwuid(3) for more detail. === Example: Etc.getpwuid(0) #=> # ;T;[;![;"I"getpwuid(uid) -> Passwd Returns the /etc/passwd information for the user with the given integer +uid+. The information is returned as a Passwd struct. If +uid+ is omitted, the value from Passwd[:uid] is returned instead. See the unix manpage for getpwuid(3) for more detail. === Example: Etc.getpwuid(0) #=> #;T;#0;$@j ;.F;C0;%@I ;9I"static VALUE etc_getpwuid(int argc, VALUE *argv, VALUE obj) { #if defined(HAVE_GETPWENT) VALUE id; rb_uid_t uid; struct passwd *pwd; if (rb_scan_args(argc, argv, "01", &id) == 1) { uid = NUM2UIDT(id); } else { uid = getuid(); } pwd = getpwuid(uid); if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %d", (int)uid); return setup_passwd(pwd); #else return Qnil; #endif };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Etc.getpwuid;F;7@l ;@n ;T;;,;0;@p ;{;IC; "getpwuid(uid) -> Passwd Returns the /etc/passwd information for the user with the given integer +uid+. The information is returned as a Passwd struct. If +uid+ is omitted, the value from Passwd[:uid] is returned instead. See the unix manpage for getpwuid(3) for more detail. === Example: Etc.getpwuid(0) #=> #;T;[;![;"I"getpwuid(uid) -> Passwd Returns the /etc/passwd information for the user with the given integer +uid+. The information is returned as a Passwd struct. If +uid+ is omitted, the value from Passwd[:uid] is returned instead. See the unix manpage for getpwuid(3) for more detail. === Example: Etc.getpwuid(0) #=> # ;T;#0;$@x ;.F;/o;0;1T;2i;3i;Bi;%@I ;9@v ;:@w ;;To;4;5F;6;;;;&I"Etc#getpwnam;F;7[[I"nam;T0;[[@di;T;: getpwnam;0;[;{;IC; "ngetpwnam(name) -> Passwd Returns the /etc/passwd information for the user with specified login +name+. The information is returned as a Passwd struct. See the unix manpage for getpwnam(3) for more detail. === Example: Etc.getpwnam('root') #=> # ;T;[;![;"I"ngetpwnam(name) -> Passwd Returns the /etc/passwd information for the user with specified login +name+. The information is returned as a Passwd struct. See the unix manpage for getpwnam(3) for more detail. === Example: Etc.getpwnam('root') #=> #;T;#0;$@ ;.F;C0;%@I ;9I"/static VALUE etc_getpwnam(VALUE obj, VALUE nam) { #ifdef HAVE_GETPWENT struct passwd *pwd; const char *p = StringValueCStr(nam); pwd = getpwnam(p); if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %"PRIsVALUE, nam); return setup_passwd(pwd); #else return Qnil; #endif };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Etc.getpwnam;F;7@ ;@ ;T;;-;0;@ ;{;IC; "ngetpwnam(name) -> Passwd Returns the /etc/passwd information for the user with specified login +name+. The information is returned as a Passwd struct. See the unix manpage for getpwnam(3) for more detail. === Example: Etc.getpwnam('root') #=> #;T;[;![;"I"pgetpwnam(name) -> Passwd Returns the /etc/passwd information for the user with specified login +name+. The information is returned as a Passwd struct. See the unix manpage for getpwnam(3) for more detail. === Example: Etc.getpwnam('root') #=> # ;T;#0;$@ ;.F;/o;0;1T;2i;3i;Bi;%@I ;9@ ;:@ ;;To;4;5F;6;;;;&I"Etc#setpwent;F;7[;[[@din;T;: setpwent;0;[;{;IC; "Resets the process of reading the /etc/passwd file, so that the next call to ::getpwent will return the first entry again. ;T;[;![;"I"Resets the process of reading the /etc/passwd file, so that the next call to ::getpwent will return the first entry again.;T;#0;$@ ;.F;C0;%@I ;9I"jstatic VALUE etc_setpwent(VALUE obj) { #ifdef HAVE_GETPWENT setpwent(); #endif return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Etc.setpwent;F;7@ ;@ ;T;;.;0;@ ;{;IC; "Resets the process of reading the /etc/passwd file, so that the next call to ::getpwent will return the first entry again.;T;[;![;"I"{Resets the process of reading the /etc/passwd file, so that the next call to ::getpwent will return the first entry again. ;T;#0;$@ ;.F;/o;0;1T;2ik;3im;Bi;%@I ;9@ ;:@ ;;To;4;5F;6;;;;&I"Etc#endpwent;F;7[;[[@diz;T;: endpwent;0;[;{;IC; "jEnds the process of scanning through the /etc/passwd file begun with ::getpwent, and closes the file. ;T;[;![;"I"jEnds the process of scanning through the /etc/passwd file begun with ::getpwent, and closes the file.;T;#0;$@ ;.F;C0;%@I ;9I"jstatic VALUE etc_endpwent(VALUE obj) { #ifdef HAVE_GETPWENT endpwent(); #endif return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Etc.endpwent;F;7@ ;@ ;T;;/;0;@ ;{;IC; "jEnds the process of scanning through the /etc/passwd file begun with ::getpwent, and closes the file.;T;[;![;"I"kEnds the process of scanning through the /etc/passwd file begun with ::getpwent, and closes the file. ;T;#0;$@ ;.F;/o;0;1T;2iw;3iy;Bi;%@I ;9@ ;:@ ;;To;4;5F;6;;;;&I"Etc#getpwent;F;7[;[[@di;T;: getpwent;0;[;{;IC; "CReturns an entry from the /etc/passwd file. The first time it is called it opens the file and returns the first entry; each successive call returns the next entry, or +nil+ if the end of the file has been reached. To close the file when processing is complete, call ::endpwent. Each entry is returned as a Passwd struct. ;T;[;![;"I"CReturns an entry from the /etc/passwd file. The first time it is called it opens the file and returns the first entry; each successive call returns the next entry, or +nil+ if the end of the file has been reached. To close the file when processing is complete, call ::endpwent. Each entry is returned as a Passwd struct.;T;#0;$@ ;.F;C0;%@I ;9I"static VALUE etc_getpwent(VALUE obj) { #ifdef HAVE_GETPWENT struct passwd *pw; if ((pw = getpwent()) != 0) { return setup_passwd(pw); } #endif return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Etc.getpwent;F;7@ ;@ ;T;;0;0;@ ;{;IC; "CReturns an entry from the /etc/passwd file. The first time it is called it opens the file and returns the first entry; each successive call returns the next entry, or +nil+ if the end of the file has been reached. To close the file when processing is complete, call ::endpwent. Each entry is returned as a Passwd struct.;T;[;![;"I"EReturns an entry from the /etc/passwd file. The first time it is called it opens the file and returns the first entry; each successive call returns the next entry, or +nil+ if the end of the file has been reached. To close the file when processing is complete, call ::endpwent. Each entry is returned as a Passwd struct. ;T;#0;$@ ;.F;/o;0;1T;2i;3i;Bi;%@I ;9@ ;:@ ;;To;4;5F;6;;;;&I"Etc#passwd;F;7[;[[@di9;T;: passwd;0;[;{;IC; "OEtc.passwd { |struct| block } -> Passwd Etc.passwd -> Passwd Provides a convenient Ruby iterator which executes a block for each entry in the /etc/passwd file. The code block is passed an Passwd struct. See ::getpwent above for details. Example: require 'etc' Etc.passwd {|u| puts u.name + " = " + u.gecos } ;T;[;![;"I"OEtc.passwd { |struct| block } -> Passwd Etc.passwd -> Passwd Provides a convenient Ruby iterator which executes a block for each entry in the /etc/passwd file. The code block is passed an Passwd struct. See ::getpwent above for details. Example: require 'etc' Etc.passwd {|u| puts u.name + " = " + u.gecos };T;#0;$@ ;.F;C0;%@I ;9I"static VALUE etc_passwd(VALUE obj) { #ifdef HAVE_GETPWENT struct passwd *pw; if (rb_block_given_p()) { each_passwd(); } else if ((pw = getpwent()) != 0) { return setup_passwd(pw); } #endif return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Etc.passwd;F;7@ ;@ ;T;;1;0;@ ;{;IC; "OEtc.passwd { |struct| block } -> Passwd Etc.passwd -> Passwd Provides a convenient Ruby iterator which executes a block for each entry in the /etc/passwd file. The code block is passed an Passwd struct. See ::getpwent above for details. Example: require 'etc' Etc.passwd {|u| puts u.name + " = " + u.gecos };T;[;![;"I"REtc.passwd { |struct| block } -> Passwd Etc.passwd -> Passwd Provides a convenient Ruby iterator which executes a block for each entry in the /etc/passwd file. The code block is passed an Passwd struct. See ::getpwent above for details. Example: require 'etc' Etc.passwd {|u| puts u.name + " = " + u.gecos } ;T;#0;$@ ;.F;/o;0;1T;2i%;3i8;Bi;%@I ;9@ ;:@ ;;To;4;5F;6;;;;&I"Etc#getgrgid;F;7[[@90;[[@di;T;: getgrgid;0;[;{;IC; "bgetgrgid(group_id) -> Group Returns information about the group with specified integer +group_id+, as found in /etc/group. The information is returned as a Group struct. See the unix manpage for getgrgid(3) for more detail. === Example: Etc.getgrgid(100) #=> # ;T;[;![;"I"bgetgrgid(group_id) -> Group Returns information about the group with specified integer +group_id+, as found in /etc/group. The information is returned as a Group struct. See the unix manpage for getgrgid(3) for more detail. === Example: Etc.getgrgid(100) #=> #;T;#0;$@ ;.F;C0;%@I ;9I"static VALUE etc_getgrgid(int argc, VALUE *argv, VALUE obj) { #ifdef HAVE_GETGRENT VALUE id; gid_t gid; struct group *grp; if (rb_scan_args(argc, argv, "01", &id) == 1) { gid = NUM2GIDT(id); } else { gid = getgid(); } grp = getgrgid(gid); if (grp == 0) rb_raise(rb_eArgError, "can't find group for %d", (int)gid); return setup_group(grp); #else return Qnil; #endif };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Etc.getgrgid;F;7@ ;@ ;T;;2;0;@ ;{;IC; "bgetgrgid(group_id) -> Group Returns information about the group with specified integer +group_id+, as found in /etc/group. The information is returned as a Group struct. See the unix manpage for getgrgid(3) for more detail. === Example: Etc.getgrgid(100) #=> #;T;[;![;"I"egetgrgid(group_id) -> Group Returns information about the group with specified integer +group_id+, as found in /etc/group. The information is returned as a Group struct. See the unix manpage for getgrgid(3) for more detail. === Example: Etc.getgrgid(100) #=> # ;T;#0;$@ ;.F;/o;0;1T;2i;3i;Bi;%@I ;9@ ;:@ ;;To;4;5F;6;;;;&I"Etc#getgrnam;F;7[[I"nam;T0;[[@di;T;: getgrnam;0;[;{;IC; "Vgetgrnam(name) -> Group Returns information about the group with specified +name+, as found in /etc/group. The information is returned as a Group struct. See the unix manpage for getgrnam(3) for more detail. === Example: Etc.getgrnam('users') #=> # ;T;[;![;"I"Vgetgrnam(name) -> Group Returns information about the group with specified +name+, as found in /etc/group. The information is returned as a Group struct. See the unix manpage for getgrnam(3) for more detail. === Example: Etc.getgrnam('users') #=> #;T;#0;$@;.F;C0;%@I ;9I".static VALUE etc_getgrnam(VALUE obj, VALUE nam) { #ifdef HAVE_GETGRENT struct group *grp; const char *p = StringValueCStr(nam); grp = getgrnam(p); if (grp == 0) rb_raise(rb_eArgError, "can't find group for %"PRIsVALUE, nam); return setup_group(grp); #else return Qnil; #endif };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Etc.getgrnam;F;7@;@;T;;3;0;@;{;IC; "Vgetgrnam(name) -> Group Returns information about the group with specified +name+, as found in /etc/group. The information is returned as a Group struct. See the unix manpage for getgrnam(3) for more detail. === Example: Etc.getgrnam('users') #=> #;T;[;![;"I"Ygetgrnam(name) -> Group Returns information about the group with specified +name+, as found in /etc/group. The information is returned as a Group struct. See the unix manpage for getgrnam(3) for more detail. === Example: Etc.getgrnam('users') #=> # ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@I ;9@;:@;;To;4;5F;6;;;;&I"Etc#group;F;7[;[[@di*;T;;E;0;[;{;IC; "Provides a convenient Ruby iterator which executes a block for each entry in the /etc/group file. The code block is passed an Group struct. See ::getgrent above for details. Example: require 'etc' Etc.group {|g| puts g.name + ": " + g.mem.join(', ') } ;T;[;![;"I"Provides a convenient Ruby iterator which executes a block for each entry in the /etc/group file. The code block is passed an Group struct. See ::getgrent above for details. Example: require 'etc' Etc.group {|g| puts g.name + ": " + g.mem.join(', ') };T;#0;$@;.F;C0;%@I ;9I"static VALUE etc_group(VALUE obj) { #ifdef HAVE_GETGRENT struct group *grp; if (rb_block_given_p()) { each_group(); } else if ((grp = getgrent()) != 0) { return setup_group(grp); } #endif return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Etc.group;F;7@;@;T;;E;0;@;{;IC; "Provides a convenient Ruby iterator which executes a block for each entry in the /etc/group file. The code block is passed an Group struct. See ::getgrent above for details. Example: require 'etc' Etc.group {|g| puts g.name + ": " + g.mem.join(', ') };T;[;![;"I"Provides a convenient Ruby iterator which executes a block for each entry in the /etc/group file. The code block is passed an Group struct. See ::getgrent above for details. Example: require 'etc' Etc.group {|g| puts g.name + ": " + g.mem.join(', ') } ;T;#0;$@%;.F;/o;0;1T;2i;3i);Bi;%@I ;9@#;:@$;;To;4;5F;6;;;;&I"Etc#setgrent;F;7[;[[@di];T;: setgrent;0;[;{;IC; "~Resets the process of reading the /etc/group file, so that the next call to ::getgrent will return the first entry again. ;T;[;![;"I"~Resets the process of reading the /etc/group file, so that the next call to ::getgrent will return the first entry again.;T;#0;$@-;.F;C0;%@I ;9I"jstatic VALUE etc_setgrent(VALUE obj) { #ifdef HAVE_GETGRENT setgrent(); #endif return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Etc.setgrent;F;7@/;@0;T;;4;0;@2;{;IC; "~Resets the process of reading the /etc/group file, so that the next call to ::getgrent will return the first entry again.;T;[;![;"I"Resets the process of reading the /etc/group file, so that the next call to ::getgrent will return the first entry again. ;T;#0;$@:;.F;/o;0;1T;2iZ;3i\;Bi;%@I ;9@8;:@9;;To;4;5F;6;;;;&I"Etc#endgrent;F;7[;[[@dii;T;: endgrent;0;[;{;IC; "gEnds the process of scanning through the /etc/group file begun by ::getgrent, and closes the file. ;T;[;![;"I"gEnds the process of scanning through the /etc/group file begun by ::getgrent, and closes the file.;T;#0;$@B;.F;C0;%@I ;9I"jstatic VALUE etc_endgrent(VALUE obj) { #ifdef HAVE_GETGRENT endgrent(); #endif return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Etc.endgrent;F;7@D;@E;T;;5;0;@G;{;IC; "gEnds the process of scanning through the /etc/group file begun by ::getgrent, and closes the file.;T;[;![;"I"hEnds the process of scanning through the /etc/group file begun by ::getgrent, and closes the file. ;T;#0;$@O;.F;/o;0;1T;2if;3ih;Bi;%@I ;9@M;:@N;;To;4;5F;6;;;;&I"Etc#getgrent;F;7[;[[@di|;T;: getgrent;0;[;{;IC; "@Returns an entry from the /etc/group file. The first time it is called it opens the file and returns the first entry; each successive call returns the next entry, or +nil+ if the end of the file has been reached. To close the file when processing is complete, call ::endgrent. Each entry is returned as a Group struct ;T;[;![;"I"@Returns an entry from the /etc/group file. The first time it is called it opens the file and returns the first entry; each successive call returns the next entry, or +nil+ if the end of the file has been reached. To close the file when processing is complete, call ::endgrent. Each entry is returned as a Group struct;T;#0;$@W;.F;C0;%@I ;9I"static VALUE etc_getgrent(VALUE obj) { #ifdef HAVE_GETGRENT struct group *gr; if ((gr = getgrent()) != 0) { return setup_group(gr); } #endif return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Etc.getgrent;F;7@Y;@Z;T;;6;0;@\;{;IC; "@Returns an entry from the /etc/group file. The first time it is called it opens the file and returns the first entry; each successive call returns the next entry, or +nil+ if the end of the file has been reached. To close the file when processing is complete, call ::endgrent. Each entry is returned as a Group struct;T;[;![;"I"AReturns an entry from the /etc/group file. The first time it is called it opens the file and returns the first entry; each successive call returns the next entry, or +nil+ if the end of the file has been reached. To close the file when processing is complete, call ::endgrent. Each entry is returned as a Group struct ;T;#0;$@d;.F;/o;0;1T;2ir;3i{;Bi;%@I ;9@b;:@c;;To;4;5F;6;;;;&I"Etc#sysconfdir;F;7[;[[@di;T;:sysconfdir;0;[;{;IC; "8Returns system configuration directory. This is typically "/etc", but is modified by the prefix used when Ruby was compiled. For example, if Ruby is built and installed in /usr/local, returns "/usr/local/etc" on other platforms than Windows. On Windows, this always returns the directory provided by the system. ;T;[;![;"I"8Returns system configuration directory. This is typically "/etc", but is modified by the prefix used when Ruby was compiled. For example, if Ruby is built and installed in /usr/local, returns "/usr/local/etc" on other platforms than Windows. On Windows, this always returns the directory provided by the system.;T;#0;$@l;.F;C0;%@I ;9I"static VALUE etc_sysconfdir(VALUE obj) { #ifdef _WIN32 return rb_w32_special_folder(CSIDL_COMMON_APPDATA); #else return rb_filesystem_str_new_cstr(SYSCONFDIR); #endif };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Etc.sysconfdir;F;7@n;@o;T;;7;0;@q;{;IC; "8Returns system configuration directory. This is typically "/etc", but is modified by the prefix used when Ruby was compiled. For example, if Ruby is built and installed in /usr/local, returns "/usr/local/etc" on other platforms than Windows. On Windows, this always returns the directory provided by the system.;T;[;![;"I"9Returns system configuration directory. This is typically "/etc", but is modified by the prefix used when Ruby was compiled. For example, if Ruby is built and installed in /usr/local, returns "/usr/local/etc" on other platforms than Windows. On Windows, this always returns the directory provided by the system. ;T;#0;$@y;.F;/o;0;1T;2i;3i;Bi;%@I ;9@w;:@x;;To;4;5F;6;;;;&I"Etc#systmpdir;F;7[;[[@di;T;:systmpdir;0;[;{;IC; ":Returns system temporary directory; typically "/tmp". ;T;[;![;"I":Returns system temporary directory; typically "/tmp".;T;#0;$@;.F;C0;%@I ;9I"static VALUE etc_systmpdir(VALUE _) { VALUE tmpdir; #ifdef _WIN32 WCHAR path[_MAX_PATH]; UINT len = rb_w32_system_tmpdir(path, numberof(path)); if (!len) return Qnil; tmpdir = rb_w32_conv_from_wchar(path, rb_filesystem_encoding()); #else const char default_tmp[] = "/tmp"; const char *tmpstr = default_tmp; size_t tmplen = strlen(default_tmp); # if defined _CS_DARWIN_USER_TEMP_DIR #ifndef MAXPATHLEN #define MAXPATHLEN 1024 #endif char path[MAXPATHLEN]; size_t len; len = confstr(_CS_DARWIN_USER_TEMP_DIR, path, sizeof(path)); if (len > 0) { tmpstr = path; tmplen = len - 1; if (len > sizeof(path)) tmpstr = 0; } # endif tmpdir = rb_filesystem_str_new(tmpstr, tmplen); # if defined _CS_DARWIN_USER_TEMP_DIR if (!tmpstr) { confstr(_CS_DARWIN_USER_TEMP_DIR, RSTRING_PTR(tmpdir), len); } # endif #endif #ifndef RB_PASS_KEYWORDS /* untaint on Ruby < 2.7 */ FL_UNSET(tmpdir, FL_TAINT); #endif return tmpdir; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Etc.systmpdir;F;7@;@;T;;8;0;@;{;IC; ":Returns system temporary directory; typically "/tmp".;T;[;![;"I";Returns system temporary directory; typically "/tmp". ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@I ;9@;:@;;To;4;5F;6;;;;&I"Etc#uname;F;7[;[[@di;T;: uname;0;[;{;IC; "Returns the system information obtained by uname system call. The return value is a hash which has 5 keys at least: :sysname, :nodename, :release, :version, :machine Example: require 'etc' require 'pp' pp Etc.uname #=> {:sysname=>"Linux", # :nodename=>"boron", # :release=>"2.6.18-6-xen-686", # :version=>"#1 SMP Thu Nov 5 19:54:42 UTC 2009", # :machine=>"i686"} ;T;[;![;"I"Returns the system information obtained by uname system call. The return value is a hash which has 5 keys at least: :sysname, :nodename, :release, :version, :machine Example: require 'etc' require 'pp' pp Etc.uname #=> {:sysname=>"Linux", # :nodename=>"boron", # :release=>"2.6.18-6-xen-686", # :version=>"#1 SMP Thu Nov 5 19:54:42 UTC 2009", # :machine=>"i686"};T;#0;$@;.F;C0;%@I ;9I" static VALUE etc_uname(VALUE obj) { #ifdef _WIN32 OSVERSIONINFOW v; SYSTEM_INFO s; const char *sysname, *mach; VALUE result, release, version; VALUE vbuf, nodename = Qnil; DWORD len = 0; WCHAR *buf; v.dwOSVersionInfoSize = sizeof(v); if (!GetVersionExW(&v)) rb_sys_fail("GetVersionEx"); result = rb_hash_new(); switch (v.dwPlatformId) { case VER_PLATFORM_WIN32s: sysname = "Win32s"; break; case VER_PLATFORM_WIN32_NT: sysname = "Windows_NT"; break; case VER_PLATFORM_WIN32_WINDOWS: default: sysname = "Windows"; break; } rb_hash_aset(result, ID2SYM(rb_intern("sysname")), rb_str_new_cstr(sysname)); release = rb_sprintf("%lu.%lu.%lu", v.dwMajorVersion, v.dwMinorVersion, v.dwBuildNumber); rb_hash_aset(result, ID2SYM(rb_intern("release")), release); version = rb_sprintf("%s Version %"PRIsVALUE": %"PRIsVALUE, sysname, release, rb_w32_conv_from_wchar(v.szCSDVersion, rb_utf8_encoding())); rb_hash_aset(result, ID2SYM(rb_intern("version")), version); # if defined _MSC_VER && _MSC_VER < 1300 # define GET_COMPUTER_NAME(ptr, plen) GetComputerNameW(ptr, plen) # else # define GET_COMPUTER_NAME(ptr, plen) GetComputerNameExW(ComputerNameDnsFullyQualified, ptr, plen) # endif GET_COMPUTER_NAME(NULL, &len); buf = ALLOCV_N(WCHAR, vbuf, len); if (GET_COMPUTER_NAME(buf, &len)) { nodename = rb_w32_conv_from_wchar(buf, rb_utf8_encoding()); } ALLOCV_END(vbuf); if (NIL_P(nodename)) nodename = rb_str_new(0, 0); rb_hash_aset(result, ID2SYM(rb_intern("nodename")), nodename); # ifndef PROCESSOR_ARCHITECTURE_AMD64 # define PROCESSOR_ARCHITECTURE_AMD64 9 # endif # ifndef PROCESSOR_ARCHITECTURE_INTEL # define PROCESSOR_ARCHITECTURE_INTEL 0 # endif GetSystemInfo(&s); switch (s.wProcessorArchitecture) { case PROCESSOR_ARCHITECTURE_AMD64: mach = "x64"; break; case PROCESSOR_ARCHITECTURE_ARM: mach = "ARM"; break; case PROCESSOR_ARCHITECTURE_INTEL: mach = "x86"; break; default: mach = "unknown"; break; } rb_hash_aset(result, ID2SYM(rb_intern("machine")), rb_str_new_cstr(mach)); #else struct utsname u; int ret; VALUE result; ret = uname(&u); if (ret == -1) rb_sys_fail("uname"); result = rb_hash_new(); rb_hash_aset(result, ID2SYM(rb_intern("sysname")), rb_str_new_cstr(u.sysname)); rb_hash_aset(result, ID2SYM(rb_intern("nodename")), rb_str_new_cstr(u.nodename)); rb_hash_aset(result, ID2SYM(rb_intern("release")), rb_str_new_cstr(u.release)); rb_hash_aset(result, ID2SYM(rb_intern("version")), rb_str_new_cstr(u.version)); rb_hash_aset(result, ID2SYM(rb_intern("machine")), rb_str_new_cstr(u.machine)); #endif return result; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Etc.uname;F;7@;@;T;;9;0;@;{;IC; "Returns the system information obtained by uname system call. The return value is a hash which has 5 keys at least: :sysname, :nodename, :release, :version, :machine Example: require 'etc' require 'pp' pp Etc.uname #=> {:sysname=>"Linux", # :nodename=>"boron", # :release=>"2.6.18-6-xen-686", # :version=>"#1 SMP Thu Nov 5 19:54:42 UTC 2009", # :machine=>"i686"};T;[;![;"I"Returns the system information obtained by uname system call. The return value is a hash which has 5 keys at least: :sysname, :nodename, :release, :version, :machine Example: require 'etc' require 'pp' pp Etc.uname #=> {:sysname=>"Linux", # :nodename=>"boron", # :release=>"2.6.18-6-xen-686", # :version=>"#1 SMP Thu Nov 5 19:54:42 UTC 2009", # :machine=>"i686"} ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@I ;9@;:@;;To;4;5F;6;;;;&I"Etc#sysconf;F;7[[I"arg;T0;[[@diO;T;: sysconf;0;[;{;IC; "ZReturns system configuration variable using sysconf(). _name_ should be a constant under Etc which begins with SC_. The return value is an integer or nil. nil means indefinite limit. (sysconf() returns -1 but errno is not set.) Etc.sysconf(Etc::SC_ARG_MAX) #=> 2097152 Etc.sysconf(Etc::SC_LOGIN_NAME_MAX) #=> 256 ;T;[;![;"I"ZReturns system configuration variable using sysconf(). _name_ should be a constant under Etc which begins with SC_. The return value is an integer or nil. nil means indefinite limit. (sysconf() returns -1 but errno is not set.) Etc.sysconf(Etc::SC_ARG_MAX) #=> 2097152 Etc.sysconf(Etc::SC_LOGIN_NAME_MAX) #=> 256;T;#0;$@;.F;C0;%@I ;9I"&static VALUE etc_sysconf(VALUE obj, VALUE arg) { int name; long ret; name = NUM2INT(arg); errno = 0; ret = sysconf(name); if (ret == -1) { if (errno == 0) /* no limit */ return Qnil; rb_sys_fail("sysconf"); } return LONG2NUM(ret); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Etc.sysconf;F;7@;@;T;;:;0;@;{;IC; "ZReturns system configuration variable using sysconf(). _name_ should be a constant under Etc which begins with SC_. The return value is an integer or nil. nil means indefinite limit. (sysconf() returns -1 but errno is not set.) Etc.sysconf(Etc::SC_ARG_MAX) #=> 2097152 Etc.sysconf(Etc::SC_LOGIN_NAME_MAX) #=> 256;T;[;![;"I"\Returns system configuration variable using sysconf(). _name_ should be a constant under Etc which begins with SC_. The return value is an integer or nil. nil means indefinite limit. (sysconf() returns -1 but errno is not set.) Etc.sysconf(Etc::SC_ARG_MAX) #=> 2097152 Etc.sysconf(Etc::SC_LOGIN_NAME_MAX) #=> 256 ;T;#0;$@;.F;/o;0;1T;2iC;3iM;Bi;%@I ;9@;:@;;To;4;5F;6;;;;&I"Etc#confstr;F;7[[I"arg;T0;[[@dit;T;: confstr;0;[;{;IC; "Returns system configuration variable using confstr(). _name_ should be a constant under Etc which begins with CS_. The return value is a string or nil. nil means no configuration-defined value. (confstr() returns 0 but errno is not set.) Etc.confstr(Etc::CS_PATH) #=> "/bin:/usr/bin" # GNU/Linux Etc.confstr(Etc::CS_GNU_LIBC_VERSION) #=> "glibc 2.18" Etc.confstr(Etc::CS_GNU_LIBPTHREAD_VERSION) #=> "NPTL 2.18" ;T;[;![;"I"Returns system configuration variable using confstr(). _name_ should be a constant under Etc which begins with CS_. The return value is a string or nil. nil means no configuration-defined value. (confstr() returns 0 but errno is not set.) Etc.confstr(Etc::CS_PATH) #=> "/bin:/usr/bin" # GNU/Linux Etc.confstr(Etc::CS_GNU_LIBC_VERSION) #=> "glibc 2.18" Etc.confstr(Etc::CS_GNU_LIBPTHREAD_VERSION) #=> "NPTL 2.18";T;#0;$@;.F;C0;%@I ;9I"static VALUE etc_confstr(VALUE obj, VALUE arg) { int name; char localbuf[128], *buf = localbuf; size_t bufsize = sizeof(localbuf), ret; VALUE tmp; name = NUM2INT(arg); errno = 0; ret = confstr(name, buf, bufsize); if (bufsize < ret) { bufsize = ret; buf = ALLOCV_N(char, tmp, bufsize); errno = 0; ret = confstr(name, buf, bufsize); } if (bufsize < ret) rb_bug("required buffer size for confstr() changed dynamically."); if (ret == 0) { if (errno == 0) /* no configuration-defined value */ return Qnil; rb_sys_fail("confstr"); } return rb_str_new_cstr(buf); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Etc.confstr;F;7@;@;T;;;;0;@;{;IC; "Returns system configuration variable using confstr(). _name_ should be a constant under Etc which begins with CS_. The return value is a string or nil. nil means no configuration-defined value. (confstr() returns 0 but errno is not set.) Etc.confstr(Etc::CS_PATH) #=> "/bin:/usr/bin" # GNU/Linux Etc.confstr(Etc::CS_GNU_LIBC_VERSION) #=> "glibc 2.18" Etc.confstr(Etc::CS_GNU_LIBPTHREAD_VERSION) #=> "NPTL 2.18";T;[;![;"I"Returns system configuration variable using confstr(). _name_ should be a constant under Etc which begins with CS_. The return value is a string or nil. nil means no configuration-defined value. (confstr() returns 0 but errno is not set.) Etc.confstr(Etc::CS_PATH) #=> "/bin:/usr/bin" # GNU/Linux Etc.confstr(Etc::CS_GNU_LIBC_VERSION) #=> "glibc 2.18" Etc.confstr(Etc::CS_GNU_LIBPTHREAD_VERSION) #=> "NPTL 2.18" ;T;#0;$@;.F;/o;0;1T;2ie;3ir;Bi;%@I ;9@;:@;;To;4;5F;6;;;;&I"Etc#nprocessors;F;7[;[[@di ;T;:nprocessors;0;[;{;IC; "\Returns the number of online processors. The result is intended as the number of processes to use all available processors. This method is implemented using: - sched_getaffinity(): Linux - sysconf(_SC_NPROCESSORS_ONLN): GNU/Linux, NetBSD, FreeBSD, OpenBSD, DragonFly BSD, OpenIndiana, Mac OS X, AIX Example: require 'etc' p Etc.nprocessors #=> 4 The result might be smaller number than physical cpus especially when ruby process is bound to specific cpus. This is intended for getting better parallel processing. Example: (Linux) linux$ taskset 0x3 ./ruby -retc -e "p Etc.nprocessors" #=> 2 ;T;[;![;"I"\Returns the number of online processors. The result is intended as the number of processes to use all available processors. This method is implemented using: - sched_getaffinity(): Linux - sysconf(_SC_NPROCESSORS_ONLN): GNU/Linux, NetBSD, FreeBSD, OpenBSD, DragonFly BSD, OpenIndiana, Mac OS X, AIX Example: require 'etc' p Etc.nprocessors #=> 4 The result might be smaller number than physical cpus especially when ruby process is bound to specific cpus. This is intended for getting better parallel processing. Example: (Linux) linux$ taskset 0x3 ./ruby -retc -e "p Etc.nprocessors" #=> 2;T;#0;$@;.F;C0;%@I ;9I",static VALUE etc_nprocessors(VALUE obj) { long ret; #if !defined(_WIN32) #if defined(HAVE_SCHED_GETAFFINITY) && defined(CPU_ALLOC) int ncpus; ncpus = etc_nprocessors_affin(); if (ncpus != -1) { return INT2NUM(ncpus); } /* fallback to _SC_NPROCESSORS_ONLN */ #endif errno = 0; ret = sysconf(_SC_NPROCESSORS_ONLN); if (ret == -1) { rb_sys_fail("sysconf(_SC_NPROCESSORS_ONLN)"); } #else SYSTEM_INFO si; GetSystemInfo(&si); ret = (long)si.dwNumberOfProcessors; #endif return LONG2NUM(ret); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Etc.nprocessors;F;7@;@;T;;<;0;@;{;IC; "\Returns the number of online processors. The result is intended as the number of processes to use all available processors. This method is implemented using: - sched_getaffinity(): Linux - sysconf(_SC_NPROCESSORS_ONLN): GNU/Linux, NetBSD, FreeBSD, OpenBSD, DragonFly BSD, OpenIndiana, Mac OS X, AIX Example: require 'etc' p Etc.nprocessors #=> 4 The result might be smaller number than physical cpus especially when ruby process is bound to specific cpus. This is intended for getting better parallel processing. Example: (Linux) linux$ taskset 0x3 ./ruby -retc -e "p Etc.nprocessors" #=> 2;T;[;![;"I"^Returns the number of online processors. The result is intended as the number of processes to use all available processors. This method is implemented using: - sched_getaffinity(): Linux - sysconf(_SC_NPROCESSORS_ONLN): GNU/Linux, NetBSD, FreeBSD, OpenBSD, DragonFly BSD, OpenIndiana, Mac OS X, AIX Example: require 'etc' p Etc.nprocessors #=> 4 The result might be smaller number than physical cpus especially when ruby process is bound to specific cpus. This is intended for getting better parallel processing. Example: (Linux) linux$ taskset 0x3 ./ruby -retc -e "p Etc.nprocessors" #=> 2 ;T;#0;$@;.F;/o;0;1T;2i;3i ;Bi;%@I ;9@;:@;;To;u;[[@di;F;: Passwd;;w;;;[;{;IC; "Passwd Passwd is a Struct that contains the following members: name:: contains the short login name of the user as a String. passwd:: contains the encrypted password of the user as a String. an 'x' is returned if shadow passwords are in use. An '*' is returned if the user cannot log in using a password. uid:: contains the integer user ID (uid) of the user. gid:: contains the integer group ID (gid) of the user's primary group. dir:: contains the path to the home directory of the user as a String. shell:: contains the path to the login shell of the user as a String. === The following members below are optional, and must be compiled with special flags: gecos:: contains a longer String description of the user, such as a full name. Some Unix systems provide structured information in the gecos field, but this is system-dependent. must be compiled with +HAVE_STRUCT_PASSWD_PW_GECOS+ change:: password change time(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_CHANGE+ quota:: quota value(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_QUOTA+ age:: password age(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_AGE+ class:: user access class(string) must be compiled with +HAVE_STRUCT_PASSWD_PW_CLASS+ comment:: comment(string) must be compiled with +HAVE_STRUCT_PASSWD_PW_COMMENT+ expire:: account expiration time(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_EXPIRE+ ;T;[;![;"I"Passwd Passwd is a Struct that contains the following members: name:: contains the short login name of the user as a String. passwd:: contains the encrypted password of the user as a String. an 'x' is returned if shadow passwords are in use. An '*' is returned if the user cannot log in using a password. uid:: contains the integer user ID (uid) of the user. gid:: contains the integer group ID (gid) of the user's primary group. dir:: contains the path to the home directory of the user as a String. shell:: contains the path to the login shell of the user as a String. === The following members below are optional, and must be compiled with special flags: gecos:: contains a longer String description of the user, such as a full name. Some Unix systems provide structured information in the gecos field, but this is system-dependent. must be compiled with +HAVE_STRUCT_PASSWD_PW_GECOS+ change:: password change time(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_CHANGE+ quota:: quota value(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_QUOTA+ age:: password age(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_AGE+ class:: user access class(string) must be compiled with +HAVE_STRUCT_PASSWD_PW_CLASS+ comment:: comment(string) must be compiled with +HAVE_STRUCT_PASSWD_PW_COMMENT+ expire:: account expiration time(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_EXPIRE+ ;T;#0;$@;.F;/o;0;1T;2i;3i;%@I ;&I"Etc::Passwd;F;xI"Define-const;To;u;[[@di;F;;;;w;;;[;{;IC; "pGroup Group is a Struct that is only available when compiled with +HAVE_GETGRENT+. The struct contains the following members: name:: contains the name of the group as a String. passwd:: contains the encrypted password as a String. An 'x' is returned if password access to the group is not available; an empty string is returned if no password is needed to obtain membership of the group. Must be compiled with +HAVE_STRUCT_GROUP_GR_PASSWD+. gid:: contains the group's numeric ID as an integer. mem:: is an Array of Strings containing the short login names of the members of the group. ;T;[;![;"I"qGroup Group is a Struct that is only available when compiled with +HAVE_GETGRENT+. The struct contains the following members: name:: contains the name of the group as a String. passwd:: contains the encrypted password as a String. An 'x' is returned if password access to the group is not available; an empty string is returned if no password is needed to obtain membership of the group. Must be compiled with +HAVE_STRUCT_GROUP_GR_PASSWD+. gid:: contains the group's numeric ID as an integer. mem:: is an Array of Strings containing the short login names of the members of the group. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@I ;&I"Etc::Group;F;xI"Define-const;T; @I ; IC;[; @I ; IC;[; @I ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@diN;F;:Etc;;;;;[;{;IC; " ;T;[;![;"@;#0;$@I ;Bi;%@;&I"Etc;Fo; ;IC;[o;4;5F;6;;;;&I"WIN32OLE_TYPE.ole_classes;F;7[[I" typelib;T0;[[I"!ext/win32ole/win32ole_type.c;Tiw;T;:ole_classes;0;[;{;IC; "Returns array of WIN32OLE_TYPE objects defined by the typelib type library. This method will be OBSOLETE. Use WIN32OLE_TYPELIB.new(typelib).ole_classes instead. ;T;[o;= ;>I" overload;F;?0;;?;@0;:I"ole_classes(typelib);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" typelib;T0;$@;![;"I"Returns array of WIN32OLE_TYPE objects defined by the typelib type library. This method will be OBSOLETE. Use WIN32OLE_TYPELIB.new(typelib).ole_classes instead. @overload ole_classes(typelib);T;#0;$@;.F;/o;0;1T;2ip;3it;%@;9I"nstatic VALUE foletype_s_ole_classes(VALUE self, VALUE typelib) { VALUE obj; /* rb_warn("%s is obsolete; use %s instead.", "WIN32OLE_TYPE.ole_classes", "WIN32OLE_TYPELIB.new(typelib).ole_types"); */ obj = rb_funcall(cWIN32OLE_TYPELIB, rb_intern("new"), 1, typelib); return rb_funcall(obj, rb_intern("ole_types"), 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPE.typelibs;F;7[;[[@i;T;: typelibs;0;[;{;IC; "~Returns array of type libraries. This method will be OBSOLETE. Use WIN32OLE_TYPELIB.typelibs.collect{|t| t.name} instead. ;T;[o;= ;>I" overload;F;?0;;@;@0;:I" typelibs;T;IC; ";T;[;![;"I";T;#0;$@2;.F;Bi;C0;7[;$@2;![;"I"Returns array of type libraries. This method will be OBSOLETE. Use WIN32OLE_TYPELIB.typelibs.collect{|t| t.name} instead. @overload typelibs;T;#0;$@2;.F;/o;0;1T;2i;3i;%@;9I"static VALUE foletype_s_typelibs(VALUE self) { /* rb_warn("%s is obsolete. use %s instead.", "WIN32OLE_TYPE.typelibs", "WIN32OLE_TYPELIB.typelibs.collect{t|t.name}"); */ return rb_eval_string("WIN32OLE_TYPELIB.typelibs.collect{|t|t.name}"); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPE.progids;F;7[;[[@i;T;: progids;0;[;{;IC; "Returns array of ProgID. ;T;[o;= ;>I" overload;F;?0;;A;@0;:I" progids;T;IC; ";T;[;![;"I";T;#0;$@H;.F;Bi;C0;7[;$@H;![;"I"1Returns array of ProgID. @overload progids;T;#0;$@H;.F;/o;0;1T;2i;3i;%@;9I"1static VALUE foletype_s_progids(VALUE self) { HKEY hclsids, hclsid; DWORD i; LONG err; VALUE clsid; VALUE v = rb_str_new2(""); VALUE progids = rb_ary_new(); err = reg_open_key(HKEY_CLASSES_ROOT, "CLSID", &hclsids); if(err != ERROR_SUCCESS) { return progids; } for(i = 0; ; i++) { clsid = reg_enum_key(hclsids, i); if (clsid == Qnil) break; err = reg_open_vkey(hclsids, clsid, &hclsid); if (err != ERROR_SUCCESS) continue; if ((v = reg_get_val2(hclsid, "ProgID")) != Qnil) rb_ary_push(progids, v); if ((v = reg_get_val2(hclsid, "VersionIndependentProgID")) != Qnil) rb_ary_push(progids, v); RegCloseKey(hclsid); } RegCloseKey(hclsids); return progids; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPE#initialize;F;7[[I" typelib;T0[I" oleclass;T0;[[@i;T;;D;0;[;{;IC; "!Returns a new WIN32OLE_TYPE object. The first argument typelib specifies OLE type library name. The second argument specifies OLE class name. WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application') # => WIN32OLE_TYPE object of Application class of Excel. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(typelib, ole_class);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"WIN32OLE_TYPE object;T;$@^;![;"I"#@return [WIN32OLE_TYPE object];T;#0;$@^;.F;Bi;C0;7[[I" typelib;T0[I"ole_class;T0;$@^;![;"I"fReturns a new WIN32OLE_TYPE object. The first argument typelib specifies OLE type library name. The second argument specifies OLE class name. WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application') # => WIN32OLE_TYPE object of Application class of Excel. @overload new(typelib, ole_class) @return [WIN32OLE_TYPE object];T;#0;$@^;.F;/o;0;1T;2i;3i;%@;9I"static VALUE foletype_initialize(VALUE self, VALUE typelib, VALUE oleclass) { VALUE file; OLECHAR * pbuf; ITypeLib *pTypeLib; HRESULT hr; SafeStringValue(oleclass); SafeStringValue(typelib); file = typelib_file(typelib); if (file == Qnil) { file = typelib; } pbuf = ole_vstr2wc(file); hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib); if (FAILED(hr)) ole_raise(hr, eWIN32OLERuntimeError, "failed to LoadTypeLibEx"); SysFreeString(pbuf); if (oleclass_from_typelib(self, pTypeLib, oleclass) == Qfalse) { OLE_RELEASE(pTypeLib); rb_raise(eWIN32OLERuntimeError, "not found `%s` in `%s`", StringValuePtr(oleclass), StringValuePtr(typelib)); } OLE_RELEASE(pTypeLib); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPE#name;F;7[;[[@i%;T;;F;0;[;{;IC; "Returns OLE type name. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application') puts tobj.name # => Application ;T;[;![;"I" Returns OLE type name. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application') puts tobj.name # => Application ;T;#0;$o;4;5F;6;;;;&I"WIN32OLE_TYPE#to_s;F;7[;[[@i;F;;G;;;[;{;@;%@;9I"`static VALUE foletype_name(VALUE self) { return rb_ivar_get(self, rb_intern("name")); };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i";%@;9I"`static VALUE foletype_name(VALUE self) { return rb_ivar_get(self, rb_intern("name")); };T;:@;;To;4;5F;6;;;;&I"WIN32OLE_TYPE#ole_type;F;7[;[[@ia;T;: ole_type;0;[;{;IC; "returns type of OLE class. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application') puts tobj.ole_type # => Class ;T;[;![;"I" returns type of OLE class. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application') puts tobj.ole_type # => Class ;T;#0;$@;.F;/o;0;1T;2iY;3i^;%@;9I"~static VALUE foletype_ole_type(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_ole_type(pTypeInfo); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPE#guid;F;7[;[[@i;T;: guid;0;[;{;IC; "Returns GUID. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application') puts tobj.guid # => {00024500-0000-0000-C000-000000000046} ;T;[;![;"I" Returns GUID. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application') puts tobj.guid # => {00024500-0000-0000-C000-000000000046} ;T;#0;$@;.F;/o;0;1T;2i{;3i;%@;9I"{static VALUE foletype_guid(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_guid(pTypeInfo); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPE#progid;F;7[;[[@i;T;: progid;0;[;{;IC; "Returns ProgID if it exists. If not found, then returns nil. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application') puts tobj.progid # => Excel.Application.9 ;T;[;![;"I" Returns ProgID if it exists. If not found, then returns nil. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application') puts tobj.progid # => Excel.Application.9 ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE foletype_progid(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_progid(pTypeInfo); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPE#visible?;F;7[;[[@i;T;: visible?;0;[;{;IC; "Returns true if the OLE class is public. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application') puts tobj.visible # => true;T;[o;= ;>I" overload;F;?0;;E;@0;:I" visible? #=> true or false;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"#;TI"> true or false;T;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"Returns true if the OLE class is public. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application') puts tobj.visible # => true @overload visible? #=> true or false;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE foletype_visible(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_visible(pTypeInfo); };T;:I"static VALUE;T;;T@o;4;5F;6;;;;&I" WIN32OLE_TYPE#major_version;F;7[;[[@i;T;:major_version;0;[;{;IC; "Returns major version. tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents') puts tobj.major_version # => 8 ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"major_version;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns major version. tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents') puts tobj.major_version # => 8 @overload major_version;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE foletype_major_version(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_major_version(pTypeInfo); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" WIN32OLE_TYPE#minor_version;F;7[;[[@i;T;:minor_version;0;[;{;IC; "Returns minor version. tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents') puts tobj.minor_version # => 2 ;T;[;![;"I" Returns minor version. tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents') puts tobj.minor_version # => 2 ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE foletype_minor_version(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_minor_version(pTypeInfo); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPE#typekind;F;7[;[[@i;T;: typekind;0;[;{;IC; "Returns number which represents type. tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents') puts tobj.typekind # => 4 ;T;[;![;"I" Returns number which represents type. tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents') puts tobj.typekind # => 4 ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE foletype_typekind(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_typekind(pTypeInfo); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPE#helpstring;F;7[;[[@i:;T;:helpstring;0;[;{;IC; "Returns help string. tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'IWebBrowser') puts tobj.helpstring # => Web Browser interface ;T;[;![;"I" Returns help string. tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'IWebBrowser') puts tobj.helpstring # => Web Browser interface ;T;#0;$@;.F;/o;0;1T;2i2;3i7;%@;9I"static VALUE foletype_helpstring(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_helpstring(pTypeInfo); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPE#src_type;F;7[;[[@i\;T;: src_type;0;[;{;IC; "Returns source class when the OLE class is 'Alias'. tobj = WIN32OLE_TYPE.new('Microsoft Office 9.0 Object Library', 'MsoRGBType') puts tobj.src_type # => I4 ;T;[;![;"I" Returns source class when the OLE class is 'Alias'. tobj = WIN32OLE_TYPE.new('Microsoft Office 9.0 Object Library', 'MsoRGBType') puts tobj.src_type # => I4 ;T;#0;$@;.F;/o;0;1T;2iS;3iY;%@;9I"static VALUE foletype_src_type(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_src_type(pTypeInfo); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPE#helpfile;F;7[;[[@ix;T;: helpfile;0;[;{;IC; "Returns helpfile path. If helpfile is not found, then returns nil. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet') puts tobj.helpfile # => C:\...\VBAXL9.CHM ;T;[o;= ;>I" overload;F;?0;;K;@0;:I" helpfile;T;IC; ";T;[;![;"I";T;#0;$@+;.F;Bi;C0;7[;$@+;![;"I"Returns helpfile path. If helpfile is not found, then returns nil. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet') puts tobj.helpfile # => C:\...\VBAXL9.CHM @overload helpfile;T;#0;$@+;.F;/o;0;1T;2io;3iu;%@;9I"static VALUE foletype_helpfile(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_helpfile(pTypeInfo); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPE#helpcontext;F;7[;[[@i;T;:helpcontext;0;[;{;IC; "Returns helpcontext. If helpcontext is not found, then returns nil. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet') puts tobj.helpfile # => 131185 ;T;[o;= ;>I" overload;F;?0;;L;@0;:I"helpcontext;T;IC; ";T;[;![;"I";T;#0;$@A;.F;Bi;C0;7[;$@A;![;"I"Returns helpcontext. If helpcontext is not found, then returns nil. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet') puts tobj.helpfile # => 131185 @overload helpcontext;T;#0;$@A;.F;/o;0;1T;2i;3i;%@;9I"static VALUE foletype_helpcontext(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_helpcontext(pTypeInfo); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPE#variables;F;7[;[[@i;T;:variables;0;[;{;IC; "Returns array of WIN32OLE_VARIABLE objects which represent variables defined in OLE class. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') vars = tobj.variables vars.each do |v| puts "#{v.name} = #{v.value}" end The result of above sample script is follows: xlChart = -4109 xlDialogSheet = -4116 xlExcel4IntlMacroSheet = 4 xlExcel4MacroSheet = 3 xlWorksheet = -4167 ;T;[o;= ;>I" overload;F;?0;;M;@0;:I"variables;T;IC; ";T;[;![;"I";T;#0;$@W;.F;Bi;C0;7[;$@W;![;"I"Returns array of WIN32OLE_VARIABLE objects which represent variables defined in OLE class. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') vars = tobj.variables vars.each do |v| puts "#{v.name} = #{v.value}" end The result of above sample script is follows: xlChart = -4109 xlDialogSheet = -4116 xlExcel4IntlMacroSheet = 4 xlExcel4MacroSheet = 3 xlWorksheet = -4167 @overload variables;T;#0;$@W;.F;/o;0;1T;2i;3i;%@;9I"static VALUE foletype_variables(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_variables(pTypeInfo); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPE#ole_methods;F;7[;[[@i;T;:ole_methods;0;[;{;IC; "Returns array of WIN32OLE_METHOD objects which represent OLE method defined in OLE type library. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet') methods = tobj.ole_methods.collect{|m| m.name } # => ['Activate', 'Copy', 'Delete',....] ;T;[;![;"I" Returns array of WIN32OLE_METHOD objects which represent OLE method defined in OLE type library. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet') methods = tobj.ole_methods.collect{|m| m.name } # => ['Activate', 'Copy', 'Delete',....] ;T;#0;$@m;.F;/o;0;1T;2i;3i;%@;9I"static VALUE foletype_methods(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_methods_from_typeinfo(pTypeInfo, INVOKE_FUNC | INVOKE_PROPERTYGET | INVOKE_PROPERTYPUT | INVOKE_PROPERTYPUTREF); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPE#ole_typelib;F;7[;[[@i;T;:ole_typelib;0;[;{;IC; "Returns the WIN32OLE_TYPELIB object which is including the WIN32OLE_TYPE object. If it is not found, then returns nil. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet') puts tobj.ole_typelib # => 'Microsoft Excel 9.0 Object Library' ;T;[o;= ;>I" overload;F;?0;;O;@0;:I"ole_typelib;T;IC; ";T;[;![;"I";T;#0;$@{;.F;Bi;C0;7[;$@{;![;"I" Returns the WIN32OLE_TYPELIB object which is including the WIN32OLE_TYPE object. If it is not found, then returns nil. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet') puts tobj.ole_typelib # => 'Microsoft Excel 9.0 Object Library' @overload ole_typelib;T;#0;$@{;.F;/o;0;1T;2i;3i;%@;9I"static VALUE foletype_ole_typelib(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_typelib_from_itypeinfo(pTypeInfo); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(WIN32OLE_TYPE#implemented_ole_types;F;7[;[[@i.;T;:implemented_ole_types;0;[;{;IC; "Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet') p tobj.implemented_ole_types # => [_Worksheet, DocEvents] ;T;[o;= ;>I" overload;F;?0;;P;@0;:I"implemented_ole_types;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I" Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet') p tobj.implemented_ole_types # => [_Worksheet, DocEvents] @overload implemented_ole_types;T;#0;$@;.F;/o;0;1T;2i%;3i+;%@;9I"static VALUE foletype_impl_ole_types(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_impl_ole_types(pTypeInfo, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#WIN32OLE_TYPE#source_ole_types;F;7[;[[@i?;T;:source_ole_types;0;[;{;IC; "7Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object and having IMPLTYPEFLAG_FSOURCE. tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer") p tobj.source_ole_types # => [#, #] ;T;[o;= ;>I" overload;F;?0;;Q;@0;:I"source_ole_types;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"TReturns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object and having IMPLTYPEFLAG_FSOURCE. tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer") p tobj.source_ole_types # => [#, #] @overload source_ole_types;T;#0;$@;.F;/o;0;1T;2i5;3i<;%@;9I"static VALUE foletype_source_ole_types(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_impl_ole_types(pTypeInfo, IMPLTYPEFLAG_FSOURCE); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(WIN32OLE_TYPE#default_event_sources;F;7[;[[@iO;T;:default_event_sources;0;[;{;IC; "0Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object and having IMPLTYPEFLAG_FSOURCE and IMPLTYPEFLAG_FDEFAULT. tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer") p tobj.default_event_sources # => [#] ;T;[o;= ;>I" overload;F;?0;;R;@0;:I"default_event_sources;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"RReturns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object and having IMPLTYPEFLAG_FSOURCE and IMPLTYPEFLAG_FDEFAULT. tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer") p tobj.default_event_sources # => [#] @overload default_event_sources;T;#0;$@;.F;/o;0;1T;2iF;3iL;%@;9I"static VALUE foletype_default_event_sources(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_impl_ole_types(pTypeInfo, IMPLTYPEFLAG_FSOURCE|IMPLTYPEFLAG_FDEFAULT); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$WIN32OLE_TYPE#default_ole_types;F;7[;[[@i`;T;:default_ole_types;0;[;{;IC; "4Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object and having IMPLTYPEFLAG_FDEFAULT. tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer") p tobj.default_ole_types # => [#, #] ;T;[o;= ;>I" overload;F;?0;;S;@0;:I"default_ole_types;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"RReturns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object and having IMPLTYPEFLAG_FDEFAULT. tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer") p tobj.default_ole_types # => [#, #] @overload default_ole_types;T;#0;$@;.F;/o;0;1T;2iV;3i];%@;9I"static VALUE foletype_default_ole_types(VALUE self) { ITypeInfo *pTypeInfo = itypeinfo(self); return ole_type_impl_ole_types(pTypeInfo, IMPLTYPEFLAG_FDEFAULT); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPE#inspect;F;7[;[[@ip;T;;J;0;[;{;IC; "Returns the type name with class name. ie = WIN32OLE.new('InternetExplorer.Application') ie.ole_type.inspect => # ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the type name with class name. ie = WIN32OLE.new('InternetExplorer.Application') ie.ole_type.inspect => # @overload inspect @return [String];T;#0;$@;.F;/o;0;1T;2ig;3in;%@;9I"estatic VALUE foletype_inspect(VALUE self) { return default_inspect(self, "WIN32OLE_TYPE"); };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{@;F;[;[[@i=[@iz;T;:WIN32OLE_TYPE;;;;;[;{;IC; "OWIN32OLE_TYPE objects represent OLE type library information.;T;[;![;"I"S WIN32OLE_TYPE objects represent OLE type library information. ;T;#0;$@;.F;/o;0;1T;2i=;3i?;Bi;%@;&I"WIN32OLE_TYPE;F;'@o;u;[[@&i;F;:TOPLEVEL_BINDING;;w;;;[;{;IC; "'The Binding of the top level scope ;T;[;![;"I"(The Binding of the top level scope ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"TOPLEVEL_BINDING;F;xI"rb_binding_new();To; ;IC;[o;4;5F;6;;;;&I"WIN32OLE_PARAM#initialize;F;7[[I"olemethod;T0[I"n;T0;[[I""ext/win32ole/win32ole_param.c;Ti;T;;D;0;[;{;IC; "Returns WIN32OLE_PARAM object which represents OLE parameter information. 1st argument should be WIN32OLE_METHOD object. 2nd argument `n' is n-th parameter of the method specified by 1st argument. tobj = WIN32OLE_TYPE.new('Microsoft Scripting Runtime', 'IFileSystem') method = WIN32OLE_METHOD.new(tobj, 'CreateTextFile') param = WIN32OLE_PARAM.new(method, 2) # => # ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(method, n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"WIN32OLE_PARAM object;T;$@$;![;"I"$@return [WIN32OLE_PARAM object];T;#0;$@$;.F;Bi;C0;7[[I" method;T0[I"n;T0;$@$;![;"I"Returns WIN32OLE_PARAM object which represents OLE parameter information. 1st argument should be WIN32OLE_METHOD object. 2nd argument `n' is n-th parameter of the method specified by 1st argument. tobj = WIN32OLE_TYPE.new('Microsoft Scripting Runtime', 'IFileSystem') method = WIN32OLE_METHOD.new(tobj, 'CreateTextFile') param = WIN32OLE_PARAM.new(method, 2) # => # @overload new(method, n) @return [WIN32OLE_PARAM object];T;#0;$@$;.F;/o;0;1T;2i;3i;%@";9I"8static VALUE foleparam_initialize(VALUE self, VALUE olemethod, VALUE n) { int idx; if (!rb_obj_is_kind_of(olemethod, cWIN32OLE_METHOD)) { rb_raise(rb_eTypeError, "1st parameter must be WIN32OLE_METHOD object"); } idx = RB_FIX2INT(n); return oleparam_ole_param(self, olemethod, idx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_PARAM#name;F;7[;[[@-i;T;;F;0;[;{;IC; "Returns name. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') param1 = method.params[0] puts param1.name # => Filename ;T;[o;= ;>I" overload;F;?0;;F;@0;:I" name;T;IC; ";T;[;![;"I";T;#0;$@H;.F;Bi;C0;7[;$@H;![;"I"Returns name. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') param1 = method.params[0] puts param1.name # => Filename @overload name;T;#0;$o;4;5F;6;;;;&I"WIN32OLE_PARAM#to_s;F;7[;[[@-i;F;;G;;;[;{;@O;%@";9I"astatic VALUE foleparam_name(VALUE self) { return rb_ivar_get(self, rb_intern("name")); };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@";9I"astatic VALUE foleparam_name(VALUE self) { return rb_ivar_get(self, rb_intern("name")); };T;:@c;;To;4;5F;6;;;;&I"WIN32OLE_PARAM#ole_type;F;7[;[[@-i;T;;B;0;[;{;IC; "Returns OLE type of WIN32OLE_PARAM object(parameter of OLE method). tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') param1 = method.params[0] puts param1.ole_type # => VARIANT ;T;[o;= ;>I" overload;F;?0;;B;@0;:I" ole_type;T;IC; ";T;[;![;"I";T;#0;$@f;.F;Bi;C0;7[;$@f;![;"I"Returns OLE type of WIN32OLE_PARAM object(parameter of OLE method). tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') param1 = method.params[0] puts param1.ole_type # => VARIANT @overload ole_type;T;#0;$@f;.F;/o;0;1T;2i;3i;%@";9I"static VALUE foleparam_ole_type(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_ole_type(pparam->pTypeInfo, pparam->method_index, pparam->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#WIN32OLE_PARAM#ole_type_detail;F;7[;[[@-i;T;:ole_type_detail;0;[;{;IC; "Returns detail information of type of argument. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'IWorksheetFunction') method = WIN32OLE_METHOD.new(tobj, 'SumIf') param1 = method.params[0] p param1.ole_type_detail # => ["PTR", "USERDEFINED", "Range"] ;T;[o;= ;>I" overload;F;?0;;V;@0;:I"ole_type_detail;T;IC; ";T;[;![;"I";T;#0;$@|;.F;Bi;C0;7[;$@|;![;"I"0Returns detail information of type of argument. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'IWorksheetFunction') method = WIN32OLE_METHOD.new(tobj, 'SumIf') param1 = method.params[0] p param1.ole_type_detail # => ["PTR", "USERDEFINED", "Range"] @overload ole_type_detail;T;#0;$@|;.F;/o;0;1T;2i;3i;%@";9I"+static VALUE foleparam_ole_type_detail(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_ole_type_detail(pparam->pTypeInfo, pparam->method_index, pparam->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_PARAM#input?;F;7[;[[@-i ;T;: input?;0;[;{;IC; "Returns true if the parameter is input. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') param1 = method.params[0] puts param1.input? # => true;T;[o;= ;>I" overload;F;?0;;W;@0;:I" input?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"Returns true if the parameter is input. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') param1 = method.params[0] puts param1.input? # => true @overload input?;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@";9I"$static VALUE foleparam_input(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index, pparam->index, PARAMFLAG_FIN); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_PARAM#output?;F;7[;[[@-i%;T;: output?;0;[;{;IC; "Returns true if argument is output. tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'DWebBrowserEvents') method = WIN32OLE_METHOD.new(tobj, 'NewWindow') method.params.each do |param| puts "#{param.name} #{param.output?}" end The result of above script is following: URL false Flags false TargetFrameName false PostData false Headers false Processed true;T;[o;= ;>I" overload;F;?0;;X;@0;:I" output?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"Returns true if argument is output. tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'DWebBrowserEvents') method = WIN32OLE_METHOD.new(tobj, 'NewWindow') method.params.each do |param| puts "#{param.name} #{param.output?}" end The result of above script is following: URL false Flags false TargetFrameName false PostData false Headers false Processed true @overload output?;T;#0;$@;.F;/o;0;1T;2i;3i";Bi;%@";9I"&static VALUE foleparam_output(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index, pparam->index, PARAMFLAG_FOUT); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_PARAM#optional?;F;7[;[[@-i8;T;:optional?;0;[;{;IC; "Returns true if argument is optional. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') param1 = method.params[0] puts "#{param1.name} #{param1.optional?}" # => Filename true;T;[o;= ;>I" overload;F;?0;;Y;@0;:I"optional?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"Returns true if argument is optional. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') param1 = method.params[0] puts "#{param1.name} #{param1.optional?}" # => Filename true @overload optional?;T;#0;$@;.F;/o;0;1T;2i.;3i5;Bi;%@";9I"(static VALUE foleparam_optional(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index, pparam->index, PARAMFLAG_FOPT); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_PARAM#retval?;F;7[;[[@-iL;T;: retval?;0;[;{;IC; ":Returns true if argument is return value. tobj = WIN32OLE_TYPE.new('DirectX 7 for Visual Basic Type Library', 'DirectPlayLobbyConnection') method = WIN32OLE_METHOD.new(tobj, 'GetPlayerShortName') param = method.params[0] puts "#{param.name} #{param.retval?}" # => name true;T;[o;= ;>I" overload;F;?0;;Z;@0;:I" retval?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"NReturns true if argument is return value. tobj = WIN32OLE_TYPE.new('DirectX 7 for Visual Basic Type Library', 'DirectPlayLobbyConnection') method = WIN32OLE_METHOD.new(tobj, 'GetPlayerShortName') param = method.params[0] puts "#{param.name} #{param.retval?}" # => name true @overload retval?;T;#0;$@;.F;/o;0;1T;2iA;3iI;Bi;%@";9I")static VALUE foleparam_retval(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index, pparam->index, PARAMFLAG_FRETVAL); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_PARAM#default;F;7[;[[@-i;T;;;0;[;{;IC; "|Returns default value. If the default value does not exist, this method returns nil. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') method.params.each do |param| if param.default puts "#{param.name} (= #{param.default})" else puts "#{param}" end end The above script result is following: Filename FileFormat Password WriteResPassword ReadOnlyRecommended CreateBackup AccessMode (= 1) ConflictResolution AddToMru TextCodepage TextVisualLayout ;T;[o;= ;>I" overload;F;?0;;;@0;:I" default;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns default value. If the default value does not exist, this method returns nil. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') method.params.each do |param| if param.default puts "#{param.name} (= #{param.default})" else puts "#{param}" end end The above script result is following: Filename FileFormat Password WriteResPassword ReadOnlyRecommended CreateBackup AccessMode (= 1) ConflictResolution AddToMru TextCodepage TextVisualLayout @overload default;T;#0;$@;.F;/o;0;1T;2il;3i;%@";9I"static VALUE foleparam_default(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_default(pparam->pTypeInfo, pparam->method_index, pparam->index); };T;:I"static VALUE;T;;T@[o;4;5F;6;;;;&I"WIN32OLE_PARAM#inspect;F;7[;[[@-i;T;;J;0;[;{;IC; "Returns the parameter name with class name. If the parameter has default value, then returns name=value string with class name. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Returns the parameter name with class name. If the parameter has default value, then returns name=value string with class name. @overload inspect @return [String];T;#0;$@ ;.F;/o;0;1T;2i;3i;%@";9I"+static VALUE foleparam_inspect(VALUE self) { VALUE detail = foleparam_name(self); VALUE defval = foleparam_default(self); if (defval != Qnil) { rb_str_cat2(detail, "="); rb_str_concat(detail, rb_inspect(defval)); } return make_inspect("WIN32OLE_PARAM", detail); };T;:I"static VALUE;T;;T; @"; IC;[; @"; IC;[; @"; IC;{;IC;{;T;IC;{;T;T;{@[;F;[;[[@-iG[@-i;T;:WIN32OLE_PARAM;;;;;[;{;IC; "YWIN32OLE_PARAM objects represent param information of the OLE method.;T;[;![;"I"] WIN32OLE_PARAM objects represent param information of the OLE method. ;T;#0;$@";.F;/o;0;1T;2iG;3iJ;Bi;%@;&I"WIN32OLE_PARAM;F;'@o; ;IC;[o;4;5F;6;;;;&I"WIN32OLE_VARIANT.array;F;7[[I" elems;T0[I"vvt;T0;[[I"$ext/win32ole/win32ole_variant.c;Ti;T;: array;0;[;{;IC; "Returns Ruby object wrapping OLE variant whose variant type is VT_ARRAY. The first argument should be Array object which specifies dimensions and each size of dimensions of OLE array. The second argument specifies variant type of the element of OLE array. The following create 2 dimensions OLE array. The first dimensions size is 3, and the second is 4. ole_ary = WIN32OLE_VARIANT.array([3,4], VT_I4) ruby_ary = ole_ary.value # => [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]] ;T;[o;= ;>I" overload;F;?0;;\;@0;:I"array(ary, vt);T;IC; ";T;[;![;"I";T;#0;$@;;.F;Bi;C0;7[[I"ary;T0[I"vt;T0;$@;;![;"I"Returns Ruby object wrapping OLE variant whose variant type is VT_ARRAY. The first argument should be Array object which specifies dimensions and each size of dimensions of OLE array. The second argument specifies variant type of the element of OLE array. The following create 2 dimensions OLE array. The first dimensions size is 3, and the second is 4. ole_ary = WIN32OLE_VARIANT.array([3,4], VT_I4) ruby_ary = ole_ary.value # => [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]] @overload array(ary, vt);T;#0;$@;;.F;/o;0;1T;2i ;3i;%@9;9I"static VALUE folevariant_s_array(VALUE klass, VALUE elems, VALUE vvt) { VALUE obj = Qnil; VARTYPE vt; struct olevariantdata *pvar; SAFEARRAYBOUND *psab = NULL; SAFEARRAY *psa = NULL; UINT dim = 0; UINT i = 0; ole_initialize(); vt = RB_NUM2UINT(vvt); vt = (vt | VT_ARRAY); Check_Type(elems, T_ARRAY); obj = folevariant_s_allocate(klass); TypedData_Get_Struct(obj, struct olevariantdata, &olevariant_datatype, pvar); dim = RARRAY_LEN(elems); psab = ALLOC_N(SAFEARRAYBOUND, dim); if(!psab) { rb_raise(rb_eRuntimeError, "memory allocation error"); } for (i = 0; i < dim; i++) { psab[i].cElements = RB_FIX2INT(rb_ary_entry(elems, i)); psab[i].lLbound = 0; } psa = SafeArrayCreate((VARTYPE)(vt & VT_TYPEMASK), dim, psab); if (psa == NULL) { if (psab) free(psab); rb_raise(rb_eRuntimeError, "memory allocation error(SafeArrayCreate)"); } V_VT(&(pvar->var)) = vt; if (vt & VT_BYREF) { V_VT(&(pvar->realvar)) = (vt & ~VT_BYREF); V_ARRAY(&(pvar->realvar)) = psa; V_ARRAYREF(&(pvar->var)) = &(V_ARRAY(&(pvar->realvar))); } else { V_ARRAY(&(pvar->var)) = psa; } if (psab) free(psab); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" WIN32OLE_VARIANT#initialize;F;7[[I" args;T0;[[@Di;T;;D;0;[;{;IC; "PReturns Ruby object wrapping OLE variant. The first argument specifies Ruby object to convert OLE variant variable. The second argument specifies VARIANT type. In some situation, you need the WIN32OLE_VARIANT object to pass OLE method shell = WIN32OLE.new("Shell.Application") folder = shell.NameSpace("C:\\Windows") item = folder.ParseName("tmp.txt") # You can't use Ruby String object to call FolderItem.InvokeVerb. # Instead, you have to use WIN32OLE_VARIANT object to call the method. shortcut = WIN32OLE_VARIANT.new("Create Shortcut(\&S)") item.invokeVerb(shortcut) ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"3new(val, vartype) #=> WIN32OLE_VARIANT object.;T;IC; ";T;[;![;"I";T;#0;$@Z;.F;Bi;C0;7[[I"val;T0[I" vartype;T0;$@Z;![;"I"Returns Ruby object wrapping OLE variant. The first argument specifies Ruby object to convert OLE variant variable. The second argument specifies VARIANT type. In some situation, you need the WIN32OLE_VARIANT object to pass OLE method shell = WIN32OLE.new("Shell.Application") folder = shell.NameSpace("C:\\Windows") item = folder.ParseName("tmp.txt") # You can't use Ruby String object to call FolderItem.InvokeVerb. # Instead, you have to use WIN32OLE_VARIANT object to call the method. shortcut = WIN32OLE_VARIANT.new("Create Shortcut(\&S)") item.invokeVerb(shortcut) @overload new(val, vartype) #=> WIN32OLE_VARIANT object.;T;#0;$@Z;.F;/o;0;1T;2i;3i;%@9;9I"static VALUE folevariant_initialize(VALUE self, VALUE args) { int len = 0; VARIANT var; VALUE val; VALUE vvt; VARTYPE vt; struct olevariantdata *pvar; len = RARRAY_LEN(args); rb_check_arity(len, 1, 3); VariantInit(&var); val = rb_ary_entry(args, 0); check_type_val2variant(val); TypedData_Get_Struct(self, struct olevariantdata, &olevariant_datatype, pvar); if (len == 1) { ole_val2variant(val, &(pvar->var)); } else { vvt = rb_ary_entry(args, 1); vt = RB_NUM2INT(vvt); if ((vt & VT_TYPEMASK) == VT_RECORD) { rb_raise(rb_eArgError, "not supported VT_RECORD WIN32OLE_VARIANT object"); } ole_val2olevariantdata(val, vt, pvar); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_VARIANT#value;F;7[;[[@Di`;T;;5;0;[;{;IC; "Returns Ruby object value from OLE variant. obj = WIN32OLE_VARIANT.new(1, WIN32OLE::VARIANT::VT_BSTR) obj.value # => "1" (not Integer object, but String object "1") ;T;[;![;"I" Returns Ruby object value from OLE variant. obj = WIN32OLE_VARIANT.new(1, WIN32OLE::VARIANT::VT_BSTR) obj.value # => "1" (not Integer object, but String object "1") ;T;#0;$@v;.F;/o;0;1T;2iW;3i];%@9;9I"static VALUE folevariant_value(VALUE self) { struct olevariantdata *pvar; VALUE val = Qnil; VARTYPE vt; int dim; SAFEARRAY *psa; TypedData_Get_Struct(self, struct olevariantdata, &olevariant_datatype, pvar); val = ole_variant2val(&(pvar->var)); vt = V_VT(&(pvar->var)); if ((vt & ~VT_BYREF) == (VT_UI1|VT_ARRAY)) { if (vt & VT_BYREF) { psa = *V_ARRAYREF(&(pvar->var)); } else { psa = V_ARRAY(&(pvar->var)); } if (!psa) { return val; } dim = SafeArrayGetDim(psa); if (dim == 1) { val = rb_funcall(val, rb_intern("pack"), 1, rb_str_new2("C*")); } } return val; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_VARIANT#value=;F;7[[I"val;T0;[[@Di;T;;;0;[;{;IC; "Sets variant value to val. If the val type does not match variant value type(vartype), then val is changed to match variant value type(vartype) before setting val. This method is not available when vartype is VT_ARRAY(except VT_UI1|VT_ARRAY). If the vartype is VT_UI1|VT_ARRAY, the val should be String object. obj = WIN32OLE_VARIANT.new(1) # obj.vartype is WIN32OLE::VARIANT::VT_I4 obj.value = 3.2 # 3.2 is changed to 3 when setting value. p obj.value # => 3 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"value=(val);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"val;T0;$@;![;"I"Sets variant value to val. If the val type does not match variant value type(vartype), then val is changed to match variant value type(vartype) before setting val. This method is not available when vartype is VT_ARRAY(except VT_UI1|VT_ARRAY). If the vartype is VT_UI1|VT_ARRAY, the val should be String object. obj = WIN32OLE_VARIANT.new(1) # obj.vartype is WIN32OLE::VARIANT::VT_I4 obj.value = 3.2 # 3.2 is changed to 3 when setting value. p obj.value # => 3 @overload value=(val);T;#0;$@;.F;/o;0;1T;2i;3i;%@9;9I"static VALUE folevariant_set_value(VALUE self, VALUE val) { struct olevariantdata *pvar; VARTYPE vt; TypedData_Get_Struct(self, struct olevariantdata, &olevariant_datatype, pvar); vt = V_VT(&(pvar->var)); if (V_ISARRAY(&(pvar->var)) && ((vt & ~VT_BYREF) != (VT_UI1|VT_ARRAY) || !RB_TYPE_P(val, T_STRING))) { rb_raise(eWIN32OLERuntimeError, "`value=' is not available for this variant type object"); } ole_val2olevariantdata(val, vt, pvar); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_VARIANT#vartype;F;7[;[[@Di;T;: vartype;0;[;{;IC; "uReturns OLE variant type. obj = WIN32OLE_VARIANT.new("string") obj.vartype # => WIN32OLE::VARIANT::VT_BSTR ;T;[;![;"I"y Returns OLE variant type. obj = WIN32OLE_VARIANT.new("string") obj.vartype # => WIN32OLE::VARIANT::VT_BSTR ;T;#0;$@;.F;/o;0;1T;2i~;3i;%@9;9I"static VALUE folevariant_vartype(VALUE self) { struct olevariantdata *pvar; TypedData_Get_Struct(self, struct olevariantdata, &olevariant_datatype, pvar); return RB_INT2FIX(V_VT(&pvar->var)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_VARIANT#[];F;7[[@90;[[@Di;T;;;0;[;{;IC; "Returns the element of WIN32OLE_VARIANT object(OLE array). This method is available only when the variant type of WIN32OLE_VARIANT object is VT_ARRAY. REMARK: The all indices should be 0 or natural number and lower than or equal to max indices. (This point is different with Ruby Array indices.) obj = WIN32OLE_VARIANT.new([[1,2,3],[4,5,6]]) p obj[0,0] # => 1 p obj[1,0] # => 4 p obj[2,0] # => WIN32OLERuntimeError p obj[0, -1] # => WIN32OLERuntimeError ;T;[o;= ;>I" overload;F;?0;;;@0;:I"[](i,j,...);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"i;T0[I"j;T0[I"...;T0;$@;![;"I"Returns the element of WIN32OLE_VARIANT object(OLE array). This method is available only when the variant type of WIN32OLE_VARIANT object is VT_ARRAY. REMARK: The all indices should be 0 or natural number and lower than or equal to max indices. (This point is different with Ruby Array indices.) obj = WIN32OLE_VARIANT.new([[1,2,3],[4,5,6]]) p obj[0,0] # => 1 p obj[1,0] # => 4 p obj[2,0] # => WIN32OLERuntimeError p obj[0, -1] # => WIN32OLERuntimeError @overload [](i,j,...);T;#0;$@;.F;/o;0;1T;2i;3i;%@9;9I"static VALUE folevariant_ary_aref(int argc, VALUE *argv, VALUE self) { struct olevariantdata *pvar; SAFEARRAY *psa; VALUE val = Qnil; VARIANT variant; LONG *pid; HRESULT hr; TypedData_Get_Struct(self, struct olevariantdata, &olevariant_datatype, pvar); if (!V_ISARRAY(&(pvar->var))) { rb_raise(eWIN32OLERuntimeError, "`[]' is not available for this variant type object"); } psa = get_locked_safe_array(self); if (psa == NULL) { return val; } pid = ary2safe_array_index(argc, argv, psa); VariantInit(&variant); V_VT(&variant) = (V_VT(&(pvar->var)) & ~VT_ARRAY) | VT_BYREF; hr = SafeArrayPtrOfIndex(psa, pid, &V_BYREF(&variant)); if (FAILED(hr)) { ole_raise(hr, eWIN32OLERuntimeError, "failed to SafeArrayPtrOfIndex"); } val = ole_variant2val(&variant); unlock_safe_array(psa); if (pid) free(pid); return val; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_VARIANT#[]=;F;7[[@90;[[@Di/;T;;8;0;[;{;IC; "Set the element of WIN32OLE_VARIANT object(OLE array) to val. This method is available only when the variant type of WIN32OLE_VARIANT object is VT_ARRAY. REMARK: The all indices should be 0 or natural number and lower than or equal to max indices. (This point is different with Ruby Array indices.) obj = WIN32OLE_VARIANT.new([[1,2,3],[4,5,6]]) obj[0,0] = 7 obj[1,0] = 8 p obj.value # => [[7,2,3], [8,5,6]] obj[2,0] = 9 # => WIN32OLERuntimeError obj[0, -1] = 9 # => WIN32OLERuntimeError ;T;[o;= ;>I" overload;F;?0;;8;@0;:I"[]=(i,j,...);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"i;T0[I"j;T0[I"...;T0;$@;![;"I"Set the element of WIN32OLE_VARIANT object(OLE array) to val. This method is available only when the variant type of WIN32OLE_VARIANT object is VT_ARRAY. REMARK: The all indices should be 0 or natural number and lower than or equal to max indices. (This point is different with Ruby Array indices.) obj = WIN32OLE_VARIANT.new([[1,2,3],[4,5,6]]) obj[0,0] = 7 obj[1,0] = 8 p obj.value # => [[7,2,3], [8,5,6]] obj[2,0] = 9 # => WIN32OLERuntimeError obj[0, -1] = 9 # => WIN32OLERuntimeError @overload []=(i,j,...);T;#0;$@;.F;/o;0;1T;2i;3i,;%@9;9I"static VALUE folevariant_ary_aset(int argc, VALUE *argv, VALUE self) { struct olevariantdata *pvar; SAFEARRAY *psa; VARIANT var; VARTYPE vt; LONG *pid; HRESULT hr; VOID *p = NULL; TypedData_Get_Struct(self, struct olevariantdata, &olevariant_datatype, pvar); if (!V_ISARRAY(&(pvar->var))) { rb_raise(eWIN32OLERuntimeError, "`[]' is not available for this variant type object"); } psa = get_locked_safe_array(self); if (psa == NULL) { rb_raise(rb_eRuntimeError, "failed to get SafeArray pointer"); } pid = ary2safe_array_index(argc-1, argv, psa); VariantInit(&var); vt = (V_VT(&(pvar->var)) & ~VT_ARRAY); p = val2variant_ptr(argv[argc-1], &var, vt); if ((V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == NULL) || (V_VT(&var) == VT_UNKNOWN && V_UNKNOWN(&var) == NULL)) { rb_raise(eWIN32OLERuntimeError, "argument does not have IDispatch or IUnknown Interface"); } hr = SafeArrayPutElement(psa, pid, p); if (FAILED(hr)) { ole_raise(hr, eWIN32OLERuntimeError, "failed to SafeArrayPutElement"); } unlock_safe_array(psa); if (pid) free(pid); return argv[argc-1]; };T;:I"static VALUE;T;;To;u;[[@Di;F;: Empty;;w;;;[;{;IC; "$represents VT_EMPTY OLE object. ;T;[;![;"I"%represents VT_EMPTY OLE object. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@9;&I"WIN32OLE_VARIANT::Empty;F;xI"Srb_funcall(cWIN32OLE_VARIANT, rb_intern("new"), 2, Qnil, RB_INT2FIX(VT_EMPTY));To;u;[[@Di;F;: Null;;w;;;[;{;IC; "#represents VT_NULL OLE object. ;T;[;![;"I"$represents VT_NULL OLE object. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@9;&I"WIN32OLE_VARIANT::Null;F;xI"Rrb_funcall(cWIN32OLE_VARIANT, rb_intern("new"), 2, Qnil, RB_INT2FIX(VT_NULL));To;u;[[@Di;F;: Nothing;;w;;;[;{;IC; "(represents Nothing of VB.NET or VB. ;T;[;![;"I")represents Nothing of VB.NET or VB. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@9;&I"WIN32OLE_VARIANT::Nothing;F;xI"Vrb_funcall(cWIN32OLE_VARIANT, rb_intern("new"), 2, Qnil, RB_INT2FIX(VT_DISPATCH));To;u;[[@Di;F;: NoParam;;w;;;[;{;IC; ":NoParam, false) ;T;[;![;"I":NoParam, false) ;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@9;&I"WIN32OLE_VARIANT::NoParam;F;xI"represents VT_ERROR variant with DISP_E_PARAMNOTFOUND. This constants is used for not specified parameter. fso = WIN32OLE.new("Scripting.FileSystemObject") fso.openTextFile(filename, WIN32OLE_VARIANT;T; @9; IC;[; @9; IC;[; @9; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Din[@Di;T;:WIN32OLE_VARIANT;;;;;[;{;IC; "DWIN32OLE_VARIANT objects represents OLE variant. Win32OLE converts Ruby object into OLE variant automatically when invoking OLE methods. If OLE method requires the argument which is different from the variant by automatic conversion of Win32OLE, you can convert the specified variant type by using WIN32OLE_VARIANT class. param = WIN32OLE_VARIANT.new(10, WIN32OLE::VARIANT::VT_R4) oleobj.method(param) WIN32OLE_VARIANT does not support VT_RECORD variant. Use WIN32OLE_RECORD class instead of WIN32OLE_VARIANT if the VT_RECORD variant is needed.;T;[;![;"I"H WIN32OLE_VARIANT objects represents OLE variant. Win32OLE converts Ruby object into OLE variant automatically when invoking OLE methods. If OLE method requires the argument which is different from the variant by automatic conversion of Win32OLE, you can convert the specified variant type by using WIN32OLE_VARIANT class. param = WIN32OLE_VARIANT.new(10, WIN32OLE::VARIANT::VT_R4) oleobj.method(param) WIN32OLE_VARIANT does not support VT_RECORD variant. Use WIN32OLE_RECORD class instead of WIN32OLE_VARIANT if the VT_RECORD variant is needed. ;T;#0;$@9;.F;/o;0;1T;2in;3i{;Bi;%@;&I"WIN32OLE_VARIANT;F;'@o; ;IC;[ o;4;5F;6;;;;&I"WIN32OLE_RECORD#initialize;F;7[[I" typename;T0[I" oleobj;T0;[[I"#ext/win32ole/win32ole_record.c;Ti;T;;D;0;[;{;IC; "Returns WIN32OLE_RECORD object. The first argument is struct name (String or Symbol). The second parameter obj should be WIN32OLE object or WIN32OLE_TYPELIB object. If COM server in VB.NET ComServer project is the following: Imports System.Runtime.InteropServices Public Class ComClass Public Structure Book _ Public title As String Public cost As Integer End Structure End Class then, you can create WIN32OLE_RECORD object is as following: require 'win32ole' obj = WIN32OLE.new('ComServer.ComClass') book1 = WIN32OLE_RECORD.new('Book', obj) # => WIN32OLE_RECORD object tlib = obj.ole_typelib book2 = WIN32OLE_RECORD.new('Book', tlib) # => WIN32OLE_RECORD object ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(typename, obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"WIN32OLE_RECORD object;T;$@*;![;"I"%@return [WIN32OLE_RECORD object];T;#0;$@*;.F;Bi;C0;7[[I" typename;T0[I"obj;T0;$@*;![;"I"6Returns WIN32OLE_RECORD object. The first argument is struct name (String or Symbol). The second parameter obj should be WIN32OLE object or WIN32OLE_TYPELIB object. If COM server in VB.NET ComServer project is the following: Imports System.Runtime.InteropServices Public Class ComClass Public Structure Book _ Public title As String Public cost As Integer End Structure End Class then, you can create WIN32OLE_RECORD object is as following: require 'win32ole' obj = WIN32OLE.new('ComServer.ComClass') book1 = WIN32OLE_RECORD.new('Book', obj) # => WIN32OLE_RECORD object tlib = obj.ole_typelib book2 = WIN32OLE_RECORD.new('Book', tlib) # => WIN32OLE_RECORD object @overload new(typename, obj) @return [WIN32OLE_RECORD object];T;#0;$@*;.F;/o;0;1T;2i;3i;%@(;9I"static VALUE folerecord_initialize(VALUE self, VALUE typename, VALUE oleobj) { HRESULT hr; ITypeLib *pTypeLib = NULL; IRecordInfo *pri = NULL; if (!RB_TYPE_P(typename, T_STRING) && !RB_TYPE_P(typename, T_SYMBOL)) { rb_raise(rb_eArgError, "1st argument should be String or Symbol"); } if (RB_TYPE_P(typename, T_SYMBOL)) { typename = rb_sym2str(typename); } hr = S_OK; if(rb_obj_is_kind_of(oleobj, cWIN32OLE)) { hr = typelib_from_val(oleobj, &pTypeLib); } else if (rb_obj_is_kind_of(oleobj, cWIN32OLE_TYPELIB)) { pTypeLib = itypelib(oleobj); OLE_ADDREF(pTypeLib); if (pTypeLib) { hr = S_OK; } else { hr = E_FAIL; } } else { rb_raise(rb_eArgError, "2nd argument should be WIN32OLE object or WIN32OLE_TYPELIB object"); } if (FAILED(hr)) { ole_raise(hr, eWIN32OLERuntimeError, "fail to query ITypeLib interface"); } hr = recordinfo_from_itypelib(pTypeLib, typename, &pri); OLE_RELEASE(pTypeLib); if (FAILED(hr)) { ole_raise(hr, eWIN32OLERuntimeError, "fail to query IRecordInfo interface for `%s'", StringValuePtr(typename)); } olerecord_set_ivar(self, pri, NULL); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_RECORD#to_h;F;7[;[[@3ie;T;;;0;[;{;IC; "yReturns Ruby Hash object which represents VT_RECORD variable. The keys of Hash object are member names of VT_RECORD OLE variable and the values of Hash object are values of VT_RECORD OLE variable. If COM server in VB.NET ComServer project is the following: Imports System.Runtime.InteropServices Public Class ComClass Public Structure Book _ Public title As String Public cost As Integer End Structure Public Function getBook() As Book Dim book As New Book book.title = "The Ruby Book" book.cost = 20 Return book End Function End Class then, the result of WIN32OLE_RECORD#to_h is the following: require 'win32ole' obj = WIN32OLE.new('ComServer.ComClass') book = obj.getBook book.to_h # => {"title"=>"The Ruby Book", "cost"=>20} ;T;[;![;"I"} Returns Ruby Hash object which represents VT_RECORD variable. The keys of Hash object are member names of VT_RECORD OLE variable and the values of Hash object are values of VT_RECORD OLE variable. If COM server in VB.NET ComServer project is the following: Imports System.Runtime.InteropServices Public Class ComClass Public Structure Book _ Public title As String Public cost As Integer End Structure Public Function getBook() As Book Dim book As New Book book.title = "The Ruby Book" book.cost = 20 Return book End Function End Class then, the result of WIN32OLE_RECORD#to_h is the following: require 'win32ole' obj = WIN32OLE.new('ComServer.ComClass') book = obj.getBook book.to_h # => {"title"=>"The Ruby Book", "cost"=>20} ;T;#0;$@N;.F;/o;0;1T;2iD;3ib;%@(;9I"dstatic VALUE folerecord_to_h(VALUE self) { return rb_ivar_get(self, rb_intern("fields")); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_RECORD#typename;F;7[;[[@3i;T;: typename;0;[;{;IC; "Returns the type name of VT_RECORD OLE variable. If COM server in VB.NET ComServer project is the following: Imports System.Runtime.InteropServices Public Class ComClass Public Structure Book _ Public title As String Public cost As Integer End Structure Public Function getBook() As Book Dim book As New Book book.title = "The Ruby Book" book.cost = 20 Return book End Function End Class then, the result of WIN32OLE_RECORD#typename is the following: require 'win32ole' obj = WIN32OLE.new('ComServer.ComClass') book = obj.getBook book.typename # => "Book" ;T;[;![;"I" Returns the type name of VT_RECORD OLE variable. If COM server in VB.NET ComServer project is the following: Imports System.Runtime.InteropServices Public Class ComClass Public Structure Book _ Public title As String Public cost As Integer End Structure Public Function getBook() As Book Dim book As New Book book.title = "The Ruby Book" book.cost = 20 Return book End Function End Class then, the result of WIN32OLE_RECORD#typename is the following: require 'win32ole' obj = WIN32OLE.new('ComServer.ComClass') book = obj.getBook book.typename # => "Book" ;T;#0;$@\;.F;/o;0;1T;2ik;3i;%@(;9I"jstatic VALUE folerecord_typename(VALUE self) { return rb_ivar_get(self, rb_intern("typename")); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#WIN32OLE_RECORD#method_missing;F;7[[@90;[[@3i;T;;;0;[;{;IC; "!Returns value specified by the member name of VT_RECORD OLE variable. Or sets value specified by the member name of VT_RECORD OLE variable. If the member name is not correct, KeyError exception is raised. If COM server in VB.NET ComServer project is the following: Imports System.Runtime.InteropServices Public Class ComClass Public Structure Book _ Public title As String Public cost As Integer End Structure End Class Then getting/setting value from Ruby is as the following: obj = WIN32OLE.new('ComServer.ComClass') book = WIN32OLE_RECORD.new('Book', obj) book.title # => nil ( book.method_missing(:title) is invoked. ) book.title = "Ruby" # ( book.method_missing(:title=, "Ruby") is invoked. ) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"method_missing(name);T;IC; ";T;[;![;"I";T;#0;$@j;.F;Bi;C0;7[[I" name;T0;$@j;![;"I"BReturns value specified by the member name of VT_RECORD OLE variable. Or sets value specified by the member name of VT_RECORD OLE variable. If the member name is not correct, KeyError exception is raised. If COM server in VB.NET ComServer project is the following: Imports System.Runtime.InteropServices Public Class ComClass Public Structure Book _ Public title As String Public cost As Integer End Structure End Class Then getting/setting value from Ruby is as the following: obj = WIN32OLE.new('ComServer.ComClass') book = WIN32OLE_RECORD.new('Book', obj) book.title # => nil ( book.method_missing(:title) is invoked. ) book.title = "Ruby" # ( book.method_missing(:title=, "Ruby") is invoked. ) @overload method_missing(name);T;#0;$@j;.F;/o;0;1T;2i;3i;%@(;9I"static VALUE folerecord_method_missing(int argc, VALUE *argv, VALUE self) { VALUE name; rb_check_arity(argc, 1, 2); name = rb_sym2str(argv[0]); #if SIZEOF_SIZE_T > SIZEOF_LONG { size_t n = strlen(StringValueCStr(name)); if (n >= LONG_MAX) { rb_raise(rb_eRuntimeError, "too long member name"); } } #endif if (argc == 1) { return olerecord_ivar_get(self, name); } else if (argc == 2) { return olerecord_ivar_set(self, name, argv[1]); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I".WIN32OLE_RECORD#ole_instance_variable_get;F;7[[I" name;T0;[[@3i;T;:ole_instance_variable_get;0;[;{;IC; "Returns value specified by the member name of VT_RECORD OLE object. If the member name is not correct, KeyError exception is raised. If you can't access member variable of VT_RECORD OLE object directly, use this method. If COM server in VB.NET ComServer project is the following: Imports System.Runtime.InteropServices Public Class ComClass Public Structure ComObject Public object_id As Ineger End Structure End Class and Ruby Object class has title attribute: then accessing object_id of ComObject from Ruby is as the following: srver = WIN32OLE.new('ComServer.ComClass') obj = WIN32OLE_RECORD.new('ComObject', server) # obj.object_id returns Ruby Object#object_id obj.ole_instance_variable_get(:object_id) # => nil ;T;[o;= ;>I" overload;F;?0;;d;@0;:I"$ole_instance_variable_get(name);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" name;T0;$@;![;"I"-Returns value specified by the member name of VT_RECORD OLE object. If the member name is not correct, KeyError exception is raised. If you can't access member variable of VT_RECORD OLE object directly, use this method. If COM server in VB.NET ComServer project is the following: Imports System.Runtime.InteropServices Public Class ComClass Public Structure ComObject Public object_id As Ineger End Structure End Class and Ruby Object class has title attribute: then accessing object_id of ComObject from Ruby is as the following: srver = WIN32OLE.new('ComServer.ComClass') obj = WIN32OLE_RECORD.new('ComObject', server) # obj.object_id returns Ruby Object#object_id obj.ole_instance_variable_get(:object_id) # => nil @overload ole_instance_variable_get(name);T;#0;$@;.F;/o;0;1T;2i;3i;%@(;9I"static VALUE folerecord_ole_instance_variable_get(VALUE self, VALUE name) { VALUE sname; if(!RB_TYPE_P(name, T_STRING) && !RB_TYPE_P(name, T_SYMBOL)) { rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)"); } sname = name; if (RB_TYPE_P(name, T_SYMBOL)) { sname = rb_sym2str(name); } return olerecord_ivar_get(self, sname); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I".WIN32OLE_RECORD#ole_instance_variable_set;F;7[[I" name;T0[I"val;T0;[[@3i;T;:ole_instance_variable_set;0;[;{;IC; "Sets value specified by the member name of VT_RECORD OLE object. If the member name is not correct, KeyError exception is raised. If you can't set value of member of VT_RECORD OLE object directly, use this method. If COM server in VB.NET ComServer project is the following: Imports System.Runtime.InteropServices Public Class ComClass _ Public title As String Public cost As Integer End Class then setting value of the `title' member is as following: srver = WIN32OLE.new('ComServer.ComClass') obj = WIN32OLE_RECORD.new('Book', server) obj.ole_instance_variable_set(:title, "The Ruby Book") ;T;[o;= ;>I" overload;F;?0;;e;@0;:I")ole_instance_variable_set(name, val);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" name;T0[I"val;T0;$@;![;"I"Sets value specified by the member name of VT_RECORD OLE object. If the member name is not correct, KeyError exception is raised. If you can't set value of member of VT_RECORD OLE object directly, use this method. If COM server in VB.NET ComServer project is the following: Imports System.Runtime.InteropServices Public Class ComClass _ Public title As String Public cost As Integer End Class then setting value of the `title' member is as following: srver = WIN32OLE.new('ComServer.ComClass') obj = WIN32OLE_RECORD.new('Book', server) obj.ole_instance_variable_set(:title, "The Ruby Book") @overload ole_instance_variable_set(name, val);T;#0;$@;.F;/o;0;1T;2i;3i;%@(;9I"static VALUE folerecord_ole_instance_variable_set(VALUE self, VALUE name, VALUE val) { VALUE sname; if(!RB_TYPE_P(name, T_STRING) && !RB_TYPE_P(name, T_SYMBOL)) { rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)"); } sname = name; if (RB_TYPE_P(name, T_SYMBOL)) { sname = rb_sym2str(name); } return olerecord_ivar_set(self, sname, val); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_RECORD#inspect;F;7[;[[@3iA;T;;J;0;[;{;IC; "Returns the OLE struct name and member name and the value of member If COM server in VB.NET ComServer project is the following: Imports System.Runtime.InteropServices Public Class ComClass _ Public title As String Public cost As Integer End Class then srver = WIN32OLE.new('ComServer.ComClass') obj = WIN32OLE_RECORD.new('Book', server) obj.inspect # => nil, "cost" => nil}> ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the OLE struct name and member name and the value of member If COM server in VB.NET ComServer project is the following: Imports System.Runtime.InteropServices Public Class ComClass _ Public title As String Public cost As Integer End Class then srver = WIN32OLE.new('ComServer.ComClass') obj = WIN32OLE_RECORD.new('Book', server) obj.inspect # => nil, "cost" => nil}> @overload inspect @return [String];T;#0;$@;.F;/o;0;1T;2i+;3i?;%@(;9I"kstatic VALUE folerecord_inspect(VALUE self) { VALUE tname; VALUE field; tname = folerecord_typename(self); if (tname == Qnil) { tname = rb_inspect(tname); } field = rb_inspect(folerecord_to_h(self)); return rb_sprintf("#", tname, field); };T;:I"static VALUE;T;;T; @(; IC;[; @(; IC;[; @(; IC;{;IC;{;T;IC;{;T;T;{;[;[[@3i[@3iU;T;:WIN32OLE_RECORD;;;;;[;{;IC; "WIN32OLE_RECORD objects represents VT_RECORD OLE variant. Win32OLE returns WIN32OLE_RECORD object if the result value of invoking OLE methods. If COM server in VB.NET ComServer project is the following: Imports System.Runtime.InteropServices Public Class ComClass Public Structure Book _ Public title As String Public cost As Integer End Structure Public Function getBook() As Book Dim book As New Book book.title = "The Ruby Book" book.cost = 20 Return book End Function End Class then, you can retrieve getBook return value from the following Ruby script: require 'win32ole' obj = WIN32OLE.new('ComServer.ComClass') book = obj.getBook book.class # => WIN32OLE_RECORD book.title # => "The Ruby Book" book.cost # => 20;T;[;![;"I" WIN32OLE_RECORD objects represents VT_RECORD OLE variant. Win32OLE returns WIN32OLE_RECORD object if the result value of invoking OLE methods. If COM server in VB.NET ComServer project is the following: Imports System.Runtime.InteropServices Public Class ComClass Public Structure Book _ Public title As String Public cost As Integer End Structure Public Function getBook() As Book Dim book As New Book book.title = "The Ruby Book" book.cost = 20 Return book End Function End Class then, you can retrieve getBook return value from the following Ruby script: require 'win32ole' obj = WIN32OLE.new('ComServer.ComClass') book = obj.getBook book.class # => WIN32OLE_RECORD book.title # => "The Ruby Book" book.cost # => 20 ;T;#0;$@(;.F;/o;0;1T;2i;3i;Bi;%@;&I"WIN32OLE_RECORD;F;'@o; ;IC;[o;4;5F;6;;;;&I"WIN32OLE_METHOD#initialize;F;7[[I" oletype;T0[I" method;T0;[[I"#ext/win32ole/win32ole_method.c;Ti ;T;;D;0;[;{;IC; "Returns a new WIN32OLE_METHOD object which represents the information about OLE method. The first argument ole_type specifies WIN32OLE_TYPE object. The second argument method specifies OLE method name defined OLE class which represents WIN32OLE_TYPE object. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(ole_type, method);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"WIN32OLE_METHOD object;T;$@;![;"I"%@return [WIN32OLE_METHOD object];T;#0;$@;.F;Bi;C0;7[[I" ole_type;T0[I" method;T0;$@;![;"I"Returns a new WIN32OLE_METHOD object which represents the information about OLE method. The first argument ole_type specifies WIN32OLE_TYPE object. The second argument method specifies OLE method name defined OLE class which represents WIN32OLE_TYPE object. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') @overload new(ole_type, method) @return [WIN32OLE_METHOD object];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"Dstatic VALUE folemethod_initialize(VALUE self, VALUE oletype, VALUE method) { VALUE obj = Qnil; ITypeInfo *pTypeInfo; if (rb_obj_is_kind_of(oletype, cWIN32OLE_TYPE)) { SafeStringValue(method); pTypeInfo = itypeinfo(oletype); obj = olemethod_from_typeinfo(self, pTypeInfo, method); if (obj == Qnil) { rb_raise(eWIN32OLERuntimeError, "not found %s", StringValuePtr(method)); } } else { rb_raise(rb_eTypeError, "1st argument should be WIN32OLE_TYPE object"); } return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_METHOD#name;F;7[;[[@i(;T;;F;0;[;{;IC; "Returns the name of the method. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') puts method.name # => SaveAs ;T;[o;= ;>I" overload;F;?0;;F;@0;:I" name;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the name of the method. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') puts method.name # => SaveAs @overload name;T;#0;$o;4;5F;6;;;;&I"WIN32OLE_METHOD#to_s;F;7[;[[@i;F;;G;;;[;{;@;%@;9I"bstatic VALUE folemethod_name(VALUE self) { return rb_ivar_get(self, rb_intern("name")); };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i%;%@;9I"bstatic VALUE folemethod_name(VALUE self) { return rb_ivar_get(self, rb_intern("name")); };T;:@);;To;4;5F;6;;;;&I" WIN32OLE_METHOD#return_type;F;7[;[[@iH;T;:return_type;0;[;{;IC; "Returns string of return value type of method. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.return_type # => Workbook ;T;[o;= ;>I" overload;F;?0;;g;@0;:I"return_type;T;IC; ";T;[;![;"I";T;#0;$@,;.F;Bi;C0;7[;$@,;![;"I"Returns string of return value type of method. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.return_type # => Workbook @overload return_type;T;#0;$@,;.F;/o;0;1T;2i>;3iE;%@;9I"static VALUE folemethod_return_type(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_return_type(pmethod->pTypeInfo, pmethod->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!WIN32OLE_METHOD#return_vtype;F;7[;[[@ij;T;:return_vtype;0;[;{;IC; "Returns number of return value type of method. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.return_vtype # => 26 ;T;[o;= ;>I" overload;F;?0;;h;@0;:I"return_vtype;T;IC; ";T;[;![;"I";T;#0;$@B;.F;Bi;C0;7[;$@B;![;"I"Returns number of return value type of method. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.return_vtype # => 26 @overload return_vtype;T;#0;$@B;.F;/o;0;1T;2i`;3ig;%@;9I"static VALUE folemethod_return_vtype(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_return_vtype(pmethod->pTypeInfo, pmethod->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'WIN32OLE_METHOD#return_type_detail;F;7[;[[@i;T;:return_type_detail;0;[;{;IC; "Returns detail information of return value type of method. The information is array. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') p method.return_type_detail # => ["PTR", "USERDEFINED", "Workbook"] ;T;[o;= ;>I" overload;F;?0;;i;@0;:I"return_type_detail;T;IC; ";T;[;![;"I";T;#0;$@X;.F;Bi;C0;7[;$@X;![;"I"6Returns detail information of return value type of method. The information is array. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') p method.return_type_detail # => ["PTR", "USERDEFINED", "Workbook"] @overload return_type_detail;T;#0;$@X;.F;/o;0;1T;2i;3i;%@;9I"static VALUE folemethod_return_type_detail(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_return_type_detail(pmethod->pTypeInfo, pmethod->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" WIN32OLE_METHOD#invoke_kind;F;7[;[[@i;T;:invoke_kind;0;[;{;IC; "8Returns the method kind string. The string is "UNKNOWN" or "PROPERTY" or "PROPERTY" or "PROPERTYGET" or "PROPERTYPUT" or "PROPERTYPPUTREF" or "FUNC". tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.invoke_kind # => "FUNC" ;T;[o;= ;>I" overload;F;?0;;j;@0;:I"invoke_kind;T;IC; ";T;[;![;"I";T;#0;$@n;.F;Bi;C0;7[;$@n;![;"I"PReturns the method kind string. The string is "UNKNOWN" or "PROPERTY" or "PROPERTY" or "PROPERTYGET" or "PROPERTYPUT" or "PROPERTYPPUTREF" or "FUNC". tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.invoke_kind # => "FUNC" @overload invoke_kind;T;#0;$@n;.F;/o;0;1T;2i;3i;%@;9I"static VALUE folemethod_invoke_kind(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_invoke_kind(pmethod->pTypeInfo, pmethod->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_METHOD#invkind;F;7[;[[@i;T;: invkind;0;[;{;IC; "Returns the method invoke kind. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.invkind # => 1 ;T;[o;= ;>I" overload;F;?0;;k;@0;:I" invkind;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the method invoke kind. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.invkind # => 1 @overload invkind;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE folemethod_invkind(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_invkind(pmethod->pTypeInfo, pmethod->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_METHOD#visible?;F;7[;[[@i;T;;E;0;[;{;IC; "Returns true if the method is public. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.visible? # => true;T;[o;= ;>I" overload;F;?0;;E;@0;:I" visible?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"Returns true if the method is public. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.visible? # => true @overload visible?;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE folemethod_visible(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_visible(pmethod->pTypeInfo, pmethod->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_METHOD#event?;F;7[;[[@iJ;T;: event?;0;[;{;IC; "Returns true if the method is event. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SheetActivate') puts method.event? # => true;T;[o;= ;>I" overload;F;?0;;l;@0;:I" event?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"Returns true if the method is event. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SheetActivate') puts method.event? # => true @overload event?;T;#0;$@;.F;/o;0;1T;2i@;3iG;Bi;%@;9I"static VALUE folemethod_event(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); if (!pmethod->pOwnerTypeInfo) return Qfalse; return ole_method_event(pmethod->pOwnerTypeInfo, pmethod->index, rb_ivar_get(self, rb_intern("name"))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$WIN32OLE_METHOD#event_interface;F;7[;[[@i_;T;:event_interface;0;[;{;IC; "Returns event interface name if the method is event. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SheetActivate') puts method.event_interface # => WorkbookEvents ;T;[o;= ;>I" overload;F;?0;;m;@0;:I"event_interface;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns event interface name if the method is event. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SheetActivate') puts method.event_interface # => WorkbookEvents @overload event_interface;T;#0;$@;.F;/o;0;1T;2iV;3i\;%@;9I"static VALUE folemethod_event_interface(VALUE self) { BSTR name; struct olemethoddata *pmethod; HRESULT hr; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); if(folemethod_event(self) == Qtrue) { hr = ole_docinfo_from_type(pmethod->pTypeInfo, &name, NULL, NULL, NULL); if(SUCCEEDED(hr)) return WC2VSTR(name); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_METHOD#helpstring;F;7[;[[@i;T;;I;0;[;{;IC; "Returns help string of OLE method. If the help string is not found, then the method returns nil. tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'IWebBrowser') method = WIN32OLE_METHOD.new(tobj, 'Navigate') puts method.helpstring # => Navigates to a URL or file. ;T;[o;= ;>I" overload;F;?0;;I;@0;:I"helpstring;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"/Returns help string of OLE method. If the help string is not found, then the method returns nil. tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'IWebBrowser') method = WIN32OLE_METHOD.new(tobj, 'Navigate') puts method.helpstring # => Navigates to a URL or file. @overload helpstring;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE folemethod_helpstring(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_helpstring(pmethod->pTypeInfo, pmethod->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_METHOD#helpfile;F;7[;[[@i;T;;K;0;[;{;IC; "Returns help file. If help file is not found, then the method returns nil. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.helpfile # => C:\...\VBAXL9.CHM ;T;[o;= ;>I" overload;F;?0;;K;@0;:I" helpfile;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I" Returns help file. If help file is not found, then the method returns nil. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.helpfile # => C:\...\VBAXL9.CHM @overload helpfile;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE folemethod_helpfile(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_helpfile(pmethod->pTypeInfo, pmethod->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" WIN32OLE_METHOD#helpcontext;F;7[;[[@i;T;;L;0;[;{;IC; "Returns help context. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.helpcontext # => 65717 ;T;[o;= ;>I" overload;F;?0;;L;@0;:I"helpcontext;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns help context. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.helpcontext # => 65717 @overload helpcontext;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE folemethod_helpcontext(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_helpcontext(pmethod->pTypeInfo, pmethod->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_METHOD#dispid;F;7[;[[@i;T;: dispid;0;[;{;IC; "Returns dispatch ID. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.dispid # => 181 ;T;[o;= ;>I" overload;F;?0;;n;@0;:I" dispid;T;IC; ";T;[;![;"I";T;#0;$@$;.F;Bi;C0;7[;$@$;![;"I"Returns dispatch ID. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.dispid # => 181 @overload dispid;T;#0;$@$;.F;/o;0;1T;2i;3i;%@;9I"static VALUE folemethod_dispid(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_dispid(pmethod->pTypeInfo, pmethod->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" WIN32OLE_METHOD#offset_vtbl;F;7[;[[@i;T;:offset_vtbl;0;[;{;IC; "Returns the offset ov VTBL. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.offset_vtbl # => 40 ;T;[o;= ;>I" overload;F;?0;;o;@0;:I"offset_vtbl;T;IC; ";T;[;![;"I";T;#0;$@:;.F;Bi;C0;7[;$@:;![;"I"Returns the offset ov VTBL. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.offset_vtbl # => 40 @overload offset_vtbl;T;#0;$@:;.F;/o;0;1T;2i ;3i;%@;9I"static VALUE folemethod_offset_vtbl(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_offset_vtbl(pmethod->pTypeInfo, pmethod->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" WIN32OLE_METHOD#size_params;F;7[;[[@i5;T;:size_params;0;[;{;IC; "Returns the size of arguments of the method. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') puts method.size_params # => 11 ;T;[o;= ;>I" overload;F;?0;;p;@0;:I"size_params;T;IC; ";T;[;![;"I";T;#0;$@P;.F;Bi;C0;7[;$@P;![;"I"Returns the size of arguments of the method. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') puts method.size_params # => 11 @overload size_params;T;#0;$@P;.F;/o;0;1T;2i+;3i2;%@;9I"static VALUE folemethod_size_params(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_size_params(pmethod->pTypeInfo, pmethod->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$WIN32OLE_METHOD#size_opt_params;F;7[;[[@iT;T;:size_opt_params;0;[;{;IC; "Returns the size of optional parameters. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') puts method.size_opt_params # => 4 ;T;[o;= ;>I" overload;F;?0;;q;@0;:I"size_opt_params;T;IC; ";T;[;![;"I";T;#0;$@f;.F;Bi;C0;7[;$@f;![;"I"Returns the size of optional parameters. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') puts method.size_opt_params # => 4 @overload size_opt_params;T;#0;$@f;.F;/o;0;1T;2iK;3iQ;%@;9I"static VALUE folemethod_size_opt_params(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_size_opt_params(pmethod->pTypeInfo, pmethod->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_METHOD#params;F;7[;[[@i;T;;;0;[;{;IC; "returns array of WIN32OLE_PARAM object corresponding with method parameters. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') p method.params # => [Filename, FileFormat, Password, WriteResPassword, ReadOnlyRecommended, CreateBackup, AccessMode, ConflictResolution, AddToMru, TextCodepage, TextVisualLayout] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" params;T;IC; ";T;[;![;"I";T;#0;$@|;.F;Bi;C0;7[;$@|;![;"I"returns array of WIN32OLE_PARAM object corresponding with method parameters. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') p method.params # => [Filename, FileFormat, Password, WriteResPassword, ReadOnlyRecommended, CreateBackup, AccessMode, ConflictResolution, AddToMru, TextCodepage, TextVisualLayout] @overload params;T;#0;$@|;.F;/o;0;1T;2i};3i;%@;9I"static VALUE folemethod_params(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_params(pmethod->pTypeInfo, pmethod->index); };T;:I"static VALUE;T;;T@!o;4;5F;6;;;;&I"WIN32OLE_METHOD#inspect;F;7[;[[@i;T;;J;0;[;{;IC; "-Returns the method name with class name. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"UReturns the method name with class name. @overload inspect @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"istatic VALUE folemethod_inspect(VALUE self) { return default_inspect(self, "WIN32OLE_METHOD"); };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{@!;F;[;[[@i[@i;T;:WIN32OLE_METHOD;;;;;[;{;IC; "KWIN32OLE_METHOD objects represent OLE method information.;T;[;![;"I"O WIN32OLE_METHOD objects represent OLE method information. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;&I"WIN32OLE_METHOD;F;'@o; ;IC;[o;4;5F;6;;;;&I"WIN32OLE_TYPELIB.typelibs;F;7[;[[I"$ext/win32ole/win32ole_typelib.c;Ti;T;;@;0;[;{;IC; "XReturns the array of WIN32OLE_TYPELIB object. tlibs = WIN32OLE_TYPELIB.typelibs ;T;[o;= ;>I" overload;F;?0;;@;@0;:I" typelibs;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"nReturns the array of WIN32OLE_TYPELIB object. tlibs = WIN32OLE_TYPELIB.typelibs @overload typelibs;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE foletypelib_s_typelibs(VALUE self) { HKEY htypelib, hguid; DWORD i, j; LONG err; VALUE guid; VALUE version; VALUE name = Qnil; VALUE typelibs = rb_ary_new(); VALUE typelib = Qnil; HRESULT hr; ITypeLib *pTypeLib; err = reg_open_key(HKEY_CLASSES_ROOT, "TypeLib", &htypelib); if(err != ERROR_SUCCESS) { return typelibs; } for(i = 0; ; i++) { guid = reg_enum_key(htypelib, i); if (guid == Qnil) break; err = reg_open_vkey(htypelib, guid, &hguid); if (err != ERROR_SUCCESS) continue; for(j = 0; ; j++) { version = reg_enum_key(hguid, j); if (version == Qnil) break; if ( (name = reg_get_val2(hguid, StringValuePtr(version))) != Qnil ) { hr = oletypelib_from_guid(guid, version, &pTypeLib); if (SUCCEEDED(hr)) { typelib = create_win32ole_typelib(pTypeLib); rb_ary_push(typelibs, typelib); } } } RegCloseKey(hguid); } RegCloseKey(htypelib); return typelibs; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" WIN32OLE_TYPELIB#initialize;F;7[[I" args;T0;[[@i;T;;D;0;[;{;IC; ";Returns a new WIN32OLE_TYPELIB object. The first argument typelib specifies OLE type library name or GUID or OLE library file. The second argument is major version or version of the type library. The third argument is minor version. The second argument and third argument are optional. If the first argument is type library name, then the second and third argument are ignored. tlib1 = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') tlib2 = WIN32OLE_TYPELIB.new('{00020813-0000-0000-C000-000000000046}') tlib3 = WIN32OLE_TYPELIB.new('{00020813-0000-0000-C000-000000000046}', 1.3) tlib4 = WIN32OLE_TYPELIB.new('{00020813-0000-0000-C000-000000000046}', 1, 3) tlib5 = WIN32OLE_TYPELIB.new("C:\\WINNT\\SYSTEM32\\SHELL32.DLL") puts tlib1.name # -> 'Microsoft Excel 9.0 Object Library' puts tlib2.name # -> 'Microsoft Excel 9.0 Object Library' puts tlib3.name # -> 'Microsoft Excel 9.0 Object Library' puts tlib4.name # -> 'Microsoft Excel 9.0 Object Library' puts tlib5.name # -> 'Microsoft Shell Controls And Automation' ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"(new(typelib [, version1, version2]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"WIN32OLE_TYPELIB object;T;$@;![;"I"&@return [WIN32OLE_TYPELIB object];T;#0;$@;.F;Bi;C0;7[[I""typelib[, version1, version2];T0;$@;![;"I"Returns a new WIN32OLE_TYPELIB object. The first argument typelib specifies OLE type library name or GUID or OLE library file. The second argument is major version or version of the type library. The third argument is minor version. The second argument and third argument are optional. If the first argument is type library name, then the second and third argument are ignored. tlib1 = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') tlib2 = WIN32OLE_TYPELIB.new('{00020813-0000-0000-C000-000000000046}') tlib3 = WIN32OLE_TYPELIB.new('{00020813-0000-0000-C000-000000000046}', 1.3) tlib4 = WIN32OLE_TYPELIB.new('{00020813-0000-0000-C000-000000000046}', 1, 3) tlib5 = WIN32OLE_TYPELIB.new("C:\\WINNT\\SYSTEM32\\SHELL32.DLL") puts tlib1.name # -> 'Microsoft Excel 9.0 Object Library' puts tlib2.name # -> 'Microsoft Excel 9.0 Object Library' puts tlib3.name # -> 'Microsoft Excel 9.0 Object Library' puts tlib4.name # -> 'Microsoft Excel 9.0 Object Library' puts tlib5.name # -> 'Microsoft Shell Controls And Automation' @overload new(typelib [, version1, version2]) @return [WIN32OLE_TYPELIB object];T;#0;$@;.F;/o;0;1T;2im;3i;%@;9I"static VALUE foletypelib_initialize(VALUE self, VALUE args) { VALUE found = Qfalse; VALUE typelib = Qnil; int len = 0; OLECHAR * pbuf; ITypeLib *pTypeLib; HRESULT hr = S_OK; len = RARRAY_LEN(args); rb_check_arity(len, 1, 3); typelib = rb_ary_entry(args, 0); SafeStringValue(typelib); found = oletypelib_search_registry(self, typelib); if (found == Qfalse) { found = oletypelib_search_registry2(self, args); } if (found == Qfalse) { pbuf = ole_vstr2wc(typelib); hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib); SysFreeString(pbuf); if (SUCCEEDED(hr)) { found = Qtrue; oletypelib_set_member(self, pTypeLib); } } if (found == Qfalse) { rb_raise(eWIN32OLERuntimeError, "not found type library `%s`", StringValuePtr(typelib)); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPELIB#guid;F;7[;[[@i;T;;C;0;[;{;IC; "Returns guid string which specifies type library. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') guid = tlib.guid # -> '{00020813-0000-0000-C000-000000000046}' ;T;[o;= ;>I" overload;F;?0;;C;@0;:I" guid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"The guid string.;T;$@;![;"I"@return [The guid string.];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns guid string which specifies type library. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') guid = tlib.guid # -> '{00020813-0000-0000-C000-000000000046}' @overload guid @return [The guid string.];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE foletypelib_guid(VALUE self) { ITypeLib *pTypeLib; OLECHAR bstr[80]; VALUE guid = Qnil; int len; TLIBATTR *pTLibAttr; pTypeLib = itypelib(self); oletypelib_get_libattr(pTypeLib, &pTLibAttr); len = StringFromGUID2(&pTLibAttr->guid, bstr, sizeof(bstr)/sizeof(OLECHAR)); if (len > 3) { guid = ole_wc2vstr(bstr, FALSE); } pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr); return guid; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPELIB#name;F;7[;[[@i;T;;F;0;[;{;IC; "Returns the type library name. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') name = tlib.name # -> 'Microsoft Excel 9.0 Object Library' ;T;[o;= ;>I" overload;F;?0;;F;@0;:I" name;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"The type library name;T;$@;![;"I"$@return [The type library name];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the type library name. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') name = tlib.name # -> 'Microsoft Excel 9.0 Object Library' @overload name @return [The type library name];T;#0;$o;4;5F;6;;;;&I"WIN32OLE_TYPELIB#to_s;F;7[;[[@iL;F;;G;;;[;{;@;%@;9I"static VALUE foletypelib_name(VALUE self) { ITypeLib *pTypeLib; HRESULT hr; BSTR bstr; VALUE name; pTypeLib = itypelib(self); hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, -1, NULL, &bstr, NULL, NULL); if (FAILED(hr)) { ole_raise(hr, eWIN32OLERuntimeError, "failed to get name from ITypeLib"); } name = WC2VSTR(bstr); return name; };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@;9I"static VALUE foletypelib_name(VALUE self) { ITypeLib *pTypeLib; HRESULT hr; BSTR bstr; VALUE name; pTypeLib = itypelib(self); hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, -1, NULL, &bstr, NULL, NULL); if (FAILED(hr)) { ole_raise(hr, eWIN32OLERuntimeError, "failed to get name from ITypeLib"); } name = WC2VSTR(bstr); return name; };T;:@2;;To;4;5F;6;;;;&I"WIN32OLE_TYPELIB#version;F;7[;[[@i;T;;?;0;[;{;IC; "Returns the type library version. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') puts tlib.version #-> "1.3" ;T;[o;= ;>I" overload;F;?0;;?;@0;:I" version;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I",The type library version String object.;T;$@5;![;"I"6@return [The type library version String object.];T;#0;$@5;.F;Bi;C0;7[;$@5;![;"I"Returns the type library version. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') puts tlib.version #-> "1.3" @overload version @return [The type library version String object.];T;#0;$@5;.F;/o;0;1T;2i;3i;%@;9I"kstatic VALUE foletypelib_version(VALUE self) { TLIBATTR *pTLibAttr; ITypeLib *pTypeLib; VALUE version; pTypeLib = itypelib(self); oletypelib_get_libattr(pTypeLib, &pTLibAttr); version = rb_sprintf("%d.%d", pTLibAttr->wMajorVerNum, pTLibAttr->wMinorVerNum); pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr); return version; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#WIN32OLE_TYPELIB#major_version;F;7[;[[@i;T;;F;0;[;{;IC; "Returns the type library major version. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') puts tlib.major_version # -> 1 ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"major_version;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"$The type library major version.;T;$@P;![;"I".@return [The type library major version.];T;#0;$@P;.F;Bi;C0;7[;$@P;![;"I"Returns the type library major version. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') puts tlib.major_version # -> 1 @overload major_version @return [The type library major version.];T;#0;$@P;.F;/o;0;1T;2i ;3i;%@;9I"Jstatic VALUE foletypelib_major_version(VALUE self) { TLIBATTR *pTLibAttr; VALUE major; ITypeLib *pTypeLib; pTypeLib = itypelib(self); oletypelib_get_libattr(pTypeLib, &pTLibAttr); major = RB_INT2NUM(pTLibAttr->wMajorVerNum); pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr); return major; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#WIN32OLE_TYPELIB#minor_version;F;7[;[[@i,;T;;G;0;[;{;IC; "Returns the type library minor version. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') puts tlib.minor_version # -> 3 ;T;[o;= ;>I" overload;F;?0;;G;@0;:I"minor_version;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"$The type library minor version.;T;$@k;![;"I".@return [The type library minor version.];T;#0;$@k;.F;Bi;C0;7[;$@k;![;"I"Returns the type library minor version. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') puts tlib.minor_version # -> 3 @overload minor_version @return [The type library minor version.];T;#0;$@k;.F;/o;0;1T;2i#;3i*;%@;9I"Istatic VALUE foletypelib_minor_version(VALUE self) { TLIBATTR *pTLibAttr; VALUE minor; ITypeLib *pTypeLib; pTypeLib = itypelib(self); oletypelib_get_libattr(pTypeLib, &pTLibAttr); minor = RB_INT2NUM(pTLibAttr->wMinorVerNum); pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr); return minor; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPELIB#path;F;7[;[[@iB;T;;O;0;[;{;IC; "Returns the type library file path. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') puts tlib.path #-> 'C:\...\EXCEL9.OLB' ;T;[o;= ;>I" overload;F;?0;;O;@0;:I" path;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" The type library file path.;T;$@;![;"I"*@return [The type library file path.];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the type library file path. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') puts tlib.path #-> 'C:\...\EXCEL9.OLB' @overload path @return [The type library file path.];T;#0;$@;.F;/o;0;1T;2i9;3i@;%@;9I"static VALUE foletypelib_path(VALUE self) { TLIBATTR *pTLibAttr; HRESULT hr = S_OK; BSTR bstr; LCID lcid = cWIN32OLE_lcid; VALUE path; ITypeLib *pTypeLib; pTypeLib = itypelib(self); oletypelib_get_libattr(pTypeLib, &pTLibAttr); hr = QueryPathOfRegTypeLib(&pTLibAttr->guid, pTLibAttr->wMajorVerNum, pTLibAttr->wMinorVerNum, lcid, &bstr); if (FAILED(hr)) { pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr); ole_raise(hr, eWIN32OLERuntimeError, "failed to QueryPathOfRegTypeTypeLib"); } pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr); path = WC2VSTR(bstr); return path; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_TYPELIB#ole_types;F;7[;[[@i ;T;:ole_types;0;[;{;IC; "Returns the type library file path. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') classes = tlib.ole_types.collect{|k| k.name} # -> ['AddIn', 'AddIns' ...] ;T;[o;= ;>I" overload;F;?0;;s;@0;:I"ole_types;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"AThe array of WIN32OLE_TYPE object included the type library.;T;$@;![;"I"K@return [The array of WIN32OLE_TYPE object included the type library.];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the type library file path. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') classes = tlib.ole_types.collect{|k| k.name} # -> ['AddIn', 'AddIns' ...] @overload ole_types @return [The array of WIN32OLE_TYPE object included the type library.];T;#0;$o;4;5F;6;;;;&I"!WIN32OLE_TYPELIB#ole_classes;F;7[;[[@iI;F;;?;;;[;{;@;%@;9I"static VALUE foletypelib_ole_types(VALUE self) { ITypeLib *pTypeLib = NULL; VALUE classes = rb_ary_new(); pTypeLib = itypelib(self); ole_types_from_typelib(pTypeLib, classes); return classes; };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@;9I"static VALUE foletypelib_ole_types(VALUE self) { ITypeLib *pTypeLib = NULL; VALUE classes = rb_ary_new(); pTypeLib = itypelib(self); ole_types_from_typelib(pTypeLib, classes); return classes; };T;:@;;T@o;4;5F;6;;;;&I"WIN32OLE_TYPELIB#visible?;F;7[;[[@ij;T;;E;0;[;{;IC; "uReturns true if the type library information is not hidden. If wLibFlags of TLIBATTR is 0 or LIBFLAG_FRESTRICTED or LIBFLAG_FHIDDEN, the method returns false, otherwise, returns true. If the method fails to access the TLIBATTR information, then WIN32OLERuntimeError is raised. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') tlib.visible? # => true;T;[o;= ;>I" overload;F;?0;;E;@0;:I" visible?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"Returns true if the type library information is not hidden. If wLibFlags of TLIBATTR is 0 or LIBFLAG_FRESTRICTED or LIBFLAG_FHIDDEN, the method returns false, otherwise, returns true. If the method fails to access the TLIBATTR information, then WIN32OLERuntimeError is raised. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') tlib.visible? # => true @overload visible?;T;#0;$@;.F;/o;0;1T;2i];3ig;Bi;%@;9I"static VALUE foletypelib_visible(VALUE self) { ITypeLib *pTypeLib = NULL; VALUE visible = Qtrue; TLIBATTR *pTLibAttr; pTypeLib = itypelib(self); oletypelib_get_libattr(pTypeLib, &pTLibAttr); if ((pTLibAttr->wLibFlags == 0) || (pTLibAttr->wLibFlags & LIBFLAG_FRESTRICTED) || (pTLibAttr->wLibFlags & LIBFLAG_FHIDDEN)) { visible = Qfalse; } pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr); return visible; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""WIN32OLE_TYPELIB#library_name;F;7[;[[@i;T;:library_name;0;[;{;IC; "Returns library name. If the method fails to access library name, WIN32OLERuntimeError is raised. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') tlib.library_name # => Excel ;T;[o;= ;>I" overload;F;?0;;t;@0;:I"library_name;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns library name. If the method fails to access library name, WIN32OLERuntimeError is raised. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') tlib.library_name # => Excel @overload library_name;T;#0;$@;.F;/o;0;1T;2i};3i;%@;9I"static VALUE foletypelib_library_name(VALUE self) { HRESULT hr; ITypeLib *pTypeLib = NULL; VALUE libname = Qnil; BSTR bstr; pTypeLib = itypelib(self); hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, -1, &bstr, NULL, NULL, NULL); if (FAILED(hr)) { ole_raise(hr, eWIN32OLERuntimeError, "failed to get library name"); } libname = WC2VSTR(bstr); return libname; };T;:I"static VALUE;T;;T@*o;4;5F;6;;;;&I"WIN32OLE_TYPELIB#inspect;F;7[;[[@i3;T;;J;0;[;{;IC; "Returns the type library name with class name. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') tlib.inspect # => "<#WIN32OLE_TYPELIB:Microsoft Excel 9.0 Object Library>" ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the type library name with class name. tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') tlib.inspect # => "<#WIN32OLE_TYPELIB:Microsoft Excel 9.0 Object Library>" @overload inspect @return [String];T;#0;$@;.F;/o;0;1T;2i*;3i1;%@;9I"kstatic VALUE foletypelib_inspect(VALUE self) { return default_inspect(self, "WIN32OLE_TYPELIB"); };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{@;s@*;F;[;[[@i[@i>;T;:WIN32OLE_TYPELIB;;;;;[;{;IC; "LWIN32OLE_TYPELIB objects represent OLE tyblib information.;T;[;![;"I"P WIN32OLE_TYPELIB objects represent OLE tyblib information. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;&I"WIN32OLE_TYPELIB;F;'@o; ;IC;[; @ ; IC;[; @ ; IC;[; @ ; IC;{;IC;{;T;IC;{;T;T;{;[;[[I""ext/win32ole/win32ole_error.c;TiJ[@+iZ;T;:WIN32OLERuntimeError;;;;;[;{;IC; "Raised when OLE processing failed. EX: obj = WIN32OLE.new("NonExistProgID") raises the exception: WIN32OLERuntimeError: unknown OLE server: `NonExistProgID' HRESULT error code:0x800401f3 Invalid class string ;T;[;![;"I" Raised when OLE processing failed. EX: obj = WIN32OLE.new("NonExistProgID") raises the exception: WIN32OLERuntimeError: unknown OLE server: `NonExistProgID' HRESULT error code:0x800401f3 Invalid class string ;T;#0;$@ ;.F;/o;0;1T;2iJ;3iW;%@;&I"WIN32OLERuntimeError;F;'o;( ;)0;*0;+0;;;%@;-@[;;o; ;IC;[; @6; IC;[; @6; IC;[; @6; IC;{;IC;{;T;IC;{;T;T;{;[;[[@+i[;F;: WIN32OLEQueryInterfaceError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@6;%@;&I" WIN32OLEQueryInterfaceError;F;'@ o; ;IC;[o;4;5F;6;;;;&I"WIN32OLE_VARIABLE#name;F;7[;[[I"%ext/win32ole/win32ole_variable.c;TiY;T;;F;0;[;{;IC; "cReturns the name of variable. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') variables = tobj.variables variables.each do |variable| puts "#{variable.name}" end The result of above script is following: xlChart xlDialogSheet xlExcel4IntlMacroSheet xlExcel4MacroSheet xlWorksheet ;T;[o;= ;>I" overload;F;?0;;F;@0;:I" name;T;IC; ";T;[;![;"I";T;#0;$@I;.F;Bi;C0;7[;$@I;![;"I"uReturns the name of variable. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') variables = tobj.variables variables.each do |variable| puts "#{variable.name}" end The result of above script is following: xlChart xlDialogSheet xlExcel4IntlMacroSheet xlExcel4MacroSheet xlWorksheet @overload name;T;#0;$o;4;5F;6;;;;&I"WIN32OLE_VARIABLE#to_s;F;7[;[[@Ni};F;;G;;;[;{;@Q;%@G;9I"dstatic VALUE folevariable_name(VALUE self) { return rb_ivar_get(self, rb_intern("name")); };T;:I"static VALUE;T;.F;/o;0;1T;2iE;3iV;%@G;9I"dstatic VALUE folevariable_name(VALUE self) { return rb_ivar_get(self, rb_intern("name")); };T;:@e;;To;4;5F;6;;;;&I"WIN32OLE_VARIABLE#ole_type;F;7[;[[@Ni|;T;;B;0;[;{;IC; "|Returns OLE type string. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') variables = tobj.variables variables.each do |variable| puts "#{variable.ole_type} #{variable.name}" end The result of above script is following: INT xlChart INT xlDialogSheet INT xlExcel4IntlMacroSheet INT xlExcel4MacroSheet INT xlWorksheet ;T;[o;= ;>I" overload;F;?0;;B;@0;:I" ole_type;T;IC; ";T;[;![;"I";T;#0;$@h;.F;Bi;C0;7[;$@h;![;"I"Returns OLE type string. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') variables = tobj.variables variables.each do |variable| puts "#{variable.ole_type} #{variable.name}" end The result of above script is following: INT xlChart INT xlDialogSheet INT xlExcel4IntlMacroSheet INT xlExcel4MacroSheet INT xlWorksheet @overload ole_type;T;#0;$@h;.F;/o;0;1T;2im;3i~;%@G;9I"static VALUE folevariable_ole_type(VALUE self) { struct olevariabledata *pvar; TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar); return ole_variable_ole_type(pvar->pTypeInfo, pvar->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&WIN32OLE_VARIABLE#ole_type_detail;F;7[;[[@Ni;T;;V;0;[;{;IC; "LReturns detail information of type. The information is array of type. tobj = WIN32OLE_TYPE.new('DirectX 7 for Visual Basic Type Library', 'D3DCLIPSTATUS') variable = tobj.variables.find {|variable| variable.name == 'lFlags'} tdetail = variable.ole_type_detail p tdetail # => ["USERDEFINED", "CONST_D3DCLIPSTATUSFLAGS"] ;T;[o;= ;>I" overload;F;?0;;V;@0;:I"ole_type_detail;T;IC; ";T;[;![;"I";T;#0;$@~;.F;Bi;C0;7[;$@~;![;"I"iReturns detail information of type. The information is array of type. tobj = WIN32OLE_TYPE.new('DirectX 7 for Visual Basic Type Library', 'D3DCLIPSTATUS') variable = tobj.variables.find {|variable| variable.name == 'lFlags'} tdetail = variable.ole_type_detail p tdetail # => ["USERDEFINED", "CONST_D3DCLIPSTATUSFLAGS"] @overload ole_type_detail;T;#0;$@~;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE folevariable_ole_type_detail(VALUE self) { struct olevariabledata *pvar; TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar); return ole_variable_ole_type_detail(pvar->pTypeInfo, pvar->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_VARIABLE#value;F;7[;[[@Ni;T;;5;0;[;{;IC; "Returns value if value is exists. If the value does not exist, this method returns nil. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') variables = tobj.variables variables.each do |variable| puts "#{variable.name} #{variable.value}" end The result of above script is following: xlChart = -4109 xlDialogSheet = -4116 xlExcel4IntlMacroSheet = 4 xlExcel4MacroSheet = 3 xlWorksheet = -4167 ;T;[o;= ;>I" overload;F;?0;;5;@0;:I" value;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns value if value is exists. If the value does not exist, this method returns nil. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') variables = tobj.variables variables.each do |variable| puts "#{variable.name} #{variable.value}" end The result of above script is following: xlChart = -4109 xlDialogSheet = -4116 xlExcel4IntlMacroSheet = 4 xlExcel4MacroSheet = 3 xlWorksheet = -4167 @overload value;T;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE folevariable_value(VALUE self) { struct olevariabledata *pvar; TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar); return ole_variable_value(pvar->pTypeInfo, pvar->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_VARIABLE#visible?;F;7[;[[@Ni;T;;E;0;[;{;IC; "Returns true if the variable is public. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') variables = tobj.variables variables.each do |variable| puts "#{variable.name} #{variable.visible?}" end The result of above script is following: xlChart true xlDialogSheet true xlExcel4IntlMacroSheet true xlExcel4MacroSheet true xlWorksheet true;T;[o;= ;>I" overload;F;?0;;E;@0;:I" visible?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"Returns true if the variable is public. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') variables = tobj.variables variables.each do |variable| puts "#{variable.name} #{variable.visible?}" end The result of above script is following: xlChart true xlDialogSheet true xlExcel4IntlMacroSheet true xlExcel4MacroSheet true xlWorksheet true @overload visible?;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@G;9I"static VALUE folevariable_visible(VALUE self) { struct olevariabledata *pvar; TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar); return ole_variable_visible(pvar->pTypeInfo, pvar->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$WIN32OLE_VARIABLE#variable_kind;F;7[;[[@Ni0;T;:variable_kind;0;[;{;IC; "Returns variable kind string. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') variables = tobj.variables variables.each do |variable| puts "#{variable.name} #{variable.variable_kind}" end The result of above script is following: xlChart CONSTANT xlDialogSheet CONSTANT xlExcel4IntlMacroSheet CONSTANT xlExcel4MacroSheet CONSTANT xlWorksheet CONSTANT ;T;[o;= ;>I" overload;F;?0;;x;@0;:I"variable_kind;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns variable kind string. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') variables = tobj.variables variables.each do |variable| puts "#{variable.name} #{variable.variable_kind}" end The result of above script is following: xlChart CONSTANT xlDialogSheet CONSTANT xlExcel4IntlMacroSheet CONSTANT xlExcel4MacroSheet CONSTANT xlWorksheet CONSTANT @overload variable_kind;T;#0;$@;.F;/o;0;1T;2i;3i-;%@G;9I"static VALUE folevariable_variable_kind(VALUE self) { struct olevariabledata *pvar; TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar); return ole_variable_kind(pvar->pTypeInfo, pvar->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_VARIABLE#varkind;F;7[;[[@NiX;T;: varkind;0;[;{;IC; "Returns the number which represents variable kind. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') variables = tobj.variables variables.each do |variable| puts "#{variable.name} #{variable.varkind}" end The result of above script is following: xlChart 2 xlDialogSheet 2 xlExcel4IntlMacroSheet 2 xlExcel4MacroSheet 2 xlWorksheet 2 ;T;[o;= ;>I" overload;F;?0;;y;@0;:I" varkind;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the number which represents variable kind. tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType') variables = tobj.variables variables.each do |variable| puts "#{variable.name} #{variable.varkind}" end The result of above script is following: xlChart 2 xlDialogSheet 2 xlExcel4IntlMacroSheet 2 xlExcel4MacroSheet 2 xlWorksheet 2 @overload varkind;T;#0;$@;.F;/o;0;1T;2iF;3iU;%@G;9I"static VALUE folevariable_varkind(VALUE self) { struct olevariabledata *pvar; TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar); return ole_variable_varkind(pvar->pTypeInfo, pvar->index); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_VARIABLE#inspect;F;7[;[[@Nig;T;;J;0;[;{;IC; "AReturns the OLE variable name and the value with class name. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"iReturns the OLE variable name and the value with class name. @overload inspect @return [String];T;#0;$@;.F;/o;0;1T;2i`;3ie;%@G;9I"static VALUE folevariable_inspect(VALUE self) { VALUE v = rb_inspect(folevariable_value(self)); VALUE n = folevariable_name(self); VALUE detail = rb_sprintf("%"PRIsVALUE"=%"PRIsVALUE, n, v); return make_inspect("WIN32OLE_VARIABLE", detail); };T;:I"static VALUE;T;;T@]; @G; IC;[; @G; IC;[; @G; IC;{;IC;{;T;IC;{;T;T;{@];F;[;[[@Ni2[@Nit;T;:WIN32OLE_VARIABLE;;;;;[;{;IC; "OWIN32OLE_VARIABLE objects represent OLE variable information.;T;[;![;"I"S WIN32OLE_VARIABLE objects represent OLE variable information. ;T;#0;$@G;.F;/o;0;1T;2i2;3i4;Bi;%@;&I"WIN32OLE_VARIABLE;F;'@o; ;IC;[4o;4;5F;6;;;;&I"WIN32OLE#initialize;F;7[[@90;[[I"ext/win32ole/win32ole.c;Ti ;T;;D;0;[;{;IC; " Returns a new WIN32OLE object(OLE Automation object). The first argument server specifies OLE Automation server. The first argument should be CLSID or PROGID. If second argument host specified, then returns OLE Automation object on host. If :license keyword argument is provided, IClassFactory2::CreateInstanceLic is used to create instance of licensed server. WIN32OLE.new('Excel.Application') # => Excel OLE Automation WIN32OLE object. WIN32OLE.new('{00024500-0000-0000-C000-000000000046}') # => Excel OLE Automation WIN32OLE object. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(server, [host]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"WIN32OLE object;T;$@;![;"I"@return [WIN32OLE object];T;#0;$@;.F;Bi;C0;7[[I" server;T0[I" [host];T0;$@o;= ;>I" overload;F;?0;;E;@0;:I" new(server, license: 'key');T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"WIN32OLE object;T;$@;![;"I"@return [WIN32OLE object];T;#0;$@;.F;Bi;C0;7[[I" server;T0[I" license:;TI" 'key';T;$@;![;"I"Returns a new WIN32OLE object(OLE Automation object). The first argument server specifies OLE Automation server. The first argument should be CLSID or PROGID. If second argument host specified, then returns OLE Automation object on host. If :license keyword argument is provided, IClassFactory2::CreateInstanceLic is used to create instance of licensed server. WIN32OLE.new('Excel.Application') # => Excel OLE Automation WIN32OLE object. WIN32OLE.new('{00024500-0000-0000-C000-000000000046}') # => Excel OLE Automation WIN32OLE object. @overload new(server, [host]) @return [WIN32OLE object] @overload new(server, license: 'key') @return [WIN32OLE object];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"=static VALUE fole_initialize(int argc, VALUE *argv, VALUE self) { VALUE svr_name; VALUE host; VALUE others; VALUE opts; HRESULT hr; CLSID clsid; OLECHAR *pBuf; OLECHAR *key_buf; IDispatch *pDispatch; IClassFactory2 * pIClassFactory2; void *p; static ID keyword_ids[1]; VALUE kwargs[1]; rb_call_super(0, 0); rb_scan_args(argc, argv, "11*:", &svr_name, &host, &others, &opts); StringValue(svr_name); if (!NIL_P(host)) { StringValue(host); return ole_create_dcom(self, svr_name, host, others); } /* get CLSID from OLE server name */ pBuf = ole_vstr2wc(svr_name); hr = CLSIDFromProgID(pBuf, &clsid); if(FAILED(hr)) { hr = CLSIDFromString(pBuf, &clsid); } SysFreeString(pBuf); if(FAILED(hr)) { ole_raise(hr, eWIN32OLERuntimeError, "unknown OLE server: `%s'", StringValuePtr(svr_name)); } if (!keyword_ids[0]) { keyword_ids[0] = rb_intern_const("license"); } rb_get_kwargs(opts, keyword_ids, 0, 1, kwargs); if (kwargs[0] == Qundef) { /* get IDispatch interface */ hr = CoCreateInstance( &clsid, NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, &IID_IDispatch, &p ); } else { hr = CoGetClassObject( &clsid, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, NULL, &IID_IClassFactory2, (LPVOID)&pIClassFactory2 ); if (hr == S_OK) { key_buf = ole_vstr2wc(kwargs[0]); hr = pIClassFactory2->lpVtbl->CreateInstanceLic(pIClassFactory2, NULL, NULL, &IID_IDispatch, key_buf, &p); SysFreeString(key_buf); OLE_RELEASE(pIClassFactory2); } } pDispatch = p; if(FAILED(hr)) { ole_raise(hr, eWIN32OLERuntimeError, "failed to create WIN32OLE object from `%s'", StringValuePtr(svr_name)); } ole_set_member(self, pDispatch); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE.connect;F;7[[@90;[[@$i;T;;;0;[;{;IC; "Returns running OLE Automation object or WIN32OLE object from moniker. 1st argument should be OLE program id or class id or moniker. WIN32OLE.connect('Excel.Application') # => WIN32OLE object which represents running Excel. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"!connect( ole ) --> aWIN32OLE;T;IC; ";T;[;![;"I";T;#0;$@Q;.F;Bi;C0;7[[I"ole;T0;$@Q;![;"I" Returns running OLE Automation object or WIN32OLE object from moniker. 1st argument should be OLE program id or class id or moniker. WIN32OLE.connect('Excel.Application') # => WIN32OLE object which represents running Excel. @overload connect( ole ) --> aWIN32OLE;T;#0;$@Q;.F;/o;0;1T;2i;3i;%@;9I"static VALUE fole_s_connect(int argc, VALUE *argv, VALUE self) { VALUE svr_name; VALUE others; HRESULT hr; CLSID clsid; OLECHAR *pBuf; IDispatch *pDispatch; void *p; IUnknown *pUnknown; /* initialize to use OLE */ ole_initialize(); rb_scan_args(argc, argv, "1*", &svr_name, &others); StringValue(svr_name); /* get CLSID from OLE server name */ pBuf = ole_vstr2wc(svr_name); hr = CLSIDFromProgID(pBuf, &clsid); if(FAILED(hr)) { hr = CLSIDFromString(pBuf, &clsid); } SysFreeString(pBuf); if(FAILED(hr)) { return ole_bind_obj(svr_name, argc, argv, self); } hr = GetActiveObject(&clsid, 0, &pUnknown); if (FAILED(hr)) { ole_raise(hr, eWIN32OLERuntimeError, "OLE server `%s' not running", StringValuePtr(svr_name)); } hr = pUnknown->lpVtbl->QueryInterface(pUnknown, &IID_IDispatch, &p); pDispatch = p; if(FAILED(hr)) { OLE_RELEASE(pUnknown); ole_raise(hr, eWIN32OLERuntimeError, "failed to create WIN32OLE server `%s'", StringValuePtr(svr_name)); } OLE_RELEASE(pUnknown); return create_win32ole_object(self, pDispatch, argc, argv); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE.const_load;F;7[[@90;[[@$i;T;:const_load;0;[;{;IC; "Defines the constants of OLE Automation server as mod's constants. The first argument is WIN32OLE object or type library name. If 2nd argument is omitted, the default is WIN32OLE. The first letter of Ruby's constant variable name is upper case, so constant variable name of WIN32OLE object is capitalized. For example, the 'xlTop' constant of Excel is changed to 'XlTop' in WIN32OLE. If the first letter of constant variable is not [A-Z], then the constant is defined as CONSTANTS hash element. module EXCEL_CONST end excel = WIN32OLE.new('Excel.Application') WIN32OLE.const_load(excel, EXCEL_CONST) puts EXCEL_CONST::XlTop # => -4160 puts EXCEL_CONST::CONSTANTS['_xlDialogChartSourceData'] # => 541 WIN32OLE.const_load(excel) puts WIN32OLE::XlTop # => -4160 module MSO end WIN32OLE.const_load('Microsoft Office 9.0 Object Library', MSO) puts MSO::MsoLineSingle # => 1 ;T;[o;= ;>I" overload;F;?0;;{;@0;:I"%const_load( ole, mod = WIN32OLE);T;IC; ";T;[;![;"I";T;#0;$@j;.F;Bi;C0;7[[I"ole;T0[I"mod;TI" WIN32OLE;T;$@j;![;"I"Defines the constants of OLE Automation server as mod's constants. The first argument is WIN32OLE object or type library name. If 2nd argument is omitted, the default is WIN32OLE. The first letter of Ruby's constant variable name is upper case, so constant variable name of WIN32OLE object is capitalized. For example, the 'xlTop' constant of Excel is changed to 'XlTop' in WIN32OLE. If the first letter of constant variable is not [A-Z], then the constant is defined as CONSTANTS hash element. module EXCEL_CONST end excel = WIN32OLE.new('Excel.Application') WIN32OLE.const_load(excel, EXCEL_CONST) puts EXCEL_CONST::XlTop # => -4160 puts EXCEL_CONST::CONSTANTS['_xlDialogChartSourceData'] # => 541 WIN32OLE.const_load(excel) puts WIN32OLE::XlTop # => -4160 module MSO end WIN32OLE.const_load('Microsoft Office 9.0 Object Library', MSO) puts MSO::MsoLineSingle # => 1 @overload const_load( ole, mod = WIN32OLE);T;#0;$@j;.F;/o;0;1T;2i;3i;%@;9I" static VALUE fole_s_const_load(int argc, VALUE *argv, VALUE self) { VALUE ole; VALUE klass; struct oledata *pole = NULL; ITypeInfo *pTypeInfo; ITypeLib *pTypeLib; unsigned int index; HRESULT hr; OLECHAR *pBuf; VALUE file; LCID lcid = cWIN32OLE_lcid; rb_scan_args(argc, argv, "11", &ole, &klass); if (!RB_TYPE_P(klass, T_CLASS) && !RB_TYPE_P(klass, T_MODULE) && !RB_TYPE_P(klass, T_NIL)) { rb_raise(rb_eTypeError, "2nd parameter must be Class or Module"); } if (rb_obj_is_kind_of(ole, cWIN32OLE)) { pole = oledata_get_struct(ole); hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch, 0, lcid, &pTypeInfo); if(FAILED(hr)) { ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetTypeInfo"); } hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &index); if(FAILED(hr)) { OLE_RELEASE(pTypeInfo); ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetContainingTypeLib"); } OLE_RELEASE(pTypeInfo); if(!RB_TYPE_P(klass, T_NIL)) { ole_const_load(pTypeLib, klass, self); } else { ole_const_load(pTypeLib, cWIN32OLE, self); } OLE_RELEASE(pTypeLib); } else if(RB_TYPE_P(ole, T_STRING)) { file = typelib_file(ole); if (file == Qnil) { file = ole; } pBuf = ole_vstr2wc(file); hr = LoadTypeLibEx(pBuf, REGKIND_NONE, &pTypeLib); SysFreeString(pBuf); if (FAILED(hr)) ole_raise(hr, eWIN32OLERuntimeError, "failed to LoadTypeLibEx"); if(!RB_TYPE_P(klass, T_NIL)) { ole_const_load(pTypeLib, klass, self); } else { ole_const_load(pTypeLib, cWIN32OLE, self); } OLE_RELEASE(pTypeLib); } else { rb_raise(rb_eTypeError, "1st parameter must be WIN32OLE instance"); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE.ole_free;F;7[[I"obj;T0;[[@$if;T;: ole_free;0;[;{;IC; "Invokes Release method of Dispatch interface of WIN32OLE object. You should not use this method because this method exists only for debugging WIN32OLE. The return value is reference counter of OLE object. ;T;[o;= ;>I" overload;F;?0;;|;@0;:I"#ole_free(aWIN32OLE) --> number;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"aWIN32OLE;T0;$@;![;"I"Invokes Release method of Dispatch interface of WIN32OLE object. You should not use this method because this method exists only for debugging WIN32OLE. The return value is reference counter of OLE object. @overload ole_free(aWIN32OLE) --> number;T;#0;$@;.F;/o;0;1T;2i];3ic;%@;9I"%static VALUE fole_s_free(VALUE self, VALUE obj) { ULONG n = 0; struct oledata * pole = NULL; pole = oledata_get_struct(obj); if(pole->pDispatch) { if (reference_count(pole) > 0) { n = OLE_RELEASE(pole->pDispatch); } } return RB_INT2NUM(n); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!WIN32OLE.ole_reference_count;F;7[[I"obj;T0;[[@$iU;T;:ole_reference_count;0;[;{;IC; "Returns reference counter of Dispatch interface of WIN32OLE object. You should not use this method because this method exists only for debugging WIN32OLE. ;T;[o;= ;>I" overload;F;?0;;};@0;:I".ole_reference_count(aWIN32OLE) --> number;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"aWIN32OLE;T0;$@;![;"I"Returns reference counter of Dispatch interface of WIN32OLE object. You should not use this method because this method exists only for debugging WIN32OLE. @overload ole_reference_count(aWIN32OLE) --> number;T;#0;$@;.F;/o;0;1T;2iM;3iR;%@;9I"static VALUE fole_s_reference_count(VALUE self, VALUE obj) { struct oledata * pole = NULL; pole = oledata_get_struct(obj); return RB_INT2NUM(reference_count(pole)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE.ole_show_help;F;7[[@90;[[@$i;T;:ole_show_help;0;[;{;IC; "Displays helpfile. The 1st argument specifies WIN32OLE_TYPE object or WIN32OLE_METHOD object or helpfile. excel = WIN32OLE.new('Excel.Application') typeobj = excel.ole_type WIN32OLE.ole_show_help(typeobj) ;T;[o;= ;>I" overload;F;?0;;~;@0;:I"&ole_show_help(obj [,helpcontext]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"obj[,helpcontext];T0;$@;![;"I"Displays helpfile. The 1st argument specifies WIN32OLE_TYPE object or WIN32OLE_METHOD object or helpfile. excel = WIN32OLE.new('Excel.Application') typeobj = excel.ole_type WIN32OLE.ole_show_help(typeobj) @overload ole_show_help(obj [,helpcontext]);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I">static VALUE fole_s_show_help(int argc, VALUE *argv, VALUE self) { VALUE target; VALUE helpcontext; VALUE helpfile; VALUE name; HWND hwnd; rb_scan_args(argc, argv, "11", &target, &helpcontext); if (rb_obj_is_kind_of(target, cWIN32OLE_TYPE) || rb_obj_is_kind_of(target, cWIN32OLE_METHOD)) { helpfile = rb_funcall(target, rb_intern("helpfile"), 0); if(strlen(StringValuePtr(helpfile)) == 0) { name = rb_ivar_get(target, rb_intern("name")); rb_raise(rb_eRuntimeError, "no helpfile of `%s'", StringValuePtr(name)); } helpcontext = rb_funcall(target, rb_intern("helpcontext"), 0); } else { helpfile = target; } if (!RB_TYPE_P(helpfile, T_STRING)) { rb_raise(rb_eTypeError, "1st parameter must be (String|WIN32OLE_TYPE|WIN32OLE_METHOD)"); } hwnd = ole_show_help(helpfile, helpcontext); if(hwnd == 0) { rb_raise(rb_eRuntimeError, "failed to open help file `%s'", StringValuePtr(helpfile)); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE.codepage;F;7[;[[@$i;T;: codepage;0;[;{;IC; "IReturns current codepage. WIN32OLE.codepage # => WIN32OLE::CP_ACP ;T;[o;= ;>I" overload;F;?0;;;@0;:I" codepage;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"^Returns current codepage. WIN32OLE.codepage # => WIN32OLE::CP_ACP @overload codepage;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"[static VALUE fole_s_get_code_page(VALUE self) { return RB_INT2FIX(cWIN32OLE_cp); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE.codepage=;F;7[[I"vcp;T0;[[@$i;T;:codepage=;0;[;{;IC; "Sets current codepage. The WIN32OLE.codepage is initialized according to Encoding.default_internal. If Encoding.default_internal is nil then WIN32OLE.codepage is initialized according to Encoding.default_external. WIN32OLE.codepage = WIN32OLE::CP_UTF8 WIN32OLE.codepage = 65001 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"codepage=(CP);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"CP;T0;$@;![;"I"6Sets current codepage. The WIN32OLE.codepage is initialized according to Encoding.default_internal. If Encoding.default_internal is nil then WIN32OLE.codepage is initialized according to Encoding.default_external. WIN32OLE.codepage = WIN32OLE::CP_UTF8 WIN32OLE.codepage = 65001 @overload codepage=(CP);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE fole_s_set_code_page(VALUE self, VALUE vcp) { UINT cp = RB_FIX2INT(vcp); set_ole_codepage(cp); /* * Should this method return old codepage? */ return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE.locale;F;7[;[[@$i;T;: locale;0;[;{;IC; "xReturns current locale id (lcid). The default locale is WIN32OLE::LOCALE_SYSTEM_DEFAULT. lcid = WIN32OLE.locale ;T;[o;= ;>I" overload;F;?0;;;@0;:I" locale;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns current locale id (lcid). The default locale is WIN32OLE::LOCALE_SYSTEM_DEFAULT. lcid = WIN32OLE.locale @overload locale;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"Zstatic VALUE fole_s_get_locale(VALUE self) { return RB_INT2FIX(cWIN32OLE_lcid); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE.locale=;F;7[[I" vlcid;T0;[[@$i ;T;: locale=;0;[;{;IC; "Sets current locale id (lcid). WIN32OLE.locale = 1033 # set locale English(U.S) obj = WIN32OLE_VARIANT.new("$100,000", WIN32OLE::VARIANT::VT_CY) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"locale=(lcid);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" lcid;T0;$@;![;"I"Sets current locale id (lcid). WIN32OLE.locale = 1033 # set locale English(U.S) obj = WIN32OLE_VARIANT.new("$100,000", WIN32OLE::VARIANT::VT_CY) @overload locale=(lcid);T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE fole_s_set_locale(VALUE self, VALUE vlcid) { LCID lcid = RB_FIX2INT(vlcid); if (lcid_installed(lcid)) { cWIN32OLE_lcid = lcid; } else { switch (lcid) { case LOCALE_SYSTEM_DEFAULT: case LOCALE_USER_DEFAULT: cWIN32OLE_lcid = lcid; break; default: rb_raise(eWIN32OLERuntimeError, "not installed locale: %u", (unsigned int)lcid); } } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE.create_guid;F;7[;[[@$i1 ;T;:create_guid;0;[;{;IC; "VCreates GUID. WIN32OLE.create_guid # => {1CB530F1-F6B1-404D-BCE6-1959BF91F4A8} ;T;[o;= ;>I" overload;F;?0;;;@0;:I"create_guid;T;IC; ";T;[;![;"I";T;#0;$@3;.F;Bi;C0;7[;$@3;![;"I"nCreates GUID. WIN32OLE.create_guid # => {1CB530F1-F6B1-404D-BCE6-1959BF91F4A8} @overload create_guid;T;#0;$@3;.F;/o;0;1T;2i* ;3i. ;%@;9I"static VALUE fole_s_create_guid(VALUE self) { GUID guid; HRESULT hr; OLECHAR bstr[80]; int len = 0; hr = CoCreateGuid(&guid); if (FAILED(hr)) { ole_raise(hr, eWIN32OLERuntimeError, "failed to create GUID"); } len = StringFromGUID2(&guid, bstr, sizeof(bstr)/sizeof(OLECHAR)); if (len == 0) { rb_raise(rb_eRuntimeError, "failed to create GUID(buffer over)"); } return ole_wc2vstr(bstr, FALSE); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE.ole_initialize;F;7[;[[@$iJ ;T;:ole_initialize;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@I;.F;/o;0;1T;2iI ;3iI ;%@;9I"^static VALUE fole_s_ole_initialize(VALUE self) { ole_initialize(); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE.ole_uninitialize;F;7[;[[@$iR ;T;:ole_uninitialize;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@W;.F;/o;0;1T;2iQ ;3iQ ;%@;9I"bstatic VALUE fole_s_ole_uninitialize(VALUE self) { ole_uninitialize(); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE#invoke;F;7[[@90;[[@$i ;T;: invoke;0;[;{;IC; "3Runs OLE method. The first argument specifies the method name of OLE Automation object. The others specify argument of the method. If you can not execute method directly, then use this method instead. excel = WIN32OLE.new('Excel.Application') excel.invoke('Quit') # => same as excel.Quit ;T;[o;= ;>I" overload;F;?0;;;@0;:I"invoke(method, [arg1,...]);T;IC; ";T;[;![;"I";T;#0;$@e;.F;Bi;C0;7[[I" method;T0[I"[arg1,...];T0;$@e;![;"I"[Runs OLE method. The first argument specifies the method name of OLE Automation object. The others specify argument of the method. If you can not execute method directly, then use this method instead. excel = WIN32OLE.new('Excel.Application') excel.invoke('Quit') # => same as excel.Quit @overload invoke(method, [arg1,...]);T;#0;$@e;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE fole_invoke(int argc, VALUE *argv, VALUE self) { VALUE v = ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET, FALSE); if (v == rb_eNoMethodError) { return rb_call_super(argc, argv); } return v; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE#[];F;7[[@90;[[@$iX ;T;;;0;[;{;IC; "Returns the value of Collection specified by a1, a2,.... dict = WIN32OLE.new('Scripting.Dictionary') dict.add('ruby', 'Ruby') puts dict['ruby'] # => 'Ruby' (same as `puts dict.item('ruby')') Remark: You can not use this method to get the property. excel = WIN32OLE.new('Excel.Application') # puts excel['Visible'] This is error !!! puts excel.Visible # You should to use this style to get the property. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"[](a1,a2,...);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"a1;T0[I"a2;T0[I"...;T0;$@;![;"I"Returns the value of Collection specified by a1, a2,.... dict = WIN32OLE.new('Scripting.Dictionary') dict.add('ruby', 'Ruby') puts dict['ruby'] # => 'Ruby' (same as `puts dict.item('ruby')') Remark: You can not use this method to get the property. excel = WIN32OLE.new('Excel.Application') # puts excel['Visible'] This is error !!! puts excel.Visible # You should to use this style to get the property. @overload [](a1,a2,...);T;#0;$@;.F;/o;0;1T;2iH ;3iU ;%@;9I"static VALUE fole_getproperty_with_bracket(int argc, VALUE *argv, VALUE self) { VALUE v = ole_invoke(argc, argv, self, DISPATCH_PROPERTYGET, TRUE); if (v == rb_eNoMethodError) { return rb_call_super(argc, argv); } return v; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE#_invoke;F;7[[I" dispid;T0[I" args;T0[I" types;T0;[[@$i ;T;: _invoke;0;[;{;IC; "!Runs the early binding method. The 1st argument specifies dispatch ID, the 2nd argument specifies the array of arguments, the 3rd argument specifies the array of the type of arguments. excel = WIN32OLE.new('Excel.Application') excel._invoke(302, [], []) # same effect as excel.Quit ;T;[o;= ;>I" overload;F;?0;;;@0;:I"!_invoke(dispid, args, types);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" dispid;T0[I" args;T0[I" types;T0;$@;![;"I"JRuns the early binding method. The 1st argument specifies dispatch ID, the 2nd argument specifies the array of arguments, the 3rd argument specifies the array of the type of arguments. excel = WIN32OLE.new('Excel.Application') excel._invoke(302, [], []) # same effect as excel.Quit @overload _invoke(dispid, args, types);T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE fole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types) { return ole_invoke2(self, dispid, args, types, DISPATCH_METHOD); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE#_getproperty;F;7[[I" dispid;T0[I" args;T0[I" types;T0;[[@$i ;T;:_getproperty;0;[;{;IC; "BRuns the early binding method to get property. The 1st argument specifies dispatch ID, the 2nd argument specifies the array of arguments, the 3rd argument specifies the array of the type of arguments. excel = WIN32OLE.new('Excel.Application') puts excel._getproperty(558, [], []) # same effect as puts excel.visible ;T;[o;= ;>I" overload;F;?0;;;@0;:I"&_getproperty(dispid, args, types);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" dispid;T0[I" args;T0[I" types;T0;$@;![;"I"pRuns the early binding method to get property. The 1st argument specifies dispatch ID, the 2nd argument specifies the array of arguments, the 3rd argument specifies the array of the type of arguments. excel = WIN32OLE.new('Excel.Application') puts excel._getproperty(558, [], []) # same effect as puts excel.visible @overload _getproperty(dispid, args, types);T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE fole_getproperty2(VALUE self, VALUE dispid, VALUE args, VALUE types) { return ole_invoke2(self, dispid, args, types, DISPATCH_PROPERTYGET); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE#_setproperty;F;7[[I" dispid;T0[I" args;T0[I" types;T0;[[@$i ;T;:_setproperty;0;[;{;IC; "]Runs the early binding method to set property. The 1st argument specifies dispatch ID, the 2nd argument specifies the array of arguments, the 3rd argument specifies the array of the type of arguments. excel = WIN32OLE.new('Excel.Application') excel._setproperty(558, [true], [WIN32OLE::VARIANT::VT_BOOL]) # same effect as excel.visible = true ;T;[o;= ;>I" overload;F;?0;;;@0;:I"&_setproperty(dispid, args, types);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" dispid;T0[I" args;T0[I" types;T0;$@;![;"I"Runs the early binding method to set property. The 1st argument specifies dispatch ID, the 2nd argument specifies the array of arguments, the 3rd argument specifies the array of the type of arguments. excel = WIN32OLE.new('Excel.Application') excel._setproperty(558, [true], [WIN32OLE::VARIANT::VT_BOOL]) # same effect as excel.visible = true @overload _setproperty(dispid, args, types);T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE fole_setproperty2(VALUE self, VALUE dispid, VALUE args, VALUE types) { return ole_invoke2(self, dispid, args, types, DISPATCH_PROPERTYPUT); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE#[]=;F;7[[@90;[[@$i' ;T;;8;0;[;{;IC; "Sets the value to WIN32OLE object specified by a1, a2, ... dict = WIN32OLE.new('Scripting.Dictionary') dict.add('ruby', 'RUBY') dict['ruby'] = 'Ruby' puts dict['ruby'] # => 'Ruby' Remark: You can not use this method to set the property value. excel = WIN32OLE.new('Excel.Application') # excel['Visible'] = true # This is error !!! excel.Visible = true # You should to use this style to set the property. ;T;[o;= ;>I" overload;F;?0;;8;@0;:I"[]=(a1, a2, ...);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"a1;T0[I"a2;T0[I"...;T0;$@;![;"I"Sets the value to WIN32OLE object specified by a1, a2, ... dict = WIN32OLE.new('Scripting.Dictionary') dict.add('ruby', 'RUBY') dict['ruby'] = 'Ruby' puts dict['ruby'] # => 'Ruby' Remark: You can not use this method to set the property value. excel = WIN32OLE.new('Excel.Application') # excel['Visible'] = true # This is error !!! excel.Visible = true # You should to use this style to set the property. @overload []=(a1, a2, ...);T;#0;$@;.F;/o;0;1T;2i ;3i$ ;%@;9I"static VALUE fole_setproperty_with_bracket(int argc, VALUE *argv, VALUE self) { VALUE v = ole_invoke(argc, argv, self, DISPATCH_PROPERTYPUT, TRUE); if (v == rb_eNoMethodError) { return rb_call_super(argc, argv); } return v; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE#ole_free;F;7[;[[@$i ;T;;|;0;[;{;IC; "invokes Release method of Dispatch interface of WIN32OLE object. Usually, you do not need to call this method because Release method called automatically when WIN32OLE object garbaged. ;T;[o;= ;>I" overload;F;?0;;|;@0;:I" ole_free;T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"invokes Release method of Dispatch interface of WIN32OLE object. Usually, you do not need to call this method because Release method called automatically when WIN32OLE object garbaged. @overload ole_free;T;#0;$@ ;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE fole_free(VALUE self) { struct oledata *pole = NULL; pole = oledata_get_struct(self); OLE_FREE(pole->pDispatch); pole->pDispatch = NULL; return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE#each;F;7[;[[@$i ;T;;;0;[;{;IC; " Iterates over each item of OLE collection which has IEnumVARIANT interface. excel = WIN32OLE.new('Excel.Application') book = excel.workbooks.add sheets = book.worksheets(1) cells = sheets.cells("A1:A5") cells.each do |cell| cell.value = 10 end ;T;[o;= ;>I" overload;F;?0;;;@0;:I" each;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"i;T;$@6;![;"I"@yield [i];T;#0;$@6;.F;Bi;C0;7[;$@6;![;"I")Iterates over each item of OLE collection which has IEnumVARIANT interface. excel = WIN32OLE.new('Excel.Application') book = excel.workbooks.add sheets = book.worksheets(1) cells = sheets.cells("A1:A5") cells.each do |cell| cell.value = 10 end @overload each @yield [i];T;#0;$@6;.F;/o;0;1T;2i ;3i ;%@;9I"Bstatic VALUE fole_each(VALUE self) { LCID lcid = cWIN32OLE_lcid; struct oledata *pole = NULL; unsigned int argErr; EXCEPINFO excepinfo; DISPPARAMS dispParams; VARIANT result; HRESULT hr; IEnumVARIANT *pEnum = NULL; void *p; RETURN_ENUMERATOR(self, 0, 0); VariantInit(&result); dispParams.rgvarg = NULL; dispParams.rgdispidNamedArgs = NULL; dispParams.cNamedArgs = 0; dispParams.cArgs = 0; memset(&excepinfo, 0, sizeof(excepinfo)); pole = oledata_get_struct(self); hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DISPID_NEWENUM, &IID_NULL, lcid, DISPATCH_METHOD | DISPATCH_PROPERTYGET, &dispParams, &result, &excepinfo, &argErr); if (FAILED(hr)) { VariantClear(&result); ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to get IEnum Interface"); } if (V_VT(&result) == VT_UNKNOWN) { hr = V_UNKNOWN(&result)->lpVtbl->QueryInterface(V_UNKNOWN(&result), &IID_IEnumVARIANT, &p); pEnum = p; } else if (V_VT(&result) == VT_DISPATCH) { hr = V_DISPATCH(&result)->lpVtbl->QueryInterface(V_DISPATCH(&result), &IID_IEnumVARIANT, &p); pEnum = p; } if (FAILED(hr) || !pEnum) { VariantClear(&result); ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to get IEnum Interface"); } VariantClear(&result); rb_ensure(ole_each_sub, (VALUE)pEnum, ole_ienum_free, (VALUE)pEnum); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE#method_missing;F;7[[@90;[[@$i ;T;;;0;[;{;IC; ""Calls WIN32OLE#invoke method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"*method_missing(id [,arg1, arg2, ...]);T;IC; ";T;[;![;"I";T;#0;$@Q;.F;Bi;C0;7[[I"id[,arg1, arg2, ...];T0;$@Q;![;"I"TCalls WIN32OLE#invoke method. @overload method_missing(id [,arg1, arg2, ...]);T;#0;$@Q;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE fole_missing(int argc, VALUE *argv, VALUE self) { VALUE mid, org_mid, sym, v; const char* mname; long n; rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS); mid = org_mid = argv[0]; sym = rb_check_symbol(&mid); if (!NIL_P(sym)) mid = rb_sym2str(sym); mname = StringValueCStr(mid); if(!mname) { rb_raise(rb_eRuntimeError, "fail: unknown method or property"); } n = RSTRING_LEN(mid); if(mname[n-1] == '=') { rb_check_arity(argc, 2, 2); argv[0] = rb_enc_associate(rb_str_subseq(mid, 0, n-1), cWIN32OLE_enc); return ole_propertyput(self, argv[0], argv[1]); } else { argv[0] = rb_enc_associate(rb_str_dup(mid), cWIN32OLE_enc); v = ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET, FALSE); if (v == rb_eNoMethodError) { argv[0] = org_mid; return rb_call_super(argc, argv); } return v; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE#setproperty;F;7[[@90;[[@$i> ;T;:setproperty;0;[;{;IC; "*Sets property of OLE object. When you want to set property with argument, you can use this method. excel = WIN32OLE.new('Excel.Application') excel.Visible = true book = excel.workbooks.add sheet = book.worksheets(1) sheet.setproperty('Cells', 1, 2, 10) # => The B1 cell value is 10. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"2setproperty('property', [arg1, arg2,...] val);T;IC; ";T;[;![;"I";T;#0;$@j;.F;Bi;C0;7[["'property'0[I"[arg1, arg2,...];T0;$@j;![;"I"dSets property of OLE object. When you want to set property with argument, you can use this method. excel = WIN32OLE.new('Excel.Application') excel.Visible = true book = excel.workbooks.add sheet = book.worksheets(1) sheet.setproperty('Cells', 1, 2, 10) # => The B1 cell value is 10. @overload setproperty('property', [arg1, arg2,...] val);T;#0;$@j;.F;/o;0;1T;2i1 ;3i; ;%@;9I"static VALUE fole_setproperty(int argc, VALUE *argv, VALUE self) { VALUE v = ole_invoke(argc, argv, self, DISPATCH_PROPERTYPUT, FALSE); if (v == rb_eNoMethodError) { return rb_call_super(argc, argv); } return v; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE#ole_methods;F;7[;[[@$iz ;T;;N;0;[;{;IC; "Returns the array of WIN32OLE_METHOD object. The element is OLE method of WIN32OLE object. excel = WIN32OLE.new('Excel.Application') methods = excel.ole_methods ;T;[o;= ;>I" overload;F;?0;;N;@0;:I"ole_methods;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the array of WIN32OLE_METHOD object. The element is OLE method of WIN32OLE object. excel = WIN32OLE.new('Excel.Application') methods = excel.ole_methods @overload ole_methods;T;#0;$@;.F;/o;0;1T;2io ;3iw ;%@;9I"static VALUE fole_methods(VALUE self) { return ole_methods( self, INVOKE_FUNC | INVOKE_PROPERTYGET | INVOKE_PROPERTYPUT | INVOKE_PROPERTYPUTREF); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE#ole_get_methods;F;7[;[[@$i ;T;:ole_get_methods;0;[;{;IC; "Returns the array of WIN32OLE_METHOD object . The element of the array is property (gettable) of WIN32OLE object. excel = WIN32OLE.new('Excel.Application') properties = excel.ole_get_methods ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ole_get_methods;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the array of WIN32OLE_METHOD object . The element of the array is property (gettable) of WIN32OLE object. excel = WIN32OLE.new('Excel.Application') properties = excel.ole_get_methods @overload ole_get_methods;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"estatic VALUE fole_get_methods(VALUE self) { return ole_methods( self, INVOKE_PROPERTYGET); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE#ole_put_methods;F;7[;[[@$i ;T;:ole_put_methods;0;[;{;IC; "Returns the array of WIN32OLE_METHOD object . The element of the array is property (settable) of WIN32OLE object. excel = WIN32OLE.new('Excel.Application') properties = excel.ole_put_methods ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ole_put_methods;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the array of WIN32OLE_METHOD object . The element of the array is property (settable) of WIN32OLE object. excel = WIN32OLE.new('Excel.Application') properties = excel.ole_put_methods @overload ole_put_methods;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"{static VALUE fole_put_methods(VALUE self) { return ole_methods( self, INVOKE_PROPERTYPUT|INVOKE_PROPERTYPUTREF); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE#ole_func_methods;F;7[;[[@$i ;T;:ole_func_methods;0;[;{;IC; "Returns the array of WIN32OLE_METHOD object . The element of the array is property (settable) of WIN32OLE object. excel = WIN32OLE.new('Excel.Application') properties = excel.ole_func_methods ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ole_func_methods;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the array of WIN32OLE_METHOD object . The element of the array is property (settable) of WIN32OLE object. excel = WIN32OLE.new('Excel.Application') properties = excel.ole_func_methods @overload ole_func_methods;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"_static VALUE fole_func_methods(VALUE self) { return ole_methods( self, INVOKE_FUNC); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE#ole_method;F;7[[I" cmdname;T0;[[@$i;T;:ole_method;0;[;{;IC; "Returns WIN32OLE_METHOD object corresponding with method specified by 1st argument. excel = WIN32OLE.new('Excel.Application') method = excel.ole_method_help('Quit') ;T;[o;= ;>I" overload;F;?0;:ole_method_help;@0;:I"ole_method_help(method);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" method;T0;$@;![;"I"Returns WIN32OLE_METHOD object corresponding with method specified by 1st argument. excel = WIN32OLE.new('Excel.Application') method = excel.ole_method_help('Quit') @overload ole_method_help(method);T;#0;$o;4;5F;6;;;;&I"WIN32OLE#ole_method_help;F;7[;[[@$i;F;;;;;[;{;@;%@;9I"Gstatic VALUE fole_method_help(VALUE self, VALUE cmdname) { ITypeInfo *pTypeInfo; HRESULT hr; struct oledata *pole = NULL; VALUE obj; SafeStringValue(cmdname); pole = oledata_get_struct(self); hr = typeinfo_from_ole(pole, &pTypeInfo); if(FAILED(hr)) ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to get ITypeInfo"); obj = create_win32ole_method(pTypeInfo, cmdname); OLE_RELEASE(pTypeInfo); if (obj == Qnil) rb_raise(eWIN32OLERuntimeError, "not found %s", StringValuePtr(cmdname)); return obj; };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@;9I"Gstatic VALUE fole_method_help(VALUE self, VALUE cmdname) { ITypeInfo *pTypeInfo; HRESULT hr; struct oledata *pole = NULL; VALUE obj; SafeStringValue(cmdname); pole = oledata_get_struct(self); hr = typeinfo_from_ole(pole, &pTypeInfo); if(FAILED(hr)) ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to get ITypeInfo"); obj = create_win32ole_method(pTypeInfo, cmdname); OLE_RELEASE(pTypeInfo); if (obj == Qnil) rb_raise(eWIN32OLERuntimeError, "not found %s", StringValuePtr(cmdname)); return obj; };T;:@;;T@o;4;5F;6;;;;&I"$WIN32OLE#ole_activex_initialize;F;7[;[[@$i(;T;:ole_activex_initialize;0;[;{;IC; "Initialize WIN32OLE object(ActiveX Control) by calling IPersistMemory::InitNew. Before calling OLE method, some kind of the ActiveX controls created with MFC should be initialized by calling IPersistXXX::InitNew. If and only if you received the exception "HRESULT error code: 0x8000ffff catastrophic failure", try this method before invoking any ole_method. obj = WIN32OLE.new("ProgID_or_GUID_of_ActiveX_Control") obj.ole_activex_initialize obj.method(...) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ole_activex_initialize();T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Qnil;T;$@;![;"I"@return [Qnil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I" Initialize WIN32OLE object(ActiveX Control) by calling IPersistMemory::InitNew. Before calling OLE method, some kind of the ActiveX controls created with MFC should be initialized by calling IPersistXXX::InitNew. If and only if you received the exception "HRESULT error code: 0x8000ffff catastrophic failure", try this method before invoking any ole_method. obj = WIN32OLE.new("ProgID_or_GUID_of_ActiveX_Control") obj.ole_activex_initialize obj.method(...) @overload ole_activex_initialize() @return [Qnil];T;#0;$@;.F;/o;0;1T;2i;3i&;%@;9I"~static VALUE fole_activex_initialize(VALUE self) { struct oledata *pole = NULL; IPersistMemory *pPersistMemory; void *p; HRESULT hr = S_OK; pole = oledata_get_struct(self); hr = pole->pDispatch->lpVtbl->QueryInterface(pole->pDispatch, &IID_IPersistMemory, &p); pPersistMemory = p; if (SUCCEEDED(hr)) { hr = pPersistMemory->lpVtbl->InitNew(pPersistMemory); OLE_RELEASE(pPersistMemory); if (SUCCEEDED(hr)) { return Qnil; } } if (FAILED(hr)) { ole_raise(hr, eWIN32OLERuntimeError, "fail to initialize ActiveX control"); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE#ole_type;F;7[;[[@$i ;T;;B;0;[;{;IC; "iReturns WIN32OLE_TYPE object. excel = WIN32OLE.new('Excel.Application') tobj = excel.ole_type ;T;[o;= ;>I" overload;F;?0;;B;@0;:I" ole_type;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"~Returns WIN32OLE_TYPE object. excel = WIN32OLE.new('Excel.Application') tobj = excel.ole_type @overload ole_type;T;#0;$o;4;5F;6;;;;&I"WIN32OLE#ole_obj_help;F;7[;[[@$i;F;:ole_obj_help;;;[;{;@!;%@;9I"cstatic VALUE fole_type(VALUE self) { ITypeInfo *pTypeInfo; HRESULT hr; struct oledata *pole = NULL; LCID lcid = cWIN32OLE_lcid; VALUE type = Qnil; pole = oledata_get_struct(self); hr = pole->pDispatch->lpVtbl->GetTypeInfo( pole->pDispatch, 0, lcid, &pTypeInfo ); if(FAILED(hr)) { ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetTypeInfo"); } type = ole_type_from_itypeinfo(pTypeInfo); OLE_RELEASE(pTypeInfo); if (type == Qnil) { rb_raise(rb_eRuntimeError, "failed to create WIN32OLE_TYPE obj from ITypeInfo"); } return type; };T;:I"static VALUE;T;.F;/o;0;1T;2i ;3i ;%@;9I"cstatic VALUE fole_type(VALUE self) { ITypeInfo *pTypeInfo; HRESULT hr; struct oledata *pole = NULL; LCID lcid = cWIN32OLE_lcid; VALUE type = Qnil; pole = oledata_get_struct(self); hr = pole->pDispatch->lpVtbl->GetTypeInfo( pole->pDispatch, 0, lcid, &pTypeInfo ); if(FAILED(hr)) { ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetTypeInfo"); } type = ole_type_from_itypeinfo(pTypeInfo); OLE_RELEASE(pTypeInfo); if (type == Qnil) { rb_raise(rb_eRuntimeError, "failed to create WIN32OLE_TYPE obj from ITypeInfo"); } return type; };T;:@5;;T@-o;4;5F;6;;;;&I"WIN32OLE#ole_typelib;F;7[;[[@$i ;T;;O;0;[;{;IC; "Returns the WIN32OLE_TYPELIB object. The object represents the type library which contains the WIN32OLE object. excel = WIN32OLE.new('Excel.Application') tlib = excel.ole_typelib puts tlib.name # -> 'Microsoft Excel 9.0 Object Library' ;T;[o;= ;>I" overload;F;?0;;O;@0;:I"ole_typelib;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" The WIN32OLE_TYPELIB object;T;$@8;![;"I"*@return [The WIN32OLE_TYPELIB object];T;#0;$@8;.F;Bi;C0;7[;$@8;![;"I"6Returns the WIN32OLE_TYPELIB object. The object represents the type library which contains the WIN32OLE object. excel = WIN32OLE.new('Excel.Application') tlib = excel.ole_typelib puts tlib.name # -> 'Microsoft Excel 9.0 Object Library' @overload ole_typelib @return [The WIN32OLE_TYPELIB object];T;#0;$@8;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE fole_typelib(VALUE self) { struct oledata *pole = NULL; HRESULT hr; ITypeInfo *pTypeInfo; LCID lcid = cWIN32OLE_lcid; VALUE vtlib = Qnil; pole = oledata_get_struct(self); hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch, 0, lcid, &pTypeInfo); if(FAILED(hr)) { ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to GetTypeInfo"); } vtlib = ole_typelib_from_itypeinfo(pTypeInfo); OLE_RELEASE(pTypeInfo); if (vtlib == Qnil) { rb_raise(rb_eRuntimeError, "failed to get type library info."); } return vtlib; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!WIN32OLE#ole_query_interface;F;7[[I" str_iid;T0;[[@$i ;T;:ole_query_interface;0;[;{;IC; "Returns WIN32OLE object for a specific dispatch or dual interface specified by iid. ie = WIN32OLE.new('InternetExplorer.Application') ie_web_app = ie.ole_query_interface('{0002DF05-0000-0000-C000-000000000046}') # => WIN32OLE object for dispinterface IWebBrowserApp ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ole_query_interface(iid);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"WIN32OLE object;T;$@S;![;"I"@return [WIN32OLE object];T;#0;$@S;.F;Bi;C0;7[[I"iid;T0;$@S;![;"I"SReturns WIN32OLE object for a specific dispatch or dual interface specified by iid. ie = WIN32OLE.new('InternetExplorer.Application') ie_web_app = ie.ole_query_interface('{0002DF05-0000-0000-C000-000000000046}') # => WIN32OLE object for dispinterface IWebBrowserApp @overload ole_query_interface(iid) @return [WIN32OLE object];T;#0;$@S;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE fole_query_interface(VALUE self, VALUE str_iid) { HRESULT hr; OLECHAR *pBuf; IID iid; struct oledata *pole = NULL; IDispatch *pDispatch; void *p; pBuf = ole_vstr2wc(str_iid); hr = CLSIDFromString(pBuf, &iid); SysFreeString(pBuf); if(FAILED(hr)) { ole_raise(hr, eWIN32OLERuntimeError, "invalid iid: `%s'", StringValuePtr(str_iid)); } pole = oledata_get_struct(self); if(!pole->pDispatch) { rb_raise(rb_eRuntimeError, "failed to get dispatch interface"); } hr = pole->pDispatch->lpVtbl->QueryInterface(pole->pDispatch, &iid, &p); if(FAILED(hr)) { ole_raise(hr, eWIN32OLEQueryInterfaceError, "failed to get interface `%s'", StringValuePtr(str_iid)); } pDispatch = p; return create_win32ole_object(cWIN32OLE, pDispatch, 0, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE#ole_respond_to?;F;7[[I" method;T0;[[@$i*;T;:ole_respond_to?;0;[;{;IC; "Returns true when OLE object has OLE method, otherwise returns false. ie = WIN32OLE.new('InternetExplorer.Application') ie.ole_respond_to?("gohome") => true;T;[o;= ;>I" overload;F;?0;;;@0;:I"ole_respond_to?(method);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@r;![;"I"@return [Boolean];T;#0;$@r;.F;Bi;C0;7[[I" method;T0;$@r;![;"I"Returns true when OLE object has OLE method, otherwise returns false. ie = WIN32OLE.new('InternetExplorer.Application') ie.ole_respond_to?("gohome") => true @overload ole_respond_to?(method) @return [Boolean];T;#0;$@r;.F;/o;0;1T;2i!;3i(;Bi;%@;9I"static VALUE fole_respond_to(VALUE self, VALUE method) { struct oledata *pole = NULL; BSTR wcmdname; DISPID DispID; HRESULT hr; if(!RB_TYPE_P(method, T_STRING) && !RB_TYPE_P(method, T_SYMBOL)) { rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)"); } if (RB_TYPE_P(method, T_SYMBOL)) { method = rb_sym2str(method); } pole = oledata_get_struct(self); wcmdname = ole_vstr2wc(method); hr = pole->pDispatch->lpVtbl->GetIDsOfNames( pole->pDispatch, &IID_NULL, &wcmdname, 1, cWIN32OLE_lcid, &DispID); SysFreeString(wcmdname); return SUCCEEDED(hr) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;u;[[@$i;F;;;;w;;;[;{;IC; " Version string of WIN32OLE. ;T;[;![;"I"!Version string of WIN32OLE. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"WIN32OLE::VERSION;F;xI""rb_str_new2(WIN32OLE_VERSION);To;u;[[@$i;F;;*;;w;;;[;{;IC; "void calcsum(int a, int b, out int c) { c = a + b; } then, the Ruby OLE(COM) client script to retrieve the value of argument c after invoking calcsum method is following: a = 10 b = 20 c = 0 comserver.calcsum(a, b, c) p c # => 0 p WIN32OLE::ARGV # => [10, 20, 30] You can use WIN32OLE_VARIANT object to retrieve the value of reference arguments instead of referring WIN32OLE::ARGV. ;T;[;![;"I"void calcsum(int a, int b, out int c) { c = a + b; } then, the Ruby OLE(COM) client script to retrieve the value of argument c after invoking calcsum method is following: a = 10 b = 20 c = 0 comserver.calcsum(a, b, c) p c # => 0 p WIN32OLE::ARGV # => [10, 20, 30] You can use WIN32OLE_VARIANT object to retrieve the value of reference arguments instead of referring WIN32OLE::ARGV. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"WIN32OLE::ARGV;F;xI"After invoking OLE methods with reference arguments, you can access the value of arguments by using ARGV. If the method of OLE(COM) server written by C#.NET is following;To;u;[[@$i;F;: CP_ACP;;w;;;[;{;IC; "BANSI code page. See WIN32OLE.codepage and WIN32OLE.codepage=. ;T;[;![;"I"CANSI code page. See WIN32OLE.codepage and WIN32OLE.codepage=. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"WIN32OLE::CP_ACP;F;xI"0;To;u;[[@$i;F;: CP_OEMCP;;w;;;[;{;IC; "AOEM code page. See WIN32OLE.codepage and WIN32OLE.codepage=. ;T;[;![;"I"BOEM code page. See WIN32OLE.codepage and WIN32OLE.codepage=. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"WIN32OLE::CP_OEMCP;F;xI"1;To;u;[[@$i;F;: CP_MACCP;;w;;;[;{;IC; "2 ;T;[;![;"I"2 ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"WIN32OLE::CP_MACCP;F;xI"RB_INT2FIX(CP_MACCP);To;u;[[@$i;F;:CP_THREAD_ACP;;w;;;[;{;IC; "Qcurrent thread ANSI code page. See WIN32OLE.codepage and WIN32OLE.codepage=. ;T;[;![;"I"Rcurrent thread ANSI code page. See WIN32OLE.codepage and WIN32OLE.codepage=. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"WIN32OLE::CP_THREAD_ACP;F;xI"3;To;u;[[@$i ;F;:CP_SYMBOL;;w;;;[;{;IC; "Dsymbol code page. See WIN32OLE.codepage and WIN32OLE.codepage=. ;T;[;![;"I"Esymbol code page. See WIN32OLE.codepage and WIN32OLE.codepage=. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"WIN32OLE::CP_SYMBOL;F;xI"42;To;u;[[@$i;F;: CP_UTF7;;w;;;[;{;IC; "CUTF-7 code page. See WIN32OLE.codepage and WIN32OLE.codepage=. ;T;[;![;"I"DUTF-7 code page. See WIN32OLE.codepage and WIN32OLE.codepage=. ;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"WIN32OLE::CP_UTF7;F;xI" 65000;To;u;[[@$i;F;: CP_UTF8;;w;;;[;{;IC; "CUTF-8 code page. See WIN32OLE.codepage and WIN32OLE.codepage=. ;T;[;![;"I"DUTF-8 code page. See WIN32OLE.codepage and WIN32OLE.codepage=. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"WIN32OLE::CP_UTF8;F;xI" 65001;To;u;[[@$i;F;:LOCALE_SYSTEM_DEFAULT;;w;;;[;{;IC; "Wdefault locale for the operating system. See WIN32OLE.locale and WIN32OLE.locale=. ;T;[;![;"I"Xdefault locale for the operating system. See WIN32OLE.locale and WIN32OLE.locale=. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"$WIN32OLE::LOCALE_SYSTEM_DEFAULT;F;xI" 0x0800;To;u;[[@$i ;F;:LOCALE_USER_DEFAULT;;w;;;[;{;IC; "Vdefault locale for the user or process. See WIN32OLE.locale and WIN32OLE.locale=. ;T;[;![;"I"Wdefault locale for the user or process. See WIN32OLE.locale and WIN32OLE.locale=. ;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;&I""WIN32OLE::LOCALE_USER_DEFAULT;F;xI" 0x0400;To;;IC;[o;u;[[I"&ext/win32ole/win32ole_variant_m.c;Ti;F;: VT_EMPTY;;w;;;[;{;IC; "'represents VT_EMPTY type constant. ;T;[;![;"I"(represents VT_EMPTY type constant. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I" WIN32OLE::VARIANT::VT_EMPTY;F;xI"RB_INT2FIX(VT_EMPTY);To;u;[[@i ;F;: VT_NULL;;w;;;[;{;IC; "&represents VT_NULL type constant. ;T;[;![;"I"'represents VT_NULL type constant. ;T;#0;$@$;.F;/o;0;1T;2i;3i;%@;&I"WIN32OLE::VARIANT::VT_NULL;F;xI"RB_INT2FIX(VT_NULL);To;u;[[@i%;F;: VT_I2;;w;;;[;{;IC; "$represents VT_I2 type constant. ;T;[;![;"I"%represents VT_I2 type constant. ;T;#0;$@0;.F;/o;0;1T;2i";3i#;%@;&I"WIN32OLE::VARIANT::VT_I2;F;xI"RB_INT2FIX(VT_I2);To;u;[[@i*;F;: VT_I4;;w;;;[;{;IC; "$represents VT_I4 type constant. ;T;[;![;"I"%represents VT_I4 type constant. ;T;#0;$@<;.F;/o;0;1T;2i';3i(;%@;&I"WIN32OLE::VARIANT::VT_I4;F;xI"RB_INT2FIX(VT_I4);To;u;[[@i/;F;: VT_R4;;w;;;[;{;IC; "$represents VT_R4 type constant. ;T;[;![;"I"%represents VT_R4 type constant. ;T;#0;$@H;.F;/o;0;1T;2i,;3i-;%@;&I"WIN32OLE::VARIANT::VT_R4;F;xI"RB_INT2FIX(VT_R4);To;u;[[@i4;F;: VT_R8;;w;;;[;{;IC; "$represents VT_R8 type constant. ;T;[;![;"I"%represents VT_R8 type constant. ;T;#0;$@T;.F;/o;0;1T;2i1;3i2;%@;&I"WIN32OLE::VARIANT::VT_R8;F;xI"RB_INT2FIX(VT_R8);To;u;[[@i9;F;: VT_CY;;w;;;[;{;IC; "$represents VT_CY type constant. ;T;[;![;"I"%represents VT_CY type constant. ;T;#0;$@`;.F;/o;0;1T;2i6;3i7;%@;&I"WIN32OLE::VARIANT::VT_CY;F;xI"RB_INT2FIX(VT_CY);To;u;[[@i>;F;: VT_DATE;;w;;;[;{;IC; "&represents VT_DATE type constant. ;T;[;![;"I"'represents VT_DATE type constant. ;T;#0;$@l;.F;/o;0;1T;2i;;3i<;%@;&I"WIN32OLE::VARIANT::VT_DATE;F;xI"RB_INT2FIX(VT_DATE);To;u;[[@iC;F;: VT_BSTR;;w;;;[;{;IC; "&represents VT_BSTR type constant. ;T;[;![;"I"'represents VT_BSTR type constant. ;T;#0;$@x;.F;/o;0;1T;2i@;3iA;%@;&I"WIN32OLE::VARIANT::VT_BSTR;F;xI"RB_INT2FIX(VT_BSTR);To;u;[[@iH;F;:VT_USERDEFINED;;w;;;[;{;IC; "-represents VT_USERDEFINED type constant. ;T;[;![;"I".represents VT_USERDEFINED type constant. ;T;#0;$@;.F;/o;0;1T;2iE;3iF;%@;&I"&WIN32OLE::VARIANT::VT_USERDEFINED;F;xI"RB_INT2FIX(VT_USERDEFINED);To;u;[[@iM;F;: VT_PTR;;w;;;[;{;IC; "%represents VT_PTR type constant. ;T;[;![;"I"&represents VT_PTR type constant. ;T;#0;$@;.F;/o;0;1T;2iJ;3iK;%@;&I"WIN32OLE::VARIANT::VT_PTR;F;xI"RB_INT2FIX(VT_PTR);To;u;[[@iR;F;:VT_DISPATCH;;w;;;[;{;IC; "*represents VT_DISPATCH type constant. ;T;[;![;"I"+represents VT_DISPATCH type constant. ;T;#0;$@;.F;/o;0;1T;2iO;3iP;%@;&I"#WIN32OLE::VARIANT::VT_DISPATCH;F;xI"RB_INT2FIX(VT_DISPATCH);To;u;[[@iW;F;: VT_ERROR;;w;;;[;{;IC; "'represents VT_ERROR type constant. ;T;[;![;"I"(represents VT_ERROR type constant. ;T;#0;$@;.F;/o;0;1T;2iT;3iU;%@;&I" WIN32OLE::VARIANT::VT_ERROR;F;xI"RB_INT2FIX(VT_ERROR);To;u;[[@i\;F;: VT_BOOL;;w;;;[;{;IC; "&represents VT_BOOL type constant. ;T;[;![;"I"'represents VT_BOOL type constant. ;T;#0;$@;.F;/o;0;1T;2iY;3iZ;%@;&I"WIN32OLE::VARIANT::VT_BOOL;F;xI"RB_INT2FIX(VT_BOOL);To;u;[[@ia;F;:VT_VARIANT;;w;;;[;{;IC; ")represents VT_VARIANT type constant. ;T;[;![;"I"*represents VT_VARIANT type constant. ;T;#0;$@;.F;/o;0;1T;2i^;3i_;%@;&I""WIN32OLE::VARIANT::VT_VARIANT;F;xI"RB_INT2FIX(VT_VARIANT);To;u;[[@if;F;:VT_UNKNOWN;;w;;;[;{;IC; ")represents VT_UNKNOWN type constant. ;T;[;![;"I"*represents VT_UNKNOWN type constant. ;T;#0;$@;.F;/o;0;1T;2ic;3id;%@;&I""WIN32OLE::VARIANT::VT_UNKNOWN;F;xI"RB_INT2FIX(VT_UNKNOWN);To;u;[[@ik;F;: VT_I1;;w;;;[;{;IC; "$represents VT_I1 type constant. ;T;[;![;"I"%represents VT_I1 type constant. ;T;#0;$@;.F;/o;0;1T;2ih;3ii;%@;&I"WIN32OLE::VARIANT::VT_I1;F;xI"RB_INT2FIX(VT_I1);To;u;[[@ip;F;: VT_UI1;;w;;;[;{;IC; "%represents VT_UI1 type constant. ;T;[;![;"I"&represents VT_UI1 type constant. ;T;#0;$@;.F;/o;0;1T;2im;3in;%@;&I"WIN32OLE::VARIANT::VT_UI1;F;xI"RB_INT2FIX(VT_UI1);To;u;[[@iu;F;: VT_UI2;;w;;;[;{;IC; "%represents VT_UI2 type constant. ;T;[;![;"I"&represents VT_UI2 type constant. ;T;#0;$@;.F;/o;0;1T;2ir;3is;%@;&I"WIN32OLE::VARIANT::VT_UI2;F;xI"RB_INT2FIX(VT_UI2);To;u;[[@iz;F;: VT_UI4;;w;;;[;{;IC; "%represents VT_UI4 type constant. ;T;[;![;"I"&represents VT_UI4 type constant. ;T;#0;$@;.F;/o;0;1T;2iw;3ix;%@;&I"WIN32OLE::VARIANT::VT_UI4;F;xI"RB_INT2FIX(VT_UI4);To;u;[[@i{;F;: VT_I8;;w;;;[;{;IC; "$represents VT_I8 type constant. ;T;[;![;"I"%represents VT_I8 type constant. ;T;#0;$@;.F;/o;0;1T;2i};3i~;%@;&I"WIN32OLE::VARIANT::VT_I8;F;xI"RB_INT2FIX(VT_I8);To;u;[[@i;F;: VT_UI8;;w;;;[;{;IC; "%represents VT_UI8 type constant. ;T;[;![;"I"&represents VT_UI8 type constant. ;T;#0;$@;.F;/o;0;1T;2i};3i~;%@;&I"WIN32OLE::VARIANT::VT_UI8;F;xI"RB_INT2FIX(VT_UI8);To;u;[[@i;F;: VT_INT;;w;;;[;{;IC; "%represents VT_INT type constant. ;T;[;![;"I"&represents VT_INT type constant. ;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;&I"WIN32OLE::VARIANT::VT_INT;F;xI"RB_INT2FIX(VT_INT);To;u;[[@i;F;: VT_UINT;;w;;;[;{;IC; "&represents VT_UINT type constant. ;T;[;![;"I"'represents VT_UINT type constant. ;T;#0;$@,;.F;/o;0;1T;2i;3i;%@;&I"WIN32OLE::VARIANT::VT_UINT;F;xI"RB_INT2FIX(VT_UINT);To;u;[[@i;F;: VT_ARRAY;;w;;;[;{;IC; "'represents VT_ARRAY type constant. ;T;[;![;"I"(represents VT_ARRAY type constant. ;T;#0;$@8;.F;/o;0;1T;2i;3i;%@;&I" WIN32OLE::VARIANT::VT_ARRAY;F;xI"RB_INT2FIX(VT_ARRAY);To;u;[[@i;F;: VT_BYREF;;w;;;[;{;IC; "'represents VT_BYREF type constant. ;T;[;![;"I"(represents VT_BYREF type constant. ;T;#0;$@D;.F;/o;0;1T;2i;3i;%@;&I" WIN32OLE::VARIANT::VT_BYREF;F;xI"RB_INT2FIX(VT_BYREF);T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i [@i;T;: VARIANT;;;;;[;{;IC; "The WIN32OLE::VARIANT module includes constants of VARIANT type constants. The constants is used when creating WIN32OLE_VARIANT object. obj = WIN32OLE_VARIANT.new("2e3", WIN32OLE::VARIANT::VT_R4) obj.value # => 2000.0 ;T;[;![;"I" The WIN32OLE::VARIANT module includes constants of VARIANT type constants. The constants is used when creating WIN32OLE_VARIANT object. obj = WIN32OLE_VARIANT.new("2e3", WIN32OLE::VARIANT::VT_R4) obj.value # => 2000.0 ;T;#0;$@;.F;/o;0;1T;2i ;3i;%@;&I"WIN32OLE::VARIANT;F; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{@;@-;B;[;[[@$iY [@$i;T;: WIN32OLE;;;;;[;{;IC; "3WIN32OLE objects represent OLE Automation object in Ruby. By using WIN32OLE, you can access OLE server like VBScript. Here is sample script. require 'win32ole' excel = WIN32OLE.new('Excel.Application') excel.visible = true workbook = excel.Workbooks.Add(); worksheet = workbook.Worksheets(1); worksheet.Range("A1:D1").value = ["North","South","East","West"]; worksheet.Range("A2:B2").value = [5.2, 10]; worksheet.Range("C2").value = 8; worksheet.Range("D2").value = 20; range = worksheet.Range("A1:D2"); range.select chart = workbook.Charts.Add; workbook.saved = true; excel.ActiveWorkbook.Close(0); excel.Quit(); Unfortunately, Win32OLE doesn't support the argument passed by reference directly. Instead, Win32OLE provides WIN32OLE::ARGV or WIN32OLE_VARIANT object. If you want to get the result value of argument passed by reference, you can use WIN32OLE::ARGV or WIN32OLE_VARIANT. oleobj.method(arg1, arg2, refargv3) puts WIN32OLE::ARGV[2] # the value of refargv3 after called oleobj.method or refargv3 = WIN32OLE_VARIANT.new(XXX, WIN32OLE::VARIANT::VT_BYREF|WIN32OLE::VARIANT::VT_XXX) oleobj.method(arg1, arg2, refargv3) p refargv3.value # the value of refargv3 after called oleobj.method.;T;[;![;"I"8 WIN32OLE objects represent OLE Automation object in Ruby. By using WIN32OLE, you can access OLE server like VBScript. Here is sample script. require 'win32ole' excel = WIN32OLE.new('Excel.Application') excel.visible = true workbook = excel.Workbooks.Add(); worksheet = workbook.Worksheets(1); worksheet.Range("A1:D1").value = ["North","South","East","West"]; worksheet.Range("A2:B2").value = [5.2, 10]; worksheet.Range("C2").value = 8; worksheet.Range("D2").value = 20; range = worksheet.Range("A1:D2"); range.select chart = workbook.Charts.Add; workbook.saved = true; excel.ActiveWorkbook.Close(0); excel.Quit(); Unfortunately, Win32OLE doesn't support the argument passed by reference directly. Instead, Win32OLE provides WIN32OLE::ARGV or WIN32OLE_VARIANT object. If you want to get the result value of argument passed by reference, you can use WIN32OLE::ARGV or WIN32OLE_VARIANT. oleobj.method(arg1, arg2, refargv3) puts WIN32OLE::ARGV[2] # the value of refargv3 after called oleobj.method or refargv3 = WIN32OLE_VARIANT.new(XXX, WIN32OLE::VARIANT::VT_BYREF|WIN32OLE::VARIANT::VT_XXX) oleobj.method(arg1, arg2, refargv3) p refargv3.value # the value of refargv3 after called oleobj.method. ;T;#0;$@;.F;/o;0;1T;2iY ;3i ;Bi;%@;&I" WIN32OLE;F;'@o; ;IC;[ o;4;5F;6;;;;&I" WIN32OLE_EVENT.message_loop;F;7[;[[I""ext/win32ole/win32ole_event.c;Ti;T;:message_loop;0;[;{;IC; "/Translates and dispatches Windows message. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"message_loop;T;IC; ";T;[;![;"I";T;#0;$@v;.F;Bi;C0;7[;$@v;![;"I"HTranslates and dispatches Windows message. @overload message_loop;T;#0;$@v;.F;/o;0;1T;2i;3i;%@t;9I"Vstatic VALUE fev_s_msg_loop(VALUE klass) { ole_msg_loop(); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_EVENT#initialize;F;7[[@90;[[@{i;T;;D;0;[;{;IC; "Returns OLE event object. The first argument specifies WIN32OLE object. The second argument specifies OLE event name. ie = WIN32OLE.new('InternetExplorer.Application') ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents') ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"/new(ole, event) #=> WIN32OLE_EVENT object.;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"ole;T0[I" event;T0;$@;![;"I"Returns OLE event object. The first argument specifies WIN32OLE object. The second argument specifies OLE event name. ie = WIN32OLE.new('InternetExplorer.Application') ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents') @overload new(ole, event) #=> WIN32OLE_EVENT object.;T;#0;$@;.F;/o;0;1T;2i;3i;%@t;9I"static VALUE fev_initialize(int argc, VALUE *argv, VALUE self) { ev_advise(argc, argv, self); evs_push(self); rb_ivar_set(self, id_events, rb_ary_new()); fev_set_handler(self, Qnil); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_EVENT#on_event;F;7[[@90;[[@{i:;T;: on_event;0;[;{;IC; "wDefines the callback event. If argument is omitted, this method defines the callback of all events. If you want to modify reference argument in callback, return hash in callback. If you want to return value to OLE server as result of callback use `return' or :return. ie = WIN32OLE.new('InternetExplorer.Application') ev = WIN32OLE_EVENT.new(ie) ev.on_event("NavigateComplete") {|url| puts url} ev.on_event() {|ev, *args| puts "#{ev} fired"} ev.on_event("BeforeNavigate2") {|*args| ... # set true to BeforeNavigate reference argument `Cancel'. # Cancel is 7-th argument of BeforeNavigate, # so you can use 6 as key of hash instead of 'Cancel'. # The argument is counted from 0. # The hash key of 0 means first argument.) {:Cancel => true} # or {'Cancel' => true} or {6 => true} } ev.on_event(...) {|*args| {:return => 1, :xxx => yyy} } ;T;[o;= ;>I" overload;F;?0;;;@0;:I"on_event([event]);T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@;![;"I"@yield [];T;#0;$@;.F;Bi;C0;7[[I" [event];T0;$@;![;"I"Defines the callback event. If argument is omitted, this method defines the callback of all events. If you want to modify reference argument in callback, return hash in callback. If you want to return value to OLE server as result of callback use `return' or :return. ie = WIN32OLE.new('InternetExplorer.Application') ev = WIN32OLE_EVENT.new(ie) ev.on_event("NavigateComplete") {|url| puts url} ev.on_event() {|ev, *args| puts "#{ev} fired"} ev.on_event("BeforeNavigate2") {|*args| ... # set true to BeforeNavigate reference argument `Cancel'. # Cancel is 7-th argument of BeforeNavigate, # so you can use 6 as key of hash instead of 'Cancel'. # The argument is counted from 0. # The hash key of 0 means first argument.) {:Cancel => true} # or {'Cancel' => true} or {6 => true} } ev.on_event(...) {|*args| {:return => 1, :xxx => yyy} } @overload on_event([event]) @yield [];T;#0;$@;.F;/o;0;1T;2i;3i8;%@t;9I"wstatic VALUE fev_on_event(int argc, VALUE *argv, VALUE self) { return ev_on_event(argc, argv, self, Qfalse); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I")WIN32OLE_EVENT#on_event_with_outargs;F;7[[@90;[[@{iN;T;:on_event_with_outargs;0;[;{;IC; "+Defines the callback of event. If you want modify argument in callback, you could use this method instead of WIN32OLE_EVENT#on_event. ie = WIN32OLE.new('InternetExplorer.Application') ev = WIN32OLE_EVENT.new(ie) ev.on_event_with_outargs('BeforeNavigate2') {|*args| args.last[6] = true } ;T;[o;= ;>I" overload;F;?0;;;@0;:I"#on_event_with_outargs([event]);T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@;![;"I"@yield [];T;#0;$@;.F;Bi;C0;7[[I" [event];T0;$@;![;"I"bDefines the callback of event. If you want modify argument in callback, you could use this method instead of WIN32OLE_EVENT#on_event. ie = WIN32OLE.new('InternetExplorer.Application') ev = WIN32OLE_EVENT.new(ie) ev.on_event_with_outargs('BeforeNavigate2') {|*args| args.last[6] = true } @overload on_event_with_outargs([event]) @yield [];T;#0;$@;.F;/o;0;1T;2i@;3iL;%@t;9I"~static VALUE fev_on_event_with_outargs(int argc, VALUE *argv, VALUE self) { return ev_on_event(argc, argv, self, Qtrue); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_EVENT#off_event;F;7[[@90;[[@{ic;T;:off_event;0;[;{;IC; "removes the callback of event. ie = WIN32OLE.new('InternetExplorer.Application') ev = WIN32OLE_EVENT.new(ie) ev.on_event('BeforeNavigate2') {|*args| args.last[6] = true } ... ev.off_event('BeforeNavigate2') ... ;T;[o;= ;>I" overload;F;?0;;;@0;:I"off_event([event]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" [event];T0;$@;![;"I"removes the callback of event. ie = WIN32OLE.new('InternetExplorer.Application') ev = WIN32OLE_EVENT.new(ie) ev.on_event('BeforeNavigate2') {|*args| args.last[6] = true } ... ev.off_event('BeforeNavigate2') ... @overload off_event([event]);T;#0;$@;.F;/o;0;1T;2iT;3i`;%@t;9I"Qstatic VALUE fev_off_event(int argc, VALUE *argv, VALUE self) { VALUE event = Qnil; VALUE events; rb_scan_args(argc, argv, "01", &event); if(!NIL_P(event)) { if(!RB_TYPE_P(event, T_STRING) && !RB_TYPE_P(event, T_SYMBOL)) { rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)"); } if (RB_TYPE_P(event, T_SYMBOL)) { event = rb_sym2str(event); } } events = rb_ivar_get(self, id_events); if (NIL_P(events)) { return Qnil; } ole_delete_event(events, event); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_EVENT#unadvise;F;7[;[[@{i;T;: unadvise;0;[;{;IC; ",disconnects OLE server. If this method called, then the WIN32OLE_EVENT object does not receive the OLE server event any more. This method is trial implementation. ie = WIN32OLE.new('InternetExplorer.Application') ev = WIN32OLE_EVENT.new(ie) ev.on_event() {...} ... ev.unadvise ;T;[o;= ;>I" overload;F;?0;;;@0;:I" unadvise;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Rdisconnects OLE server. If this method called, then the WIN32OLE_EVENT object does not receive the OLE server event any more. This method is trial implementation. ie = WIN32OLE.new('InternetExplorer.Application') ev = WIN32OLE_EVENT.new(ie) ev.on_event() {...} ... ev.unadvise @overload unadvise @return [nil];T;#0;$@;.F;/o;0;1T;2iz;3i;%@t;9I"static VALUE fev_unadvise(VALUE self) { struct oleeventdata *poleev; TypedData_Get_Struct(self, struct oleeventdata, &oleevent_datatype, poleev); if (poleev->pConnectionPoint) { ole_msg_loop(); evs_delete(poleev->event_id); poleev->pConnectionPoint->lpVtbl->Unadvise(poleev->pConnectionPoint, poleev->dwCookie); OLE_RELEASE(poleev->pConnectionPoint); poleev->pConnectionPoint = NULL; } OLE_FREE(poleev->pDispatch); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_EVENT#handler=;F;7[[I"val;T0;[[@{i;T;: handler=;0;[;{;IC; "sets event handler object. If handler object has onXXX method according to XXX event, then onXXX method is called when XXX event occurs. If handler object has method_missing and there is no method according to the event, then method_missing called and 1-st argument is event name. If handler object has onXXX method and there is block defined by WIN32OLE_EVENT#on_event('XXX'){}, then block is executed but handler object method is not called when XXX event occurs. class Handler def onStatusTextChange(text) puts "StatusTextChanged" end def onPropertyChange(prop) puts "PropertyChanged" end def method_missing(ev, *arg) puts "other event #{ev}" end end handler = Handler.new ie = WIN32OLE.new('InternetExplorer.Application') ev = WIN32OLE_EVENT.new(ie) ev.on_event("StatusTextChange") {|*args| puts "this block executed." puts "handler.onStatusTextChange method is not called." } ev.handler = handler ;T;[o;= ;>I" overload;F;?0;;;@0;:I" handler=;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"sets event handler object. If handler object has onXXX method according to XXX event, then onXXX method is called when XXX event occurs. If handler object has method_missing and there is no method according to the event, then method_missing called and 1-st argument is event name. If handler object has onXXX method and there is block defined by WIN32OLE_EVENT#on_event('XXX'){}, then block is executed but handler object method is not called when XXX event occurs. class Handler def onStatusTextChange(text) puts "StatusTextChanged" end def onPropertyChange(prop) puts "PropertyChanged" end def method_missing(ev, *arg) puts "other event #{ev}" end end handler = Handler.new ie = WIN32OLE.new('InternetExplorer.Application') ev = WIN32OLE_EVENT.new(ie) ev.on_event("StatusTextChange") {|*args| puts "this block executed." puts "handler.onStatusTextChange method is not called." } ev.handler = handler @overload handler=;T;#0;$@;.F;/o;0;1T;2i;3i;%@t;9I"ustatic VALUE fev_set_handler(VALUE self, VALUE val) { return rb_ivar_set(self, rb_intern("handler"), val); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"WIN32OLE_EVENT#handler;F;7[;[[@{i;T;: handler;0;[;{;IC; "returns handler object. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" handler;T;IC; ";T;[;![;"I";T;#0;$@,;.F;Bi;C0;7[;$@,;![;"I"1returns handler object. @overload handler;T;#0;$@,;.F;/o;0;1T;2i;3i;%@t;9I"estatic VALUE fev_get_handler(VALUE self) { return rb_ivar_get(self, rb_intern("handler")); };T;:I"static VALUE;T;;T; @t; IC;[; @t; IC;[; @t; IC;{;IC;{;T;IC;{;T;T;{;[;[[@{i[@{i;T;:WIN32OLE_EVENT;;;;;[;{;IC; "<WIN32OLE_EVENT objects controls OLE event.;T;[;![;"I"@ WIN32OLE_EVENT objects controls OLE event. ;T;#0;$@t;.F;/o;0;1T;2i;3i ;Bi;%@;&I"WIN32OLE_EVENT;F;'@o; ;IC;[; @T; IC;[; @T; IC;[; @T; IC;{;IC;{;T;IC;{;T;T;{;[;[[I" string.c;Ti+;T;: Symbol;;;;;[;{;IC; "******************************************************************** Symbol objects represent named identifiers inside the Ruby interpreter. You can create a \Symbol object explicitly with: - A {symbol literal}[doc/syntax/literals_rdoc.html#label-Symbol+Literals]. The same Symbol object will be created for a given name or string for the duration of a program's execution, regardless of the context or meaning of that name. Thus if Fred is a constant in one context, a method in another, and a class in a third, the Symbol :Fred will be the same object in all three contexts. module One class Fred end $f1 = :Fred end module Two Fred = 1 $f2 = :Fred end def Fred() end $f3 = :Fred $f1.object_id #=> 2514190 $f2.object_id #=> 2514190 $f3.object_id #=> 2514190 Constant, method, and variable names are returned as symbols: module One Two = 2 def three; 3 end @four = 4 @@five = 5 $six = 6 end seven = 7 One.constants # => [:Two] One.instance_methods(true) # => [:three] One.instance_variables # => [:@four] One.class_variables # => [:@@five] global_variables.grep(/six/) # => [:$six] local_variables # => [:seven] Symbol objects are different from String objects in that Symbol objects represent identifiers, while String objects represent text or data. == What's Here First, what's elsewhere. \Class \Symbol: - Inherits from {class Object}[Object.html#class-Object-label-What-27s+Here]. - Includes {module Comparable}[Comparable.html#module-Comparable-label-What-27s+Here]. Here, class \Symbol provides methods that are useful for: - {Querying}[#class-Symbol-label-Methods+for+Querying] - {Comparing}[#class-Symbol-label-Methods+for+Comparing] - {Converting}[#class-Symbol-label-Methods+for+Converting] === Methods for Querying - ::all_symbols:: Returns an array of the symbols currently in Ruby's symbol table. - {#=~}[#method-i-3D~]:: Returns the index of the first substring in symbol that matches a given Regexp or other object; returns +nil+ if no match is found. - #[], #slice :: Returns a substring of symbol determined by a given index, start/length, or range, or string. - #empty?:: Returns +true+ if +self.length+ is zero; +false+ otherwise. - #encoding:: Returns the Encoding object that represents the encoding of symbol. - #end_with?:: Returns +true+ if symbol ends with any of the given strings. - #match:: Returns a MatchData object if symbol matches a given Regexp; +nil+ otherwise. - #match?:: Returns +true+ if symbol matches a given Regexp; +false+ otherwise. - #length, #size:: Returns the number of characters in symbol. - #start_with?:: Returns +true+ if symbol starts with any of the given strings. === Methods for Comparing - {#<=>}[#method-i-3C-3D-3E]:: Returns -1, 0, or 1 as a given symbol is smaller than, equal to, or larger than symbol. - {#==, #===}[#method-i-3D-3D]:: Returns +true+ if a given symbol has the same content and encoding. - #casecmp:: Ignoring case, returns -1, 0, or 1 as a given symbol is smaller than, equal to, or larger than symbol. - #casecmp?:: Returns +true+ if symbol is equal to a given symbol after Unicode case folding; +false+ otherwise. === Methods for Converting - #capitalize:: Returns symbol with the first character upcased and all other characters downcased. - #downcase:: Returns symbol with all characters downcased. - #inspect:: Returns the string representation of +self+ as a symbol literal. - #name:: Returns the frozen string corresponding to symbol. - #succ, #next:: Returns the symbol that is the successor to symbol. - #swapcase:: Returns symbol with all upcase characters downcased and all downcase characters upcased. - #to_proc:: Returns a Proc object which responds to the method named by symbol. - #to_s, #id2name:: Returns the string corresponding to +self+. - #to_sym, #intern:: Returns +self+. - #upcase:: Returns symbol with all characters upcased. ;T;[;![;"I"******************************************************************** Symbol objects represent named identifiers inside the Ruby interpreter. You can create a \Symbol object explicitly with: - A {symbol literal}[doc/syntax/literals_rdoc.html#label-Symbol+Literals]. The same Symbol object will be created for a given name or string for the duration of a program's execution, regardless of the context or meaning of that name. Thus if Fred is a constant in one context, a method in another, and a class in a third, the Symbol :Fred will be the same object in all three contexts. module One class Fred end $f1 = :Fred end module Two Fred = 1 $f2 = :Fred end def Fred() end $f3 = :Fred $f1.object_id #=> 2514190 $f2.object_id #=> 2514190 $f3.object_id #=> 2514190 Constant, method, and variable names are returned as symbols: module One Two = 2 def three; 3 end @four = 4 @@five = 5 $six = 6 end seven = 7 One.constants # => [:Two] One.instance_methods(true) # => [:three] One.instance_variables # => [:@four] One.class_variables # => [:@@five] global_variables.grep(/six/) # => [:$six] local_variables # => [:seven] Symbol objects are different from String objects in that Symbol objects represent identifiers, while String objects represent text or data. == What's Here First, what's elsewhere. \Class \Symbol: - Inherits from {class Object}[Object.html#class-Object-label-What-27s+Here]. - Includes {module Comparable}[Comparable.html#module-Comparable-label-What-27s+Here]. Here, class \Symbol provides methods that are useful for: - {Querying}[#class-Symbol-label-Methods+for+Querying] - {Comparing}[#class-Symbol-label-Methods+for+Comparing] - {Converting}[#class-Symbol-label-Methods+for+Converting] === Methods for Querying - ::all_symbols:: Returns an array of the symbols currently in Ruby's symbol table. - {#=~}[#method-i-3D~]:: Returns the index of the first substring in symbol that matches a given Regexp or other object; returns +nil+ if no match is found. - #[], #slice :: Returns a substring of symbol determined by a given index, start/length, or range, or string. - #empty?:: Returns +true+ if +self.length+ is zero; +false+ otherwise. - #encoding:: Returns the Encoding object that represents the encoding of symbol. - #end_with?:: Returns +true+ if symbol ends with any of the given strings. - #match:: Returns a MatchData object if symbol matches a given Regexp; +nil+ otherwise. - #match?:: Returns +true+ if symbol matches a given Regexp; +false+ otherwise. - #length, #size:: Returns the number of characters in symbol. - #start_with?:: Returns +true+ if symbol starts with any of the given strings. === Methods for Comparing - {#<=>}[#method-i-3C-3D-3E]:: Returns -1, 0, or 1 as a given symbol is smaller than, equal to, or larger than symbol. - {#==, #===}[#method-i-3D-3D]:: Returns +true+ if a given symbol has the same content and encoding. - #casecmp:: Ignoring case, returns -1, 0, or 1 as a given symbol is smaller than, equal to, or larger than symbol. - #casecmp?:: Returns +true+ if symbol is equal to a given symbol after Unicode case folding; +false+ otherwise. === Methods for Converting - #capitalize:: Returns symbol with the first character upcased and all other characters downcased. - #downcase:: Returns symbol with all characters downcased. - #inspect:: Returns the string representation of +self+ as a symbol literal. - #name:: Returns the frozen string corresponding to symbol. - #succ, #next:: Returns the symbol that is the successor to symbol. - #swapcase:: Returns symbol with all upcase characters downcased and all downcase characters upcased. - #to_proc:: Returns a Proc object which responds to the method named by symbol. - #to_s, #id2name:: Returns the string corresponding to +self+. - #to_sym, #intern:: Returns +self+. - #upcase:: Returns symbol with all characters upcased. ;T;#0;$@T;.F;/o;0;1T;2i+;3id,;%@;&I" Symbol;F;'o;( ;)0;*0;+0;;;%@;-@;0o; ;IC;[o;4;5F;6;;;;&I"Random#initialize_copy;F;7[[I" orig;T0;[[@ i;T;;];0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@k;.F;/o;0;1T;2i;3i;%@i;9I"Istatic VALUE rand_mt_copy(VALUE obj, VALUE orig) { rb_random_mt_t *rnd1, *rnd2; struct MT *mt; if (!OBJ_INIT_COPY(obj, orig)) return obj; rnd1 = get_rnd_mt(obj); rnd2 = get_rnd_mt(orig); mt = &rnd1->mt; *rnd1 = *rnd2; mt->next = mt->state + numberof(mt->state) - mt->left + 1; return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random#marshal_dump;F;7[;[[@ i=;T;;[;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@{;.F;/o;0;1T;2i<;3i<;%@i;9I" static VALUE rand_mt_dump(VALUE obj) { rb_random_mt_t *rnd = rb_check_typeddata(obj, &random_mt_type); VALUE dump = rb_ary_new2(3); rb_ary_push(dump, mt_state(&rnd->mt)); rb_ary_push(dump, INT2FIX(rnd->mt.left)); rb_ary_push(dump, rnd->base.seed); return dump; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random#marshal_load;F;7[[I" dump;T0;[[@ iK;T;;;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2iJ;3iJ;%@i;9I"static VALUE rand_mt_load(VALUE obj, VALUE dump) { rb_random_mt_t *rnd = rb_check_typeddata(obj, &random_mt_type); struct MT *mt = &rnd->mt; VALUE state, left = INT2FIX(1), seed = INT2FIX(0); unsigned long x; rb_check_copyable(obj, dump); Check_Type(dump, T_ARRAY); switch (RARRAY_LEN(dump)) { case 3: seed = RARRAY_AREF(dump, 2); case 2: left = RARRAY_AREF(dump, 1); case 1: state = RARRAY_AREF(dump, 0); break; default: rb_raise(rb_eArgError, "wrong dump data"); } rb_integer_pack(state, mt->state, numberof(mt->state), sizeof(*mt->state), 0, INTEGER_PACK_LSWORD_FIRST|INTEGER_PACK_NATIVE_BYTE_ORDER); x = NUM2ULONG(left); if (x > numberof(mt->state)) { rb_raise(rb_eArgError, "wrong value"); } mt->left = (unsigned int)x; mt->next = mt->state + numberof(mt->state) - x + 1; rnd->base.seed = rb_to_int(seed); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random#state;F;7[;[[@ i;T;;;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2i;3i;%@i;9I"xstatic VALUE rand_mt_state(VALUE obj) { rb_random_mt_t *rnd = get_rnd_mt(obj); return mt_state(&rnd->mt); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random#left;F;7[;[[@ i.;T;: left;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2i-;3i-;%@i;9I"zstatic VALUE rand_mt_left(VALUE obj) { rb_random_mt_t *rnd = get_rnd_mt(obj); return INT2FIX(rnd->mt.left); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random#==;F;7[[I" other;T0;[[@ i<;T;;F;0;[;{;IC; "lReturns true if the two generators have the same internal state, otherwise false. Equivalent generators will return the same sequence of pseudo-random numbers. Two generators will generally have the same state only if they were initialized with the same seed Random.new == Random.new # => false Random.new(1234) == Random.new(1234) # => true and have the same invocation history. prng1 = Random.new(1234) prng2 = Random.new(1234) prng1 == prng2 # => true prng1.rand # => 0.1915194503788923 prng1 == prng2 # => false prng2.rand # => 0.1915194503788923 prng1 == prng2 # => true ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(prng2);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" prng2;T0;$@;![;"I"Returns true if the two generators have the same internal state, otherwise false. Equivalent generators will return the same sequence of pseudo-random numbers. Two generators will generally have the same state only if they were initialized with the same seed Random.new == Random.new # => false Random.new(1234) == Random.new(1234) # => true and have the same invocation history. prng1 = Random.new(1234) prng2 = Random.new(1234) prng1 == prng2 # => true prng1.rand # => 0.1915194503788923 prng1 == prng2 # => false prng2.rand # => 0.1915194503788923 prng1 == prng2 # => true @overload ==(prng2) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i$;3i:;%@i;9I"static VALUE rand_mt_equal(VALUE self, VALUE other) { rb_random_mt_t *r1, *r2; if (rb_obj_class(self) != rb_obj_class(other)) return Qfalse; r1 = get_rnd_mt(self); r2 = get_rnd_mt(other); if (memcmp(r1->mt.state, r2->mt.state, sizeof(r1->mt.state))) return Qfalse; if ((r1->mt.next - r1->mt.state) != (r2->mt.next - r2->mt.state)) return Qfalse; if (r1->mt.left != r2->mt.left) return Qfalse; return rb_equal(r1->base.seed, r2->base.seed); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random#initialize;F;7[[@90;[[@ i;T;;D;0;[;{;IC; "Creates a new PRNG using +seed+ to set the initial state. If +seed+ is omitted, the generator is initialized with Random.new_seed. See Random.srand for more information on the use of seed values. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I" new(seed = Random.new_seed);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" seed;TI"Random.new_seed;T;$@;![;"I"Creates a new PRNG using +seed+ to set the initial state. If +seed+ is omitted, the generator is initialized with Random.new_seed. See Random.srand for more information on the use of seed values. @overload new(seed = Random.new_seed);T;#0;$@;.F;/o;0;1T;2i;3i;%@i;9I"static VALUE random_init(int argc, VALUE *argv, VALUE obj) { rb_random_t *rnd = try_get_rnd(obj); const rb_random_interface_t *rng = rb_rand_if(obj); if (!rng) { rb_raise(rb_eTypeError, "undefined random interface: %s", RTYPEDDATA_TYPE(obj)->wrap_struct_name); } argc = rb_check_arity(argc, 0, 1); rb_check_frozen(obj); if (argc == 0) { rnd->seed = rand_init_default(rng, rnd); } else { rnd->seed = rand_init(rng, rnd, rb_to_int(argv[0])); } return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random#rand;F;7[[@90;[[@ i;T;;;0;[;{;IC; "When +max+ is an Integer, +rand+ returns a random integer greater than or equal to zero and less than +max+. Unlike Kernel.rand, when +max+ is a negative integer or zero, +rand+ raises an ArgumentError. prng = Random.new prng.rand(100) # => 42 When +max+ is a Float, +rand+ returns a random floating point number between 0.0 and +max+, including 0.0 and excluding +max+. prng.rand(1.5) # => 1.4600282860034115 When +range+ is a Range, +rand+ returns a random number where range.member?(number) == true. prng.rand(5..9) # => one of [5, 6, 7, 8, 9] prng.rand(5...9) # => one of [5, 6, 7, 8] prng.rand(5.0..9.0) # => between 5.0 and 9.0, including 9.0 prng.rand(5.0...9.0) # => between 5.0 and 9.0, excluding 9.0 Both the beginning and ending values of the range must respond to subtract (-) and add (+)methods, or rand will raise an ArgumentError. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" rand;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"rand(max);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@;![;"I"@return [Numeric];T;#0;$@;.F;Bi;C0;7[[I"max;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"rand(range);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@;![;"I"@return [Numeric];T;#0;$@;.F;Bi;C0;7[[I" range;T0;$@;![;"I" When +max+ is an Integer, +rand+ returns a random integer greater than or equal to zero and less than +max+. Unlike Kernel.rand, when +max+ is a negative integer or zero, +rand+ raises an ArgumentError. prng = Random.new prng.rand(100) # => 42 When +max+ is a Float, +rand+ returns a random floating point number between 0.0 and +max+, including 0.0 and excluding +max+. prng.rand(1.5) # => 1.4600282860034115 When +range+ is a Range, +rand+ returns a random number where range.member?(number) == true. prng.rand(5..9) # => one of [5, 6, 7, 8, 9] prng.rand(5...9) # => one of [5, 6, 7, 8] prng.rand(5.0..9.0) # => between 5.0 and 9.0, including 9.0 prng.rand(5.0...9.0) # => between 5.0 and 9.0, excluding 9.0 Both the beginning and ending values of the range must respond to subtract (-) and add (+)methods, or rand will raise an ArgumentError. @overload rand @return [Float] @overload rand(max) @return [Numeric] @overload rand(range) @return [Numeric];T;#0;$@;.F;/o;0;1T;2i;3i;%@i;9I"static VALUE random_rand(int argc, VALUE *argv, VALUE obj) { VALUE v = rand_random(argc, argv, obj, try_get_rnd(obj)); check_random_number(v, argv); return v; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random#bytes;F;7[[I"len;T0;[[@ i;T;: bytes;0;[;{;IC; "Returns a random binary string containing +size+ bytes. random_string = Random.new.bytes(10) # => "\xD7:R\xAB?\x83\xCE\xFAkO" random_string.size # => 10 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"bytes(size);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@(;![;"I"@return [String];T;#0;$@(;.F;Bi;C0;7[[I" size;T0;$@(;![;"I"Returns a random binary string containing +size+ bytes. random_string = Random.new.bytes(10) # => "\xD7:R\xAB?\x83\xCE\xFAkO" random_string.size # => 10 @overload bytes(size) @return [String];T;#0;$@(;.F;/o;0;1T;2i;3i;%@i;9I"static VALUE random_bytes(VALUE obj, VALUE len) { rb_random_t *rnd = try_get_rnd(obj); return rand_bytes(rb_rand_if(obj), rnd, NUM2LONG(rb_to_int(len))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random#seed;F;7[;[[@ i;T;;;0;[;{;IC; "PReturns the seed value used to initialize the generator. This may be used to initialize another generator with the same state at a later time, causing it to produce the same sequence of numbers. prng1 = Random.new(1234) prng1.seed #=> 1234 prng1.rand(100) #=> 47 prng2 = Random.new(prng1.seed) prng2.rand(100) #=> 47 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" seed;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@G;![;"I"@return [Integer];T;#0;$@G;.F;Bi;C0;7[;$@G;![;"I"uReturns the seed value used to initialize the generator. This may be used to initialize another generator with the same state at a later time, causing it to produce the same sequence of numbers. prng1 = Random.new(1234) prng1.seed #=> 1234 prng1.rand(100) #=> 47 prng2 = Random.new(prng1.seed) prng2.rand(100) #=> 47 @overload seed @return [Integer];T;#0;$@G;.F;/o;0;1T;2i;3i;%@i;9I"Ostatic VALUE random_get_seed(VALUE obj) { return get_rnd(obj)->seed; };T;:I"static VALUE;T;;To;u;[[@ i;F;: DEFAULT;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@b;%@i;&I"Random::DEFAULT;F;xI"rb_cRandom;To;4;5F;6;;;;&I"Random.srand;F;7[[@90;[[@ i;T;;;0;[;{;IC; "hSeeds the system pseudo-random number generator, with +number+. The previous seed value is returned. If +number+ is omitted, seeds the generator using a source of entropy provided by the operating system, if available (/dev/urandom on Unix systems or the RSA cryptographic provider on Windows), which is then combined with the time, the process id, and a sequence number. srand may be used to ensure repeatable sequences of pseudo-random numbers between different runs of the program. By setting the seed to a known value, programs can be made deterministic during testing. srand 1234 # => 268519324636777531569100071560086917274 [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319] [ rand(10), rand(1000) ] # => [4, 664] srand 1234 # => 1234 [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"$srand(number = Random.new_seed);T;IC; ";T;[;![;"I";T;#0;$@l;.F;Bi;C0;7[[I" number;TI"Random.new_seed;T;$@l;![;"@ ;#0;$@l;.F;/o;0;1T;2i;3i;%@i;9I"ystatic VALUE rb_f_srand(int argc, VALUE *argv, VALUE obj) { VALUE seed, old; rb_random_mt_t *r = rand_mt_start(default_rand()); if (rb_check_arity(argc, 0, 1) == 0) { seed = random_seed(obj); } else { seed = rb_to_int(argv[0]); } old = r->base.seed; rand_init(&random_mt_if, &r->base, seed); r->base.seed = seed; return old; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random.rand;F;7[[@90;[[@ i;T;;;0;[;{;IC; "OReturns a random number using the Ruby system PRNG. See also Random#rand. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" rand;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"rand(max);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@;![;"I"@return [Numeric];T;#0;$@;.F;Bi;C0;7[[I"max;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"rand(range);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@;![;"I"@return [Numeric];T;#0;$@;.F;Bi;C0;7[[I" range;T0;$@;![;"I"Returns a random number using the Ruby system PRNG. See also Random#rand. @overload rand @return [Float] @overload rand(max) @return [Numeric] @overload rand(range) @return [Numeric];T;#0;$@;.F;/o;0;1T;2iz;3i;%@i;9I"static VALUE random_s_rand(int argc, VALUE *argv, VALUE obj) { VALUE v = rand_random(argc, argv, Qnil, rand_start(default_rand())); check_random_number(v, argv); return v; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random.bytes;F;7[[I"len;T0;[[@ i ;T;;;0;[;{;IC; "eReturns a random binary string. The argument +size+ specifies the length of the returned string. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"bytes(size);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I" size;T0;$@;![;"I"Returns a random binary string. The argument +size+ specifies the length of the returned string. @overload bytes(size) @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@i;9I"static VALUE random_s_bytes(VALUE obj, VALUE len) { rb_random_t *rnd = rand_start(default_rand()); return rand_bytes(&random_mt_if, rnd, NUM2LONG(rb_to_int(len))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random.seed;F;7[;[[@ i;T;;;0;[;{;IC; "tReturns the seed value used to initialize the Ruby system PRNG. This may be used to initialize another generator with the same state at a later time, causing it to produce the same sequence of numbers. Random.seed #=> 1234 prng1 = Random.new(Random.seed) prng1.seed #=> 1234 prng1.rand(100) #=> 47 Random.seed #=> 1234 Random.rand(100) #=> 47 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" seed;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the seed value used to initialize the Ruby system PRNG. This may be used to initialize another generator with the same state at a later time, causing it to produce the same sequence of numbers. Random.seed #=> 1234 prng1 = Random.new(Random.seed) prng1.seed #=> 1234 prng1.rand(100) #=> 47 Random.seed #=> 1234 Random.rand(100) #=> 47 @overload seed @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@i;9I"}static VALUE random_s_seed(VALUE obj) { rb_random_mt_t *rnd = rand_mt_start(default_rand()); return rnd->base.seed; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random.new_seed;F;7[;[[@ i;T;: new_seed;0;[;{;IC; "Returns an arbitrary seed value. This is used by Random.new when no seed value is specified as an argument. Random.new_seed #=> 115032730400174366788466674494640623225 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" new_seed;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns an arbitrary seed value. This is used by Random.new when no seed value is specified as an argument. Random.new_seed #=> 115032730400174366788466674494640623225 @overload new_seed @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@i;9I"static VALUE random_seed(VALUE _) { VALUE v; with_random_seed(DEFAULT_SEED_CNT, 1) { v = make_seed_value(seedbuf, DEFAULT_SEED_CNT); } return v; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random.urandom;F;7[[I" size;T0;[[@ i;T;: urandom;0;[;{;IC; "Returns a string, using platform providing features. Returned value is expected to be a cryptographically secure pseudo-random number in binary form. This method raises a RuntimeError if the feature provided by platform failed to prepare the result. In 2017, Linux manpage random(7) writes that "no cryptographic primitive available today can hope to promise more than 256 bits of security". So it might be questionable to pass size > 32 to this method. Random.urandom(8) #=> "\x78\x41\xBA\xAF\x7D\xEA\xD8\xEA" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"urandom(size);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[[I" size;T0;$@ ;![;"I"1Returns a string, using platform providing features. Returned value is expected to be a cryptographically secure pseudo-random number in binary form. This method raises a RuntimeError if the feature provided by platform failed to prepare the result. In 2017, Linux manpage random(7) writes that "no cryptographic primitive available today can hope to promise more than 256 bits of security". So it might be questionable to pass size > 32 to this method. Random.urandom(8) #=> "\x78\x41\xBA\xAF\x7D\xEA\xD8\xEA" @overload urandom(size) @return [String];T;#0;$@ ;.F;/o;0;1T;2i;3i;%@i;9I"static VALUE random_raw_seed(VALUE self, VALUE size) { long n = NUM2ULONG(size); VALUE buf = rb_str_new(0, n); if (n == 0) return buf; if (fill_random_bytes(RSTRING_PTR(buf), n, TRUE)) rb_raise(rb_eRuntimeError, "failed to get urandom"); return buf; };T;:I"static VALUE;T;;To;;IC;[o;4;5F;6;;;;&I"$Random::Formatter#random_number;F;7[[@90;[[@ i;T;:random_number;0;[;{;IC; "NGenerates formatted random number from raw random bytes. See Random#rand. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"random_number;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@5 ;![;"I"@return [Float];T;#0;$@5 ;.F;Bi;C0;7[;$@5 o;= ;>I" overload;F;?0;;;@0;:I"random_number(max);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@5 ;![;"I"@return [Numeric];T;#0;$@5 ;.F;Bi;C0;7[[I"max;T0;$@5 o;= ;>I" overload;F;?0;;;@0;:I"random_number(range);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@5 ;![;"I"@return [Numeric];T;#0;$@5 ;.F;Bi;C0;7[[I" range;T0;$@5 o;= ;>I" overload;F;?0;;;@0;:I" rand;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@5 ;![;"I"@return [Float];T;#0;$@5 ;.F;Bi;C0;7[;$@5 o;= ;>I" overload;F;?0;;;@0;:I"rand(max);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@5 ;![;"I"@return [Numeric];T;#0;$@5 ;.F;Bi;C0;7[[I"max;T0;$@5 o;= ;>I" overload;F;?0;;;@0;:I"rand(range);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@5 ;![;"I"@return [Numeric];T;#0;$@5 ;.F;Bi;C0;7[[I" range;T0;$@5 ;![;"I"LGenerates formatted random number from raw random bytes. See Random#rand. @overload random_number @return [Float] @overload random_number(max) @return [Numeric] @overload random_number(range) @return [Numeric] @overload rand @return [Float] @overload rand(max) @return [Numeric] @overload rand(range) @return [Numeric];T;#0;$@5 ;.F;/o;0;1T;2i;3i;%@3 ;9I" static VALUE rand_random_number(int argc, VALUE *argv, VALUE obj) { rb_random_t *rnd = try_get_rnd(obj); VALUE v = rand_random(argc, argv, obj, rnd); if (NIL_P(v)) v = rand_random(0, 0, obj, rnd); else if (!v) invalid_argument(argv[0]); return v; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random::Formatter#rand;F;7[[@90;[[@ i;T;;;0;[;{;IC; "NGenerates formatted random number from raw random bytes. See Random#rand. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"random_number;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@ ;![;"I"@return [Float];T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;;;@0;:I"random_number(max);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@ ;![;"I"@return [Numeric];T;#0;$@ ;.F;Bi;C0;7[[I"max;T0;$@ o;= ;>I" overload;F;?0;;;@0;:I"random_number(range);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@ ;![;"I"@return [Numeric];T;#0;$@ ;.F;Bi;C0;7[[I" range;T0;$@ o;= ;>I" overload;F;?0;;;@0;:I" rand;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@ ;![;"I"@return [Float];T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;;;@0;:I"rand(max);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@ ;![;"I"@return [Numeric];T;#0;$@ ;.F;Bi;C0;7[[I"max;T0;$@ o;= ;>I" overload;F;?0;;;@0;:I"rand(range);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@ ;![;"I"@return [Numeric];T;#0;$@ ;.F;Bi;C0;7[[I" range;T0;$@ ;![;"@ ;#0;$@ ;.F;/o;0;1T;2i;3i;%@3 ;9I" static VALUE rand_random_number(int argc, VALUE *argv, VALUE obj) { rb_random_t *rnd = try_get_rnd(obj); VALUE v = rand_random(argc, argv, obj, rnd); if (NIL_P(v)) v = rand_random(0, 0, obj, rnd); else if (!v) invalid_argument(argv[0]); return v; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%Random::Formatter#exec_recursive;F;7[[I"mid;T0;[[I"%ext/-test-/recursion/recursion.c;Ti;T;:exec_recursive;0;[;{;IC; " ;T;[;![;"@;#0;$@ ;%@3 ;9I"qstatic VALUE exec_recursive(VALUE self, VALUE mid) { return rb_exec_recursive(recursive_i, self, mid); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+Random::Formatter#exec_recursive_outer;F;7[[I"mid;T0;[[@!i;T;:exec_recursive_outer;0;[;{;IC; " ;T;[;![;"@;#0;$@ !;%@3 ;9I"}static VALUE exec_recursive_outer(VALUE self, VALUE mid) { return rb_exec_recursive_outer(recursive_i, self, mid); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random::Formatter.s;F;7[[I"obj;T0;[[I"ext/-test-/printf/printf.c;Ti ;T;:s;0;[;{;IC; " ;T;[;![;"@;#0;$@!;%@3 ;9I"~static VALUE printf_test_s(VALUE self, VALUE obj) { return rb_enc_sprintf(rb_usascii_encoding(), "<%"PRIsVALUE">", obj); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random::Formatter.v;F;7[[I"obj;T0;[[@"!i;T;:v;0;[;{;IC; " ;T;[;![;"@;#0;$@*!;%@3 ;9I"static VALUE printf_test_v(VALUE self, VALUE obj) { return rb_enc_sprintf(rb_usascii_encoding(), "{%+"PRIsVALUE"}", obj); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random::Formatter.q;F;7[[I"obj;T0;[[@"!i;T;:q;0;[;{;IC; " ;T;[;![;"@;#0;$@8!;%@3 ;9I"static VALUE printf_test_q(VALUE self, VALUE obj) { return rb_enc_sprintf(rb_usascii_encoding(), "[% "PRIsVALUE"]", obj); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random::Formatter.call;F;7[[@90;[[@"!i';T;: call;0;[;{;IC; " ;T;[;![;"@;#0;$@F!;%@3 ;9I"static VALUE printf_test_call(int argc, VALUE *argv, VALUE self) { VALUE opt, type, num, result; char format[sizeof(int) * 6 + 8], *p = format, cnv; int n = 0; const char *s = 0; rb_scan_args(argc, argv, "2:", &type, &num, &opt); Check_Type(type, T_STRING); if (RSTRING_LEN(type) != 1) rb_raise(rb_eArgError, "wrong length(%ld)", RSTRING_LEN(type)); switch (cnv = RSTRING_PTR(type)[0]) { case 'd': case 'x': case 'o': case 'X': n = NUM2INT(num); break; case 's': s = StringValueCStr(num); break; default: rb_raise(rb_eArgError, "wrong conversion(%c)", cnv); } *p++ = '%'; if (!NIL_P(opt)) { VALUE v; Check_Type(opt, T_HASH); if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("space"))))) { *p++ = ' '; } if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("hash"))))) { *p++ = '#'; } if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("plus"))))) { *p++ = '+'; } if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("minus"))))) { *p++ = '-'; } if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("zero"))))) { *p++ = '0'; } if (!NIL_P(v = rb_hash_aref(opt, ID2SYM(rb_intern("width"))))) { p = uint_to_str(p, format + sizeof(format), NUM2UINT(v)); } if (!NIL_P(v = rb_hash_aref(opt, ID2SYM(rb_intern("prec"))))) { *p++ = '.'; if (FIXNUM_P(v)) p = uint_to_str(p, format + sizeof(format), NUM2UINT(v)); } } *p++ = cnv; *p++ = '\0'; if (cnv == 's') { result = rb_enc_sprintf(rb_usascii_encoding(), format, s); } else { result = rb_enc_sprintf(rb_usascii_encoding(), format, n); } return rb_assoc_new(result, rb_usascii_str_new_cstr(format)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Random::Formatter.sncount;F;7[[I"str;T0;[[@"!ib;T;: sncount;0;[;{;IC; " ;T;[;![;"@;#0;$@S!;%@3 ;9I"static VALUE snprintf_count(VALUE self, VALUE str) { int n = ruby_snprintf(NULL, 0, "%s", StringValueCStr(str)); return INT2FIX(n); };T;:I"static VALUE;T;;T; @3 ; IC;[; @3 ; IC;[; @3 ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ i2;F;:Formatter;;;;;[;{;IC; " ;T;[;![;"@;#0;$@3 ;Bi;%@i;&I"Random::Formatter;F; @i; IC;[; @i; IC;[; @i; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ i;T;;;;;;;[;{;IC; "Random provides an interface to Ruby's pseudo-random number generator, or PRNG. The PRNG produces a deterministic sequence of bits which approximate true randomness. The sequence may be represented by integers, floats, or binary strings. The generator may be initialized with either a system-generated or user-supplied seed value by using Random.srand. The class method Random.rand provides the base functionality of Kernel.rand along with better handling of floating point values. These are both interfaces to the Ruby system PRNG. Random.new will create a new PRNG with a state independent of the Ruby system PRNG, allowing multiple generators with different seed values or sequence positions to exist simultaneously. Random objects can be marshaled, allowing sequences to be saved and resumed. PRNGs are currently implemented as a modified Mersenne Twister with a period of 2**19937-1. As this algorithm is _not_ for cryptographical use, you must use SecureRandom for security purpose, instead of this PRNG.;T;[;![;"I" Random provides an interface to Ruby's pseudo-random number generator, or PRNG. The PRNG produces a deterministic sequence of bits which approximate true randomness. The sequence may be represented by integers, floats, or binary strings. The generator may be initialized with either a system-generated or user-supplied seed value by using Random.srand. The class method Random.rand provides the base functionality of Kernel.rand along with better handling of floating point values. These are both interfaces to the Ruby system PRNG. Random.new will create a new PRNG with a state independent of the Ruby system PRNG, allowing multiple generators with different seed values or sequence positions to exist simultaneously. Random objects can be marshaled, allowing sequences to be saved and resumed. PRNGs are currently implemented as a modified Mersenne Twister with a period of 2**19937-1. As this algorithm is _not_ for cryptographical use, you must use SecureRandom for security purpose, instead of this PRNG. ;T;#0;$@i;.F;/o;0;1T;2i;3i;Bi;%@;&I" Random;F;'0o; ;IC;[2o;4;5F;6;;;;&I"Complex.rectangular;F;7[[@90;[[@ i;T;:rectangular;0;[;{;IC; "qReturns a complex object which denotes the given rectangular form. Complex.rectangular(1, 2) #=> (1+2i) ;T;[o;= ;>I" overload;F;?0;: rect;@0;:I"rect(real[, imag]);T;IC; ";T;[;![;"I";T;#0;$@!;.F;Bi;C0;7[[I"real[, imag];T0;$@!o;= ;>I" overload;F;?0;;;@0;:I"rectangular(real[, imag]);T;IC; ";T;[;![;"I";T;#0;$@!;.F;Bi;C0;7[[I"real[, imag];T0;$@!;![;"I"Returns a complex object which denotes the given rectangular form. Complex.rectangular(1, 2) #=> (1+2i) @overload rect(real[, imag]) @overload rectangular(real[, imag]);T;#0;$@!;.F;/o;0;1T;2i;3i;%@!;9I"bstatic VALUE nucomp_s_new(int argc, VALUE *argv, VALUE klass) { VALUE real, imag; switch (rb_scan_args(argc, argv, "11", &real, &imag)) { case 1: nucomp_real_check(real); imag = ZERO; break; default: nucomp_real_check(real); nucomp_real_check(imag); break; } return nucomp_s_canonicalize_internal(klass, real, imag); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex.rect;F;7[[@90;[[@ i;T;;;0;[;{;IC; "qReturns a complex object which denotes the given rectangular form. Complex.rectangular(1, 2) #=> (1+2i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"rect(real[, imag]);T;IC; ";T;[;![;"I";T;#0;$@!;.F;Bi;C0;7[[I"real[, imag];T0;$@!o;= ;>I" overload;F;?0;;;@0;:I"rectangular(real[, imag]);T;IC; ";T;[;![;"I";T;#0;$@!;.F;Bi;C0;7[[I"real[, imag];T0;$@!;![;"@!;#0;$@!;.F;/o;0;1T;2i;3i;%@!;9I"bstatic VALUE nucomp_s_new(int argc, VALUE *argv, VALUE klass) { VALUE real, imag; switch (rb_scan_args(argc, argv, "11", &real, &imag)) { case 1: nucomp_real_check(real); imag = ZERO; break; default: nucomp_real_check(real); nucomp_real_check(imag); break; } return nucomp_s_canonicalize_internal(klass, real, imag); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex.polar;F;7[[@90;[[@ i;T;: polar;0;[;{;IC; "8Returns a complex object which denotes the given polar form. Complex.polar(3, 0) #=> (3.0+0.0i) Complex.polar(3, Math::PI/2) #=> (1.836909530733566e-16+3.0i) Complex.polar(3, Math::PI) #=> (-3.0+3.673819061467132e-16i) Complex.polar(3, -Math::PI/2) #=> (1.836909530733566e-16-3.0i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"polar(abs[, arg]);T;IC; ";T;[;![;"I";T;#0;$@!;.F;Bi;C0;7[[I"abs[, arg];T0;$@!;![;"I"VReturns a complex object which denotes the given polar form. Complex.polar(3, 0) #=> (3.0+0.0i) Complex.polar(3, Math::PI/2) #=> (1.836909530733566e-16+3.0i) Complex.polar(3, Math::PI) #=> (-3.0+3.673819061467132e-16i) Complex.polar(3, -Math::PI/2) #=> (1.836909530733566e-16-3.0i) @overload polar(abs[, arg]);T;#0;$@!;.F;/o;0;1T;2i;3i;%@!;9I"static VALUE nucomp_s_polar(int argc, VALUE *argv, VALUE klass) { VALUE abs, arg; switch (rb_scan_args(argc, argv, "11", &abs, &arg)) { case 1: nucomp_real_check(abs); return nucomp_s_new_internal(klass, abs, ZERO); default: nucomp_real_check(abs); nucomp_real_check(arg); break; } if (RB_TYPE_P(abs, T_COMPLEX)) { get_dat1(abs); abs = dat->real; } if (RB_TYPE_P(arg, T_COMPLEX)) { get_dat1(arg); arg = dat->real; } return f_complex_polar(klass, abs, arg); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#real;F;7[;[[@ i;T;: real;0;[;{;IC; "XReturns the real part. Complex(7).real #=> 7 Complex(9, -4).real #=> 9 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" real;T;IC; ";T;[;![;"I";T;#0;$@!;.F;Bi;C0;7[;$@!;![;"I"iReturns the real part. Complex(7).real #=> 7 Complex(9, -4).real #=> 9 @overload real;T;#0;$@!;.F;/o;0;1T;2i;3i;%@!;9I"TVALUE rb_complex_real(VALUE self) { get_dat1(self); return dat->real; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Complex#imaginary;F;7[;[[@ i;T;:imaginary;0;[;{;IC; "hReturns the imaginary part. Complex(7).imaginary #=> 0 Complex(9, -4).imaginary #=> -4 ;T;[o;= ;>I" overload;F;?0;: imag;@0;:I" imag;T;IC; ";T;[;![;"I";T;#0;$@!;.F;Bi;C0;7[;$@!o;= ;>I" overload;F;?0;;;@0;:I"imaginary;T;IC; ";T;[;![;"I";T;#0;$@!;.F;Bi;C0;7[;$@!;![;"I"Returns the imaginary part. Complex(7).imaginary #=> 0 Complex(9, -4).imaginary #=> -4 @overload imag @overload imaginary;T;#0;$@!;.F;/o;0;1T;2i;3i;%@!;9I"TVALUE rb_complex_imag(VALUE self) { get_dat1(self); return dat->imag; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Complex#imag;F;7[;[[@ i;T;;;0;[;{;IC; "hReturns the imaginary part. Complex(7).imaginary #=> 0 Complex(9, -4).imaginary #=> -4 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" imag;T;IC; ";T;[;![;"I";T;#0;$@";.F;Bi;C0;7[;$@"o;= ;>I" overload;F;?0;;;@0;:I"imaginary;T;IC; ";T;[;![;"I";T;#0;$@";.F;Bi;C0;7[;$@";![;"@";#0;$@";.F;/o;0;1T;2i;3i;%@!;9I"TVALUE rb_complex_imag(VALUE self) { get_dat1(self); return dat->imag; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Complex#-@;F;7[;[[@ i;T;;;0;[;{;IC; "CReturns negation of the value. -Complex(1, 2) #=> (-1-2i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" -cmp;T;IC; ";T;[;![;"I";T;#0;$@2";.F;Bi;C0;7[;$@2";![;"I"TReturns negation of the value. -Complex(1, 2) #=> (-1-2i) @overload -cmp;T;#0;$@2";.F;/o;0;1T;2i;3i;%@!;9I"VALUE rb_complex_uminus(VALUE self) { get_dat1(self); return f_complex_new2(CLASS_OF(self), f_negate(dat->real), f_negate(dat->imag)); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Complex#+;F;7[[I" other;T0;[[@ i ;T;;;0;[;{;IC; "Performs addition. Complex(2, 3) + Complex(2, 3) #=> (4+6i) Complex(900) + Complex(1) #=> (901+0i) Complex(-2, 9) + Complex(-9, 2) #=> (-11+11i) Complex(9, 8) + 4 #=> (13+8i) Complex(20, 9) + 9.8 #=> (29.8+9i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"+(numeric);T;IC; ";T;[;![;"I";T;#0;$@H";.F;Bi;C0;7[[I" numeric;T0;$@H";![;"I"Performs addition. Complex(2, 3) + Complex(2, 3) #=> (4+6i) Complex(900) + Complex(1) #=> (901+0i) Complex(-2, 9) + Complex(-9, 2) #=> (-11+11i) Complex(9, 8) + 4 #=> (13+8i) Complex(20, 9) + 9.8 #=> (29.8+9i) @overload +(numeric);T;#0;$@H";.F;/o;0;1T;2i;3i;%@!;9I"VALUE rb_complex_plus(VALUE self, VALUE other) { if (RB_TYPE_P(other, T_COMPLEX)) { VALUE real, imag; get_dat2(self, other); real = f_add(adat->real, bdat->real); imag = f_add(adat->imag, bdat->imag); return f_complex_new2(CLASS_OF(self), real, imag); } if (k_numeric_p(other) && f_real_p(other)) { get_dat1(self); return f_complex_new2(CLASS_OF(self), f_add(dat->real, other), dat->imag); } return rb_num_coerce_bin(self, other, '+'); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Complex#-;F;7[[I" other;T0;[[@ i,;T;;;0;[;{;IC; "Performs subtraction. Complex(2, 3) - Complex(2, 3) #=> (0+0i) Complex(900) - Complex(1) #=> (899+0i) Complex(-2, 9) - Complex(-9, 2) #=> (7+7i) Complex(9, 8) - 4 #=> (5+8i) Complex(20, 9) - 9.8 #=> (10.2+9i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"-(numeric);T;IC; ";T;[;![;"I";T;#0;$@b";.F;Bi;C0;7[[I" numeric;T0;$@b";![;"I"Performs subtraction. Complex(2, 3) - Complex(2, 3) #=> (0+0i) Complex(900) - Complex(1) #=> (899+0i) Complex(-2, 9) - Complex(-9, 2) #=> (7+7i) Complex(9, 8) - 4 #=> (5+8i) Complex(20, 9) - 9.8 #=> (10.2+9i) @overload -(numeric);T;#0;$@b";.F;/o;0;1T;2i ;3i);%@!;9I"VALUE rb_complex_minus(VALUE self, VALUE other) { if (RB_TYPE_P(other, T_COMPLEX)) { VALUE real, imag; get_dat2(self, other); real = f_sub(adat->real, bdat->real); imag = f_sub(adat->imag, bdat->imag); return f_complex_new2(CLASS_OF(self), real, imag); } if (k_numeric_p(other) && f_real_p(other)) { get_dat1(self); return f_complex_new2(CLASS_OF(self), f_sub(dat->real, other), dat->imag); } return rb_num_coerce_bin(self, other, '-'); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Complex#*;F;7[[I" other;T0;[[@ ih;T;;;0;[;{;IC; "Performs multiplication. Complex(2, 3) * Complex(2, 3) #=> (-5+12i) Complex(900) * Complex(1) #=> (900+0i) Complex(-2, 9) * Complex(-9, 2) #=> (0-85i) Complex(9, 8) * 4 #=> (36+32i) Complex(20, 9) * 9.8 #=> (196.0+88.2i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"*(numeric);T;IC; ";T;[;![;"I";T;#0;$@|";.F;Bi;C0;7[[I" numeric;T0;$@|";![;"I")Performs multiplication. Complex(2, 3) * Complex(2, 3) #=> (-5+12i) Complex(900) * Complex(1) #=> (900+0i) Complex(-2, 9) * Complex(-9, 2) #=> (0-85i) Complex(9, 8) * 4 #=> (36+32i) Complex(20, 9) * 9.8 #=> (196.0+88.2i) @overload *(numeric);T;#0;$@|";.F;/o;0;1T;2i\;3ie;%@!;9I"VALUE rb_complex_mul(VALUE self, VALUE other) { if (RB_TYPE_P(other, T_COMPLEX)) { VALUE real, imag; get_dat2(self, other); comp_mul(adat->real, adat->imag, bdat->real, bdat->imag, &real, &imag); return f_complex_new2(CLASS_OF(self), real, imag); } if (k_numeric_p(other) && f_real_p(other)) { get_dat1(self); return f_complex_new2(CLASS_OF(self), f_mul(dat->real, other), f_mul(dat->imag, other)); } return rb_num_coerce_bin(self, other, '*'); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Complex#/;F;7[[I" other;T0;[[@ i;T;;;0;[;{;IC; "JPerforms division. Complex(2, 3) / Complex(2, 3) #=> ((1/1)+(0/1)*i) Complex(900) / Complex(1) #=> ((900/1)+(0/1)*i) Complex(-2, 9) / Complex(-9, 2) #=> ((36/85)-(77/85)*i) Complex(9, 8) / 4 #=> ((9/4)+(2/1)*i) Complex(20, 9) / 9.8 #=> (2.0408163265306123+0.9183673469387754i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"/(numeric);T;IC; ";T;[;![;"I";T;#0;$@";.F;Bi;C0;7[[I" numeric;T0;$@"o;= ;>I" overload;F;?0;:quo;@0;:I"quo(numeric);T;IC; ";T;[;![;"I";T;#0;$@";.F;Bi;C0;7[[I" numeric;T0;$@";![;"I"xPerforms division. Complex(2, 3) / Complex(2, 3) #=> ((1/1)+(0/1)*i) Complex(900) / Complex(1) #=> ((900/1)+(0/1)*i) Complex(-2, 9) / Complex(-9, 2) #=> ((36/85)-(77/85)*i) Complex(9, 8) / 4 #=> ((9/4)+(2/1)*i) Complex(20, 9) / 9.8 #=> (2.0408163265306123+0.9183673469387754i) @overload /(numeric) @overload quo(numeric);T;#0;$@";.F;/o;0;1T;2i;3i;%@!;9I"gVALUE rb_complex_div(VALUE self, VALUE other) { return f_divide(self, other, f_quo, id_quo); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Complex#quo;F;7[;[;F;;;;;[;{;IC; " ;T;[;![;"@;#0;$@";%@!;;To;4;5F;6;;;;&I"Complex#fdiv;F;7[[I" other;T0;[[@ i;T;: fdiv;0;[;{;IC; "Performs division as each part is a float, never returns a float. Complex(11, 22).fdiv(3) #=> (3.6666666666666665+7.333333333333333i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"fdiv(numeric);T;IC; ";T;[;![;"I";T;#0;$@";.F;Bi;C0;7[[I" numeric;T0;$@";![;"I"Performs division as each part is a float, never returns a float. Complex(11, 22).fdiv(3) #=> (3.6666666666666665+7.333333333333333i) @overload fdiv(numeric);T;#0;$@";.F;/o;0;1T;2i;3i;%@!;9I"mstatic VALUE nucomp_fdiv(VALUE self, VALUE other) { return f_divide(self, other, f_fdiv, id_fdiv); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#**;F;7[[I" other;T0;[[@ i;T;;;0;[;{;IC; "Performs exponentiation. Complex('i') ** 2 #=> (-1+0i) Complex(-8) ** Rational(1, 3) #=> (1.0000000000000002+1.7320508075688772i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"**(numeric);T;IC; ";T;[;![;"I";T;#0;$@";.F;Bi;C0;7[[I" numeric;T0;$@";![;"I"Performs exponentiation. Complex('i') ** 2 #=> (-1+0i) Complex(-8) ** Rational(1, 3) #=> (1.0000000000000002+1.7320508075688772i) @overload **(numeric);T;#0;$@";.F;/o;0;1T;2i;3i;%@!;9I"E VALUE rb_complex_pow(VALUE self, VALUE other) { if (k_numeric_p(other) && k_exact_zero_p(other)) return f_complex_new_bang1(CLASS_OF(self), ONE); if (RB_TYPE_P(other, T_RATIONAL) && RRATIONAL(other)->den == LONG2FIX(1)) other = RRATIONAL(other)->num; /* c14n */ if (RB_TYPE_P(other, T_COMPLEX)) { get_dat1(other); if (k_exact_zero_p(dat->imag)) other = dat->real; /* c14n */ } if (RB_TYPE_P(other, T_COMPLEX)) { VALUE r, theta, nr, ntheta; get_dat1(other); r = f_abs(self); theta = f_arg(self); nr = m_exp_bang(f_sub(f_mul(dat->real, m_log_bang(r)), f_mul(dat->imag, theta))); ntheta = f_add(f_mul(theta, dat->real), f_mul(dat->imag, m_log_bang(r))); return f_complex_polar(CLASS_OF(self), nr, ntheta); } if (FIXNUM_P(other)) { long n = FIX2LONG(other); if (n == 0) { return nucomp_s_new_internal(CLASS_OF(self), ONE, ZERO); } if (n < 0) { self = f_reciprocal(self); other = rb_int_uminus(other); n = -n; } { get_dat1(self); VALUE xr = dat->real, xi = dat->imag, zr = xr, zi = xi; if (f_zero_p(xi)) { zr = rb_num_pow(zr, other); } else if (f_zero_p(xr)) { zi = rb_num_pow(zi, other); if (n & 2) zi = f_negate(zi); if (!(n & 1)) { VALUE tmp = zr; zr = zi; zi = tmp; } } else { while (--n) { long q, r; for (; q = n / 2, r = n % 2, r == 0; n = q) { VALUE tmp = f_sub(f_mul(xr, xr), f_mul(xi, xi)); xi = f_mul(f_mul(TWO, xr), xi); xr = tmp; } comp_mul(zr, zi, xr, xi, &zr, &zi); } } return nucomp_s_new_internal(CLASS_OF(self), zr, zi); } } if (k_numeric_p(other) && f_real_p(other)) { VALUE r, theta; if (RB_BIGNUM_TYPE_P(other)) rb_warn("in a**b, b may be too big"); r = f_abs(self); theta = f_arg(self); return f_complex_polar(CLASS_OF(self), f_expt(r, other), f_mul(theta, other)); } return rb_num_coerce_bin(self, other, id_expt); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Complex#==;F;7[[I" other;T0;[[@ i;;T;;F;0;[;{;IC; "Returns true if cmp equals object numerically. Complex(2, 3) == Complex(2, 3) #=> true Complex(5) == 5 #=> true Complex(0) == 0.0 #=> true Complex('1/3') == 0.33 #=> false Complex('1/2') == '1/2' #=> false ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@";![;"I"@return [Boolean];T;#0;$@";.F;Bi;C0;7[[I" object;T0;$@";![;"I"BReturns true if cmp equals object numerically. Complex(2, 3) == Complex(2, 3) #=> true Complex(5) == 5 #=> true Complex(0) == 0.0 #=> true Complex('1/3') == 0.33 #=> false Complex('1/2') == '1/2' #=> false @overload ==(object) @return [Boolean];T;#0;$@";.F;/o;0;1T;2i/;3i9;%@!;9I"static VALUE nucomp_eqeq_p(VALUE self, VALUE other) { if (RB_TYPE_P(other, T_COMPLEX)) { get_dat2(self, other); return RBOOL(f_eqeq_p(adat->real, bdat->real) && f_eqeq_p(adat->imag, bdat->imag)); } if (k_numeric_p(other) && f_real_p(other)) { get_dat1(self); return RBOOL(f_eqeq_p(dat->real, other) && f_zero_p(dat->imag)); } return RBOOL(f_eqeq_p(other, self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#<=>;F;7[[I" other;T0;[[@ ia;T;;Y;0;[;{;IC; "If +cmp+'s imaginary part is zero, and +object+ is also a real number (or a Complex number where the imaginary part is zero), compare the real part of +cmp+ to object. Otherwise, return nil. Complex(2, 3) <=> Complex(2, 3) #=> nil Complex(2, 3) <=> 1 #=> nil Complex(2) <=> 1 #=> 1 Complex(2) <=> 2 #=> 0 Complex(2) <=> 3 #=> -1 ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I"<=>(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[ I"0;TI"1;TI"-1;TI"nil;T;$@#;![;"I"@return [ 0, 1, -1, nil];T;#0;$@#;.F;Bi;C0;7[[I" object;T0;$@#;![;"I"If +cmp+'s imaginary part is zero, and +object+ is also a real number (or a Complex number where the imaginary part is zero), compare the real part of +cmp+ to object. Otherwise, return nil. Complex(2, 3) <=> Complex(2, 3) #=> nil Complex(2, 3) <=> 1 #=> nil Complex(2) <=> 1 #=> 1 Complex(2) <=> 2 #=> 0 Complex(2) <=> 3 #=> -1 @overload <=>(object) @return [ 0, 1, -1, nil];T;#0;$@#;.F;/o;0;1T;2iS;3i_;%@!;9I"static VALUE nucomp_cmp(VALUE self, VALUE other) { if (nucomp_real_p(self) && k_numeric_p(other)) { if (RB_TYPE_P(other, T_COMPLEX) && nucomp_real_p(other)) { get_dat2(self, other); return rb_funcall(adat->real, idCmp, 1, bdat->real); } else if (f_real_p(other)) { get_dat1(self); return rb_funcall(dat->real, idCmp, 1, other); } } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#coerce;F;7[[I" other;T0;[[@ ir;T;;;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@8#;.F;/o;0;1T;2iq;3iq;%@!;9I"static VALUE nucomp_coerce(VALUE self, VALUE other) { if (RB_TYPE_P(other, T_COMPLEX)) return rb_assoc_new(other, self); if (k_numeric_p(other) && f_real_p(other)) return rb_assoc_new(f_complex_new_bang1(CLASS_OF(self), other), self); rb_raise(rb_eTypeError, "%"PRIsVALUE" can't be coerced into %"PRIsVALUE, rb_obj_class(other), rb_obj_class(self)); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#abs;F;7[;[[@ i;T;;;0;[;{;IC; "vReturns the absolute part of its polar form. Complex(-1).abs #=> 1 Complex(3.0, -4.0).abs #=> 5.0 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"abs;T;IC; ";T;[;![;"I";T;#0;$@H#;.F;Bi;C0;7[;$@H#o;= ;>I" overload;F;?0;:magnitude;@0;:I"magnitude;T;IC; ";T;[;![;"I";T;#0;$@H#;.F;Bi;C0;7[;$@H#;![;"I"Returns the absolute part of its polar form. Complex(-1).abs #=> 1 Complex(3.0, -4.0).abs #=> 5.0 @overload abs @overload magnitude;T;#0;$@H#;.F;/o;0;1T;2i;3i;%@!;9I"VALUE rb_complex_abs(VALUE self) { get_dat1(self); if (f_zero_p(dat->real)) { VALUE a = f_abs(dat->imag); if (RB_FLOAT_TYPE_P(dat->real) && !RB_FLOAT_TYPE_P(dat->imag)) a = f_to_f(a); return a; } if (f_zero_p(dat->imag)) { VALUE a = f_abs(dat->real); if (!RB_FLOAT_TYPE_P(dat->real) && RB_FLOAT_TYPE_P(dat->imag)) a = f_to_f(a); return a; } return rb_math_hypot(dat->real, dat->imag); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Complex#magnitude;F;7[;[[@ i;T;;;0;[;{;IC; "vReturns the absolute part of its polar form. Complex(-1).abs #=> 1 Complex(3.0, -4.0).abs #=> 5.0 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"abs;T;IC; ";T;[;![;"I";T;#0;$@f#;.F;Bi;C0;7[;$@f#o;= ;>I" overload;F;?0;;;@0;:I"magnitude;T;IC; ";T;[;![;"I";T;#0;$@f#;.F;Bi;C0;7[;$@f#;![;"@b#;#0;$@f#;.F;/o;0;1T;2i;3i;%@!;9I"VALUE rb_complex_abs(VALUE self) { get_dat1(self); if (f_zero_p(dat->real)) { VALUE a = f_abs(dat->imag); if (RB_FLOAT_TYPE_P(dat->real) && !RB_FLOAT_TYPE_P(dat->imag)) a = f_to_f(a); return a; } if (f_zero_p(dat->imag)) { VALUE a = f_abs(dat->real); if (!RB_FLOAT_TYPE_P(dat->real) && RB_FLOAT_TYPE_P(dat->imag)) a = f_to_f(a); return a; } return rb_math_hypot(dat->real, dat->imag); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Complex#abs2;F;7[;[[@ i;T;: abs2;0;[;{;IC; "rReturns square of the absolute value. Complex(-1).abs2 #=> 1 Complex(3.0, -4.0).abs2 #=> 25.0 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" abs2;T;IC; ";T;[;![;"I";T;#0;$@#;.F;Bi;C0;7[;$@#;![;"I"~Returns square of the absolute value. Complex(-1).abs2 #=> 1 Complex(3.0, -4.0).abs2 #=> 25.0 @overload abs2;T;#0;$@#;.F;/o;0;1T;2i;3i;%@!;9I"static VALUE nucomp_abs2(VALUE self) { get_dat1(self); return f_add(f_mul(dat->real, dat->real), f_mul(dat->imag, dat->imag)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#arg;F;7[;[[@ i;T;:arg;0;[;{;IC; "kReturns the angle part of its polar form. Complex.polar(3, Math::PI/2).arg #=> 1.5707963267948966 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"arg;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@#;![;"I"@return [Float];T;#0;$@#;.F;Bi;C0;7[;$@#o;= ;>I" overload;F;?0;: angle;@0;:I" angle;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@#;![;"I"@return [Float];T;#0;$@#;.F;Bi;C0;7[;$@#o;= ;>I" overload;F;?0;: phase;@0;:I" phase;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@#;![;"I"@return [Float];T;#0;$@#;.F;Bi;C0;7[;$@#;![;"I"Returns the angle part of its polar form. Complex.polar(3, Math::PI/2).arg #=> 1.5707963267948966 @overload arg @return [Float] @overload angle @return [Float] @overload phase @return [Float];T;#0;$@#;.F;/o;0;1T;2i;3i;%@!;9I"mVALUE rb_complex_arg(VALUE self) { get_dat1(self); return rb_math_atan2(dat->imag, dat->real); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Complex#angle;F;7[;[[@ i;T;;;0;[;{;IC; "kReturns the angle part of its polar form. Complex.polar(3, Math::PI/2).arg #=> 1.5707963267948966 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"arg;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@#;![;"I"@return [Float];T;#0;$@#;.F;Bi;C0;7[;$@#o;= ;>I" overload;F;?0;;;@0;:I" angle;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@#;![;"I"@return [Float];T;#0;$@#;.F;Bi;C0;7[;$@#o;= ;>I" overload;F;?0;;;@0;:I" phase;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@#;![;"I"@return [Float];T;#0;$@#;.F;Bi;C0;7[;$@#;![;"@#;#0;$@#;.F;/o;0;1T;2i;3i;%@!;9I"mVALUE rb_complex_arg(VALUE self) { get_dat1(self); return rb_math_atan2(dat->imag, dat->real); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Complex#phase;F;7[;[[@ i;T;;;0;[;{;IC; "kReturns the angle part of its polar form. Complex.polar(3, Math::PI/2).arg #=> 1.5707963267948966 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"arg;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@$;![;"I"@return [Float];T;#0;$@$;.F;Bi;C0;7[;$@$o;= ;>I" overload;F;?0;;;@0;:I" angle;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@$;![;"I"@return [Float];T;#0;$@$;.F;Bi;C0;7[;$@$o;= ;>I" overload;F;?0;;;@0;:I" phase;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@$;![;"I"@return [Float];T;#0;$@$;.F;Bi;C0;7[;$@$;![;"@#;#0;$@$;.F;/o;0;1T;2i;3i;%@!;9I"mVALUE rb_complex_arg(VALUE self) { get_dat1(self); return rb_math_atan2(dat->imag, dat->real); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Complex#rectangular;F;7[;[[@ i;T;;;0;[;{;IC; "VReturns an array; [cmp.real, cmp.imag]. Complex(1, 2).rectangular #=> [1, 2] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" rect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@6$;![;"I"@return [Array];T;#0;$@6$;.F;Bi;C0;7[;$@6$o;= ;>I" overload;F;?0;;;@0;:I"rectangular;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@6$;![;"I"@return [Array];T;#0;$@6$;.F;Bi;C0;7[;$@6$;![;"I"Returns an array; [cmp.real, cmp.imag]. Complex(1, 2).rectangular #=> [1, 2] @overload rect @return [Array] @overload rectangular @return [Array];T;#0;$@6$;.F;/o;0;1T;2i;3i;%@!;9I"pstatic VALUE nucomp_rect(VALUE self) { get_dat1(self); return rb_assoc_new(dat->real, dat->imag); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#rect;F;7[;[[@ i;T;;;0;[;{;IC; "VReturns an array; [cmp.real, cmp.imag]. Complex(1, 2).rectangular #=> [1, 2] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" rect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@^$;![;"I"@return [Array];T;#0;$@^$;.F;Bi;C0;7[;$@^$o;= ;>I" overload;F;?0;;;@0;:I"rectangular;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@^$;![;"I"@return [Array];T;#0;$@^$;.F;Bi;C0;7[;$@^$;![;"@Z$;#0;$@^$;.F;/o;0;1T;2i;3i;%@!;9I"pstatic VALUE nucomp_rect(VALUE self) { get_dat1(self); return rb_assoc_new(dat->real, dat->imag); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#polar;F;7[;[[@ i;T;;;0;[;{;IC; "nReturns an array; [cmp.abs, cmp.arg]. Complex(1, 2).polar #=> [2.23606797749979, 1.1071487177940904] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" polar;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@$;![;"I"@return [Array];T;#0;$@$;.F;Bi;C0;7[;$@$;![;"I"Returns an array; [cmp.abs, cmp.arg]. Complex(1, 2).polar #=> [2.23606797749979, 1.1071487177940904] @overload polar @return [Array];T;#0;$@$;.F;/o;0;1T;2i;3i;%@!;9I"astatic VALUE nucomp_polar(VALUE self) { return rb_assoc_new(f_abs(self), f_arg(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#conjugate;F;7[;[[@ i;T;:conjugate;0;[;{;IC; "KReturns the complex conjugate. Complex(1, 2).conjugate #=> (1-2i) ;T;[o;= ;>I" overload;F;?0;: conj;@0;:I" conj;T;IC; ";T;[;![;"I";T;#0;$@$;.F;Bi;C0;7[;$@$o;= ;>I" overload;F;?0;;;@0;:I"conjugate;T;IC; ";T;[;![;"I";T;#0;$@$;.F;Bi;C0;7[;$@$;![;"I"pReturns the complex conjugate. Complex(1, 2).conjugate #=> (1-2i) @overload conj @overload conjugate;T;#0;$@$;.F;/o;0;1T;2i;3i;%@!;9I"VALUE rb_complex_conjugate(VALUE self) { get_dat1(self); return f_complex_new2(CLASS_OF(self), dat->real, f_negate(dat->imag)); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Complex#conj;F;7[;[[@ i;T;;;0;[;{;IC; "KReturns the complex conjugate. Complex(1, 2).conjugate #=> (1-2i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" conj;T;IC; ";T;[;![;"I";T;#0;$@$;.F;Bi;C0;7[;$@$o;= ;>I" overload;F;?0;;;@0;:I"conjugate;T;IC; ";T;[;![;"I";T;#0;$@$;.F;Bi;C0;7[;$@$;![;"@$;#0;$@$;.F;/o;0;1T;2i;3i;%@!;9I"VALUE rb_complex_conjugate(VALUE self) { get_dat1(self); return f_complex_new2(CLASS_OF(self), dat->real, f_negate(dat->imag)); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Complex#real?;F;7[;[[@ i;T;: real?;0;[;{;IC; "EReturns false, even if the complex number has no imaginary part.;T;[o;= ;>I" overload;F;?0;;;@0;:I"Complex(1).real?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" false;T;$@$;![;"I"@return [false];T;#0;$@$;.F;Bi;C0;7[[I"1;T0;$@$o;= ;>I" overload;F;?0;;;@0;:I"Complex(1, 2).real?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" false;T;$@$;![;"I"@return [false];T;#0;$@$;.F;Bi;C0;7[[I"1;T0[I"2;T0;$@$;![;"I"Returns false, even if the complex number has no imaginary part. @overload Complex(1).real? @return [false] @overload Complex(1, 2).real? @return [false];T;#0;$@$;.F;/o;0;1T;2i;3i;Bi;%@!;9I"Dstatic VALUE nucomp_real_p_m(VALUE self) { return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#numerator;F;7[;[[@ i;T;:numerator;0;[;{;IC; "Returns the numerator. 1 2 3+4i <- numerator - + -i -> ---- 2 3 6 <- denominator c = Complex('1/2+2/3i') #=> ((1/2)+(2/3)*i) n = c.numerator #=> (3+4i) d = c.denominator #=> 6 n / d #=> ((1/2)+(2/3)*i) Complex(Rational(n.real, d), Rational(n.imag, d)) #=> ((1/2)+(2/3)*i) See denominator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"numerator;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@ %;![;"I"@return [Numeric];T;#0;$@ %;.F;Bi;C0;7[;$@ %;![;"I"Returns the numerator. 1 2 3+4i <- numerator - + -i -> ---- 2 3 6 <- denominator c = Complex('1/2+2/3i') #=> ((1/2)+(2/3)*i) n = c.numerator #=> (3+4i) d = c.denominator #=> 6 n / d #=> ((1/2)+(2/3)*i) Complex(Rational(n.real, d), Rational(n.imag, d)) #=> ((1/2)+(2/3)*i) See denominator. @overload numerator @return [Numeric];T;#0;$@ %;.F;/o;0;1T;2i ;3i;%@!;9I"9static VALUE nucomp_numerator(VALUE self) { VALUE cd; get_dat1(self); cd = nucomp_denominator(self); return f_complex_new2(CLASS_OF(self), f_mul(f_numerator(dat->real), f_div(cd, f_denominator(dat->real))), f_mul(f_numerator(dat->imag), f_div(cd, f_denominator(dat->imag)))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#denominator;F;7[;[[@ i;T;:denominator;0;[;{;IC; "WReturns the denominator (lcm of both denominator - real and imag). See numerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"denominator;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@$%;![;"I"@return [Integer];T;#0;$@$%;.F;Bi;C0;7[;$@$%;![;"I"~Returns the denominator (lcm of both denominator - real and imag). See numerator. @overload denominator @return [Integer];T;#0;$@$%;.F;/o;0;1T;2i;3i;%@!;9I"static VALUE nucomp_denominator(VALUE self) { get_dat1(self); return rb_lcm(f_denominator(dat->real), f_denominator(dat->imag)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#hash;F;7[;[[@ i:;T;;X;0;[;{;IC; " ;T;[;![;"@;#0;$@?%;%@!;9I"Wstatic VALUE nucomp_hash(VALUE self) { return ST2FIX(rb_complex_hash(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#eql?;F;7[[I" other;T0;[[@ iA;T;;V;0;[;{;IC; " :nodoc:;T;[o;A ;>I" return;F;?@;0;@[@L;$@K%;![;"I" :nodoc:;T;#0;$@K%;.F;/o;0;1T;2i@;3i@;Bi;%@!;9I"$static VALUE nucomp_eql_p(VALUE self, VALUE other) { if (RB_TYPE_P(other, T_COMPLEX)) { get_dat2(self, other); return RBOOL((CLASS_OF(adat->real) == CLASS_OF(bdat->real)) && (CLASS_OF(adat->imag) == CLASS_OF(bdat->imag)) && f_eqeq_p(self, other)); } return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#to_s;F;7[;[[@ i;T;;G;0;[;{;IC; "5Returns the value as a string. Complex(2).to_s #=> "2+0i" Complex('-8/6').to_s #=> "-4/3+0i" Complex('1/2i').to_s #=> "0+1/2i" Complex(0, Float::INFINITY).to_s #=> "0+Infinity*i" Complex(Float::NAN, Float::NAN).to_s #=> "NaN+NaN*i" ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@^%;![;"I"@return [String];T;#0;$@^%;.F;Bi;C0;7[;$@^%;![;"I"YReturns the value as a string. Complex(2).to_s #=> "2+0i" Complex('-8/6').to_s #=> "-4/3+0i" Complex('1/2i').to_s #=> "0+1/2i" Complex(0, Float::INFINITY).to_s #=> "0+Infinity*i" Complex(Float::NAN, Float::NAN).to_s #=> "NaN+NaN*i" @overload to_s @return [String];T;#0;$@^%;.F;/o;0;1T;2it;3i~;%@!;9I"Sstatic VALUE nucomp_to_s(VALUE self) { return f_format(self, rb_String); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#inspect;F;7[;[[@ i;T;;J;0;[;{;IC; "bReturns the value as a string for inspection. Complex(2).inspect #=> "(2+0i)" Complex('-8/6').inspect #=> "((-4/3)+0i)" Complex('1/2i').inspect #=> "(0+(1/2)*i)" Complex(0, Float::INFINITY).inspect #=> "(0+Infinity*i)" Complex(Float::NAN, Float::NAN).inspect #=> "(NaN+NaN*i)" ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@y%;![;"I"@return [String];T;#0;$@y%;.F;Bi;C0;7[;$@y%;![;"I"Returns the value as a string for inspection. Complex(2).inspect #=> "(2+0i)" Complex('-8/6').inspect #=> "((-4/3)+0i)" Complex('1/2i').inspect #=> "(0+(1/2)*i)" Complex(0, Float::INFINITY).inspect #=> "(0+Infinity*i)" Complex(Float::NAN, Float::NAN).inspect #=> "(NaN+NaN*i)" @overload inspect @return [String];T;#0;$@y%;.F;/o;0;1T;2i;3i;%@!;9I"static VALUE nucomp_inspect(VALUE self) { VALUE s; s = rb_usascii_str_new2("("); rb_str_concat(s, f_format(self, rb_inspect)); rb_str_cat2(s, ")"); return s; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#finite?;F;7[;[[@ i;T;: finite?;0;[;{;IC; "kReturns +true+ if +cmp+'s real and imaginary parts are both finite numbers, otherwise returns +false+.;T;[o;= ;>I" overload;F;?0;;;@0;:I" finite?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@%;![;"I"@return [Boolean];T;#0;$@%;.F;Bi;C0;7[;$@%;![;"I"Returns +true+ if +cmp+'s real and imaginary parts are both finite numbers, otherwise returns +false+. @overload finite? @return [Boolean];T;#0;$@%;.F;/o;0;1T;2i;3i;Bi;%@!;9I"static VALUE rb_complex_finite_p(VALUE self) { get_dat1(self); return RBOOL(f_finite_p(dat->real) && f_finite_p(dat->imag)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#infinite?;F;7[;[[@ i;T;:infinite?;0;[;{;IC; "Returns +1+ if +cmp+'s real or imaginary part is an infinite number, otherwise returns +nil+. For example: (1+1i).infinite? #=> nil (Float::INFINITY + 1i).infinite? #=> 1;T;[o;= ;>I" overload;F;?0;;;@0;:I"infinite?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;TI"1;T;$@%;![;"I"@return [nil, 1];T;#0;$@%;.F;Bi;C0;7[;$@%;![;"I"Returns +1+ if +cmp+'s real or imaginary part is an infinite number, otherwise returns +nil+. For example: (1+1i).infinite? #=> nil (Float::INFINITY + 1i).infinite? #=> 1 @overload infinite? @return [nil, 1];T;#0;$@%;.F;/o;0;1T;2i;3i;Bi;%@!;9I"static VALUE rb_complex_infinite_p(VALUE self) { get_dat1(self); if (!f_infinite_p(dat->real) && !f_infinite_p(dat->imag)) { return Qnil; } return ONE; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#marshal_dump;F;7[;[[@ i;T;;[;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@%;.F;/o;0;1T;2i;3i;%@!;9I"static VALUE nucomp_marshal_dump(VALUE self) { VALUE a; get_dat1(self); a = rb_assoc_new(dat->real, dat->imag); rb_copy_generic_ivar(a, self); return a; };T;:I"static VALUE;T;;To; ;IC;[o;4;5F;6;;;;&I"%Complex::compatible#marshal_load;F;7[[I"a;T0;[[@ i;T;;;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@%;.F;/o;0;1T;2i;3i;%@%;9I"Vstatic VALUE nucomp_marshal_load(VALUE self, VALUE a) { Check_Type(a, T_ARRAY); if (RARRAY_LEN(a) != 2) rb_raise(rb_eArgError, "marshaled complex must have an array whose length is 2 but %ld", RARRAY_LEN(a)); rb_ivar_set(self, id_i_real, RARRAY_AREF(a, 0)); rb_ivar_set(self, id_i_imag, RARRAY_AREF(a, 1)); return self; };T;:I"static VALUE;T;;T; @%; IC;[; @%; IC;[; @%; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ i[ ;F;:compatible;;;;;[;{;IC; " ;T;[;![;"@;#0;$@%;Bi;%@!;&I"Complex::compatible;F;'@o;4;5F;6;;;;&I"Complex#to_i;F;7[;[[@ i$;T;;;0;[;{;IC; "Returns the value as an integer if possible (the imaginary part should be exactly zero). Complex(1, 0).to_i #=> 1 Complex(1, 0.0).to_i # RangeError Complex(1, 2).to_i # RangeError ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_i;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@%;![;"I"@return [Integer];T;#0;$@%;.F;Bi;C0;7[;$@%;![;"I"Returns the value as an integer if possible (the imaginary part should be exactly zero). Complex(1, 0).to_i #=> 1 Complex(1, 0.0).to_i # RangeError Complex(1, 2).to_i # RangeError @overload to_i @return [Integer];T;#0;$@%;.F;/o;0;1T;2i;3i";%@!;9I"static VALUE nucomp_to_i(VALUE self) { get_dat1(self); if (!k_exact_zero_p(dat->imag)) { rb_raise(rb_eRangeError, "can't convert %"PRIsVALUE" into Integer", self); } return f_to_i(dat->real); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#to_f;F;7[;[[@ i;;T;;;0;[;{;IC; "Returns the value as a float if possible (the imaginary part should be exactly zero). Complex(1, 0).to_f #=> 1.0 Complex(1, 0.0).to_f # RangeError Complex(1, 2).to_f # RangeError ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_f;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@&;![;"I"@return [Float];T;#0;$@&;.F;Bi;C0;7[;$@&;![;"I"Returns the value as a float if possible (the imaginary part should be exactly zero). Complex(1, 0).to_f #=> 1.0 Complex(1, 0.0).to_f # RangeError Complex(1, 2).to_f # RangeError @overload to_f @return [Float];T;#0;$@&;.F;/o;0;1T;2i0;3i9;%@!;9I"static VALUE nucomp_to_f(VALUE self) { get_dat1(self); if (!k_exact_zero_p(dat->imag)) { rb_raise(rb_eRangeError, "can't convert %"PRIsVALUE" into Float", self); } return f_to_f(dat->real); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#to_r;F;7[;[[@ iT;T;;;0;[;{;IC; "Returns the value as a rational if possible (the imaginary part should be exactly zero). Complex(1, 0).to_r #=> (1/1) Complex(1, 0.0).to_r # RangeError Complex(1, 2).to_r # RangeError See rationalize. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_r;T;IC; ";T;[;![;"I";T;#0;$@0&;.F;Bi;C0;7[;$@0&;![;"I"Returns the value as a rational if possible (the imaginary part should be exactly zero). Complex(1, 0).to_r #=> (1/1) Complex(1, 0.0).to_r # RangeError Complex(1, 2).to_r # RangeError See rationalize. @overload to_r;T;#0;$@0&;.F;/o;0;1T;2iG;3iQ;%@!;9I"static VALUE nucomp_to_r(VALUE self) { get_dat1(self); if (!k_exact_zero_p(dat->imag)) { rb_raise(rb_eRangeError, "can't convert %"PRIsVALUE" into Rational", self); } return f_to_r(dat->real); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#rationalize;F;7[[@90;[[@ im;T;;;0;[;{;IC; "Returns the value as a rational if possible (the imaginary part should be exactly zero). Complex(1.0/3, 0).rationalize #=> (1/3) Complex(1, 0.0).rationalize # RangeError Complex(1, 2).rationalize # RangeError See to_r. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"rationalize([eps]);T;IC; ";T;[;![;"I";T;#0;$@F&;.F;Bi;C0;7[[I" [eps];T0;$@F&;![;"I" Returns the value as a rational if possible (the imaginary part should be exactly zero). Complex(1.0/3, 0).rationalize #=> (1/3) Complex(1, 0.0).rationalize # RangeError Complex(1, 2).rationalize # RangeError See to_r. @overload rationalize([eps]);T;#0;$@F&;.F;/o;0;1T;2i`;3ij;%@!;9I"Jstatic VALUE nucomp_rationalize(int argc, VALUE *argv, VALUE self) { get_dat1(self); rb_check_arity(argc, 0, 1); if (!k_exact_zero_p(dat->imag)) { rb_raise(rb_eRangeError, "can't convert %"PRIsVALUE" into Rational", self); } return rb_funcallv(dat->real, id_rationalize, argc, argv); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Complex#to_c;F;7[;[[@ i;T;;;0;[;{;IC; "ZReturns self. Complex(2).to_c #=> (2+0i) Complex(-8, 6).to_c #=> (-8+6i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_c;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@_&;![;"I"@return [self];T;#0;$@_&;.F;Bi;C0;7[;$@_&;![;"I"|Returns self. Complex(2).to_c #=> (2+0i) Complex(-8, 6).to_c #=> (-8+6i) @overload to_c @return [self];T;#0;$@_&;.F;/o;0;1T;2i{;3i;%@!;9I">static VALUE nucomp_to_c(VALUE self) { return self; };T;:I"static VALUE;T;;To;u;[[@ i ;F;:I;;w;;;[;{;IC; "The imaginary unit. ;T;[;![;"I"The imaginary unit. ;T;#0;$@z&;.F;/o;0;1T;2i| ;3i} ;%@!;&I"Complex::I;F;xI"0f_complex_new_bang2(rb_cComplex, ZERO, ONE);T; @!; IC;[; @!; IC;[; @!; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ i ;F;;;;;;;[;{;IC; "]A complex number can be represented as a paired real number with imaginary unit; a+bi. Where a is real part, b is imaginary part and i is imaginary unit. Real a equals complex a+0i mathematically. You can create a \Complex object explicitly with: - A {complex literal}[doc/syntax/literals_rdoc.html#label-Complex+Literals]. You can convert certain objects to \Complex objects with: - \Method {Complex}[Kernel.html#method-i-Complex]. Complex object can be created as literal, and also by using Kernel#Complex, Complex::rect, Complex::polar or to_c method. 2+1i #=> (2+1i) Complex(1) #=> (1+0i) Complex(2, 3) #=> (2+3i) Complex.polar(2, 3) #=> (-1.9799849932008908+0.2822400161197344i) 3.to_c #=> (3+0i) You can also create complex object from floating-point numbers or strings. Complex(0.3) #=> (0.3+0i) Complex('0.3-0.5i') #=> (0.3-0.5i) Complex('2/3+3/4i') #=> ((2/3)+(3/4)*i) Complex('1@2') #=> (-0.4161468365471424+0.9092974268256817i) 0.3.to_c #=> (0.3+0i) '0.3-0.5i'.to_c #=> (0.3-0.5i) '2/3+3/4i'.to_c #=> ((2/3)+(3/4)*i) '1@2'.to_c #=> (-0.4161468365471424+0.9092974268256817i) A complex object is either an exact or an inexact number. Complex(1, 1) / 2 #=> ((1/2)+(1/2)*i) Complex(1, 1) / 2.0 #=> (0.5+0.5i) ;T;[;![;"I"^A complex number can be represented as a paired real number with imaginary unit; a+bi. Where a is real part, b is imaginary part and i is imaginary unit. Real a equals complex a+0i mathematically. You can create a \Complex object explicitly with: - A {complex literal}[doc/syntax/literals_rdoc.html#label-Complex+Literals]. You can convert certain objects to \Complex objects with: - \Method {Complex}[Kernel.html#method-i-Complex]. Complex object can be created as literal, and also by using Kernel#Complex, Complex::rect, Complex::polar or to_c method. 2+1i #=> (2+1i) Complex(1) #=> (1+0i) Complex(2, 3) #=> (2+3i) Complex.polar(2, 3) #=> (-1.9799849932008908+0.2822400161197344i) 3.to_c #=> (3+0i) You can also create complex object from floating-point numbers or strings. Complex(0.3) #=> (0.3+0i) Complex('0.3-0.5i') #=> (0.3-0.5i) Complex('2/3+3/4i') #=> ((2/3)+(3/4)*i) Complex('1@2') #=> (-0.4161468365471424+0.9092974268256817i) 0.3.to_c #=> (0.3+0i) '0.3-0.5i'.to_c #=> (0.3-0.5i) '2/3+3/4i'.to_c #=> ((2/3)+(3/4)*i) '1@2'.to_c #=> (-0.4161468365471424+0.9092974268256817i) A complex object is either an exact or an inexact number. Complex(1, 1) / 2 #=> ((1/2)+(1/2)*i) Complex(1, 1) / 2.0 #=> (0.5+0.5i) ;T;#0;$@!;.F;/o;0;1T;2i;3i;%@;&I" Complex;F;'o;( ;)0;*0;+0;: Numeric;%@;-o; ;IC;[0o;4;5F;6;;;;&I"Numeric#to_c;F;7[;[[@ i;T;;;0;[;{;IC; "$Returns the value as a complex. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_c;T;IC; ";T;[;![;"I";T;#0;$@&;.F;Bi;C0;7[;$@&;![;"I"5Returns the value as a complex. @overload to_c;T;#0;$@&;.F;/o;0;1T;2i;3i;%@&;9I"Pstatic VALUE numeric_to_c(VALUE self) { return rb_complex_new1(self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#real;F;7[;[[@ i_;T;;;0;[;{;IC; "Returns self. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" real;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@&;![;"I"@return [self];T;#0;$@&;.F;Bi;C0;7[;$@&;![;"I"4Returns self. @overload real @return [self];T;#0;$@&;.F;/o;0;1T;2iY;3i];%@&;9I"?static VALUE numeric_real(VALUE self) { return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#imaginary;F;7[;[[@ il;T;;;0;[;{;IC; "Returns zero. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" imag;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@&;![;"I"@return [ 0];T;#0;$@&;.F;Bi;C0;7[;$@&o;= ;>I" overload;F;?0;;;@0;:I"imaginary;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@&;![;"I"@return [ 0];T;#0;$@&;.F;Bi;C0;7[;$@&;![;"I"UReturns zero. @overload imag @return [ 0] @overload imaginary @return [ 0];T;#0;$@&;.F;/o;0;1T;2ie;3ik;%@&;9I"Estatic VALUE numeric_imag(VALUE self) { return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#imag;F;7[;[[@ il;T;;;0;[;{;IC; "Returns zero. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" imag;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@&;![;"I"@return [ 0];T;#0;$@&;.F;Bi;C0;7[;$@&o;= ;>I" overload;F;?0;;;@0;:I"imaginary;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@&;![;"I"@return [ 0];T;#0;$@&;.F;Bi;C0;7[;$@&;![;"@&;#0;$@&;.F;/o;0;1T;2ie;3ik;%@&;9I"Estatic VALUE numeric_imag(VALUE self) { return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#abs2;F;7[;[[@ ix;T;;;0;[;{;IC; "Returns square of self. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" abs2;T;IC; ";T;[;![;"I";T;#0;$@';.F;Bi;C0;7[;$@';![;"I"-Returns square of self. @overload abs2;T;#0;$@';.F;/o;0;1T;2ir;3iu;%@&;9I"Lstatic VALUE numeric_abs2(VALUE self) { return f_mul(self, self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#arg;F;7[;[[@ i;T;;;0;[;{;IC; "6Returns 0 if the value is positive, pi otherwise. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"arg;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI" Float;T;$@0';![;"I"@return [ 0, Float];T;#0;$@0';.F;Bi;C0;7[;$@0'o;= ;>I" overload;F;?0;;;@0;:I" angle;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI" Float;T;$@0';![;"I"@return [ 0, Float];T;#0;$@0';.F;Bi;C0;7[;$@0'o;= ;>I" overload;F;?0;;;@0;:I" phase;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI" Float;T;$@0';![;"I"@return [ 0, Float];T;#0;$@0';.F;Bi;C0;7[;$@0';![;"I"Returns 0 if the value is positive, pi otherwise. @overload arg @return [ 0, Float] @overload angle @return [ 0, Float] @overload phase @return [ 0, Float];T;#0;$@0';.F;/o;0;1T;2i~;3i;%@&;9I"~static VALUE numeric_arg(VALUE self) { if (f_positive_p(self)) return INT2FIX(0); return DBL2NUM(M_PI); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#angle;F;7[;[[@ i;T;;;0;[;{;IC; "6Returns 0 if the value is positive, pi otherwise. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"arg;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI" Float;T;$@h';![;"I"@return [ 0, Float];T;#0;$@h';.F;Bi;C0;7[;$@h'o;= ;>I" overload;F;?0;;;@0;:I" angle;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI" Float;T;$@h';![;"I"@return [ 0, Float];T;#0;$@h';.F;Bi;C0;7[;$@h'o;= ;>I" overload;F;?0;;;@0;:I" phase;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI" Float;T;$@h';![;"I"@return [ 0, Float];T;#0;$@h';.F;Bi;C0;7[;$@h';![;"@d';#0;$@h';.F;/o;0;1T;2i~;3i;%@&;9I"~static VALUE numeric_arg(VALUE self) { if (f_positive_p(self)) return INT2FIX(0); return DBL2NUM(M_PI); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#phase;F;7[;[[@ i;T;;;0;[;{;IC; "6Returns 0 if the value is positive, pi otherwise. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"arg;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI" Float;T;$@';![;"I"@return [ 0, Float];T;#0;$@';.F;Bi;C0;7[;$@'o;= ;>I" overload;F;?0;;;@0;:I" angle;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI" Float;T;$@';![;"I"@return [ 0, Float];T;#0;$@';.F;Bi;C0;7[;$@'o;= ;>I" overload;F;?0;;;@0;:I" phase;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI" Float;T;$@';![;"I"@return [ 0, Float];T;#0;$@';.F;Bi;C0;7[;$@';![;"@d';#0;$@';.F;/o;0;1T;2i~;3i;%@&;9I"~static VALUE numeric_arg(VALUE self) { if (f_positive_p(self)) return INT2FIX(0); return DBL2NUM(M_PI); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#rectangular;F;7[;[[@ i;T;;;0;[;{;IC; " Returns an array; [num, 0]. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" rect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@';![;"I"@return [Array];T;#0;$@';.F;Bi;C0;7[;$@'o;= ;>I" overload;F;?0;;;@0;:I"rectangular;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@';![;"I"@return [Array];T;#0;$@';.F;Bi;C0;7[;$@';![;"I"kReturns an array; [num, 0]. @overload rect @return [Array] @overload rectangular @return [Array];T;#0;$@';.F;/o;0;1T;2i;3i;%@&;9I"Ystatic VALUE numeric_rect(VALUE self) { return rb_assoc_new(self, INT2FIX(0)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#rect;F;7[;[[@ i;T;;;0;[;{;IC; " Returns an array; [num, 0]. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" rect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@';![;"I"@return [Array];T;#0;$@';.F;Bi;C0;7[;$@'o;= ;>I" overload;F;?0;;;@0;:I"rectangular;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@';![;"I"@return [Array];T;#0;$@';.F;Bi;C0;7[;$@';![;"@';#0;$@';.F;/o;0;1T;2i;3i;%@&;9I"Ystatic VALUE numeric_rect(VALUE self) { return rb_assoc_new(self, INT2FIX(0)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#polar;F;7[;[[@ i;T;;;0;[;{;IC; "*Returns an array; [num.abs, num.arg]. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" polar;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@%(;![;"I"@return [Array];T;#0;$@%(;.F;Bi;C0;7[;$@%(;![;"I"NReturns an array; [num.abs, num.arg]. @overload polar @return [Array];T;#0;$@%(;.F;/o;0;1T;2i;3i;%@&;9I"static VALUE numeric_polar(VALUE self) { VALUE abs, arg; if (RB_INTEGER_TYPE_P(self)) { abs = rb_int_abs(self); arg = numeric_arg(self); } else if (RB_FLOAT_TYPE_P(self)) { abs = rb_float_abs(self); arg = float_arg(self); } else if (RB_TYPE_P(self, T_RATIONAL)) { abs = rb_rational_abs(self); arg = numeric_arg(self); } else { abs = f_abs(self); arg = f_arg(self); } return rb_assoc_new(abs, arg); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#conjugate;F;7[;[[@ i;T;;;0;[;{;IC; "Returns self. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" conj;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@@(;![;"I"@return [self];T;#0;$@@(;.F;Bi;C0;7[;$@@(o;= ;>I" overload;F;?0;;;@0;:I"conjugate;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@@(;![;"I"@return [self];T;#0;$@@(;.F;Bi;C0;7[;$@@(;![;"I"YReturns self. @overload conj @return [self] @overload conjugate @return [self];T;#0;$@@(;.F;/o;0;1T;2i;3i;%@&;9I"?static VALUE numeric_conj(VALUE self) { return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#conj;F;7[;[[@ i;T;;;0;[;{;IC; "Returns self. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" conj;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@h(;![;"I"@return [self];T;#0;$@h(;.F;Bi;C0;7[;$@h(o;= ;>I" overload;F;?0;;;@0;:I"conjugate;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@h(;![;"I"@return [self];T;#0;$@h(;.F;Bi;C0;7[;$@h(;![;"@d(;#0;$@h(;.F;/o;0;1T;2i;3i;%@&;9I"?static VALUE numeric_conj(VALUE self) { return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#Numeric#singleton_method_added;F;7[[I" name;T0;[[@i;T;;;0;[;{;IC; ":nodoc: Trap attempts to add methods to Numeric objects. Always raises a TypeError. Numerics should be values; singleton_methods should not be added to them. ;T;[;![;"I":nodoc: Trap attempts to add methods to Numeric objects. Always raises a TypeError. Numerics should be values; singleton_methods should not be added to them. ;T;#0;$@(;.F;/o;0;1T;2i;3i;%@&;9I"static VALUE num_sadded(VALUE x, VALUE name) { ID mid = rb_to_id(name); /* ruby_frame = ruby_frame->prev; */ /* pop frame for "singleton_method_added" */ rb_remove_method_id(rb_singleton_class(x), mid); rb_raise(rb_eTypeError, "can't define singleton method \"%"PRIsVALUE"\" for %"PRIsVALUE, rb_id2str(mid), rb_obj_class(x)); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#coerce;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "Returns a 2-element array containing two numeric elements, formed from the two operands +self+ and +other+, of a common compatible type. Of the Core and Standard Library classes, Integer, Rational, and Complex use this implementation. Examples: i = 2 # => 2 i.coerce(3) # => [3, 2] i.coerce(3.0) # => [3.0, 2.0] i.coerce(Rational(1, 2)) # => [0.5, 2.0] i.coerce(Complex(3, 4)) # Raises RangeError. r = Rational(5, 2) # => (5/2) r.coerce(2) # => [(2/1), (5/2)] r.coerce(2.0) # => [2.0, 2.5] r.coerce(Rational(2, 3)) # => [(2/3), (5/2)] r.coerce(Complex(3, 4)) # => [(3+4i), ((5/2)+0i)] c = Complex(2, 3) # => (2+3i) c.coerce(2) # => [(2+0i), (2+3i)] c.coerce(2.0) # => [(2.0+0i), (2+3i)] c.coerce(Rational(1, 2)) # => [((1/2)+0i), (2+3i)] c.coerce(Complex(3, 4)) # => [(3+4i), (2+3i)] Raises an exception if any type conversion fails. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"coerce(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@(;![;"I"@return [Array];T;#0;$@(;.F;Bi;C0;7[[I" other;T0;$@(;![;"I"Returns a 2-element array containing two numeric elements, formed from the two operands +self+ and +other+, of a common compatible type. Of the Core and Standard Library classes, Integer, Rational, and Complex use this implementation. Examples: i = 2 # => 2 i.coerce(3) # => [3, 2] i.coerce(3.0) # => [3.0, 2.0] i.coerce(Rational(1, 2)) # => [0.5, 2.0] i.coerce(Complex(3, 4)) # Raises RangeError. r = Rational(5, 2) # => (5/2) r.coerce(2) # => [(2/1), (5/2)] r.coerce(2.0) # => [2.0, 2.5] r.coerce(Rational(2, 3)) # => [(2/3), (5/2)] r.coerce(Complex(3, 4)) # => [(3+4i), ((5/2)+0i)] c = Complex(2, 3) # => (2+3i) c.coerce(2) # => [(2+0i), (2+3i)] c.coerce(2.0) # => [(2.0+0i), (2+3i)] c.coerce(Rational(1, 2)) # => [((1/2)+0i), (2+3i)] c.coerce(Complex(3, 4)) # => [(3+4i), (2+3i)] Raises an exception if any type conversion fails. @overload coerce(other) @return [Array];T;#0;$@(;.F;/o;0;1T;2i;3i;%@&;9I"static VALUE num_coerce(VALUE x, VALUE y) { if (CLASS_OF(x) == CLASS_OF(y)) return rb_assoc_new(y, x); x = rb_Float(x); y = rb_Float(y); return rb_assoc_new(y, x); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#clone;F;7[[@90;[[@i;T;;;0;[;{;IC; "wReturns +self+. Raises an exception if the value for +freeze+ is neither +true+ nor +nil+. Related: Numeric#dup. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"clone(freeze: true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@(;![;"I"@return [self];T;#0;$@(;.F;Bi;C0;7[[I" freeze:;TI" true;T;$@(;![;"I"Returns +self+. Raises an exception if the value for +freeze+ is neither +true+ nor +nil+. Related: Numeric#dup. @overload clone(freeze: true) @return [self];T;#0;$@(;.F;/o;0;1T;2i;3i;%@&;9I"qstatic VALUE num_clone(int argc, VALUE *argv, VALUE x) { return rb_immutable_obj_clone(argc, argv, x); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#dup;F;7[;[[@i/;T;;[;0;[;{;IC; "-Returns +self+. Related: Numeric#clone. ;T;[o;= ;>I" overload;F;?0;;[;@0;:I"dup;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@(;![;"I"@return [self];T;#0;$@(;.F;Bi;C0;7[;$@(;![;"I"OReturns +self+. Related: Numeric#clone. @overload dup @return [self];T;#0;$@(;.F;/o;0;1T;2i&;3i-;%@&;9I"4static VALUE num_dup(VALUE x) { return x; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#i;F;7[;[[@iT;T;:i;0;[;{;IC; "Returns Complex(0, self): 2.i # => (0+2i) -2.i # => (0-2i) 2.0.i # => (0+2.0i) Rational(1, 2).i # => (0+(1/2)*i) Complex(3, 4).i # Raises NoMethodError. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"i;T;IC; ";T;[;![;"I";T;#0;$@(;.F;Bi;C0;7[;$@(;![;"I"Returns Complex(0, self): 2.i # => (0+2i) -2.i # => (0-2i) 2.0.i # => (0+2.0i) Rational(1, 2).i # => (0+(1/2)*i) Complex(3, 4).i # Raises NoMethodError. @overload i;T;#0;$@(;.F;/o;0;1T;2iF;3iP;%@&;9I"Zstatic VALUE num_imaginary(VALUE num) { return rb_complex_new(INT2FIX(0), num); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#+@;F;7[;[[@i@;T;;;0;[;{;IC; "Returns +self+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" +self;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@);![;"I"@return [self];T;#0;$@);.F;Bi;C0;7[;$@);![;"I"8Returns +self+. @overload +self @return [self];T;#0;$@);.F;/o;0;1T;2i8;3i=;%@&;9I":static VALUE num_uplus(VALUE num) { return num; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#-@;F;7[;[[@ia;T;;;0;[;{;IC; "1Unary Minus---Returns the receiver, negated. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" -self;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@));![;"I"@return [Numeric];T;#0;$@));.F;Bi;C0;7[;$@));![;"I"WUnary Minus---Returns the receiver, negated. @overload -self @return [Numeric];T;#0;$@));.F;/o;0;1T;2iZ;3i^;%@&;9I"static VALUE num_uminus(VALUE num) { VALUE zero; zero = INT2FIX(0); do_coerce(&zero, &num, TRUE); return num_funcall1(zero, '-', num); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#<=>;F;7[[I"y;T0;[[@i-;T;;Y;0;[;{;IC; "Returns zero if +self+ is the same as +other+, +nil+ otherwise. No subclass in the Ruby Core or Standard Library uses this implementation. ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I"<=>(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@D);![;"I"@return [nil];T;#0;$@D);.F;Bi;C0;7[[I" other;T0;$@D);![;"I"Returns zero if +self+ is the same as +other+, +nil+ otherwise. No subclass in the Ruby Core or Standard Library uses this implementation. @overload <=>(other) @return [nil];T;#0;$@D);.F;/o;0;1T;2i#;3i*;%@&;9I"cstatic VALUE num_cmp(VALUE x, VALUE y) { if (x == y) return INT2FIX(0); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#eql?;F;7[[I"y;T0;[[@i;T;;V;0;[;{;IC; "Returns +true+ if +self+ and +other+ are the same type and have equal values. Of the Core and Standard Library classes, only Integer, Rational, and Complex use this implementation. Examples: 1.eql?(1) # => true 1.eql?(1.0) # => false 1.eql?(Rational(1, 1)) # => false 1.eql?(Complex(1, 0)) # => false \Method +eql?+ is different from +==+ in that +eql?+ requires matching types, while +==+ does not.;T;[o;= ;>I" overload;F;?0;;V;@0;:I"eql?(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@c);![;"I"@return [Boolean];T;#0;$@c);.F;Bi;C0;7[[I" other;T0;$@c);![;"I"Returns +true+ if +self+ and +other+ are the same type and have equal values. Of the Core and Standard Library classes, only Integer, Rational, and Complex use this implementation. Examples: 1.eql?(1) # => true 1.eql?(1.0) # => false 1.eql?(Rational(1, 1)) # => false 1.eql?(Complex(1, 0)) # => false \Method +eql?+ is different from +==+ in that +eql?+ requires matching types, while +==+ does not. @overload eql?(other) @return [Boolean];T;#0;$@c);.F;/o;0;1T;2i;3i;Bi;%@&;9I"static VALUE num_eql(VALUE x, VALUE y) { if (TYPE(x) != TYPE(y)) return Qfalse; if (RB_BIGNUM_TYPE_P(x)) { return rb_big_eql(x, y); } return rb_equal(x, y); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#fdiv;F;7[[I"y;T0;[[@iy;T;;;0;[;{;IC; "Returns the quotient self/other as a float, using method +/+ in the derived class of +self+. (\Numeric itself does not define method +/+.) Of the Core and Standard Library classes, only BigDecimal uses this implementation. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"fdiv(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@);![;"I"@return [Float];T;#0;$@);.F;Bi;C0;7[[I" other;T0;$@);![;"I"Returns the quotient self/other as a float, using method +/+ in the derived class of +self+. (\Numeric itself does not define method +/+.) Of the Core and Standard Library classes, only BigDecimal uses this implementation. @overload fdiv(other) @return [Float];T;#0;$@);.F;/o;0;1T;2il;3iv;%@&;9I"_static VALUE num_fdiv(VALUE x, VALUE y) { return rb_funcall(rb_Float(x), '/', 1, y); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#div;F;7[[I"y;T0;[[@i;T;:div;0;[;{;IC; "Returns the quotient self/other as an integer (via +floor+), using method +/+ in the derived class of +self+. (\Numeric itself does not define method +/+.) Of the Core and Standard Library classes, Float, Rational, and Complex use this implementation. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"div(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@);![;"I"@return [Integer];T;#0;$@);.F;Bi;C0;7[[I" other;T0;$@);![;"I"1Returns the quotient self/other as an integer (via +floor+), using method +/+ in the derived class of +self+. (\Numeric itself does not define method +/+.) Of the Core and Standard Library classes, Float, Rational, and Complex use this implementation. @overload div(other) @return [Integer];T;#0;$@);.F;/o;0;1T;2i;3i;%@&;9I"static VALUE num_div(VALUE x, VALUE y) { if (rb_equal(INT2FIX(0), y)) rb_num_zerodiv(); return rb_funcall(num_funcall1(x, '/', y), rb_intern("floor"), 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#divmod;F;7[[I"y;T0;[[@i;T;: divmod;0;[;{;IC; "GReturns a 2-element array [q, r], where q = (self/other).floor # Quotient r = self % other # Remainder Of the Core and Standard Library classes, only Rational uses this implementation. Examples: Rational(11, 1).divmod(4) # => [2, (3/1)] Rational(11, 1).divmod(-4) # => [-3, (-1/1)] Rational(-11, 1).divmod(4) # => [-3, (1/1)] Rational(-11, 1).divmod(-4) # => [2, (-3/1)] Rational(12, 1).divmod(4) # => [3, (0/1)] Rational(12, 1).divmod(-4) # => [-3, (0/1)] Rational(-12, 1).divmod(4) # => [-3, (0/1)] Rational(-12, 1).divmod(-4) # => [3, (0/1)] Rational(13, 1).divmod(4.0) # => [3, 1.0] Rational(13, 1).divmod(Rational(4, 11)) # => [35, (3/11)] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"divmod(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@);![;"I"@return [Array];T;#0;$@);.F;Bi;C0;7[[I" other;T0;$@);![;"I"sReturns a 2-element array [q, r], where q = (self/other).floor # Quotient r = self % other # Remainder Of the Core and Standard Library classes, only Rational uses this implementation. Examples: Rational(11, 1).divmod(4) # => [2, (3/1)] Rational(11, 1).divmod(-4) # => [-3, (-1/1)] Rational(-11, 1).divmod(4) # => [-3, (1/1)] Rational(-11, 1).divmod(-4) # => [2, (-3/1)] Rational(12, 1).divmod(4) # => [3, (0/1)] Rational(12, 1).divmod(-4) # => [-3, (0/1)] Rational(-12, 1).divmod(4) # => [-3, (0/1)] Rational(-12, 1).divmod(-4) # => [3, (0/1)] Rational(13, 1).divmod(4.0) # => [3, 1.0] Rational(13, 1).divmod(Rational(4, 11)) # => [35, (3/11)] @overload divmod(other) @return [Array];T;#0;$@);.F;/o;0;1T;2i;3i ;%@&;9I"lstatic VALUE num_divmod(VALUE x, VALUE y) { return rb_assoc_new(num_div(x, y), num_modulo(x, y)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#%;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "Returns +self+ modulo +other+ as a real number. Of the Core and Standard Library classes, only Rational uses this implementation. For \Rational +r+ and real number +n+, these expressions are equivalent: c % n c-n*(c/n).floor c.divmod(n)[1] See Numeric#divmod. Examples: r = Rational(1, 2) # => (1/2) r2 = Rational(2, 3) # => (2/3) r % r2 # => (1/2) r % 2 # => (1/2) r % 2.0 # => 0.5 r = Rational(301,100) # => (301/100) r2 = Rational(7,5) # => (7/5) r % r2 # => (21/100) r % -r2 # => (-119/100) (-r) % r2 # => (119/100) (-r) %-r2 # => (-21/100) Numeric#modulo is an alias for Numeric#%. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" %(other);T;IC; ";T;[;![;"I";T;#0;$@);.F;Bi;C0;7[[I" other;T0;$@);![;"I"Returns +self+ modulo +other+ as a real number. Of the Core and Standard Library classes, only Rational uses this implementation. For \Rational +r+ and real number +n+, these expressions are equivalent: c % n c-n*(c/n).floor c.divmod(n)[1] See Numeric#divmod. Examples: r = Rational(1, 2) # => (1/2) r2 = Rational(2, 3) # => (2/3) r % r2 # => (1/2) r % 2 # => (1/2) r % 2.0 # => 0.5 r = Rational(301,100) # => (301/100) r2 = Rational(7,5) # => (7/5) r % r2 # => (21/100) r % -r2 # => (-119/100) (-r) % r2 # => (119/100) (-r) %-r2 # => (-21/100) Numeric#modulo is an alias for Numeric#%. @overload %(other);T;#0;$@);.F;/o;0;1T;2i;3i;%@&;9I"static VALUE num_modulo(VALUE x, VALUE y) { VALUE q = num_funcall1(x, id_div, y); return rb_funcall(x, '-', 1, rb_funcall(y, '*', 1, q)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#modulo;F;7[[I"y;T0;[[@i;T;: modulo;0;[;{;IC; "Returns +self+ modulo +other+ as a real number. Of the Core and Standard Library classes, only Rational uses this implementation. For \Rational +r+ and real number +n+, these expressions are equivalent: c % n c-n*(c/n).floor c.divmod(n)[1] See Numeric#divmod. Examples: r = Rational(1, 2) # => (1/2) r2 = Rational(2, 3) # => (2/3) r % r2 # => (1/2) r % 2 # => (1/2) r % 2.0 # => 0.5 r = Rational(301,100) # => (301/100) r2 = Rational(7,5) # => (7/5) r % r2 # => (21/100) r % -r2 # => (-119/100) (-r) % r2 # => (119/100) (-r) %-r2 # => (-21/100) Numeric#modulo is an alias for Numeric#%. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" %(other);T;IC; ";T;[;![;"I";T;#0;$@);.F;Bi;C0;7[[I" other;T0;$@);![;"@);#0;$@);.F;/o;0;1T;2i;3i;%@&;9I"static VALUE num_modulo(VALUE x, VALUE y) { VALUE q = num_funcall1(x, id_div, y); return rb_funcall(x, '-', 1, rb_funcall(y, '*', 1, q)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#remainder;F;7[[I"y;T0;[[@i;T;:remainder;0;[;{;IC; "Returns the remainder after dividing +self+ by +other+. Of the Core and Standard Library classes, only Float and Rational use this implementation. Examples: 11.0.remainder(4) # => 3.0 11.0.remainder(-4) # => 3.0 -11.0.remainder(4) # => -3.0 -11.0.remainder(-4) # => -3.0 12.0.remainder(4) # => 0.0 12.0.remainder(-4) # => 0.0 -12.0.remainder(4) # => -0.0 -12.0.remainder(-4) # => -0.0 13.0.remainder(4.0) # => 1.0 13.0.remainder(Rational(4, 1)) # => 1.0 Rational(13, 1).remainder(4) # => (1/1) Rational(13, 1).remainder(-4) # => (1/1) Rational(-13, 1).remainder(4) # => (-1/1) Rational(-13, 1).remainder(-4) # => (-1/1) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"remainder(other);T;IC; ";T;[;![;"I";T;#0;$@*;.F;Bi;C0;7[[I" other;T0;$@*;![;"I"Returns the remainder after dividing +self+ by +other+. Of the Core and Standard Library classes, only Float and Rational use this implementation. Examples: 11.0.remainder(4) # => 3.0 11.0.remainder(-4) # => 3.0 -11.0.remainder(4) # => -3.0 -11.0.remainder(-4) # => -3.0 12.0.remainder(4) # => 0.0 12.0.remainder(-4) # => 0.0 -12.0.remainder(4) # => -0.0 -12.0.remainder(-4) # => -0.0 13.0.remainder(4.0) # => 1.0 13.0.remainder(Rational(4, 1)) # => 1.0 Rational(13, 1).remainder(4) # => (1/1) Rational(13, 1).remainder(-4) # => (1/1) Rational(-13, 1).remainder(4) # => (-1/1) Rational(-13, 1).remainder(-4) # => (-1/1) @overload remainder(other);T;#0;$@*;.F;/o;0;1T;2i;3i;%@&;9I"static VALUE num_remainder(VALUE x, VALUE y) { VALUE z = num_funcall1(x, '%', y); if ((!rb_equal(z, INT2FIX(0))) && ((rb_num_negative_int_p(x) && rb_num_positive_int_p(y)) || (rb_num_positive_int_p(x) && rb_num_negative_int_p(y)))) { if (RB_FLOAT_TYPE_P(y)) { if (isinf(RFLOAT_VALUE(y))) { return x; } } return rb_funcall(z, '-', 1, y); } return z; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#abs;F;7[;[[@i";T;;;0;[;{;IC; "Returns the absolute value of +self+. 12.abs #=> 12 (-34.56).abs #=> 34.56 -34.56.abs #=> 34.56 Numeric#magnitude is an alias for Numeric#abs. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"abs;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@,*;![;"I"@return [Numeric];T;#0;$@,*;.F;Bi;C0;7[;$@,*;![;"I"Returns the absolute value of +self+. 12.abs #=> 12 (-34.56).abs #=> 34.56 -34.56.abs #=> 34.56 Numeric#magnitude is an alias for Numeric#abs. @overload abs @return [Numeric];T;#0;$@,*;.F;/o;0;1T;2i;3i;%@&;9I"static VALUE num_abs(VALUE num) { if (rb_num_negative_int_p(num)) { return num_funcall0(num, idUMinus); } return num; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#magnitude;F;7[;[[@i";T;;;0;[;{;IC; "Returns the absolute value of +self+. 12.abs #=> 12 (-34.56).abs #=> 34.56 -34.56.abs #=> 34.56 Numeric#magnitude is an alias for Numeric#abs. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"abs;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@G*;![;"I"@return [Numeric];T;#0;$@G*;.F;Bi;C0;7[;$@G*;![;"@C*;#0;$@G*;.F;/o;0;1T;2i;3i;%@&;9I"static VALUE num_abs(VALUE num) { if (rb_num_negative_int_p(num)) { return num_funcall0(num, idUMinus); } return num; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#to_int;F;7[;[[@iz;T;;;0;[;{;IC; "]Returns +self+ as an integer; converts using method +to_i+ in the derived class. Of the Core and Standard Library classes, only Rational and Complex use this implementation. Examples: Rational(1, 2).to_int # => 0 Rational(2, 1).to_int # => 2 Complex(2, 0).to_int # => 2 Complex(2, 1) # Raises RangeError (non-zero imaginary part) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_int;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@a*;![;"I"@return [Integer];T;#0;$@a*;.F;Bi;C0;7[;$@a*;![;"I"Returns +self+ as an integer; converts using method +to_i+ in the derived class. Of the Core and Standard Library classes, only Rational and Complex use this implementation. Examples: Rational(1, 2).to_int # => 0 Rational(2, 1).to_int # => 2 Complex(2, 0).to_int # => 2 Complex(2, 1) # Raises RangeError (non-zero imaginary part) @overload to_int @return [Integer];T;#0;$@a*;.F;/o;0;1T;2ig;3iw;%@&;9I"Rstatic VALUE num_to_int(VALUE num) { return num_funcall0(num, id_to_i); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#zero?;F;7[;[[@i6;T;;B;0;[;{;IC; "Returns +true+ if +zero+ has a zero value, +false+ otherwise. Of the Core and Standard Library classes, only Rational and Complex use this implementation.;T;[o;= ;>I" overload;F;?0;;B;@0;:I" zero?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@|*;![;"I"@return [Boolean];T;#0;$@|*;.F;Bi;C0;7[;$@|*;![;"I"Returns +true+ if +zero+ has a zero value, +false+ otherwise. Of the Core and Standard Library classes, only Rational and Complex use this implementation. @overload zero? @return [Boolean];T;#0;$@|*;.F;/o;0;1T;2i+;3i3;Bi;%@&;9I"Qstatic VALUE num_zero_p(VALUE num) { return rb_equal(num, INT2FIX(0)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#nonzero?;F;7[;[[@i^;T;: nonzero?;0;[;{;IC; "Returns +self+ if +self+ is not a zero value, +nil+ otherwise; uses method zero? for the evaluation. The returned +self+ allows the method to be chained: a = %w[z Bb bB bb BB a aA Aa AA A] a.sort {|a, b| (a.downcase <=> b.downcase).nonzero? || a <=> b } # => ["A", "a", "AA", "Aa", "aA", "BB", "Bb", "bB", "bb", "z"] Of the Core and Standard Library classes, Integer, Float, Rational, and Complex use this implementation.;T;[o;= ;>I" overload;F;?0;;;@0;:I" nonzero?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;TI"nil;T;$@*;![;"I"@return [self, nil];T;#0;$@*;.F;Bi;C0;7[;$@*;![;"I"Returns +self+ if +self+ is not a zero value, +nil+ otherwise; uses method zero? for the evaluation. The returned +self+ allows the method to be chained: a = %w[z Bb bB bb BB a aA Aa AA A] a.sort {|a, b| (a.downcase <=> b.downcase).nonzero? || a <=> b } # => ["A", "a", "AA", "Aa", "aA", "BB", "Bb", "bB", "bb", "z"] Of the Core and Standard Library classes, Integer, Float, Rational, and Complex use this implementation. @overload nonzero? @return [self, nil];T;#0;$@*;.F;/o;0;1T;2iL;3i[;Bi;%@&;9I"static VALUE num_nonzero_p(VALUE num) { if (RTEST(num_funcall0(num, rb_intern("zero?")))) { return Qnil; } return num; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#floor;F;7[[@90;[[@ii ;T;;;0;[;{;IC; "Returns the largest number that is less than or equal to +self+ with a precision of +digits+ decimal digits. \Numeric implements this by converting +self+ to a Float and invoking Float#floor. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"floor(digits = 0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI" Float;T;$@*;![;"I"@return [Integer, Float];T;#0;$@*;.F;Bi;C0;7[[I" digits;TI"0;T;$@*;![;"I"Returns the largest number that is less than or equal to +self+ with a precision of +digits+ decimal digits. \Numeric implements this by converting +self+ to a Float and invoking Float#floor. @overload floor(digits = 0) @return [Integer, Float];T;#0;$@*;.F;/o;0;1T;2i^ ;3if ;%@&;9I"rstatic VALUE num_floor(int argc, VALUE *argv, VALUE num) { return flo_floor(argc, argv, rb_Float(num)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#ceil;F;7[[@90;[[@iz ;T;;;0;[;{;IC; "Returns the smallest number that is greater than or equal to +self+ with a precision of +digits+ decimal digits. \Numeric implements this by converting +self+ to a Float and invoking Float#ceil. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ceil(digits = 0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI" Float;T;$@*;![;"I"@return [Integer, Float];T;#0;$@*;.F;Bi;C0;7[[I" digits;TI"0;T;$@*;![;"I"Returns the smallest number that is greater than or equal to +self+ with a precision of +digits+ decimal digits. \Numeric implements this by converting +self+ to a Float and invoking Float#ceil. @overload ceil(digits = 0) @return [Integer, Float];T;#0;$@*;.F;/o;0;1T;2io ;3iw ;%@&;9I"pstatic VALUE num_ceil(int argc, VALUE *argv, VALUE num) { return flo_ceil(argc, argv, rb_Float(num)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#round;F;7[[@90;[[@i ;T;;;0;[;{;IC; "Returns +self+ rounded to the nearest value with a precision of +digits+ decimal digits. \Numeric implements this by converting +self+ to a Float and invoking Float#round. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"round(digits = 0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI" Float;T;$@*;![;"I"@return [Integer, Float];T;#0;$@*;.F;Bi;C0;7[[I" digits;TI"0;T;$@*;![;"I"Returns +self+ rounded to the nearest value with a precision of +digits+ decimal digits. \Numeric implements this by converting +self+ to a Float and invoking Float#round. @overload round(digits = 0) @return [Integer, Float];T;#0;$@*;.F;/o;0;1T;2i ;3i ;%@&;9I"rstatic VALUE num_round(int argc, VALUE* argv, VALUE num) { return flo_round(argc, argv, rb_Float(num)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#truncate;F;7[[@90;[[@i ;T;;_;0;[;{;IC; "Returns +self+ truncated (toward zero) to a precision of +digits+ decimal digits. \Numeric implements this by converting +self+ to a Float and invoking Float#truncate. ;T;[o;= ;>I" overload;F;?0;;_;@0;:I"truncate(digits = 0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI" Float;T;$@+;![;"I"@return [Integer, Float];T;#0;$@+;.F;Bi;C0;7[[I" digits;TI"0;T;$@+;![;"I"Returns +self+ truncated (toward zero) to a precision of +digits+ decimal digits. \Numeric implements this by converting +self+ to a Float and invoking Float#truncate. @overload truncate(digits = 0) @return [Integer, Float];T;#0;$@+;.F;/o;0;1T;2i ;3i ;%@&;9I"xstatic VALUE num_truncate(int argc, VALUE *argv, VALUE num) { return flo_truncate(argc, argv, rb_Float(num)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#step;F;7[[@90;[[@i ;T;;;0;[;{;IC; " Generates a sequence of numbers; with a block given, traverses the sequence. Of the Core and Standard Library classes, Integer, Float, and Rational use this implementation. A quick example: squares = [] 1.step(by: 2, to: 10) {|i| squares.push(i*i) } squares # => [1, 9, 25, 49, 81] The generated sequence: - Begins with +self+. - Continues at intervals of +step+ (which may not be zero). - Ends with the last number that is within or equal to +limit+; that is, less than or equal to +limit+ if +step+ is positive, greater than or equal to +limit+ if +step+ is negative. If +limit+ is not given, the sequence is of infinite length. If a block is given, calls the block with each number in the sequence; returns +self+. If no block is given, returns an Enumerator::ArithmeticSequence. Keyword Arguments With keyword arguments +by+ and +to+, their values (or defaults) determine the step and limit: # Both keywords given. squares = [] 4.step(by: 2, to: 10) {|i| squares.push(i*i) } # => 4 squares # => [16, 36, 64, 100] cubes = [] 3.step(by: -1.5, to: -3) {|i| cubes.push(i*i*i) } # => 3 cubes # => [27.0, 3.375, 0.0, -3.375, -27.0] squares = [] 1.2.step(by: 0.2, to: 2.0) {|f| squares.push(f*f) } squares # => [1.44, 1.9599999999999997, 2.5600000000000005, 3.24, 4.0] squares = [] Rational(6/5).step(by: 0.2, to: 2.0) {|r| squares.push(r*r) } squares # => [1.0, 1.44, 1.9599999999999997, 2.5600000000000005, 3.24, 4.0] # Only keyword to given. squares = [] 4.step(to: 10) {|i| squares.push(i*i) } # => 4 squares # => [16, 25, 36, 49, 64, 81, 100] # Only by given. # Only keyword by given squares = [] 4.step(by:2) {|i| squares.push(i*i); break if i > 10 } squares # => [16, 36, 64, 100, 144] # No block given. e = 3.step(by: -1.5, to: -3) # => (3.step(by: -1.5, to: -3)) e.class # => Enumerator::ArithmeticSequence Positional Arguments With optional positional arguments +limit+ and +step+, their values (or defaults) determine the step and limit: squares = [] 4.step(10, 2) {|i| squares.push(i*i) } # => 4 squares # => [16, 36, 64, 100] squares = [] 4.step(10) {|i| squares.push(i*i) } squares # => [16, 25, 36, 49, 64, 81, 100] squares = [] 4.step {|i| squares.push(i*i); break if i > 10 } # => nil squares # => [16, 25, 36, 49, 64, 81, 100, 121] Implementation Notes If all the arguments are integers, the loop operates using an integer counter. If any of the arguments are floating point numbers, all are converted to floats, and the loop is executed floor(n + n*Float::EPSILON) + 1 times, where n = (limit - self)/step. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"step(to = nil, by = 1);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"n;T;$@3+o;A ;>I" return;F;?I";T;0;@[I" self;T;$@3+;![;"I"@yield [n] @return [self];T;#0;$@3+;.F;Bi;C0;7[[I"to;TI"nil;T[I"by;TI"1;T;$@3+o;= ;>I" overload;F;?0;;;@0;:I"step(to = nil, by = 1);T;IC; ";T;[;![;"I";T;#0;$@3+;.F;Bi;C0;7[[I"to;TI"nil;T[I"by;TI"1;T;$@3+o;= ;>I" overload;F;?0;;;@0;:I"step(to = nil, by: 1);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"n;T;$@3+o;A ;>I" return;F;?I";T;0;@[I" self;T;$@3+;![;"I"@yield [n] @return [self];T;#0;$@3+;.F;Bi;C0;7[[I"to;TI"nil;T[I"by:;TI"1;T;$@3+o;= ;>I" overload;F;?0;;;@0;:I"step(to = nil, by: 1);T;IC; ";T;[;![;"I";T;#0;$@3+;.F;Bi;C0;7[[I"to;TI"nil;T[I"by:;TI"1;T;$@3+o;= ;>I" overload;F;?0;;;@0;:I"step(by: 1, to: );T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"n;T;$@3+o;A ;>I" return;F;?I";T;0;@[I" self;T;$@3+;![;"I"@yield [n] @return [self];T;#0;$@3+;.F;Bi;C0;7[[I"by:;TI"1;T[I"to:;TI";T;$@3+o;= ;>I" overload;F;?0;;;@0;:I"step(by: 1, to: );T;IC; ";T;[;![;"I";T;#0;$@3+;.F;Bi;C0;7[[I"by:;TI"1;T[I"to:;TI";T;$@3+o;= ;>I" overload;F;?0;;;@0;:I"step(by: , to: nil);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"n;T;$@3+o;A ;>I" return;F;?I";T;0;@[I" self;T;$@3+;![;"I"@yield [n] @return [self];T;#0;$@3+;.F;Bi;C0;7[[I"by:;TI";T[I"to:;TI"nil;T;$@3+o;= ;>I" overload;F;?0;;;@0;:I"step(by: , to: nil);T;IC; ";T;[;![;"I";T;#0;$@3+;.F;Bi;C0;7[[I"by:;TI";T[I"to:;TI"nil;T;$@3+;![;"I" Generates a sequence of numbers; with a block given, traverses the sequence. Of the Core and Standard Library classes, Integer, Float, and Rational use this implementation. A quick example: squares = [] 1.step(by: 2, to: 10) {|i| squares.push(i*i) } squares # => [1, 9, 25, 49, 81] The generated sequence: - Begins with +self+. - Continues at intervals of +step+ (which may not be zero). - Ends with the last number that is within or equal to +limit+; that is, less than or equal to +limit+ if +step+ is positive, greater than or equal to +limit+ if +step+ is negative. If +limit+ is not given, the sequence is of infinite length. If a block is given, calls the block with each number in the sequence; returns +self+. If no block is given, returns an Enumerator::ArithmeticSequence. Keyword Arguments With keyword arguments +by+ and +to+, their values (or defaults) determine the step and limit: # Both keywords given. squares = [] 4.step(by: 2, to: 10) {|i| squares.push(i*i) } # => 4 squares # => [16, 36, 64, 100] cubes = [] 3.step(by: -1.5, to: -3) {|i| cubes.push(i*i*i) } # => 3 cubes # => [27.0, 3.375, 0.0, -3.375, -27.0] squares = [] 1.2.step(by: 0.2, to: 2.0) {|f| squares.push(f*f) } squares # => [1.44, 1.9599999999999997, 2.5600000000000005, 3.24, 4.0] squares = [] Rational(6/5).step(by: 0.2, to: 2.0) {|r| squares.push(r*r) } squares # => [1.0, 1.44, 1.9599999999999997, 2.5600000000000005, 3.24, 4.0] # Only keyword to given. squares = [] 4.step(to: 10) {|i| squares.push(i*i) } # => 4 squares # => [16, 25, 36, 49, 64, 81, 100] # Only by given. # Only keyword by given squares = [] 4.step(by:2) {|i| squares.push(i*i); break if i > 10 } squares # => [16, 36, 64, 100, 144] # No block given. e = 3.step(by: -1.5, to: -3) # => (3.step(by: -1.5, to: -3)) e.class # => Enumerator::ArithmeticSequence Positional Arguments With optional positional arguments +limit+ and +step+, their values (or defaults) determine the step and limit: squares = [] 4.step(10, 2) {|i| squares.push(i*i) } # => 4 squares # => [16, 36, 64, 100] squares = [] 4.step(10) {|i| squares.push(i*i) } squares # => [16, 25, 36, 49, 64, 81, 100] squares = [] 4.step {|i| squares.push(i*i); break if i > 10 } # => nil squares # => [16, 25, 36, 49, 64, 81, 100, 121] Implementation Notes If all the arguments are integers, the loop operates using an integer counter. If any of the arguments are floating point numbers, all are converted to floats, and the loop is executed floor(n + n*Float::EPSILON) + 1 times, where n = (limit - self)/step. @overload step(to = nil, by = 1) @yield [n] @return [self] @overload step(to = nil, by = 1) @overload step(to = nil, by: 1) @yield [n] @return [self] @overload step(to = nil, by: 1) @overload step(by: 1, to: ) @yield [n] @return [self] @overload step(by: 1, to: ) @overload step(by: , to: nil) @yield [n] @return [self] @overload step(by: , to: nil);T;#0;$@3+;.F;/o;0;1T;2i| ;3i ;%@&;9I"static VALUE num_step(int argc, VALUE *argv, VALUE from) { VALUE to, step; int desc, inf; if (!rb_block_given_p()) { VALUE by = Qundef; num_step_extract_args(argc, argv, &to, &step, &by); if (by != Qundef) { step = by; } if (NIL_P(step)) { step = INT2FIX(1); } else if (rb_equal(step, INT2FIX(0))) { rb_raise(rb_eArgError, "step can't be 0"); } if ((NIL_P(to) || rb_obj_is_kind_of(to, rb_cNumeric)) && rb_obj_is_kind_of(step, rb_cNumeric)) { return rb_arith_seq_new(from, ID2SYM(rb_frame_this_func()), argc, argv, num_step_size, from, to, step, FALSE); } return SIZED_ENUMERATOR(from, 2, ((VALUE [2]){to, step}), num_step_size); } desc = num_step_scan_args(argc, argv, &to, &step, TRUE, FALSE); if (rb_equal(step, INT2FIX(0))) { inf = 1; } else if (RB_FLOAT_TYPE_P(to)) { double f = RFLOAT_VALUE(to); inf = isinf(f) && (signbit(f) ? desc : !desc); } else inf = 0; if (FIXNUM_P(from) && (inf || FIXNUM_P(to)) && FIXNUM_P(step)) { long i = FIX2LONG(from); long diff = FIX2LONG(step); if (inf) { for (;; i += diff) rb_yield(LONG2FIX(i)); } else { long end = FIX2LONG(to); if (desc) { for (; i >= end; i += diff) rb_yield(LONG2FIX(i)); } else { for (; i <= end; i += diff) rb_yield(LONG2FIX(i)); } } } else if (!ruby_float_step(from, to, step, FALSE, FALSE)) { VALUE i = from; if (inf) { for (;; i = rb_funcall(i, '+', 1, step)) rb_yield(i); } else { ID cmp = desc ? '<' : '>'; for (; !RTEST(rb_funcall(i, cmp, 1, to)); i = rb_funcall(i, '+', 1, step)) rb_yield(i); } } return from; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#positive?;F;7[;[[@i;T;:positive?;0;[;{;IC; "CReturns +true+ if +self+ is greater than 0, +false+ otherwise.;T;[o;= ;>I" overload;F;?0;;;@0;:I"positive?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@+;![;"I"@return [Boolean];T;#0;$@+;.F;Bi;C0;7[;$@+;![;"I"nReturns +true+ if +self+ is greater than 0, +false+ otherwise. @overload positive? @return [Boolean];T;#0;$@+;.F;/o;0;1T;2i;3i;Bi;%@&;9I"static VALUE num_positive_p(VALUE num) { const ID mid = '>'; if (FIXNUM_P(num)) { if (method_basic_p(rb_cInteger)) return RBOOL((SIGNED_VALUE)num > (SIGNED_VALUE)INT2FIX(0)); } else if (RB_BIGNUM_TYPE_P(num)) { if (method_basic_p(rb_cInteger)) return RBOOL(BIGNUM_POSITIVE_P(num) && !rb_bigzero_p(num)); } return rb_num_compare_with_zero(num, mid); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#negative?;F;7[;[[@i;T;;;0;[;{;IC; "@Returns +true+ if +self+ is less than 0, +false+ otherwise.;T;[o;= ;>I" overload;F;?0;;;@0;:I"negative?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@+;![;"I"@return [Boolean];T;#0;$@+;.F;Bi;C0;7[;$@+;![;"I"kReturns +true+ if +self+ is less than 0, +false+ otherwise. @overload negative? @return [Boolean];T;#0;$@+;.F;/o;0;1T;2i;3i;Bi;%@&;9I"]static VALUE num_negative_p(VALUE num) { return RBOOL(rb_num_negative_int_p(num)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#numerator;F;7[;[[@ri;T;;;0;[;{;IC; "Returns the numerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"numerator;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@,;![;"I"@return [Integer];T;#0;$@,;.F;Bi;C0;7[;$@,;![;"I"EReturns the numerator. @overload numerator @return [Integer];T;#0;$@,;.F;/o;0;1T;2i;3i;%@&;9I"Ystatic VALUE numeric_numerator(VALUE self) { return f_numerator(f_to_r(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#denominator;F;7[;[[@ri;T;;;0;[;{;IC; "/Returns the denominator (always positive). ;T;[o;= ;>I" overload;F;?0;;;@0;:I"denominator;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@+,;![;"I"@return [Integer];T;#0;$@+,;.F;Bi;C0;7[;$@+,;![;"I"[Returns the denominator (always positive). @overload denominator @return [Integer];T;#0;$@+,;.F;/o;0;1T;2i;3i;%@&;9I"]static VALUE numeric_denominator(VALUE self) { return f_denominator(f_to_r(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Numeric#quo;F;7[[I"y;T0;[[@ri;T;;;0;[;{;IC; "OReturns the most exact division (rational for integers, float for floats). ;T;[o;= ;>I" overload;F;?0;;;@0;:I"quo(int_or_rat);T;IC; ";T;[;![;"I";T;#0;$@F,;.F;Bi;C0;7[[I"int_or_rat;T0;$@F,o;= ;>I" overload;F;?0;;;@0;:I" quo(flo);T;IC; ";T;[;![;"I";T;#0;$@F,;.F;Bi;C0;7[[I"flo;T0;$@F,;![;"I"~Returns the most exact division (rational for integers, float for floats). @overload quo(int_or_rat) @overload quo(flo);T;#0;$@F,;.F;/o;0;1T;2i;3i;%@&;9I"*VALUE rb_numeric_quo(VALUE x, VALUE y) { if (RB_TYPE_P(x, T_COMPLEX)) { return rb_complex_div(x, y); } if (RB_FLOAT_TYPE_P(y)) { return rb_funcallv(x, idFdiv, 1, &y); } x = rb_convert_type(x, T_RATIONAL, "Rational", "to_r"); return rb_rational_div(x, y); };T;:I" VALUE;T;;T; @&; IC;[; @&; IC;[o;( ;)0;*0;+0;;;%@;-@?_;0; @&; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i-;T;;;;;;;[;{;IC; "Numeric is the class from which all higher-level numeric classes should inherit. Numeric allows instantiation of heap-allocated objects. Other core numeric classes such as Integer are implemented as immediates, which means that each Integer is a single immutable object which is always passed by value. a = 1 1.object_id == a.object_id #=> true There can only ever be one instance of the integer +1+, for example. Ruby ensures this by preventing instantiation. If duplication is attempted, the same instance is returned. Integer.new(1) #=> NoMethodError: undefined method `new' for Integer:Class 1.dup #=> 1 1.object_id == 1.dup.object_id #=> true For this reason, Numeric should be used when defining other numeric classes. Classes which inherit from Numeric must implement +coerce+, which returns a two-member Array containing an object that has been coerced into an instance of the new class and +self+ (see #coerce). Inheriting classes should also implement arithmetic operator methods (+, -, * and /) and the <=> operator (see Comparable). These methods may rely on +coerce+ to ensure interoperability with instances of other numeric classes. class Tally < Numeric def initialize(string) @string = string end def to_s @string end def to_i @string.size end def coerce(other) [self.class.new('|' * other.to_i), self] end def <=>(other) to_i <=> other.to_i end def +(other) self.class.new('|' * (to_i + other.to_i)) end def -(other) self.class.new('|' * (to_i - other.to_i)) end def *(other) self.class.new('|' * (to_i * other.to_i)) end def /(other) self.class.new('|' * (to_i / other.to_i)) end end tally = Tally.new('||') puts tally * 2 #=> "||||" puts tally > 1 #=> true == What's Here First, what's elsewhere. \Class \Numeric: - Inherits from {class Object}[Object.html#class-Object-label-What-27s+Here]. - Includes {module Comparable}[Comparable.html#module-Comparable-label-What-27s+Here]. Here, class \Numeric provides methods for: - {Querying}[#class-Numeric-label-Querying] - {Comparing}[#class-Numeric-label-Comparing] - {Converting}[#class-Numeric-label-Converting] - {Other}[#class-Numeric-label-Other] === Querying - #finite?:: Returns true unless +self+ is infinite or not a number. - #infinite?:: Returns -1, +nil+ or +1, depending on whether +self+ is -Infinity, finite, or +Infinity. - #integer?:: Returns whether +self+ is an integer. - #negative?:: Returns whether +self+ is negative. - #nonzero?:: Returns whether +self+ is not zero. - #positive?:: Returns whether +self+ is positive. - #real?:: Returns whether +self+ is a real value. - #zero?:: Returns whether +self+ is zero. === Comparing - {<=>}[#method-i-3C-3D-3E]:: Returns: - -1 if +self+ is less than the given value. - 0 if +self+ is equal to the given value. - 1 if +self+ is greater than the given value. - +nil+ if +self+ and the given value are not comparable. - #eql?:: Returns whether +self+ and the given value have the same value and type. === Converting - #% (aliased as #modulo):: Returns the remainder of +self+ divided by the given value. - #-@:: Returns the value of +self+, negated. - #abs (aliased as #magnitude):: Returns the absolute value of +self+. - #abs2:: Returns the square of +self+. - #angle (aliased as #arg and #phase):: Returns 0 if +self+ is positive, Math::PI otherwise. - #ceil:: Returns the smallest number greater than or equal to +self+, to a given precision. - #coerce:: Returns array [coerced_self, coerced_other] for the given other value. - #conj (aliased as #conjugate):: Returns the complex conjugate of +self+. - #denominator:: Returns the denominator (always positive) of the Rational representation of +self+. - #div:: Returns the value of +self+ divided by the given value and converted to an integer. - #divmod:: Returns array [quotient, modulus] resulting from dividing +self+ the given divisor. - #fdiv:: Returns the Float result of dividing +self+ by the given divisor. - #floor:: Returns the largest number less than or equal to +self+, to a given precision. - #i:: Returns the Complex object Complex(0, self). the given value. - #imaginary (aliased as #imag):: Returns the imaginary part of the +self+. - #numerator:: Returns the numerator of the Rational representation of +self+; has the same sign as +self+. - #polar:: Returns the array [self.abs, self.arg]. - #quo:: Returns the value of +self+ divided by the given value. - #real:: Returns the real part of +self+. - #rect (aliased as #rectangular):: Returns the array [self, 0]. - #remainder:: Returns self-arg*(self/arg).truncate for the given +arg+. - #round:: Returns the value of +self+ rounded to the nearest value for the given a precision. - #to_c:: Returns the Complex representation of +self+. - #to_int:: Returns the Integer representation of +self+, truncating if necessary. - #truncate:: Returns +self+ truncated (toward zero) to a given precision. === Other - #clone:: Returns +self+; does not allow freezing. - #dup (aliased as #+@):: Returns +self+. - #step:: Invokes the given block with the sequence of specified numbers.;T;[;![;"I" Numeric is the class from which all higher-level numeric classes should inherit. Numeric allows instantiation of heap-allocated objects. Other core numeric classes such as Integer are implemented as immediates, which means that each Integer is a single immutable object which is always passed by value. a = 1 1.object_id == a.object_id #=> true There can only ever be one instance of the integer +1+, for example. Ruby ensures this by preventing instantiation. If duplication is attempted, the same instance is returned. Integer.new(1) #=> NoMethodError: undefined method `new' for Integer:Class 1.dup #=> 1 1.object_id == 1.dup.object_id #=> true For this reason, Numeric should be used when defining other numeric classes. Classes which inherit from Numeric must implement +coerce+, which returns a two-member Array containing an object that has been coerced into an instance of the new class and +self+ (see #coerce). Inheriting classes should also implement arithmetic operator methods (+, -, * and /) and the <=> operator (see Comparable). These methods may rely on +coerce+ to ensure interoperability with instances of other numeric classes. class Tally < Numeric def initialize(string) @string = string end def to_s @string end def to_i @string.size end def coerce(other) [self.class.new('|' * other.to_i), self] end def <=>(other) to_i <=> other.to_i end def +(other) self.class.new('|' * (to_i + other.to_i)) end def -(other) self.class.new('|' * (to_i - other.to_i)) end def *(other) self.class.new('|' * (to_i * other.to_i)) end def /(other) self.class.new('|' * (to_i / other.to_i)) end end tally = Tally.new('||') puts tally * 2 #=> "||||" puts tally > 1 #=> true == What's Here First, what's elsewhere. \Class \Numeric: - Inherits from {class Object}[Object.html#class-Object-label-What-27s+Here]. - Includes {module Comparable}[Comparable.html#module-Comparable-label-What-27s+Here]. Here, class \Numeric provides methods for: - {Querying}[#class-Numeric-label-Querying] - {Comparing}[#class-Numeric-label-Comparing] - {Converting}[#class-Numeric-label-Converting] - {Other}[#class-Numeric-label-Other] === Querying - #finite?:: Returns true unless +self+ is infinite or not a number. - #infinite?:: Returns -1, +nil+ or +1, depending on whether +self+ is -Infinity, finite, or +Infinity. - #integer?:: Returns whether +self+ is an integer. - #negative?:: Returns whether +self+ is negative. - #nonzero?:: Returns whether +self+ is not zero. - #positive?:: Returns whether +self+ is positive. - #real?:: Returns whether +self+ is a real value. - #zero?:: Returns whether +self+ is zero. === Comparing - {<=>}[#method-i-3C-3D-3E]:: Returns: - -1 if +self+ is less than the given value. - 0 if +self+ is equal to the given value. - 1 if +self+ is greater than the given value. - +nil+ if +self+ and the given value are not comparable. - #eql?:: Returns whether +self+ and the given value have the same value and type. === Converting - #% (aliased as #modulo):: Returns the remainder of +self+ divided by the given value. - #-@:: Returns the value of +self+, negated. - #abs (aliased as #magnitude):: Returns the absolute value of +self+. - #abs2:: Returns the square of +self+. - #angle (aliased as #arg and #phase):: Returns 0 if +self+ is positive, Math::PI otherwise. - #ceil:: Returns the smallest number greater than or equal to +self+, to a given precision. - #coerce:: Returns array [coerced_self, coerced_other] for the given other value. - #conj (aliased as #conjugate):: Returns the complex conjugate of +self+. - #denominator:: Returns the denominator (always positive) of the Rational representation of +self+. - #div:: Returns the value of +self+ divided by the given value and converted to an integer. - #divmod:: Returns array [quotient, modulus] resulting from dividing +self+ the given divisor. - #fdiv:: Returns the Float result of dividing +self+ by the given divisor. - #floor:: Returns the largest number less than or equal to +self+, to a given precision. - #i:: Returns the Complex object Complex(0, self). the given value. - #imaginary (aliased as #imag):: Returns the imaginary part of the +self+. - #numerator:: Returns the numerator of the Rational representation of +self+; has the same sign as +self+. - #polar:: Returns the array [self.abs, self.arg]. - #quo:: Returns the value of +self+ divided by the given value. - #real:: Returns the real part of +self+. - #rect (aliased as #rectangular):: Returns the array [self, 0]. - #remainder:: Returns self-arg*(self/arg).truncate for the given +arg+. - #round:: Returns the value of +self+ rounded to the nearest value for the given a precision. - #to_c:: Returns the Complex representation of +self+. - #to_int:: Returns the Integer representation of +self+, truncating if necessary. - #truncate:: Returns +self+ truncated (toward zero) to a given precision. === Other - #clone:: Returns +self+; does not allow freezing. - #dup (aliased as #+@):: Returns +self+. - #step:: Invokes the given block with the sequence of specified numbers. ;T;#0;$@&;.F;/o;0;1T;2i;3i;Bi;%@;&I" Numeric;F;'@;;@&o; ;IC;[ o;4;5F;6;;;;&I"String#to_c;F;7[;[[@ i;T;;;0;[;{;IC; "sReturns a complex which denotes the string form. The parser ignores leading whitespaces and trailing garbage. Any digit sequences can be separated by an underscore. Returns zero for null or garbage string. '9'.to_c #=> (9+0i) '2.5'.to_c #=> (2.5+0i) '2.5/1'.to_c #=> ((5/2)+0i) '-3/2'.to_c #=> ((-3/2)+0i) '-i'.to_c #=> (0-1i) '45i'.to_c #=> (0+45i) '3-4i'.to_c #=> (3-4i) '-4e2-4e-2i'.to_c #=> (-400.0-0.04i) '-0.0-0.0i'.to_c #=> (-0.0-0.0i) '1/2+3/4i'.to_c #=> ((1/2)+(3/4)*i) 'ruby'.to_c #=> (0+0i) See Kernel.Complex. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_c;T;IC; ";T;[;![;"I";T;#0;$@,;.F;Bi;C0;7[;$@,;![;"I"Returns a complex which denotes the string form. The parser ignores leading whitespaces and trailing garbage. Any digit sequences can be separated by an underscore. Returns zero for null or garbage string. '9'.to_c #=> (9+0i) '2.5'.to_c #=> (2.5+0i) '2.5/1'.to_c #=> ((5/2)+0i) '-3/2'.to_c #=> ((-3/2)+0i) '-i'.to_c #=> (0-1i) '45i'.to_c #=> (0+45i) '3-4i'.to_c #=> (3-4i) '-4e2-4e-2i'.to_c #=> (-400.0-0.04i) '-0.0-0.0i'.to_c #=> (-0.0-0.0i) '1/2+3/4i'.to_c #=> ((1/2)+(3/4)*i) 'ruby'.to_c #=> (0+0i) See Kernel.Complex. @overload to_c;T;#0;$@,;.F;/o;0;1T;2i;3i;%@},;9I"Jstatic VALUE string_to_c(VALUE self) { char *s; VALUE num; rb_must_asciicompat(self); s = RSTRING_PTR(self); if (s && s[RSTRING_LEN(self)]) { rb_str_modify(self); s = RSTRING_PTR(self); s[RSTRING_LEN(self)] = '\0'; } if (!s) s = (char *)""; (void)parse_comp(s, 0, &num); return num; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"String#to_r;F;7[;[[@ri ;T;;;0;[;{;IC; ")Returns the result of interpreting leading characters in +str+ as a rational. Leading whitespace and extraneous characters past the end of a valid number are ignored. Digit sequences can be separated by an underscore. If there is not a valid number at the start of +str+, zero is returned. This method never raises an exception. ' 2 '.to_r #=> (2/1) '300/2'.to_r #=> (150/1) '-9.2'.to_r #=> (-46/5) '-9.2e2'.to_r #=> (-920/1) '1_234_567'.to_r #=> (1234567/1) '21 June 09'.to_r #=> (21/1) '21/06/09'.to_r #=> (7/2) 'BWV 1079'.to_r #=> (0/1) NOTE: "0.3".to_r isn't the same as 0.3.to_r. The former is equivalent to "3/10".to_r, but the latter isn't so. "0.3".to_r == 3/10r #=> true 0.3.to_r == 3/10r #=> false See also Kernel#Rational. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_r;T;IC; ";T;[;![;"I";T;#0;$@,;.F;Bi;C0;7[;$@,;![;"I":Returns the result of interpreting leading characters in +str+ as a rational. Leading whitespace and extraneous characters past the end of a valid number are ignored. Digit sequences can be separated by an underscore. If there is not a valid number at the start of +str+, zero is returned. This method never raises an exception. ' 2 '.to_r #=> (2/1) '300/2'.to_r #=> (150/1) '-9.2'.to_r #=> (-46/5) '-9.2e2'.to_r #=> (-920/1) '1_234_567'.to_r #=> (1234567/1) '21 June 09'.to_r #=> (21/1) '21/06/09'.to_r #=> (7/2) 'BWV 1079'.to_r #=> (0/1) NOTE: "0.3".to_r isn't the same as 0.3.to_r. The former is equivalent to "3/10".to_r, but the latter isn't so. "0.3".to_r == 3/10r #=> true 0.3.to_r == 3/10r #=> false See also Kernel#Rational. @overload to_r;T;#0;$@,;.F;/o;0;1T;2i ;3i ;%@},;9I"static VALUE string_to_r(VALUE self) { VALUE num; rb_must_asciicompat(self); num = parse_rat(RSTRING_PTR(self), RSTRING_END(self), 0, TRUE); if (RB_FLOAT_TYPE_P(num) && !FLOAT_ZERO_P(num)) rb_raise(rb_eFloatDomainError, "Infinity"); return num; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"String#encode;F;7[[@90;[[I"transcode.c;TiN ;T;: encode;0;[;{;IC; "The first form returns a copy of +str+ transcoded to encoding +encoding+. The second form returns a copy of +str+ transcoded from src_encoding to dst_encoding. The last form returns a copy of +str+ transcoded to Encoding.default_internal. By default, the first and second form raise Encoding::UndefinedConversionError for characters that are undefined in the destination encoding, and Encoding::InvalidByteSequenceError for invalid byte sequences in the source encoding. The last form by default does not raise exceptions but uses replacement strings. The +options+ keyword arguments give details for conversion. The arguments are: :invalid :: If the value is +:replace+, #encode replaces invalid byte sequences in +str+ with the replacement character. The default is to raise the Encoding::InvalidByteSequenceError exception :undef :: If the value is +:replace+, #encode replaces characters which are undefined in the destination encoding with the replacement character. The default is to raise the Encoding::UndefinedConversionError. :replace :: Sets the replacement string to the given value. The default replacement string is "\uFFFD" for Unicode encoding forms, and "?" otherwise. :fallback :: Sets the replacement string by the given object for undefined character. The object should be a Hash, a Proc, a Method, or an object which has [] method. Its key is an undefined character encoded in the source encoding of current transcoder. Its value can be any encoding until it can be converted into the destination encoding of the transcoder. :xml :: The value must be +:text+ or +:attr+. If the value is +:text+ #encode replaces undefined characters with their (upper-case hexadecimal) numeric character references. '&', '<', and '>' are converted to "&", "<", and ">", respectively. If the value is +:attr+, #encode also quotes the replacement result (using '"'), and replaces '"' with """. :cr_newline :: Replaces LF ("\n") with CR ("\r") if value is true. :crlf_newline :: Replaces LF ("\n") with CRLF ("\r\n") if value is true. :universal_newline :: Replaces CRLF ("\r\n") and CR ("\r") with LF ("\n") if value is true. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" encode(encoding, **options);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@,;![;"I"@return [String];T;#0;$@,;.F;Bi;C0;7[[I" encoding;T0[I"**options;T0;$@,o;= ;>I" overload;F;?0;;;@0;:I"2encode(dst_encoding, src_encoding, **options);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@,;![;"I"@return [String];T;#0;$@,;.F;Bi;C0;7[[I"dst_encoding;T0[I"src_encoding;T0[I"**options;T0;$@,o;= ;>I" overload;F;?0;;;@0;:I"encode(**options);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@,;![;"I"@return [String];T;#0;$@,;.F;Bi;C0;7[[I"**options;T0;$@,;![;"I"O The first form returns a copy of +str+ transcoded to encoding +encoding+. The second form returns a copy of +str+ transcoded from src_encoding to dst_encoding. The last form returns a copy of +str+ transcoded to Encoding.default_internal. By default, the first and second form raise Encoding::UndefinedConversionError for characters that are undefined in the destination encoding, and Encoding::InvalidByteSequenceError for invalid byte sequences in the source encoding. The last form by default does not raise exceptions but uses replacement strings. The +options+ keyword arguments give details for conversion. The arguments are: :invalid :: If the value is +:replace+, #encode replaces invalid byte sequences in +str+ with the replacement character. The default is to raise the Encoding::InvalidByteSequenceError exception :undef :: If the value is +:replace+, #encode replaces characters which are undefined in the destination encoding with the replacement character. The default is to raise the Encoding::UndefinedConversionError. :replace :: Sets the replacement string to the given value. The default replacement string is "\uFFFD" for Unicode encoding forms, and "?" otherwise. :fallback :: Sets the replacement string by the given object for undefined character. The object should be a Hash, a Proc, a Method, or an object which has [] method. Its key is an undefined character encoded in the source encoding of current transcoder. Its value can be any encoding until it can be converted into the destination encoding of the transcoder. :xml :: The value must be +:text+ or +:attr+. If the value is +:text+ #encode replaces undefined characters with their (upper-case hexadecimal) numeric character references. '&', '<', and '>' are converted to "&", "<", and ">", respectively. If the value is +:attr+, #encode also quotes the replacement result (using '"'), and replaces '"' with """. :cr_newline :: Replaces LF ("\n") with CR ("\r") if value is true. :crlf_newline :: Replaces LF ("\n") with CRLF ("\r\n") if value is true. :universal_newline :: Replaces CRLF ("\r\n") and CR ("\r") with LF ("\n") if value is true. @overload encode(encoding, **options) @return [String] @overload encode(dst_encoding, src_encoding, **options) @return [String] @overload encode(**options) @return [String];T;#0;$@,;.F;/o;0;1T;2i ;3iM ;%@},;9I"static VALUE str_encode(int argc, VALUE *argv, VALUE str) { VALUE newstr = str; int encidx = str_transcode(argc, argv, &newstr); return encoded_dup(newstr, str, encidx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"String#encode!;F;7[[@90;[[@,i ;T;: encode!;0;[;{;IC; ";The first form transcodes the contents of str from str.encoding to +encoding+. The second form transcodes the contents of str from src_encoding to dst_encoding. The +options+ keyword arguments give details for conversion. See String#encode for details. Returns the string even if no changes were made. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"!encode!(encoding, **options);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@,;![;"I"@return [String];T;#0;$@,;.F;Bi;C0;7[[I" encoding;T0[I"**options;T0;$@,o;= ;>I" overload;F;?0;;;@0;:I"3encode!(dst_encoding, src_encoding, **options);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@,;![;"I"@return [String];T;#0;$@,;.F;Bi;C0;7[[I"dst_encoding;T0[I"src_encoding;T0[I"**options;T0;$@,;![;"I"The first form transcodes the contents of str from str.encoding to +encoding+. The second form transcodes the contents of str from src_encoding to dst_encoding. The +options+ keyword arguments give details for conversion. See String#encode for details. Returns the string even if no changes were made. @overload encode!(encoding, **options) @return [String] @overload encode!(dst_encoding, src_encoding, **options) @return [String];T;#0;$@,;.F;/o;0;1T;2i ;3i ;%@},;9I"static VALUE str_encode_bang(int argc, VALUE *argv, VALUE str) { VALUE newstr; int encidx; rb_check_frozen(str); newstr = str; encidx = str_transcode(argc, argv, &newstr); if (encidx < 0) return str; if (newstr == str) { rb_enc_associate_index(str, encidx); return str; } rb_str_shared_replace(str, newstr); return str_encode_associate(str, encidx); };T;:I"static VALUE;T;;T; @},; IC;[; @},; IC;[; @},; IC;{;IC;{;T;IC;{;T;T;{;[;[;F;;;;;;;[;{;IC; " ;T;[;![;"@;#0;$@},;Bi;%@;&I" String;F;'o;( ;)0;*0;+0;;;%@;-@;0o; ;IC;[9o;4;5F;6;;;;&I"Float#arg;F;7[;[[@ i;T;;;0;[;{;IC; "6Returns 0 if the value is positive, pi otherwise. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"arg;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI" Float;T;$@2-;![;"I"@return [ 0, Float];T;#0;$@2-;.F;Bi;C0;7[;$@2-o;= ;>I" overload;F;?0;;;@0;:I" angle;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI" Float;T;$@2-;![;"I"@return [ 0, Float];T;#0;$@2-;.F;Bi;C0;7[;$@2-o;= ;>I" overload;F;?0;;;@0;:I" phase;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI" Float;T;$@2-;![;"I"@return [ 0, Float];T;#0;$@2-;.F;Bi;C0;7[;$@2-;![;"I"Returns 0 if the value is positive, pi otherwise. @overload arg @return [ 0, Float] @overload angle @return [ 0, Float] @overload phase @return [ 0, Float];T;#0;$@2-;.F;/o;0;1T;2i;3i;%@0-;9I"static VALUE float_arg(VALUE self) { if (isnan(RFLOAT_VALUE(self))) return self; if (f_tpositive_p(self)) return INT2FIX(0); return rb_const_get(rb_mMath, id_PI); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Float#angle;F;7[;[[@ i;T;;;0;[;{;IC; "6Returns 0 if the value is positive, pi otherwise. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"arg;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI" Float;T;$@j-;![;"I"@return [ 0, Float];T;#0;$@j-;.F;Bi;C0;7[;$@j-o;= ;>I" overload;F;?0;;;@0;:I" angle;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI" Float;T;$@j-;![;"I"@return [ 0, Float];T;#0;$@j-;.F;Bi;C0;7[;$@j-o;= ;>I" overload;F;?0;;;@0;:I" phase;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI" Float;T;$@j-;![;"I"@return [ 0, Float];T;#0;$@j-;.F;Bi;C0;7[;$@j-;![;"@f-;#0;$@j-;.F;/o;0;1T;2i;3i;%@0-;9I"static VALUE float_arg(VALUE self) { if (isnan(RFLOAT_VALUE(self))) return self; if (f_tpositive_p(self)) return INT2FIX(0); return rb_const_get(rb_mMath, id_PI); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Float#phase;F;7[;[[@ i;T;;;0;[;{;IC; "6Returns 0 if the value is positive, pi otherwise. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"arg;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI" Float;T;$@-;![;"I"@return [ 0, Float];T;#0;$@-;.F;Bi;C0;7[;$@-o;= ;>I" overload;F;?0;;;@0;:I" angle;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI" Float;T;$@-;![;"I"@return [ 0, Float];T;#0;$@-;.F;Bi;C0;7[;$@-o;= ;>I" overload;F;?0;;;@0;:I" phase;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI" Float;T;$@-;![;"I"@return [ 0, Float];T;#0;$@-;.F;Bi;C0;7[;$@-;![;"@f-;#0;$@-;.F;/o;0;1T;2i;3i;%@0-;9I"static VALUE float_arg(VALUE self) { if (isnan(RFLOAT_VALUE(self))) return self; if (f_tpositive_p(self)) return INT2FIX(0); return rb_const_get(rb_mMath, id_PI); };T;:I"static VALUE;T;;To;u;[[@i;F;: RADIX;;w;;;[;{;IC; "The base of the floating point, or number of unique digits used to represent the number. Usually defaults to 2 on most systems, which would represent a base-10 decimal. ;T;[;![;"I"The base of the floating point, or number of unique digits used to represent the number. Usually defaults to 2 on most systems, which would represent a base-10 decimal. ;T;#0;$@-;.F;/o;0;1T;2i;3i;%@0-;&I"Float::RADIX;F;xI"INT2FIX(FLT_RADIX);To;u;[[@i;F;: MANT_DIG;;w;;;[;{;IC; "SThe number of base digits for the +double+ data type. Usually defaults to 53. ;T;[;![;"I"TThe number of base digits for the +double+ data type. Usually defaults to 53. ;T;#0;$@-;.F;/o;0;1T;2i;3i;%@0-;&I"Float::MANT_DIG;F;xI"INT2FIX(DBL_MANT_DIG);To;u;[[@i;F;:DIG;;w;;;[;{;IC; "tThe minimum number of significant decimal digits in a double-precision floating point. Usually defaults to 15. ;T;[;![;"I"uThe minimum number of significant decimal digits in a double-precision floating point. Usually defaults to 15. ;T;#0;$@-;.F;/o;0;1T;2i;3i;%@0-;&I"Float::DIG;F;xI"INT2FIX(DBL_DIG);To;u;[[@i;F;: MIN_EXP;;w;;;[;{;IC; "kThe smallest possible exponent value in a double-precision floating point. Usually defaults to -1021. ;T;[;![;"I"lThe smallest possible exponent value in a double-precision floating point. Usually defaults to -1021. ;T;#0;$@-;.F;/o;0;1T;2i;3i;%@0-;&I"Float::MIN_EXP;F;xI"INT2FIX(DBL_MIN_EXP);To;u;[[@i;F;: MAX_EXP;;w;;;[;{;IC; "iThe largest possible exponent value in a double-precision floating point. Usually defaults to 1024. ;T;[;![;"I"jThe largest possible exponent value in a double-precision floating point. Usually defaults to 1024. ;T;#0;$@.;.F;/o;0;1T;2i;3i;%@0-;&I"Float::MAX_EXP;F;xI"INT2FIX(DBL_MAX_EXP);To;u;[[@i;F;:MIN_10_EXP;;w;;;[;{;IC; "The smallest negative exponent in a double-precision floating point where 10 raised to this power minus 1. Usually defaults to -307. ;T;[;![;"I"The smallest negative exponent in a double-precision floating point where 10 raised to this power minus 1. Usually defaults to -307. ;T;#0;$@.;.F;/o;0;1T;2i;3i;%@0-;&I"Float::MIN_10_EXP;F;xI"INT2FIX(DBL_MIN_10_EXP);To;u;[[@i;F;:MAX_10_EXP;;w;;;[;{;IC; "The largest positive exponent in a double-precision floating point where 10 raised to this power minus 1. Usually defaults to 308. ;T;[;![;"I"The largest positive exponent in a double-precision floating point where 10 raised to this power minus 1. Usually defaults to 308. ;T;#0;$@ .;.F;/o;0;1T;2i;3i;%@0-;&I"Float::MAX_10_EXP;F;xI"INT2FIX(DBL_MAX_10_EXP);To;u;[[@i;F;:MIN;;w;;;[;{;IC; "m:MIN. 0.0.next_float returns the smallest positive floating point number including denormalized numbers. ;T;[;![;"I"n:MIN. 0.0.next_float returns the smallest positive floating point number including denormalized numbers. ;T;#0;$@,.;.F;/o;0;1T;2i;3i;%@0-;&I"Float::MIN;F;xI"The smallest positive normalized number in a double-precision floating point. Usually defaults to 2.2250738585072014e-308. If the platform supports denormalized numbers, there are numbers between zero and Float;To;u;[[@i;F;:MAX;;w;;;[;{;IC; "|The largest possible integer in a double-precision floating point number. Usually defaults to 1.7976931348623157e+308. ;T;[;![;"I"}The largest possible integer in a double-precision floating point number. Usually defaults to 1.7976931348623157e+308. ;T;#0;$@8.;.F;/o;0;1T;2i;3i;%@0-;&I"Float::MAX;F;xI"DBL2NUM(DBL_MAX);To;u;[[@i;F;: EPSILON;;w;;;[;{;IC; "The difference between 1 and the smallest double-precision floating point number greater than 1. Usually defaults to 2.2204460492503131e-16. ;T;[;![;"I"The difference between 1 and the smallest double-precision floating point number greater than 1. Usually defaults to 2.2204460492503131e-16. ;T;#0;$@D.;.F;/o;0;1T;2i;3i;%@0-;&I"Float::EPSILON;F;xI"DBL2NUM(DBL_EPSILON);To;u;[[@i;F;: INFINITY;;w;;;[;{;IC; "2An expression representing positive infinity. ;T;[;![;"I"3An expression representing positive infinity. ;T;#0;$@P.;.F;/o;0;1T;2i;3i;%@0-;&I"Float::INFINITY;F;xI"DBL2NUM(HUGE_VAL);To;u;[[@i;F;:NAN;;w;;;[;{;IC; "@An expression representing a value which is "not a number". ;T;[;![;"I"AAn expression representing a value which is "not a number". ;T;#0;$@\.;.F;/o;0;1T;2i;3i;%@0-;&I"Float::NAN;F;xI"DBL2NUM(nan(""));To;4;5F;6;;;;&I"Float#to_s;F;7[;[[@i;T;;G;0;[;{;IC; "Returns a string containing a representation of +self+; depending of the value of +self+, the string representation may contain: - A fixed-point number. - A number in "scientific notation" (containing an exponent). - 'Infinity'. - '-Infinity'. - 'NaN' (indicating not-a-number). 3.14.to_s # => "3.14" (10.1**50).to_s # => "1.644631821843879e+50" (10.1**500).to_s # => "Infinity" (-10.1**500).to_s # => "-Infinity" (0.0/0.0).to_s # => "NaN" ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@h.;![;"I"@return [String];T;#0;$@h.;.F;Bi;C0;7[;$@h.;![;"I"Returns a string containing a representation of +self+; depending of the value of +self+, the string representation may contain: - A fixed-point number. - A number in "scientific notation" (containing an exponent). - 'Infinity'. - '-Infinity'. - 'NaN' (indicating not-a-number). 3.14.to_s # => "3.14" (10.1**50).to_s # => "1.644631821843879e+50" (10.1**500).to_s # => "Infinity" (-10.1**500).to_s # => "-Infinity" (0.0/0.0).to_s # => "NaN" @overload to_s @return [String];T;#0;$o;4;5F;6;;;;&I"Float#inspect;F;7[;[[@i;F;;J;;;[;{;@o.;%@0-;9I"static VALUE flo_to_s(VALUE flt) { enum {decimal_mant = DBL_MANT_DIG-DBL_DIG}; enum {float_dig = DBL_DIG+1}; char buf[float_dig + (decimal_mant + CHAR_BIT - 1) / CHAR_BIT + 10]; double value = RFLOAT_VALUE(flt); VALUE s; char *p, *e; int sign, decpt, digs; if (isinf(value)) { static const char minf[] = "-Infinity"; const int pos = (value > 0); /* skip "-" */ return rb_usascii_str_new(minf+pos, strlen(minf)-pos); } else if (isnan(value)) return rb_usascii_str_new2("NaN"); p = ruby_dtoa(value, 0, 0, &decpt, &sign, &e); s = sign ? rb_usascii_str_new_cstr("-") : rb_usascii_str_new(0, 0); if ((digs = (int)(e - p)) >= (int)sizeof(buf)) digs = (int)sizeof(buf) - 1; memcpy(buf, p, digs); xfree(p); if (decpt > 0) { if (decpt < digs) { memmove(buf + decpt + 1, buf + decpt, digs - decpt); buf[decpt] = '.'; rb_str_cat(s, buf, digs + 1); } else if (decpt <= DBL_DIG) { long len; char *ptr; rb_str_cat(s, buf, digs); rb_str_resize(s, (len = RSTRING_LEN(s)) + decpt - digs + 2); ptr = RSTRING_PTR(s) + len; if (decpt > digs) { memset(ptr, '0', decpt - digs); ptr += decpt - digs; } memcpy(ptr, ".0", 2); } else { goto exp; } } else if (decpt > -4) { long len; char *ptr; rb_str_cat(s, "0.", 2); rb_str_resize(s, (len = RSTRING_LEN(s)) - decpt + digs); ptr = RSTRING_PTR(s); memset(ptr += len, '0', -decpt); memcpy(ptr -= decpt, buf, digs); } else { goto exp; } return s; exp: if (digs > 1) { memmove(buf + 2, buf + 1, digs - 1); } else { buf[2] = '0'; digs++; } buf[1] = '.'; rb_str_cat(s, buf, digs + 1); rb_str_catf(s, "e%+03d", decpt - 1); return s; };T;:I"static VALUE;T;.F;/o;0;1T;2i ;3i;%@0-;9I"static VALUE flo_to_s(VALUE flt) { enum {decimal_mant = DBL_MANT_DIG-DBL_DIG}; enum {float_dig = DBL_DIG+1}; char buf[float_dig + (decimal_mant + CHAR_BIT - 1) / CHAR_BIT + 10]; double value = RFLOAT_VALUE(flt); VALUE s; char *p, *e; int sign, decpt, digs; if (isinf(value)) { static const char minf[] = "-Infinity"; const int pos = (value > 0); /* skip "-" */ return rb_usascii_str_new(minf+pos, strlen(minf)-pos); } else if (isnan(value)) return rb_usascii_str_new2("NaN"); p = ruby_dtoa(value, 0, 0, &decpt, &sign, &e); s = sign ? rb_usascii_str_new_cstr("-") : rb_usascii_str_new(0, 0); if ((digs = (int)(e - p)) >= (int)sizeof(buf)) digs = (int)sizeof(buf) - 1; memcpy(buf, p, digs); xfree(p); if (decpt > 0) { if (decpt < digs) { memmove(buf + decpt + 1, buf + decpt, digs - decpt); buf[decpt] = '.'; rb_str_cat(s, buf, digs + 1); } else if (decpt <= DBL_DIG) { long len; char *ptr; rb_str_cat(s, buf, digs); rb_str_resize(s, (len = RSTRING_LEN(s)) + decpt - digs + 2); ptr = RSTRING_PTR(s) + len; if (decpt > digs) { memset(ptr, '0', decpt - digs); ptr += decpt - digs; } memcpy(ptr, ".0", 2); } else { goto exp; } } else if (decpt > -4) { long len; char *ptr; rb_str_cat(s, "0.", 2); rb_str_resize(s, (len = RSTRING_LEN(s)) - decpt + digs); ptr = RSTRING_PTR(s); memset(ptr += len, '0', -decpt); memcpy(ptr -= decpt, buf, digs); } else { goto exp; } return s; exp: if (digs > 1) { memmove(buf + 2, buf + 1, digs - 1); } else { buf[2] = '0'; digs++; } buf[1] = '.'; rb_str_cat(s, buf, digs + 1); rb_str_catf(s, "e%+03d", decpt - 1); return s; };T;:@.;;T@.o;4;5F;6;;;;&I"Float#coerce;F;7[[I"y;T0;[[@iz;T;;;0;[;{;IC; "UReturns a 2-element array containing +other+ converted to a \Float and +self+: f = 3.14 # => 3.14 f.coerce(2) # => [2.0, 3.14] f.coerce(2.0) # => [2.0, 3.14] f.coerce(Rational(1, 2)) # => [0.5, 3.14] f.coerce(Complex(1, 0)) # => [1.0, 3.14] Raises an exception if a type conversion fails. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"coerce(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@.;![;"I"@return [Array];T;#0;$@.;.F;Bi;C0;7[[I" other;T0;$@.;![;"I"Returns a 2-element array containing +other+ converted to a \Float and +self+: f = 3.14 # => 3.14 f.coerce(2) # => [2.0, 3.14] f.coerce(2.0) # => [2.0, 3.14] f.coerce(Rational(1, 2)) # => [0.5, 3.14] f.coerce(Complex(1, 0)) # => [1.0, 3.14] Raises an exception if a type conversion fails. @overload coerce(other) @return [Array];T;#0;$@.;.F;/o;0;1T;2ii;3iw;%@0-;9I"[static VALUE flo_coerce(VALUE x, VALUE y) { return rb_assoc_new(rb_Float(y), x); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Float#+;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; " Returns a new \Float which is the sum of +self+ and +other+: f = 3.14 f + 1 # => 4.140000000000001 f + 1.0 # => 4.140000000000001 f + Rational(1, 1) # => 4.140000000000001 f + Complex(1, 0) # => (4.140000000000001+0i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" +(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@.;![;"I"@return [Numeric];T;#0;$@.;.F;Bi;C0;7[[I" other;T0;$@.;![;"I"3Returns a new \Float which is the sum of +self+ and +other+: f = 3.14 f + 1 # => 4.140000000000001 f + 1.0 # => 4.140000000000001 f + Rational(1, 1) # => 4.140000000000001 f + Complex(1, 0) # => (4.140000000000001+0i) @overload +(other) @return [Numeric];T;#0;$@.;.F;/o;0;1T;2i;3i;%@0-;9I"nVALUE rb_float_plus(VALUE x, VALUE y) { if (FIXNUM_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) + (double)FIX2LONG(y)); } else if (RB_BIGNUM_TYPE_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) + rb_big2dbl(y)); } else if (RB_FLOAT_TYPE_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) + RFLOAT_VALUE(y)); } else { return rb_num_coerce_bin(x, y, '+'); } };T;:I" VALUE;T;;To;4;5F;6;;;;&I" Float#-;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "Returns a new \Float which is the difference of +self+ and +other+: f = 3.14 f - 1 # => 2.14 f - 1.0 # => 2.14 f - Rational(1, 1) # => 2.14 f - Complex(1, 0) # => (2.14+0i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" -(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@.;![;"I"@return [Numeric];T;#0;$@.;.F;Bi;C0;7[[I" other;T0;$@.;![;"I"Returns a new \Float which is the difference of +self+ and +other+: f = 3.14 f - 1 # => 2.14 f - 1.0 # => 2.14 f - Rational(1, 1) # => 2.14 f - Complex(1, 0) # => (2.14+0i) @overload -(other) @return [Numeric];T;#0;$@.;.F;/o;0;1T;2i;3i;%@0-;9I"oVALUE rb_float_minus(VALUE x, VALUE y) { if (FIXNUM_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) - (double)FIX2LONG(y)); } else if (RB_BIGNUM_TYPE_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) - rb_big2dbl(y)); } else if (RB_FLOAT_TYPE_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) - RFLOAT_VALUE(y)); } else { return rb_num_coerce_bin(x, y, '-'); } };T;:I" VALUE;T;;To;4;5F;6;;;;&I" Float#*;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "Returns a new \Float which is the product of +self+ and +other+: f = 3.14 f * 2 # => 6.28 f * 2.0 # => 6.28 f * Rational(1, 2) # => 1.57 f * Complex(2, 0) # => (6.28+0.0i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" *(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@.;![;"I"@return [Numeric];T;#0;$@.;.F;Bi;C0;7[[I" other;T0;$@.;![;"I"Returns a new \Float which is the product of +self+ and +other+: f = 3.14 f * 2 # => 6.28 f * 2.0 # => 6.28 f * Rational(1, 2) # => 1.57 f * Complex(2, 0) # => (6.28+0.0i) @overload *(other) @return [Numeric];T;#0;$@.;.F;/o;0;1T;2i;3i;%@0-;9I"mVALUE rb_float_mul(VALUE x, VALUE y) { if (FIXNUM_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) * (double)FIX2LONG(y)); } else if (RB_BIGNUM_TYPE_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) * rb_big2dbl(y)); } else if (RB_FLOAT_TYPE_P(y)) { return DBL2NUM(RFLOAT_VALUE(x) * RFLOAT_VALUE(y)); } else { return rb_num_coerce_bin(x, y, '*'); } };T;:I" VALUE;T;;To;4;5F;6;;;;&I" Float#/;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "Returns a new \Float which is the result of dividing +self+ by +other+: f = 3.14 f / 2 # => 1.57 f / 2.0 # => 1.57 f / Rational(2, 1) # => 1.57 f / Complex(2, 0) # => (1.57+0.0i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" /(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@/;![;"I"@return [Numeric];T;#0;$@/;.F;Bi;C0;7[[I" other;T0;$@/;![;"I"Returns a new \Float which is the result of dividing +self+ by +other+: f = 3.14 f / 2 # => 1.57 f / 2.0 # => 1.57 f / Rational(2, 1) # => 1.57 f / Complex(2, 0) # => (1.57+0.0i) @overload /(other) @return [Numeric];T;#0;$@/;.F;/o;0;1T;2i;3i;%@0-;9I"VALUE rb_float_div(VALUE x, VALUE y) { double num = RFLOAT_VALUE(x); double den; double ret; if (FIXNUM_P(y)) { den = FIX2LONG(y); } else if (RB_BIGNUM_TYPE_P(y)) { den = rb_big2dbl(y); } else if (RB_FLOAT_TYPE_P(y)) { den = RFLOAT_VALUE(y); } else { return rb_num_coerce_bin(x, y, '/'); } ret = double_div_double(num, den); return DBL2NUM(ret); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Float#quo;F;7[[I"y;T0;[[@i0;T;;;0;[;{;IC; "Returns the quotient from dividing +self+ by +other+: f = 3.14 f.quo(2) # => 1.57 f.quo(-2) # => -1.57 f.quo(Rational(2, 1)) # => 1.57 f.quo(Complex(2, 0)) # => (1.57+0.0i) Float#fdiv is an alias for Float#quo. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"quo(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@&/;![;"I"@return [Numeric];T;#0;$@&/;.F;Bi;C0;7[[I" other;T0;$@&/;![;"I"$Returns the quotient from dividing +self+ by +other+: f = 3.14 f.quo(2) # => 1.57 f.quo(-2) # => -1.57 f.quo(Rational(2, 1)) # => 1.57 f.quo(Complex(2, 0)) # => (1.57+0.0i) Float#fdiv is an alias for Float#quo. @overload quo(other) @return [Numeric];T;#0;$@&/;.F;/o;0;1T;2i ;3i-;%@0-;9I"Sstatic VALUE flo_quo(VALUE x, VALUE y) { return num_funcall1(x, '/', y); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Float#fdiv;F;7[[I"y;T0;[[@i0;T;;;0;[;{;IC; "Returns the quotient from dividing +self+ by +other+: f = 3.14 f.quo(2) # => 1.57 f.quo(-2) # => -1.57 f.quo(Rational(2, 1)) # => 1.57 f.quo(Complex(2, 0)) # => (1.57+0.0i) Float#fdiv is an alias for Float#quo. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"quo(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@E/;![;"I"@return [Numeric];T;#0;$@E/;.F;Bi;C0;7[[I" other;T0;$@E/;![;"@A/;#0;$@E/;.F;/o;0;1T;2i ;3i-;%@0-;9I"Sstatic VALUE flo_quo(VALUE x, VALUE y) { return num_funcall1(x, '/', y); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Float#%;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "Returns +self+ modulo +other+ as a float. For float +f+ and real number +r+, these expressions are equivalent: f % r f-r*(f/r).floor f.divmod(r)[1] See Numeric#divmod. Examples: 10.0 % 2 # => 0.0 10.0 % 3 # => 1.0 10.0 % 4 # => 2.0 10.0 % -2 # => 0.0 10.0 % -3 # => -2.0 10.0 % -4 # => -2.0 10.0 % 4.0 # => 2.0 10.0 % Rational(4, 1) # => 2.0 Float#modulo is an alias for Float#%. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" %(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@c/;![;"I"@return [Float];T;#0;$@c/;.F;Bi;C0;7[[I" other;T0;$@c/;![;"I"Returns +self+ modulo +other+ as a float. For float +f+ and real number +r+, these expressions are equivalent: f % r f-r*(f/r).floor f.divmod(r)[1] See Numeric#divmod. Examples: 10.0 % 2 # => 0.0 10.0 % 3 # => 1.0 10.0 % 4 # => 2.0 10.0 % -2 # => 0.0 10.0 % -3 # => -2.0 10.0 % -4 # => -2.0 10.0 % 4.0 # => 2.0 10.0 % Rational(4, 1) # => 2.0 Float#modulo is an alias for Float#%. @overload %(other) @return [Float];T;#0;$@c/;.F;/o;0;1T;2ii;3i;%@0-;9I"astatic VALUE flo_mod(VALUE x, VALUE y) { double fy; if (FIXNUM_P(y)) { fy = (double)FIX2LONG(y); } else if (RB_BIGNUM_TYPE_P(y)) { fy = rb_big2dbl(y); } else if (RB_FLOAT_TYPE_P(y)) { fy = RFLOAT_VALUE(y); } else { return rb_num_coerce_bin(x, y, '%'); } return DBL2NUM(ruby_float_mod(RFLOAT_VALUE(x), fy)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Float#modulo;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "Returns +self+ modulo +other+ as a float. For float +f+ and real number +r+, these expressions are equivalent: f % r f-r*(f/r).floor f.divmod(r)[1] See Numeric#divmod. Examples: 10.0 % 2 # => 0.0 10.0 % 3 # => 1.0 10.0 % 4 # => 2.0 10.0 % -2 # => 0.0 10.0 % -3 # => -2.0 10.0 % -4 # => -2.0 10.0 % 4.0 # => 2.0 10.0 % Rational(4, 1) # => 2.0 Float#modulo is an alias for Float#%. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" %(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@/;![;"I"@return [Float];T;#0;$@/;.F;Bi;C0;7[[I" other;T0;$@/;![;"@~/;#0;$@/;.F;/o;0;1T;2ii;3i;%@0-;9I"astatic VALUE flo_mod(VALUE x, VALUE y) { double fy; if (FIXNUM_P(y)) { fy = (double)FIX2LONG(y); } else if (RB_BIGNUM_TYPE_P(y)) { fy = rb_big2dbl(y); } else if (RB_FLOAT_TYPE_P(y)) { fy = RFLOAT_VALUE(y); } else { return rb_num_coerce_bin(x, y, '%'); } return DBL2NUM(ruby_float_mod(RFLOAT_VALUE(x), fy)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Float#divmod;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "RReturns a 2-element array [q, r], where q = (self/other).floor # Quotient r = self % other # Remainder Examples: 11.0.divmod(4) # => [2, 3.0] 11.0.divmod(-4) # => [-3, -1.0] -11.0.divmod(4) # => [-3, 1.0] -11.0.divmod(-4) # => [2, -3.0] 12.0.divmod(4) # => [3, 0.0] 12.0.divmod(-4) # => [-3, 0.0] -12.0.divmod(4) # => [-3, -0.0] -12.0.divmod(-4) # => [3, -0.0] 13.0.divmod(4.0) # => [3, 1.0] 13.0.divmod(Rational(4, 1)) # => [3, 1.0] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"divmod(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@/;![;"I"@return [Array];T;#0;$@/;.F;Bi;C0;7[[I" other;T0;$@/;![;"I"Returns a 2-element array [q, r], where q = (self/other).floor # Quotient r = self % other # Remainder Examples: 11.0.divmod(4) # => [2, 3.0] 11.0.divmod(-4) # => [-3, -1.0] -11.0.divmod(4) # => [-3, 1.0] -11.0.divmod(-4) # => [2, -3.0] 12.0.divmod(4) # => [3, 0.0] 12.0.divmod(-4) # => [-3, 0.0] -12.0.divmod(4) # => [-3, -0.0] -12.0.divmod(-4) # => [3, -0.0] 13.0.divmod(4.0) # => [3, 1.0] 13.0.divmod(Rational(4, 1)) # => [3, 1.0] @overload divmod(other) @return [Array];T;#0;$@/;.F;/o;0;1T;2i;3i;%@0-;9I"static VALUE flo_divmod(VALUE x, VALUE y) { double fy, div, mod; volatile VALUE a, b; if (FIXNUM_P(y)) { fy = (double)FIX2LONG(y); } else if (RB_BIGNUM_TYPE_P(y)) { fy = rb_big2dbl(y); } else if (RB_FLOAT_TYPE_P(y)) { fy = RFLOAT_VALUE(y); } else { return rb_num_coerce_bin(x, y, id_divmod); } flodivmod(RFLOAT_VALUE(x), fy, &div, &mod); a = dbl2ival(div); b = DBL2NUM(mod); return rb_assoc_new(a, b); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Float#**;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "Raises +self+ to the power of +other+: f = 3.14 f ** 2 # => 9.8596 f ** -2 # => 0.1014239928597509 f ** 2.1 # => 11.054834900588839 f ** Rational(2, 1) # => 9.8596 f ** Complex(2, 0) # => (9.8596+0i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"**(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@/;![;"I"@return [Numeric];T;#0;$@/;.F;Bi;C0;7[[I" other;T0;$@/;![;"I"$Raises +self+ to the power of +other+: f = 3.14 f ** 2 # => 9.8596 f ** -2 # => 0.1014239928597509 f ** 2.1 # => 11.054834900588839 f ** Rational(2, 1) # => 9.8596 f ** Complex(2, 0) # => (9.8596+0i) @overload **(other) @return [Numeric];T;#0;$@/;.F;/o;0;1T;2i;3i;%@0-;9I"QVALUE rb_float_pow(VALUE x, VALUE y) { double dx, dy; if (y == INT2FIX(2)) { dx = RFLOAT_VALUE(x); return DBL2NUM(dx * dx); } else if (FIXNUM_P(y)) { dx = RFLOAT_VALUE(x); dy = (double)FIX2LONG(y); } else if (RB_BIGNUM_TYPE_P(y)) { dx = RFLOAT_VALUE(x); dy = rb_big2dbl(y); } else if (RB_FLOAT_TYPE_P(y)) { dx = RFLOAT_VALUE(x); dy = RFLOAT_VALUE(y); if (dx < 0 && dy != round(dy)) return rb_dbl_complex_new_polar_pi(pow(-dx, dy), dy); } else { return rb_num_coerce_bin(x, y, idPow); } return DBL2NUM(pow(dx, dy)); };T;:I" VALUE;T;;To;4;5F;6;;;;&I" Float#==;F;7[;[;F;;F;;;[;{;IC; " ;T;[;![;"@;#0;$@/;%@0-;;To;4;5F;6;;;;&I"Float#===;F;7[;[;F;;S;;;[;{;IC; " ;T;[;![;"@;#0;$@/;%@0-;;To;4;5F;6;;;;&I"Float#<=>;F;7[[I"y;T0;[[@i;T;;Y;0;[;{;IC; "wReturns a value that depends on the numeric relation between +self+ and +other+: - -1, if +self+ is less than +other+. - 0, if +self+ is equal to +other+. - 1, if +self+ is greater than +other+. - +nil+, if the two values are incommensurate. Examples: 2.0 <=> 2 # => 0 2.0 <=> 2.0 # => 0 2.0 <=> Rational(2, 1) # => 0 2.0 <=> Complex(2, 0) # => 0 2.0 <=> 1.9 # => 1 2.0 <=> 2.1 # => -1 2.0 <=> 'foo' # => nil This is the basis for the tests in the Comparable module. Float::NAN <=> Float::NAN returns an implementation-dependent value. ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I"<=>(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[ I"-1;TI"0;TI"+1;TI"nil;T;$@/;![;"I" @return [ -1, 0, +1, nil];T;#0;$@/;.F;Bi;C0;7[[I" other;T0;$@/;![;"I"Returns a value that depends on the numeric relation between +self+ and +other+: - -1, if +self+ is less than +other+. - 0, if +self+ is equal to +other+. - 1, if +self+ is greater than +other+. - +nil+, if the two values are incommensurate. Examples: 2.0 <=> 2 # => 0 2.0 <=> 2.0 # => 0 2.0 <=> Rational(2, 1) # => 0 2.0 <=> Complex(2, 0) # => 0 2.0 <=> 1.9 # => 1 2.0 <=> 2.1 # => -1 2.0 <=> 'foo' # => nil This is the basis for the tests in the Comparable module. Float::NAN <=> Float::NAN returns an implementation-dependent value. @overload <=>(other) @return [ -1, 0, +1, nil];T;#0;$@/;.F;/o;0;1T;2i;3i;%@0-;9I"static VALUE flo_cmp(VALUE x, VALUE y) { double a, b; VALUE i; a = RFLOAT_VALUE(x); if (isnan(a)) return Qnil; if (RB_INTEGER_TYPE_P(y)) { VALUE rel = rb_integer_float_cmp(y, x); if (FIXNUM_P(rel)) return LONG2FIX(-FIX2LONG(rel)); return rel; } else if (RB_FLOAT_TYPE_P(y)) { b = RFLOAT_VALUE(y); } else { if (isinf(a) && (i = rb_check_funcall(y, rb_intern("infinite?"), 0, 0)) != Qundef) { if (RTEST(i)) { int j = rb_cmpint(i, x, y); j = (a > 0.0) ? (j > 0 ? 0 : +1) : (j < 0 ? 0 : -1); return INT2FIX(j); } if (a > 0.0) return INT2FIX(1); return INT2FIX(-1); } return rb_num_coerce_cmp(x, y, id_cmp); } return rb_dbl_cmp(a, b); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Float#>;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "Returns +true+ if +self+ is numerically greater than +other+: 2.0 > 1 # => true 2.0 > 1.0 # => true 2.0 > Rational(1, 2) # => true 2.0 > 2.0 # => false Float::NAN > Float::NAN returns an implementation-dependent value. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" >(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@0;![;"I"@return [Boolean];T;#0;$@0;.F;Bi;C0;7[[I" other;T0;$@0;![;"I":Returns +true+ if +self+ is numerically greater than +other+: 2.0 > 1 # => true 2.0 > 1.0 # => true 2.0 > Rational(1, 2) # => true 2.0 > 2.0 # => false Float::NAN > Float::NAN returns an implementation-dependent value. @overload >(other) @return [Boolean];T;#0;$@0;.F;/o;0;1T;2i;3i;%@0-;9I" VALUE rb_float_gt(VALUE x, VALUE y) { double a, b; a = RFLOAT_VALUE(x); if (RB_INTEGER_TYPE_P(y)) { VALUE rel = rb_integer_float_cmp(y, x); if (FIXNUM_P(rel)) return RBOOL(-FIX2LONG(rel) > 0); return Qfalse; } else if (RB_FLOAT_TYPE_P(y)) { b = RFLOAT_VALUE(y); #if MSC_VERSION_BEFORE(1300) if (isnan(b)) return Qfalse; #endif } else { return rb_num_coerce_relop(x, y, '>'); } #if MSC_VERSION_BEFORE(1300) if (isnan(a)) return Qfalse; #endif return RBOOL(a > b); };T;:I" VALUE;T;;To;4;5F;6;;;;&I" Float#>=;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "CReturns +true+ if +self+ is numerically greater than or equal to +other+: 2.0 >= 1 # => true 2.0 >= 1.0 # => true 2.0 >= Rational(1, 2) # => true 2.0 >= 2.0 # => true 2.0 >= 2.1 # => false Float::NAN >= Float::NAN returns an implementation-dependent value. ;T;[o;= ;>I" overload;F;?0;;;@0;:I">=(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@10;![;"I"@return [Boolean];T;#0;$@10;.F;Bi;C0;7[[I" other;T0;$@10;![;"I"nReturns +true+ if +self+ is numerically greater than or equal to +other+: 2.0 >= 1 # => true 2.0 >= 1.0 # => true 2.0 >= Rational(1, 2) # => true 2.0 >= 2.0 # => true 2.0 >= 2.1 # => false Float::NAN >= Float::NAN returns an implementation-dependent value. @overload >=(other) @return [Boolean];T;#0;$@10;.F;/o;0;1T;2i;3i;%@0-;9I">static VALUE flo_ge(VALUE x, VALUE y) { double a, b; a = RFLOAT_VALUE(x); if (RB_TYPE_P(y, T_FIXNUM) || RB_BIGNUM_TYPE_P(y)) { VALUE rel = rb_integer_float_cmp(y, x); if (FIXNUM_P(rel)) return RBOOL(-FIX2LONG(rel) >= 0); return Qfalse; } else if (RB_FLOAT_TYPE_P(y)) { b = RFLOAT_VALUE(y); #if MSC_VERSION_BEFORE(1300) if (isnan(b)) return Qfalse; #endif } else { return rb_num_coerce_relop(x, y, idGE); } #if MSC_VERSION_BEFORE(1300) if (isnan(a)) return Qfalse; #endif return RBOOL(a >= b); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Float#<;F;7[[I"y;T0;[[@i.;T;;;0;[;{;IC; " Returns +true+ if +self+ is numerically less than +other+: 2.0 < 3 # => true 2.0 < 3.0 # => true 2.0 < Rational(3, 1) # => true 2.0 < 2.0 # => false Float::NAN < Float::NAN returns an implementation-dependent value. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" <(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@P0;![;"I"@return [Boolean];T;#0;$@P0;.F;Bi;C0;7[[I" other;T0;$@P0;![;"I"7Returns +true+ if +self+ is numerically less than +other+: 2.0 < 3 # => true 2.0 < 3.0 # => true 2.0 < Rational(3, 1) # => true 2.0 < 2.0 # => false Float::NAN < Float::NAN returns an implementation-dependent value. @overload <(other) @return [Boolean];T;#0;$@P0;.F;/o;0;1T;2i;3i+;%@0-;9I""static VALUE flo_lt(VALUE x, VALUE y) { double a, b; a = RFLOAT_VALUE(x); if (RB_INTEGER_TYPE_P(y)) { VALUE rel = rb_integer_float_cmp(y, x); if (FIXNUM_P(rel)) return RBOOL(-FIX2LONG(rel) < 0); return Qfalse; } else if (RB_FLOAT_TYPE_P(y)) { b = RFLOAT_VALUE(y); #if MSC_VERSION_BEFORE(1300) if (isnan(b)) return Qfalse; #endif } else { return rb_num_coerce_relop(x, y, '<'); } #if MSC_VERSION_BEFORE(1300) if (isnan(a)) return Qfalse; #endif return RBOOL(a < b); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Float#<=;F;7[[I"y;T0;[[@iY;T;;;0;[;{;IC; "@Returns +true+ if +self+ is numerically less than or equal to +other+: 2.0 <= 3 # => true 2.0 <= 3.0 # => true 2.0 <= Rational(3, 1) # => true 2.0 <= 2.0 # => true 2.0 <= 1.0 # => false Float::NAN <= Float::NAN returns an implementation-dependent value. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"<=(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@o0;![;"I"@return [Boolean];T;#0;$@o0;.F;Bi;C0;7[[I" other;T0;$@o0;![;"I"kReturns +true+ if +self+ is numerically less than or equal to +other+: 2.0 <= 3 # => true 2.0 <= 3.0 # => true 2.0 <= Rational(3, 1) # => true 2.0 <= 2.0 # => true 2.0 <= 1.0 # => false Float::NAN <= Float::NAN returns an implementation-dependent value. @overload <=(other) @return [Boolean];T;#0;$@o0;.F;/o;0;1T;2iI;3iV;%@0-;9I"%static VALUE flo_le(VALUE x, VALUE y) { double a, b; a = RFLOAT_VALUE(x); if (RB_INTEGER_TYPE_P(y)) { VALUE rel = rb_integer_float_cmp(y, x); if (FIXNUM_P(rel)) return RBOOL(-FIX2LONG(rel) <= 0); return Qfalse; } else if (RB_FLOAT_TYPE_P(y)) { b = RFLOAT_VALUE(y); #if MSC_VERSION_BEFORE(1300) if (isnan(b)) return Qfalse; #endif } else { return rb_num_coerce_relop(x, y, idLE); } #if MSC_VERSION_BEFORE(1300) if (isnan(a)) return Qfalse; #endif return RBOOL(a <= b); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Float#eql?;F;7[;[;F;;V;;;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@0;![;"@;#0;$@0;Bi;%@0-;;To;4;5F;6;;;;&I"Float#hash;F;7[;[[@ir;T;;X;0;[;{;IC; "FReturns the integer hash value for +self+. See also Object#hash. ;T;[o;= ;>I" overload;F;?0;;X;@0;:I" hash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@0;![;"I"@return [Integer];T;#0;$@0;.F;Bi;C0;7[;$@0;![;"I"kReturns the integer hash value for +self+. See also Object#hash. @overload hash @return [Integer];T;#0;$@0;.F;/o;0;1T;2ii;3io;%@0-;9I"Tstatic VALUE flo_hash(VALUE num) { return rb_dbl_hash(RFLOAT_VALUE(num)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Float#to_i;F;7[;[[@i' ;T;;;0;[;{;IC; "Returns +self+ truncated to an Integer. 1.2.to_i # => 1 (-1.2).to_i # => -1 Note that the limited precision of floating-point arithmetic may lead to surprising results: (0.3 / 0.1).to_i # => 2 (!) Float#to_int is an alias for Float#to_i. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_i;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@0;![;"I"@return [Integer];T;#0;$@0;.F;Bi;C0;7[;$@0;![;"I" Returns +self+ truncated to an Integer. 1.2.to_i # => 1 (-1.2).to_i # => -1 Note that the limited precision of floating-point arithmetic may lead to surprising results: (0.3 / 0.1).to_i # => 2 (!) Float#to_int is an alias for Float#to_i. @overload to_i @return [Integer];T;#0;$@0;.F;/o;0;1T;2i ;3i$ ;%@0-;9I"static VALUE flo_to_i(VALUE num) { double f = RFLOAT_VALUE(num); if (f > 0.0) f = floor(f); if (f < 0.0) f = ceil(f); return dbl2ival(f); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Float#to_int;F;7[;[[@i' ;T;;;0;[;{;IC; "Returns +self+ truncated to an Integer. 1.2.to_i # => 1 (-1.2).to_i # => -1 Note that the limited precision of floating-point arithmetic may lead to surprising results: (0.3 / 0.1).to_i # => 2 (!) Float#to_int is an alias for Float#to_i. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_i;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@0;![;"I"@return [Integer];T;#0;$@0;.F;Bi;C0;7[;$@0;![;"@0;#0;$@0;.F;/o;0;1T;2i ;3i$ ;%@0-;9I"static VALUE flo_to_i(VALUE num) { double f = RFLOAT_VALUE(num); if (f > 0.0) f = floor(f); if (f < 0.0) f = ceil(f); return dbl2ival(f); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Float#floor;F;7[[@90;[[@i;T;;;0;[;{;IC; "Returns the largest number less than or equal to +self+ with a precision of +ndigits+ decimal digits. When +ndigits+ is positive, returns a float with +ndigits+ digits after the decimal point (as available): f = 12345.6789 f.floor(1) # => 12345.6 f.floor(3) # => 12345.678 f = -12345.6789 f.floor(1) # => -12345.7 f.floor(3) # => -12345.679 When +ndigits+ is non-positive, returns an integer with at least ndigits.abs trailing zeros: f = 12345.6789 f.floor(0) # => 12345 f.floor(-3) # => 12000 f = -12345.6789 f.floor(0) # => -12346 f.floor(-3) # => -13000 Note that the limited precision of floating-point arithmetic may lead to surprising results: (0.3 / 0.1).floor #=> 2 (!) Related: Float#ceil. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"floor(ndigits = 0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;TI" Integer;T;$@0;![;"I"@return [Float, Integer];T;#0;$@0;.F;Bi;C0;7[[I" ndigits;TI"0;T;$@0;![;"I"'Returns the largest number less than or equal to +self+ with a precision of +ndigits+ decimal digits. When +ndigits+ is positive, returns a float with +ndigits+ digits after the decimal point (as available): f = 12345.6789 f.floor(1) # => 12345.6 f.floor(3) # => 12345.678 f = -12345.6789 f.floor(1) # => -12345.7 f.floor(3) # => -12345.679 When +ndigits+ is non-positive, returns an integer with at least ndigits.abs trailing zeros: f = 12345.6789 f.floor(0) # => 12345 f.floor(-3) # => 12000 f = -12345.6789 f.floor(0) # => -12346 f.floor(-3) # => -13000 Note that the limited precision of floating-point arithmetic may lead to surprising results: (0.3 / 0.1).floor #=> 2 (!) Related: Float#ceil. @overload floor(ndigits = 0) @return [Float, Integer];T;#0;$@0;.F;/o;0;1T;2ix;3i;%@0-;9I"static VALUE flo_floor(int argc, VALUE *argv, VALUE num) { int ndigits = flo_ndigits(argc, argv); return rb_float_floor(num, ndigits); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Float#ceil;F;7[[@90;[[@i;T;;;0;[;{;IC; "Returns the smallest number greater than or equal to +self+ with a precision of +ndigits+ decimal digits. When +ndigits+ is positive, returns a float with +ndigits+ digits after the decimal point (as available): f = 12345.6789 f.ceil(1) # => 12345.7 f.ceil(3) # => 12345.679 f = -12345.6789 f.ceil(1) # => -12345.6 f.ceil(3) # => -12345.678 When +ndigits+ is non-positive, returns an integer with at least ndigits.abs trailing zeros: f = 12345.6789 f.ceil(0) # => 12346 f.ceil(-3) # => 13000 f = -12345.6789 f.ceil(0) # => -12345 f.ceil(-3) # => -12000 Note that the limited precision of floating-point arithmetic may lead to surprising results: (2.1 / 0.7).ceil #=> 4 (!) Related: Float#floor. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ceil(ndigits = 0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;TI" Integer;T;$@ 1;![;"I"@return [Float, Integer];T;#0;$@ 1;.F;Bi;C0;7[[I" ndigits;TI"0;T;$@ 1;![;"I""Returns the smallest number greater than or equal to +self+ with a precision of +ndigits+ decimal digits. When +ndigits+ is positive, returns a float with +ndigits+ digits after the decimal point (as available): f = 12345.6789 f.ceil(1) # => 12345.7 f.ceil(3) # => 12345.679 f = -12345.6789 f.ceil(1) # => -12345.6 f.ceil(3) # => -12345.678 When +ndigits+ is non-positive, returns an integer with at least ndigits.abs trailing zeros: f = 12345.6789 f.ceil(0) # => 12346 f.ceil(-3) # => 13000 f = -12345.6789 f.ceil(0) # => -12345 f.ceil(-3) # => -12000 Note that the limited precision of floating-point arithmetic may lead to surprising results: (2.1 / 0.7).ceil #=> 4 (!) Related: Float#floor. @overload ceil(ndigits = 0) @return [Float, Integer];T;#0;$@ 1;.F;/o;0;1T;2i;3i;%@0-;9I"static VALUE flo_ceil(int argc, VALUE *argv, VALUE num) { int ndigits = flo_ndigits(argc, argv); return rb_float_ceil(num, ndigits); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Float#round;F;7[[@90;[[@i ;T;;;0;[;{;IC; " Returns +self+ rounded to the nearest value with a precision of +ndigits+ decimal digits. When +ndigits+ is non-negative, returns a float with +ndigits+ after the decimal point (as available): f = 12345.6789 f.round(1) # => 12345.7 f.round(3) # => 12345.679 f = -12345.6789 f.round(1) # => -12345.7 f.round(3) # => -12345.679 When +ndigits+ is negative, returns an integer with at least ndigits.abs trailing zeros: f = 12345.6789 f.round(0) # => 12346 f.round(-3) # => 12000 f = -12345.6789 f.round(0) # => -12346 f.round(-3) # => -12000 If keyword argument +half+ is given, and +self+ is equidistant from the two candidate values, the rounding is according to the given +half+ value: - +:up+ or +nil+: round away from zero: 2.5.round(half: :up) # => 3 3.5.round(half: :up) # => 4 (-2.5).round(half: :up) # => -3 - +:down+: round toward zero: 2.5.round(half: :down) # => 2 3.5.round(half: :down) # => 3 (-2.5).round(half: :down) # => -2 - +:even+: round toward the candidate whose last nonzero digit is even: 2.5.round(half: :even) # => 2 3.5.round(half: :even) # => 4 (-2.5).round(half: :even) # => -2 Raises and exception if the value for +half+ is invalid. Related: Float#truncate. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"#round(ndigits = 0, half: :up]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI" Float;T;$@*1;![;"I"@return [Integer, Float];T;#0;$@*1;.F;Bi;C0;7[[I" ndigits;TI"0;T[I" half:;TI" :up];T;$@*1;![;"I"SReturns +self+ rounded to the nearest value with a precision of +ndigits+ decimal digits. When +ndigits+ is non-negative, returns a float with +ndigits+ after the decimal point (as available): f = 12345.6789 f.round(1) # => 12345.7 f.round(3) # => 12345.679 f = -12345.6789 f.round(1) # => -12345.7 f.round(3) # => -12345.679 When +ndigits+ is negative, returns an integer with at least ndigits.abs trailing zeros: f = 12345.6789 f.round(0) # => 12346 f.round(-3) # => 12000 f = -12345.6789 f.round(0) # => -12346 f.round(-3) # => -12000 If keyword argument +half+ is given, and +self+ is equidistant from the two candidate values, the rounding is according to the given +half+ value: - +:up+ or +nil+: round away from zero: 2.5.round(half: :up) # => 3 3.5.round(half: :up) # => 4 (-2.5).round(half: :up) # => -3 - +:down+: round toward zero: 2.5.round(half: :down) # => 2 3.5.round(half: :down) # => 3 (-2.5).round(half: :down) # => -2 - +:even+: round toward the candidate whose last nonzero digit is even: 2.5.round(half: :even) # => 2 3.5.round(half: :even) # => 4 (-2.5).round(half: :even) # => -2 Raises and exception if the value for +half+ is invalid. Related: Float#truncate. @overload round(ndigits = 0, half: :up]) @return [Integer, Float];T;#0;$@*1;.F;/o;0;1T;2i ;3i ;%@0-;9I"static VALUE flo_round(int argc, VALUE *argv, VALUE num) { double number, f, x; VALUE nd, opt; int ndigits = 0; enum ruby_num_rounding_mode mode; if (rb_scan_args(argc, argv, "01:", &nd, &opt)) { ndigits = NUM2INT(nd); } mode = rb_num_get_rounding_option(opt); number = RFLOAT_VALUE(num); if (number == 0.0) { return ndigits > 0 ? DBL2NUM(number) : INT2FIX(0); } if (ndigits < 0) { return rb_int_round(flo_to_i(num), ndigits, mode); } if (ndigits == 0) { x = ROUND_CALL(mode, round, (number, 1.0)); return dbl2ival(x); } if (isfinite(number)) { int binexp; frexp(number, &binexp); if (float_round_overflow(ndigits, binexp)) return num; if (float_round_underflow(ndigits, binexp)) return DBL2NUM(0); if (ndigits > 14) { /* In this case, pow(10, ndigits) may not be accurate. */ return rb_flo_round_by_rational(argc, argv, num); } f = pow(10, ndigits); x = ROUND_CALL(mode, round, (number, f)); return DBL2NUM(x / f); } return num; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Float#truncate;F;7[[@90;[[@iU ;T;;_;0;[;{;IC; "Returns +self+ truncated (toward zero) to a precision of +ndigits+ decimal digits. When +ndigits+ is positive, returns a float with +ndigits+ digits after the decimal point (as available): f = 12345.6789 f.truncate(1) # => 12345.6 f.truncate(3) # => 12345.678 f = -12345.6789 f.truncate(1) # => -12345.6 f.truncate(3) # => -12345.678 When +ndigits+ is negative, returns an integer with at least ndigits.abs trailing zeros: f = 12345.6789 f.truncate(0) # => 12345 f.truncate(-3) # => 12000 f = -12345.6789 f.truncate(0) # => -12345 f.truncate(-3) # => -12000 Note that the limited precision of floating-point arithmetic may lead to surprising results: (0.3 / 0.1).truncate #=> 2 (!) Related: Float#round. ;T;[o;= ;>I" overload;F;?0;;_;@0;:I"truncate(ndigits = 0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;TI" Integer;T;$@M1;![;"I"@return [Float, Integer];T;#0;$@M1;.F;Bi;C0;7[[I" ndigits;TI"0;T;$@M1;![;"I"+Returns +self+ truncated (toward zero) to a precision of +ndigits+ decimal digits. When +ndigits+ is positive, returns a float with +ndigits+ digits after the decimal point (as available): f = 12345.6789 f.truncate(1) # => 12345.6 f.truncate(3) # => 12345.678 f = -12345.6789 f.truncate(1) # => -12345.6 f.truncate(3) # => -12345.678 When +ndigits+ is negative, returns an integer with at least ndigits.abs trailing zeros: f = 12345.6789 f.truncate(0) # => 12345 f.truncate(-3) # => 12000 f = -12345.6789 f.truncate(0) # => -12345 f.truncate(-3) # => -12000 Note that the limited precision of floating-point arithmetic may lead to surprising results: (0.3 / 0.1).truncate #=> 2 (!) Related: Float#round. @overload truncate(ndigits = 0) @return [Float, Integer];T;#0;$@M1;.F;/o;0;1T;2i2 ;3iS ;%@0-;9I"static VALUE flo_truncate(int argc, VALUE *argv, VALUE num) { if (signbit(RFLOAT_VALUE(num))) return flo_ceil(argc, argv, num); else return flo_floor(argc, argv, num); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Float#nan?;F;7[;[[@i;T;: nan?;0;[;{;IC; "Returns +true+ if +self+ is a NaN, +false+ otherwise. f = -1.0 #=> -1.0 f.nan? #=> false f = 0.0/0.0 #=> NaN f.nan? #=> true;T;[o;= ;>I" overload;F;?0;;;@0;:I" nan?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@m1;![;"I"@return [Boolean];T;#0;$@m1;.F;Bi;C0;7[;$@m1;![;"I"Returns +true+ if +self+ is a NaN, +false+ otherwise. f = -1.0 #=> -1.0 f.nan? #=> false f = 0.0/0.0 #=> NaN f.nan? #=> true @overload nan? @return [Boolean];T;#0;$@m1;.F;/o;0;1T;2i;3i;Bi;%@0-;9I"tstatic VALUE flo_is_nan_p(VALUE num) { double value = RFLOAT_VALUE(num); return RBOOL(isnan(value)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Float#infinite?;F;7[;[[@i;T;;;0;[;{;IC; "<Returns: - 1, if +self+ is Infinity. - -1 if +self+ is -Infinity. - +nil+, otherwise. Examples: f = 1.0/0.0 # => Infinity f.infinite? # => 1 f = -1.0/0.0 # => -Infinity f.infinite? # => -1 f = 1.0 # => 1.0 f.infinite? # => nil f = 0.0/0.0 # => NaN f.infinite? # => nil;T;[o;= ;>I" overload;F;?0;;;@0;:I"infinite?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"-1;TI"1;TI"nil;T;$@1;![;"I"@return [-1, 1, nil];T;#0;$@1;.F;Bi;C0;7[;$@1;![;"I"kReturns: - 1, if +self+ is Infinity. - -1 if +self+ is -Infinity. - +nil+, otherwise. Examples: f = 1.0/0.0 # => Infinity f.infinite? # => 1 f = -1.0/0.0 # => -Infinity f.infinite? # => -1 f = 1.0 # => 1.0 f.infinite? # => nil f = 0.0/0.0 # => NaN f.infinite? # => nil @overload infinite? @return [-1, 1, nil];T;#0;$@1;.F;/o;0;1T;2i;3i;Bi;%@0-;9I"VALUE rb_flo_is_infinite_p(VALUE num) { double value = RFLOAT_VALUE(num); if (isinf(value)) { return INT2FIX( value < 0 ? -1 : 1 ); } return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Float#finite?;F;7[;[[@i;T;;;0;[;{;IC; "(Returns +true+ if +self+ is not +Infinity+, +-Infinity+, or +Nan+, +false+ otherwise: f = 2.0 # => 2.0 f.finite? # => true f = 1.0/0.0 # => Infinity f.finite? # => false f = -1.0/0.0 # => -Infinity f.finite? # => false f = 0.0/0.0 # => NaN f.finite? # => false;T;[o;= ;>I" overload;F;?0;;;@0;:I" finite?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@1;![;"I"@return [Boolean];T;#0;$@1;.F;Bi;C0;7[;$@1;![;"I"QReturns +true+ if +self+ is not +Infinity+, +-Infinity+, or +Nan+, +false+ otherwise: f = 2.0 # => 2.0 f.finite? # => true f = 1.0/0.0 # => Infinity f.finite? # => false f = -1.0/0.0 # => -Infinity f.finite? # => false f = 0.0/0.0 # => NaN f.finite? # => false @overload finite? @return [Boolean];T;#0;$@1;.F;/o;0;1T;2i;3i;Bi;%@0-;9I"vVALUE rb_flo_is_finite_p(VALUE num) { double value = RFLOAT_VALUE(num); return RBOOL(isfinite(value)); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Float#next_float;F;7[;[[@i#;T;:next_float;0;[;{;IC; "Returns the next-larger representable \Float. These examples show the internally stored values (64-bit hexadecimal) for each \Float +f+ and for the corresponding f.next_float: f = 0.0 # 0x0000000000000000 f.next_float # 0x0000000000000001 f = 0.01 # 0x3f847ae147ae147b f.next_float # 0x3f847ae147ae147c In the remaining examples here, the output is shown in the usual way (result +to_s+): 0.01.next_float # => 0.010000000000000002 1.0.next_float # => 1.0000000000000002 100.0.next_float # => 100.00000000000001 f = 0.01 (0..3).each_with_index {|i| printf "%2d %-20a %s\n", i, f, f.to_s; f = f.next_float } Output: 0 0x1.47ae147ae147bp-7 0.01 1 0x1.47ae147ae147cp-7 0.010000000000000002 2 0x1.47ae147ae147dp-7 0.010000000000000004 3 0x1.47ae147ae147ep-7 0.010000000000000005 f = 0.0; 100.times { f += 0.1 } f # => 9.99999999999998 # should be 10.0 in the ideal world. 10-f # => 1.9539925233402755e-14 # the floating point error. 10.0.next_float-10 # => 1.7763568394002505e-15 # 1 ulp (unit in the last place). (10-f)/(10.0.next_float-10) # => 11.0 # the error is 11 ulp. (10-f)/(10*Float::EPSILON) # => 8.8 # approximation of the above. "%a" % 10 # => "0x1.4p+3" "%a" % f # => "0x1.3fffffffffff5p+3" # the last hex digit is 5. 16 - 5 = 11 ulp. Related: Float#prev_float ;T;[o;= ;>I" overload;F;?0;;;@0;:I"next_float;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@1;![;"I"@return [Float];T;#0;$@1;.F;Bi;C0;7[;$@1;![;"I"Returns the next-larger representable \Float. These examples show the internally stored values (64-bit hexadecimal) for each \Float +f+ and for the corresponding f.next_float: f = 0.0 # 0x0000000000000000 f.next_float # 0x0000000000000001 f = 0.01 # 0x3f847ae147ae147b f.next_float # 0x3f847ae147ae147c In the remaining examples here, the output is shown in the usual way (result +to_s+): 0.01.next_float # => 0.010000000000000002 1.0.next_float # => 1.0000000000000002 100.0.next_float # => 100.00000000000001 f = 0.01 (0..3).each_with_index {|i| printf "%2d %-20a %s\n", i, f, f.to_s; f = f.next_float } Output: 0 0x1.47ae147ae147bp-7 0.01 1 0x1.47ae147ae147cp-7 0.010000000000000002 2 0x1.47ae147ae147dp-7 0.010000000000000004 3 0x1.47ae147ae147ep-7 0.010000000000000005 f = 0.0; 100.times { f += 0.1 } f # => 9.99999999999998 # should be 10.0 in the ideal world. 10-f # => 1.9539925233402755e-14 # the floating point error. 10.0.next_float-10 # => 1.7763568394002505e-15 # 1 ulp (unit in the last place). (10-f)/(10.0.next_float-10) # => 11.0 # the error is 11 ulp. (10-f)/(10*Float::EPSILON) # => 8.8 # approximation of the above. "%a" % 10 # => "0x1.4p+3" "%a" % f # => "0x1.3fffffffffff5p+3" # the last hex digit is 5. 16 - 5 = 11 ulp. Related: Float#prev_float @overload next_float @return [Float];T;#0;$@1;.F;/o;0;1T;2i;3i!;%@0-;9I"Vstatic VALUE flo_next_float(VALUE vx) { return flo_nextafter(vx, HUGE_VAL); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Float#prev_float;F;7[;[[@iL;T;:prev_float;0;[;{;IC; "^Returns the next-smaller representable \Float. These examples show the internally stored values (64-bit hexadecimal) for each \Float +f+ and for the corresponding f.pev_float: f = 5e-324 # 0x0000000000000001 f.prev_float # 0x0000000000000000 f = 0.01 # 0x3f847ae147ae147b f.prev_float # 0x3f847ae147ae147a In the remaining examples here, the output is shown in the usual way (result +to_s+): 0.01.prev_float # => 0.009999999999999998 1.0.prev_float # => 0.9999999999999999 100.0.prev_float # => 99.99999999999999 f = 0.01 (0..3).each_with_index {|i| printf "%2d %-20a %s\n", i, f, f.to_s; f = f.prev_float } Output: 0 0x1.47ae147ae147bp-7 0.01 1 0x1.47ae147ae147ap-7 0.009999999999999998 2 0x1.47ae147ae1479p-7 0.009999999999999997 3 0x1.47ae147ae1478p-7 0.009999999999999995 Related: Float#next_float. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"prev_float;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@1;![;"I"@return [Float];T;#0;$@1;.F;Bi;C0;7[;$@1;![;"I"Returns the next-smaller representable \Float. These examples show the internally stored values (64-bit hexadecimal) for each \Float +f+ and for the corresponding f.pev_float: f = 5e-324 # 0x0000000000000001 f.prev_float # 0x0000000000000000 f = 0.01 # 0x3f847ae147ae147b f.prev_float # 0x3f847ae147ae147a In the remaining examples here, the output is shown in the usual way (result +to_s+): 0.01.prev_float # => 0.009999999999999998 1.0.prev_float # => 0.9999999999999999 100.0.prev_float # => 99.99999999999999 f = 0.01 (0..3).each_with_index {|i| printf "%2d %-20a %s\n", i, f, f.to_s; f = f.prev_float } Output: 0 0x1.47ae147ae147bp-7 0.01 1 0x1.47ae147ae147ap-7 0.009999999999999998 2 0x1.47ae147ae1479p-7 0.009999999999999997 3 0x1.47ae147ae1478p-7 0.009999999999999995 Related: Float#next_float. @overload prev_float @return [Float];T;#0;$@1;.F;/o;0;1T;2i);3iJ;%@0-;9I"Wstatic VALUE flo_prev_float(VALUE vx) { return flo_nextafter(vx, -HUGE_VAL); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Float#numerator;F;7[;[[@ri,;T;;;0;[;{;IC; "Returns the numerator. The result is machine dependent. n = 0.3.numerator #=> 5404319552844595 d = 0.3.denominator #=> 18014398509481984 n.fdiv(d) #=> 0.3 See also Float#denominator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"numerator;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@1;![;"I"@return [Integer];T;#0;$@1;.F;Bi;C0;7[;$@1;![;"I"Returns the numerator. The result is machine dependent. n = 0.3.numerator #=> 5404319552844595 d = 0.3.denominator #=> 18014398509481984 n.fdiv(d) #=> 0.3 See also Float#denominator. @overload numerator @return [Integer];T;#0;$@1;.F;/o;0;1T;2i ;3i*;%@0-;9I"VALUE rb_float_numerator(VALUE self) { double d = RFLOAT_VALUE(self); VALUE r; if (!isfinite(d)) return self; r = float_to_r(self); return nurat_numerator(r); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Float#denominator;F;7[;[[@ri@;T;;;0;[;{;IC; "lReturns the denominator (always positive). The result is machine dependent. See also Float#numerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"denominator;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@2;![;"I"@return [Integer];T;#0;$@2;.F;Bi;C0;7[;$@2;![;"I"Returns the denominator (always positive). The result is machine dependent. See also Float#numerator. @overload denominator @return [Integer];T;#0;$@2;.F;/o;0;1T;2i7;3i>;%@0-;9I"VALUE rb_float_denominator(VALUE self) { double d = RFLOAT_VALUE(self); VALUE r; if (!isfinite(d)) return INT2FIX(1); r = float_to_r(self); return nurat_denominator(r); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Float#to_r;F;7[;[[@ri;T;;;0;[;{;IC; "Returns the value as a rational. 2.0.to_r #=> (2/1) 2.5.to_r #=> (5/2) -0.75.to_r #=> (-3/4) 0.0.to_r #=> (0/1) 0.3.to_r #=> (5404319552844595/18014398509481984) NOTE: 0.3.to_r isn't the same as "0.3".to_r. The latter is equivalent to "3/10".to_r, but the former isn't so. 0.3.to_r == 3/10r #=> false "0.3".to_r == 3/10r #=> true See also Float#rationalize. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_r;T;IC; ";T;[;![;"I";T;#0;$@,2;.F;Bi;C0;7[;$@,2;![;"I"Returns the value as a rational. 2.0.to_r #=> (2/1) 2.5.to_r #=> (5/2) -0.75.to_r #=> (-3/4) 0.0.to_r #=> (0/1) 0.3.to_r #=> (5404319552844595/18014398509481984) NOTE: 0.3.to_r isn't the same as "0.3".to_r. The latter is equivalent to "3/10".to_r, but the former isn't so. 0.3.to_r == 3/10r #=> false "0.3".to_r == 3/10r #=> true See also Float#rationalize. @overload to_r;T;#0;$@,2;.F;/o;0;1T;2i;3i;%@0-;9I"static VALUE float_to_r(VALUE self) { VALUE f; int n; float_decode_internal(self, &f, &n); #if FLT_RADIX == 2 if (n == 0) return rb_rational_new1(f); if (n > 0) return rb_rational_new1(rb_int_lshift(f, INT2FIX(n))); n = -n; return rb_rational_new2(f, rb_int_lshift(ONE, INT2FIX(n))); #else f = rb_int_mul(f, rb_int_pow(INT2FIX(FLT_RADIX), n)); if (RB_TYPE_P(f, T_RATIONAL)) return f; return rb_rational_new1(f); #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Float#rationalize;F;7[[@90;[[@ri;T;;;0;[;{;IC; "/Returns a simpler approximation of the value (flt-|eps| <= result <= flt+|eps|). If the optional argument +eps+ is not given, it will be chosen automatically. 0.3.rationalize #=> (3/10) 1.333.rationalize #=> (1333/1000) 1.333.rationalize(0.01) #=> (4/3) See also Float#to_r. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"rationalize([eps]);T;IC; ";T;[;![;"I";T;#0;$@B2;.F;Bi;C0;7[[I" [eps];T0;$@B2;![;"I"NReturns a simpler approximation of the value (flt-|eps| <= result <= flt+|eps|). If the optional argument +eps+ is not given, it will be chosen automatically. 0.3.rationalize #=> (3/10) 1.333.rationalize #=> (1333/1000) 1.333.rationalize(0.01) #=> (4/3) See also Float#to_r. @overload rationalize([eps]);T;#0;$@B2;.F;/o;0;1T;2i;3i;%@0-;9I"static VALUE float_rationalize(int argc, VALUE *argv, VALUE self) { double d = RFLOAT_VALUE(self); VALUE rat; int neg = d < 0.0; if (neg) self = DBL2NUM(-d); if (rb_check_arity(argc, 0, 1)) { rat = rb_flt_rationalize_with_prec(self, argv[0]); } else { rat = rb_flt_rationalize(self); } if (neg) RATIONAL_SET_NUM(rat, rb_int_uminus(RRATIONAL(rat)->num)); return rat; };T;:I"static VALUE;T;;T; @0-; IC;[; @0-; IC;[; @0-; IC;{;IC;{;T;IC;{;T;T;{@.;G;[;[[@i[@i;T;: Float;;;;;[;{;IC; " ****************************************************************** A \Float object represents a sometimes-inexact real number using the native architecture's double-precision floating point representation. Floating point has a different arithmetic and is an inexact number. So you should know its esoteric system. See following: - https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html - https://github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ#floats_imprecise - https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems You can create a \Float object explicitly with: - A {floating-point literal}[doc/syntax/literals_rdoc.html#label-Float+Literals]. You can convert certain objects to Floats with: - \Method {Float}[Kernel.html#method-i-Float]. == What's Here First, what's elsewhere. \Class \Float: - Inherits from {class Numeric}[Numeric.html#class-Numeric-label-What-27s+Here]. Here, class \Float provides methods for: - {Querying}[#class-Float-label-Querying] - {Comparing}[#class-Float-label-Comparing] - {Converting}[#class-Float-label-Converting] === Querying - #finite?:: Returns whether +self+ is finite. - #hash:: Returns the integer hash code for +self+. - #infinite?:: Returns whether +self+ is infinite. - #nan?:: Returns whether +self+ is a NaN (not-a-number). === Comparing - {<}[#method-i-3C]:: Returns whether +self+ is less than the given value. - {<=}[#method-i-3C-3D]:: Returns whether +self+ is less than or equal to the given value. - {<=>}[#method-i-3C-3D-3E]:: Returns a number indicating whether +self+ is less than, equal to, or greater than the given value. - {==}[#method-i-3D-3D] (aliased as #=== and #eql>):: Returns whether +self+ is equal to the given value. - {>}[#method-i-3E]:: Returns whether +self+ is greater than the given value. - {>=}[#method-i-3E-3D]:: Returns whether +self+ is greater than or equal to the given value. === Converting - #% (aliased as #modulo):: Returns +self+ modulo the given value. - #*:: Returns the product of +self+ and the given value. - {**}[#method-i-2A-2A]:: Returns the value of +self+ raised to the power of the given value. - #+:: Returns the sum of +self+ and the given value. - #-:: Returns the difference of +self+ and the given value. - {/}[#method-i-2F]:: Returns the quotient of +self+ and the given value. - #ceil:: Returns the smallest number greater than or equal to +self+. - #coerce:: Returns a 2-element array containing the given value converted to a \Float and +self+ - #divmod:: Returns a 2-element array containing the quotient and remainder results of dividing +self+ by the given value. - #fdiv:: Returns the Float result of dividing +self+ by the given value. - #floor:: Returns the greatest number smaller than or equal to +self+. - #next_float:: Returns the next-larger representable \Float. - #prev_float:: Returns the next-smaller representable \Float. - #quo:: Returns the quotient from dividing +self+ by the given value. - #round:: Returns +self+ rounded to the nearest value, to a given precision. - #to_i (aliased as #to_int):: Returns +self+ truncated to an Integer. - #to_s (aliased as #inspect):: Returns a string containing the place-value representation of +self+ in the given radix. - #truncate:: Returns +self+ truncated to a given precision.;T;[;![;"I"****************************************************************** A \Float object represents a sometimes-inexact real number using the native architecture's double-precision floating point representation. Floating point has a different arithmetic and is an inexact number. So you should know its esoteric system. See following: - https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html - https://github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ#floats_imprecise - https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems You can create a \Float object explicitly with: - A {floating-point literal}[doc/syntax/literals_rdoc.html#label-Float+Literals]. You can convert certain objects to Floats with: - \Method {Float}[Kernel.html#method-i-Float]. == What's Here First, what's elsewhere. \Class \Float: - Inherits from {class Numeric}[Numeric.html#class-Numeric-label-What-27s+Here]. Here, class \Float provides methods for: - {Querying}[#class-Float-label-Querying] - {Comparing}[#class-Float-label-Comparing] - {Converting}[#class-Float-label-Converting] === Querying - #finite?:: Returns whether +self+ is finite. - #hash:: Returns the integer hash code for +self+. - #infinite?:: Returns whether +self+ is infinite. - #nan?:: Returns whether +self+ is a NaN (not-a-number). === Comparing - {<}[#method-i-3C]:: Returns whether +self+ is less than the given value. - {<=}[#method-i-3C-3D]:: Returns whether +self+ is less than or equal to the given value. - {<=>}[#method-i-3C-3D-3E]:: Returns a number indicating whether +self+ is less than, equal to, or greater than the given value. - {==}[#method-i-3D-3D] (aliased as #=== and #eql>):: Returns whether +self+ is equal to the given value. - {>}[#method-i-3E]:: Returns whether +self+ is greater than the given value. - {>=}[#method-i-3E-3D]:: Returns whether +self+ is greater than or equal to the given value. === Converting - #% (aliased as #modulo):: Returns +self+ modulo the given value. - #*:: Returns the product of +self+ and the given value. - {**}[#method-i-2A-2A]:: Returns the value of +self+ raised to the power of the given value. - #+:: Returns the sum of +self+ and the given value. - #-:: Returns the difference of +self+ and the given value. - {/}[#method-i-2F]:: Returns the quotient of +self+ and the given value. - #ceil:: Returns the smallest number greater than or equal to +self+. - #coerce:: Returns a 2-element array containing the given value converted to a \Float and +self+ - #divmod:: Returns a 2-element array containing the quotient and remainder results of dividing +self+ by the given value. - #fdiv:: Returns the Float result of dividing +self+ by the given value. - #floor:: Returns the greatest number smaller than or equal to +self+. - #next_float:: Returns the next-larger representable \Float. - #prev_float:: Returns the next-smaller representable \Float. - #quo:: Returns the quotient from dividing +self+ by the given value. - #round:: Returns +self+ rounded to the nearest value, to a given precision. - #to_i (aliased as #to_int):: Returns +self+ truncated to an Integer. - #to_s (aliased as #inspect):: Returns a string containing the place-value representation of +self+ in the given radix. - #truncate:: Returns +self+ truncated to a given precision. ;T;#0;$@0-;.F;/o;0;1T;2i;3i;Bi;%@;&I" Float;F;'@&o; ;IC;[_o;4;5F;6;;;;&I"!BigDecimal.interpret_loosely;F;7[[I"str;T0;[[@i ;T;:interpret_loosely;0;[;{;IC; " ;T;[;![;"@;#0;$@o2;%@m2;9I"static VALUE BigDecimal_s_interpret_loosely(VALUE klass, VALUE str) { char const *c_str = StringValueCStr(str); Real *vp = VpNewRbClass(0, c_str, klass, false, true); if (!vp) return Qnil; else return VpCheckGetValue(vp); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal.mode;F;7[[@90;[[@i^;T;;*;0;[;{;IC; "Returns an integer representing the mode settings for exception handling and rounding. These modes control exception handling: - \BigDecimal::EXCEPTION_NaN. - \BigDecimal::EXCEPTION_INFINITY. - \BigDecimal::EXCEPTION_UNDERFLOW. - \BigDecimal::EXCEPTION_OVERFLOW. - \BigDecimal::EXCEPTION_ZERODIVIDE. - \BigDecimal::EXCEPTION_ALL. Values for +setting+ for exception handling: - +true+: sets the given +mode+ to +true+. - +false+: sets the given +mode+ to +false+. - +nil+: does not modify the mode settings. You can use method BigDecimal.save_exception_mode to temporarily change, and then automatically restore, exception modes. For clarity, some examples below begin by setting all exception modes to +false+. This mode controls the way rounding is to be performed: - \BigDecimal::ROUND_MODE You can use method BigDecimal.save_rounding_mode to temporarily change, and then automatically restore, the rounding mode. NaNs Mode \BigDecimal::EXCEPTION_NaN controls behavior when a \BigDecimal NaN is created. Settings: - +false+ (default): Returns BigDecimal('NaN'). - +true+: Raises FloatDomainError. Examples: BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0 BigDecimal('NaN') # => NaN BigDecimal.mode(BigDecimal::EXCEPTION_NaN, true) # => 2 BigDecimal('NaN') # Raises FloatDomainError Infinities Mode \BigDecimal::EXCEPTION_INFINITY controls behavior when a \BigDecimal Infinity or -Infinity is created. Settings: - +false+ (default): Returns BigDecimal('Infinity') or BigDecimal('-Infinity'). - +true+: Raises FloatDomainError. Examples: BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0 BigDecimal('Infinity') # => Infinity BigDecimal('-Infinity') # => -Infinity BigDecimal.mode(BigDecimal::EXCEPTION_INFINITY, true) # => 1 BigDecimal('Infinity') # Raises FloatDomainError BigDecimal('-Infinity') # Raises FloatDomainError Underflow Mode \BigDecimal::EXCEPTION_UNDERFLOW controls behavior when a \BigDecimal underflow occurs. Settings: - +false+ (default): Returns BigDecimal('0') or BigDecimal('-Infinity'). - +true+: Raises FloatDomainError. Examples: BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0 def flow_under x = BigDecimal('0.1') 100.times { x *= x } end flow_under # => 100 BigDecimal.mode(BigDecimal::EXCEPTION_UNDERFLOW, true) # => 4 flow_under # Raises FloatDomainError Overflow Mode \BigDecimal::EXCEPTION_OVERFLOW controls behavior when a \BigDecimal overflow occurs. Settings: - +false+ (default): Returns BigDecimal('Infinity') or BigDecimal('-Infinity'). - +true+: Raises FloatDomainError. Examples: BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0 def flow_over x = BigDecimal('10') 100.times { x *= x } end flow_over # => 100 BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, true) # => 1 flow_over # Raises FloatDomainError Zero Division Mode \BigDecimal::EXCEPTION_ZERODIVIDE controls behavior when a zero-division occurs. Settings: - +false+ (default): Returns BigDecimal('Infinity') or BigDecimal('-Infinity'). - +true+: Raises FloatDomainError. Examples: BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0 one = BigDecimal('1') zero = BigDecimal('0') one / zero # => Infinity BigDecimal.mode(BigDecimal::EXCEPTION_ZERODIVIDE, true) # => 16 one / zero # Raises FloatDomainError All Exceptions Mode \BigDecimal::EXCEPTION_ALL controls all of the above: BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0 BigDecimal.mode(BigDecimal::EXCEPTION_ALL, true) # => 23 Rounding Mode \BigDecimal::ROUND_MODE controls the way rounding is to be performed; its +setting+ values are: - +ROUND_UP+: Round away from zero. Aliased as +:up+. - +ROUND_DOWN+: Round toward zero. Aliased as +:down+ and +:truncate+. - +ROUND_HALF_UP+: Round toward the nearest neighbor; if the neighbors are equidistant, round away from zero. Aliased as +:half_up+ and +:default+. - +ROUND_HALF_DOWN+: Round toward the nearest neighbor; if the neighbors are equidistant, round toward zero. Aliased as +:half_down+. - +ROUND_HALF_EVEN+ (Banker's rounding): Round toward the nearest neighbor; if the neighbors are equidistant, round toward the even neighbor. Aliased as +:half_even+ and +:banker+. - +ROUND_CEILING+: Round toward positive infinity. Aliased as +:ceiling+ and +:ceil+. - +ROUND_FLOOR+: Round toward negative infinity. Aliased as +:floor:+. ;T;[o;= ;>I" overload;F;?0;;*;@0;:I"mode(mode, setting = nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@}2;![;"I"@return [Integer];T;#0;$@}2;.F;Bi;C0;7[[I" mode;T0[I" setting;TI"nil;T;$@}2;![;"I"Returns an integer representing the mode settings for exception handling and rounding. These modes control exception handling: - \BigDecimal::EXCEPTION_NaN. - \BigDecimal::EXCEPTION_INFINITY. - \BigDecimal::EXCEPTION_UNDERFLOW. - \BigDecimal::EXCEPTION_OVERFLOW. - \BigDecimal::EXCEPTION_ZERODIVIDE. - \BigDecimal::EXCEPTION_ALL. Values for +setting+ for exception handling: - +true+: sets the given +mode+ to +true+. - +false+: sets the given +mode+ to +false+. - +nil+: does not modify the mode settings. You can use method BigDecimal.save_exception_mode to temporarily change, and then automatically restore, exception modes. For clarity, some examples below begin by setting all exception modes to +false+. This mode controls the way rounding is to be performed: - \BigDecimal::ROUND_MODE You can use method BigDecimal.save_rounding_mode to temporarily change, and then automatically restore, the rounding mode. NaNs Mode \BigDecimal::EXCEPTION_NaN controls behavior when a \BigDecimal NaN is created. Settings: - +false+ (default): Returns BigDecimal('NaN'). - +true+: Raises FloatDomainError. Examples: BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0 BigDecimal('NaN') # => NaN BigDecimal.mode(BigDecimal::EXCEPTION_NaN, true) # => 2 BigDecimal('NaN') # Raises FloatDomainError Infinities Mode \BigDecimal::EXCEPTION_INFINITY controls behavior when a \BigDecimal Infinity or -Infinity is created. Settings: - +false+ (default): Returns BigDecimal('Infinity') or BigDecimal('-Infinity'). - +true+: Raises FloatDomainError. Examples: BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0 BigDecimal('Infinity') # => Infinity BigDecimal('-Infinity') # => -Infinity BigDecimal.mode(BigDecimal::EXCEPTION_INFINITY, true) # => 1 BigDecimal('Infinity') # Raises FloatDomainError BigDecimal('-Infinity') # Raises FloatDomainError Underflow Mode \BigDecimal::EXCEPTION_UNDERFLOW controls behavior when a \BigDecimal underflow occurs. Settings: - +false+ (default): Returns BigDecimal('0') or BigDecimal('-Infinity'). - +true+: Raises FloatDomainError. Examples: BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0 def flow_under x = BigDecimal('0.1') 100.times { x *= x } end flow_under # => 100 BigDecimal.mode(BigDecimal::EXCEPTION_UNDERFLOW, true) # => 4 flow_under # Raises FloatDomainError Overflow Mode \BigDecimal::EXCEPTION_OVERFLOW controls behavior when a \BigDecimal overflow occurs. Settings: - +false+ (default): Returns BigDecimal('Infinity') or BigDecimal('-Infinity'). - +true+: Raises FloatDomainError. Examples: BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0 def flow_over x = BigDecimal('10') 100.times { x *= x } end flow_over # => 100 BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, true) # => 1 flow_over # Raises FloatDomainError Zero Division Mode \BigDecimal::EXCEPTION_ZERODIVIDE controls behavior when a zero-division occurs. Settings: - +false+ (default): Returns BigDecimal('Infinity') or BigDecimal('-Infinity'). - +true+: Raises FloatDomainError. Examples: BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0 one = BigDecimal('1') zero = BigDecimal('0') one / zero # => Infinity BigDecimal.mode(BigDecimal::EXCEPTION_ZERODIVIDE, true) # => 16 one / zero # Raises FloatDomainError All Exceptions Mode \BigDecimal::EXCEPTION_ALL controls all of the above: BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0 BigDecimal.mode(BigDecimal::EXCEPTION_ALL, true) # => 23 Rounding Mode \BigDecimal::ROUND_MODE controls the way rounding is to be performed; its +setting+ values are: - +ROUND_UP+: Round away from zero. Aliased as +:up+. - +ROUND_DOWN+: Round toward zero. Aliased as +:down+ and +:truncate+. - +ROUND_HALF_UP+: Round toward the nearest neighbor; if the neighbors are equidistant, round away from zero. Aliased as +:half_up+ and +:default+. - +ROUND_HALF_DOWN+: Round toward the nearest neighbor; if the neighbors are equidistant, round toward zero. Aliased as +:half_down+. - +ROUND_HALF_EVEN+ (Banker's rounding): Round toward the nearest neighbor; if the neighbors are equidistant, round toward the even neighbor. Aliased as +:half_even+ and +:banker+. - +ROUND_CEILING+: Round toward positive infinity. Aliased as +:ceiling+ and +:ceil+. - +ROUND_FLOOR+: Round toward negative infinity. Aliased as +:floor:+. @overload mode(mode, setting = nil) @return [Integer];T;#0;$@}2;.F;/o;0;1T;2i;3i];%@m2;9I"static VALUE BigDecimal_mode(int argc, VALUE *argv, VALUE self) { VALUE which; VALUE val; unsigned long f,fo; rb_scan_args(argc, argv, "11", &which, &val); f = (unsigned long)NUM2INT(which); if (f & VP_EXCEPTION_ALL) { /* Exception mode setting */ fo = VpGetException(); if (val == Qnil) return INT2FIX(fo); if (val != Qfalse && val!=Qtrue) { rb_raise(rb_eArgError, "second argument must be true or false"); return Qnil; /* Not reached */ } if (f & VP_EXCEPTION_INFINITY) { VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_INFINITY) : (fo & (~VP_EXCEPTION_INFINITY)))); } fo = VpGetException(); if (f & VP_EXCEPTION_NaN) { VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_NaN) : (fo & (~VP_EXCEPTION_NaN)))); } fo = VpGetException(); if (f & VP_EXCEPTION_UNDERFLOW) { VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_UNDERFLOW) : (fo & (~VP_EXCEPTION_UNDERFLOW)))); } fo = VpGetException(); if(f & VP_EXCEPTION_ZERODIVIDE) { VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_ZERODIVIDE) : (fo & (~VP_EXCEPTION_ZERODIVIDE)))); } fo = VpGetException(); return INT2FIX(fo); } if (VP_ROUND_MODE == f) { /* Rounding mode setting */ unsigned short sw; fo = VpGetRoundMode(); if (NIL_P(val)) return INT2FIX(fo); sw = check_rounding_mode(val); fo = VpSetRoundMode(sw); return INT2FIX(fo); } rb_raise(rb_eTypeError, "first argument for BigDecimal.mode invalid"); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal.limit;F;7[[@90;[[@i;T;;J;0;[;{;IC; "BigDecimal.limit(digits) Limit the number of significant digits in newly created BigDecimal numbers to the specified value. Rounding is performed as necessary, as specified by BigDecimal.mode. A limit of 0, the default, means no upper limit. The limit specified by this method takes less priority over any limit specified to instance methods such as ceil, floor, truncate, or round. ;T;[;![;"I"BigDecimal.limit(digits) Limit the number of significant digits in newly created BigDecimal numbers to the specified value. Rounding is performed as necessary, as specified by BigDecimal.mode. A limit of 0, the default, means no upper limit. The limit specified by this method takes less priority over any limit specified to instance methods such as ceil, floor, truncate, or round. ;T;#0;$@2;.F;/o;0;1T;2i ;3i;%@m2;9I"pstatic VALUE BigDecimal_limit(int argc, VALUE *argv, VALUE self) { VALUE nFig; VALUE nCur = SIZET2NUM(VpGetPrecLimit()); if (rb_scan_args(argc, argv, "01", &nFig) == 1) { int nf; if (NIL_P(nFig)) return nCur; nf = NUM2INT(nFig); if (nf < 0) { rb_raise(rb_eArgError, "argument must be positive"); } VpSetPrecLimit(nf); } return nCur; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal.double_fig;F;7[;[[@i ;T;:double_fig;0;[;{;IC; "Returns the number of digits a Float object is allowed to have; the result is system-dependent: BigDecimal.double_fig # => 16 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"double_fig;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@2;![;"I"@return [Integer];T;#0;$@2;.F;Bi;C0;7[;$@2;![;"I" Returns the number of digits a Float object is allowed to have; the result is system-dependent: BigDecimal.double_fig # => 16 @overload double_fig @return [Integer];T;#0;$@2;.F;/o;0;1T;2i;3i ;%@m2;9I"Wstatic VALUE BigDecimal_double_fig(VALUE self) { return INT2FIX(VpDblFig()); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal._load;F;7[[I"str;T0;[[@iN;T;;;0;[;{;IC; "QInternal method used to provide marshalling support. See the Marshal module. ;T;[;![;"I"RInternal method used to provide marshalling support. See the Marshal module. ;T;#0;$@2;.F;/o;0;1T;2iK;3iL;%@m2;9I"static VALUE BigDecimal_load(VALUE self, VALUE str) { ENTER(2); Real *pv; unsigned char *pch; unsigned char ch; unsigned long m=0; pch = (unsigned char *)StringValueCStr(str); /* First get max prec */ while((*pch) != (unsigned char)'\0' && (ch = *pch++) != (unsigned char)':') { if(!ISDIGIT(ch)) { rb_raise(rb_eTypeError, "load failed: invalid character in the marshaled string"); } m = m*10 + (unsigned long)(ch-'0'); } if (m > VpBaseFig()) m -= VpBaseFig(); GUARD_OBJ(pv, VpNewRbClass(m, (char *)pch, self, true, true)); m /= VpBaseFig(); if (m && pv->MaxPrec > m) { pv->MaxPrec = m+1; } return VpCheckGetValue(pv); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#BigDecimal.save_exception_mode;F;7[;[[@i@;T;:save_exception_mode;0;[;{;IC; "Execute the provided block, but preserve the exception mode BigDecimal.save_exception_mode do BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false) BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false) BigDecimal(BigDecimal('Infinity')) BigDecimal(BigDecimal('-Infinity')) BigDecimal(BigDecimal('NaN')) end For use with the BigDecimal::EXCEPTION_* See BigDecimal.mode ;T;[o;= ;>I" overload;F;?0;;;@0;:I"save_exception_mode;T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@2;![;"I"@yield [];T;#0;$@2;.F;Bi;C0;7[;$@2;![;"I"Execute the provided block, but preserve the exception mode BigDecimal.save_exception_mode do BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false) BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false) BigDecimal(BigDecimal('Infinity')) BigDecimal(BigDecimal('-Infinity')) BigDecimal(BigDecimal('NaN')) end For use with the BigDecimal::EXCEPTION_* See BigDecimal.mode @overload save_exception_mode @yield [];T;#0;$@2;.F;/o;0;1T;2i.;3i?;%@m2;9I"static VALUE BigDecimal_save_exception_mode(VALUE self) { unsigned short const exception_mode = VpGetException(); int state; VALUE ret = rb_protect(rb_yield, Qnil, &state); VpSetException(exception_mode); if (state) rb_jump_tag(state); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""BigDecimal.save_rounding_mode;F;7[;[[@iY;T;:save_rounding_mode;0;[;{;IC; " Execute the provided block, but preserve the rounding mode BigDecimal.save_rounding_mode do BigDecimal.mode(BigDecimal::ROUND_MODE, :up) puts BigDecimal.mode(BigDecimal::ROUND_MODE) end For use with the BigDecimal::ROUND_* See BigDecimal.mode ;T;[o;= ;>I" overload;F;?0;;;@0;:I"save_rounding_mode;T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@2;![;"I"@yield [];T;#0;$@2;.F;Bi;C0;7[;$@2;![;"I"4Execute the provided block, but preserve the rounding mode BigDecimal.save_rounding_mode do BigDecimal.mode(BigDecimal::ROUND_MODE, :up) puts BigDecimal.mode(BigDecimal::ROUND_MODE) end For use with the BigDecimal::ROUND_* See BigDecimal.mode @overload save_rounding_mode @yield [];T;#0;$@2;.F;/o;0;1T;2iK;3iX;%@m2;9I"static VALUE BigDecimal_save_rounding_mode(VALUE self) { unsigned short const round_mode = VpGetRoundMode(); int state; VALUE ret = rb_protect(rb_yield, Qnil, &state); VpSetRoundMode(round_mode); if (state) rb_jump_tag(state); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal.save_limit;F;7[;[[@ir;T;:save_limit;0;[;{;IC; "Execute the provided block, but preserve the precision limit BigDecimal.limit(100) puts BigDecimal.limit BigDecimal.save_limit do BigDecimal.limit(200) puts BigDecimal.limit end puts BigDecimal.limit ;T;[o;= ;>I" overload;F;?0;;;@0;:I"save_limit;T;IC; ";T;[o;A ;>I" yield;F;?I"[];T;0;@0;$@ 3;![;"I"@yield [];T;#0;$@ 3;.F;Bi;C0;7[;$@ 3;![;"I"Execute the provided block, but preserve the precision limit BigDecimal.limit(100) puts BigDecimal.limit BigDecimal.save_limit do BigDecimal.limit(200) puts BigDecimal.limit end puts BigDecimal.limit @overload save_limit @yield [];T;#0;$@ 3;.F;/o;0;1T;2id;3iq;%@m2;9I"static VALUE BigDecimal_save_limit(VALUE self) { size_t const limit = VpGetPrecLimit(); int state; VALUE ret = rb_protect(rb_yield, Qnil, &state); VpSetPrecLimit(limit); if (state) rb_jump_tag(state); return ret; };T;:I"static VALUE;T;;To;u;[[@i|;F;;;;w;;;[;{;IC; "&The version of bigdecimal library ;T;[;![;"I"'The version of bigdecimal library ;T;#0;$@#3;.F;/o;0;1T;2iy;3iz;%@m2;&I"BigDecimal::VERSION;F;xI")rb_str_new2(RUBY_BIGDECIMAL_VERSION);To;u;[[@i;F;: BASE;;w;;;[;{;IC; "Base value used in internal calculations. On a 32 bit system, BASE is 10000, indicating that calculation is done in groups of 4 digits. (If it were larger, BASE**2 wouldn't fit in 32 bits, so you couldn't guarantee that two groups could always be multiplied together without overflow.) ;T;[;![;"I"Base value used in internal calculations. On a 32 bit system, BASE is 10000, indicating that calculation is done in groups of 4 digits. (If it were larger, BASE**2 wouldn't fit in 32 bits, so you couldn't guarantee that two groups could always be multiplied together without overflow.) ;T;#0;$@/3;.F;/o;0;1T;2i~;3i;%@m2;&I"BigDecimal::BASE;F;xI"'INT2FIX((SIGNED_VALUE)VpBaseVal());To;u;[[@i;F;:EXCEPTION_ALL;;w;;;[;{;IC; "tDetermines whether overflow, underflow or zero divide result in an exception being thrown. See BigDecimal.mode. ;T;[;![;"I"uDetermines whether overflow, underflow or zero divide result in an exception being thrown. See BigDecimal.mode. ;T;#0;$@;3;.F;/o;0;1T;2i;3i;%@m2;&I"BigDecimal::EXCEPTION_ALL;F;xI" 0xff;To;u;[[@i;F;:EXCEPTION_NaN;;w;;;[;{;IC; "iDetermines what happens when the result of a computation is not a number (NaN). See BigDecimal.mode. ;T;[;![;"I"jDetermines what happens when the result of a computation is not a number (NaN). See BigDecimal.mode. ;T;#0;$@G3;.F;/o;0;1T;2i;3i;%@m2;&I"BigDecimal::EXCEPTION_NaN;F;xI" 0x02;To;u;[[@i;F;:EXCEPTION_INFINITY;;w;;;[;{;IC; "`Determines what happens when the result of a computation is infinity. See BigDecimal.mode. ;T;[;![;"I"aDetermines what happens when the result of a computation is infinity. See BigDecimal.mode. ;T;#0;$@S3;.F;/o;0;1T;2i;3i;%@m2;&I"#BigDecimal::EXCEPTION_INFINITY;F;xI" 0x01;To;u;[[@i;F;:EXCEPTION_UNDERFLOW;;w;;;[;{;IC; "Determines what happens when the result of a computation is an underflow (a result too small to be represented). See BigDecimal.mode. ;T;[;![;"I"Determines what happens when the result of a computation is an underflow (a result too small to be represented). See BigDecimal.mode. ;T;#0;$@_3;.F;/o;0;1T;2i;3i;%@m2;&I"$BigDecimal::EXCEPTION_UNDERFLOW;F;xI" 0x04;To;u;[[@i;F;:EXCEPTION_OVERFLOW;;w;;;[;{;IC; "Determines what happens when the result of a computation is an overflow (a result too large to be represented). See BigDecimal.mode. ;T;[;![;"I"Determines what happens when the result of a computation is an overflow (a result too large to be represented). See BigDecimal.mode. ;T;#0;$@k3;.F;/o;0;1T;2i;3i;%@m2;&I"#BigDecimal::EXCEPTION_OVERFLOW;F;xI" 0x01;To;u;[[@i;F;:EXCEPTION_ZERODIVIDE;;w;;;[;{;IC; "WDetermines what happens when a division by zero is performed. See BigDecimal.mode. ;T;[;![;"I"XDetermines what happens when a division by zero is performed. See BigDecimal.mode. ;T;#0;$@w3;.F;/o;0;1T;2i;3i;%@m2;&I"%BigDecimal::EXCEPTION_ZERODIVIDE;F;xI" 0x10;To;u;[[@i;F;:ROUND_MODE;;w;;;[;{;IC; "Determines what happens when a result must be rounded in order to fit in the appropriate number of significant digits. See BigDecimal.mode. ;T;[;![;"I"Determines what happens when a result must be rounded in order to fit in the appropriate number of significant digits. See BigDecimal.mode. ;T;#0;$@3;.F;/o;0;1T;2i;3i;%@m2;&I"BigDecimal::ROUND_MODE;F;xI" 0x100;To;u;[[@i;F;: ROUND_UP;;w;;;[;{;IC; "QIndicates that values should be rounded away from zero. See BigDecimal.mode. ;T;[;![;"I"RIndicates that values should be rounded away from zero. See BigDecimal.mode. ;T;#0;$@3;.F;/o;0;1T;2i;3i;%@m2;&I"BigDecimal::ROUND_UP;F;xI"1;To;u;[[@i;F;:ROUND_DOWN;;w;;;[;{;IC; "OIndicates that values should be rounded towards zero. See BigDecimal.mode. ;T;[;![;"I"PIndicates that values should be rounded towards zero. See BigDecimal.mode. ;T;#0;$@3;.F;/o;0;1T;2i;3i;%@m2;&I"BigDecimal::ROUND_DOWN;F;xI"2;To;u;[[@i;F;:ROUND_HALF_UP;;w;;;[;{;IC; "_Indicates that digits >= 5 should be rounded up, others rounded down. See BigDecimal.mode. ;T;[;![;"I"_Indicates that digits >= 5 should be rounded up, others rounded down. See BigDecimal.mode.;T;#0;$@3;.F;/o;0;1T;2i;3i;%@m2;&I"BigDecimal::ROUND_HALF_UP;F;xI"3;To;u;[[@i;F;:ROUND_HALF_DOWN;;w;;;[;{;IC; "_Indicates that digits >= 6 should be rounded up, others rounded down. See BigDecimal.mode. ;T;[;![;"I"`Indicates that digits >= 6 should be rounded up, others rounded down. See BigDecimal.mode. ;T;#0;$@3;.F;/o;0;1T;2i;3i;%@m2;&I" BigDecimal::ROUND_HALF_DOWN;F;xI"4;To;u;[[@i;F;:ROUND_CEILING;;w;;;[;{;IC; "2Round towards +Infinity. See BigDecimal.mode. ;T;[;![;"I"2Round towards +Infinity. See BigDecimal.mode.;T;#0;$@3;.F;/o;0;1T;2i;3i;%@m2;&I"BigDecimal::ROUND_CEILING;F;xI"5;To;u;[[@i;F;:ROUND_FLOOR;;w;;;[;{;IC; "2Round towards -Infinity. See BigDecimal.mode. ;T;[;![;"I"2Round towards -Infinity. See BigDecimal.mode.;T;#0;$@3;.F;/o;0;1T;2i;3i;%@m2;&I"BigDecimal::ROUND_FLOOR;F;xI"6;To;u;[[@i;F;:ROUND_HALF_EVEN;;w;;;[;{;IC; ":Round towards the even neighbor. See BigDecimal.mode. ;T;[;![;"I":Round towards the even neighbor. See BigDecimal.mode.;T;#0;$@3;.F;/o;0;1T;2i;3i;%@m2;&I" BigDecimal::ROUND_HALF_EVEN;F;xI"7;To;u;[[@i;F;: SIGN_NaN;;w;;;[;{;IC; "AIndicates that a value is not a number. See BigDecimal.sign. ;T;[;![;"I"AIndicates that a value is not a number. See BigDecimal.sign.;T;#0;$@3;.F;/o;0;1T;2i;3i;%@m2;&I"BigDecimal::SIGN_NaN;F;xI"0;To;u;[[@i;F;:SIGN_POSITIVE_ZERO;;w;;;[;{;IC; "7Indicates that a value is +0. See BigDecimal.sign. ;T;[;![;"I"7Indicates that a value is +0. See BigDecimal.sign.;T;#0;$@3;.F;/o;0;1T;2i;3i;%@m2;&I"#BigDecimal::SIGN_POSITIVE_ZERO;F;xI"1;To;u;[[@i;F;:SIGN_NEGATIVE_ZERO;;w;;;[;{;IC; "7Indicates that a value is -0. See BigDecimal.sign. ;T;[;![;"I"7Indicates that a value is -0. See BigDecimal.sign.;T;#0;$@3;.F;/o;0;1T;2i;3i;%@m2;&I"#BigDecimal::SIGN_NEGATIVE_ZERO;F;xI"-1;To;u;[[@i;F;:SIGN_POSITIVE_FINITE;;w;;;[;{;IC; "HIndicates that a value is positive and finite. See BigDecimal.sign. ;T;[;![;"I"HIndicates that a value is positive and finite. See BigDecimal.sign.;T;#0;$@4;.F;/o;0;1T;2i;3i;%@m2;&I"%BigDecimal::SIGN_POSITIVE_FINITE;F;xI"2;To;u;[[@i;F;:SIGN_NEGATIVE_FINITE;;w;;;[;{;IC; "HIndicates that a value is negative and finite. See BigDecimal.sign. ;T;[;![;"I"HIndicates that a value is negative and finite. See BigDecimal.sign.;T;#0;$@4;.F;/o;0;1T;2i;3i;%@m2;&I"%BigDecimal::SIGN_NEGATIVE_FINITE;F;xI"-2;To;u;[[@i;F;:SIGN_POSITIVE_INFINITE;;w;;;[;{;IC; "JIndicates that a value is positive and infinite. See BigDecimal.sign. ;T;[;![;"I"JIndicates that a value is positive and infinite. See BigDecimal.sign.;T;#0;$@4;.F;/o;0;1T;2i;3i;%@m2;&I"'BigDecimal::SIGN_POSITIVE_INFINITE;F;xI"3;To;u;[[@i;F;:SIGN_NEGATIVE_INFINITE;;w;;;[;{;IC; "JIndicates that a value is negative and infinite. See BigDecimal.sign. ;T;[;![;"I"JIndicates that a value is negative and infinite. See BigDecimal.sign.;T;#0;$@+4;.F;/o;0;1T;2i;3i;%@m2;&I"'BigDecimal::SIGN_NEGATIVE_INFINITE;F;xI"-3;To;u;[[@i;F;;;;w;;;[;{;IC; "Special value constants ;T;[;![;"I"Special value constants;T;#0;$@74;.F;/o;0;1T;2i;3i;%@m2;&I"BigDecimal::INFINITY;F;xI"!BIGDECIMAL_POSITIVE_INFINITY;To;u;[[@i;F;;;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@C4;%@m2;&I"BigDecimal::NAN;F;xI"BIGDECIMAL_NAN;To;4;5F;6;;;;&I"BigDecimal#precs;F;7[;[[@i;T;: precs;0;[;{;IC; "hReturns an Array of two Integer values that represent platform-dependent internal storage properties. This method is deprecated and will be removed in the future. Instead, use BigDecimal#n_significant_digits for obtaining the number of significant digits in scientific notation, and BigDecimal#precision for obtaining the number of digits in decimal notation. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" precs;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@M4;![;"I"@return [Array];T;#0;$@M4;.F;Bi;C0;7[;$@M4;![;"I"Returns an Array of two Integer values that represent platform-dependent internal storage properties. This method is deprecated and will be removed in the future. Instead, use BigDecimal#n_significant_digits for obtaining the number of significant digits in scientific notation, and BigDecimal#precision for obtaining the number of digits in decimal notation. @overload precs @return [Array];T;#0;$@M4;.F;/o;0;1T;2i;3i;%@m2;9I"static VALUE BigDecimal_prec(VALUE self) { ENTER(1); Real *p; VALUE obj; rb_category_warn(RB_WARN_CATEGORY_DEPRECATED, "BigDecimal#precs is deprecated and will be removed in the future; " "use BigDecimal#precision instead."); GUARD_OBJ(p, GetVpValue(self, 1)); obj = rb_assoc_new(SIZET2NUM(p->Prec*VpBaseFig()), SIZET2NUM(p->MaxPrec*VpBaseFig())); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#precision;F;7[;[[@i;T;:precision;0;[;{;IC; "Returns the number of decimal digits in +self+: BigDecimal("0").precision # => 0 BigDecimal("1").precision # => 1 BigDecimal("1.1").precision # => 2 BigDecimal("3.1415").precision # => 5 BigDecimal("-1e20").precision # => 21 BigDecimal("1e-20").precision # => 20 BigDecimal("Infinity").precision # => 0 BigDecimal("-Infinity").precision # => 0 BigDecimal("NaN").precision # => 0 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"precision;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@h4;![;"I"@return [Integer];T;#0;$@h4;.F;Bi;C0;7[;$@h4;![;"I"Returns the number of decimal digits in +self+: BigDecimal("0").precision # => 0 BigDecimal("1").precision # => 1 BigDecimal("1.1").precision # => 2 BigDecimal("3.1415").precision # => 5 BigDecimal("-1e20").precision # => 21 BigDecimal("1e-20").precision # => 20 BigDecimal("Infinity").precision # => 0 BigDecimal("-Infinity").precision # => 0 BigDecimal("NaN").precision # => 0 @overload precision @return [Integer];T;#0;$@h4;.F;/o;0;1T;2i;3i;%@m2;9I"static VALUE BigDecimal_precision(VALUE self) { ssize_t precision; BigDecimal_count_precision_and_scale(self, &precision, NULL); return SSIZET2NUM(precision); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#scale;F;7[;[[@i;T;: scale;0;[;{;IC; "Returns the number of decimal digits following the decimal digits in +self+. BigDecimal("0").scale # => 0 BigDecimal("1").scale # => 1 BigDecimal("1.1").scale # => 1 BigDecimal("3.1415").scale # => 4 BigDecimal("-1e20").precision # => 0 BigDecimal("1e-20").precision # => 20 BigDecimal("Infinity").scale # => 0 BigDecimal("-Infinity").scale # => 0 BigDecimal("NaN").scale # => 0 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" scale;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@4;![;"I"@return [Integer];T;#0;$@4;.F;Bi;C0;7[;$@4;![;"I"Returns the number of decimal digits following the decimal digits in +self+. BigDecimal("0").scale # => 0 BigDecimal("1").scale # => 1 BigDecimal("1.1").scale # => 1 BigDecimal("3.1415").scale # => 4 BigDecimal("-1e20").precision # => 0 BigDecimal("1e-20").precision # => 20 BigDecimal("Infinity").scale # => 0 BigDecimal("-Infinity").scale # => 0 BigDecimal("NaN").scale # => 0 @overload scale @return [Integer];T;#0;$@4;.F;/o;0;1T;2i;3i;%@m2;9I"static VALUE BigDecimal_scale(VALUE self) { ssize_t scale; BigDecimal_count_precision_and_scale(self, NULL, &scale); return SSIZET2NUM(scale); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#precision_scale;F;7[;[[@i;T;:precision_scale;0;[;{;IC; "Returns a 2-length array; the first item is the result of BigDecimal#precision and the second one is of BigDecimal#scale. See BigDecimal#precision. See BigDecimal#scale. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"precision_scale;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@4;![;"I"@return [Array];T;#0;$@4;.F;Bi;C0;7[;$@4;![;"I"Returns a 2-length array; the first item is the result of BigDecimal#precision and the second one is of BigDecimal#scale. See BigDecimal#precision. See BigDecimal#scale. @overload precision_scale @return [Array];T;#0;$@4;.F;/o;0;1T;2i;3i;%@m2;9I"static VALUE BigDecimal_precision_scale(VALUE self) { ssize_t precision, scale; BigDecimal_count_precision_and_scale(self, &precision, &scale); return rb_assoc_new(SSIZET2NUM(precision), SSIZET2NUM(scale)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$BigDecimal#n_significant_digits;F;7[;[[@i;T;:n_significant_digits;0;[;{;IC; "Returns the number of decimal significant digits in +self+. BigDecimal("0").scale # => 0 BigDecimal("1").scale # => 1 BigDecimal("1.1").scale # => 2 BigDecimal("3.1415").scale # => 5 BigDecimal("-1e20").precision # => 1 BigDecimal("1e-20").precision # => 1 BigDecimal("Infinity").scale # => 0 BigDecimal("-Infinity").scale # => 0 BigDecimal("NaN").scale # => 0 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"n_significant_digits;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@4;![;"I"@return [Integer];T;#0;$@4;.F;Bi;C0;7[;$@4;![;"I"Returns the number of decimal significant digits in +self+. BigDecimal("0").scale # => 0 BigDecimal("1").scale # => 1 BigDecimal("1.1").scale # => 2 BigDecimal("3.1415").scale # => 5 BigDecimal("-1e20").precision # => 1 BigDecimal("1e-20").precision # => 1 BigDecimal("Infinity").scale # => 0 BigDecimal("-Infinity").scale # => 0 BigDecimal("NaN").scale # => 0 @overload n_significant_digits @return [Integer];T;#0;$@4;.F;/o;0;1T;2i;3i;%@m2;9I"static VALUE BigDecimal_n_significant_digits(VALUE self) { ENTER(1); Real *p; GUARD_OBJ(p, GetVpValue(self, 1)); if (VpIsZero(p) || !VpIsDef(p)) { return INT2FIX(0); } ssize_t n = p->Prec; /* The length of frac without trailing zeros. */ for (n = p->Prec; n > 0 && p->frac[n-1] == 0; --n); if (n == 0) return INT2FIX(0); DECDIG x; int nlz = BASE_FIG; for (x = p->frac[0]; x > 0; x /= 10) --nlz; int ntz = 0; for (x = p->frac[n-1]; x > 0 && x % 10 == 0; x /= 10) ++ntz; ssize_t n_significant_digits = BASE_FIG*n - nlz - ntz; return SSIZET2NUM(n_significant_digits); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#add;F;7[[I"b;T0[I"n;T0;[[@i);T;; ;0;[;{;IC; "Returns the \BigDecimal sum of +self+ and +value+ with a precision of +ndigits+ decimal digits. When +ndigits+ is less than the number of significant digits in the sum, the sum is rounded to that number of digits, according to the current rounding mode; see BigDecimal.mode. Examples: # Set the rounding mode. BigDecimal.mode(BigDecimal::ROUND_MODE, :half_up) b = BigDecimal('111111.111') b.add(1, 0) # => 0.111112111e6 b.add(1, 3) # => 0.111e6 b.add(1, 6) # => 0.111112e6 b.add(1, 15) # => 0.111112111e6 b.add(1.0, 15) # => 0.111112111e6 b.add(Rational(1, 1), 15) # => 0.111112111e6 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"add(value, ndigits);T;IC; ";T;[;![;"I";T;#0;$@4;.F;Bi;C0;7[[I" value;T0[I" ndigits;T0;$@4;![;"I"Returns the \BigDecimal sum of +self+ and +value+ with a precision of +ndigits+ decimal digits. When +ndigits+ is less than the number of significant digits in the sum, the sum is rounded to that number of digits, according to the current rounding mode; see BigDecimal.mode. Examples: # Set the rounding mode. BigDecimal.mode(BigDecimal::ROUND_MODE, :half_up) b = BigDecimal('111111.111') b.add(1, 0) # => 0.111112111e6 b.add(1, 3) # => 0.111e6 b.add(1, 6) # => 0.111112e6 b.add(1, 15) # => 0.111112111e6 b.add(1.0, 15) # => 0.111112111e6 b.add(Rational(1, 1), 15) # => 0.111112111e6 @overload add(value, ndigits);T;#0;$@4;.F;/o;0;1T;2i;3i%;%@m2;9I"static VALUE BigDecimal_add2(VALUE self, VALUE b, VALUE n) { ENTER(2); Real *cv; SIGNED_VALUE mx = GetPrecisionInt(n); if (mx == 0) return BigDecimal_add(self, b); else { size_t pl = VpSetPrecLimit(0); VALUE c = BigDecimal_add(self, b); VpSetPrecLimit(pl); GUARD_OBJ(cv, GetVpValue(c, 1)); VpLeftRound(cv, VpGetRoundMode(), mx); return VpCheckGetValue(cv); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#sub;F;7[[I"b;T0[I"n;T0;[[@iG;T;:sub;0;[;{;IC; " sub(value, digits) -> bigdecimal Subtract the specified value. e.g. c = a.sub(b,n) digits:: If specified and less than the number of significant digits of the result, the result is rounded to that number of digits, according to BigDecimal.mode. ;T;[;![;"I"sub(value, digits) -> bigdecimal Subtract the specified value. e.g. c = a.sub(b,n) digits:: If specified and less than the number of significant digits of the result, the result is rounded to that number of digits, according to BigDecimal.mode. ;T;#0;$@4;.F;/o;0;1T;2i:;3iF;%@m2;9I"static VALUE BigDecimal_sub2(VALUE self, VALUE b, VALUE n) { ENTER(2); Real *cv; SIGNED_VALUE mx = GetPrecisionInt(n); if (mx == 0) return BigDecimal_sub(self, b); else { size_t pl = VpSetPrecLimit(0); VALUE c = BigDecimal_sub(self, b); VpSetPrecLimit(pl); GUARD_OBJ(cv, GetVpValue(c, 1)); VpLeftRound(cv, VpGetRoundMode(), mx); return VpCheckGetValue(cv); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#mult;F;7[[I"b;T0[I"n;T0;[[@ir;T;: mult;0;[;{;IC; "Returns the \BigDecimal product of +self+ and +value+ with a precision of +ndigits+ decimal digits. When +ndigits+ is less than the number of significant digits in the sum, the sum is rounded to that number of digits, according to the current rounding mode; see BigDecimal.mode. Examples: # Set the rounding mode. BigDecimal.mode(BigDecimal::ROUND_MODE, :half_up) b = BigDecimal('555555.555') b.mult(3, 0) # => 0.1666666665e7 b.mult(3, 3) # => 0.167e7 b.mult(3, 6) # => 0.166667e7 b.mult(3, 15) # => 0.1666666665e7 b.mult(3.0, 0) # => 0.1666666665e7 b.mult(Rational(3, 1), 0) # => 0.1666666665e7 b.mult(Complex(3, 0), 0) # => (0.1666666665e7+0.0i) ;T;[o;= ;>I" overload;F;?0;;!;@0;:I"mult(other, ndigits);T;IC; ";T;[;![;"I";T;#0;$@5;.F;Bi;C0;7[[I" other;T0[I" ndigits;T0;$@5;![;"I"Returns the \BigDecimal product of +self+ and +value+ with a precision of +ndigits+ decimal digits. When +ndigits+ is less than the number of significant digits in the sum, the sum is rounded to that number of digits, according to the current rounding mode; see BigDecimal.mode. Examples: # Set the rounding mode. BigDecimal.mode(BigDecimal::ROUND_MODE, :half_up) b = BigDecimal('555555.555') b.mult(3, 0) # => 0.1666666665e7 b.mult(3, 3) # => 0.167e7 b.mult(3, 6) # => 0.166667e7 b.mult(3, 15) # => 0.1666666665e7 b.mult(3.0, 0) # => 0.1666666665e7 b.mult(Rational(3, 1), 0) # => 0.1666666665e7 b.mult(Complex(3, 0), 0) # => (0.1666666665e7+0.0i) @overload mult(other, ndigits);T;#0;$@5;.F;/o;0;1T;2iX;3in;%@m2;9I"static VALUE BigDecimal_mult2(VALUE self, VALUE b, VALUE n) { ENTER(2); Real *cv; SIGNED_VALUE mx = GetPrecisionInt(n); if (mx == 0) return BigDecimal_mult(self, b); else { size_t pl = VpSetPrecLimit(0); VALUE c = BigDecimal_mult(self, b); VpSetPrecLimit(pl); GUARD_OBJ(cv, GetVpValue(c, 1)); VpLeftRound(cv, VpGetRoundMode(), mx); return VpCheckGetValue(cv); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#div;F;7[[@90;[[@i;T;;;0;[;{;IC; "call-seq: div(value) -> integer div(value, digits) -> bigdecimal or integer Divide by the specified value. digits:: If specified and less than the number of significant digits of the result, the result is rounded to that number of digits, according to BigDecimal.mode. If digits is 0, the result is the same as for the / operator or #quo. If digits is not specified, the result is an integer, by analogy with Float#div; see also BigDecimal#divmod. See BigDecimal#/. See BigDecimal#quo. Examples: a = BigDecimal("4") b = BigDecimal("3") a.div(b, 3) # => 0.133e1 a.div(b, 0) # => 0.1333333333333333333e1 a / b # => 0.1333333333333333333e1 a.quo(b) # => 0.1333333333333333333e1 a.div(b) # => 1 ;T;[;![;"I" call-seq: div(value) -> integer div(value, digits) -> bigdecimal or integer Divide by the specified value. digits:: If specified and less than the number of significant digits of the result, the result is rounded to that number of digits, according to BigDecimal.mode. If digits is 0, the result is the same as for the / operator or #quo. If digits is not specified, the result is an integer, by analogy with Float#div; see also BigDecimal#divmod. See BigDecimal#/. See BigDecimal#quo. Examples: a = BigDecimal("4") b = BigDecimal("3") a.div(b, 3) # => 0.133e1 a.div(b, 0) # => 0.1333333333333333333e1 a / b # => 0.1333333333333333333e1 a.quo(b) # => 0.1333333333333333333e1 a.div(b) # => 1 ;T;#0;$@"5;.F;/o;0;1T;2i;3i;%@m2;9I"static VALUE BigDecimal_div3(int argc, VALUE *argv, VALUE self) { VALUE b,n; rb_scan_args(argc, argv, "11", &b, &n); return BigDecimal_div2(self, b, n); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#hash;F;7[;[[@i;T;;X;0;[;{;IC; "Returns the integer hash value for +self+. Two instances of \BigDecimal have the same hash value if and only if they have equal: - Sign. - Fractional part. - Exponent. ;T;[o;= ;>I" overload;F;?0;;X;@0;:I" hash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@15;![;"I"@return [Integer];T;#0;$@15;.F;Bi;C0;7[;$@15;![;"I"Returns the integer hash value for +self+. Two instances of \BigDecimal have the same hash value if and only if they have equal: - Sign. - Fractional part. - Exponent. @overload hash @return [Integer];T;#0;$@15;.F;/o;0;1T;2i ;3i;%@m2;9I"static VALUE BigDecimal_hash(VALUE self) { ENTER(1); Real *p; st_index_t hash; GUARD_OBJ(p, GetVpValue(self, 1)); hash = (st_index_t)p->sign; /* hash!=2: the case for 0(1),NaN(0) or +-Infinity(3) is sign itself */ if(hash == 2 || hash == (st_index_t)-2) { hash ^= rb_memhash(p->frac, sizeof(DECDIG)*p->Prec); hash += p->exponent; } return ST2FIX(hash); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#to_s;F;7[[@90;[[@i ;T;;G;0;[;{;IC; "xto_s(s) Converts the value to a string. The default format looks like 0.xxxxEnn. The optional parameter s consists of either an integer; or an optional '+' or ' ', followed by an optional number, followed by an optional 'E' or 'F'. If there is a '+' at the start of s, positive values are returned with a leading '+'. A space at the start of s returns positive values with a leading space. If s contains a number, a space is inserted after each group of that many fractional digits. If s ends with an 'E', engineering notation (0.xxxxEnn) is used. If s ends with an 'F', conventional floating point notation is used. Examples: BigDecimal('-123.45678901234567890').to_s('5F') #=> '-123.45678 90123 45678 9' BigDecimal('123.45678901234567890').to_s('+8F') #=> '+123.45678901 23456789' BigDecimal('123.45678901234567890').to_s(' F') #=> ' 123.4567890123456789' ;T;[;![;"I"zto_s(s) Converts the value to a string. The default format looks like 0.xxxxEnn. The optional parameter s consists of either an integer; or an optional '+' or ' ', followed by an optional number, followed by an optional 'E' or 'F'. If there is a '+' at the start of s, positive values are returned with a leading '+'. A space at the start of s returns positive values with a leading space. If s contains a number, a space is inserted after each group of that many fractional digits. If s ends with an 'E', engineering notation (0.xxxxEnn) is used. If s ends with an 'F', conventional floating point notation is used. Examples: BigDecimal('-123.45678901234567890').to_s('5F') #=> '-123.45678 90123 45678 9' BigDecimal('123.45678901234567890').to_s('+8F') #=> '+123.45678901 23456789' BigDecimal('123.45678901234567890').to_s(' F') #=> ' 123.4567890123456789' ;T;#0;$@L5;.F;/o;0;1T;2i ;3i ;%@m2;9I"Jstatic VALUE BigDecimal_to_s(int argc, VALUE *argv, VALUE self) { ENTER(5); int fmt = 0; /* 0: E format, 1: F format */ int fPlus = 0; /* 0: default, 1: set ' ' before digits, 2: set '+' before digits. */ Real *vp; volatile VALUE str; char *psz; char ch; size_t nc, mc = 0; SIGNED_VALUE m; VALUE f; GUARD_OBJ(vp, GetVpValue(self, 1)); if (rb_scan_args(argc, argv, "01", &f) == 1) { if (RB_TYPE_P(f, T_STRING)) { psz = StringValueCStr(f); if (*psz == ' ') { fPlus = 1; psz++; } else if (*psz == '+') { fPlus = 2; psz++; } while ((ch = *psz++) != 0) { if (ISSPACE(ch)) { continue; } if (!ISDIGIT(ch)) { if (ch == 'F' || ch == 'f') { fmt = 1; /* F format */ } break; } mc = mc*10 + ch - '0'; } } else { m = NUM2INT(f); if (m <= 0) { rb_raise(rb_eArgError, "argument must be positive"); } mc = (size_t)m; } } if (fmt) { nc = VpNumOfChars(vp, "F"); } else { nc = VpNumOfChars(vp, "E"); } if (mc > 0) { nc += (nc + mc - 1) / mc + 1; } str = rb_usascii_str_new(0, nc); psz = RSTRING_PTR(str); if (fmt) { VpToFString(vp, psz, mc, fPlus); } else { VpToString (vp, psz, mc, fPlus); } rb_str_resize(str, strlen(psz)); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#to_i;F;7[;[[@i;T;;;0;[;{;IC; "eReturns the value as an Integer. If the BigDecimal is infinity or NaN, raises FloatDomainError. ;T;[;![;"I"fReturns the value as an Integer. If the BigDecimal is infinity or NaN, raises FloatDomainError. ;T;#0;$@[5;.F;/o;0;1T;2i;3i;%@m2;9I" static VALUE BigDecimal_to_i(VALUE self) { ENTER(5); ssize_t e, nf; Real *p; GUARD_OBJ(p, GetVpValue(self, 1)); BigDecimal_check_num(p); e = VpExponent10(p); if (e <= 0) return INT2FIX(0); nf = VpBaseFig(); if (e <= nf) { return LONG2NUM((long)(VpGetSign(p) * (DECDIG_DBL_SIGNED)p->frac[0])); } else { VALUE a = BigDecimal_split(self); VALUE digits = RARRAY_AREF(a, 1); VALUE numerator = rb_funcall(digits, rb_intern("to_i"), 0); VALUE ret; ssize_t dpower = e - (ssize_t)RSTRING_LEN(digits); if (BIGDECIMAL_NEGATIVE_P(p)) { numerator = rb_funcall(numerator, '*', 1, INT2FIX(-1)); } if (dpower < 0) { ret = rb_funcall(numerator, rb_intern("div"), 1, rb_funcall(INT2FIX(10), rb_intern("**"), 1, INT2FIX(-dpower))); } else { ret = rb_funcall(numerator, '*', 1, rb_funcall(INT2FIX(10), rb_intern("**"), 1, INT2FIX(dpower))); } if (RB_TYPE_P(ret, T_FLOAT)) { rb_raise(rb_eFloatDomainError, "Infinity"); } return ret; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#to_int;F;7[;[[@i;T;;;0;[;{;IC; "eReturns the value as an Integer. If the BigDecimal is infinity or NaN, raises FloatDomainError. ;T;[;![;"@e5;#0;$@i5;.F;/o;0;1T;2i;3i;%@m2;9I" static VALUE BigDecimal_to_i(VALUE self) { ENTER(5); ssize_t e, nf; Real *p; GUARD_OBJ(p, GetVpValue(self, 1)); BigDecimal_check_num(p); e = VpExponent10(p); if (e <= 0) return INT2FIX(0); nf = VpBaseFig(); if (e <= nf) { return LONG2NUM((long)(VpGetSign(p) * (DECDIG_DBL_SIGNED)p->frac[0])); } else { VALUE a = BigDecimal_split(self); VALUE digits = RARRAY_AREF(a, 1); VALUE numerator = rb_funcall(digits, rb_intern("to_i"), 0); VALUE ret; ssize_t dpower = e - (ssize_t)RSTRING_LEN(digits); if (BIGDECIMAL_NEGATIVE_P(p)) { numerator = rb_funcall(numerator, '*', 1, INT2FIX(-1)); } if (dpower < 0) { ret = rb_funcall(numerator, rb_intern("div"), 1, rb_funcall(INT2FIX(10), rb_intern("**"), 1, INT2FIX(-dpower))); } else { ret = rb_funcall(numerator, '*', 1, rb_funcall(INT2FIX(10), rb_intern("**"), 1, INT2FIX(dpower))); } if (RB_TYPE_P(ret, T_FLOAT)) { rb_raise(rb_eFloatDomainError, "Infinity"); } return ret; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#to_r;F;7[;[[@i};T;;;0;[;{;IC; ")Converts a BigDecimal to a Rational. ;T;[;![;"I"*Converts a BigDecimal to a Rational. ;T;#0;$@v5;.F;/o;0;1T;2i{;3i|;%@m2;9I"$static VALUE BigDecimal_to_r(VALUE self) { Real *p; ssize_t sign, power, denomi_power; VALUE a, digits, numerator; p = GetVpValue(self, 1); BigDecimal_check_num(p); sign = VpGetSign(p); power = VpExponent10(p); a = BigDecimal_split(self); digits = RARRAY_AREF(a, 1); denomi_power = power - RSTRING_LEN(digits); numerator = rb_funcall(digits, rb_intern("to_i"), 0); if (sign < 0) { numerator = rb_funcall(numerator, '*', 1, INT2FIX(-1)); } if (denomi_power < 0) { return rb_Rational(numerator, rb_funcall(INT2FIX(10), rb_intern("**"), 1, INT2FIX(-denomi_power))); } else { return rb_Rational1(rb_funcall(numerator, '*', 1, rb_funcall(INT2FIX(10), rb_intern("**"), 1, INT2FIX(denomi_power)))); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#split;F;7[;[[@i* ;T;;j;0;[;{;IC; "gSplits a BigDecimal number into four parts, returned as an array of values. The first value represents the sign of the BigDecimal, and is -1 or 1, or 0 if the BigDecimal is Not a Number. The second value is a string representing the significant digits of the BigDecimal, with no leading zeros. The third value is the base used for arithmetic (currently always 10) as an Integer. The fourth value is an Integer exponent. If the BigDecimal can be represented as 0.xxxxxx*10**n, then xxxxxx is the string of significant digits with no leading zeros, and n is the exponent. From these values, you can translate a BigDecimal to a float as follows: sign, significant_digits, base, exponent = a.split f = sign * "0.#{significant_digits}".to_f * (base ** exponent) (Note that the to_f method is provided as a more convenient way to translate a BigDecimal to a Float.) ;T;[;![;"I"hSplits a BigDecimal number into four parts, returned as an array of values. The first value represents the sign of the BigDecimal, and is -1 or 1, or 0 if the BigDecimal is Not a Number. The second value is a string representing the significant digits of the BigDecimal, with no leading zeros. The third value is the base used for arithmetic (currently always 10) as an Integer. The fourth value is an Integer exponent. If the BigDecimal can be represented as 0.xxxxxx*10**n, then xxxxxx is the string of significant digits with no leading zeros, and n is the exponent. From these values, you can translate a BigDecimal to a float as follows: sign, significant_digits, base, exponent = a.split f = sign * "0.#{significant_digits}".to_f * (base ** exponent) (Note that the to_f method is provided as a more convenient way to translate a BigDecimal to a Float.) ;T;#0;$@5;.F;/o;0;1T;2i ;3i) ;%@m2;9I"static VALUE BigDecimal_split(VALUE self) { ENTER(5); Real *vp; VALUE obj,str; ssize_t e, s; char *psz1; GUARD_OBJ(vp, GetVpValue(self, 1)); str = rb_str_new(0, VpNumOfChars(vp, "E")); psz1 = RSTRING_PTR(str); VpSzMantissa(vp, psz1); s = 1; if(psz1[0] == '-') { size_t len = strlen(psz1 + 1); memmove(psz1, psz1 + 1, len); psz1[len] = '\0'; s = -1; } if (psz1[0] == 'N') s = 0; /* NaN */ e = VpExponent10(vp); obj = rb_ary_new2(4); rb_ary_push(obj, INT2FIX(s)); rb_ary_push(obj, str); rb_str_resize(str, strlen(psz1)); rb_ary_push(obj, INT2FIX(10)); rb_ary_push(obj, SSIZET2NUM(e)); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#+;F;7[[I"r;T0;[[@i;T;;;0;[;{;IC; "Returns the \BigDecimal sum of +self+ and +value+: b = BigDecimal('111111.111') # => 0.111111111e6 b + 2 # => 0.111113111e6 b + 2.0 # => 0.111113111e6 b + Rational(2, 1) # => 0.111113111e6 b + Complex(2, 0) # => (0.111113111e6+0i) See the {Note About Precision}[BigDecimal.html#class-BigDecimal-label-A+Note+About+Precision]. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" +(value);T;IC; ";T;[;![;"I";T;#0;$@5;.F;Bi;C0;7[[I" value;T0;$@5;![;"I"Returns the \BigDecimal sum of +self+ and +value+: b = BigDecimal('111111.111') # => 0.111111111e6 b + 2 # => 0.111113111e6 b + 2.0 # => 0.111113111e6 b + Rational(2, 1) # => 0.111113111e6 b + Complex(2, 0) # => (0.111113111e6+0i) See the {Note About Precision}[BigDecimal.html#class-BigDecimal-label-A+Note+About+Precision]. @overload +(value);T;#0;$@5;.F;/o;0;1T;2i;3i;%@m2;9I"Mstatic VALUE BigDecimal_add(VALUE self, VALUE r) { ENTER(5); Real *c, *a, *b; size_t mx; GUARD_OBJ(a, GetVpValue(self, 1)); if (RB_TYPE_P(r, T_FLOAT)) { b = GetVpValueWithPrec(r, 0, 1); } else if (RB_TYPE_P(r, T_RATIONAL)) { b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); } else { b = GetVpValue(r, 0); } if (!b) return DoSomeOne(self,r,'+'); SAVE(b); if (VpIsNaN(b)) return b->obj; if (VpIsNaN(a)) return a->obj; mx = GetAddSubPrec(a, b); if (mx == (size_t)-1L) { GUARD_OBJ(c, VpCreateRbObject(VpBaseFig() + 1, "0", true)); VpAddSub(c, a, b, 1); } else { GUARD_OBJ(c, VpCreateRbObject(mx * (VpBaseFig() + 1), "0", true)); if(!mx) { VpSetInf(c, VpGetSign(a)); } else { VpAddSub(c, a, b, 1); } } return VpCheckGetValue(c); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#-;F;7[[I"r;T0;[[@i;T;;;0;[;{;IC; "Returns the \BigDecimal difference of +self+ and +value+: b = BigDecimal('333333.333') # => 0.333333333e6 b - 2 # => 0.333331333e6 b - 2.0 # => 0.333331333e6 b - Rational(2, 1) # => 0.333331333e6 b - Complex(2, 0) # => (0.333331333e6+0i) See the {Note About Precision}[BigDecimal.html#class-BigDecimal-label-A+Note+About+Precision]. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" -(value);T;IC; ";T;[;![;"I";T;#0;$@5;.F;Bi;C0;7[[I" value;T0;$@5;![;"I"Returns the \BigDecimal difference of +self+ and +value+: b = BigDecimal('333333.333') # => 0.333333333e6 b - 2 # => 0.333331333e6 b - 2.0 # => 0.333331333e6 b - Rational(2, 1) # => 0.333331333e6 b - Complex(2, 0) # => (0.333331333e6+0i) See the {Note About Precision}[BigDecimal.html#class-BigDecimal-label-A+Note+About+Precision]. @overload -(value);T;#0;$@5;.F;/o;0;1T;2i;3i;%@m2;9I"Jstatic VALUE BigDecimal_sub(VALUE self, VALUE r) { ENTER(5); Real *c, *a, *b; size_t mx; GUARD_OBJ(a, GetVpValue(self,1)); if (RB_TYPE_P(r, T_FLOAT)) { b = GetVpValueWithPrec(r, 0, 1); } else if (RB_TYPE_P(r, T_RATIONAL)) { b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); } else { b = GetVpValue(r,0); } if (!b) return DoSomeOne(self,r,'-'); SAVE(b); if (VpIsNaN(b)) return b->obj; if (VpIsNaN(a)) return a->obj; mx = GetAddSubPrec(a,b); if (mx == (size_t)-1L) { GUARD_OBJ(c, VpCreateRbObject(VpBaseFig() + 1, "0", true)); VpAddSub(c, a, b, -1); } else { GUARD_OBJ(c,VpCreateRbObject(mx *(VpBaseFig() + 1), "0", true)); if (!mx) { VpSetInf(c,VpGetSign(a)); } else { VpAddSub(c, a, b, -1); } } return VpCheckGetValue(c); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#+@;F;7[;[[@i;T;;;0;[;{;IC; "RReturns +self+: +BigDecimal(5) # => 0.5e1 +BigDecimal(-5) # => -0.5e1 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"+big_decimal;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@5;![;"I"@return [self];T;#0;$@5;.F;Bi;C0;7[;$@5;![;"I"}Returns +self+: +BigDecimal(5) # => 0.5e1 +BigDecimal(-5) # => -0.5e1 @overload +big_decimal @return [self];T;#0;$@5;.F;/o;0;1T;2i;3i;%@m2;9I"Cstatic VALUE BigDecimal_uplus(VALUE self) { return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#-@;F;7[;[[@i*;T;;;0;[;{;IC; "wReturns the \BigDecimal negation of self: b0 = BigDecimal('1.5') b1 = -b0 # => -0.15e1 b2 = -b1 # => 0.15e1 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" -self;T;IC; ";T;[;![;"I";T;#0;$@5;.F;Bi;C0;7[;$@5;![;"I"Returns the \BigDecimal negation of self: b0 = BigDecimal('1.5') b1 = -b0 # => -0.15e1 b2 = -b1 # => 0.15e1 @overload -self;T;#0;$@5;.F;/o;0;1T;2i;3i&;%@m2;9I"static VALUE BigDecimal_neg(VALUE self) { ENTER(5); Real *c, *a; GUARD_OBJ(a, GetVpValue(self, 1)); GUARD_OBJ(c, VpCreateRbObject(a->Prec *(VpBaseFig() + 1), "0", true)); VpAsgn(c, a, -1); return VpCheckGetValue(c); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#*;F;7[[I"r;T0;[[@i5;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@5;%@m2;9I":static VALUE BigDecimal_mult(VALUE self, VALUE r) { ENTER(5); Real *c, *a, *b; size_t mx; GUARD_OBJ(a, GetVpValue(self, 1)); if (RB_TYPE_P(r, T_FLOAT)) { b = GetVpValueWithPrec(r, 0, 1); } else if (RB_TYPE_P(r, T_RATIONAL)) { b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); } else { b = GetVpValue(r,0); } if (!b) return DoSomeOne(self, r, '*'); SAVE(b); mx = a->Prec + b->Prec; GUARD_OBJ(c, VpCreateRbObject(mx *(VpBaseFig() + 1), "0", true)); VpMult(c, a, b); return VpCheckGetValue(c); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#/;F;7[;[[@i;T;;;0;[;{;IC; ")For c = self/r: with round operation ;T;[;![;"I")For c = self/r: with round operation;T;#0;$@6;.F;/o;0;1T;2i;3i;%@m2;9I"pstatic VALUE BigDecimal_div(VALUE self, VALUE r) /* For c = self/r: with round operation */ { ENTER(5); Real *c=NULL, *res=NULL, *div = NULL; r = BigDecimal_divide(self, r, &c, &res, &div); if (!NIL_P(r)) return r; /* coerced by other */ SAVE(c); SAVE(res); SAVE(div); /* a/b = c + r/b */ /* c xxxxx r 00000yyyyy ==> (y/b)*BASE >= HALF_BASE */ /* Round */ if (VpHasVal(div)) { /* frac[0] must be zero for NaN,INF,Zero */ VpInternalRound(c, 0, c->frac[c->Prec-1], (DECDIG)(VpBaseVal() * (DECDIG_DBL)res->frac[0] / div->frac[0])); } return VpCheckGetValue(c); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#quo;F;7[[@90;[[@i;T;;;0;[;{;IC; "zDivide by the specified value. digits:: If specified and less than the number of significant digits of the result, the result is rounded to the given number of digits, according to the rounding mode indicated by BigDecimal.mode. If digits is 0 or omitted, the result is the same as for the / operator. See BigDecimal#/. See BigDecimal#div. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"quo(value);T;IC; ";T;[;![;"I";T;#0;$@6;.F;Bi;C0;7[[I" value;T0;$@6o;= ;>I" overload;F;?0;;;@0;:I"quo(value, digits);T;IC; ";T;[;![;"I";T;#0;$@6;.F;Bi;C0;7[[I" value;T0[I" digits;T0;$@6;![;"I"Divide by the specified value. digits:: If specified and less than the number of significant digits of the result, the result is rounded to the given number of digits, according to the rounding mode indicated by BigDecimal.mode. If digits is 0 or omitted, the result is the same as for the / operator. See BigDecimal#/. See BigDecimal#div. @overload quo(value) @overload quo(value, digits);T;#0;$@6;.F;/o;0;1T;2i;3i;%@m2;9I"static VALUE BigDecimal_quo(int argc, VALUE *argv, VALUE self) { VALUE value, digits, result; SIGNED_VALUE n = -1; argc = rb_scan_args(argc, argv, "11", &value, &digits); if (argc > 1) { n = GetPrecisionInt(digits); } if (n > 0) { result = BigDecimal_div2(self, value, digits); } else { result = BigDecimal_div(self, value); } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#%;F;7[;[[@iB;T;;;0;[;{;IC; "&%: a%b = a - (a.to_f/b).floor * b ;T;[;![;"I"&%: a%b = a - (a.to_f/b).floor * b;T;#0;$@86;.F;/o;0;1T;2iC;3iC;%@m2;9I"(static VALUE BigDecimal_mod(VALUE self, VALUE r) /* %: a%b = a - (a.to_f/b).floor * b */ { ENTER(3); Real *div = NULL, *mod = NULL; if (BigDecimal_DoDivmod(self, r, &div, &mod)) { SAVE(div); SAVE(mod); return VpCheckGetValue(mod); } return DoSomeOne(self, r, '%'); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#modulo;F;7[;[[@iB;T;;;0;[;{;IC; "&%: a%b = a - (a.to_f/b).floor * b ;T;[;![;"@B6;#0;$@F6;.F;/o;0;1T;2iC;3iC;%@m2;9I"(static VALUE BigDecimal_mod(VALUE self, VALUE r) /* %: a%b = a - (a.to_f/b).floor * b */ { ENTER(3); Real *div = NULL, *mod = NULL; if (BigDecimal_DoDivmod(self, r, &div, &mod)) { SAVE(div); SAVE(mod); return VpCheckGetValue(mod); } return DoSomeOne(self, r, '%'); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#remainder;F;7[;[[@i;T;;;0;[;{;IC; "remainder ;T;[;![;"I"remainder;T;#0;$@S6;.F;/o;0;1T;2i;3i;%@m2;9I"static VALUE BigDecimal_remainder(VALUE self, VALUE r) /* remainder */ { VALUE f; Real *d, *rv = 0; f = BigDecimal_divremain(self, r, &d, &rv); if (!NIL_P(f)) return f; return VpCheckGetValue(rv); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#divmod;F;7[[I"r;T0;[[@i;T;;;0;[;{;IC; "divmod(value) Divides by the specified value, and returns the quotient and modulus as BigDecimal numbers. The quotient is rounded towards negative infinity. For example: require 'bigdecimal' a = BigDecimal("42") b = BigDecimal("9") q, m = a.divmod(b) c = q * b + m a == c #=> true The quotient q is (a/b).floor, and the modulus is the amount that must be added to q * b to get a. ;T;[;![;"I"divmod(value) Divides by the specified value, and returns the quotient and modulus as BigDecimal numbers. The quotient is rounded towards negative infinity. For example: require 'bigdecimal' a = BigDecimal("42") b = BigDecimal("9") q, m = a.divmod(b) c = q * b + m a == c #=> true The quotient q is (a/b).floor, and the modulus is the amount that must be added to q * b to get a. ;T;#0;$@a6;.F;/o;0;1T;2i;3i;%@m2;9I"5static VALUE BigDecimal_divmod(VALUE self, VALUE r) { ENTER(5); Real *div = NULL, *mod = NULL; if (BigDecimal_DoDivmod(self, r, &div, &mod)) { SAVE(div); SAVE(mod); return rb_assoc_new(VpCheckGetValue(div), VpCheckGetValue(mod)); } return DoSomeOne(self,r,rb_intern("divmod")); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#clone;F;7[;[[@i ;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@q6;%@m2;9I"Astatic VALUE BigDecimal_clone(VALUE self) { return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#dup;F;7[;[[@i ;T;;[;0;[;{;IC; " ;T;[;![;"@;#0;$@}6;%@m2;9I"Astatic VALUE BigDecimal_clone(VALUE self) { return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#to_f;F;7[;[[@iN;T;;;0;[;{;IC; "Returns a new Float object having approximately the same value as the BigDecimal number. Normal accuracy limits and built-in errors of binary Float arithmetic apply. ;T;[;![;"I"Returns a new Float object having approximately the same value as the BigDecimal number. Normal accuracy limits and built-in errors of binary Float arithmetic apply. ;T;#0;$@6;.F;/o;0;1T;2iJ;3iM;%@m2;9I"'static VALUE BigDecimal_to_f(VALUE self) { ENTER(1); Real *p; double d; SIGNED_VALUE e; char *buf; volatile VALUE str; GUARD_OBJ(p, GetVpValue(self, 1)); if (VpVtoD(&d, &e, p) != 1) return rb_float_new(d); if (e > (SIGNED_VALUE)(DBL_MAX_10_EXP+BASE_FIG)) goto overflow; if (e < (SIGNED_VALUE)(DBL_MIN_10_EXP-BASE_FIG)) goto underflow; str = rb_str_new(0, VpNumOfChars(p, "E")); buf = RSTRING_PTR(str); VpToString(p, buf, 0, 0); errno = 0; d = strtod(buf, 0); if (errno == ERANGE) { if (d == 0.0) goto underflow; if (fabs(d) >= HUGE_VAL) goto overflow; } return rb_float_new(d); overflow: VpException(VP_EXCEPTION_OVERFLOW, "BigDecimal to Float conversion", 0); if (BIGDECIMAL_NEGATIVE_P(p)) return rb_float_new(VpGetDoubleNegInf()); else return rb_float_new(VpGetDoublePosInf()); underflow: VpException(VP_EXCEPTION_UNDERFLOW, "BigDecimal to Float conversion", 0); if (BIGDECIMAL_NEGATIVE_P(p)) return rb_float_new(-0.0); else return rb_float_new(0.0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#abs;F;7[;[[@i;T;;;0;[;{;IC; "{Returns the \BigDecimal absolute value of +self+: BigDecimal('5').abs # => 0.5e1 BigDecimal('-3').abs # => 0.3e1 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"abs;T;IC; ";T;[;![;"I";T;#0;$@6;.F;Bi;C0;7[;$@6;![;"I"Returns the \BigDecimal absolute value of +self+: BigDecimal('5').abs # => 0.5e1 BigDecimal('-3').abs # => 0.3e1 @overload abs;T;#0;$@6;.F;/o;0;1T;2i;3i;%@m2;9I"%static VALUE BigDecimal_abs(VALUE self) { ENTER(5); Real *c, *a; size_t mx; GUARD_OBJ(a, GetVpValue(self, 1)); mx = a->Prec *(VpBaseFig() + 1); GUARD_OBJ(c, VpCreateRbObject(mx, "0", true)); VpAsgn(c, a, 1); VpChangeSign(c, 1); return VpCheckGetValue(c); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#sqrt;F;7[[I" nFig;T0;[[@i;T;: sqrt;0;[;{;IC; "^sqrt(n) Returns the square root of the value. Result has at least n significant digits. ;T;[;![;"I"`sqrt(n) Returns the square root of the value. Result has at least n significant digits. ;T;#0;$@6;.F;/o;0;1T;2i;3i;%@m2;9I"lstatic VALUE BigDecimal_sqrt(VALUE self, VALUE nFig) { ENTER(5); Real *c, *a; size_t mx, n; GUARD_OBJ(a, GetVpValue(self, 1)); mx = a->Prec * (VpBaseFig() + 1); n = GetPrecisionInt(nFig) + VpDblFig() + BASE_FIG; if (mx <= n) mx = n; GUARD_OBJ(c, VpCreateRbObject(mx, "0", true)); VpSqrt(c, a); return VpCheckGetValue(c); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#fix;F;7[;[[@i;T;:fix;0;[;{;IC; "Prec *(VpBaseFig() + 1); GUARD_OBJ(c, VpCreateRbObject(mx, "0", true)); VpActiveRound(c, a, VP_ROUND_DOWN, 0); /* 0: round off */ return VpCheckGetValue(c); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#round;F;7[[@90;[[@i;T;;;0;[;{;IC; "+round(n, mode) Round to the nearest integer (by default), returning the result as a BigDecimal if n is specified, or as an Integer if it isn't. BigDecimal('3.14159').round #=> 3 BigDecimal('8.7').round #=> 9 BigDecimal('-9.9').round #=> -10 BigDecimal('3.14159').round(2).class.name #=> "BigDecimal" BigDecimal('3.14159').round.class.name #=> "Integer" If n is specified and positive, the fractional part of the result has no more than that many digits. If n is specified and negative, at least that many digits to the left of the decimal point will be 0 in the result, and return value will be an Integer. BigDecimal('3.14159').round(3) #=> 3.142 BigDecimal('13345.234').round(-2) #=> 13300 The value of the optional mode argument can be used to determine how rounding is performed; see BigDecimal.mode. ;T;[;![;"I"-round(n, mode) Round to the nearest integer (by default), returning the result as a BigDecimal if n is specified, or as an Integer if it isn't. BigDecimal('3.14159').round #=> 3 BigDecimal('8.7').round #=> 9 BigDecimal('-9.9').round #=> -10 BigDecimal('3.14159').round(2).class.name #=> "BigDecimal" BigDecimal('3.14159').round.class.name #=> "Integer" If n is specified and positive, the fractional part of the result has no more than that many digits. If n is specified and negative, at least that many digits to the left of the decimal point will be 0 in the result, and return value will be an Integer. BigDecimal('3.14159').round(3) #=> 3.142 BigDecimal('13345.234').round(-2) #=> 13300 The value of the optional mode argument can be used to determine how rounding is performed; see BigDecimal.mode. ;T;#0;$@6;.F;/o;0;1T;2i;3i;%@m2;9I"Istatic VALUE BigDecimal_round(int argc, VALUE *argv, VALUE self) { ENTER(5); Real *c, *a; int iLoc = 0; VALUE vLoc; VALUE vRound; int round_to_int = 0; size_t mx, pl; unsigned short sw = VpGetRoundMode(); switch (rb_scan_args(argc, argv, "02", &vLoc, &vRound)) { case 0: iLoc = 0; round_to_int = 1; break; case 1: if (RB_TYPE_P(vLoc, T_HASH)) { sw = check_rounding_mode_option(vLoc); } else { iLoc = NUM2INT(vLoc); if (iLoc < 1) round_to_int = 1; } break; case 2: iLoc = NUM2INT(vLoc); if (RB_TYPE_P(vRound, T_HASH)) { sw = check_rounding_mode_option(vRound); } else { sw = check_rounding_mode(vRound); } break; default: break; } pl = VpSetPrecLimit(0); GUARD_OBJ(a, GetVpValue(self, 1)); mx = a->Prec * (VpBaseFig() + 1); GUARD_OBJ(c, VpCreateRbObject(mx, "0", true)); VpSetPrecLimit(pl); VpActiveRound(c, a, sw, iLoc); if (round_to_int) { return BigDecimal_to_i(VpCheckGetValue(c)); } return VpCheckGetValue(c); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#frac;F;7[;[[@iB ;T;: frac;0;[;{;IC; "?Return the fractional part of the number, as a BigDecimal. ;T;[;![;"I"@Return the fractional part of the number, as a BigDecimal. ;T;#0;$@6;.F;/o;0;1T;2i@ ;3iA ;%@m2;9I" static VALUE BigDecimal_frac(VALUE self) { ENTER(5); Real *c, *a; size_t mx; GUARD_OBJ(a, GetVpValue(self, 1)); mx = a->Prec * (VpBaseFig() + 1); GUARD_OBJ(c, VpCreateRbObject(mx, "0", true)); VpFrac(c, a); return VpCheckGetValue(c); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#floor;F;7[[@90;[[@ia ;T;;;0;[;{;IC; "floor(n) Return the largest integer less than or equal to the value, as a BigDecimal. BigDecimal('3.14159').floor #=> 3 BigDecimal('-9.1').floor #=> -10 If n is specified and positive, the fractional part of the result has no more than that many digits. If n is specified and negative, at least that many digits to the left of the decimal point will be 0 in the result. BigDecimal('3.14159').floor(3) #=> 3.141 BigDecimal('13345.234').floor(-2) #=> 13300.0 ;T;[;![;"I"floor(n) Return the largest integer less than or equal to the value, as a BigDecimal. BigDecimal('3.14159').floor #=> 3 BigDecimal('-9.1').floor #=> -10 If n is specified and positive, the fractional part of the result has no more than that many digits. If n is specified and negative, at least that many digits to the left of the decimal point will be 0 in the result. BigDecimal('3.14159').floor(3) #=> 3.141 BigDecimal('13345.234').floor(-2) #=> 13300.0 ;T;#0;$@6;.F;/o;0;1T;2iP ;3i` ;%@m2;9I"static VALUE BigDecimal_floor(int argc, VALUE *argv, VALUE self) { ENTER(5); Real *c, *a; int iLoc; VALUE vLoc; size_t mx, pl = VpSetPrecLimit(0); if (rb_scan_args(argc, argv, "01", &vLoc)==0) { iLoc = 0; } else { iLoc = NUM2INT(vLoc); } GUARD_OBJ(a, GetVpValue(self, 1)); mx = a->Prec * (VpBaseFig() + 1); GUARD_OBJ(c, VpCreateRbObject(mx, "0", true)); VpSetPrecLimit(pl); VpActiveRound(c, a, VP_ROUND_FLOOR, iLoc); #ifdef BIGDECIMAL_DEBUG VPrint(stderr, "floor: c=%\n", c); #endif if (argc == 0) { return BigDecimal_to_i(VpCheckGetValue(c)); } return VpCheckGetValue(c); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#ceil;F;7[[@90;[[@i ;T;;;0;[;{;IC; "ceil(n) Return the smallest integer greater than or equal to the value, as a BigDecimal. BigDecimal('3.14159').ceil #=> 4 BigDecimal('-9.1').ceil #=> -9 If n is specified and positive, the fractional part of the result has no more than that many digits. If n is specified and negative, at least that many digits to the left of the decimal point will be 0 in the result. BigDecimal('3.14159').ceil(3) #=> 3.142 BigDecimal('13345.234').ceil(-2) #=> 13400.0 ;T;[;![;"I"ceil(n) Return the smallest integer greater than or equal to the value, as a BigDecimal. BigDecimal('3.14159').ceil #=> 4 BigDecimal('-9.1').ceil #=> -9 If n is specified and positive, the fractional part of the result has no more than that many digits. If n is specified and negative, at least that many digits to the left of the decimal point will be 0 in the result. BigDecimal('3.14159').ceil(3) #=> 3.142 BigDecimal('13345.234').ceil(-2) #=> 13400.0 ;T;#0;$@6;.F;/o;0;1T;2i ;3i ;%@m2;9I"Hstatic VALUE BigDecimal_ceil(int argc, VALUE *argv, VALUE self) { ENTER(5); Real *c, *a; int iLoc; VALUE vLoc; size_t mx, pl = VpSetPrecLimit(0); if (rb_scan_args(argc, argv, "01", &vLoc) == 0) { iLoc = 0; } else { iLoc = NUM2INT(vLoc); } GUARD_OBJ(a, GetVpValue(self, 1)); mx = a->Prec * (VpBaseFig() + 1); GUARD_OBJ(c, VpCreateRbObject(mx, "0", true)); VpSetPrecLimit(pl); VpActiveRound(c, a, VP_ROUND_CEIL, iLoc); if (argc == 0) { return BigDecimal_to_i(VpCheckGetValue(c)); } return VpCheckGetValue(c); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#power;F;7[[@90;[[@i ;T;: power;0;[;{;IC; "power(n) power(n, prec) Returns the value raised to the power of n. Note that n must be an Integer. Also available as the operator **. ;T;[;![;"I"power(n) power(n, prec) Returns the value raised to the power of n. Note that n must be an Integer. Also available as the operator **. ;T;#0;$@7;.F;/o;0;1T;2i ;3i ;%@m2;9I"static VALUE BigDecimal_power(int argc, VALUE*argv, VALUE self) { ENTER(5); VALUE vexp, prec; Real* exp = NULL; Real *x, *y; ssize_t mp, ma, n; SIGNED_VALUE int_exp; double d; rb_scan_args(argc, argv, "11", &vexp, &prec); GUARD_OBJ(x, GetVpValue(self, 1)); n = NIL_P(prec) ? (ssize_t)(x->Prec*VpBaseFig()) : NUM2SSIZET(prec); if (VpIsNaN(x)) { y = VpCreateRbObject(n, "0", true); RB_GC_GUARD(y->obj); VpSetNaN(y); return VpCheckGetValue(y); } retry: switch (TYPE(vexp)) { case T_FIXNUM: break; case T_BIGNUM: break; case T_FLOAT: d = RFLOAT_VALUE(vexp); if (d == round(d)) { if (FIXABLE(d)) { vexp = LONG2FIX((long)d); } else { vexp = rb_dbl2big(d); } goto retry; } if (NIL_P(prec)) { n += BIGDECIMAL_DOUBLE_FIGURES; } exp = GetVpValueWithPrec(vexp, 0, 1); break; case T_RATIONAL: if (is_zero(rb_rational_num(vexp))) { if (is_positive(vexp)) { vexp = INT2FIX(0); goto retry; } } else if (is_one(rb_rational_den(vexp))) { vexp = rb_rational_num(vexp); goto retry; } exp = GetVpValueWithPrec(vexp, n, 1); if (NIL_P(prec)) { n += n; } break; case T_DATA: if (is_kind_of_BigDecimal(vexp)) { VALUE zero = INT2FIX(0); VALUE rounded = BigDecimal_round(1, &zero, vexp); if (RTEST(BigDecimal_eq(vexp, rounded))) { vexp = BigDecimal_to_i(vexp); goto retry; } if (NIL_P(prec)) { GUARD_OBJ(y, GetVpValue(vexp, 1)); n += y->Prec*VpBaseFig(); } exp = DATA_PTR(vexp); break; } /* fall through */ default: rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected scalar Numeric)", RB_OBJ_CLASSNAME(vexp)); } if (VpIsZero(x)) { if (is_negative(vexp)) { y = VpCreateRbObject(n, "#0", true); RB_GC_GUARD(y->obj); if (BIGDECIMAL_NEGATIVE_P(x)) { if (is_integer(vexp)) { if (is_even(vexp)) { /* (-0) ** (-even_integer) -> Infinity */ VpSetPosInf(y); } else { /* (-0) ** (-odd_integer) -> -Infinity */ VpSetNegInf(y); } } else { /* (-0) ** (-non_integer) -> Infinity */ VpSetPosInf(y); } } else { /* (+0) ** (-num) -> Infinity */ VpSetPosInf(y); } return VpCheckGetValue(y); } else if (is_zero(vexp)) { return VpCheckGetValue(VpCreateRbObject(n, "1", true)); } else { return VpCheckGetValue(VpCreateRbObject(n, "0", true)); } } if (is_zero(vexp)) { return VpCheckGetValue(VpCreateRbObject(n, "1", true)); } else if (is_one(vexp)) { return self; } if (VpIsInf(x)) { if (is_negative(vexp)) { if (BIGDECIMAL_NEGATIVE_P(x)) { if (is_integer(vexp)) { if (is_even(vexp)) { /* (-Infinity) ** (-even_integer) -> +0 */ return VpCheckGetValue(VpCreateRbObject(n, "0", true)); } else { /* (-Infinity) ** (-odd_integer) -> -0 */ return VpCheckGetValue(VpCreateRbObject(n, "-0", true)); } } else { /* (-Infinity) ** (-non_integer) -> -0 */ return VpCheckGetValue(VpCreateRbObject(n, "-0", true)); } } else { return VpCheckGetValue(VpCreateRbObject(n, "0", true)); } } else { y = VpCreateRbObject(n, "0", true); if (BIGDECIMAL_NEGATIVE_P(x)) { if (is_integer(vexp)) { if (is_even(vexp)) { VpSetPosInf(y); } else { VpSetNegInf(y); } } else { /* TODO: support complex */ rb_raise(rb_eMathDomainError, "a non-integral exponent for a negative base"); } } else { VpSetPosInf(y); } return VpCheckGetValue(y); } } if (exp != NULL) { return bigdecimal_power_by_bigdecimal(x, exp, n); } else if (RB_TYPE_P(vexp, T_BIGNUM)) { VALUE abs_value = BigDecimal_abs(self); if (is_one(abs_value)) { return VpCheckGetValue(VpCreateRbObject(n, "1", true)); } else if (RTEST(rb_funcall(abs_value, '<', 1, INT2FIX(1)))) { if (is_negative(vexp)) { y = VpCreateRbObject(n, "0", true); if (is_even(vexp)) { VpSetInf(y, VpGetSign(x)); } else { VpSetInf(y, -VpGetSign(x)); } return VpCheckGetValue(y); } else if (BIGDECIMAL_NEGATIVE_P(x) && is_even(vexp)) { return VpCheckGetValue(VpCreateRbObject(n, "-0", true)); } else { return VpCheckGetValue(VpCreateRbObject(n, "0", true)); } } else { if (is_positive(vexp)) { y = VpCreateRbObject(n, "0", true); if (is_even(vexp)) { VpSetInf(y, VpGetSign(x)); } else { VpSetInf(y, -VpGetSign(x)); } return VpCheckGetValue(y); } else if (BIGDECIMAL_NEGATIVE_P(x) && is_even(vexp)) { return VpCheckGetValue(VpCreateRbObject(n, "-0", true)); } else { return VpCheckGetValue(VpCreateRbObject(n, "0", true)); } } } int_exp = FIX2LONG(vexp); ma = int_exp; if (ma < 0) ma = -ma; if (ma == 0) ma = 1; if (VpIsDef(x)) { mp = x->Prec * (VpBaseFig() + 1); GUARD_OBJ(y, VpCreateRbObject(mp * (ma + 1), "0", true)); } else { GUARD_OBJ(y, VpCreateRbObject(1, "0", true)); } VpPowerByInt(y, x, int_exp); if (!NIL_P(prec) && VpIsDef(y)) { VpMidRound(y, VpGetRoundMode(), n); } return VpCheckGetValue(y); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#**;F;7[[I"exp;T0;[[@i ;T;;;0;[;{;IC; "Returns the \BigDecimal value of +self+ raised to power +other+: b = BigDecimal('3.14') b ** 2 # => 0.98596e1 b ** 2.0 # => 0.98596e1 b ** Rational(2, 1) # => 0.98596e1 Related: BigDecimal#power. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"**(other);T;IC; ";T;[;![;"I";T;#0;$@7;.F;Bi;C0;7[[I" other;T0;$@7;![;"I"Returns the \BigDecimal value of +self+ raised to power +other+: b = BigDecimal('3.14') b ** 2 # => 0.98596e1 b ** 2.0 # => 0.98596e1 b ** Rational(2, 1) # => 0.98596e1 Related: BigDecimal#power. @overload **(other);T;#0;$@7;.F;/o;0;1T;2i ;3i ;%@m2;9I"lstatic VALUE BigDecimal_power_op(VALUE self, VALUE exp) { return BigDecimal_power(1, &exp, self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#<=>;F;7[[I"r;T0;[[@i;T;;Y;0;[;{;IC; "NThe comparison operator. a <=> b is 0 if a == b, 1 if a > b, -1 if a < b. ;T;[;![;"I"OThe comparison operator. a <=> b is 0 if a == b, 1 if a > b, -1 if a < b. ;T;#0;$@/7;.F;/o;0;1T;2i;3i;%@m2;9I"bstatic VALUE BigDecimal_comp(VALUE self, VALUE r) { return BigDecimalCmp(self, r, '*'); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#==;F;7[[I"r;T0;[[@i;T;;F;0;[;{;IC; "Tests for value equality; returns true if the values are equal. The == and === operators and the eql? method have the same implementation for BigDecimal. Values may be coerced to perform the comparison: BigDecimal('1.0') == 1.0 #=> true ;T;[;![;"I"Tests for value equality; returns true if the values are equal. The == and === operators and the eql? method have the same implementation for BigDecimal. Values may be coerced to perform the comparison: BigDecimal('1.0') == 1.0 #=> true ;T;#0;$@?7;.F;/o;0;1T;2i;3i;%@m2;9I"`static VALUE BigDecimal_eq(VALUE self, VALUE r) { return BigDecimalCmp(self, r, '='); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#===;F;7[[I"r;T0;[[@i;T;;S;0;[;{;IC; "Tests for value equality; returns true if the values are equal. The == and === operators and the eql? method have the same implementation for BigDecimal. Values may be coerced to perform the comparison: BigDecimal('1.0') == 1.0 #=> true ;T;[;![;"@K7;#0;$@O7;.F;/o;0;1T;2i;3i;%@m2;9I"`static VALUE BigDecimal_eq(VALUE self, VALUE r) { return BigDecimalCmp(self, r, '='); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#eql?;F;7[[I"r;T0;[[@i;T;;V;0;[;{;IC; "Tests for value equality; returns true if the values are equal. The == and === operators and the eql? method have the same implementation for BigDecimal. Values may be coerced to perform the comparison: BigDecimal('1.0') == 1.0 #=> true;T;[o;A ;>I" return;F;?@;0;@[@L;$@^7;![;"@K7;#0;$@^7;.F;/o;0;1T;2i;3i;Bi;%@m2;9I"`static VALUE BigDecimal_eq(VALUE self, VALUE r) { return BigDecimalCmp(self, r, '='); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#<;F;7[[I"r;T0;[[@i;T;;;0;[;{;IC; "&Returns +true+ if +self+ is less than +other+, +false+ otherwise: b = BigDecimal('1.5') # => 0.15e1 b < 2 # => true b < 2.0 # => true b < Rational(2, 1) # => true b < 1.5 # => false Raises an exception if the comparison cannot be made. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" <(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@p7;![;"I"@return [Boolean];T;#0;$@p7;.F;Bi;C0;7[[I" other;T0;$@p7;![;"I"PReturns +true+ if +self+ is less than +other+, +false+ otherwise: b = BigDecimal('1.5') # => 0.15e1 b < 2 # => true b < 2.0 # => true b < Rational(2, 1) # => true b < 1.5 # => false Raises an exception if the comparison cannot be made. @overload <(other) @return [Boolean];T;#0;$@p7;.F;/o;0;1T;2i;3i;%@m2;9I"`static VALUE BigDecimal_lt(VALUE self, VALUE r) { return BigDecimalCmp(self, r, '<'); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#<=;F;7[[I"r;T0;[[@i;T;;;0;[;{;IC; "TReturns +true+ if +self+ is less or equal to than +other+, +false+ otherwise: b = BigDecimal('1.5') # => 0.15e1 b <= 2 # => true b <= 2.0 # => true b <= Rational(2, 1) # => true b <= 1.5 # => true b < 1 # => false Raises an exception if the comparison cannot be made. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"<=(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@7;![;"I"@return [Boolean];T;#0;$@7;.F;Bi;C0;7[[I" other;T0;$@7;![;"I"Returns +true+ if +self+ is less or equal to than +other+, +false+ otherwise: b = BigDecimal('1.5') # => 0.15e1 b <= 2 # => true b <= 2.0 # => true b <= Rational(2, 1) # => true b <= 1.5 # => true b < 1 # => false Raises an exception if the comparison cannot be made. @overload <=(other) @return [Boolean];T;#0;$@7;.F;/o;0;1T;2i;3i;%@m2;9I"`static VALUE BigDecimal_le(VALUE self, VALUE r) { return BigDecimalCmp(self, r, 'L'); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#>;F;7[[I"r;T0;[[@i;T;;;0;[;{;IC; "Returns +true+ if +self+ is greater than +other+, +false+ otherwise: b = BigDecimal('1.5') b > 1 # => true b > 1.0 # => true b > Rational(1, 1) # => true b > 2 # => false Raises an exception if the comparison cannot be made. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" >(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@7;![;"I"@return [Boolean];T;#0;$@7;.F;Bi;C0;7[[I" other;T0;$@7;![;"I";Returns +true+ if +self+ is greater than +other+, +false+ otherwise: b = BigDecimal('1.5') b > 1 # => true b > 1.0 # => true b > Rational(1, 1) # => true b > 2 # => false Raises an exception if the comparison cannot be made. @overload >(other) @return [Boolean];T;#0;$@7;.F;/o;0;1T;2i;3i;%@m2;9I"`static VALUE BigDecimal_gt(VALUE self, VALUE r) { return BigDecimalCmp(self, r, '>'); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#>=;F;7[[I"r;T0;[[@i;T;;;0;[;{;IC; "AReturns +true+ if +self+ is greater than or equal to +other+, +false+ otherwise: b = BigDecimal('1.5') b >= 1 # => true b >= 1.0 # => true b >= Rational(1, 1) # => true b >= 1.5 # => true b > 2 # => false Raises an exception if the comparison cannot be made. ;T;[o;= ;>I" overload;F;?0;;;@0;:I">=(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@7;![;"I"@return [Boolean];T;#0;$@7;.F;Bi;C0;7[[I" other;T0;$@7;![;"I"lReturns +true+ if +self+ is greater than or equal to +other+, +false+ otherwise: b = BigDecimal('1.5') b >= 1 # => true b >= 1.0 # => true b >= Rational(1, 1) # => true b >= 1.5 # => true b > 2 # => false Raises an exception if the comparison cannot be made. @overload >=(other) @return [Boolean];T;#0;$@7;.F;/o;0;1T;2i ;3i;%@m2;9I"`static VALUE BigDecimal_ge(VALUE self, VALUE r) { return BigDecimalCmp(self, r, 'G'); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#zero?;F;7[;[[@i;T;;B;0;[;{;IC; "'Returns True if the value is zero.;T;[o;A ;>I" return;F;?@;0;@[@L;$@7;![;"I"'Returns True if the value is zero.;T;#0;$@7;.F;/o;0;1T;2i;3i;Bi;%@m2;9I"}static VALUE BigDecimal_zero(VALUE self) { Real *a = GetVpValue(self, 1); return VpIsZero(a) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#nonzero?;F;7[;[[@i;T;;;0;[;{;IC; ":Returns self if the value is non-zero, nil otherwise.;T;[o;A ;>I" return;F;?@;0;@[@L;$@7;![;"I":Returns self if the value is non-zero, nil otherwise.;T;#0;$@7;.F;/o;0;1T;2i;3i;Bi;%@m2;9I"}static VALUE BigDecimal_nonzero(VALUE self) { Real *a = GetVpValue(self, 1); return VpIsZero(a) ? Qnil : self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#coerce;F;7[[I" other;T0;[[@i;T;;;0;[;{;IC; "The coerce method provides support for Ruby type coercion. It is not enabled by default. This means that binary operations like + * / or - can often be performed on a BigDecimal and an object of another type, if the other object can be coerced into a BigDecimal value. e.g. a = BigDecimal("1.0") b = a / 2.0 #=> 0.5 Note that coercing a String to a BigDecimal is not supported by default; it requires a special compile-time option when building Ruby. ;T;[;![;"I"The coerce method provides support for Ruby type coercion. It is not enabled by default. This means that binary operations like + * / or - can often be performed on a BigDecimal and an object of another type, if the other object can be coerced into a BigDecimal value. e.g. a = BigDecimal("1.0") b = a / 2.0 #=> 0.5 Note that coercing a String to a BigDecimal is not supported by default; it requires a special compile-time option when building Ruby. ;T;#0;$@8;.F;/o;0;1T;2i;3i;%@m2;9I"static VALUE BigDecimal_coerce(VALUE self, VALUE other) { ENTER(2); VALUE obj; Real *b; if (RB_TYPE_P(other, T_FLOAT)) { GUARD_OBJ(b, GetVpValueWithPrec(other, 0, 1)); obj = rb_assoc_new(VpCheckGetValue(b), self); } else { if (RB_TYPE_P(other, T_RATIONAL)) { Real* pv = DATA_PTR(self); GUARD_OBJ(b, GetVpValueWithPrec(other, pv->Prec*VpBaseFig(), 1)); } else { GUARD_OBJ(b, GetVpValue(other, 1)); } obj = rb_assoc_new(b->obj, self); } return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#inspect;F;7[;[[@i[ ;T;;J;0;[;{;IC; "gReturns a string representation of self. BigDecimal("1234.5678").inspect #=> "0.12345678e4" ;T;[;![;"I"hReturns a string representation of self. BigDecimal("1234.5678").inspect #=> "0.12345678e4" ;T;#0;$@8;.F;/o;0;1T;2iV ;3iZ ;%@m2;9I"Gstatic VALUE BigDecimal_inspect(VALUE self) { ENTER(5); Real *vp; volatile VALUE str; size_t nc; GUARD_OBJ(vp, GetVpValue(self, 1)); nc = VpNumOfChars(vp, "E"); str = rb_str_new(0, nc); VpToString(vp, RSTRING_PTR(str), 0, 0); rb_str_resize(str, strlen(RSTRING_PTR(str))); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#exponent;F;7[;[[@iO ;T;: exponent;0;[;{;IC; "Returns the exponent of the BigDecimal number, as an Integer. If the number can be represented as 0.xxxxxx*10**n where xxxxxx is a string of digits with no leading zeros, then n is the exponent. ;T;[;![;"I"Returns the exponent of the BigDecimal number, as an Integer. If the number can be represented as 0.xxxxxx*10**n where xxxxxx is a string of digits with no leading zeros, then n is the exponent. ;T;#0;$@,8;.F;/o;0;1T;2iJ ;3iN ;%@m2;9I"}static VALUE BigDecimal_exponent(VALUE self) { ssize_t e = VpExponent10(GetVpValue(self, 1)); return SSIZET2NUM(e); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#sign;F;7[;[[@i';T;;7;0;[;{;IC; "'Returns the sign of the value. Returns a positive value if > 0, a negative value if < 0, and a zero if == 0. The specific value returned indicates the type and sign of the BigDecimal, as follows: BigDecimal::SIGN_NaN:: value is Not a Number BigDecimal::SIGN_POSITIVE_ZERO:: value is +0 BigDecimal::SIGN_NEGATIVE_ZERO:: value is -0 BigDecimal::SIGN_POSITIVE_INFINITE:: value is +Infinity BigDecimal::SIGN_NEGATIVE_INFINITE:: value is -Infinity BigDecimal::SIGN_POSITIVE_FINITE:: value is positive BigDecimal::SIGN_NEGATIVE_FINITE:: value is negative ;T;[;![;"I"(Returns the sign of the value. Returns a positive value if > 0, a negative value if < 0, and a zero if == 0. The specific value returned indicates the type and sign of the BigDecimal, as follows: BigDecimal::SIGN_NaN:: value is Not a Number BigDecimal::SIGN_POSITIVE_ZERO:: value is +0 BigDecimal::SIGN_NEGATIVE_ZERO:: value is -0 BigDecimal::SIGN_POSITIVE_INFINITE:: value is +Infinity BigDecimal::SIGN_NEGATIVE_INFINITE:: value is -Infinity BigDecimal::SIGN_POSITIVE_FINITE:: value is positive BigDecimal::SIGN_NEGATIVE_FINITE:: value is negative ;T;#0;$@:8;.F;/o;0;1T;2i;3i&;%@m2;9I"zstatic VALUE BigDecimal_sign(VALUE self) { /* sign */ int s = GetVpValue(self, 1)->sign; return INT2FIX(s); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#nan?;F;7[;[[@i;T;;;0;[;{;IC; "/Returns True if the value is Not a Number.;T;[o;A ;>I" return;F;?@;0;@[@L;$@H8;![;"I"/Returns True if the value is Not a Number.;T;#0;$@H8;.F;/o;0;1T;2i;3i;Bi;%@m2;9I"static VALUE BigDecimal_IsNaN(VALUE self) { Real *p = GetVpValue(self, 1); if (VpIsNaN(p)) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#infinite?;F;7[;[[@i;T;;;0;[;{;IC; "^Returns nil, -1, or +1 depending on whether the value is finite, -Infinity, or +Infinity.;T;[o;A ;>I" return;F;?@;0;@[@L;$@Y8;![;"I"_Returns nil, -1, or +1 depending on whether the value is finite, -Infinity, or +Infinity. ;T;#0;$@Y8;.F;/o;0;1T;2i;3i;Bi;%@m2;9I"static VALUE BigDecimal_IsInfinite(VALUE self) { Real *p = GetVpValue(self, 1); if (VpIsPosInf(p)) return INT2FIX(1); if (VpIsNegInf(p)) return INT2FIX(-1); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#finite?;F;7[;[[@i ;T;;;0;[;{;IC; "?Returns True if the value is finite (not NaN or infinite).;T;[o;A ;>I" return;F;?@;0;@[@L;$@j8;![;"I"?Returns True if the value is finite (not NaN or infinite).;T;#0;$@j8;.F;/o;0;1T;2i ;3i ;Bi;%@m2;9I"static VALUE BigDecimal_IsFinite(VALUE self) { Real *p = GetVpValue(self, 1); if (VpIsNaN(p)) return Qfalse; if (VpIsInf(p)) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#truncate;F;7[[@90;[[@i% ;T;;_;0;[;{;IC; "truncate(n) Truncate to the nearest integer (by default), returning the result as a BigDecimal. BigDecimal('3.14159').truncate #=> 3 BigDecimal('8.7').truncate #=> 8 BigDecimal('-9.9').truncate #=> -9 If n is specified and positive, the fractional part of the result has no more than that many digits. If n is specified and negative, at least that many digits to the left of the decimal point will be 0 in the result. BigDecimal('3.14159').truncate(3) #=> 3.141 BigDecimal('13345.234').truncate(-2) #=> 13300.0 ;T;[;![;"I"truncate(n) Truncate to the nearest integer (by default), returning the result as a BigDecimal. BigDecimal('3.14159').truncate #=> 3 BigDecimal('8.7').truncate #=> 8 BigDecimal('-9.9').truncate #=> -9 If n is specified and positive, the fractional part of the result has no more than that many digits. If n is specified and negative, at least that many digits to the left of the decimal point will be 0 in the result. BigDecimal('3.14159').truncate(3) #=> 3.141 BigDecimal('13345.234').truncate(-2) #=> 13300.0 ;T;#0;$@{8;.F;/o;0;1T;2i ;3i$ ;%@m2;9I"bstatic VALUE BigDecimal_truncate(int argc, VALUE *argv, VALUE self) { ENTER(5); Real *c, *a; int iLoc; VALUE vLoc; size_t mx, pl = VpSetPrecLimit(0); if (rb_scan_args(argc, argv, "01", &vLoc) == 0) { iLoc = 0; } else { iLoc = NUM2INT(vLoc); } GUARD_OBJ(a, GetVpValue(self, 1)); mx = a->Prec * (VpBaseFig() + 1); GUARD_OBJ(c, VpCreateRbObject(mx, "0", true)); VpSetPrecLimit(pl); VpActiveRound(c, a, VP_ROUND_DOWN, iLoc); /* 0: truncate */ if (argc == 0) { return BigDecimal_to_i(VpCheckGetValue(c)); } return VpCheckGetValue(c); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigDecimal#_dump;F;7[[@90;[[@i8;T;;;0;[;{;IC; "Returns a string representing the marshalling of +self+. See module Marshal. inf = BigDecimal('Infinity') # => Infinity dumped = inf._dump # => "9:Infinity" BigDecimal._load(dumped) # => Infinity ;T;[o;= ;>I" overload;F;?0;;;@0;:I" _dump;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@8;![;"I"@return [String];T;#0;$@8;.F;Bi;C0;7[;$@8;![;"I"Returns a string representing the marshalling of +self+. See module Marshal. inf = BigDecimal('Infinity') # => Infinity dumped = inf._dump # => "9:Infinity" BigDecimal._load(dumped) # => Infinity @overload _dump @return [String];T;#0;$@8;.F;/o;0;1T;2i,;3i6;%@m2;9I"static VALUE BigDecimal_dump(int argc, VALUE *argv, VALUE self) { ENTER(5); Real *vp; char *psz; VALUE dummy; volatile VALUE dump; rb_scan_args(argc, argv, "01", &dummy); GUARD_OBJ(vp,GetVpValue(self, 1)); dump = rb_str_new(0, VpNumOfChars(vp, "E")+50); psz = RSTRING_PTR(dump); sprintf(psz, "%"PRIuSIZE":", VpMaxPrec(vp)*VpBaseFig()); VpToString(vp, psz+strlen(psz), 0, 0); rb_str_resize(dump, strlen(psz)); return dump; };T;:I"static VALUE;T;;T; @m2; IC;[; @m2; IC;[; @m2; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@ib;T;;;;;;;[;{;IC; "BigDecimal provides arbitrary-precision floating point decimal arithmetic. == Introduction Ruby provides built-in support for arbitrary precision integer arithmetic. For example: 42**13 #=> 1265437718438866624512 BigDecimal provides similar support for very large or very accurate floating point numbers. Decimal arithmetic is also useful for general calculation, because it provides the correct answers people expect--whereas normal binary floating point arithmetic often introduces subtle errors because of the conversion between base 10 and base 2. For example, try: sum = 0 10_000.times do sum = sum + 0.0001 end print sum #=> 0.9999999999999062 and contrast with the output from: require 'bigdecimal' sum = BigDecimal("0") 10_000.times do sum = sum + BigDecimal("0.0001") end print sum #=> 0.1E1 Similarly: (BigDecimal("1.2") - BigDecimal("1.0")) == BigDecimal("0.2") #=> true (1.2 - 1.0) == 0.2 #=> false == A Note About Precision For a calculation using a \BigDecimal and another +value+, the precision of the result depends on the type of +value+: - If +value+ is a \Float, the precision is Float::DIG + 1. - If +value+ is a \Rational, the precision is larger than Float::DIG + 1. - If +value+ is a \BigDecimal, the precision is +value+'s precision in the internal representation, which is platform-dependent. - If +value+ is other object, the precision is determined by the result of +BigDecimal(value)+. == Special features of accurate decimal arithmetic Because BigDecimal is more accurate than normal binary floating point arithmetic, it requires some special values. === Infinity BigDecimal sometimes needs to return infinity, for example if you divide a value by zero. BigDecimal("1.0") / BigDecimal("0.0") #=> Infinity BigDecimal("-1.0") / BigDecimal("0.0") #=> -Infinity You can represent infinite numbers to BigDecimal using the strings 'Infinity', '+Infinity' and '-Infinity' (case-sensitive) === Not a Number When a computation results in an undefined value, the special value +NaN+ (for 'not a number') is returned. Example: BigDecimal("0.0") / BigDecimal("0.0") #=> NaN You can also create undefined values. NaN is never considered to be the same as any other value, even NaN itself: n = BigDecimal('NaN') n == 0.0 #=> false n == n #=> false === Positive and negative zero If a computation results in a value which is too small to be represented as a BigDecimal within the currently specified limits of precision, zero must be returned. If the value which is too small to be represented is negative, a BigDecimal value of negative zero is returned. BigDecimal("1.0") / BigDecimal("-Infinity") #=> -0.0 If the value is positive, a value of positive zero is returned. BigDecimal("1.0") / BigDecimal("Infinity") #=> 0.0 (See BigDecimal.mode for how to specify limits of precision.) Note that +-0.0+ and +0.0+ are considered to be the same for the purposes of comparison. Note also that in mathematics, there is no particular concept of negative or positive zero; true mathematical zero has no sign. == bigdecimal/util When you require +bigdecimal/util+, the #to_d method will be available on BigDecimal and the native Integer, Float, Rational, and String classes: require 'bigdecimal/util' 42.to_d # => 0.42e2 0.5.to_d # => 0.5e0 (2/3r).to_d(3) # => 0.667e0 "0.5".to_d # => 0.5e0 == License Copyright (C) 2002 by Shigeo Kobayashi . BigDecimal is released under the Ruby and 2-clause BSD licenses. See LICENSE.txt for details. Maintained by mrkn and ruby-core members. Documented by zzak , mathew , and many other contributors.;T;[;![;"I"BigDecimal provides arbitrary-precision floating point decimal arithmetic. == Introduction Ruby provides built-in support for arbitrary precision integer arithmetic. For example: 42**13 #=> 1265437718438866624512 BigDecimal provides similar support for very large or very accurate floating point numbers. Decimal arithmetic is also useful for general calculation, because it provides the correct answers people expect--whereas normal binary floating point arithmetic often introduces subtle errors because of the conversion between base 10 and base 2. For example, try: sum = 0 10_000.times do sum = sum + 0.0001 end print sum #=> 0.9999999999999062 and contrast with the output from: require 'bigdecimal' sum = BigDecimal("0") 10_000.times do sum = sum + BigDecimal("0.0001") end print sum #=> 0.1E1 Similarly: (BigDecimal("1.2") - BigDecimal("1.0")) == BigDecimal("0.2") #=> true (1.2 - 1.0) == 0.2 #=> false == A Note About Precision For a calculation using a \BigDecimal and another +value+, the precision of the result depends on the type of +value+: - If +value+ is a \Float, the precision is Float::DIG + 1. - If +value+ is a \Rational, the precision is larger than Float::DIG + 1. - If +value+ is a \BigDecimal, the precision is +value+'s precision in the internal representation, which is platform-dependent. - If +value+ is other object, the precision is determined by the result of +BigDecimal(value)+. == Special features of accurate decimal arithmetic Because BigDecimal is more accurate than normal binary floating point arithmetic, it requires some special values. === Infinity BigDecimal sometimes needs to return infinity, for example if you divide a value by zero. BigDecimal("1.0") / BigDecimal("0.0") #=> Infinity BigDecimal("-1.0") / BigDecimal("0.0") #=> -Infinity You can represent infinite numbers to BigDecimal using the strings 'Infinity', '+Infinity' and '-Infinity' (case-sensitive) === Not a Number When a computation results in an undefined value, the special value +NaN+ (for 'not a number') is returned. Example: BigDecimal("0.0") / BigDecimal("0.0") #=> NaN You can also create undefined values. NaN is never considered to be the same as any other value, even NaN itself: n = BigDecimal('NaN') n == 0.0 #=> false n == n #=> false === Positive and negative zero If a computation results in a value which is too small to be represented as a BigDecimal within the currently specified limits of precision, zero must be returned. If the value which is too small to be represented is negative, a BigDecimal value of negative zero is returned. BigDecimal("1.0") / BigDecimal("-Infinity") #=> -0.0 If the value is positive, a value of positive zero is returned. BigDecimal("1.0") / BigDecimal("Infinity") #=> 0.0 (See BigDecimal.mode for how to specify limits of precision.) Note that +-0.0+ and +0.0+ are considered to be the same for the purposes of comparison. Note also that in mathematics, there is no particular concept of negative or positive zero; true mathematical zero has no sign. == bigdecimal/util When you require +bigdecimal/util+, the #to_d method will be available on BigDecimal and the native Integer, Float, Rational, and String classes: require 'bigdecimal/util' 42.to_d # => 0.42e2 0.5.to_d # => 0.5e0 (2/3r).to_d(3) # => 0.667e0 "0.5".to_d # => 0.5e0 == License Copyright (C) 2002 by Shigeo Kobayashi . BigDecimal is released under the Ruby and 2-clause BSD licenses. See LICENSE.txt for details. Maintained by mrkn and ruby-core members. Documented by zzak , mathew , and many other contributors. ;T;#0;$@m2;.F;/o;0;1T;2i;3iP;Bi;%@;&I"BigDecimal;F;'@&o;;IC;[o;4;5F;6;;;;&I"BigMath.exp;F;7[[I"x;T0[I" vprec;T0;[[@i;T;:exp;0;[;{;IC; " BigMath.exp(decimal, numeric) -> BigDecimal Computes the value of e (the base of natural logarithms) raised to the power of +decimal+, to the specified number of digits of precision. If +decimal+ is infinity, returns Infinity. If +decimal+ is NaN, returns NaN. ;T;[;![;"I" BigMath.exp(decimal, numeric) -> BigDecimal Computes the value of e (the base of natural logarithms) raised to the power of +decimal+, to the specified number of digits of precision. If +decimal+ is infinity, returns Infinity. If +decimal+ is NaN, returns NaN. ;T;#0;$@8;.F;/o;0;1T;2i};3i;%@8;9I"X static VALUE BigMath_s_exp(VALUE klass, VALUE x, VALUE vprec) { ssize_t prec, n, i; Real* vx = NULL; VALUE one, d, y; int negative = 0; int infinite = 0; int nan = 0; double flo; prec = NUM2SSIZET(vprec); if (prec <= 0) { rb_raise(rb_eArgError, "Zero or negative precision for exp"); } /* TODO: the following switch statement is almost same as one in the * BigDecimalCmp function. */ switch (TYPE(x)) { case T_DATA: if (!is_kind_of_BigDecimal(x)) break; vx = DATA_PTR(x); negative = BIGDECIMAL_NEGATIVE_P(vx); infinite = VpIsPosInf(vx) || VpIsNegInf(vx); nan = VpIsNaN(vx); break; case T_FIXNUM: /* fall through */ case T_BIGNUM: vx = GetVpValue(x, 0); break; case T_FLOAT: flo = RFLOAT_VALUE(x); negative = flo < 0; infinite = isinf(flo); nan = isnan(flo); if (!infinite && !nan) { vx = GetVpValueWithPrec(x, 0, 0); } break; case T_RATIONAL: vx = GetVpValueWithPrec(x, prec, 0); break; default: break; } if (infinite) { if (negative) { return VpCheckGetValue(GetVpValueWithPrec(INT2FIX(0), prec, 1)); } else { Real* vy; vy = VpCreateRbObject(prec, "#0", true); VpSetInf(vy, VP_SIGN_POSITIVE_INFINITE); RB_GC_GUARD(vy->obj); return VpCheckGetValue(vy); } } else if (nan) { Real* vy; vy = VpCreateRbObject(prec, "#0", true); VpSetNaN(vy); RB_GC_GUARD(vy->obj); return VpCheckGetValue(vy); } else if (vx == NULL) { cannot_be_coerced_into_BigDecimal(rb_eArgError, x); } x = vx->obj; n = prec + BIGDECIMAL_DOUBLE_FIGURES; negative = BIGDECIMAL_NEGATIVE_P(vx); if (negative) { VALUE x_zero = INT2NUM(1); VALUE x_copy = f_BigDecimal(1, &x_zero, klass); x = BigDecimal_initialize_copy(x_copy, x); vx = DATA_PTR(x); VpSetSign(vx, 1); } one = VpCheckGetValue(VpCreateRbObject(1, "1", true)); y = one; d = y; i = 1; while (!VpIsZero((Real*)DATA_PTR(d))) { SIGNED_VALUE const ey = VpExponent10(DATA_PTR(y)); SIGNED_VALUE const ed = VpExponent10(DATA_PTR(d)); ssize_t m = n - vabs(ey - ed); rb_thread_check_ints(); if (m <= 0) { break; } else if ((size_t)m < BIGDECIMAL_DOUBLE_FIGURES) { m = BIGDECIMAL_DOUBLE_FIGURES; } d = BigDecimal_mult(d, x); /* d <- d * x */ d = BigDecimal_div2(d, SSIZET2NUM(i), SSIZET2NUM(m)); /* d <- d / i */ y = BigDecimal_add(y, d); /* y <- y + d */ ++i; /* i <- i + 1 */ } if (negative) { return BigDecimal_div2(one, y, vprec); } else { vprec = SSIZET2NUM(prec - VpExponent10(DATA_PTR(y))); return BigDecimal_round(1, &vprec, y); } RB_GC_GUARD(one); RB_GC_GUARD(x); RB_GC_GUARD(y); RB_GC_GUARD(d); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BigMath.log;F;7[[I"x;T0[I" vprec;T0;[[@i;T;;;0;[;{;IC; ",BigMath.log(decimal, numeric) -> BigDecimal Computes the natural logarithm of +decimal+ to the specified number of digits of precision, +numeric+. If +decimal+ is zero or negative, raises Math::DomainError. If +decimal+ is positive infinity, returns Infinity. If +decimal+ is NaN, returns NaN. ;T;[;![;"I".BigMath.log(decimal, numeric) -> BigDecimal Computes the natural logarithm of +decimal+ to the specified number of digits of precision, +numeric+. If +decimal+ is zero or negative, raises Math::DomainError. If +decimal+ is positive infinity, returns Infinity. If +decimal+ is NaN, returns NaN. ;T;#0;$@8;.F;/o;0;1T;2i;3i ;%@8;9I"[static VALUE BigMath_s_log(VALUE klass, VALUE x, VALUE vprec) { ssize_t prec, n, i; SIGNED_VALUE expo; Real* vx = NULL; VALUE vn, one, two, w, x2, y, d; int zero = 0; int negative = 0; int infinite = 0; int nan = 0; double flo; long fix; if (!is_integer(vprec)) { rb_raise(rb_eArgError, "precision must be an Integer"); } prec = NUM2SSIZET(vprec); if (prec <= 0) { rb_raise(rb_eArgError, "Zero or negative precision for exp"); } /* TODO: the following switch statement is almost same as one in the * BigDecimalCmp function. */ switch (TYPE(x)) { case T_DATA: if (!is_kind_of_BigDecimal(x)) break; vx = DATA_PTR(x); zero = VpIsZero(vx); negative = BIGDECIMAL_NEGATIVE_P(vx); infinite = VpIsPosInf(vx) || VpIsNegInf(vx); nan = VpIsNaN(vx); break; case T_FIXNUM: fix = FIX2LONG(x); zero = fix == 0; negative = fix < 0; goto get_vp_value; case T_BIGNUM: i = FIX2INT(rb_big_cmp(x, INT2FIX(0))); zero = i == 0; negative = i < 0; get_vp_value: if (zero || negative) break; vx = GetVpValue(x, 0); break; case T_FLOAT: flo = RFLOAT_VALUE(x); zero = flo == 0; negative = flo < 0; infinite = isinf(flo); nan = isnan(flo); if (!zero && !negative && !infinite && !nan) { vx = GetVpValueWithPrec(x, 0, 1); } break; case T_RATIONAL: zero = RRATIONAL_ZERO_P(x); negative = RRATIONAL_NEGATIVE_P(x); if (zero || negative) break; vx = GetVpValueWithPrec(x, prec, 1); break; case T_COMPLEX: rb_raise(rb_eMathDomainError, "Complex argument for BigMath.log"); default: break; } if (infinite && !negative) { Real* vy; vy = VpCreateRbObject(prec, "#0", true); RB_GC_GUARD(vy->obj); VpSetInf(vy, VP_SIGN_POSITIVE_INFINITE); return VpCheckGetValue(vy); } else if (nan) { Real* vy; vy = VpCreateRbObject(prec, "#0", true); RB_GC_GUARD(vy->obj); VpSetNaN(vy); return VpCheckGetValue(vy); } else if (zero || negative) { rb_raise(rb_eMathDomainError, "Zero or negative argument for log"); } else if (vx == NULL) { cannot_be_coerced_into_BigDecimal(rb_eArgError, x); } x = VpCheckGetValue(vx); RB_GC_GUARD(one) = VpCheckGetValue(VpCreateRbObject(1, "1", true)); RB_GC_GUARD(two) = VpCheckGetValue(VpCreateRbObject(1, "2", true)); n = prec + BIGDECIMAL_DOUBLE_FIGURES; RB_GC_GUARD(vn) = SSIZET2NUM(n); expo = VpExponent10(vx); if (expo < 0 || expo >= 3) { char buf[DECIMAL_SIZE_OF_BITS(SIZEOF_VALUE * CHAR_BIT) + 4]; snprintf(buf, sizeof(buf), "1E%"PRIdVALUE, -expo); x = BigDecimal_mult2(x, VpCheckGetValue(VpCreateRbObject(1, buf, true)), vn); } else { expo = 0; } w = BigDecimal_sub(x, one); x = BigDecimal_div2(w, BigDecimal_add(x, one), vn); RB_GC_GUARD(x2) = BigDecimal_mult2(x, x, vn); RB_GC_GUARD(y) = x; RB_GC_GUARD(d) = y; i = 1; while (!VpIsZero((Real*)DATA_PTR(d))) { SIGNED_VALUE const ey = VpExponent10(DATA_PTR(y)); SIGNED_VALUE const ed = VpExponent10(DATA_PTR(d)); ssize_t m = n - vabs(ey - ed); if (m <= 0) { break; } else if ((size_t)m < BIGDECIMAL_DOUBLE_FIGURES) { m = BIGDECIMAL_DOUBLE_FIGURES; } x = BigDecimal_mult2(x2, x, vn); i += 2; d = BigDecimal_div2(x, SSIZET2NUM(i), SSIZET2NUM(m)); y = BigDecimal_add(y, d); } y = BigDecimal_mult(y, two); if (expo != 0) { VALUE log10, vexpo, dy; log10 = BigMath_s_log(klass, INT2FIX(10), vprec); vexpo = VpCheckGetValue(GetVpValue(SSIZET2NUM(expo), 1)); dy = BigDecimal_mult(log10, vexpo); y = BigDecimal_add(y, dy); } return y; };T;:I"static VALUE;T;;T; @8; IC;[; @8; IC;[; @8; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i=;F;: BigMath;;;;;[;{;IC; " ;T;[;![;"@;#0;$@8;Bi;%@;&I" BigMath;Fo; ;IC;[;o;4;5F;6;;;;&I"Integer#coerce;F;7[[I"y;T0;[[@qiY;T;;;0;[;{;IC; "Returns an array with both a +numeric+ and a +big+ represented as Bignum objects. This is achieved by converting +numeric+ to a Bignum. A TypeError is raised if the +numeric+ is not a Fixnum or Bignum type. (0x3FFFFFFFFFFFFFFF+1).coerce(42) #=> [42, 4611686018427387904] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"coerce(numeric);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@8;![;"I"@return [Array];T;#0;$@8;.F;Bi;C0;7[[I" numeric;T0;$@8;![;"I"EReturns an array with both a +numeric+ and a +big+ represented as Bignum objects. This is achieved by converting +numeric+ to a Bignum. A TypeError is raised if the +numeric+ is not a Fixnum or Bignum type. (0x3FFFFFFFFFFFFFFF+1).coerce(42) #=> [42, 4611686018427387904] @overload coerce(numeric) @return [Array];T;#0;$@8;.F;/o;0;1T;2iK;3iV;%@8;9I"static VALUE rb_int_coerce(VALUE x, VALUE y) { if (RB_INTEGER_TYPE_P(y)) { return rb_assoc_new(y, x); } else { x = rb_Float(x); y = rb_Float(y); return rb_assoc_new(y, x); } };T;:I"static VALUE;T;;To;u;[[@qi ;F;:GMP_VERSION;;w;;;[;{;IC; "The version of loaded GMP. ;T;[;![;"I"The version of loaded GMP.;T;#0;$@9;.F;/o;0;1T;2i ;3i ;%@8;&I"Integer::GMP_VERSION;F;xI"&rb_sprintf("GMP %s", gmp_version);To;4;5F;6;;;;&I"Integer.sqrt;F;7[;[;F;;";;;[;{;IC; " ;T;[;![;"@;#0;$@9;%@8;;To;4;5F;6;;;;&I"Integer.try_convert;F;7[[I"num;T0;[[@ik;T;;v;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@#9;.F;/o;0;1T;2ij;3ij;%@8;9I"estatic VALUE int_s_try_convert(VALUE self, VALUE num) { return rb_check_integer_type(num); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#to_s;F;7[[@90;[[@i[;T;;G;0;[;{;IC; "Returns a string containing the place-value representation of +self+ in radix +base+ (in 2..36). 12345.to_s # => "12345" 12345.to_s(2) # => "11000000111001" 12345.to_s(8) # => "30071" 12345.to_s(10) # => "12345" 12345.to_s(16) # => "3039" 12345.to_s(36) # => "9ix" 78546939656932.to_s(36) # => "rubyrules" Raises an exception if +base+ is out of range. Integer#inspect is an alias for Integer#to_s. ;T;[o;= ;>I" overload;F;?0;;G;@0;:I"to_s(base = 10);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@39;![;"I"@return [String];T;#0;$@39;.F;Bi;C0;7[[I" base;TI"10;T;$@39;![;"I"Returns a string containing the place-value representation of +self+ in radix +base+ (in 2..36). 12345.to_s # => "12345" 12345.to_s(2) # => "11000000111001" 12345.to_s(8) # => "30071" 12345.to_s(10) # => "12345" 12345.to_s(16) # => "3039" 12345.to_s(36) # => "9ix" 78546939656932.to_s(36) # => "rubyrules" Raises an exception if +base+ is out of range. Integer#inspect is an alias for Integer#to_s. @overload to_s(base = 10) @return [String];T;#0;$o;4;5F;6;;;;&I"Integer#inspect;F;7[;[[@iV;F;;J;;;[;{;@;9;%@8;9I"MJIT_FUNC_EXPORTED VALUE rb_int_to_s(int argc, VALUE *argv, VALUE x) { int base; if (rb_check_arity(argc, 0, 1)) base = NUM2INT(argv[0]); else base = 10; return rb_int2str(x, base); };T;:I"MJIT_FUNC_EXPORTED VALUE;T;.F;/o;0;1T;2iF;3iX;%@8;9I"MJIT_FUNC_EXPORTED VALUE rb_int_to_s(int argc, VALUE *argv, VALUE x) { int base; if (rb_check_arity(argc, 0, 1)) base = NUM2INT(argv[0]); else base = 10; return rb_int2str(x, base); };T;:@W9;;T@O9o;4;5F;6;;;;&I"Integer#allbits?;F;7[[I" mask;T0;[[@i*;T;: allbits?;0;[;{;IC; "eReturns +true+ if all bits that are set (=1) in +mask+ are also set in +self+; returns +false+ otherwise. Example values: 0b1010101 self 0b1010100 mask 0b1010100 self & mask true self.allbits?(mask) 0b1010100 self 0b1010101 mask 0b1010100 self & mask false self.allbits?(mask) Related: Integer#anybits?, Integer#nobits?.;T;[o;= ;>I" overload;F;?0;;*;@0;:I"allbits?(mask);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Z9;![;"I"@return [Boolean];T;#0;$@Z9;.F;Bi;C0;7[[I" mask;T0;$@Z9;![;"I"Returns +true+ if all bits that are set (=1) in +mask+ are also set in +self+; returns +false+ otherwise. Example values: 0b1010101 self 0b1010100 mask 0b1010100 self & mask true self.allbits?(mask) 0b1010100 self 0b1010101 mask 0b1010100 self & mask false self.allbits?(mask) Related: Integer#anybits?, Integer#nobits?. @overload allbits?(mask) @return [Boolean];T;#0;$@Z9;.F;/o;0;1T;2i;3i';Bi;%@8;9I"static VALUE int_allbits_p(VALUE num, VALUE mask) { mask = rb_to_int(mask); return rb_int_equal(rb_int_and(num, mask), mask); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#anybits?;F;7[[I" mask;T0;[[@iH;T;: anybits?;0;[;{;IC; "jReturns +true+ if any bit that is set (=1) in +mask+ is also set in +self+; returns +false+ otherwise. Example values: 0b10000010 self 0b11111111 mask 0b10000010 self & mask true self.anybits?(mask) 0b00000000 self 0b11111111 mask 0b00000000 self & mask false self.anybits?(mask) Related: Integer#allbits?, Integer#nobits?.;T;[o;= ;>I" overload;F;?0;;+;@0;:I"anybits?(mask);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@y9;![;"I"@return [Boolean];T;#0;$@y9;.F;Bi;C0;7[[I" mask;T0;$@y9;![;"I"Returns +true+ if any bit that is set (=1) in +mask+ is also set in +self+; returns +false+ otherwise. Example values: 0b10000010 self 0b11111111 mask 0b10000010 self & mask true self.anybits?(mask) 0b00000000 self 0b11111111 mask 0b00000000 self & mask false self.anybits?(mask) Related: Integer#allbits?, Integer#nobits?. @overload anybits?(mask) @return [Boolean];T;#0;$@y9;.F;/o;0;1T;2i1;3iE;Bi;%@8;9I"static VALUE int_anybits_p(VALUE num, VALUE mask) { mask = rb_to_int(mask); return int_zero_p(rb_int_and(num, mask)) ? Qfalse : Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#nobits?;F;7[[I" mask;T0;[[@if;T;: nobits?;0;[;{;IC; "hReturns +true+ if no bit that is set (=1) in +mask+ is also set in +self+; returns +false+ otherwise. Example values: 0b11110000 self 0b00001111 mask 0b00000000 self & mask true self.nobits?(mask) 0b00000001 self 0b11111111 mask 0b00000001 self & mask false self.nobits?(mask) Related: Integer#allbits?, Integer#anybits?.;T;[o;= ;>I" overload;F;?0;;,;@0;:I"nobits?(mask);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@9;![;"I"@return [Boolean];T;#0;$@9;.F;Bi;C0;7[[I" mask;T0;$@9;![;"I"Returns +true+ if no bit that is set (=1) in +mask+ is also set in +self+; returns +false+ otherwise. Example values: 0b11110000 self 0b00001111 mask 0b00000000 self & mask true self.nobits?(mask) 0b00000001 self 0b11111111 mask 0b00000001 self & mask false self.nobits?(mask) Related: Integer#allbits?, Integer#anybits?. @overload nobits?(mask) @return [Boolean];T;#0;$@9;.F;/o;0;1T;2iO;3ic;Bi;%@8;9I"~static VALUE int_nobits_p(VALUE num, VALUE mask) { mask = rb_to_int(mask); return int_zero_p(rb_int_and(num, mask)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#upto;F;7[[I"to;T0;[[@i;T;;;0;[;{;IC; "Calls the given block with each integer value from +self+ up to +limit+; returns +self+: a = [] 5.upto(10) {|i| a << i } # => 5 a # => [5, 6, 7, 8, 9, 10] a = [] -5.upto(0) {|i| a << i } # => -5 a # => [-5, -4, -3, -2, -1, 0] 5.upto(4) {|i| fail 'Cannot happen' } # => 5 With no block given, returns an Enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"upto(limit);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"i;T;$@9o;A ;>I" return;F;?I";T;0;@[I" self;T;$@9;![;"I"@yield [i] @return [self];T;#0;$@9;.F;Bi;C0;7[[I" limit;T0;$@9o;= ;>I" overload;F;?0;;;@0;:I"upto(limit);T;IC; ";T;[;![;"I";T;#0;$@9;.F;Bi;C0;7[[I" limit;T0;$@9;![;"I"Calls the given block with each integer value from +self+ up to +limit+; returns +self+: a = [] 5.upto(10) {|i| a << i } # => 5 a # => [5, 6, 7, 8, 9, 10] a = [] -5.upto(0) {|i| a << i } # => -5 a # => [-5, -4, -3, -2, -1, 0] 5.upto(4) {|i| fail 'Cannot happen' } # => 5 With no block given, returns an Enumerator. @overload upto(limit) @yield [i] @return [self] @overload upto(limit);T;#0;$@9;.F;/o;0;1T;2i;3i;%@8;9I"static VALUE int_upto(VALUE from, VALUE to) { RETURN_SIZED_ENUMERATOR(from, 1, &to, int_upto_size); if (FIXNUM_P(from) && FIXNUM_P(to)) { long i, end; end = FIX2LONG(to); for (i = FIX2LONG(from); i <= end; i++) { rb_yield(LONG2FIX(i)); } } else { VALUE i = from, c; while (!(c = rb_funcall(i, '>', 1, to))) { rb_yield(i); i = rb_funcall(i, '+', 1, INT2FIX(1)); } ensure_cmp(c, i, to); } return from; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#downto;F;7[[I"to;T0;[[@i;T;;;0;[;{;IC; "Calls the given block with each integer value from +self+ down to +limit+; returns +self+: a = [] 10.downto(5) {|i| a << i } # => 10 a # => [10, 9, 8, 7, 6, 5] a = [] 0.downto(-5) {|i| a << i } # => 0 a # => [0, -1, -2, -3, -4, -5] 4.downto(5) {|i| fail 'Cannot happen' } # => 4 With no block given, returns an Enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"downto(limit);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"i;T;$@9o;A ;>I" return;F;?I";T;0;@[I" self;T;$@9;![;"I"@yield [i] @return [self];T;#0;$@9;.F;Bi;C0;7[[I" limit;T0;$@9o;= ;>I" overload;F;?0;;;@0;:I"downto(limit);T;IC; ";T;[;![;"I";T;#0;$@9;.F;Bi;C0;7[[I" limit;T0;$@9;![;"I" Calls the given block with each integer value from +self+ down to +limit+; returns +self+: a = [] 10.downto(5) {|i| a << i } # => 10 a # => [10, 9, 8, 7, 6, 5] a = [] 0.downto(-5) {|i| a << i } # => 0 a # => [0, -1, -2, -3, -4, -5] 4.downto(5) {|i| fail 'Cannot happen' } # => 4 With no block given, returns an Enumerator. @overload downto(limit) @yield [i] @return [self] @overload downto(limit);T;#0;$@9;.F;/o;0;1T;2i;3i;%@8;9I"static VALUE int_downto(VALUE from, VALUE to) { RETURN_SIZED_ENUMERATOR(from, 1, &to, int_downto_size); if (FIXNUM_P(from) && FIXNUM_P(to)) { long i, end; end = FIX2LONG(to); for (i=FIX2LONG(from); i >= end; i--) { rb_yield(LONG2FIX(i)); } } else { VALUE i = from, c; while (!(c = rb_funcall(i, '<', 1, to))) { rb_yield(i); i = rb_funcall(i, '-', 1, INT2FIX(1)); } if (NIL_P(c)) rb_cmperr(i, to); } return from; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#times;F;7[;[[@i9;T;;;0;[;{;IC; "Calls the given block +self+ times with each integer in (0..self-1): a = [] 5.times {|i| a.push(i) } # => 5 a # => [0, 1, 2, 3, 4] With no block given, returns an Enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" times;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"i;T;$@:o;A ;>I" return;F;?I";T;0;@[I" self;T;$@:;![;"I"@yield [i] @return [self];T;#0;$@:;.F;Bi;C0;7[;$@:o;= ;>I" overload;F;?0;;;@0;:I" times;T;IC; ";T;[;![;"I";T;#0;$@:;.F;Bi;C0;7[;$@:;![;"I"Calls the given block +self+ times with each integer in (0..self-1): a = [] 5.times {|i| a.push(i) } # => 5 a # => [0, 1, 2, 3, 4] With no block given, returns an Enumerator. @overload times @yield [i] @return [self] @overload times;T;#0;$@:;.F;/o;0;1T;2i*;3i7;%@8;9I"static VALUE int_dotimes(VALUE num) { RETURN_SIZED_ENUMERATOR(num, 0, 0, int_dotimes_size); if (FIXNUM_P(num)) { long i, end; end = FIX2LONG(num); for (i=0; i "A" 0..chr # => "\x00" 255.chr # => "\xFF" string = 255.chr(Encoding::UTF_8) string.encoding # => Encoding::UTF_8 Raises an exception if +self+ is negative. Related: Integer#ord. ;T;[o;= ;>I" overload;F;?0;;.;@0;:I"chr;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@V:;![;"I"@return [String];T;#0;$@V:;.F;Bi;C0;7[;$@V:o;= ;>I" overload;F;?0;;.;@0;:I"chr(encoding);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@V:;![;"I"@return [String];T;#0;$@V:;.F;Bi;C0;7[[I" encoding;T0;$@V:;![;"I"Returns a 1-character string containing the character represented by the value of +self+, according to the given +encoding+. 65.chr # => "A" 0..chr # => "\x00" 255.chr # => "\xFF" string = 255.chr(Encoding::UTF_8) string.encoding # => Encoding::UTF_8 Raises an exception if +self+ is negative. Related: Integer#ord. @overload chr @return [String] @overload chr(encoding) @return [String];T;#0;$@V:;.F;/o;0;1T;2i;3i;%@8;9I"Qstatic VALUE int_chr(int argc, VALUE *argv, VALUE num) { char c; unsigned int i; rb_encoding *enc; if (rb_num_to_uint(num, &i) == 0) { } else if (FIXNUM_P(num)) { rb_raise(rb_eRangeError, "%ld out of char range", FIX2LONG(num)); } else { rb_raise(rb_eRangeError, "bignum out of char range"); } switch (argc) { case 0: if (0xff < i) { enc = rb_default_internal_encoding(); if (!enc) { rb_raise(rb_eRangeError, "%u out of char range", i); } goto decode; } c = (char)i; if (i < 0x80) { return rb_usascii_str_new(&c, 1); } else { return rb_str_new(&c, 1); } case 1: break; default: rb_error_arity(argc, 0, 1); } enc = rb_to_encoding(argv[0]); if (!enc) enc = rb_ascii8bit_encoding(); decode: return rb_enc_uint_chr(i, enc); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#to_f;F;7[;[[@i;T;;;0;[;{;IC; "Converts +self+ to a Float: 1.to_f # => 1.0 -1.to_f # => -1.0 If the value of +self+ does not fit in a \Float, the result is infinity: (10**400).to_f # => Infinity (-10**400).to_f # => -Infinity ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_f;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@:;![;"I"@return [Float];T;#0;$@:;.F;Bi;C0;7[;$@:;![;"I"Converts +self+ to a Float: 1.to_f # => 1.0 -1.to_f # => -1.0 If the value of +self+ does not fit in a \Float, the result is infinity: (10**400).to_f # => Infinity (-10**400).to_f # => -Infinity @overload to_f @return [Float];T;#0;$@:;.F;/o;0;1T;2i;3i;%@8;9I"5static VALUE int_to_f(VALUE num) { double val; if (FIXNUM_P(num)) { val = (double)FIX2LONG(num); } else if (RB_BIGNUM_TYPE_P(num)) { val = rb_big2dbl(num); } else { rb_raise(rb_eNotImpError, "Unknown subclass for to_f: %s", rb_obj_classname(num)); } return DBL2NUM(val); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#floor;F;7[[@90;[[@i;T;;;0;[;{;IC; "Returns the largest number less than or equal to +self+ with a precision of +ndigits+ decimal digits. When +ndigits+ is negative, the returned value has at least ndigits.abs trailing zeros: 555.floor(-1) # => 550 555.floor(-2) # => 500 -555.floor(-2) # => -600 555.floor(-3) # => 0 Returns +self+ when +ndigits+ is zero or positive. 555.floor # => 555 555.floor(50) # => 555 Related: Integer#ceil. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"floor(ndigits = 0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@:;![;"I"@return [Integer];T;#0;$@:;.F;Bi;C0;7[[I" ndigits;TI"0;T;$@:;![;"I"Returns the largest number less than or equal to +self+ with a precision of +ndigits+ decimal digits. When +ndigits+ is negative, the returned value has at least ndigits.abs trailing zeros: 555.floor(-1) # => 550 555.floor(-2) # => 500 -555.floor(-2) # => -600 555.floor(-3) # => 0 Returns +self+ when +ndigits+ is zero or positive. 555.floor # => 555 555.floor(50) # => 555 Related: Integer#ceil. @overload floor(ndigits = 0) @return [Integer];T;#0;$@:;.F;/o;0;1T;2i;3i;%@8;9I"static VALUE int_floor(int argc, VALUE* argv, VALUE num) { int ndigits; if (!rb_check_arity(argc, 0, 1)) return num; ndigits = NUM2INT(argv[0]); if (ndigits >= 0) { return num; } return rb_int_floor(num, ndigits); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#ceil;F;7[[@90;[[@i;T;;;0;[;{;IC; "Returns the smallest number greater than or equal to +self+ with a precision of +ndigits+ decimal digits. When the precision is negative, the returned value is an integer with at least ndigits.abs trailing zeros: 555.ceil(-1) # => 560 555.ceil(-2) # => 600 -555.ceil(-2) # => -500 555.ceil(-3) # => 1000 Returns +self+ when +ndigits+ is zero or positive. 555.ceil # => 555 555.ceil(50) # => 555 Related: Integer#floor. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ceil(ndigits = 0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@:;![;"I"@return [Integer];T;#0;$@:;.F;Bi;C0;7[[I" ndigits;TI"0;T;$@:;![;"I"Returns the smallest number greater than or equal to +self+ with a precision of +ndigits+ decimal digits. When the precision is negative, the returned value is an integer with at least ndigits.abs trailing zeros: 555.ceil(-1) # => 560 555.ceil(-2) # => 600 -555.ceil(-2) # => -500 555.ceil(-3) # => 1000 Returns +self+ when +ndigits+ is zero or positive. 555.ceil # => 555 555.ceil(50) # => 555 Related: Integer#floor. @overload ceil(ndigits = 0) @return [Integer];T;#0;$@:;.F;/o;0;1T;2i;3i;%@8;9I"static VALUE int_ceil(int argc, VALUE* argv, VALUE num) { int ndigits; if (!rb_check_arity(argc, 0, 1)) return num; ndigits = NUM2INT(argv[0]); if (ndigits >= 0) { return num; } return rb_int_ceil(num, ndigits); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#truncate;F;7[[@90;[[@i;T;;_;0;[;{;IC; "Returns +self+ truncated (toward zero) to a precision of +ndigits+ decimal digits. When +ndigits+ is negative, the returned value has at least ndigits.abs trailing zeros: 555.truncate(-1) # => 550 555.truncate(-2) # => 500 -555.truncate(-2) # => -500 Returns +self+ when +ndigits+ is zero or positive. 555.truncate # => 555 555.truncate(50) # => 555 Related: Integer#round. ;T;[o;= ;>I" overload;F;?0;;_;@0;:I"truncate(ndigits = 0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@:;![;"I"@return [Integer];T;#0;$@:;.F;Bi;C0;7[[I" ndigits;TI"0;T;$@:;![;"I"Returns +self+ truncated (toward zero) to a precision of +ndigits+ decimal digits. When +ndigits+ is negative, the returned value has at least ndigits.abs trailing zeros: 555.truncate(-1) # => 550 555.truncate(-2) # => 500 -555.truncate(-2) # => -500 Returns +self+ when +ndigits+ is zero or positive. 555.truncate # => 555 555.truncate(50) # => 555 Related: Integer#round. @overload truncate(ndigits = 0) @return [Integer];T;#0;$@:;.F;/o;0;1T;2i;3i;%@8;9I"static VALUE int_truncate(int argc, VALUE* argv, VALUE num) { int ndigits; if (!rb_check_arity(argc, 0, 1)) return num; ndigits = NUM2INT(argv[0]); if (ndigits >= 0) { return num; } return rb_int_truncate(num, ndigits); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#round;F;7[[@90;[[@i;T;;;0;[;{;IC; "tReturns +self+ rounded to the nearest value with a precision of +ndigits+ decimal digits. When +ndigits+ is negative, the returned value has at least ndigits.abs trailing zeros: 555.round(-1) # => 560 555.round(-2) # => 600 555.round(-3) # => 1000 -555.round(-2) # => -600 555.round(-4) # => 0 Returns +self+ when +ndigits+ is zero or positive. 555.round # => 555 555.round(1) # => 555 555.round(50) # => 555 If keyword argument +half+ is given, and +self+ is equidistant from the two candidate values, the rounding is according to the given +half+ value: - +:up+ or +nil+: round away from zero: 25.round(-1, half: :up) # => 30 (-25).round(-1, half: :up) # => -30 - +:down+: round toward zero: 25.round(-1, half: :down) # => 20 (-25).round(-1, half: :down) # => -20 - +:even+: round toward the candidate whose last nonzero digit is even: 25.round(-1, half: :even) # => 20 15.round(-1, half: :even) # => 20 (-25).round(-1, half: :even) # => -20 Raises and exception if the value for +half+ is invalid. Related: Integer#truncate. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"!round(ndigits= 0, half: :up);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@:;![;"I"@return [Integer];T;#0;$@:;.F;Bi;C0;7[[I" ndigits;TI"0;T[I" half:;TI":up;T;$@:;![;"I"Returns +self+ rounded to the nearest value with a precision of +ndigits+ decimal digits. When +ndigits+ is negative, the returned value has at least ndigits.abs trailing zeros: 555.round(-1) # => 560 555.round(-2) # => 600 555.round(-3) # => 1000 -555.round(-2) # => -600 555.round(-4) # => 0 Returns +self+ when +ndigits+ is zero or positive. 555.round # => 555 555.round(1) # => 555 555.round(50) # => 555 If keyword argument +half+ is given, and +self+ is equidistant from the two candidate values, the rounding is according to the given +half+ value: - +:up+ or +nil+: round away from zero: 25.round(-1, half: :up) # => 30 (-25).round(-1, half: :up) # => -30 - +:down+: round toward zero: 25.round(-1, half: :down) # => 20 (-25).round(-1, half: :down) # => -20 - +:even+: round toward the candidate whose last nonzero digit is even: 25.round(-1, half: :even) # => 20 15.round(-1, half: :even) # => 20 (-25).round(-1, half: :even) # => -20 Raises and exception if the value for +half+ is invalid. Related: Integer#truncate. @overload round(ndigits= 0, half: :up) @return [Integer];T;#0;$@:;.F;/o;0;1T;2iR;3i;%@8;9I"Ostatic VALUE int_round(int argc, VALUE* argv, VALUE num) { int ndigits; int mode; VALUE nd, opt; if (!rb_scan_args(argc, argv, "01:", &nd, &opt)) return num; ndigits = NUM2INT(nd); mode = rb_num_get_rounding_option(opt); if (ndigits >= 0) { return num; } return rb_int_round(num, ndigits, mode); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#<=>;F;7[[I"y;T0;[[@i[;T;;Y;0;[;{;IC; "Returns: - -1, if +self+ is less than +other+. - 0, if +self+ is equal to +other+. - 1, if +self+ is greater then +other+. - +nil+, if +self+ and +other+ are incomparable. Examples: 1 <=> 2 # => -1 1 <=> 1 # => 0 1 <=> 0 # => 1 1 <=> 'foo' # => nil 1 <=> 1.0 # => 0 1 <=> Rational(1, 1) # => 0 1 <=> Complex(1, 0) # => 0 This method is the basis for comparisons in module Comparable. ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I"<=>(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[ I"-1;TI"0;TI"+1;TI"nil;T;$@;;![;"I" @return [ -1, 0, +1, nil];T;#0;$@;;.F;Bi;C0;7[[I" other;T0;$@;;![;"I"Returns: - -1, if +self+ is less than +other+. - 0, if +self+ is equal to +other+. - 1, if +self+ is greater then +other+. - +nil+, if +self+ and +other+ are incomparable. Examples: 1 <=> 2 # => -1 1 <=> 1 # => 0 1 <=> 0 # => 1 1 <=> 'foo' # => nil 1 <=> 1.0 # => 0 1 <=> Rational(1, 1) # => 0 1 <=> Complex(1, 0) # => 0 This method is the basis for comparisons in module Comparable. @overload <=>(other) @return [ -1, 0, +1, nil];T;#0;$@;;.F;/o;0;1T;2iA;3iX;%@8;9I"VALUE rb_int_cmp(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_cmp(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_cmp(x, y); } else { rb_raise(rb_eNotImpError, "need to define `<=>' in %s", rb_obj_classname(x)); } };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#+;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "Performs addition: 2 + 2 # => 4 -2 + 2 # => 0 -2 + -2 # => -4 2 + 2.0 # => 4.0 2 + Rational(2, 1) # => (4/1) 2 + Complex(2, 0) # => (4+0i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"+(numeric);T;IC; ";T;[;![;"I";T;#0;$@=;;.F;Bi;C0;7[[I" numeric;T0;$@=;;![;"I"Performs addition: 2 + 2 # => 4 -2 + 2 # => 0 -2 + -2 # => -4 2 + 2.0 # => 4.0 2 + Rational(2, 1) # => (4/1) 2 + Complex(2, 0) # => (4+0i) @overload +(numeric);T;#0;$@=;;.F;/o;0;1T;2i;3i;%@8;9I"VALUE rb_int_plus(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_plus(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_plus(x, y); } return rb_num_coerce_bin(x, y, '+'); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#-;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "Performs subtraction: 4 - 2 # => 2 -4 - 2 # => -6 -4 - -2 # => -2 4 - 2.0 # => 2.0 4 - Rational(2, 1) # => (2/1) 4 - Complex(2, 0) # => (2+0i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"-(numeric);T;IC; ";T;[;![;"I";T;#0;$@W;;.F;Bi;C0;7[[I" numeric;T0;$@W;;![;"I"Performs subtraction: 4 - 2 # => 2 -4 - 2 # => -6 -4 - -2 # => -2 4 - 2.0 # => 2.0 4 - Rational(2, 1) # => (2/1) 4 - Complex(2, 0) # => (2+0i) @overload -(numeric);T;#0;$@W;;.F;/o;0;1T;2i;3i;%@8;9I"VALUE rb_int_minus(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_minus(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_minus(x, y); } return rb_num_coerce_bin(x, y, '-'); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#*;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "Performs multiplication: 4 * 2 # => 8 4 * -2 # => -8 -4 * 2 # => -8 4 * 2.0 # => 8.0 4 * Rational(1, 3) # => (4/3) 4 * Complex(2, 0) # => (8+0i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"*(numeric);T;IC; ";T;[;![;"I";T;#0;$@q;;.F;Bi;C0;7[[I" numeric;T0;$@q;;![;"I"Performs multiplication: 4 * 2 # => 8 4 * -2 # => -8 -4 * 2 # => -8 4 * 2.0 # => 8.0 4 * Rational(1, 3) # => (4/3) 4 * Complex(2, 0) # => (8+0i) @overload *(numeric);T;#0;$@q;;.F;/o;0;1T;2i;3i;%@8;9I"VALUE rb_int_mul(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_mul(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_mul(x, y); } return rb_num_coerce_bin(x, y, '*'); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#/;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "fPerforms division; for integer +numeric+, truncates the result to an integer: 4 / 3 # => 1 4 / -3 # => -2 -4 / 3 # => -2 -4 / -3 # => 1 For other +numeric+, returns non-integer result: 4 / 3.0 # => 1.3333333333333333 4 / Rational(3, 1) # => (4/3) 4 / Complex(3, 0) # => ((4/3)+0i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"/(numeric);T;IC; ";T;[;![;"I";T;#0;$@;;.F;Bi;C0;7[[I" numeric;T0;$@;;![;"I"~Performs division; for integer +numeric+, truncates the result to an integer: 4 / 3 # => 1 4 / -3 # => -2 -4 / 3 # => -2 -4 / -3 # => 1 For other +numeric+, returns non-integer result: 4 / 3.0 # => 1.3333333333333333 4 / Rational(3, 1) # => (4/3) 4 / Complex(3, 0) # => ((4/3)+0i) @overload /(numeric);T;#0;$@;;.F;/o;0;1T;2iq;3i;%@8;9I"VALUE rb_int_div(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_div(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_div(x, y); } return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#div;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "4Performs integer division; returns the integer result of dividing +self+ by +numeric+: 4.div(3) # => 1 4.div(-3) # => -2 -4.div(3) # => -2 -4.div(-3) # => 1 4.div(3.0) # => 1 4.div(Rational(3, 1)) # => 1 Raises an exception if +numeric+ does not have method +div+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"div(numeric);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;;![;"I"@return [Integer];T;#0;$@;;.F;Bi;C0;7[[I" numeric;T0;$@;;![;"I"bPerforms integer division; returns the integer result of dividing +self+ by +numeric+: 4.div(3) # => 1 4.div(-3) # => -2 -4.div(3) # => -2 -4.div(-3) # => 1 4.div(3.0) # => 1 4.div(Rational(3, 1)) # => 1 Raises an exception if +numeric+ does not have method +div+. @overload div(numeric) @return [Integer];T;#0;$@;;.F;/o;0;1T;2i;3i;%@8;9I"VALUE rb_int_idiv(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_idiv(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_idiv(x, y); } return num_div(x, y); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#%;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "Returns +self+ modulo +other+ as a real number. For integer +n+ and real number +r+, these expressions are equivalent: n % r n-r*(n/r).floor n.divmod(r)[1] See Numeric#divmod. Examples: 10 % 2 # => 0 10 % 3 # => 1 10 % 4 # => 2 10 % -2 # => 0 10 % -3 # => -2 10 % -4 # => -2 10 % 3.0 # => 1.0 10 % Rational(3, 1) # => (1/1) Integer#modulo is an alias for Integer#%. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" %(other);T;IC; ";T;[;![;"I";T;#0;$@;;.F;Bi;C0;7[[I" other;T0;$@;;![;"I"Returns +self+ modulo +other+ as a real number. For integer +n+ and real number +r+, these expressions are equivalent: n % r n-r*(n/r).floor n.divmod(r)[1] See Numeric#divmod. Examples: 10 % 2 # => 0 10 % 3 # => 1 10 % 4 # => 2 10 % -2 # => 0 10 % -3 # => -2 10 % -4 # => -2 10 % 3.0 # => 1.0 10 % Rational(3, 1) # => (1/1) Integer#modulo is an alias for Integer#%. @overload %(other);T;#0;$@;;.F;/o;0;1T;2i;3i;%@8;9I"VALUE rb_int_modulo(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_mod(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_modulo(x, y); } return num_modulo(x, y); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#modulo;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "Returns +self+ modulo +other+ as a real number. For integer +n+ and real number +r+, these expressions are equivalent: n % r n-r*(n/r).floor n.divmod(r)[1] See Numeric#divmod. Examples: 10 % 2 # => 0 10 % 3 # => 1 10 % 4 # => 2 10 % -2 # => 0 10 % -3 # => -2 10 % -4 # => -2 10 % 3.0 # => 1.0 10 % Rational(3, 1) # => (1/1) Integer#modulo is an alias for Integer#%. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" %(other);T;IC; ";T;[;![;"I";T;#0;$@;;.F;Bi;C0;7[[I" other;T0;$@;;![;"@;;#0;$@;;.F;/o;0;1T;2i;3i;%@8;9I"VALUE rb_int_modulo(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_mod(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_modulo(x, y); } return num_modulo(x, y); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#remainder;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "Returns the remainder after dividing +self+ by +other+. Examples: 11.remainder(4) # => 3 11.remainder(-4) # => 3 -11.remainder(4) # => -3 -11.remainder(-4) # => -3 12.remainder(4) # => 0 12.remainder(-4) # => 0 -12.remainder(4) # => 0 -12.remainder(-4) # => 0 13.remainder(4.0) # => 1.0 13.remainder(Rational(4, 1)) # => (1/1) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"remainder(other);T;IC; ";T;[;![;"I";T;#0;$@;;.F;Bi;C0;7[[I" other;T0;$@;;![;"I"Returns the remainder after dividing +self+ by +other+. Examples: 11.remainder(4) # => 3 11.remainder(-4) # => 3 -11.remainder(4) # => -3 -11.remainder(-4) # => -3 12.remainder(4) # => 0 12.remainder(-4) # => 0 -12.remainder(4) # => 0 -12.remainder(-4) # => 0 13.remainder(4.0) # => 1.0 13.remainder(Rational(4, 1)) # => (1/1) @overload remainder(other);T;#0;$@;;.F;/o;0;1T;2i;3i;%@8;9I"static VALUE int_remainder(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return num_remainder(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_remainder(x, y); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#divmod;F;7[[I"y;T0;[[@iJ;T;;;0;[;{;IC; "*Returns a 2-element array [q, r], where q = (self/other).floor # Quotient r = self % other # Remainder Examples: 11.divmod(4) # => [2, 3] 11.divmod(-4) # => [-3, -1] -11.divmod(4) # => [-3, 1] -11.divmod(-4) # => [2, -3] 12.divmod(4) # => [3, 0] 12.divmod(-4) # => [-3, 0] -12.divmod(4) # => [-3, 0] -12.divmod(-4) # => [3, 0] 13.divmod(4.0) # => [3, 1.0] 13.divmod(Rational(4, 1)) # => [3, (1/1)] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"divmod(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@<;![;"I"@return [Array];T;#0;$@<;.F;Bi;C0;7[[I" other;T0;$@<;![;"I"WReturns a 2-element array [q, r], where q = (self/other).floor # Quotient r = self % other # Remainder Examples: 11.divmod(4) # => [2, 3] 11.divmod(-4) # => [-3, -1] -11.divmod(4) # => [-3, 1] -11.divmod(-4) # => [2, -3] 12.divmod(4) # => [3, 0] 12.divmod(-4) # => [-3, 0] -12.divmod(4) # => [-3, 0] -12.divmod(-4) # => [3, 0] 13.divmod(4.0) # => [3, 1.0] 13.divmod(Rational(4, 1)) # => [3, (1/1)] @overload divmod(other) @return [Array];T;#0;$@<;.F;/o;0;1T;2i1;3iH;%@8;9I"VALUE rb_int_divmod(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_divmod(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_divmod(x, y); } return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#fdiv;F;7[[I"y;T0;[[@iC;T;;;0;[;{;IC; "Returns the Float result of dividing +self+ by +numeric+: 4.fdiv(2) # => 2.0 4.fdiv(-2) # => -2.0 -4.fdiv(2) # => -2.0 4.fdiv(2.0) # => 2.0 4.fdiv(Rational(3, 4)) # => 5.333333333333333 Raises an exception if +numeric+ cannot be converted to a Float. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"fdiv(numeric);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@0<;![;"I"@return [Float];T;#0;$@0<;.F;Bi;C0;7[[I" numeric;T0;$@0<;![;"I"LReturns the Float result of dividing +self+ by +numeric+: 4.fdiv(2) # => 2.0 4.fdiv(-2) # => -2.0 -4.fdiv(2) # => -2.0 4.fdiv(2.0) # => 2.0 4.fdiv(Rational(3, 4)) # => 5.333333333333333 Raises an exception if +numeric+ cannot be converted to a Float. @overload fdiv(numeric) @return [Float];T;#0;$@0<;.F;/o;0;1T;2i3;3i@;%@8;9I"VALUE rb_int_fdiv(VALUE x, VALUE y) { if (RB_INTEGER_TYPE_P(x)) { return DBL2NUM(rb_int_fdiv_double(x, y)); } return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#**;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "Raises +self+ to the power of +numeric+: 2 ** 3 # => 8 2 ** -3 # => (1/8) -2 ** 3 # => -8 -2 ** -3 # => (-1/8) 2 ** 3.3 # => 9.849155306759329 2 ** Rational(3, 1) # => (8/1) 2 ** Complex(3, 0) # => (8+0i) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"**(numeric);T;IC; ";T;[;![;"I";T;#0;$@O<;.F;Bi;C0;7[[I" numeric;T0;$@O<;![;"I"0Raises +self+ to the power of +numeric+: 2 ** 3 # => 8 2 ** -3 # => (1/8) -2 ** 3 # => -8 -2 ** -3 # => (-1/8) 2 ** 3.3 # => 9.849155306759329 2 ** Rational(3, 1) # => (8/1) 2 ** Complex(3, 0) # => (8+0i) @overload **(numeric);T;#0;$@O<;.F;/o;0;1T;2i;3i;%@8;9I"VALUE rb_int_pow(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_pow(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_pow(x, y); } return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#pow;F;7[[I"*;T0[I" const;T0;[[@qi;T;:pow;0;[;{;IC; "Returns (modular) exponentiation as: a.pow(b) #=> same as a**b a.pow(b, m) #=> same as (a**b) % m, but avoids huge temporary values ;T;[o;= ;>I" overload;F;?0;;/;@0;:I"pow(numeric);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@i<;![;"I"@return [Numeric];T;#0;$@i<;.F;Bi;C0;7[[I" numeric;T0;$@i<o;= ;>I" overload;F;?0;;/;@0;:I"pow(integer, integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@i<;![;"I"@return [Integer];T;#0;$@i<;.F;Bi;C0;7[[I" integer;T0[I" integer;T0;$@i<;![;"I"Returns (modular) exponentiation as: a.pow(b) #=> same as a**b a.pow(b, m) #=> same as (a**b) % m, but avoids huge temporary values @overload pow(numeric) @return [Numeric] @overload pow(integer, integer) @return [Integer];T;#0;$@i<;.F;/o;0;1T;2i;3i;%@8;9I"&VALUE rb_int_powm(int const argc, VALUE * const argv, VALUE const num) { rb_check_arity(argc, 1, 2); if (argc == 1) { return rb_int_pow(num, argv[0]); } else { VALUE const a = num; VALUE const b = argv[0]; VALUE m = argv[1]; int nega_flg = 0; if ( ! RB_INTEGER_TYPE_P(b)) { rb_raise(rb_eTypeError, "Integer#pow() 2nd argument not allowed unless a 1st argument is integer"); } if (rb_int_negative_p(b)) { rb_raise(rb_eRangeError, "Integer#pow() 1st argument cannot be negative when 2nd argument specified"); } if (!RB_INTEGER_TYPE_P(m)) { rb_raise(rb_eTypeError, "Integer#pow() 2nd argument not allowed unless all arguments are integers"); } if (rb_int_negative_p(m)) { m = rb_int_uminus(m); nega_flg = 1; } if (FIXNUM_P(m)) { long const half_val = (long)HALF_LONG_MSB; long const mm = FIX2LONG(m); if (!mm) rb_num_zerodiv(); if (mm == 1) return INT2FIX(0); if (mm <= half_val) { return int_pow_tmp1(rb_int_modulo(a, m), b, mm, nega_flg); } else { return int_pow_tmp2(rb_int_modulo(a, m), b, mm, nega_flg); } } else { if (rb_bigzero_p(m)) rb_num_zerodiv(); if (bignorm(m) == INT2FIX(1)) return INT2FIX(0); return int_pow_tmp3(rb_int_modulo(a, m), b, m, nega_flg); } } UNREACHABLE_RETURN(Qnil); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#===;F;7[[I"y;T0;[[@i;T;;S;0;[;{;IC; "Returns +true+ if +self+ is numerically equal to +other+; +false+ otherwise. 1 == 2 #=> false 1 == 1.0 #=> true Related: Integer#eql? (requires +other+ to be an \Integer). Integer#=== is an alias for Integer#==. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@<;![;"I"@return [Boolean];T;#0;$@<;.F;Bi;C0;7[[I" other;T0;$@<;![;"I" Returns +true+ if +self+ is numerically equal to +other+; +false+ otherwise. 1 == 2 #=> false 1 == 1.0 #=> true Related: Integer#eql? (requires +other+ to be an \Integer). Integer#=== is an alias for Integer#==. @overload ==(other) @return [Boolean];T;#0;$@<;.F;/o;0;1T;2i;3i;%@8;9I"VALUE rb_int_equal(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_equal(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_eq(x, y); } return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#==;F;7[[I"y;T0;[[@i;T;;F;0;[;{;IC; "Returns +true+ if +self+ is numerically equal to +other+; +false+ otherwise. 1 == 2 #=> false 1 == 1.0 #=> true Related: Integer#eql? (requires +other+ to be an \Integer). Integer#=== is an alias for Integer#==. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@<;![;"I"@return [Boolean];T;#0;$@<;.F;Bi;C0;7[[I" other;T0;$@<;![;"@<;#0;$@<;.F;/o;0;1T;2i;3i;%@8;9I"VALUE rb_int_equal(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_equal(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_eq(x, y); } return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#>;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "Returns +true+ if the value of +self+ is greater than that of +other+: 1 > 0 # => true 1 > 1 # => false 1 > 2 # => false 1 > 0.5 # => true 1 > Rational(1, 2) # => true Raises an exception if the comparison cannot be made. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" >(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@<;![;"I"@return [Boolean];T;#0;$@<;.F;Bi;C0;7[[I" other;T0;$@<;![;"I"EReturns +true+ if the value of +self+ is greater than that of +other+: 1 > 0 # => true 1 > 1 # => false 1 > 2 # => false 1 > 0.5 # => true 1 > Rational(1, 2) # => true Raises an exception if the comparison cannot be made. @overload >(other) @return [Boolean];T;#0;$@<;.F;/o;0;1T;2iz;3i;%@8;9I"VALUE rb_int_gt(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_gt(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_gt(x, y); } return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#>=;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "+Returns +true+ if the value of +self+ is greater than or equal to that of +other+: 1 >= 0 # => true 1 >= 1 # => true 1 >= 2 # => false 1 >= 0.5 # => true 1 >= Rational(1, 2) # => true Raises an exception if the comparison cannot be made. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" >=(real);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@<;![;"I"@return [Boolean];T;#0;$@<;.F;Bi;C0;7[[I" real;T0;$@<;![;"I"UReturns +true+ if the value of +self+ is greater than or equal to that of +other+: 1 >= 0 # => true 1 >= 1 # => true 1 >= 2 # => false 1 >= 0.5 # => true 1 >= Rational(1, 2) # => true Raises an exception if the comparison cannot be made. @overload >=(real) @return [Boolean];T;#0;$@<;.F;/o;0;1T;2i;3i;%@8;9I"VALUE rb_int_ge(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_ge(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_ge(x, y); } return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#<;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; " Returns +true+ if the value of +self+ is less than that of +other+: 1 < 0 # => false 1 < 1 # => false 1 < 2 # => true 1 < 0.5 # => false 1 < Rational(1, 2) # => false Raises an exception if the comparison cannot be made. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" <(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@=;![;"I"@return [Boolean];T;#0;$@=;.F;Bi;C0;7[[I" other;T0;$@=;![;"I"JReturns +true+ if the value of +self+ is less than that of +other+: 1 < 0 # => false 1 < 1 # => false 1 < 2 # => true 1 < 0.5 # => false 1 < Rational(1, 2) # => false Raises an exception if the comparison cannot be made. @overload <(other) @return [Boolean];T;#0;$@=;.F;/o;0;1T;2i;3i;%@8;9I"static VALUE int_lt(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_lt(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_lt(x, y); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#<=;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "1Returns +true+ if the value of +self+ is less than or equal to that of +other+: 1 <= 0 # => false 1 <= 1 # => true 1 <= 2 # => true 1 <= 0.5 # => false 1 <= Rational(1, 2) # => false Raises an exception if the comparison cannot be made. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" <=(real);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@5=;![;"I"@return [Boolean];T;#0;$@5=;.F;Bi;C0;7[[I" real;T0;$@5=;![;"I"\ Returns +true+ if the value of +self+ is less than or equal to that of +other+: 1 <= 0 # => false 1 <= 1 # => true 1 <= 2 # => true 1 <= 0.5 # => false 1 <= Rational(1, 2) # => false Raises an exception if the comparison cannot be made. @overload <=(real) @return [Boolean];T;#0;$@5=;.F;/o;0;1T;2i;3i;%@8;9I"static VALUE int_le(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_le(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_le(x, y); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#&;F;7[[I"y;T0;[[@in;T;;E;0;[;{;IC; "Bitwise AND; each bit in the result is 1 if both corresponding bits in +self+ and +other+ are 1, 0 otherwise: "%04b" % (0b0101 & 0b0110) # => "0100" Raises an exception if +other+ is not an \Integer. Related: Integer#| (bitwise OR), Integer#^ (bitwise EXCLUSIVE OR). ;T;[o;= ;>I" overload;F;?0;;E;@0;:I" &(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@T=;![;"I"@return [Integer];T;#0;$@T=;.F;Bi;C0;7[[I" other;T0;$@T=;![;"I"9Bitwise AND; each bit in the result is 1 if both corresponding bits in +self+ and +other+ are 1, 0 otherwise: "%04b" % (0b0101 & 0b0110) # => "0100" Raises an exception if +other+ is not an \Integer. Related: Integer#| (bitwise OR), Integer#^ (bitwise EXCLUSIVE OR). @overload &(other) @return [Integer];T;#0;$@T=;.F;/o;0;1T;2i_;3ik;%@8;9I"VALUE rb_int_and(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_and(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_and(x, y); } return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#|;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "Bitwise OR; each bit in the result is 1 if either corresponding bit in +self+ or +other+ is 1, 0 otherwise: "%04b" % (0b0101 | 0b0110) # => "0111" Raises an exception if +other+ is not an \Integer. Related: Integer#& (bitwise AND), Integer#^ (bitwise EXCLUSIVE OR). ;T;[o;= ;>I" overload;F;?0;;;@0;:I" |(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@s=;![;"I"@return [Integer];T;#0;$@s=;.F;Bi;C0;7[[I" other;T0;$@s=;![;"I"8Bitwise OR; each bit in the result is 1 if either corresponding bit in +self+ or +other+ is 1, 0 otherwise: "%04b" % (0b0101 | 0b0110) # => "0111" Raises an exception if +other+ is not an \Integer. Related: Integer#& (bitwise AND), Integer#^ (bitwise EXCLUSIVE OR). @overload |(other) @return [Integer];T;#0;$@s=;.F;/o;0;1T;2i;3i;%@8;9I"static VALUE int_or(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_or(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_or(x, y); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#^;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "Bitwise EXCLUSIVE OR; each bit in the result is 1 if the corresponding bits in +self+ and +other+ are different, 0 otherwise: "%04b" % (0b0101 ^ 0b0110) # => "0011" Raises an exception if +other+ is not an \Integer. Related: Integer#& (bitwise AND), Integer#| (bitwise OR). ;T;[o;= ;>I" overload;F;?0;;;@0;:I" ^(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@=;![;"I"@return [Integer];T;#0;$@=;.F;Bi;C0;7[[I" other;T0;$@=;![;"I"@Bitwise EXCLUSIVE OR; each bit in the result is 1 if the corresponding bits in +self+ and +other+ are different, 0 otherwise: "%04b" % (0b0101 ^ 0b0110) # => "0011" Raises an exception if +other+ is not an \Integer. Related: Integer#& (bitwise AND), Integer#| (bitwise OR). @overload ^(other) @return [Integer];T;#0;$@=;.F;/o;0;1T;2i;3i;%@8;9I"static VALUE int_xor(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return fix_xor(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_xor(x, y); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#[];F;7[[I"*;T0[I" const;T0;[[@i;T;;;0;[;{;IC; "Returns a slice of bits from +self+. With argument +offset+, returns the bit at the given offset, where offset 0 refers to the least significant bit: n = 0b10 # => 2 n[0] # => 0 n[1] # => 1 n[2] # => 0 n[3] # => 0 In principle, n[i] is equivalent to (n >> i) & 1. Thus, negative index always returns zero: 255[-1] # => 0 With arguments +offset+ and +size+, returns +size+ bits from +self+, beginning at +offset+ and including bits of greater significance: n = 0b111000 # => 56 "%010b" % n[0, 10] # => "0000111000" "%010b" % n[4, 10] # => "0000000011" With argument +range+, returns range.size bits from +self+, beginning at range.begin and including bits of greater significance: n = 0b111000 # => 56 "%010b" % n[0..9] # => "0000111000" "%010b" % n[4..9] # => "0000000011" Raises an exception if the slice cannot be constructed. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"[](offset);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;TI"1;T;$@=;![;"I"@return [0, 1];T;#0;$@=;.F;Bi;C0;7[[I" offset;T0;$@=o;= ;>I" overload;F;?0;;;@0;:I"[](offset, size);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@=;![;"I"@return [Integer];T;#0;$@=;.F;Bi;C0;7[[I" offset;T0[I" size;T0;$@=o;= ;>I" overload;F;?0;;;@0;:I"[](range);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@=;![;"I"@return [Integer];T;#0;$@=;.F;Bi;C0;7[[I" range;T0;$@=;![;"I"$Returns a slice of bits from +self+. With argument +offset+, returns the bit at the given offset, where offset 0 refers to the least significant bit: n = 0b10 # => 2 n[0] # => 0 n[1] # => 1 n[2] # => 0 n[3] # => 0 In principle, n[i] is equivalent to (n >> i) & 1. Thus, negative index always returns zero: 255[-1] # => 0 With arguments +offset+ and +size+, returns +size+ bits from +self+, beginning at +offset+ and including bits of greater significance: n = 0b111000 # => 56 "%010b" % n[0, 10] # => "0000111000" "%010b" % n[4, 10] # => "0000000011" With argument +range+, returns range.size bits from +self+, beginning at range.begin and including bits of greater significance: n = 0b111000 # => 56 "%010b" % n[0..9] # => "0000111000" "%010b" % n[4..9] # => "0000000011" Raises an exception if the slice cannot be constructed. @overload [](offset) @return [0, 1] @overload [](offset, size) @return [Integer] @overload [](range) @return [Integer];T;#0;$@=;.F;/o;0;1T;2i;3i;%@8;9I"static VALUE int_aref(int const argc, VALUE * const argv, VALUE const num) { rb_check_arity(argc, 1, 2); if (argc == 2) { return int_aref2(num, argv[0], argv[1]); } return int_aref1(num, argv[0]); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#<<;F;7[[I"y;T0;[[@i;T;;;0;[;{;IC; "'Returns +self+ with bits shifted +count+ positions to the left, or to the right if +count+ is negative: n = 0b11110000 "%08b" % (n << 1) # => "111100000" "%08b" % (n << 3) # => "11110000000" "%08b" % (n << -1) # => "01111000" "%08b" % (n << -3) # => "00011110" Related: Integer#>>. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"<<(count);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@=;![;"I"@return [Integer];T;#0;$@=;.F;Bi;C0;7[[I" count;T0;$@=;![;"I"RReturns +self+ with bits shifted +count+ positions to the left, or to the right if +count+ is negative: n = 0b11110000 "%08b" % (n << 1) # => "111100000" "%08b" % (n << 3) # => "11110000000" "%08b" % (n << -1) # => "01111000" "%08b" % (n << -3) # => "00011110" Related: Integer#>>. @overload <<(count) @return [Integer];T;#0;$@=;.F;/o;0;1T;2i;3i;%@8;9I"VALUE rb_int_lshift(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return rb_fix_lshift(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_lshift(x, y); } return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#>>;F;7[[I"y;T0;[[@i/;T;;;0;[;{;IC; "'Returns +self+ with bits shifted +count+ positions to the right, or to the left if +count+ is negative: n = 0b11110000 "%08b" % (n >> 1) # => "01111000" "%08b" % (n >> 3) # => "00011110" "%08b" % (n >> -1) # => "111100000" "%08b" % (n >> -3) # => "11110000000" Related: Integer#<<. ;T;[o;= ;>I" overload;F;?0;;;@0;:I">>(count);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@>;![;"I"@return [Integer];T;#0;$@>;.F;Bi;C0;7[[I" count;T0;$@>;![;"I"RReturns +self+ with bits shifted +count+ positions to the right, or to the left if +count+ is negative: n = 0b11110000 "%08b" % (n >> 1) # => "01111000" "%08b" % (n >> 3) # => "00011110" "%08b" % (n >> -1) # => "111100000" "%08b" % (n >> -3) # => "11110000000" Related: Integer#<<. @overload >>(count) @return [Integer];T;#0;$@>;.F;/o;0;1T;2i;3i,;%@8;9I"static VALUE rb_int_rshift(VALUE x, VALUE y) { if (FIXNUM_P(x)) { return rb_fix_rshift(x, y); } else if (RB_BIGNUM_TYPE_P(x)) { return rb_big_rshift(x, y); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#digits;F;7[[@90;[[@i;T;: digits;0;[;{;IC; "PReturns an array of integers representing the +base+-radix digits of +self+; the first element of the array represents the least significant digit: 12345.digits # => [5, 4, 3, 2, 1] 12345.digits(7) # => [4, 6, 6, 0, 5] 12345.digits(100) # => [45, 23, 1] Raises an exception if +self+ is negative or +base+ is less than 2. ;T;[o;= ;>I" overload;F;?0;;0;@0;:I"digits(base = 10);T;IC; ";T;[;![;"I";T;#0;$@1>;.F;Bi;C0;7[[I" base;TI"10;T;$@1>;![;"I"oReturns an array of integers representing the +base+-radix digits of +self+; the first element of the array represents the least significant digit: 12345.digits # => [5, 4, 3, 2, 1] 12345.digits(7) # => [4, 6, 6, 0, 5] 12345.digits(100) # => [45, 23, 1] Raises an exception if +self+ is negative or +base+ is less than 2. @overload digits(base = 10);T;#0;$@1>;.F;/o;0;1T;2i;3i;%@8;9I"static VALUE rb_int_digits(int argc, VALUE *argv, VALUE num) { VALUE base_value; long base; if (rb_num_negative_p(num)) rb_raise(rb_eMathDomainError, "out of domain"); if (rb_check_arity(argc, 0, 1)) { base_value = rb_to_int(argv[0]); if (!RB_INTEGER_TYPE_P(base_value)) rb_raise(rb_eTypeError, "wrong argument type %s (expected Integer)", rb_obj_classname(argv[0])); if (RB_BIGNUM_TYPE_P(base_value)) return rb_int_digits_bigbase(num, base_value); base = FIX2LONG(base_value); if (base < 0) rb_raise(rb_eArgError, "negative radix"); else if (base < 2) rb_raise(rb_eArgError, "invalid radix %ld", base); } else base = 10; if (FIXNUM_P(num)) return rb_fix_digits(num, base); else if (RB_BIGNUM_TYPE_P(num)) return rb_int_digits_bigbase(num, LONG2FIX(base)); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#gcd;F;7[[I" other;T0;[[@rio;T;;;0;[;{;IC; "Returns the greatest common divisor of the two integers. The result is always positive. 0.gcd(x) and x.gcd(0) return x.abs. 36.gcd(60) #=> 12 2.gcd(2) #=> 2 3.gcd(-7) #=> 1 ((1<<31)-1).gcd((1<<61)-1) #=> 1 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"gcd(other_int);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@K>;![;"I"@return [Integer];T;#0;$@K>;.F;Bi;C0;7[[I"other_int;T0;$@K>;![;"I"@Returns the greatest common divisor of the two integers. The result is always positive. 0.gcd(x) and x.gcd(0) return x.abs. 36.gcd(60) #=> 12 2.gcd(2) #=> 2 3.gcd(-7) #=> 1 ((1<<31)-1).gcd((1<<61)-1) #=> 1 @overload gcd(other_int) @return [Integer];T;#0;$@K>;.F;/o;0;1T;2ic;3im;%@8;9I"qVALUE rb_gcd(VALUE self, VALUE other) { other = nurat_int_value(other); return f_gcd(self, other); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#lcm;F;7[[I" other;T0;[[@ri;T;:lcm;0;[;{;IC; "+Returns the least common multiple of the two integers. The result is always positive. 0.lcm(x) and x.lcm(0) return zero. 36.lcm(60) #=> 180 2.lcm(2) #=> 2 3.lcm(-7) #=> 21 ((1<<31)-1).lcm((1<<61)-1) #=> 4951760154835678088235319297 ;T;[o;= ;>I" overload;F;?0;;1;@0;:I"lcm(other_int);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@j>;![;"I"@return [Integer];T;#0;$@j>;.F;Bi;C0;7[[I"other_int;T0;$@j>;![;"I"ZReturns the least common multiple of the two integers. The result is always positive. 0.lcm(x) and x.lcm(0) return zero. 36.lcm(60) #=> 180 2.lcm(2) #=> 2 3.lcm(-7) #=> 21 ((1<<31)-1).lcm((1<<61)-1) #=> 4951760154835678088235319297 @overload lcm(other_int) @return [Integer];T;#0;$@j>;.F;/o;0;1T;2iv;3i;%@8;9I"qVALUE rb_lcm(VALUE self, VALUE other) { other = nurat_int_value(other); return f_lcm(self, other); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#gcdlcm;F;7[[I" other;T0;[[@ri;T;: gcdlcm;0;[;{;IC; "DReturns an array with the greatest common divisor and the least common multiple of the two integers, [gcd, lcm]. 36.gcdlcm(60) #=> [12, 180] 2.gcdlcm(2) #=> [2, 2] 3.gcdlcm(-7) #=> [1, 21] ((1<<31)-1).gcdlcm((1<<61)-1) #=> [1, 4951760154835678088235319297] ;T;[o;= ;>I" overload;F;?0;;2;@0;:I"gcdlcm(other_int);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@>;![;"I"@return [Array];T;#0;$@>;.F;Bi;C0;7[[I"other_int;T0;$@>;![;"I"tReturns an array with the greatest common divisor and the least common multiple of the two integers, [gcd, lcm]. 36.gcdlcm(60) #=> [12, 180] 2.gcdlcm(2) #=> [2, 2] 3.gcdlcm(-7) #=> [1, 21] ((1<<31)-1).gcdlcm((1<<61)-1) #=> [1, 4951760154835678088235319297] @overload gcdlcm(other_int) @return [Array];T;#0;$@>;.F;/o;0;1T;2i;3i;%@8;9I"VALUE rb_gcdlcm(VALUE self, VALUE other) { other = nurat_int_value(other); return rb_assoc_new(f_gcd(self, other), f_lcm(self, other)); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Integer#numerator;F;7[;[[@ri;T;;;0;[;{;IC; "Returns self. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"numerator;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@>;![;"I"@return [self];T;#0;$@>;.F;Bi;C0;7[;$@>;![;"I"9Returns self. @overload numerator @return [self];T;#0;$@>;.F;/o;0;1T;2i;3i ;%@8;9I"Dstatic VALUE integer_numerator(VALUE self) { return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#denominator;F;7[;[[@ri;T;;;0;[;{;IC; "Returns 1. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"denominator;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"1;T;$@>;![;"I"@return [ 1];T;#0;$@>;.F;Bi;C0;7[;$@>;![;"I"6Returns 1. @overload denominator @return [ 1];T;#0;$@>;.F;/o;0;1T;2i;3i;%@8;9I"Lstatic VALUE integer_denominator(VALUE self) { return INT2FIX(1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#to_r;F;7[;[[@rin;T;;;0;[;{;IC; "oReturns the value as a rational. 1.to_r #=> (1/1) (1<<64).to_r #=> (18446744073709551616/1) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_r;T;IC; ";T;[;![;"I";T;#0;$@>;.F;Bi;C0;7[;$@>;![;"I"{Returns the value as a rational. 1.to_r #=> (1/1) (1<<64).to_r #=> (18446744073709551616/1) @overload to_r;T;#0;$@>;.F;/o;0;1T;2ie;3ik;%@8;9I"Qstatic VALUE integer_to_r(VALUE self) { return rb_rational_new1(self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Integer#rationalize;F;7[[@90;[[@ri{;T;;;0;[;{;IC; "UReturns the value as a rational. The optional argument +eps+ is always ignored. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"rationalize([eps]);T;IC; ";T;[;![;"I";T;#0;$@>;.F;Bi;C0;7[[I" [eps];T0;$@>;![;"I"tReturns the value as a rational. The optional argument +eps+ is always ignored. @overload rationalize([eps]);T;#0;$@>;.F;/o;0;1T;2it;3ix;%@8;9I"static VALUE integer_rationalize(int argc, VALUE *argv, VALUE self) { rb_check_arity(argc, 0, 1); return integer_to_r(self); };T;:I"static VALUE;T;;T; @8; IC;[; @8; IC;[; @8; IC;{;IC;{;T;IC;{;T;T;{@O9;G;[;[[@i [@iO;T;;;;;;;[;{;IC; "****************************************************************** An \Integer object represents an integer value. You can create an \Integer object explicitly with: - An {integer literal}[doc/syntax/literals_rdoc.html#label-Integer+Literals]. You can convert certain objects to Integers with: - \Method {Integer}[Kernel.html#method-i-Integer]. An attempt to add a singleton method to an instance of this class causes an exception to be raised. == What's Here First, what's elsewhere. \Class \Integer: - Inherits from {class Numeric}[Numeric.html#class-Numeric-label-What-27s+Here]. Here, class \Integer provides methods for: - {Querying}[#class-Integer-label-Querying] - {Comparing}[#class-Integer-label-Comparing] - {Converting}[#class-Integer-label-Converting] - {Other}[#class-Integer-label-Other] === Querying - #allbits?:: Returns whether all bits in +self+ are set. - #anybits?:: Returns whether any bits in +self+ are set. - #nobits?:: Returns whether no bits in +self+ are set. === Comparing - {<}[#method-i-3C]:: Returns whether +self+ is less than the given value. - {<=}[#method-i-3C-3D]:: Returns whether +self+ is less than or equal to the given value. - {<=>}[#method-i-3C-3D-3E]:: Returns a number indicating whether +self+ is less than, equal to, or greater than the given value. - {==}[#method-i-3D-3D] (aliased as #===):: Returns whether +self+ is equal to the given value. - {>}[#method-i-3E]:: Returns whether +self+ is greater than the given value. - {>=}[#method-i-3E-3D]:: Returns whether +self+ is greater than or equal to the given value. === Converting - ::sqrt:: Returns the integer square root of the given value. - ::try_convert:: Returns the given value converted to an \Integer. - #% (aliased as #modulo):: Returns +self+ modulo the given value. - {&}[#method-i-26]:: Returns the bitwise AND of +self+ and the given value. - #*:: Returns the product of +self+ and the given value. - {**}[#method-i-2A-2A]:: Returns the value of +self+ raised to the power of the given value. - #+:: Returns the sum of +self+ and the given value. - #-:: Returns the difference of +self+ and the given value. - {/}[#method-i-2F]:: Returns the quotient of +self+ and the given value. - #<<:: Returns the value of +self+ after a leftward bit-shift. - #>>:: Returns the value of +self+ after a rightward bit-shift. - #[]:: Returns a slice of bits from +self+. - {^}[#method-i-5E]:: Returns the bitwise EXCLUSIVE OR of +self+ and the given value. - #ceil:: Returns the smallest number greater than or equal to +self+. - #chr:: Returns a 1-character string containing the character represented by the value of +self+. - #digits:: Returns an array of integers representing the base-radix digits of +self+. - #div:: Returns the integer result of dividing +self+ by the given value. - #divmod:: Returns a 2-element array containing the quotient and remainder results of dividing +self+ by the given value. - #fdiv:: Returns the Float result of dividing +self+ by the given value. - #floor:: Returns the greatest number smaller than or equal to +self+. - #pow:: Returns the modular exponentiation of +self+. - #pred:: Returns the integer predecessor of +self+. - #remainder:: Returns the remainder after dividing +self+ by the given value. - #round:: Returns +self+ rounded to the nearest value with the given precision. - #succ (aliased as #next):: Returns the integer successor of +self+. - #to_f:: Returns +self+ converted to a Float. - #to_s (aliased as #inspect):: Returns a string containing the place-value representation of +self+ in the given radix. - #truncate:: Returns +self+ truncated to the given precision. - {/}[#method-i-7C]:: Returns the bitwise OR of +self+ and the given value. === Other - #downto:: Calls the given block with each integer value from +self+ down to the given value. - #times:: Calls the given block +self+ times with each integer in (0..self-1). - #upto:: Calls the given block with each integer value from +self+ up to the given value.;T;[;![;"I"****************************************************************** An \Integer object represents an integer value. You can create an \Integer object explicitly with: - An {integer literal}[doc/syntax/literals_rdoc.html#label-Integer+Literals]. You can convert certain objects to Integers with: - \Method {Integer}[Kernel.html#method-i-Integer]. An attempt to add a singleton method to an instance of this class causes an exception to be raised. == What's Here First, what's elsewhere. \Class \Integer: - Inherits from {class Numeric}[Numeric.html#class-Numeric-label-What-27s+Here]. Here, class \Integer provides methods for: - {Querying}[#class-Integer-label-Querying] - {Comparing}[#class-Integer-label-Comparing] - {Converting}[#class-Integer-label-Converting] - {Other}[#class-Integer-label-Other] === Querying - #allbits?:: Returns whether all bits in +self+ are set. - #anybits?:: Returns whether any bits in +self+ are set. - #nobits?:: Returns whether no bits in +self+ are set. === Comparing - {<}[#method-i-3C]:: Returns whether +self+ is less than the given value. - {<=}[#method-i-3C-3D]:: Returns whether +self+ is less than or equal to the given value. - {<=>}[#method-i-3C-3D-3E]:: Returns a number indicating whether +self+ is less than, equal to, or greater than the given value. - {==}[#method-i-3D-3D] (aliased as #===):: Returns whether +self+ is equal to the given value. - {>}[#method-i-3E]:: Returns whether +self+ is greater than the given value. - {>=}[#method-i-3E-3D]:: Returns whether +self+ is greater than or equal to the given value. === Converting - ::sqrt:: Returns the integer square root of the given value. - ::try_convert:: Returns the given value converted to an \Integer. - #% (aliased as #modulo):: Returns +self+ modulo the given value. - {&}[#method-i-26]:: Returns the bitwise AND of +self+ and the given value. - #*:: Returns the product of +self+ and the given value. - {**}[#method-i-2A-2A]:: Returns the value of +self+ raised to the power of the given value. - #+:: Returns the sum of +self+ and the given value. - #-:: Returns the difference of +self+ and the given value. - {/}[#method-i-2F]:: Returns the quotient of +self+ and the given value. - #<<:: Returns the value of +self+ after a leftward bit-shift. - #>>:: Returns the value of +self+ after a rightward bit-shift. - #[]:: Returns a slice of bits from +self+. - {^}[#method-i-5E]:: Returns the bitwise EXCLUSIVE OR of +self+ and the given value. - #ceil:: Returns the smallest number greater than or equal to +self+. - #chr:: Returns a 1-character string containing the character represented by the value of +self+. - #digits:: Returns an array of integers representing the base-radix digits of +self+. - #div:: Returns the integer result of dividing +self+ by the given value. - #divmod:: Returns a 2-element array containing the quotient and remainder results of dividing +self+ by the given value. - #fdiv:: Returns the Float result of dividing +self+ by the given value. - #floor:: Returns the greatest number smaller than or equal to +self+. - #pow:: Returns the modular exponentiation of +self+. - #pred:: Returns the integer predecessor of +self+. - #remainder:: Returns the remainder after dividing +self+ by the given value. - #round:: Returns +self+ rounded to the nearest value with the given precision. - #succ (aliased as #next):: Returns the integer successor of +self+. - #to_f:: Returns +self+ converted to a Float. - #to_s (aliased as #inspect):: Returns a string containing the place-value representation of +self+ in the given radix. - #truncate:: Returns +self+ truncated to the given precision. - {/}[#method-i-7C]:: Returns the bitwise OR of +self+ and the given value. === Other - #downto:: Calls the given block with each integer value from +self+ down to the given value. - #times:: Calls the given block +self+ times with each integer in (0..self-1). - #upto:: Calls the given block with each integer value from +self+ up to the given value. ;T;#0;$@8;.F;/o;0;1T;2i ;3i ;Bi;%@;&I" Integer;F;'@&o;;IC;[@o;;IC;[; @!?; IC;[; @!?; IC;[; @!?; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"ext/-test-/proc/init.c;Ti;F;: Proc;;;;;[;{;IC; " ;T;[;![;"@;#0;$@!?;%@?;&I"Bug::Proc;Fo; ;IC;[o;4;5F;6;;;;&I"#Bug::NotImplement#notimplement;F;7[[@90;[[@iF;T;:notimplement;0;[;{;IC; " ;T;[;![;"@;#0;$@5?;%@3?;9I"VALUE rb_f_notimplement(int argc, const VALUE *argv, VALUE obj, VALUE marker) { rb_notimplement(); UNREACHABLE_RETURN(Qnil); };T;:I" VALUE;T;;T; @3?; IC;[; @3?; IC;[; @3?; IC;{;IC;{;T;IC;{;T;T;{;[;[[I""ext/-test-/notimplement/bug.c;Ti;F;:NotImplement;;;;;[;{;IC; " ;T;[;![;"@;#0;$@3?;%@?;&I"Bug::NotImplement;F;'@o;4;5F;6;;;;&I"Bug#funcall;F;7[[@90;[[@K?i;T;: funcall;0;[;{;IC; " ;T;[;![;"I";F;#0;$@R?;.F;C0;%@?;9I"static VALUE bug_funcall(int argc, VALUE *argv, VALUE self) { if (argc < 1) rb_raise(rb_eArgError, "not enough argument"); return rb_funcallv(self, rb_to_id(*argv), argc-1, argv+1); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Bug.funcall;F;7@T?;@V?;T;;6;0;@X?;{;IC; " ;T;[;![;"@;#0;$@`?;Bi;%@?;9@^?;:@_?;;To;4;5F;6;;;;&I"Bug#notimplement;F;7[[@90;[[@iF;T;;4;0;[;{;IC; " ;T;[;![;"I";F;#0;$@f?;.F;C0;%@?;9I"VALUE rb_f_notimplement(int argc, const VALUE *argv, VALUE obj, VALUE marker) { rb_notimplement(); UNREACHABLE_RETURN(Qnil); };T;:I" VALUE;T;;To;4;5T;6;;;;&I"Bug.notimplement;F;7@h?;@j?;T;;4;0;@l?;{;IC; " ;T;[;![;"@;#0;$@t?;Bi;%@?;9@r?;:@s?;;To;;IC;[o;4;5F;6;;;;&I"Bug::EnumeratorKw#m;F;7[[@90;[[I"-ext/-test-/enumerator_kw/enumerator_kw.c;Ti;T;:m;0;[;{;IC; " ;T;[;![;"@;#0;$@|?;%@z?;9I"static VALUE enumerator_kw(int argc, VALUE *argv, VALUE self) { VALUE opt, enum_args[4]; enum_args[0] = Qnil; enum_args[1] = Qnil; rb_scan_args(argc, argv, "01*:", enum_args, enum_args+1, &opt); enum_args[3] = self; enum_args[2] = opt; RETURN_SIZED_ENUMERATOR_KW(self, 4, enum_args, 0, RB_NO_KEYWORDS); return rb_yield_values_kw(4, enum_args, RB_NO_KEYWORDS); };T;:I"static VALUE;T;;T; @z?; IC;[; @z?; IC;[; @z?; IC;{;IC;{;T;IC;{;T;T;{;[;[[@?i;F;:EnumeratorKw;;;;;[;{;IC; " ;T;[;![;"@;#0;$@z?;%@?;&I"Bug::EnumeratorKw;Fo;;IC;[o;4;5F;6;;;;&I"Bug::Thread.runnable_sleep;F;7[[I" timeout;T0;[[I"7ext/-test-/gvl/call_without_gvl/call_without_gvl.c;Ti;T;:runnable_sleep;0;[;{;IC; " ;T;[;![;"@;#0;$@?;%@?;9I"Estatic VALUE thread_runnable_sleep(VALUE thread, VALUE timeout) { struct timeval timeval; if (NIL_P(timeout)) { rb_raise(rb_eArgError, "timeout must be non nil"); } timeval = rb_time_interval(timeout); rb_thread_call_without_gvl(native_sleep_callback, &timeval, RUBY_UBF_IO, NULL); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Thread.ubf_async_safe;F;7[[I"notify_fd;T0;[[@?i@;T;:ubf_async_safe;0;[;{;IC; " ;T;[;![;"@;#0;$@?;%@?;9I"static VALUE thread_ubf_async_safe(VALUE thread, VALUE notify_fd) { struct loop_ctl ctl; ctl.notify_fd = NUM2INT(notify_fd); ctl.stop = 0; rb_nogvl(do_loop, &ctl, stop_set, &ctl, RB_NOGVL_UBF_ASYNC_SAFE); return Qnil; };T;:I"static VALUE;T;;T; @?; IC;[; @?; IC;[; @?; IC;{;IC;{;T;IC;{;T;T;{;[;[[@?iP;F;;Z;;;;;[;{;IC; " ;T;[;![;"@;#0;$@?;%@?;&I"Bug::Thread;Fo;;IC;[ o;;IC;[ o;4;5F;6;;;;&I"$Bug::Iter::Breakable#iter_break;F;7[;[[I"ext/-test-/iter/break.c;Ti;T;:iter_break;0;[;{;IC; " ;T;[;![;"I";F;#0;$@?;.F;C0;%@?;9I"`static VALUE iter_break(VALUE self) { rb_iter_break(); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"$Bug::Iter::Breakable.iter_break;F;7@?;@?;T;;;;0;@?;{;IC; " ;T;[;![;"@;#0;$@?;Bi;%@?;9@?;:@?;;To;4;5F;6;;;;&I"*Bug::Iter::Breakable#iter_break_value;F;7[[I"val;T0;[[@?i;T;:iter_break_value;0;[;{;IC; " ;T;[;![;"I";F;#0;$@?;.F;C0;%@?;9I"zstatic VALUE iter_break_value(VALUE self, VALUE val) { rb_iter_break_value(val); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"*Bug::Iter::Breakable.iter_break_value;F;7@?;@?;T;;<;0;@?;{;IC; " ;T;[;![;"@;#0;$@?;Bi;%@?;9@?;:@?;;T; @?; IC;[; @?; IC;[; @?; IC;{;IC;{;T;IC;{;T;T;{;[;[[@?i;F;:Breakable;;;;;[;{;IC; " ;T;[;![;"@;#0;$@?;%@?;&I"Bug::Iter::Breakable;Fo;;IC;[o;4;5F;6;;;;&I"!Bug::Iter::Yield#yield_block;F;7[[@90;[[I"ext/-test-/iter/yield.c;Ti;T;:yield_block;0;[;{;IC; " ;T;[;![;"@;#0;$@@;%@@;9I"static VALUE yield_block(int argc, VALUE *argv, VALUE self) { rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS); return rb_block_call_kw(self, rb_to_id(argv[0]), argc-1, argv+1, rb_yield_block, 0, RB_PASS_CALLED_KEYWORDS); };T;:I"static VALUE;T;;T; @@; IC;[; @@; IC;[; @@; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ @i;F;: Yield;;;;;[;{;IC; " ;T;[;![;"@;#0;$@@;Bi;%@?;&I"Bug::Iter::Yield;Fo;4;5F;6;;;;&I" Bug::Iter.parse_depth_limit;F;7[;[[I"*ext/-test-/regexp/parse_depth_limit.c;Ti ;T;:parse_depth_limit;0;[;{;IC; " ;T;[;![;"@;#0;$@"@;%@?;9I"static VALUE get_parse_depth_limit(VALUE self) { unsigned int depth = onig_get_parse_depth_limit(); return UINT2NUM(depth); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Bug::Iter.parse_depth_limit=;F;7[[I" depth;T0;[[@'@i;T;:parse_depth_limit=;0;[;{;IC; " ;T;[;![;"@;#0;$@/@;%@?;9I"static VALUE set_parse_depth_limit(VALUE self, VALUE depth) { onig_set_parse_depth_limit(NUM2UINT(depth)); return depth; };T;:I"static VALUE;T;;T; @?; IC;[; @?; IC;[; @?; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"ext/-test-/iter/init.c;Ti;F;: Iter;;;;;[;{;IC; " ;T;[;![;"@;#0;$@?;%@?;&I"Bug::Iter;Fo; ;IC;[; @M@; IC;[; @M@; IC;[; @M@; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"ext/-test-/regexp/init.c;Ti;F;: Regexp;;;;;[;{;IC; " ;T;[;![;"@;#0;$@M@;%@?;&I"Bug::Regexp;F;'o;( ;)0;*0;+0;;C;%@;-o; ;IC;[#o;4;5F;6;;;;&I"Regexp.compile;F;7[[@90;[[@Regexp.new(Regexp.escape(str))=~str will be true. Regexp.escape('\*?{}.') #=> \\\*\?\{\}\. ;T;[o;= ;>I" overload;F;?0;: escape;@0;:I"escape(str);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@q@;![;"I"@return [String];T;#0;$@q@;.F;Bi;C0;7[[I"str;T0;$@q@o;= ;>I" overload;F;?0;;D;@0;:I"quote(str);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@q@;![;"I"@return [String];T;#0;$@q@;.F;Bi;C0;7[[I"str;T0;$@q@;![;"I"rEscapes any characters that would have special meaning in a regular expression. Returns a new escaped string with the same or compatible encoding. For any string, Regexp.new(Regexp.escape(str))=~str will be true. Regexp.escape('\*?{}.') #=> \\\*\?\{\}\. @overload escape(str) @return [String] @overload quote(str) @return [String];T;#0;$@q@;.F;/o;0;1T;2i6;3iB;%@`@;9I"istatic VALUE rb_reg_s_quote(VALUE c, VALUE str) { return rb_reg_quote(reg_operand(str, TRUE)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Regexp.escape;F;7[[I"str;T0;[[@x@iD;T;;E;0;[;{;IC; "Escapes any characters that would have special meaning in a regular expression. Returns a new escaped string with the same or compatible encoding. For any string, Regexp.new(Regexp.escape(str))=~str will be true. Regexp.escape('\*?{}.') #=> \\\*\?\{\}\. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"escape(str);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@@;![;"I"@return [String];T;#0;$@@;.F;Bi;C0;7[[I"str;T0;$@@o;= ;>I" overload;F;?0;;D;@0;:I"quote(str);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@@;![;"I"@return [String];T;#0;$@@;.F;Bi;C0;7[[I"str;T0;$@@;![;"@@;#0;$@@;.F;/o;0;1T;2i6;3iB;%@`@;9I"istatic VALUE rb_reg_s_quote(VALUE c, VALUE str) { return rb_reg_quote(reg_operand(str, TRUE)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Regexp.union;F;7[[I" args;T0;[[@x@i;T;;;0;[;{;IC; "(Return a Regexp object that is the union of the given patterns, i.e., will match any of its parts. The patterns can be Regexp objects, in which case their options will be preserved, or Strings. If no patterns are given, returns /(?!)/. The behavior is unspecified if any given pattern contains capture. Regexp.union #=> /(?!)/ Regexp.union("penzance") #=> /penzance/ Regexp.union("a+b*c") #=> /a\+b\*c/ Regexp.union("skiing", "sledding") #=> /skiing|sledding/ Regexp.union(["skiing", "sledding"]) #=> /skiing|sledding/ Regexp.union(/dogs/, /cats/i) #=> /(?-mix:dogs)|(?i-mx:cats)/ Note: the arguments for ::union will try to be converted into a regular expression literal via #to_regexp. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"union(pat1, pat2, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Regexp;T;$@@;![;"I"@return [Regexp];T;#0;$@@;.F;Bi;C0;7[[I" pat1;T0[I" pat2;T0[I"...;T0;$@@o;= ;>I" overload;F;?0;;;@0;:I"union(pats_ary);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Regexp;T;$@@;![;"I"@return [Regexp];T;#0;$@@;.F;Bi;C0;7[[I" pats_ary;T0;$@@;![;"I"Return a Regexp object that is the union of the given patterns, i.e., will match any of its parts. The patterns can be Regexp objects, in which case their options will be preserved, or Strings. If no patterns are given, returns /(?!)/. The behavior is unspecified if any given pattern contains capture. Regexp.union #=> /(?!)/ Regexp.union("penzance") #=> /penzance/ Regexp.union("a+b*c") #=> /a\+b\*c/ Regexp.union("skiing", "sledding") #=> /skiing|sledding/ Regexp.union(["skiing", "sledding"]) #=> /skiing|sledding/ Regexp.union(/dogs/, /cats/i) #=> /(?-mix:dogs)|(?i-mx:cats)/ Note: the arguments for ::union will try to be converted into a regular expression literal via #to_regexp. @overload union(pat1, pat2, ...) @return [Regexp] @overload union(pats_ary) @return [Regexp];T;#0;$@@;.F;/o;0;1T;2i;3i;%@`@;9I"static VALUE rb_reg_s_union_m(VALUE self, VALUE args) { VALUE v; if (RARRAY_LEN(args) == 1 && !NIL_P(v = rb_check_array_type(rb_ary_entry(args, 0)))) { return rb_reg_s_union(self, v); } return rb_reg_s_union(self, args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Regexp.last_match;F;7[[@90;[[@x@i;T;:last_match;0;[;{;IC; "RThe first form returns the MatchData object generated by the last successful pattern match. Equivalent to reading the special global variable $~ (see Special global variables in Regexp for details). The second form returns the nth field in this MatchData object. _n_ can be a string or symbol to reference a named capture. Note that the last_match is local to the thread and method scope of the method that did the pattern match. /c(.)t/ =~ 'cat' #=> 0 Regexp.last_match #=> # Regexp.last_match(0) #=> "cat" Regexp.last_match(1) #=> "a" Regexp.last_match(2) #=> nil /(?\w+)\s*=\s*(?\w+)/ =~ "var = val" Regexp.last_match #=> # Regexp.last_match(:lhs) #=> "var" Regexp.last_match(:rhs) #=> "val" ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"last_match;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"MatchData;T;$@@;![;"I"@return [MatchData];T;#0;$@@;.F;Bi;C0;7[;$@@o;= ;>I" overload;F;?0;;F;@0;:I"last_match(n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@@;![;"I"@return [String];T;#0;$@@;.F;Bi;C0;7[[I"n;T0;$@@;![;"I"The first form returns the MatchData object generated by the last successful pattern match. Equivalent to reading the special global variable $~ (see Special global variables in Regexp for details). The second form returns the nth field in this MatchData object. _n_ can be a string or symbol to reference a named capture. Note that the last_match is local to the thread and method scope of the method that did the pattern match. /c(.)t/ =~ 'cat' #=> 0 Regexp.last_match #=> # Regexp.last_match(0) #=> "cat" Regexp.last_match(1) #=> "a" Regexp.last_match(2) #=> nil /(?\w+)\s*=\s*(?\w+)/ =~ "var = val" Regexp.last_match #=> # Regexp.last_match(:lhs) #=> "var" Regexp.last_match(:rhs) #=> "val" @overload last_match @return [MatchData] @overload last_match(n) @return [String];T;#0;$@@;.F;/o;0;1T;2i;3i;%@`@;9I"Dstatic VALUE rb_reg_s_last_match(int argc, VALUE *argv, VALUE _) { if (rb_check_arity(argc, 0, 1) == 1) { VALUE match = rb_backref_get(); int n; if (NIL_P(match)) return Qnil; n = match_backref_number(match, argv[0]); return rb_reg_nth_match(n, match); } return match_getter(); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Regexp.try_convert;F;7[[I"re;T0;[[@x@im;T;;v;0;[;{;IC; "xTry to convert obj into a Regexp, using to_regexp method. Returns converted regexp or nil if obj cannot be converted for any reason. Regexp.try_convert(/re/) #=> /re/ Regexp.try_convert("re") #=> nil o = Object.new Regexp.try_convert(o) #=> nil def o.to_regexp() /foo/ end Regexp.try_convert(o) #=> /foo/ ;T;[o;= ;>I" overload;F;?0;;v;@0;:I"try_convert(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@*A;![;"I"@return [nil];T;#0;$@*A;.F;Bi;C0;7[[I"obj;T0;$@*A;![;"I"Try to convert obj into a Regexp, using to_regexp method. Returns converted regexp or nil if obj cannot be converted for any reason. Regexp.try_convert(/re/) #=> /re/ Regexp.try_convert("re") #=> nil o = Object.new Regexp.try_convert(o) #=> nil def o.to_regexp() /foo/ end Regexp.try_convert(o) #=> /foo/ @overload try_convert(obj) @return [nil];T;#0;$@*A;.F;/o;0;1T;2i\;3ik;%@`@;9I"fstatic VALUE rb_reg_s_try_convert(VALUE dummy, VALUE re) { return rb_check_regexp_type(re); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Regexp#initialize;F;7[[@90;[[@x@i ;T;;D;0;[;{;IC; "Constructs a new regular expression from +pattern+, which can be either a String or a Regexp (in which case that regexp's options are propagated), and new options may not be specified (a change as of Ruby 1.8). If +options+ is an Integer, it should be one or more of the constants Regexp::EXTENDED, Regexp::IGNORECASE, and Regexp::MULTILINE, or-ed together. Otherwise, if +options+ is not +nil+ or +false+, the regexp will be case insensitive. r1 = Regexp.new('^a-z+:\\s+\w+') #=> /^a-z+:\s+\w+/ r2 = Regexp.new('cat', true) #=> /cat/i r3 = Regexp.new(r2) #=> /cat/i r4 = Regexp.new('dog', Regexp::EXTENDED | Regexp::IGNORECASE) #=> /dog/ix ;T;[ o;= ;>I" overload;F;?0;;E;@0;:I"new(string, [options]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Regexp;T;$@IA;![;"I"@return [Regexp];T;#0;$@IA;.F;Bi;C0;7[[I" string;T0[I"[options];T0;$@IAo;= ;>I" overload;F;?0;;E;@0;:I"new(regexp);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Regexp;T;$@IA;![;"I"@return [Regexp];T;#0;$@IA;.F;Bi;C0;7[[I" regexp;T0;$@IAo;= ;>I" overload;F;?0;;;@0;:I"compile(string, [options]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Regexp;T;$@IA;![;"I"@return [Regexp];T;#0;$@IA;.F;Bi;C0;7[[I" string;T0[I"[options];T0;$@IAo;= ;>I" overload;F;?0;;;@0;:I"compile(regexp);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Regexp;T;$@IA;![;"I"@return [Regexp];T;#0;$@IA;.F;Bi;C0;7[[I" regexp;T0;$@IA;![;"I"iConstructs a new regular expression from +pattern+, which can be either a String or a Regexp (in which case that regexp's options are propagated), and new options may not be specified (a change as of Ruby 1.8). If +options+ is an Integer, it should be one or more of the constants Regexp::EXTENDED, Regexp::IGNORECASE, and Regexp::MULTILINE, or-ed together. Otherwise, if +options+ is not +nil+ or +false+, the regexp will be case insensitive. r1 = Regexp.new('^a-z+:\\s+\w+') #=> /^a-z+:\s+\w+/ r2 = Regexp.new('cat', true) #=> /cat/i r3 = Regexp.new(r2) #=> /cat/i r4 = Regexp.new('dog', Regexp::EXTENDED | Regexp::IGNORECASE) #=> /dog/ix @overload new(string, [options]) @return [Regexp] @overload new(regexp) @return [Regexp] @overload compile(string, [options]) @return [Regexp] @overload compile(regexp) @return [Regexp];T;#0;$@IA;.F;/o;0;1T;2i ;3i ;%@`@;9I"static VALUE rb_reg_initialize_m(int argc, VALUE *argv, VALUE self) { int flags = 0; VALUE str; rb_encoding *enc = 0; rb_check_arity(argc, 1, 3); if (RB_TYPE_P(argv[0], T_REGEXP)) { VALUE re = argv[0]; if (argc > 1) { rb_warn("flags ignored"); } rb_reg_check(re); flags = rb_reg_options(re); str = RREGEXP_SRC(re); } else { if (argc >= 2) { if (FIXNUM_P(argv[1])) flags = FIX2INT(argv[1]); else if (RTEST(argv[1])) flags = ONIG_OPTION_IGNORECASE; } if (argc == 3 && !NIL_P(argv[2])) { char *kcode = StringValuePtr(argv[2]); if (kcode[0] == 'n' || kcode[0] == 'N') { enc = rb_ascii8bit_encoding(); flags |= ARG_ENCODING_NONE; } else { rb_category_warn(RB_WARN_CATEGORY_DEPRECATED, "encoding option is ignored - %s", kcode); } } str = StringValue(argv[0]); } if (enc && rb_enc_get(str) != enc) rb_reg_init_str_enc(self, str, enc, flags); else rb_reg_init_str(self, str, flags); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Regexp#initialize_copy;F;7[[I"re;T0;[[@x@i;T;;];0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@A;.F;/o;0;1T;2i;3i;%@`@;9I"static VALUE rb_reg_init_copy(VALUE copy, VALUE re) { if (!OBJ_INIT_COPY(copy, re)) return copy; rb_reg_check(re); return rb_reg_init_str(copy, RREGEXP_SRC(re), rb_reg_options(re)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Regexp#hash;F;7[;[[@x@i ;T;;X;0;[;{;IC; "dProduce a hash based on the text and options of this regular expression. See also Object#hash. ;T;[o;= ;>I" overload;F;?0;;X;@0;:I" hash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@A;![;"I"@return [Integer];T;#0;$@A;.F;Bi;C0;7[;$@A;![;"I"Produce a hash based on the text and options of this regular expression. See also Object#hash. @overload hash @return [Integer];T;#0;$@A;.F;/o;0;1T;2i ;3i ;%@`@;9I"gVALUE rb_reg_hash(VALUE re) { st_index_t hashval = reg_hash(re); return ST2FIX(hashval); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Regexp#eql?;F;7[[I"re2;T0;[[@x@i# ;T;;V;0;[;{;IC; "Equality---Two regexps are equal if their patterns are identical, they have the same character set code, and their casefold? values are the same. /abc/ == /abc/x #=> false /abc/ == /abc/i #=> false /abc/ == /abc/u #=> false /abc/u == /abc/n #=> false;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(other_rxp);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@A;![;"I"@return [Boolean];T;#0;$@A;.F;Bi;C0;7[[I"other_rxp;T0;$@Ao;= ;>I" overload;F;?0;;V;@0;:I"eql?(other_rxp);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@A;![;"I"@return [Boolean];T;#0;$@A;.F;Bi;C0;7[[I"other_rxp;T0;$@A;![;"I"{Equality---Two regexps are equal if their patterns are identical, they have the same character set code, and their casefold? values are the same. /abc/ == /abc/x #=> false /abc/ == /abc/i #=> false /abc/ == /abc/u #=> false /abc/u == /abc/n #=> false @overload ==(other_rxp) @return [Boolean] @overload eql?(other_rxp) @return [Boolean];T;#0;$@A;.F;/o;0;1T;2i ;3i! ;Bi;%@`@;9I"-VALUE rb_reg_equal(VALUE re1, VALUE re2) { if (re1 == re2) return Qtrue; if (!RB_TYPE_P(re2, T_REGEXP)) return Qfalse; rb_reg_check(re1); rb_reg_check(re2); if (FL_TEST(re1, KCODE_FIXED) != FL_TEST(re2, KCODE_FIXED)) return Qfalse; if (RREGEXP_PTR(re1)->options != RREGEXP_PTR(re2)->options) return Qfalse; if (RREGEXP_SRC_LEN(re1) != RREGEXP_SRC_LEN(re2)) return Qfalse; if (ENCODING_GET(re1) != ENCODING_GET(re2)) return Qfalse; return RBOOL(memcmp(RREGEXP_SRC_PTR(re1), RREGEXP_SRC_PTR(re2), RREGEXP_SRC_LEN(re1)) == 0); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Regexp#==;F;7[[I"re2;T0;[[@x@i# ;T;;F;0;[;{;IC; "Equality---Two regexps are equal if their patterns are identical, they have the same character set code, and their casefold? values are the same. /abc/ == /abc/x #=> false /abc/ == /abc/i #=> false /abc/ == /abc/u #=> false /abc/u == /abc/n #=> false ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(other_rxp);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@A;![;"I"@return [Boolean];T;#0;$@A;.F;Bi;C0;7[[I"other_rxp;T0;$@Ao;= ;>I" overload;F;?0;;V;@0;:I"eql?(other_rxp);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@A;![;"I"@return [Boolean];T;#0;$@A;.F;Bi;C0;7[[I"other_rxp;T0;$@A;![;"@A;#0;$@A;.F;/o;0;1T;2i ;3i! ;%@`@;9I"-VALUE rb_reg_equal(VALUE re1, VALUE re2) { if (re1 == re2) return Qtrue; if (!RB_TYPE_P(re2, T_REGEXP)) return Qfalse; rb_reg_check(re1); rb_reg_check(re2); if (FL_TEST(re1, KCODE_FIXED) != FL_TEST(re2, KCODE_FIXED)) return Qfalse; if (RREGEXP_PTR(re1)->options != RREGEXP_PTR(re2)->options) return Qfalse; if (RREGEXP_SRC_LEN(re1) != RREGEXP_SRC_LEN(re2)) return Qfalse; if (ENCODING_GET(re1) != ENCODING_GET(re2)) return Qfalse; return RBOOL(memcmp(RREGEXP_SRC_PTR(re1), RREGEXP_SRC_PTR(re2), RREGEXP_SRC_LEN(re1)) == 0); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Regexp#=~;F;7[[I"str;T0;[[@x@i ;T;;T;0;[;{;IC; "Match---Matches rxp against str. /at/ =~ "input data" #=> 7 /ax/ =~ "input data" #=> nil If =~ is used with a regexp literal with named captures, captured strings (or nil) is assigned to local variables named by the capture names. /(?\w+)\s*=\s*(?\w+)/ =~ " x = y " p lhs #=> "x" p rhs #=> "y" If it is not matched, nil is assigned for the variables. /(?\w+)\s*=\s*(?\w+)/ =~ " x = " p lhs #=> nil p rhs #=> nil This assignment is implemented in the Ruby parser. The parser detects 'regexp-literal =~ expression' for the assignment. The regexp must be a literal without interpolation and placed at left hand side. The assignment does not occur if the regexp is not a literal. re = /(?\w+)\s*=\s*(?\w+)/ re =~ " x = y " p lhs # undefined local variable p rhs # undefined local variable A regexp interpolation, #{}, also disables the assignment. rhs_pat = /(?\w+)/ /(?\w+)\s*=\s*#{rhs_pat}/ =~ "x = y" p lhs # undefined local variable The assignment does not occur if the regexp is placed at the right hand side. " x = y " =~ /(?\w+)\s*=\s*(?\w+)/ p lhs, rhs # undefined local variable ;T;[o;= ;>I" overload;F;?0;;T;@0;:I" =~(str);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@B;![;"I"@return [Integer, nil];T;#0;$@B;.F;Bi;C0;7[[I"str;T0;$@B;![;"I" Match---Matches rxp against str. /at/ =~ "input data" #=> 7 /ax/ =~ "input data" #=> nil If =~ is used with a regexp literal with named captures, captured strings (or nil) is assigned to local variables named by the capture names. /(?\w+)\s*=\s*(?\w+)/ =~ " x = y " p lhs #=> "x" p rhs #=> "y" If it is not matched, nil is assigned for the variables. /(?\w+)\s*=\s*(?\w+)/ =~ " x = " p lhs #=> nil p rhs #=> nil This assignment is implemented in the Ruby parser. The parser detects 'regexp-literal =~ expression' for the assignment. The regexp must be a literal without interpolation and placed at left hand side. The assignment does not occur if the regexp is not a literal. re = /(?\w+)\s*=\s*(?\w+)/ re =~ " x = y " p lhs # undefined local variable p rhs # undefined local variable A regexp interpolation, #{}, also disables the assignment. rhs_pat = /(?\w+)/ /(?\w+)\s*=\s*#{rhs_pat}/ =~ "x = y" p lhs # undefined local variable The assignment does not occur if the regexp is placed at the right hand side. " x = y " =~ /(?\w+)\s*=\s*(?\w+)/ p lhs, rhs # undefined local variable @overload =~(str) @return [Integer, nil];T;#0;$@B;.F;/o;0;1T;2i ;3i ;%@`@;9I"VALUE rb_reg_match(VALUE re, VALUE str) { long pos = reg_match_pos(re, &str, 0, NULL); if (pos < 0) return Qnil; pos = rb_str_sublen(str, pos); return LONG2FIX(pos); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Regexp#===;F;7[[I"str;T0;[[@x@i ;T;;S;0;[;{;IC; "Case Equality---Used in case statements. a = "HELLO" case a when /\A[a-z]*\z/; print "Lower case\n" when /\A[A-Z]*\z/; print "Upper case\n" else; print "Mixed case\n" end #=> "Upper case" Following a regular expression literal with the #=== operator allows you to compare against a String. /^[a-z]*$/ === "HELLO" #=> false /^[A-Z]*$/ === "HELLO" #=> true ;T;[o;= ;>I" overload;F;?0;;S;@0;:I" ===(str);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@>B;![;"I"@return [Boolean];T;#0;$@>B;.F;Bi;C0;7[[I"str;T0;$@>B;![;"I"Case Equality---Used in case statements. a = "HELLO" case a when /\A[a-z]*\z/; print "Lower case\n" when /\A[A-Z]*\z/; print "Upper case\n" else; print "Mixed case\n" end #=> "Upper case" Following a regular expression literal with the #=== operator allows you to compare against a String. /^[a-z]*$/ === "HELLO" #=> false /^[A-Z]*$/ === "HELLO" #=> true @overload ===(str) @return [Boolean];T;#0;$@>B;.F;/o;0;1T;2i ;3i ;%@`@;9I"static VALUE rb_reg_eqq(VALUE re, VALUE str) { long start; str = reg_operand(str, FALSE); if (NIL_P(str)) { rb_backref_set(Qnil); return Qfalse; } start = rb_reg_search(re, str, 0, 0); if (start < 0) { return Qfalse; } return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Regexp#~;F;7[;[[@x@i ;T;:~;0;[;{;IC; "Match---Matches rxp against the contents of $_. Equivalent to rxp =~ $_. $_ = "input data" ~ /at/ #=> 7 ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" ~ rxp;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@]B;![;"I"@return [Integer, nil];T;#0;$@]B;.F;Bi;C0;7[[I"rxp;T0;$@]B;![;"I"Match---Matches rxp against the contents of $_. Equivalent to rxp =~ $_. $_ = "input data" ~ /at/ #=> 7 @overload ~ rxp @return [Integer, nil];T;#0;$@]B;.F;/o;0;1T;2i ;3i ;%@`@;9I"@VALUE rb_reg_match2(VALUE re) { long start; VALUE line = rb_lastline_get(); if (!RB_TYPE_P(line, T_STRING)) { rb_backref_set(Qnil); return Qnil; } start = rb_reg_search(re, line, 0, 0); if (start < 0) { return Qnil; } start = rb_str_sublen(line, start); return LONG2FIX(start); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Regexp#match;F;7[[@90;[[@x@i* ;T;: match;0;[;{;IC; "Returns a MatchData object describing the match, or nil if there was no match. This is equivalent to retrieving the value of the special variable $~ following a normal match. If the second parameter is present, it specifies the position in the string to begin the search. /(.)(.)(.)/.match("abc")[2] #=> "b" /(.)(.)/.match("abc", 1)[2] #=> "c" If a block is given, invoke the block with MatchData if match succeed, so that you can write /M(.*)/.match("Matz") do |m| puts m[0] puts m[1] end instead of if m = /M(.*)/.match("Matz") puts m[0] puts m[1] end The return value is a value from block execution in this case. ;T;[o;= ;>I" overload;F;?0;;H;@0;:I"match(str, pos=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"MatchData;TI"nil;T;$@{B;![;"I"@return [MatchData, nil];T;#0;$@{B;.F;Bi;C0;7[[I"str;T0[I"pos;TI"0;T;$@{Bo;= ;>I" overload;F;?0;;H;@0;:I"match(str, pos=0);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" match;T;$@{Bo;A ;>I" return;F;?I";T;0;@[I" Object;T;$@{B;![;"I"$@yield [match] @return [Object];T;#0;$@{B;.F;Bi;C0;7[[I"str;T0[I"pos;TI"0;T;$@{B;![;"I",Returns a MatchData object describing the match, or nil if there was no match. This is equivalent to retrieving the value of the special variable $~ following a normal match. If the second parameter is present, it specifies the position in the string to begin the search. /(.)(.)(.)/.match("abc")[2] #=> "b" /(.)(.)/.match("abc", 1)[2] #=> "c" If a block is given, invoke the block with MatchData if match succeed, so that you can write /M(.*)/.match("Matz") do |m| puts m[0] puts m[1] end instead of if m = /M(.*)/.match("Matz") puts m[0] puts m[1] end The return value is a value from block execution in this case. @overload match(str, pos=0) @return [MatchData, nil] @overload match(str, pos=0) @yield [match] @return [Object];T;#0;$@{B;.F;/o;0;1T;2i ;3i) ;%@`@;9I"static VALUE rb_reg_match_m(int argc, VALUE *argv, VALUE re) { VALUE result = Qnil, str, initpos; long pos; if (rb_scan_args(argc, argv, "11", &str, &initpos) == 2) { pos = NUM2LONG(initpos); } else { pos = 0; } pos = reg_match_pos(re, &str, pos, &result); if (pos < 0) { rb_backref_set(Qnil); return Qnil; } rb_match_busy(result); if (!NIL_P(result) && rb_block_given_p()) { return rb_yield(result); } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Regexp#match?;F;7[[@90;[[@x@iS ;T;;;0;[;{;IC; "Returns true or false to indicate whether the regexp is matched or not without updating $~ and other related variables. If the second parameter is present, it specifies the position in the string to begin the search. /R.../.match?("Ruby") #=> true /R.../.match?("Ruby", 1) #=> false /P.../.match?("Ruby") #=> false $& #=> nil;T;[o;= ;>I" overload;F;?0;;;@0;:I"match?(str);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@B;![;"I"@return [Boolean];T;#0;$@B;.F;Bi;C0;7[[I"str;T0;$@Bo;= ;>I" overload;F;?0;;;@0;:I"match?(str, pos=0);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@B;![;"I"@return [Boolean];T;#0;$@B;.F;Bi;C0;7[[I"str;T0[I"pos;TI"0;T;$@B;![;"I"Returns true or false to indicate whether the regexp is matched or not without updating $~ and other related variables. If the second parameter is present, it specifies the position in the string to begin the search. /R.../.match?("Ruby") #=> true /R.../.match?("Ruby", 1) #=> false /P.../.match?("Ruby") #=> false $& #=> nil @overload match?(str) @return [Boolean] @overload match?(str, pos=0) @return [Boolean];T;#0;$@B;.F;/o;0;1T;2iC ;3iQ ;Bi;%@`@;9I"static VALUE rb_reg_match_m_p(int argc, VALUE *argv, VALUE re) { long pos = rb_check_arity(argc, 1, 2) > 1 ? NUM2LONG(argv[1]) : 0; return rb_reg_match_p(re, argv[0], pos); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Regexp#to_s;F;7[;[[@x@i";T;;G;0;[;{;IC; "Returns a string containing the regular expression and its options (using the (?opts:source) notation. This string can be fed back in to Regexp::new to a regular expression with the same semantics as the original. (However, Regexp#== may not return true when comparing the two, as the source of the regular expression itself may differ, as the example shows). Regexp#inspect produces a generally more readable version of rxp. r1 = /ab+c/ix #=> /ab+c/ix s1 = r1.to_s #=> "(?ix-m:ab+c)" r2 = Regexp.new(s1) #=> /(?ix-m:ab+c)/ r1 == r2 #=> false r1.source #=> "ab+c" r2.source #=> "(?ix-m:ab+c)" ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@B;![;"I"@return [String];T;#0;$@B;.F;Bi;C0;7[;$@B;![;"I"Returns a string containing the regular expression and its options (using the (?opts:source) notation. This string can be fed back in to Regexp::new to a regular expression with the same semantics as the original. (However, Regexp#== may not return true when comparing the two, as the source of the regular expression itself may differ, as the example shows). Regexp#inspect produces a generally more readable version of rxp. r1 = /ab+c/ix #=> /ab+c/ix s1 = r1.to_s #=> "(?ix-m:ab+c)" r2 = Regexp.new(s1) #=> /(?ix-m:ab+c)/ r1 == r2 #=> false r1.source #=> "ab+c" r2.source #=> "(?ix-m:ab+c)" @overload to_s @return [String];T;#0;$@B;.F;/o;0;1T;2i;3i;%@`@;9I"Ustatic VALUE rb_reg_to_s(VALUE re) { return rb_reg_str_with_term(re, '/'); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Regexp#inspect;F;7[;[[@x@i;T;;J;0;[;{;IC; "Produce a nicely formatted string-version of _rxp_. Perhaps surprisingly, #inspect actually produces the more natural version of the string than #to_s. /ab+c/ix.inspect #=> "/ab+c/ix" ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@B;![;"I"@return [String];T;#0;$@B;.F;Bi;C0;7[;$@B;![;"I"Produce a nicely formatted string-version of _rxp_. Perhaps surprisingly, #inspect actually produces the more natural version of the string than #to_s. /ab+c/ix.inspect #=> "/ab+c/ix" @overload inspect @return [String];T;#0;$@B;.F;/o;0;1T;2i;3i;%@`@;9I"static VALUE rb_reg_inspect(VALUE re) { if (!RREGEXP_PTR(re) || !RREGEXP_SRC(re) || !RREGEXP_SRC_PTR(re)) { return rb_any_to_s(re); } return rb_reg_desc(RREGEXP_SRC_PTR(re), RREGEXP_SRC_LEN(re), re); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Regexp#source;F;7[;[[@x@i;T;: source;0;[;{;IC; "Returns the original string of the pattern. /ab+c/ix.source #=> "ab+c" Note that escape sequences are retained as is. /\x20\+/.source #=> "\\x20\\+" ;T;[o;= ;>I" overload;F;?0;;I;@0;:I" source;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@C;![;"I"@return [String];T;#0;$@C;.F;Bi;C0;7[;$@C;![;"I"Returns the original string of the pattern. /ab+c/ix.source #=> "ab+c" Note that escape sequences are retained as is. /\x20\+/.source #=> "\\x20\\+" @overload source @return [String];T;#0;$@C;.F;/o;0;1T;2i;3i;%@`@;9I"static VALUE rb_reg_source(VALUE re) { VALUE str; rb_reg_check(re); str = rb_str_dup(RREGEXP_SRC(re)); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Regexp#casefold?;F;7[;[[@x@i;T;:casefold?;0;[;{;IC; "Returns the value of the case-insensitive flag. /a/.casefold? #=> false /a/i.casefold? #=> true /(?i:a)/.casefold? #=> false;T;[o;= ;>I" overload;F;?0;;J;@0;:I"casefold?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@5C;![;"I"@return [Boolean];T;#0;$@5C;.F;Bi;C0;7[;$@5C;![;"I"Returns the value of the case-insensitive flag. /a/.casefold? #=> false /a/i.casefold? #=> true /(?i:a)/.casefold? #=> false @overload casefold? @return [Boolean];T;#0;$@5C;.F;/o;0;1T;2i;3i;Bi;%@`@;9I"static VALUE rb_reg_casefold_p(VALUE re) { rb_reg_check(re); return RBOOL(RREGEXP_PTR(re)->options & ONIG_OPTION_IGNORECASE); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Regexp#options;F;7[;[[@x@i;T;;;0;[;{;IC; "Returns the set of bits corresponding to the options used when creating this Regexp (see Regexp::new for details. Note that additional bits may be set in the returned options: these are used internally by the regular expression code. These extra bits are ignored if the options are passed to Regexp::new. Regexp::IGNORECASE #=> 1 Regexp::EXTENDED #=> 2 Regexp::MULTILINE #=> 4 /cat/.options #=> 0 /cat/ix.options #=> 3 Regexp.new('cat', true).options #=> 1 /\xa1\xa2/e.options #=> 16 r = /cat/ix Regexp.new(r.source, r.options) #=> /cat/ix ;T;[o;= ;>I" overload;F;?0;;;@0;:I" options;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@PC;![;"I"@return [Integer];T;#0;$@PC;.F;Bi;C0;7[;$@PC;![;"I"Returns the set of bits corresponding to the options used when creating this Regexp (see Regexp::new for details. Note that additional bits may be set in the returned options: these are used internally by the regular expression code. These extra bits are ignored if the options are passed to Regexp::new. Regexp::IGNORECASE #=> 1 Regexp::EXTENDED #=> 2 Regexp::MULTILINE #=> 4 /cat/.options #=> 0 /cat/ix.options #=> 3 Regexp.new('cat', true).options #=> 1 /\xa1\xa2/e.options #=> 16 r = /cat/ix Regexp.new(r.source, r.options) #=> /cat/ix @overload options @return [Integer];T;#0;$@PC;.F;/o;0;1T;2i;3i;%@`@;9I"sstatic VALUE rb_reg_options_m(VALUE re) { int options = rb_reg_options(re); return INT2NUM(options); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Regexp#encoding;F;7[;[[I"encoding.c;Ti;T;: encoding;0;[;{;IC; "EReturns the Encoding object that represents the encoding of obj. ;T;[o;= ;>I" overload;F;?0;;K;@0;:I" encoding;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Encoding;T;$@kC;![;"I"@return [Encoding];T;#0;$@kC;.F;Bi;C0;7[;$@kC;![;"I"oReturns the Encoding object that represents the encoding of obj. @overload encoding @return [Encoding];T;#0;$@kC;.F;/o;0;1T;2i;3i;%@`@;9I"VALUE rb_obj_encoding(VALUE obj) { int idx = rb_enc_get_index(obj); if (idx < 0) { rb_raise(rb_eTypeError, "unknown encoding"); } return rb_enc_from_encoding_index(idx & ENC_INDEX_MASK); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Regexp#fixed_encoding?;F;7[;[[@x@i;T;:fixed_encoding?;0;[;{;IC; "'Returns false if rxp is applicable to a string with any ASCII compatible encoding. Returns true otherwise. r = /a/ r.fixed_encoding? #=> false r =~ "\u{6666} a" #=> 2 r =~ "\xa1\xa2 a".force_encoding("euc-jp") #=> 2 r =~ "abc".force_encoding("euc-jp") #=> 0 r = /a/u r.fixed_encoding? #=> true r.encoding #=> # r =~ "\u{6666} a" #=> 2 r =~ "\xa1\xa2".force_encoding("euc-jp") #=> Encoding::CompatibilityError r =~ "abc".force_encoding("euc-jp") #=> 0 r = /\u{6666}/ r.fixed_encoding? #=> true r.encoding #=> # r =~ "\u{6666} a" #=> 0 r =~ "\xa1\xa2".force_encoding("euc-jp") #=> Encoding::CompatibilityError r =~ "abc".force_encoding("euc-jp") #=> nil;T;[o;= ;>I" overload;F;?0;;L;@0;:I"fixed_encoding?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@C;![;"I"@return [Boolean];T;#0;$@C;.F;Bi;C0;7[;$@C;![;"I"WReturns false if rxp is applicable to a string with any ASCII compatible encoding. Returns true otherwise. r = /a/ r.fixed_encoding? #=> false r =~ "\u{6666} a" #=> 2 r =~ "\xa1\xa2 a".force_encoding("euc-jp") #=> 2 r =~ "abc".force_encoding("euc-jp") #=> 0 r = /a/u r.fixed_encoding? #=> true r.encoding #=> # r =~ "\u{6666} a" #=> 2 r =~ "\xa1\xa2".force_encoding("euc-jp") #=> Encoding::CompatibilityError r =~ "abc".force_encoding("euc-jp") #=> 0 r = /\u{6666}/ r.fixed_encoding? #=> true r.encoding #=> # r =~ "\u{6666} a" #=> 0 r =~ "\xa1\xa2".force_encoding("euc-jp") #=> Encoding::CompatibilityError r =~ "abc".force_encoding("euc-jp") #=> nil @overload fixed_encoding? @return [Boolean];T;#0;$@C;.F;/o;0;1T;2i;3i;Bi;%@`@;9I"cstatic VALUE rb_reg_fixed_encoding_p(VALUE re) { return RBOOL(FL_TEST(re, KCODE_FIXED)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Regexp#names;F;7[;[[@x@i;T;: names;0;[;{;IC; "Returns a list of names of captures as an array of strings. /(?.)(?.)(?.)/.names #=> ["foo", "bar", "baz"] /(?.)(?.)/.names #=> ["foo"] /(.)(.)/.names #=> [] ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" names;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@C;![;"I"@return [Array];T;#0;$@C;.F;Bi;C0;7[;$@C;![;"I"Returns a list of names of captures as an array of strings. /(?.)(?.)(?.)/.names #=> ["foo", "bar", "baz"] /(?.)(?.)/.names #=> ["foo"] /(.)(.)/.names #=> [] @overload names @return [Array];T;#0;$@C;.F;/o;0;1T;2i;3i;%@`@;9I"static VALUE rb_reg_names(VALUE re) { VALUE ary; rb_reg_check(re); ary = rb_ary_new_capa(onig_number_of_names(RREGEXP_PTR(re))); onig_foreach_name(RREGEXP_PTR(re), reg_names_iter, (void*)ary); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Regexp#named_captures;F;7[;[[@x@iB;T;:named_captures;0;[;{;IC; "Returns a hash representing information about named captures of rxp. A key of the hash is a name of the named captures. A value of the hash is an array which is list of indexes of corresponding named captures. /(?.)(?.)/.named_captures #=> {"foo"=>[1], "bar"=>[2]} /(?.)(?.)/.named_captures #=> {"foo"=>[1, 2]} If there are no named captures, an empty hash is returned. /(.)(.)/.named_captures #=> {} ;T;[o;= ;>I" overload;F;?0;;N;@0;:I"named_captures;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@C;![;"I"@return [Hash];T;#0;$@C;.F;Bi;C0;7[;$@C;![;"I"Returns a hash representing information about named captures of rxp. A key of the hash is a name of the named captures. A value of the hash is an array which is list of indexes of corresponding named captures. /(?.)(?.)/.named_captures #=> {"foo"=>[1], "bar"=>[2]} /(?.)(?.)/.named_captures #=> {"foo"=>[1, 2]} If there are no named captures, an empty hash is returned. /(.)(.)/.named_captures #=> {} @overload named_captures @return [Hash];T;#0;$@C;.F;/o;0;1T;2i,;3i?;%@`@;9I"static VALUE rb_reg_named_captures(VALUE re) { regex_t *reg = (rb_reg_check(re), RREGEXP_PTR(re)); VALUE hash = rb_hash_new_with_size(onig_number_of_names(reg)); onig_foreach_name(reg, reg_named_captures_iter, (void*)hash); return hash; };T;:I"static VALUE;T;;To;u;[[@x@i1;F;:IGNORECASE;;w;;;[;{;IC; "&see Regexp.options and Regexp.new ;T;[;![;"I"&see Regexp.options and Regexp.new;T;#0;$@C;.F;/o;0;1T;2i0;3i0;%@`@;&I"Regexp::IGNORECASE;F;xI"$INT2FIX(ONIG_OPTION_IGNORECASE);To;u;[[@x@i3;F;: EXTENDED;;w;;;[;{;IC; "&see Regexp.options and Regexp.new ;T;[;![;"I"&see Regexp.options and Regexp.new;T;#0;$@C;.F;/o;0;1T;2i2;3i2;%@`@;&I"Regexp::EXTENDED;F;xI" INT2FIX(ONIG_OPTION_EXTEND);To;u;[[@x@i5;F;;z;;w;;;[;{;IC; "&see Regexp.options and Regexp.new ;T;[;![;"I"&see Regexp.options and Regexp.new;T;#0;$@C;.F;/o;0;1T;2i4;3i4;%@`@;&I"Regexp::MULTILINE;F;xI"#INT2FIX(ONIG_OPTION_MULTILINE);To;u;[[@x@i7;F;:FIXEDENCODING;;w;;;[;{;IC; "&see Regexp.options and Regexp.new ;T;[;![;"I"&see Regexp.options and Regexp.new;T;#0;$@C;.F;/o;0;1T;2i6;3i6;%@`@;&I"Regexp::FIXEDENCODING;F;xI" INT2FIX(ARG_ENCODING_FIXED);To;u;[[@x@i9;F;:NOENCODING;;w;;;[;{;IC; "&see Regexp.options and Regexp.new ;T;[;![;"I"&see Regexp.options and Regexp.new;T;#0;$@D;.F;/o;0;1T;2i8;3i8;%@`@;&I"Regexp::NOENCODING;F;xI"INT2FIX(ARG_ENCODING_NONE);T; @`@; IC;[; @`@; IC;[; @`@; IC;{;IC;{;T;IC;{;T;T;{;[;[[@x@i[@x@i;T;;C;;;;;[;{;IC; "^A Regexp holds a regular expression, used to match a pattern against strings. Regexps are created using the /.../ and %r{...} literals, and by the Regexp::new constructor. You can create a \Regexp object explicitly with: - A {regexp literal}[doc/syntax/literals_rdoc.html#label-Regexp+Literals]. :include: doc/regexp.rdoc;T;[;![;"I"` A Regexp holds a regular expression, used to match a pattern against strings. Regexps are created using the /.../ and %r{...} literals, and by the Regexp::new constructor. You can create a \Regexp object explicitly with: - A {regexp literal}[doc/syntax/literals_rdoc.html#label-Regexp+Literals]. :include: doc/regexp.rdoc ;T;#0;$@`@;.F;/o;0;1T;2i;3i;Bi;%@;&I" Regexp;F;'@;;o;4;5F;6;;;;&I"Bug#funcall_callback;F;7[[I"obj;T0;[[I"ext/-test-/bug-5832/bug.c;Ti;T;:funcall_callback;0;[;{;IC; " ;T;[;![;"I";F;#0;$@&D;.F;C0;%@?;9I"wstatic VALUE bug_funcall_callback(VALUE self, VALUE obj) { return rb_funcall(obj, rb_intern("callback"), 0); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Bug.funcall_callback;F;7@(D;@+D;T;;S;0;@.D;{;IC; " ;T;[;![;"@;#0;$@6D;Bi;%@?;9@4D;:@5D;;To;;IC;[ o;;IC;[ o;4;5F;6;;;;&I"Bug::File::Fs#fsname;F;7[[I"str;T0;[[I"ext/-test-/file/fs.c;Ti4;T;: fsname;0;[;{;IC; " ;T;[;![;"I";F;#0;$@@D;.F;C0;%@>D;9I";VALUE get_fsname(VALUE self, VALUE str) { #ifdef STATFS statfs_t st; # define CSTR(s) rb_str_new_cstr(s) FilePathValue(str); str = rb_str_encode_ospath(str); if (STATFS(StringValueCStr(str), &st) == -1) { rb_sys_fail_str(str); } # ifdef HAVE_STRUCT_STATFS_T_F_FSTYPENAME if (st.f_fstypename[0]) return CSTR(st.f_fstypename); # endif # ifdef HAVE_STRUCT_STATFS_T_F_TYPE switch (st.f_type) { case 0x9123683E: /* BTRFS_SUPER_MAGIC */ return CSTR("btrfs"); case 0x7461636f: /* OCFS2_SUPER_MAGIC */ return CSTR("ocfs"); case 0xEF53: /* EXT2_SUPER_MAGIC EXT3_SUPER_MAGIC EXT4_SUPER_MAGIC */ return CSTR("ext4"); case 0x58465342: /* XFS_SUPER_MAGIC */ return CSTR("xfs"); case 0x01021994: /* TMPFS_MAGIC */ return CSTR("tmpfs"); } # endif #endif return Qnil; };T;:I" VALUE;T;;To;4;5T;6;;;;&I"Bug::File::Fs.fsname;F;7@BD;@ED;T;;T;0;@HD;{;IC; " ;T;[;![;"@;#0;$@PD;Bi;%@>D;9@ND;:@OD;;To;4;5F;6;;;;&I"Bug::File::Fs#noatime?;F;7[[I"str;T0;[[@GDiV;T;: noatime?;0;[;{;IC; " ;T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@VD;![;"I"@return [Boolean] ;T;#0;$@VD;.F;C0;%@>D;9I"!VALUE get_noatime_p(VALUE self, VALUE str) { #ifdef STATFS statfs_t st; FilePathValue(str); str = rb_str_encode_ospath(str); if (STATFS(StringValueCStr(str), &st) == -1) { rb_sys_fail_str(str); } # ifdef HAVE_STRUCT_STATFS_F_FLAGS # ifdef MNT_STRICTATIME if (!(st.f_flags & MNT_STRICTATIME)) return Qtrue; # endif # ifdef MNT_NOATIME return st.f_flags & MNT_NOATIME ? Qtrue : Qfalse; # elif defined(ST_NOATIME) return st.f_flags & ST_NOATIME ? Qtrue : Qfalse; # endif # endif #endif return Qnil; };T;:I" VALUE;T;;To;4;5T;6;;;;&I"Bug::File::Fs.noatime?;F;7@XD;@[D;T;;U;0;@]D;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@jD;![;"@;#0;$@jD;Bi;%@>D;9@hD;:@iD;;T; @>D; IC;[; @>D; IC;[; @>D; IC;{;IC;{;T;IC;{;T;T;{;[;[[@GDiq;F;:Fs;;;;;[;{;IC; " ;T;[;![;"@;#0;$@>D;Bi;%@num_entries); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Bug::File::Stat#delete_safe;F;7[[I"key;T0;[[@Diw;T;:delete_safe;0;[;{;IC; " ;T;[;![;"@;#0;$@E;%@D;9I" static VALUE numhash_delete_safe(VALUE self, VALUE key) { st_table *table = (st_table *)Check_TypedStruct(self, &numhash_type); st_data_t val, k = (st_data_t)key; if (st_delete_safe(table, &k, &val, (st_data_t)self)) { return val; } return Qnil; };T;:I"static VALUE;T;;T; @D; IC;[; @D; IC;[; @D; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Di;F;;M;;;;;[;{;IC; " ;T;[;![;"@;#0;$@D;%@I" return;F;?@;0;@[@L;$@pF;![;"@;#0;$@pF;Bi;%@_F;9I"static VALUE sym_pinneddown_p(VALUE dummy, VALUE sym) { ID id = rb_check_id(&sym); if (!id) return Qnil; #ifdef ULL2NUM return ULL2NUM(id); #else return ULONG2NUM(id); #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Symbol.iv_get;F;7[[I"obj;T0[I" name;T0;[[@hFi;T;: iv_get;0;[;{;IC; " ;T;[;![;"@;#0;$@F;%@_F;9I"static VALUE sym_iv_get(VALUE dummy, VALUE obj, VALUE name) { const char *n = StringValueCStr(name); return rb_iv_get(obj, n); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Symbol.attrset;F;7[;[;F;: attrset;;;[;{;IC; " ;T;[;![;"@;#0;$@F;%@_F;;To;4;5F;6;;;;&I"Bug::Symbol.id2str;F;7[[I"sym;T0;[[I"ext/-test-/symbol/type.c;Ti+;T;: id2str;0;[;{;IC; " ;T;[;![;"@;#0;$@F;%@_F;9I"Sstatic VALUE bug_id2str(VALUE self, VALUE sym) { return rb_sym2str(sym); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Symbol.static?;F;7[[I"sym;T0;[[@Fi1;T;: static?;0;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@F;![;"@;#0;$@F;Bi;%@_F;9I"hstatic VALUE bug_static_p(VALUE self, VALUE sym) { return STATIC_SYM_P(sym) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Symbol.dynamic?;F;7[[I"sym;T0;[[@Fi7;T;: dynamic?;0;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@F;![;"@;#0;$@F;Bi;%@_F;9I"jstatic VALUE bug_dynamic_p(VALUE self, VALUE sym) { return DYNAMIC_SYM_P(sym) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Symbol.pindown;F;7[[I"sym;T0;[[@Fi@;T;: pindown;0;[;{;IC; " ;T;[;![;"@;#0;$@F;%@_F;9I"hstatic VALUE bug_pindown(VALUE self, VALUE sym) { rb_pin_dynamic_symbol(sym); return sym; };T;:I"static VALUE;T;;T; @_F; IC;[; @_F; IC;[; @_F; IC;{;IC;{;T;IC;{;T;T;{;[;[[@hFi';F;;;;;;;[;{;IC; " ;T;[;![;"@;#0;$@_F;%@?;&I"Bug::Symbol;F;'@To; ;IC;[ o;4;5F;6;;;;&I"%Bug::Time.reset_leap_second_info;F;7[;[[I""ext/-test-/time/leap_second.c;Ti ;T;:reset_leap_second_info;0;[;{;IC; " ;T;[;![;"@;#0;$@F;%@F;9I"xstatic VALUE bug_time_s_reset_leap_second_info(VALUE klass) { ruby_reset_leap_second_info(); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Time.nano_new;F;7[[I"sec;T0[I" nsec;T0;[[I"ext/-test-/time/new.c;Ti;T;: nano_new;0;[;{;IC; " ;T;[;![;"@;#0;$@F;%@F;9I"static VALUE bug_time_s_nano_new(VALUE klass, VALUE sec, VALUE nsec) { return rb_time_nano_new(NUM2TIMET(sec), NUM2LONG(nsec)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Time.timespec_new;F;7[[I"sec;T0[I" nsec;T0[I" gmtoff;T0;[[@Gi;T;:timespec_new;0;[;{;IC; " ;T;[;![;"@;#0;$@G;%@F;9I"static VALUE bug_time_s_timespec_new(VALUE klass, VALUE sec, VALUE nsec, VALUE gmtoff) { struct timespec ts; ts.tv_sec = NUM2TIMET(sec); ts.tv_nsec = NUM2LONG(nsec); return rb_time_timespec_new(&ts, NUM2INT(gmtoff)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Time.timespec_now;F;7[;[[@Gi;T;:timespec_now;0;[;{;IC; " ;T;[;![;"@;#0;$@G;%@F;9I"static VALUE bug_time_s_timespec_now(VALUE klass) { struct timespec ts; VALUE v; rb_timespec_now(&ts); v = rb_Rational(LONG2NUM(ts.tv_nsec), LONG2NUM(1000000000L)); return rb_num_coerce_bin(TIMET2NUM(ts.tv_sec), v, '+'); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Time#rstruct_len;F;7[;[[I"ext/-test-/struct/len.c;Ti;T;:rstruct_len;0;[;{;IC; " ;T;[;![;"@;#0;$@&G;%@F;9I"Vstatic VALUE bug_struct_len(VALUE obj) { return LONG2NUM(RSTRUCT_LEN(obj)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Time.new_duplicate;F;7[[I" name;T0[I"mem;T0;[[I""ext/-test-/struct/duplicate.c;Ti;T;:new_duplicate;0;[;{;IC; " ;T;[;![;"@;#0;$@3G;%@F;9I"static VALUE bug_struct_new_duplicate(VALUE obj, VALUE name, VALUE mem) { const char *n = NIL_P(name) ? 0 : StringValueCStr(name); const char *m = StringValueCStr(mem); return rb_struct_define(n, m, m, NULL); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""Bug::Time.new_duplicate_under;F;7[[I" name;T0[I"mem;T0;[[@bins != NULL) rb_bug("should still be packed\n"); st_foreach_check(tbl, unp_fec_i, (st_data_t)&c, -1); if (c.test == ID2SYM(rb_intern("delete2"))) { if (c.nr != 1) { rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)\n", (VALUE)c.nr); } } else if (c.nr != expect_size) { rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE")\n", (VALUE)c.nr, (VALUE)expect_size); } if (tbl->bins == NULL) rb_bug("should be unpacked\n"); st_free_table(tbl); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug.unp_st_foreach;F;7[[I" test;T0;[[@kGi;T;:unp_st_foreach;0;[;{;IC; " ;T;[;![;"@;#0;$@sG;%@?;9I"static VALUE unp_fe(VALUE self, VALUE test) { st_table *tbl = st_init_numtable(); struct checker c; c.tbl = tbl; c.nr = 0; c.test = test; st_add_direct(tbl, 0, 0); if (tbl->bins != NULL) rb_bug("should still be packed\n"); st_foreach(tbl, unp_fe_i, (st_data_t)&c); if (c.test == ID2SYM(rb_intern("unpack_delete"))) { if (c.nr != 1) { rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)\n", (VALUE)c.nr); } } else if (c.nr != expect_size) { rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE"o)\n", (VALUE)c.nr, (VALUE)expect_size); } if (tbl->bins == NULL) rb_bug("should be unpacked\n"); st_free_table(tbl); return Qnil; };T;:I"static VALUE;T;;To; ;IC;[o;4;5F;6;;;;&I"Bug::Struct#get;F;7[[I" name;T0;[[I"ext/-test-/struct/member.c;Ti;T;:get;0;[;{;IC; " ;T;[;![;"@;#0;$@G;%@G;9I"static VALUE bug_struct_get(VALUE obj, VALUE name) { ID id = rb_check_id(&name); if (!id) { rb_name_error_str(name, "`%"PRIsVALUE"' is not a struct member", name); } return rb_struct_getmember(obj, id); };T;:I"static VALUE;T;;T; @G; IC;[; @G; IC;[; @G; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"ext/-test-/struct/init.c;Ti;F;: Struct;;;;;[;{;IC; " ;T;[;![;"@;#0;$@G;%@?;&I"Bug::Struct;F;'o;( ;)0;*0;+0;;v;%@;-o; ;IC;[!o;4;5F;6;;;;&I"Struct.new;F;7[[@90;[[I" struct.c;Ti<;T;;E;0;[;{;IC; " Struct.new returns a new subclass of +Struct+. The new subclass: - May be anonymous, or may have the name given by +class_name+. - May have members as given by +member_names+. - May have initialization via ordinary arguments (the default) or via keyword arguments (if keyword_init: true is given). The new subclass has its own method ::new; thus: Foo = Struct.new('Foo', :foo, :bar) # => Struct::Foo f = Foo.new(0, 1) # => # \Class Name With string argument +class_name+, returns a new subclass of +Struct+ named Struct::class_name: Foo = Struct.new('Foo', :foo, :bar) # => Struct::Foo Foo.name # => "Struct::Foo" Foo.superclass # => Struct Without string argument +class_name+, returns a new anonymous subclass of +Struct+: Struct.new(:foo, :bar).name # => nil Block With a block given, the created subclass is yielded to the block: Customer = Struct.new('Customer', :name, :address) do |new_class| p "The new subclass is #{new_class}" def greeting "Hello #{name} at #{address}" end end # => Struct::Customer dave = Customer.new('Dave', '123 Main') dave # => # dave.greeting # => "Hello Dave at 123 Main" Output, from Struct.new: "The new subclass is Struct::Customer" Member Names \Symbol arguments +member_names+ determines the members of the new subclass: Struct.new(:foo, :bar).members # => [:foo, :bar] Struct.new('Foo', :foo, :bar).members # => [:foo, :bar] The new subclass has instance methods corresponding to +member_names+: Foo = Struct.new('Foo', :foo, :bar) Foo.instance_methods(false) # => [:foo, :bar, :foo=, :bar=] f = Foo.new # => # f.foo # => nil f.foo = 0 # => 0 f.bar # => nil f.bar = 1 # => 1 f # => # Singleton Methods A subclass returned by Struct.new has these singleton methods: - \Method ::new creates an instance of the subclass: Foo.new # => # Foo.new(0) # => # Foo.new(0, 1) # => # Foo.new(0, 1, 2) # Raises ArgumentError: struct size differs \Method ::[] is an alias for method ::new. - \Method :inspect returns a string representation of the subclass: Foo.inspect # => "Struct::Foo" - \Method ::members returns an array of the member names: Foo.members # => [:foo, :bar] Keyword Argument By default, the arguments for initializing an instance of the new subclass are ordinary arguments (not keyword arguments). With optional keyword argument keyword_init: true, the new subclass is initialized with keyword arguments: # Without keyword_init: true. Foo = Struct.new('Foo', :foo, :bar) Foo # => Struct::Foo Foo.new(0, 1) # => # # With keyword_init: true. Bar = Struct.new(:foo, :bar, keyword_init: true) Bar # => # => Bar(keyword_init: true) Bar.new(bar: 1, foo: 0) # => # ;T;[ o;= ;>I" overload;F;?0;;E;@0;:I",new(*member_names, keyword_init: false);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"Struct_subclass;T;$@Go;A ;>I" return;F;?I";T;0;@[I"Struct_subclass;T;$@G;![;"I"7@yield [Struct_subclass] @return [Struct_subclass];T;#0;$@G;.F;Bi;C0;7[[I"*member_names;T0[I"keyword_init:;TI" false;T;$@Go;= ;>I" overload;F;?0;;E;@0;:I"8new(class_name, *member_names, keyword_init: false);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"Struct_subclass;T;$@Go;A ;>I" return;F;?I";T;0;@[I"Struct_subclass;T;$@G;![;"I"7@yield [Struct_subclass] @return [Struct_subclass];T;#0;$@G;.F;Bi;C0;7[[I"class_name;T0[I"*member_names;T0[I"keyword_init:;TI" false;T;$@Go;= ;>I" overload;F;?0;;E;@0;:I"new(*member_names);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Struct_subclass_instance;T;$@G;![;"I"'@return [Struct_subclass_instance];T;#0;$@G;.F;Bi;C0;7[[I"*member_names;T0;$@Go;= ;>I" overload;F;?0;;E;@0;:I"new(**member_names);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Struct_subclass_instance;T;$@G;![;"I"'@return [Struct_subclass_instance];T;#0;$@G;.F;Bi;C0;7[[I"**member_names;T0;$@G;![;"I"Struct.new returns a new subclass of +Struct+. The new subclass: - May be anonymous, or may have the name given by +class_name+. - May have members as given by +member_names+. - May have initialization via ordinary arguments (the default) or via keyword arguments (if keyword_init: true is given). The new subclass has its own method ::new; thus: Foo = Struct.new('Foo', :foo, :bar) # => Struct::Foo f = Foo.new(0, 1) # => # \Class Name With string argument +class_name+, returns a new subclass of +Struct+ named Struct::class_name: Foo = Struct.new('Foo', :foo, :bar) # => Struct::Foo Foo.name # => "Struct::Foo" Foo.superclass # => Struct Without string argument +class_name+, returns a new anonymous subclass of +Struct+: Struct.new(:foo, :bar).name # => nil Block With a block given, the created subclass is yielded to the block: Customer = Struct.new('Customer', :name, :address) do |new_class| p "The new subclass is #{new_class}" def greeting "Hello #{name} at #{address}" end end # => Struct::Customer dave = Customer.new('Dave', '123 Main') dave # => # dave.greeting # => "Hello Dave at 123 Main" Output, from Struct.new: "The new subclass is Struct::Customer" Member Names \Symbol arguments +member_names+ determines the members of the new subclass: Struct.new(:foo, :bar).members # => [:foo, :bar] Struct.new('Foo', :foo, :bar).members # => [:foo, :bar] The new subclass has instance methods corresponding to +member_names+: Foo = Struct.new('Foo', :foo, :bar) Foo.instance_methods(false) # => [:foo, :bar, :foo=, :bar=] f = Foo.new # => # f.foo # => nil f.foo = 0 # => 0 f.bar # => nil f.bar = 1 # => 1 f # => # Singleton Methods A subclass returned by Struct.new has these singleton methods: - \Method ::new creates an instance of the subclass: Foo.new # => # Foo.new(0) # => # Foo.new(0, 1) # => # Foo.new(0, 1, 2) # Raises ArgumentError: struct size differs \Method ::[] is an alias for method ::new. - \Method :inspect returns a string representation of the subclass: Foo.inspect # => "Struct::Foo" - \Method ::members returns an array of the member names: Foo.members # => [:foo, :bar] Keyword Argument By default, the arguments for initializing an instance of the new subclass are ordinary arguments (not keyword arguments). With optional keyword argument keyword_init: true, the new subclass is initialized with keyword arguments: # Without keyword_init: true. Foo = Struct.new('Foo', :foo, :bar) Foo # => Struct::Foo Foo.new(0, 1) # => # # With keyword_init: true. Bar = Struct.new(:foo, :bar, keyword_init: true) Bar # => # => Bar(keyword_init: true) Bar.new(bar: 1, foo: 0) # => # @overload new(*member_names, keyword_init: false) @yield [Struct_subclass] @return [Struct_subclass] @overload new(class_name, *member_names, keyword_init: false) @yield [Struct_subclass] @return [Struct_subclass] @overload new(*member_names) @return [Struct_subclass_instance] @overload new(**member_names) @return [Struct_subclass_instance];T;#0;$@G;.F;/o;0;1T;2i;3i>;%@G;9I"static VALUE rb_struct_s_def(int argc, VALUE *argv, VALUE klass) { VALUE name, rest, keyword_init = Qnil; long i; VALUE st; st_table *tbl; rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS); name = argv[0]; if (SYMBOL_P(name)) { name = Qnil; } else { --argc; ++argv; } if (RB_TYPE_P(argv[argc-1], T_HASH)) { static ID keyword_ids[1]; if (!keyword_ids[0]) { keyword_ids[0] = rb_intern("keyword_init"); } rb_get_kwargs(argv[argc-1], keyword_ids, 0, 1, &keyword_init); if (keyword_init == Qundef) { keyword_init = Qnil; } else if (RTEST(keyword_init)) { keyword_init = Qtrue; } --argc; } rest = rb_ident_hash_new(); RBASIC_CLEAR_CLASS(rest); OBJ_WB_UNPROTECT(rest); tbl = RHASH_TBL_RAW(rest); for (i=0; ikeyword_init: true. Otherwise returns +nil+ or +false+. Examples: Foo = Struct.new(:a) Foo.keyword_init? # => nil Bar = Struct.new(:a, keyword_init: true) Bar.keyword_init? # => true Baz = Struct.new(:a, keyword_init: false) Baz.keyword_init? # => false;T;[o;= ;>I" overload;F;?0;:StructClass::keyword_init?;@0;:I"StructClass::keyword_init?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;T;$@H;![;"I"@return [true];T;#0;$@H;.F;Bi;C0;7[;$@H;![;"I"|Returns +true+ if the class was initialized with keyword_init: true. Otherwise returns +nil+ or +false+. Examples: Foo = Struct.new(:a) Foo.keyword_init? # => nil Bar = Struct.new(:a, keyword_init: true) Bar.keyword_init? # => true Baz = Struct.new(:a, keyword_init: false) Baz.keyword_init? # => false @overload StructClass::keyword_init? @return [true];T;#0;$@H;.F;/o;0;1T;2i-;3i:;Bi;%@G;9I";static VALUE rb_struct_s_keyword_init_p(VALUE obj) { };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Struct.members;F;7[;[[@Gi;T;: members;0;[;{;IC; "Returns the member names of the Struct descendant as an array: Customer = Struct.new(:name, :address, :zip) Customer.members # => [:name, :address, :zip] ;T;[o;= ;>I" overload;F;?0;:StructClass::members;@0;:I"StructClass::members;T;IC; ";T;[;![;"I";T;#0;$@H;.F;Bi;C0;7[;$@H;![;"I"Returns the member names of the Struct descendant as an array: Customer = Struct.new(:name, :address, :zip) Customer.members # => [:name, :address, :zip] @overload StructClass::members;T;#0;$@H;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE rb_struct_s_members_m(VALUE klass) { VALUE members = rb_struct_s_members(klass); return rb_ary_dup(members); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Struct#initialize;F;7[[@90;[[@Gi;T;;D;0;[;{;IC; " ;T;[;![;"@;#0;$@4H;%@G;9I"static VALUE rb_struct_initialize_m(int argc, const VALUE *argv, VALUE self) { VALUE klass = rb_obj_class(self); rb_struct_modify(self); long n = num_members(klass); if (argc == 0) { rb_mem_clear((VALUE *)RSTRUCT_CONST_PTR(self), n); return Qnil; } VALUE keyword_init = rb_struct_s_keyword_init(klass); if (RTEST(keyword_init)) { struct struct_hash_set_arg arg; if (argc > 1 || !RB_TYPE_P(argv[0], T_HASH)) { rb_raise(rb_eArgError, "wrong number of arguments (given %d, expected 0)", argc); } rb_mem_clear((VALUE *)RSTRUCT_CONST_PTR(self), n); arg.self = self; arg.unknown_keywords = Qnil; rb_hash_foreach(argv[0], struct_hash_set_i, (VALUE)&arg); if (arg.unknown_keywords != Qnil) { rb_raise(rb_eArgError, "unknown keywords: %s", RSTRING_PTR(rb_ary_join(arg.unknown_keywords, rb_str_new2(", ")))); } } else { if (n < argc) { rb_raise(rb_eArgError, "struct size differs"); } if (NIL_P(keyword_init) && argc == 1 && RB_TYPE_P(argv[0], T_HASH) && rb_keyword_given_p()) { rb_warn("Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. "\ "Please use a Hash literal like .new({k: v}) instead of .new(k: v)."); } for (long i=0; i argc) { rb_mem_clear((VALUE *)RSTRUCT_CONST_PTR(self)+argc, n-argc); } } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Struct#initialize_copy;F;7[[I"s;T0;[[@Gi5;T;;];0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@AH;.F;/o;0;1T;2i4;3i4;%@G;9I"OVALUE rb_struct_init_copy(VALUE copy, VALUE s) { long i, len; if (!OBJ_INIT_COPY(copy, s)) return copy; if (RSTRUCT_LEN(copy) != RSTRUCT_LEN(s)) { rb_raise(rb_eTypeError, "struct size mismatch"); } for (i=0, len=RSTRUCT_LEN(copy); iother.class == self.class. - For each member name +name+, other.name == self.name. Examples: Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe_jr = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe_jr == joe # => true joe_jr[:name] = 'Joe Smith, Jr.' # => "Joe Smith, Jr." joe_jr == joe # => false ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@QH;![;"I"@return [Boolean];T;#0;$@QH;.F;Bi;C0;7[[I" other;T0;$@QH;![;"I"Returns +true+ if and only if the following are true; otherwise returns +false+: - other.class == self.class. - For each member name +name+, other.name == self.name. Examples: Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe_jr = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe_jr == joe # => true joe_jr[:name] = 'Joe Smith, Jr.' # => "Joe Smith, Jr." joe_jr == joe # => false @overload ==(other) @return [Boolean];T;#0;$@QH;.F;/o;0;1T;2i8;3iI;%@G;9I"nstatic VALUE rb_struct_equal(VALUE s, VALUE s2) { if (s == s2) return Qtrue; if (!RB_TYPE_P(s2, T_STRUCT)) return Qfalse; if (rb_obj_class(s) != rb_obj_class(s2)) return Qfalse; if (RSTRUCT_LEN(s) != RSTRUCT_LEN(s2)) { rb_bug("inconsistent struct"); /* should never happen */ } return rb_exec_recursive_paired(recursive_equal, s, s2, s2); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Struct#eql?;F;7[[I"s2;T0;[[@Gi;T;;V;0;[;{;IC; "Returns +true+ if and only if the following are true; otherwise returns +false+: - other.class == self.class. - For each member name +name+, other.name.eql?(self.name). Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe_jr = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe_jr.eql?(joe) # => true joe_jr[:name] = 'Joe Smith, Jr.' joe_jr.eql?(joe) # => false Related: Object#==.;T;[o;= ;>I" overload;F;?0;;V;@0;:I"eql?(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@pH;![;"I"@return [Boolean];T;#0;$@pH;.F;Bi;C0;7[[I" other;T0;$@pH;![;"I" Returns +true+ if and only if the following are true; otherwise returns +false+: - other.class == self.class. - For each member name +name+, other.name.eql?(self.name). Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe_jr = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe_jr.eql?(joe) # => true joe_jr[:name] = 'Joe Smith, Jr.' joe_jr.eql?(joe) # => false Related: Object#==. @overload eql?(other) @return [Boolean];T;#0;$@pH;.F;/o;0;1T;2i;3i;Bi;%@G;9I"jstatic VALUE rb_struct_eql(VALUE s, VALUE s2) { if (s == s2) return Qtrue; if (!RB_TYPE_P(s2, T_STRUCT)) return Qfalse; if (rb_obj_class(s) != rb_obj_class(s2)) return Qfalse; if (RSTRUCT_LEN(s) != RSTRUCT_LEN(s2)) { rb_bug("inconsistent struct"); /* should never happen */ } return rb_exec_recursive_paired(recursive_eql, s, s2, s2); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Struct#hash;F;7[;[[@Gil;T;;X;0;[;{;IC; "Returns the integer hash value for +self+. Two structs of the same class and with the same content will have the same hash code (and will compare using Struct#eql?): Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe_jr = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.hash == joe_jr.hash # => true joe_jr[:name] = 'Joe Smith, Jr.' joe.hash == joe_jr.hash # => false Related: Object#hash. ;T;[o;= ;>I" overload;F;?0;;X;@0;:I" hash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@H;![;"I"@return [Integer];T;#0;$@H;.F;Bi;C0;7[;$@H;![;"I"Returns the integer hash value for +self+. Two structs of the same class and with the same content will have the same hash code (and will compare using Struct#eql?): Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe_jr = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.hash == joe_jr.hash # => true joe_jr[:name] = 'Joe Smith, Jr.' joe.hash == joe_jr.hash # => false Related: Object#hash. @overload hash @return [Integer];T;#0;$@H;.F;/o;0;1T;2iY;3ii;%@G;9I"Cstatic VALUE rb_struct_hash(VALUE s) { long i, len; st_index_t h; VALUE n; h = rb_hash_start(rb_hash(rb_obj_class(s))); len = RSTRUCT_LEN(s); for (i = 0; i < len; i++) { n = rb_hash(RSTRUCT_GET(s, i)); h = rb_hash_uint(h, NUM2LONG(n)); } h = rb_hash_end(h); return ST2FIX(h); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Struct#inspect;F;7[;[[@Gi;T;;J;0;[;{;IC; "@Returns a string representation of +self+: Customer = Struct.new(:name, :address, :zip) # => Customer joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.inspect # => "#" Struct#to_s is an alias for Struct#inspect. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@H;![;"I"@return [String];T;#0;$@H;.F;Bi;C0;7[;$@H;![;"I"hReturns a string representation of +self+: Customer = Struct.new(:name, :address, :zip) # => Customer joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.inspect # => "#" Struct#to_s is an alias for Struct#inspect. @overload inspect @return [String];T;#0;$o;4;5F;6;;;;&I"Struct#to_s;F;7[;[[@Gic;F;;G;;;[;{;@H;%@G;9I"dstatic VALUE rb_struct_inspect(VALUE s) { return rb_exec_recursive(inspect_struct, s, 0); };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@G;9I"dstatic VALUE rb_struct_inspect(VALUE s) { return rb_exec_recursive(inspect_struct, s, 0); };T;:@H;;T@Ho;4;5F;6;;;;&I"Struct#to_a;F;7[;[[@Gi;T;;;0;[;{;IC; "0Returns the values in +self+ as an array: Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.to_a # => ["Joe Smith", "123 Maple, Anytown NC", 12345] Struct#values and Struct#deconstruct are aliases for Struct#to_a. Related: #members. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_a;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@H;![;"I"@return [Array];T;#0;$@H;.F;Bi;C0;7[;$@H;![;"I"SReturns the values in +self+ as an array: Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.to_a # => ["Joe Smith", "123 Maple, Anytown NC", 12345] Struct#values and Struct#deconstruct are aliases for Struct#to_a. Related: #members. @overload to_a @return [Array];T;#0;$@H;.F;/o;0;1T;2i;3i;%@G;9I"kstatic VALUE rb_struct_to_a(VALUE s) { return rb_ary_new4(RSTRUCT_LEN(s), RSTRUCT_CONST_PTR(s)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Struct#to_h;F;7[;[[@Gi;T;;;0;[;{;IC; "Returns a hash containing the name and value for each member: Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) h = joe.to_h h # => {:name=>"Joe Smith", :address=>"123 Maple, Anytown NC", :zip=>12345} If a block is given, it is called with each name/value pair; the block should return a 2-element array whose elements will become a key/value pair in the returned hash: h = joe.to_h{|name, value| [name.upcase, value.to_s.upcase]} h # => {:NAME=>"JOE SMITH", :ADDRESS=>"123 MAPLE, ANYTOWN NC", :ZIP=>"12345"} Raises ArgumentError if the block returns an inappropriate value. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_h;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@H;![;"I"@return [Hash];T;#0;$@H;.F;Bi;C0;7[;$@Ho;= ;>I" overload;F;?0;;;@0;:I" to_h;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" name;TI" value;T;$@Ho;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@H;![;"I"(@yield [name, value] @return [Hash];T;#0;$@H;.F;Bi;C0;7[;$@H;![;"I"Returns a hash containing the name and value for each member: Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) h = joe.to_h h # => {:name=>"Joe Smith", :address=>"123 Maple, Anytown NC", :zip=>12345} If a block is given, it is called with each name/value pair; the block should return a 2-element array whose elements will become a key/value pair in the returned hash: h = joe.to_h{|name, value| [name.upcase, value.to_s.upcase]} h # => {:NAME=>"JOE SMITH", :ADDRESS=>"123 MAPLE, ANYTOWN NC", :ZIP=>"12345"} Raises ArgumentError if the block returns an inappropriate value. @overload to_h @return [Hash] @overload to_h @yield [name, value] @return [Hash];T;#0;$@H;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE rb_struct_to_h(VALUE s) { VALUE h = rb_hash_new_with_size(RSTRUCT_LEN(s)); VALUE members = rb_struct_members(s); long i; int block_given = rb_block_given_p(); for (i=0; i ["Joe Smith", "123 Maple, Anytown NC", 12345] Struct#values and Struct#deconstruct are aliases for Struct#to_a. Related: #members. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_a;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@I;![;"I"@return [Array];T;#0;$@I;.F;Bi;C0;7[;$@I;![;"@H;#0;$@I;.F;/o;0;1T;2i;3i;%@G;9I"kstatic VALUE rb_struct_to_a(VALUE s) { return rb_ary_new4(RSTRUCT_LEN(s), RSTRUCT_CONST_PTR(s)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Struct#size;F;7[;[[@Gi;T;;;0;[;{;IC; "Returns the number of members. Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.size #=> 3 Struct#length is an alias for Struct#size. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@0I;![;"I"@return [Integer];T;#0;$@0I;.F;Bi;C0;7[;$@0I;![;"I"Returns the number of members. Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.size #=> 3 Struct#length is an alias for Struct#size. @overload size @return [Integer];T;#0;$@0I;.F;/o;0;1T;2i;3i;%@G;9I"KVALUE rb_struct_size(VALUE s) { return LONG2FIX(RSTRUCT_LEN(s)); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Struct#length;F;7[;[[@Gi;T;;b;0;[;{;IC; "Returns the number of members. Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.size #=> 3 Struct#length is an alias for Struct#size. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@KI;![;"I"@return [Integer];T;#0;$@KI;.F;Bi;C0;7[;$@KI;![;"@GI;#0;$@KI;.F;/o;0;1T;2i;3i;%@G;9I"KVALUE rb_struct_size(VALUE s) { return LONG2FIX(RSTRUCT_LEN(s)); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Struct#each;F;7[;[[@GiK;T;;;0;[;{;IC; "QCalls the given block with the value of each member; returns +self+: Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.each {|value| p value } Output: "Joe Smith" "123 Maple, Anytown NC" 12345 Returns an Enumerator if no block is given. Related: #each_pair. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" each;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" value;T;$@eIo;A ;>I" return;F;?I";T;0;@[I" self;T;$@eI;![;"I""@yield [value] @return [self];T;#0;$@eI;.F;Bi;C0;7[;$@eIo;= ;>I" overload;F;?0;;;@0;:I" each;T;IC; ";T;[;![;"I";T;#0;$@eI;.F;Bi;C0;7[;$@eI;![;"I"Calls the given block with the value of each member; returns +self+: Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.each {|value| p value } Output: "Joe Smith" "123 Maple, Anytown NC" 12345 Returns an Enumerator if no block is given. Related: #each_pair. @overload each @yield [value] @return [self] @overload each;T;#0;$@eI;.F;/o;0;1T;2i5;3iI;%@G;9I"static VALUE rb_struct_each(VALUE s) { long i; RETURN_SIZED_ENUMERATOR(s, 0, 0, struct_enum_size); for (i=0; i Customer joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.each_pair {|(name, value)| p "#{name} => #{value}" } Output: "name => Joe Smith" "address => 123 Maple, Anytown NC" "zip => 12345" Returns an Enumerator if no block is given. Related: #each. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"each_pair;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"(name, value);T;$@Io;A ;>I" return;F;?I";T;0;@[I" self;T;$@I;![;"I"*@yield [(name, value)] @return [self];T;#0;$@I;.F;Bi;C0;7[;$@Io;= ;>I" overload;F;?0;;;@0;:I"each_pair;T;IC; ";T;[;![;"I";T;#0;$@I;.F;Bi;C0;7[;$@I;![;"I"Calls the given block with each member name/value pair; returns +self+: Customer = Struct.new(:name, :address, :zip) # => Customer joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.each_pair {|(name, value)| p "#{name} => #{value}" } Output: "name => Joe Smith" "address => 123 Maple, Anytown NC" "zip => 12345" Returns an Enumerator if no block is given. Related: #each. @overload each_pair @yield [(name, value)] @return [self] @overload each_pair;T;#0;$@I;.F;/o;0;1T;2iW;3il;%@G;9I"9static VALUE rb_struct_each_pair(VALUE s) { VALUE members; long i; RETURN_SIZED_ENUMERATOR(s, 0, 0, struct_enum_size); members = rb_struct_members(s); if (rb_block_pair_yield_optimizable()) { for (i=0; i 12345 Raises NameError if +name+ is not the name of a member. With integer argument +n+ given, returns self.values[n] if +n+ is in range; see {Array Indexes}[Array.html#class-Array-label-Array+Indexes]: joe[2] # => 12345 joe[-2] # => "123 Maple, Anytown NC" Raises IndexError if +n+ is out of range. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" [](name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@I;![;"I"@return [Object];T;#0;$@I;.F;Bi;C0;7[[I" name;T0;$@Io;= ;>I" overload;F;?0;;;@0;:I" [](n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@I;![;"I"@return [Object];T;#0;$@I;.F;Bi;C0;7[[I"n;T0;$@I;![;"I"Returns a value from +self+. With symbol or string argument +name+ given, returns the value for the named member: Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe[:zip] # => 12345 Raises NameError if +name+ is not the name of a member. With integer argument +n+ given, returns self.values[n] if +n+ is in range; see {Array Indexes}[Array.html#class-Array-label-Array+Indexes]: joe[2] # => 12345 joe[-2] # => "123 Maple, Anytown NC" Raises IndexError if +n+ is out of range. @overload [](name) @return [Object] @overload [](n) @return [Object];T;#0;$@I;.F;/o;0;1T;2iz;3i;%@G;9I"VALUE rb_struct_aref(VALUE s, VALUE idx) { int i = rb_struct_pos(s, &idx); if (i < 0) invalid_struct_pos(s, idx); return RSTRUCT_GET(s, i); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Struct#[]=;F;7[[I"idx;T0[I"val;T0;[[@Gi;T;;8;0;[;{;IC; "vAssigns a value to a member. With symbol or string argument +name+ given, assigns the given +value+ to the named member; returns +value+: Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe[:zip] = 54321 # => 54321 joe # => # Raises NameError if +name+ is not the name of a member. With integer argument +n+ given, assigns the given +value+ to the +n+-th member if +n+ is in range; see {Array Indexes}[Array.html#class-Array-label-Array+Indexes]: joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe[2] = 54321 # => 54321 joe[-3] = 'Joseph Smith' # => "Joseph Smith" joe # => # Raises IndexError if +n+ is out of range. ;T;[o;= ;>I" overload;F;?0;;8;@0;:I"[]=(name);T;IC; ";T;[;![;"I";T;#0;$@I;.F;Bi;C0;7[[I" name;T0;$@Io;= ;>I" overload;F;?0;;8;@0;:I" []=(n);T;IC; ";T;[;![;"I";T;#0;$@I;.F;Bi;C0;7[[I"n;T0;$@I;![;"I"Assigns a value to a member. With symbol or string argument +name+ given, assigns the given +value+ to the named member; returns +value+: Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe[:zip] = 54321 # => 54321 joe # => # Raises NameError if +name+ is not the name of a member. With integer argument +n+ given, assigns the given +value+ to the +n+-th member if +n+ is in range; see {Array Indexes}[Array.html#class-Array-label-Array+Indexes]: joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe[2] = 54321 # => 54321 joe[-3] = 'Joseph Smith' # => "Joseph Smith" joe # => # Raises IndexError if +n+ is out of range. @overload []=(name) @overload []=(n);T;#0;$@I;.F;/o;0;1T;2i;3i;%@G;9I"VALUE rb_struct_aset(VALUE s, VALUE idx, VALUE val) { int i = rb_struct_pos(s, &idx); if (i < 0) invalid_struct_pos(s, idx); rb_struct_modify(s); RSTRUCT_SET(s, i, val); return val; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Struct#select;F;7[[@90;[[@Gi;T;;;0;[;{;IC; "With a block given, returns an array of values from +self+ for which the block returns a truthy value: Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) a = joe.select {|value| value.is_a?(String) } a # => ["Joe Smith", "123 Maple, Anytown NC"] a = joe.select {|value| value.is_a?(Integer) } a # => [12345] With no block given, returns an Enumerator. Struct#filter is an alias for Struct#select. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" value;T;$@ Jo;A ;>I" return;F;?I";T;0;@[I" Array;T;$@ J;![;"I"#@yield [value] @return [Array];T;#0;$@ J;.F;Bi;C0;7[;$@ Jo;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[;![;"I";T;#0;$@ J;.F;Bi;C0;7[;$@ J;![;"I"With a block given, returns an array of values from +self+ for which the block returns a truthy value: Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) a = joe.select {|value| value.is_a?(String) } a # => ["Joe Smith", "123 Maple, Anytown NC"] a = joe.select {|value| value.is_a?(Integer) } a # => [12345] With no block given, returns an Enumerator. Struct#filter is an alias for Struct#select. @overload select @yield [value] @return [Array] @overload select;T;#0;$@ J;.F;/o;0;1T;2i;3i;%@G;9I"sstatic VALUE rb_struct_select(int argc, VALUE *argv, VALUE s) { VALUE result; long i; rb_check_arity(argc, 0, 0); RETURN_SIZED_ENUMERATOR(s, 0, 0, struct_enum_size); result = rb_ary_new(); for (i = 0; i < RSTRUCT_LEN(s); i++) { if (RTEST(rb_yield(RSTRUCT_GET(s, i)))) { rb_ary_push(result, RSTRUCT_GET(s, i)); } } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Struct#filter;F;7[[@90;[[@Gi;T;;;0;[;{;IC; "With a block given, returns an array of values from +self+ for which the block returns a truthy value: Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) a = joe.select {|value| value.is_a?(String) } a # => ["Joe Smith", "123 Maple, Anytown NC"] a = joe.select {|value| value.is_a?(Integer) } a # => [12345] With no block given, returns an Enumerator. Struct#filter is an alias for Struct#select. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" value;T;$@2Jo;A ;>I" return;F;?I";T;0;@[I" Array;T;$@2J;![;"I"#@yield [value] @return [Array];T;#0;$@2J;.F;Bi;C0;7[;$@2Jo;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[;![;"I";T;#0;$@2J;.F;Bi;C0;7[;$@2J;![;"@.J;#0;$@2J;.F;/o;0;1T;2i;3i;%@G;9I"sstatic VALUE rb_struct_select(int argc, VALUE *argv, VALUE s) { VALUE result; long i; rb_check_arity(argc, 0, 0); RETURN_SIZED_ENUMERATOR(s, 0, 0, struct_enum_size); result = rb_ary_new(); for (i = 0; i < RSTRUCT_LEN(s); i++) { if (RTEST(rb_yield(RSTRUCT_GET(s, i)))) { rb_ary_push(result, RSTRUCT_GET(s, i)); } } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Struct#values_at;F;7[[@90;[[@Gi;T;;;0;[;{;IC; "Returns an array of values from +self+. With integer arguments +integers+ given, returns an array containing each value given by one of +integers+: Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.values_at(0, 2) # => ["Joe Smith", 12345] joe.values_at(2, 0) # => [12345, "Joe Smith"] joe.values_at(2, 1, 0) # => [12345, "123 Maple, Anytown NC", "Joe Smith"] joe.values_at(0, -3) # => ["Joe Smith", "Joe Smith"] Raises IndexError if any of +integers+ is out of range; see {Array Indexes}[Array.html#class-Array-label-Array+Indexes]. With integer range argument +integer_range+ given, returns an array containing each value given by the elements of the range; fills with +nil+ values for range elements larger than the structure: joe.values_at(0..2) # => ["Joe Smith", "123 Maple, Anytown NC", 12345] joe.values_at(-3..-1) # => ["Joe Smith", "123 Maple, Anytown NC", 12345] joe.values_at(1..4) # => ["123 Maple, Anytown NC", 12345, nil, nil] Raises RangeError if any element of the range is negative and out of range; see {Array Indexes}[Array.html#class-Array-label-Array+Indexes]. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"values_at(*integers);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@ZJ;![;"I"@return [Array];T;#0;$@ZJ;.F;Bi;C0;7[[I"*integers;T0;$@ZJo;= ;>I" overload;F;?0;;;@0;:I"values_at(integer_range);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@ZJ;![;"I"@return [Array];T;#0;$@ZJ;.F;Bi;C0;7[[I"integer_range;T0;$@ZJ;![;"I"Returns an array of values from +self+. With integer arguments +integers+ given, returns an array containing each value given by one of +integers+: Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.values_at(0, 2) # => ["Joe Smith", 12345] joe.values_at(2, 0) # => [12345, "Joe Smith"] joe.values_at(2, 1, 0) # => [12345, "123 Maple, Anytown NC", "Joe Smith"] joe.values_at(0, -3) # => ["Joe Smith", "Joe Smith"] Raises IndexError if any of +integers+ is out of range; see {Array Indexes}[Array.html#class-Array-label-Array+Indexes]. With integer range argument +integer_range+ given, returns an array containing each value given by the elements of the range; fills with +nil+ values for range elements larger than the structure: joe.values_at(0..2) # => ["Joe Smith", "123 Maple, Anytown NC", 12345] joe.values_at(-3..-1) # => ["Joe Smith", "123 Maple, Anytown NC", 12345] joe.values_at(1..4) # => ["123 Maple, Anytown NC", 12345, nil, nil] Raises RangeError if any element of the range is negative and out of range; see {Array Indexes}[Array.html#class-Array-label-Array+Indexes]. @overload values_at(*integers) @return [Array] @overload values_at(integer_range) @return [Array];T;#0;$@ZJ;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE rb_struct_values_at(int argc, VALUE *argv, VALUE s) { return rb_get_values_at(s, RSTRUCT_LEN(s), argc, argv, struct_entry); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Struct#members;F;7[;[[@Gi;T;;y;0;[;{;IC; "Returns the member names from +self+ as an array: Customer = Struct.new(:name, :address, :zip) Customer.new.members # => [:name, :address, :zip] Related: #to_a. ;T;[o;= ;>I" overload;F;?0;;y;@0;:I" members;T;IC; ";T;[;![;"I";T;#0;$@J;.F;Bi;C0;7[;$@J;![;"I"Returns the member names from +self+ as an array: Customer = Struct.new(:name, :address, :zip) Customer.new.members # => [:name, :address, :zip] Related: #to_a. @overload members;T;#0;$@J;.F;/o;0;1T;2i;3i;%@G;9I"istatic VALUE rb_struct_members_m(VALUE obj) { return rb_struct_s_members_m(rb_obj_class(obj)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Struct#dig;F;7[[@90;[[@Gi;T;;;0;[;{;IC; "Finds and returns an object among nested objects. The nested objects may be instances of various classes. See {Dig Methods}[rdoc-ref:dig_methods.rdoc]. Given symbol or string argument +name+, returns the object that is specified by +name+ and +identifiers+: Foo = Struct.new(:a) f = Foo.new(Foo.new({b: [1, 2, 3]})) f.dig(:a) # => #[1, 2, 3]}> f.dig(:a, :a) # => {:b=>[1, 2, 3]} f.dig(:a, :a, :b) # => [1, 2, 3] f.dig(:a, :a, :b, 0) # => 1 f.dig(:b, 0) # => nil Given integer argument +n+, returns the object that is specified by +n+ and +identifiers+: f.dig(0) # => #[1, 2, 3]}> f.dig(0, 0) # => {:b=>[1, 2, 3]} f.dig(0, 0, :b) # => [1, 2, 3] f.dig(0, 0, :b, 0) # => 1 f.dig(:b, 0) # => nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I"dig(name, *identifiers);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@J;![;"I"@return [Object];T;#0;$@J;.F;Bi;C0;7[[I" name;T0[I"*identifiers;T0;$@Jo;= ;>I" overload;F;?0;;;@0;:I"dig(n, *identifiers);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@J;![;"I"@return [Object];T;#0;$@J;.F;Bi;C0;7[[I"n;T0[I"*identifiers;T0;$@J;![;"I"g Finds and returns an object among nested objects. The nested objects may be instances of various classes. See {Dig Methods}[rdoc-ref:dig_methods.rdoc]. Given symbol or string argument +name+, returns the object that is specified by +name+ and +identifiers+: Foo = Struct.new(:a) f = Foo.new(Foo.new({b: [1, 2, 3]})) f.dig(:a) # => #[1, 2, 3]}> f.dig(:a, :a) # => {:b=>[1, 2, 3]} f.dig(:a, :a, :b) # => [1, 2, 3] f.dig(:a, :a, :b, 0) # => 1 f.dig(:b, 0) # => nil Given integer argument +n+, returns the object that is specified by +n+ and +identifiers+: f.dig(0) # => #[1, 2, 3]}> f.dig(0, 0) # => {:b=>[1, 2, 3]} f.dig(0, 0, :b) # => [1, 2, 3] f.dig(0, 0, :b, 0) # => 1 f.dig(:b, 0) # => nil @overload dig(name, *identifiers) @return [Object] @overload dig(n, *identifiers) @return [Object];T;#0;$@J;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE rb_struct_dig(int argc, VALUE *argv, VALUE self) { rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS); self = rb_struct_lookup(self, *argv); if (!--argc) return self; ++argv; return rb_obj_dig(argc, argv, self, Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Struct#deconstruct;F;7[;[[@Gi;T;;4;0;[;{;IC; "0Returns the values in +self+ as an array: Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.to_a # => ["Joe Smith", "123 Maple, Anytown NC", 12345] Struct#values and Struct#deconstruct are aliases for Struct#to_a. Related: #members. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_a;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@J;![;"I"@return [Array];T;#0;$@J;.F;Bi;C0;7[;$@J;![;"@H;#0;$@J;.F;/o;0;1T;2i;3i;%@G;9I"kstatic VALUE rb_struct_to_a(VALUE s) { return rb_ary_new4(RSTRUCT_LEN(s), RSTRUCT_CONST_PTR(s)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Struct#deconstruct_keys;F;7[[I" keys;T0;[[@Gi;T;;;0;[;{;IC; "Returns a hash of the name/value pairs for the given member names. Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) h = joe.deconstruct_keys([:zip, :address]) h # => {:zip=>12345, :address=>"123 Maple, Anytown NC"} Returns all names and values if +array_of_names+ is +nil+: h = joe.deconstruct_keys(nil) h # => {:name=>"Joseph Smith, Jr.", :address=>"123 Maple, Anytown NC", :zip=>12345} ;T;[o;= ;>I" overload;F;?0;;;@0;:I"%deconstruct_keys(array_of_names);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@J;![;"I"@return [Hash];T;#0;$@J;.F;Bi;C0;7[[I"array_of_names;T0;$@J;![;"I" Returns a hash of the name/value pairs for the given member names. Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) h = joe.deconstruct_keys([:zip, :address]) h # => {:zip=>12345, :address=>"123 Maple, Anytown NC"} Returns all names and values if +array_of_names+ is +nil+: h = joe.deconstruct_keys(nil) h # => {:name=>"Joseph Smith, Jr.", :address=>"123 Maple, Anytown NC", :zip=>12345} @overload deconstruct_keys(array_of_names) @return [Hash];T;#0;$@J;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE rb_struct_deconstruct_keys(VALUE s, VALUE keys) { VALUE h; long i; if (NIL_P(keys)) { return rb_struct_to_h(s); } if (UNLIKELY(!RB_TYPE_P(keys, T_ARRAY))) { rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected Array or nil)", rb_obj_class(keys)); } if (RSTRUCT_LEN(s) < RARRAY_LEN(keys)) { return rb_hash_new_with_size(0); } h = rb_hash_new_with_size(RARRAY_LEN(keys)); for (i=0; iStruct::Customer; the first argument, a string, is the name of the subclass; the other arguments, symbols, determine the _members_ of the new subclass. Customer = Struct.new('Customer', :name, :address, :zip) Customer.name # => "Struct::Customer" Customer.class # => Class Customer.superclass # => Struct Corresponding to each member are two methods, a writer and a reader, that store and fetch values: methods = Customer.instance_methods false methods # => [:zip, :address=, :zip=, :address, :name, :name=] An instance of the subclass may be created, and its members assigned values, via method ::new: joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe # => # The member values may be managed thus: joe.name # => "Joe Smith" joe.name = 'Joseph Smith' joe.name # => "Joseph Smith" And thus; note that member name may be expressed as either a string or a symbol: joe[:name] # => "Joseph Smith" joe[:name] = 'Joseph Smith, Jr.' joe['name'] # => "Joseph Smith, Jr." See Struct::new. == What's Here First, what's elsewhere. \Class \Struct: - Inherits from {class Object}[Object.html#class-Object-label-What-27s+Here]. - Includes {module Enumerable}[Enumerable.html#module-Enumerable-label-What-27s+Here], which provides dozens of additional methods. Here, class \Struct provides methods that are useful for: - {Creating a Struct Subclass}[#class-Struct-label-Methods+for+Creating+a+Struct+Subclass] - {Querying}[#class-Struct-label-Methods+for+Querying] - {Comparing}[#class-Struct-label-Methods+for+Comparing] - {Fetching}[#class-Struct-label-Methods+for+Fetching] - {Assigning}[#class-Struct-label-Methods+for+Assigning] - {Iterating}[#class-Struct-label-Methods+for+Iterating] - {Converting}[#class-Struct-label-Methods+for+Converting] === Methods for Creating a Struct Subclass ::new:: Returns a new subclass of \Struct. === Methods for Querying #hash:: Returns the integer hash code. #length, #size:: Returns the number of members. === Methods for Comparing {#==}[#method-i-3D-3D]:: Returns whether a given object is equal to +self+, using == to compare member values. #eql?:: Returns whether a given object is equal to +self+, using eql? to compare member values. === Methods for Fetching #[]:: Returns the value associated with a given member name. #to_a, #values, #deconstruct:: Returns the member values in +self+ as an array. #deconstruct_keys:: Returns a hash of the name/value pairs for given member names. #dig:: Returns the object in nested objects that is specified by a given member name and additional arguments. #members:: Returns an array of the member names. #select, #filter:: Returns an array of member values from +self+, as selected by the given block. #values_at:: Returns an array containing values for given member names. === Methods for Assigning #[]=:: Assigns a given value to a given member name. === Methods for Iterating #each:: Calls a given block with each member name. #each_pair:: Calls a given block with each member name/value pair. === Methods for Converting #inspect, #to_s:: Returns a string representation of +self+. #to_h:: Returns a hash of the member name/value pairs in +self+.;T;[;![;"I" \Class \Struct provides a convenient way to create a simple class that can store and fetch values. This example creates a subclass of +Struct+, Struct::Customer; the first argument, a string, is the name of the subclass; the other arguments, symbols, determine the _members_ of the new subclass. Customer = Struct.new('Customer', :name, :address, :zip) Customer.name # => "Struct::Customer" Customer.class # => Class Customer.superclass # => Struct Corresponding to each member are two methods, a writer and a reader, that store and fetch values: methods = Customer.instance_methods false methods # => [:zip, :address=, :zip=, :address, :name, :name=] An instance of the subclass may be created, and its members assigned values, via method ::new: joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe # => # The member values may be managed thus: joe.name # => "Joe Smith" joe.name = 'Joseph Smith' joe.name # => "Joseph Smith" And thus; note that member name may be expressed as either a string or a symbol: joe[:name] # => "Joseph Smith" joe[:name] = 'Joseph Smith, Jr.' joe['name'] # => "Joseph Smith, Jr." See Struct::new. == What's Here First, what's elsewhere. \Class \Struct: - Inherits from {class Object}[Object.html#class-Object-label-What-27s+Here]. - Includes {module Enumerable}[Enumerable.html#module-Enumerable-label-What-27s+Here], which provides dozens of additional methods. Here, class \Struct provides methods that are useful for: - {Creating a Struct Subclass}[#class-Struct-label-Methods+for+Creating+a+Struct+Subclass] - {Querying}[#class-Struct-label-Methods+for+Querying] - {Comparing}[#class-Struct-label-Methods+for+Comparing] - {Fetching}[#class-Struct-label-Methods+for+Fetching] - {Assigning}[#class-Struct-label-Methods+for+Assigning] - {Iterating}[#class-Struct-label-Methods+for+Iterating] - {Converting}[#class-Struct-label-Methods+for+Converting] === Methods for Creating a Struct Subclass ::new:: Returns a new subclass of \Struct. === Methods for Querying #hash:: Returns the integer hash code. #length, #size:: Returns the number of members. === Methods for Comparing {#==}[#method-i-3D-3D]:: Returns whether a given object is equal to +self+, using == to compare member values. #eql?:: Returns whether a given object is equal to +self+, using eql? to compare member values. === Methods for Fetching #[]:: Returns the value associated with a given member name. #to_a, #values, #deconstruct:: Returns the member values in +self+ as an array. #deconstruct_keys:: Returns a hash of the name/value pairs for given member names. #dig:: Returns the object in nested objects that is specified by a given member name and additional arguments. #members:: Returns an array of the member names. #select, #filter:: Returns an array of member values from +self+, as selected by the given block. #values_at:: Returns an array containing values for given member names. === Methods for Assigning #[]=:: Assigns a given value to a given member name. === Methods for Iterating #each:: Calls a given block with each member name. #each_pair:: Calls a given block with each member name/value pair. === Methods for Converting #inspect, #to_s:: Returns a string representation of +self+. #to_h:: Returns a hash of the member name/value pairs in +self+. ;T;#0;$@G;.F;/o;0;1T;2i;3iK;Bi;%@;&I" Struct;F;'@;;o; ;IC;[o;4;5F;6;;;;&I"Bug::VM.register_at_exit;F;7[[I"t;T0;[[I"ext/-test-/vm/at_exit.c;Ti;T;:register_at_exit;0;[;{;IC; " ;T;[;![;"@;#0;$@4K;%@2K;9I"static VALUE register_at_exit(VALUE self, VALUE t) { switch (t) { case Qtrue: ruby_vm_at_exit(print_begin); break; case Qfalse: ruby_vm_at_exit(print_end); break; default: ruby_vm_at_exit(do_nothing); break; } return self; };T;:I"static VALUE;T;;T; @2K; IC;[; @2K; IC;[; @2K; IC;{;IC;{;T;IC;{;T;T;{;[;[[@;Ki/;F;:VM;;;;;[;{;IC; " ;T;[;![;"@;#0;$@2K;%@?;&I" Bug::VM;F;'@o;4;5F;6;;;;&I"Bug.load_protect;F;7[[@90;[[I"&ext/-test-/load/protect/protect.c;Ti;T;:load_protect;0;[;{;IC; " ;T;[;![;"@;#0;$@RK;%@?;9I"static VALUE load_protect(int argc, VALUE *argv, VALUE self) { int state; VALUE path, wrap; rb_scan_args(argc, argv, "11", &path, &wrap); rb_load_protect(path, RTEST(wrap), &state); if (state) rb_jump_tag(state); return Qnil; };T;:I"static VALUE;T;;To; ;IC;[o;4;5F;6;;;;&I" Bug::Float.system_nextafter;F;7[[I"vx;T0[I"vy;T0;[[I"!ext/-test-/float/nextafter.c;Ti;T;:system_nextafter;0;[;{;IC; " ;T;[;![;"@;#0;$@bK;%@`K;9I"static VALUE system_nextafter_m(VALUE klass, VALUE vx, VALUE vy) { double x, y, z; x = NUM2DBL(vx); y = NUM2DBL(vy); z = nextafter(x, y); return DBL2NUM(z); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Bug::Float.missing_nextafter;F;7[[I"vx;T0[I"vy;T0;[[@kKi;T;:missing_nextafter;0;[;{;IC; " ;T;[;![;"@;#0;$@sK;%@`K;9I"static VALUE missing_nextafter_m(VALUE klass, VALUE vx, VALUE vy) { double x, y, z; x = NUM2DBL(vx); y = NUM2DBL(vy); z = missing_nextafter(x, y); return DBL2NUM(z); };T;:I"static VALUE;T;;T; @`K; IC;[; @`K; IC;[; @`K; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"ext/-test-/float/init.c;Ti;F;;;;;;;[;{;IC; " ;T;[;![;"@;#0;$@`K;%@?;&I"Bug::Float;F;'@o;;IC;[ o;4;5F;6;;;;&I"Bug::Rational.gcd_normal;F;7[[I"x;T0[I"y;T0;[[I"ext/-test-/rational/rat.c;Ti;T;:gcd_normal;0;[;{;IC; " ;T;[;![;"@;#0;$@K;%@K;9I"}static VALUE gcd_normal(VALUE klass, VALUE x, VALUE y) { return rb_big_norm(rb_gcd_normal(rb_to_int(x), rb_to_int(y))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Rational.gcd_gmp;F;7[[I"x;T0[I"y;T0;[[@Ki;T;: gcd_gmp;0;[;{;IC; " ;T;[;![;"@;#0;$@K;%@K;9I"pstatic VALUE gcd_gmp(VALUE klass, VALUE x, VALUE y) { return rb_big_norm(rb_gcd_gmp(big(x), big(y))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Rational.raw;F;7[[I"x;T0[I"y;T0;[[@Ki%;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@K;%@K;9I"estatic VALUE s_rational_raw(VALUE klass, VALUE x, VALUE y) { return rb_rational_raw(x, y); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Rational.class2name;F;7[[I" klass;T0;[[I""ext/-test-/class/class2name.c;Ti;T;:class2name;0;[;{;IC; " ;T;[;![;"@;#0;$@K;%@K;9I"static VALUE class2name(VALUE self, VALUE klass) { const char *name = rb_class2name(klass); return name ? rb_str_new_cstr(name) : Qnil; };T;:I"static VALUE;T;;T; @K; IC;[; @K; IC;[; @K; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Ki/;F;;;;;;;[;{;IC; " ;T;[;![;"@;#0;$@K;%@?;&I"Bug::Rational;Fo;4;5F;6;;;;&I")Bug#tracepoint_track_objspace_events;F;7[;[[I"'ext/-test-/tracepoint/tracepoint.c;Ti=;T;:%tracepoint_track_objspace_events;0;[;{;IC; " ;T;[;![;"I";F;#0;$@K;.F;C0;%@?;9I"sstatic VALUE tracepoint_track_objspace_events(VALUE self) { struct tracepoint_track track = {0, 0, 0, 0, 0,}; VALUE tpval = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_NEWOBJ | RUBY_INTERNAL_EVENT_FREEOBJ | RUBY_INTERNAL_EVENT_GC_START | RUBY_INTERNAL_EVENT_GC_END_MARK | RUBY_INTERNAL_EVENT_GC_END_SWEEP, tracepoint_track_objspace_events_i, &track); VALUE result = rb_ary_new(); rb_tracepoint_enable(tpval); rb_ensure(rb_yield, Qundef, rb_tracepoint_disable, tpval); rb_ary_push(result, SIZET2NUM(track.newobj_count)); rb_ary_push(result, SIZET2NUM(track.free_count)); rb_ary_push(result, SIZET2NUM(track.gc_start_count)); rb_ary_push(result, SIZET2NUM(track.gc_end_mark_count)); rb_ary_push(result, SIZET2NUM(track.gc_end_sweep_count)); rb_ary_cat(result, track.objects, track.objects_count); return result; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I")Bug.tracepoint_track_objspace_events;F;7@K;@K;T;;;0;@K;{;IC; " ;T;[;![;"@;#0;$@K;Bi;%@?;9@K;:@K;;To;4;5F;6;;;;&I"6Bug#tracepoint_specify_normal_and_internal_events;F;7[;[[@KiT;T;:2tracepoint_specify_normal_and_internal_events;0;[;{;IC; " ;T;[;![;"I";F;#0;$@K;.F;C0;%@?;9I"static VALUE tracepoint_specify_normal_and_internal_events(VALUE self) { VALUE tpval = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_NEWOBJ | RUBY_EVENT_CALL, 0, 0); rb_tracepoint_enable(tpval); return Qnil; /* should not be reached */ };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"6Bug.tracepoint_specify_normal_and_internal_events;F;7@K;@K;T;;;0;@K;{;IC; " ;T;[;![;"@;#0;$@L;Bi;%@?;9@L;:@L;;To;;IC;[ o; ;IC;[; @ L; IC;[; @ L; IC;[; @ L; IC;{;IC;{;T;IC;{;T;T;{;[;[;F;: Loop;;;;;[;{;IC; " ;T;[;![;"@;#0;$@ L;%@ L;&I"Bug::Class::Loop;F;'0o;4;5F;6;;;;&I" Bug::Class#obj_method_arity;F;7[[I"obj;T0[I"mid;T0;[[I"ext/-test-/method/arity.c;Ti;T;:obj_method_arity;0;[;{;IC; " ;T;[;![;"I";F;#0;$@L;.F;C0;%@ L;9I"static VALUE obj_method_arity(VALUE self, VALUE obj, VALUE mid) { int arity = rb_obj_method_arity(obj, rb_check_id(&mid)); return INT2FIX(arity); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I" Bug::Class.obj_method_arity;F;7@L;@$L;T;;;0;@'L;{;IC; " ;T;[;![;"@;#0;$@/L;Bi;%@ L;9@-L;:@.L;;To;4;5F;6;;;;&I" Bug::Class#mod_method_arity;F;7[[I"mod;T0[I"mid;T0;[[@&Li;T;:mod_method_arity;0;[;{;IC; " ;T;[;![;"I";F;#0;$@5L;.F;C0;%@ L;9I"static VALUE mod_method_arity(VALUE self, VALUE mod, VALUE mid) { int arity = rb_mod_method_arity(mod, rb_check_id(&mid)); return INT2FIX(arity); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I" Bug::Class.mod_method_arity;F;7@7L;@L;{;IC; " ;T;[;![;"@;#0;$@FL;Bi;%@ L;9@DL;:@EL;;T; @ L; IC;[; @ L; IC;[; @ L; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"ext/-test-/class/init.c;Ti;F;;+;;;;;[;{;IC; " ;T;[;![;"@;#0;$@ L;%@?;&I"Bug::Class;Fo; ;IC;[o; ;IC;[o;4;5F;6;;;;&I" Bug::Integer::MyInteger.new;F;7[;[[I"$ext/-test-/integer/my_integer.c;Ti;T;;E;0;[;{;IC; " ;T;[;![;"@;#0;$@`L;%@^L;9I"`static VALUE my_integer_s_new(VALUE klass) { return Data_Wrap_Struct(klass, 0, 0, 0); };T;:I"static VALUE;T;;T; @^L; IC;[; @^L; IC;[; @^L; IC;{;IC;{;T;IC;{;T;T;{;[;[[@eLi;F;:MyInteger;;;;;[;{;IC; " ;T;[;![;"@;#0;$@^L;%@\L;&I"Bug::Integer::MyInteger;F;'@8o;4;5F;6;;;;&I"Bug::Integer.bignum?;F;7[[I" self;T0;[[I""ext/-test-/integer/core_ext.c;Ti;T;: bignum?;0;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@|L;![;"@;#0;$@|L;Bi;%@\L;9I"rstatic VALUE int_bignum_p(VALUE klass, VALUE self) { return RB_TYPE_P(self, T_BIGNUM) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Integer.fixnum?;F;7[[I" self;T0;[[@Li;T;: fixnum?;0;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@L;![;"@;#0;$@L;Bi;%@\L;9I"gstatic VALUE int_fixnum_p(VALUE klass, VALUE self) { return FIXNUM_P(self) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Integer.to_bignum;F;7[[I"x;T0;[[@Li;T;:to_bignum;0;[;{;IC; " ;T;[;![;"@;#0;$@L;%@\L;9I"static VALUE rb_int_to_bignum(VALUE klass, VALUE x) { if (FIXNUM_P(x)) x = rb_int2big(FIX2LONG(x)); return x; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Integer.positive_pow;F;7[[I"x;T0[I"y;T0;[[@Li;T;:positive_pow;0;[;{;IC; " ;T;[;![;"@;#0;$@L;%@\L;9I"|static VALUE positive_pow(VALUE klass, VALUE x, VALUE y) { return rb_int_positive_pow(NUM2LONG(x), NUM2ULONG(y)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$Bug::Integer.str2big_poweroftwo;F;7[[I"str;T0[I" vbase;T0[I" badcheck;T0;[[I" ext/-test-/bignum/str2big.c;Ti;T;:str2big_poweroftwo;0;[;{;IC; " ;T;[;![;"@;#0;$@L;%@\L;9I"static VALUE str2big_poweroftwo(VALUE klass, VALUE str, VALUE vbase, VALUE badcheck) { return rb_str2big_poweroftwo(str, NUM2INT(vbase), RTEST(badcheck)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Bug::Integer.str2big_normal;F;7[[I"str;T0[I" vbase;T0[I" badcheck;T0;[[@Li;T;:str2big_normal;0;[;{;IC; " ;T;[;![;"@;#0;$@L;%@\L;9I"static VALUE str2big_normal(VALUE klass, VALUE str, VALUE vbase, VALUE badcheck) { return rb_str2big_normal(str, NUM2INT(vbase), RTEST(badcheck)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#Bug::Integer.str2big_karatsuba;F;7[[I"str;T0[I" vbase;T0[I" badcheck;T0;[[@Li;T;:str2big_karatsuba;0;[;{;IC; " ;T;[;![;"@;#0;$@L;%@\L;9I"static VALUE str2big_karatsuba(VALUE klass, VALUE str, VALUE vbase, VALUE badcheck) { return rb_str2big_karatsuba(str, NUM2INT(vbase), RTEST(badcheck)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Integer.str2big_gmp;F;7[[I"str;T0[I" vbase;T0[I" badcheck;T0;[[@Li;T;:str2big_gmp;0;[;{;IC; " ;T;[;![;"@;#0;$@L;%@\L;9I"static VALUE str2big_gmp(VALUE klass, VALUE str, VALUE vbase, VALUE badcheck) { return rb_str2big_gmp(str, NUM2INT(vbase), RTEST(badcheck)); };T;:I"static VALUE;T;;To;u;[[I"ext/-test-/bignum/mul.c;Ti>;F;:SIZEOF_BDIGIT;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@M;%@\L;&I" Bug::Integer::SIZEOF_BDIGIT;F;xI"INT2NUM(SIZEOF_BDIGIT);To;u;[[@ Mi?;F;:BITSPERDIG;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@M;%@\L;&I"Bug::Integer::BITSPERDIG;F;xI"&INT2NUM(SIZEOF_BDIGIT * CHAR_BIT);To;4;5F;6;;;;&I" Bug::Integer.big_mul_normal;F;7[[I"x;T0[I"y;T0;[[@ Mi;T;:big_mul_normal;0;[;{;IC; " ;T;[;![;"@;#0;$@M;%@\L;9I"zstatic VALUE mul_normal(VALUE klass, VALUE x, VALUE y) { return rb_big_norm(rb_big_mul_normal(big(x), big(y))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Integer.big_sq_fast;F;7[[I"x;T0;[[@ Mi;T;:big_sq_fast;0;[;{;IC; " ;T;[;![;"@;#0;$@+M;%@\L;9I"cstatic VALUE sq_fast(VALUE klass, VALUE x) { return rb_big_norm(rb_big_sq_fast(big(x))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Bug::Integer.big_mul_balance;F;7[[I"x;T0[I"y;T0;[[@ Mi;T;:big_mul_balance;0;[;{;IC; " ;T;[;![;"@;#0;$@9M;%@\L;9I"|static VALUE mul_balance(VALUE klass, VALUE x, VALUE y) { return rb_big_norm(rb_big_mul_balance(big(x), big(y))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#Bug::Integer.big_mul_karatsuba;F;7[[I"x;T0[I"y;T0;[[@ Mi%;T;:big_mul_karatsuba;0;[;{;IC; " ;T;[;![;"@;#0;$@IM;%@\L;9I"{static VALUE mul_karatsuba(VALUE klass, VALUE x, VALUE y) { return rb_big_norm(rb_big_mul_karatsuba(big(x), big(y))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Integer.big_mul_toom3;F;7[[I"x;T0[I"y;T0;[[@ Mi+;T;:big_mul_toom3;0;[;{;IC; " ;T;[;![;"@;#0;$@YM;%@\L;9I"xstatic VALUE mul_toom3(VALUE klass, VALUE x, VALUE y) { return rb_big_norm(rb_big_mul_toom3(big(x), big(y))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Integer.big_mul_gmp;F;7[[I"x;T0[I"y;T0;[[@ Mi2;T;:big_mul_gmp;0;[;{;IC; " ;T;[;![;"@;#0;$@iM;%@\L;9I"tstatic VALUE mul_gmp(VALUE klass, VALUE x, VALUE y) { return rb_big_norm(rb_big_mul_gmp(big(x), big(y))); };T;:I"static VALUE;T;;T; @\L; IC;[; @\L; IC;[; @\L; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"ext/-test-/integer/init.c;Ti;F;;;;;;;[;{;IC; " ;T;[;![;"@;#0;$@\L;%@?;&I"Bug::Integer;F;'@o; ;IC;[%o;4;5F;6;;;;&I""Bug::Bignum.big_divrem_normal;F;7[[I"x;T0[I"y;T0;[[I"ext/-test-/bignum/div.c;Ti;T;:big_divrem_normal;0;[;{;IC; " ;T;[;![;"@;#0;$@M;%@M;9I"{static VALUE divrem_normal(VALUE klass, VALUE x, VALUE y) { return rb_big_norm(rb_big_divrem_normal(big(x), big(y))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Bignum.big_divrem_gmp;F;7[[I"x;T0[I"y;T0;[[@Mi;T;:big_divrem_gmp;0;[;{;IC; " ;T;[;![;"@;#0;$@M;%@M;9I"zstatic VALUE divrem_gmp(VALUE klass, VALUE x, VALUE y) { return rb_big_norm(rb_big_divrem_gmp(big(x), big(y))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Bignum.test_pack_raw;F;7[ [I"val;T0[I"buf;T0[I"numwords_arg;T0[I"wordsize_arg;T0[I" nails;T0[I" flags;T0;[[I" ext/-test-/bignum/intpack.c;Ti;T;:test_pack_raw;0;[;{;IC; " ;T;[;![;"@;#0;$@M;%@M;9I"static VALUE rb_integer_pack_raw_m(VALUE klass, VALUE val, VALUE buf, VALUE numwords_arg, VALUE wordsize_arg, VALUE nails, VALUE flags) { int sign; size_t numwords = 0; size_t wordsize = NUM2SIZET(wordsize_arg); StringValue(buf); rb_str_modify(buf); sign = rb_integer_pack(val, RSTRING_PTR(buf), NUM2SIZET(numwords_arg), NUM2SIZET(wordsize_arg), NUM2SIZET(nails), NUM2INT(flags)); return rb_ary_new_from_args(2, INT2NUM(sign), rb_str_new(RSTRING_PTR(buf), wordsize * numwords)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Bignum.test_pack;F;7[ [I"val;T0[I"numwords_arg;T0[I"wordsize_arg;T0[I" nails;T0[I" flags;T0;[[@Mi;T;:test_pack;0;[;{;IC; " ;T;[;![;"@;#0;$@M;%@M;9I"Cstatic VALUE rb_integer_pack_m(VALUE klass, VALUE val, VALUE numwords_arg, VALUE wordsize_arg, VALUE nails, VALUE flags) { int sign; size_t numwords = NUM2SIZET(numwords_arg); size_t wordsize = NUM2SIZET(wordsize_arg); VALUE buf; if (numwords != 0 && wordsize != 0 && LONG_MAX / wordsize < numwords) rb_raise(rb_eArgError, "too big numwords * wordsize"); buf = rb_str_new(NULL, numwords * wordsize); sign = rb_integer_pack(val, RSTRING_PTR(buf), numwords, wordsize, NUM2SIZET(nails), NUM2INT(flags)); return rb_assoc_new(INT2NUM(sign), buf); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Bignum.test_unpack;F;7[ [I"buf;T0[I" numwords;T0[I" wordsize;T0[I" nails;T0[I" flags;T0;[[@Mi*;T;:test_unpack;0;[;{;IC; " ;T;[;![;"@;#0;$@M;%@M;9I"!static VALUE rb_integer_unpack_m(VALUE klass, VALUE buf, VALUE numwords, VALUE wordsize, VALUE nails, VALUE flags) { StringValue(buf); return rb_integer_unpack(RSTRING_PTR(buf), NUM2SIZET(numwords), NUM2SIZET(wordsize), NUM2SIZET(nails), NUM2INT(flags)); };T;:I"static VALUE;T;;To;u;[[@MiN;F;:INTEGER_PACK_MSWORD_FIRST;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@M;%@M;&I"+Bug::Bignum::INTEGER_PACK_MSWORD_FIRST;F;xI"'INT2NUM(INTEGER_PACK_MSWORD_FIRST);To;u;[[@MiO;F;:INTEGER_PACK_LSWORD_FIRST;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@M;%@M;&I"+Bug::Bignum::INTEGER_PACK_LSWORD_FIRST;F;xI"'INT2NUM(INTEGER_PACK_LSWORD_FIRST);To;u;[[@MiP;F;:INTEGER_PACK_MSBYTE_FIRST;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@N;%@M;&I"+Bug::Bignum::INTEGER_PACK_MSBYTE_FIRST;F;xI"'INT2NUM(INTEGER_PACK_MSBYTE_FIRST);To;u;[[@MiQ;F;:INTEGER_PACK_LSBYTE_FIRST;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@N;%@M;&I"+Bug::Bignum::INTEGER_PACK_LSBYTE_FIRST;F;xI"'INT2NUM(INTEGER_PACK_LSBYTE_FIRST);To;u;[[@MiR;F;:#INTEGER_PACK_NATIVE_BYTE_ORDER;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@N;%@M;&I"0Bug::Bignum::INTEGER_PACK_NATIVE_BYTE_ORDER;F;xI",INT2NUM(INTEGER_PACK_NATIVE_BYTE_ORDER);To;u;[[@MiS;F;:INTEGER_PACK_2COMP;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@#N;%@M;&I"$Bug::Bignum::INTEGER_PACK_2COMP;F;xI" INT2NUM(INTEGER_PACK_2COMP);To;u;[[@MiT;F;:INTEGER_PACK_LITTLE_ENDIAN;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@-N;%@M;&I",Bug::Bignum::INTEGER_PACK_LITTLE_ENDIAN;F;xI"(INT2NUM(INTEGER_PACK_LITTLE_ENDIAN);To;u;[[@MiU;F;:INTEGER_PACK_BIG_ENDIAN;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@7N;%@M;&I")Bug::Bignum::INTEGER_PACK_BIG_ENDIAN;F;xI"%INT2NUM(INTEGER_PACK_BIG_ENDIAN);To;u;[[@MiV;F;:INTEGER_PACK_FORCE_BIGNUM;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@AN;%@M;&I"+Bug::Bignum::INTEGER_PACK_FORCE_BIGNUM;F;xI"'INT2NUM(INTEGER_PACK_FORCE_BIGNUM);To;u;[[@MiW;F;:INTEGER_PACK_NEGATIVE;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@KN;%@M;&I"'Bug::Bignum::INTEGER_PACK_NEGATIVE;F;xI"#INT2NUM(INTEGER_PACK_NEGATIVE);To;u;[[@MiX;F;:.INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@UN;%@M;&I";Bug::Bignum::INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION;F;xI"7INT2NUM(INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION);To;4;5F;6;;;;&I"0Bug::Bignum.test_numbits_2comp_without_sign;F;7[[I"val;T0;[[@Mi4;T;:$test_numbits_2comp_without_sign;0;[;{;IC; " ;T;[;![;"@;#0;$@_N;%@M;9I"static VALUE rb_integer_test_numbits_2comp_without_sign(VALUE klass, VALUE val) { size_t size; int neg = FIXNUM_P(val) ? FIX2LONG(val) < 0 : BIGNUM_NEGATIVE_P(val); size = rb_absint_numwords(val, 1, NULL) - (neg && rb_absint_singlebit_p(val)); return SIZET2NUM(size); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I".Bug::Bignum.test_numbytes_2comp_with_sign;F;7[[I"val;T0;[[@Mi=;T;:"test_numbytes_2comp_with_sign;0;[;{;IC; " ;T;[;![;"@;#0;$@mN;%@M;9I"<static VALUE rb_integer_test_numbytes_2comp_with_sign(VALUE klass, VALUE val) { int neg = FIXNUM_P(val) ? FIX2LONG(val) < 0 : BIGNUM_NEGATIVE_P(val); int nlz_bits; size_t size = rb_absint_size(val, &nlz_bits); if (nlz_bits == 0 && !(neg && rb_absint_singlebit_p(val))) size++; return SIZET2NUM(size); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Bug::Bignum.big2str_generic;F;7[[I"x;T0[I" vbase;T0;[[I" ext/-test-/bignum/big2str.c;Ti;T;:big2str_generic;0;[;{;IC; " ;T;[;![;"@;#0;$@{N;%@M;9I"static VALUE big2str_generic(VALUE klass, VALUE x, VALUE vbase) { int base = NUM2INT(vbase); if (base < 2 || 36 < base) rb_raise(rb_eArgError, "invalid radix %d", base); return rb_big2str_generic(big(x), base); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#Bug::Bignum.big2str_poweroftwo;F;7[[I"x;T0[I" vbase;T0;[[@Ni;T;:big2str_poweroftwo;0;[;{;IC; " ;T;[;![;"@;#0;$@N;%@M;9I"static VALUE big2str_poweroftwo(VALUE klass, VALUE x, VALUE vbase) { int base = NUM2INT(vbase); if (base < 2 || 36 < base || !POW2_P(base)) rb_raise(rb_eArgError, "invalid radix %d", base); return rb_big2str_poweroftwo(big(x), base); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Bignum.big2str_gmp;F;7[[I"x;T0[I" vbase;T0;[[@Ni(;T;:big2str_gmp;0;[;{;IC; " ;T;[;![;"@;#0;$@N;%@M;9I"static VALUE big2str_gmp(VALUE klass, VALUE x, VALUE vbase) { int base = NUM2INT(vbase); if (base < 2 || 36 < base) rb_raise(rb_eArgError, "invalid radix %d", base); return rb_big2str_gmp(big(x), base); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Bignum.zero;F;7[[I" length;T0;[[I" ext/-test-/bignum/bigzero.c;Ti;T;: zero;0;[;{;IC; " ;T;[;![;"@;#0;$@N;%@M;9I"static VALUE bug_big_zero(VALUE self, VALUE length) { long len = NUM2ULONG(length); VALUE z = rb_big_new(len, 1); MEMZERO(BIGNUM_DIGITS(z), BDIGIT, len); return z; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Bignum.negzero;F;7[[I" length;T0;[[@Ni;T;: negzero;0;[;{;IC; " ;T;[;![;"@;#0;$@N;%@M;9I"static VALUE bug_big_negzero(VALUE self, VALUE length) { long len = NUM2ULONG(length); VALUE z = rb_big_new(len, 0); MEMZERO(BIGNUM_DIGITS(z), BDIGIT, len); return z; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Bignum#coderange;F;7[;[[I""ext/-test-/string/coderange.c;Ti;T;:coderange;0;[;{;IC; ""return coderange without scan ;T;[;![;"I""return coderange without scan;T;#0;$@N;.F;/o;0;1T;2i;3i;%@M;9I"`static VALUE str_coderange(VALUE str) { return coderange_int2sym(ENC_CODERANGE(str)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Bignum#coderange_scan;F;7[;[[@Ni$;T;:coderange_scan;0;[;{;IC; ")scan coderange and return the result ;T;[;![;"I")scan coderange and return the result;T;#0;$@N;.F;/o;0;1T;2i#;3i#;%@M;9I"static VALUE str_coderange_scan(VALUE str) { ENC_CODERANGE_SET(str, ENC_CODERANGE_UNKNOWN); return coderange_int2sym(rb_enc_str_coderange(str)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Bignum.capacity;F;7[[I"str;T0;[[I"!ext/-test-/string/capacity.c;Ti ;T;: capacity;0;[;{;IC; " ;T;[;![;"@;#0;$@N;%@M;9I"static VALUE bug_str_capacity(VALUE klass, VALUE str) { if (!STR_EMBED_P(str) && STR_SHARED_P(str)) { return INT2FIX(0); } return LONG2FIX(rb_str_capacity(str)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::Bignum.fstring;F;7[[I"str;T0;[[I" ext/-test-/string/fstring.c;Ti ;T;: fstring;0;[;{;IC; " ;T;[;![;"@;#0;$@N;%@M;9I"OVALUE bug_s_fstring(VALUE self, VALUE str) { return rb_fstring(str); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"$Bug::Bignum.rb_enc_interned_str;F;7[[I" encoding;T0;[[@Ni;T;:rb_enc_interned_str;0;[;{;IC; " ;T;[;![;"@;#0;$@O;%@M;9I"VALUE bug_s_rb_enc_interned_str(VALUE self, VALUE encoding) { return rb_enc_interned_str("foo", 3, RDATA(encoding)->data); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Bug::Bignum.rb_enc_str_new;F;7[[I" encoding;T0;[[@Ni;T;:rb_enc_str_new;0;[;{;IC; " ;T;[;![;"@;#0;$@O;%@M;9I"{VALUE bug_s_rb_enc_str_new(VALUE self, VALUE encoding) { return rb_enc_str_new("foo", 3, RDATA(encoding)->data); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"$Bug::Bignum.rb_interned_str_dup;F;7[[I"str;T0;[[I"(ext/-test-/string/rb_interned_str.c;Ti;T;:rb_interned_str_dup;0;[;{;IC; " ;T;[;![;"@;#0;$@ O;%@M;9I"static VALUE bug_rb_interned_str_dup(VALUE self, VALUE str) { Check_Type(str, T_STRING); return rb_interned_str(RSTRING_PTR(str), RSTRING_LEN(str)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$Bug::Bignum#associate_encoding!;F;7[[I"enc;T0;[[I"&ext/-test-/string/enc_associate.c;Ti ;T;:associate_encoding!;0;[;{;IC; " ;T;[;![;"@;#0;$@/O;%@M;9I"qVALUE bug_str_enc_associate(VALUE str, VALUE enc) { return rb_enc_associate(str, rb_to_encoding(enc)); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Bug::Bignum.encoding_index;F;7[[I"str;T0;[[@6Oi;T;:encoding_index;0;[;{;IC; " ;T;[;![;"@;#0;$@>O;%@M;9I"zVALUE bug_str_encoding_index(VALUE self, VALUE str) { int idx = rb_enc_get_index(str); return INT2NUM(idx); };T;:I" VALUE;T;;T; @M; IC;[; @M; IC;[; @M; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"ext/-test-/bignum/init.c;Ti;F;;v;;;;;[;{;IC; " ;T;[;![;"@;#0;$@M;Bi;%@?;&I"Bug::Bignum;F;'@},o; ;IC;[o;4;5F;6;;;;&I"Bug::String.rb_str_dup;F;7[[I"str;T0;[[I"#ext/-test-/string/rb_str_dup.c;Ti ;T;:rb_str_dup;0;[;{;IC; " ;T;[;![;"@;#0;$@^O;%@\O;9I"ystatic VALUE bug_rb_str_dup(VALUE self, VALUE str) { rb_check_type(str, T_STRING); return rb_str_dup(str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::String.shared_string?;F;7[[I"str;T0;[[@eOi;T;:shared_string?;0;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@mO;![;"@;#0;$@mO;Bi;%@\O;9I"static VALUE bug_shared_string_p(VALUE self, VALUE str) { rb_check_type(str, T_STRING); return RB_FL_TEST(str, RUBY_ELTS_SHARED) && RB_FL_TEST(str, RSTRING_NOEMBED) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%Bug::String.sharing_with_shared?;F;7[[I"str;T0;[[@eOi;T;:sharing_with_shared?;0;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@~O;![;"@;#0;$@~O;Bi;%@\O;9I"static VALUE bug_sharing_with_shared_p(VALUE self, VALUE str) { rb_check_type(str, T_STRING); if (bug_shared_string_p(self, str)) { return bug_shared_string_p(self, RSTRING(str)->as.heap.aux.shared); } return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::String#cstr_term;F;7[;[[I"ext/-test-/string/cstr.c;Ti ;T;:cstr_term;0;[;{;IC; " ;T;[;![;"@;#0;$@O;%@\O;9I")static VALUE bug_str_cstr_term(VALUE str) { long len; char *s; int c; rb_encoding *enc; len = RSTRING_LEN(str); s = StringValueCStr(str); rb_gc(); enc = rb_enc_get(str); c = rb_enc_codepoint(&s[len], &s[len+rb_enc_mbminlen(enc)], enc); return INT2NUM(c); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::String#cstr_unterm;F;7[[I"c;T0;[[@Oi;T;:cstr_unterm;0;[;{;IC; " ;T;[;![;"@;#0;$@O;%@\O;9I"static VALUE bug_str_cstr_unterm(VALUE str, VALUE c) { long len; rb_str_modify(str); len = RSTRING_LEN(str); RSTRING_PTR(str)[len] = NUM2CHR(c); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::String#cstr_term_char;F;7[;[[@Oi%;T;:cstr_term_char;0;[;{;IC; " ;T;[;![;"@;#0;$@O;%@\O;9I"static VALUE bug_str_cstr_term_char(VALUE str) { long len; char *s; int c; rb_encoding *enc = rb_enc_get(str); RSTRING_GETMEM(str, s, len); s += len; len = rb_enc_mbminlen(enc); c = rb_enc_precise_mbclen(s, s + len, enc); if (!MBCLEN_CHARFOUND_P(c)) { c = (unsigned char)*s; } else { c = rb_enc_mbc_to_codepoint(s, s + len, enc); if (!c) return Qnil; } return rb_enc_uint_chr((unsigned int)c, enc); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'Bug::String#unterminated_substring;F;7[[I" vbeg;T0[I" vlen;T0;[[@Oi;;T;:unterminated_substring;0;[;{;IC; " ;T;[;![;"@;#0;$@O;%@\O;9I"Pstatic VALUE bug_str_unterminated_substring(VALUE str, VALUE vbeg, VALUE vlen) { long beg = NUM2LONG(vbeg); long len = NUM2LONG(vlen); rb_str_modify(str); if (len < 0) rb_raise(rb_eArgError, "negative length: %ld", len); if (RSTRING_LEN(str) < beg) rb_raise(rb_eIndexError, "beg: %ld", beg); if (RSTRING_LEN(str) < beg + len) rb_raise(rb_eIndexError, "end: %ld", beg + len); str = rb_str_new_shared(str); if (STR_EMBED_P(str)) { #if USE_RVARGC RSTRING(str)->as.embed.len = (short)len; #else RSTRING(str)->basic.flags &= ~RSTRING_EMBED_LEN_MASK; RSTRING(str)->basic.flags |= len << RSTRING_EMBED_LEN_SHIFT; #endif memmove(RSTRING(str)->as.embed.ary, RSTRING(str)->as.embed.ary + beg, len); } else { RSTRING(str)->as.heap.ptr += beg; RSTRING(str)->as.heap.len = len; } return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::String.cstr_term;F;7[[I"str;T0;[[@OiU;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@O;%@\O;9I"}static VALUE bug_str_s_cstr_term(VALUE self, VALUE str) { Check_Type(str, T_STRING); return bug_str_cstr_term(str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::String.cstr_unterm;F;7[[I"str;T0[I"c;T0;[[@Oi\;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@O;%@\O;9I"static VALUE bug_str_s_cstr_unterm(VALUE self, VALUE str, VALUE c) { Check_Type(str, T_STRING); return bug_str_cstr_unterm(str, c); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::String.cstr_term_char;F;7[[I"str;T0;[[@Oic;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@O;%@\O;9I"static VALUE bug_str_s_cstr_term_char(VALUE self, VALUE str) { Check_Type(str, T_STRING); return bug_str_cstr_term_char(str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::String.cstr_noembed;F;7[[I"str;T0;[[@Ois;T;:cstr_noembed;0;[;{;IC; " ;T;[;![;"@;#0;$@O;%@\O;9I"static VALUE bug_str_s_cstr_noembed(VALUE self, VALUE str) { VALUE str2 = rb_str_new(NULL, 0); long capacity = RSTRING_LEN(str) + TERM_LEN(str); char *buf = ALLOC_N(char, capacity); Check_Type(str, T_STRING); FL_SET((str2), STR_NOEMBED); memcpy(buf, RSTRING_PTR(str), capacity); #if USE_RVARGC RBASIC(str2)->flags &= ~(STR_SHARED | FL_USER5 | FL_USER6); #else RBASIC(str2)->flags &= ~RSTRING_EMBED_LEN_MASK; #endif RSTRING(str2)->as.heap.aux.capa = capacity; RSTRING(str2)->as.heap.ptr = buf; RSTRING(str2)->as.heap.len = RSTRING_LEN(str); TERM_FILL(RSTRING_END(str2), TERM_LEN(str)); return str2; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::String.cstr_embedded?;F;7[[I"str;T0;[[@Oi;T;:cstr_embedded?;0;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@P;![;"@;#0;$@P;Bi;%@\O;9I"tstatic VALUE bug_str_s_cstr_embedded_p(VALUE self, VALUE str) { return STR_EMBED_P(str) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""Bug::String.rb_str_new_frozen;F;7[[I"str;T0;[[@Oi;T;:rb_str_new_frozen;0;[;{;IC; " ;T;[;![;"@;#0;$@P;%@\O;9I"kstatic VALUE bug_str_s_rb_str_new_frozen(VALUE self, VALUE str) { return rb_str_new_frozen(str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::String#qsort!;F;7[[@90;[[I"ext/-test-/string/qsort.c;Ti!;T;: qsort!;0;[;{;IC; " ;T;[;![;"@;#0;$@P;%@\O;9I"static VALUE bug_str_qsort_bang(int argc, VALUE *argv, VALUE str) { VALUE beg, len, size; long l, b = 0, n, s = 1; struct sort_data d; rb_scan_args(argc, argv, "03", &beg, &len, &size); l = RSTRING_LEN(str); if (!NIL_P(beg) && (b = NUM2INT(beg)) < 0 && (b += l) < 0) { rb_raise(rb_eArgError, "out of bounds"); } if (!NIL_P(size) && (s = NUM2INT(size)) < 0) { rb_raise(rb_eArgError, "negative size"); } if (NIL_P(len) || (((n = NUM2INT(len)) < 0) ? (rb_raise(rb_eArgError, "negative length"), 0) : (b + n * s > l))) { n = (l - b) / s; } rb_str_modify(str); d.enc = rb_enc_get(str); d.elsize = s; ruby_qsort(RSTRING_PTR(str) + b, n, s, rb_block_given_p() ? cmp_1 : cmp_2, &d); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::String.nofree;F;7[;[[I"ext/-test-/string/nofree.c;Ti;T;: nofree;0;[;{;IC; " ;T;[;![;"@;#0;$@-P;%@\O;9I"OVALUE bug_str_nofree(VALUE self) { return rb_str_new_cstr("abcdef"); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Bug::String#ellipsize;F;7[[I"len;T0;[[I""ext/-test-/string/ellipsize.c;Ti;T;:ellipsize;0;[;{;IC; " ;T;[;![;"@;#0;$@:P;%@\O;9I"nstatic VALUE bug_str_ellipsize(VALUE str, VALUE len) { return rb_str_ellipsize(str, NUM2LONG(len)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Bug::String#normalize_ospath;F;7[;[[I""ext/-test-/string/normalize.c;Ti ;T;:normalize_ospath;0;[;{;IC; " ;T;[;![;"@;#0;$@IP;%@\O;9I"ystatic VALUE normalize_ospath(VALUE str) { return rb_str_normalize_ospath(RSTRING_PTR(str), RSTRING_LEN(str)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::String#modify!;F;7[;[[I"ext/-test-/string/modify.c;Ti;T;: modify!;0;[;{;IC; " ;T;[;![;"@;#0;$@VP;%@\O;9I"PVALUE bug_str_modify(VALUE str) { rb_str_modify(str); return str; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Bug::String#modify_expand!;F;7[[I" expand;T0;[[@[Pi;T;:modify_expand!;0;[;{;IC; " ;T;[;![;"@;#0;$@cP;%@\O;9I"~VALUE bug_str_modify_expand(VALUE str, VALUE expand) { rb_str_modify_expand(str, NUM2LONG(expand)); return str; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Bug::String#set_len;F;7[[I"len;T0;[[I" ext/-test-/string/set_len.c;Ti;T;: set_len;0;[;{;IC; " ;T;[;![;"@;#0;$@qP;%@\O;9I"sstatic VALUE bug_str_set_len(VALUE str, VALUE len) { rb_str_set_len(str, NUM2LONG(len)); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Bug::String#enc_str_buf_cat;F;7[[I" str2;T0;[[I"(ext/-test-/string/enc_str_buf_cat.c;Ti ;T;:enc_str_buf_cat;0;[;{;IC; " ;T;[;![;"@;#0;$@P;%@\O;9I"static VALUE enc_str_buf_cat(VALUE str, VALUE str2) { return rb_enc_str_buf_cat(str, RSTRING_PTR(str2), RSTRING_LEN(str2), rb_enc_get(str2)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""Bug::String#str_conv_enc_opts;F;7[ [I" from;T0[I"to;T0[I" ecflags;T0[I" ecopts;T0;[[@Pi;T;:str_conv_enc_opts;0;[;{;IC; " ;T;[;![;"@;#0;$@P;%@\O;9I"static VALUE str_conv_enc_opts(VALUE str, VALUE from, VALUE to, VALUE ecflags, VALUE ecopts) { rb_encoding *from_enc = NIL_P(from) ? NULL : rb_to_encoding(from); rb_encoding *to_enc = NIL_P(to) ? NULL : rb_to_encoding(to); int flags = NUM2INT(ecflags); if (!NIL_P(ecopts)) { Check_Type(ecopts, T_HASH); OBJ_FREEZE(ecopts); } return rb_str_conv_enc_opts(str, from_enc, to_enc, flags, ecopts); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::String.buf_new;F;7[[I"len;T0;[[I"ext/-test-/string/new.c;Ti ;T;: buf_new;0;[;{;IC; " ;T;[;![;"@;#0;$@P;%@\O;9I"fstatic VALUE bug_str_buf_new(VALUE self, VALUE len) { return rb_str_buf_new(NUM2LONG(len)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::String.external_new;F;7[[I"len;T0[I"enc;T0;[[@Pi;T;:external_new;0;[;{;IC; " ;T;[;![;"@;#0;$@P;%@\O;9I"static VALUE bug_external_str_new(VALUE self, VALUE len, VALUE enc) { return rb_external_str_new_with_enc(NULL, NUM2LONG(len), rb_to_encoding(enc)); };T;:I"static VALUE;T;;To; ;IC;[; @P; IC;[; @P; IC;[; @P; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"%ext/-test-/exception/dataerror.c;Ti";F;:DataError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@P;%@\O;&I"Bug::String::DataError;F;'@; @\O; IC;[; @\O; IC;[; @\O; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"ext/-test-/string/init.c;Ti;F;;;;;;;[;{;IC; " ;T;[;![;"@;#0;$@\O;%@?;&I"Bug::String;F;'@},o;;IC;[o;4;5F;6;;;;&I"Bug::RbCallSuperKw#m;F;7[[@90;[[I"3ext/-test-/rb_call_super_kw/rb_call_super_kw.c;Ti;T;;7;0;[;{;IC; " ;T;[;![;"@;#0;$@P;%@P;9I"static VALUE rb_call_super_kw_m(int argc, VALUE *argv, VALUE self) { return rb_call_super_kw(argc, argv, RB_PASS_CALLED_KEYWORDS); };T;:I"static VALUE;T;;T; @P; IC;[; @P; IC;[; @P; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Pi;F;:RbCallSuperKw;;;;;[;{;IC; " ;T;[;![;"@;#0;$@P;%@?;&I"Bug::RbCallSuperKw;Fo;4;5F;6;;;;&I"Bug#test_select;F;7[;[[I"-ext/-test-/win32/fd_setsize/fd_setsize.c;Ti ;T;:test_select;0;[;{;IC; " ;T;[;![;"I";F;#0;$@Q;.F;C0;%@?;9I"static VALUE test_select(VALUE self) { int sd = socket(AF_INET, SOCK_DGRAM, 0); struct timeval zero; fd_set read; fd_set write; fd_set error; zero.tv_sec = 0; zero.tv_usec = 0; FD_ZERO(&read); FD_ZERO(&write); FD_ZERO(&error); FD_SET(sd, &read); FD_SET(sd, &write); FD_SET(sd, &error); select(sd+1, &read, &write, &error, &zero); return Qtrue; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Bug.test_select;F;7@Q;@Q;T;;;0;@ Q;{;IC; " ;T;[;![;"@;#0;$@Q;Bi;%@?;9@Q;:@Q;;To;4;5F;6;;;;&I"Bug#test_fdset;F;7[;[[@Qi$;T;:test_fdset;0;[;{;IC; " ;T;[;![;"I";F;#0;$@Q;.F;C0;%@?;9I"static VALUE test_fdset(VALUE self) { int i; fd_set set; FD_ZERO(&set); for (i = 0; i < FD_SETSIZE * 2; i++) { int sd = socket(AF_INET, SOCK_DGRAM, 0); FD_SET(sd, &set); if (set.fd_count > FD_SETSIZE) { return Qfalse; } } return Qtrue; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Bug.test_fdset;F;7@Q;@Q;T;;;0;@Q;{;IC; " ;T;[;![;"@;#0;$@$Q;Bi;%@?;9@"Q;:@#Q;;To;4;5F;6;;;;&I"Bug#dlntest;F;7[;[[I"#ext/-test-/win32/dln/dlntest.c;Ti ;T;: dlntest;0;[;{;IC; " ;T;[;![;"I";F;#0;$@*Q;.F;C0;%@?;9I"Ustatic VALUE dln_dlntest(VALUE self) { dlntest_ordinal(); return self; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Bug.dlntest;F;7@,Q;@-Q;T;;;0;@0Q;{;IC; " ;T;[;![;"@;#0;$@8Q;Bi;%@?;9@6Q;:@7Q;;To;;IC;[o;4;5F;6;;;;&I"Bug::Win32.console_info;F;7[[I"io;T0;[[I")ext/-test-/win32/console/attribute.c;Ti;T;:console_info;0;[;{;IC; " ;T;[;![;"@;#0;$@@Q;%@>Q;9I"static VALUE console_info(VALUE klass, VALUE io) { HANDLE h = io_handle(io); CONSOLE_SCREEN_BUFFER_INFO csbi; if (!GetConsoleScreenBufferInfo(h, &csbi)) rb_syserr_fail(rb_w32_map_errno(GetLastError()), "not console"); return rb_struct_new(rb_cConsoleScreenBufferInfo, INT2FIX(csbi.dwSize.X), INT2FIX(csbi.dwSize.Y), INT2FIX(csbi.dwCursorPosition.X), INT2FIX(csbi.dwCursorPosition.Y), INT2FIX(csbi.wAttributes)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Bug::Win32.console_attribute;F;7[[I"io;T0[I" attr;T0;[[@GQi$;T;:console_attribute;0;[;{;IC; " ;T;[;![;"@;#0;$@OQ;%@>Q;9I"static VALUE console_set_attribute(VALUE klass, VALUE io, VALUE attr) { HANDLE h = io_handle(io); SetConsoleTextAttribute(h, (WORD)NUM2INT(attr)); return Qnil; };T;:I"static VALUE;T;;To;u;[[@GQi:;F;:FOREGROUND_MASK;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@_Q;%@>Q;&I" Bug::Win32::FOREGROUND_MASK;F;xI"INT2FIX(FOREGROUND_MASK);To;u;[[@GQi;;F;:FOREGROUND_BLUE;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@iQ;%@>Q;&I" Bug::Win32::FOREGROUND_BLUE;F;xI"INT2FIX(FOREGROUND_BLUE);To;u;[[@GQi<;F;:FOREGROUND_GREEN;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@sQ;%@>Q;&I"!Bug::Win32::FOREGROUND_GREEN;F;xI"INT2FIX(FOREGROUND_GREEN);To;u;[[@GQi=;F;:FOREGROUND_RED;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@}Q;%@>Q;&I"Bug::Win32::FOREGROUND_RED;F;xI"INT2FIX(FOREGROUND_RED);To;u;[[@GQi>;F;:FOREGROUND_INTENSITY;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@Q;%@>Q;&I"%Bug::Win32::FOREGROUND_INTENSITY;F;xI""INT2FIX(FOREGROUND_INTENSITY);To;u;[[@GQi@;F;:BACKGROUND_MASK;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@Q;%@>Q;&I" Bug::Win32::BACKGROUND_MASK;F;xI"INT2FIX(BACKGROUND_MASK);To;u;[[@GQiA;F;:BACKGROUND_BLUE;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@Q;%@>Q;&I" Bug::Win32::BACKGROUND_BLUE;F;xI"INT2FIX(BACKGROUND_BLUE);To;u;[[@GQiB;F;:BACKGROUND_GREEN;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@Q;%@>Q;&I"!Bug::Win32::BACKGROUND_GREEN;F;xI"INT2FIX(BACKGROUND_GREEN);To;u;[[@GQiC;F;:BACKGROUND_RED;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@Q;%@>Q;&I"Bug::Win32::BACKGROUND_RED;F;xI"INT2FIX(BACKGROUND_RED);To;u;[[@GQiD;F;:BACKGROUND_INTENSITY;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@Q;%@>Q;&I"%Bug::Win32::BACKGROUND_INTENSITY;F;xI""INT2FIX(BACKGROUND_INTENSITY);To;u;[[@GQiI;F;:REVERSE_VIDEO;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@Q;%@>Q;&I"Bug::Win32::REVERSE_VIDEO;F;xI"&INT2FIX(COMMON_LVB_REVERSE_VIDEO);T; @>Q; IC;[; @>Q; IC;[; @>Q; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"$ext/-test-/win32/console/init.c;Ti;F;: Win32;;;;;[;{;IC; " ;T;[;![;"@;#0;$@>Q;%@?;&I"Bug::Win32;Fo;4;5F;6;;;;&I"Bug#bug_14834;F;7[;[;F;:bug_14834;;;[;{;IC; " ;T;[;![;"I";F;#0;$@Q;.F;C0;%@?;;To;4;5T;6;;;;&I"Bug.bug_14834;F;7@Q;@Q;F;;;;;@Q;{;IC; " ;T;[;![;"@;#0;$@Q;Bi;%@?;;To;;IC;["o;4;5F;6;;;;&I"Bug::ScanArgs.lead;F;7[[@90;[[I"%ext/-test-/scan_args/scan_args.c;Ti ;T;: lead;0;[;{;IC; " ;T;[;![;"@;#0;$@Q;%@Q;9I"static VALUE scan_args_lead(int argc, VALUE *argv, VALUE self) { VALUE args[2]; int n = rb_scan_args(argc, argv, "1", args+1); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::ScanArgs.opt;F;7[[@90;[[@Qi;T;:opt;0;[;{;IC; " ;T;[;![;"@;#0;$@Q;%@Q;9I"static VALUE scan_args_opt(int argc, VALUE *argv, VALUE self) { VALUE args[2]; int n = rb_scan_args(argc, argv, "01", args+1); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::ScanArgs.lead_opt;F;7[[@90;[[@Qi;T;: lead_opt;0;[;{;IC; " ;T;[;![;"@;#0;$@ R;%@Q;9I"static VALUE scan_args_lead_opt(int argc, VALUE *argv, VALUE self) { VALUE args[3]; int n = rb_scan_args(argc, argv, "11", args+1, args+2); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::ScanArgs.var;F;7[[@90;[[@Qi(;T;:var;0;[;{;IC; "var ;T;[;![;"I"var;T;#0;$@R;.F;/o;0;1T;2i';3i';%@Q;9I"static VALUE scan_args_var(int argc, VALUE *argv, VALUE self) { VALUE args[2]; int n = rb_scan_args(argc, argv, "*", args+1); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::ScanArgs.lead_var;F;7[[@90;[[@Qi1;T;: lead_var;0;[;{;IC; " ;T;[;![;"@;#0;$@&R;%@Q;9I"static VALUE scan_args_lead_var(int argc, VALUE *argv, VALUE self) { VALUE args[3]; int n = rb_scan_args(argc, argv, "1*", args+1, args+2); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::ScanArgs.opt_var;F;7[[@90;[[@Qi:;T;: opt_var;0;[;{;IC; " ;T;[;![;"@;#0;$@3R;%@Q;9I"static VALUE scan_args_opt_var(int argc, VALUE *argv, VALUE self) { VALUE args[3]; int n = rb_scan_args(argc, argv, "01*", args+1, args+2); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::ScanArgs.lead_opt_var;F;7[[@90;[[@QiC;T;:lead_opt_var;0;[;{;IC; " ;T;[;![;"@;#0;$@@R;%@Q;9I"static VALUE scan_args_lead_opt_var(int argc, VALUE *argv, VALUE self) { VALUE args[4]; int n = rb_scan_args(argc, argv, "11*", args+1, args+2, args+3); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::ScanArgs.opt_trail;F;7[[@90;[[@QiM;T;:opt_trail;0;[;{;IC; " trail ;T;[;![;"I" trail;T;#0;$@MR;.F;/o;0;1T;2iL;3iL;%@Q;9I"static VALUE scan_args_opt_trail(int argc, VALUE *argv, VALUE self) { VALUE args[3]; int n = rb_scan_args(argc, argv, "011", args+1, args+2); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Bug::ScanArgs.lead_opt_trail;F;7[[@90;[[@QiV;T;:lead_opt_trail;0;[;{;IC; " ;T;[;![;"@;#0;$@\R;%@Q;9I"static VALUE scan_args_lead_opt_trail(int argc, VALUE *argv, VALUE self) { VALUE args[4]; int n = rb_scan_args(argc, argv, "111", args+1, args+2, args+3); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::ScanArgs.var_trail;F;7[[@90;[[@Qi_;T;:var_trail;0;[;{;IC; " ;T;[;![;"@;#0;$@iR;%@Q;9I"static VALUE scan_args_var_trail(int argc, VALUE *argv, VALUE self) { VALUE args[3]; int n = rb_scan_args(argc, argv, "*1", args+1, args+2); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Bug::ScanArgs.lead_var_trail;F;7[[@90;[[@Qih;T;:lead_var_trail;0;[;{;IC; " ;T;[;![;"@;#0;$@vR;%@Q;9I"static VALUE scan_args_lead_var_trail(int argc, VALUE *argv, VALUE self) { VALUE args[4]; int n = rb_scan_args(argc, argv, "1*1", args+1, args+2, args+3); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Bug::ScanArgs.opt_var_trail;F;7[[@90;[[@Qiq;T;:opt_var_trail;0;[;{;IC; " ;T;[;![;"@;#0;$@R;%@Q;9I"static VALUE scan_args_opt_var_trail(int argc, VALUE *argv, VALUE self) { VALUE args[4]; int n = rb_scan_args(argc, argv, "01*1", args+1, args+2, args+3); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%Bug::ScanArgs.lead_opt_var_trail;F;7[[@90;[[@Qiz;T;:lead_opt_var_trail;0;[;{;IC; " ;T;[;![;"@;#0;$@R;%@Q;9I"static VALUE scan_args_lead_opt_var_trail(int argc, VALUE *argv, VALUE self) { VALUE args[5]; int n = rb_scan_args(argc, argv, "11*1", args+1, args+2, args+3, args+4); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::ScanArgs.hash;F;7[[@90;[[@Qi;T;;X;0;[;{;IC; " hash ;T;[;![;"I" hash;T;#0;$@R;.F;/o;0;1T;2i~;3i~;%@Q;9I"static VALUE scan_args_hash(int argc, VALUE *argv, VALUE self) { VALUE args[2]; int n = rb_scan_args(argc, argv, ":", args+1); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::ScanArgs.lead_hash;F;7[[@90;[[@Qi;T;:lead_hash;0;[;{;IC; " ;T;[;![;"@;#0;$@R;%@Q;9I"static VALUE scan_args_lead_hash(int argc, VALUE *argv, VALUE self) { VALUE args[3]; int n = rb_scan_args(argc, argv, "1:", args+1, args+2); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::ScanArgs.opt_hash;F;7[[@90;[[@Qi;T;: opt_hash;0;[;{;IC; " ;T;[;![;"@;#0;$@R;%@Q;9I"static VALUE scan_args_opt_hash(int argc, VALUE *argv, VALUE self) { VALUE args[3]; int n = rb_scan_args(argc, argv, "01:", args+1, args+2); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Bug::ScanArgs.lead_opt_hash;F;7[[@90;[[@Qi;T;:lead_opt_hash;0;[;{;IC; " ;T;[;![;"@;#0;$@R;%@Q;9I"static VALUE scan_args_lead_opt_hash(int argc, VALUE *argv, VALUE self) { VALUE args[4]; int n = rb_scan_args(argc, argv, "11:", args+1, args+2, args+3); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::ScanArgs.var_hash;F;7[[@90;[[@Qi;T;: var_hash;0;[;{;IC; " ;T;[;![;"@;#0;$@R;%@Q;9I"static VALUE scan_args_var_hash(int argc, VALUE *argv, VALUE self) { VALUE args[3]; int n = rb_scan_args(argc, argv, "*:", args+1, args+2); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Bug::ScanArgs.lead_var_hash;F;7[[@90;[[@Qi;T;:lead_var_hash;0;[;{;IC; " ;T;[;![;"@;#0;$@R;%@Q;9I"static VALUE scan_args_lead_var_hash(int argc, VALUE *argv, VALUE self) { VALUE args[4]; int n = rb_scan_args(argc, argv, "1*:", args+1, args+2, args+3); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Bug::ScanArgs.opt_var_hash;F;7[[@90;[[@Qi;T;:opt_var_hash;0;[;{;IC; " ;T;[;![;"@;#0;$@R;%@Q;9I"static VALUE scan_args_opt_var_hash(int argc, VALUE *argv, VALUE self) { VALUE args[4]; int n = rb_scan_args(argc, argv, "01*:", args+1, args+2, args+3); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$Bug::ScanArgs.lead_opt_var_hash;F;7[[@90;[[@Qi;T;:lead_opt_var_hash;0;[;{;IC; " ;T;[;![;"@;#0;$@R;%@Q;9I"static VALUE scan_args_lead_opt_var_hash(int argc, VALUE *argv, VALUE self) { VALUE args[5]; int n = rb_scan_args(argc, argv, "11*:", args+1, args+2, args+3, args+4); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Bug::ScanArgs.opt_trail_hash;F;7[[@90;[[@Qi;T;:opt_trail_hash;0;[;{;IC; " ;T;[;![;"@;#0;$@S;%@Q;9I"static VALUE scan_args_opt_trail_hash(int argc, VALUE *argv, VALUE self) { VALUE args[4]; int n = rb_scan_args(argc, argv, "011:", args+1, args+2, args+3); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&Bug::ScanArgs.lead_opt_trail_hash;F;7[[@90;[[@Qi;T;:lead_opt_trail_hash;0;[;{;IC; " ;T;[;![;"@;#0;$@S;%@Q;9I"static VALUE scan_args_lead_opt_trail_hash(int argc, VALUE *argv, VALUE self) { VALUE args[5]; int n = rb_scan_args(argc, argv, "111:", args+1, args+2, args+3, args+4); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Bug::ScanArgs.var_trail_hash;F;7[[@90;[[@Qi;T;:var_trail_hash;0;[;{;IC; " ;T;[;![;"@;#0;$@!S;%@Q;9I"static VALUE scan_args_var_trail_hash(int argc, VALUE *argv, VALUE self) { VALUE args[4]; int n = rb_scan_args(argc, argv, "*1:", args+1, args+2, args+3); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&Bug::ScanArgs.lead_var_trail_hash;F;7[[@90;[[@Qi;T;:lead_var_trail_hash;0;[;{;IC; " ;T;[;![;"@;#0;$@.S;%@Q;9I"static VALUE scan_args_lead_var_trail_hash(int argc, VALUE *argv, VALUE self) { VALUE args[5]; int n = rb_scan_args(argc, argv, "1*1:", args+1, args+2, args+3, args+4); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%Bug::ScanArgs.opt_var_trail_hash;F;7[[@90;[[@Qi;T;:opt_var_trail_hash;0;[;{;IC; " ;T;[;![;"@;#0;$@;S;%@Q;9I"static VALUE scan_args_opt_var_trail_hash(int argc, VALUE *argv, VALUE self) { VALUE args[5]; int n = rb_scan_args(argc, argv, "01*1:", args+1, args+2, args+3, args+4); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*Bug::ScanArgs.lead_opt_var_trail_hash;F;7[[@90;[[@Qi;T;:lead_opt_var_trail_hash;0;[;{;IC; " ;T;[;![;"@;#0;$@HS;%@Q;9I"static VALUE scan_args_lead_opt_var_trail_hash(int argc, VALUE *argv, VALUE self) { VALUE args[6]; int n = rb_scan_args(argc, argv, "11*1:", args+1, args+2, args+3, args+4, args+5); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""Bug::ScanArgs.k_lead_opt_hash;F;7[[@90;[[@Qi;T;:k_lead_opt_hash;0;[;{;IC; " ;T;[;![;"@;#0;$@US;%@Q;9I"static VALUE scan_args_k_lead_opt_hash(int argc, VALUE *argv, VALUE self) { VALUE args[4]; int n = rb_scan_args_kw(RB_SCAN_ARGS_KEYWORDS, argc, argv, "11:", args+1, args+2, args+3); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""Bug::ScanArgs.n_lead_opt_hash;F;7[[@90;[[@Qi;T;:n_lead_opt_hash;0;[;{;IC; " ;T;[;![;"@;#0;$@bS;%@Q;9I"static VALUE scan_args_n_lead_opt_hash(int argc, VALUE *argv, VALUE self) { VALUE args[4]; int n = rb_scan_args_kw(RB_SCAN_ARGS_LAST_HASH_KEYWORDS, argc, argv, "11:", args+1, args+2, args+3); args[0] = INT2NUM(n); return rb_ary_new_from_values(numberof(args), args); };T;:I"static VALUE;T;;T; @Q; IC;[; @Q; IC;[; @Q; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Qi;F;: ScanArgs;;;;;[;{;IC; " ;T;[;![;"@;#0;$@Q;Bi;%@?;&I"Bug::ScanArgs;Fo; ;IC;[ o;4;5F;6;;;;&I"Bug::Exception#enc_raise;F;7[[I" encoding;T0[I" mesg;T0;[[I"%ext/-test-/exception/enc_raise.c;Ti ;T;:enc_raise;0;[;{;IC; " ;T;[;![;"I";F;#0;$@S;.F;C0;%@~S;9I"static VALUE enc_raise(VALUE exc, VALUE encoding, VALUE mesg) { rb_enc_raise(rb_to_encoding(encoding), exc, "%s", StringValueCStr(mesg)); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Bug::Exception.enc_raise;F;7@S;@S;T;;;0;@S;{;IC; " ;T;[;![;"@;#0;$@S;Bi;%@~S;9@S;:@S;;To;4;5F;6;;;;&I"Bug::Exception#ensured;F;7[[I" object;T0;[[I"#ext/-test-/exception/ensured.c;Ti;T;: ensured;0;[;{;IC; " ;T;[;![;"I";F;#0;$@S;.F;C0;%@~S;9I"nstatic VALUE ensured(VALUE module, VALUE object) { return rb_ensure(begin, object, ensure, object); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Bug::Exception.ensured;F;7@S;@S;T;; ;0;@S;{;IC; " ;T;[;![;"@;#0;$@S;Bi;%@~S;9@S;:@S;;To;4;5F;6;;;;&I" Bug::Exception#ensure_raise;F;7[[I" object;T0[I"exc;T0;[[@Si!;T;:ensure_raise;0;[;{;IC; " ;T;[;![;"I";F;#0;$@S;.F;C0;%@~S;9I"|static VALUE ensure_raise(VALUE module, VALUE object, VALUE exc) { return rb_ensure(rb_yield, object, exc_raise, exc); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I" Bug::Exception.ensure_raise;F;7@S;@S;T;; ;0;@S;{;IC; " ;T;[;![;"@;#0;$@S;Bi;%@~S;9@S;:@S;;T; @~S; IC;[; @~S; IC;[; @~S; IC;{;IC;{;T;IC;{;T;T;{;[;[[I" ext/-test-/exception/init.c;Ti;F;;O;;;;;[;{;IC; " ;T;[;![;"@;#0;$@~S;%@?;&I"Bug::Exception;F;'@o;;IC;[o;4;5F;6;;;;&I"Bug::Method#inspector;F;7[;[[I"!ext/-test-/debug/inspector.c;Ti;T;:inspector;0;[;{;IC; " ;T;[;![;"I";F;#0;$@S;.F;C0;%@S;9I"estatic VALUE debug_inspector(VALUE self) { return rb_debug_inspector_open(callback, NULL); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Bug::Method.inspector;F;7@S;@S;T;; ;0;@S;{;IC; " ;T;[;![;"@;#0;$@S;Bi;%@S;9@S;:@S;;T; @S; IC;[; @S; IC;[; @S; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"ext/-test-/method/init.c;Ti;F;: Method;;;;;[;{;IC; " ;T;[;![;"@;#0;$@S;%@?;&I"Bug::Method;Fo;4;5F;6;;;;&I"Bug.rb_fatal;F;7[[I"msg;T0;[[I" ext/-test-/fatal/rb_fatal.c;Ti;T;: rb_fatal;0;[;{;IC; " ;T;[;![;"@;#0;$@S;%@?;9I"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;;IC;[o;4;5F;6;;;;&I"Bug::Debug#profile_frames;F;7[[I" start_v;T0[I" num_v;T0;[[I"&ext/-test-/debug/profile_frames.c;Ti ;T;:profile_frames;0;[;{;IC; " ;T;[;![;"I";F;#0;$@ T;.F;C0;%@ T;9I"astatic VALUE profile_frames(VALUE self, VALUE start_v, VALUE num_v) { int i, collected_size; int start = NUM2INT(start_v); int buff_size = NUM2INT(num_v); VALUE buff[MAX_BUF_SIZE]; int lines[MAX_BUF_SIZE]; VALUE result = rb_ary_new(); if (buff_size > MAX_BUF_SIZE) rb_raise(rb_eRuntimeError, "too long buff_size"); collected_size = rb_profile_frames(start, buff_size, buff, lines); for (i=0; i"=": ENV['='] = '0' # Raises Errno::EINVAL (Invalid argument - ruby_setenv(=)) A new name or value: - May not be a non-String that does not respond to \#to_str: ENV['foo'] = Object.new # Raises TypeError (no implicit conversion of Object into String) ENV[Object.new] = '0' # Raises TypeError (no implicit conversion of Object into String) - May not contain the NUL character "\0": ENV['foo'] = "\0" # Raises ArgumentError (bad environment variable value: contains null byte) ENV["\0"] == '0' # Raises ArgumentError (bad environment variable name: contains null byte) - May not have an ASCII-incompatible encoding such as UTF-16LE or ISO-2022-JP: ENV['foo'] = '0'.force_encoding(Encoding::ISO_2022_JP) # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: ISO-2022-JP) ENV["foo".force_encoding(Encoding::ISO_2022_JP)] = '0' # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: ISO-2022-JP) === About Ordering ENV enumerates its name/value pairs in the order found in the operating system's environment variables. Therefore the ordering of ENV content is OS-dependent, and may be indeterminate. This will be seen in: - A Hash returned by an ENV method. - An Enumerator returned by an ENV method. - An Array returned by ENV.keys, ENV.values, or ENV.to_a. - The String returned by ENV.inspect. - The Array returned by ENV.shift. - The name returned by ENV.key. === About the Examples Some methods in ENV return ENV itself. Typically, there are many environment variables. It's not useful to display a large ENV in the examples here, so most example snippets begin by resetting the contents of ENV: - ENV.replace replaces ENV with a new collection of entries. - ENV.clear empties ENV. == What's Here First, what's elsewhere. \Class \ENV: - Inherits from {class Object}[Object.html#class-Object-label-What-27s+Here]. - Extends {module Enumerable}[Enumerable.html#module-Enumerable-label-What-27s+Here], Here, class \ENV provides methods that are useful for: - {Querying}[#class-ENV-label-Methods+for+Querying] - {Assigning}[#class-ENV-label-Methods+for+Assigning] - {Deleting}[#class-ENV-label-Methods+for+Deleting] - {Iterating}[#class-ENV-label-Methods+for+Iterating] - {Converting}[#class-ENV-label-Methods+for+Converting] - {And more ....}[#class-ENV-label-More+Methods] === Methods for Querying - ::[]:: Returns the value for the given environment variable name if it exists: - ::empty?:: Returns whether \ENV is empty. - ::has_value?, ::value?:: Returns whether the given value is in \ENV. - ::include?, ::has_key?, ::key?, ::member?:: Returns whether the given name is in \ENV. - ::key:: Returns the name of the first entry with the given value. - ::size, ::length:: Returns the number of entries. - ::value?:: Returns whether any entry has the given value. === Methods for Assigning - ::[]=, ::store:: Creates, updates, or deletes the named environment variable. - ::clear:: Removes every environment variable; returns \ENV: - ::update, ::merge!:: Adds to \ENV each key/value pair in the given hash. - ::replace:: Replaces the entire content of the \ENV with the name/value pairs in the given hash. === Methods for Deleting - ::delete:: Deletes the named environment variable name if it exists. - ::delete_if:: Deletes entries selected by the block. - ::keep_if:: Deletes entries not selected by the block. - ::reject!:: Similar to #delete_if, but returns +nil+ if no change was made. - ::select!, ::filter!:: Deletes entries selected by the block. - ::shift:: Removes and returns the first entry. === Methods for Iterating - ::each, ::each_pair:: Calls the block with each name/value pair. - ::each_key:: Calls the block with each name. - ::each_value:: Calls the block with each value. === Methods for Converting - ::assoc:: Returns a 2-element array containing the name and value of the named environment variable if it exists: - ::clone:: Returns \ENV (and issues a warning). - ::except:: Returns a hash of all name/value pairs except those given. - ::fetch:: Returns the value for the given name. - ::inspect:: Returns the contents of \ENV as a string. - ::invert:: Returns a hash whose keys are the ENV values, and whose values are the corresponding ENV names. - ::keys:: Returns an array of all names. - ::rassoc:: Returns the name and value of the first found entry that has the given value. - ::reject:: Returns a hash of those entries not rejected by the block. - ::select, ::filter:: Returns a hash of name/value pairs selected by the block. - ::slice:: Returns a hash of the given names and their corresponding values. - ::to_a:: Returns the entries as an array of 2-element Arrays. - ::to_h:: Returns a hash of entries selected by the block. - ::to_hash:: Returns a hash of all entries. - ::to_s:: Returns the string 'ENV'. - ::values:: Returns all values as an array. - ::values_at:: Returns an array of the values for the given name. === More Methods - ::dup:: Raises an exception. - ::freeze:: Raises an exception. - ::rehash:: Returns +nil+, without modifying \ENV. ;T;[;![;"I"j ENV is a hash-like accessor for environment variables. === Interaction with the Operating System The ENV object interacts with the operating system's environment variables: - When you get the value for a name in ENV, the value is retrieved from among the current environment variables. - When you create or set a name-value pair in ENV, the name and value are immediately set in the environment variables. - When you delete a name-value pair in ENV, it is immediately deleted from the environment variables. === Names and Values Generally, a name or value is a String. ==== Valid Names and Values Each name or value must be one of the following: - A String. - An object that responds to \#to_str by returning a String, in which case that String will be used as the name or value. ==== Invalid Names and Values A new name: - May not be the empty string: ENV[''] = '0' # Raises Errno::EINVAL (Invalid argument - ruby_setenv()) - May not contain character "=": ENV['='] = '0' # Raises Errno::EINVAL (Invalid argument - ruby_setenv(=)) A new name or value: - May not be a non-String that does not respond to \#to_str: ENV['foo'] = Object.new # Raises TypeError (no implicit conversion of Object into String) ENV[Object.new] = '0' # Raises TypeError (no implicit conversion of Object into String) - May not contain the NUL character "\0": ENV['foo'] = "\0" # Raises ArgumentError (bad environment variable value: contains null byte) ENV["\0"] == '0' # Raises ArgumentError (bad environment variable name: contains null byte) - May not have an ASCII-incompatible encoding such as UTF-16LE or ISO-2022-JP: ENV['foo'] = '0'.force_encoding(Encoding::ISO_2022_JP) # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: ISO-2022-JP) ENV["foo".force_encoding(Encoding::ISO_2022_JP)] = '0' # Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: ISO-2022-JP) === About Ordering ENV enumerates its name/value pairs in the order found in the operating system's environment variables. Therefore the ordering of ENV content is OS-dependent, and may be indeterminate. This will be seen in: - A Hash returned by an ENV method. - An Enumerator returned by an ENV method. - An Array returned by ENV.keys, ENV.values, or ENV.to_a. - The String returned by ENV.inspect. - The Array returned by ENV.shift. - The name returned by ENV.key. === About the Examples Some methods in ENV return ENV itself. Typically, there are many environment variables. It's not useful to display a large ENV in the examples here, so most example snippets begin by resetting the contents of ENV: - ENV.replace replaces ENV with a new collection of entries. - ENV.clear empties ENV. == What's Here First, what's elsewhere. \Class \ENV: - Inherits from {class Object}[Object.html#class-Object-label-What-27s+Here]. - Extends {module Enumerable}[Enumerable.html#module-Enumerable-label-What-27s+Here], Here, class \ENV provides methods that are useful for: - {Querying}[#class-ENV-label-Methods+for+Querying] - {Assigning}[#class-ENV-label-Methods+for+Assigning] - {Deleting}[#class-ENV-label-Methods+for+Deleting] - {Iterating}[#class-ENV-label-Methods+for+Iterating] - {Converting}[#class-ENV-label-Methods+for+Converting] - {And more ....}[#class-ENV-label-More+Methods] === Methods for Querying - ::[]:: Returns the value for the given environment variable name if it exists: - ::empty?:: Returns whether \ENV is empty. - ::has_value?, ::value?:: Returns whether the given value is in \ENV. - ::include?, ::has_key?, ::key?, ::member?:: Returns whether the given name is in \ENV. - ::key:: Returns the name of the first entry with the given value. - ::size, ::length:: Returns the number of entries. - ::value?:: Returns whether any entry has the given value. === Methods for Assigning - ::[]=, ::store:: Creates, updates, or deletes the named environment variable. - ::clear:: Removes every environment variable; returns \ENV: - ::update, ::merge!:: Adds to \ENV each key/value pair in the given hash. - ::replace:: Replaces the entire content of the \ENV with the name/value pairs in the given hash. === Methods for Deleting - ::delete:: Deletes the named environment variable name if it exists. - ::delete_if:: Deletes entries selected by the block. - ::keep_if:: Deletes entries not selected by the block. - ::reject!:: Similar to #delete_if, but returns +nil+ if no change was made. - ::select!, ::filter!:: Deletes entries selected by the block. - ::shift:: Removes and returns the first entry. === Methods for Iterating - ::each, ::each_pair:: Calls the block with each name/value pair. - ::each_key:: Calls the block with each name. - ::each_value:: Calls the block with each value. === Methods for Converting - ::assoc:: Returns a 2-element array containing the name and value of the named environment variable if it exists: - ::clone:: Returns \ENV (and issues a warning). - ::except:: Returns a hash of all name/value pairs except those given. - ::fetch:: Returns the value for the given name. - ::inspect:: Returns the contents of \ENV as a string. - ::invert:: Returns a hash whose keys are the ENV values, and whose values are the corresponding ENV names. - ::keys:: Returns an array of all names. - ::rassoc:: Returns the name and value of the first found entry that has the given value. - ::reject:: Returns a hash of those entries not rejected by the block. - ::select, ::filter:: Returns a hash of name/value pairs selected by the block. - ::slice:: Returns a hash of the given names and their corresponding values. - ::to_a:: Returns the entries as an array of 2-element Arrays. - ::to_h:: Returns a hash of entries selected by the block. - ::to_hash:: Returns a hash of all entries. - ::to_s:: Returns the string 'ENV'. - ::values:: Returns all values as an array. - ::values_at:: Returns an array of the values for the given name. === More Methods - ::dup:: Raises an exception. - ::freeze:: Raises an exception. - ::rehash:: Returns +nil+, without modifying \ENV. ;T;#0;$@fT;.F;/o;0;1T;2iM;3i;%@;&I"ENV;F;'o;( ;)0;*0;+0;;;%@;-@;0o;;IC;[o;4;5F;6;;;;&I"#MemoryViewTestUtils#available?;F;7[[I"obj;T0;[[I")ext/-test-/memory_view/memory_view.c;Ti7;T;:available?;0;[;{;IC; " ;T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@}T;![;"I"@return [Boolean] ;T;#0;$@}T;.F;C0;%@{T;9I"{static VALUE memory_view_available_p(VALUE mod, VALUE obj) { return rb_memory_view_available_p(obj) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"#MemoryViewTestUtils.available?;F;7@T;@T;T;; ;0;@T;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@T;![;"@;#0;$@T;Bi;%@{T;9@T;:@T;;To;4;5F;6;;;;&I"!MemoryViewTestUtils#register;F;7[[I"obj;T0;[[@Ti=;T;; ;0;[;{;IC; " ;T;[;![;"I";F;#0;$@T;.F;C0;%@{T;9I"static VALUE memory_view_register(VALUE mod, VALUE obj) { return rb_memory_view_register(obj, &exportable_string_memory_view_entry) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"!MemoryViewTestUtils.register;F;7@T;@T;T;; ;0;@T;{;IC; " ;T;[;![;"@;#0;$@T;Bi;%@{T;9@T;:@T;;To;4;5F;6;;;;&I".MemoryViewTestUtils#item_size_from_format;F;7[[I" format;T0;[[@TiC;T;:item_size_from_format;0;[;{;IC; " ;T;[;![;"I";F;#0;$@T;.F;C0;%@{T;9I"static VALUE memory_view_item_size_from_format(VALUE mod, VALUE format) { const char *c_str = NULL; if (!NIL_P(format)) c_str = StringValueCStr(format); const char *err = NULL; ssize_t item_size = rb_memory_view_item_size_from_format(c_str, &err); if (!err) return rb_assoc_new(SSIZET2NUM(item_size), Qnil); else return rb_assoc_new(SSIZET2NUM(item_size), rb_str_new_cstr(err)); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I".MemoryViewTestUtils.item_size_from_format;F;7@T;@T;T;; ;0;@T;{;IC; " ;T;[;![;"@;#0;$@T;Bi;%@{T;9@T;:@T;;To;4;5F;6;;;;&I"*MemoryViewTestUtils#parse_item_format;F;7[[I" format;T0;[[@TiQ;T;:parse_item_format;0;[;{;IC; " ;T;[;![;"I";F;#0;$@T;.F;C0;%@{T;9I"static VALUE memory_view_parse_item_format(VALUE mod, VALUE format) { const char *c_str = NULL; if (!NIL_P(format)) c_str = StringValueCStr(format); const char *err = NULL; rb_memory_view_item_component_t *members; size_t n_members; ssize_t item_size = rb_memory_view_parse_item_format(c_str, &members, &n_members, &err); VALUE result = rb_ary_new_capa(3); rb_ary_push(result, SSIZET2NUM(item_size)); if (!err) { VALUE ary = rb_ary_new_capa((long)n_members); size_t i; for (i = 0; i < n_members; ++i) { VALUE member = rb_hash_new(); rb_hash_aset(member, sym_format, rb_str_new(&members[i].format, 1)); rb_hash_aset(member, sym_native_size_p, members[i].native_size_p ? Qtrue : Qfalse); rb_hash_aset(member, sym_endianness, members[i].little_endian_p ? sym_little_endian : sym_big_endian); rb_hash_aset(member, sym_offset, SSIZET2NUM(members[i].offset)); rb_hash_aset(member, sym_size, SSIZET2NUM(members[i].size)); rb_hash_aset(member, sym_repeat, SSIZET2NUM(members[i].repeat)); rb_ary_push(ary, member); } xfree(members); rb_ary_push(result, ary); rb_ary_push(result, Qnil); } else { rb_ary_push(result, Qnil); // members rb_ary_push(result, rb_str_new_cstr(err)); } return result; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"*MemoryViewTestUtils.parse_item_format;F;7@T;@T;T;; ;0;@T;{;IC; " ;T;[;![;"@;#0;$@T;Bi;%@{T;9@T;:@T;;To;4;5F;6;;;;&I"-MemoryViewTestUtils#get_memory_view_info;F;7[[I"obj;T0;[[@Tiy;T;:get_memory_view_info;0;[;{;IC; " ;T;[;![;"I";F;#0;$@T;.F;C0;%@{T;9I"static VALUE memory_view_get_memory_view_info(VALUE mod, VALUE obj) { rb_memory_view_t view; if (!rb_memory_view_get(obj, &view, 0)) { return Qnil; } VALUE hash = rb_hash_new(); rb_hash_aset(hash, sym_obj, view.obj); rb_hash_aset(hash, sym_byte_size, SSIZET2NUM(view.byte_size)); rb_hash_aset(hash, sym_readonly, view.readonly ? Qtrue : Qfalse); rb_hash_aset(hash, sym_format, view.format ? rb_str_new_cstr(view.format) : Qnil); rb_hash_aset(hash, sym_item_size, SSIZET2NUM(view.item_size)); rb_hash_aset(hash, sym_ndim, SSIZET2NUM(view.ndim)); if (view.shape) { VALUE shape = rb_ary_new_capa(view.ndim); rb_hash_aset(hash, sym_shape, shape); } else { rb_hash_aset(hash, sym_shape, Qnil); } if (view.strides) { VALUE strides = rb_ary_new_capa(view.ndim); rb_hash_aset(hash, sym_strides, strides); } else { rb_hash_aset(hash, sym_strides, Qnil); } if (view.sub_offsets) { VALUE sub_offsets = rb_ary_new_capa(view.ndim); rb_hash_aset(hash, sym_sub_offsets, sub_offsets); } else { rb_hash_aset(hash, sym_sub_offsets, Qnil); } rb_memory_view_release(&view); return hash; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"-MemoryViewTestUtils.get_memory_view_info;F;7@T;@T;T;; ;0;@T;{;IC; " ;T;[;![;"@;#0;$@T;Bi;%@{T;9@T;:@T;;To;4;5F;6;;;;&I"0MemoryViewTestUtils#fill_contiguous_strides;F;7[ [I" ndim_v;T0[I"item_size_v;T0[I" shape_v;T0[I"row_major_p;T0;[[@Ti;T;:fill_contiguous_strides;0;[;{;IC; " ;T;[;![;"I";F;#0;$@T;.F;C0;%@{T;9I"static VALUE memory_view_fill_contiguous_strides(VALUE mod, VALUE ndim_v, VALUE item_size_v, VALUE shape_v, VALUE row_major_p) { ssize_t i, ndim = NUM2SSIZET(ndim_v); Check_Type(shape_v, T_ARRAY); ssize_t *shape = ALLOC_N(ssize_t, ndim); for (i = 0; i < ndim; ++i) { shape[i] = NUM2SSIZET(RARRAY_AREF(shape_v, i)); } ssize_t *strides = ALLOC_N(ssize_t, ndim); rb_memory_view_fill_contiguous_strides(ndim, NUM2SSIZET(item_size_v), shape, RTEST(row_major_p), strides); VALUE result = rb_ary_new_capa(ndim); for (i = 0; i < ndim; ++i) { rb_ary_push(result, SSIZET2NUM(strides[i])); } xfree(strides); xfree(shape); return result; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"0MemoryViewTestUtils.fill_contiguous_strides;F;7@T;@T;T;; ;0;@T;{;IC; " ;T;[;![;"@;#0;$@U;Bi;%@{T;9@U;:@U;;To;4;5F;6;;;;&I"2MemoryViewTestUtils#ref_count_while_exporting;F;7[[I"obj;T0[I"n;T0;[[@Ti;T;:ref_count_while_exporting;0;[;{;IC; " ;T;[;![;"I";F;#0;$@ U;.F;C0;%@{T;9I"static VALUE memory_view_ref_count_while_exporting(VALUE mod, VALUE obj, VALUE n) { Check_Type(n, T_FIXNUM); return memory_view_ref_count_while_exporting_i(obj, FIX2LONG(n)); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"2MemoryViewTestUtils.ref_count_while_exporting;F;7@ U;@U;T;; ;0;@U;{;IC; " ;T;[;![;"@;#0;$@U;Bi;%@{T;9@U;:@U;;To;4;5F;6;;;;&I"-MemoryViewTestUtils#extract_item_members;F;7[[I"str;T0[I" format;T0;[[@Ti;T;:extract_item_members;0;[;{;IC; " ;T;[;![;"I";F;#0;$@!U;.F;C0;%@{T;9I"!static VALUE memory_view_extract_item_members(VALUE mod, VALUE str, VALUE format) { StringValue(str); StringValue(format); rb_memory_view_item_component_t *members; size_t n_members; const char *err = NULL; (void)rb_memory_view_parse_item_format(RSTRING_PTR(format), &members, &n_members, &err); if (err != NULL) { rb_raise(rb_eArgError, "Unable to parse item format"); } VALUE item = rb_memory_view_extract_item_members(RSTRING_PTR(str), members, n_members); xfree(members); return item; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"-MemoryViewTestUtils.extract_item_members;F;7@#U;@(U;T;; ;0;@*U;{;IC; " ;T;[;![;"@;#0;$@2U;Bi;%@{T;9@0U;:@1U;;To; ;IC;[o;4;5F;6;;;;&I"5MemoryViewTestUtils::ExportableString#initialize;F;7[[I"s;T0;[[@Ti;T;;D;0;[;{;IC; " ;T;[;![;"@;#0;$@:U;%@8U;9I"static VALUE expstr_initialize(VALUE obj, VALUE s) { if (!NIL_P(s)) { Check_Type(s, T_STRING); } rb_ivar_set(obj, id_str, s); return Qnil; };T;:I"static VALUE;T;;T; @8U; IC;[; @8U; IC;[; @8U; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Ti;F;:ExportableString;;;;;[;{;IC; " ;T;[;![;"@;#0;$@8U;%@{T;&I"*MemoryViewTestUtils::ExportableString;F;'@o; ;IC;[o;4;5F;6;;;;&I"9MemoryViewTestUtils::MultiDimensionalView#initialize;F;7[ [I"buf;T0[I" format;T0[I" shape;T0[I" strides;T0;[[@TiN;T;;D;0;[;{;IC; " ;T;[;![;"@;#0;$@YU;%@WU;9I"static VALUE mdview_initialize(VALUE obj, VALUE buf, VALUE format, VALUE shape, VALUE strides) { Check_Type(buf, T_STRING); StringValue(format); Check_Type(shape, T_ARRAY); if (!NIL_P(strides)) Check_Type(strides, T_ARRAY); rb_ivar_set(obj, id_str, buf); rb_ivar_set(obj, SYM2ID(sym_format), format); rb_ivar_set(obj, SYM2ID(sym_shape), shape); rb_ivar_set(obj, SYM2ID(sym_strides), strides); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"1MemoryViewTestUtils::MultiDimensionalView#[];F;7[[I"indices_v;T0;[[@Ti];T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@mU;%@WU;9I"static VALUE mdview_aref(VALUE obj, VALUE indices_v) { Check_Type(indices_v, T_ARRAY); rb_memory_view_t view; if (!rb_memory_view_get(obj, &view, 0)) { rb_raise(rb_eRuntimeError, "rb_memory_view_get: failed"); } if (RARRAY_LEN(indices_v) != view.ndim) { rb_raise(rb_eKeyError, "Indices has an invalid dimension"); } VALUE buf_indices; ssize_t *indices = ALLOCV_N(ssize_t, buf_indices, view.ndim); ssize_t i; for (i = 0; i < view.ndim; ++i) { indices[i] = NUM2SSIZET(RARRAY_AREF(indices_v, i)); } VALUE result = rb_memory_view_get_item(&view, indices); ALLOCV_END(buf_indices); rb_memory_view_release(&view); return result; };T;:I"static VALUE;T;;T; @WU; IC;[; @WU; IC;[; @WU; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Ti;F;:MultiDimensionalView;;;;;[;{;IC; " ;T;[;![;"@;#0;$@WU;%@{T;&I".MemoryViewTestUtils::MultiDimensionalView;F;'@; @{T; IC;[; @{T; IC;[; @{T; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Ti;F;:MemoryViewTestUtils;;;;;[;{;IC; " ;T;[;![;"@;#0;$@{T;%@;&I"MemoryViewTestUtils;Fo;;IC;[o;4;5F;6;;;;&I"Num2int#NUM2SHORT;F;7[[I"num;T0;[[I"!ext/-test-/num2int/num2int.c;Ti;T;:NUM2SHORT;0;[;{;IC; " ;T;[;![;"I";F;#0;$@U;.F;C0;%@U;9I"static VALUE test_num2short(VALUE obj, VALUE num) { char buf[128]; sprintf(buf, "%d", NUM2SHORT(num)); return rb_str_new_cstr(buf); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Num2int.NUM2SHORT;F;7@U;@U;T;; ;0;@U;{;IC; " ;T;[;![;"@;#0;$@U;Bi;%@U;9@U;:@U;;To;4;5F;6;;;;&I"Num2int#NUM2USHORT;F;7[[I"num;T0;[[@Ui;T;:NUM2USHORT;0;[;{;IC; " ;T;[;![;"I";F;#0;$@U;.F;C0;%@U;9I"static VALUE test_num2ushort(VALUE obj, VALUE num) { char buf[128]; sprintf(buf, "%u", NUM2USHORT(num)); return rb_str_new_cstr(buf); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Num2int.NUM2USHORT;F;7@U;@U;T;; ;0;@U;{;IC; " ;T;[;![;"@;#0;$@U;Bi;%@U;9@U;:@U;;To;4;5F;6;;;;&I"Num2int#NUM2INT;F;7[[I"num;T0;[[@Ui;T;: NUM2INT;0;[;{;IC; " ;T;[;![;"I";F;#0;$@U;.F;C0;%@U;9I"static VALUE test_num2int(VALUE obj, VALUE num) { char buf[128]; sprintf(buf, "%d", NUM2INT(num)); return rb_str_new_cstr(buf); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Num2int.NUM2INT;F;7@U;@U;T;; ;0;@U;{;IC; " ;T;[;![;"@;#0;$@U;Bi;%@U;9@U;:@U;;To;4;5F;6;;;;&I"Num2int#NUM2UINT;F;7[[I"num;T0;[[@Ui ;T;: NUM2UINT;0;[;{;IC; " ;T;[;![;"I";F;#0;$@U;.F;C0;%@U;9I"static VALUE test_num2uint(VALUE obj, VALUE num) { char buf[128]; sprintf(buf, "%u", NUM2UINT(num)); return rb_str_new_cstr(buf); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Num2int.NUM2UINT;F;7@U;@U;T;; ;0;@U;{;IC; " ;T;[;![;"@;#0;$@U;Bi;%@U;9@U;:@U;;To;4;5F;6;;;;&I"Num2int#NUM2LONG;F;7[[I"num;T0;[[@Ui(;T;: NUM2LONG;0;[;{;IC; " ;T;[;![;"I";F;#0;$@U;.F;C0;%@U;9I"static VALUE test_num2long(VALUE obj, VALUE num) { char buf[128]; sprintf(buf, "%ld", NUM2LONG(num)); return rb_str_new_cstr(buf); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Num2int.NUM2LONG;F;7@U;@U;T;; ;0;@U;{;IC; " ;T;[;![;"@;#0;$@U;Bi;%@U;9@U;:@U;;To;4;5F;6;;;;&I"Num2int#NUM2ULONG;F;7[[I"num;T0;[[@Ui0;T;:NUM2ULONG;0;[;{;IC; " ;T;[;![;"I";F;#0;$@V;.F;C0;%@U;9I"static VALUE test_num2ulong(VALUE obj, VALUE num) { char buf[128]; sprintf(buf, "%lu", NUM2ULONG(num)); return rb_str_new_cstr(buf); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Num2int.NUM2ULONG;F;7@V;@ V;T;; ;0;@ V;{;IC; " ;T;[;![;"@;#0;$@V;Bi;%@U;9@V;:@V;;To;4;5F;6;;;;&I"Num2int#NUM2LL;F;7[[I"num;T0;[[@Ui9;T;: NUM2LL;0;[;{;IC; " ;T;[;![;"I";F;#0;$@V;.F;C0;%@U;9I"static VALUE test_num2ll(VALUE obj, VALUE num) { char buf[128]; sprintf(buf, "%"PRI_LL_PREFIX"d", NUM2LL(num)); return rb_str_new_cstr(buf); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Num2int.NUM2LL;F;7@V;@V;T;; ;0;@!V;{;IC; " ;T;[;![;"@;#0;$@)V;Bi;%@U;9@'V;:@(V;;To;4;5F;6;;;;&I"Num2int#NUM2ULL;F;7[[I"num;T0;[[@UiA;T;: NUM2ULL;0;[;{;IC; " ;T;[;![;"I";F;#0;$@/V;.F;C0;%@U;9I"static VALUE test_num2ull(VALUE obj, VALUE num) { char buf[128]; sprintf(buf, "%"PRI_LL_PREFIX"u", NUM2ULL(num)); return rb_str_new_cstr(buf); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Num2int.NUM2ULL;F;7@1V;@4V;T;; ;0;@6V;{;IC; " ;T;[;![;"@;#0;$@>V;Bi;%@U;9@produces: Got . Got .. Got config.h Got main.rb ;T;[ o;= ;>I" overload;F;?0;;p;@0;:I"foreach( dirname );T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" filename;T;$@Vo;A ;>I" return;F;?I";T;0;@[I"nil;T;$@V;![;"I"&@yield [ filename ] @return [nil];T;#0;$@V;.F;Bi;C0;7[[I" dirname;T0;$@Vo;= ;>I" overload;F;?0;;p;@0;:I"&foreach( dirname, encoding: enc );T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" filename;T;$@Vo;A ;>I" return;F;?I";T;0;@[I"nil;T;$@V;![;"I"&@yield [ filename ] @return [nil];T;#0;$@V;.F;Bi;C0;7[[I" dirname;T0[I"encoding:;TI"enc;T;$@Vo;= ;>I" overload;F;?0;;p;@0;:I"foreach( dirname );T;IC; ";T;[;![;"I";T;#0;$@V;.F;Bi;C0;7[[I" dirname;T0;$@Vo;= ;>I" overload;F;?0;;p;@0;:I"&foreach( dirname, encoding: enc );T;IC; ";T;[;![;"I";T;#0;$@V;.F;Bi;C0;7[[I" dirname;T0[I"encoding:;TI"enc;T;$@V;![;"I"Calls the block once for each entry in the named directory, passing the filename of each entry as a parameter to the block. If no block is given, an enumerator is returned instead. Dir.foreach("testdir") {|x| puts "Got #{x}" } produces: Got . Got .. Got config.h Got main.rb @overload foreach( dirname ) @yield [ filename ] @return [nil] @overload foreach( dirname, encoding: enc ) @yield [ filename ] @return [nil] @overload foreach( dirname ) @overload foreach( dirname, encoding: enc );T;#0;$@V;.F;/o;0;1T;2i ;3i ;%@V;9I"static VALUE dir_foreach(int argc, VALUE *argv, VALUE io) { VALUE dir; RETURN_ENUMERATOR(io, argc, argv); dir = dir_open_dir(argc, argv); rb_ensure(dir_each, dir, dir_close, dir); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Dir.entries;F;7[[@90;[[@fi ;T;;;0;[;{;IC; "ZReturns an array containing all of the filenames in the given directory. Will raise a SystemCallError if the named directory doesn't exist. The optional encoding keyword argument specifies the encoding of the directory. If not specified, the filesystem encoding is used. Dir.entries("testdir") #=> [".", "..", "config.h", "main.rb"] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"entries( dirname );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@W;![;"I"@return [Array];T;#0;$@W;.F;Bi;C0;7[[I" dirname;T0;$@Wo;= ;>I" overload;F;?0;;;@0;:I"&entries( dirname, encoding: enc );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@W;![;"I"@return [Array];T;#0;$@W;.F;Bi;C0;7[[I" dirname;T0[I"encoding:;TI"enc;T;$@W;![;"I"Returns an array containing all of the filenames in the given directory. Will raise a SystemCallError if the named directory doesn't exist. The optional encoding keyword argument specifies the encoding of the directory. If not specified, the filesystem encoding is used. Dir.entries("testdir") #=> [".", "..", "config.h", "main.rb"] @overload entries( dirname ) @return [Array] @overload entries( dirname, encoding: enc ) @return [Array];T;#0;$@W;.F;/o;0;1T;2i ;3i ;%@V;9I"static VALUE dir_entries(int argc, VALUE *argv, VALUE io) { VALUE dir; dir = dir_open_dir(argc, argv); return rb_ensure(dir_collect, dir, dir_close, dir); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Dir.each_child;F;7[[@90;[[@fi ;T;;;0;[;{;IC; "6Calls the block once for each entry except for "." and ".." in the named directory, passing the filename of each entry as a parameter to the block. If no block is given, an enumerator is returned instead. Dir.each_child("testdir") {|x| puts "Got #{x}" } produces: Got config.h Got main.rb ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"each_child( dirname );T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" filename;T;$@?Wo;A ;>I" return;F;?I";T;0;@[I"nil;T;$@?W;![;"I"&@yield [ filename ] @return [nil];T;#0;$@?W;.F;Bi;C0;7[[I" dirname;T0;$@?Wo;= ;>I" overload;F;?0;;;@0;:I")each_child( dirname, encoding: enc );T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" filename;T;$@?Wo;A ;>I" return;F;?I";T;0;@[I"nil;T;$@?W;![;"I"&@yield [ filename ] @return [nil];T;#0;$@?W;.F;Bi;C0;7[[I" dirname;T0[I"encoding:;TI"enc;T;$@?Wo;= ;>I" overload;F;?0;;;@0;:I"each_child( dirname );T;IC; ";T;[;![;"I";T;#0;$@?W;.F;Bi;C0;7[[I" dirname;T0;$@?Wo;= ;>I" overload;F;?0;;;@0;:I")each_child( dirname, encoding: enc );T;IC; ";T;[;![;"I";T;#0;$@?W;.F;Bi;C0;7[[I" dirname;T0[I"encoding:;TI"enc;T;$@?W;![;"I"#Calls the block once for each entry except for "." and ".." in the named directory, passing the filename of each entry as a parameter to the block. If no block is given, an enumerator is returned instead. Dir.each_child("testdir") {|x| puts "Got #{x}" } produces: Got config.h Got main.rb @overload each_child( dirname ) @yield [ filename ] @return [nil] @overload each_child( dirname, encoding: enc ) @yield [ filename ] @return [nil] @overload each_child( dirname ) @overload each_child( dirname, encoding: enc );T;#0;$@?W;.F;/o;0;1T;2i ;3i ;%@V;9I"static VALUE dir_s_each_child(int argc, VALUE *argv, VALUE io) { VALUE dir; RETURN_ENUMERATOR(io, argc, argv); dir = dir_open_dir(argc, argv); rb_ensure(dir_each_child, dir, dir_close, dir); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Dir.children;F;7[[@90;[[@fiM ;T;: children;0;[;{;IC; "hReturns an array containing all of the filenames except for "." and ".." in the given directory. Will raise a SystemCallError if the named directory doesn't exist. The optional encoding keyword argument specifies the encoding of the directory. If not specified, the filesystem encoding is used. Dir.children("testdir") #=> ["config.h", "main.rb"] ;T;[o;= ;>I" overload;F;?0;;! ;@0;:I"children( dirname );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@W;![;"I"@return [Array];T;#0;$@W;.F;Bi;C0;7[[I" dirname;T0;$@Wo;= ;>I" overload;F;?0;;! ;@0;:I"'children( dirname, encoding: enc );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@W;![;"I"@return [Array];T;#0;$@W;.F;Bi;C0;7[[I" dirname;T0[I"encoding:;TI"enc;T;$@W;![;"I"Returns an array containing all of the filenames except for "." and ".." in the given directory. Will raise a SystemCallError if the named directory doesn't exist. The optional encoding keyword argument specifies the encoding of the directory. If not specified, the filesystem encoding is used. Dir.children("testdir") #=> ["config.h", "main.rb"] @overload children( dirname ) @return [Array] @overload children( dirname, encoding: enc ) @return [Array];T;#0;$@W;.F;/o;0;1T;2i> ;3iL ;%@V;9I"static VALUE dir_s_children(int argc, VALUE *argv, VALUE io) { VALUE dir; dir = dir_open_dir(argc, argv); return rb_ensure(dir_collect_children, dir, dir_close, dir); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Dir#fileno;F;7[;[[@fi;T;;;0;[;{;IC; "Returns the file descriptor used in dir. d = Dir.new("..") d.fileno #=> 8 This method uses dirfd() function defined by POSIX 2008. NotImplementedError is raised on other platforms, such as Windows, which doesn't provide the function. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" fileno;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@W;![;"I"@return [Integer];T;#0;$@W;.F;Bi;C0;7[;$@W;![;"I"$Returns the file descriptor used in dir. d = Dir.new("..") d.fileno #=> 8 This method uses dirfd() function defined by POSIX 2008. NotImplementedError is raised on other platforms, such as Windows, which doesn't provide the function. @overload fileno @return [Integer];T;#0;$@W;.F;/o;0;1T;2i;3i;%@V;9I"static VALUE dir_fileno(VALUE dir) { struct dir_data *dirp; int fd; GetDIR(dir, dirp); fd = dirfd(dirp->dir); if (fd == -1) rb_sys_fail("dirfd"); return INT2NUM(fd); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Dir#path;F;7[;[[@fi;T;;O;0;[;{;IC; "pReturns the path parameter passed to dir's constructor. d = Dir.new("..") d.path #=> ".." ;T;[o;= ;>I" overload;F;?0;;O;@0;:I" path;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@W;![;"I"@return [String, nil];T;#0;$@W;.F;Bi;C0;7[;$@Wo;= ;>I" overload;F;?0;;n;@0;:I" to_path;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@W;![;"I"@return [String, nil];T;#0;$@W;.F;Bi;C0;7[;$@W;![;"I"Returns the path parameter passed to dir's constructor. d = Dir.new("..") d.path #=> ".." @overload path @return [String, nil] @overload to_path @return [String, nil];T;#0;$@W;.F;/o;0;1T;2i;3i;%@V;9I"static VALUE dir_path(VALUE dir) { struct dir_data *dirp; TypedData_Get_Struct(dir, struct dir_data, &dir_data_type, dirp); if (NIL_P(dirp->path)) return Qnil; return rb_str_dup(dirp->path); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Dir#to_path;F;7[;[[@fi;T;;n;0;[;{;IC; "pReturns the path parameter passed to dir's constructor. d = Dir.new("..") d.path #=> ".." ;T;[o;= ;>I" overload;F;?0;;O;@0;:I" path;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@X;![;"I"@return [String, nil];T;#0;$@X;.F;Bi;C0;7[;$@Xo;= ;>I" overload;F;?0;;n;@0;:I" to_path;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@X;![;"I"@return [String, nil];T;#0;$@X;.F;Bi;C0;7[;$@X;![;"@X;#0;$@X;.F;/o;0;1T;2i;3i;%@V;9I"static VALUE dir_path(VALUE dir) { struct dir_data *dirp; TypedData_Get_Struct(dir, struct dir_data, &dir_data_type, dirp); if (NIL_P(dirp->path)) return Qnil; return rb_str_dup(dirp->path); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Dir#inspect;F;7[;[[@fil;T;;J;0;[;{;IC; "0Return a string describing this Dir object. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@.X;![;"I"@return [String];T;#0;$@.X;.F;Bi;C0;7[;$@.X;![;"I"WReturn a string describing this Dir object. @overload inspect @return [String];T;#0;$@.X;.F;/o;0;1T;2if;3ij;%@V;9I"static VALUE dir_inspect(VALUE dir) { struct dir_data *dirp; TypedData_Get_Struct(dir, struct dir_data, &dir_data_type, dirp); if (!NIL_P(dirp->path)) { VALUE str = rb_str_new_cstr("#<"); rb_str_append(str, rb_class_name(CLASS_OF(dir))); rb_str_cat2(str, ":"); rb_str_append(str, dirp->path); rb_str_cat2(str, ">"); return str; } return rb_funcallv(dir, idTo_s, 0, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Dir#read;F;7[;[[@fi;T;;q;0;[;{;IC; "Reads the next entry from dir and returns it as a string. Returns nil at the end of the stream. d = Dir.new("testdir") d.read #=> "." d.read #=> ".." d.read #=> "config.h" ;T;[o;= ;>I" overload;F;?0;;q;@0;:I" read;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@IX;![;"I"@return [String, nil];T;#0;$@IX;.F;Bi;C0;7[;$@IX;![;"I"Reads the next entry from dir and returns it as a string. Returns nil at the end of the stream. d = Dir.new("testdir") d.read #=> "." d.read #=> ".." d.read #=> "config.h" @overload read @return [String, nil];T;#0;$@IX;.F;/o;0;1T;2i;3i;%@V;9I"kstatic VALUE dir_read(VALUE dir) { struct dir_data *dirp; struct dirent *dp; GetDIR(dir, dirp); errno = 0; if ((dp = READDIR(dirp->dir, dirp->enc)) != NULL) { return rb_external_str_new_with_enc(dp->d_name, NAMLEN(dp), dirp->enc); } else { int e = errno; if (e != 0) rb_syserr_fail(e, 0); return Qnil; /* end of stream */ } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Dir#each;F;7[;[[@fi ;T;;;0;[;{;IC; "4Calls the block once for each entry in this directory, passing the filename of each entry as a parameter to the block. If no block is given, an enumerator is returned instead. d = Dir.new("testdir") d.each {|x| puts "Got #{x}" } produces: Got . Got .. Got config.h Got main.rb ;T;[o;= ;>I" overload;F;?0;;;@0;:I" each;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" filename;T;$@eXo;A ;>I" return;F;?I";T;0;@[I"Dir;T;$@eX;![;"I"$@yield [filename] @return [Dir];T;#0;$@eX;.F;Bi;C0;7[;$@eXo;= ;>I" overload;F;?0;;;@0;:I" each;T;IC; ";T;[;![;"I";T;#0;$@eX;.F;Bi;C0;7[;$@eX;![;"I"xCalls the block once for each entry in this directory, passing the filename of each entry as a parameter to the block. If no block is given, an enumerator is returned instead. d = Dir.new("testdir") d.each {|x| puts "Got #{x}" } produces: Got . Got .. Got config.h Got main.rb @overload each @yield [filename] @return [Dir] @overload each;T;#0;$@eX;.F;/o;0;1T;2i ;3i;%@V;9I"~static VALUE dir_each(VALUE dir) { RETURN_ENUMERATOR(dir, 0, 0); return dir_each_entry(dir, dir_yield, Qnil, FALSE); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Dir#each_child;F;7[;[[@fi$ ;T;;;0;[;{;IC; "?Calls the block once for each entry except for "." and ".." in this directory, passing the filename of each entry as a parameter to the block. If no block is given, an enumerator is returned instead. d = Dir.new("testdir") d.each_child {|x| puts "Got #{x}" } produces: Got config.h Got main.rb ;T;[o;= ;>I" overload;F;?0;;;@0;:I"each_child;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" filename;T;$@Xo;A ;>I" return;F;?I";T;0;@[I"Dir;T;$@X;![;"I"&@yield [ filename ] @return [Dir];T;#0;$@X;.F;Bi;C0;7[;$@Xo;= ;>I" overload;F;?0;;;@0;:I"each_child;T;IC; ";T;[;![;"I";T;#0;$@X;.F;Bi;C0;7[;$@X;![;"I"Calls the block once for each entry except for "." and ".." in this directory, passing the filename of each entry as a parameter to the block. If no block is given, an enumerator is returned instead. d = Dir.new("testdir") d.each_child {|x| puts "Got #{x}" } produces: Got config.h Got main.rb @overload each_child @yield [ filename ] @return [Dir] @overload each_child;T;#0;$@X;.F;/o;0;1T;2i ;3i# ;%@V;9I"static VALUE dir_each_child_m(VALUE dir) { RETURN_ENUMERATOR(dir, 0, 0); return dir_each_entry(dir, dir_yield, Qnil, TRUE); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Dir#children;F;7[;[[@fi6 ;T;;! ;0;[;{;IC; "Returns an array containing all of the filenames except for "." and ".." in this directory. d = Dir.new("testdir") d.children #=> ["config.h", "main.rb"] ;T;[o;= ;>I" overload;F;?0;;! ;@0;:I" children;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@X;![;"I"@return [Array];T;#0;$@X;.F;Bi;C0;7[;$@X;![;"I"Returns an array containing all of the filenames except for "." and ".." in this directory. d = Dir.new("testdir") d.children #=> ["config.h", "main.rb"] @overload children @return [Array];T;#0;$@X;.F;/o;0;1T;2i+ ;3i4 ;%@V;9I"static VALUE dir_collect_children(VALUE dir) { VALUE ary = rb_ary_new(); dir_each_entry(dir, rb_ary_push, ary, TRUE); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Dir#rewind;F;7[;[[@fi;T;;;0;[;{;IC; "Repositions dir to the first entry. d = Dir.new("testdir") d.read #=> "." d.rewind #=> # d.read #=> "." ;T;[o;= ;>I" overload;F;?0;;;@0;:I" rewind;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Dir;T;$@X;![;"I"@return [Dir];T;#0;$@X;.F;Bi;C0;7[;$@X;![;"I"Repositions dir to the first entry. d = Dir.new("testdir") d.read #=> "." d.rewind #=> # d.read #=> "." @overload rewind @return [Dir];T;#0;$@X;.F;/o;0;1T;2i;3i;%@V;9I"static VALUE dir_rewind(VALUE dir) { struct dir_data *dirp; GetDIR(dir, dirp); rewinddir(dirp->dir); return dir; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Dir#tell;F;7[;[[@fiT;T;;;0;[;{;IC; "Returns the current position in dir. See also Dir#seek. d = Dir.new("testdir") d.tell #=> 0 d.read #=> "." d.tell #=> 12 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"pos;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@X;![;"I"@return [Integer];T;#0;$@X;.F;Bi;C0;7[;$@Xo;= ;>I" overload;F;?0;;;@0;:I" tell;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@X;![;"I"@return [Integer];T;#0;$@X;.F;Bi;C0;7[;$@X;![;"I"Returns the current position in dir. See also Dir#seek. d = Dir.new("testdir") d.tell #=> 0 d.read #=> "." d.tell #=> 12 @overload pos @return [Integer] @overload tell @return [Integer];T;#0;$@X;.F;/o;0;1T;2iH;3iS;%@V;9I"static VALUE dir_tell(VALUE dir) { struct dir_data *dirp; long pos; GetDIR(dir, dirp); pos = telldir(dirp->dir); return rb_int2inum(pos); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Dir#seek;F;7[[I"pos;T0;[[@fiq;T;;;0;[;{;IC; "ZSeeks to a particular location in dir. integer must be a value returned by Dir#tell. d = Dir.new("testdir") #=> # d.read #=> "." i = d.tell #=> 12 d.read #=> ".." d.seek(i) #=> # d.read #=> ".." ;T;[o;= ;>I" overload;F;?0;;;@0;:I"seek( integer );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Dir;T;$@Y;![;"I"@return [Dir];T;#0;$@Y;.F;Bi;C0;7[[I" integer;T0;$@Y;![;"I"Seeks to a particular location in dir. integer must be a value returned by Dir#tell. d = Dir.new("testdir") #=> # d.read #=> "." i = d.tell #=> 12 d.read #=> ".." d.seek(i) #=> # d.read #=> ".." @overload seek( integer ) @return [Dir];T;#0;$@Y;.F;/o;0;1T;2ic;3io;%@V;9I"static VALUE dir_seek(VALUE dir, VALUE pos) { struct dir_data *dirp; long p = NUM2LONG(pos); GetDIR(dir, dirp); seekdir(dirp->dir, p); return dir; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Dir#pos;F;7[;[[@fiT;T;;;0;[;{;IC; "Returns the current position in dir. See also Dir#seek. d = Dir.new("testdir") d.tell #=> 0 d.read #=> "." d.tell #=> 12 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"pos;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@2Y;![;"I"@return [Integer];T;#0;$@2Y;.F;Bi;C0;7[;$@2Yo;= ;>I" overload;F;?0;;;@0;:I" tell;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@2Y;![;"I"@return [Integer];T;#0;$@2Y;.F;Bi;C0;7[;$@2Y;![;"@Y;#0;$@2Y;.F;/o;0;1T;2iH;3iS;%@V;9I"static VALUE dir_tell(VALUE dir) { struct dir_data *dirp; long pos; GetDIR(dir, dirp); pos = telldir(dirp->dir); return rb_int2inum(pos); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Dir#pos=;F;7[[I"pos;T0;[[@fi;T;;;0;[;{;IC; " Synonym for Dir#seek, but returns the position parameter. d = Dir.new("testdir") #=> # d.read #=> "." i = d.pos #=> 12 d.read #=> ".." d.pos = i #=> 12 d.read #=> ".." ;T;[o;= ;>I" overload;F;?0;;;@0;:I"pos=(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@YY;![;"I"@return [Integer];T;#0;$@YY;.F;Bi;C0;7[[I" integer;T0;$@YY;![;"I"NSynonym for Dir#seek, but returns the position parameter. d = Dir.new("testdir") #=> # d.read #=> "." i = d.pos #=> 12 d.read #=> ".." d.pos = i #=> 12 d.read #=> ".." @overload pos=(integer) @return [Integer];T;#0;$@YY;.F;/o;0;1T;2i;3i;%@V;9I"_static VALUE dir_set_pos(VALUE dir, VALUE pos) { dir_seek(dir, pos); return pos; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Dir#close;F;7[;[[@fi;T;;;0;[;{;IC; "Closes the directory stream. Calling this method on closed Dir object is ignored since Ruby 2.3. d = Dir.new("testdir") d.close #=> nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I" close;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@xY;![;"I"@return [nil];T;#0;$@xY;.F;Bi;C0;7[;$@xY;![;"I"Closes the directory stream. Calling this method on closed Dir object is ignored since Ruby 2.3. d = Dir.new("testdir") d.close #=> nil @overload close @return [nil];T;#0;$@xY;.F;/o;0;1T;2i;3i;%@V;9I"static VALUE dir_close(VALUE dir) { struct dir_data *dirp; dirp = dir_get(dir); if (!dirp->dir) return Qnil; closedir(dirp->dir); dirp->dir = NULL; return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Dir.chdir;F;7[[@90;[[@fi;T;: chdir;0;[;{;IC; "wChanges the current working directory of the process to the given string. When called without an argument, changes the directory to the value of the environment variable HOME, or LOGDIR. SystemCallError (probably Errno::ENOENT) if the target directory does not exist. If a block is given, it is passed the name of the new current directory, and the block is executed with that as the current directory. The original working directory is restored when the block exits. The return value of chdir is the value of the block. chdir blocks can be nested, but in a multi-threaded program an error will be raised if a thread attempts to open a chdir block while another thread has one open or a call to chdir without a block occurs inside a block passed to chdir (even in the same thread). Dir.chdir("/var/spool/mail") puts Dir.pwd Dir.chdir("/tmp") do puts Dir.pwd Dir.chdir("/usr") do puts Dir.pwd end puts Dir.pwd end puts Dir.pwd produces: /var/spool/mail /tmp /usr /tmp /var/spool/mail ;T;[o;= ;>I" overload;F;?0;;" ;@0;:I"chdir( [ string] );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@Y;![;"I"@return [0];T;#0;$@Y;.F;Bi;C0;7[[I"[ string];T0;$@Yo;= ;>I" overload;F;?0;;" ;@0;:I"chdir( [ string] );T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" path;T;$@Yo;A ;>I" return;F;?I";T;0;@[I" Object;T;$@Y;![;"I"%@yield [ path ] @return [Object];T;#0;$@Y;.F;Bi;C0;7[[I"[ string];T0;$@Y;![;"I"Changes the current working directory of the process to the given string. When called without an argument, changes the directory to the value of the environment variable HOME, or LOGDIR. SystemCallError (probably Errno::ENOENT) if the target directory does not exist. If a block is given, it is passed the name of the new current directory, and the block is executed with that as the current directory. The original working directory is restored when the block exits. The return value of chdir is the value of the block. chdir blocks can be nested, but in a multi-threaded program an error will be raised if a thread attempts to open a chdir block while another thread has one open or a call to chdir without a block occurs inside a block passed to chdir (even in the same thread). Dir.chdir("/var/spool/mail") puts Dir.pwd Dir.chdir("/tmp") do puts Dir.pwd Dir.chdir("/usr") do puts Dir.pwd end puts Dir.pwd end puts Dir.pwd produces: /var/spool/mail /tmp /usr /tmp /var/spool/mail @overload chdir( [ string] ) @return [0] @overload chdir( [ string] ) @yield [ path ] @return [Object];T;#0;$@Y;.F;/o;0;1T;2i;3i;%@V;9I"Astatic VALUE dir_s_chdir(int argc, VALUE *argv, VALUE obj) { VALUE path = Qnil; if (rb_check_arity(argc, 0, 1) == 1) { path = rb_str_encode_ospath(rb_get_path(argv[0])); } else { const char *dist = getenv("HOME"); if (!dist) { dist = getenv("LOGDIR"); if (!dist) rb_raise(rb_eArgError, "HOME/LOGDIR not set"); } path = rb_str_new2(dist); } if (chdir_blocking > 0) { if (rb_thread_current() != chdir_thread) rb_raise(rb_eRuntimeError, "conflicting chdir during another chdir block"); if (!rb_block_given_p()) rb_warn("conflicting chdir during another chdir block"); } if (rb_block_given_p()) { struct chdir_data args; args.old_path = rb_str_encode_ospath(rb_dir_getwd()); args.new_path = path; args.done = FALSE; return rb_ensure(chdir_yield, (VALUE)&args, chdir_restore, (VALUE)&args); } else { char *p = RSTRING_PTR(path); int r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_chdir, p, RUBY_UBF_IO, 0); if (r < 0) rb_sys_fail_path(path); } return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Dir.getwd;F;7[;[[@fi;T;: getwd;0;[;{;IC; "Returns the path to the current working directory of this process as a string. Dir.chdir("/tmp") #=> 0 Dir.getwd #=> "/tmp" Dir.pwd #=> "/tmp" ;T;[o;= ;>I" overload;F;?0;;# ;@0;:I" getwd;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@Y;![;"I"@return [String];T;#0;$@Y;.F;Bi;C0;7[;$@Yo;= ;>I" overload;F;?0;:pwd;@0;:I"pwd;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@Y;![;"I"@return [String];T;#0;$@Y;.F;Bi;C0;7[;$@Y;![;"I"Returns the path to the current working directory of this process as a string. Dir.chdir("/tmp") #=> 0 Dir.getwd #=> "/tmp" Dir.pwd #=> "/tmp" @overload getwd @return [String] @overload pwd @return [String];T;#0;$@Y;.F;/o;0;1T;2is;3i~;%@V;9I"Gstatic VALUE dir_s_getwd(VALUE dir) { return rb_dir_getwd(); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Dir.pwd;F;7[;[[@fi;T;;$ ;0;[;{;IC; "Returns the path to the current working directory of this process as a string. Dir.chdir("/tmp") #=> 0 Dir.getwd #=> "/tmp" Dir.pwd #=> "/tmp" ;T;[o;= ;>I" overload;F;?0;;# ;@0;:I" getwd;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@Y;![;"I"@return [String];T;#0;$@Y;.F;Bi;C0;7[;$@Yo;= ;>I" overload;F;?0;;$ ;@0;:I"pwd;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@Y;![;"I"@return [String];T;#0;$@Y;.F;Bi;C0;7[;$@Y;![;"@Y;#0;$@Y;.F;/o;0;1T;2is;3i~;%@V;9I"Gstatic VALUE dir_s_getwd(VALUE dir) { return rb_dir_getwd(); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Dir.chroot;F;7[[I" path;T0;[[@fi;T;: chroot;0;[;{;IC; "Changes this process's idea of the file system root. Only a privileged process may make this call. Not available on all platforms. On Unix systems, see chroot(2) for more information. ;T;[o;= ;>I" overload;F;?0;;% ;@0;:I"chroot( string );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@Z;![;"I"@return [0];T;#0;$@Z;.F;Bi;C0;7[[I" string;T0;$@Z;![;"I"Changes this process's idea of the file system root. Only a privileged process may make this call. Not available on all platforms. On Unix systems, see chroot(2) for more information. @overload chroot( string ) @return [0];T;#0;$@Z;.F;/o;0;1T;2i;3i;%@V;9I"static VALUE dir_s_chroot(VALUE dir, VALUE path) { path = check_dirname(path); if (chroot(RSTRING_PTR(path)) == -1) rb_sys_fail_path(path); return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Dir.mkdir;F;7[[@90;[[@fi;T;: mkdir;0;[;{;IC; "Makes a new directory named by string, with permissions specified by the optional parameter anInteger. The permissions may be modified by the value of File::umask, and are ignored on NT. Raises a SystemCallError if the directory cannot be created. See also the discussion of permissions in the class documentation for File. Dir.mkdir(File.join(Dir.home, ".foo"), 0700) #=> 0 ;T;[o;= ;>I" overload;F;?0;;& ;@0;:I" mkdir( string [, integer] );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@3Z;![;"I"@return [0];T;#0;$@3Z;.F;Bi;C0;7[[I"string[, integer];T0;$@3Z;![;"I"Makes a new directory named by string, with permissions specified by the optional parameter anInteger. The permissions may be modified by the value of File::umask, and are ignored on NT. Raises a SystemCallError if the directory cannot be created. See also the discussion of permissions in the class documentation for File. Dir.mkdir(File.join(Dir.home, ".foo"), 0700) #=> 0 @overload mkdir( string [, integer] ) @return [0];T;#0;$@3Z;.F;/o;0;1T;2i;3i;%@V;9I"static VALUE dir_s_mkdir(int argc, VALUE *argv, VALUE obj) { struct mkdir_arg m; VALUE path, vmode; int r; if (rb_scan_args(argc, argv, "11", &path, &vmode) == 2) { m.mode = NUM2MODET(vmode); } else { m.mode = 0777; } path = check_dirname(path); m.path = RSTRING_PTR(path); r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_mkdir, &m, RUBY_UBF_IO, 0); if (r < 0) rb_sys_fail_path(path); return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Dir.rmdir;F;7[[I"dir;T0;[[@fi;T;: rmdir;0;[;{;IC; "dDeletes the named directory. Raises a subclass of SystemCallError if the directory isn't empty. ;T;[o;= ;>I" overload;F;?0;;\;@0;:I"delete( string );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@QZ;![;"I"@return [0];T;#0;$@QZ;.F;Bi;C0;7[[I" string;T0;$@QZo;= ;>I" overload;F;?0;;' ;@0;:I"rmdir( string );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@QZ;![;"I"@return [0];T;#0;$@QZ;.F;Bi;C0;7[[I" string;T0;$@QZo;= ;>I" overload;F;?0;;[;@0;:I"unlink( string );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@QZ;![;"I"@return [0];T;#0;$@QZ;.F;Bi;C0;7[[I" string;T0;$@QZ;![;"I"Deletes the named directory. Raises a subclass of SystemCallError if the directory isn't empty. @overload delete( string ) @return [0] @overload rmdir( string ) @return [0] @overload unlink( string ) @return [0];T;#0;$@QZ;.F;/o;0;1T;2i;3i;%@V;9I" static VALUE dir_s_rmdir(VALUE obj, VALUE dir) { const char *p; int r; dir = check_dirname(dir); p = RSTRING_PTR(dir); r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_rmdir, (void *)p, RUBY_UBF_IO, 0); if (r < 0) rb_sys_fail_path(dir); return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Dir.delete;F;7[[I"dir;T0;[[@fi;T;;\;0;[;{;IC; "dDeletes the named directory. Raises a subclass of SystemCallError if the directory isn't empty. ;T;[o;= ;>I" overload;F;?0;;\;@0;:I"delete( string );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@Z;![;"I"@return [0];T;#0;$@Z;.F;Bi;C0;7[[I" string;T0;$@Zo;= ;>I" overload;F;?0;;' ;@0;:I"rmdir( string );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@Z;![;"I"@return [0];T;#0;$@Z;.F;Bi;C0;7[[I" string;T0;$@Zo;= ;>I" overload;F;?0;;[;@0;:I"unlink( string );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@Z;![;"I"@return [0];T;#0;$@Z;.F;Bi;C0;7[[I" string;T0;$@Z;![;"@Z;#0;$@Z;.F;/o;0;1T;2i;3i;%@V;9I" static VALUE dir_s_rmdir(VALUE obj, VALUE dir) { const char *p; int r; dir = check_dirname(dir); p = RSTRING_PTR(dir); r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_rmdir, (void *)p, RUBY_UBF_IO, 0); if (r < 0) rb_sys_fail_path(dir); return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Dir.unlink;F;7[[I"dir;T0;[[@fi;T;;[;0;[;{;IC; "dDeletes the named directory. Raises a subclass of SystemCallError if the directory isn't empty. ;T;[o;= ;>I" overload;F;?0;;\;@0;:I"delete( string );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@Z;![;"I"@return [0];T;#0;$@Z;.F;Bi;C0;7[[I" string;T0;$@Zo;= ;>I" overload;F;?0;;' ;@0;:I"rmdir( string );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@Z;![;"I"@return [0];T;#0;$@Z;.F;Bi;C0;7[[I" string;T0;$@Zo;= ;>I" overload;F;?0;;[;@0;:I"unlink( string );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@Z;![;"I"@return [0];T;#0;$@Z;.F;Bi;C0;7[[I" string;T0;$@Z;![;"@Z;#0;$@Z;.F;/o;0;1T;2i;3i;%@V;9I" static VALUE dir_s_rmdir(VALUE obj, VALUE dir) { const char *p; int r; dir = check_dirname(dir); p = RSTRING_PTR(dir); r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_rmdir, (void *)p, RUBY_UBF_IO, 0); if (r < 0) rb_sys_fail_path(dir); return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Dir.home;F;7[[@90;[[@fi ;T;: home;0;[;{;IC; "OReturns the home directory of the current user or the named user if given. ;T;[o;= ;>I" overload;F;?0;;( ;@0;:I" home();T;IC; ";T;[;![;"I";T;#0;$@[;.F;Bi;C0;7[;$@[o;= ;>I" overload;F;?0;;( ;@0;:I"home("root");T;IC; ";T;[;![;"I";T;#0;$@[;.F;Bi;C0;7[[" "root"0;$@[;![;"I"yReturns the home directory of the current user or the named user if given. @overload home() @overload home("root");T;#0;$@[;.F;/o;0;1T;2i ;3i ;%@V;9I"static VALUE dir_s_home(int argc, VALUE *argv, VALUE obj) { VALUE user; const char *u = 0; rb_check_arity(argc, 0, 1); user = (argc > 0) ? argv[0] : Qnil; if (!NIL_P(user)) { SafeStringValue(user); rb_must_asciicompat(user); u = StringValueCStr(user); if (*u) { return rb_home_dir_of(user, rb_str_new(0, 0)); } } return rb_default_home_dir(rb_str_new(0, 0)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Dir.exist?;F;7[;[[@fi ;T;;;0;[;{;IC; "^Returns true if the named file is a directory, false otherwise.;T;[o;= ;>I" overload;F;?0;;;@0;:I"exist?(file_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@'[;![;"I"@return [Boolean];T;#0;$@'[;.F;Bi;C0;7[[I"file_name;T0;$@'[;![;"I"Returns true if the named file is a directory, false otherwise. @overload exist?(file_name) @return [Boolean];T;#0;$@'[;.F;/o;0;1T;2i ;3i ;Bi;%@V;9I"(VALUE rb_file_directory_p(void) { };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Dir.exists?;F;7[[I" fname;T0;[[@fi ;T;;O;0;[;{;IC; " :nodoc:;T;[o;A ;>I" return;F;?@;0;@[@L;$@D[;![;"I" :nodoc:;T;#0;$@D[;.F;/o;0;1T;2i ;3i ;Bi;%@V;9I"static VALUE rb_dir_exists_p(VALUE obj, VALUE fname) { rb_warn_deprecated("Dir.exists?", "Dir.exist?"); return rb_file_directory_p(obj, fname); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Dir.empty?;F;7[[I" dirname;T0;[[@fi ;T;;;0;[;{;IC; "|Returns true if the named file is an empty directory, false if it is not a directory or non-empty.;T;[o;= ;>I" overload;F;?0;;;@0;:I"empty?(path_name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@W[;![;"I"@return [Boolean];T;#0;$@W[;.F;Bi;C0;7[[I"path_name;T0;$@W[;![;"I"Returns true if the named file is an empty directory, false if it is not a directory or non-empty. @overload empty?(path_name) @return [Boolean];T;#0;$@W[;.F;/o;0;1T;2i ;3i ;Bi;%@V;9I"pstatic VALUE rb_dir_s_empty_p(VALUE obj, VALUE dirname) { VALUE result, orig; const char *path; enum {false_on_notdir = 1}; FilePathValue(dirname); orig = rb_str_dup_frozen(dirname); dirname = rb_str_encode_ospath(dirname); dirname = rb_str_dup_frozen(dirname); path = RSTRING_PTR(dirname); #if defined HAVE_GETATTRLIST && defined ATTR_DIR_ENTRYCOUNT { u_int32_t attrbuf[SIZEUP32(fsobj_tag_t)]; struct attrlist al = {ATTR_BIT_MAP_COUNT, 0, ATTR_CMN_OBJTAG,}; if (getattrlist(path, &al, attrbuf, sizeof(attrbuf), 0) != 0) rb_sys_fail_path(orig); if (*(const fsobj_tag_t *)(attrbuf+1) == VT_HFS) { al.commonattr = 0; al.dirattr = ATTR_DIR_ENTRYCOUNT; if (getattrlist(path, &al, attrbuf, sizeof(attrbuf), 0) == 0) { if (attrbuf[0] >= 2 * sizeof(u_int32_t)) return attrbuf[1] ? Qfalse : Qtrue; if (false_on_notdir) return Qfalse; } rb_sys_fail_path(orig); } } #endif result = (VALUE)rb_thread_call_without_gvl(nogvl_dir_empty_p, (void *)path, RUBY_UBF_IO, 0); if (result == Qundef) { rb_sys_fail_path(orig); } return result; };T;:I"static VALUE;T;;T; @V; IC;[; @V; IC;[o;( ;)0;*0;+0;;;%@;-@y,;0; @V; IC;{;IC;{;T;IC;{;T;T;{;[;[[@fi ;F;:Dir;;;;;[;{;IC; " ;T;[;![;"@;#0;$@V;Bi;%@;&I"Dir;F;'@o; ;IC;[ o;4;5F;6;;;;&I"Range#initialize;F;7[[@90;[[I" range.c;Tii;T;;D;0;[;{;IC; "Returns a new range based on the given objects +begin+ and +end+. Optional argument +exclude_end+ determines whether object +end+ is included as the last object in the range: Range.new(2, 5).to_a # => [2, 3, 4, 5] Range.new(2, 5, true).to_a # => [2, 3, 4] Range.new('a', 'd').to_a # => ["a", "b", "c", "d"] Range.new('a', 'd', true).to_a # => ["a", "b", "c"] ;T;[o;= ;>I" overload;F;?0;;E;@0;:I")new(begin, end, exclude_end = false);T;IC; ";T;[;![;"I";T;#0;$@[;.F;Bi;C0;7[;$@[;![;"I"Returns a new range based on the given objects +begin+ and +end+. Optional argument +exclude_end+ determines whether object +end+ is included as the last object in the range: Range.new(2, 5).to_a # => [2, 3, 4, 5] Range.new(2, 5, true).to_a # => [2, 3, 4] Range.new('a', 'd').to_a # => ["a", "b", "c", "d"] Range.new('a', 'd', true).to_a # => ["a", "b", "c"] @overload new(begin, end, exclude_end = false);T;#0;$@[;.F;/o;0;1T;2iZ;3ie;%@[;9I"static VALUE range_initialize(int argc, VALUE *argv, VALUE range) { VALUE beg, end, flags; rb_scan_args(argc, argv, "21", &beg, &end, &flags); range_modify(range); range_init(range, beg, end, RBOOL(RTEST(flags))); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#initialize_copy;F;7[[I" orig;T0;[[@[iu;T;;];0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@[;.F;/o;0;1T;2it;3it;%@[;9I"static VALUE range_initialize_copy(VALUE range, VALUE orig) { range_modify(range); rb_struct_init_copy(range, orig); return range; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Range#==;F;7[[I"obj;T0;[[@[i;T;;F;0;[;{;IC; "Returns +true+ if and only if: - +other+ is a range. - other.begin == self.begin. - other.end == self.end. - other.exclude_end? == self.exclude_end?. Otherwise returns +false+. r = (1..5) r == (1..5) # => true r = Range.new(1, 5) r == 'foo' # => false r == (2..5) # => false r == (1..4) # => false r == (1...5) # => false r == Range.new(1, 5, true) # => false Note that even with the same argument, the return values of #== and #eql? can differ: (1..2) == (1..2.0) # => true (1..2).eql? (1..2.0) # => false Related: Range#eql?. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@[;![;"I"@return [Boolean];T;#0;$@[;.F;Bi;C0;7[[I" other;T0;$@[;![;"I"Returns +true+ if and only if: - +other+ is a range. - other.begin == self.begin. - other.end == self.end. - other.exclude_end? == self.exclude_end?. Otherwise returns +false+. r = (1..5) r == (1..5) # => true r = Range.new(1, 5) r == 'foo' # => false r == (2..5) # => false r == (1..4) # => false r == (1...5) # => false r == Range.new(1, 5, true) # => false Note that even with the same argument, the return values of #== and #eql? can differ: (1..2) == (1..2.0) # => true (1..2).eql? (1..2.0) # => false Related: Range#eql?. @overload ==(other) @return [Boolean];T;#0;$@[;.F;/o;0;1T;2i;3i;%@[;9I"static VALUE range_eq(VALUE range, VALUE obj) { if (range == obj) return Qtrue; if (!rb_obj_is_kind_of(obj, rb_cRange)) return Qfalse; return rb_exec_recursive_paired(recursive_equal, range, obj, obj); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#===;F;7[[I"val;T0;[[@[i;T;;S;0;[;{;IC; "Returns +true+ if +object+ is between self.begin and self.end. +false+ otherwise: (1..4) === 2 # => true (1..4) === 5 # => false (1..4) === 'a' # => false (1..4) === 4 # => true (1...4) === 4 # => false ('a'..'d') === 'c' # => true ('a'..'d') === 'e' # => false A case statement uses method ===, and so: case 79 when (1..50) "low" when (51..75) "medium" when (76..100) "high" end # => "high" case "2.6.5" when ..."2.4" "EOL" when "2.4"..."2.5" "maintenance" when "2.5"..."3.0" "stable" when "3.1".. "upcoming" end # => "stable" ;T;[o;= ;>I" overload;F;?0;;S;@0;:I"===(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@[;![;"I"@return [Boolean];T;#0;$@[;.F;Bi;C0;7[[I" object;T0;$@[;![;"I"Returns +true+ if +object+ is between self.begin and self.end. +false+ otherwise: (1..4) === 2 # => true (1..4) === 5 # => false (1..4) === 'a' # => false (1..4) === 4 # => true (1...4) === 4 # => false ('a'..'d') === 'c' # => true ('a'..'d') === 'e' # => false A case statement uses method ===, and so: case 79 when (1..50) "low" when (51..75) "medium" when (76..100) "high" end # => "high" case "2.6.5" when ..."2.4" "EOL" when "2.4"..."2.5" "maintenance" when "2.5"..."3.0" "stable" when "3.1".. "upcoming" end # => "stable" @overload ===(object) @return [Boolean];T;#0;$@[;.F;/o;0;1T;2i;3i;%@[;9I"static VALUE range_eqq(VALUE range, VALUE val) { VALUE ret = range_include_internal(range, val, 1); if (ret != Qundef) return ret; return r_cover_p(range, RANGE_BEG(range), RANGE_END(range), val); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#eql?;F;7[[I"obj;T0;[[@[i;T;;V;0;[;{;IC; "Returns +true+ if and only if: - +other+ is a range. - other.begin eql? self.begin. - other.end eql? self.end. - other.exclude_end? == self.exclude_end?. Otherwise returns +false+. r = (1..5) r.eql?(1..5) # => true r = Range.new(1, 5) r.eql?('foo') # => false r.eql?(2..5) # => false r.eql?(1..4) # => false r.eql?(1...5) # => false r.eql?(Range.new(1, 5, true)) # => false Note that even with the same argument, the return values of #== and #eql? can differ: (1..2) == (1..2.0) # => true (1..2).eql? (1..2.0) # => false Related: Range#==.;T;[o;= ;>I" overload;F;?0;;V;@0;:I"eql?(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@[;![;"I"@return [Boolean];T;#0;$@[;.F;Bi;C0;7[[I" other;T0;$@[;![;"I"Returns +true+ if and only if: - +other+ is a range. - other.begin eql? self.begin. - other.end eql? self.end. - other.exclude_end? == self.exclude_end?. Otherwise returns +false+. r = (1..5) r.eql?(1..5) # => true r = Range.new(1, 5) r.eql?('foo') # => false r.eql?(2..5) # => false r.eql?(1..4) # => false r.eql?(1...5) # => false r.eql?(Range.new(1, 5, true)) # => false Note that even with the same argument, the return values of #== and #eql? can differ: (1..2) == (1..2.0) # => true (1..2).eql? (1..2.0) # => false Related: Range#==. @overload eql?(other) @return [Boolean];T;#0;$@[;.F;/o;0;1T;2i;3i;Bi;%@[;9I"static VALUE range_eql(VALUE range, VALUE obj) { if (range == obj) return Qtrue; if (!rb_obj_is_kind_of(obj, rb_cRange)) return Qfalse; return rb_exec_recursive_paired(recursive_eql, range, obj, obj); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#hash;F;7[;[[@[i;T;;X;0;[;{;IC; "Returns the integer hash value for +self+. Two range objects +r0+ and +r1+ have the same hash value if and only if r0.eql?(r1). Related: Range#eql?, Object#hash. ;T;[o;= ;>I" overload;F;?0;;X;@0;:I" hash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ \;![;"I"@return [Integer];T;#0;$@ \;.F;Bi;C0;7[;$@ \;![;"I"Returns the integer hash value for +self+. Two range objects +r0+ and +r1+ have the same hash value if and only if r0.eql?(r1). Related: Range#eql?, Object#hash. @overload hash @return [Integer];T;#0;$@ \;.F;/o;0;1T;2i;3i ;%@[;9I"static VALUE range_hash(VALUE range) { st_index_t hash = EXCL(range); VALUE v; hash = rb_hash_start(hash); v = rb_hash(RANGE_BEG(range)); hash = rb_hash_uint(hash, NUM2LONG(v)); v = rb_hash(RANGE_END(range)); hash = rb_hash_uint(hash, NUM2LONG(v)); hash = rb_hash_uint(hash, EXCL(range) << 24); hash = rb_hash_end(hash); return ST2FIX(hash); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#each;F;7[;[[@[i;T;;;0;[;{;IC; "With a block given, passes each element of +self+ to the block: a = [] (1..4).each {|element| a.push(element) } # => 1..4 a # => [1, 2, 3, 4] Raises an exception unless self.first.respond_to?(:succ). With no block given, returns an enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" each;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@(\o;A ;>I" return;F;?I";T;0;@[I" self;T;$@(\;![;"I"$@yield [element] @return [self];T;#0;$@(\;.F;Bi;C0;7[;$@(\o;= ;>I" overload;F;?0;;;@0;:I" each;T;IC; ";T;[;![;"I";T;#0;$@(\;.F;Bi;C0;7[;$@(\;![;"I"JWith a block given, passes each element of +self+ to the block: a = [] (1..4).each {|element| a.push(element) } # => 1..4 a # => [1, 2, 3, 4] Raises an exception unless self.first.respond_to?(:succ). With no block given, returns an enumerator. @overload each @yield [element] @return [self] @overload each;T;#0;$@(\;.F;/o;0;1T;2iv;3i;%@[;9I"p static VALUE range_each(VALUE range) { VALUE beg, end; long i; RETURN_SIZED_ENUMERATOR(range, 0, 0, range_enum_size); beg = RANGE_BEG(range); end = RANGE_END(range); if (FIXNUM_P(beg) && NIL_P(end)) { range_each_fixnum_endless(beg); } else if (FIXNUM_P(beg) && FIXNUM_P(end)) { /* fixnums are special */ return range_each_fixnum_loop(beg, end, range); } else if (RB_INTEGER_TYPE_P(beg) && (NIL_P(end) || RB_INTEGER_TYPE_P(end))) { if (SPECIAL_CONST_P(end) || RBIGNUM_POSITIVE_P(end)) { /* end >= FIXNUM_MIN */ if (!FIXNUM_P(beg)) { if (RBIGNUM_NEGATIVE_P(beg)) { do { rb_yield(beg); } while (!FIXNUM_P(beg = rb_big_plus(beg, INT2FIX(1)))); if (NIL_P(end)) range_each_fixnum_endless(beg); if (FIXNUM_P(end)) return range_each_fixnum_loop(beg, end, range); } else { if (NIL_P(end)) range_each_bignum_endless(beg); if (FIXNUM_P(end)) return range; } } if (FIXNUM_P(beg)) { i = FIX2LONG(beg); do { rb_yield(LONG2FIX(i)); } while (POSFIXABLE(++i)); beg = LONG2NUM(i); } ASSUME(!FIXNUM_P(beg)); ASSUME(!SPECIAL_CONST_P(end)); } if (!FIXNUM_P(beg) && RBIGNUM_SIGN(beg) == RBIGNUM_SIGN(end)) { if (EXCL(range)) { while (rb_big_cmp(beg, end) == INT2FIX(-1)) { rb_yield(beg); beg = rb_big_plus(beg, INT2FIX(1)); } } else { VALUE c; while ((c = rb_big_cmp(beg, end)) != INT2FIX(1)) { rb_yield(beg); if (c == INT2FIX(0)) break; beg = rb_big_plus(beg, INT2FIX(1)); } } } } else if (SYMBOL_P(beg) && (NIL_P(end) || SYMBOL_P(end))) { /* symbols are special */ beg = rb_sym2str(beg); if (NIL_P(end)) { rb_str_upto_endless_each(beg, sym_each_i, 0); } else { rb_str_upto_each(beg, rb_sym2str(end), EXCL(range), sym_each_i, 0); } } else { VALUE tmp = rb_check_string_type(beg); if (!NIL_P(tmp)) { if (!NIL_P(end)) { rb_str_upto_each(tmp, end, EXCL(range), each_i, 0); } else { rb_str_upto_endless_each(tmp, each_i, 0); } } else { if (!discrete_object_p(beg)) { rb_raise(rb_eTypeError, "can't iterate from %s", rb_obj_classname(beg)); } if (!NIL_P(end)) range_each_func(range, each_i, 0); else for (;; beg = rb_funcallv(beg, id_succ, 0, 0)) rb_yield(beg); } } return range; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#step;F;7[[@90;[[@[i;T;;;0;[;{;IC; "Iterates over the elements of +self+. With a block given and no argument, calls the block each element of the range; returns +self+: a = [] (1..5).step {|element| a.push(element) } # => 1..5 a # => [1, 2, 3, 4, 5] a = [] ('a'..'e').step {|element| a.push(element) } # => "a".."e" a # => ["a", "b", "c", "d", "e"] With a block given and a positive integer argument +n+ given, calls the block with element +0+, element +n+, element 2n, and so on: a = [] (1..5).step(2) {|element| a.push(element) } # => 1..5 a # => [1, 3, 5] a = [] ('a'..'e').step(2) {|element| a.push(element) } # => "a".."e" a # => ["a", "c", "e"] With no block given, returns an enumerator, which will be of class Enumerator::ArithmeticSequence if +self+ is numeric; otherwise of class Enumerator: e = (1..5).step(2) # => ((1..5).step(2)) e.class # => Enumerator::ArithmeticSequence ('a'..'e').step # => # Related: Range#%. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"step(n = 1);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@P\o;A ;>I" return;F;?I";T;0;@[I" self;T;$@P\;![;"I"$@yield [element] @return [self];T;#0;$@P\;.F;Bi;C0;7[[I"n;TI"1;T;$@P\o;= ;>I" overload;F;?0;;;@0;:I"step(n = 1);T;IC; ";T;[;![;"I";T;#0;$@P\;.F;Bi;C0;7[[I"n;TI"1;T;$@P\;![;"I"Iterates over the elements of +self+. With a block given and no argument, calls the block each element of the range; returns +self+: a = [] (1..5).step {|element| a.push(element) } # => 1..5 a # => [1, 2, 3, 4, 5] a = [] ('a'..'e').step {|element| a.push(element) } # => "a".."e" a # => ["a", "b", "c", "d", "e"] With a block given and a positive integer argument +n+ given, calls the block with element +0+, element +n+, element 2n, and so on: a = [] (1..5).step(2) {|element| a.push(element) } # => 1..5 a # => [1, 3, 5] a = [] ('a'..'e').step(2) {|element| a.push(element) } # => "a".."e" a # => ["a", "c", "e"] With no block given, returns an enumerator, which will be of class Enumerator::ArithmeticSequence if +self+ is numeric; otherwise of class Enumerator: e = (1..5).step(2) # => ((1..5).step(2)) e.class # => Enumerator::ArithmeticSequence ('a'..'e').step # => # Related: Range#%. @overload step(n = 1) @yield [element] @return [self] @overload step(n = 1);T;#0;$@P\;.F;/o;0;1T;2i;3i;%@[;9I" static VALUE range_step(int argc, VALUE *argv, VALUE range) { VALUE b, e, step, tmp; b = RANGE_BEG(range); e = RANGE_END(range); step = (!rb_check_arity(argc, 0, 1) ? INT2FIX(1) : argv[0]); if (!rb_block_given_p()) { if (!rb_obj_is_kind_of(step, rb_cNumeric)) { step = rb_to_int(step); } if (rb_equal(step, INT2FIX(0))) { rb_raise(rb_eArgError, "step can't be 0"); } const VALUE b_num_p = rb_obj_is_kind_of(b, rb_cNumeric); const VALUE e_num_p = rb_obj_is_kind_of(e, rb_cNumeric); if ((b_num_p && (NIL_P(e) || e_num_p)) || (NIL_P(b) && e_num_p)) { return rb_arith_seq_new(range, ID2SYM(rb_frame_this_func()), argc, argv, range_step_size, b, e, step, EXCL(range)); } RETURN_SIZED_ENUMERATOR(range, argc, argv, range_step_size); } step = check_step_domain(step); VALUE iter[2] = {INT2FIX(1), step}; if (FIXNUM_P(b) && NIL_P(e) && FIXNUM_P(step)) { long i = FIX2LONG(b), unit = FIX2LONG(step); do { rb_yield(LONG2FIX(i)); i += unit; /* FIXABLE+FIXABLE never overflow */ } while (FIXABLE(i)); b = LONG2NUM(i); for (;; b = rb_big_plus(b, step)) rb_yield(b); } else if (FIXNUM_P(b) && FIXNUM_P(e) && FIXNUM_P(step)) { /* fixnums are special */ long end = FIX2LONG(e); long i, unit = FIX2LONG(step); if (!EXCL(range)) end += 1; i = FIX2LONG(b); while (i < end) { rb_yield(LONG2NUM(i)); if (i + unit < i) break; i += unit; } } else if (SYMBOL_P(b) && (NIL_P(e) || SYMBOL_P(e))) { /* symbols are special */ b = rb_sym2str(b); if (NIL_P(e)) { rb_str_upto_endless_each(b, sym_step_i, (VALUE)iter); } else { rb_str_upto_each(b, rb_sym2str(e), EXCL(range), sym_step_i, (VALUE)iter); } } else if (ruby_float_step(b, e, step, EXCL(range), TRUE)) { /* done */ } else if (rb_obj_is_kind_of(b, rb_cNumeric) || !NIL_P(rb_check_to_integer(b, "to_int")) || !NIL_P(rb_check_to_integer(e, "to_int"))) { ID op = EXCL(range) ? '<' : idLE; VALUE v = b; int i = 0; while (NIL_P(e) || RTEST(rb_funcall(v, op, 1, e))) { rb_yield(v); i++; v = rb_funcall(b, '+', 1, rb_funcall(INT2NUM(i), '*', 1, step)); } } else { tmp = rb_check_string_type(b); if (!NIL_P(tmp)) { b = tmp; if (NIL_P(e)) { rb_str_upto_endless_each(b, step_i, (VALUE)iter); } else { rb_str_upto_each(b, e, EXCL(range), step_i, (VALUE)iter); } } else { if (!discrete_object_p(b)) { rb_raise(rb_eTypeError, "can't iterate from %s", rb_obj_classname(b)); } range_each_func(range, step_i, (VALUE)iter); } } return range; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Range#%;F;7[[I" step;T0;[[@[i8;T;;;0;[;{;IC; "bIterates over the elements of +self+. With a block given, calls the block with selected elements of the range; returns +self+: a = [] (1..5).%(2) {|element| a.push(element) } # => 1..5 a # => [1, 3, 5] a = [] ('a'..'e').%(2) {|element| a.push(element) } # => "a".."e" a # => ["a", "c", "e"] With no block given, returns an enumerator, which will be of class Enumerator::ArithmeticSequence if +self+ is numeric; otherwise of class Enumerator: e = (1..5) % 2 # => ((1..5).%(2)) e.class # => Enumerator::ArithmeticSequence ('a'..'e') % 2 # => # Related: Range#step. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" %(n);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@\o;A ;>I" return;F;?I";T;0;@[I" self;T;$@\;![;"I"$@yield [element] @return [self];T;#0;$@\;.F;Bi;C0;7[[I"n;T0;$@\o;= ;>I" overload;F;?0;;;@0;:I" %(n);T;IC; ";T;[;![;"I";T;#0;$@\;.F;Bi;C0;7[[I"n;T0;$@\;![;"I"Iterates over the elements of +self+. With a block given, calls the block with selected elements of the range; returns +self+: a = [] (1..5).%(2) {|element| a.push(element) } # => 1..5 a # => [1, 3, 5] a = [] ('a'..'e').%(2) {|element| a.push(element) } # => "a".."e" a # => ["a", "c", "e"] With no block given, returns an enumerator, which will be of class Enumerator::ArithmeticSequence if +self+ is numeric; otherwise of class Enumerator: e = (1..5) % 2 # => ((1..5).%(2)) e.class # => Enumerator::ArithmeticSequence ('a'..'e') % 2 # => # Related: Range#step. @overload %(n) @yield [element] @return [self] @overload %(n);T;#0;$@\;.F;/o;0;1T;2i;3i7;%@[;9I"istatic VALUE range_percent_step(VALUE range, VALUE step) { return range_step(1, &step, range); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#bsearch;F;7[;[[@[i;T;;2;0;[;{;IC; "pReturns an element from +self+ selected by a binary search. See {Binary Searching}[rdoc-ref:bsearch.rdoc]. ;T;[o;= ;>I" overload;F;?0;;2;@0;:I" bsearch;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@\;![;"I"@yield [obj];T;#0;$@\;.F;Bi;C0;7[;$@\;![;"I"Returns an element from +self+ selected by a binary search. See {Binary Searching}[rdoc-ref:bsearch.rdoc]. @overload bsearch @yield [obj];T;#0;$@\;.F;/o;0;1T;2i;3i;%@[;9I" static VALUE range_bsearch(VALUE range) { VALUE beg, end, satisfied = Qnil; int smaller; /* Implementation notes: * Floats are handled by mapping them to 64 bits integers. * Apart from sign issues, floats and their 64 bits integer have the * same order, assuming they are represented as exponent followed * by the mantissa. This is true with or without implicit bit. * * Finding the average of two ints needs to be careful about * potential overflow (since float to long can use 64 bits) * as well as the fact that -1/2 can be 0 or -1 in C89. * * Note that -0.0 is mapped to the same int as 0.0 as we don't want * (-1...0.0).bsearch to yield -0.0. */ #define BSEARCH(conv) \ do { \ RETURN_ENUMERATOR(range, 0, 0); \ if (EXCL(range)) high--; \ org_high = high; \ while (low < high) { \ mid = ((high < 0) == (low < 0)) ? low + ((high - low) / 2) \ : (low < -high) ? -((-1 - low - high)/2 + 1) : (low + high) / 2; \ BSEARCH_CHECK(conv(mid)); \ if (smaller) { \ high = mid; \ } \ else { \ low = mid + 1; \ } \ } \ if (low == org_high) { \ BSEARCH_CHECK(conv(low)); \ if (!smaller) return Qnil; \ } \ return satisfied; \ } while (0) beg = RANGE_BEG(range); end = RANGE_END(range); if (FIXNUM_P(beg) && FIXNUM_P(end)) { long low = FIX2LONG(beg); long high = FIX2LONG(end); long mid, org_high; BSEARCH(INT2FIX); } #if SIZEOF_DOUBLE == 8 && defined(HAVE_INT64_T) else if (RB_FLOAT_TYPE_P(beg) || RB_FLOAT_TYPE_P(end)) { int64_t low = double_as_int64(NIL_P(beg) ? -HUGE_VAL : RFLOAT_VALUE(rb_Float(beg))); int64_t high = double_as_int64(NIL_P(end) ? HUGE_VAL : RFLOAT_VALUE(rb_Float(end))); int64_t mid, org_high; BSEARCH(int64_as_double_to_num); } #endif else if (is_integer_p(beg) && is_integer_p(end)) { RETURN_ENUMERATOR(range, 0, 0); return bsearch_integer_range(beg, end, EXCL(range)); } else if (is_integer_p(beg) && NIL_P(end)) { VALUE diff = LONG2FIX(1); RETURN_ENUMERATOR(range, 0, 0); while (1) { VALUE mid = rb_funcall(beg, '+', 1, diff); BSEARCH_CHECK(mid); if (smaller) { return bsearch_integer_range(beg, mid, 0); } diff = rb_funcall(diff, '*', 1, LONG2FIX(2)); } } else if (NIL_P(beg) && is_integer_p(end)) { VALUE diff = LONG2FIX(-1); RETURN_ENUMERATOR(range, 0, 0); while (1) { VALUE mid = rb_funcall(end, '+', 1, diff); BSEARCH_CHECK(mid); if (!smaller) { return bsearch_integer_range(mid, end, 0); } diff = rb_funcall(diff, '*', 1, LONG2FIX(2)); } } else { rb_raise(rb_eTypeError, "can't do binary search for %s", rb_obj_classname(beg)); } return range; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#begin;F;7[;[[@[i;T;;2;0;[;{;IC; "Returns the object that defines the beginning of +self+. (1..4).begin # => 1 (..2).begin # => nil Related: Range#first, Range#end. ;T;[o;= ;>I" overload;F;?0;;2;@0;:I" begin;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@\;![;"I"@return [Object];T;#0;$@\;.F;Bi;C0;7[;$@\;![;"I"Returns the object that defines the beginning of +self+. (1..4).begin # => 1 (..2).begin # => nil Related: Range#first, Range#end. @overload begin @return [Object];T;#0;$@\;.F;/o;0;1T;2i;3i;%@[;9I"Kstatic VALUE range_begin(VALUE range) { return RANGE_BEG(range); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#end;F;7[;[[@[i;T;;3;0;[;{;IC; "Returns the object that defines the end of +self+. (1..4).end # => 4 (1...4).end # => 4 (1..).end # => nil Related: Range#begin, Range#last. ;T;[o;= ;>I" overload;F;?0;;3;@0;:I"end;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@\;![;"I"@return [Object];T;#0;$@\;.F;Bi;C0;7[;$@\;![;"I"Returns the object that defines the end of +self+. (1..4).end # => 4 (1...4).end # => 4 (1..).end # => nil Related: Range#begin, Range#last. @overload end @return [Object];T;#0;$@\;.F;/o;0;1T;2i;3i;%@[;9I"Istatic VALUE range_end(VALUE range) { return RANGE_END(range); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#first;F;7[[@90;[[@[i2;T;;;0;[;{;IC; "With no argument, returns the first element of +self+, if it exists: (1..4).first # => 1 ('a'..'d').first # => "a" With non-negative integer argument +n+ given, returns the first +n+ elements in an array: (1..10).first(3) # => [1, 2, 3] (1..10).first(0) # => [] (1..4).first(50) # => [1, 2, 3, 4] Raises an exception if there is no first element: (..4).first # Raises RangeError ;T;[o;= ;>I" overload;F;?0;;;@0;:I" first;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@\;![;"I"@return [Object];T;#0;$@\;.F;Bi;C0;7[;$@\o;= ;>I" overload;F;?0;;;@0;:I" first(n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@\;![;"I"@return [Array];T;#0;$@\;.F;Bi;C0;7[[I"n;T0;$@\;![;"I"With no argument, returns the first element of +self+, if it exists: (1..4).first # => 1 ('a'..'d').first # => "a" With non-negative integer argument +n+ given, returns the first +n+ elements in an array: (1..10).first(3) # => [1, 2, 3] (1..10).first(0) # => [] (1..4).first(50) # => [1, 2, 3, 4] Raises an exception if there is no first element: (..4).first # Raises RangeError @overload first @return [Object] @overload first(n) @return [Array];T;#0;$@\;.F;/o;0;1T;2i;3i0;%@[;9I"static VALUE range_first(int argc, VALUE *argv, VALUE range) { VALUE n, ary[2]; if (NIL_P(RANGE_BEG(range))) { rb_raise(rb_eRangeError, "cannot get the first element of beginless range"); } if (argc == 0) return RANGE_BEG(range); rb_scan_args(argc, argv, "1", &n); ary[0] = n; ary[1] = rb_ary_new2(NUM2LONG(n)); rb_block_call(range, idEach, 0, 0, first_i, (VALUE)ary); return ary[1]; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#last;F;7[[@90;[[@[i;T;;;0;[;{;IC; "With no argument, returns the last element of +self+, if it exists: (1..4).last # => 4 ('a'..'d').last # => "d" Note that +last+ with no argument returns the end element of +self+ even if #exclude_end? is +true+: (1...4).last # => 4 ('a'...'d').last # => "d" With non-negative integer argument +n+ given, returns the last +n+ elements in an array: (1..10).last(3) # => [8, 9, 10] (1..10).last(0) # => [] (1..4).last(50) # => [1, 2, 3, 4] Note that +last+ with argument does not return the end element of +self+ if #exclude_end? it +true+: (1...4).last(3) # => [1, 2, 3] ('a'...'d').last(3) # => ["a", "b", "c"] Raises an exception if there is no last element: (1..).last # Raises RangeError ;T;[o;= ;>I" overload;F;?0;;;@0;:I" last;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@)];![;"I"@return [Object];T;#0;$@)];.F;Bi;C0;7[;$@)]o;= ;>I" overload;F;?0;;;@0;:I" last(n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@)];![;"I"@return [Array];T;#0;$@)];.F;Bi;C0;7[[I"n;T0;$@)];![;"I"$With no argument, returns the last element of +self+, if it exists: (1..4).last # => 4 ('a'..'d').last # => "d" Note that +last+ with no argument returns the end element of +self+ even if #exclude_end? is +true+: (1...4).last # => 4 ('a'...'d').last # => "d" With non-negative integer argument +n+ given, returns the last +n+ elements in an array: (1..10).last(3) # => [8, 9, 10] (1..10).last(0) # => [] (1..4).last(50) # => [1, 2, 3, 4] Note that +last+ with argument does not return the end element of +self+ if #exclude_end? it +true+: (1...4).last(3) # => [1, 2, 3] ('a'...'d').last(3) # => ["a", "b", "c"] Raises an exception if there is no last element: (1..).last # Raises RangeError @overload last @return [Object] @overload last(n) @return [Array];T;#0;$@)];.F;/o;0;1T;2iy;3i;%@[;9I"static VALUE range_last(int argc, VALUE *argv, VALUE range) { VALUE b, e; if (NIL_P(RANGE_END(range))) { rb_raise(rb_eRangeError, "cannot get the last element of endless range"); } if (argc == 0) return RANGE_END(range); b = RANGE_BEG(range); e = RANGE_END(range); if (RB_INTEGER_TYPE_P(b) && RB_INTEGER_TYPE_P(e) && RB_LIKELY(rb_method_basic_definition_p(rb_cRange, idEach))) { return rb_int_range_last(argc, argv, range); } return rb_ary_last(argc, argv, rb_Array(range)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#min;F;7[[@90;[[@[i;T;;;0;[;{;IC; "Returns the minimum value in +self+, using method <=> or a given block for comparison. With no argument and no block given, returns the minimum-valued element of +self+. (1..4).min # => 1 ('a'..'d').min # => "a" (-4..-1).min # => -4 With non-negative integer argument +n+ given, and no block given, returns the +n+ minimum-valued elements of +self+ in an array: (1..4).min(2) # => [1, 2] ('a'..'d').min(2) # => ["a", "b"] (-4..-1).min(2) # => [-4, -3] (1..4).min(50) # => [1, 2, 3, 4] If a block is given, it is called: - First, with the first two element of +self+. - Then, sequentially, with the so-far minimum value and the next element of +self+. To illustrate: (1..4).min {|a, b| p [a, b]; a <=> b } # => 1 Output: [2, 1] [3, 1] [4, 1] With no argument and a block given, returns the return value of the last call to the block: (1..4).min {|a, b| -(a <=> b) } # => 4 With non-negative integer argument +n+ given, and a block given, returns the return values of the last +n+ calls to the block in an array: (1..4).min(2) {|a, b| -(a <=> b) } # => [4, 3] (1..4).min(50) {|a, b| -(a <=> b) } # => [4, 3, 2, 1] Returns an empty array if +n+ is zero: (1..4).min(0) # => [] (1..4).min(0) {|a, b| -(a <=> b) } # => [] Returns +nil+ or an empty array if: - The begin value of the range is larger than the end value: (4..1).min # => nil (4..1).min(2) # => [] (4..1).min {|a, b| -(a <=> b) } # => nil (4..1).min(2) {|a, b| -(a <=> b) } # => [] - The begin value of an exclusive range is equal to the end value: (1...1).min # => nil (1...1).min(2) # => [] (1...1).min {|a, b| -(a <=> b) } # => nil (1...1).min(2) {|a, b| -(a <=> b) } # => [] Raises an exception if either: - +self+ is a beginless range: (..4). - A block is given and +self+ is an endless range. Related: Range#max, Range#minmax. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"min;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@T];![;"I"@return [Object];T;#0;$@T];.F;Bi;C0;7[;$@T]o;= ;>I" overload;F;?0;;;@0;:I" min(n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@T];![;"I"@return [Array];T;#0;$@T];.F;Bi;C0;7[[I"n;T0;$@T]o;= ;>I" overload;F;?0;;;@0;:I"min;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"a;TI"b;T;$@T]o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@T];![;"I"#@yield [a, b] @return [Object];T;#0;$@T];.F;Bi;C0;7[;$@T]o;= ;>I" overload;F;?0;;;@0;:I" min(n);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"a;TI"b;T;$@T]o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@T];![;"I""@yield [a, b] @return [Array];T;#0;$@T];.F;Bi;C0;7[[I"n;T0;$@T];![;"I"Returns the minimum value in +self+, using method <=> or a given block for comparison. With no argument and no block given, returns the minimum-valued element of +self+. (1..4).min # => 1 ('a'..'d').min # => "a" (-4..-1).min # => -4 With non-negative integer argument +n+ given, and no block given, returns the +n+ minimum-valued elements of +self+ in an array: (1..4).min(2) # => [1, 2] ('a'..'d').min(2) # => ["a", "b"] (-4..-1).min(2) # => [-4, -3] (1..4).min(50) # => [1, 2, 3, 4] If a block is given, it is called: - First, with the first two element of +self+. - Then, sequentially, with the so-far minimum value and the next element of +self+. To illustrate: (1..4).min {|a, b| p [a, b]; a <=> b } # => 1 Output: [2, 1] [3, 1] [4, 1] With no argument and a block given, returns the return value of the last call to the block: (1..4).min {|a, b| -(a <=> b) } # => 4 With non-negative integer argument +n+ given, and a block given, returns the return values of the last +n+ calls to the block in an array: (1..4).min(2) {|a, b| -(a <=> b) } # => [4, 3] (1..4).min(50) {|a, b| -(a <=> b) } # => [4, 3, 2, 1] Returns an empty array if +n+ is zero: (1..4).min(0) # => [] (1..4).min(0) {|a, b| -(a <=> b) } # => [] Returns +nil+ or an empty array if: - The begin value of the range is larger than the end value: (4..1).min # => nil (4..1).min(2) # => [] (4..1).min {|a, b| -(a <=> b) } # => nil (4..1).min(2) {|a, b| -(a <=> b) } # => [] - The begin value of an exclusive range is equal to the end value: (1...1).min # => nil (1...1).min(2) # => [] (1...1).min {|a, b| -(a <=> b) } # => nil (1...1).min(2) {|a, b| -(a <=> b) } # => [] Raises an exception if either: - +self+ is a beginless range: (..4). - A block is given and +self+ is an endless range. Related: Range#max, Range#minmax. @overload min @return [Object] @overload min(n) @return [Array] @overload min @yield [a, b] @return [Object] @overload min(n) @yield [a, b] @return [Array];T;#0;$@T];.F;/o;0;1T;2i;3i;%@[;9I"static VALUE range_min(int argc, VALUE *argv, VALUE range) { if (NIL_P(RANGE_BEG(range))) { rb_raise(rb_eRangeError, "cannot get the minimum of beginless range"); } if (rb_block_given_p()) { if (NIL_P(RANGE_END(range))) { rb_raise(rb_eRangeError, "cannot get the minimum of endless range with custom comparison method"); } return rb_call_super(argc, argv); } else if (argc != 0) { return range_first(argc, argv, range); } else { struct cmp_opt_data cmp_opt = { 0, 0 }; VALUE b = RANGE_BEG(range); VALUE e = RANGE_END(range); int c = NIL_P(e) ? -1 : OPTIMIZED_CMP(b, e, cmp_opt); if (c > 0 || (c == 0 && EXCL(range))) return Qnil; return b; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#max;F;7[[@90;[[@[in;T;;e;0;[;{;IC; "Returns the maximum value in +self+, using method <=> or a given block for comparison. With no argument and no block given, returns the maximum-valued element of +self+. (1..4).max # => 4 ('a'..'d').max # => "d" (-4..-1).max # => -1 With non-negative integer argument +n+ given, and no block given, returns the +n+ maximum-valued elements of +self+ in an array: (1..4).max(2) # => [4, 3] ('a'..'d').max(2) # => ["d", "c"] (-4..-1).max(2) # => [-1, -2] (1..4).max(50) # => [4, 3, 2, 1] If a block is given, it is called: - First, with the first two element of +self+. - Then, sequentially, with the so-far maximum value and the next element of +self+. To illustrate: (1..4).max {|a, b| p [a, b]; a <=> b } # => 4 Output: [2, 1] [3, 2] [4, 3] With no argument and a block given, returns the return value of the last call to the block: (1..4).max {|a, b| -(a <=> b) } # => 1 With non-negative integer argument +n+ given, and a block given, returns the return values of the last +n+ calls to the block in an array: (1..4).max(2) {|a, b| -(a <=> b) } # => [1, 2] (1..4).max(50) {|a, b| -(a <=> b) } # => [1, 2, 3, 4] Returns an empty array if +n+ is zero: (1..4).max(0) # => [] (1..4).max(0) {|a, b| -(a <=> b) } # => [] Returns +nil+ or an empty array if: - The begin value of the range is larger than the end value: (4..1).max # => nil (4..1).max(2) # => [] (4..1).max {|a, b| -(a <=> b) } # => nil (4..1).max(2) {|a, b| -(a <=> b) } # => [] - The begin value of an exclusive range is equal to the end value: (1...1).max # => nil (1...1).max(2) # => [] (1...1).max {|a, b| -(a <=> b) } # => nil (1...1).max(2) {|a, b| -(a <=> b) } # => [] Raises an exception if either: - +self+ is a endless range: (1..). - A block is given and +self+ is a beginless range. Related: Range#min, Range#minmax. ;T;[ o;= ;>I" overload;F;?0;;e;@0;:I"max;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@];![;"I"@return [Object];T;#0;$@];.F;Bi;C0;7[;$@]o;= ;>I" overload;F;?0;;e;@0;:I" max(n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@];![;"I"@return [Array];T;#0;$@];.F;Bi;C0;7[[I"n;T0;$@]o;= ;>I" overload;F;?0;;e;@0;:I"max;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"a;TI"b;T;$@]o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@];![;"I"#@yield [a, b] @return [Object];T;#0;$@];.F;Bi;C0;7[;$@]o;= ;>I" overload;F;?0;;e;@0;:I" max(n);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"a;TI"b;T;$@]o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@];![;"I""@yield [a, b] @return [Array];T;#0;$@];.F;Bi;C0;7[[I"n;T0;$@];![;"I"Returns the maximum value in +self+, using method <=> or a given block for comparison. With no argument and no block given, returns the maximum-valued element of +self+. (1..4).max # => 4 ('a'..'d').max # => "d" (-4..-1).max # => -1 With non-negative integer argument +n+ given, and no block given, returns the +n+ maximum-valued elements of +self+ in an array: (1..4).max(2) # => [4, 3] ('a'..'d').max(2) # => ["d", "c"] (-4..-1).max(2) # => [-1, -2] (1..4).max(50) # => [4, 3, 2, 1] If a block is given, it is called: - First, with the first two element of +self+. - Then, sequentially, with the so-far maximum value and the next element of +self+. To illustrate: (1..4).max {|a, b| p [a, b]; a <=> b } # => 4 Output: [2, 1] [3, 2] [4, 3] With no argument and a block given, returns the return value of the last call to the block: (1..4).max {|a, b| -(a <=> b) } # => 1 With non-negative integer argument +n+ given, and a block given, returns the return values of the last +n+ calls to the block in an array: (1..4).max(2) {|a, b| -(a <=> b) } # => [1, 2] (1..4).max(50) {|a, b| -(a <=> b) } # => [1, 2, 3, 4] Returns an empty array if +n+ is zero: (1..4).max(0) # => [] (1..4).max(0) {|a, b| -(a <=> b) } # => [] Returns +nil+ or an empty array if: - The begin value of the range is larger than the end value: (4..1).max # => nil (4..1).max(2) # => [] (4..1).max {|a, b| -(a <=> b) } # => nil (4..1).max(2) {|a, b| -(a <=> b) } # => [] - The begin value of an exclusive range is equal to the end value: (1...1).max # => nil (1...1).max(2) # => [] (1...1).max {|a, b| -(a <=> b) } # => nil (1...1).max(2) {|a, b| -(a <=> b) } # => [] Raises an exception if either: - +self+ is a endless range: (1..). - A block is given and +self+ is a beginless range. Related: Range#min, Range#minmax. @overload max @return [Object] @overload max(n) @return [Array] @overload max @yield [a, b] @return [Object] @overload max(n) @yield [a, b] @return [Array];T;#0;$@];.F;/o;0;1T;2i;3ip;%@[;9I"static VALUE range_max(int argc, VALUE *argv, VALUE range) { VALUE e = RANGE_END(range); int nm = FIXNUM_P(e) || rb_obj_is_kind_of(e, rb_cNumeric); if (NIL_P(RANGE_END(range))) { rb_raise(rb_eRangeError, "cannot get the maximum of endless range"); } VALUE b = RANGE_BEG(range); if (rb_block_given_p() || (EXCL(range) && !nm) || argc) { if (NIL_P(b)) { rb_raise(rb_eRangeError, "cannot get the maximum of beginless range with custom comparison method"); } return rb_call_super(argc, argv); } else { struct cmp_opt_data cmp_opt = { 0, 0 }; int c = NIL_P(b) ? -1 : OPTIMIZED_CMP(b, e, cmp_opt); if (c > 0) return Qnil; if (EXCL(range)) { if (!RB_INTEGER_TYPE_P(e)) { rb_raise(rb_eTypeError, "cannot exclude non Integer end value"); } if (c == 0) return Qnil; if (!RB_INTEGER_TYPE_P(b)) { rb_raise(rb_eTypeError, "cannot exclude end value with non Integer begin value"); } if (FIXNUM_P(e)) { return LONG2NUM(FIX2LONG(e) - 1); } return rb_funcall(e, '-', 1, INT2FIX(1)); } return e; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#minmax;F;7[;[[@[i;T;;;0;[;{;IC; "Returns a 2-element array containing the minimum and maximum value in +self+, either according to comparison method <=> or a given block. With no block given, returns the minimum and maximum values, using <=> for comparison: (1..4).minmax # => [1, 4] (1...4).minmax # => [1, 3] ('a'..'d').minmax # => ["a", "d"] (-4..-1).minmax # => [-4, -1] With a block given, the block must return an integer: - Negative if +a+ is smaller than +b+. - Zero if +a+ and +b+ are equal. - Positive if +a+ is larger than +b+. The block is called self.size times to compare elements; returns a 2-element Array containing the minimum and maximum values from +self+, per the block: (1..4).minmax {|a, b| -(a <=> b) } # => [4, 1] Returns [nil, nil] if: - The begin value of the range is larger than the end value: (4..1).minmax # => [nil, nil] (4..1).minmax {|a, b| -(a <=> b) } # => [nil, nil] - The begin value of an exclusive range is equal to the end value: (1...1).minmax # => [nil, nil] (1...1).minmax {|a, b| -(a <=> b) } # => [nil, nil] Raises an exception if +self+ is a beginless or an endless range. Related: Range#min, Range#max. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" minmax;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@];![;"I"@return [Array];T;#0;$@];.F;Bi;C0;7[;$@]o;= ;>I" overload;F;?0;;;@0;:I" minmax;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"a;TI"b;T;$@]o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@];![;"I""@yield [a, b] @return [Array];T;#0;$@];.F;Bi;C0;7[;$@];![;"I"<Returns a 2-element array containing the minimum and maximum value in +self+, either according to comparison method <=> or a given block. With no block given, returns the minimum and maximum values, using <=> for comparison: (1..4).minmax # => [1, 4] (1...4).minmax # => [1, 3] ('a'..'d').minmax # => ["a", "d"] (-4..-1).minmax # => [-4, -1] With a block given, the block must return an integer: - Negative if +a+ is smaller than +b+. - Zero if +a+ and +b+ are equal. - Positive if +a+ is larger than +b+. The block is called self.size times to compare elements; returns a 2-element Array containing the minimum and maximum values from +self+, per the block: (1..4).minmax {|a, b| -(a <=> b) } # => [4, 1] Returns [nil, nil] if: - The begin value of the range is larger than the end value: (4..1).minmax # => [nil, nil] (4..1).minmax {|a, b| -(a <=> b) } # => [nil, nil] - The begin value of an exclusive range is equal to the end value: (1...1).minmax # => [nil, nil] (1...1).minmax {|a, b| -(a <=> b) } # => [nil, nil] Raises an exception if +self+ is a beginless or an endless range. Related: Range#min, Range#max. @overload minmax @return [Array] @overload minmax @yield [a, b] @return [Array];T;#0;$@];.F;/o;0;1T;2i;3i;%@[;9I"static VALUE range_minmax(VALUE range) { if (rb_block_given_p()) { return rb_call_super(0, NULL); } return rb_assoc_new( rb_funcall(range, id_min, 0), rb_funcall(range, id_max, 0) ); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#size;F;7[;[[@[i&;T;;;0;[;{;IC; "Returns the count of elements in +self+ if both begin and end values are numeric; otherwise, returns +nil+: (1..4).size # => 4 (1...4).size # => 3 (1..).size # => Infinity ('a'..'z').size #=> nil Related: Range#count. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Infinity;TI"nil;T;$@(^;![;"I"@return [Infinity, nil];T;#0;$@(^;.F;Bi;C0;7[;$@(^;![;"I"Returns the count of elements in +self+ if both begin and end values are numeric; otherwise, returns +nil+: (1..4).size # => 4 (1...4).size # => 3 (1..).size # => Infinity ('a'..'z').size #=> nil Related: Range#count. @overload size @return [Infinity, nil];T;#0;$@(^;.F;/o;0;1T;2i;3i#;%@[;9I"static VALUE range_size(VALUE range) { VALUE b = RANGE_BEG(range), e = RANGE_END(range); if (rb_obj_is_kind_of(b, rb_cNumeric)) { if (rb_obj_is_kind_of(e, rb_cNumeric)) { return ruby_num_interval_step_size(b, e, INT2FIX(1), EXCL(range)); } if (NIL_P(e)) { return DBL2NUM(HUGE_VAL); } } else if (NIL_P(b)) { return DBL2NUM(HUGE_VAL); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#to_a;F;7[;[[@[iG;T;;;0;[;{;IC; "Returns an array containing the elements in +self+, if a finite collection; raises an exception otherwise. (1..4).to_a # => [1, 2, 3, 4] (1...4).to_a # => [1, 2, 3] ('a'..'d').to_a # => ["a", "b", "c", "d"] Range#entries is an alias for Range#to_a. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_a;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@D^;![;"I"@return [Array];T;#0;$@D^;.F;Bi;C0;7[;$@D^;![;"I"*Returns an array containing the elements in +self+, if a finite collection; raises an exception otherwise. (1..4).to_a # => [1, 2, 3, 4] (1...4).to_a # => [1, 2, 3] ('a'..'d').to_a # => ["a", "b", "c", "d"] Range#entries is an alias for Range#to_a. @overload to_a @return [Array];T;#0;$@D^;.F;/o;0;1T;2i9;3iD;%@[;9I"static VALUE range_to_a(VALUE range) { if (NIL_P(RANGE_END(range))) { rb_raise(rb_eRangeError, "cannot convert endless range to an array"); } return rb_call_super(0, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#entries;F;7[;[[@[iG;T;;;0;[;{;IC; "Returns an array containing the elements in +self+, if a finite collection; raises an exception otherwise. (1..4).to_a # => [1, 2, 3, 4] (1...4).to_a # => [1, 2, 3] ('a'..'d').to_a # => ["a", "b", "c", "d"] Range#entries is an alias for Range#to_a. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_a;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@_^;![;"I"@return [Array];T;#0;$@_^;.F;Bi;C0;7[;$@_^;![;"@[^;#0;$@_^;.F;/o;0;1T;2i9;3iD;%@[;9I"static VALUE range_to_a(VALUE range) { if (NIL_P(RANGE_END(range))) { rb_raise(rb_eRangeError, "cannot convert endless range to an array"); } return rb_call_super(0, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#to_s;F;7[;[[@[iO;T;;G;0;[;{;IC; "fReturns a string representation of +self+, including begin.to_s and end.to_s: (1..4).to_s # => "1..4" (1...4).to_s # => "1...4" (1..).to_s # => "1.." (..4).to_s # => "..4" Note that returns from #to_s and #inspect may differ: ('a'..'d').to_s # => "a..d" ('a'..'d').inspect # => "\"a\"..\"d\"" Related: Range#inspect. ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@y^;![;"I"@return [String];T;#0;$@y^;.F;Bi;C0;7[;$@y^;![;"I"Returns a string representation of +self+, including begin.to_s and end.to_s: (1..4).to_s # => "1..4" (1...4).to_s # => "1...4" (1..).to_s # => "1.." (..4).to_s # => "..4" Note that returns from #to_s and #inspect may differ: ('a'..'d').to_s # => "a..d" ('a'..'d').inspect # => "\"a\"..\"d\"" Related: Range#inspect. @overload to_s @return [String];T;#0;$@y^;.F;/o;0;1T;2i:;3iL;%@[;9I"static VALUE range_to_s(VALUE range) { VALUE str, str2; str = rb_obj_as_string(RANGE_BEG(range)); str2 = rb_obj_as_string(RANGE_END(range)); str = rb_str_dup(str); rb_str_cat(str, "...", EXCL(range) ? 3 : 2); rb_str_append(str, str2); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#inspect;F;7[;[[@[i;T;;J;0;[;{;IC; "uReturns a string representation of +self+, including begin.inspect and end.inspect: (1..4).inspect # => "1..4" (1...4).inspect # => "1...4" (1..).inspect # => "1.." (..4).inspect # => "..4" Note that returns from #to_s and #inspect may differ: ('a'..'d').to_s # => "a..d" ('a'..'d').inspect # => "\"a\"..\"d\"" Related: Range#to_s. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@^;![;"I"@return [String];T;#0;$@^;.F;Bi;C0;7[;$@^;![;"I"Returns a string representation of +self+, including begin.inspect and end.inspect: (1..4).inspect # => "1..4" (1...4).inspect # => "1...4" (1..).inspect # => "1.." (..4).inspect # => "..4" Note that returns from #to_s and #inspect may differ: ('a'..'d').to_s # => "a..d" ('a'..'d').inspect # => "\"a\"..\"d\"" Related: Range#to_s. @overload inspect @return [String];T;#0;$@^;.F;/o;0;1T;2it;3i;%@[;9I"gstatic VALUE range_inspect(VALUE range) { return rb_exec_recursive(inspect_range, range, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#exclude_end?;F;7[;[[@[i;T;:exclude_end?;0;[;{;IC; "Returns +true+ if +self+ excludes its end value; +false+ otherwise: Range.new(2, 5).exclude_end? # => false Range.new(2, 5, true).exclude_end? # => true (2..5).exclude_end? # => false (2...5).exclude_end? # => true;T;[o;= ;>I" overload;F;?0;;* ;@0;:I"exclude_end?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@^;![;"I"@return [Boolean];T;#0;$@^;.F;Bi;C0;7[;$@^;![;"I"/Returns +true+ if +self+ excludes its end value; +false+ otherwise: Range.new(2, 5).exclude_end? # => false Range.new(2, 5, true).exclude_end? # => true (2..5).exclude_end? # => false (2...5).exclude_end? # => true @overload exclude_end? @return [Boolean];T;#0;$@^;.F;/o;0;1T;2i};3i;Bi;%@[;9I"Ustatic VALUE range_exclude_end_p(VALUE range) { return RBOOL(EXCL(range)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#member?;F;7[[I"val;T0;[[@[i;T;;;0;[;{;IC; "Returns +true+ if +object+ is an element of +self+, +false+ otherwise: (1..4).include?(2) # => true (1..4).include?(5) # => false (1..4).include?(4) # => true (1...4).include?(4) # => false ('a'..'d').include?('b') # => true ('a'..'d').include?('e') # => false ('a'..'d').include?('B') # => false ('a'..'d').include?('d') # => true ('a'...'d').include?('d') # => false If begin and end are numeric, #include? behaves like #cover? (1..3).include?(1.5) # => true (1..3).cover?(1.5) # => true But when not numeric, the two methods may differ: ('a'..'d').include?('cc') # => false ('a'..'d').cover?('cc') # => true Related: Range#cover?. Range#member? is an alias for Range#include?.;T;[o;= ;>I" overload;F;?0;;;@0;:I"include?(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@^;![;"I"@return [Boolean];T;#0;$@^;.F;Bi;C0;7[[I" object;T0;$@^;![;"I"Returns +true+ if +object+ is an element of +self+, +false+ otherwise: (1..4).include?(2) # => true (1..4).include?(5) # => false (1..4).include?(4) # => true (1...4).include?(4) # => false ('a'..'d').include?('b') # => true ('a'..'d').include?('e') # => false ('a'..'d').include?('B') # => false ('a'..'d').include?('d') # => true ('a'...'d').include?('d') # => false If begin and end are numeric, #include? behaves like #cover? (1..3).include?(1.5) # => true (1..3).cover?(1.5) # => true But when not numeric, the two methods may differ: ('a'..'d').include?('cc') # => false ('a'..'d').cover?('cc') # => true Related: Range#cover?. Range#member? is an alias for Range#include?. @overload include?(object) @return [Boolean];T;#0;$@^;.F;/o;0;1T;2i;3i;Bi;%@[;9I"static VALUE range_include(VALUE range, VALUE val) { VALUE ret = range_include_internal(range, val, 0); if (ret != Qundef) return ret; return rb_call_super(1, &val); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#include?;F;7[[I"val;T0;[[@[i;T;;;0;[;{;IC; "Returns +true+ if +object+ is an element of +self+, +false+ otherwise: (1..4).include?(2) # => true (1..4).include?(5) # => false (1..4).include?(4) # => true (1...4).include?(4) # => false ('a'..'d').include?('b') # => true ('a'..'d').include?('e') # => false ('a'..'d').include?('B') # => false ('a'..'d').include?('d') # => true ('a'...'d').include?('d') # => false If begin and end are numeric, #include? behaves like #cover? (1..3).include?(1.5) # => true (1..3).cover?(1.5) # => true But when not numeric, the two methods may differ: ('a'..'d').include?('cc') # => false ('a'..'d').cover?('cc') # => true Related: Range#cover?. Range#member? is an alias for Range#include?.;T;[o;= ;>I" overload;F;?0;;;@0;:I"include?(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@^;![;"I"@return [Boolean];T;#0;$@^;.F;Bi;C0;7[[I" object;T0;$@^;![;"@^;#0;$@^;.F;/o;0;1T;2i;3i;Bi;%@[;9I"static VALUE range_include(VALUE range, VALUE val) { VALUE ret = range_include_internal(range, val, 0); if (ret != Qundef) return ret; return rb_call_super(1, &val); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#cover?;F;7[[I"val;T0;[[@[id;T;: cover?;0;[;{;IC; ":Returns +true+ if the given argument is within +self+, +false+ otherwise. With non-range argument +object+, evaluates with <= and <. For range +self+ with included end value (#exclude_end? == false), evaluates thus: self.begin <= object <= self.end Examples: r = (1..4) r.cover?(1) # => true r.cover?(4) # => true r.cover?(0) # => false r.cover?(5) # => false r.cover?('foo') # => false r = ('a'..'d') r.cover?('a') # => true r.cover?('d') # => true r.cover?(' ') # => false r.cover?('e') # => false r.cover?(0) # => false For range +r+ with excluded end value (#exclude_end? == true), evaluates thus: r.begin <= object < r.end Examples: r = (1...4) r.cover?(1) # => true r.cover?(3) # => true r.cover?(0) # => false r.cover?(4) # => false r.cover?('foo') # => false r = ('a'...'d') r.cover?('a') # => true r.cover?('c') # => true r.cover?(' ') # => false r.cover?('d') # => false r.cover?(0) # => false With range argument +range+, compares the first and last elements of +self+ and +range+: r = (1..4) r.cover?(1..4) # => true r.cover?(0..4) # => false r.cover?(1..5) # => false r.cover?('a'..'d') # => false r = (1...4) r.cover?(1..3) # => true r.cover?(1..4) # => false If begin and end are numeric, #cover? behaves like #include? (1..3).cover?(1.5) # => true (1..3).include?(1.5) # => true But when not numeric, the two methods may differ: ('a'..'d').cover?('cc') # => true ('a'..'d').include?('cc') # => false Returns +false+ if either: - The begin value of +self+ is larger than its end value. - An internal call to <=> returns +nil+; that is, the operands are not comparable. Related: Range#include?.;T;[o;= ;>I" overload;F;?0;;+ ;@0;:I"cover?(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@_;![;"I"@return [Boolean];T;#0;$@_;.F;Bi;C0;7[[I" object;T0;$@_o;= ;>I" overload;F;?0;;+ ;@0;:I"cover?(range);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@_;![;"I"@return [Boolean];T;#0;$@_;.F;Bi;C0;7[[I" range;T0;$@_;![;"I"Returns +true+ if the given argument is within +self+, +false+ otherwise. With non-range argument +object+, evaluates with <= and <. For range +self+ with included end value (#exclude_end? == false), evaluates thus: self.begin <= object <= self.end Examples: r = (1..4) r.cover?(1) # => true r.cover?(4) # => true r.cover?(0) # => false r.cover?(5) # => false r.cover?('foo') # => false r = ('a'..'d') r.cover?('a') # => true r.cover?('d') # => true r.cover?(' ') # => false r.cover?('e') # => false r.cover?(0) # => false For range +r+ with excluded end value (#exclude_end? == true), evaluates thus: r.begin <= object < r.end Examples: r = (1...4) r.cover?(1) # => true r.cover?(3) # => true r.cover?(0) # => false r.cover?(4) # => false r.cover?('foo') # => false r = ('a'...'d') r.cover?('a') # => true r.cover?('c') # => true r.cover?(' ') # => false r.cover?('d') # => false r.cover?(0) # => false With range argument +range+, compares the first and last elements of +self+ and +range+: r = (1..4) r.cover?(1..4) # => true r.cover?(0..4) # => false r.cover?(1..5) # => false r.cover?('a'..'d') # => false r = (1...4) r.cover?(1..3) # => true r.cover?(1..4) # => false If begin and end are numeric, #cover? behaves like #include? (1..3).cover?(1.5) # => true (1..3).include?(1.5) # => true But when not numeric, the two methods may differ: ('a'..'d').cover?('cc') # => true ('a'..'d').include?('cc') # => false Returns +false+ if either: - The begin value of +self+ is larger than its end value. - An internal call to <=> returns +nil+; that is, the operands are not comparable. Related: Range#include?. @overload cover?(object) @return [Boolean] @overload cover?(range) @return [Boolean];T;#0;$@_;.F;/o;0;1T;2i;3ib;Bi;%@[;9I"static VALUE range_cover(VALUE range, VALUE val) { VALUE beg, end; beg = RANGE_BEG(range); end = RANGE_END(range); if (rb_obj_is_kind_of(val, rb_cRange)) { return RBOOL(r_cover_range_p(range, beg, end, val)); } return r_cover_p(range, beg, end, val); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Range#count;F;7[[@90;[[@[i;T;;;0;[;{;IC; "Returns the count of elements, based on an argument or block criterion, if given. With no argument and no block given, returns the number of elements: (1..4).count # => 4 (1...4).count # => 3 ('a'..'d').count # => 4 ('a'...'d').count # => 3 (1..).count # => Infinity (..4).count # => Infinity With argument +object+, returns the number of +object+ found in +self+, which will usually be zero or one: (1..4).count(2) # => 1 (1..4).count(5) # => 0 (1..4).count('a') # => 0 With a block given, calls the block with each element; returns the number of elements for which the block returns a truthy value: (1..4).count {|element| element < 3 } # => 2 Related: Range#size. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" count;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@5_;![;"I"@return [Integer];T;#0;$@5_;.F;Bi;C0;7[;$@5_o;= ;>I" overload;F;?0;;;@0;:I"count(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@5_;![;"I"@return [Integer];T;#0;$@5_;.F;Bi;C0;7[[I" object;T0;$@5_o;= ;>I" overload;F;?0;;;@0;:I" count;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" element;T;$@5_o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@5_;![;"I"'@yield [element] @return [Integer];T;#0;$@5_;.F;Bi;C0;7[;$@5_;![;"I"YReturns the count of elements, based on an argument or block criterion, if given. With no argument and no block given, returns the number of elements: (1..4).count # => 4 (1...4).count # => 3 ('a'..'d').count # => 4 ('a'...'d').count # => 3 (1..).count # => Infinity (..4).count # => Infinity With argument +object+, returns the number of +object+ found in +self+, which will usually be zero or one: (1..4).count(2) # => 1 (1..4).count(5) # => 0 (1..4).count('a') # => 0 With a block given, calls the block with each element; returns the number of elements for which the block returns a truthy value: (1..4).count {|element| element < 3 } # => 2 Related: Range#size. @overload count @return [Integer] @overload count(object) @return [Integer] @overload count @yield [element] @return [Integer];T;#0;$@5_;.F;/o;0;1T;2i;3i;%@[;9I" static VALUE range_count(int argc, VALUE *argv, VALUE range) { if (argc != 0) { /* It is odd for instance (1...).count(0) to return Infinity. Just let * it loop. */ return rb_call_super(argc, argv); } else if (rb_block_given_p()) { /* Likewise it is odd for instance (1...).count {|x| x == 0 } to return * Infinity. Just let it loop. */ return rb_call_super(argc, argv); } else if (NIL_P(RANGE_END(range))) { /* We are confident that the answer is Infinity. */ return DBL2NUM(HUGE_VAL); } else if (NIL_P(RANGE_BEG(range))) { /* We are confident that the answer is Infinity. */ return DBL2NUM(HUGE_VAL); } else { return rb_call_super(argc, argv); } };T;:I"static VALUE;T;;T; @[; IC;[; @[; IC;[o;( ;)0;*0;+0;;;%@;-@y,;0; @[; IC;{;IC;{;T;IC;{;T;T;{;[;[[@[i;F;;0;;;;;[;{;IC; "A \Range object represents a collection of values that are between given begin and end values. You can create an \Range object explicitly with: - A {range literal}[doc/syntax/literals_rdoc.html#label-Range+Literals]: # Ranges that use '..' to include the given end value. (1..4).to_a # => [1, 2, 3, 4] ('a'..'d').to_a # => ["a", "b", "c", "d"] # Ranges that use '...' to exclude the given end value. (1...4).to_a # => [1, 2, 3] ('a'...'d').to_a # => ["a", "b", "c"] A range may be created using method Range.new: # Ranges that by default include the given end value. Range.new(1, 4).to_a # => [1, 2, 3, 4] Range.new('a', 'd').to_a # => ["a", "b", "c", "d"] # Ranges that use third argument +exclude_end+ to exclude the given end value. Range.new(1, 4, true).to_a # => [1, 2, 3] Range.new('a', 'd', true).to_a # => ["a", "b", "c"] == Beginless Ranges A _beginless_ _range_ has a definite end value, but a +nil+ begin value. Such a range includes all values up to the end value. r = (..4) # => nil..4 r.begin # => nil r.include?(-50) # => true r.include?(4) # => true r = (...4) # => nil...4 r.include?(4) # => false Range.new(nil, 4) # => nil..4 Range.new(nil, 4, true) # => nil...4 A beginless range may be used to slice an array: a = [1, 2, 3, 4] r = (..2) # => nil...2 a[r] # => [1, 2] \Method +each+ for a beginless range raises an exception. == Endless Ranges An _endless_ _range_ has a definite begin value, but a +nil+ end value. Such a range includes all values from the begin value. r = (1..) # => 1.. r.end # => nil r.include?(50) # => true Range.new(1, nil) # => 1.. The literal for an endless range may be written with either two dots or three. The range has the same elements, either way. But note that the two are not equal: r0 = (1..) # => 1.. r1 = (1...) # => 1... r0.begin == r1.begin # => true r0.end == r1.end # => true r0 == r1 # => false An endless range may be used to slice an array: a = [1, 2, 3, 4] r = (2..) # => 2.. a[r] # => [3, 4] \Method +each+ for an endless range calls the given block indefinitely: a = [] r = (1..) r.each do |i| a.push(i) if i.even? break if i > 10 end a # => [2, 4, 6, 8, 10] == Ranges and Other Classes An object may be put into a range if its class implements instance method <=>. Ruby core classes that do so include Array, Complex, File::Stat, Float, Integer, Kernel, Module, Numeric, Rational, String, Symbol, and Time. Example: t0 = Time.now # => 2021-09-19 09:22:48.4854986 -0500 t1 = Time.now # => 2021-09-19 09:22:56.0365079 -0500 t2 = Time.now # => 2021-09-19 09:23:08.5263283 -0500 (t0..t2).include?(t1) # => true (t0..t1).include?(t2) # => false A range can be iterated over only if its elements implement instance method +succ+. Ruby core classes that do so include Integer, String, and Symbol (but not the other classes mentioned above). Iterator methods include: - In \Range itself: #each, #step, and #% - Included from module Enumerable: #each_entry, #each_with_index, #each_with_object, #each_slice, #each_cons, and #reverse_each. Example: a = [] (1..4).each {|i| a.push(i) } a # => [1, 2, 3, 4] == Ranges and User-Defined Classes A user-defined class that is to be used in a range must implement instance <=>; see {Integer#<=>}[Integer.html#label-method-i-3C-3D-3E]. To make iteration available, it must also implement instance method +succ+; see Integer#succ. The class below implements both <=> and +succ+, and so can be used both to construct ranges and to iterate over them. Note that the Comparable module is included so the == method is defined in terms of <=>. # Represent a string of 'X' characters. class Xs include Comparable attr_accessor :length def initialize(n) @length = n end def succ Xs.new(@length + 1) end def <=>(other) @length <=> other.length end def to_s sprintf "%2d #{inspect}", @length end def inspect 'X' * @length end end r = Xs.new(3)..Xs.new(6) #=> XXX..XXXXXX r.to_a #=> [XXX, XXXX, XXXXX, XXXXXX] r.include?(Xs.new(5)) #=> true r.include?(Xs.new(7)) #=> false == What's Here First, what's elsewhere. \Class \Range: - Inherits from {class Object}[Object.html#class-Object-label-What-27s+Here]. - Includes {module Enumerable}[Enumerable.html#module-Enumerable-label-What-27s+Here], which provides dozens of additional methods. Here, class \Range provides methods that are useful for: - {Creating a Range}[#class-Range-label-Methods+for+Creating+a+Range] - {Querying}[#class-Range-label-Methods+for+Querying] - {Comparing}[#class-Range-label-Methods+for+Comparing] - {Iterating}[#class-Range-label-Methods+for+Iterating] - {Converting}[#class-Range-label-Methods+for+Converting] === Methods for Creating a \Range - ::new:: Returns a new range. === Methods for Querying - #begin:: Returns the begin value given for +self+. - #bsearch:: Returns an element from +self+ selected by a binary search. - #count:: Returns a count of elements in +self+. - #end:: Returns the end value given for +self+. - #exclude_end?:: Returns whether the end object is excluded. - #first:: Returns the first elements of +self+. - #hash:: Returns the integer hash code. - #last:: Returns the last elements of +self+. - #max:: Returns the maximum values in +self+. - #min:: Returns the minimum values in +self+. - #minmax:: Returns the minimum and maximum values in +self+. - #size:: Returns the count of elements in +self+. === Methods for Comparing - {#==}[#method-i-3D-3D]:: Returns whether a given object is equal to +self+ (uses #==). - #===:: Returns whether the given object is between the begin and end values. - #cover?:: Returns whether a given object is within +self+. - #eql?:: Returns whether a given object is equal to +self+ (uses #eql?). - #include? (aliased as #member?):: Returns whether a given object is an element of +self+. === Methods for Iterating - #%:: Requires argument +n+; calls the block with each +n+-th element of +self+. - #each:: Calls the block with each element of +self+. - #step:: Takes optional argument +n+ (defaults to 1); calls the block with each +n+-th element of +self+. === Methods for Converting - #inspect:: Returns a string representation of +self+ (uses #inspect). - #to_a (aliased as #entries):: Returns elements of +self+ in an array. - #to_s:: Returns a string representation of +self+ (uses #to_s). ;T;[;![;"I"A \Range object represents a collection of values that are between given begin and end values. You can create an \Range object explicitly with: - A {range literal}[doc/syntax/literals_rdoc.html#label-Range+Literals]: # Ranges that use '..' to include the given end value. (1..4).to_a # => [1, 2, 3, 4] ('a'..'d').to_a # => ["a", "b", "c", "d"] # Ranges that use '...' to exclude the given end value. (1...4).to_a # => [1, 2, 3] ('a'...'d').to_a # => ["a", "b", "c"] A range may be created using method Range.new: # Ranges that by default include the given end value. Range.new(1, 4).to_a # => [1, 2, 3, 4] Range.new('a', 'd').to_a # => ["a", "b", "c", "d"] # Ranges that use third argument +exclude_end+ to exclude the given end value. Range.new(1, 4, true).to_a # => [1, 2, 3] Range.new('a', 'd', true).to_a # => ["a", "b", "c"] == Beginless Ranges A _beginless_ _range_ has a definite end value, but a +nil+ begin value. Such a range includes all values up to the end value. r = (..4) # => nil..4 r.begin # => nil r.include?(-50) # => true r.include?(4) # => true r = (...4) # => nil...4 r.include?(4) # => false Range.new(nil, 4) # => nil..4 Range.new(nil, 4, true) # => nil...4 A beginless range may be used to slice an array: a = [1, 2, 3, 4] r = (..2) # => nil...2 a[r] # => [1, 2] \Method +each+ for a beginless range raises an exception. == Endless Ranges An _endless_ _range_ has a definite begin value, but a +nil+ end value. Such a range includes all values from the begin value. r = (1..) # => 1.. r.end # => nil r.include?(50) # => true Range.new(1, nil) # => 1.. The literal for an endless range may be written with either two dots or three. The range has the same elements, either way. But note that the two are not equal: r0 = (1..) # => 1.. r1 = (1...) # => 1... r0.begin == r1.begin # => true r0.end == r1.end # => true r0 == r1 # => false An endless range may be used to slice an array: a = [1, 2, 3, 4] r = (2..) # => 2.. a[r] # => [3, 4] \Method +each+ for an endless range calls the given block indefinitely: a = [] r = (1..) r.each do |i| a.push(i) if i.even? break if i > 10 end a # => [2, 4, 6, 8, 10] == Ranges and Other Classes An object may be put into a range if its class implements instance method <=>. Ruby core classes that do so include Array, Complex, File::Stat, Float, Integer, Kernel, Module, Numeric, Rational, String, Symbol, and Time. Example: t0 = Time.now # => 2021-09-19 09:22:48.4854986 -0500 t1 = Time.now # => 2021-09-19 09:22:56.0365079 -0500 t2 = Time.now # => 2021-09-19 09:23:08.5263283 -0500 (t0..t2).include?(t1) # => true (t0..t1).include?(t2) # => false A range can be iterated over only if its elements implement instance method +succ+. Ruby core classes that do so include Integer, String, and Symbol (but not the other classes mentioned above). Iterator methods include: - In \Range itself: #each, #step, and #% - Included from module Enumerable: #each_entry, #each_with_index, #each_with_object, #each_slice, #each_cons, and #reverse_each. Example: a = [] (1..4).each {|i| a.push(i) } a # => [1, 2, 3, 4] == Ranges and User-Defined Classes A user-defined class that is to be used in a range must implement instance <=>; see {Integer#<=>}[Integer.html#label-method-i-3C-3D-3E]. To make iteration available, it must also implement instance method +succ+; see Integer#succ. The class below implements both <=> and +succ+, and so can be used both to construct ranges and to iterate over them. Note that the Comparable module is included so the == method is defined in terms of <=>. # Represent a string of 'X' characters. class Xs include Comparable attr_accessor :length def initialize(n) @length = n end def succ Xs.new(@length + 1) end def <=>(other) @length <=> other.length end def to_s sprintf "%2d #{inspect}", @length end def inspect 'X' * @length end end r = Xs.new(3)..Xs.new(6) #=> XXX..XXXXXX r.to_a #=> [XXX, XXXX, XXXXX, XXXXXX] r.include?(Xs.new(5)) #=> true r.include?(Xs.new(7)) #=> false == What's Here First, what's elsewhere. \Class \Range: - Inherits from {class Object}[Object.html#class-Object-label-What-27s+Here]. - Includes {module Enumerable}[Enumerable.html#module-Enumerable-label-What-27s+Here], which provides dozens of additional methods. Here, class \Range provides methods that are useful for: - {Creating a Range}[#class-Range-label-Methods+for+Creating+a+Range] - {Querying}[#class-Range-label-Methods+for+Querying] - {Comparing}[#class-Range-label-Methods+for+Comparing] - {Iterating}[#class-Range-label-Methods+for+Iterating] - {Converting}[#class-Range-label-Methods+for+Converting] === Methods for Creating a \Range - ::new:: Returns a new range. === Methods for Querying - #begin:: Returns the begin value given for +self+. - #bsearch:: Returns an element from +self+ selected by a binary search. - #count:: Returns a count of elements in +self+. - #end:: Returns the end value given for +self+. - #exclude_end?:: Returns whether the end object is excluded. - #first:: Returns the first elements of +self+. - #hash:: Returns the integer hash code. - #last:: Returns the last elements of +self+. - #max:: Returns the maximum values in +self+. - #min:: Returns the minimum values in +self+. - #minmax:: Returns the minimum and maximum values in +self+. - #size:: Returns the count of elements in +self+. === Methods for Comparing - {#==}[#method-i-3D-3D]:: Returns whether a given object is equal to +self+ (uses #==). - #===:: Returns whether the given object is between the begin and end values. - #cover?:: Returns whether a given object is within +self+. - #eql?:: Returns whether a given object is equal to +self+ (uses #eql?). - #include? (aliased as #member?):: Returns whether a given object is an element of +self+. === Methods for Iterating - #%:: Requires argument +n+; calls the block with each +n+-th element of +self+. - #each:: Calls the block with each element of +self+. - #step:: Takes optional argument +n+ (defaults to 1); calls the block with each +n+-th element of +self+. === Methods for Converting - #inspect:: Returns a string representation of +self+ (uses #inspect). - #to_a (aliased as #entries):: Returns elements of +self+ in an array. - #to_s:: Returns a string representation of +self+ (uses #to_s). ;T;#0;$@[;.F;/o;0;1T;2i;3i;%@;&I" Range;F;'@o;;IC;[ o;4;5F;6;;;;&I"Marshal#dump;F;7[[@90;[[I"marshal.c;TiJ;T;: dump;0;[;{;IC; "[Serializes obj and all descendant objects. If anIO is specified, the serialized data will be written to it, otherwise the data will be returned as a String. If limit is specified, the traversal of subobjects will be limited to that depth. If limit is negative, no checking of depth will be performed. class Klass def initialize(str) @str = str end def say_hello @str end end (produces no output) o = Klass.new("hello\n") data = Marshal.dump(o) obj = Marshal.load(data) obj.say_hello #=> "hello\n" Marshal can't dump following objects: * anonymous Class/Module. * objects which are related to system (ex: Dir, File::Stat, IO, File, Socket and so on) * an instance of MatchData, Data, Method, UnboundMethod, Proc, Thread, ThreadGroup, Continuation * objects which define singleton methods ;T;[o;= ;>I" overload;F;?0;;, ;@0;:I"$dump( obj [, anIO] , limit=-1 );T;IC; ";T;[;![;"I";T;#0;$@_;.F;Bi;C0;7[[I"obj[, anIO];T0[I" limit;TI"-1;T;$@_;![;"I"Serializes obj and all descendant objects. If anIO is specified, the serialized data will be written to it, otherwise the data will be returned as a String. If limit is specified, the traversal of subobjects will be limited to that depth. If limit is negative, no checking of depth will be performed. class Klass def initialize(str) @str = str end def say_hello @str end end (produces no output) o = Klass.new("hello\n") data = Marshal.dump(o) obj = Marshal.load(data) obj.say_hello #=> "hello\n" Marshal can't dump following objects: * anonymous Class/Module. * objects which are related to system (ex: Dir, File::Stat, IO, File, Socket and so on) * an instance of MatchData, Data, Method, UnboundMethod, Proc, Thread, ThreadGroup, Continuation * objects which define singleton methods @overload dump( obj [, anIO] , limit=-1 ) ;T;#0;$@_;.F;C0;%@_;9I"static VALUE marshal_dump(int argc, VALUE *argv, VALUE _) { VALUE obj, port, a1, a2; int limit = -1; port = Qnil; rb_scan_args(argc, argv, "12", &obj, &a1, &a2); if (argc == 3) { if (!NIL_P(a2)) limit = NUM2INT(a2); if (NIL_P(a1)) io_needed(); port = a1; } else if (argc == 2) { if (FIXNUM_P(a1)) limit = FIX2INT(a1); else if (NIL_P(a1)) io_needed(); else port = a1; } return rb_marshal_dump_limited(obj, port, limit); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Marshal.dump;F;7@_;@_;T;;, ;0;@_;{;IC; "[Serializes obj and all descendant objects. If anIO is specified, the serialized data will be written to it, otherwise the data will be returned as a String. If limit is specified, the traversal of subobjects will be limited to that depth. If limit is negative, no checking of depth will be performed. class Klass def initialize(str) @str = str end def say_hello @str end end (produces no output) o = Klass.new("hello\n") data = Marshal.dump(o) obj = Marshal.load(data) obj.say_hello #=> "hello\n" Marshal can't dump following objects: * anonymous Class/Module. * objects which are related to system (ex: Dir, File::Stat, IO, File, Socket and so on) * an instance of MatchData, Data, Method, UnboundMethod, Proc, Thread, ThreadGroup, Continuation * objects which define singleton methods;T;[o;= ;>I" overload;F;?0;;, ;@0;:I"$dump( obj [, anIO] , limit=-1 );T;IC; ";T;[;![;"I";T;#0;$@_;.F;Bi;C0;7[[I"obj[, anIO];T0[I" limit;TI"-1;T;$@_;![;"I"Serializes obj and all descendant objects. If anIO is specified, the serialized data will be written to it, otherwise the data will be returned as a String. If limit is specified, the traversal of subobjects will be limited to that depth. If limit is negative, no checking of depth will be performed. class Klass def initialize(str) @str = str end def say_hello @str end end (produces no output) o = Klass.new("hello\n") data = Marshal.dump(o) obj = Marshal.load(data) obj.say_hello #=> "hello\n" Marshal can't dump following objects: * anonymous Class/Module. * objects which are related to system (ex: Dir, File::Stat, IO, File, Socket and so on) * an instance of MatchData, Data, Method, UnboundMethod, Proc, Thread, ThreadGroup, Continuation * objects which define singleton methods @overload dump( obj [, anIO] , limit=-1 );T;#0;$@_;.F;/o;0;1T;2i(;3iG;Bi;%@_;9@_;:@_;;To;u;[[@_ib ;F;:MAJOR_VERSION;;w;;;[;{;IC; "major version ;T;[;![;"I"major version;T;#0;$@_;.F;/o;0;1T;2ia ;3ia ;%@_;&I"Marshal::MAJOR_VERSION;F;xI"INT2FIX(MARSHAL_MAJOR);To;u;[[@_id ;F;:MINOR_VERSION;;w;;;[;{;IC; "minor version ;T;[;![;"I"minor version;T;#0;$@_;.F;/o;0;1T;2ic ;3ic ;%@_;&I"Marshal::MINOR_VERSION;F;xI"INT2FIX(MARSHAL_MINOR);To; ;IC;[ o;4;5F;6;;;;&I"%Marshal::InternalIVar#initialize;F;7[[I" arg1;T0[I" arg2;T0[I" arg3;T0;[[I"5ext/-test-/marshal/internal_ivar/internal_ivar.c;Ti ;T;;D;0;[;{;IC; " ;T;[;![;"@;#0;$@_;%@_;9I"static VALUE init(VALUE self, VALUE arg1, VALUE arg2, VALUE arg3) { rb_ivar_set(self, id_normal_ivar, arg1); rb_ivar_set(self, id_internal_ivar, arg2); rb_ivar_set(self, id_encoding_short, arg3); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Marshal::InternalIVar#normal;F;7[;[[@_i;T;: normal;0;[;{;IC; " ;T;[;![;"@;#0;$@_;%@_;9I"Zstatic VALUE get_normal(VALUE self) { return rb_attr_get(self, id_normal_ivar); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#Marshal::InternalIVar#internal;F;7[;[[@_i;T;: internal;0;[;{;IC; " ;T;[;![;"@;#0;$@_;%@_;9I"^static VALUE get_internal(VALUE self) { return rb_attr_get(self, id_internal_ivar); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I")Marshal::InternalIVar#encoding_short;F;7[;[[@_i;T;:encoding_short;0;[;{;IC; " ;T;[;![;"@;#0;$@_;%@_;9I"estatic VALUE get_encoding_short(VALUE self) { return rb_attr_get(self, id_encoding_short); };T;:I"static VALUE;T;;To; ;IC;[o;4;5F;6;;;;&I"/Marshal::InternalIVar::compat#marshal_load;F;7[[I" data;T0;[[I"*ext/-test-/marshal/compat/usrcompat.c;Ti;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@ `;%@`;9I"}static VALUE compat_mload(VALUE self, VALUE data) { rb_ivar_set(self, rb_intern("@value"), data); return self; };T;:I"static VALUE;T;;T; @`; IC;[; @`; IC;[; @`; IC;{;IC;{;T;IC;{;T;T;{;[;[[@`i!;F;: compat;;;;;[;{;IC; " ;T;[;![;"@;#0;$@`;%@_;&I""Marshal::InternalIVar::compat;F;'@; @_; IC;[; @_; IC;[; @_; IC;{;IC;{;T;IC;{;T;T;{;[;[[@_i);F;:InternalIVar;;;;;[;{;IC; " ;T;[;![;"@;#0;$@_;%@_;&I"Marshal::InternalIVar;F;'@o; ;IC;[ o;4;5F;6;;;;&I"#Marshal::UsrMarshal#initialize;F;7[[I"val;T0;[[I"(ext/-test-/marshal/usr/usrmarshal.c;Ti;T;;D;0;[;{;IC; " ;T;[;![;"@;#0;$@9`;%@7`;9I"static VALUE usr_init(VALUE self, VALUE val) { int *ptr = Check_TypedStruct(self, &usrmarshal_type); *ptr = NUM2INT(val); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Marshal::UsrMarshal#value;F;7[;[[@@`i$;T;;5;0;[;{;IC; " ;T;[;![;"@;#0;$@H`;%@7`;9I"static VALUE usr_value(VALUE self) { int *ptr = Check_TypedStruct(self, &usrmarshal_type); int val = *ptr; return INT2NUM(val); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%Marshal::UsrMarshal#marshal_load;F;7[[I"val;T0;[[@@`i;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@T`;%@7`;9I"static VALUE usr_init(VALUE self, VALUE val) { int *ptr = Check_TypedStruct(self, &usrmarshal_type); *ptr = NUM2INT(val); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%Marshal::UsrMarshal#marshal_dump;F;7[;[[@@`i$;T;;[;0;[;{;IC; " ;T;[;![;"@;#0;$@b`;%@7`;9I"static VALUE usr_value(VALUE self) { int *ptr = Check_TypedStruct(self, &usrmarshal_type); int val = *ptr; return INT2NUM(val); };T;:I"static VALUE;T;;T; @7`; IC;[; @7`; IC;[; @7`; IC;{;IC;{;T;IC;{;T;T;{;[;[[@@`i0;F;:UsrMarshal;;;;;[;{;IC; " ;T;[;![;"@;#0;$@7`;%@_;&I"Marshal::UsrMarshal;F;'@; @_; IC;[; @_; IC;[; @_; IC;{;IC;{;T;IC;{;T;T;{;[;[[@_iN ;F;: Marshal;;;;;[;{;IC; " ;T;[;![;"@;#0;$@_;Bi;%@;&I" Marshal;Fo; ;IC;[o; ;IC;[6o;4;5F;6;;;;&I"%Enumerator::Lazy#_enumerable_map;F;7[;[[@i;F;:_enumerable_map;;;[;{;IC; " ;T;[;![;"@;#0;$@`;%@`;:I"def _enumerable_map;To;4;5F;6;;;;&I")Enumerator::Lazy#_enumerable_collect;F;7[;[[@i;F;:_enumerable_collect;;;[;{;IC; " ;T;[;![;"@;#0;$@`;%@`;:I"def _enumerable_collect;To;4;5F;6;;;;&I"*Enumerator::Lazy#_enumerable_flat_map;F;7[;[[@i;F;:_enumerable_flat_map;;;[;{;IC; " ;T;[;![;"@;#0;$@`;%@`;:I"def _enumerable_flat_map;To;4;5F;6;;;;&I"0Enumerator::Lazy#_enumerable_collect_concat;F;7[;[[@i;F;:_enumerable_collect_concat;;;[;{;IC; " ;T;[;![;"@;#0;$@`;%@`;:I"#def _enumerable_collect_concat;To;4;5F;6;;;;&I"(Enumerator::Lazy#_enumerable_select;F;7[;[[@i;F;:_enumerable_select;;;[;{;IC; " ;T;[;![;"@;#0;$@`;%@`;:I"def _enumerable_select;To;4;5F;6;;;;&I"*Enumerator::Lazy#_enumerable_find_all;F;7[;[[@i;F;:_enumerable_find_all;;;[;{;IC; " ;T;[;![;"@;#0;$@`;%@`;:I"def _enumerable_find_all;To;4;5F;6;;;;&I"(Enumerator::Lazy#_enumerable_filter;F;7[;[[@i;F;:_enumerable_filter;;;[;{;IC; " ;T;[;![;"@;#0;$@`;%@`;:I"def _enumerable_filter;To;4;5F;6;;;;&I",Enumerator::Lazy#_enumerable_filter_map;F;7[;[[@i;F;:_enumerable_filter_map;;;[;{;IC; " ;T;[;![;"@;#0;$@`;%@`;:I"def _enumerable_filter_map;To;4;5F;6;;;;&I"(Enumerator::Lazy#_enumerable_reject;F;7[;[[@i;F;:_enumerable_reject;;;[;{;IC; " ;T;[;![;"@;#0;$@`;%@`;:I"def _enumerable_reject;To;4;5F;6;;;;&I"&Enumerator::Lazy#_enumerable_grep;F;7[;[[@i;F;:_enumerable_grep;;;[;{;IC; " ;T;[;![;"@;#0;$@`;%@`;:I"def _enumerable_grep;To;4;5F;6;;;;&I"(Enumerator::Lazy#_enumerable_grep_v;F;7[;[[@i;F;:_enumerable_grep_v;;;[;{;IC; " ;T;[;![;"@;#0;$@`;%@`;:I"def _enumerable_grep_v;To;4;5F;6;;;;&I"%Enumerator::Lazy#_enumerable_zip;F;7[;[[@i;F;:_enumerable_zip;;;[;{;IC; " ;T;[;![;"@;#0;$@ a;%@`;:I"def _enumerable_zip;To;4;5F;6;;;;&I"&Enumerator::Lazy#_enumerable_take;F;7[;[[@i;F;:_enumerable_take;;;[;{;IC; " ;T;[;![;"@;#0;$@a;%@`;:I"def _enumerable_take;To;4;5F;6;;;;&I",Enumerator::Lazy#_enumerable_take_while;F;7[;[[@i;F;:_enumerable_take_while;;;[;{;IC; " ;T;[;![;"@;#0;$@a;%@`;:I"def _enumerable_take_while;To;4;5F;6;;;;&I"&Enumerator::Lazy#_enumerable_drop;F;7[;[[@i;F;:_enumerable_drop;;;[;{;IC; " ;T;[;![;"@;#0;$@*a;%@`;:I"def _enumerable_drop;To;4;5F;6;;;;&I",Enumerator::Lazy#_enumerable_drop_while;F;7[;[[@i;F;:_enumerable_drop_while;;;[;{;IC; " ;T;[;![;"@;#0;$@5a;%@`;:I"def _enumerable_drop_while;To;4;5F;6;;;;&I"&Enumerator::Lazy#_enumerable_uniq;F;7[;[[@i;F;:_enumerable_uniq;;;[;{;IC; " ;T;[;![;"@;#0;$@@a;%@`;:I"def _enumerable_uniq;To;4;5F;6;;;;&I",Enumerator::Lazy#_enumerable_with_index;F;7[[@90;[[@i;T;:_enumerable_with_index;0;[;{;IC; "Iterates the given block for each element with an index, which starts from +offset+. If no block is given, returns a new Enumerator that includes the index, starting from +offset+ +offset+:: the starting index to use ;T;[o;= ;>I" overload;F;?0;:with_index;@0;:I"with_index(offset = 0);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" (*args);TI"idx;T;$@Ka;![;"I"@yield [(*args), idx];T;#0;$@Ka;.F;Bi;C0;7[[I" offset;TI"0;T;$@Kao;= ;>I" overload;F;?0;;H ;@0;:I"with_index(offset = 0);T;IC; ";T;[;![;"I";T;#0;$@Ka;.F;Bi;C0;7[[I" offset;TI"0;T;$@Ka;![;"I"7Iterates the given block for each element with an index, which starts from +offset+. If no block is given, returns a new Enumerator that includes the index, starting from +offset+ +offset+:: the starting index to use @overload with_index(offset = 0) @yield [(*args), idx] @overload with_index(offset = 0);T;#0;$@Ka;.F;/o;0;1T;2i;3i;%@`;9I"fstatic VALUE enumerator_with_index(int argc, VALUE *argv, VALUE obj) { VALUE memo; rb_check_arity(argc, 0, 1); RETURN_SIZED_ENUMERATOR(obj, argc, argv, enumerator_enum_size); memo = (!argc || NIL_P(memo = argv[0])) ? INT2FIX(0) : rb_to_int(memo); return enumerator_block_call(obj, enumerator_with_index_i, (VALUE)MEMO_NEW(memo, 0, 0)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Enumerator::Lazy#initialize;F;7[[@90;[[@i;T;;D;0;[;{;IC; "Creates a new Lazy enumerator. When the enumerator is actually enumerated (e.g. by calling #force), +obj+ will be enumerated and each value passed to the given block. The block can yield values back using +yielder+. For example, to create a "filter+map" enumerator: def filter_map(sequence) Lazy.new(sequence) do |yielder, *values| result = yield *values yielder << result if result end end filter_map(1..Float::INFINITY) {|i| i*i if i.even?}.first(5) #=> [4, 16, 36, 64, 100] ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(obj, size=nil);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" yielder;TI" *values;T;$@va;![;"I"@yield [yielder, *values];T;#0;$@va;.F;Bi;C0;7[[I"obj;T0[I" size;TI"nil;T;$@va;![;"I"5Creates a new Lazy enumerator. When the enumerator is actually enumerated (e.g. by calling #force), +obj+ will be enumerated and each value passed to the given block. The block can yield values back using +yielder+. For example, to create a "filter+map" enumerator: def filter_map(sequence) Lazy.new(sequence) do |yielder, *values| result = yield *values yielder << result if result end end filter_map(1..Float::INFINITY) {|i| i*i if i.even?}.first(5) #=> [4, 16, 36, 64, 100] @overload new(obj, size=nil) @yield [yielder, *values];T;#0;$@va;.F;/o;0;1T;2i;3i;%@`;9I"6static VALUE lazy_initialize(int argc, VALUE *argv, VALUE self) { VALUE obj, size = Qnil; VALUE generator; rb_check_arity(argc, 1, 2); if (!rb_block_given_p()) { rb_raise(rb_eArgError, "tried to call lazy new without a block"); } obj = argv[0]; if (argc > 1) { size = argv[1]; } generator = generator_allocate(rb_cGenerator); rb_block_call(generator, id_initialize, 0, 0, lazy_init_block_i, obj); enumerator_init(self, generator, sym_each, 0, 0, 0, size, 0); rb_ivar_set(self, id_receiver, obj); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#to_enum;F;7[[@90;[[@i;T;;y;0;[;{;IC; "^Similar to Object#to_enum, except it returns a lazy enumerator. This makes it easy to define Enumerable methods that will naturally remain lazy if called from a lazy enumerator. For example, continuing from the example in Object#to_enum: # See Object#to_enum for the definition of repeat r = 1..Float::INFINITY r.repeat(2).first(5) # => [1, 1, 2, 2, 3] r.repeat(2).class # => Enumerator r.repeat(2).map{|n| n ** 2}.first(5) # => endless loop! # works naturally on lazy enumerator: r.lazy.repeat(2).class # => Enumerator::Lazy r.lazy.repeat(2).map{|n| n ** 2}.first(5) # => [1, 1, 4, 4, 9] ;T;[ o;= ;>I" overload;F;?0;;y;@0;:I"#to_enum(method = :each, *args);T;IC; ";T;[;![;"I";T;#0;$@a;.F;Bi;C0;7[[I" method;TI" :each;T[I" *args;T0;$@ao;= ;>I" overload;F;?0;;z;@0;:I"$enum_for(method = :each, *args);T;IC; ";T;[;![;"I";T;#0;$@a;.F;Bi;C0;7[[I" method;TI" :each;T[I" *args;T0;$@ao;= ;>I" overload;F;?0;;y;@0;:I"#to_enum(method = :each, *args);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" *args;T;$@a;![;"I"@yield [*args];T;#0;$@a;.F;Bi;C0;7[[I" method;TI" :each;T[I" *args;T0;$@ao;= ;>I" overload;F;?0;;z;@0;:I"$enum_for(method = :each, *args);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" *args;T;$@a;![;"I"@yield [*args];T;#0;$@a;.F;Bi;C0;7[[I" method;TI" :each;T[I" *args;T0;$@a;![;"I"(Similar to Object#to_enum, except it returns a lazy enumerator. This makes it easy to define Enumerable methods that will naturally remain lazy if called from a lazy enumerator. For example, continuing from the example in Object#to_enum: # See Object#to_enum for the definition of repeat r = 1..Float::INFINITY r.repeat(2).first(5) # => [1, 1, 2, 2, 3] r.repeat(2).class # => Enumerator r.repeat(2).map{|n| n ** 2}.first(5) # => endless loop! # works naturally on lazy enumerator: r.lazy.repeat(2).class # => Enumerator::Lazy r.lazy.repeat(2).map{|n| n ** 2}.first(5) # => [1, 1, 4, 4, 9] @overload to_enum(method = :each, *args) @overload enum_for(method = :each, *args) @overload to_enum(method = :each, *args) @yield [*args] @overload enum_for(method = :each, *args) @yield [*args];T;#0;$@a;.F;/o;0;1T;2it;3i;%@`;9I"static VALUE lazy_to_enum(int argc, VALUE *argv, VALUE self) { VALUE lazy, meth = sym_each, super_meth; if (argc > 0) { --argc; meth = *argv++; } if (RTEST((super_meth = rb_hash_aref(lazy_use_super_method, meth)))) { meth = super_meth; } lazy = lazy_to_enum_i(self, meth, argc, argv, 0, rb_keyword_given_p()); if (rb_block_given_p()) { enumerator_ptr(lazy)->size = rb_block_proc(); } return lazy; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#enum_for;F;7[[@90;[[@i;T;;z;0;[;{;IC; "^Similar to Object#to_enum, except it returns a lazy enumerator. This makes it easy to define Enumerable methods that will naturally remain lazy if called from a lazy enumerator. For example, continuing from the example in Object#to_enum: # See Object#to_enum for the definition of repeat r = 1..Float::INFINITY r.repeat(2).first(5) # => [1, 1, 2, 2, 3] r.repeat(2).class # => Enumerator r.repeat(2).map{|n| n ** 2}.first(5) # => endless loop! # works naturally on lazy enumerator: r.lazy.repeat(2).class # => Enumerator::Lazy r.lazy.repeat(2).map{|n| n ** 2}.first(5) # => [1, 1, 4, 4, 9] ;T;[ o;= ;>I" overload;F;?0;;y;@0;:I"#to_enum(method = :each, *args);T;IC; ";T;[;![;"I";T;#0;$@a;.F;Bi;C0;7[[I" method;TI" :each;T[I" *args;T0;$@ao;= ;>I" overload;F;?0;;z;@0;:I"$enum_for(method = :each, *args);T;IC; ";T;[;![;"I";T;#0;$@a;.F;Bi;C0;7[[I" method;TI" :each;T[I" *args;T0;$@ao;= ;>I" overload;F;?0;;y;@0;:I"#to_enum(method = :each, *args);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" *args;T;$@a;![;"I"@yield [*args];T;#0;$@a;.F;Bi;C0;7[[I" method;TI" :each;T[I" *args;T0;$@ao;= ;>I" overload;F;?0;;z;@0;:I"$enum_for(method = :each, *args);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" *args;T;$@a;![;"I"@yield [*args];T;#0;$@a;.F;Bi;C0;7[[I" method;TI" :each;T[I" *args;T0;$@a;![;"@a;#0;$@a;.F;/o;0;1T;2it;3i;%@`;9I"static VALUE lazy_to_enum(int argc, VALUE *argv, VALUE self) { VALUE lazy, meth = sym_each, super_meth; if (argc > 0) { --argc; meth = *argv++; } if (RTEST((super_meth = rb_hash_aref(lazy_use_super_method, meth)))) { meth = super_meth; } lazy = lazy_to_enum_i(self, meth, argc, argv, 0, rb_keyword_given_p()); if (rb_block_given_p()) { enumerator_ptr(lazy)->size = rb_block_proc(); } return lazy; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#eager;F;7[;[[@i;T;: eager;0;[;{;IC; "FReturns a non-lazy Enumerator converted from the lazy enumerator. ;T;[o;= ;>I" overload;F;?0;;I ;@0;:I" eager;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@1b;![;"I"@return [Enumerator];T;#0;$@1b;.F;Bi;C0;7[;$@1b;![;"I"oReturns a non-lazy Enumerator converted from the lazy enumerator. @overload eager @return [Enumerator];T;#0;$@1b;.F;/o;0;1T;2i;3i;%@`;9I"static VALUE lazy_eager(VALUE self) { return enumerator_init(enumerator_allocate(rb_cEnumerator), self, sym_each, 0, 0, lazy_eager_size, Qnil, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#map;F;7[;[[@i;T;;;0;[;{;IC; "Like Enumerable#map, but chains operation to be lazy-evaluated. (1..Float::INFINITY).lazy.map {|i| i**2 } #=> #:map> (1..Float::INFINITY).lazy.map {|i| i**2 }.first(3) #=> [1, 4, 9] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" collect;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@Lb;![;"I"@yield [obj];T;#0;$@Lb;.F;Bi;C0;7[;$@Lbo;= ;>I" overload;F;?0;;;@0;:I"map;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@Lb;![;"I"@yield [obj];T;#0;$@Lb;.F;Bi;C0;7[;$@Lb;![;"I"5Like Enumerable#map, but chains operation to be lazy-evaluated. (1..Float::INFINITY).lazy.map {|i| i**2 } #=> #:map> (1..Float::INFINITY).lazy.map {|i| i**2 }.first(3) #=> [1, 4, 9] @overload collect @yield [obj] @overload map @yield [obj];T;#0;$@Lb;.F;/o;0;1T;2i;3i;%@`;9I"static VALUE lazy_map(VALUE obj) { if (!rb_block_given_p()) { rb_raise(rb_eArgError, "tried to call lazy map without a block"); } return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_map_funcs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#collect;F;7[;[[@i;T;;;0;[;{;IC; "Like Enumerable#map, but chains operation to be lazy-evaluated. (1..Float::INFINITY).lazy.map {|i| i**2 } #=> #:map> (1..Float::INFINITY).lazy.map {|i| i**2 }.first(3) #=> [1, 4, 9] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" collect;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@tb;![;"I"@yield [obj];T;#0;$@tb;.F;Bi;C0;7[;$@tbo;= ;>I" overload;F;?0;;;@0;:I"map;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@tb;![;"I"@yield [obj];T;#0;$@tb;.F;Bi;C0;7[;$@tb;![;"@pb;#0;$@tb;.F;/o;0;1T;2i;3i;%@`;9I"static VALUE lazy_map(VALUE obj) { if (!rb_block_given_p()) { rb_raise(rb_eArgError, "tried to call lazy map without a block"); } return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_map_funcs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#flat_map;F;7[;[[@i<;T;;;0;[;{;IC; ":Returns a new lazy enumerator with the concatenated results of running +block+ once for every element in the lazy enumerator. ["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force #=> ["f", "o", "o", "b", "a", "r"] A value +x+ returned by +block+ is decomposed if either of the following conditions is true: * +x+ responds to both each and force, which means that +x+ is a lazy enumerator. * +x+ is an array or responds to to_ary. Otherwise, +x+ is contained as-is in the return value. [{a:1}, {b:2}].lazy.flat_map {|i| i}.force #=> [{:a=>1}, {:b=>2}] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"collect_concat;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@b;![;"I"@yield [obj];T;#0;$@b;.F;Bi;C0;7[;$@bo;= ;>I" overload;F;?0;;;@0;:I" flat_map;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@b;![;"I"@yield [obj];T;#0;$@b;.F;Bi;C0;7[;$@b;![;"I"Returns a new lazy enumerator with the concatenated results of running +block+ once for every element in the lazy enumerator. ["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force #=> ["f", "o", "o", "b", "a", "r"] A value +x+ returned by +block+ is decomposed if either of the following conditions is true: * +x+ responds to both each and force, which means that +x+ is a lazy enumerator. * +x+ is an array or responds to to_ary. Otherwise, +x+ is contained as-is in the return value. [{a:1}, {b:2}].lazy.flat_map {|i| i}.force #=> [{:a=>1}, {:b=>2}] @overload collect_concat @yield [obj] @overload flat_map @yield [obj];T;#0;$@b;.F;/o;0;1T;2i%;3i;;%@`;9I"static VALUE lazy_flat_map(VALUE obj) { if (!rb_block_given_p()) { rb_raise(rb_eArgError, "tried to call lazy flat_map without a block"); } return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_flat_map_funcs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$Enumerator::Lazy#collect_concat;F;7[;[[@i<;T;;;0;[;{;IC; ":Returns a new lazy enumerator with the concatenated results of running +block+ once for every element in the lazy enumerator. ["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force #=> ["f", "o", "o", "b", "a", "r"] A value +x+ returned by +block+ is decomposed if either of the following conditions is true: * +x+ responds to both each and force, which means that +x+ is a lazy enumerator. * +x+ is an array or responds to to_ary. Otherwise, +x+ is contained as-is in the return value. [{a:1}, {b:2}].lazy.flat_map {|i| i}.force #=> [{:a=>1}, {:b=>2}] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"collect_concat;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@b;![;"I"@yield [obj];T;#0;$@b;.F;Bi;C0;7[;$@bo;= ;>I" overload;F;?0;;;@0;:I" flat_map;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@b;![;"I"@yield [obj];T;#0;$@b;.F;Bi;C0;7[;$@b;![;"@b;#0;$@b;.F;/o;0;1T;2i%;3i;;%@`;9I"static VALUE lazy_flat_map(VALUE obj) { if (!rb_block_given_p()) { rb_raise(rb_eArgError, "tried to call lazy flat_map without a block"); } return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_flat_map_funcs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#select;F;7[;[[@iZ;T;;;0;[;{;IC; "GLike Enumerable#select, but chains operation to be lazy-evaluated. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" find_all;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@b;![;"I"@yield [obj];T;#0;$@b;.F;Bi;C0;7[;$@bo;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@b;![;"I"@yield [obj];T;#0;$@b;.F;Bi;C0;7[;$@bo;= ;>I" overload;F;?0;;;@0;:I" filter;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@b;![;"I"@yield [obj];T;#0;$@b;.F;Bi;C0;7[;$@b;![;"I"Like Enumerable#select, but chains operation to be lazy-evaluated. @overload find_all @yield [obj] @overload select @yield [obj] @overload filter @yield [obj];T;#0;$@b;.F;/o;0;1T;2iR;3iZ;%@`;9I"static VALUE lazy_select(VALUE obj) { if (!rb_block_given_p()) { rb_raise(rb_eArgError, "tried to call lazy select without a block"); } return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_select_funcs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#find_all;F;7[;[[@iZ;T;;;0;[;{;IC; "GLike Enumerable#select, but chains operation to be lazy-evaluated. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" find_all;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@c;![;"I"@yield [obj];T;#0;$@c;.F;Bi;C0;7[;$@co;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@c;![;"I"@yield [obj];T;#0;$@c;.F;Bi;C0;7[;$@co;= ;>I" overload;F;?0;;;@0;:I" filter;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@c;![;"I"@yield [obj];T;#0;$@c;.F;Bi;C0;7[;$@c;![;"@c;#0;$@c;.F;/o;0;1T;2iR;3iZ;%@`;9I"static VALUE lazy_select(VALUE obj) { if (!rb_block_given_p()) { rb_raise(rb_eArgError, "tried to call lazy select without a block"); } return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_select_funcs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#filter;F;7[;[[@iZ;T;;;0;[;{;IC; "GLike Enumerable#select, but chains operation to be lazy-evaluated. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" find_all;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@Sc;![;"I"@yield [obj];T;#0;$@Sc;.F;Bi;C0;7[;$@Sco;= ;>I" overload;F;?0;;;@0;:I" select;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@Sc;![;"I"@yield [obj];T;#0;$@Sc;.F;Bi;C0;7[;$@Sco;= ;>I" overload;F;?0;;;@0;:I" filter;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@Sc;![;"I"@yield [obj];T;#0;$@Sc;.F;Bi;C0;7[;$@Sc;![;"@c;#0;$@Sc;.F;/o;0;1T;2iR;3iZ;%@`;9I"static VALUE lazy_select(VALUE obj) { if (!rb_block_given_p()) { rb_raise(rb_eArgError, "tried to call lazy select without a block"); } return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_select_funcs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Enumerator::Lazy#filter_map;F;7[;[[@i|;T;;;0;[;{;IC; "Like Enumerable#filter_map, but chains operation to be lazy-evaluated. (1..).lazy.filter_map { |i| i * 2 if i.even? }.first(5) #=> [4, 8, 12, 16, 20] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"filter_map;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@c;![;"I"@yield [obj];T;#0;$@c;.F;Bi;C0;7[;$@c;![;"I"Like Enumerable#filter_map, but chains operation to be lazy-evaluated. (1..).lazy.filter_map { |i| i * 2 if i.even? }.first(5) #=> [4, 8, 12, 16, 20] @overload filter_map @yield [obj];T;#0;$@c;.F;/o;0;1T;2ir;3iy;%@`;9I"static VALUE lazy_filter_map(VALUE obj) { if (!rb_block_given_p()) { rb_raise(rb_eArgError, "tried to call lazy filter_map without a block"); } return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_filter_map_funcs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#reject;F;7[;[[@i;T;;;0;[;{;IC; "GLike Enumerable#reject, but chains operation to be lazy-evaluated. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" reject;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@c;![;"I"@yield [obj];T;#0;$@c;.F;Bi;C0;7[;$@c;![;"I"iLike Enumerable#reject, but chains operation to be lazy-evaluated. @overload reject @yield [obj];T;#0;$@c;.F;/o;0;1T;2i;3i;%@`;9I"static VALUE lazy_reject(VALUE obj) { if (!rb_block_given_p()) { rb_raise(rb_eArgError, "tried to call lazy reject without a block"); } return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_reject_funcs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#grep;F;7[[I" pattern;T0;[[@i;T;;;0;[;{;IC; "ELike Enumerable#grep, but chains operation to be lazy-evaluated. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"grep(pattern);T;IC; ";T;[;![;"I";T;#0;$@c;.F;Bi;C0;7[[I" pattern;T0;$@co;= ;>I" overload;F;?0;;;@0;:I"grep(pattern);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@c;![;"I"@yield [obj];T;#0;$@c;.F;Bi;C0;7[[I" pattern;T0;$@c;![;"I"Like Enumerable#grep, but chains operation to be lazy-evaluated. @overload grep(pattern) @overload grep(pattern) @yield [obj];T;#0;$@c;.F;/o;0;1T;2i;3i;%@`;9I"static VALUE lazy_grep(VALUE obj, VALUE pattern) { const lazyenum_funcs *const funcs = rb_block_given_p() ? &lazy_grep_iter_funcs : &lazy_grep_funcs; return lazy_add_method(obj, 0, 0, pattern, rb_ary_new3(1, pattern), funcs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#grep_v;F;7[[I" pattern;T0;[[@i;T;;;0;[;{;IC; "GLike Enumerable#grep_v, but chains operation to be lazy-evaluated. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"grep_v(pattern);T;IC; ";T;[;![;"I";T;#0;$@c;.F;Bi;C0;7[[I" pattern;T0;$@co;= ;>I" overload;F;?0;;;@0;:I"grep_v(pattern);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@c;![;"I"@yield [obj];T;#0;$@c;.F;Bi;C0;7[[I" pattern;T0;$@c;![;"I"Like Enumerable#grep_v, but chains operation to be lazy-evaluated. @overload grep_v(pattern) @overload grep_v(pattern) @yield [obj];T;#0;$@c;.F;/o;0;1T;2i;3i;%@`;9I"static VALUE lazy_grep_v(VALUE obj, VALUE pattern) { const lazyenum_funcs *const funcs = rb_block_given_p() ? &lazy_grep_v_iter_funcs : &lazy_grep_v_funcs; return lazy_add_method(obj, 0, 0, pattern, rb_ary_new3(1, pattern), funcs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#zip;F;7[[@90;[[@iJ ;T;;;0;[;{;IC; "Like Enumerable#zip, but chains operation to be lazy-evaluated. However, if a block is given to zip, values are enumerated immediately. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"zip(arg, ...);T;IC; ";T;[;![;"I";T;#0;$@d;.F;Bi;C0;7[[I"arg;T0[I"...;T0;$@do;= ;>I" overload;F;?0;;;@0;:I"zip(arg, ...);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"arr;T;$@do;A ;>I" return;F;?I";T;0;@[I"nil;T;$@d;![;"I"@yield [arr] @return [nil];T;#0;$@d;.F;Bi;C0;7[[I"arg;T0[I"...;T0;$@d;![;"I"Like Enumerable#zip, but chains operation to be lazy-evaluated. However, if a block is given to zip, values are enumerated immediately. @overload zip(arg, ...) @overload zip(arg, ...) @yield [arr] @return [nil];T;#0;$@d;.F;/o;0;1T;2iB ;3iI ;%@`;9I"static VALUE lazy_zip(int argc, VALUE *argv, VALUE obj) { VALUE ary, v; long i; const lazyenum_funcs *funcs = &lazy_zip_funcs[1]; if (rb_block_given_p()) { return rb_call_super(argc, argv); } ary = rb_ary_new2(argc); for (i = 0; i < argc; i++) { v = rb_check_array_type(argv[i]); if (NIL_P(v)) { for (; i < argc; i++) { if (!rb_respond_to(argv[i], id_each)) { rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (must respond to :each)", rb_obj_class(argv[i])); } } ary = rb_ary_new4(argc, argv); funcs = &lazy_zip_funcs[0]; break; } rb_ary_push(ary, v); } return lazy_add_method(obj, 0, 0, ary, ary, funcs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#take;F;7[[I"n;T0;[[@i ;T;;;0;[;{;IC; "ELike Enumerable#take, but chains operation to be lazy-evaluated. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" take(n);T;IC; ";T;[;![;"I";T;#0;$@@d;.F;Bi;C0;7[[I"n;T0;$@@d;![;"I"YLike Enumerable#take, but chains operation to be lazy-evaluated. @overload take(n);T;#0;$@@d;.F;/o;0;1T;2i ;3i ;%@`;9I"~static VALUE lazy_take(VALUE obj, VALUE n) { long len = NUM2LONG(n); int argc = 0; VALUE argv[2]; if (len < 0) { rb_raise(rb_eArgError, "attempt to take negative size"); } if (len == 0) { argv[0] = sym_cycle; argv[1] = INT2NUM(0); argc = 2; } return lazy_add_method(obj, argc, argv, n, rb_ary_new3(1, n), &lazy_take_funcs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Enumerator::Lazy#take_while;F;7[;[[@i ;T;;;0;[;{;IC; "KLike Enumerable#take_while, but chains operation to be lazy-evaluated. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"take_while;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@Zd;![;"I"@yield [obj];T;#0;$@Zd;.F;Bi;C0;7[;$@Zd;![;"I"qLike Enumerable#take_while, but chains operation to be lazy-evaluated. @overload take_while @yield [obj];T;#0;$@Zd;.F;/o;0;1T;2i ;3i ;%@`;9I"static VALUE lazy_take_while(VALUE obj) { if (!rb_block_given_p()) { rb_raise(rb_eArgError, "tried to call lazy take_while without a block"); } return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_take_while_funcs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#drop;F;7[[I"n;T0;[[@i ;T;;;0;[;{;IC; "ELike Enumerable#drop, but chains operation to be lazy-evaluated. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" drop(n);T;IC; ";T;[;![;"I";T;#0;$@ud;.F;Bi;C0;7[[I"n;T0;$@ud;![;"I"YLike Enumerable#drop, but chains operation to be lazy-evaluated. @overload drop(n);T;#0;$@ud;.F;/o;0;1T;2i ;3i ;%@`;9I"-static VALUE lazy_drop(VALUE obj, VALUE n) { long len = NUM2LONG(n); VALUE argv[2]; argv[0] = sym_each; argv[1] = n; if (len < 0) { rb_raise(rb_eArgError, "attempt to drop negative size"); } return lazy_add_method(obj, 2, argv, n, rb_ary_new3(1, n), &lazy_drop_funcs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Enumerator::Lazy#drop_while;F;7[;[[@i ;T;;;0;[;{;IC; "KLike Enumerable#drop_while, but chains operation to be lazy-evaluated. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"drop_while;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"obj;T;$@d;![;"I"@yield [obj];T;#0;$@d;.F;Bi;C0;7[;$@d;![;"I"qLike Enumerable#drop_while, but chains operation to be lazy-evaluated. @overload drop_while @yield [obj];T;#0;$@d;.F;/o;0;1T;2i ;3i ;%@`;9I"static VALUE lazy_drop_while(VALUE obj) { if (!rb_block_given_p()) { rb_raise(rb_eArgError, "tried to call lazy drop_while without a block"); } return lazy_add_method(obj, 0, 0, Qfalse, Qnil, &lazy_drop_while_funcs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#lazy;F;7[;[[@i ;T;;;0;[;{;IC; "Returns self. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" lazy;T;IC; ";T;[;![;"I";T;#0;$@d;.F;Bi;C0;7[;$@d;![;"I"#Returns self. @overload lazy;T;#0;$@d;.F;/o;0;1T;2i ;3i ;%@`;9I":static VALUE lazy_lazy(VALUE obj) { return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#chunk;F;7[;[[@i [@i ;T;;;0;[;{;IC; "FLike Enumerable#chunk, but chains operation to be lazy-evaluated. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" chunk;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"elt;T;$@d;![;"I"@yield [elt];T;#0;$@d;.F;Bi;C0;7[;$@d;![;"I"gLike Enumerable#chunk, but chains operation to be lazy-evaluated. @overload chunk @yield [elt];T;#0;$@d;.F;/o;0;1T;2i ;3i ;%@`;9I"zstatic VALUE lazy_super(int argc, VALUE *argv, VALUE lazy) { return enumerable_lazy(rb_call_super(argc, argv)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""Enumerator::Lazy#slice_before;F;7[;[[@i [@i ;T;;;0;[;{;IC; "MLike Enumerable#slice_before, but chains operation to be lazy-evaluated. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"slice_before(pattern);T;IC; ";T;[;![;"I";T;#0;$@d;.F;Bi;C0;7[[I" pattern;T0;$@do;= ;>I" overload;F;?0;;;@0;:I"slice_before;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"elt;T;$@d;![;"I"@yield [elt];T;#0;$@d;.F;Bi;C0;7[;$@d;![;"I"Like Enumerable#slice_before, but chains operation to be lazy-evaluated. @overload slice_before(pattern) @overload slice_before @yield [elt];T;#0;$@d;.F;/o;0;1T;2i ;3i ;%@`;9I"zstatic VALUE lazy_super(int argc, VALUE *argv, VALUE lazy) { return enumerable_lazy(rb_call_super(argc, argv)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Enumerator::Lazy#slice_after;F;7[;[[@i [@i ;T;;;0;[;{;IC; "LLike Enumerable#slice_after, but chains operation to be lazy-evaluated. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"slice_after(pattern);T;IC; ";T;[;![;"I";T;#0;$@e;.F;Bi;C0;7[[I" pattern;T0;$@eo;= ;>I" overload;F;?0;;;@0;:I"slice_after;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"elt;T;$@e;![;"I"@yield [elt];T;#0;$@e;.F;Bi;C0;7[;$@e;![;"I"Like Enumerable#slice_after, but chains operation to be lazy-evaluated. @overload slice_after(pattern) @overload slice_after @yield [elt];T;#0;$@e;.F;/o;0;1T;2i ;3i ;%@`;9I"zstatic VALUE lazy_super(int argc, VALUE *argv, VALUE lazy) { return enumerable_lazy(rb_call_super(argc, argv)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Enumerator::Lazy#slice_when;F;7[;[[@i [@i ;T;;;0;[;{;IC; "KLike Enumerable#slice_when, but chains operation to be lazy-evaluated. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"slice_when;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"elt_before;TI"elt_after;T;$@(e;![;"I"#@yield [elt_before, elt_after];T;#0;$@(e;.F;Bi;C0;7[;$@(e;![;"I"~Like Enumerable#slice_when, but chains operation to be lazy-evaluated. @overload slice_when @yield [elt_before, elt_after];T;#0;$@(e;.F;/o;0;1T;2i ;3i ;%@`;9I"zstatic VALUE lazy_super(int argc, VALUE *argv, VALUE lazy) { return enumerable_lazy(rb_call_super(argc, argv)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Enumerator::Lazy#chunk_while;F;7[;[[@i [@i ;T;;;0;[;{;IC; "LLike Enumerable#chunk_while, but chains operation to be lazy-evaluated. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"chunk_while;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"elt_before;TI"elt_after;T;$@Ee;![;"I"#@yield [elt_before, elt_after];T;#0;$@Ee;.F;Bi;C0;7[;$@Ee;![;"I"Like Enumerable#chunk_while, but chains operation to be lazy-evaluated. @overload chunk_while @yield [elt_before, elt_after];T;#0;$@Ee;.F;/o;0;1T;2i ;3i ;%@`;9I"zstatic VALUE lazy_super(int argc, VALUE *argv, VALUE lazy) { return enumerable_lazy(rb_call_super(argc, argv)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#uniq;F;7[;[[@iV ;T;;;0;[;{;IC; "ELike Enumerable#uniq, but chains operation to be lazy-evaluated. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" uniq;T;IC; ";T;[;![;"I";T;#0;$@be;.F;Bi;C0;7[;$@beo;= ;>I" overload;F;?0;;;@0;:I" uniq;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" item;T;$@be;![;"I"@yield [item];T;#0;$@be;.F;Bi;C0;7[;$@be;![;"I"uLike Enumerable#uniq, but chains operation to be lazy-evaluated. @overload uniq @overload uniq @yield [item];T;#0;$@be;.F;/o;0;1T;2iN ;3iS ;%@`;9I"static VALUE lazy_uniq(VALUE obj) { const lazyenum_funcs *const funcs = rb_block_given_p() ? &lazy_uniq_iter_funcs : &lazy_uniq_funcs; return lazy_add_method(obj, 0, 0, Qnil, Qnil, funcs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#compact;F;7[;[[@ip ;T;;;0;[;{;IC; "HLike Enumerable#compact, but chains operation to be lazy-evaluated. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" compact;T;IC; ";T;[;![;"I";T;#0;$@e;.F;Bi;C0;7[;$@e;![;"I"\Like Enumerable#compact, but chains operation to be lazy-evaluated. @overload compact;T;#0;$@e;.F;/o;0;1T;2ii ;3il ;%@`;9I"ustatic VALUE lazy_compact(VALUE obj) { return lazy_add_method(obj, 0, 0, Qnil, Qnil, &lazy_compact_funcs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Enumerator::Lazy#with_index;F;7[[@90;[[@i ;T;;H ;0;[;{;IC; "If a block is given, returns a lazy enumerator that will iterate over the given block for each element with an index, which starts from +offset+, and returns a lazy enumerator that yields the same values (without the index). If a block is not given, returns a new lazy enumerator that includes the index, starting from +offset+. +offset+:: the starting index to use See Enumerator#with_index. ;T;[o;= ;>I" overload;F;?0;;H ;@0;:I"with_index(offset = 0);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" (*args);TI"idx;T;$@e;![;"I"@yield [(*args), idx];T;#0;$@e;.F;Bi;C0;7[[I" offset;TI"0;T;$@eo;= ;>I" overload;F;?0;;H ;@0;:I"with_index(offset = 0);T;IC; ";T;[;![;"I";T;#0;$@e;.F;Bi;C0;7[[I" offset;TI"0;T;$@e;![;"I"If a block is given, returns a lazy enumerator that will iterate over the given block for each element with an index, which starts from +offset+, and returns a lazy enumerator that yields the same values (without the index). If a block is not given, returns a new lazy enumerator that includes the index, starting from +offset+. +offset+:: the starting index to use See Enumerator#with_index. @overload with_index(offset = 0) @yield [(*args), idx] @overload with_index(offset = 0);T;#0;$@e;.F;/o;0;1T;2i ;3i ;%@`;9I"static VALUE lazy_with_index(int argc, VALUE *argv, VALUE obj) { VALUE memo; rb_scan_args(argc, argv, "01", &memo); if (NIL_P(memo)) memo = LONG2NUM(0); return lazy_add_method(obj, 0, 0, memo, rb_ary_new_from_values(1, &memo), &lazy_with_index_funcs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Lazy#to_a;F;7[;[[@i;T;;;0;[;{;IC; "@Expands +lazy+ enumerator to an array. See Enumerable#to_a. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_a;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@e;![;"I"@return [Array];T;#0;$@e;.F;Bi;C0;7[;$@eo;= ;>I" overload;F;?0;: force;@0;:I" force;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@e;![;"I"@return [Array];T;#0;$@e;.F;Bi;C0;7[;$@e;![;"I"Expands +lazy+ enumerator to an array. See Enumerable#to_a. @overload to_a @return [Array] @overload force @return [Array];T;#0;$o;4;5F;6;;;;&I"Enumerator::Lazy#force;F;7[;[[@iO;F;;J ;;;[;{;@e;%@`;9I"+static VALUE lazy_to_a(VALUE self) { };T;:I"'static VALUE lazy_to_a(VALUE self);T;.F;/o;0;1T;2i;3i;%@`;9I"+static VALUE lazy_to_a(VALUE self) { };T;:@e;;T@e; @`; IC;[; @`; IC;[; @`; IC;{;IC;{;T;IC;{;T;T;{@`;@`;@`;@`;@`;@`;@`;@`;@`;@`;@`;@ a;@a;@a;@*a;@5a;@@a;@e;;[;[[@i[@i;T;: Lazy;;;;;[;{;IC; "Enumerator::Lazy is a special type of Enumerator, that allows constructing chains of operations without evaluating them immediately, and evaluating values on as-needed basis. In order to do so it redefines most of Enumerable methods so that they just construct another lazy enumerator. Enumerator::Lazy can be constructed from any Enumerable with the Enumerable#lazy method. lazy = (1..Float::INFINITY).lazy.select(&:odd?).drop(10).take_while { |i| i < 30 } # => #:select>:drop(10)>:take_while> The real enumeration is performed when any non-redefined Enumerable method is called, like Enumerable#first or Enumerable#to_a (the latter is aliased as #force for more semantic code): lazy.first(2) #=> [21, 23] lazy.force #=> [21, 23, 25, 27, 29] Note that most Enumerable methods that could be called with or without a block, on Enumerator::Lazy will always require a block: [1, 2, 3].map #=> # [1, 2, 3].lazy.map # ArgumentError: tried to call lazy map without a block This class allows idiomatic calculations on long or infinite sequences, as well as chaining of calculations without constructing intermediate arrays. Example for working with a slowly calculated sequence: require 'open-uri' # This will fetch all URLs before selecting # necessary data URLS.map { |u| JSON.parse(URI.open(u).read) } .select { |data| data.key?('stats') } .first(5) # This will fetch URLs one-by-one, only till # there is enough data to satisfy the condition URLS.lazy.map { |u| JSON.parse(URI.open(u).read) } .select { |data| data.key?('stats') } .first(5) Ending a chain with ".eager" generates a non-lazy enumerator, which is suitable for returning or passing to another method that expects a normal enumerator. def active_items groups .lazy .flat_map(&:items) .reject(&:disabled) .eager end # This works lazily; if a checked item is found, it stops # iteration and does not look into remaining groups. first_checked = active_items.find(&:checked) # This returns an array of items like a normal enumerator does. all_checked = active_items.select(&:checked);T;[;![;"I" Enumerator::Lazy is a special type of Enumerator, that allows constructing chains of operations without evaluating them immediately, and evaluating values on as-needed basis. In order to do so it redefines most of Enumerable methods so that they just construct another lazy enumerator. Enumerator::Lazy can be constructed from any Enumerable with the Enumerable#lazy method. lazy = (1..Float::INFINITY).lazy.select(&:odd?).drop(10).take_while { |i| i < 30 } # => #:select>:drop(10)>:take_while> The real enumeration is performed when any non-redefined Enumerable method is called, like Enumerable#first or Enumerable#to_a (the latter is aliased as #force for more semantic code): lazy.first(2) #=> [21, 23] lazy.force #=> [21, 23, 25, 27, 29] Note that most Enumerable methods that could be called with or without a block, on Enumerator::Lazy will always require a block: [1, 2, 3].map #=> # [1, 2, 3].lazy.map # ArgumentError: tried to call lazy map without a block This class allows idiomatic calculations on long or infinite sequences, as well as chaining of calculations without constructing intermediate arrays. Example for working with a slowly calculated sequence: require 'open-uri' # This will fetch all URLs before selecting # necessary data URLS.map { |u| JSON.parse(URI.open(u).read) } .select { |data| data.key?('stats') } .first(5) # This will fetch URLs one-by-one, only till # there is enough data to satisfy the condition URLS.lazy.map { |u| JSON.parse(URI.open(u).read) } .select { |data| data.key?('stats') } .first(5) Ending a chain with ".eager" generates a non-lazy enumerator, which is suitable for returning or passing to another method that expects a normal enumerator. def active_items groups .lazy .flat_map(&:items) .reject(&:disabled) .eager end # This works lazily; if a checked item is found, it stops # iteration and does not look into remaining groups. first_checked = active_items.find(&:checked) # This returns an array of items like a normal enumerator does. all_checked = active_items.select(&:checked) ;T;#0;$@`;.F;/o;0;1T;2i;3i;Bi;%o;( ;)0;*0;+0;:Enumerator;%@;-@`;0;&I"Enumerator::Lazy;F;'@`o; ;IC;[ o;4;5F;6;;;;&I"!Enumerator::Chain#initialize;F;7[[I" enums;T0;[[@i; ;T;;D;0;[;{;IC; "Generates a new enumerator object that iterates over the elements of given enumerable objects in sequence. e = Enumerator::Chain.new(1..3, [4, 5]) e.to_a #=> [1, 2, 3, 4, 5] e.size #=> 5 ;T;[o;= ;>I" overload;F;?0;:Enumerator::Chain.new;@0;:I""Enumerator::Chain.new(*enums);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@ f;![;"I"@return [Enumerator];T;#0;$@ f;.F;Bi;C0;7[[I" *enums;T0;$@ f;![;"I"Generates a new enumerator object that iterates over the elements of given enumerable objects in sequence. e = Enumerator::Chain.new(1..3, [4, 5]) e.to_a #=> [1, 2, 3, 4, 5] e.size #=> 5 @overload Enumerator::Chain.new(*enums) @return [Enumerator];T;#0;$@ f;.F;/o;0;1T;2i0 ;3i9 ;%@ f;9I"Kstatic VALUE enum_chain_initialize(VALUE obj, VALUE enums) { struct enum_chain *ptr; rb_check_frozen(obj); TypedData_Get_Struct(obj, struct enum_chain, &enum_chain_data_type, ptr); if (!ptr) rb_raise(rb_eArgError, "unallocated chain"); ptr->enums = rb_obj_freeze(enums); ptr->pos = -1; return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&Enumerator::Chain#initialize_copy;F;7[[I" orig;T0;[[@i[ ;T;;];0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@*f;.F;/o;0;1T;2iZ ;3iZ ;%@ f;9I"static VALUE enum_chain_init_copy(VALUE obj, VALUE orig) { struct enum_chain *ptr0, *ptr1; if (!OBJ_INIT_COPY(obj, orig)) return obj; ptr0 = enum_chain_ptr(orig); TypedData_Get_Struct(obj, struct enum_chain, &enum_chain_data_type, ptr1); if (!ptr1) rb_raise(rb_eArgError, "unallocated chain"); ptr1->enums = ptr0->enums; ptr1->pos = ptr0->pos; return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Chain#each;F;7[[@90;[[@i ;T;;;0;[;{;IC; "Iterates over the elements of the first enumerable by calling the "each" method on it with the given arguments, then proceeds to the following enumerables in sequence until all of the enumerables are exhausted. If no block is given, returns an enumerator. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"each(*args);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"...;T;$@:fo;A ;>I" return;F;?I";T;0;@[I" Object;T;$@:f;![;"I""@yield [...] @return [Object];T;#0;$@:f;.F;Bi;C0;7[[I" *args;T0;$@:fo;= ;>I" overload;F;?0;;;@0;:I"each(*args);T;IC; ";T;[;![;"I";T;#0;$@:f;.F;Bi;C0;7[[I" *args;T0;$@:f;![;"I"PIterates over the elements of the first enumerable by calling the "each" method on it with the given arguments, then proceeds to the following enumerables in sequence until all of the enumerables are exhausted. If no block is given, returns an enumerator. @overload each(*args) @yield [...] @return [Object] @overload each(*args);T;#0;$@:f;.F;/o;0;1T;2i ;3i ;%@ f;9I"static VALUE enum_chain_each(int argc, VALUE *argv, VALUE obj) { VALUE enums, block; struct enum_chain *objptr; long i; RETURN_SIZED_ENUMERATOR(obj, argc, argv, argc > 0 ? enum_chain_enum_no_size : enum_chain_enum_size); objptr = enum_chain_ptr(obj); enums = objptr->enums; block = rb_block_proc(); for (i = 0; i < RARRAY_LEN(enums); i++) { objptr->pos = i; rb_funcall_with_block(RARRAY_AREF(enums, i), id_each, argc, argv, block); } return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Chain#size;F;7[;[[@i ;T;;;0;[;{;IC; "Returns the total size of the enumerator chain calculated by summing up the size of each enumerable in the chain. If any of the enumerables reports its size as nil or Float::INFINITY, that value is returned as the total size. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"Float::INFINITY;TI"nil;T;$@gf;![;"I"-@return [Integer, Float::INFINITY, nil];T;#0;$@gf;.F;Bi;C0;7[;$@gf;![;"I"Returns the total size of the enumerator chain calculated by summing up the size of each enumerable in the chain. If any of the enumerables reports its size as nil or Float::INFINITY, that value is returned as the total size. @overload size @return [Integer, Float::INFINITY, nil];T;#0;$@gf;.F;/o;0;1T;2i ;3i ;%@ f;9I"nstatic VALUE enum_chain_size(VALUE obj) { return enum_chain_total_size(enum_chain_ptr(obj)->enums); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Chain#rewind;F;7[;[[@i ;T;;;0;[;{;IC; "Rewinds the enumerator chain by calling the "rewind" method on each enumerable in reverse order. Each call is performed only if the enumerable responds to the method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" rewind;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@f;![;"I"@return [Object];T;#0;$@f;.F;Bi;C0;7[;$@f;![;"I"Rewinds the enumerator chain by calling the "rewind" method on each enumerable in reverse order. Each call is performed only if the enumerable responds to the method. @overload rewind @return [Object];T;#0;$@f;.F;/o;0;1T;2i ;3i ;%@ f;9I"9static VALUE enum_chain_rewind(VALUE obj) { struct enum_chain *objptr = enum_chain_ptr(obj); VALUE enums = objptr->enums; long i; for (i = objptr->pos; 0 <= i && i < RARRAY_LEN(enums); objptr->pos = --i) { rb_check_funcall(RARRAY_AREF(enums, i), id_rewind, 0, 0); } return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Chain#inspect;F;7[;[[@i ;T;;J;0;[;{;IC; "9Returns a printable version of the enumerator chain. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@f;![;"I"@return [String];T;#0;$@f;.F;Bi;C0;7[;$@f;![;"I"`Returns a printable version of the enumerator chain. @overload inspect @return [String];T;#0;$@f;.F;/o;0;1T;2i ;3i ;%@ f;9I"mstatic VALUE enum_chain_inspect(VALUE obj) { return rb_exec_recursive(inspect_enum_chain, obj, 0); };T;:I"static VALUE;T;;T; @ f; IC;[; @ f; IC;[; @ f; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i [@ik;T;: Chain;;;;;[;{;IC; "Enumerator::Chain is a subclass of Enumerator, which represents a chain of enumerables that works as a single enumerator. This type of objects can be created by Enumerable#chain and Enumerator#+.;T;[;![;"I" Enumerator::Chain is a subclass of Enumerator, which represents a chain of enumerables that works as a single enumerator. This type of objects can be created by Enumerable#chain and Enumerator#+. ;T;#0;$@ f;.F;/o;0;1T;2i ;3i ;Bi;%o;( ;)0;*0;+0;;L ;%@;-@`;0;&I"Enumerator::Chain;F;'@`o; ;IC;[o;4;5F;6;;;;&I")Enumerator::ArithmeticSequence#begin;F;7[;[;F;;2;;;[;{;IC; " ;T;[;![;"@;#0;$@f;%@f;;To;4;5F;6;;;;&I"'Enumerator::ArithmeticSequence#end;F;7[;[;F;;3;;;[;{;IC; " ;T;[;![;"@;#0;$@f;%@f;;To;4;5F;6;;;;&I"0Enumerator::ArithmeticSequence#exclude_end?;F;7[;[;F;;* ;;;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@f;![;"@;#0;$@f;Bi;%@f;;To;4;5F;6;;;;&I"(Enumerator::ArithmeticSequence#step;F;7[;[;F;;;;;[;{;IC; " ;T;[;![;"@;#0;$@f;%@f;;To;4;5F;6;;;;&I")Enumerator::ArithmeticSequence#first;F;7[[@90;[[@i ;T;;;0;[;{;IC; "aReturns the first number in this arithmetic sequence, or an array of the first +n+ elements. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" first;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;TI"nil;T;$@f;![;"I"@return [Numeric, nil];T;#0;$@f;.F;Bi;C0;7[;$@fo;= ;>I" overload;F;?0;;;@0;:I" first(n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@f;![;"I"@return [Array];T;#0;$@f;.F;Bi;C0;7[[I"n;T0;$@f;![;"I"Returns the first number in this arithmetic sequence, or an array of the first +n+ elements. @overload first @return [Numeric, nil] @overload first(n) @return [Array];T;#0;$@f;.F;/o;0;1T;2i ;3i ;%@f;9I"%static VALUE arith_seq_first(int argc, VALUE *argv, VALUE self) { VALUE b, e, s, ary; long n; int x; rb_check_arity(argc, 0, 1); b = arith_seq_begin(self); e = arith_seq_end(self); s = arith_seq_step(self); if (argc == 0) { if (NIL_P(b)) { return Qnil; } if (!NIL_P(e)) { VALUE zero = INT2FIX(0); int r = rb_cmpint(rb_num_coerce_cmp(s, zero, idCmp), s, zero); if (r > 0 && RTEST(rb_funcall(b, '>', 1, e))) { return Qnil; } if (r < 0 && RTEST(rb_funcall(b, '<', 1, e))) { return Qnil; } } return b; } // TODO: the following code should be extracted as arith_seq_take n = NUM2LONG(argv[0]); if (n < 0) { rb_raise(rb_eArgError, "attempt to take negative size"); } if (n == 0) { return rb_ary_new_capa(0); } x = arith_seq_exclude_end_p(self); if (FIXNUM_P(b) && NIL_P(e) && FIXNUM_P(s)) { long i = FIX2LONG(b), unit = FIX2LONG(s); ary = rb_ary_new_capa(n); while (n > 0 && FIXABLE(i)) { rb_ary_push(ary, LONG2FIX(i)); i += unit; // FIXABLE + FIXABLE never overflow; --n; } if (n > 0) { b = LONG2NUM(i); while (n > 0) { rb_ary_push(ary, b); b = rb_big_plus(b, s); --n; } } return ary; } else if (FIXNUM_P(b) && FIXNUM_P(e) && FIXNUM_P(s)) { long i = FIX2LONG(b); long end = FIX2LONG(e); long unit = FIX2LONG(s); long len; if (unit >= 0) { if (!x) end += 1; len = end - i; if (len < 0) len = 0; ary = rb_ary_new_capa((n < len) ? n : len); while (n > 0 && i < end) { rb_ary_push(ary, LONG2FIX(i)); if (i + unit < i) break; i += unit; --n; } } else { if (!x) end -= 1; len = i - end; if (len < 0) len = 0; ary = rb_ary_new_capa((n < len) ? n : len); while (n > 0 && i > end) { rb_ary_push(ary, LONG2FIX(i)); if (i + unit > i) break; i += unit; --n; } } return ary; } else if (RB_FLOAT_TYPE_P(b) || RB_FLOAT_TYPE_P(e) || RB_FLOAT_TYPE_P(s)) { /* generate values like ruby_float_step */ double unit = NUM2DBL(s); double beg = NUM2DBL(b); double end = NIL_P(e) ? (unit < 0 ? -1 : 1)*HUGE_VAL : NUM2DBL(e); double len = ruby_float_step_size(beg, end, unit, x); long i; if (n > len) n = (long)len; if (isinf(unit)) { if (len > 0) { ary = rb_ary_new_capa(1); rb_ary_push(ary, DBL2NUM(beg)); } else { ary = rb_ary_new_capa(0); } } else if (unit == 0) { VALUE val = DBL2NUM(beg); ary = rb_ary_new_capa(n); for (i = 0; i < len; ++i) { rb_ary_push(ary, val); } } else { ary = rb_ary_new_capa(n); for (i = 0; i < n; ++i) { double d = i*unit+beg; if (unit >= 0 ? end < d : d < end) d = end; rb_ary_push(ary, DBL2NUM(d)); } } return ary; } return rb_call_super(argc, argv); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(Enumerator::ArithmeticSequence#last;F;7[[@90;[[@i;T;;;0;[;{;IC; "_Returns the last number in this arithmetic sequence, or an array of the last +n+ elements. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" last;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;TI"nil;T;$@"g;![;"I"@return [Numeric, nil];T;#0;$@"g;.F;Bi;C0;7[;$@"go;= ;>I" overload;F;?0;;;@0;:I" last(n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@"g;![;"I"@return [Array];T;#0;$@"g;.F;Bi;C0;7[[I"n;T0;$@"g;![;"I"Returns the last number in this arithmetic sequence, or an array of the last +n+ elements. @overload last @return [Numeric, nil] @overload last(n) @return [Array];T;#0;$@"g;.F;/o;0;1T;2i;3i;%@f;9I"Qstatic VALUE arith_seq_last(int argc, VALUE *argv, VALUE self) { VALUE b, e, s, len_1, len, last, nv, ary; int last_is_adjusted; long n; e = arith_seq_end(self); if (NIL_P(e)) { rb_raise(rb_eRangeError, "cannot get the last element of endless arithmetic sequence"); } b = arith_seq_begin(self); s = arith_seq_step(self); len_1 = num_idiv(num_minus(e, b), s); if (rb_num_negative_int_p(len_1)) { if (argc == 0) { return Qnil; } return rb_ary_new_capa(0); } last = num_plus(b, num_mul(s, len_1)); if ((last_is_adjusted = arith_seq_exclude_end_p(self) && rb_equal(last, e))) { last = num_minus(last, s); } if (argc == 0) { return last; } if (last_is_adjusted) { len = len_1; } else { len = rb_int_plus(len_1, INT2FIX(1)); } rb_scan_args(argc, argv, "1", &nv); if (!RB_INTEGER_TYPE_P(nv)) { nv = rb_to_int(nv); } if (RTEST(rb_int_gt(nv, len))) { nv = len; } n = NUM2LONG(nv); if (n < 0) { rb_raise(rb_eArgError, "negative array size"); } ary = rb_ary_new_capa(n); b = rb_int_minus(last, rb_int_mul(s, nv)); while (n) { b = rb_int_plus(b, s); rb_ary_push(ary, b); --n; } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+Enumerator::ArithmeticSequence#inspect;F;7[;[[@i;T;;J;0;[;{;IC; ":Convert this arithmetic sequence to a printable form. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@Ng;![;"I"@return [String];T;#0;$@Ng;.F;Bi;C0;7[;$@Ng;![;"I"aConvert this arithmetic sequence to a printable form. @overload inspect @return [String];T;#0;$@Ng;.F;/o;0;1T;2i;3i;%@f;9I"static VALUE arith_seq_inspect(VALUE self) { struct enumerator *e; VALUE eobj, str, eargs; int range_p; TypedData_Get_Struct(self, struct enumerator, &enumerator_data_type, e); eobj = rb_attr_get(self, id_receiver); if (NIL_P(eobj)) { eobj = e->obj; } range_p = RTEST(rb_obj_is_kind_of(eobj, rb_cRange)); str = rb_sprintf("(%s%"PRIsVALUE"%s.", range_p ? "(" : "", eobj, range_p ? ")" : ""); rb_str_buf_append(str, rb_id2str(e->meth)); eargs = rb_attr_get(eobj, id_arguments); if (NIL_P(eargs)) { eargs = e->args; } if (eargs != Qfalse) { long argc = RARRAY_LEN(eargs); const VALUE *argv = RARRAY_CONST_PTR(eargs); /* WB: no new reference */ if (argc > 0) { VALUE kwds = Qnil; rb_str_buf_cat2(str, "("); if (RB_TYPE_P(argv[argc-1], T_HASH)) { int all_key = TRUE; rb_hash_foreach(argv[argc-1], key_symbol_p, (VALUE)&all_key); if (all_key) kwds = argv[--argc]; } while (argc--) { VALUE arg = *argv++; rb_str_append(str, rb_inspect(arg)); rb_str_buf_cat2(str, ", "); } if (!NIL_P(kwds)) { rb_hash_foreach(kwds, kwd_append, str); } rb_str_set_len(str, RSTRING_LEN(str)-2); /* drop the last ", " */ rb_str_buf_cat2(str, ")"); } } rb_str_buf_cat2(str, ")"); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&Enumerator::ArithmeticSequence#==;F;7[[I" other;T0;[[@i ;T;;F;0;[;{;IC; "Returns true only if +obj+ is an Enumerator::ArithmeticSequence, has equivalent begin, end, step, and exclude_end? settings. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I" ==(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ig;![;"I"@return [Boolean];T;#0;$@ig;.F;Bi;C0;7[[I"obj;T0;$@ig;![;"I"Returns true only if +obj+ is an Enumerator::ArithmeticSequence, has equivalent begin, end, step, and exclude_end? settings. @overload ==(obj) @return [Boolean];T;#0;$@ig;.F;/o;0;1T;2i;3i ;%@f;9I")static VALUE arith_seq_eq(VALUE self, VALUE other) { if (!RTEST(rb_obj_is_kind_of(other, rb_cArithSeq))) { return Qfalse; } if (!rb_equal(arith_seq_begin(self), arith_seq_begin(other))) { return Qfalse; } if (!rb_equal(arith_seq_end(self), arith_seq_end(other))) { return Qfalse; } if (!rb_equal(arith_seq_step(self), arith_seq_step(other))) { return Qfalse; } if (arith_seq_exclude_end_p(self) != arith_seq_exclude_end_p(other)) { return Qfalse; } return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'Enumerator::ArithmeticSequence#===;F;7[[I" other;T0;[[@i ;T;;S;0;[;{;IC; "Returns true only if +obj+ is an Enumerator::ArithmeticSequence, has equivalent begin, end, step, and exclude_end? settings. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I" ==(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@g;![;"I"@return [Boolean];T;#0;$@g;.F;Bi;C0;7[[I"obj;T0;$@g;![;"@g;#0;$@g;.F;/o;0;1T;2i;3i ;%@f;9I")static VALUE arith_seq_eq(VALUE self, VALUE other) { if (!RTEST(rb_obj_is_kind_of(other, rb_cArithSeq))) { return Qfalse; } if (!rb_equal(arith_seq_begin(self), arith_seq_begin(other))) { return Qfalse; } if (!rb_equal(arith_seq_end(self), arith_seq_end(other))) { return Qfalse; } if (!rb_equal(arith_seq_step(self), arith_seq_step(other))) { return Qfalse; } if (arith_seq_exclude_end_p(self) != arith_seq_exclude_end_p(other)) { return Qfalse; } return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(Enumerator::ArithmeticSequence#eql?;F;7[[I" other;T0;[[@i ;T;;V;0;[;{;IC; "Returns true only if +obj+ is an Enumerator::ArithmeticSequence, has equivalent begin, end, step, and exclude_end? settings.;T;[o;= ;>I" overload;F;?0;;F;@0;:I" ==(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@g;![;"I"@return [Boolean];T;#0;$@g;.F;Bi;C0;7[[I"obj;T0;$@g;![;"@g;#0;$@g;.F;/o;0;1T;2i;3i ;Bi;%@f;9I")static VALUE arith_seq_eq(VALUE self, VALUE other) { if (!RTEST(rb_obj_is_kind_of(other, rb_cArithSeq))) { return Qfalse; } if (!rb_equal(arith_seq_begin(self), arith_seq_begin(other))) { return Qfalse; } if (!rb_equal(arith_seq_end(self), arith_seq_end(other))) { return Qfalse; } if (!rb_equal(arith_seq_step(self), arith_seq_step(other))) { return Qfalse; } if (arith_seq_exclude_end_p(self) != arith_seq_exclude_end_p(other)) { return Qfalse; } return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(Enumerator::ArithmeticSequence#hash;F;7[;[[@i0;T;;X;0;[;{;IC; "Compute a hash-value for this arithmetic sequence. Two arithmetic sequences with same begin, end, step, and exclude_end? values will generate the same hash-value. See also Object#hash. ;T;[o;= ;>I" overload;F;?0;;X;@0;:I" hash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@g;![;"I"@return [Integer];T;#0;$@g;.F;Bi;C0;7[;$@g;![;"I"Compute a hash-value for this arithmetic sequence. Two arithmetic sequences with same begin, end, step, and exclude_end? values will generate the same hash-value. See also Object#hash. @overload hash @return [Integer];T;#0;$@g;.F;/o;0;1T;2i&;3i.;%@f;9I"static VALUE arith_seq_hash(VALUE self) { st_index_t hash; VALUE v; hash = rb_hash_start(arith_seq_exclude_end_p(self)); v = rb_hash(arith_seq_begin(self)); hash = rb_hash_uint(hash, NUM2LONG(v)); v = rb_hash(arith_seq_end(self)); hash = rb_hash_uint(hash, NUM2LONG(v)); v = rb_hash(arith_seq_step(self)); hash = rb_hash_uint(hash, NUM2LONG(v)); hash = rb_hash_end(hash); return ST2FIX(hash); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(Enumerator::ArithmeticSequence#each;F;7[;[[@iP;T;;;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I" each;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"i;T;$@g;![;"I"@yield [i];T;#0;$@g;.F;Bi;C0;7[;$@go;= ;>I" overload;F;?0;;;@0;:I" each;T;IC; ";T;[;![;"I";T;#0;$@g;.F;Bi;C0;7[;$@g;![;"I"0 @overload each @yield [i] @overload each;T;#0;$@g;.F;/o;0;1T;2iK;3iN;%@f;9I"#static VALUE arith_seq_each(VALUE self) { VALUE c, e, s, len_1, last; int x; if (!rb_block_given_p()) return self; c = arith_seq_begin(self); e = arith_seq_end(self); s = arith_seq_step(self); x = arith_seq_exclude_end_p(self); if (!RB_TYPE_P(s, T_COMPLEX) && ruby_float_step(c, e, s, x, TRUE)) { return self; } if (NIL_P(e)) { while (1) { rb_yield(c); c = rb_int_plus(c, s); } return self; } if (rb_equal(s, INT2FIX(0))) { while (1) { rb_yield(c); } return self; } len_1 = num_idiv(num_minus(e, c), s); last = num_plus(c, num_mul(s, len_1)); if (x && rb_equal(last, e)) { last = num_minus(last, s); } if (rb_num_negative_int_p(s)) { while (NUM_GE(c, last)) { rb_yield(c); c = num_plus(c, s); } } else { while (NUM_GE(last, c)) { rb_yield(c); c = num_plus(c, s); } } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(Enumerator::ArithmeticSequence#size;F;7[;[[@i;T;;;0;[;{;IC; "|Returns the number of elements in this arithmetic sequence if it is a finite sequence. Otherwise, returns nil. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;TI"nil;T;$@h;![;"I"@return [Numeric, nil];T;#0;$@h;.F;Bi;C0;7[;$@h;![;"I"Returns the number of elements in this arithmetic sequence if it is a finite sequence. Otherwise, returns nil. @overload size @return [Numeric, nil];T;#0;$@h;.F;/o;0;1T;2i;3i;%@f;9I"static VALUE arith_seq_size(VALUE self) { VALUE b, e, s, len_1, len, last; int x; b = arith_seq_begin(self); e = arith_seq_end(self); s = arith_seq_step(self); x = arith_seq_exclude_end_p(self); if (RB_FLOAT_TYPE_P(b) || RB_FLOAT_TYPE_P(e) || RB_FLOAT_TYPE_P(s)) { double ee, n; if (NIL_P(e)) { if (rb_num_negative_int_p(s)) { ee = -HUGE_VAL; } else { ee = HUGE_VAL; } } else { ee = NUM2DBL(e); } n = ruby_float_step_size(NUM2DBL(b), ee, NUM2DBL(s), x); if (isinf(n)) return DBL2NUM(n); if (POSFIXABLE(n)) return LONG2FIX((long)n); return rb_dbl2big(n); } if (NIL_P(e)) { return DBL2NUM(HUGE_VAL); } if (!rb_obj_is_kind_of(s, rb_cNumeric)) { s = rb_to_int(s); } if (rb_equal(s, INT2FIX(0))) { return DBL2NUM(HUGE_VAL); } len_1 = rb_int_idiv(rb_int_minus(e, b), s); if (rb_num_negative_int_p(len_1)) { return INT2FIX(0); } last = rb_int_plus(b, rb_int_mul(s, len_1)); if (x && rb_equal(last, e)) { len = len_1; } else { len = rb_int_plus(len_1, INT2FIX(1)); } return len; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"/Enumerator::ArithmeticSequence.__extract__;F;7[[I"obj;T0;[[I"+ext/-test-/arith_seq/extract/extract.c;Ti;T;:__extract__;0;[;{;IC; " ;T;[;![;"@;#0;$@h;%@f;9I"static VALUE arith_seq_s_extract(VALUE mod, VALUE obj) { rb_arithmetic_sequence_components_t x; VALUE ret; int r; r = rb_arithmetic_sequence_extract(obj, &x); ret = rb_ary_new2(5); rb_ary_store(ret, 0, r ? x.begin : Qnil); rb_ary_store(ret, 1, r ? x.end : Qnil); rb_ary_store(ret, 2, r ? x.step : Qnil); rb_ary_store(ret, 3, r ? INT2FIX(x.exclude_end) : Qnil); rb_ary_store(ret, 4, INT2FIX(r)); return ret; };T;:I"static VALUE;T;;T; @f; IC;[; @f; IC;[; @f; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i [@iz;T;:ArithmeticSequence;;;;;[;{;IC; "+Enumerator::ArithmeticSequence is a subclass of Enumerator, that is a representation of sequences of numbers with common difference. Instances of this class can be generated by the Range#step and Numeric#step methods. The class can be used for slicing Array (see Array#slice) or custom collections.;T;[;![;"I"- Enumerator::ArithmeticSequence is a subclass of Enumerator, that is a representation of sequences of numbers with common difference. Instances of this class can be generated by the Range#step and Numeric#step methods. The class can be used for slicing Array (see Array#slice) or custom collections. ;T;#0;$@f;.F;/o;0;1T;2i ;3i ;Bi;%o;( ;)0;*0;+0;;L ;%@;-@`;0;&I"#Enumerator::ArithmeticSequence;F;'@`o;4;5F;6;;;;&I"Enumerator#initialize;F;7[[@90;[[@i;T;;D;0;[;{;IC; "ACreates a new Enumerator object, which can be used as an Enumerable. Iteration is defined by the given block, in which a "yielder" object, given as block parameter, can be used to yield a value by calling the +yield+ method (aliased as <<): fib = Enumerator.new do |y| a = b = 1 loop do y << a a, b = b, a + b end end fib.take(10) # => [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] The optional parameter can be used to specify how to calculate the size in a lazy fashion (see Enumerator#size). It can either be a value or a callable object. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(size = nil);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" yielder;T;$@@h;![;"I"@yield [yielder];T;#0;$@@h;.F;Bi;C0;7[[I" size;TI"nil;T;$@@h;![;"I"pCreates a new Enumerator object, which can be used as an Enumerable. Iteration is defined by the given block, in which a "yielder" object, given as block parameter, can be used to yield a value by calling the +yield+ method (aliased as <<): fib = Enumerator.new do |y| a = b = 1 loop do y << a a, b = b, a + b end end fib.take(10) # => [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] The optional parameter can be used to specify how to calculate the size in a lazy fashion (see Enumerator#size). It can either be a value or a callable object. @overload new(size = nil) @yield [yielder];T;#0;$@@h;.F;/o;0;1T;2i;3i;%@`;9I"qstatic VALUE enumerator_initialize(int argc, VALUE *argv, VALUE obj) { VALUE iter = rb_block_proc(); VALUE recv = generator_init(generator_allocate(rb_cGenerator), iter); VALUE arg0 = rb_check_arity(argc, 0, 1) ? argv[0] : Qnil; VALUE size = convert_to_feasible_size_value(arg0); return enumerator_init(obj, recv, sym_each, 0, 0, 0, size, false); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator#initialize_copy;F;7[[I" orig;T0;[[@i;T;;];0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@_h;.F;/o;0;1T;2i;3i;%@`;9I"static VALUE enumerator_init_copy(VALUE obj, VALUE orig) { struct enumerator *ptr0, *ptr1; if (!OBJ_INIT_COPY(obj, orig)) return obj; ptr0 = enumerator_ptr(orig); if (ptr0->fib) { /* Fibers cannot be copied */ rb_raise(rb_eTypeError, "can't copy execution context"); } TypedData_Get_Struct(obj, struct enumerator, &enumerator_data_type, ptr1); if (!ptr1) { rb_raise(rb_eArgError, "unallocated enumerator"); } ptr1->obj = ptr0->obj; ptr1->meth = ptr0->meth; ptr1->args = ptr0->args; ptr1->fib = 0; ptr1->lookahead = Qundef; ptr1->feedvalue = Qundef; ptr1->size = ptr0->size; ptr1->size_fn = ptr0->size_fn; return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator#each;F;7[[@90;[[@iP;T;;;0;[;{;IC; ">Iterates over the block according to how this Enumerator was constructed. If no block and no arguments are given, returns self. === Examples "Hello, world!".scan(/\w+/) #=> ["Hello", "world"] "Hello, world!".to_enum(:scan, /\w+/).to_a #=> ["Hello", "world"] "Hello, world!".to_enum(:scan).each(/\w+/).to_a #=> ["Hello", "world"] obj = Object.new def obj.each_arg(a, b=:b, *rest) yield a yield b yield rest :method_returned end enum = obj.to_enum :each_arg, :a, :x enum.each.to_a #=> [:a, :x, []] enum.each.equal?(enum) #=> true enum.each { |elm| elm } #=> :method_returned enum.each(:y, :z).to_a #=> [:a, :x, [:y, :z]] enum.each(:y, :z).equal?(enum) #=> false enum.each(:y, :z) { |elm| elm } #=> :method_returned ;T;[ o;= ;>I" overload;F;?0;;;@0;:I" each;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"elm;T;$@oho;A ;>I" return;F;?I";T;0;@[I" Object;T;$@oh;![;"I""@yield [elm] @return [Object];T;#0;$@oh;.F;Bi;C0;7[;$@oho;= ;>I" overload;F;?0;;;@0;:I" each;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@oh;![;"I"@return [Enumerator];T;#0;$@oh;.F;Bi;C0;7[;$@oho;= ;>I" overload;F;?0;;;@0;:I"each(*appending_args);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"elm;T;$@oho;A ;>I" return;F;?I";T;0;@[I" Object;T;$@oh;![;"I""@yield [elm] @return [Object];T;#0;$@oh;.F;Bi;C0;7[[I"*appending_args;T0;$@oho;= ;>I" overload;F;?0;;;@0;:I"each(*appending_args);T;IC; ";T;[;![;"I";T;#0;$@oh;.F;Bi;C0;7[[I"*appending_args;T0;$@oh;![;"I"Iterates over the block according to how this Enumerator was constructed. If no block and no arguments are given, returns self. === Examples "Hello, world!".scan(/\w+/) #=> ["Hello", "world"] "Hello, world!".to_enum(:scan, /\w+/).to_a #=> ["Hello", "world"] "Hello, world!".to_enum(:scan).each(/\w+/).to_a #=> ["Hello", "world"] obj = Object.new def obj.each_arg(a, b=:b, *rest) yield a yield b yield rest :method_returned end enum = obj.to_enum :each_arg, :a, :x enum.each.to_a #=> [:a, :x, []] enum.each.equal?(enum) #=> true enum.each { |elm| elm } #=> :method_returned enum.each(:y, :z).to_a #=> [:a, :x, [:y, :z]] enum.each(:y, :z).equal?(enum) #=> false enum.each(:y, :z) { |elm| elm } #=> :method_returned @overload each @yield [elm] @return [Object] @overload each @return [Enumerator] @overload each(*appending_args) @yield [elm] @return [Object] @overload each(*appending_args);T;#0;$@oh;.F;/o;0;1T;2i,;3iR;%@`;9I"?static VALUE enumerator_each(int argc, VALUE *argv, VALUE obj) { if (argc > 0) { struct enumerator *e = enumerator_ptr(obj = rb_obj_dup(obj)); VALUE args = e->args; if (args) { #if SIZEOF_INT < SIZEOF_LONG /* check int range overflow */ rb_long2int(RARRAY_LEN(args) + argc); #endif args = rb_ary_dup(args); rb_ary_cat(args, argv, argc); } else { args = rb_ary_new4(argc, argv); } e->args = args; e->size = Qnil; e->size_fn = 0; } if (!rb_block_given_p()) return obj; return enumerator_block_call(obj, 0, obj); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator#each_with_index;F;7[;[[@i;T;;;0;[;{;IC; "Same as Enumerator#with_index(0), i.e. there is no starting offset. If no block is given, a new Enumerator is returned that includes the index. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"each_with_index;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" (*args);TI"idx;T;$@h;![;"I"@yield [(*args), idx];T;#0;$@h;.F;Bi;C0;7[;$@ho;= ;>I" overload;F;?0;;;@0;:I"each_with_index;T;IC; ";T;[;![;"I";T;#0;$@h;.F;Bi;C0;7[;$@h;![;"I"Same as Enumerator#with_index(0), i.e. there is no starting offset. If no block is given, a new Enumerator is returned that includes the index. @overload each_with_index @yield [(*args), idx] @overload each_with_index;T;#0;$@h;.F;/o;0;1T;2i;3i;%@`;9I"kstatic VALUE enumerator_each_with_index(VALUE obj) { return enumerator_with_index(0, NULL, obj); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Enumerator#each_with_object;F;7[[I" memo;T0;[[@i;T;;;0;[;{;IC; "Iterates the given block for each element with an arbitrary object, +obj+, and returns +obj+ If no block is given, returns a new Enumerator. === Example to_three = Enumerator.new do |y| 3.times do |x| y << x end end to_three_with_string = to_three.with_object("foo") to_three_with_string.each do |x,string| puts "#{string}: #{x}" end # => foo: 0 # => foo: 1 # => foo: 2 ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"each_with_object(obj);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" (*args);TI"obj;T;$@h;![;"I"@yield [(*args), obj];T;#0;$@h;.F;Bi;C0;7[[I"obj;T0;$@ho;= ;>I" overload;F;?0;;;@0;:I"each_with_object(obj);T;IC; ";T;[;![;"I";T;#0;$@h;.F;Bi;C0;7[[I"obj;T0;$@ho;= ;>I" overload;F;?0;:with_object;@0;:I"with_object(obj);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" (*args);TI"obj;T;$@h;![;"I"@yield [(*args), obj];T;#0;$@h;.F;Bi;C0;7[[I"obj;T0;$@ho;= ;>I" overload;F;?0;;Q ;@0;:I"with_object(obj);T;IC; ";T;[;![;"I";T;#0;$@h;.F;Bi;C0;7[[I"obj;T0;$@h;![;"I"@Iterates the given block for each element with an arbitrary object, +obj+, and returns +obj+ If no block is given, returns a new Enumerator. === Example to_three = Enumerator.new do |y| 3.times do |x| y << x end end to_three_with_string = to_three.with_object("foo") to_three_with_string.each do |x,string| puts "#{string}: #{x}" end # => foo: 0 # => foo: 1 # => foo: 2 @overload each_with_object(obj) @yield [(*args), obj] @overload each_with_object(obj) @overload with_object(obj) @yield [(*args), obj] @overload with_object(obj);T;#0;$@h;.F;/o;0;1T;2i;3i;%@`;9I"static VALUE enumerator_with_object(VALUE obj, VALUE memo) { RETURN_SIZED_ENUMERATOR(obj, 1, &memo, enumerator_enum_size); enumerator_block_call(obj, enumerator_with_object_i, memo); return memo; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator#with_index;F;7[[@90;[[@i;T;;H ;0;[;{;IC; "Iterates the given block for each element with an index, which starts from +offset+. If no block is given, returns a new Enumerator that includes the index, starting from +offset+ +offset+:: the starting index to use ;T;[o;= ;>I" overload;F;?0;;H ;@0;:I"with_index(offset = 0);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" (*args);TI"idx;T;$@#i;![;"I"@yield [(*args), idx];T;#0;$@#i;.F;Bi;C0;7[[I" offset;TI"0;T;$@#io;= ;>I" overload;F;?0;;H ;@0;:I"with_index(offset = 0);T;IC; ";T;[;![;"I";T;#0;$@#i;.F;Bi;C0;7[[I" offset;TI"0;T;$@#i;![;"@ra;#0;$@#i;.F;/o;0;1T;2i;3i;%@`;9I"fstatic VALUE enumerator_with_index(int argc, VALUE *argv, VALUE obj) { VALUE memo; rb_check_arity(argc, 0, 1); RETURN_SIZED_ENUMERATOR(obj, argc, argv, enumerator_enum_size); memo = (!argc || NIL_P(memo = argv[0])) ? INT2FIX(0) : rb_to_int(memo); return enumerator_block_call(obj, enumerator_with_index_i, (VALUE)MEMO_NEW(memo, 0, 0)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator#with_object;F;7[[I" memo;T0;[[@i;T;;Q ;0;[;{;IC; "Iterates the given block for each element with an arbitrary object, +obj+, and returns +obj+ If no block is given, returns a new Enumerator. === Example to_three = Enumerator.new do |y| 3.times do |x| y << x end end to_three_with_string = to_three.with_object("foo") to_three_with_string.each do |x,string| puts "#{string}: #{x}" end # => foo: 0 # => foo: 1 # => foo: 2 ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"each_with_object(obj);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" (*args);TI"obj;T;$@Mi;![;"I"@yield [(*args), obj];T;#0;$@Mi;.F;Bi;C0;7[[I"obj;T0;$@Mio;= ;>I" overload;F;?0;;;@0;:I"each_with_object(obj);T;IC; ";T;[;![;"I";T;#0;$@Mi;.F;Bi;C0;7[[I"obj;T0;$@Mio;= ;>I" overload;F;?0;;Q ;@0;:I"with_object(obj);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" (*args);TI"obj;T;$@Mi;![;"I"@yield [(*args), obj];T;#0;$@Mi;.F;Bi;C0;7[[I"obj;T0;$@Mio;= ;>I" overload;F;?0;;Q ;@0;:I"with_object(obj);T;IC; ";T;[;![;"I";T;#0;$@Mi;.F;Bi;C0;7[[I"obj;T0;$@Mi;![;"@i;#0;$@Mi;.F;/o;0;1T;2i;3i;%@`;9I"static VALUE enumerator_with_object(VALUE obj, VALUE memo) { RETURN_SIZED_ENUMERATOR(obj, 1, &memo, enumerator_enum_size); enumerator_block_call(obj, enumerator_with_object_i, memo); return memo; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator#next_values;F;7[;[[@i?;T;:next_values;0;[;{;IC; "UReturns the next object as an array in the enumerator, and move the internal position forward. When the position reached at the end, StopIteration is raised. See class-level notes about external iterators. This method can be used to distinguish yield and yield nil. === Example o = Object.new def o.each yield yield 1 yield 1, 2 yield nil yield [1, 2] end e = o.to_enum p e.next_values p e.next_values p e.next_values p e.next_values p e.next_values e = o.to_enum p e.next p e.next p e.next p e.next p e.next ## yield args next_values next # yield [] nil # yield 1 [1] 1 # yield 1, 2 [1, 2] [1, 2] # yield nil [nil] nil # yield [1, 2] [[1, 2]] [1, 2] ;T;[o;= ;>I" overload;F;?0;;R ;@0;:I"next_values;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@i;![;"I"@return [Array];T;#0;$@i;.F;Bi;C0;7[;$@i;![;"I"Returns the next object as an array in the enumerator, and move the internal position forward. When the position reached at the end, StopIteration is raised. See class-level notes about external iterators. This method can be used to distinguish yield and yield nil. === Example o = Object.new def o.each yield yield 1 yield 1, 2 yield nil yield [1, 2] end e = o.to_enum p e.next_values p e.next_values p e.next_values p e.next_values p e.next_values e = o.to_enum p e.next p e.next p e.next p e.next p e.next ## yield args next_values next # yield [] nil # yield 1 [1] 1 # yield 1, 2 [1, 2] [1, 2] # yield nil [nil] nil # yield [1, 2] [[1, 2]] [1, 2] @overload next_values @return [Array];T;#0;$@i;.F;/o;0;1T;2i;3i<;%@`;9I" static VALUE enumerator_next_values(VALUE obj) { struct enumerator *e = enumerator_ptr(obj); VALUE vs; if (e->lookahead != Qundef) { vs = e->lookahead; e->lookahead = Qundef; return vs; } return get_next_values(obj, e); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator#peek_values;F;7[;[[@i;T;:peek_values;0;[;{;IC; " Returns the next object as an array, similar to Enumerator#next_values, but doesn't move the internal position forward. If the position is already at the end, StopIteration is raised. See class-level notes about external iterators. === Example o = Object.new def o.each yield yield 1 yield 1, 2 end e = o.to_enum p e.peek_values #=> [] e.next p e.peek_values #=> [1] p e.peek_values #=> [1] e.next p e.peek_values #=> [1, 2] e.next p e.peek_values # raises StopIteration ;T;[o;= ;>I" overload;F;?0;;S ;@0;:I"peek_values;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@i;![;"I"@return [Array];T;#0;$@i;.F;Bi;C0;7[;$@i;![;"I"8Returns the next object as an array, similar to Enumerator#next_values, but doesn't move the internal position forward. If the position is already at the end, StopIteration is raised. See class-level notes about external iterators. === Example o = Object.new def o.each yield yield 1 yield 1, 2 end e = o.to_enum p e.peek_values #=> [] e.next p e.peek_values #=> [1] p e.peek_values #=> [1] e.next p e.peek_values #=> [1, 2] e.next p e.peek_values # raises StopIteration @overload peek_values @return [Array];T;#0;$@i;.F;/o;0;1T;2i;3i;%@`;9I"mstatic VALUE enumerator_peek_values_m(VALUE obj) { return rb_ary_dup(enumerator_peek_values(obj)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator#next;F;7[;[[@iv;T;;;0;[;{;IC; "KReturns the next object in the enumerator, and move the internal position forward. When the position reached at the end, StopIteration is raised. === Example a = [1,2,3] e = a.to_enum p e.next #=> 1 p e.next #=> 2 p e.next #=> 3 p e.next #raises StopIteration See class-level notes about external iterators. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" next;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@i;![;"I"@return [Object];T;#0;$@i;.F;Bi;C0;7[;$@i;![;"I"pReturns the next object in the enumerator, and move the internal position forward. When the position reached at the end, StopIteration is raised. === Example a = [1,2,3] e = a.to_enum p e.next #=> 1 p e.next #=> 2 p e.next #=> 3 p e.next #raises StopIteration See class-level notes about external iterators. @overload next @return [Object];T;#0;$@i;.F;/o;0;1T;2ib;3is;%@`;9I"vstatic VALUE enumerator_next(VALUE obj) { VALUE vs = enumerator_next_values(obj); return ary2sv(vs, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator#peek;F;7[;[[@i;T;;;0;[;{;IC; "Returns the next object in the enumerator, but doesn't move the internal position forward. If the position is already at the end, StopIteration is raised. See class-level notes about external iterators. === Example a = [1,2,3] e = a.to_enum p e.next #=> 1 p e.peek #=> 2 p e.peek #=> 2 p e.peek #=> 2 p e.next #=> 2 p e.next #=> 3 p e.peek #raises StopIteration ;T;[o;= ;>I" overload;F;?0;;;@0;:I" peek;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@i;![;"I"@return [Object];T;#0;$@i;.F;Bi;C0;7[;$@i;![;"I"Returns the next object in the enumerator, but doesn't move the internal position forward. If the position is already at the end, StopIteration is raised. See class-level notes about external iterators. === Example a = [1,2,3] e = a.to_enum p e.next #=> 1 p e.peek #=> 2 p e.peek #=> 2 p e.peek #=> 2 p e.next #=> 2 p e.next #=> 3 p e.peek #raises StopIteration @overload peek @return [Object];T;#0;$@i;.F;/o;0;1T;2i;3i;%@`;9I"vstatic VALUE enumerator_peek(VALUE obj) { VALUE vs = enumerator_peek_values(obj); return ary2sv(vs, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator#feed;F;7[[I"v;T0;[[@i;T;: feed;0;[;{;IC; "BSets the value to be returned by the next yield inside +e+. If the value is not set, the yield returns nil. This value is cleared after being yielded. # Array#map passes the array's elements to "yield" and collects the # results of "yield" as an array. # Following example shows that "next" returns the passed elements and # values passed to "feed" are collected as an array which can be # obtained by StopIteration#result. e = [1,2,3].map p e.next #=> 1 e.feed "a" p e.next #=> 2 e.feed "b" p e.next #=> 3 e.feed "c" begin e.next rescue StopIteration p $!.result #=> ["a", "b", "c"] end o = Object.new def o.each x = yield # (2) blocks p x # (5) => "foo" x = yield # (6) blocks p x # (8) => nil x = yield # (9) blocks p x # not reached w/o another e.next end e = o.to_enum e.next # (1) e.feed "foo" # (3) e.next # (4) e.next # (7) # (10) ;T;[o;= ;>I" overload;F;?0;:obj;@0;:I"obj;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@i;![;"I"@return [nil];T;#0;$@i;.F;Bi;C0;7[;$@i;![;"I"bSets the value to be returned by the next yield inside +e+. If the value is not set, the yield returns nil. This value is cleared after being yielded. # Array#map passes the array's elements to "yield" and collects the # results of "yield" as an array. # Following example shows that "next" returns the passed elements and # values passed to "feed" are collected as an array which can be # obtained by StopIteration#result. e = [1,2,3].map p e.next #=> 1 e.feed "a" p e.next #=> 2 e.feed "b" p e.next #=> 3 e.feed "c" begin e.next rescue StopIteration p $!.result #=> ["a", "b", "c"] end o = Object.new def o.each x = yield # (2) blocks p x # (5) => "foo" x = yield # (6) blocks p x # (8) => nil x = yield # (9) blocks p x # not reached w/o another e.next end e = o.to_enum e.next # (1) e.feed "foo" # (3) e.next # (4) e.next # (7) # (10) @overload obj @return [nil];T;#0;$@i;.F;/o;0;1T;2i;3i;%@`;9I"static VALUE enumerator_feed(VALUE obj, VALUE v) { struct enumerator *e = enumerator_ptr(obj); if (e->feedvalue != Qundef) { rb_raise(rb_eTypeError, "feed value already set"); } e->feedvalue = v; return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator#rewind;F;7[;[[@i;T;;;0;[;{;IC; "|Rewinds the enumeration sequence to the beginning. If the enclosed object responds to a "rewind" method, it is called. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" rewind;T;IC; ";T;[;![;"I";T;#0;$@j;.F;Bi;C0;7[;$@j;![;"I"Rewinds the enumeration sequence to the beginning. If the enclosed object responds to a "rewind" method, it is called. @overload rewind;T;#0;$@j;.F;/o;0;1T;2i;3i ;%@`;9I"static VALUE enumerator_rewind(VALUE obj) { struct enumerator *e = enumerator_ptr(obj); rb_check_funcall(e->obj, id_rewind, 0, 0); e->fib = 0; e->dst = Qnil; e->lookahead = Qundef; e->feedvalue = Qundef; e->stop_exc = Qfalse; return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator#inspect;F;7[;[[@i;T;;J;0;[;{;IC; "-Creates a printable version of e. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@/j;![;"I"@return [String];T;#0;$@/j;.F;Bi;C0;7[;$@/j;![;"I"TCreates a printable version of e. @overload inspect @return [String];T;#0;$@/j;.F;/o;0;1T;2i;3i;%@`;9I"mstatic VALUE enumerator_inspect(VALUE obj) { return rb_exec_recursive(inspect_enumerator, obj, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator#size;F;7[;[[@i;T;;;0;[;{;IC; "Returns the size of the enumerator, or +nil+ if it can't be calculated lazily. (1..100).to_a.permutation(4).size # => 94109400 loop.size # => Float::INFINITY (1..100).drop_while.size # => nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"Float::INFINITY;TI"nil;T;$@Jj;![;"I"-@return [Integer, Float::INFINITY, nil];T;#0;$@Jj;.F;Bi;C0;7[;$@Jj;![;"I"Returns the size of the enumerator, or +nil+ if it can't be calculated lazily. (1..100).to_a.permutation(4).size # => 94109400 loop.size # => Float::INFINITY (1..100).drop_while.size # => nil @overload size @return [Integer, Float::INFINITY, nil];T;#0;$@Jj;.F;/o;0;1T;2i;3i;%@`;9I"static VALUE enumerator_size(VALUE obj) { struct enumerator *e = enumerator_ptr(obj); int argc = 0; const VALUE *argv = NULL; VALUE size; if (e->procs) { struct generator *g = generator_ptr(e->obj); VALUE receiver = rb_check_funcall(g->obj, id_size, 0, 0); long i = 0; for (i = 0; i < RARRAY_LEN(e->procs); i++) { VALUE proc = RARRAY_AREF(e->procs, i); struct proc_entry *entry = proc_entry_ptr(proc); lazyenum_size_func *size_fn = entry->fn->size; if (!size_fn) { return Qnil; } receiver = (*size_fn)(proc, receiver); } return receiver; } if (e->size_fn) { return (*e->size_fn)(e->obj, e->args, obj); } if (e->args) { argc = (int)RARRAY_LEN(e->args); argv = RARRAY_CONST_PTR(e->args); } size = rb_check_funcall_kw(e->size, id_call, argc, argv, e->kw_splat); if (size != Qundef) return size; return e->size; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator#+;F;7[[I" eobj;T0;[[@i ;T;;;0;[;{;IC; "Returns an enumerator object generated from this enumerator and a given enumerable. e = (1..3).each + [4, 5] e.to_a #=> [1, 2, 3, 4, 5] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" +(enum);T;IC; ";T;[;![;"I";T;#0;$@gj;.F;Bi;C0;7[[I" enum;T0;$@gj;![;"I"Returns an enumerator object generated from this enumerator and a given enumerable. e = (1..3).each + [4, 5] e.to_a #=> [1, 2, 3, 4, 5] @overload +(enum);T;#0;$@gj;.F;/o;0;1T;2i ;3i ;%@`;9I"{static VALUE enumerator_plus(VALUE obj, VALUE eobj) { return new_enum_chain(rb_ary_new_from_args(2, obj, eobj)); };T;:I"static VALUE;T;;To; ;IC;[o;4;5F;6;;;;&I"%Enumerator::Generator#initialize;F;7[[@90;[[@i;T;;D;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@j;.F;/o;0;1T;2i;3i;%@j;9I"static VALUE generator_initialize(int argc, VALUE *argv, VALUE obj) { VALUE proc; if (argc == 0) { rb_need_block(); proc = rb_block_proc(); } else { rb_scan_args(argc, argv, "1", &proc); if (!rb_obj_is_proc(proc)) rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (expected Proc)", rb_obj_class(proc)); if (rb_block_given_p()) { rb_warn("given block not used"); } } return generator_init(obj, proc); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*Enumerator::Generator#initialize_copy;F;7[[I" orig;T0;[[@i;T;;];0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@j;.F;/o;0;1T;2i;3i;%@j;9I"vstatic VALUE generator_init_copy(VALUE obj, VALUE orig) { struct generator *ptr0, *ptr1; if (!OBJ_INIT_COPY(obj, orig)) return obj; ptr0 = generator_ptr(orig); TypedData_Get_Struct(obj, struct generator, &generator_data_type, ptr1); if (!ptr1) { rb_raise(rb_eArgError, "unallocated generator"); } ptr1->proc = ptr0->proc; return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Generator#each;F;7[[@90;[[@i;T;;;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@j;.F;/o;0;1T;2i;3i;%@j;9I"@static VALUE generator_each(int argc, VALUE *argv, VALUE obj) { struct generator *ptr = generator_ptr(obj); VALUE args = rb_ary_new2(argc + 1); rb_ary_push(args, yielder_new()); if (argc > 0) { rb_ary_cat(args, argv, argc); } return rb_proc_call_kw(ptr->proc, args, RB_PASS_CALLED_KEYWORDS); };T;:I"static VALUE;T;;T; @j; IC;[; @j; IC;[@y,; @j; IC;{;IC;{;T;IC;{;T;T;{;[;[[@iU;F;:Generator;;;;;[;{;IC; " ;T;[;![;"@;#0;$@j;Bi;%@`;&I"Enumerator::Generator;F;'@o; ;IC;[ o;4;5F;6;;;;&I"#Enumerator::Yielder#initialize;F;7[;[[@i&;T;;D;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@j;.F;/o;0;1T;2i%;3i%;%@j;9I"xstatic VALUE yielder_initialize(VALUE obj) { rb_need_block(); return yielder_init(obj, rb_block_proc()); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Yielder#yield;F;7[[I" args;T0;[[@i/;T;: yield;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@j;.F;/o;0;1T;2i.;3i.;%@j;9I"static VALUE yielder_yield(VALUE obj, VALUE args) { struct yielder *ptr = yielder_ptr(obj); return rb_proc_call_kw(ptr->proc, args, RB_PASS_CALLED_KEYWORDS); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Enumerator::Yielder#<<;F;7[[I"arg;T0;[[@i8;T;;;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@j;.F;/o;0;1T;2i7;3i7;%@j;9I"static VALUE yielder_yield_push(VALUE obj, VALUE arg) { struct yielder *ptr = yielder_ptr(obj); rb_proc_call_with_block(ptr->proc, 1, &arg, Qnil); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Enumerator::Yielder#to_proc;F;7[;[[@iN;T;;;0;[;{;IC; "#Returns a Proc object that takes arguments and yields them. This method is implemented so that a Yielder object can be directly passed to another method as a block argument. enum = Enumerator.new { |y| Dir.glob("*.rb") { |file| File.open(file) { |f| f.each_line(&y) } } } ;T;[;![;"I"$Returns a Proc object that takes arguments and yields them. This method is implemented so that a Yielder object can be directly passed to another method as a block argument. enum = Enumerator.new { |y| Dir.glob("*.rb") { |file| File.open(file) { |f| f.each_line(&y) } } } ;T;#0;$@j;.F;/o;0;1T;2iB;3iL;%@j;9I"static VALUE yielder_to_proc(VALUE obj) { VALUE method = rb_obj_method(obj, sym_yield); return rb_funcall(method, idTo_proc, 0); };T;:I"static VALUE;T;;T; @j; IC;[; @j; IC;[; @j; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i];F;: Yielder;;;;;[;{;IC; " ;T;[;![;"@;#0;$@j;Bi;%@`;&I"Enumerator::Yielder;F;'@o; ;IC;[o;4;5F;6;;;;&I"Enumerator::Producer#each;F;7[;[[@i ;T;;;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@k;.F;/o;0;1T;2i ;3i ;%@ k;9I"static VALUE producer_each(VALUE obj) { rb_need_block(); return rb_rescue2(producer_each_i, obj, producer_each_stop, (VALUE)0, rb_eStopIteration, (VALUE)0); };T;:I"static VALUE;T;;T; @ k; IC;[; @ k; IC;[; @ k; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ie;F;: Producer;;;;;[;{;IC; " ;T;[;![;"@;#0;$@ k;Bi;%@`;&I"Enumerator::Producer;F;'@o;4;5F;6;;;;&I"Enumerator.produce;F;7[[@90;[[@i ;T;: produce;0;[;{;IC; "Creates an infinite enumerator from any block, just called over and over. The result of the previous iteration is passed to the next one. If +initial+ is provided, it is passed to the first iteration, and becomes the first element of the enumerator; if it is not provided, the first iteration receives +nil+, and its result becomes the first element of the iterator. Raising StopIteration from the block stops an iteration. Enumerator.produce(1, &:succ) # => enumerator of 1, 2, 3, 4, .... Enumerator.produce { rand(10) } # => infinite random number sequence ancestors = Enumerator.produce(node) { |prev| node = prev.parent or raise StopIteration } enclosing_section = ancestors.find { |n| n.type == :section } Using ::produce together with Enumerable methods like Enumerable#detect, Enumerable#slice_after, Enumerable#take_while can provide Enumerator-based alternatives for +while+ and +until+ cycles: # Find next Tuesday require "date" Enumerator.produce(Date.today, &:succ).detect(&:tuesday?) # Simple lexer: require "strscan" scanner = StringScanner.new("7+38/6") PATTERN = %r{\d+|[-/+*]} Enumerator.produce { scanner.scan(PATTERN) }.slice_after { scanner.eos? }.first # => ["7", "+", "38", "/", "6"] ;T;[o;= ;>I" overload;F;?0;;Z ;@0;:I"produce(initial = nil);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" prev;T;$@,k;![;"I"@yield [prev];T;#0;$@,k;.F;Bi;C0;7[[I" initial;TI"nil;T;$@,k;![;"I" Creates an infinite enumerator from any block, just called over and over. The result of the previous iteration is passed to the next one. If +initial+ is provided, it is passed to the first iteration, and becomes the first element of the enumerator; if it is not provided, the first iteration receives +nil+, and its result becomes the first element of the iterator. Raising StopIteration from the block stops an iteration. Enumerator.produce(1, &:succ) # => enumerator of 1, 2, 3, 4, .... Enumerator.produce { rand(10) } # => infinite random number sequence ancestors = Enumerator.produce(node) { |prev| node = prev.parent or raise StopIteration } enclosing_section = ancestors.find { |n| n.type == :section } Using ::produce together with Enumerable methods like Enumerable#detect, Enumerable#slice_after, Enumerable#take_while can provide Enumerator-based alternatives for +while+ and +until+ cycles: # Find next Tuesday require "date" Enumerator.produce(Date.today, &:succ).detect(&:tuesday?) # Simple lexer: require "strscan" scanner = StringScanner.new("7+38/6") PATTERN = %r{\d+|[-/+*]} Enumerator.produce { scanner.scan(PATTERN) }.slice_after { scanner.eos? }.first # => ["7", "+", "38", "/", "6"] @overload produce(initial = nil) @yield [prev];T;#0;$@,k;.F;/o;0;1T;2i ;3i ;%@`;9I"static VALUE enumerator_s_produce(int argc, VALUE *argv, VALUE klass) { VALUE init, producer; if (!rb_block_given_p()) rb_raise(rb_eArgError, "no block given"); if (rb_scan_args(argc, argv, "01", &init) == 0) { init = Qundef; } producer = producer_init(producer_allocate(rb_cEnumProducer), init, rb_block_proc()); return rb_enumeratorize_with_size_kw(producer, sym_each, 0, 0, producer_size, RB_NO_KEYWORDS); };T;:I"static VALUE;T;;T; @`; IC;[; @`; IC;[o;( ;)0;*0;+0;;;%@;-@y,;0; @`; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i%[@i;T;;L ;;;;;[;{;IC; "\ A class which allows both internal and external iteration. An Enumerator can be created by the following methods. - Object#to_enum - Object#enum_for - Enumerator.new Most methods have two forms: a block form where the contents are evaluated for each item in the enumeration, and a non-block form which returns a new Enumerator wrapping the iteration. enumerator = %w(one two three).each puts enumerator.class # => Enumerator enumerator.each_with_object("foo") do |item, obj| puts "#{obj}: #{item}" end # foo: one # foo: two # foo: three enum_with_obj = enumerator.each_with_object("foo") puts enum_with_obj.class # => Enumerator enum_with_obj.each do |item, obj| puts "#{obj}: #{item}" end # foo: one # foo: two # foo: three This allows you to chain Enumerators together. For example, you can map a list's elements to strings containing the index and the element as a string via: puts %w[foo bar baz].map.with_index { |w, i| "#{i}:#{w}" } # => ["0:foo", "1:bar", "2:baz"] An Enumerator can also be used as an external iterator. For example, Enumerator#next returns the next value of the iterator or raises StopIteration if the Enumerator is at the end. e = [1,2,3].each # returns an enumerator object. puts e.next # => 1 puts e.next # => 2 puts e.next # => 3 puts e.next # raises StopIteration Note that enumeration sequence by +next+, +next_values+, +peek+ and +peek_values+ do not affect other non-external enumeration methods, unless the underlying iteration method itself has side-effect, e.g. IO#each_line. Moreover, implementation typically uses fibers so performance could be slower and exception stacktraces different than expected. You can use this to implement an internal iterator as follows: def ext_each(e) while true begin vs = e.next_values rescue StopIteration return $!.result end y = yield(*vs) e.feed y end end o = Object.new def o.each puts yield puts yield(1) puts yield(1, 2) 3 end # use o.each as an internal iterator directly. puts o.each {|*x| puts x; [:b, *x] } # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3 # convert o.each to an external iterator for # implementing an internal iterator. puts ext_each(o.to_enum) {|*x| puts x; [:b, *x] } # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3;T;[;![;"I"_ A class which allows both internal and external iteration. An Enumerator can be created by the following methods. - Object#to_enum - Object#enum_for - Enumerator.new Most methods have two forms: a block form where the contents are evaluated for each item in the enumeration, and a non-block form which returns a new Enumerator wrapping the iteration. enumerator = %w(one two three).each puts enumerator.class # => Enumerator enumerator.each_with_object("foo") do |item, obj| puts "#{obj}: #{item}" end # foo: one # foo: two # foo: three enum_with_obj = enumerator.each_with_object("foo") puts enum_with_obj.class # => Enumerator enum_with_obj.each do |item, obj| puts "#{obj}: #{item}" end # foo: one # foo: two # foo: three This allows you to chain Enumerators together. For example, you can map a list's elements to strings containing the index and the element as a string via: puts %w[foo bar baz].map.with_index { |w, i| "#{i}:#{w}" } # => ["0:foo", "1:bar", "2:baz"] An Enumerator can also be used as an external iterator. For example, Enumerator#next returns the next value of the iterator or raises StopIteration if the Enumerator is at the end. e = [1,2,3].each # returns an enumerator object. puts e.next # => 1 puts e.next # => 2 puts e.next # => 3 puts e.next # raises StopIteration Note that enumeration sequence by +next+, +next_values+, +peek+ and +peek_values+ do not affect other non-external enumeration methods, unless the underlying iteration method itself has side-effect, e.g. IO#each_line. Moreover, implementation typically uses fibers so performance could be slower and exception stacktraces different than expected. You can use this to implement an internal iterator as follows: def ext_each(e) while true begin vs = e.next_values rescue StopIteration return $!.result end y = yield(*vs) e.feed y end end o = Object.new def o.each puts yield puts yield(1) puts yield(1, 2) 3 end # use o.each as an internal iterator directly. puts o.each {|*x| puts x; [:b, *x] } # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3 # convert o.each to an external iterator for # implementing an internal iterator. puts ext_each(o.to_enum) {|*x| puts x; [:b, *x] } # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3 ;T;#0;$@`;.F;/o;0;1T;2i%;3i{;Bi;%@;&I"Enumerator;F;'@o; ;IC;[o;4;5F;6;;;;&I"StopIteration#result;F;7[;[[@i/ ;T;: result;0;[;{;IC; "]Returns the return value of the iterator. o = Object.new def o.each yield 1 yield 2 yield 3 100 end e = o.to_enum puts e.next #=> 1 puts e.next #=> 2 puts e.next #=> 3 begin e.next rescue StopIteration => ex puts ex.result #=> 100 end ;T;[o;= ;>I" overload;F;?0;;[ ;@0;:I" result;T;IC; ";T;[;![;"I";T;#0;$@`k;.F;Bi;C0;7[;$@`k;![;"I"qReturns the return value of the iterator. o = Object.new def o.each yield 1 yield 2 yield 3 100 end e = o.to_enum puts e.next #=> 1 puts e.next #=> 2 puts e.next #=> 3 begin e.next rescue StopIteration => ex puts ex.result #=> 100 end @overload result;T;#0;$@`k;.F;/o;0;1T;2i ;3i+ ;%@^k;9I"Vstatic VALUE stop_result(VALUE self) { return rb_attr_get(self, id_result); };T;:I"static VALUE;T;;T; @^k; IC;[; @^k; IC;[; @^k; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i [@iQ;T;:StopIteration;;;;;[;{;IC; "Raised to stop the iteration, in particular by Enumerator#next. It is rescued by Kernel#loop. loop do puts "Hello" raise StopIteration puts "World" end puts "Done!" produces: Hello Done!;T;[;![;"I" Raised to stop the iteration, in particular by Enumerator#next. It is rescued by Kernel#loop. loop do puts "Hello" raise StopIteration puts "World" end puts "Done!" produces: Hello Done! ;T;#0;$@^k;.F;/o;0;1T;2i ;3i ;Bi;%@;&I"StopIteration;F;'o;( ;)0;*0;+0;:IndexError;%@;-o; ;IC;[; @k; IC;[; @k; IC;[; @k; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i [@)iU ;T;;] ;;;;;[;{;IC; "Raised when the given index is invalid. a = [:foo, :bar] a.fetch(0) #=> :foo a[4] #=> nil a.fetch(4) #=> IndexError: index 4 outside of array bounds: -2...2 ;T;[;![;"I" Raised when the given index is invalid. a = [:foo, :bar] a.fetch(0) #=> :foo a[4] #=> nil a.fetch(4) #=> IndexError: index 4 outside of array bounds: -2...2 ;T;#0;$@k;.F;/o;0;1T;2i ;3i ;%@;&I"IndexError;F;'@;;@y,o; ;IC;[ o;4;5F;6;;;;&I""UncaughtThrowError#initialize;F;7[[@90;[[@Ci;T;;D;0;[;{;IC; "Raised when +throw+ is called with a _tag_ which does not have corresponding +catch+ block. throw "foo", "bar" raises the exception: UncaughtThrowError: uncaught throw "foo" ;T;[;![;"I" Raised when +throw+ is called with a _tag_ which does not have corresponding +catch+ block. throw "foo", "bar" raises the exception: UncaughtThrowError: uncaught throw "foo" ;T;#0;$@k;.F;/o;0;1T;2i;3i;%@k;9I"static VALUE uncaught_throw_init(int argc, const VALUE *argv, VALUE exc) { rb_check_arity(argc, 2, UNLIMITED_ARGUMENTS); rb_call_super(argc - 2, argv + 2); rb_ivar_set(exc, id_tag, argv[0]); rb_ivar_set(exc, id_value, argv[1]); return exc; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UncaughtThrowError#tag;F;7[;[[@Ci;T;:tag;0;[;{;IC; "0Return the tag object which was called for. ;T;[o;= ;>I" overload;F;?0;;^ ;@0;:I"tag;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@k;![;"I"@return [Object];T;#0;$@k;.F;Bi;C0;7[;$@k;![;"I"SReturn the tag object which was called for. @overload tag @return [Object];T;#0;$@k;.F;/o;0;1T;2i;3i;%@k;9I"Xstatic VALUE uncaught_throw_tag(VALUE exc) { return rb_ivar_get(exc, id_tag); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UncaughtThrowError#value;F;7[;[[@Ci;T;;5;0;[;{;IC; "2Return the return value which was called for. ;T;[o;= ;>I" overload;F;?0;;5;@0;:I" value;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@k;![;"I"@return [Object];T;#0;$@k;.F;Bi;C0;7[;$@k;![;"I"WReturn the return value which was called for. @overload value @return [Object];T;#0;$@k;.F;/o;0;1T;2i;3i;%@k;9I"\static VALUE uncaught_throw_value(VALUE exc) { return rb_ivar_get(exc, id_value); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UncaughtThrowError#to_s;F;7[;[[@Ci;T;;G;0;[;{;IC; "6Returns formatted message with the inspected tag. ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@k;![;"I"@return [String];T;#0;$@k;.F;Bi;C0;7[;$@k;![;"I"ZReturns formatted message with the inspected tag. @overload to_s @return [String];T;#0;$@k;.F;/o;0;1T;2i;3i;%@k;9I"static VALUE uncaught_throw_to_s(VALUE exc) { VALUE mesg = rb_attr_get(exc, id_mesg); VALUE tag = uncaught_throw_tag(exc); return rb_str_format(1, &tag, mesg); };T;:I"static VALUE;T;;T; @k; IC;[; @k; IC;[; @k; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Ci[@Ci ;T;:UncaughtThrowError;;;;;[;{;IC; "Raised when +throw+ is called with a _tag_ which does not have corresponding +catch+ block. throw "foo", "bar" raises the exception: UncaughtThrowError: uncaught throw "foo";T;[;![;"@k;#0;$@k;.F;/o;0;1T;2i;3i;Bi;%@;&I"UncaughtThrowError;F;'o;( ;)0;*0;+0;;5;%@;-@/;;o;;IC;[ o;4;5F;6;;;;&I"Warning.[];F;7[[I" category;T0;[[@)i;T;;;0;[;{;IC; "5Returns the flag to show the warning messages for +category+. Supported categories are: +:deprecated+ :: deprecation warnings * assignment of non-nil value to $, and $; * keyword arguments * proc/lambda without block etc. +:experimental+ :: experimental features * Pattern matching ;T;[o;= ;>I" overload;F;?0;;;@0;:I"[](category);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@l;![;"I"@return [Boolean];T;#0;$@l;.F;Bi;C0;7[[I" category;T0;$@l;![;"I"bReturns the flag to show the warning messages for +category+. Supported categories are: +:deprecated+ :: deprecation warnings * assignment of non-nil value to $, and $; * keyword arguments * proc/lambda without block etc. +:experimental+ :: experimental features * Pattern matching @overload [](category) @return [Boolean];T;#0;$@l;.F;/o;0;1T;2i;3i;%@l;9I"static VALUE rb_warning_s_aref(VALUE mod, VALUE category) { rb_warning_category_t cat = rb_warning_category_from_name(category); return RBOOL(rb_warning_category_enabled_p(cat)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Warning.[]=;F;7[[I" category;T0[I" flag;T0;[[@)i;T;;8;0;[;{;IC; "NSets the warning flags for +category+. See Warning.[] for the categories. ;T;[o;= ;>I" overload;F;?0;;8;@0;:I"[]=(category);T;IC; ";T;[;![;"I";T;#0;$@2l;.F;Bi;C0;7[[I" category;T0;$@2l;![;"I"hSets the warning flags for +category+. See Warning.[] for the categories. @overload []=(category);T;#0;$@2l;.F;/o;0;1T;2i;3i;%@l;9I"Ostatic VALUE rb_warning_s_aset(VALUE mod, VALUE category, VALUE flag) { unsigned int mask = rb_warning_category_mask(category); unsigned int disabled = warning_disabled_categories; if (!RTEST(flag)) disabled |= mask; else disabled &= ~mask; warning_disabled_categories = disabled; return flag; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Warning#warn;F;7[[@90;[[@)i;T;: warn;0;[;{;IC; "Writes warning message +msg+ to $stderr. This method is called by Ruby for all emitted warnings. A +category+ may be included with the warning. See the documentation of the Warning module for how to customize this. ;T;[o;= ;>I" overload;F;?0;;` ;@0;:I"warn(msg, category: nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@Nl;![;"I"@return [nil];T;#0;$@Nl;.F;Bi;C0;7[[I"msg;T0[I"category:;TI"nil;T;$@Nl;![;"I" Writes warning message +msg+ to $stderr. This method is called by Ruby for all emitted warnings. A +category+ may be included with the warning. See the documentation of the Warning module for how to customize this. @overload warn(msg, category: nil) @return [nil];T;#0;$@Nl;.F;/o;0;1T;2i;3i;%@l;9I"static VALUE rb_warning_s_warn(int argc, VALUE *argv, VALUE mod) { VALUE str; VALUE opt; VALUE category = Qnil; rb_scan_args(argc, argv, "1:", &str, &opt); if (!NIL_P(opt)) rb_get_kwargs(opt, &id_category, 0, 1, &category); Check_Type(str, T_STRING); rb_must_asciicompat(str); if (!NIL_P(category)) { rb_warning_category_t cat = rb_warning_category_from_name(category); if (!rb_warning_category_enabled_p(cat)) return Qnil; } rb_write_error_str(str); return Qnil; };T;:I"static VALUE;T;;To; ;IC;[o;4;5F;6;;;;&I"Warning::buffer#write;F;7[[@90;[[@)i;T;;s;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@ql;.F;/o;0;1T;2i;3i;%@ol;9I"static VALUE warning_write(int argc, VALUE *argv, VALUE buf) { while (argc-- > 0) { rb_str_append(buf, *argv++); } return buf; };T;:I"static VALUE;T;;T; @ol; IC;[; @ol; IC;[; @ol; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i ;F;: buffer;;;;;[;{;IC; " ;T;[;![;"@;#0;$@ol;Bi;%@l;&I"Warning::buffer;F;'@},; @l; IC;[; @l; IC;[; @l; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i[@)i ;T;: Warning;;;;;[;{;IC; "The Warning module contains a single method named #warn, and the module extends itself, making Warning.warn available. Warning.warn is called for all warnings issued by Ruby. By default, warnings are printed to $stderr. Changing the behavior of Warning.warn is useful to customize how warnings are handled by Ruby, for instance by filtering some warnings, and/or outputting warnings somewhere other than $stderr. If you want to change the behavior of Warning.warn you should use +Warning.extend(MyNewModuleWithWarnMethod)+ and you can use `super` to get the default behavior of printing the warning to $stderr. Example: module MyWarningFilter def warn(message, category: nil, **kwargs) if /some warning I want to ignore/.match?(message) # ignore else super end end end Warning.extend MyWarningFilter You should never redefine Warning#warn (the instance method), as that will then no longer provide a way to use the default behavior. The +warning+ gem provides convenient ways to customize Warning.warn.;T;[;![;"I"! The Warning module contains a single method named #warn, and the module extends itself, making Warning.warn available. Warning.warn is called for all warnings issued by Ruby. By default, warnings are printed to $stderr. Changing the behavior of Warning.warn is useful to customize how warnings are handled by Ruby, for instance by filtering some warnings, and/or outputting warnings somewhere other than $stderr. If you want to change the behavior of Warning.warn you should use +Warning.extend(MyNewModuleWithWarnMethod)+ and you can use `super` to get the default behavior of printing the warning to $stderr. Example: module MyWarningFilter def warn(message, category: nil, **kwargs) if /some warning I want to ignore/.match?(message) # ignore else super end end end Warning.extend MyWarningFilter You should never redefine Warning#warn (the instance method), as that will then no longer provide a way to use the default behavior. The +warning+ gem provides convenient ways to customize Warning.warn. ;T;#0;$@l;.F;/o;0;1T;2i;3i2;Bi;%@;&I" Warning;Fo;;IC;[; @l; IC;[; @l; IC;[; @l; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i[@)i ;T;: Errno;;;;;[;{;IC; "Ruby exception objects are subclasses of Exception. However, operating systems typically report errors using plain integers. Module Errno is created dynamically to map these operating system errors to Ruby classes, with each error number generating its own subclass of SystemCallError. As the subclass is created in module Errno, its name will start Errno::. The names of the Errno:: classes depend on the environment in which Ruby runs. On a typical Unix or Windows platform, there are Errno classes such as Errno::EACCES, Errno::EAGAIN, Errno::EINTR, and so on. The integer operating system error number corresponding to a particular error is available as the class constant Errno::error::Errno. Errno::EACCES::Errno #=> 13 Errno::EAGAIN::Errno #=> 11 Errno::EINTR::Errno #=> 4 The full list of operating system errors on your particular platform are available as the constants of Errno. Errno.constants #=> :E2BIG, :EACCES, :EADDRINUSE, :EADDRNOTAVAIL, ... ;T;[;![;"I" Ruby exception objects are subclasses of Exception. However, operating systems typically report errors using plain integers. Module Errno is created dynamically to map these operating system errors to Ruby classes, with each error number generating its own subclass of SystemCallError. As the subclass is created in module Errno, its name will start Errno::. The names of the Errno:: classes depend on the environment in which Ruby runs. On a typical Unix or Windows platform, there are Errno classes such as Errno::EACCES, Errno::EAGAIN, Errno::EINTR, and so on. The integer operating system error number corresponding to a particular error is available as the class constant Errno::error::Errno. Errno::EACCES::Errno #=> 13 Errno::EAGAIN::Errno #=> 11 Errno::EINTR::Errno #=> 4 The full list of operating system errors on your particular platform are available as the constants of Errno. Errno.constants #=> :E2BIG, :EACCES, :EADDRINUSE, :EADDRNOTAVAIL, ... ;T;#0;$@l;.F;/o;0;1T;2i;3i;%@;&I" Errno;F@o; ;IC;[o;4;5F;6;;;;&I"SystemExit#initialize;F;7[[@90;[[@)i;T;;D;0;[;{;IC; "Create a new +SystemExit+ exception with the given status and message. Status is true, false, or an integer. If status is not given, true is used. ;T;[ o;= ;>I" overload;F;?0;;E;@0;:I"new;T;IC; ";T;[;![;"I";T;#0;$@l;.F;Bi;C0;7[;$@lo;= ;>I" overload;F;?0;;E;@0;:I"new(status);T;IC; ";T;[;![;"I";T;#0;$@l;.F;Bi;C0;7[[I" status;T0;$@lo;= ;>I" overload;F;?0;;E;@0;:I"new(status, msg);T;IC; ";T;[;![;"I";T;#0;$@l;.F;Bi;C0;7[[I" status;T0[I"msg;T0;$@lo;= ;>I" overload;F;?0;;E;@0;:I" new(msg);T;IC; ";T;[;![;"I";T;#0;$@l;.F;Bi;C0;7[[I"msg;T0;$@l;![;"I"Create a new +SystemExit+ exception with the given status and message. Status is true, false, or an integer. If status is not given, true is used. @overload new @overload new(status) @overload new(status, msg) @overload new(msg);T;#0;$@l;.F;/o;0;1T;2i;3i;%@l;9I"static VALUE exit_initialize(int argc, VALUE *argv, VALUE exc) { VALUE status; if (argc > 0) { status = *argv; switch (status) { case Qtrue: status = INT2FIX(EXIT_SUCCESS); ++argv; --argc; break; case Qfalse: status = INT2FIX(EXIT_FAILURE); ++argv; --argc; break; default: status = rb_check_to_int(status); if (NIL_P(status)) { status = INT2FIX(EXIT_SUCCESS); } else { #if EXIT_SUCCESS != 0 if (status == INT2FIX(0)) status = INT2FIX(EXIT_SUCCESS); #endif ++argv; --argc; } break; } } else { status = INT2FIX(EXIT_SUCCESS); } rb_call_super(argc, argv); rb_ivar_set(exc, id_status, status); return exc; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"SystemExit#status;F;7[;[[@)iP;T;;>;0;[;{;IC; ">Return the status value associated with this system exit. ;T;[o;= ;>I" overload;F;?0;;>;@0;:I" status;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@l;![;"I"@return [Integer];T;#0;$@l;.F;Bi;C0;7[;$@l;![;"I"eReturn the status value associated with this system exit. @overload status @return [Integer];T;#0;$@l;.F;/o;0;1T;2iI;3iM;%@l;9I"Tstatic VALUE exit_status(VALUE exc) { return rb_attr_get(exc, id_status); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"SystemExit#success?;F;7[;[[@)i^;T;;L;0;[;{;IC; ":Returns +true+ if exiting successful, +false+ if not.;T;[o;= ;>I" overload;F;?0;;L;@0;:I" success?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ m;![;"I"@return [Boolean];T;#0;$@ m;.F;Bi;C0;7[;$@ m;![;"I"cReturns +true+ if exiting successful, +false+ if not. @overload success? @return [Boolean];T;#0;$@ m;.F;/o;0;1T;2iW;3i[;Bi;%@l;9I"static VALUE exit_success_p(VALUE exc) { VALUE status_val = rb_attr_get(exc, id_status); int status; if (NIL_P(status_val)) return Qtrue; status = NUM2INT(status_val); return RBOOL(WIFEXITED(status) && WEXITSTATUS(status) == EXIT_SUCCESS); };T;:I"static VALUE;T;;T; @l; IC;[; @l; IC;[; @l; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i [@)iI ;T;:SystemExit;;;;;[;{;IC; "@Raised by +exit+ to initiate the termination of the script.;T;[;![;"I"B Raised by +exit+ to initiate the termination of the script. ;T;#0;$@l;.F;/o;0;1T;2i ;3i ;Bi;%@;&I"SystemExit;F;'@3o; ;IC;[o;4;5F;6;;;;&I"SignalException#initialize;F;7[[@90;[[@iV;T;;D;0;[;{;IC; "XConstruct a new SignalException object. +sig_name+ should be a known signal name. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(sig_name);T;IC; ";T;[;![;"I";T;#0;$@8m;.F;Bi;C0;7[[I" sig_name;T0;$@8mo;= ;>I" overload;F;?0;;E;@0;:I"new(sig_number [, name]);T;IC; ";T;[;![;"I";T;#0;$@8m;.F;Bi;C0;7[[I"sig_number[, name];T0;$@8m;![;"I" Construct a new SignalException object. +sig_name+ should be a known signal name. @overload new(sig_name) @overload new(sig_number [, name]);T;#0;$@8m;.F;/o;0;1T;2iM;3iR;%@6m;9I"static VALUE esignal_init(int argc, VALUE *argv, VALUE self) { int argnum = 1; VALUE sig = Qnil; int signo; if (argc > 0) { sig = rb_check_to_integer(argv[0], "to_int"); if (!NIL_P(sig)) argnum = 2; else sig = argv[0]; } rb_check_arity(argc, 1, argnum); if (argnum == 2) { signo = NUM2INT(sig); if (signo < 0 || signo > NSIG) { rb_raise(rb_eArgError, "invalid signal number (%d)", signo); } if (argc > 1) { sig = argv[1]; } else { sig = rb_signo2signm(signo); } } else { int prefix; signo = signm2signo(&sig, FALSE, FALSE, &prefix); if (prefix != signame_prefix_len) { sig = rb_str_append(rb_str_new_cstr("SIG"), sig); } } rb_call_super(1, &sig); rb_ivar_set(self, id_signo, INT2NUM(signo)); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"SignalException#signo;F;7[;[[@i;T;: signo;0;[;{;IC; "Returns a signal number. ;T;[o;= ;>I" overload;F;?0;;e ;@0;:I" signo;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@[m;![;"I"@return [Numeric];T;#0;$@[m;.F;Bi;C0;7[;$@[m;![;"I"D Returns a signal number. @overload signo @return [Numeric];T;#0;$@[m;.F;/o;0;1T;2i|;3i;%@6m;9I"Wstatic VALUE esignal_signo(VALUE self) { return rb_ivar_get(self, id_signo); };T;:I"static VALUE;T;;T; @6m; IC;[; @6m; IC;[; @6m; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i [@)iO ;T;:SignalException;;;;;[;{;IC; "Raised when a signal is received. begin Process.kill('HUP',Process.pid) sleep # wait for receiver to handle signal sent by Process.kill rescue SignalException => e puts "received Exception #{e}" end produces: received Exception SIGHUP;T;[;![;"I" Raised when a signal is received. begin Process.kill('HUP',Process.pid) sleep # wait for receiver to handle signal sent by Process.kill rescue SignalException => e puts "received Exception #{e}" end produces: received Exception SIGHUP ;T;#0;$@6m;.F;/o;0;1T;2i ;3i ;Bi;%@;&I"SignalException;F;'@3o; ;IC;[o;4;5F;6;;;;&I"Interrupt#initialize;F;7[[@90;[[@i;T;;D;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@m;.F;/o;0;1T;2i;3i;%@m;9I"static VALUE interrupt_init(int argc, VALUE *argv, VALUE self) { VALUE args[2]; args[0] = INT2FIX(SIGINT); args[1] = rb_check_arity(argc, 0, 1) ? argv[0] : Qnil; return rb_call_super(2, args); };T;:I"static VALUE;T;;T; @m; IC;[; @m; IC;[; @m; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i [@)iP ;T;:Interrupt;;;;;[;{;IC; "Raised when the interrupt signal is received, typically because the user has pressed Control-C (on most posix platforms). As such, it is a subclass of +SignalException+. begin puts "Press ctrl-C when you get bored" loop {} rescue Interrupt => e puts "Note: You will typically use Signal.trap instead." end produces: Press ctrl-C when you get bored then waits until it is interrupted with Control-C and then prints: Note: You will typically use Signal.trap instead.;T;[;![;"I" Raised when the interrupt signal is received, typically because the user has pressed Control-C (on most posix platforms). As such, it is a subclass of +SignalException+. begin puts "Press ctrl-C when you get bored" loop {} rescue Interrupt => e puts "Note: You will typically use Signal.trap instead." end produces: Press ctrl-C when you get bored then waits until it is interrupted with Control-C and then prints: Note: You will typically use Signal.trap instead. ;T;#0;$@m;.F;/o;0;1T;2i ;3i ;Bi;%@;&I"Interrupt;F;'@6mo; ;IC;[; @m; IC;[; @m; IC;[; @m; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i [@)iS ;T;:TypeError;;;;;[;{;IC; "Raised when encountering an object that is not of the expected type. [1, 2, 3].first("two") raises the exception: TypeError: no implicit conversion of String into Integer ;T;[;![;"I" Raised when encountering an object that is not of the expected type. [1, 2, 3].first("two") raises the exception: TypeError: no implicit conversion of String into Integer ;T;#0;$@m;.F;/o;0;1T;2i ;3i ;%@;&I"TypeError;F;'@@/@ko; ;IC;[o;4;5F;6;;;;&I"KeyError#initialize;F;7[[@90;[[@)i^;T;;D;0;[;{;IC; "SConstruct a new +KeyError+ exception with the given message, receiver and key. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I".new(message=nil, receiver: nil, key: nil);T;IC; ";T;[;![;"I";T;#0;$@m;.F;Bi;C0;7[[I" message;TI"nil;T[I"receiver:;TI"nil;T[I" key:;TI"nil;T;$@m;![;"I"Construct a new +KeyError+ exception with the given message, receiver and key. @overload new(message=nil, receiver: nil, key: nil);T;#0;$@m;.F;/o;0;1T;2iV;3iZ;%@m;9I"static VALUE key_err_initialize(int argc, VALUE *argv, VALUE self) { VALUE options; rb_call_super(rb_scan_args(argc, argv, "01:", NULL, &options), argv); if (!NIL_P(options)) { ID keywords[2]; VALUE values[numberof(keywords)]; int i; keywords[0] = id_receiver; keywords[1] = id_key; rb_get_kwargs(options, keywords, 0, numberof(values), values); for (i = 0; i < numberof(values); ++i) { if (values[i] != Qundef) { rb_ivar_set(self, keywords[i], values[i]); } } } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"KeyError#receiver;F;7[;[[@)i0;T;: receiver;0;[;{;IC; "AReturn the receiver associated with this KeyError exception. ;T;[o;= ;>I" overload;F;?0;;i ;@0;:I" receiver;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@m;![;"I"@return [Object];T;#0;$@m;.F;Bi;C0;7[;$@m;![;"I"iReturn the receiver associated with this KeyError exception. @overload receiver @return [Object];T;#0;$@m;.F;/o;0;1T;2i);3i-;%@m;9I"static VALUE key_err_receiver(VALUE self) { VALUE recv; recv = rb_ivar_lookup(self, id_receiver, Qundef); if (recv != Qundef) return recv; rb_raise(rb_eArgError, "no receiver is available"); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"KeyError#key;F;7[;[[@)iA;T;;;0;[;{;IC; "3Return the key caused this KeyError exception. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"key;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@m;![;"I"@return [Object];T;#0;$@m;.F;Bi;C0;7[;$@m;![;"I"VReturn the key caused this KeyError exception. @overload key @return [Object];T;#0;$@m;.F;/o;0;1T;2i:;3i>;%@m;9I"static VALUE key_err_key(VALUE self) { VALUE key; key = rb_ivar_lookup(self, id_key, Qundef); if (key != Qundef) return key; rb_raise(rb_eArgError, "no key is available"); };T;:I"static VALUE;T;;T; @m; IC;[; @m; IC;[; @m; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i [@)iV ;T;: KeyError;;;;;[;{;IC; "Raised when the specified key is not found. It is a subclass of IndexError. h = {"foo" => :bar} h.fetch("foo") #=> :bar h.fetch("baz") #=> KeyError: key not found: "baz";T;[;![;"I" Raised when the specified key is not found. It is a subclass of IndexError. h = {"foo" => :bar} h.fetch("foo") #=> :bar h.fetch("baz") #=> KeyError: key not found: "baz" ;T;#0;$@m;.F;/o;0;1T;2i ;3i ;Bi;%@;&I" KeyError;F;'@ko; ;IC;[; @)n; IC;[; @)n; IC;[; @)n; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i [@)iZ ;T;:RangeError;;;;;[;{;IC; "Raised when a given numerical value is out of range. [1, 2, 3].drop(1 << 100) raises the exception: RangeError: bignum too big to convert into `long' ;T;[;![;"I" Raised when a given numerical value is out of range. [1, 2, 3].drop(1 << 100) raises the exception: RangeError: bignum too big to convert into `long' ;T;#0;$@)n;.F;/o;0;1T;2i ;3i ;%@;&I"RangeError;F;'@o; ;IC;[; @=n; IC;[; @=n; IC;[; @=n; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i [@)i\ ;T;:ScriptError;;;;;[;{;IC; "(ScriptError is the superclass for errors raised when a script can not be executed because of a +LoadError+, +NotImplementedError+ or a +SyntaxError+. Note these type of +ScriptErrors+ are not +StandardError+ and will not be rescued unless it is specified explicitly (or its ancestor +Exception+). ;T;[;![;"I"* ScriptError is the superclass for errors raised when a script can not be executed because of a +LoadError+, +NotImplementedError+ or a +SyntaxError+. Note these type of +ScriptErrors+ are not +StandardError+ and will not be rescued unless it is specified explicitly (or its ancestor +Exception+). ;T;#0;$@=n;.F;/o;0;1T;2i ;3i ;%@;&I"ScriptError;F;'@3o; ;IC;[o;4;5F;6;;;;&I"SyntaxError#initialize;F;7[[@90;[[@)i;T;;D;0;[;{;IC; "'Construct a SyntaxError exception. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new([msg]);T;IC; ";T;[;![;"I";T;#0;$@Sn;.F;Bi;C0;7[[I" [msg];T0;$@Sn;![;"I">Construct a SyntaxError exception. @overload new([msg]);T;#0;$@Sn;.F;/o;0;1T;2i;3i;%@Qn;9I"static VALUE syntax_error_initialize(int argc, VALUE *argv, VALUE self) { VALUE mesg; if (argc == 0) { mesg = rb_fstring_lit("compile error"); argc = 1; argv = &mesg; } return rb_call_super(argc, argv); };T;:I"static VALUE;T;;T; @Qn; IC;[; @Qn; IC;[; @Qn; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i [@)i] ;T;:SyntaxError;;;;;[;{;IC; "Raised when encountering Ruby code with an invalid syntax. eval("1+1=2") raises the exception: SyntaxError: (eval):1: syntax error, unexpected '=', expecting $end;T;[;![;"I" Raised when encountering Ruby code with an invalid syntax. eval("1+1=2") raises the exception: SyntaxError: (eval):1: syntax error, unexpected '=', expecting $end ;T;#0;$@Qn;.F;/o;0;1T;2i ;3i ;Bi;%@;&I"SyntaxError;F;'@=no; ;IC;[; @~n; IC;[; @~n; IC;[; @~n; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i [@)i` ;T;:LoadError;;;;;[;{;IC; "Raised when a file required (a Ruby script, extension library, ...) fails to load. require 'this/file/does/not/exist' raises the exception: LoadError: no such file to load -- this/file/does/not/exist ;T;[;![;"I" Raised when a file required (a Ruby script, extension library, ...) fails to load. require 'this/file/does/not/exist' raises the exception: LoadError: no such file to load -- this/file/does/not/exist ;T;#0;$@~n;.F;/o;0;1T;2i ;3i( ;%@;&I"LoadError;F;'@=no; ;IC;[; @n; IC;[; @n; IC;[; @n; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i, [@)id ;T;:NotImplementedError;;;;;[;{;IC; "TRaised when a feature is not implemented on the current platform. For example, methods depending on the +fsync+ or +fork+ system calls may raise this exception if the underlying operating system or Ruby runtime does not support them. Note that if +fork+ raises a +NotImplementedError+, then respond_to?(:fork) returns +false+. ;T;[;![;"I"V Raised when a feature is not implemented on the current platform. For example, methods depending on the +fsync+ or +fork+ system calls may raise this exception if the underlying operating system or Ruby runtime does not support them. Note that if +fork+ raises a +NotImplementedError+, then respond_to?(:fork) returns +false+. ;T;#0;$@n;.F;/o;0;1T;2i, ;3i4 ;%@;&I"NotImplementedError;F;'@=no; ;IC;[ o; ;IC;[ o;4;5F;6;;;;&I"'NameError::message#initialize_copy;F;7[[I" obj2;T0;[[@)i{;T;;];0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@n;.F;/o;0;1T;2iz;3iz;%@n;9I"rstatic VALUE name_err_mesg_init_copy(VALUE obj1, VALUE obj2) { VALUE *ptr1, *ptr2; if (obj1 == obj2) return obj1; rb_obj_init_copy(obj1, obj2); TypedData_Get_Struct(obj1, VALUE, &name_err_mesg_data_type, ptr1); TypedData_Get_Struct(obj2, VALUE, &name_err_mesg_data_type, ptr2); MEMCPY(ptr1, ptr2, VALUE, NAME_ERR_MESG_COUNT); return obj1; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"NameError::message#==;F;7[[I" obj2;T0;[[@)i;T;;F;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@n;.F;/o;0;1T;2i;3i;%@n;9I"static VALUE name_err_mesg_equal(VALUE obj1, VALUE obj2) { VALUE *ptr1, *ptr2; int i; if (obj1 == obj2) return Qtrue; if (rb_obj_class(obj2) != rb_cNameErrorMesg) return Qfalse; TypedData_Get_Struct(obj1, VALUE, &name_err_mesg_data_type, ptr1); TypedData_Get_Struct(obj2, VALUE, &name_err_mesg_data_type, ptr2); for (i=0; i 0 && RSTRING_PTR(d)[0] == '#'); break; } if (!singleton) { s = FAKE_CSTR(&s_str, ":"); c = rb_class_name(CLASS_OF(obj)); } else { c = s = FAKE_CSTR(&s_str, ""); } args[0] = rb_obj_as_string(ptr[NAME_ERR_MESG__NAME]); args[1] = d; args[2] = s; args[3] = c; mesg = rb_str_format(4, args, mesg); } return mesg; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"NameError::message#_dump;F;7[[I" limit;T0;[[@)i;T;;;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@n;.F;/o;0;1T;2i;3i;%@n;9I"fstatic VALUE name_err_mesg_dump(VALUE obj, VALUE limit) { return name_err_mesg_to_str(obj); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"NameError::message._load;F;7[[I"str;T0;[[@)i;T;;;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@n;.F;/o;0;1T;2i;3i;%@n;9I"Pstatic VALUE name_err_mesg_load(VALUE klass, VALUE str) { return str; };T;:I"static VALUE;T;;T; @n; IC;[; @n; IC;[; @n; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i [@)ik ;T;;H;;;;;[;{;IC; " :nodoc:;T;[;![;"I" :nodoc: ;T;#0;$@n;.F;/o;0;1T;2i ;3i ;Bi;%o;( ;)0;*0;+0;;};%@;-@n;0;&I"NameError::message;F;'@o;4;5F;6;;;;&I"NameError#initialize;F;7[[@90;[[@)i;T;;D;0;[;{;IC; "Construct a new NameError exception. If given the name parameter may subsequently be examined using the NameError#name method. receiver parameter allows to pass object in context of which the error happened. Example: [1, 2, 3].method(:rject) # NameError with name "rject" and receiver: Array [1, 2, 3].singleton_method(:rject) # NameError with name "rject" and receiver: [1, 2, 3] ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"*new(msg=nil, name=nil, receiver: nil);T;IC; ";T;[;![;"I";T;#0;$@ o;.F;Bi;C0;7[[I"msg;TI"nil;T[I" name;TI"nil;T[I"receiver:;TI"nil;T;$@ o;![;"I"Construct a new NameError exception. If given the name parameter may subsequently be examined using the NameError#name method. receiver parameter allows to pass object in context of which the error happened. Example: [1, 2, 3].method(:rject) # NameError with name "rject" and receiver: Array [1, 2, 3].singleton_method(:rject) # NameError with name "rject" and receiver: [1, 2, 3] @overload new(msg=nil, name=nil, receiver: nil);T;#0;$@ o;.F;/o;0;1T;2i;3i;%@n;9I"static VALUE name_err_initialize(int argc, VALUE *argv, VALUE self) { ID keywords[1]; VALUE values[numberof(keywords)], name, options; argc = rb_scan_args(argc, argv, "*:", NULL, &options); keywords[0] = id_receiver; rb_get_kwargs(options, keywords, 0, numberof(values), values); name = (argc > 1) ? argv[--argc] : Qnil; rb_call_super(argc, argv); name_err_init_attr(self, values[0], name); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"NameError#name;F;7[;[[@)i;T;;F;0;[;{;IC; ">Return the name associated with this NameError exception. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I" name;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@+o;![;"I"@return [String, nil];T;#0;$@+o;.F;Bi;C0;7[;$@+o;![;"I"gReturn the name associated with this NameError exception. @overload name @return [String, nil];T;#0;$@+o;.F;/o;0;1T;2i;3i;%@n;9I"Vstatic VALUE name_err_name(VALUE self) { return rb_attr_get(self, id_name); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"NameError#receiver;F;7[;[[@)i;T;;i ;0;[;{;IC; "BReturn the receiver associated with this NameError exception. ;T;[o;= ;>I" overload;F;?0;;i ;@0;:I" receiver;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@Go;![;"I"@return [Object];T;#0;$@Go;.F;Bi;C0;7[;$@Go;![;"I"jReturn the receiver associated with this NameError exception. @overload receiver @return [Object];T;#0;$@Go;.F;/o;0;1T;2i;3i;%@n;9I"static VALUE name_err_receiver(VALUE self) { VALUE *ptr, recv, mesg; recv = rb_ivar_lookup(self, id_recv, Qundef); if (recv != Qundef) return recv; mesg = rb_attr_get(self, id_mesg); if (!rb_typeddata_is_kind_of(mesg, &name_err_mesg_data_type)) { rb_raise(rb_eArgError, "no receiver is available"); } ptr = DATA_PTR(mesg); return ptr[NAME_ERR_MESG__RECV]; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"NameError#local_variables;F;7[;[[@)i;T;;;0;[;{;IC; "uReturn a list of the local variable names defined where this NameError exception was raised. Internal use only. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"local_variables;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@bo;![;"I"@return [Array];T;#0;$@bo;.F;Bi;C0;7[;$@bo;![;"I"Return a list of the local variable names defined where this NameError exception was raised. Internal use only. @overload local_variables @return [Array];T;#0;$@bo;.F;/o;0;1T;2i;3i;%@n;9I"Xstatic VALUE name_err_local_variables(VALUE self) { VALUE vars = rb_attr_get(self, id_local_variables); if (NIL_P(vars)) { VALUE iseqw = rb_attr_get(self, id_iseq); if (!NIL_P(iseqw)) vars = rb_iseqw_local_variables(iseqw); if (NIL_P(vars)) vars = rb_ary_new(); rb_ivar_set(self, id_local_variables, vars); } return vars; };T;:I"static VALUE;T;;T; @n; IC;[; @n; IC;[; @n; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i8 [@)if ;T;;};;;;;[;{;IC; "CRaised when a given name is invalid or undefined. puts foo raises the exception: NameError: undefined local variable or method `foo' for main:Object Since constant names must start with a capital: Integer.const_set :answer, 42 raises the exception: NameError: wrong constant name answer;T;[;![;"I"E Raised when a given name is invalid or undefined. puts foo raises the exception: NameError: undefined local variable or method `foo' for main:Object Since constant names must start with a capital: Integer.const_set :answer, 42 raises the exception: NameError: wrong constant name answer ;T;#0;$@n;.F;/o;0;1T;2i8 ;3iH ;Bi;%@;&I"NameError;F;'@o; ;IC;[o;4;5F;6;;;;&I"NoMethodError#initialize;F;7[[@90;[[@)i(;T;;D;0;[;{;IC; "Construct a NoMethodError exception for a method of the given name called with the given arguments. The name may be accessed using the #name method on the resulting object, and the arguments using the #args method. If private argument were passed, it designates method was attempted to call in private context, and can be accessed with #private_call? method. receiver argument stores an object whose method was called. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"Cnew(msg=nil, name=nil, args=nil, private=false, receiver: nil);T;IC; ";T;[;![;"I";T;#0;$@o;.F;Bi;C0;7[ [I"msg;TI"nil;T[I" name;TI"nil;T[I" args;TI"nil;T[I" private;TI" false;T[I"receiver:;TI"nil;T;$@o;![;"I"$Construct a NoMethodError exception for a method of the given name called with the given arguments. The name may be accessed using the #name method on the resulting object, and the arguments using the #args method. If private argument were passed, it designates method was attempted to call in private context, and can be accessed with #private_call? method. receiver argument stores an object whose method was called. @overload new(msg=nil, name=nil, args=nil, private=false, receiver: nil);T;#0;$@o;.F;/o;0;1T;2i;3i$;%@o;9I"static VALUE nometh_err_initialize(int argc, VALUE *argv, VALUE self) { int priv; VALUE args, options; argc = rb_scan_args(argc, argv, "*:", NULL, &options); priv = (argc > 3) && (--argc, RTEST(argv[argc])); args = (argc > 2) ? argv[--argc] : Qnil; if (!NIL_P(options)) argv[argc++] = options; rb_call_super_kw(argc, argv, RB_PASS_CALLED_KEYWORDS); return nometh_err_init_attr(self, args, priv); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"NoMethodError#args;F;7[;[[@)i;T;: args;0;[;{;IC; "NReturn the arguments passed in as the third parameter to the constructor. ;T;[o;= ;>I" overload;F;?0;;q ;@0;:I" args;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@o;![;"I"@return [Object];T;#0;$@o;.F;Bi;C0;7[;$@o;![;"I"rReturn the arguments passed in as the third parameter to the constructor. @overload args @return [Object];T;#0;$@o;.F;/o;0;1T;2i;3i ;%@o;9I"Xstatic VALUE nometh_err_args(VALUE self) { return rb_attr_get(self, id_args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" NoMethodError#private_call?;F;7[;[[@)i;T;:private_call?;0;[;{;IC; "I" overload;F;?0;;r ;@0;:I"private_call?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@o;![;"I"@return [Boolean];T;#0;$@o;.F;Bi;C0;7[;$@o;![;"I"jReturn true if the caused method was called as private. @overload private_call? @return [Boolean];T;#0;$@o;.F;/o;0;1T;2i;3i;Bi;%@o;9I"lstatic VALUE nometh_err_private_call_p(VALUE self) { return rb_attr_get(self, id_private_call_p); };T;:I"static VALUE;T;;T; @o; IC;[; @o; IC;[; @o; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)iL [@)ir ;T;:NoMethodError;;;;;[;{;IC; "Raised when a method is called on a receiver which doesn't have it defined and also fails to respond with +method_missing+. "hello".to_ary raises the exception: NoMethodError: undefined method `to_ary' for "hello":String;T;[;![;"I" Raised when a method is called on a receiver which doesn't have it defined and also fails to respond with +method_missing+. "hello".to_ary raises the exception: NoMethodError: undefined method `to_ary' for "hello":String ;T;#0;$@o;.F;/o;0;1T;2iL ;3iU ;Bi;%@;&I"NoMethodError;F;'@no; ;IC;[o;4;5F;6;;;;&I"FrozenError#initialize;F;7[[@90;[[@)i};T;;D;0;[;{;IC; "Construct a new FrozenError exception. If given the receiver parameter may subsequently be examined using the FrozenError#receiver method. a = [].freeze raise FrozenError.new("can't modify frozen array", receiver: a) ;T;[o;= ;>I" overload;F;?0;;E;@0;:I" new(msg=nil, receiver: nil);T;IC; ";T;[;![;"I";T;#0;$@p;.F;Bi;C0;7[[I"msg;TI"nil;T[I"receiver:;TI"nil;T;$@p;![;"I"Construct a new FrozenError exception. If given the receiver parameter may subsequently be examined using the FrozenError#receiver method. a = [].freeze raise FrozenError.new("can't modify frozen array", receiver: a) @overload new(msg=nil, receiver: nil);T;#0;$@p;.F;/o;0;1T;2iq;3iy;%@o;9I"~static VALUE frozen_err_initialize(int argc, VALUE *argv, VALUE self) { ID keywords[1]; VALUE values[numberof(keywords)], options; argc = rb_scan_args(argc, argv, "*:", NULL, &options); keywords[0] = id_receiver; rb_get_kwargs(options, keywords, 0, numberof(values), values); rb_call_super(argc, argv); err_init_recv(self, values[0]); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"FrozenError#receiver;F;7[;[;F;;i ;;;[;{;IC; "DReturn the receiver associated with this FrozenError exception. ;T;[o;= ;>I" overload;F;?0;;i ;@0;:I" receiver;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@p;![;"I"@return [Object];T;#0;$@p;.F;Bi;C0;7[;$@p;![;"I"lReturn the receiver associated with this FrozenError exception. @overload receiver @return [Object];T;#0;$@p;.F;/o;0;1T;2i;3i;%@o;;T; @o; IC;[; @o; IC;[; @o; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)iY [@)ix ;T;:FrozenError;;;;;[;{;IC; "Raised when there is an attempt to modify a frozen object. [1, 2, 3].freeze << 4 raises the exception: FrozenError: can't modify frozen Array;T;[;![;"I" Raised when there is an attempt to modify a frozen object. [1, 2, 3].freeze << 4 raises the exception: FrozenError: can't modify frozen Array ;T;#0;$@o;.F;/o;0;1T;2iY ;3ia ;Bi;%@;&I"FrozenError;F;'@[@[o; ;IC;[; @Hp; IC;[; @Hp; IC;[; @Hp; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)is [@)i{ ;T;:SecurityError;;;;;[;{;IC; "%No longer used by internal code. ;T;[;![;"I"' No longer used by internal code. ;T;#0;$@Hp;.F;/o;0;1T;2is ;3iu ;%@;&I"SecurityError;F;'@3o; ;IC;[; @\p; IC;[; @\p; IC;[; @\p; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)iy [@)i| ;T;:NoMemoryError;;;;;[;{;IC; ")Raised when memory allocation fails. ;T;[;![;"I"+ Raised when memory allocation fails. ;T;#0;$@\p;.F;/o;0;1T;2iy ;3i{ ;%@;&I"NoMemoryError;F;'@3o; ;IC;[o;4;5F;6;;;;&I"SystemCallError#initialize;F;7[[@90;[[@)i& ;T;;D;0;[;{;IC; "If _errno_ corresponds to a known system error code, constructs the appropriate Errno class for that error, otherwise constructs a generic SystemCallError object. The error number is subsequently available via the #errno method. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(msg, errno);T;IC; ";T;[;![;"I";T;#0;$@rp;.F;Bi;C0;7[[I"msg;T0[I" errno;T0;$@rp;![;"I"If _errno_ corresponds to a known system error code, constructs the appropriate Errno class for that error, otherwise constructs a generic SystemCallError object. The error number is subsequently available via the #errno method. @overload new(msg, errno);T;#0;$@rp;.F;/o;0;1T;2i ;3i" ;%@pp;9I"static VALUE syserr_initialize(int argc, VALUE *argv, VALUE self) { #if !defined(_WIN32) char *strerror(); #endif const char *err; VALUE mesg, error, func, errmsg; VALUE klass = rb_obj_class(self); if (klass == rb_eSystemCallError) { st_data_t data = (st_data_t)klass; rb_scan_args(argc, argv, "12", &mesg, &error, &func); if (argc == 1 && FIXNUM_P(mesg)) { error = mesg; mesg = Qnil; } if (!NIL_P(error) && st_lookup(syserr_tbl, NUM2LONG(error), &data)) { klass = (VALUE)data; /* change class */ if (!RB_TYPE_P(self, T_OBJECT)) { /* insurance to avoid type crash */ rb_raise(rb_eTypeError, "invalid instance type"); } RBASIC_SET_CLASS(self, klass); } } else { rb_scan_args(argc, argv, "02", &mesg, &func); error = rb_const_get(klass, id_Errno); } if (!NIL_P(error)) err = strerror(NUM2INT(error)); else err = "unknown error"; errmsg = rb_enc_str_new_cstr(err, rb_locale_encoding()); if (!NIL_P(mesg)) { VALUE str = StringValue(mesg); if (!NIL_P(func)) rb_str_catf(errmsg, " @ %"PRIsVALUE, func); rb_str_catf(errmsg, " - %"PRIsVALUE, str); } mesg = errmsg; rb_call_super(1, &mesg); rb_ivar_set(self, id_errno, error); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"SystemCallError#errno;F;7[;[[@)i[ ;T;: errno;0;[;{;IC; "0Return this SystemCallError's error number. ;T;[o;= ;>I" overload;F;?0;;w ;@0;:I" errno;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@p;![;"I"@return [Integer];T;#0;$@p;.F;Bi;C0;7[;$@p;![;"I"VReturn this SystemCallError's error number. @overload errno @return [Integer];T;#0;$@p;.F;/o;0;1T;2iT ;3iX ;%@pp;9I"Vstatic VALUE syserr_errno(VALUE self) { return rb_attr_get(self, id_errno); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"SystemCallError.===;F;7[[I"exc;T0;[[@)ii ;T;;S;0;[;{;IC; "{Return +true+ if the receiver is a generic +SystemCallError+, or if the error numbers +self+ and _other_ are the same. ;T;[o;= ;>I" overload;F;?0;;S;@0;:I"===(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@p;![;"I"@return [Boolean];T;#0;$@p;.F;Bi;C0;7[[I" other;T0;$@p;![;"I"Return +true+ if the receiver is a generic +SystemCallError+, or if the error numbers +self+ and _other_ are the same. @overload ===(other) @return [Boolean];T;#0;$@p;.F;/o;0;1T;2ia ;3if ;%@pp;9I"static VALUE syserr_eqq(VALUE self, VALUE exc) { VALUE num, e; if (!rb_obj_is_kind_of(exc, rb_eSystemCallError)) { if (!rb_respond_to(exc, id_errno)) return Qfalse; } else if (self == rb_eSystemCallError) return Qtrue; num = rb_attr_get(exc, id_errno); if (NIL_P(num)) { num = rb_funcallv(exc, id_errno, 0, 0); } e = rb_const_get(self, id_Errno); return RBOOL(FIXNUM_P(num) ? num == e : rb_equal(num, e)); };T;:I"static VALUE;T;;T; @pp; IC;[; @pp; IC;[; @pp; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i [@)i ;T;:SystemCallError;;;;;[;{;IC; "ASystemCallError is the base class for all low-level platform-dependent errors. The errors available on the current platform are subclasses of SystemCallError and are defined in the Errno module. File.open("does/not/exist") raises the exception: Errno::ENOENT: No such file or directory - does/not/exist;T;[;![;"I"C SystemCallError is the base class for all low-level platform-dependent errors. The errors available on the current platform are subclasses of SystemCallError and are defined in the Errno module. File.open("does/not/exist") raises the exception: Errno::ENOENT: No such file or directory - does/not/exist ;T;#0;$@pp;.F;/o;0;1T;2i ;3i ;Bi;%@;&I"SystemCallError;F;'@o; ;IC;[; @p; IC;[; @p; IC;[; @p; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i [@)i} ;T;:EncodingError;;;;;[;{;IC; "9EncodingError is the base class for encoding errors. ;T;[;![;"I"; EncodingError is the base class for encoding errors. ;T;#0;$@p;.F;/o;0;1T;2i ;3i ;%@;&I"EncodingError;F;'@o; ;IC;[; @p; IC;[; @p; IC;[; @p; IC;{;IC;{;T;IC;{;T;T;{;[;[[@iq[@i+;T;:ZeroDivisionError;;;;;[;{;IC; "Raised when attempting to divide an integer by 0. 42 / 0 #=> ZeroDivisionError: divided by 0 Note that only division by an exact 0 will raise the exception: 42 / 0.0 #=> Float::INFINITY 42 / -0.0 #=> -Float::INFINITY 0 / 0.0 #=> NaN ;T;[;![;"I" Raised when attempting to divide an integer by 0. 42 / 0 #=> ZeroDivisionError: divided by 0 Note that only division by an exact 0 will raise the exception: 42 / 0.0 #=> Float::INFINITY 42 / -0.0 #=> -Float::INFINITY 0 / 0.0 #=> NaN ;T;#0;$@p;.F;/o;0;1T;2iq;3i{;%@;&I"ZeroDivisionError;F;'@o; ;IC;[; @q; IC;[; @q; IC;[; @q; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i,;T;:FloatDomainError;;;;;[;{;IC; "Raised when attempting to convert special float values (in particular +Infinity+ or +NaN+) to numerical classes which don't support them. Float::INFINITY.to_r #=> FloatDomainError: Infinity ;T;[;![;"I" Raised when attempting to convert special float values (in particular +Infinity+ or +NaN+) to numerical classes which don't support them. Float::INFINITY.to_r #=> FloatDomainError: Infinity ;T;#0;$@q;.F;/o;0;1T;2i;3i;%@;&I"FloatDomainError;F;'@)no; ;IC;[#o;4;5F;6;;;;&I"Rational#numerator;F;7[;[[@ri<;T;;;0;[;{;IC; "Returns the numerator. Rational(7).numerator #=> 7 Rational(7, 1).numerator #=> 7 Rational(9, -4).numerator #=> -9 Rational(-2, -10).numerator #=> 1 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"numerator;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@q;![;"I"@return [Integer];T;#0;$@q;.F;Bi;C0;7[;$@q;![;"I"Returns the numerator. Rational(7).numerator #=> 7 Rational(7, 1).numerator #=> 7 Rational(9, -4).numerator #=> -9 Rational(-2, -10).numerator #=> 1 @overload numerator @return [Integer];T;#0;$@q;.F;/o;0;1T;2i1;3i:;%@q;9I"Zstatic VALUE nurat_numerator(VALUE self) { get_dat1(self); return dat->num; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Rational#denominator;F;7[;[[@riN;T;;;0;[;{;IC; "Returns the denominator (always positive). Rational(7).denominator #=> 1 Rational(7, 1).denominator #=> 1 Rational(9, -4).denominator #=> 4 Rational(-2, -10).denominator #=> 5 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"denominator;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@2q;![;"I"@return [Integer];T;#0;$@2q;.F;Bi;C0;7[;$@2q;![;"I" Returns the denominator (always positive). Rational(7).denominator #=> 1 Rational(7, 1).denominator #=> 1 Rational(9, -4).denominator #=> 4 Rational(-2, -10).denominator #=> 5 @overload denominator @return [Integer];T;#0;$@2q;.F;/o;0;1T;2iC;3iL;%@q;9I"\static VALUE nurat_denominator(VALUE self) { get_dat1(self); return dat->den; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Rational#-@;F;7[;[[@ri[;T;;;0;[;{;IC; "Negates +rat+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" -rat;T;IC; ";T;[;![;"I";T;#0;$@Mq;.F;Bi;C0;7[;$@Mq;![;"I"$Negates +rat+. @overload -rat;T;#0;$@Mq;.F;/o;0;1T;2iU;3iX;%@q;9I"VALUE rb_rational_uminus(VALUE self) { const int unused = (assert(RB_TYPE_P(self, T_RATIONAL)), 0); get_dat1(self); (void)unused; return f_rational_new2(CLASS_OF(self), rb_int_uminus(dat->num), dat->den); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Rational#+;F;7[[I" other;T0;[[@ri;T;;;0;[;{;IC; "Performs addition. Rational(2, 3) + Rational(2, 3) #=> (4/3) Rational(900) + Rational(1) #=> (901/1) Rational(-2, 9) + Rational(-9, 2) #=> (-85/18) Rational(9, 8) + 4 #=> (41/8) Rational(20, 9) + 9.8 #=> 12.022222222222222 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"+(numeric);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@cq;![;"I"@return [Numeric];T;#0;$@cq;.F;Bi;C0;7[[I" numeric;T0;$@cq;![;"I"APerforms addition. Rational(2, 3) + Rational(2, 3) #=> (4/3) Rational(900) + Rational(1) #=> (901/1) Rational(-2, 9) + Rational(-9, 2) #=> (-85/18) Rational(9, 8) + 4 #=> (41/8) Rational(20, 9) + 9.8 #=> 12.022222222222222 @overload +(numeric) @return [Numeric];T;#0;$@cq;.F;/o;0;1T;2i;3i;%@q;9I"\VALUE rb_rational_plus(VALUE self, VALUE other) { if (RB_INTEGER_TYPE_P(other)) { { get_dat1(self); return f_rational_new_no_reduce2(CLASS_OF(self), rb_int_plus(dat->num, rb_int_mul(other, dat->den)), dat->den); } } else if (RB_FLOAT_TYPE_P(other)) { return DBL2NUM(nurat_to_double(self) + RFLOAT_VALUE(other)); } else if (RB_TYPE_P(other, T_RATIONAL)) { { get_dat2(self, other); return f_addsub(self, adat->num, adat->den, bdat->num, bdat->den, '+'); } } else { return rb_num_coerce_bin(self, other, '+'); } };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Rational#-;F;7[[I" other;T0;[[@ri;T;;;0;[;{;IC; "Performs subtraction. Rational(2, 3) - Rational(2, 3) #=> (0/1) Rational(900) - Rational(1) #=> (899/1) Rational(-2, 9) - Rational(-9, 2) #=> (77/18) Rational(9, 8) - 4 #=> (-23/8) Rational(20, 9) - 9.8 #=> -7.577777777777778 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"-(numeric);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@q;![;"I"@return [Numeric];T;#0;$@q;.F;Bi;C0;7[[I" numeric;T0;$@q;![;"I"DPerforms subtraction. Rational(2, 3) - Rational(2, 3) #=> (0/1) Rational(900) - Rational(1) #=> (899/1) Rational(-2, 9) - Rational(-9, 2) #=> (77/18) Rational(9, 8) - 4 #=> (-23/8) Rational(20, 9) - 9.8 #=> -7.577777777777778 @overload -(numeric) @return [Numeric];T;#0;$@q;.F;/o;0;1T;2i;3i;%@q;9I"^VALUE rb_rational_minus(VALUE self, VALUE other) { if (RB_INTEGER_TYPE_P(other)) { { get_dat1(self); return f_rational_new_no_reduce2(CLASS_OF(self), rb_int_minus(dat->num, rb_int_mul(other, dat->den)), dat->den); } } else if (RB_FLOAT_TYPE_P(other)) { return DBL2NUM(nurat_to_double(self) - RFLOAT_VALUE(other)); } else if (RB_TYPE_P(other, T_RATIONAL)) { { get_dat2(self, other); return f_addsub(self, adat->num, adat->den, bdat->num, bdat->den, '-'); } } else { return rb_num_coerce_bin(self, other, '-'); } };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Rational#*;F;7[[I" other;T0;[[@riU;T;;;0;[;{;IC; "Performs multiplication. Rational(2, 3) * Rational(2, 3) #=> (4/9) Rational(900) * Rational(1) #=> (900/1) Rational(-2, 9) * Rational(-9, 2) #=> (1/1) Rational(9, 8) * 4 #=> (9/2) Rational(20, 9) * 9.8 #=> 21.77777777777778 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"*(numeric);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@q;![;"I"@return [Numeric];T;#0;$@q;.F;Bi;C0;7[[I" numeric;T0;$@q;![;"I"BPerforms multiplication. Rational(2, 3) * Rational(2, 3) #=> (4/9) Rational(900) * Rational(1) #=> (900/1) Rational(-2, 9) * Rational(-9, 2) #=> (1/1) Rational(9, 8) * 4 #=> (9/2) Rational(20, 9) * 9.8 #=> 21.77777777777778 @overload *(numeric) @return [Numeric];T;#0;$@q;.F;/o;0;1T;2iI;3iS;%@q;9I"!VALUE rb_rational_mul(VALUE self, VALUE other) { if (RB_INTEGER_TYPE_P(other)) { { get_dat1(self); return f_muldiv(self, dat->num, dat->den, other, ONE, '*'); } } else if (RB_FLOAT_TYPE_P(other)) { return DBL2NUM(nurat_to_double(self) * RFLOAT_VALUE(other)); } else if (RB_TYPE_P(other, T_RATIONAL)) { { get_dat2(self, other); return f_muldiv(self, adat->num, adat->den, bdat->num, bdat->den, '*'); } } else { return rb_num_coerce_bin(self, other, '*'); } };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Rational#/;F;7[[I" other;T0;[[@ri;T;;;0;[;{;IC; "Performs division. Rational(2, 3) / Rational(2, 3) #=> (1/1) Rational(900) / Rational(1) #=> (900/1) Rational(-2, 9) / Rational(-9, 2) #=> (4/81) Rational(9, 8) / 4 #=> (9/32) Rational(20, 9) / 9.8 #=> 0.22675736961451246 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"/(numeric);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@q;![;"I"@return [Numeric];T;#0;$@q;.F;Bi;C0;7[[I" numeric;T0;$@qo;= ;>I" overload;F;?0;;;@0;:I"quo(numeric);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@q;![;"I"@return [Numeric];T;#0;$@q;.F;Bi;C0;7[[I" numeric;T0;$@q;![;"I"kPerforms division. Rational(2, 3) / Rational(2, 3) #=> (1/1) Rational(900) / Rational(1) #=> (900/1) Rational(-2, 9) / Rational(-9, 2) #=> (4/81) Rational(9, 8) / 4 #=> (9/32) Rational(20, 9) / 9.8 #=> 0.22675736961451246 @overload /(numeric) @return [Numeric] @overload quo(numeric) @return [Numeric];T;#0;$@q;.F;/o;0;1T;2ir;3i~;%@q;9I"VALUE rb_rational_div(VALUE self, VALUE other) { if (RB_INTEGER_TYPE_P(other)) { if (f_zero_p(other)) rb_num_zerodiv(); { get_dat1(self); return f_muldiv(self, dat->num, dat->den, other, ONE, '/'); } } else if (RB_FLOAT_TYPE_P(other)) { VALUE v = nurat_to_f(self); return rb_flo_div_flo(v, other); } else if (RB_TYPE_P(other, T_RATIONAL)) { if (f_zero_p(other)) rb_num_zerodiv(); { get_dat2(self, other); if (f_one_p(self)) return f_rational_new_no_reduce2(CLASS_OF(self), bdat->den, bdat->num); return f_muldiv(self, adat->num, adat->den, bdat->num, bdat->den, '/'); } } else { return rb_num_coerce_bin(self, other, '/'); } };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Rational#quo;F;7[[I" other;T0;[[@ri;T;;;0;[;{;IC; "Performs division. Rational(2, 3) / Rational(2, 3) #=> (1/1) Rational(900) / Rational(1) #=> (900/1) Rational(-2, 9) / Rational(-9, 2) #=> (4/81) Rational(9, 8) / 4 #=> (9/32) Rational(20, 9) / 9.8 #=> 0.22675736961451246 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"/(numeric);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@q;![;"I"@return [Numeric];T;#0;$@q;.F;Bi;C0;7[[I" numeric;T0;$@qo;= ;>I" overload;F;?0;;;@0;:I"quo(numeric);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Numeric;T;$@q;![;"I"@return [Numeric];T;#0;$@q;.F;Bi;C0;7[[I" numeric;T0;$@q;![;"@q;#0;$@q;.F;/o;0;1T;2ir;3i~;%@q;9I"VALUE rb_rational_div(VALUE self, VALUE other) { if (RB_INTEGER_TYPE_P(other)) { if (f_zero_p(other)) rb_num_zerodiv(); { get_dat1(self); return f_muldiv(self, dat->num, dat->den, other, ONE, '/'); } } else if (RB_FLOAT_TYPE_P(other)) { VALUE v = nurat_to_f(self); return rb_flo_div_flo(v, other); } else if (RB_TYPE_P(other, T_RATIONAL)) { if (f_zero_p(other)) rb_num_zerodiv(); { get_dat2(self, other); if (f_one_p(self)) return f_rational_new_no_reduce2(CLASS_OF(self), bdat->den, bdat->num); return f_muldiv(self, adat->num, adat->den, bdat->num, bdat->den, '/'); } } else { return rb_num_coerce_bin(self, other, '/'); } };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Rational#fdiv;F;7[[I" other;T0;[[@ri;T;;;0;[;{;IC; "Performs division and returns the value as a Float. Rational(2, 3).fdiv(1) #=> 0.6666666666666666 Rational(2, 3).fdiv(0.5) #=> 1.3333333333333333 Rational(2).fdiv(3) #=> 0.6666666666666666 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"fdiv(numeric);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@r;![;"I"@return [Float];T;#0;$@r;.F;Bi;C0;7[[I" numeric;T0;$@r;![;"I"Performs division and returns the value as a Float. Rational(2, 3).fdiv(1) #=> 0.6666666666666666 Rational(2, 3).fdiv(0.5) #=> 1.3333333333333333 Rational(2).fdiv(3) #=> 0.6666666666666666 @overload fdiv(numeric) @return [Float];T;#0;$@r;.F;/o;0;1T;2i;3i;%@q;9I"static VALUE nurat_fdiv(VALUE self, VALUE other) { VALUE div; if (f_zero_p(other)) return rb_rational_div(self, rb_float_new(0.0)); if (FIXNUM_P(other) && other == LONG2FIX(1)) return nurat_to_f(self); div = rb_rational_div(self, other); if (RB_TYPE_P(div, T_RATIONAL)) return nurat_to_f(div); if (RB_FLOAT_TYPE_P(div)) return div; return rb_funcall(div, idTo_f, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Rational#**;F;7[;[;F;;;;;[;{;IC; " ;T;[;![;"@;#0;$@:r;%@q;;To;4;5F;6;;;;&I"Rational#<=>;F;7[[I" other;T0;[[@ri+;T;;Y;0;[;{;IC; "Returns -1, 0, or +1 depending on whether +rational+ is less than, equal to, or greater than +numeric+. +nil+ is returned if the two values are incomparable. Rational(2, 3) <=> Rational(2, 3) #=> 0 Rational(5) <=> 5 #=> 0 Rational(2, 3) <=> Rational(1, 3) #=> 1 Rational(1, 3) <=> 1 #=> -1 Rational(1, 3) <=> 0.3 #=> 1 Rational(1, 3) <=> "0.3" #=> nil ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I"<=>(numeric);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[ I"-1;TI"0;TI"+1;TI"nil;T;$@Cr;![;"I" @return [ -1, 0, +1, nil];T;#0;$@Cr;.F;Bi;C0;7[[I" numeric;T0;$@Cr;![;"I"Returns -1, 0, or +1 depending on whether +rational+ is less than, equal to, or greater than +numeric+. +nil+ is returned if the two values are incomparable. Rational(2, 3) <=> Rational(2, 3) #=> 0 Rational(5) <=> 5 #=> 0 Rational(2, 3) <=> Rational(1, 3) #=> 1 Rational(1, 3) <=> 1 #=> -1 Rational(1, 3) <=> 0.3 #=> 1 Rational(1, 3) <=> "0.3" #=> nil @overload <=>(numeric) @return [ -1, 0, +1, nil];T;#0;$@Cr;.F;/o;0;1T;2i;3i);%@q;9I"VALUE rb_rational_cmp(VALUE self, VALUE other) { switch (TYPE(other)) { case T_FIXNUM: case T_BIGNUM: { get_dat1(self); if (dat->den == LONG2FIX(1)) return rb_int_cmp(dat->num, other); /* c14n */ other = f_rational_new_bang1(CLASS_OF(self), other); /* FALLTHROUGH */ } case T_RATIONAL: { VALUE num1, num2; get_dat2(self, other); if (FIXNUM_P(adat->num) && FIXNUM_P(adat->den) && FIXNUM_P(bdat->num) && FIXNUM_P(bdat->den)) { num1 = f_imul(FIX2LONG(adat->num), FIX2LONG(bdat->den)); num2 = f_imul(FIX2LONG(bdat->num), FIX2LONG(adat->den)); } else { num1 = rb_int_mul(adat->num, bdat->den); num2 = rb_int_mul(bdat->num, adat->den); } return rb_int_cmp(rb_int_minus(num1, num2), ZERO); } case T_FLOAT: return rb_dbl_cmp(nurat_to_double(self), RFLOAT_VALUE(other)); default: return rb_num_coerce_cmp(self, other, idCmp); } };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Rational#==;F;7[[I" other;T0;[[@ri`;T;;F;0;[;{;IC; "'Returns +true+ if +rat+ equals +object+ numerically. Rational(2, 3) == Rational(2, 3) #=> true Rational(5) == 5 #=> true Rational(0) == 0.0 #=> true Rational('1/3') == 0.33 #=> false Rational('1/2') == '1/2' #=> false ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(object);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@er;![;"I"@return [Boolean];T;#0;$@er;.F;Bi;C0;7[[I" object;T0;$@er;![;"I"RReturns +true+ if +rat+ equals +object+ numerically. Rational(2, 3) == Rational(2, 3) #=> true Rational(5) == 5 #=> true Rational(0) == 0.0 #=> true Rational('1/3') == 0.33 #=> false Rational('1/2') == '1/2' #=> false @overload ==(object) @return [Boolean];T;#0;$@er;.F;/o;0;1T;2iT;3i^;%@q;9I"static VALUE nurat_eqeq_p(VALUE self, VALUE other) { if (RB_INTEGER_TYPE_P(other)) { get_dat1(self); if (RB_INTEGER_TYPE_P(dat->num) && RB_INTEGER_TYPE_P(dat->den)) { if (INT_ZERO_P(dat->num) && INT_ZERO_P(other)) return Qtrue; if (!FIXNUM_P(dat->den)) return Qfalse; if (FIX2LONG(dat->den) != 1) return Qfalse; return rb_int_equal(dat->num, other); } else { const double d = nurat_to_double(self); return RBOOL(FIXNUM_ZERO_P(rb_dbl_cmp(d, NUM2DBL(other)))); } } else if (RB_FLOAT_TYPE_P(other)) { const double d = nurat_to_double(self); return RBOOL(FIXNUM_ZERO_P(rb_dbl_cmp(d, RFLOAT_VALUE(other)))); } else if (RB_TYPE_P(other, T_RATIONAL)) { { get_dat2(self, other); if (INT_ZERO_P(adat->num) && INT_ZERO_P(bdat->num)) return Qtrue; return RBOOL(rb_int_equal(adat->num, bdat->num) && rb_int_equal(adat->den, bdat->den)); } } else { return rb_equal(other, self); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Rational#coerce;F;7[[I" other;T0;[[@ri;T;;;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@r;.F;/o;0;1T;2i;3i;%@q;9I"static VALUE nurat_coerce(VALUE self, VALUE other) { if (RB_INTEGER_TYPE_P(other)) { return rb_assoc_new(f_rational_new_bang1(CLASS_OF(self), other), self); } else if (RB_FLOAT_TYPE_P(other)) { return rb_assoc_new(other, nurat_to_f(self)); } else if (RB_TYPE_P(other, T_RATIONAL)) { return rb_assoc_new(other, self); } else if (RB_TYPE_P(other, T_COMPLEX)) { if (!k_exact_zero_p(RCOMPLEX(other)->imag)) return rb_assoc_new(other, rb_Complex(self, INT2FIX(0))); other = RCOMPLEX(other)->real; if (RB_FLOAT_TYPE_P(other)) { other = float_to_r(other); RBASIC_SET_CLASS(other, CLASS_OF(self)); } else { other = f_rational_new_bang1(CLASS_OF(self), other); } return rb_assoc_new(other, self); } rb_raise(rb_eTypeError, "%s can't be coerced into %s", rb_obj_classname(other), rb_obj_classname(self)); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Rational#positive?;F;7[;[[@ri;T;;;0;[;{;IC; "/Returns +true+ if +rat+ is greater than 0.;T;[o;= ;>I" overload;F;?0;;;@0;:I"positive?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@r;![;"I"@return [Boolean];T;#0;$@r;.F;Bi;C0;7[;$@r;![;"I"YReturns +true+ if +rat+ is greater than 0. @overload positive? @return [Boolean];T;#0;$@r;.F;/o;0;1T;2i;3i;Bi;%@q;9I"rstatic VALUE nurat_positive_p(VALUE self) { get_dat1(self); return RBOOL(INT_POSITIVE_P(dat->num)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Rational#negative?;F;7[;[[@ri;T;;;0;[;{;IC; ",Returns +true+ if +rat+ is less than 0.;T;[o;= ;>I" overload;F;?0;;;@0;:I"negative?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@r;![;"I"@return [Boolean];T;#0;$@r;.F;Bi;C0;7[;$@r;![;"I"VReturns +true+ if +rat+ is less than 0. @overload negative? @return [Boolean];T;#0;$@r;.F;/o;0;1T;2i;3i;Bi;%@q;9I"rstatic VALUE nurat_negative_p(VALUE self) { get_dat1(self); return RBOOL(INT_NEGATIVE_P(dat->num)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Rational#abs;F;7[;[[@ri;T;;;0;[;{;IC; "Returns the absolute value of +rat+. (1/2r).abs #=> (1/2) (-1/2r).abs #=> (1/2) Rational#magnitude is an alias for Rational#abs. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"abs;T;IC; ";T;[;![;"I";T;#0;$@r;.F;Bi;C0;7[;$@ro;= ;>I" overload;F;?0;;;@0;:I"magnitude;T;IC; ";T;[;![;"I";T;#0;$@r;.F;Bi;C0;7[;$@r;![;"I"Returns the absolute value of +rat+. (1/2r).abs #=> (1/2) (-1/2r).abs #=> (1/2) Rational#magnitude is an alias for Rational#abs. @overload abs @overload magnitude;T;#0;$@r;.F;/o;0;1T;2i;3i;%@q;9I"VALUE rb_rational_abs(VALUE self) { get_dat1(self); if (INT_NEGATIVE_P(dat->num)) { VALUE num = rb_int_abs(dat->num); return nurat_s_canonicalize_internal_no_reduce(CLASS_OF(self), num, dat->den); } return self; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Rational#magnitude;F;7[;[[@ri;T;;;0;[;{;IC; "Returns the absolute value of +rat+. (1/2r).abs #=> (1/2) (-1/2r).abs #=> (1/2) Rational#magnitude is an alias for Rational#abs. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"abs;T;IC; ";T;[;![;"I";T;#0;$@r;.F;Bi;C0;7[;$@ro;= ;>I" overload;F;?0;;;@0;:I"magnitude;T;IC; ";T;[;![;"I";T;#0;$@r;.F;Bi;C0;7[;$@r;![;"@r;#0;$@r;.F;/o;0;1T;2i;3i;%@q;9I"VALUE rb_rational_abs(VALUE self) { get_dat1(self); if (INT_NEGATIVE_P(dat->num)) { VALUE num = rb_int_abs(dat->num); return nurat_s_canonicalize_internal_no_reduce(CLASS_OF(self), num, dat->den); } return self; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Rational#floor;F;7[[@90;[[@ri;T;;;0;[;{;IC; "Returns the largest number less than or equal to +rat+ with a precision of +ndigits+ decimal digits (default: 0). When the precision is negative, the returned value is an integer with at least ndigits.abs trailing zeros. Returns a rational when +ndigits+ is positive, otherwise returns an integer. Rational(3).floor #=> 3 Rational(2, 3).floor #=> 0 Rational(-3, 2).floor #=> -2 # decimal - 1 2 3 . 4 5 6 # ^ ^ ^ ^ ^ ^ # precision -3 -2 -1 0 +1 +2 Rational('-123.456').floor(+1).to_f #=> -123.5 Rational('-123.456').floor(-1) #=> -130 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"floor([ndigits]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@s;![;"I"@return [Integer];T;#0;$@s;.F;Bi;C0;7[[I"[ndigits];T0;$@s;![;"I"Returns the largest number less than or equal to +rat+ with a precision of +ndigits+ decimal digits (default: 0). When the precision is negative, the returned value is an integer with at least ndigits.abs trailing zeros. Returns a rational when +ndigits+ is positive, otherwise returns an integer. Rational(3).floor #=> 3 Rational(2, 3).floor #=> 0 Rational(-3, 2).floor #=> -2 # decimal - 1 2 3 . 4 5 6 # ^ ^ ^ ^ ^ ^ # precision -3 -2 -1 0 +1 +2 Rational('-123.456').floor(+1).to_f #=> -123.5 Rational('-123.456').floor(-1) #=> -130 @overload floor([ndigits]) @return [Integer];T;#0;$@s;.F;/o;0;1T;2i|;3i;%@q;9I"{static VALUE nurat_floor_n(int argc, VALUE *argv, VALUE self) { return f_round_common(argc, argv, self, nurat_floor); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Rational#ceil;F;7[[@90;[[@ri;T;;;0;[;{;IC; "Returns the smallest number greater than or equal to +rat+ with a precision of +ndigits+ decimal digits (default: 0). When the precision is negative, the returned value is an integer with at least ndigits.abs trailing zeros. Returns a rational when +ndigits+ is positive, otherwise returns an integer. Rational(3).ceil #=> 3 Rational(2, 3).ceil #=> 1 Rational(-3, 2).ceil #=> -1 # decimal - 1 2 3 . 4 5 6 # ^ ^ ^ ^ ^ ^ # precision -3 -2 -1 0 +1 +2 Rational('-123.456').ceil(+1).to_f #=> -123.4 Rational('-123.456').ceil(-1) #=> -120 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ceil([ndigits]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@#s;![;"I"@return [Integer];T;#0;$@#s;.F;Bi;C0;7[[I"[ndigits];T0;$@#s;![;"I"Returns the smallest number greater than or equal to +rat+ with a precision of +ndigits+ decimal digits (default: 0). When the precision is negative, the returned value is an integer with at least ndigits.abs trailing zeros. Returns a rational when +ndigits+ is positive, otherwise returns an integer. Rational(3).ceil #=> 3 Rational(2, 3).ceil #=> 1 Rational(-3, 2).ceil #=> -1 # decimal - 1 2 3 . 4 5 6 # ^ ^ ^ ^ ^ ^ # precision -3 -2 -1 0 +1 +2 Rational('-123.456').ceil(+1).to_f #=> -123.4 Rational('-123.456').ceil(-1) #=> -120 @overload ceil([ndigits]) @return [Integer];T;#0;$@#s;.F;/o;0;1T;2i;3i;%@q;9I"~static VALUE nurat_ceil_n(int argc, VALUE *argv, VALUE self) { return f_round_common(argc, argv, self, nurat_ceil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Rational#truncate;F;7[[@90;[[@ri;T;;_;0;[;{;IC; "~Returns +rat+ truncated (toward zero) to a precision of +ndigits+ decimal digits (default: 0). When the precision is negative, the returned value is an integer with at least ndigits.abs trailing zeros. Returns a rational when +ndigits+ is positive, otherwise returns an integer. Rational(3).truncate #=> 3 Rational(2, 3).truncate #=> 0 Rational(-3, 2).truncate #=> -1 # decimal - 1 2 3 . 4 5 6 # ^ ^ ^ ^ ^ ^ # precision -3 -2 -1 0 +1 +2 Rational('-123.456').truncate(+1).to_f #=> -123.4 Rational('-123.456').truncate(-1) #=> -120 ;T;[o;= ;>I" overload;F;?0;;_;@0;:I"truncate([ndigits]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@As;![;"I"@return [Integer];T;#0;$@As;.F;Bi;C0;7[[I"[ndigits];T0;$@As;![;"I"Returns +rat+ truncated (toward zero) to a precision of +ndigits+ decimal digits (default: 0). When the precision is negative, the returned value is an integer with at least ndigits.abs trailing zeros. Returns a rational when +ndigits+ is positive, otherwise returns an integer. Rational(3).truncate #=> 3 Rational(2, 3).truncate #=> 0 Rational(-3, 2).truncate #=> -1 # decimal - 1 2 3 . 4 5 6 # ^ ^ ^ ^ ^ ^ # precision -3 -2 -1 0 +1 +2 Rational('-123.456').truncate(+1).to_f #=> -123.4 Rational('-123.456').truncate(-1) #=> -120 @overload truncate([ndigits]) @return [Integer];T;#0;$@As;.F;/o;0;1T;2i;3i;%@q;9I"static VALUE nurat_truncate_n(int argc, VALUE *argv, VALUE self) { return f_round_common(argc, argv, self, nurat_truncate); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Rational#round;F;7[[@90;[[@ri;T;;;0;[;{;IC; "Returns +rat+ rounded to the nearest value with a precision of +ndigits+ decimal digits (default: 0). When the precision is negative, the returned value is an integer with at least ndigits.abs trailing zeros. Returns a rational when +ndigits+ is positive, otherwise returns an integer. Rational(3).round #=> 3 Rational(2, 3).round #=> 1 Rational(-3, 2).round #=> -2 # decimal - 1 2 3 . 4 5 6 # ^ ^ ^ ^ ^ ^ # precision -3 -2 -1 0 +1 +2 Rational('-123.456').round(+1).to_f #=> -123.5 Rational('-123.456').round(-1) #=> -120 The optional +half+ keyword argument is available similar to Float#round. Rational(25, 100).round(1, half: :up) #=> (3/10) Rational(25, 100).round(1, half: :down) #=> (1/5) Rational(25, 100).round(1, half: :even) #=> (1/5) Rational(35, 100).round(1, half: :up) #=> (2/5) Rational(35, 100).round(1, half: :down) #=> (3/10) Rational(35, 100).round(1, half: :even) #=> (2/5) Rational(-25, 100).round(1, half: :up) #=> (-3/10) Rational(-25, 100).round(1, half: :down) #=> (-1/5) Rational(-25, 100).round(1, half: :even) #=> (-1/5) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"$round([ndigits] [, half: mode]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@_s;![;"I"@return [Integer];T;#0;$@_s;.F;Bi;C0;7[[I"[ndigits][, half:;TI" mode];T;$@_s;![;"I"Returns +rat+ rounded to the nearest value with a precision of +ndigits+ decimal digits (default: 0). When the precision is negative, the returned value is an integer with at least ndigits.abs trailing zeros. Returns a rational when +ndigits+ is positive, otherwise returns an integer. Rational(3).round #=> 3 Rational(2, 3).round #=> 1 Rational(-3, 2).round #=> -2 # decimal - 1 2 3 . 4 5 6 # ^ ^ ^ ^ ^ ^ # precision -3 -2 -1 0 +1 +2 Rational('-123.456').round(+1).to_f #=> -123.5 Rational('-123.456').round(-1) #=> -120 The optional +half+ keyword argument is available similar to Float#round. Rational(25, 100).round(1, half: :up) #=> (3/10) Rational(25, 100).round(1, half: :down) #=> (1/5) Rational(25, 100).round(1, half: :even) #=> (1/5) Rational(35, 100).round(1, half: :up) #=> (2/5) Rational(35, 100).round(1, half: :down) #=> (3/10) Rational(35, 100).round(1, half: :even) #=> (2/5) Rational(-25, 100).round(1, half: :up) #=> (-3/10) Rational(-25, 100).round(1, half: :down) #=> (-1/5) Rational(-25, 100).round(1, half: :even) #=> (-1/5) @overload round([ndigits] [, half: mode]) @return [Integer];T;#0;$@_s;.F;/o;0;1T;2i;3i;%@q;9I"Pstatic VALUE nurat_round_n(int argc, VALUE *argv, VALUE self) { VALUE opt; enum ruby_num_rounding_mode mode = ( argc = rb_scan_args(argc, argv, "*:", NULL, &opt), rb_num_get_rounding_option(opt)); VALUE (*round_func)(VALUE) = ROUND_FUNC(mode, nurat_round); return f_round_common(argc, argv, self, round_func); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Rational#to_i;F;7[;[[@ri;T;;;0;[;{;IC; "Returns the truncated value as an integer. Equivalent to Rational#truncate. Rational(2, 3).to_i #=> 0 Rational(3).to_i #=> 3 Rational(300.6).to_i #=> 300 Rational(98, 71).to_i #=> 1 Rational(-31, 2).to_i #=> -15 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_i;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@~s;![;"I"@return [Integer];T;#0;$@~s;.F;Bi;C0;7[;$@~s;![;"I"Returns the truncated value as an integer. Equivalent to Rational#truncate. Rational(2, 3).to_i #=> 0 Rational(3).to_i #=> 3 Rational(300.6).to_i #=> 300 Rational(98, 71).to_i #=> 1 Rational(-31, 2).to_i #=> -15 @overload to_i @return [Integer];T;#0;$@~s;.F;/o;0;1T;2i;3i;%@q;9I"static VALUE nurat_truncate(VALUE self) { get_dat1(self); if (INT_NEGATIVE_P(dat->num)) return rb_int_uminus(rb_int_idiv(rb_int_uminus(dat->num), dat->den)); return rb_int_idiv(dat->num, dat->den); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Rational#to_f;F;7[;[[@ri!;T;;;0;[;{;IC; "Returns the value as a Float. Rational(2).to_f #=> 2.0 Rational(9, 4).to_f #=> 2.25 Rational(-3, 4).to_f #=> -0.75 Rational(20, 3).to_f #=> 6.666666666666667 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_f;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@s;![;"I"@return [Float];T;#0;$@s;.F;Bi;C0;7[;$@s;![;"I"Returns the value as a Float. Rational(2).to_f #=> 2.0 Rational(9, 4).to_f #=> 2.25 Rational(-3, 4).to_f #=> -0.75 Rational(20, 3).to_f #=> 6.666666666666667 @overload to_f @return [Float];T;#0;$@s;.F;/o;0;1T;2i;3i;%@q;9I"Wstatic VALUE nurat_to_f(VALUE self) { return DBL2NUM(nurat_to_double(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Rational#to_r;F;7[;[[@ri0;T;;;0;[;{;IC; "ZReturns self. Rational(2).to_r #=> (2/1) Rational(-8, 6).to_r #=> (-4/3) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_r;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@s;![;"I"@return [self];T;#0;$@s;.F;Bi;C0;7[;$@s;![;"I"|Returns self. Rational(2).to_r #=> (2/1) Rational(-8, 6).to_r #=> (-4/3) @overload to_r @return [self];T;#0;$@s;.F;/o;0;1T;2i';3i.;%@q;9I"=static VALUE nurat_to_r(VALUE self) { return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Rational#rationalize;F;7[[@90;[[@ri;T;;;0;[;{;IC; "DReturns a simpler approximation of the value if the optional argument +eps+ is given (rat-|eps| <= result <= rat+|eps|), self otherwise. r = Rational(5033165, 16777216) r.rationalize #=> (5033165/16777216) r.rationalize(Rational('0.01')) #=> (3/10) r.rationalize(Rational('0.1')) #=> (1/3) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"rationalize;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" self;T;$@s;![;"I"@return [self];T;#0;$@s;.F;Bi;C0;7[;$@so;= ;>I" overload;F;?0;;;@0;:I"rationalize(eps);T;IC; ";T;[;![;"I";T;#0;$@s;.F;Bi;C0;7[[I"eps;T0;$@s;![;"I"Returns a simpler approximation of the value if the optional argument +eps+ is given (rat-|eps| <= result <= rat+|eps|), self otherwise. r = Rational(5033165, 16777216) r.rationalize #=> (5033165/16777216) r.rationalize(Rational('0.01')) #=> (3/10) r.rationalize(Rational('0.1')) #=> (1/3) @overload rationalize @return [self] @overload rationalize(eps);T;#0;$@s;.F;/o;0;1T;2i;3i;%@q;9I"static VALUE nurat_rationalize(int argc, VALUE *argv, VALUE self) { VALUE e, a, b, p, q; VALUE rat = self; get_dat1(self); if (rb_check_arity(argc, 0, 1) == 0) return self; e = f_abs(argv[0]); if (INT_NEGATIVE_P(dat->num)) { rat = f_rational_new2(RBASIC_CLASS(self), rb_int_uminus(dat->num), dat->den); } a = FIXNUM_ZERO_P(e) ? rat : rb_rational_minus(rat, e); b = FIXNUM_ZERO_P(e) ? rat : rb_rational_plus(rat, e); if (f_eqeq_p(a, b)) return self; nurat_rationalize_internal(a, b, &p, &q); if (rat != self) { RATIONAL_SET_NUM(rat, rb_int_uminus(p)); RATIONAL_SET_DEN(rat, q); return rat; } return f_rational_new2(CLASS_OF(self), p, q); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Rational#hash;F;7[;[[@ri;T;;X;0;[;{;IC; " ;T;[;![;"@;#0;$@s;%@q;9I"Wstatic VALUE nurat_hash(VALUE self) { return ST2FIX(rb_rational_hash(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Rational#to_s;F;7[;[[@ri;T;;G;0;[;{;IC; "Returns the value as a string. Rational(2).to_s #=> "2/1" Rational(-8, 6).to_s #=> "-4/3" Rational('1/2').to_s #=> "1/2" ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@t;![;"I"@return [String];T;#0;$@t;.F;Bi;C0;7[;$@t;![;"I"Returns the value as a string. Rational(2).to_s #=> "2/1" Rational(-8, 6).to_s #=> "-4/3" Rational('1/2').to_s #=> "1/2" @overload to_s @return [String];T;#0;$@t;.F;/o;0;1T;2i;3i;%@q;9I"Ostatic VALUE nurat_to_s(VALUE self) { return f_format(self, f_to_s); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Rational#inspect;F;7[;[[@ri;T;;J;0;[;{;IC; "Returns the value as a string for inspection. Rational(2).inspect #=> "(2/1)" Rational(-8, 6).inspect #=> "(-4/3)" Rational('1/2').inspect #=> "(1/2)" ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@t;![;"I"@return [String];T;#0;$@t;.F;Bi;C0;7[;$@t;![;"I"Returns the value as a string for inspection. Rational(2).inspect #=> "(2/1)" Rational(-8, 6).inspect #=> "(-4/3)" Rational('1/2').inspect #=> "(1/2)" @overload inspect @return [String];T;#0;$@t;.F;/o;0;1T;2i ;3i;%@q;9I"static VALUE nurat_inspect(VALUE self) { VALUE s; s = rb_usascii_str_new2("("); rb_str_concat(s, f_format(self, f_inspect)); rb_str_cat2(s, ")"); return s; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Rational#marshal_dump;F;7[;[[@ri:;T;;[;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@7t;.F;/o;0;1T;2i9;3i9;%@q;9I"static VALUE nurat_marshal_dump(VALUE self) { VALUE a; get_dat1(self); a = rb_assoc_new(dat->num, dat->den); rb_copy_generic_ivar(a, self); return a; };T;:I"static VALUE;T;;To; ;IC;[o;4;5F;6;;;;&I"&Rational::compatible#marshal_load;F;7[[I"a;T0;[[@riF;T;;;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@Gt;.F;/o;0;1T;2iE;3iE;%@Et;9I"static VALUE nurat_marshal_load(VALUE self, VALUE a) { VALUE num, den; rb_check_frozen(self); Check_Type(a, T_ARRAY); if (RARRAY_LEN(a) != 2) rb_raise(rb_eArgError, "marshaled rational must have an array whose length is 2 but %ld", RARRAY_LEN(a)); num = RARRAY_AREF(a, 0); den = RARRAY_AREF(a, 1); nurat_int_check(num); nurat_int_check(den); nurat_canonicalize(&num, &den); rb_ivar_set(self, id_i_num, num); rb_ivar_set(self, id_i_den, den); return self; };T;:I"static VALUE;T;;T; @Et; IC;[; @Et; IC;[; @Et; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ri ;F;;;;;;;[;{;IC; " ;T;[;![;"@;#0;$@Et;Bi;%@q;&I"Rational::compatible;F;'@; @q; IC;[; @q; IC;[; @q; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ri ;F;;;;;;;[;{;IC; "A rational number can be represented as a pair of integer numbers: a/b (b>0), where a is the numerator and b is the denominator. Integer a equals rational a/1 mathematically. You can create a \Rational object explicitly with: - A {rational literal}[doc/syntax/literals_rdoc.html#label-Rational+Literals]. You can convert certain objects to Rationals with: - \Method {Rational}[Kernel.html#method-i-Rational]. Examples Rational(1) #=> (1/1) Rational(2, 3) #=> (2/3) Rational(4, -6) #=> (-2/3) # Reduced. 3.to_r #=> (3/1) 2/3r #=> (2/3) You can also create rational objects from floating-point numbers or strings. Rational(0.3) #=> (5404319552844595/18014398509481984) Rational('0.3') #=> (3/10) Rational('2/3') #=> (2/3) 0.3.to_r #=> (5404319552844595/18014398509481984) '0.3'.to_r #=> (3/10) '2/3'.to_r #=> (2/3) 0.3.rationalize #=> (3/10) A rational object is an exact number, which helps you to write programs without any rounding errors. 10.times.inject(0) {|t| t + 0.1 } #=> 0.9999999999999999 10.times.inject(0) {|t| t + Rational('0.1') } #=> (1/1) However, when an expression includes an inexact component (numerical value or operation), it will produce an inexact result. Rational(10) / 3 #=> (10/3) Rational(10) / 3.0 #=> 3.3333333333333335 Rational(-8) ** Rational(1, 3) #=> (1.0000000000000002+1.7320508075688772i) ;T;[;![;"I"A rational number can be represented as a pair of integer numbers: a/b (b>0), where a is the numerator and b is the denominator. Integer a equals rational a/1 mathematically. You can create a \Rational object explicitly with: - A {rational literal}[doc/syntax/literals_rdoc.html#label-Rational+Literals]. You can convert certain objects to Rationals with: - \Method {Rational}[Kernel.html#method-i-Rational]. Examples Rational(1) #=> (1/1) Rational(2, 3) #=> (2/3) Rational(4, -6) #=> (-2/3) # Reduced. 3.to_r #=> (3/1) 2/3r #=> (2/3) You can also create rational objects from floating-point numbers or strings. Rational(0.3) #=> (5404319552844595/18014398509481984) Rational('0.3') #=> (3/10) Rational('2/3') #=> (2/3) 0.3.to_r #=> (5404319552844595/18014398509481984) '0.3'.to_r #=> (3/10) '2/3'.to_r #=> (2/3) 0.3.rationalize #=> (3/10) A rational object is an exact number, which helps you to write programs without any rounding errors. 10.times.inject(0) {|t| t + 0.1 } #=> 0.9999999999999999 10.times.inject(0) {|t| t + Rational('0.1') } #=> (1/1) However, when an expression includes an inexact component (numerical value or operation), it will produce an inexact result. Rational(10) / 3 #=> (10/3) Rational(10) / 3.0 #=> 3.3333333333333335 Rational(-8) ** Rational(1, 3) #=> (1.0000000000000002+1.7320508075688772i) ;T;#0;$@q;.F;/o;0;1T;2i ;3i ;%@;&I" Rational;F;'@&o;;IC;[; @wt; IC;[; @wt; IC;[; @wt; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"-ext/-test-/memory_status/memory_status.c;TiJ;F;: Memory;;;;;[;{;IC; " ;T;[;![;"@;#0;$@wt;%@;&I" Memory;Fo; ;IC;[o;4;5F;6;;;;&I"Method#==;F;7[[I" other;T0;[[@i;T;;F;0;[;{;IC; "Two method objects are equal if they are bound to the same object and refer to the same method definition and the classes defining the methods are the same class or module. ;T;[o;= ;>I" overload;F;?0;;V;@0;:I"eql?(other_meth);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@t;![;"I"@return [Boolean];T;#0;$@t;.F;Bi;C0;7[[I"other_meth;T0;$@to;= ;>I" overload;F;?0;;F;@0;:I"==(other_meth);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@t;![;"I"@return [Boolean];T;#0;$@t;.F;Bi;C0;7[[I"other_meth;T0;$@t;![;"I" Two method objects are equal if they are bound to the same object and refer to the same method definition and the classes defining the methods are the same class or module. @overload eql?(other_meth) @return [Boolean] @overload ==(other_meth) @return [Boolean];T;#0;$@t;.F;/o;0;1T;2i;3i;%@t;9I"jstatic VALUE method_eq(VALUE method, VALUE other) { struct METHOD *m1, *m2; VALUE klass1, klass2; if (!rb_obj_is_method(other)) return Qfalse; if (CLASS_OF(method) != CLASS_OF(other)) return Qfalse; Check_TypedStruct(method, &method_data_type); m1 = (struct METHOD *)DATA_PTR(method); m2 = (struct METHOD *)DATA_PTR(other); klass1 = method_entry_defined_class(m1->me); klass2 = method_entry_defined_class(m2->me); if (!rb_method_entry_eq(m1->me, m2->me) || klass1 != klass2 || m1->klass != m2->klass || m1->recv != m2->recv) { return Qfalse; } return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#eql?;F;7[[I" other;T0;[[@i;T;;V;0;[;{;IC; "Two method objects are equal if they are bound to the same object and refer to the same method definition and the classes defining the methods are the same class or module.;T;[o;= ;>I" overload;F;?0;;V;@0;:I"eql?(other_meth);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@t;![;"I"@return [Boolean];T;#0;$@t;.F;Bi;C0;7[[I"other_meth;T0;$@to;= ;>I" overload;F;?0;;F;@0;:I"==(other_meth);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@t;![;"I"@return [Boolean];T;#0;$@t;.F;Bi;C0;7[[I"other_meth;T0;$@t;![;"@t;#0;$@t;.F;/o;0;1T;2i;3i;Bi;%@t;9I"jstatic VALUE method_eq(VALUE method, VALUE other) { struct METHOD *m1, *m2; VALUE klass1, klass2; if (!rb_obj_is_method(other)) return Qfalse; if (CLASS_OF(method) != CLASS_OF(other)) return Qfalse; Check_TypedStruct(method, &method_data_type); m1 = (struct METHOD *)DATA_PTR(method); m2 = (struct METHOD *)DATA_PTR(other); klass1 = method_entry_defined_class(m1->me); klass2 = method_entry_defined_class(m2->me); if (!rb_method_entry_eq(m1->me, m2->me) || klass1 != klass2 || m1->klass != m2->klass || m1->recv != m2->recv) { return Qfalse; } return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#hash;F;7[;[[@i;T;;X;0;[;{;IC; "TReturns a hash value corresponding to the method object. See also Object#hash. ;T;[o;= ;>I" overload;F;?0;;X;@0;:I" hash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@t;![;"I"@return [Integer];T;#0;$@t;.F;Bi;C0;7[;$@t;![;"I"yReturns a hash value corresponding to the method object. See also Object#hash. @overload hash @return [Integer];T;#0;$@t;.F;/o;0;1T;2i;3i;%@t;9I"2static VALUE method_hash(VALUE method) { struct METHOD *m; st_index_t hash; TypedData_Get_Struct(method, struct METHOD, &method_data_type, m); hash = rb_hash_start((st_index_t)m->recv); hash = rb_hash_method_entry(hash, m->me); hash = rb_hash_end(hash); return ST2FIX(hash); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#clone;F;7[;[[@i ;T;;;0;[;{;IC; "Returns a clone of this method. class A def foo return "bar" end end m = A.new.method(:foo) m.call # => "bar" n = m.clone.call # => "bar" ;T;[o;= ;>I" overload;F;?0;;;@0;:I" clone;T;IC; ";T;[;![;"I";T;#0;$@u;.F;Bi;C0;7[;$@u;![;"I"Returns a clone of this method. class A def foo return "bar" end end m = A.new.method(:foo) m.call # => "bar" n = m.clone.call # => "bar" @overload clone;T;#0;$@u;.F;/o;0;1T;2i ;3i ;%@t;9I"static VALUE method_clone(VALUE self) { VALUE clone; struct METHOD *orig, *data; TypedData_Get_Struct(self, struct METHOD, &method_data_type, orig); clone = TypedData_Make_Struct(CLASS_OF(self), struct METHOD, &method_data_type, data); CLONESETUP(clone, self); RB_OBJ_WRITE(clone, &data->recv, orig->recv); RB_OBJ_WRITE(clone, &data->klass, orig->klass); RB_OBJ_WRITE(clone, &data->iclass, orig->iclass); RB_OBJ_WRITE(clone, &data->me, rb_method_entry_clone(orig->me)); return clone; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#call;F;7[[@90;[[@iU ;T;;;0;[;{;IC; "Invokes the meth with the specified arguments, returning the method's return value. m = 12.method("+") m.call(3) #=> 15 m.call(20) #=> 32 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"call(args, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@u;![;"I"@return [Object];T;#0;$@u;.F;Bi;C0;7[[I" args;T0[I"...;T0;$@u;![;"I"Invokes the meth with the specified arguments, returning the method's return value. m = 12.method("+") m.call(3) #=> 15 m.call(20) #=> 32 @overload call(args, ...) @return [Object];T;#0;$@u;.F;/o;0;1T;2iI ;3iR ;%@t;9I"static VALUE rb_method_call_pass_called_kw(int argc, const VALUE *argv, VALUE method) { VALUE procval = rb_block_given_p() ? rb_block_proc() : Qnil; return rb_method_call_with_block_kw(argc, argv, method, procval, RB_PASS_CALLED_KEYWORDS); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#===;F;7[[@90;[[@iU ;T;;S;0;[;{;IC; "Invokes the meth with the specified arguments, returning the method's return value. m = 12.method("+") m.call(3) #=> 15 m.call(20) #=> 32 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"call(args, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@7u;![;"I"@return [Object];T;#0;$@7u;.F;Bi;C0;7[[I" args;T0[I"...;T0;$@7u;![;"@3u;#0;$@7u;.F;/o;0;1T;2iI ;3iR ;%@t;9I"static VALUE rb_method_call_pass_called_kw(int argc, const VALUE *argv, VALUE method) { VALUE procval = rb_block_given_p() ? rb_block_proc() : Qnil; return rb_method_call_with_block_kw(argc, argv, method, procval, RB_PASS_CALLED_KEYWORDS); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#curry;F;7[[@90;[[@i;T;: curry;0;[;{;IC; "PReturns a curried proc based on the method. When the proc is called with a number of arguments that is lower than the method's arity, then another curried proc is returned. Only when enough arguments have been supplied to satisfy the method signature, will the method actually be called. The optional arity argument should be supplied when currying methods with variable arguments to determine how many arguments are needed before the method is called. def foo(a,b,c) [a, b, c] end proc = self.method(:foo).curry proc2 = proc.call(1, 2) #=> # proc2.call(3) #=> [1,2,3] def vararg(*args) args end proc = self.method(:vararg).curry(4) proc2 = proc.call(:x) #=> # proc3 = proc2.call(:y, :z) #=> # proc3.call(:a) #=> [:x, :y, :z, :a] ;T;[o;= ;>I" overload;F;?0;;} ;@0;:I" curry;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@Vu;![;"I"@return [Proc];T;#0;$@Vu;.F;Bi;C0;7[;$@Vuo;= ;>I" overload;F;?0;;} ;@0;:I"curry(arity);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@Vu;![;"I"@return [Proc];T;#0;$@Vu;.F;Bi;C0;7[[I" arity;T0;$@Vu;![;"I"Returns a curried proc based on the method. When the proc is called with a number of arguments that is lower than the method's arity, then another curried proc is returned. Only when enough arguments have been supplied to satisfy the method signature, will the method actually be called. The optional arity argument should be supplied when currying methods with variable arguments to determine how many arguments are needed before the method is called. def foo(a,b,c) [a, b, c] end proc = self.method(:foo).curry proc2 = proc.call(1, 2) #=> # proc2.call(3) #=> [1,2,3] def vararg(*args) args end proc = self.method(:vararg).curry(4) proc2 = proc.call(:x) #=> # proc3 = proc2.call(:y, :z) #=> # proc3.call(:a) #=> [:x, :y, :z, :a] @overload curry @return [Proc] @overload curry(arity) @return [Proc];T;#0;$@Vu;.F;/o;0;1T;2i ;3i;%@t;9I"static VALUE rb_method_curry(int argc, const VALUE *argv, VALUE self) { VALUE proc = method_to_proc(self); return proc_curry(argc, argv, proc); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#<<;F;7[[I"g;T0;[[@i;T;;;0;[;{;IC; "3Returns a proc that is the composition of this method and the given g. The returned proc takes a variable number of arguments, calls g with them then calls this method with the result. def f(x) x * x end f = self.method(:f) g = proc {|x| x + x } p (f << g).call(2) #=> 16 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" <<(g);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@u;![;"I"@return [Proc];T;#0;$@u;.F;Bi;C0;7[[I"g;T0;$@u;![;"I"VReturns a proc that is the composition of this method and the given g. The returned proc takes a variable number of arguments, calls g with them then calls this method with the result. def f(x) x * x end f = self.method(:f) g = proc {|x| x + x } p (f << g).call(2) #=> 16 @overload <<(g) @return [Proc];T;#0;$@u;.F;/o;0;1T;2i;3i;%@t;9I"static VALUE rb_method_compose_to_left(VALUE self, VALUE g) { g = to_callable(g); self = method_to_proc(self); return proc_compose_to_left(self, g); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#>>;F;7[[I"g;T0;[[@i;T;;;0;[;{;IC; "2Returns a proc that is the composition of this method and the given g. The returned proc takes a variable number of arguments, calls this method with them then calls g with the result. def f(x) x * x end f = self.method(:f) g = proc {|x| x + x } p (f >> g).call(2) #=> 8 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" >>(g);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@u;![;"I"@return [Proc];T;#0;$@u;.F;Bi;C0;7[[I"g;T0;$@u;![;"I"UReturns a proc that is the composition of this method and the given g. The returned proc takes a variable number of arguments, calls this method with them then calls g with the result. def f(x) x * x end f = self.method(:f) g = proc {|x| x + x } p (f >> g).call(2) #=> 8 @overload >>(g) @return [Proc];T;#0;$@u;.F;/o;0;1T;2i;3i;%@t;9I"static VALUE rb_method_compose_to_right(VALUE self, VALUE g) { g = to_callable(g); self = method_to_proc(self); return proc_compose_to_right(self, g); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#[];F;7[[@90;[[@iU ;T;;;0;[;{;IC; "Invokes the meth with the specified arguments, returning the method's return value. m = 12.method("+") m.call(3) #=> 15 m.call(20) #=> 32 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"call(args, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@u;![;"I"@return [Object];T;#0;$@u;.F;Bi;C0;7[[I" args;T0[I"...;T0;$@u;![;"@3u;#0;$@u;.F;/o;0;1T;2iI ;3iR ;%@t;9I"static VALUE rb_method_call_pass_called_kw(int argc, const VALUE *argv, VALUE method) { VALUE procval = rb_block_given_p() ? rb_block_proc() : Qnil; return rb_method_call_with_block_kw(argc, argv, method, procval, RB_PASS_CALLED_KEYWORDS); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#arity;F;7[;[[@i ;T;: arity;0;[;{;IC; "Returns an indication of the number of arguments accepted by a method. Returns a nonnegative integer for methods that take a fixed number of arguments. For Ruby methods that take a variable number of arguments, returns -n-1, where n is the number of required arguments. Keyword arguments will be considered as a single additional argument, that argument being mandatory if any keyword argument is mandatory. For methods written in C, returns -1 if the call takes a variable number of arguments. class C def one; end def two(a); end def three(*a); end def four(a, b); end def five(a, b, *c); end def six(a, b, *c, &d); end def seven(a, b, x:0); end def eight(x:, y:); end def nine(x:, y:, **z); end def ten(*a, x:, y:); end end c = C.new c.method(:one).arity #=> 0 c.method(:two).arity #=> 1 c.method(:three).arity #=> -1 c.method(:four).arity #=> 2 c.method(:five).arity #=> -3 c.method(:six).arity #=> -3 c.method(:seven).arity #=> -3 c.method(:eight).arity #=> 1 c.method(:nine).arity #=> 1 c.method(:ten).arity #=> -2 "cat".method(:size).arity #=> 0 "cat".method(:replace).arity #=> 1 "cat".method(:squeeze).arity #=> -1 "cat".method(:count).arity #=> -1 ;T;[o;= ;>I" overload;F;?0;;~ ;@0;:I" arity;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@u;![;"I"@return [Integer];T;#0;$@u;.F;Bi;C0;7[;$@u;![;"I"EReturns an indication of the number of arguments accepted by a method. Returns a nonnegative integer for methods that take a fixed number of arguments. For Ruby methods that take a variable number of arguments, returns -n-1, where n is the number of required arguments. Keyword arguments will be considered as a single additional argument, that argument being mandatory if any keyword argument is mandatory. For methods written in C, returns -1 if the call takes a variable number of arguments. class C def one; end def two(a); end def three(*a); end def four(a, b); end def five(a, b, *c); end def six(a, b, *c, &d); end def seven(a, b, x:0); end def eight(x:, y:); end def nine(x:, y:, **z); end def ten(*a, x:, y:); end end c = C.new c.method(:one).arity #=> 0 c.method(:two).arity #=> 1 c.method(:three).arity #=> -1 c.method(:four).arity #=> 2 c.method(:five).arity #=> -3 c.method(:six).arity #=> -3 c.method(:seven).arity #=> -3 c.method(:eight).arity #=> 1 c.method(:nine).arity #=> 1 c.method(:ten).arity #=> -2 "cat".method(:size).arity #=> 0 "cat".method(:replace).arity #=> 1 "cat".method(:squeeze).arity #=> -1 "cat".method(:count).arity #=> -1 @overload arity @return [Integer];T;#0;$@u;.F;/o;0;1T;2i ;3i ;%@t;9I"kstatic VALUE method_arity_m(VALUE method) { int n = method_arity(method); return INT2FIX(n); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#inspect;F;7[;[[@i ;T;;J;0;[;{;IC; "2Returns a human-readable description of the underlying method. "cat".method(:count).inspect #=> "#" (1..3).method(:map).inspect #=> "#" In the latter case, the method description includes the "owner" of the original method (+Enumerable+ module, which is included into +Range+). +inspect+ also provides, when possible, method argument names (call sequence) and source location. require 'net/http' Net::HTTP.method(:get).inspect #=> "#/lib/ruby/2.7.0/net/http.rb:457>" ... in argument definition means argument is optional (has some default value). For methods defined in C (language core and extensions), location and argument names can't be extracted, and only generic information is provided in form of * (any number of arguments) or _ (some positional argument). "cat".method(:count).inspect #=> "#" "cat".method(:+).inspect #=> "#"" ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@u;![;"I"@return [String];T;#0;$@u;.F;Bi;C0;7[;$@uo;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@u;![;"I"@return [String];T;#0;$@u;.F;Bi;C0;7[;$@u;![;"I"|Returns a human-readable description of the underlying method. "cat".method(:count).inspect #=> "#" (1..3).method(:map).inspect #=> "#" In the latter case, the method description includes the "owner" of the original method (+Enumerable+ module, which is included into +Range+). +inspect+ also provides, when possible, method argument names (call sequence) and source location. require 'net/http' Net::HTTP.method(:get).inspect #=> "#/lib/ruby/2.7.0/net/http.rb:457>" ... in argument definition means argument is optional (has some default value). For methods defined in C (language core and extensions), location and argument names can't be extracted, and only generic information is provided in form of * (any number of arguments) or _ (some positional argument). "cat".method(:count).inspect #=> "#" "cat".method(:+).inspect #=> "#"" @overload to_s @return [String] @overload inspect @return [String];T;#0;$@u;.F;/o;0;1T;2i ;3i ;%@t;9I"zstatic VALUE method_inspect(VALUE method) { struct METHOD *data; VALUE str; const char *sharp = "#"; VALUE mklass; VALUE defined_class; TypedData_Get_Struct(method, struct METHOD, &method_data_type, data); str = rb_sprintf("#<% "PRIsVALUE": ", rb_obj_class(method)); mklass = data->iclass; if (!mklass) mklass = data->klass; if (RB_TYPE_P(mklass, T_ICLASS)) { /* TODO: I'm not sure why mklass is T_ICLASS. * UnboundMethod#bind() can set it as T_ICLASS at convert_umethod_to_method_components() * but not sure it is needed. */ mklass = RBASIC_CLASS(mklass); } if (data->me->def->type == VM_METHOD_TYPE_ALIAS) { defined_class = data->me->def->body.alias.original_me->owner; } else { defined_class = method_entry_defined_class(data->me); } if (RB_TYPE_P(defined_class, T_ICLASS)) { defined_class = RBASIC_CLASS(defined_class); } if (FL_TEST(mklass, FL_SINGLETON)) { VALUE v = rb_ivar_get(mklass, attached); if (data->recv == Qundef) { rb_str_buf_append(str, rb_inspect(mklass)); } else if (data->recv == v) { rb_str_buf_append(str, rb_inspect(v)); sharp = "."; } else { rb_str_buf_append(str, rb_inspect(data->recv)); rb_str_buf_cat2(str, "("); rb_str_buf_append(str, rb_inspect(v)); rb_str_buf_cat2(str, ")"); sharp = "."; } } else { mklass = data->klass; if (FL_TEST(mklass, FL_SINGLETON)) { VALUE v = rb_ivar_get(mklass, attached); if (!(RB_TYPE_P(v, T_CLASS) || RB_TYPE_P(v, T_MODULE))) { do { mklass = RCLASS_SUPER(mklass); } while (RB_TYPE_P(mklass, T_ICLASS)); } } rb_str_buf_append(str, rb_inspect(mklass)); if (defined_class != mklass) { rb_str_catf(str, "(% "PRIsVALUE")", defined_class); } } rb_str_buf_cat2(str, sharp); rb_str_append(str, rb_id2str(data->me->called_id)); if (data->me->called_id != data->me->def->original_id) { rb_str_catf(str, "(%"PRIsVALUE")", rb_id2str(data->me->def->original_id)); } if (data->me->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) { rb_str_buf_cat2(str, " (not-implemented)"); } // parameter information { VALUE params = rb_method_parameters(method); VALUE pair, name, kind; const VALUE req = ID2SYM(rb_intern("req")); const VALUE opt = ID2SYM(rb_intern("opt")); const VALUE keyreq = ID2SYM(rb_intern("keyreq")); const VALUE key = ID2SYM(rb_intern("key")); const VALUE rest = ID2SYM(rb_intern("rest")); const VALUE keyrest = ID2SYM(rb_intern("keyrest")); const VALUE block = ID2SYM(rb_intern("block")); const VALUE nokey = ID2SYM(rb_intern("nokey")); int forwarding = 0; rb_str_buf_cat2(str, "("); for (int i = 0; i < RARRAY_LEN(params); i++) { pair = RARRAY_AREF(params, i); kind = RARRAY_AREF(pair, 0); name = RARRAY_AREF(pair, 1); // FIXME: in tests it turns out that kind, name = [:req] produces name to be false. Why?.. if (NIL_P(name) || name == Qfalse) { // FIXME: can it be reduced to switch/case? if (kind == req || kind == opt) { name = rb_str_new2("_"); } else if (kind == rest || kind == keyrest) { name = rb_str_new2(""); } else if (kind == block) { name = rb_str_new2("block"); } else if (kind == nokey) { name = rb_str_new2("nil"); } } if (kind == req) { rb_str_catf(str, "%"PRIsVALUE, name); } else if (kind == opt) { rb_str_catf(str, "%"PRIsVALUE"=...", name); } else if (kind == keyreq) { rb_str_catf(str, "%"PRIsVALUE":", name); } else if (kind == key) { rb_str_catf(str, "%"PRIsVALUE": ...", name); } else if (kind == rest) { if (name == ID2SYM('*')) { forwarding = 1; rb_str_cat_cstr(str, "..."); } else { rb_str_catf(str, "*%"PRIsVALUE, name); } } else if (kind == keyrest) { if (name != ID2SYM(idPow)) { rb_str_catf(str, "**%"PRIsVALUE, name); } else if (i > 0) { rb_str_set_len(str, RSTRING_LEN(str) - 2); } } else if (kind == block) { if (name == ID2SYM('&')) { if (forwarding) { rb_str_set_len(str, RSTRING_LEN(str) - 2); } else { rb_str_cat_cstr(str, "..."); } } else { rb_str_catf(str, "&%"PRIsVALUE, name); } } else if (kind == nokey) { rb_str_buf_cat2(str, "**nil"); } if (i < RARRAY_LEN(params) - 1) { rb_str_buf_cat2(str, ", "); } } rb_str_buf_cat2(str, ")"); } { // source location VALUE loc = rb_method_location(method); if (!NIL_P(loc)) { rb_str_catf(str, " %"PRIsVALUE":%"PRIsVALUE, RARRAY_AREF(loc, 0), RARRAY_AREF(loc, 1)); } } rb_str_buf_cat2(str, ">"); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#to_s;F;7[;[[@i ;T;;G;0;[;{;IC; "2Returns a human-readable description of the underlying method. "cat".method(:count).inspect #=> "#" (1..3).method(:map).inspect #=> "#" In the latter case, the method description includes the "owner" of the original method (+Enumerable+ module, which is included into +Range+). +inspect+ also provides, when possible, method argument names (call sequence) and source location. require 'net/http' Net::HTTP.method(:get).inspect #=> "#/lib/ruby/2.7.0/net/http.rb:457>" ... in argument definition means argument is optional (has some default value). For methods defined in C (language core and extensions), location and argument names can't be extracted, and only generic information is provided in form of * (any number of arguments) or _ (some positional argument). "cat".method(:count).inspect #=> "#" "cat".method(:+).inspect #=> "#"" ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@!v;![;"I"@return [String];T;#0;$@!v;.F;Bi;C0;7[;$@!vo;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@!v;![;"I"@return [String];T;#0;$@!v;.F;Bi;C0;7[;$@!v;![;"@v;#0;$@!v;.F;/o;0;1T;2i ;3i ;%@t;9I"zstatic VALUE method_inspect(VALUE method) { struct METHOD *data; VALUE str; const char *sharp = "#"; VALUE mklass; VALUE defined_class; TypedData_Get_Struct(method, struct METHOD, &method_data_type, data); str = rb_sprintf("#<% "PRIsVALUE": ", rb_obj_class(method)); mklass = data->iclass; if (!mklass) mklass = data->klass; if (RB_TYPE_P(mklass, T_ICLASS)) { /* TODO: I'm not sure why mklass is T_ICLASS. * UnboundMethod#bind() can set it as T_ICLASS at convert_umethod_to_method_components() * but not sure it is needed. */ mklass = RBASIC_CLASS(mklass); } if (data->me->def->type == VM_METHOD_TYPE_ALIAS) { defined_class = data->me->def->body.alias.original_me->owner; } else { defined_class = method_entry_defined_class(data->me); } if (RB_TYPE_P(defined_class, T_ICLASS)) { defined_class = RBASIC_CLASS(defined_class); } if (FL_TEST(mklass, FL_SINGLETON)) { VALUE v = rb_ivar_get(mklass, attached); if (data->recv == Qundef) { rb_str_buf_append(str, rb_inspect(mklass)); } else if (data->recv == v) { rb_str_buf_append(str, rb_inspect(v)); sharp = "."; } else { rb_str_buf_append(str, rb_inspect(data->recv)); rb_str_buf_cat2(str, "("); rb_str_buf_append(str, rb_inspect(v)); rb_str_buf_cat2(str, ")"); sharp = "."; } } else { mklass = data->klass; if (FL_TEST(mklass, FL_SINGLETON)) { VALUE v = rb_ivar_get(mklass, attached); if (!(RB_TYPE_P(v, T_CLASS) || RB_TYPE_P(v, T_MODULE))) { do { mklass = RCLASS_SUPER(mklass); } while (RB_TYPE_P(mklass, T_ICLASS)); } } rb_str_buf_append(str, rb_inspect(mklass)); if (defined_class != mklass) { rb_str_catf(str, "(% "PRIsVALUE")", defined_class); } } rb_str_buf_cat2(str, sharp); rb_str_append(str, rb_id2str(data->me->called_id)); if (data->me->called_id != data->me->def->original_id) { rb_str_catf(str, "(%"PRIsVALUE")", rb_id2str(data->me->def->original_id)); } if (data->me->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) { rb_str_buf_cat2(str, " (not-implemented)"); } // parameter information { VALUE params = rb_method_parameters(method); VALUE pair, name, kind; const VALUE req = ID2SYM(rb_intern("req")); const VALUE opt = ID2SYM(rb_intern("opt")); const VALUE keyreq = ID2SYM(rb_intern("keyreq")); const VALUE key = ID2SYM(rb_intern("key")); const VALUE rest = ID2SYM(rb_intern("rest")); const VALUE keyrest = ID2SYM(rb_intern("keyrest")); const VALUE block = ID2SYM(rb_intern("block")); const VALUE nokey = ID2SYM(rb_intern("nokey")); int forwarding = 0; rb_str_buf_cat2(str, "("); for (int i = 0; i < RARRAY_LEN(params); i++) { pair = RARRAY_AREF(params, i); kind = RARRAY_AREF(pair, 0); name = RARRAY_AREF(pair, 1); // FIXME: in tests it turns out that kind, name = [:req] produces name to be false. Why?.. if (NIL_P(name) || name == Qfalse) { // FIXME: can it be reduced to switch/case? if (kind == req || kind == opt) { name = rb_str_new2("_"); } else if (kind == rest || kind == keyrest) { name = rb_str_new2(""); } else if (kind == block) { name = rb_str_new2("block"); } else if (kind == nokey) { name = rb_str_new2("nil"); } } if (kind == req) { rb_str_catf(str, "%"PRIsVALUE, name); } else if (kind == opt) { rb_str_catf(str, "%"PRIsVALUE"=...", name); } else if (kind == keyreq) { rb_str_catf(str, "%"PRIsVALUE":", name); } else if (kind == key) { rb_str_catf(str, "%"PRIsVALUE": ...", name); } else if (kind == rest) { if (name == ID2SYM('*')) { forwarding = 1; rb_str_cat_cstr(str, "..."); } else { rb_str_catf(str, "*%"PRIsVALUE, name); } } else if (kind == keyrest) { if (name != ID2SYM(idPow)) { rb_str_catf(str, "**%"PRIsVALUE, name); } else if (i > 0) { rb_str_set_len(str, RSTRING_LEN(str) - 2); } } else if (kind == block) { if (name == ID2SYM('&')) { if (forwarding) { rb_str_set_len(str, RSTRING_LEN(str) - 2); } else { rb_str_cat_cstr(str, "..."); } } else { rb_str_catf(str, "&%"PRIsVALUE, name); } } else if (kind == nokey) { rb_str_buf_cat2(str, "**nil"); } if (i < RARRAY_LEN(params) - 1) { rb_str_buf_cat2(str, ", "); } } rb_str_buf_cat2(str, ")"); } { // source location VALUE loc = rb_method_location(method); if (!NIL_P(loc)) { rb_str_catf(str, " %"PRIsVALUE":%"PRIsVALUE, RARRAY_AREF(loc, 0), RARRAY_AREF(loc, 1)); } } rb_str_buf_cat2(str, ">"); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#to_proc;F;7[;[[@i ;T;;;0;[;{;IC; "8Returns a Proc object corresponding to this method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_proc;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@Hv;![;"I"@return [Proc];T;#0;$@Hv;.F;Bi;C0;7[;$@Hv;![;"I"]Returns a Proc object corresponding to this method. @overload to_proc @return [Proc];T;#0;$@Hv;.F;/o;0;1T;2i ;3i ;%@t;9I"static VALUE method_to_proc(VALUE method) { VALUE procval; rb_proc_t *proc; /* * class Method * def to_proc * lambda{|*args| * self.call(*args) * } * end * end */ procval = rb_block_call(rb_mRubyVMFrozenCore, idLambda, 0, 0, bmcall, method); GetProcPtr(procval, proc); proc->is_from_method = 1; return procval; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#receiver;F;7[;[[@i9;T;;i ;0;[;{;IC; "_Returns the bound receiver of the method object. (1..3).method(:map).receiver # => 1..3 ;T;[o;= ;>I" overload;F;?0;;i ;@0;:I" receiver;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@cv;![;"I"@return [Object];T;#0;$@cv;.F;Bi;C0;7[;$@cv;![;"I"Returns the bound receiver of the method object. (1..3).method(:map).receiver # => 1..3 @overload receiver @return [Object];T;#0;$@cv;.F;/o;0;1T;2i0;3i6;%@t;9I"static VALUE method_receiver(VALUE obj) { struct METHOD *data; TypedData_Get_Struct(obj, struct METHOD, &method_data_type, data); return data->recv; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#name;F;7[;[[@iI;T;;F;0;[;{;IC; "$Returns the name of the method. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I" name;T;IC; ";T;[;![;"I";T;#0;$@~v;.F;Bi;C0;7[;$@~v;![;"I"5Returns the name of the method. @overload name;T;#0;$@~v;.F;/o;0;1T;2iB;3iE;%@t;9I"static VALUE method_name(VALUE obj) { struct METHOD *data; TypedData_Get_Struct(obj, struct METHOD, &method_data_type, data); return ID2SYM(data->me->called_id); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#original_name;F;7[;[[@i_;T;:original_name;0;[;{;IC; "Returns the original name of the method. class C def foo; end alias bar foo end C.instance_method(:bar).original_name # => :foo ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"original_name;T;IC; ";T;[;![;"I";T;#0;$@v;.F;Bi;C0;7[;$@v;![;"I"Returns the original name of the method. class C def foo; end alias bar foo end C.instance_method(:bar).original_name # => :foo @overload original_name;T;#0;$@v;.F;/o;0;1T;2iR;3i[;%@t;9I"static VALUE method_original_name(VALUE obj) { struct METHOD *data; TypedData_Get_Struct(obj, struct METHOD, &method_data_type, data); return ID2SYM(data->me->def->original_id); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#owner;F;7[;[[@ir;T;: owner;0;[;{;IC; "Returns the class or module that defines the method. See also Method#receiver. (1..3).method(:map).owner #=> Enumerable ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" owner;T;IC; ";T;[;![;"I";T;#0;$@v;.F;Bi;C0;7[;$@v;![;"I"Returns the class or module that defines the method. See also Method#receiver. (1..3).method(:map).owner #=> Enumerable @overload owner;T;#0;$@v;.F;/o;0;1T;2ih;3in;%@t;9I"static VALUE method_owner(VALUE obj) { struct METHOD *data; TypedData_Get_Struct(obj, struct METHOD, &method_data_type, data); return data->me->owner; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#unbind;F;7[;[[@i;T;: unbind;0;[;{;IC; "Dissociates meth from its current receiver. The resulting UnboundMethod can subsequently be bound to a new object of the same class (see UnboundMethod). ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" unbind;T;IC; ";T;[;![;"I";T;#0;$@v;.F;Bi;C0;7[;$@v;![;"I"Dissociates meth from its current receiver. The resulting UnboundMethod can subsequently be bound to a new object of the same class (see UnboundMethod). @overload unbind;T;#0;$@v;.F;/o;0;1T;2i;3i;%@t;9I"static VALUE method_unbind(VALUE obj) { VALUE method; struct METHOD *orig, *data; TypedData_Get_Struct(obj, struct METHOD, &method_data_type, orig); method = TypedData_Make_Struct(rb_cUnboundMethod, struct METHOD, &method_data_type, data); RB_OBJ_WRITE(method, &data->recv, Qundef); RB_OBJ_WRITE(method, &data->klass, orig->klass); RB_OBJ_WRITE(method, &data->iclass, orig->iclass); RB_OBJ_WRITE(method, &data->me, rb_method_entry_clone(orig->me)); return method; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#source_location;F;7[;[[@i[ ;T;:source_location;0;[;{;IC; "Returns the Ruby source filename and line number containing this method or nil if this method was not defined in Ruby (i.e. native). ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"source_location;T;IC; ";T;[o;A ;>I" return;F;?I"];T;0;@[I" Array;TI" Integer;T;$@v;![;"I"@return [Array, Integer]];T;#0;$@v;.F;Bi;C0;7[;$@v;![;"I"Returns the Ruby source filename and line number containing this method or nil if this method was not defined in Ruby (i.e. native). @overload source_location @return [Array, Integer]];T;#0;$@v;.F;/o;0;1T;2iS ;3iX ;%@t;9I"fVALUE rb_method_location(VALUE method) { return method_def_location(rb_method_def(method)); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Method#parameters;F;7[;[[@i ;T;:parameters;0;[;{;IC; "Returns the parameter information of this method. def foo(bar); end method(:foo).parameters #=> [[:req, :bar]] def foo(bar, baz, bat, &blk); end method(:foo).parameters #=> [[:req, :bar], [:req, :baz], [:req, :bat], [:block, :blk]] def foo(bar, *args); end method(:foo).parameters #=> [[:req, :bar], [:rest, :args]] def foo(bar, baz, *args, &blk); end method(:foo).parameters #=> [[:req, :bar], [:req, :baz], [:rest, :args], [:block, :blk]] ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"parameters;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@v;![;"I"@return [Array];T;#0;$@v;.F;Bi;C0;7[;$@v;![;"I"Returns the parameter information of this method. def foo(bar); end method(:foo).parameters #=> [[:req, :bar]] def foo(bar, baz, bat, &blk); end method(:foo).parameters #=> [[:req, :bar], [:req, :baz], [:req, :bat], [:block, :blk]] def foo(bar, *args); end method(:foo).parameters #=> [[:req, :bar], [:rest, :args]] def foo(bar, baz, *args, &blk); end method(:foo).parameters #=> [[:req, :bar], [:req, :baz], [:rest, :args], [:block, :blk]] @overload parameters @return [Array];T;#0;$@v;.F;/o;0;1T;2i ;3i ;%@t;9I"qstatic VALUE rb_method_parameters(VALUE method) { return method_def_parameters(rb_method_def(method)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#super_method;F;7[;[[@i ;T;:super_method;0;[;{;IC; "xReturns a Method of superclass which would be called when super is used or nil if there is no method on superclass. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"super_method;T;IC; ";T;[;![;"I";T;#0;$@ w;.F;Bi;C0;7[;$@ w;![;"I"Returns a Method of superclass which would be called when super is used or nil if there is no method on superclass. @overload super_method;T;#0;$@ w;.F;/o;0;1T;2i ;3i ;%@t;9I"static VALUE method_super_method(VALUE method) { const struct METHOD *data; VALUE super_class, iclass; ID mid; const rb_method_entry_t *me; TypedData_Get_Struct(method, struct METHOD, &method_data_type, data); iclass = data->iclass; if (!iclass) return Qnil; if (data->me->def->type == VM_METHOD_TYPE_ALIAS && data->me->defined_class) { super_class = RCLASS_SUPER(rb_find_defined_class_by_owner(data->me->defined_class, data->me->def->body.alias.original_me->owner)); mid = data->me->def->body.alias.original_me->def->original_id; } else { super_class = RCLASS_SUPER(RCLASS_ORIGIN(iclass)); mid = data->me->def->original_id; } if (!super_class) return Qnil; me = (rb_method_entry_t *)rb_callable_method_entry_with_refinements(super_class, mid, &iclass); if (!me) return Qnil; return mnew_internal(me, me->owner, iclass, data->recv, mid, rb_obj_class(method), FALSE, FALSE); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#public?;F;7[;[[@i ;T;;;0;[;{;IC; "*Returns whether the method is public.;T;[o;= ;>I" overload;F;?0;;;@0;:I" public?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@#w;![;"I"@return [Boolean];T;#0;$@#w;.F;Bi;C0;7[;$@#w;![;"I"RReturns whether the method is public. @overload public? @return [Boolean];T;#0;$@#w;.F;/o;0;1T;2i ;3i ;Bi;%@t;9I"static VALUE method_public_p(VALUE method) { const struct METHOD *data; TypedData_Get_Struct(method, struct METHOD, &method_data_type, data); return RBOOL(METHOD_ENTRY_VISI(data->me) == METHOD_VISI_PUBLIC); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#protected?;F;7[;[[@i ;T;:protected?;0;[;{;IC; "-Returns whether the method is protected.;T;[o;= ;>I" overload;F;?0;; ;@0;:I"protected?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@>w;![;"I"@return [Boolean];T;#0;$@>w;.F;Bi;C0;7[;$@>w;![;"I"XReturns whether the method is protected. @overload protected? @return [Boolean];T;#0;$@>w;.F;/o;0;1T;2i ;3i ;Bi;%@t;9I"static VALUE method_protected_p(VALUE method) { const struct METHOD *data; TypedData_Get_Struct(method, struct METHOD, &method_data_type, data); return RBOOL(METHOD_ENTRY_VISI(data->me) == METHOD_VISI_PROTECTED); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Method#private?;F;7[;[[@i ;T;;;0;[;{;IC; "+Returns whether the method is private.;T;[o;= ;>I" overload;F;?0;;;@0;:I" private?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Yw;![;"I"@return [Boolean];T;#0;$@Yw;.F;Bi;C0;7[;$@Yw;![;"I"TReturns whether the method is private. @overload private? @return [Boolean];T;#0;$@Yw;.F;/o;0;1T;2i ;3i ;Bi;%@t;9I"static VALUE method_private_p(VALUE method) { const struct METHOD *data; TypedData_Get_Struct(method, struct METHOD, &method_data_type, data); return RBOOL(METHOD_ENTRY_VISI(data->me) == METHOD_VISI_PRIVATE); };T;:I"static VALUE;T;;T; @t; IC;[; @t; IC;[; @t; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;; ;;;;;[;{;IC; "`******************************************************************** Method objects are created by Object#method, and are associated with a particular object (not just with a class). They may be used to invoke the method within the object, and as a block associated with an iterator. They may also be unbound from one object (creating an UnboundMethod) and bound to another. class Thing def square(n) n*n end end thing = Thing.new meth = thing.method(:square) meth.call(9) #=> 81 [ 1, 2, 3 ].collect(&meth) #=> [1, 4, 9] [ 1, 2, 3 ].each(&method(:puts)) #=> prints 1, 2, 3 require 'date' %w[2017-03-01 2017-03-02].collect(&Date.method(:parse)) #=> [#, #];T;[;![;"I"a******************************************************************** Method objects are created by Object#method, and are associated with a particular object (not just with a class). They may be used to invoke the method within the object, and as a block associated with an iterator. They may also be unbound from one object (creating an UnboundMethod) and bound to another. class Thing def square(n) n*n end end thing = Thing.new meth = thing.method(:square) meth.call(9) #=> 81 [ 1, 2, 3 ].collect(&meth) #=> [1, 4, 9] [ 1, 2, 3 ].each(&method(:puts)) #=> prints 1, 2, 3 require 'date' %w[2017-03-01 2017-03-02].collect(&Date.method(:parse)) #=> [#, #] ;T;#0;$@t;.F;/o;0;1T;2i;3i;Bi;%@;&I" Method;F;'@o; ;IC;[o;4;5F;6;;;;&I"UnboundMethod#==;F;7[[I" other;T0;[[@i;T;;F;0;[;{;IC; "Two method objects are equal if they are bound to the same object and refer to the same method definition and the classes defining the methods are the same class or module. ;T;[o;= ;>I" overload;F;?0;;V;@0;:I"eql?(other_meth);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@w;![;"I"@return [Boolean];T;#0;$@w;.F;Bi;C0;7[[I"other_meth;T0;$@wo;= ;>I" overload;F;?0;;F;@0;:I"==(other_meth);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@w;![;"I"@return [Boolean];T;#0;$@w;.F;Bi;C0;7[[I"other_meth;T0;$@w;![;"@t;#0;$@w;.F;/o;0;1T;2i;3i;%@w;9I"jstatic VALUE method_eq(VALUE method, VALUE other) { struct METHOD *m1, *m2; VALUE klass1, klass2; if (!rb_obj_is_method(other)) return Qfalse; if (CLASS_OF(method) != CLASS_OF(other)) return Qfalse; Check_TypedStruct(method, &method_data_type); m1 = (struct METHOD *)DATA_PTR(method); m2 = (struct METHOD *)DATA_PTR(other); klass1 = method_entry_defined_class(m1->me); klass2 = method_entry_defined_class(m2->me); if (!rb_method_entry_eq(m1->me, m2->me) || klass1 != klass2 || m1->klass != m2->klass || m1->recv != m2->recv) { return Qfalse; } return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UnboundMethod#eql?;F;7[[I" other;T0;[[@i;T;;V;0;[;{;IC; "Two method objects are equal if they are bound to the same object and refer to the same method definition and the classes defining the methods are the same class or module.;T;[o;= ;>I" overload;F;?0;;V;@0;:I"eql?(other_meth);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@w;![;"I"@return [Boolean];T;#0;$@w;.F;Bi;C0;7[[I"other_meth;T0;$@wo;= ;>I" overload;F;?0;;F;@0;:I"==(other_meth);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@w;![;"I"@return [Boolean];T;#0;$@w;.F;Bi;C0;7[[I"other_meth;T0;$@w;![;"@t;#0;$@w;.F;/o;0;1T;2i;3i;Bi;%@w;9I"jstatic VALUE method_eq(VALUE method, VALUE other) { struct METHOD *m1, *m2; VALUE klass1, klass2; if (!rb_obj_is_method(other)) return Qfalse; if (CLASS_OF(method) != CLASS_OF(other)) return Qfalse; Check_TypedStruct(method, &method_data_type); m1 = (struct METHOD *)DATA_PTR(method); m2 = (struct METHOD *)DATA_PTR(other); klass1 = method_entry_defined_class(m1->me); klass2 = method_entry_defined_class(m2->me); if (!rb_method_entry_eq(m1->me, m2->me) || klass1 != klass2 || m1->klass != m2->klass || m1->recv != m2->recv) { return Qfalse; } return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UnboundMethod#hash;F;7[;[[@i;T;;X;0;[;{;IC; "TReturns a hash value corresponding to the method object. See also Object#hash. ;T;[o;= ;>I" overload;F;?0;;X;@0;:I" hash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@w;![;"I"@return [Integer];T;#0;$@w;.F;Bi;C0;7[;$@w;![;"@t;#0;$@w;.F;/o;0;1T;2i;3i;%@w;9I"2static VALUE method_hash(VALUE method) { struct METHOD *m; st_index_t hash; TypedData_Get_Struct(method, struct METHOD, &method_data_type, m); hash = rb_hash_start((st_index_t)m->recv); hash = rb_hash_method_entry(hash, m->me); hash = rb_hash_end(hash); return ST2FIX(hash); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UnboundMethod#clone;F;7[;[[@i ;T;;;0;[;{;IC; "Returns a clone of this method. class A def foo return "bar" end end m = A.new.method(:foo) m.call # => "bar" n = m.clone.call # => "bar" ;T;[o;= ;>I" overload;F;?0;;;@0;:I" clone;T;IC; ";T;[;![;"I";T;#0;$@w;.F;Bi;C0;7[;$@w;![;"@u;#0;$@w;.F;/o;0;1T;2i ;3i ;%@w;9I"static VALUE method_clone(VALUE self) { VALUE clone; struct METHOD *orig, *data; TypedData_Get_Struct(self, struct METHOD, &method_data_type, orig); clone = TypedData_Make_Struct(CLASS_OF(self), struct METHOD, &method_data_type, data); CLONESETUP(clone, self); RB_OBJ_WRITE(clone, &data->recv, orig->recv); RB_OBJ_WRITE(clone, &data->klass, orig->klass); RB_OBJ_WRITE(clone, &data->iclass, orig->iclass); RB_OBJ_WRITE(clone, &data->me, rb_method_entry_clone(orig->me)); return clone; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UnboundMethod#arity;F;7[;[[@i ;T;;~ ;0;[;{;IC; "Returns an indication of the number of arguments accepted by a method. Returns a nonnegative integer for methods that take a fixed number of arguments. For Ruby methods that take a variable number of arguments, returns -n-1, where n is the number of required arguments. Keyword arguments will be considered as a single additional argument, that argument being mandatory if any keyword argument is mandatory. For methods written in C, returns -1 if the call takes a variable number of arguments. class C def one; end def two(a); end def three(*a); end def four(a, b); end def five(a, b, *c); end def six(a, b, *c, &d); end def seven(a, b, x:0); end def eight(x:, y:); end def nine(x:, y:, **z); end def ten(*a, x:, y:); end end c = C.new c.method(:one).arity #=> 0 c.method(:two).arity #=> 1 c.method(:three).arity #=> -1 c.method(:four).arity #=> 2 c.method(:five).arity #=> -3 c.method(:six).arity #=> -3 c.method(:seven).arity #=> -3 c.method(:eight).arity #=> 1 c.method(:nine).arity #=> 1 c.method(:ten).arity #=> -2 "cat".method(:size).arity #=> 0 "cat".method(:replace).arity #=> 1 "cat".method(:squeeze).arity #=> -1 "cat".method(:count).arity #=> -1 ;T;[o;= ;>I" overload;F;?0;;~ ;@0;:I" arity;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@x;![;"I"@return [Integer];T;#0;$@x;.F;Bi;C0;7[;$@x;![;"@u;#0;$@x;.F;/o;0;1T;2i ;3i ;%@w;9I"kstatic VALUE method_arity_m(VALUE method) { int n = method_arity(method); return INT2FIX(n); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UnboundMethod#inspect;F;7[;[[@i ;T;;J;0;[;{;IC; "2Returns a human-readable description of the underlying method. "cat".method(:count).inspect #=> "#" (1..3).method(:map).inspect #=> "#" In the latter case, the method description includes the "owner" of the original method (+Enumerable+ module, which is included into +Range+). +inspect+ also provides, when possible, method argument names (call sequence) and source location. require 'net/http' Net::HTTP.method(:get).inspect #=> "#/lib/ruby/2.7.0/net/http.rb:457>" ... in argument definition means argument is optional (has some default value). For methods defined in C (language core and extensions), location and argument names can't be extracted, and only generic information is provided in form of * (any number of arguments) or _ (some positional argument). "cat".method(:count).inspect #=> "#" "cat".method(:+).inspect #=> "#"" ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@+x;![;"I"@return [String];T;#0;$@+x;.F;Bi;C0;7[;$@+xo;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@+x;![;"I"@return [String];T;#0;$@+x;.F;Bi;C0;7[;$@+x;![;"@v;#0;$@+x;.F;/o;0;1T;2i ;3i ;%@w;9I"zstatic VALUE method_inspect(VALUE method) { struct METHOD *data; VALUE str; const char *sharp = "#"; VALUE mklass; VALUE defined_class; TypedData_Get_Struct(method, struct METHOD, &method_data_type, data); str = rb_sprintf("#<% "PRIsVALUE": ", rb_obj_class(method)); mklass = data->iclass; if (!mklass) mklass = data->klass; if (RB_TYPE_P(mklass, T_ICLASS)) { /* TODO: I'm not sure why mklass is T_ICLASS. * UnboundMethod#bind() can set it as T_ICLASS at convert_umethod_to_method_components() * but not sure it is needed. */ mklass = RBASIC_CLASS(mklass); } if (data->me->def->type == VM_METHOD_TYPE_ALIAS) { defined_class = data->me->def->body.alias.original_me->owner; } else { defined_class = method_entry_defined_class(data->me); } if (RB_TYPE_P(defined_class, T_ICLASS)) { defined_class = RBASIC_CLASS(defined_class); } if (FL_TEST(mklass, FL_SINGLETON)) { VALUE v = rb_ivar_get(mklass, attached); if (data->recv == Qundef) { rb_str_buf_append(str, rb_inspect(mklass)); } else if (data->recv == v) { rb_str_buf_append(str, rb_inspect(v)); sharp = "."; } else { rb_str_buf_append(str, rb_inspect(data->recv)); rb_str_buf_cat2(str, "("); rb_str_buf_append(str, rb_inspect(v)); rb_str_buf_cat2(str, ")"); sharp = "."; } } else { mklass = data->klass; if (FL_TEST(mklass, FL_SINGLETON)) { VALUE v = rb_ivar_get(mklass, attached); if (!(RB_TYPE_P(v, T_CLASS) || RB_TYPE_P(v, T_MODULE))) { do { mklass = RCLASS_SUPER(mklass); } while (RB_TYPE_P(mklass, T_ICLASS)); } } rb_str_buf_append(str, rb_inspect(mklass)); if (defined_class != mklass) { rb_str_catf(str, "(% "PRIsVALUE")", defined_class); } } rb_str_buf_cat2(str, sharp); rb_str_append(str, rb_id2str(data->me->called_id)); if (data->me->called_id != data->me->def->original_id) { rb_str_catf(str, "(%"PRIsVALUE")", rb_id2str(data->me->def->original_id)); } if (data->me->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) { rb_str_buf_cat2(str, " (not-implemented)"); } // parameter information { VALUE params = rb_method_parameters(method); VALUE pair, name, kind; const VALUE req = ID2SYM(rb_intern("req")); const VALUE opt = ID2SYM(rb_intern("opt")); const VALUE keyreq = ID2SYM(rb_intern("keyreq")); const VALUE key = ID2SYM(rb_intern("key")); const VALUE rest = ID2SYM(rb_intern("rest")); const VALUE keyrest = ID2SYM(rb_intern("keyrest")); const VALUE block = ID2SYM(rb_intern("block")); const VALUE nokey = ID2SYM(rb_intern("nokey")); int forwarding = 0; rb_str_buf_cat2(str, "("); for (int i = 0; i < RARRAY_LEN(params); i++) { pair = RARRAY_AREF(params, i); kind = RARRAY_AREF(pair, 0); name = RARRAY_AREF(pair, 1); // FIXME: in tests it turns out that kind, name = [:req] produces name to be false. Why?.. if (NIL_P(name) || name == Qfalse) { // FIXME: can it be reduced to switch/case? if (kind == req || kind == opt) { name = rb_str_new2("_"); } else if (kind == rest || kind == keyrest) { name = rb_str_new2(""); } else if (kind == block) { name = rb_str_new2("block"); } else if (kind == nokey) { name = rb_str_new2("nil"); } } if (kind == req) { rb_str_catf(str, "%"PRIsVALUE, name); } else if (kind == opt) { rb_str_catf(str, "%"PRIsVALUE"=...", name); } else if (kind == keyreq) { rb_str_catf(str, "%"PRIsVALUE":", name); } else if (kind == key) { rb_str_catf(str, "%"PRIsVALUE": ...", name); } else if (kind == rest) { if (name == ID2SYM('*')) { forwarding = 1; rb_str_cat_cstr(str, "..."); } else { rb_str_catf(str, "*%"PRIsVALUE, name); } } else if (kind == keyrest) { if (name != ID2SYM(idPow)) { rb_str_catf(str, "**%"PRIsVALUE, name); } else if (i > 0) { rb_str_set_len(str, RSTRING_LEN(str) - 2); } } else if (kind == block) { if (name == ID2SYM('&')) { if (forwarding) { rb_str_set_len(str, RSTRING_LEN(str) - 2); } else { rb_str_cat_cstr(str, "..."); } } else { rb_str_catf(str, "&%"PRIsVALUE, name); } } else if (kind == nokey) { rb_str_buf_cat2(str, "**nil"); } if (i < RARRAY_LEN(params) - 1) { rb_str_buf_cat2(str, ", "); } } rb_str_buf_cat2(str, ")"); } { // source location VALUE loc = rb_method_location(method); if (!NIL_P(loc)) { rb_str_catf(str, " %"PRIsVALUE":%"PRIsVALUE, RARRAY_AREF(loc, 0), RARRAY_AREF(loc, 1)); } } rb_str_buf_cat2(str, ">"); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UnboundMethod#to_s;F;7[;[[@i ;T;;G;0;[;{;IC; "2Returns a human-readable description of the underlying method. "cat".method(:count).inspect #=> "#" (1..3).method(:map).inspect #=> "#" In the latter case, the method description includes the "owner" of the original method (+Enumerable+ module, which is included into +Range+). +inspect+ also provides, when possible, method argument names (call sequence) and source location. require 'net/http' Net::HTTP.method(:get).inspect #=> "#/lib/ruby/2.7.0/net/http.rb:457>" ... in argument definition means argument is optional (has some default value). For methods defined in C (language core and extensions), location and argument names can't be extracted, and only generic information is provided in form of * (any number of arguments) or _ (some positional argument). "cat".method(:count).inspect #=> "#" "cat".method(:+).inspect #=> "#"" ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@Rx;![;"I"@return [String];T;#0;$@Rx;.F;Bi;C0;7[;$@Rxo;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@Rx;![;"I"@return [String];T;#0;$@Rx;.F;Bi;C0;7[;$@Rx;![;"@v;#0;$@Rx;.F;/o;0;1T;2i ;3i ;%@w;9I"zstatic VALUE method_inspect(VALUE method) { struct METHOD *data; VALUE str; const char *sharp = "#"; VALUE mklass; VALUE defined_class; TypedData_Get_Struct(method, struct METHOD, &method_data_type, data); str = rb_sprintf("#<% "PRIsVALUE": ", rb_obj_class(method)); mklass = data->iclass; if (!mklass) mklass = data->klass; if (RB_TYPE_P(mklass, T_ICLASS)) { /* TODO: I'm not sure why mklass is T_ICLASS. * UnboundMethod#bind() can set it as T_ICLASS at convert_umethod_to_method_components() * but not sure it is needed. */ mklass = RBASIC_CLASS(mklass); } if (data->me->def->type == VM_METHOD_TYPE_ALIAS) { defined_class = data->me->def->body.alias.original_me->owner; } else { defined_class = method_entry_defined_class(data->me); } if (RB_TYPE_P(defined_class, T_ICLASS)) { defined_class = RBASIC_CLASS(defined_class); } if (FL_TEST(mklass, FL_SINGLETON)) { VALUE v = rb_ivar_get(mklass, attached); if (data->recv == Qundef) { rb_str_buf_append(str, rb_inspect(mklass)); } else if (data->recv == v) { rb_str_buf_append(str, rb_inspect(v)); sharp = "."; } else { rb_str_buf_append(str, rb_inspect(data->recv)); rb_str_buf_cat2(str, "("); rb_str_buf_append(str, rb_inspect(v)); rb_str_buf_cat2(str, ")"); sharp = "."; } } else { mklass = data->klass; if (FL_TEST(mklass, FL_SINGLETON)) { VALUE v = rb_ivar_get(mklass, attached); if (!(RB_TYPE_P(v, T_CLASS) || RB_TYPE_P(v, T_MODULE))) { do { mklass = RCLASS_SUPER(mklass); } while (RB_TYPE_P(mklass, T_ICLASS)); } } rb_str_buf_append(str, rb_inspect(mklass)); if (defined_class != mklass) { rb_str_catf(str, "(% "PRIsVALUE")", defined_class); } } rb_str_buf_cat2(str, sharp); rb_str_append(str, rb_id2str(data->me->called_id)); if (data->me->called_id != data->me->def->original_id) { rb_str_catf(str, "(%"PRIsVALUE")", rb_id2str(data->me->def->original_id)); } if (data->me->def->type == VM_METHOD_TYPE_NOTIMPLEMENTED) { rb_str_buf_cat2(str, " (not-implemented)"); } // parameter information { VALUE params = rb_method_parameters(method); VALUE pair, name, kind; const VALUE req = ID2SYM(rb_intern("req")); const VALUE opt = ID2SYM(rb_intern("opt")); const VALUE keyreq = ID2SYM(rb_intern("keyreq")); const VALUE key = ID2SYM(rb_intern("key")); const VALUE rest = ID2SYM(rb_intern("rest")); const VALUE keyrest = ID2SYM(rb_intern("keyrest")); const VALUE block = ID2SYM(rb_intern("block")); const VALUE nokey = ID2SYM(rb_intern("nokey")); int forwarding = 0; rb_str_buf_cat2(str, "("); for (int i = 0; i < RARRAY_LEN(params); i++) { pair = RARRAY_AREF(params, i); kind = RARRAY_AREF(pair, 0); name = RARRAY_AREF(pair, 1); // FIXME: in tests it turns out that kind, name = [:req] produces name to be false. Why?.. if (NIL_P(name) || name == Qfalse) { // FIXME: can it be reduced to switch/case? if (kind == req || kind == opt) { name = rb_str_new2("_"); } else if (kind == rest || kind == keyrest) { name = rb_str_new2(""); } else if (kind == block) { name = rb_str_new2("block"); } else if (kind == nokey) { name = rb_str_new2("nil"); } } if (kind == req) { rb_str_catf(str, "%"PRIsVALUE, name); } else if (kind == opt) { rb_str_catf(str, "%"PRIsVALUE"=...", name); } else if (kind == keyreq) { rb_str_catf(str, "%"PRIsVALUE":", name); } else if (kind == key) { rb_str_catf(str, "%"PRIsVALUE": ...", name); } else if (kind == rest) { if (name == ID2SYM('*')) { forwarding = 1; rb_str_cat_cstr(str, "..."); } else { rb_str_catf(str, "*%"PRIsVALUE, name); } } else if (kind == keyrest) { if (name != ID2SYM(idPow)) { rb_str_catf(str, "**%"PRIsVALUE, name); } else if (i > 0) { rb_str_set_len(str, RSTRING_LEN(str) - 2); } } else if (kind == block) { if (name == ID2SYM('&')) { if (forwarding) { rb_str_set_len(str, RSTRING_LEN(str) - 2); } else { rb_str_cat_cstr(str, "..."); } } else { rb_str_catf(str, "&%"PRIsVALUE, name); } } else if (kind == nokey) { rb_str_buf_cat2(str, "**nil"); } if (i < RARRAY_LEN(params) - 1) { rb_str_buf_cat2(str, ", "); } } rb_str_buf_cat2(str, ")"); } { // source location VALUE loc = rb_method_location(method); if (!NIL_P(loc)) { rb_str_catf(str, " %"PRIsVALUE":%"PRIsVALUE, RARRAY_AREF(loc, 0), RARRAY_AREF(loc, 1)); } } rb_str_buf_cat2(str, ">"); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UnboundMethod#name;F;7[;[[@iI;T;;F;0;[;{;IC; "$Returns the name of the method. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I" name;T;IC; ";T;[;![;"I";T;#0;$@yx;.F;Bi;C0;7[;$@yx;![;"@v;#0;$@yx;.F;/o;0;1T;2iB;3iE;%@w;9I"static VALUE method_name(VALUE obj) { struct METHOD *data; TypedData_Get_Struct(obj, struct METHOD, &method_data_type, data); return ID2SYM(data->me->called_id); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" UnboundMethod#original_name;F;7[;[[@i_;T;; ;0;[;{;IC; "Returns the original name of the method. class C def foo; end alias bar foo end C.instance_method(:bar).original_name # => :foo ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"original_name;T;IC; ";T;[;![;"I";T;#0;$@x;.F;Bi;C0;7[;$@x;![;"@v;#0;$@x;.F;/o;0;1T;2iR;3i[;%@w;9I"static VALUE method_original_name(VALUE obj) { struct METHOD *data; TypedData_Get_Struct(obj, struct METHOD, &method_data_type, data); return ID2SYM(data->me->def->original_id); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UnboundMethod#owner;F;7[;[[@ir;T;; ;0;[;{;IC; "Returns the class or module that defines the method. See also Method#receiver. (1..3).method(:map).owner #=> Enumerable ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" owner;T;IC; ";T;[;![;"I";T;#0;$@x;.F;Bi;C0;7[;$@x;![;"@v;#0;$@x;.F;/o;0;1T;2ih;3in;%@w;9I"static VALUE method_owner(VALUE obj) { struct METHOD *data; TypedData_Get_Struct(obj, struct METHOD, &method_data_type, data); return data->me->owner; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UnboundMethod#bind;F;7[[I" recv;T0;[[@i ;T;: bind;0;[;{;IC; "9Bind umeth to obj. If Klass was the class from which umeth was obtained, obj.kind_of?(Klass) must be true. class A def test puts "In test, class = #{self.class}" end end class B < A end class C < B end um = B.instance_method(:test) bm = um.bind(C.new) bm.call bm = um.bind(B.new) bm.call bm = um.bind(A.new) bm.call produces: In test, class = C In test, class = B prog.rb:16:in `bind': bind argument must be an instance of B (TypeError) from prog.rb:16 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"bind(obj);T;IC; ";T;[;![;"I";T;#0;$@x;.F;Bi;C0;7[[I"obj;T0;$@x;![;"I"OBind umeth to obj. If Klass was the class from which umeth was obtained, obj.kind_of?(Klass) must be true. class A def test puts "In test, class = #{self.class}" end end class B < A end class C < B end um = B.instance_method(:test) bm = um.bind(C.new) bm.call bm = um.bind(B.new) bm.call bm = um.bind(A.new) bm.call produces: In test, class = C In test, class = B prog.rb:16:in `bind': bind argument must be an instance of B (TypeError) from prog.rb:16 @overload bind(obj);T;#0;$@x;.F;/o;0;1T;2i ;3i ;%@w;9I"static VALUE umethod_bind(VALUE method, VALUE recv) { VALUE methclass, klass, iclass; const rb_method_entry_t *me; const struct METHOD *data; TypedData_Get_Struct(method, struct METHOD, &method_data_type, data); convert_umethod_to_method_components(data, recv, &methclass, &klass, &iclass, &me); struct METHOD *bound; method = TypedData_Make_Struct(rb_cMethod, struct METHOD, &method_data_type, bound); RB_OBJ_WRITE(method, &bound->recv, recv); RB_OBJ_WRITE(method, &bound->klass, klass); RB_OBJ_WRITE(method, &bound->iclass, iclass); RB_OBJ_WRITE(method, &bound->me, me); return method; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UnboundMethod#bind_call;F;7[[@90;[[@i- ;T;:bind_call;0;[;{;IC; "Bind umeth to recv and then invokes the method with the specified arguments. This is semantically equivalent to umeth.bind(recv).call(args, ...). ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"bind_call(recv, args, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@x;![;"I"@return [Object];T;#0;$@x;.F;Bi;C0;7[[I" recv;T0[I" args;T0[I"...;T0;$@x;![;"I"Bind umeth to recv and then invokes the method with the specified arguments. This is semantically equivalent to umeth.bind(recv).call(args, ...). @overload bind_call(recv, args, ...) @return [Object];T;#0;$@x;.F;/o;0;1T;2i% ;3i+ ;%@w;9I"6static VALUE umethod_bind_call(int argc, VALUE *argv, VALUE method) { rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS); VALUE recv = argv[0]; argc--; argv++; VALUE passed_procval = rb_block_given_p() ? rb_block_proc() : Qnil; rb_execution_context_t *ec = GET_EC(); const struct METHOD *data; TypedData_Get_Struct(method, struct METHOD, &method_data_type, data); const rb_callable_method_entry_t *cme = rb_callable_method_entry(CLASS_OF(recv), data->me->called_id); if (data->me == (const rb_method_entry_t *)cme) { vm_passed_block_handler_set(ec, proc_to_block_handler(passed_procval)); return rb_vm_call_kw(ec, recv, cme->called_id, argc, argv, cme, RB_PASS_CALLED_KEYWORDS); } else { VALUE methclass, klass, iclass; const rb_method_entry_t *me; convert_umethod_to_method_components(data, recv, &methclass, &klass, &iclass, &me); struct METHOD bound = { recv, klass, 0, me }; return call_method_data(ec, &bound, argc, argv, passed_procval, RB_PASS_CALLED_KEYWORDS); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""UnboundMethod#source_location;F;7[;[[@i[ ;T;; ;0;[;{;IC; "Returns the Ruby source filename and line number containing this method or nil if this method was not defined in Ruby (i.e. native). ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"source_location;T;IC; ";T;[o;A ;>I" return;F;?I"];T;0;@[I" Array;TI" Integer;T;$@x;![;"I"@return [Array, Integer]];T;#0;$@x;.F;Bi;C0;7[;$@x;![;"@v;#0;$@x;.F;/o;0;1T;2iS ;3iX ;%@w;9I"fVALUE rb_method_location(VALUE method) { return method_def_location(rb_method_def(method)); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"UnboundMethod#parameters;F;7[;[[@i ;T;; ;0;[;{;IC; "Returns the parameter information of this method. def foo(bar); end method(:foo).parameters #=> [[:req, :bar]] def foo(bar, baz, bat, &blk); end method(:foo).parameters #=> [[:req, :bar], [:req, :baz], [:req, :bat], [:block, :blk]] def foo(bar, *args); end method(:foo).parameters #=> [[:req, :bar], [:rest, :args]] def foo(bar, baz, *args, &blk); end method(:foo).parameters #=> [[:req, :bar], [:req, :baz], [:rest, :args], [:block, :blk]] ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"parameters;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@y;![;"I"@return [Array];T;#0;$@y;.F;Bi;C0;7[;$@y;![;"@ w;#0;$@y;.F;/o;0;1T;2i ;3i ;%@w;9I"qstatic VALUE rb_method_parameters(VALUE method) { return method_def_parameters(rb_method_def(method)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UnboundMethod#super_method;F;7[;[[@i ;T;; ;0;[;{;IC; "xReturns a Method of superclass which would be called when super is used or nil if there is no method on superclass. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"super_method;T;IC; ";T;[;![;"I";T;#0;$@)y;.F;Bi;C0;7[;$@)y;![;"@w;#0;$@)y;.F;/o;0;1T;2i ;3i ;%@w;9I"static VALUE method_super_method(VALUE method) { const struct METHOD *data; VALUE super_class, iclass; ID mid; const rb_method_entry_t *me; TypedData_Get_Struct(method, struct METHOD, &method_data_type, data); iclass = data->iclass; if (!iclass) return Qnil; if (data->me->def->type == VM_METHOD_TYPE_ALIAS && data->me->defined_class) { super_class = RCLASS_SUPER(rb_find_defined_class_by_owner(data->me->defined_class, data->me->def->body.alias.original_me->owner)); mid = data->me->def->body.alias.original_me->def->original_id; } else { super_class = RCLASS_SUPER(RCLASS_ORIGIN(iclass)); mid = data->me->def->original_id; } if (!super_class) return Qnil; me = (rb_method_entry_t *)rb_callable_method_entry_with_refinements(super_class, mid, &iclass); if (!me) return Qnil; return mnew_internal(me, me->owner, iclass, data->recv, mid, rb_obj_class(method), FALSE, FALSE); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UnboundMethod#public?;F;7[;[[@i ;T;;;0;[;{;IC; "*Returns whether the method is public.;T;[o;= ;>I" overload;F;?0;;;@0;:I" public?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@>y;![;"I"@return [Boolean];T;#0;$@>y;.F;Bi;C0;7[;$@>y;![;"@:w;#0;$@>y;.F;/o;0;1T;2i ;3i ;Bi;%@w;9I"static VALUE method_public_p(VALUE method) { const struct METHOD *data; TypedData_Get_Struct(method, struct METHOD, &method_data_type, data); return RBOOL(METHOD_ENTRY_VISI(data->me) == METHOD_VISI_PUBLIC); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UnboundMethod#protected?;F;7[;[[@i ;T;; ;0;[;{;IC; "-Returns whether the method is protected.;T;[o;= ;>I" overload;F;?0;; ;@0;:I"protected?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Xy;![;"I"@return [Boolean];T;#0;$@Xy;.F;Bi;C0;7[;$@Xy;![;"@Uw;#0;$@Xy;.F;/o;0;1T;2i ;3i ;Bi;%@w;9I"static VALUE method_protected_p(VALUE method) { const struct METHOD *data; TypedData_Get_Struct(method, struct METHOD, &method_data_type, data); return RBOOL(METHOD_ENTRY_VISI(data->me) == METHOD_VISI_PROTECTED); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UnboundMethod#private?;F;7[;[[@i ;T;;;0;[;{;IC; "+Returns whether the method is private.;T;[o;= ;>I" overload;F;?0;;;@0;:I" private?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ry;![;"I"@return [Boolean];T;#0;$@ry;.F;Bi;C0;7[;$@ry;![;"@pw;#0;$@ry;.F;/o;0;1T;2i ;3i ;Bi;%@w;9I"static VALUE method_private_p(VALUE method) { const struct METHOD *data; TypedData_Get_Struct(method, struct METHOD, &method_data_type, data); return RBOOL(METHOD_ENTRY_VISI(data->me) == METHOD_VISI_PRIVATE); };T;:I"static VALUE;T;;T; @w; IC;[; @w; IC;[; @w; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i [@i;T;:UnboundMethod;;;;;[;{;IC; "******************************************************************** Ruby supports two forms of objectified methods. Class Method is used to represent methods that are associated with a particular object: these method objects are bound to that object. Bound method objects for an object can be created using Object#method. Ruby also supports unbound methods; methods objects that are not associated with a particular object. These can be created either by calling Module#instance_method or by calling #unbind on a bound method object. The result of both of these is an UnboundMethod object. Unbound methods can only be called after they are bound to an object. That object must be a kind_of? the method's original class. class Square def area @side * @side end def initialize(side) @side = side end end area_un = Square.instance_method(:area) s = Square.new(12) area = area_un.bind(s) area.call #=> 144 Unbound methods are a reference to the method at the time it was objectified: subsequent changes to the underlying class will not affect the unbound method. class Test def test :original end end um = Test.instance_method(:test) class Test def test :modified end end t = Test.new t.test #=> :modified um.bind(t).call #=> :original;T;[;![;"I"******************************************************************** Ruby supports two forms of objectified methods. Class Method is used to represent methods that are associated with a particular object: these method objects are bound to that object. Bound method objects for an object can be created using Object#method. Ruby also supports unbound methods; methods objects that are not associated with a particular object. These can be created either by calling Module#instance_method or by calling #unbind on a bound method object. The result of both of these is an UnboundMethod object. Unbound methods can only be called after they are bound to an object. That object must be a kind_of? the method's original class. class Square def area @side * @side end def initialize(side) @side = side end end area_un = Square.instance_method(:area) s = Square.new(12) area = area_un.bind(s) area.call #=> 144 Unbound methods are a reference to the method at the time it was objectified: subsequent changes to the underlying class will not affect the unbound method. class Test def test :original end end um = Test.instance_method(:test) class Test def test :modified end end t = Test.new t.test #=> :modified um.bind(t).call #=> :original ;T;#0;$@w;.F;/o;0;1T;2i ;3i ;Bi;%@;&I"UnboundMethod;F;'@o; ;IC;[o;4;5F;6;;;;&I"LocalJumpError#exit_value;F;7[;[[@i ;T;:exit_value;0;[;{;IC; "BReturns the exit value associated with this +LocalJumpError+. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"exit_value;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@y;![;"I"@return [Object];T;#0;$@y;.F;Bi;C0;7[;$@y;![;"I"lReturns the exit value associated with this +LocalJumpError+. @overload exit_value @return [Object];T;#0;$@y;.F;/o;0;1T;2i ;3i ;%@y;9I"[static VALUE localjump_xvalue(VALUE exc) { return rb_iv_get(exc, "@exit_value"); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"LocalJumpError#reason;F;7[;[[@i ;T;: reason;0;[;{;IC; "_The reason this block was terminated: :break, :redo, :retry, :next, :return, or :noreason. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" reason;T;IC; ";T;[;![;"I";T;#0;$@y;.F;Bi;C0;7[;$@y;![;"I"rThe reason this block was terminated: :break, :redo, :retry, :next, :return, or :noreason. @overload reason;T;#0;$@y;.F;/o;0;1T;2i ;3i ;%@y;9I"Wstatic VALUE localjump_reason(VALUE exc) { return rb_iv_get(exc, "@reason"); };T;:I"static VALUE;T;;T; @y; IC;[; @y; IC;[; @y; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;:LocalJumpError;;;;;[;{;IC; "Raised when Ruby can't yield as requested. A typical scenario is attempting to yield when no block is given: def call_block yield 42 end call_block raises the exception: LocalJumpError: no block given (yield) A more subtle example: def get_me_a_return Proc.new { return 42 } end get_me_a_return.call raises the exception: LocalJumpError: unexpected return;T;[;![;"I" Raised when Ruby can't yield as requested. A typical scenario is attempting to yield when no block is given: def call_block yield 42 end call_block raises the exception: LocalJumpError: no block given (yield) A more subtle example: def get_me_a_return Proc.new { return 42 } end get_me_a_return.call raises the exception: LocalJumpError: unexpected return ;T;#0;$@y;.F;/o;0;1T;2i;3i+;Bi;%@;&I"LocalJumpError;F;'@o; ;IC;[; @y; IC;[; @y; IC;[; @y; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i/[@i;T;:SystemStackError;;;;;[;{;IC; "Raised in case of a stack overflow. def me_myself_and_i me_myself_and_i end me_myself_and_i raises the exception: SystemStackError: stack level too deep ;T;[;![;"I" Raised in case of a stack overflow. def me_myself_and_i me_myself_and_i end me_myself_and_i raises the exception: SystemStackError: stack level too deep ;T;#0;$@y;.F;/o;0;1T;2i/;3i:;%@;&I"SystemStackError;F;'o;( ;)0;*0;+0;;O;%@;-@3;;o; ;IC;[o;4;5F;6;;;;&I" Proc.new;F;7[[@90;[[@iB;T;;E;0;[;{;IC; "Creates a new Proc object, bound to the current context. proc = Proc.new { "hello" } proc.call #=> "hello" Raises ArgumentError if called without a block. Proc.new #=> ArgumentError ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"...;T;$@yo;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@y;![;"I" @yield [...] @return [Proc];T;#0;$@y;.F;Bi;C0;7[;$@y;![;"I"Creates a new Proc object, bound to the current context. proc = Proc.new { "hello" } proc.call #=> "hello" Raises ArgumentError if called without a block. Proc.new #=> ArgumentError @overload new @yield [...] @return [Proc];T;#0;$@y;.F;/o;0;1T;2i4;3i@;%@y;9I"static VALUE rb_proc_s_new(int argc, VALUE *argv, VALUE klass) { VALUE block = proc_new(klass, FALSE, FALSE); rb_obj_call_init_kw(block, argc, argv, RB_PASS_CALLED_KEYWORDS); return block; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Proc#call;F;7[[@90;[[@i;T;;;0;[;{;IC; "call-seq: prc.call(params,...) -> obj prc[params,...] -> obj prc.(params,...) -> obj prc.yield(params,...) -> obj Invokes the block, setting the block's parameters to the values in params using something close to method calling semantics. Returns the value of the last expression evaluated in the block. a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } } a_proc.call(9, 1, 2, 3) #=> [9, 18, 27] a_proc[9, 1, 2, 3] #=> [9, 18, 27] a_proc.(9, 1, 2, 3) #=> [9, 18, 27] a_proc.yield(9, 1, 2, 3) #=> [9, 18, 27] Note that prc.() invokes prc.call() with the parameters given. It's syntactic sugar to hide "call". For procs created using #lambda or ->() an error is generated if the wrong number of parameters are passed to the proc. For procs created using Proc.new or Kernel.proc, extra parameters are silently discarded and missing parameters are set to +nil+. a_proc = proc {|a,b| [a,b] } a_proc.call(1) #=> [1, nil] a_proc = lambda {|a,b| [a,b] } a_proc.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2) See also Proc#lambda?. ;T;[;![;"I" call-seq: prc.call(params,...) -> obj prc[params,...] -> obj prc.(params,...) -> obj prc.yield(params,...) -> obj Invokes the block, setting the block's parameters to the values in params using something close to method calling semantics. Returns the value of the last expression evaluated in the block. a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } } a_proc.call(9, 1, 2, 3) #=> [9, 18, 27] a_proc[9, 1, 2, 3] #=> [9, 18, 27] a_proc.(9, 1, 2, 3) #=> [9, 18, 27] a_proc.yield(9, 1, 2, 3) #=> [9, 18, 27] Note that prc.() invokes prc.call() with the parameters given. It's syntactic sugar to hide "call". For procs created using #lambda or ->() an error is generated if the wrong number of parameters are passed to the proc. For procs created using Proc.new or Kernel.proc, extra parameters are silently discarded and missing parameters are set to +nil+. a_proc = proc {|a,b| [a,b] } a_proc.call(1) #=> [1, nil] a_proc = lambda {|a,b| [a,b] } a_proc.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2) See also Proc#lambda?. ;T;#0;$@z;.F;/o;0;1T;2i;3i;%@y;9I"Wstatic VALUE proc_call(int argc, VALUE *argv, VALUE procval) { /* removed */ };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Proc#[];F;7[[@90;[[@i;T;;;0;[;{;IC; "call-seq: prc.call(params,...) -> obj prc[params,...] -> obj prc.(params,...) -> obj prc.yield(params,...) -> obj Invokes the block, setting the block's parameters to the values in params using something close to method calling semantics. Returns the value of the last expression evaluated in the block. a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } } a_proc.call(9, 1, 2, 3) #=> [9, 18, 27] a_proc[9, 1, 2, 3] #=> [9, 18, 27] a_proc.(9, 1, 2, 3) #=> [9, 18, 27] a_proc.yield(9, 1, 2, 3) #=> [9, 18, 27] Note that prc.() invokes prc.call() with the parameters given. It's syntactic sugar to hide "call". For procs created using #lambda or ->() an error is generated if the wrong number of parameters are passed to the proc. For procs created using Proc.new or Kernel.proc, extra parameters are silently discarded and missing parameters are set to +nil+. a_proc = proc {|a,b| [a,b] } a_proc.call(1) #=> [1, nil] a_proc = lambda {|a,b| [a,b] } a_proc.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2) See also Proc#lambda?. ;T;[;![;"@&z;#0;$@*z;.F;/o;0;1T;2i;3i;%@y;9I"Wstatic VALUE proc_call(int argc, VALUE *argv, VALUE procval) { /* removed */ };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Proc#===;F;7[[@90;[[@i;T;;S;0;[;{;IC; "call-seq: proc === obj -> result_of_proc Invokes the block with +obj+ as the proc's parameter like Proc#call. This allows a proc object to be the target of a +when+ clause in a case statement. ;T;[;![;"I" call-seq: proc === obj -> result_of_proc Invokes the block with +obj+ as the proc's parameter like Proc#call. This allows a proc object to be the target of a +when+ clause in a case statement. ;T;#0;$@8z;.F;/o;0;1T;2i;3i;%@y;9I"Wstatic VALUE proc_call(int argc, VALUE *argv, VALUE procval) { /* removed */ };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Proc#yield;F;7[[@90;[[@i;T;;W ;0;[;{;IC; "call-seq: prc.call(params,...) -> obj prc[params,...] -> obj prc.(params,...) -> obj prc.yield(params,...) -> obj Invokes the block, setting the block's parameters to the values in params using something close to method calling semantics. Returns the value of the last expression evaluated in the block. a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } } a_proc.call(9, 1, 2, 3) #=> [9, 18, 27] a_proc[9, 1, 2, 3] #=> [9, 18, 27] a_proc.(9, 1, 2, 3) #=> [9, 18, 27] a_proc.yield(9, 1, 2, 3) #=> [9, 18, 27] Note that prc.() invokes prc.call() with the parameters given. It's syntactic sugar to hide "call". For procs created using #lambda or ->() an error is generated if the wrong number of parameters are passed to the proc. For procs created using Proc.new or Kernel.proc, extra parameters are silently discarded and missing parameters are set to +nil+. a_proc = proc {|a,b| [a,b] } a_proc.call(1) #=> [1, nil] a_proc = lambda {|a,b| [a,b] } a_proc.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2) See also Proc#lambda?. ;T;[;![;"@&z;#0;$@Gz;.F;/o;0;1T;2i;3i;%@y;9I"Wstatic VALUE proc_call(int argc, VALUE *argv, VALUE procval) { /* removed */ };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Proc#to_proc;F;7[;[[@i;T;;;0;[;{;IC; "sPart of the protocol for converting objects to Proc objects. Instances of class Proc simply return themselves. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_proc;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@Uz;![;"I"@return [Proc];T;#0;$@Uz;.F;Bi;C0;7[;$@Uz;![;"I"Part of the protocol for converting objects to Proc objects. Instances of class Proc simply return themselves. @overload to_proc @return [Proc];T;#0;$@Uz;.F;/o;0;1T;2i;3i ;%@y;9I"?static VALUE proc_to_proc(VALUE self) { return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Proc#arity;F;7[;[[@i.;T;;~ ;0;[;{;IC; "Returns the number of mandatory arguments. If the block is declared to take no arguments, returns 0. If the block is known to take exactly n arguments, returns n. If the block has optional arguments, returns -n-1, where n is the number of mandatory arguments, with the exception for blocks that are not lambdas and have only a finite number of optional arguments; in this latter case, returns n. Keyword arguments will be considered as a single additional argument, that argument being mandatory if any keyword argument is mandatory. A #proc with no argument declarations is the same as a block declaring || as its arguments. proc {}.arity #=> 0 proc { || }.arity #=> 0 proc { |a| }.arity #=> 1 proc { |a, b| }.arity #=> 2 proc { |a, b, c| }.arity #=> 3 proc { |*a| }.arity #=> -1 proc { |a, *b| }.arity #=> -2 proc { |a, *b, c| }.arity #=> -3 proc { |x:, y:, z:0| }.arity #=> 1 proc { |*a, x:, y:0| }.arity #=> -2 proc { |a=0| }.arity #=> 0 lambda { |a=0| }.arity #=> -1 proc { |a=0, b| }.arity #=> 1 lambda { |a=0, b| }.arity #=> -2 proc { |a=0, b=0| }.arity #=> 0 lambda { |a=0, b=0| }.arity #=> -1 proc { |a, b=0| }.arity #=> 1 lambda { |a, b=0| }.arity #=> -2 proc { |(a, b), c=0| }.arity #=> 1 lambda { |(a, b), c=0| }.arity #=> -2 proc { |a, x:0, y:0| }.arity #=> 1 lambda { |a, x:0, y:0| }.arity #=> -2 ;T;[o;= ;>I" overload;F;?0;;~ ;@0;:I" arity;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@pz;![;"I"@return [Integer];T;#0;$@pz;.F;Bi;C0;7[;$@pz;![;"I",Returns the number of mandatory arguments. If the block is declared to take no arguments, returns 0. If the block is known to take exactly n arguments, returns n. If the block has optional arguments, returns -n-1, where n is the number of mandatory arguments, with the exception for blocks that are not lambdas and have only a finite number of optional arguments; in this latter case, returns n. Keyword arguments will be considered as a single additional argument, that argument being mandatory if any keyword argument is mandatory. A #proc with no argument declarations is the same as a block declaring || as its arguments. proc {}.arity #=> 0 proc { || }.arity #=> 0 proc { |a| }.arity #=> 1 proc { |a, b| }.arity #=> 2 proc { |a, b, c| }.arity #=> 3 proc { |*a| }.arity #=> -1 proc { |a, *b| }.arity #=> -2 proc { |a, *b, c| }.arity #=> -3 proc { |x:, y:, z:0| }.arity #=> 1 proc { |*a, x:, y:0| }.arity #=> -2 proc { |a=0| }.arity #=> 0 lambda { |a=0| }.arity #=> -1 proc { |a=0, b| }.arity #=> 1 lambda { |a=0, b| }.arity #=> -2 proc { |a=0, b=0| }.arity #=> 0 lambda { |a=0, b=0| }.arity #=> -1 proc { |a, b=0| }.arity #=> 1 lambda { |a, b=0| }.arity #=> -2 proc { |(a, b), c=0| }.arity #=> 1 lambda { |(a, b), c=0| }.arity #=> -2 proc { |a, x:0, y:0| }.arity #=> 1 lambda { |a, x:0, y:0| }.arity #=> -2 @overload arity @return [Integer];T;#0;$@pz;.F;/o;0;1T;2i;3i+;%@y;9I"lstatic VALUE proc_arity(VALUE self) { int arity = rb_proc_arity(self); return INT2FIX(arity); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Proc#clone;F;7[;[[@i;T;;;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@z;.F;/o;0;1T;2i;3i;%@y;9I"static VALUE proc_clone(VALUE self) { VALUE procval = rb_proc_dup(self); CLONESETUP(procval, self); return procval; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Proc#dup;F;7[;[[@&i;T;;[;0;[;{;IC; " ;T;[;![;"@;#0;$@z;%@y;9I"TVALUE rb_proc_dup(VALUE self) { VALUE procval; rb_proc_t *src; GetProcPtr(self, src); procval = proc_create(rb_cProc, &src->block, src->is_from_method, src->is_lambda); if (RB_OBJ_SHAREABLE_P(self)) FL_SET_RAW(procval, RUBY_FL_SHAREABLE); RB_GC_GUARD(self); /* for: body = rb_proc_dup(body) */ return procval; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Proc#hash;F;7[;[[@i;T;;X;0;[;{;IC; "LReturns a hash value corresponding to proc body. See also Object#hash. ;T;[o;= ;>I" overload;F;?0;;X;@0;:I" hash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@z;![;"I"@return [Integer];T;#0;$@z;.F;Bi;C0;7[;$@z;![;"I"qReturns a hash value corresponding to proc body. See also Object#hash. @overload hash @return [Integer];T;#0;$@z;.F;/o;0;1T;2i;3i;%@y;9I"static VALUE proc_hash(VALUE self) { st_index_t hash; hash = rb_hash_start(0); hash = rb_hash_proc(hash, self); hash = rb_hash_end(hash); return ST2FIX(hash); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Proc#to_s;F;7[;[[@i;T;;G;0;[;{;IC; "iReturns the unique identifier for this proc, along with an indication of where the proc was defined. ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@z;![;"I"@return [String];T;#0;$@z;.F;Bi;C0;7[;$@z;![;"I"Returns the unique identifier for this proc, along with an indication of where the proc was defined. @overload to_s @return [String];T;#0;$o;4;5F;6;;;;&I"Proc#inspect;F;7[;[[@i;F;;J;;;[;{;@z;%@y;9I"static VALUE proc_to_s(VALUE self) { const rb_proc_t *proc; GetProcPtr(self, proc); return rb_block_to_s(self, &proc->block, proc->is_lambda ? " (lambda)" : NULL); };T;:I"static VALUE;T;.F;/o;0;1T;2i;3i;%@y;9I"static VALUE proc_to_s(VALUE self) { const rb_proc_t *proc; GetProcPtr(self, proc); return rb_block_to_s(self, &proc->block, proc->is_lambda ? " (lambda)" : NULL); };T;:@z;;T@zo;4;5F;6;;;;&I"Proc#lambda?;F;7[;[[@i ;T;: lambda?;0;[;{;IC; "j Returns +true+ if a Proc object is lambda. +false+ if non-lambda. The lambda-ness affects argument handling and the behavior of +return+ and +break+. A Proc object generated by +proc+ ignores extra arguments. proc {|a,b| [a,b] }.call(1,2,3) #=> [1,2] It provides +nil+ for missing arguments. proc {|a,b| [a,b] }.call(1) #=> [1,nil] It expands a single array argument. proc {|a,b| [a,b] }.call([1,2]) #=> [1,2] A Proc object generated by +lambda+ doesn't have such tricks. lambda {|a,b| [a,b] }.call(1,2,3) #=> ArgumentError lambda {|a,b| [a,b] }.call(1) #=> ArgumentError lambda {|a,b| [a,b] }.call([1,2]) #=> ArgumentError Proc#lambda? is a predicate for the tricks. It returns +true+ if no tricks apply. lambda {}.lambda? #=> true proc {}.lambda? #=> false Proc.new is the same as +proc+. Proc.new {}.lambda? #=> false +lambda+, +proc+ and Proc.new preserve the tricks of a Proc object given by & argument. lambda(&lambda {}).lambda? #=> true proc(&lambda {}).lambda? #=> true Proc.new(&lambda {}).lambda? #=> true lambda(&proc {}).lambda? #=> false proc(&proc {}).lambda? #=> false Proc.new(&proc {}).lambda? #=> false A Proc object generated by & argument has the tricks def n(&b) b.lambda? end n {} #=> false The & argument preserves the tricks if a Proc object is given by & argument. n(&lambda {}) #=> true n(&proc {}) #=> false n(&Proc.new {}) #=> false A Proc object converted from a method has no tricks. def m() end method(:m).to_proc.lambda? #=> true n(&method(:m)) #=> true n(&method(:m).to_proc) #=> true +define_method+ is treated the same as method definition. The defined method has no tricks. class C define_method(:d) {} end C.new.d(1,2) #=> ArgumentError C.new.method(:d).to_proc.lambda? #=> true +define_method+ always defines a method without the tricks, even if a non-lambda Proc object is given. This is the only exception for which the tricks are not preserved. class C define_method(:e, &proc {}) end C.new.e(1,2) #=> ArgumentError C.new.method(:e).to_proc.lambda? #=> true This exception ensures that methods never have tricks and makes it easy to have wrappers to define methods that behave as usual. class C def self.def2(name, &body) define_method(name, &body) end def2(:f) {} end C.new.f(1,2) #=> ArgumentError The wrapper def2 defines a method which has no tricks.;T;[o;= ;>I" overload;F;?0;; ;@0;:I" lambda?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@z;![;"I"@return [Boolean];T;#0;$@z;.F;Bi;C0;7[;$@z;![;"I" Returns +true+ if a Proc object is lambda. +false+ if non-lambda. The lambda-ness affects argument handling and the behavior of +return+ and +break+. A Proc object generated by +proc+ ignores extra arguments. proc {|a,b| [a,b] }.call(1,2,3) #=> [1,2] It provides +nil+ for missing arguments. proc {|a,b| [a,b] }.call(1) #=> [1,nil] It expands a single array argument. proc {|a,b| [a,b] }.call([1,2]) #=> [1,2] A Proc object generated by +lambda+ doesn't have such tricks. lambda {|a,b| [a,b] }.call(1,2,3) #=> ArgumentError lambda {|a,b| [a,b] }.call(1) #=> ArgumentError lambda {|a,b| [a,b] }.call([1,2]) #=> ArgumentError Proc#lambda? is a predicate for the tricks. It returns +true+ if no tricks apply. lambda {}.lambda? #=> true proc {}.lambda? #=> false Proc.new is the same as +proc+. Proc.new {}.lambda? #=> false +lambda+, +proc+ and Proc.new preserve the tricks of a Proc object given by & argument. lambda(&lambda {}).lambda? #=> true proc(&lambda {}).lambda? #=> true Proc.new(&lambda {}).lambda? #=> true lambda(&proc {}).lambda? #=> false proc(&proc {}).lambda? #=> false Proc.new(&proc {}).lambda? #=> false A Proc object generated by & argument has the tricks def n(&b) b.lambda? end n {} #=> false The & argument preserves the tricks if a Proc object is given by & argument. n(&lambda {}) #=> true n(&proc {}) #=> false n(&Proc.new {}) #=> false A Proc object converted from a method has no tricks. def m() end method(:m).to_proc.lambda? #=> true n(&method(:m)) #=> true n(&method(:m).to_proc) #=> true +define_method+ is treated the same as method definition. The defined method has no tricks. class C define_method(:d) {} end C.new.d(1,2) #=> ArgumentError C.new.method(:d).to_proc.lambda? #=> true +define_method+ always defines a method without the tricks, even if a non-lambda Proc object is given. This is the only exception for which the tricks are not preserved. class C define_method(:e, &proc {}) end C.new.e(1,2) #=> ArgumentError C.new.method(:e).to_proc.lambda? #=> true This exception ensures that methods never have tricks and makes it easy to have wrappers to define methods that behave as usual. class C def self.def2(name, &body) define_method(name, &body) end def2(:f) {} end C.new.f(1,2) #=> ArgumentError The wrapper def2 defines a method which has no tricks. @overload lambda? @return [Boolean];T;#0;$@z;.F;/o;0;1T;2i;3i;Bi;%@y;9I"VALUE rb_proc_lambda_p(VALUE procval) { rb_proc_t *proc; GetProcPtr(procval, proc); return RBOOL(proc->is_lambda); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Proc#binding;F;7[;[[@iJ ;T;;;0;[;{;IC; "Returns the binding associated with prc. def fred(param) proc {} end b = fred(99) eval("param", b.binding) #=> 99 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" binding;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Binding;T;$@z;![;"I"@return [Binding];T;#0;$@z;.F;Bi;C0;7[;$@z;![;"I"Returns the binding associated with prc. def fred(param) proc {} end b = fred(99) eval("param", b.binding) #=> 99 @overload binding @return [Binding];T;#0;$@z;.F;/o;0;1T;2i= ;3iH ;%@y;9I"=static VALUE proc_binding(VALUE self) { VALUE bindval, binding_self = Qundef; rb_binding_t *bind; const rb_proc_t *proc; const rb_iseq_t *iseq = NULL; const struct rb_block *block; const rb_env_t *env = NULL; GetProcPtr(self, proc); block = &proc->block; if (proc->is_isolated) rb_raise(rb_eArgError, "Can't create Binding from isolated Proc"); again: switch (vm_block_type(block)) { case block_type_iseq: iseq = block->as.captured.code.iseq; binding_self = block->as.captured.self; env = VM_ENV_ENVVAL_PTR(block->as.captured.ep); break; case block_type_proc: GetProcPtr(block->as.proc, proc); block = &proc->block; goto again; case block_type_ifunc: { const struct vm_ifunc *ifunc = block->as.captured.code.ifunc; if (IS_METHOD_PROC_IFUNC(ifunc)) { VALUE method = (VALUE)ifunc->data; VALUE name = rb_fstring_lit(""); rb_iseq_t *empty; binding_self = method_receiver(method); iseq = rb_method_iseq(method); env = VM_ENV_ENVVAL_PTR(block->as.captured.ep); env = env_clone(env, method_cref(method)); /* set empty iseq */ empty = rb_iseq_new(NULL, name, name, Qnil, 0, ISEQ_TYPE_TOP); RB_OBJ_WRITE(env, &env->iseq, empty); break; } } /* FALLTHROUGH */ case block_type_symbol: rb_raise(rb_eArgError, "Can't create Binding from C level Proc"); UNREACHABLE_RETURN(Qnil); } bindval = rb_binding_alloc(rb_cBinding); GetBindingPtr(bindval, bind); RB_OBJ_WRITE(bindval, &bind->block.as.captured.self, binding_self); RB_OBJ_WRITE(bindval, &bind->block.as.captured.code.iseq, env->iseq); rb_vm_block_ep_update(bindval, &bind->block, env->ep); RB_OBJ_WRITTEN(bindval, Qundef, VM_ENV_ENVVAL(env->ep)); if (iseq) { rb_iseq_check(iseq); RB_OBJ_WRITE(bindval, &bind->pathobj, iseq->body->location.pathobj); bind->first_lineno = FIX2INT(rb_iseq_first_lineno(iseq)); } else { RB_OBJ_WRITE(bindval, &bind->pathobj, rb_iseq_pathobj_new(rb_fstring_lit("(binding)"), Qnil)); bind->first_lineno = 1; } return bindval; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Proc#curry;F;7[[@90;[[@i ;T;;} ;0;[;{;IC; "-Returns a curried proc. If the optional arity argument is given, it determines the number of arguments. A curried proc receives some arguments. If a sufficient number of arguments are supplied, it passes the supplied arguments to the original proc and returns the result. Otherwise, returns another curried proc that takes the rest of arguments. b = proc {|x, y, z| (x||0) + (y||0) + (z||0) } p b.curry[1][2][3] #=> 6 p b.curry[1, 2][3, 4] #=> 6 p b.curry(5)[1][2][3][4][5] #=> 6 p b.curry(5)[1, 2][3, 4][5] #=> 6 p b.curry(1)[1] #=> 1 b = proc {|x, y, z, *w| (x||0) + (y||0) + (z||0) + w.inject(0, &:+) } p b.curry[1][2][3] #=> 6 p b.curry[1, 2][3, 4] #=> 10 p b.curry(5)[1][2][3][4][5] #=> 15 p b.curry(5)[1, 2][3, 4][5] #=> 15 p b.curry(1)[1] #=> 1 b = lambda {|x, y, z| (x||0) + (y||0) + (z||0) } p b.curry[1][2][3] #=> 6 p b.curry[1, 2][3, 4] #=> wrong number of arguments (given 4, expected 3) p b.curry(5) #=> wrong number of arguments (given 5, expected 3) p b.curry(1) #=> wrong number of arguments (given 1, expected 3) b = lambda {|x, y, z, *w| (x||0) + (y||0) + (z||0) + w.inject(0, &:+) } p b.curry[1][2][3] #=> 6 p b.curry[1, 2][3, 4] #=> 10 p b.curry(5)[1][2][3][4][5] #=> 15 p b.curry(5)[1, 2][3, 4][5] #=> 15 p b.curry(1) #=> wrong number of arguments (given 1, expected 3) b = proc { :foo } p b.curry[] #=> :foo ;T;[o;= ;>I" overload;F;?0;;} ;@0;:I" curry;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@{;![;"I"@return [Proc];T;#0;$@{;.F;Bi;C0;7[;$@{o;= ;>I" overload;F;?0;;} ;@0;:I"curry(arity);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@{;![;"I"@return [Proc];T;#0;$@{;.F;Bi;C0;7[[I" arity;T0;$@{;![;"I"xReturns a curried proc. If the optional arity argument is given, it determines the number of arguments. A curried proc receives some arguments. If a sufficient number of arguments are supplied, it passes the supplied arguments to the original proc and returns the result. Otherwise, returns another curried proc that takes the rest of arguments. b = proc {|x, y, z| (x||0) + (y||0) + (z||0) } p b.curry[1][2][3] #=> 6 p b.curry[1, 2][3, 4] #=> 6 p b.curry(5)[1][2][3][4][5] #=> 6 p b.curry(5)[1, 2][3, 4][5] #=> 6 p b.curry(1)[1] #=> 1 b = proc {|x, y, z, *w| (x||0) + (y||0) + (z||0) + w.inject(0, &:+) } p b.curry[1][2][3] #=> 6 p b.curry[1, 2][3, 4] #=> 10 p b.curry(5)[1][2][3][4][5] #=> 15 p b.curry(5)[1, 2][3, 4][5] #=> 15 p b.curry(1)[1] #=> 1 b = lambda {|x, y, z| (x||0) + (y||0) + (z||0) } p b.curry[1][2][3] #=> 6 p b.curry[1, 2][3, 4] #=> wrong number of arguments (given 4, expected 3) p b.curry(5) #=> wrong number of arguments (given 5, expected 3) p b.curry(1) #=> wrong number of arguments (given 1, expected 3) b = lambda {|x, y, z, *w| (x||0) + (y||0) + (z||0) + w.inject(0, &:+) } p b.curry[1][2][3] #=> 6 p b.curry[1, 2][3, 4] #=> 10 p b.curry(5)[1][2][3][4][5] #=> 15 p b.curry(5)[1, 2][3, 4][5] #=> 15 p b.curry(1) #=> wrong number of arguments (given 1, expected 3) b = proc { :foo } p b.curry[] #=> :foo @overload curry @return [Proc] @overload curry(arity) @return [Proc];T;#0;$@{;.F;/o;0;1T;2i ;3i ;%@y;9I"static VALUE proc_curry(int argc, const VALUE *argv, VALUE self) { int sarity, max_arity, min_arity = rb_proc_min_max_arity(self, &max_arity); VALUE arity; if (rb_check_arity(argc, 0, 1) == 0 || NIL_P(arity = argv[0])) { arity = INT2FIX(min_arity); } else { sarity = FIX2INT(arity); if (rb_proc_lambda_p(self)) { rb_check_arity(sarity, min_arity, max_arity); } } return make_curry_proc(self, rb_ary_new(), arity); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Proc#<<;F;7[[I"g;T0;[[@iM;T;;;0;[;{;IC; ":Returns a proc that is the composition of this proc and the given g. The returned proc takes a variable number of arguments, calls g with them then calls this proc with the result. f = proc {|x| x * x } g = proc {|x| x + x } p (f << g).call(2) #=> 16 See Proc#>> for detailed explanations. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" <<(g);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@D{;![;"I"@return [Proc];T;#0;$@D{;.F;Bi;C0;7[[I"g;T0;$@D{;![;"I"]Returns a proc that is the composition of this proc and the given g. The returned proc takes a variable number of arguments, calls g with them then calls this proc with the result. f = proc {|x| x * x } g = proc {|x| x + x } p (f << g).call(2) #=> 16 See Proc#>> for detailed explanations. @overload <<(g) @return [Proc];T;#0;$@D{;.F;/o;0;1T;2i?;3iK;%@y;9I"ystatic VALUE proc_compose_to_left(VALUE self, VALUE g) { return rb_proc_compose_to_left(self, to_callable(g)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Proc#>>;F;7[[I"g;T0;[[@i;T;;;0;[;{;IC; "uReturns a proc that is the composition of this proc and the given g. The returned proc takes a variable number of arguments, calls this proc with them then calls g with the result. f = proc {|x| x * x } g = proc {|x| x + x } p (f >> g).call(2) #=> 8 g could be other Proc, or Method, or any other object responding to +call+ method: class Parser def self.call(text) # ...some complicated parsing logic... end end pipeline = File.method(:read) >> Parser >> proc { |data| puts "data size: #{data.count}" } pipeline.call('data.json') See also Method#>> and Method#<<. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" >>(g);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@c{;![;"I"@return [Proc];T;#0;$@c{;.F;Bi;C0;7[[I"g;T0;$@c{;![;"I"Returns a proc that is the composition of this proc and the given g. The returned proc takes a variable number of arguments, calls this proc with them then calls g with the result. f = proc {|x| x * x } g = proc {|x| x + x } p (f >> g).call(2) #=> 8 g could be other Proc, or Method, or any other object responding to +call+ method: class Parser def self.call(text) # ...some complicated parsing logic... end end pipeline = File.method(:read) >> Parser >> proc { |data| puts "data size: #{data.count}" } pipeline.call('data.json') See also Method#>> and Method#<<. @overload >>(g) @return [Proc];T;#0;$@c{;.F;/o;0;1T;2in;3i;%@y;9I"{static VALUE proc_compose_to_right(VALUE self, VALUE g) { return rb_proc_compose_to_right(self, to_callable(g)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Proc#==;F;7[[I" other;T0;[[@i;T;;F;0;[;{;IC; "HTwo procs are the same if, and only if, they were created from the same code block. def return_block(&block) block end def pass_block_twice(&block) [return_block(&block), return_block(&block)] end block1, block2 = pass_block_twice { puts 'test' } # Blocks might be instantiated into Proc's lazily, so they may, or may not, # be the same object. # But they are produced from the same code block, so they are equal block1 == block2 #=> true # Another Proc will never be equal, even if the code is the "same" block1 == proc { puts 'test' } #=> false ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@{;![;"I"@return [Boolean];T;#0;$@{;.F;Bi;C0;7[[I" other;T0;$@{o;= ;>I" overload;F;?0;;V;@0;:I"eql?(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@{;![;"I"@return [Boolean];T;#0;$@{;.F;Bi;C0;7[[I" other;T0;$@{;![;"I"Two procs are the same if, and only if, they were created from the same code block. def return_block(&block) block end def pass_block_twice(&block) [return_block(&block), return_block(&block)] end block1, block2 = pass_block_twice { puts 'test' } # Blocks might be instantiated into Proc's lazily, so they may, or may not, # be the same object. # But they are produced from the same code block, so they are equal block1 == block2 #=> true # Another Proc will never be equal, even if the code is the "same" block1 == proc { puts 'test' } #=> false @overload ==(other) @return [Boolean] @overload eql?(other) @return [Boolean];T;#0;$@{;.F;/o;0;1T;2i;3i;%@y;9I"static VALUE proc_eq(VALUE self, VALUE other) { const rb_proc_t *self_proc, *other_proc; const struct rb_block *self_block, *other_block; if (rb_obj_class(self) != rb_obj_class(other)) { return Qfalse; } GetProcPtr(self, self_proc); GetProcPtr(other, other_proc); if (self_proc->is_from_method != other_proc->is_from_method || self_proc->is_lambda != other_proc->is_lambda) { return Qfalse; } self_block = &self_proc->block; other_block = &other_proc->block; if (vm_block_type(self_block) != vm_block_type(other_block)) { return Qfalse; } switch (vm_block_type(self_block)) { case block_type_iseq: if (self_block->as.captured.ep != \ other_block->as.captured.ep || self_block->as.captured.code.iseq != \ other_block->as.captured.code.iseq) { return Qfalse; } break; case block_type_ifunc: if (self_block->as.captured.ep != \ other_block->as.captured.ep || self_block->as.captured.code.ifunc != \ other_block->as.captured.code.ifunc) { return Qfalse; } break; case block_type_proc: if (self_block->as.proc != other_block->as.proc) { return Qfalse; } break; case block_type_symbol: if (self_block->as.symbol != other_block->as.symbol) { return Qfalse; } break; } return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Proc#eql?;F;7[[I" other;T0;[[@i;T;;V;0;[;{;IC; "HTwo procs are the same if, and only if, they were created from the same code block. def return_block(&block) block end def pass_block_twice(&block) [return_block(&block), return_block(&block)] end block1, block2 = pass_block_twice { puts 'test' } # Blocks might be instantiated into Proc's lazily, so they may, or may not, # be the same object. # But they are produced from the same code block, so they are equal block1 == block2 #=> true # Another Proc will never be equal, even if the code is the "same" block1 == proc { puts 'test' } #=> false;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@{;![;"I"@return [Boolean];T;#0;$@{;.F;Bi;C0;7[[I" other;T0;$@{o;= ;>I" overload;F;?0;;V;@0;:I"eql?(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@{;![;"I"@return [Boolean];T;#0;$@{;.F;Bi;C0;7[[I" other;T0;$@{;![;"@{;#0;$@{;.F;/o;0;1T;2i;3i;Bi;%@y;9I"static VALUE proc_eq(VALUE self, VALUE other) { const rb_proc_t *self_proc, *other_proc; const struct rb_block *self_block, *other_block; if (rb_obj_class(self) != rb_obj_class(other)) { return Qfalse; } GetProcPtr(self, self_proc); GetProcPtr(other, other_proc); if (self_proc->is_from_method != other_proc->is_from_method || self_proc->is_lambda != other_proc->is_lambda) { return Qfalse; } self_block = &self_proc->block; other_block = &other_proc->block; if (vm_block_type(self_block) != vm_block_type(other_block)) { return Qfalse; } switch (vm_block_type(self_block)) { case block_type_iseq: if (self_block->as.captured.ep != \ other_block->as.captured.ep || self_block->as.captured.code.iseq != \ other_block->as.captured.code.iseq) { return Qfalse; } break; case block_type_ifunc: if (self_block->as.captured.ep != \ other_block->as.captured.ep || self_block->as.captured.code.ifunc != \ other_block->as.captured.code.ifunc) { return Qfalse; } break; case block_type_proc: if (self_block->as.proc != other_block->as.proc) { return Qfalse; } break; case block_type_symbol: if (self_block->as.symbol != other_block->as.symbol) { return Qfalse; } break; } return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Proc#source_location;F;7[;[[@in;T;; ;0;[;{;IC; "Returns the Ruby source filename and line number containing this proc or +nil+ if this proc was not defined in Ruby (i.e. native). ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"source_location;T;IC; ";T;[o;A ;>I" return;F;?I"];T;0;@[I" Array;TI" Integer;T;$@{;![;"I"@return [Array, Integer]];T;#0;$@{;.F;Bi;C0;7[;$@{;![;"I"Returns the Ruby source filename and line number containing this proc or +nil+ if this proc was not defined in Ruby (i.e. native). @overload source_location @return [Array, Integer]];T;#0;$@{;.F;/o;0;1T;2if;3ik;%@y;9I"`VALUE rb_proc_location(VALUE self) { return iseq_location(rb_proc_get_iseq(self, 0)); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Proc#parameters;F;7[;[[@i;T;; ;0;[;{;IC; "Returns the parameter information of this proc. prc = lambda{|x, y=42, *other|} prc.parameters #=> [[:req, :x], [:opt, :y], [:rest, :other]] ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"parameters;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@{;![;"I"@return [Array];T;#0;$@{;.F;Bi;C0;7[;$@{;![;"I"Returns the parameter information of this proc. prc = lambda{|x, y=42, *other|} prc.parameters #=> [[:req, :x], [:opt, :y], [:rest, :other]] @overload parameters @return [Array];T;#0;$@{;.F;/o;0;1T;2i;3i;%@y;9I"static VALUE rb_proc_parameters(VALUE self) { int is_proc; const rb_iseq_t *iseq = rb_proc_get_iseq(self, &is_proc); if (!iseq) { return rb_unnamed_parameters(rb_proc_arity(self)); } return rb_iseq_parameters(iseq, is_proc); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Proc#ruby2_keywords;F;7[;[[@i;T;;;0;[;{;IC; "Marks the proc as passing keywords through a normal argument splat. This should only be called on procs that accept an argument splat (*args) but not explicit keywords or a keyword splat. It marks the proc such that if the proc is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the proc to other methods. This should only be used for procs that delegate keywords to another method, and only for backwards compatibility with Ruby versions before 2.7. This method will probably be removed at some point, as it exists only for backwards compatibility. As it does not exist in Ruby versions before 2.7, check that the proc responds to this method before calling it. Also, be aware that if this method is removed, the behavior of the proc will change so that it does not pass through keywords. module Mod foo = ->(meth, *args, &block) do send(:"do_#{meth}", *args, &block) end foo.ruby2_keywords if foo.respond_to?(:ruby2_keywords) end ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ruby2_keywords;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Proc;T;$@|;![;"I"@return [Proc];T;#0;$@|;.F;Bi;C0;7[;$@|;![;"I"Marks the proc as passing keywords through a normal argument splat. This should only be called on procs that accept an argument splat (*args) but not explicit keywords or a keyword splat. It marks the proc such that if the proc is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the proc to other methods. This should only be used for procs that delegate keywords to another method, and only for backwards compatibility with Ruby versions before 2.7. This method will probably be removed at some point, as it exists only for backwards compatibility. As it does not exist in Ruby versions before 2.7, check that the proc responds to this method before calling it. Also, be aware that if this method is removed, the behavior of the proc will change so that it does not pass through keywords. module Mod foo = ->(meth, *args, &block) do send(:"do_#{meth}", *args, &block) end foo.ruby2_keywords if foo.respond_to?(:ruby2_keywords) end @overload ruby2_keywords @return [Proc];T;#0;$@|;.F;/o;0;1T;2i;3i;%@y;9I"static VALUE proc_ruby2_keywords(VALUE procval) { rb_proc_t *proc; GetProcPtr(procval, proc); rb_check_frozen(procval); if (proc->is_from_method) { rb_warn("Skipping set of ruby2_keywords flag for proc (proc created from method)"); return procval; } switch (proc->block.type) { case block_type_iseq: if (proc->block.as.captured.code.iseq->body->param.flags.has_rest && !proc->block.as.captured.code.iseq->body->param.flags.has_kw && !proc->block.as.captured.code.iseq->body->param.flags.has_kwrest) { proc->block.as.captured.code.iseq->body->param.flags.ruby2_keywords = 1; } else { rb_warn("Skipping set of ruby2_keywords flag for proc (proc accepts keywords or proc does not accept argument splat)"); } break; default: rb_warn("Skipping set of ruby2_keywords flag for proc (proc not defined in Ruby)"); break; } return procval; };T;:I"static VALUE;T;;T; @y; IC;[; @y; IC;[; @y; IC;{;IC;{;T;IC;{;T;T;{@z;G;[;[[@i>[@ii;T;;3;;;;;[;{;IC; "'A +Proc+ object is an encapsulation of a block of code, which can be stored in a local variable, passed to a method or another Proc, and can be called. Proc is an essential concept in Ruby and a core of its functional programming features. square = Proc.new {|x| x**2 } square.call(3) #=> 9 # shorthands: square.(3) #=> 9 square[3] #=> 9 Proc objects are _closures_, meaning they remember and can use the entire context in which they were created. def gen_times(factor) Proc.new {|n| n*factor } # remembers the value of factor at the moment of creation end times3 = gen_times(3) times5 = gen_times(5) times3.call(12) #=> 36 times5.call(5) #=> 25 times3.call(times5.call(4)) #=> 60 == Creation There are several methods to create a Proc * Use the Proc class constructor: proc1 = Proc.new {|x| x**2 } * Use the Kernel#proc method as a shorthand of Proc.new: proc2 = proc {|x| x**2 } * Receiving a block of code into proc argument (note the &): def make_proc(&block) block end proc3 = make_proc {|x| x**2 } * Construct a proc with lambda semantics using the Kernel#lambda method (see below for explanations about lambdas): lambda1 = lambda {|x| x**2 } * Use the {Lambda proc literal}[doc/syntax/literals_rdoc.html#label-Lambda+Proc+Literals] syntax (also constructs a proc with lambda semantics): lambda2 = ->(x) { x**2 } == Lambda and non-lambda semantics Procs are coming in two flavors: lambda and non-lambda (regular procs). Differences are: * In lambdas, +return+ and +break+ means exit from this lambda; * In non-lambda procs, +return+ means exit from embracing method (and will throw +LocalJumpError+ if invoked outside the method); * In non-lambda procs, +break+ means exit from the method which the block given for. (and will throw +LocalJumpError+ if invoked after the method returns); * In lambdas, arguments are treated in the same way as in methods: strict, with +ArgumentError+ for mismatching argument number, and no additional argument processing; * Regular procs accept arguments more generously: missing arguments are filled with +nil+, single Array arguments are deconstructed if the proc has multiple arguments, and there is no error raised on extra arguments. Examples: # +return+ in non-lambda proc, +b+, exits +m2+. # (The block +{ return }+ is given for +m1+ and embraced by +m2+.) $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1 { return }; $a << :m2 end; m2; p $a #=> [] # +break+ in non-lambda proc, +b+, exits +m1+. # (The block +{ break }+ is given for +m1+ and embraced by +m2+.) $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1 { break }; $a << :m2 end; m2; p $a #=> [:m2] # +next+ in non-lambda proc, +b+, exits the block. # (The block +{ next }+ is given for +m1+ and embraced by +m2+.) $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1 { next }; $a << :m2 end; m2; p $a #=> [:m1, :m2] # Using +proc+ method changes the behavior as follows because # The block is given for +proc+ method and embraced by +m2+. $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&proc { return }); $a << :m2 end; m2; p $a #=> [] $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&proc { break }); $a << :m2 end; m2; p $a # break from proc-closure (LocalJumpError) $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&proc { next }); $a << :m2 end; m2; p $a #=> [:m1, :m2] # +return+, +break+ and +next+ in the stubby lambda exits the block. # (+lambda+ method behaves same.) # (The block is given for stubby lambda syntax and embraced by +m2+.) $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&-> { return }); $a << :m2 end; m2; p $a #=> [:m1, :m2] $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&-> { break }); $a << :m2 end; m2; p $a #=> [:m1, :m2] $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&-> { next }); $a << :m2 end; m2; p $a #=> [:m1, :m2] p = proc {|x, y| "x=#{x}, y=#{y}" } p.call(1, 2) #=> "x=1, y=2" p.call([1, 2]) #=> "x=1, y=2", array deconstructed p.call(1, 2, 8) #=> "x=1, y=2", extra argument discarded p.call(1) #=> "x=1, y=", nil substituted instead of error l = lambda {|x, y| "x=#{x}, y=#{y}" } l.call(1, 2) #=> "x=1, y=2" l.call([1, 2]) # ArgumentError: wrong number of arguments (given 1, expected 2) l.call(1, 2, 8) # ArgumentError: wrong number of arguments (given 3, expected 2) l.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2) def test_return -> { return 3 }.call # just returns from lambda into method body proc { return 4 }.call # returns from method return 5 end test_return # => 4, return from proc Lambdas are useful as self-sufficient functions, in particular useful as arguments to higher-order functions, behaving exactly like Ruby methods. Procs are useful for implementing iterators: def test [[1, 2], [3, 4], [5, 6]].map {|a, b| return a if a + b > 10 } # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ end Inside +map+, the block of code is treated as a regular (non-lambda) proc, which means that the internal arrays will be deconstructed to pairs of arguments, and +return+ will exit from the method +test+. That would not be possible with a stricter lambda. You can tell a lambda from a regular proc by using the #lambda? instance method. Lambda semantics is typically preserved during the proc lifetime, including &-deconstruction to a block of code: p = proc {|x, y| x } l = lambda {|x, y| x } [[1, 2], [3, 4]].map(&p) #=> [1, 3] [[1, 2], [3, 4]].map(&l) # ArgumentError: wrong number of arguments (given 1, expected 2) The only exception is dynamic method definition: even if defined by passing a non-lambda proc, methods still have normal semantics of argument checking. class C define_method(:e, &proc {}) end C.new.e(1,2) #=> ArgumentError C.new.method(:e).to_proc.lambda? #=> true This exception ensures that methods never have unusual argument passing conventions, and makes it easy to have wrappers defining methods that behave as usual. class C def self.def2(name, &body) define_method(name, &body) end def2(:f) {} end C.new.f(1,2) #=> ArgumentError The wrapper def2 receives _body_ as a non-lambda proc, yet defines a method which has normal semantics. == Conversion of other objects to procs Any object that implements the +to_proc+ method can be converted into a proc by the & operator, and therefore can be consumed by iterators. class Greeter def initialize(greeting) @greeting = greeting end def to_proc proc {|name| "#{@greeting}, #{name}!" } end end hi = Greeter.new("Hi") hey = Greeter.new("Hey") ["Bob", "Jane"].map(&hi) #=> ["Hi, Bob!", "Hi, Jane!"] ["Bob", "Jane"].map(&hey) #=> ["Hey, Bob!", "Hey, Jane!"] Of the Ruby core classes, this method is implemented by Symbol, Method, and Hash. :to_s.to_proc.call(1) #=> "1" [1, 2].map(&:to_s) #=> ["1", "2"] method(:puts).to_proc.call(1) # prints 1 [1, 2].each(&method(:puts)) # prints 1, 2 {test: 1}.to_proc.call(:test) #=> 1 %i[test many keys].map(&{test: 1}) #=> [1, nil, nil] == Orphaned Proc +return+ and +break+ in a block exit a method. If a Proc object is generated from the block and the Proc object survives until the method is returned, +return+ and +break+ cannot work. In such case, +return+ and +break+ raises LocalJumpError. A Proc object in such situation is called as orphaned Proc object. Note that the method to exit is different for +return+ and +break+. There is a situation that orphaned for +break+ but not orphaned for +return+. def m1(&b) b.call end; def m2(); m1 { return } end; m2 # ok def m1(&b) b.call end; def m2(); m1 { break } end; m2 # ok def m1(&b) b end; def m2(); m1 { return }.call end; m2 # ok def m1(&b) b end; def m2(); m1 { break }.call end; m2 # LocalJumpError def m1(&b) b end; def m2(); m1 { return } end; m2.call # LocalJumpError def m1(&b) b end; def m2(); m1 { break } end; m2.call # LocalJumpError Since +return+ and +break+ exits the block itself in lambdas, lambdas cannot be orphaned. == Numbered parameters Numbered parameters are implicitly defined block parameters intended to simplify writing short blocks: # Explicit parameter: %w[test me please].each { |str| puts str.upcase } # prints TEST, ME, PLEASE (1..5).map { |i| i**2 } # => [1, 4, 9, 16, 25] # Implicit parameter: %w[test me please].each { puts _1.upcase } # prints TEST, ME, PLEASE (1..5).map { _1**2 } # => [1, 4, 9, 16, 25] Parameter names from +_1+ to +_9+ are supported: [10, 20, 30].zip([40, 50, 60], [70, 80, 90]).map { _1 + _2 + _3 } # => [120, 150, 180] Though, it is advised to resort to them wisely, probably limiting yourself to +_1+ and +_2+, and to one-line blocks. Numbered parameters can't be used together with explicitly named ones: [10, 20, 30].map { |x| _1**2 } # SyntaxError (ordinary parameter is defined) To avoid conflicts, naming local variables or method arguments +_1+, +_2+ and so on, causes a warning. _1 = 'test' # warning: `_1' is reserved as numbered parameter Using implicit numbered parameters affects block's arity: p = proc { _1 + _2 } l = lambda { _1 + _2 } p.parameters # => [[:opt, :_1], [:opt, :_2]] p.arity # => 2 l.parameters # => [[:req, :_1], [:req, :_2]] l.arity # => 2 Blocks with numbered parameters can't be nested: %w[test me].each { _1.each_char { p _1 } } # SyntaxError (numbered parameter is already used in outer block here) # %w[test me].each { _1.each_char { p _1 } } # ^~ Numbered parameters were introduced in Ruby 2.7.;T;[;![;"I"' A +Proc+ object is an encapsulation of a block of code, which can be stored in a local variable, passed to a method or another Proc, and can be called. Proc is an essential concept in Ruby and a core of its functional programming features. square = Proc.new {|x| x**2 } square.call(3) #=> 9 # shorthands: square.(3) #=> 9 square[3] #=> 9 Proc objects are _closures_, meaning they remember and can use the entire context in which they were created. def gen_times(factor) Proc.new {|n| n*factor } # remembers the value of factor at the moment of creation end times3 = gen_times(3) times5 = gen_times(5) times3.call(12) #=> 36 times5.call(5) #=> 25 times3.call(times5.call(4)) #=> 60 == Creation There are several methods to create a Proc * Use the Proc class constructor: proc1 = Proc.new {|x| x**2 } * Use the Kernel#proc method as a shorthand of Proc.new: proc2 = proc {|x| x**2 } * Receiving a block of code into proc argument (note the &): def make_proc(&block) block end proc3 = make_proc {|x| x**2 } * Construct a proc with lambda semantics using the Kernel#lambda method (see below for explanations about lambdas): lambda1 = lambda {|x| x**2 } * Use the {Lambda proc literal}[doc/syntax/literals_rdoc.html#label-Lambda+Proc+Literals] syntax (also constructs a proc with lambda semantics): lambda2 = ->(x) { x**2 } == Lambda and non-lambda semantics Procs are coming in two flavors: lambda and non-lambda (regular procs). Differences are: * In lambdas, +return+ and +break+ means exit from this lambda; * In non-lambda procs, +return+ means exit from embracing method (and will throw +LocalJumpError+ if invoked outside the method); * In non-lambda procs, +break+ means exit from the method which the block given for. (and will throw +LocalJumpError+ if invoked after the method returns); * In lambdas, arguments are treated in the same way as in methods: strict, with +ArgumentError+ for mismatching argument number, and no additional argument processing; * Regular procs accept arguments more generously: missing arguments are filled with +nil+, single Array arguments are deconstructed if the proc has multiple arguments, and there is no error raised on extra arguments. Examples: # +return+ in non-lambda proc, +b+, exits +m2+. # (The block +{ return }+ is given for +m1+ and embraced by +m2+.) $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1 { return }; $a << :m2 end; m2; p $a #=> [] # +break+ in non-lambda proc, +b+, exits +m1+. # (The block +{ break }+ is given for +m1+ and embraced by +m2+.) $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1 { break }; $a << :m2 end; m2; p $a #=> [:m2] # +next+ in non-lambda proc, +b+, exits the block. # (The block +{ next }+ is given for +m1+ and embraced by +m2+.) $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1 { next }; $a << :m2 end; m2; p $a #=> [:m1, :m2] # Using +proc+ method changes the behavior as follows because # The block is given for +proc+ method and embraced by +m2+. $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&proc { return }); $a << :m2 end; m2; p $a #=> [] $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&proc { break }); $a << :m2 end; m2; p $a # break from proc-closure (LocalJumpError) $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&proc { next }); $a << :m2 end; m2; p $a #=> [:m1, :m2] # +return+, +break+ and +next+ in the stubby lambda exits the block. # (+lambda+ method behaves same.) # (The block is given for stubby lambda syntax and embraced by +m2+.) $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&-> { return }); $a << :m2 end; m2; p $a #=> [:m1, :m2] $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&-> { break }); $a << :m2 end; m2; p $a #=> [:m1, :m2] $a = []; def m1(&b) b.call; $a << :m1 end; def m2() m1(&-> { next }); $a << :m2 end; m2; p $a #=> [:m1, :m2] p = proc {|x, y| "x=#{x}, y=#{y}" } p.call(1, 2) #=> "x=1, y=2" p.call([1, 2]) #=> "x=1, y=2", array deconstructed p.call(1, 2, 8) #=> "x=1, y=2", extra argument discarded p.call(1) #=> "x=1, y=", nil substituted instead of error l = lambda {|x, y| "x=#{x}, y=#{y}" } l.call(1, 2) #=> "x=1, y=2" l.call([1, 2]) # ArgumentError: wrong number of arguments (given 1, expected 2) l.call(1, 2, 8) # ArgumentError: wrong number of arguments (given 3, expected 2) l.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2) def test_return -> { return 3 }.call # just returns from lambda into method body proc { return 4 }.call # returns from method return 5 end test_return # => 4, return from proc Lambdas are useful as self-sufficient functions, in particular useful as arguments to higher-order functions, behaving exactly like Ruby methods. Procs are useful for implementing iterators: def test [[1, 2], [3, 4], [5, 6]].map {|a, b| return a if a + b > 10 } # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ end Inside +map+, the block of code is treated as a regular (non-lambda) proc, which means that the internal arrays will be deconstructed to pairs of arguments, and +return+ will exit from the method +test+. That would not be possible with a stricter lambda. You can tell a lambda from a regular proc by using the #lambda? instance method. Lambda semantics is typically preserved during the proc lifetime, including &-deconstruction to a block of code: p = proc {|x, y| x } l = lambda {|x, y| x } [[1, 2], [3, 4]].map(&p) #=> [1, 3] [[1, 2], [3, 4]].map(&l) # ArgumentError: wrong number of arguments (given 1, expected 2) The only exception is dynamic method definition: even if defined by passing a non-lambda proc, methods still have normal semantics of argument checking. class C define_method(:e, &proc {}) end C.new.e(1,2) #=> ArgumentError C.new.method(:e).to_proc.lambda? #=> true This exception ensures that methods never have unusual argument passing conventions, and makes it easy to have wrappers defining methods that behave as usual. class C def self.def2(name, &body) define_method(name, &body) end def2(:f) {} end C.new.f(1,2) #=> ArgumentError The wrapper def2 receives _body_ as a non-lambda proc, yet defines a method which has normal semantics. == Conversion of other objects to procs Any object that implements the +to_proc+ method can be converted into a proc by the & operator, and therefore can be consumed by iterators. class Greeter def initialize(greeting) @greeting = greeting end def to_proc proc {|name| "#{@greeting}, #{name}!" } end end hi = Greeter.new("Hi") hey = Greeter.new("Hey") ["Bob", "Jane"].map(&hi) #=> ["Hi, Bob!", "Hi, Jane!"] ["Bob", "Jane"].map(&hey) #=> ["Hey, Bob!", "Hey, Jane!"] Of the Ruby core classes, this method is implemented by Symbol, Method, and Hash. :to_s.to_proc.call(1) #=> "1" [1, 2].map(&:to_s) #=> ["1", "2"] method(:puts).to_proc.call(1) # prints 1 [1, 2].each(&method(:puts)) # prints 1, 2 {test: 1}.to_proc.call(:test) #=> 1 %i[test many keys].map(&{test: 1}) #=> [1, nil, nil] == Orphaned Proc +return+ and +break+ in a block exit a method. If a Proc object is generated from the block and the Proc object survives until the method is returned, +return+ and +break+ cannot work. In such case, +return+ and +break+ raises LocalJumpError. A Proc object in such situation is called as orphaned Proc object. Note that the method to exit is different for +return+ and +break+. There is a situation that orphaned for +break+ but not orphaned for +return+. def m1(&b) b.call end; def m2(); m1 { return } end; m2 # ok def m1(&b) b.call end; def m2(); m1 { break } end; m2 # ok def m1(&b) b end; def m2(); m1 { return }.call end; m2 # ok def m1(&b) b end; def m2(); m1 { break }.call end; m2 # LocalJumpError def m1(&b) b end; def m2(); m1 { return } end; m2.call # LocalJumpError def m1(&b) b end; def m2(); m1 { break } end; m2.call # LocalJumpError Since +return+ and +break+ exits the block itself in lambdas, lambdas cannot be orphaned. == Numbered parameters Numbered parameters are implicitly defined block parameters intended to simplify writing short blocks: # Explicit parameter: %w[test me please].each { |str| puts str.upcase } # prints TEST, ME, PLEASE (1..5).map { |i| i**2 } # => [1, 4, 9, 16, 25] # Implicit parameter: %w[test me please].each { puts _1.upcase } # prints TEST, ME, PLEASE (1..5).map { _1**2 } # => [1, 4, 9, 16, 25] Parameter names from +_1+ to +_9+ are supported: [10, 20, 30].zip([40, 50, 60], [70, 80, 90]).map { _1 + _2 + _3 } # => [120, 150, 180] Though, it is advised to resort to them wisely, probably limiting yourself to +_1+ and +_2+, and to one-line blocks. Numbered parameters can't be used together with explicitly named ones: [10, 20, 30].map { |x| _1**2 } # SyntaxError (ordinary parameter is defined) To avoid conflicts, naming local variables or method arguments +_1+, +_2+ and so on, causes a warning. _1 = 'test' # warning: `_1' is reserved as numbered parameter Using implicit numbered parameters affects block's arity: p = proc { _1 + _2 } l = lambda { _1 + _2 } p.parameters # => [[:opt, :_1], [:opt, :_2]] p.arity # => 2 l.parameters # => [[:req, :_1], [:req, :_2]] l.arity # => 2 Blocks with numbered parameters can't be nested: %w[test me].each { _1.each_char { p _1 } } # SyntaxError (numbered parameter is already used in outer block here) # %w[test me].each { _1.each_char { p _1 } } # ^~ Numbered parameters were introduced in Ruby 2.7. ;T;#0;$@y;.F;/o;0;1T;2i>;3i_;Bi;%@;&I" Proc;F;'@o; ;IC;[o;4;5F;6;;;;&I"Binding#clone;F;7[;[[@it;T;;;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@C|;.F;/o;0;1T;2is;3is;%@A|;9I"static VALUE binding_clone(VALUE self) { VALUE bindval = binding_dup(self); CLONESETUP(bindval, self); return bindval; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Binding#dup;F;7[;[[@if;T;;[;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@Q|;.F;/o;0;1T;2ie;3ie;%@A|;9I"gstatic VALUE binding_dup(VALUE self) { VALUE bindval = rb_binding_alloc(rb_cBinding); rb_binding_t *src, *dst; GetBindingPtr(self, src); GetBindingPtr(bindval, dst); rb_vm_block_copy(bindval, &dst->block, &src->block); RB_OBJ_WRITE(bindval, &dst->pathobj, src->pathobj); dst->first_lineno = src->first_lineno; return bindval; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Binding#eval;F;7[[@90;[[@i;T;;;0;[;{;IC; "BEvaluates the Ruby expression(s) in string, in the binding's context. If the optional filename and lineno parameters are present, they will be used when reporting syntax errors. def get_binding(param) binding end b = get_binding("hello") b.eval("param") #=> "hello" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"(eval(string [, filename [,lineno]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@_|;![;"I"@return [Object];T;#0;$@_|;.F;Bi;C0;7[[I"!string[, filename [,lineno]];T0;$@_|;![;"I"Evaluates the Ruby expression(s) in string, in the binding's context. If the optional filename and lineno parameters are present, they will be used when reporting syntax errors. def get_binding(param) binding end b = get_binding("hello") b.eval("param") #=> "hello" @overload eval(string [, filename [,lineno]]) @return [Object];T;#0;$@_|;.F;/o;0;1T;2i;3i;%@A|;9I"static VALUE bind_eval(int argc, VALUE *argv, VALUE bindval) { VALUE args[4]; rb_scan_args(argc, argv, "12", &args[0], &args[2], &args[3]); args[1] = bindval; return rb_f_eval(argc+1, args, Qnil /* self will be searched in eval */); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Binding#local_variables;F;7[;[[@i ;T;;;0;[;{;IC; "Returns the names of the binding's local variables as symbols. def foo a = 1 2.times do |n| binding.local_variables #=> [:a, :n] end end This method is the short version of the following code: binding.eval("local_variables") ;T;[o;= ;>I" overload;F;?0;;;@0;:I"local_variables;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@}|;![;"I"@return [Array];T;#0;$@}|;.F;Bi;C0;7[;$@}|;![;"I"!Returns the names of the binding's local variables as symbols. def foo a = 1 2.times do |n| binding.local_variables #=> [:a, :n] end end This method is the short version of the following code: binding.eval("local_variables") @overload local_variables @return [Array];T;#0;$@}|;.F;/o;0;1T;2i;3i;%@A|;9I"static VALUE bind_local_variables(VALUE bindval) { const rb_binding_t *bind; const rb_env_t *env; GetBindingPtr(bindval, bind); env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block)); return rb_vm_env_local_variables(env); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Binding#local_variable_get;F;7[[I"sym;T0;[[@i&;T;:local_variable_get;0;[;{;IC; "Returns the value of the local variable +symbol+. def foo a = 1 binding.local_variable_get(:a) #=> 1 binding.local_variable_get(:b) #=> NameError end This method is the short version of the following code: binding.eval("#{symbol}") ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"local_variable_get(symbol);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@|;![;"I"@return [Object];T;#0;$@|;.F;Bi;C0;7[[I" symbol;T0;$@|;![;"I"/Returns the value of the local variable +symbol+. def foo a = 1 binding.local_variable_get(:a) #=> 1 binding.local_variable_get(:b) #=> NameError end This method is the short version of the following code: binding.eval("#{symbol}") @overload local_variable_get(symbol) @return [Object];T;#0;$@|;.F;/o;0;1T;2i;3i$;%@A|;9I"?static VALUE bind_local_variable_get(VALUE bindval, VALUE sym) { ID lid = check_local_id(bindval, &sym); const rb_binding_t *bind; const VALUE *ptr; const rb_env_t *env; if (!lid) goto undefined; GetBindingPtr(bindval, bind); env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block)); if ((ptr = get_local_variable_ptr(&env, lid)) != NULL) { return *ptr; } sym = ID2SYM(lid); undefined: rb_name_err_raise("local variable `%1$s' is not defined for %2$s", bindval, sym); UNREACHABLE_RETURN(Qundef); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Binding#local_variable_set;F;7[[I"sym;T0[I"val;T0;[[@iW;T;:local_variable_set;0;[;{;IC; "DSet local variable named +symbol+ as +obj+. def foo a = 1 bind = binding bind.local_variable_set(:a, 2) # set existing local variable `a' bind.local_variable_set(:b, 3) # create new local variable `b' # `b' exists only in binding p bind.local_variable_get(:a) #=> 2 p bind.local_variable_get(:b) #=> 3 p a #=> 2 p b #=> NameError end This method behaves similarly to the following code: binding.eval("#{symbol} = #{obj}") if +obj+ can be dumped in Ruby code. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"$local_variable_set(symbol, obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@|;![;"I"@return [Object];T;#0;$@|;.F;Bi;C0;7[[I" symbol;T0[I"obj;T0;$@|;![;"I"Set local variable named +symbol+ as +obj+. def foo a = 1 bind = binding bind.local_variable_set(:a, 2) # set existing local variable `a' bind.local_variable_set(:b, 3) # create new local variable `b' # `b' exists only in binding p bind.local_variable_get(:a) #=> 2 p bind.local_variable_get(:b) #=> 3 p a #=> 2 p b #=> NameError end This method behaves similarly to the following code: binding.eval("#{symbol} = #{obj}") if +obj+ can be dumped in Ruby code. @overload local_variable_set(symbol, obj) @return [Object];T;#0;$@|;.F;/o;0;1T;2i>;3iU;%@A|;9I"static VALUE bind_local_variable_set(VALUE bindval, VALUE sym, VALUE val) { ID lid = check_local_id(bindval, &sym); rb_binding_t *bind; const VALUE *ptr; const rb_env_t *env; if (!lid) lid = rb_intern_str(sym); GetBindingPtr(bindval, bind); env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block)); if ((ptr = get_local_variable_ptr(&env, lid)) == NULL) { /* not found. create new env */ ptr = rb_binding_add_dynavars(bindval, bind, 1, &lid); env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block)); } #if YJIT_STATS rb_yjit_collect_binding_set(); #endif RB_OBJ_WRITE(env, ptr, val); return val; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$Binding#local_variable_defined?;F;7[[I"sym;T0;[[@i;T;:local_variable_defined?;0;[;{;IC; "Returns +true+ if a local variable +symbol+ exists. def foo a = 1 binding.local_variable_defined?(:a) #=> true binding.local_variable_defined?(:b) #=> false end This method is the short version of the following code: binding.eval("defined?(#{symbol}) == 'local-variable'");T;[o;= ;>I" overload;F;?0;; ;@0;:I"$local_variable_defined?(symbol);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@|;![;"I"@return [Object];T;#0;$@|;.F;Bi;C0;7[[I" symbol;T0;$@|;![;"I"]Returns +true+ if a local variable +symbol+ exists. def foo a = 1 binding.local_variable_defined?(:a) #=> true binding.local_variable_defined?(:b) #=> false end This method is the short version of the following code: binding.eval("defined?(#{symbol}) == 'local-variable'") @overload local_variable_defined?(symbol) @return [Object];T;#0;$@|;.F;/o;0;1T;2ir;3i;Bi;%@A|;9I"Ystatic VALUE bind_local_variable_defined_p(VALUE bindval, VALUE sym) { ID lid = check_local_id(bindval, &sym); const rb_binding_t *bind; const rb_env_t *env; if (!lid) return Qfalse; GetBindingPtr(bindval, bind); env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block)); return RBOOL(get_local_variable_ptr(&env, lid)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Binding#receiver;F;7[;[[@i;T;;i ;0;[;{;IC; "6Returns the bound receiver of the binding object. ;T;[o;= ;>I" overload;F;?0;;i ;@0;:I" receiver;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@|;![;"I"@return [Object];T;#0;$@|;.F;Bi;C0;7[;$@|;![;"I"^Returns the bound receiver of the binding object. @overload receiver @return [Object];T;#0;$@|;.F;/o;0;1T;2i;3i;%@A|;9I"static VALUE bind_receiver(VALUE bindval) { const rb_binding_t *bind; GetBindingPtr(bindval, bind); return vm_block_self(&bind->block); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Binding#source_location;F;7[;[[@i;T;; ;0;[;{;IC; "LReturns the Ruby source filename and line number of the binding object. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"source_location;T;IC; ";T;[o;A ;>I" return;F;?I"];T;0;@[I" Array;TI" Integer;T;$@};![;"I"@return [Array, Integer]];T;#0;$@};.F;Bi;C0;7[;$@};![;"I"Returns the Ruby source filename and line number of the binding object. @overload source_location @return [Array, Integer]];T;#0;$@};.F;/o;0;1T;2i;3i;%@A|;9I"static VALUE bind_location(VALUE bindval) { VALUE loc[2]; const rb_binding_t *bind; GetBindingPtr(bindval, bind); loc[0] = pathobj_path(bind->pathobj); loc[1] = INT2FIX(bind->first_lineno); return rb_ary_new4(2, loc); };T;:I"static VALUE;T;;T; @A|; IC;[; @A|; IC;[; @A|; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i;F;: Binding;;;;;[;{;IC; "Objects of class Binding encapsulate the execution context at some particular place in the code and retain this context for future use. The variables, methods, value of self, and possibly an iterator block that can be accessed in this context are all retained. Binding objects can be created using Kernel#binding, and are made available to the callback of Kernel#set_trace_func and instances of TracePoint. These binding objects can be passed as the second argument of the Kernel#eval method, establishing an environment for the evaluation. class Demo def initialize(n) @secret = n end def get_binding binding end end k1 = Demo.new(99) b1 = k1.get_binding k2 = Demo.new(-3) b2 = k2.get_binding eval("@secret", b1) #=> 99 eval("@secret", b2) #=> -3 eval("@secret") #=> nil Binding objects have no class-specific methods. ;T;[;![;"I"Objects of class Binding encapsulate the execution context at some particular place in the code and retain this context for future use. The variables, methods, value of self, and possibly an iterator block that can be accessed in this context are all retained. Binding objects can be created using Kernel#binding, and are made available to the callback of Kernel#set_trace_func and instances of TracePoint. These binding objects can be passed as the second argument of the Kernel#eval method, establishing an environment for the evaluation. class Demo def initialize(n) @secret = n end def get_binding binding end end k1 = Demo.new(99) b1 = k1.get_binding k2 = Demo.new(-3) b2 = k2.get_binding eval("@secret", b1) #=> 99 eval("@secret", b2) #=> -3 eval("@secret") #=> nil Binding objects have no class-specific methods. ;T;#0;$@A|;.F;/o;0;1T;2i;3i;%@;&I" Binding;F;'@@?_o;u;[[I"version.c;TiA;F;:RUBY_VERSION;;w;;;[;{;IC; " The running version of ruby ;T;[;![;"I"!The running version of ruby ;T;#0;$@A};.F;/o;0;1T;2i>;3i?;%@;&I"RUBY_VERSION;F;xI"(version = MKSTR(version));To;u;[[@D}iE;F;:RUBY_RELEASE_DATE;;w;;;[;{;IC; "$The date this ruby was released ;T;[;![;"I"%The date this ruby was released ;T;#0;$@N};.F;/o;0;1T;2iB;3iC;%@;&I"RUBY_RELEASE_DATE;F;xI"MKSTR(release_date);To;u;[[@D}iI;F;:RUBY_PLATFORM;;w;;;[;{;IC; "The platform for this ruby ;T;[;![;"I" The platform for this ruby ;T;#0;$@Z};.F;/o;0;1T;2iF;3iG;%@;&I"RUBY_PLATFORM;F;xI"MKSTR(platform);To;u;[[@D}iN;F;:RUBY_PATCHLEVEL;;w;;;[;{;IC; "dThe patchlevel for this ruby. If this is a development build of ruby the patchlevel will be -1 ;T;[;![;"I"eThe patchlevel for this ruby. If this is a development build of ruby the patchlevel will be -1 ;T;#0;$@f};.F;/o;0;1T;2iJ;3iL;%@;&I"RUBY_PATCHLEVEL;F;xI"MKINT(patchlevel);To;u;[[@D}iR;F;:RUBY_REVISION;;w;;;[;{;IC; "'The GIT commit hash for this ruby. ;T;[;![;"I"(The GIT commit hash for this ruby. ;T;#0;$@r};.F;/o;0;1T;2iO;3iP;%@;&I"RUBY_REVISION;F;xI"MKSTR(revision);To;u;[[@D}iV;F;:RUBY_COPYRIGHT;;w;;;[;{;IC; ""The copyright string for ruby ;T;[;![;"I"#The copyright string for ruby ;T;#0;$@~};.F;/o;0;1T;2iS;3iT;%@;&I"RUBY_COPYRIGHT;F;xI"MKSTR(copyright);To;u;[[@D}iZ;F;:RUBY_ENGINE;;w;;;[;{;IC; ".The engine or interpreter this ruby uses. ;T;[;![;"I"/The engine or interpreter this ruby uses. ;T;#0;$@};.F;/o;0;1T;2iW;3iX;%@;&I"RUBY_ENGINE;F;xI"%ruby_engine_name = MKSTR(engine);To;u;[[@D}i_;F;:RUBY_ENGINE_VERSION;;w;;;[;{;IC; "=The version of the engine or interpreter this ruby uses. ;T;[;![;"I">The version of the engine or interpreter this ruby uses. ;T;#0;$@};.F;/o;0;1T;2i\;3i];%@;&I"RUBY_ENGINE_VERSION;F;xI"#(1 ? version : MKSTR(version));To;u;[[@D}i|;F;:RUBY_DESCRIPTION;;w;;;[;{;IC; "MKSTR(description) ;T;[;![;"I"MKSTR(description);T;#0;$@};.F;/o;0;1T;2i|;3i|;%@;&I"RUBY_DESCRIPTION;F;xI")/* MKSTR(description) */ description;To;;IC;[ o;4;5F;6;;;;&I"Signal#trap;F;7[[@90;[[@io;T;;;0;[;{;IC; "Specifies the handling of signals. The first parameter is a signal name (a string such as ``SIGALRM'', ``SIGUSR1'', and so on) or a signal number. The characters ``SIG'' may be omitted from the signal name. The command or block specifies code to be run when the signal is raised. If the command is the string ``IGNORE'' or ``SIG_IGN'', the signal will be ignored. If the command is ``DEFAULT'' or ``SIG_DFL'', the Ruby's default handler will be invoked. If the command is ``EXIT'', the script will be terminated by the signal. If the command is ``SYSTEM_DEFAULT'', the operating system's default handler will be invoked. Otherwise, the given command or block will be run. The special signal name ``EXIT'' or signal number zero will be invoked just prior to program termination. trap returns the previous handler for the given signal. Signal.trap(0, proc { puts "Terminating: #{$$}" }) Signal.trap("CLD") { puts "Child died" } fork && Process.wait produces: Terminating: 27461 Child died Terminating: 27460 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"trap( signal, command );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@};![;"I"@return [Object];T;#0;$@};.F;Bi;C0;7[[I" signal;T0[I" command;T0;$@}o;= ;>I" overload;F;?0;;;@0;:I"trap( signal );T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I";T;$@}o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@};![;"I" @yield [ ] @return [Object];T;#0;$@};.F;Bi;C0;7[[I" signal;T0;$@};![;"I"xSpecifies the handling of signals. The first parameter is a signal name (a string such as ``SIGALRM'', ``SIGUSR1'', and so on) or a signal number. The characters ``SIG'' may be omitted from the signal name. The command or block specifies code to be run when the signal is raised. If the command is the string ``IGNORE'' or ``SIG_IGN'', the signal will be ignored. If the command is ``DEFAULT'' or ``SIG_DFL'', the Ruby's default handler will be invoked. If the command is ``EXIT'', the script will be terminated by the signal. If the command is ``SYSTEM_DEFAULT'', the operating system's default handler will be invoked. Otherwise, the given command or block will be run. The special signal name ``EXIT'' or signal number zero will be invoked just prior to program termination. trap returns the previous handler for the given signal. Signal.trap(0, proc { puts "Terminating: #{$$}" }) Signal.trap("CLD") { puts "Child died" } fork && Process.wait produces: Terminating: 27461 Child died Terminating: 27460 @overload trap( signal, command ) @return [Object] @overload trap( signal ) @yield [ ] @return [Object];T;#0;$@};.F;C0;%@};9I"static VALUE sig_trap(int argc, VALUE *argv, VALUE _) { int sig; sighandler_t func; VALUE cmd; rb_check_arity(argc, 1, 2); sig = trap_signm(argv[0]); if (reserved_signal_p(sig)) { const char *name = signo2signm(sig); if (name) rb_raise(rb_eArgError, "can't trap reserved signal: SIG%s", name); else rb_raise(rb_eArgError, "can't trap reserved signal: %d", sig); } if (argc == 1) { cmd = rb_block_proc(); func = sighandler; } else { cmd = argv[1]; func = trap_handler(&cmd, sig); } if (rb_obj_is_proc(cmd) && !rb_ractor_main_p() && !rb_ractor_shareable_p(cmd)) { cmd = rb_proc_isolate(cmd); } return trap(sig, func, cmd); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Signal.trap;F;7@};@};T;;;0;@};{;IC; "Specifies the handling of signals. The first parameter is a signal name (a string such as ``SIGALRM'', ``SIGUSR1'', and so on) or a signal number. The characters ``SIG'' may be omitted from the signal name. The command or block specifies code to be run when the signal is raised. If the command is the string ``IGNORE'' or ``SIG_IGN'', the signal will be ignored. If the command is ``DEFAULT'' or ``SIG_DFL'', the Ruby's default handler will be invoked. If the command is ``EXIT'', the script will be terminated by the signal. If the command is ``SYSTEM_DEFAULT'', the operating system's default handler will be invoked. Otherwise, the given command or block will be run. The special signal name ``EXIT'' or signal number zero will be invoked just prior to program termination. trap returns the previous handler for the given signal. Signal.trap(0, proc { puts "Terminating: #{$$}" }) Signal.trap("CLD") { puts "Child died" } fork && Process.wait produces: Terminating: 27461 Child died Terminating: 27460;T;[o;= ;>I" overload;F;?0;;;@0;:I"trap( signal, command );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@};![;"I"@return [Object];T;#0;$@};.F;Bi;C0;7[[I" signal;T0[I" command;T0;$@}o;= ;>I" overload;F;?0;;;@0;:I"trap( signal );T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I";T;$@}o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@};![;"I" @yield [ ] @return [Object];T;#0;$@};.F;Bi;C0;7[[I" signal;T0;$@};![;"@.;#0;$@};.F;/o;0;1T;2iP;3io;Bi;%@};9@};:@};;To;4;5F;6;;;;&I"Signal#list;F;7[;[[@i;T;;;0;[;{;IC; "Returns a list of signal names mapped to the corresponding underlying signal numbers. Signal.list #=> {"EXIT"=>0, "HUP"=>1, "INT"=>2, "QUIT"=>3, "ILL"=>4, "TRAP"=>5, "IOT"=>6, "ABRT"=>6, "FPE"=>8, "KILL"=>9, "BUS"=>7, "SEGV"=>11, "SYS"=>31, "PIPE"=>13, "ALRM"=>14, "TERM"=>15, "URG"=>23, "STOP"=>19, "TSTP"=>20, "CONT"=>18, "CHLD"=>17, "CLD"=>17, "TTIN"=>21, "TTOU"=>22, "IO"=>29, "XCPU"=>24, "XFSZ"=>25, "VTALRM"=>26, "PROF"=>27, "WINCH"=>28, "USR1"=>10, "USR2"=>12, "PWR"=>30, "POLL"=>29} ;T;[o;= ;>I" overload;F;?0;;;@0;:I" list;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@~;![;"I"@return [Hash];T;#0;$@~;.F;Bi;C0;7[;$@~;![;"I"Returns a list of signal names mapped to the corresponding underlying signal numbers. Signal.list #=> {"EXIT"=>0, "HUP"=>1, "INT"=>2, "QUIT"=>3, "ILL"=>4, "TRAP"=>5, "IOT"=>6, "ABRT"=>6, "FPE"=>8, "KILL"=>9, "BUS"=>7, "SEGV"=>11, "SYS"=>31, "PIPE"=>13, "ALRM"=>14, "TERM"=>15, "URG"=>23, "STOP"=>19, "TSTP"=>20, "CONT"=>18, "CHLD"=>17, "CLD"=>17, "TTIN"=>21, "TTOU"=>22, "IO"=>29, "XCPU"=>24, "XFSZ"=>25, "VTALRM"=>26, "PROF"=>27, "WINCH"=>28, "USR1"=>10, "USR2"=>12, "PWR"=>30, "POLL"=>29} @overload list @return [Hash];T;#0;$@~;.F;C0;%@};9I"static VALUE sig_list(VALUE _) { VALUE h = rb_hash_new(); const struct signals *sigs; FOREACH_SIGNAL(sigs, 0) { rb_hash_aset(h, rb_fstring_cstr(sigs->signm), INT2FIX(sigs->signo)); } return h; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Signal.list;F;7@~;@~;T;;;0;@~;{;IC; "Returns a list of signal names mapped to the corresponding underlying signal numbers. Signal.list #=> {"EXIT"=>0, "HUP"=>1, "INT"=>2, "QUIT"=>3, "ILL"=>4, "TRAP"=>5, "IOT"=>6, "ABRT"=>6, "FPE"=>8, "KILL"=>9, "BUS"=>7, "SEGV"=>11, "SYS"=>31, "PIPE"=>13, "ALRM"=>14, "TERM"=>15, "URG"=>23, "STOP"=>19, "TSTP"=>20, "CONT"=>18, "CHLD"=>17, "CLD"=>17, "TTIN"=>21, "TTOU"=>22, "IO"=>29, "XCPU"=>24, "XFSZ"=>25, "VTALRM"=>26, "PROF"=>27, "WINCH"=>28, "USR1"=>10, "USR2"=>12, "PWR"=>30, "POLL"=>29};T;[o;= ;>I" overload;F;?0;;;@0;:I" list;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@)~;![;"I"@return [Hash];T;#0;$@)~;.F;Bi;C0;7[;$@)~;![;"I"Returns a list of signal names mapped to the corresponding underlying signal numbers. Signal.list #=> {"EXIT"=>0, "HUP"=>1, "INT"=>2, "QUIT"=>3, "ILL"=>4, "TRAP"=>5, "IOT"=>6, "ABRT"=>6, "FPE"=>8, "KILL"=>9, "BUS"=>7, "SEGV"=>11, "SYS"=>31, "PIPE"=>13, "ALRM"=>14, "TERM"=>15, "URG"=>23, "STOP"=>19, "TSTP"=>20, "CONT"=>18, "CHLD"=>17, "CLD"=>17, "TTIN"=>21, "TTOU"=>22, "IO"=>29, "XCPU"=>24, "XFSZ"=>25, "VTALRM"=>26, "PROF"=>27, "WINCH"=>28, "USR1"=>10, "USR2"=>12, "PWR"=>30, "POLL"=>29} @overload list @return [Hash];T;#0;$@)~;.F;/o;0;1T;2i;3i;Bi;%@};9@'~;:@(~;;To;4;5F;6;;;;&I"Signal#signame;F;7[[I" signo;T0;[[@i3;T;: signame;0;[;{;IC; "Convert signal number to signal name. Returns +nil+ if the signo is an invalid signal number. Signal.trap("INT") { |signo| puts Signal.signame(signo) } Process.kill("INT", 0) produces: INT ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"signame(signo);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@>~;![;"I"@return [String, nil];T;#0;$@>~;.F;Bi;C0;7[[I" signo;T0;$@>~;![;"I"Convert signal number to signal name. Returns +nil+ if the signo is an invalid signal number. Signal.trap("INT") { |signo| puts Signal.signame(signo) } Process.kill("INT", 0) produces: INT @overload signame(signo) @return [String, nil];T;#0;$@>~;.F;C0;%@};9I"static VALUE sig_signame(VALUE recv, VALUE signo) { const char *signame = signo2signm(NUM2INT(signo)); if (!signame) return Qnil; return rb_str_new_cstr(signame); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Signal.signame;F;7@@~;@C~;T;; ;0;@E~;{;IC; "Convert signal number to signal name. Returns +nil+ if the signo is an invalid signal number. Signal.trap("INT") { |signo| puts Signal.signame(signo) } Process.kill("INT", 0) produces: INT;T;[o;= ;>I" overload;F;?0;; ;@0;:I"signame(signo);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@]~;![;"I"@return [String, nil];T;#0;$@]~;.F;Bi;C0;7[[I" signo;T0;$@]~;![;"I"  Convert signal number to signal name. Returns +nil+ if the signo is an invalid signal number. Signal.trap("INT") { |signo| puts Signal.signame(signo) } Process.kill("INT", 0) produces: INT @overload signame(signo) @return [String, nil];T;#0;$@]~;.F;/o;0;1T;2i%;3i1;Bi;%@};9@[~;:@\~;;T; @}; IC;[; @}; IC;[; @}; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i;F;: Signal;;;;;[;{;IC; " ;T;[;![;"@;#0;$@};Bi;%@;&I" Signal;Fo;;IC;[; @~; IC;[; @~; IC;[; @~; IC;{;IC;{;T;IC;{;T;T;{;[;[[@8i-;F;: FileTest;;;;;[;{;IC; " ;T;[;![;"@;#0;$@~;%@;&I" FileTest;Fo; ;IC;[,o;u;[[I" parse.c;TiR[I"ext/ripper/ripper.c;Ti(S;F;: Version;;w;;;[;{;IC; "version of Ripper ;T;[;![;"I"version of Ripper;T;#0;$@~;.F;/o;0;1T;2i'S;3i'S;%@~;&I"Ripper::Version;F;xI"(rb_usascii_str_new2(RIPPER_VERSION);To;4;5F;6;;;;&I"Ripper#initialize;F;7[[@90;[[@~iR[@~i5R;T;;D;0;[;{;IC; "Create a new Ripper object. _src_ must be a String, an IO, or an Object which has #gets method. This method does not starts parsing. See also Ripper#parse and Ripper.parse. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I",new(src, filename="(ripper)", lineno=1);T;IC; ";T;[;![;"I";T;#0;$@~;.F;Bi;C0;7[[I"src;T0[I" filename;TI""(ripper)";T[I" lineno;TI"1;T;$@~;![;"I"Create a new Ripper object. _src_ must be a String, an IO, or an Object which has #gets method. This method does not starts parsing. See also Ripper#parse and Ripper.parse. @overload new(src, filename="(ripper)", lineno=1);T;#0;$@~;.F;/o;0;1T;2i+R;3i2R;%@~;9I"static VALUE ripper_initialize(int argc, VALUE *argv, VALUE self) { struct parser_params *p; VALUE src, fname, lineno; TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p); rb_scan_args(argc, argv, "12", &src, &fname, &lineno); if (RB_TYPE_P(src, T_FILE)) { p->lex.gets = ripper_lex_io_get; } else if (rb_respond_to(src, id_gets)) { p->lex.gets = ripper_lex_get_generic; } else { StringValue(src); p->lex.gets = lex_get_str; } p->lex.input = src; p->eofp = 0; if (NIL_P(fname)) { fname = STR_NEW2("(ripper)"); OBJ_FREEZE(fname); } else { StringValueCStr(fname); fname = rb_str_new_frozen(fname); } parser_initialize(p); p->ruby_sourcefile_string = fname; p->ruby_sourcefile = RSTRING_PTR(fname); p->ruby_sourceline = NIL_P(lineno) ? 0 : NUM2INT(lineno) - 1; return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Ripper#parse;F;7[;[[@~iKR[@~ixR;T;;+;0;[;{;IC; "I" overload;F;?0;;+;@0;:I" parse;T;IC; ";T;[;![;"I";T;#0;$@~;.F;Bi;C0;7[;$@~;![;"I"NStart parsing and returns the value of the root action. @overload parse;T;#0;$@~;.F;/o;0;1T;2irR;3iuR;%@~;9I"static VALUE ripper_parse(VALUE self) { struct parser_params *p; TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p); if (!ripper_initialized_p(p)) { rb_raise(rb_eArgError, "method called for uninitialized object"); } if (!NIL_P(p->parsing_thread)) { if (p->parsing_thread == rb_thread_current()) rb_raise(rb_eArgError, "Ripper#parse is not reentrant"); else rb_raise(rb_eArgError, "Ripper#parse is not multithread-safe"); } p->parsing_thread = rb_thread_current(); rb_ensure(ripper_parse0, self, ripper_ensure, self); return p->result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Ripper#column;F;7[;[[@~igR[@~iR;T;: column;0;[;{;IC; "MReturn column number of current parsing line. This number starts from 0. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" column;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@~;![;"I"@return [Integer];T;#0;$@~;.F;Bi;C0;7[;$@~;![;"I"tReturn column number of current parsing line. This number starts from 0. @overload column @return [Integer];T;#0;$@~;.F;/o;0;1T;2iR;3iR;%@~;9I"static VALUE ripper_column(VALUE self) { struct parser_params *p; long col; TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p); if (!ripper_initialized_p(p)) { rb_raise(rb_eArgError, "method called for uninitialized object"); } if (NIL_P(p->parsing_thread)) return Qnil; col = p->lex.ptok - p->lex.pbeg; return LONG2NUM(col); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Ripper#filename;F;7[;[[@~i|R[@~iR;T;: filename;0;[;{;IC; "%Return current parsing filename. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" filename;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@~;![;"I"@return [String];T;#0;$@~;.F;Bi;C0;7[;$@~;![;"I"MReturn current parsing filename. @overload filename @return [String];T;#0;$@~;.F;/o;0;1T;2iR;3iR;%@~;9I"0static VALUE ripper_filename(VALUE self) { struct parser_params *p; TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p); if (!ripper_initialized_p(p)) { rb_raise(rb_eArgError, "method called for uninitialized object"); } return p->ruby_sourcefile_string; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Ripper#lineno;F;7[;[[@~iR[@~iR;T;;L;0;[;{;IC; "KReturn line number of current parsing line. This number starts from 1. ;T;[o;= ;>I" overload;F;?0;;L;@0;:I" lineno;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"rReturn line number of current parsing line. This number starts from 1. @overload lineno @return [Integer];T;#0;$@;.F;/o;0;1T;2iR;3iR;%@~;9I"_static VALUE ripper_lineno(VALUE self) { struct parser_params *p; TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p); if (!ripper_initialized_p(p)) { rb_raise(rb_eArgError, "method called for uninitialized object"); } if (NIL_P(p->parsing_thread)) return Qnil; return INT2NUM(p->ruby_sourceline); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Ripper#state;F;7[;[[@~iR[@~iR;T;;;0;[;{;IC; "+Return scanner state of current token. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" state;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@1;![;"I"@return [Integer];T;#0;$@1;.F;Bi;C0;7[;$@1;![;"I"QReturn scanner state of current token. @overload state @return [Integer];T;#0;$@1;.F;/o;0;1T;2iR;3iR;%@~;9I"Qstatic VALUE ripper_state(VALUE self) { struct parser_params *p; TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p); if (!ripper_initialized_p(p)) { rb_raise(rb_eArgError, "method called for uninitialized object"); } if (NIL_P(p->parsing_thread)) return Qnil; return INT2NUM(p->lex.state); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Ripper#token;F;7[;[[@~iR[@~iR;T;: token;0;[;{;IC; "%Return the current token string. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" token;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@M;![;"I"@return [String];T;#0;$@M;.F;Bi;C0;7[;$@M;![;"I"JReturn the current token string. @overload token @return [String];T;#0;$@M;.F;/o;0;1T;2iR;3iR;%@~;9I"static VALUE ripper_token(VALUE self) { struct parser_params *p; long pos, len; TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p); if (!ripper_initialized_p(p)) { rb_raise(rb_eArgError, "method called for uninitialized object"); } if (NIL_P(p->parsing_thread)) return Qnil; pos = p->lex.ptok - p->lex.pbeg; len = p->lex.pcur - p->lex.ptok; return rb_str_subseq(p->lex.lastline, pos, len); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Ripper#end_seen?;F;7[;[[@~iGP[@~itP;T;:end_seen?;0;[;{;IC; "9Return true if parsed source ended by +\_\_END\_\_+.;T;[o;= ;>I" overload;F;?0;; ;@0;:I"end_seen?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@i;![;"I"@return [Boolean];T;#0;$@i;.F;Bi;C0;7[;$@i;![;"I"cReturn true if parsed source ended by +\_\_END\_\_+. @overload end_seen? @return [Boolean];T;#0;$@i;.F;/o;0;1T;2inP;3irP;Bi;%@~;9I"VALUE rb_parser_end_seen_p(VALUE vparser) { struct parser_params *p; TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p); return RBOOL(p->ruby__end__seen); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Ripper#encoding;F;7[;[[@~iVP[@~iP;T;;K;0;[;{;IC; "#Return encoding of the source. ;T;[o;= ;>I" overload;F;?0;;K;@0;:I" encoding;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Encoding;T;$@;![;"I"@return [Encoding];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"MReturn encoding of the source. @overload encoding @return [Encoding];T;#0;$@;.F;/o;0;1T;2i}P;3iP;%@~;9I"VALUE rb_parser_encoding(VALUE vparser) { struct parser_params *p; TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p); return rb_enc_from_encoding(p->enc); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Ripper#yydebug;F;7[;[[@~ifP[@~iP;T;: yydebug;0;[;{;IC; "Get yydebug. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" yydebug;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"9Get yydebug. @overload yydebug @return [Boolean];T;#0;$@;.F;/o;0;1T;2iP;3iP;%@~;9I"VALUE rb_parser_get_yydebug(VALUE self) { struct parser_params *p; TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p); return RBOOL(p->debug); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Ripper#yydebug=;F;7[[I" flag;T0;[[@~ivP[@~iP;T;: yydebug=;0;[;{;IC; "Set yydebug. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"yydebug=(flag);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" flag;T0;$@;![;"I",Set yydebug. @overload yydebug=(flag);T;#0;$@;.F;/o;0;1T;2iP;3iP;%@~;9I"VALUE rb_parser_set_yydebug(VALUE self, VALUE flag) { struct parser_params *p; TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p); p->debug = RTEST(flag); return flag; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Ripper#debug_output;F;7[;[[@~iP[@~iP;T;:debug_output;0;[;{;IC; "Get debug output. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"debug_output;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"BGet debug output. @overload debug_output @return [Object];T;#0;$@;.F;/o;0;1T;2iP;3iP;%@~;9I"VALUE rb_parser_get_debug_output(VALUE self) { struct parser_params *p; TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p); return p->debug_output; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Ripper#debug_output=;F;7[[I" output;T0;[[@~iP[@~iP;T;:debug_output=;0;[;{;IC; "Set debug output. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"debug_output=(obj);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"obj;T0;$@;![;"I"5Set debug output. @overload debug_output=(obj);T;#0;$@;.F;/o;0;1T;2iP;3iP;%@~;9I"VALUE rb_parser_set_debug_output(VALUE self, VALUE output) { struct parser_params *p; TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p); return p->debug_output = output; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Ripper#error?;F;7[;[[@~i7P[@~idP;T;: error?;0;[;{;IC; "-Return true if parsed source has errors.;T;[o;= ;>I" overload;F;?0;; ;@0;:I" error?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"TReturn true if parsed source has errors. @overload error? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i^P;3ibP;Bi;%@~;9I"static VALUE ripper_error_p(VALUE vparser) { struct parser_params *p; TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p); return RBOOL(p->error_p); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Ripper#assert_Qundef;F;7[[I"obj;T0[I"msg;T0;[[@~iR[@~iR;T;:assert_Qundef;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@+;.F;/o;0;1T;2iR;3iR;%@~;9I"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;4;5F;6;;;;&I"Ripper#rawVALUE;F;7[[I"obj;T0;[[@~iR[@~iR;T;: rawVALUE;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@>;.F;/o;0;1T;2iR;3iR;%@~;9I"Tstatic VALUE ripper_value(VALUE self, VALUE obj) { return ULONG2NUM(obj); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Ripper#validate_object;F;7[[I"x;T0;[[@~iQQ[@~i~Q;T;:validate_object;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@O;.F;/o;0;1T;2i}Q;3i}Q;%@~;9I"wstatic 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; 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: break; case T_NODE: if (!nd_type_p((NODE *)x, NODE_RIPPER)) { rb_raise(rb_eArgError, "NODE given: %p", (void *)x); } x = ((NODE *)x)->nd_rval; break; default: rb_raise(rb_eArgError, "wrong type of ruby object: %p (%s)", (void *)x, rb_obj_classname(x)); } if (!RBASIC_CLASS(x)) { rb_raise(rb_eArgError, "hidden ruby object: %p (%s)", (void *)x, rb_builtin_type_name(TYPE(x))); } return x; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Ripper.dedent_string;F;7[[I" input;T0[I" width;T0;[[@~i{:[@~i:;T;:dedent_string;0;[;{;IC; "USE OF RIPPER LIBRARY ONLY. Strips up to +width+ leading whitespaces from +input+, and returns the stripped column width. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" dedent_string(input, width);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@`;![;"I"@return [Integer];T;#0;$@`;.F;Bi;C0;7[[I" input;T0[I" width;T0;$@`;![;"I"USE OF RIPPER LIBRARY ONLY. Strips up to +width+ leading whitespaces from +input+, and returns the stripped column width. @overload dedent_string(input, width) @return [Integer];T;#0;$@`;.F;/o;0;1T;2i:;3i:;%@~;9I"static VALUE parser_dedent_string(VALUE self, VALUE input, VALUE width) { int wid, col; StringValue(input); wid = NUM2UINT(width); col = dedent_string(input, wid); return INT2NUM(col); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Ripper#dedent_string;F;7[[I" input;T0[I" width;T0;[[@~i{:[@~i:;T;; ;0;[;{;IC; "USE OF RIPPER LIBRARY ONLY. Strips up to +width+ leading whitespaces from +input+, and returns the stripped column width. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" dedent_string(input, width);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I" input;T0[I" width;T0;$@;![;"@;#0;$@;.F;/o;0;1T;2i:;3i:;%@~;9I"static VALUE parser_dedent_string(VALUE self, VALUE input, VALUE width) { int wid, col; StringValue(input); wid = NUM2UINT(width); col = dedent_string(input, wid); return INT2NUM(col); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Ripper.lex_state_name;F;7[[I" state;T0;[[@~iR[@~i S;T;:lex_state_name;0;[;{;IC; "2Returns a string representation of lex_state. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"lex_state_name(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I" integer;T0;$@;![;"I"iReturns a string representation of lex_state. @overload lex_state_name(integer) @return [String];T;#0;$@;.F;/o;0;1T;2iS;3i S;%@~;9I"ystatic VALUE ripper_lex_state_name(VALUE self, VALUE state) { return rb_parser_lex_state_name(NUM2INT(state)); };T;:I"static VALUE;T;;To;u;[[@~iDS;F;: EXPR_BEG;;w;;;[;{;IC; "#ignore newline, +/- is a sign. ;T;[;![;"I"#ignore newline, +/- is a sign.;T;#0;$@ǀ;.F;/o;0;1T;2iCS;3iCS;%@~;&I"Ripper::EXPR_BEG;F;xI"INT2NUM(EXPR_BEG);To;u;[[@~iFS;F;: EXPR_END;;w;;;[;{;IC; "-newline significant, +/- is an operator. ;T;[;![;"I"-newline significant, +/- is an operator.;T;#0;$@Ӏ;.F;/o;0;1T;2iES;3iES;%@~;&I"Ripper::EXPR_END;F;xI"INT2NUM(EXPR_END);To;u;[[@~iHS;F;:EXPR_ENDARG;;w;;;[;{;IC; "ditto, and unbound braces. ;T;[;![;"I"ditto, and unbound braces.;T;#0;$@߀;.F;/o;0;1T;2iGS;3iGS;%@~;&I"Ripper::EXPR_ENDARG;F;xI"INT2NUM(EXPR_ENDARG);To;u;[[@~iJS;F;:EXPR_ENDFN;;w;;;[;{;IC; "ditto, and unbound braces. ;T;[;![;"I"ditto, and unbound braces.;T;#0;$@;.F;/o;0;1T;2iIS;3iIS;%@~;&I"Ripper::EXPR_ENDFN;F;xI"INT2NUM(EXPR_ENDFN);To;u;[[@~iLS;F;: EXPR_ARG;;w;;;[;{;IC; "-newline significant, +/- is an operator. ;T;[;![;"I"-newline significant, +/- is an operator.;T;#0;$@;.F;/o;0;1T;2iKS;3iKS;%@~;&I"Ripper::EXPR_ARG;F;xI"INT2NUM(EXPR_ARG);To;u;[[@~iNS;F;:EXPR_CMDARG;;w;;;[;{;IC; "-newline significant, +/- is an operator. ;T;[;![;"I"-newline significant, +/- is an operator.;T;#0;$@;.F;/o;0;1T;2iMS;3iMS;%@~;&I"Ripper::EXPR_CMDARG;F;xI"INT2NUM(EXPR_CMDARG);To;u;[[@~iPS;F;: EXPR_MID;;w;;;[;{;IC; "-newline significant, +/- is an operator. ;T;[;![;"I"-newline significant, +/- is an operator.;T;#0;$@;.F;/o;0;1T;2iOS;3iOS;%@~;&I"Ripper::EXPR_MID;F;xI"INT2NUM(EXPR_MID);To;u;[[@~iRS;F;:EXPR_FNAME;;w;;;[;{;IC; "'ignore newline, no reserved words. ;T;[;![;"I"'ignore newline, no reserved words.;T;#0;$@;.F;/o;0;1T;2iQS;3iQS;%@~;&I"Ripper::EXPR_FNAME;F;xI"INT2NUM(EXPR_FNAME);To;u;[[@~iTS;F;: EXPR_DOT;;w;;;[;{;IC; ":', no reserved words. ;T;[;![;"I":', no reserved words.;T;#0;$@';.F;/o;0;1T;2iSS;3iSS;%@~;&I"Ripper::EXPR_DOT;F;xI"right after `.' or `;To;u;[[@~iVS;F;:EXPR_CLASS;;w;;;[;{;IC; "/immediate after `class', no here document. ;T;[;![;"I"/immediate after `class', no here document.;T;#0;$@3;.F;/o;0;1T;2iUS;3iUS;%@~;&I"Ripper::EXPR_CLASS;F;xI"INT2NUM(EXPR_CLASS);To;u;[[@~iXS;F;:EXPR_LABEL;;w;;;[;{;IC; " flag bit, label is allowed. ;T;[;![;"I" flag bit, label is allowed.;T;#0;$@?;.F;/o;0;1T;2iWS;3iWS;%@~;&I"Ripper::EXPR_LABEL;F;xI"INT2NUM(EXPR_LABEL);To;u;[[@~iZS;F;:EXPR_LABELED;;w;;;[;{;IC; ""flag bit, just after a label. ;T;[;![;"I""flag bit, just after a label.;T;#0;$@K;.F;/o;0;1T;2iYS;3iYS;%@~;&I"Ripper::EXPR_LABELED;F;xI"INT2NUM(EXPR_LABELED);To;u;[[@~i\S;F;:EXPR_FITEM;;w;;;[;{;IC; "symbol literal as FNAME. ;T;[;![;"I"symbol literal as FNAME.;T;#0;$@W;.F;/o;0;1T;2i[S;3i[S;%@~;&I"Ripper::EXPR_FITEM;F;xI"INT2NUM(EXPR_FITEM);To;u;[[@~i^S;F;:EXPR_VALUE;;w;;;[;{;IC; "equals to +EXPR_BEG+ ;T;[;![;"I"equals to +EXPR_BEG+;T;#0;$@c;.F;/o;0;1T;2i]S;3i]S;%@~;&I"Ripper::EXPR_VALUE;F;xI"INT2NUM(EXPR_VALUE);To;u;[[@~i`S;F;:EXPR_BEG_ANY;;w;;;[;{;IC; ":equals to (EXPR_BEG | EXPR_MID | EXPR_CLASS) ;T;[;![;"I":equals to (EXPR_BEG | EXPR_MID | EXPR_CLASS);T;#0;$@o;.F;/o;0;1T;2i_S;3i_S;%@~;&I"Ripper::EXPR_BEG_ANY;F;xI"INT2NUM(EXPR_BEG_ANY);To;u;[[@~ibS;F;:EXPR_ARG_ANY;;w;;;[;{;IC; "0equals to (EXPR_ARG | EXPR_CMDARG) ;T;[;![;"I"0equals to (EXPR_ARG | EXPR_CMDARG);T;#0;$@{;.F;/o;0;1T;2iaS;3iaS;%@~;&I"Ripper::EXPR_ARG_ANY;F;xI"INT2NUM(EXPR_ARG_ANY);To;u;[[@~idS;F;:EXPR_END_ANY;;w;;;[;{;IC; "=equals to (EXPR_END | EXPR_ENDARG | EXPR_ENDFN) ;T;[;![;"I"=equals to (EXPR_END | EXPR_ENDARG | EXPR_ENDFN);T;#0;$@;.F;/o;0;1T;2icS;3icS;%@~;&I"Ripper::EXPR_END_ANY;F;xI"INT2NUM(EXPR_END_ANY);To;u;[[@~ifS;F;:EXPR_NONE;;w;;;[;{;IC; "equals to +0+ ;T;[;![;"I"equals to +0+;T;#0;$@;.F;/o;0;1T;2ieS;3ieS;%@~;&I"Ripper::EXPR_NONE;F;xI"INT2NUM(EXPR_NONE);T; @~; IC;[; @~; IC;[; @~; IC;{;IC;{;T;IC;{;T;T;{;[;[[@~iR[@~i&S;F;: Ripper;;;;;[;{;IC; " ;T;[;![;"@;#0;$@~;Bi;%@;&I" Ripper;F;'@o;u;[[@~i%S[@~isS;F;:SCRIPT_LINES__;;w;;;[;{;IC; "When a Hash is assigned to +SCRIPT_LINES__+ the contents of files loaded after the assignment will be added as an Array of lines with the file name as the key. ;T;[;![;"I"When a Hash is assigned to +SCRIPT_LINES__+ the contents of files loaded after the assignment will be added as an Array of lines with the file name as the key. ;T;#0;$@;.F;/o;0;1T;2inS;3iqS;%@;&I"SCRIPT_LINES__;F;xI" Qnil;To; ;IC;[o;4;5F;6;;;;&I"MatchData#initialize_copy;F;7[[I" orig;T0;[[@x@i";T;;];0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2i!;3i!;%@;9I"static VALUE match_init_copy(VALUE obj, VALUE orig) { struct rmatch *rm; if (!OBJ_INIT_COPY(obj, orig)) return obj; RMATCH(obj)->str = RMATCH(orig)->str; RMATCH(obj)->regexp = RMATCH(orig)->regexp; rm = RMATCH(obj)->rmatch; if (rb_reg_region_copy(&rm->regs, RMATCH_REGS(orig))) rb_memerror(); if (RMATCH(orig)->rmatch->char_offset_num_allocated) { if (rm->char_offset_num_allocated < rm->regs.num_regs) { REALLOC_N(rm->char_offset, struct rmatch_offset, rm->regs.num_regs); rm->char_offset_num_allocated = rm->regs.num_regs; } MEMCPY(rm->char_offset, RMATCH(orig)->rmatch->char_offset, struct rmatch_offset, rm->regs.num_regs); RB_GC_GUARD(orig); } return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#regexp;F;7[;[[@x@iH;T;: regexp;0;[;{;IC; "MReturns the regexp. m = /a.*b/.match("abc") m.regexp #=> /a.*b/ ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" regexp;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Regexp;T;$@΁;![;"I"@return [Regexp];T;#0;$@΁;.F;Bi;C0;7[;$@΁;![;"I"sReturns the regexp. m = /a.*b/.match("abc") m.regexp #=> /a.*b/ @overload regexp @return [Regexp];T;#0;$@΁;.F;/o;0;1T;2i>;3iE;%@;9I"!static VALUE match_regexp(VALUE match) { VALUE regexp; match_check(match); regexp = RMATCH(match)->regexp; if (NIL_P(regexp)) { VALUE str = rb_reg_nth_match(0, match); regexp = rb_reg_regcomp(rb_reg_quote(str)); RMATCH(match)->regexp = regexp; } return regexp; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#names;F;7[;[[@x@id;T;;M;0;[;{;IC; "2Returns a list of names of captures as an array of strings. This is the same as mtch.regexp.names. /(?.)(?.)(?.)/.match("hoge").names #=> ["foo", "bar", "baz"] m = /(?.)(?.)?/.match("a") #=> # m.names #=> ["x", "y"] ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" names;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"VReturns a list of names of captures as an array of strings. This is the same as mtch.regexp.names. /(?.)(?.)(?.)/.match("hoge").names #=> ["foo", "bar", "baz"] m = /(?.)(?.)?/.match("a") #=> # m.names #=> ["x", "y"] @overload names @return [Array];T;#0;$@;.F;/o;0;1T;2iV;3ia;%@;9I"static VALUE match_names(VALUE match) { match_check(match); if (NIL_P(RMATCH(match)->regexp)) return rb_ary_new_capa(0); return rb_reg_names(RMATCH(match)->regexp); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#size;F;7[;[[@x@iy;T;;;0;[;{;IC; "Returns the number of elements in the match array. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.length #=> 5 m.size #=> 5 ;T;[o;= ;>I" overload;F;?0;;b;@0;:I" length;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the number of elements in the match array. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.length #=> 5 m.size #=> 5 @overload length @return [Integer] @overload size @return [Integer];T;#0;$@;.F;/o;0;1T;2im;3iw;%@;9I"wstatic VALUE match_size(VALUE match) { match_check(match); return INT2FIX(RMATCH_REGS(match)->num_regs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#length;F;7[;[[@x@iy;T;;b;0;[;{;IC; "Returns the number of elements in the match array. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.length #=> 5 m.size #=> 5 ;T;[o;= ;>I" overload;F;?0;;b;@0;:I" length;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@,;![;"I"@return [Integer];T;#0;$@,;.F;Bi;C0;7[;$@,o;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@,;![;"I"@return [Integer];T;#0;$@,;.F;Bi;C0;7[;$@,;![;"@(;#0;$@,;.F;/o;0;1T;2im;3iw;%@;9I"wstatic VALUE match_size(VALUE match) { match_check(match); return INT2FIX(RMATCH_REGS(match)->num_regs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#offset;F;7[[I"n;T0;[[@x@i;T;;;0;[;{;IC; "{Returns a two-element array containing the beginning and ending offsets of the nth match. n can be a string or symbol to reference a named capture. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.offset(0) #=> [1, 7] m.offset(4) #=> [6, 7] m = /(?.)(.)(?.)/.match("hoge") p m.offset(:foo) #=> [0, 1] p m.offset(:bar) #=> [2, 3] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"offset(n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@S;![;"I"@return [Array];T;#0;$@S;.F;Bi;C0;7[[I"n;T0;$@S;![;"I"Returns a two-element array containing the beginning and ending offsets of the nth match. n can be a string or symbol to reference a named capture. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.offset(0) #=> [1, 7] m.offset(4) #=> [6, 7] m = /(?.)(.)(?.)/.match("hoge") p m.offset(:foo) #=> [0, 1] p m.offset(:bar) #=> [2, 3] @overload offset(n) @return [Array];T;#0;$@S;.F;/o;0;1T;2i;3i;%@;9I"static VALUE match_offset(VALUE match, VALUE n) { int i = match_backref_number(match, n); struct re_registers *regs = RMATCH_REGS(match); match_check(match); backref_number_check(regs, i); if (BEG(i) < 0) return rb_assoc_new(Qnil, Qnil); update_char_offset(match); return rb_assoc_new(INT2FIX(RMATCH(match)->rmatch->char_offset[i].beg), INT2FIX(RMATCH(match)->rmatch->char_offset[i].end)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#begin;F;7[[I"n;T0;[[@x@i;T;;2;0;[;{;IC; "bReturns the offset of the start of the nth element of the match array in the string. n can be a string or symbol to reference a named capture. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.begin(0) #=> 1 m.begin(2) #=> 2 m = /(?.)(.)(?.)/.match("hoge") p m.begin(:foo) #=> 0 p m.begin(:bar) #=> 2 ;T;[o;= ;>I" overload;F;?0;;2;@0;:I" begin(n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@r;![;"I"@return [Integer];T;#0;$@r;.F;Bi;C0;7[[I"n;T0;$@r;![;"I"Returns the offset of the start of the nth element of the match array in the string. n can be a string or symbol to reference a named capture. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.begin(0) #=> 1 m.begin(2) #=> 2 m = /(?.)(.)(?.)/.match("hoge") p m.begin(:foo) #=> 0 p m.begin(:bar) #=> 2 @overload begin(n) @return [Integer];T;#0;$@r;.F;/o;0;1T;2i;3i;%@;9I"Pstatic VALUE match_begin(VALUE match, VALUE n) { int i = match_backref_number(match, n); struct re_registers *regs = RMATCH_REGS(match); match_check(match); backref_number_check(regs, i); if (BEG(i) < 0) return Qnil; update_char_offset(match); return INT2FIX(RMATCH(match)->rmatch->char_offset[i].beg); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#end;F;7[[I"n;T0;[[@x@i ;T;;3;0;[;{;IC; "Returns the offset of the character immediately following the end of the nth element of the match array in the string. n can be a string or symbol to reference a named capture. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.end(0) #=> 7 m.end(2) #=> 3 m = /(?.)(.)(?.)/.match("hoge") p m.end(:foo) #=> 1 p m.end(:bar) #=> 3 ;T;[o;= ;>I" overload;F;?0;;3;@0;:I" end(n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I"n;T0;$@;![;"I"Returns the offset of the character immediately following the end of the nth element of the match array in the string. n can be a string or symbol to reference a named capture. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.end(0) #=> 7 m.end(2) #=> 3 m = /(?.)(.)(?.)/.match("hoge") p m.end(:foo) #=> 1 p m.end(:bar) #=> 3 @overload end(n) @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"Nstatic VALUE match_end(VALUE match, VALUE n) { int i = match_backref_number(match, n); struct re_registers *regs = RMATCH_REGS(match); match_check(match); backref_number_check(regs, i); if (BEG(i) < 0) return Qnil; update_char_offset(match); return INT2FIX(RMATCH(match)->rmatch->char_offset[i].end); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#match;F;7[[I"n;T0;[[@x@i+;T;;H;0;[;{;IC; "rReturns the captured substring corresponding to the argument. n can be a string or symbol to reference a named capture. m = /(.)(.)(\d+)(\d)(\w)?/.match("THX1138.") m.match(0) #=> "HX1138" m.match(4) #=> "8" m.match(5) #=> nil m = /(?.)(.)(?.+)/.match("hoge") m.match(:foo) #=> "h" m.match(:bar) #=> "ge" ;T;[o;= ;>I" overload;F;?0;;H;@0;:I" match(n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@;![;"I"@return [String, nil];T;#0;$@;.F;Bi;C0;7[[I"n;T0;$@;![;"I"Returns the captured substring corresponding to the argument. n can be a string or symbol to reference a named capture. m = /(.)(.)(\d+)(\d)(\w)?/.match("THX1138.") m.match(0) #=> "HX1138" m.match(4) #=> "8" m.match(5) #=> nil m = /(?.)(.)(?.+)/.match("hoge") m.match(:foo) #=> "h" m.match(:bar) #=> "ge" @overload match(n) @return [String, nil];T;#0;$@;.F;/o;0;1T;2i;3i(;%@;9I"@static VALUE match_nth(VALUE match, VALUE n) { int i = match_backref_number(match, n); struct re_registers *regs = RMATCH_REGS(match); backref_number_check(regs, i); long start = BEG(i), end = END(i); if (start < 0) return Qnil; return rb_str_subseq(RMATCH(match)->str, start, end - start); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#match_length;F;7[[I"n;T0;[[@x@iL;T;:match_length;0;[;{;IC; "Returns the length of the captured substring corresponding to the argument. n can be a string or symbol to reference a named capture. m = /(.)(.)(\d+)(\d)(\w)?/.match("THX1138.") m.match_length(0) #=> 6 m.match_length(4) #=> 1 m.match_length(5) #=> nil m = /(?.)(.)(?.+)/.match("hoge") m.match_length(:foo) #=> 1 m.match_length(:bar) #=> 2 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"match_length(n);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@Ђ;![;"I"@return [Array];T;#0;$@Ђ;.F;Bi;C0;7[[I"n;T0;$@Ђ;![;"I"Returns the length of the captured substring corresponding to the argument. n can be a string or symbol to reference a named capture. m = /(.)(.)(\d+)(\d)(\w)?/.match("THX1138.") m.match_length(0) #=> 6 m.match_length(4) #=> 1 m.match_length(5) #=> nil m = /(?.)(.)(?.+)/.match("hoge") m.match_length(:foo) #=> 1 m.match_length(:bar) #=> 2 @overload match_length(n) @return [Array];T;#0;$@Ђ;.F;/o;0;1T;2i:;3iI;%@;9I"static VALUE match_nth_length(VALUE match, VALUE n) { int i = match_backref_number(match, n); struct re_registers *regs = RMATCH_REGS(match); match_check(match); backref_number_check(regs, i); if (BEG(i) < 0) return Qnil; update_char_offset(match); const struct rmatch_offset *const ofs = &RMATCH(match)->rmatch->char_offset[i]; return LONG2NUM(ofs->end - ofs->beg); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#to_a;F;7[;[[@x@i;T;;;0;[;{;IC; "Returns the array of matches. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.to_a #=> ["HX1138", "H", "X", "113", "8"] Because to_a is called when expanding *variable, there's a useful assignment shortcut for extracting matched fields. This is slightly slower than accessing the fields directly (as an intermediate array is generated). all,f1,f2,f3 = * /(.)(.)(\d+)(\d)/.match("THX1138.") all #=> "HX1138" f1 #=> "H" f2 #=> "X" f3 #=> "113" ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_a;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the array of matches. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.to_a #=> ["HX1138", "H", "X", "113", "8"] Because to_a is called when expanding *variable, there's a useful assignment shortcut for extracting matched fields. This is slightly slower than accessing the fields directly (as an intermediate array is generated). all,f1,f2,f3 = * /(.)(.)(\d+)(\d)/.match("THX1138.") all #=> "HX1138" f1 #=> "H" f2 #=> "X" f3 #=> "113" @overload to_a @return [Array];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"Ostatic VALUE match_to_a(VALUE match) { return match_array(match, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#[];F;7[[@90;[[@x@i';T;;;0;[;{;IC; "Match Reference -- MatchData acts as an array, and may be accessed using the normal array indexing techniques. mtch[0] is equivalent to the special variable $&, and returns the entire matched string. mtch[1], mtch[2], and so on return the values of the matched backreferences (portions of the pattern between parentheses). m = /(.)(.)(\d+)(\d)/.match("THX1138.") m #=> # m[0] #=> "HX1138" m[1, 2] #=> ["H", "X"] m[1..3] #=> ["H", "X", "113"] m[-3, 2] #=> ["X", "113"] m = /(?a+)b/.match("ccaaab") m #=> # m["foo"] #=> "aaa" m[:foo] #=> "aaa" ;T;[ o;= ;>I" overload;F;?0;;;@0;:I" [](i);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@ ;![;"I"@return [String, nil];T;#0;$@ ;.F;Bi;C0;7[[I"i;T0;$@ o;= ;>I" overload;F;?0;;;@0;:I"[](start, length);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@ ;![;"I"@return [Array];T;#0;$@ ;.F;Bi;C0;7[[I" start;T0[I" length;T0;$@ o;= ;>I" overload;F;?0;;;@0;:I"[](range);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@ ;![;"I"@return [Array];T;#0;$@ ;.F;Bi;C0;7[[I" range;T0;$@ o;= ;>I" overload;F;?0;;;@0;:I" [](name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@ ;![;"I"@return [String, nil];T;#0;$@ ;.F;Bi;C0;7[[I" name;T0;$@ ;![;"I"Match Reference -- MatchData acts as an array, and may be accessed using the normal array indexing techniques. mtch[0] is equivalent to the special variable $&, and returns the entire matched string. mtch[1], mtch[2], and so on return the values of the matched backreferences (portions of the pattern between parentheses). m = /(.)(.)(\d+)(\d)/.match("THX1138.") m #=> # m[0] #=> "HX1138" m[1, 2] #=> ["H", "X"] m[1..3] #=> ["H", "X", "113"] m[-3, 2] #=> ["X", "113"] m = /(?a+)b/.match("ccaaab") m #=> # m["foo"] #=> "aaa" m[:foo] #=> "aaa" @overload [](i) @return [String, nil] @overload [](start, length) @return [Array] @overload [](range) @return [Array] @overload [](name) @return [String, nil];T;#0;$@ ;.F;/o;0;1T;2i ;3i';%@;9I"xstatic VALUE match_aref(int argc, VALUE *argv, VALUE match) { VALUE idx, length; match_check(match); rb_scan_args(argc, argv, "11", &idx, &length); if (NIL_P(length)) { if (FIXNUM_P(idx)) { return rb_reg_nth_match(FIX2INT(idx), match); } else { int num = namev_to_backref_number(RMATCH_REGS(match), RMATCH(match)->regexp, idx); if (num >= 0) { return rb_reg_nth_match(num, match); } else { return match_ary_aref(match, idx, Qnil); } } } else { long beg = NUM2LONG(idx); long len = NUM2LONG(length); long num_regs = RMATCH_REGS(match)->num_regs; if (len < 0) { return Qnil; } if (beg < 0) { beg += num_regs; if (beg < 0) return Qnil; } else if (beg > num_regs) { return Qnil; } else if (beg+len > num_regs) { len = num_regs - beg; } return match_ary_subseq(match, beg, len, Qnil); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#captures;F;7[;[[@x@i;T;;;0;[;{;IC; "Returns the array of captures; equivalent to mtch.to_a[1..-1]. f1,f2,f3,f4 = /(.)(.)(\d+)(\d)/.match("THX1138.").captures f1 #=> "H" f2 #=> "X" f3 #=> "113" f4 #=> "8" ;T;[o;= ;>I" overload;F;?0;;;@0;:I" captures;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@Y;![;"I"@return [Array];T;#0;$@Y;.F;Bi;C0;7[;$@Y;![;"I"Returns the array of captures; equivalent to mtch.to_a[1..-1]. f1,f2,f3,f4 = /(.)(.)(\d+)(\d)/.match("THX1138.").captures f1 #=> "H" f2 #=> "X" f3 #=> "113" f4 #=> "8" @overload captures @return [Array];T;#0;$@Y;.F;/o;0;1T;2i;3i;%@;9I"Sstatic VALUE match_captures(VALUE match) { return match_array(match, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#named_captures;F;7[;[[@x@i;T;;N;0;[;{;IC; "Returns a Hash using named capture. A key of the hash is a name of the named captures. A value of the hash is a string of last successful capture of corresponding group. m = /(?.)(?.)/.match("01") m.named_captures #=> {"a" => "0", "b" => "1"} m = /(?.)(?.)?/.match("0") m.named_captures #=> {"a" => "0", "b" => nil} m = /(?.)(?.)/.match("01") m.named_captures #=> {"a" => "1"} m = /(?x)|(?y)/.match("x") m.named_captures #=> {"a" => "x"} ;T;[o;= ;>I" overload;F;?0;;N;@0;:I"named_captures;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@t;![;"I"@return [Hash];T;#0;$@t;.F;Bi;C0;7[;$@t;![;"I"Returns a Hash using named capture. A key of the hash is a name of the named captures. A value of the hash is a string of last successful capture of corresponding group. m = /(?.)(?.)/.match("01") m.named_captures #=> {"a" => "0", "b" => "1"} m = /(?.)(?.)?/.match("0") m.named_captures #=> {"a" => "0", "b" => nil} m = /(?.)(?.)/.match("01") m.named_captures #=> {"a" => "1"} m = /(?x)|(?y)/.match("x") m.named_captures #=> {"a" => "x"} @overload named_captures @return [Hash];T;#0;$@t;.F;/o;0;1T;2i;3i;%@;9I"fstatic VALUE match_named_captures(VALUE match) { VALUE hash; struct MEMO *memo; match_check(match); if (NIL_P(RMATCH(match)->regexp)) return rb_hash_new(); hash = rb_hash_new(); memo = MEMO_NEW(hash, match, 0); onig_foreach_name(RREGEXP(RMATCH(match)->regexp)->ptr, match_named_captures_iter, (void*)memo); return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#values_at;F;7[[@90;[[@x@id;T;;;0;[;{;IC; "Uses each index to access the matching values, returning an array of the corresponding matches. m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie") m.to_a #=> ["HX1138", "H", "X", "113", "8"] m.values_at(0, 2, -2) #=> ["HX1138", "X", "113"] m.values_at(1..2, -1) #=> ["H", "X", "8"] m = /(?\d+) *(?[+\-*\/]) *(?\d+)/.match("1 + 2") m.to_a #=> ["1 + 2", "1", "+", "2"] m.values_at(:a, :b, :op) #=> ["1", "2", "+"] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"values_at(index, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" index;T0[I"...;T0;$@;![;"I"Uses each index to access the matching values, returning an array of the corresponding matches. m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie") m.to_a #=> ["HX1138", "H", "X", "113", "8"] m.values_at(0, 2, -2) #=> ["HX1138", "X", "113"] m.values_at(1..2, -1) #=> ["H", "X", "8"] m = /(?\d+) *(?[+\-*\/]) *(?\d+)/.match("1 + 2") m.to_a #=> ["1 + 2", "1", "+", "2"] m.values_at(:a, :b, :op) #=> ["1", "2", "+"] @overload values_at(index, ...) @return [Array];T;#0;$@;.F;/o;0;1T;2iR;3i`;%@;9I"(static VALUE match_values_at(int argc, VALUE *argv, VALUE match) { VALUE result; int i; match_check(match); result = rb_ary_new2(argc); for (i=0; iregexp, argv[i]); if (num >= 0) { rb_ary_push(result, rb_reg_nth_match(num, match)); } else { match_ary_aref(match, argv[i], result); } } } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#pre_match;F;7[;[[@x@i+;T;;;0;[;{;IC; "Returns the portion of the original string before the current match. Equivalent to the special variable $`. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.pre_match #=> "T" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"pre_match;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the portion of the original string before the current match. Equivalent to the special variable $`. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.pre_match #=> "T" @overload pre_match @return [String];T;#0;$@;.F;/o;0;1T;2i ;3i(;%@;9I"VALUE rb_reg_match_pre(VALUE match) { VALUE str; struct re_registers *regs; if (NIL_P(match)) return Qnil; match_check(match); regs = RMATCH_REGS(match); if (BEG(0) == -1) return Qnil; str = rb_str_subseq(RMATCH(match)->str, 0, BEG(0)); return str; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"MatchData#post_match;F;7[;[[@x@iE;T;;;0;[;{;IC; "Returns the portion of the original string after the current match. Equivalent to the special variable $'. m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie") m.post_match #=> ": The Movie" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"post_match;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ʃ;![;"I"@return [String];T;#0;$@ʃ;.F;Bi;C0;7[;$@ʃ;![;"I"Returns the portion of the original string after the current match. Equivalent to the special variable $'. m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie") m.post_match #=> ": The Movie" @overload post_match @return [String];T;#0;$@ʃ;.F;/o;0;1T;2i:;3iB;%@;9I"]VALUE rb_reg_match_post(VALUE match) { VALUE str; long pos; struct re_registers *regs; if (NIL_P(match)) return Qnil; match_check(match); regs = RMATCH_REGS(match); if (BEG(0) == -1) return Qnil; str = RMATCH(match)->str; pos = END(0); str = rb_str_subseq(str, pos, RSTRING_LEN(str) - pos); return str; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"MatchData#to_s;F;7[;[[@x@i;T;;G;0;[;{;IC; "lReturns the entire matched string. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.to_s #=> "HX1138" ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the entire matched string. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.to_s #=> "HX1138" @overload to_s @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE match_to_s(VALUE match) { VALUE str = rb_reg_last_match(match); match_check(match); if (NIL_P(str)) str = rb_str_new(0,0); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#inspect;F;7[;[[@x@i ;T;;J;0;[;{;IC; "Returns a printable version of mtch. puts /.$/.match("foo").inspect #=> # puts /(.)(.)(.)/.match("foo").inspect #=> # puts /(.)(.)?(.)/.match("fo").inspect #=> # puts /(?.)(?.)(?.)/.match("hoge").inspect #=> # ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a printable version of mtch. puts /.$/.match("foo").inspect #=> # puts /(.)(.)(.)/.match("foo").inspect #=> # puts /(.)(.)?(.)/.match("fo").inspect #=> # puts /(?.)(?.)(?.)/.match("hoge").inspect #=> # @overload inspect @return [String];T;#0;$@;.F;/o;0;1T;2i;3i ;%@;9I"Sstatic VALUE match_inspect(VALUE match) { VALUE cname = rb_class_path(rb_obj_class(match)); VALUE str; int i; struct re_registers *regs = RMATCH_REGS(match); int num_regs = regs->num_regs; struct backref_name_tag *names; VALUE regexp = RMATCH(match)->regexp; if (regexp == 0) { return rb_sprintf("#<%"PRIsVALUE":%p>", cname, (void*)match); } else if (NIL_P(regexp)) { return rb_sprintf("#<%"PRIsVALUE": %"PRIsVALUE">", cname, rb_reg_nth_match(0, match)); } names = ALLOCA_N(struct backref_name_tag, num_regs); MEMZERO(names, struct backref_name_tag, num_regs); onig_foreach_name(RREGEXP_PTR(regexp), match_inspect_name_iter, names); str = rb_str_buf_new2("#<"); rb_str_append(str, cname); for (i = 0; i < num_regs; i++) { VALUE v; rb_str_buf_cat2(str, " "); if (0 < i) { if (names[i].name) rb_str_buf_cat(str, (const char *)names[i].name, names[i].len); else { rb_str_catf(str, "%d", i); } rb_str_buf_cat2(str, ":"); } v = rb_reg_nth_match(i, match); if (NIL_P(v)) rb_str_buf_cat2(str, "nil"); else rb_str_buf_append(str, rb_str_inspect(v)); } rb_str_buf_cat2(str, ">"); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#string;F;7[;[[@x@i;T;;;0;[;{;IC; "Returns a frozen copy of the string passed in to match. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.string #=> "THX1138." ;T;[o;= ;>I" overload;F;?0;;;@0;:I" string;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a frozen copy of the string passed in to match. m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.string #=> "THX1138." @overload string @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"zstatic VALUE match_string(VALUE match) { match_check(match); return RMATCH(match)->str; /* str is frozen */ };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#hash;F;7[;[[@x@i: ;T;;X;0;[;{;IC; "vProduce a hash based on the target string, regexp and matched positions of this matchdata. See also Object#hash. ;T;[o;= ;>I" overload;F;?0;;X;@0;:I" hash;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@6;![;"I"@return [Integer];T;#0;$@6;.F;Bi;C0;7[;$@6;![;"I"Produce a hash based on the target string, regexp and matched positions of this matchdata. See also Object#hash. @overload hash @return [Integer];T;#0;$@6;.F;/o;0;1T;2i0 ;3i7 ;%@;9I"Vstatic VALUE match_hash(VALUE match) { const struct re_registers *regs; st_index_t hashval; match_check(match); hashval = rb_hash_start(rb_str_hash(RMATCH(match)->str)); hashval = rb_hash_uint(hashval, reg_hash(match_regexp(match))); regs = RMATCH_REGS(match); hashval = rb_hash_uint(hashval, regs->num_regs); hashval = rb_hash_uint(hashval, rb_memhash(regs->beg, regs->num_regs * sizeof(*regs->beg))); hashval = rb_hash_uint(hashval, rb_memhash(regs->end, regs->num_regs * sizeof(*regs->end))); hashval = rb_hash_end(hashval); return ST2FIX(hashval); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#eql?;F;7[[I" match2;T0;[[@x@iT ;T;;V;0;[;{;IC; "pEquality---Two matchdata are equal if their target strings, patterns, and matched positions are identical.;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(mtch2);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Q;![;"I"@return [Boolean];T;#0;$@Q;.F;Bi;C0;7[[I" mtch2;T0;$@Qo;= ;>I" overload;F;?0;;V;@0;:I"eql?(mtch2);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Q;![;"I"@return [Boolean];T;#0;$@Q;.F;Bi;C0;7[[I" mtch2;T0;$@Q;![;"I" Equality---Two matchdata are equal if their target strings, patterns, and matched positions are identical. @overload ==(mtch2) @return [Boolean] @overload eql?(mtch2) @return [Boolean];T;#0;$@Q;.F;/o;0;1T;2iK ;3iR ;Bi;%@;9I"static VALUE match_equal(VALUE match1, VALUE match2) { const struct re_registers *regs1, *regs2; if (match1 == match2) return Qtrue; if (!RB_TYPE_P(match2, T_MATCH)) return Qfalse; if (!RMATCH(match1)->regexp || !RMATCH(match2)->regexp) return Qfalse; if (!rb_str_equal(RMATCH(match1)->str, RMATCH(match2)->str)) return Qfalse; if (!rb_reg_equal(match_regexp(match1), match_regexp(match2))) return Qfalse; regs1 = RMATCH_REGS(match1); regs2 = RMATCH_REGS(match2); if (regs1->num_regs != regs2->num_regs) return Qfalse; if (memcmp(regs1->beg, regs2->beg, regs1->num_regs * sizeof(*regs1->beg))) return Qfalse; if (memcmp(regs1->end, regs2->end, regs1->num_regs * sizeof(*regs1->end))) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"MatchData#==;F;7[[I" match2;T0;[[@x@iT ;T;;F;0;[;{;IC; "pEquality---Two matchdata are equal if their target strings, patterns, and matched positions are identical. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(mtch2);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" mtch2;T0;$@o;= ;>I" overload;F;?0;;V;@0;:I"eql?(mtch2);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" mtch2;T0;$@;![;"@{;#0;$@;.F;/o;0;1T;2iK ;3iR ;%@;9I"static VALUE match_equal(VALUE match1, VALUE match2) { const struct re_registers *regs1, *regs2; if (match1 == match2) return Qtrue; if (!RB_TYPE_P(match2, T_MATCH)) return Qfalse; if (!RMATCH(match1)->regexp || !RMATCH(match2)->regexp) return Qfalse; if (!rb_str_equal(RMATCH(match1)->str, RMATCH(match2)->str)) return Qfalse; if (!rb_reg_equal(match_regexp(match1), match_regexp(match2))) return Qfalse; regs1 = RMATCH_REGS(match1); regs2 = RMATCH_REGS(match2); if (regs1->num_regs != regs2->num_regs) return Qfalse; if (memcmp(regs1->beg, regs2->beg, regs1->num_regs * sizeof(*regs1->beg))) return Qfalse; if (memcmp(regs1->end, regs2->end, regs1->num_regs * sizeof(*regs1->end))) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@x@iz[@x@i=;T;:MatchData;;;;;[;{;IC; "MatchData encapsulates the result of matching a Regexp against string. It is returned by Regexp#match and String#match, and also stored in a global variable returned by Regexp.last_match. Usage: url = 'https://docs.ruby-lang.org/en/2.5.0/MatchData.html' m = url.match(/(\d\.?)+/) # => # m.string # => "https://docs.ruby-lang.org/en/2.5.0/MatchData.html" m.regexp # => /(\d\.?)+/ # entire matched substring: m[0] # => "2.5.0" # Working with unnamed captures m = url.match(%r{([^/]+)/([^/]+)\.html$}) m.captures # => ["2.5.0", "MatchData"] m[1] # => "2.5.0" m.values_at(1, 2) # => ["2.5.0", "MatchData"] # Working with named captures m = url.match(%r{(?[^/]+)/(?[^/]+)\.html$}) m.captures # => ["2.5.0", "MatchData"] m.named_captures # => {"version"=>"2.5.0", "module"=>"MatchData"} m[:version] # => "2.5.0" m.values_at(:version, :module) # => ["2.5.0", "MatchData"] # Numerical indexes are working, too m[1] # => "2.5.0" m.values_at(1, 2) # => ["2.5.0", "MatchData"] == Global variables equivalence Parts of last MatchData (returned by Regexp.last_match) are also aliased as global variables: * $~ is Regexp.last_match; * $& is Regexp.last_match[ 0 ]; * $1, $2, and so on are Regexp.last_match[ i ] (captures by number); * $` is Regexp.last_match.pre_match; * $' is Regexp.last_match.post_match; * $+ is Regexp.last_match[ -1 ] (the last capture). See also "Special global variables" section in Regexp documentation.;T;[;![;"I" MatchData encapsulates the result of matching a Regexp against string. It is returned by Regexp#match and String#match, and also stored in a global variable returned by Regexp.last_match. Usage: url = 'https://docs.ruby-lang.org/en/2.5.0/MatchData.html' m = url.match(/(\d\.?)+/) # => # m.string # => "https://docs.ruby-lang.org/en/2.5.0/MatchData.html" m.regexp # => /(\d\.?)+/ # entire matched substring: m[0] # => "2.5.0" # Working with unnamed captures m = url.match(%r{([^/]+)/([^/]+)\.html$}) m.captures # => ["2.5.0", "MatchData"] m[1] # => "2.5.0" m.values_at(1, 2) # => ["2.5.0", "MatchData"] # Working with named captures m = url.match(%r{(?[^/]+)/(?[^/]+)\.html$}) m.captures # => ["2.5.0", "MatchData"] m.named_captures # => {"version"=>"2.5.0", "module"=>"MatchData"} m[:version] # => "2.5.0" m.values_at(:version, :module) # => ["2.5.0", "MatchData"] # Numerical indexes are working, too m[1] # => "2.5.0" m.values_at(1, 2) # => ["2.5.0", "MatchData"] == Global variables equivalence Parts of last MatchData (returned by Regexp.last_match) are also aliased as global variables: * $~ is Regexp.last_match; * $& is Regexp.last_match[ 0 ]; * $1, $2, and so on are Regexp.last_match[ i ] (captures by number); * $` is Regexp.last_match.pre_match; * $' is Regexp.last_match.post_match; * $+ is Regexp.last_match[ -1 ] (the last capture). See also "Special global variables" section in Regexp documentation. ;T;#0;$@;.F;/o;0;1T;2iz;3i;Bi;%@;&I"MatchData;F;'@o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@x@i[@x@i;T;:RegexpError;;;;;[;{;IC; "Raised when given an invalid regexp expression. Regexp.new("?") raises the exception: RegexpError: target of repeat operator is not specified: /?/ ;T;[;![;"I" Raised when given an invalid regexp expression. Regexp.new("?") raises the exception: RegexpError: target of repeat operator is not specified: /?/ ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"RegexpError;F;'@@`@o; ;IC;[o;4;5F;6;;;;&I"Encoding#to_s;F;7[;[[@pCi=;T;;G;0;[;{;IC; "OReturns the name of the encoding. Encoding::UTF_8.name #=> "UTF-8" ;T;[o;= ;>I" overload;F;?0;;F;@0;:I" name;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@Ԅ;![;"I"@return [String];T;#0;$@Ԅ;.F;Bi;C0;7[;$@Ԅo;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@Ԅ;![;"I"@return [String];T;#0;$@Ԅ;.F;Bi;C0;7[;$@Ԅ;![;"I"Returns the name of the encoding. Encoding::UTF_8.name #=> "UTF-8" @overload name @return [String] @overload to_s @return [String];T;#0;$@Ԅ;.F;/o;0;1T;2i4;3i<;%@҄;9I"qstatic VALUE enc_name(VALUE self) { return rb_fstring_cstr(rb_enc_name((rb_encoding*)DATA_PTR(self))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding#inspect;F;7[;[[@pCi";T;;J;0;[;{;IC; "Returns a string which represents the encoding for programmers. Encoding::UTF_8.inspect #=> "#" Encoding::ISO_2022_JP.inspect #=> "#" ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a string which represents the encoding for programmers. Encoding::UTF_8.inspect #=> "#" Encoding::ISO_2022_JP.inspect #=> "#" @overload inspect @return [String];T;#0;$@;.F;/o;0;1T;2i;3i ;%@҄;9I"static VALUE enc_inspect(VALUE self) { rb_encoding *enc; if (!is_data_encoding(self)) { not_encoding(self); } if (!(enc = DATA_PTR(self)) || rb_enc_from_index(rb_enc_to_index(enc)) != enc) { rb_raise(rb_eTypeError, "broken Encoding"); } return rb_enc_sprintf(rb_usascii_encoding(), "#<%"PRIsVALUE":%s%s%s>", rb_obj_class(self), rb_enc_name(enc), (ENC_DUMMY_P(enc) ? " (dummy)" : ""), rb_enc_autoload_p(enc) ? " (autoload)" : ""); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding#name;F;7[;[[@pCi=;T;;F;0;[;{;IC; "OReturns the name of the encoding. Encoding::UTF_8.name #=> "UTF-8" ;T;[o;= ;>I" overload;F;?0;;F;@0;:I" name;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2i4;3i<;%@҄;9I"qstatic VALUE enc_name(VALUE self) { return rb_fstring_cstr(rb_enc_name((rb_encoding*)DATA_PTR(self))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding#names;F;7[;[[@pCiW;T;;M;0;[;{;IC; "Returns the list of name and aliases of the encoding. Encoding::WINDOWS_31J.names #=> ["Windows-31J", "CP932", "csWindows31J", "SJIS", "PCK"] ;T;[o;= ;>I" overload;F;?0;;M;@0;:I" names;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@>;![;"I"@return [Array];T;#0;$@>;.F;Bi;C0;7[;$@>;![;"I"Returns the list of name and aliases of the encoding. Encoding::WINDOWS_31J.names #=> ["Windows-31J", "CP932", "csWindows31J", "SJIS", "PCK"] @overload names @return [Array];T;#0;$@>;.F;/o;0;1T;2iO;3iU;%@҄;9I"static VALUE enc_names(VALUE self) { VALUE args[2]; args[0] = (VALUE)rb_to_encoding_index(self); args[1] = rb_ary_new2(0); GLOBAL_ENC_TABLE_EVAL(enc_table, st_foreach(enc_table->names, enc_names_i, (st_data_t)args)); return args[1]; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding#dummy?;F;7[;[[@pCi;T;: dummy?;0;[;{;IC; "Returns true for dummy encodings. A dummy encoding is an encoding for which character handling is not properly implemented. It is used for stateful encodings. Encoding::ISO_2022_JP.dummy? #=> true Encoding::UTF_8.dummy? #=> false;T;[o;= ;>I" overload;F;?0;; ;@0;:I" dummy?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Y;![;"I"@return [Boolean];T;#0;$@Y;.F;Bi;C0;7[;$@Y;![;"I"$Returns true for dummy encodings. A dummy encoding is an encoding for which character handling is not properly implemented. It is used for stateful encodings. Encoding::ISO_2022_JP.dummy? #=> true Encoding::UTF_8.dummy? #=> false @overload dummy? @return [Boolean];T;#0;$@Y;.F;/o;0;1T;2i;3i;Bi;%@҄;9I"_static VALUE enc_dummy_p(VALUE enc) { return RBOOL(ENC_DUMMY_P(must_encoding(enc))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding#ascii_compatible?;F;7[;[[@pCi;T;:ascii_compatible?;0;[;{;IC; "Returns whether ASCII-compatible or not. Encoding::UTF_8.ascii_compatible? #=> true Encoding::UTF_16BE.ascii_compatible? #=> false;T;[o;= ;>I" overload;F;?0;; ;@0;:I"ascii_compatible?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@t;![;"I"@return [Boolean];T;#0;$@t;.F;Bi;C0;7[;$@t;![;"I"Returns whether ASCII-compatible or not. Encoding::UTF_8.ascii_compatible? #=> true Encoding::UTF_16BE.ascii_compatible? #=> false @overload ascii_compatible? @return [Boolean];T;#0;$@t;.F;/o;0;1T;2i;3i;Bi;%@҄;9I"qstatic VALUE enc_ascii_compatible_p(VALUE enc) { return RBOOL(rb_enc_asciicompat(must_encoding(enc))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding#replicate;F;7[[I" name;T0;[[@pCi9;T;:replicate;0;[;{;IC; "Returns a replicated encoding of _enc_ whose name is _name_. The new encoding should have the same byte structure of _enc_. If _name_ is used by another encoding, raise ArgumentError. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"replicate(name);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Encoding;T;$@;![;"I"@return [Encoding];T;#0;$@;.F;Bi;C0;7[[I" name;T0;$@;![;"I"Returns a replicated encoding of _enc_ whose name is _name_. The new encoding should have the same byte structure of _enc_. If _name_ is used by another encoding, raise ArgumentError. @overload replicate(name) @return [Encoding];T;#0;$@;.F;/o;0;1T;2i0;3i7;%@҄;9I"static VALUE enc_replicate_m(VALUE encoding, VALUE name) { int idx = rb_enc_replicate(name_for_encoding(&name), rb_to_encoding(encoding)); RB_GC_GUARD(name); return rb_enc_from_encoding_index(idx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding.list;F;7[;[[@pCiw;T;;;0;[;{;IC; "KReturns the list of loaded encodings. Encoding.list #=> [#, #, #] Encoding.find("US-ASCII") #=> # Encoding.list #=> [#, #, #, #] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" list;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"oReturns the list of loaded encodings. Encoding.list #=> [#, #, #] Encoding.find("US-ASCII") #=> # Encoding.list #=> [#, #, #, #] @overload list @return [Array];T;#0;$@;.F;/o;0;1T;2ie;3iu;%@҄;9I"static VALUE enc_list(VALUE klass) { VALUE ary = rb_ary_new2(0); RB_VM_LOCK_ENTER(); { rb_ary_replace(ary, rb_default_encoding_list); rb_ary_concat(ary, rb_additional_encoding_list); } RB_VM_LOCK_LEAVE(); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding.name_list;F;7[;[[@pCiS;T;:name_list;0;[;{;IC; "Returns the list of available encoding names. Encoding.name_list #=> ["US-ASCII", "ASCII-8BIT", "UTF-8", "ISO-8859-1", "Shift_JIS", "EUC-JP", "Windows-31J", "BINARY", "CP932", "eucJP"] ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"name_list;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@Ʌ;![;"I"@return [Array];T;#0;$@Ʌ;.F;Bi;C0;7[;$@Ʌ;![;"I"Returns the list of available encoding names. Encoding.name_list #=> ["US-ASCII", "ASCII-8BIT", "UTF-8", "ISO-8859-1", "Shift_JIS", "EUC-JP", "Windows-31J", "BINARY", "CP932", "eucJP"] @overload name_list @return [Array];T;#0;$@Ʌ;.F;/o;0;1T;2iE;3iP;%@҄;9I"$static VALUE rb_enc_name_list(VALUE klass) { VALUE ary; GLOBAL_ENC_TABLE_ENTER(enc_table); { ary = rb_ary_new2(enc_table->names->num_entries); st_foreach(enc_table->names, rb_enc_name_list_i, (st_data_t)ary); } GLOBAL_ENC_TABLE_LEAVE(); return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding.aliases;F;7[;[[@pCi;T;: aliases;0;[;{;IC; "Returns the hash of available encoding alias and original encoding name. Encoding.aliases #=> {"BINARY"=>"ASCII-8BIT", "ASCII"=>"US-ASCII", "ANSI_X3.4-1968"=>"US-ASCII", "SJIS"=>"Windows-31J", "eucJP"=>"EUC-JP", "CP932"=>"Windows-31J"} ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" aliases;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I" Returns the hash of available encoding alias and original encoding name. Encoding.aliases #=> {"BINARY"=>"ASCII-8BIT", "ASCII"=>"US-ASCII", "ANSI_X3.4-1968"=>"US-ASCII", "SJIS"=>"Windows-31J", "eucJP"=>"EUC-JP", "CP932"=>"Windows-31J"} @overload aliases;T;#0;$@;.F;/o;0;1T;2iy;3i;%@҄;9I""static VALUE rb_enc_aliases(VALUE klass) { VALUE aliases[2]; aliases[0] = rb_hash_new(); aliases[1] = rb_ary_new(); GLOBAL_ENC_TABLE_EVAL(enc_table, st_foreach(enc_table->names, rb_enc_aliases_enc_i, (st_data_t)aliases)); return aliases[0]; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding.find;F;7[[I"enc;T0;[[@pCi;T;;;0;[;{;IC; "\Search the encoding with specified name. name should be a string. Encoding.find("US-ASCII") #=> # Names which this method accept are encoding names and aliases including following special aliases "external":: default external encoding "internal":: default internal encoding "locale":: locale encoding "filesystem":: filesystem encoding An ArgumentError is raised when no encoding with name. Only Encoding.find("internal") however returns nil when no encoding named "internal", in other words, when Ruby has no default internal encoding. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"find(string);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;T0;$@;![;"I"uSearch the encoding with specified name. name should be a string. Encoding.find("US-ASCII") #=> # Names which this method accept are encoding names and aliases including following special aliases "external":: default external encoding "internal":: default internal encoding "locale":: locale encoding "filesystem":: filesystem encoding An ArgumentError is raised when no encoding with name. Only Encoding.find("internal") however returns nil when no encoding named "internal", in other words, when Ruby has no default internal encoding. @overload find(string);T;#0;$@;.F;/o;0;1T;2i;3i;%@҄;9I"static VALUE enc_find(VALUE klass, VALUE enc) { int idx; if (is_obj_encoding(enc)) return enc; idx = str_to_encindex(enc); if (idx == UNSPECIFIED_ENCODING) return Qnil; return rb_enc_from_encoding_index(idx); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding.compatible?;F;7[[I" str1;T0[I" str2;T0;[[@pCi;T;:compatible?;0;[;{;IC; "iChecks the compatibility of two objects. If the objects are both strings they are compatible when they are concatenatable. The encoding of the concatenated string will be returned if they are compatible, nil if they are not. Encoding.compatible?("\xa1".force_encoding("iso-8859-1"), "b") #=> # Encoding.compatible?( "\xa1".force_encoding("iso-8859-1"), "\xa1\xa1".force_encoding("euc-jp")) #=> nil If the objects are non-strings their encodings are compatible when they have an encoding and: * Either encoding is US-ASCII compatible * One of the encodings is a 7-bit encoding;T;[o;= ;>I" overload;F;?0;; ;@0;:I"compatible?(obj1, obj2);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I" obj1;T0[I" obj2;T0;$@;![;"I"Checks the compatibility of two objects. If the objects are both strings they are compatible when they are concatenatable. The encoding of the concatenated string will be returned if they are compatible, nil if they are not. Encoding.compatible?("\xa1".force_encoding("iso-8859-1"), "b") #=> # Encoding.compatible?( "\xa1".force_encoding("iso-8859-1"), "\xa1\xa1".force_encoding("euc-jp")) #=> nil If the objects are non-strings their encodings are compatible when they have an encoding and: * Either encoding is US-ASCII compatible * One of the encodings is a 7-bit encoding @overload compatible?(obj1, obj2) @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@҄;9I"static VALUE enc_compatible_p(VALUE klass, VALUE str1, VALUE str2) { rb_encoding *enc; if (!enc_capable(str1)) return Qnil; if (!enc_capable(str2)) return Qnil; enc = rb_enc_compatible(str1, str2); if (!enc) return Qnil; return rb_enc_from_encoding(enc); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding#_dump;F;7[[@90;[[@pCi;T;;;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@7;.F;/o;0;1T;2i;3i;%@҄;9I"|static VALUE enc_dump(int argc, VALUE *argv, VALUE self) { rb_check_arity(argc, 0, 1); return enc_name(self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding._load;F;7[[I"str;T0;[[@pCi;T;;;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@F;.F;/o;0;1T;2i;3i;%@҄;9I"Fstatic VALUE enc_load(VALUE klass, VALUE str) { return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding.default_external;F;7[;[[@pCi;T;:default_external;0;[;{;IC; "Returns default external encoding. The default external encoding is used by default for strings created from the following locations: * CSV * File data read from disk * SDBM * StringIO * Zlib::GzipReader * Zlib::GzipWriter * String#inspect * Regexp#inspect While strings created from these locations will have this encoding, the encoding may not be valid. Be sure to check String#valid_encoding?. File data written to disk will be transcoded to the default external encoding when written, if default_internal is not nil. The default external encoding is initialized by the -E option. If -E isn't set, it is initialized to UTF-8 on Windows and the locale on other operating systems. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"default_external;T;IC; ";T;[;![;"I";T;#0;$@V;.F;Bi;C0;7[;$@V;![;"I"Returns default external encoding. The default external encoding is used by default for strings created from the following locations: * CSV * File data read from disk * SDBM * StringIO * Zlib::GzipReader * Zlib::GzipWriter * String#inspect * Regexp#inspect While strings created from these locations will have this encoding, the encoding may not be valid. Be sure to check String#valid_encoding?. File data written to disk will be transcoded to the default external encoding when written, if default_internal is not nil. The default external encoding is initialized by the -E option. If -E isn't set, it is initialized to UTF-8 on Windows and the locale on other operating systems. @overload default_external;T;#0;$@V;.F;/o;0;1T;2ix;3i;%@҄;9I"]static VALUE get_default_external(VALUE klass) { return rb_enc_default_external(); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding.default_external=;F;7[[I" encoding;T0;[[@pCi;T;:default_external=;0;[;{;IC; "Sets default external encoding. You should not set Encoding::default_external in ruby code as strings created before changing the value may have a different encoding from strings created after the value was changed., instead you should use ruby -E to invoke ruby with the correct default_external. See Encoding::default_external for information on how the default external encoding is used. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"default_external=(enc);T;IC; ";T;[;![;"I";T;#0;$@l;.F;Bi;C0;7[[I"enc;T0;$@l;![;"I"Sets default external encoding. You should not set Encoding::default_external in ruby code as strings created before changing the value may have a different encoding from strings created after the value was changed., instead you should use ruby -E to invoke ruby with the correct default_external. See Encoding::default_external for information on how the default external encoding is used. @overload default_external=(enc);T;#0;$@l;.F;/o;0;1T;2i;3i;%@҄;9I"static VALUE set_default_external(VALUE klass, VALUE encoding) { rb_warning("setting Encoding.default_external"); rb_enc_set_default_external(encoding); return encoding; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding.default_internal;F;7[;[[@pCi;T;:default_internal;0;[;{;IC; "Returns default internal encoding. Strings will be transcoded to the default internal encoding in the following places if the default internal encoding is not nil: * CSV * Etc.sysconfdir and Etc.systmpdir * File data read from disk * File names from Dir * Integer#chr * String#inspect and Regexp#inspect * Strings returned from Readline * Strings returned from SDBM * Time#zone * Values from ENV * Values in ARGV including $PROGRAM_NAME Additionally String#encode and String#encode! use the default internal encoding if no encoding is given. The script encoding (__ENCODING__), not default_internal, is used as the encoding of created strings. Encoding::default_internal is initialized with -E option or nil otherwise. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"default_internal;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns default internal encoding. Strings will be transcoded to the default internal encoding in the following places if the default internal encoding is not nil: * CSV * Etc.sysconfdir and Etc.systmpdir * File data read from disk * File names from Dir * Integer#chr * String#inspect and Regexp#inspect * Strings returned from Readline * Strings returned from SDBM * Time#zone * Values from ENV * Values in ARGV including $PROGRAM_NAME Additionally String#encode and String#encode! use the default internal encoding if no encoding is given. The script encoding (__ENCODING__), not default_internal, is used as the encoding of created strings. Encoding::default_internal is initialized with -E option or nil otherwise. @overload default_internal;T;#0;$@;.F;/o;0;1T;2i;3i;%@҄;9I"]static VALUE get_default_internal(VALUE klass) { return rb_enc_default_internal(); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding.default_internal=;F;7[[I" encoding;T0;[[@pCi;T;:default_internal=;0;[;{;IC; "Sets default internal encoding or removes default internal encoding when passed nil. You should not set Encoding::default_internal in ruby code as strings created before changing the value may have a different encoding from strings created after the change. Instead you should use ruby -E to invoke ruby with the correct default_internal. See Encoding::default_internal for information on how the default internal encoding is used. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"default_internal=(enc);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"enc;T0;$@;![;"I"Sets default internal encoding or removes default internal encoding when passed nil. You should not set Encoding::default_internal in ruby code as strings created before changing the value may have a different encoding from strings created after the change. Instead you should use ruby -E to invoke ruby with the correct default_internal. See Encoding::default_internal for information on how the default internal encoding is used. @overload default_internal=(enc);T;#0;$@;.F;/o;0;1T;2i;3i;%@҄;9I"static VALUE set_default_internal(VALUE klass, VALUE encoding) { rb_warning("setting Encoding.default_internal"); rb_enc_set_default_internal(encoding); return encoding; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding.locale_charmap;F;7[;[[I"miniinit.c;Ti;T;:locale_charmap;0;[;{;IC; "localeinit.c ;T;[;![;"I"localeinit.c;T;#0;$@;.F;/o;0;1T;2i;3i;%@҄;9I"SVALUE rb_locale_charmap(VALUE klass) { /* never used */ return Qnil; };T;:I" VALUE;T;;To; ;IC;[; @ņ; IC;[; @ņ; IC;[; @ņ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i [@)i~ ;T;:CompatibilityError;;;;;[;{;IC; "mRaised by Encoding and String methods when the source encoding is incompatible with the target encoding. ;T;[;![;"I"o Raised by Encoding and String methods when the source encoding is incompatible with the target encoding. ;T;#0;$@ņ;.F;/o;0;1T;2i ;3i ;%o;( ;)0;*0;+0;: Encoding;%@;-@҄;0;&I"!Encoding::CompatibilityError;T;'@po; ;IC;[#o;4;5F;6;;;;&I"-Encoding::Converter.asciicompat_encoding;T;7[[I"arg;T0;[[@,i ;T;:asciicompat_encoding;0;[;{;IC; "VReturns the corresponding ASCII compatible encoding. Returns nil if the argument is an ASCII compatible encoding. "corresponding ASCII compatible encoding" is an ASCII compatible encoding which can represents exactly the same characters as the given ASCII incompatible encoding. So, no conversion undefined error occurs when converting between the two encodings. Encoding::Converter.asciicompat_encoding("ISO-2022-JP") #=> # Encoding::Converter.asciicompat_encoding("UTF-16BE") #=> # Encoding::Converter.asciicompat_encoding("UTF-8") #=> nil ;T;[o;= ;>I" overload;F;?0;:-Encoding::Converter.asciicompat_encoding;@0;:I"5Encoding::Converter.asciicompat_encoding(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Encoding;TI"nil;T;$@܆;![;"I"@return [Encoding, nil];T;#0;$@܆;.F;Bi;C0;7[[I" string;T0;$@܆o;= ;>I" overload;F;?0;; ;@0;:I"7Encoding::Converter.asciicompat_encoding(encoding);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Encoding;TI"nil;T;$@܆;![;"I"@return [Encoding, nil];T;#0;$@܆;.F;Bi;C0;7[[I" encoding;T0;$@܆;![;"I"Returns the corresponding ASCII compatible encoding. Returns nil if the argument is an ASCII compatible encoding. "corresponding ASCII compatible encoding" is an ASCII compatible encoding which can represents exactly the same characters as the given ASCII incompatible encoding. So, no conversion undefined error occurs when converting between the two encodings. Encoding::Converter.asciicompat_encoding("ISO-2022-JP") #=> # Encoding::Converter.asciicompat_encoding("UTF-16BE") #=> # Encoding::Converter.asciicompat_encoding("UTF-8") #=> nil @overload Encoding::Converter.asciicompat_encoding(string) @return [Encoding, nil] @overload Encoding::Converter.asciicompat_encoding(encoding) @return [Encoding, nil];T;#0;$@܆;.F;/o;0;1T;2i ;3i ;%@چ;9I"static VALUE econv_s_asciicompat_encoding(VALUE klass, VALUE arg) { const char *arg_name, *result_name; rb_encoding *arg_enc, *result_enc; enc_arg(&arg, &arg_name, &arg_enc); result_name = rb_econv_asciicompat_encoding(arg_name); if (result_name == NULL) return Qnil; result_enc = make_encoding(result_name); return rb_enc_from_encoding(result_enc); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(Encoding::Converter.search_convpath;T;7[[@90;[[@,iZ ;T;:search_convpath;0;[;{;IC; "-Returns a conversion path. p Encoding::Converter.search_convpath("ISO-8859-1", "EUC-JP") #=> [[#, #], # [#, #]] p Encoding::Converter.search_convpath("ISO-8859-1", "EUC-JP", universal_newline: true) or p Encoding::Converter.search_convpath("ISO-8859-1", "EUC-JP", newline: :universal) #=> [[#, #], # [#, #], # "universal_newline"] p Encoding::Converter.search_convpath("ISO-8859-1", "UTF-32BE", universal_newline: true) or p Encoding::Converter.search_convpath("ISO-8859-1", "UTF-32BE", newline: :universal) #=> [[#, #], # "universal_newline", # [#, #]] ;T;[o;= ;>I" overload;F;?0;:(Encoding::Converter.search_convpath;@0;:I"OEncoding::Converter.search_convpath(source_encoding, destination_encoding);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@ ;![;"I"@return [Array];T;#0;$@ ;.F;Bi;C0;7[[I"source_encoding;T0[I"destination_encoding;T0;$@ o;= ;>I" overload;F;?0;; ;@0;:I"TEncoding::Converter.search_convpath(source_encoding, destination_encoding, opt);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@ ;![;"I"@return [Array];T;#0;$@ ;.F;Bi;C0;7[[I"source_encoding;T0[I"destination_encoding;T0[I"opt;T0;$@ ;![;"I" Returns a conversion path. p Encoding::Converter.search_convpath("ISO-8859-1", "EUC-JP") #=> [[#, #], # [#, #]] p Encoding::Converter.search_convpath("ISO-8859-1", "EUC-JP", universal_newline: true) or p Encoding::Converter.search_convpath("ISO-8859-1", "EUC-JP", newline: :universal) #=> [[#, #], # [#, #], # "universal_newline"] p Encoding::Converter.search_convpath("ISO-8859-1", "UTF-32BE", universal_newline: true) or p Encoding::Converter.search_convpath("ISO-8859-1", "UTF-32BE", newline: :universal) #=> [[#, #], # "universal_newline", # [#, #]] @overload Encoding::Converter.search_convpath(source_encoding, destination_encoding) @return [Array] @overload Encoding::Converter.search_convpath(source_encoding, destination_encoding, opt) @return [Array];T;#0;$@ ;.F;/o;0;1T;2iA ;3iY ;%@چ;9I"static VALUE econv_s_search_convpath(int argc, VALUE *argv, VALUE klass) { VALUE snamev, dnamev; const char *sname, *dname; rb_encoding *senc, *denc; int ecflags; VALUE ecopts; VALUE convpath; econv_args(argc, argv, &snamev, &dnamev, &sname, &dname, &senc, &denc, &ecflags, &ecopts); convpath = Qnil; transcode_search_path(sname, dname, search_convpath_i, &convpath); if (NIL_P(convpath)) { VALUE exc = rb_econv_open_exc(sname, dname, ecflags); RB_GC_GUARD(snamev); RB_GC_GUARD(dnamev); rb_exc_raise(exc); } if (decorate_convpath(convpath, ecflags) == -1) { VALUE exc = rb_econv_open_exc(sname, dname, ecflags); RB_GC_GUARD(snamev); RB_GC_GUARD(dnamev); rb_exc_raise(exc); } return convpath; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#Encoding::Converter#initialize;T;7[[@90;[[@,iS ;T;;D;0;[;{;IC; "+possible options elements: hash form: :invalid => nil # raise error on invalid byte sequence (default) :invalid => :replace # replace invalid byte sequence :undef => nil # raise error on undefined conversion (default) :undef => :replace # replace undefined conversion :replace => string # replacement string ("?" or "\uFFFD" if not specified) :newline => :universal # decorator for converting CRLF and CR to LF :newline => :crlf # decorator for converting LF to CRLF :newline => :cr # decorator for converting LF to CR :universal_newline => true # decorator for converting CRLF and CR to LF :crlf_newline => true # decorator for converting LF to CRLF :cr_newline => true # decorator for converting LF to CR :xml => :text # escape as XML CharData. :xml => :attr # escape as XML AttValue integer form: Encoding::Converter::INVALID_REPLACE Encoding::Converter::UNDEF_REPLACE Encoding::Converter::UNDEF_HEX_CHARREF Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR Encoding::Converter::CRLF_NEWLINE_DECORATOR Encoding::Converter::CR_NEWLINE_DECORATOR Encoding::Converter::XML_TEXT_DECORATOR Encoding::Converter::XML_ATTR_CONTENT_DECORATOR Encoding::Converter::XML_ATTR_QUOTE_DECORATOR Encoding::Converter.new creates an instance of Encoding::Converter. Source_encoding and destination_encoding should be a string or Encoding object. opt should be nil, a hash or an integer. convpath should be an array. convpath may contain - two-element arrays which contain encodings or encoding names, or - strings representing decorator names. Encoding::Converter.new optionally takes an option. The option should be a hash or an integer. The option hash can contain :invalid => nil, etc. The option integer should be logical-or of constants such as Encoding::Converter::INVALID_REPLACE, etc. [:invalid => nil] Raise error on invalid byte sequence. This is a default behavior. [:invalid => :replace] Replace invalid byte sequence by replacement string. [:undef => nil] Raise an error if a character in source_encoding is not defined in destination_encoding. This is a default behavior. [:undef => :replace] Replace undefined character in destination_encoding with replacement string. [:replace => string] Specify the replacement string. If not specified, "\uFFFD" is used for Unicode encodings and "?" for others. [:universal_newline => true] Convert CRLF and CR to LF. [:crlf_newline => true] Convert LF to CRLF. [:cr_newline => true] Convert LF to CR. [:xml => :text] Escape as XML CharData. This form can be used as an HTML 4.0 #PCDATA. - '&' -> '&' - '<' -> '<' - '>' -> '>' - undefined characters in destination_encoding -> hexadecimal CharRef such as &#xHH; [:xml => :attr] Escape as XML AttValue. The converted result is quoted as "...". This form can be used as an HTML 4.0 attribute value. - '&' -> '&' - '<' -> '<' - '>' -> '>' - '"' -> '"' - undefined characters in destination_encoding -> hexadecimal CharRef such as &#xHH; Examples: # UTF-16BE to UTF-8 ec = Encoding::Converter.new("UTF-16BE", "UTF-8") # Usually, decorators such as newline conversion are inserted last. ec = Encoding::Converter.new("UTF-16BE", "UTF-8", :universal_newline => true) p ec.convpath #=> [[#, #], # "universal_newline"] # But, if the last encoding is ASCII incompatible, # decorators are inserted before the last conversion. ec = Encoding::Converter.new("UTF-8", "UTF-16BE", :crlf_newline => true) p ec.convpath #=> ["crlf_newline", # [#, #]] # Conversion path can be specified directly. ec = Encoding::Converter.new(["universal_newline", ["EUC-JP", "UTF-8"], ["UTF-8", "UTF-16BE"]]) p ec.convpath #=> ["universal_newline", # [#, #], # [#, #]] ;T;[o;= ;>I" overload;F;?0;:Encoding::Converter.new;@0;:I"CEncoding::Converter.new(source_encoding, destination_encoding);T;IC; ";T;[;![;"I";T;#0;$@?;.F;Bi;C0;7[[I"source_encoding;T0[I"destination_encoding;T0;$@?o;= ;>I" overload;F;?0;; ;@0;:I"HEncoding::Converter.new(source_encoding, destination_encoding, opt);T;IC; ";T;[;![;"I";T;#0;$@?;.F;Bi;C0;7[[I"source_encoding;T0[I"destination_encoding;T0[I"opt;T0;$@?o;= ;>I" overload;F;?0;; ;@0;:I"&Encoding::Converter.new(convpath);T;IC; ";T;[;![;"I";T;#0;$@?;.F;Bi;C0;7[[I" convpath;T0;$@?;![;"I"possible options elements: hash form: :invalid => nil # raise error on invalid byte sequence (default) :invalid => :replace # replace invalid byte sequence :undef => nil # raise error on undefined conversion (default) :undef => :replace # replace undefined conversion :replace => string # replacement string ("?" or "\uFFFD" if not specified) :newline => :universal # decorator for converting CRLF and CR to LF :newline => :crlf # decorator for converting LF to CRLF :newline => :cr # decorator for converting LF to CR :universal_newline => true # decorator for converting CRLF and CR to LF :crlf_newline => true # decorator for converting LF to CRLF :cr_newline => true # decorator for converting LF to CR :xml => :text # escape as XML CharData. :xml => :attr # escape as XML AttValue integer form: Encoding::Converter::INVALID_REPLACE Encoding::Converter::UNDEF_REPLACE Encoding::Converter::UNDEF_HEX_CHARREF Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR Encoding::Converter::CRLF_NEWLINE_DECORATOR Encoding::Converter::CR_NEWLINE_DECORATOR Encoding::Converter::XML_TEXT_DECORATOR Encoding::Converter::XML_ATTR_CONTENT_DECORATOR Encoding::Converter::XML_ATTR_QUOTE_DECORATOR Encoding::Converter.new creates an instance of Encoding::Converter. Source_encoding and destination_encoding should be a string or Encoding object. opt should be nil, a hash or an integer. convpath should be an array. convpath may contain - two-element arrays which contain encodings or encoding names, or - strings representing decorator names. Encoding::Converter.new optionally takes an option. The option should be a hash or an integer. The option hash can contain :invalid => nil, etc. The option integer should be logical-or of constants such as Encoding::Converter::INVALID_REPLACE, etc. [:invalid => nil] Raise error on invalid byte sequence. This is a default behavior. [:invalid => :replace] Replace invalid byte sequence by replacement string. [:undef => nil] Raise an error if a character in source_encoding is not defined in destination_encoding. This is a default behavior. [:undef => :replace] Replace undefined character in destination_encoding with replacement string. [:replace => string] Specify the replacement string. If not specified, "\uFFFD" is used for Unicode encodings and "?" for others. [:universal_newline => true] Convert CRLF and CR to LF. [:crlf_newline => true] Convert LF to CRLF. [:cr_newline => true] Convert LF to CR. [:xml => :text] Escape as XML CharData. This form can be used as an HTML 4.0 #PCDATA. - '&' -> '&' - '<' -> '<' - '>' -> '>' - undefined characters in destination_encoding -> hexadecimal CharRef such as &#xHH; [:xml => :attr] Escape as XML AttValue. The converted result is quoted as "...". This form can be used as an HTML 4.0 attribute value. - '&' -> '&' - '<' -> '<' - '>' -> '>' - '"' -> '"' - undefined characters in destination_encoding -> hexadecimal CharRef such as &#xHH; Examples: # UTF-16BE to UTF-8 ec = Encoding::Converter.new("UTF-16BE", "UTF-8") # Usually, decorators such as newline conversion are inserted last. ec = Encoding::Converter.new("UTF-16BE", "UTF-8", :universal_newline => true) p ec.convpath #=> [[#, #], # "universal_newline"] # But, if the last encoding is ASCII incompatible, # decorators are inserted before the last conversion. ec = Encoding::Converter.new("UTF-8", "UTF-16BE", :crlf_newline => true) p ec.convpath #=> ["crlf_newline", # [#, #]] # Conversion path can be specified directly. ec = Encoding::Converter.new(["universal_newline", ["EUC-JP", "UTF-8"], ["UTF-8", "UTF-16BE"]]) p ec.convpath #=> ["universal_newline", # [#, #], # [#, #]] @overload Encoding::Converter.new(source_encoding, destination_encoding) @overload Encoding::Converter.new(source_encoding, destination_encoding, opt) @overload Encoding::Converter.new(convpath);T;#0;$@?;.F;/o;0;1T;2i ;3iP ;%@چ;9I"static VALUE econv_init(int argc, VALUE *argv, VALUE self) { VALUE ecopts; VALUE snamev, dnamev; const char *sname, *dname; rb_encoding *senc, *denc; rb_econv_t *ec; int ecflags; VALUE convpath; if (rb_check_typeddata(self, &econv_data_type)) { rb_raise(rb_eTypeError, "already initialized"); } if (argc == 1 && !NIL_P(convpath = rb_check_array_type(argv[0]))) { ec = rb_econv_init_by_convpath(self, convpath, &sname, &dname, &senc, &denc); ecflags = 0; ecopts = Qnil; } else { econv_args(argc, argv, &snamev, &dnamev, &sname, &dname, &senc, &denc, &ecflags, &ecopts); ec = rb_econv_open_opts(sname, dname, ecflags, ecopts); } if (!ec) { VALUE exc = rb_econv_open_exc(sname, dname, ecflags); RB_GC_GUARD(snamev); RB_GC_GUARD(dnamev); rb_exc_raise(exc); } if (!DECORATOR_P(sname, dname)) { if (!senc) senc = make_dummy_encoding(sname); if (!denc) denc = make_dummy_encoding(dname); RB_GC_GUARD(snamev); RB_GC_GUARD(dnamev); } ec->source_encoding = senc; ec->destination_encoding = denc; DATA_PTR(self) = ec; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Encoding::Converter#inspect;T;7[;[[@,i ;T;;J;0;[;{;IC; "Returns a printable version of ec ec = Encoding::Converter.new("iso-8859-1", "utf-8") puts ec.inspect #=> # ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@r;![;"I"@return [String];T;#0;$@r;.F;Bi;C0;7[;$@r;![;"I"Returns a printable version of ec ec = Encoding::Converter.new("iso-8859-1", "utf-8") puts ec.inspect #=> # @overload inspect @return [String];T;#0;$@r;.F;/o;0;1T;2i ;3i ;%@چ;9I"$static VALUE econv_inspect(VALUE self) { const char *cname = rb_obj_classname(self); rb_econv_t *ec; TypedData_Get_Struct(self, rb_econv_t, &econv_data_type, ec); if (!ec) return rb_sprintf("#<%s: uninitialized>", cname); else { const char *sname = ec->source_encoding_name; const char *dname = ec->destination_encoding_name; VALUE str; str = rb_sprintf("#<%s: ", cname); econv_description(sname, dname, ec->flags, str); rb_str_cat2(str, ">"); return str; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Encoding::Converter#convpath;T;7[;[[@,i ;T;: convpath;0;[;{;IC; "HReturns the conversion path of ec. The result is an array of conversions. ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP", crlf_newline: true) p ec.convpath #=> [[#, #], # [#, #], # "crlf_newline"] Each element of the array is a pair of encodings or a string. A pair means an encoding conversion. A string means a decorator. In the above example, [#, #] means a converter from ISO-8859-1 to UTF-8. "crlf_newline" means newline converter from LF to CRLF. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" convpath;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"oReturns the conversion path of ec. The result is an array of conversions. ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP", crlf_newline: true) p ec.convpath #=> [[#, #], # [#, #], # "crlf_newline"] Each element of the array is a pair of encodings or a string. A pair means an encoding conversion. A string means a decorator. In the above example, [#, #] means a converter from ISO-8859-1 to UTF-8. "crlf_newline" means newline converter from LF to CRLF. @overload convpath @return [Array];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@چ;9I"static VALUE econv_convpath(VALUE self) { rb_econv_t *ec = check_econv(self); VALUE result; int i; result = rb_ary_new(); for (i = 0; i < ec->num_trans; i++) { const rb_transcoder *tr = ec->elems[i].tc->transcoder; VALUE v; if (DECORATOR_P(tr->src_encoding, tr->dst_encoding)) v = rb_str_new_cstr(tr->dst_encoding); else v = rb_assoc_new(make_encobj(tr->src_encoding), make_encobj(tr->dst_encoding)); rb_ary_push(result, v); } return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(Encoding::Converter#source_encoding;T;7[;[[@,i ;T;:source_encoding;0;[;{;IC; "7Returns the source encoding as an Encoding object. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"source_encoding;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Encoding;T;$@;![;"I"@return [Encoding];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"hReturns the source encoding as an Encoding object. @overload source_encoding @return [Encoding];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@چ;9I"static VALUE econv_source_encoding(VALUE self) { rb_econv_t *ec = check_econv(self); if (!ec->source_encoding) return Qnil; return rb_enc_from_encoding(ec->source_encoding); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"-Encoding::Converter#destination_encoding;T;7[;[[@,i ;T;:destination_encoding;0;[;{;IC; "I" overload;F;?0;; ;@0;:I"destination_encoding;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Encoding;T;$@Ç;![;"I"@return [Encoding];T;#0;$@Ç;.F;Bi;C0;7[;$@Ç;![;"I"rReturns the destination encoding as an Encoding object. @overload destination_encoding @return [Encoding];T;#0;$@Ç;.F;/o;0;1T;2i ;3i ;%@چ;9I"static VALUE econv_destination_encoding(VALUE self) { rb_econv_t *ec = check_econv(self); if (!ec->destination_encoding) return Qnil; return rb_enc_from_encoding(ec->destination_encoding); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*Encoding::Converter#primitive_convert;T;7[[@90;[[@,i;T;:primitive_convert;0;[;{;IC; "f possible opt elements: hash form: :partial_input => true # source buffer may be part of larger source :after_output => true # stop conversion after output before input integer form: Encoding::Converter::PARTIAL_INPUT Encoding::Converter::AFTER_OUTPUT possible results: :invalid_byte_sequence :incomplete_input :undefined_conversion :after_output :destination_buffer_full :source_buffer_empty :finished primitive_convert converts source_buffer into destination_buffer. source_buffer should be a string or nil. nil means an empty string. destination_buffer should be a string. destination_byteoffset should be an integer or nil. nil means the end of destination_buffer. If it is omitted, nil is assumed. destination_bytesize should be an integer or nil. nil means unlimited. If it is omitted, nil is assumed. opt should be nil, a hash or an integer. nil means no flags. If it is omitted, nil is assumed. primitive_convert converts the content of source_buffer from beginning and store the result into destination_buffer. destination_byteoffset and destination_bytesize specify the region which the converted result is stored. destination_byteoffset specifies the start position in destination_buffer in bytes. If destination_byteoffset is nil, destination_buffer.bytesize is used for appending the result. destination_bytesize specifies maximum number of bytes. If destination_bytesize is nil, destination size is unlimited. After conversion, destination_buffer is resized to destination_byteoffset + actually produced number of bytes. Also destination_buffer's encoding is set to destination_encoding. primitive_convert drops the converted part of source_buffer. the dropped part is converted in destination_buffer or buffered in Encoding::Converter object. primitive_convert stops conversion when one of following condition met. - invalid byte sequence found in source buffer (:invalid_byte_sequence) +primitive_errinfo+ and +last_error+ methods returns the detail of the error. - unexpected end of source buffer (:incomplete_input) this occur only when :partial_input is not specified. +primitive_errinfo+ and +last_error+ methods returns the detail of the error. - character not representable in output encoding (:undefined_conversion) +primitive_errinfo+ and +last_error+ methods returns the detail of the error. - after some output is generated, before input is done (:after_output) this occur only when :after_output is specified. - destination buffer is full (:destination_buffer_full) this occur only when destination_bytesize is non-nil. - source buffer is empty (:source_buffer_empty) this occur only when :partial_input is specified. - conversion is finished (:finished) example: ec = Encoding::Converter.new("UTF-8", "UTF-16BE") ret = ec.primitive_convert(src="pi", dst="", nil, 100) p [ret, src, dst] #=> [:finished, "", "\x00p\x00i"] ec = Encoding::Converter.new("UTF-8", "UTF-16BE") ret = ec.primitive_convert(src="pi", dst="", nil, 1) p [ret, src, dst] #=> [:destination_buffer_full, "i", "\x00"] ret = ec.primitive_convert(src, dst="", nil, 1) p [ret, src, dst] #=> [:destination_buffer_full, "", "p"] ret = ec.primitive_convert(src, dst="", nil, 1) p [ret, src, dst] #=> [:destination_buffer_full, "", "\x00"] ret = ec.primitive_convert(src, dst="", nil, 1) p [ret, src, dst] #=> [:finished, "", "i"] ;T;[ o;= ;>I" overload;F;?0;; ;@0;:I"9primitive_convert(source_buffer, destination_buffer);T;IC; ";T;[;![;"I";T;#0;$@އ;.F;Bi;C0;7[[I"source_buffer;T0[I"destination_buffer;T0;$@އo;= ;>I" overload;F;?0;; ;@0;:I"Qprimitive_convert(source_buffer, destination_buffer, destination_byteoffset);T;IC; ";T;[;![;"I";T;#0;$@އ;.F;Bi;C0;7[[I"source_buffer;T0[I"destination_buffer;T0[I"destination_byteoffset;T0;$@އo;= ;>I" overload;F;?0;; ;@0;:I"gprimitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize);T;IC; ";T;[;![;"I";T;#0;$@އ;.F;Bi;C0;7[ [I"source_buffer;T0[I"destination_buffer;T0[I"destination_byteoffset;T0[I"destination_bytesize;T0;$@އo;= ;>I" overload;F;?0;; ;@0;:I"lprimitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize, opt);T;IC; ";T;[;![;"I";T;#0;$@އ;.F;Bi;C0;7[ [I"source_buffer;T0[I"destination_buffer;T0[I"destination_byteoffset;T0[I"destination_bytesize;T0[I"opt;T0;$@އ;![;"I"possible opt elements: hash form: :partial_input => true # source buffer may be part of larger source :after_output => true # stop conversion after output before input integer form: Encoding::Converter::PARTIAL_INPUT Encoding::Converter::AFTER_OUTPUT possible results: :invalid_byte_sequence :incomplete_input :undefined_conversion :after_output :destination_buffer_full :source_buffer_empty :finished primitive_convert converts source_buffer into destination_buffer. source_buffer should be a string or nil. nil means an empty string. destination_buffer should be a string. destination_byteoffset should be an integer or nil. nil means the end of destination_buffer. If it is omitted, nil is assumed. destination_bytesize should be an integer or nil. nil means unlimited. If it is omitted, nil is assumed. opt should be nil, a hash or an integer. nil means no flags. If it is omitted, nil is assumed. primitive_convert converts the content of source_buffer from beginning and store the result into destination_buffer. destination_byteoffset and destination_bytesize specify the region which the converted result is stored. destination_byteoffset specifies the start position in destination_buffer in bytes. If destination_byteoffset is nil, destination_buffer.bytesize is used for appending the result. destination_bytesize specifies maximum number of bytes. If destination_bytesize is nil, destination size is unlimited. After conversion, destination_buffer is resized to destination_byteoffset + actually produced number of bytes. Also destination_buffer's encoding is set to destination_encoding. primitive_convert drops the converted part of source_buffer. the dropped part is converted in destination_buffer or buffered in Encoding::Converter object. primitive_convert stops conversion when one of following condition met. - invalid byte sequence found in source buffer (:invalid_byte_sequence) +primitive_errinfo+ and +last_error+ methods returns the detail of the error. - unexpected end of source buffer (:incomplete_input) this occur only when :partial_input is not specified. +primitive_errinfo+ and +last_error+ methods returns the detail of the error. - character not representable in output encoding (:undefined_conversion) +primitive_errinfo+ and +last_error+ methods returns the detail of the error. - after some output is generated, before input is done (:after_output) this occur only when :after_output is specified. - destination buffer is full (:destination_buffer_full) this occur only when destination_bytesize is non-nil. - source buffer is empty (:source_buffer_empty) this occur only when :partial_input is specified. - conversion is finished (:finished) example: ec = Encoding::Converter.new("UTF-8", "UTF-16BE") ret = ec.primitive_convert(src="pi", dst="", nil, 100) p [ret, src, dst] #=> [:finished, "", "\x00p\x00i"] ec = Encoding::Converter.new("UTF-8", "UTF-16BE") ret = ec.primitive_convert(src="pi", dst="", nil, 1) p [ret, src, dst] #=> [:destination_buffer_full, "i", "\x00"] ret = ec.primitive_convert(src, dst="", nil, 1) p [ret, src, dst] #=> [:destination_buffer_full, "", "p"] ret = ec.primitive_convert(src, dst="", nil, 1) p [ret, src, dst] #=> [:destination_buffer_full, "", "\x00"] ret = ec.primitive_convert(src, dst="", nil, 1) p [ret, src, dst] #=> [:finished, "", "i"] @overload primitive_convert(source_buffer, destination_buffer) @overload primitive_convert(source_buffer, destination_buffer, destination_byteoffset) @overload primitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize) @overload primitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize, opt);T;#0;$@އ;.F;/o;0;1T;2i,;3i;%@چ;9I" static VALUE econv_primitive_convert(int argc, VALUE *argv, VALUE self) { VALUE input, output, output_byteoffset_v, output_bytesize_v, opt, flags_v; rb_econv_t *ec = check_econv(self); rb_econv_result_t res; const unsigned char *ip, *is; unsigned char *op, *os; long output_byteoffset, output_bytesize; unsigned long output_byteend; int flags; argc = rb_scan_args(argc, argv, "23:", &input, &output, &output_byteoffset_v, &output_bytesize_v, &flags_v, &opt); if (NIL_P(output_byteoffset_v)) output_byteoffset = 0; /* dummy */ else output_byteoffset = NUM2LONG(output_byteoffset_v); if (NIL_P(output_bytesize_v)) output_bytesize = 0; /* dummy */ else output_bytesize = NUM2LONG(output_bytesize_v); if (!NIL_P(flags_v)) { if (!NIL_P(opt)) { rb_error_arity(argc + 1, 2, 5); } flags = NUM2INT(rb_to_int(flags_v)); } else if (!NIL_P(opt)) { VALUE v; flags = 0; v = rb_hash_aref(opt, sym_partial_input); if (RTEST(v)) flags |= ECONV_PARTIAL_INPUT; v = rb_hash_aref(opt, sym_after_output); if (RTEST(v)) flags |= ECONV_AFTER_OUTPUT; } else { flags = 0; } StringValue(output); if (!NIL_P(input)) StringValue(input); rb_str_modify(output); if (NIL_P(output_bytesize_v)) { #if USE_RVARGC output_bytesize = rb_str_capacity(output); #else output_bytesize = RSTRING_EMBED_LEN_MAX; #endif if (!NIL_P(input) && output_bytesize < RSTRING_LEN(input)) output_bytesize = RSTRING_LEN(input); } retry: if (NIL_P(output_byteoffset_v)) output_byteoffset = RSTRING_LEN(output); if (output_byteoffset < 0) rb_raise(rb_eArgError, "negative output_byteoffset"); if (RSTRING_LEN(output) < output_byteoffset) rb_raise(rb_eArgError, "output_byteoffset too big"); if (output_bytesize < 0) rb_raise(rb_eArgError, "negative output_bytesize"); output_byteend = (unsigned long)output_byteoffset + (unsigned long)output_bytesize; if (output_byteend < (unsigned long)output_byteoffset || LONG_MAX < output_byteend) rb_raise(rb_eArgError, "output_byteoffset+output_bytesize too big"); if (rb_str_capacity(output) < output_byteend) rb_str_resize(output, output_byteend); if (NIL_P(input)) { ip = is = NULL; } else { ip = (const unsigned char *)RSTRING_PTR(input); is = ip + RSTRING_LEN(input); } op = (unsigned char *)RSTRING_PTR(output) + output_byteoffset; os = op + output_bytesize; res = rb_econv_convert(ec, &ip, is, &op, os, flags); rb_str_set_len(output, op-(unsigned char *)RSTRING_PTR(output)); if (!NIL_P(input)) { rb_str_drop_bytes(input, ip - (unsigned char *)RSTRING_PTR(input)); } if (NIL_P(output_bytesize_v) && res == econv_destination_buffer_full) { if (LONG_MAX / 2 < output_bytesize) rb_raise(rb_eArgError, "too long conversion result"); output_bytesize *= 2; output_byteoffset_v = Qnil; goto retry; } if (ec->destination_encoding) { rb_enc_associate(output, ec->destination_encoding); } return econv_result_to_symbol(res); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Encoding::Converter#convert;T;7[[I"source_string;T0;[[@,i;T;: convert;0;[;{;IC; "Convert source_string and return destination_string. source_string is assumed as a part of source. i.e. :partial_input=>true is specified internally. finish method should be used last. ec = Encoding::Converter.new("utf-8", "euc-jp") puts ec.convert("\u3042").dump #=> "\xA4\xA2" puts ec.finish.dump #=> "" ec = Encoding::Converter.new("euc-jp", "utf-8") puts ec.convert("\xA4").dump #=> "" puts ec.convert("\xA2").dump #=> "\xE3\x81\x82" puts ec.finish.dump #=> "" ec = Encoding::Converter.new("utf-8", "iso-2022-jp") puts ec.convert("\xE3").dump #=> "".force_encoding("ISO-2022-JP") puts ec.convert("\x81").dump #=> "".force_encoding("ISO-2022-JP") puts ec.convert("\x82").dump #=> "\e$B$\"".force_encoding("ISO-2022-JP") puts ec.finish.dump #=> "\e(B".force_encoding("ISO-2022-JP") If a conversion error occur, Encoding::UndefinedConversionError or Encoding::InvalidByteSequenceError is raised. Encoding::Converter#convert doesn't supply methods to recover or restart from these exceptions. When you want to handle these conversion errors, use Encoding::Converter#primitive_convert. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"convert(source_string);T;IC; ";T;[;![;"I";T;#0;$@);.F;Bi;C0;7[[I"source_string;T0;$@);![;"I"Convert source_string and return destination_string. source_string is assumed as a part of source. i.e. :partial_input=>true is specified internally. finish method should be used last. ec = Encoding::Converter.new("utf-8", "euc-jp") puts ec.convert("\u3042").dump #=> "\xA4\xA2" puts ec.finish.dump #=> "" ec = Encoding::Converter.new("euc-jp", "utf-8") puts ec.convert("\xA4").dump #=> "" puts ec.convert("\xA2").dump #=> "\xE3\x81\x82" puts ec.finish.dump #=> "" ec = Encoding::Converter.new("utf-8", "iso-2022-jp") puts ec.convert("\xE3").dump #=> "".force_encoding("ISO-2022-JP") puts ec.convert("\x81").dump #=> "".force_encoding("ISO-2022-JP") puts ec.convert("\x82").dump #=> "\e$B$\"".force_encoding("ISO-2022-JP") puts ec.finish.dump #=> "\e(B".force_encoding("ISO-2022-JP") If a conversion error occur, Encoding::UndefinedConversionError or Encoding::InvalidByteSequenceError is raised. Encoding::Converter#convert doesn't supply methods to recover or restart from these exceptions. When you want to handle these conversion errors, use Encoding::Converter#primitive_convert. @overload convert(source_string);T;#0;$@);.F;/o;0;1T;2i;3i;%@چ;9I"Rstatic VALUE econv_convert(VALUE self, VALUE source_string) { VALUE ret, dst; VALUE av[5]; int ac; rb_econv_t *ec = check_econv(self); StringValue(source_string); dst = rb_str_new(NULL, 0); av[0] = rb_str_dup(source_string); av[1] = dst; av[2] = Qnil; av[3] = Qnil; av[4] = INT2NUM(ECONV_PARTIAL_INPUT); ac = 5; ret = econv_primitive_convert(ac, av, self); if (ret == sym_invalid_byte_sequence || ret == sym_undefined_conversion || ret == sym_incomplete_input) { VALUE exc = make_econv_exception(ec); rb_exc_raise(exc); } if (ret == sym_finished) { rb_raise(rb_eArgError, "converter already finished"); } if (ret != sym_source_buffer_empty) { rb_bug("unexpected result of econv_primitive_convert"); } return dst; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding::Converter#finish;T;7[;[[@,iQ;T;;!;0;[;{;IC; "Finishes the converter. It returns the last part of the converted string. ec = Encoding::Converter.new("utf-8", "iso-2022-jp") p ec.convert("\u3042") #=> "\e$B$\"" p ec.finish #=> "\e(B" ;T;[o;= ;>I" overload;F;?0;;!;@0;:I" finish;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@C;![;"I"@return [String];T;#0;$@C;.F;Bi;C0;7[;$@C;![;"I"Finishes the converter. It returns the last part of the converted string. ec = Encoding::Converter.new("utf-8", "iso-2022-jp") p ec.convert("\u3042") #=> "\e$B$\"" p ec.finish #=> "\e(B" @overload finish @return [String];T;#0;$@C;.F;/o;0;1T;2iF;3iO;%@چ;9I"static VALUE econv_finish(VALUE self) { VALUE ret, dst; VALUE av[5]; int ac; rb_econv_t *ec = check_econv(self); dst = rb_str_new(NULL, 0); av[0] = Qnil; av[1] = dst; av[2] = Qnil; av[3] = Qnil; av[4] = INT2FIX(0); ac = 5; ret = econv_primitive_convert(ac, av, self); if (ret == sym_invalid_byte_sequence || ret == sym_undefined_conversion || ret == sym_incomplete_input) { VALUE exc = make_econv_exception(ec); rb_exc_raise(exc); } if (ret != sym_finished) { rb_bug("unexpected result of econv_primitive_convert"); } return dst; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*Encoding::Converter#primitive_errinfo;T;7[;[[@,i;T;:primitive_errinfo;0;[;{;IC; " primitive_errinfo returns important information regarding the last error as a 5-element array: [result, enc1, enc2, error_bytes, readagain_bytes] result is the last result of primitive_convert. Other elements are only meaningful when result is :invalid_byte_sequence, :incomplete_input or :undefined_conversion. enc1 and enc2 indicate a conversion step as a pair of strings. For example, a converter from EUC-JP to ISO-8859-1 converts a string as follows: EUC-JP -> UTF-8 -> ISO-8859-1. So [enc1, enc2] is either ["EUC-JP", "UTF-8"] or ["UTF-8", "ISO-8859-1"]. error_bytes and readagain_bytes indicate the byte sequences which caused the error. error_bytes is discarded portion. readagain_bytes is buffered portion which is read again on next conversion. Example: # \xff is invalid as EUC-JP. ec = Encoding::Converter.new("EUC-JP", "Shift_JIS") ec.primitive_convert(src="\xff", dst="", nil, 10) p ec.primitive_errinfo #=> [:invalid_byte_sequence, "EUC-JP", "Shift_JIS", "\xFF", ""] # HIRAGANA LETTER A (\xa4\xa2 in EUC-JP) is not representable in ISO-8859-1. # Since this error is occur in UTF-8 to ISO-8859-1 conversion, # error_bytes is HIRAGANA LETTER A in UTF-8 (\xE3\x81\x82). ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") ec.primitive_convert(src="\xa4\xa2", dst="", nil, 10) p ec.primitive_errinfo #=> [:undefined_conversion, "UTF-8", "ISO-8859-1", "\xE3\x81\x82", ""] # partial character is invalid ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") ec.primitive_convert(src="\xa4", dst="", nil, 10) p ec.primitive_errinfo #=> [:incomplete_input, "EUC-JP", "UTF-8", "\xA4", ""] # Encoding::Converter::PARTIAL_INPUT prevents invalid errors by # partial characters. ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") ec.primitive_convert(src="\xa4", dst="", nil, 10, Encoding::Converter::PARTIAL_INPUT) p ec.primitive_errinfo #=> [:source_buffer_empty, nil, nil, nil, nil] # \xd8\x00\x00@ is invalid as UTF-16BE because # no low surrogate after high surrogate (\xd8\x00). # It is detected by 3rd byte (\00) which is part of next character. # So the high surrogate (\xd8\x00) is discarded and # the 3rd byte is read again later. # Since the byte is buffered in ec, it is dropped from src. ec = Encoding::Converter.new("UTF-16BE", "UTF-8") ec.primitive_convert(src="\xd8\x00\x00@", dst="", nil, 10) p ec.primitive_errinfo #=> [:invalid_byte_sequence, "UTF-16BE", "UTF-8", "\xD8\x00", "\x00"] p src #=> "@" # Similar to UTF-16BE, \x00\xd8@\x00 is invalid as UTF-16LE. # The problem is detected by 4th byte. ec = Encoding::Converter.new("UTF-16LE", "UTF-8") ec.primitive_convert(src="\x00\xd8@\x00", dst="", nil, 10) p ec.primitive_errinfo #=> [:invalid_byte_sequence, "UTF-16LE", "UTF-8", "\x00\xD8", "@\x00"] p src #=> "" ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"primitive_errinfo;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@^;![;"I"@return [Array];T;#0;$@^;.F;Bi;C0;7[;$@^;![;"I"E primitive_errinfo returns important information regarding the last error as a 5-element array: [result, enc1, enc2, error_bytes, readagain_bytes] result is the last result of primitive_convert. Other elements are only meaningful when result is :invalid_byte_sequence, :incomplete_input or :undefined_conversion. enc1 and enc2 indicate a conversion step as a pair of strings. For example, a converter from EUC-JP to ISO-8859-1 converts a string as follows: EUC-JP -> UTF-8 -> ISO-8859-1. So [enc1, enc2] is either ["EUC-JP", "UTF-8"] or ["UTF-8", "ISO-8859-1"]. error_bytes and readagain_bytes indicate the byte sequences which caused the error. error_bytes is discarded portion. readagain_bytes is buffered portion which is read again on next conversion. Example: # \xff is invalid as EUC-JP. ec = Encoding::Converter.new("EUC-JP", "Shift_JIS") ec.primitive_convert(src="\xff", dst="", nil, 10) p ec.primitive_errinfo #=> [:invalid_byte_sequence, "EUC-JP", "Shift_JIS", "\xFF", ""] # HIRAGANA LETTER A (\xa4\xa2 in EUC-JP) is not representable in ISO-8859-1. # Since this error is occur in UTF-8 to ISO-8859-1 conversion, # error_bytes is HIRAGANA LETTER A in UTF-8 (\xE3\x81\x82). ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") ec.primitive_convert(src="\xa4\xa2", dst="", nil, 10) p ec.primitive_errinfo #=> [:undefined_conversion, "UTF-8", "ISO-8859-1", "\xE3\x81\x82", ""] # partial character is invalid ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") ec.primitive_convert(src="\xa4", dst="", nil, 10) p ec.primitive_errinfo #=> [:incomplete_input, "EUC-JP", "UTF-8", "\xA4", ""] # Encoding::Converter::PARTIAL_INPUT prevents invalid errors by # partial characters. ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") ec.primitive_convert(src="\xa4", dst="", nil, 10, Encoding::Converter::PARTIAL_INPUT) p ec.primitive_errinfo #=> [:source_buffer_empty, nil, nil, nil, nil] # \xd8\x00\x00@ is invalid as UTF-16BE because # no low surrogate after high surrogate (\xd8\x00). # It is detected by 3rd byte (\00) which is part of next character. # So the high surrogate (\xd8\x00) is discarded and # the 3rd byte is read again later. # Since the byte is buffered in ec, it is dropped from src. ec = Encoding::Converter.new("UTF-16BE", "UTF-8") ec.primitive_convert(src="\xd8\x00\x00@", dst="", nil, 10) p ec.primitive_errinfo #=> [:invalid_byte_sequence, "UTF-16BE", "UTF-8", "\xD8\x00", "\x00"] p src #=> "@" # Similar to UTF-16BE, \x00\xd8@\x00 is invalid as UTF-16LE. # The problem is detected by 4th byte. ec = Encoding::Converter.new("UTF-16LE", "UTF-8") ec.primitive_convert(src="\x00\xd8@\x00", dst="", nil, 10) p ec.primitive_errinfo #=> [:invalid_byte_sequence, "UTF-16LE", "UTF-8", "\x00\xD8", "@\x00"] p src #=> "" @overload primitive_errinfo @return [Array];T;#0;$@^;.F;/o;0;1T;2ir;3i;%@چ;9I":static VALUE econv_primitive_errinfo(VALUE self) { rb_econv_t *ec = check_econv(self); VALUE ary; ary = rb_ary_new2(5); rb_ary_store(ary, 0, econv_result_to_symbol(ec->last_error.result)); rb_ary_store(ary, 4, Qnil); if (ec->last_error.source_encoding) rb_ary_store(ary, 1, rb_str_new2(ec->last_error.source_encoding)); if (ec->last_error.destination_encoding) rb_ary_store(ary, 2, rb_str_new2(ec->last_error.destination_encoding)); if (ec->last_error.error_bytes_start) { rb_ary_store(ary, 3, rb_str_new((const char *)ec->last_error.error_bytes_start, ec->last_error.error_bytes_len)); rb_ary_store(ary, 4, rb_str_new((const char *)ec->last_error.error_bytes_start + ec->last_error.error_bytes_len, ec->last_error.readagain_len)); } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&Encoding::Converter#insert_output;T;7[[I" string;T0;[[@,i;T;:insert_output;0;[;{;IC; "Inserts string into the encoding converter. The string will be converted to the destination encoding and output on later conversions. If the destination encoding is stateful, string is converted according to the state and the state is updated. This method should be used only when a conversion error occurs. ec = Encoding::Converter.new("utf-8", "iso-8859-1") src = "HIRAGANA LETTER A is \u{3042}." dst = "" p ec.primitive_convert(src, dst) #=> :undefined_conversion puts "[#{dst.dump}, #{src.dump}]" #=> ["HIRAGANA LETTER A is ", "."] ec.insert_output("") p ec.primitive_convert(src, dst) #=> :finished puts "[#{dst.dump}, #{src.dump}]" #=> ["HIRAGANA LETTER A is .", ""] ec = Encoding::Converter.new("utf-8", "iso-2022-jp") src = "\u{306F 3041 3068 2661 3002}" # U+2661 is not representable in iso-2022-jp dst = "" p ec.primitive_convert(src, dst) #=> :undefined_conversion puts "[#{dst.dump}, #{src.dump}]" #=> ["\e$B$O$!$H".force_encoding("ISO-2022-JP"), "\xE3\x80\x82"] ec.insert_output "?" # state change required to output "?". p ec.primitive_convert(src, dst) #=> :finished puts "[#{dst.dump}, #{src.dump}]" #=> ["\e$B$O$!$H\e(B?\e$B!#\e(B".force_encoding("ISO-2022-JP"), ""] ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"insert_output(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@y;![;"I"@return [nil];T;#0;$@y;.F;Bi;C0;7[[I" string;T0;$@y;![;"I"Inserts string into the encoding converter. The string will be converted to the destination encoding and output on later conversions. If the destination encoding is stateful, string is converted according to the state and the state is updated. This method should be used only when a conversion error occurs. ec = Encoding::Converter.new("utf-8", "iso-8859-1") src = "HIRAGANA LETTER A is \u{3042}." dst = "" p ec.primitive_convert(src, dst) #=> :undefined_conversion puts "[#{dst.dump}, #{src.dump}]" #=> ["HIRAGANA LETTER A is ", "."] ec.insert_output("") p ec.primitive_convert(src, dst) #=> :finished puts "[#{dst.dump}, #{src.dump}]" #=> ["HIRAGANA LETTER A is .", ""] ec = Encoding::Converter.new("utf-8", "iso-2022-jp") src = "\u{306F 3041 3068 2661 3002}" # U+2661 is not representable in iso-2022-jp dst = "" p ec.primitive_convert(src, dst) #=> :undefined_conversion puts "[#{dst.dump}, #{src.dump}]" #=> ["\e$B$O$!$H".force_encoding("ISO-2022-JP"), "\xE3\x80\x82"] ec.insert_output "?" # state change required to output "?". p ec.primitive_convert(src, dst) #=> :finished puts "[#{dst.dump}, #{src.dump}]" #=> ["\e$B$O$!$H\e(B?\e$B!#\e(B".force_encoding("ISO-2022-JP"), ""] @overload insert_output(string) @return [nil];T;#0;$@y;.F;/o;0;1T;2i;3i;%@چ;9I" static VALUE econv_insert_output(VALUE self, VALUE string) { const char *insert_enc; int ret; rb_econv_t *ec = check_econv(self); StringValue(string); insert_enc = rb_econv_encoding_to_insert_output(ec); string = rb_str_encode(string, rb_enc_from_encoding(rb_enc_find(insert_enc)), 0, Qnil); ret = rb_econv_insert_output(ec, (const unsigned char *)RSTRING_PTR(string), RSTRING_LEN(string), insert_enc); if (ret == -1) { rb_raise(rb_eArgError, "too big string"); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Encoding::Converter#putback;T;7[[@90;[[@,i$;T;: putback;0;[;{;IC; "Put back the bytes which will be converted. The bytes are caused by invalid_byte_sequence error. When invalid_byte_sequence error, some bytes are discarded and some bytes are buffered to be converted later. The latter bytes can be put back. It can be observed by Encoding::InvalidByteSequenceError#readagain_bytes and Encoding::Converter#primitive_errinfo. ec = Encoding::Converter.new("utf-16le", "iso-8859-1") src = "\x00\xd8\x61\x00" dst = "" p ec.primitive_convert(src, dst) #=> :invalid_byte_sequence p ec.primitive_errinfo #=> [:invalid_byte_sequence, "UTF-16LE", "UTF-8", "\x00\xD8", "a\x00"] p ec.putback #=> "a\x00" p ec.putback #=> "" # no more bytes to put back ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" putback;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;; ;@0;:I"putback(max_numbytes);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I"max_numbytes;T0;$@;![;"I"6Put back the bytes which will be converted. The bytes are caused by invalid_byte_sequence error. When invalid_byte_sequence error, some bytes are discarded and some bytes are buffered to be converted later. The latter bytes can be put back. It can be observed by Encoding::InvalidByteSequenceError#readagain_bytes and Encoding::Converter#primitive_errinfo. ec = Encoding::Converter.new("utf-16le", "iso-8859-1") src = "\x00\xd8\x61\x00" dst = "" p ec.primitive_convert(src, dst) #=> :invalid_byte_sequence p ec.primitive_errinfo #=> [:invalid_byte_sequence, "UTF-16LE", "UTF-8", "\x00\xD8", "a\x00"] p ec.putback #=> "a\x00" p ec.putback #=> "" # no more bytes to put back @overload putback @return [String] @overload putback(max_numbytes) @return [String];T;#0;$@;.F;/o;0;1T;2i ;3i#;%@چ;9I"istatic VALUE econv_putback(int argc, VALUE *argv, VALUE self) { rb_econv_t *ec = check_econv(self); int n; int putbackable; VALUE str, max; if (!rb_check_arity(argc, 0, 1) || NIL_P(max = argv[0])) { n = rb_econv_putbackable(ec); } else { n = NUM2INT(max); putbackable = rb_econv_putbackable(ec); if (putbackable < n) n = putbackable; } str = rb_str_new(NULL, n); rb_econv_putback(ec, (unsigned char *)RSTRING_PTR(str), n); if (ec->source_encoding) { rb_enc_associate(str, ec->source_encoding); } return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#Encoding::Converter#last_error;T;7[;[[@,iT;T;:last_error;0;[;{;IC; "Returns an exception object for the last conversion. Returns nil if the last conversion did not produce an error. "error" means that Encoding::InvalidByteSequenceError and Encoding::UndefinedConversionError for Encoding::Converter#convert and :invalid_byte_sequence, :incomplete_input and :undefined_conversion for Encoding::Converter#primitive_convert. ec = Encoding::Converter.new("utf-8", "iso-8859-1") p ec.primitive_convert(src="\xf1abcd", dst="") #=> :invalid_byte_sequence p ec.last_error #=> # p ec.primitive_convert(src, dst, nil, 1) #=> :destination_buffer_full p ec.last_error #=> nil ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"last_error;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Exception;TI"nil;T;$@È;![;"I"@return [Exception, nil];T;#0;$@È;.F;Bi;C0;7[;$@È;![;"I"Returns an exception object for the last conversion. Returns nil if the last conversion did not produce an error. "error" means that Encoding::InvalidByteSequenceError and Encoding::UndefinedConversionError for Encoding::Converter#convert and :invalid_byte_sequence, :incomplete_input and :undefined_conversion for Encoding::Converter#primitive_convert. ec = Encoding::Converter.new("utf-8", "iso-8859-1") p ec.primitive_convert(src="\xf1abcd", dst="") #=> :invalid_byte_sequence p ec.last_error #=> # p ec.primitive_convert(src, dst, nil, 1) #=> :destination_buffer_full p ec.last_error #=> nil @overload last_error @return [Exception, nil];T;#0;$@È;.F;/o;0;1T;2i@;3iR;%@چ;9I"static VALUE econv_last_error(VALUE self) { rb_econv_t *ec = check_econv(self); VALUE exc; exc = make_econv_exception(ec); if (NIL_P(exc)) return Qnil; return exc; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$Encoding::Converter#replacement;T;7[;[[@,il;T;:replacement;0;[;{;IC; "Returns the replacement string. ec = Encoding::Converter.new("euc-jp", "us-ascii") p ec.replacement #=> "?" ec = Encoding::Converter.new("euc-jp", "utf-8") p ec.replacement #=> "\uFFFD" ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"replacement;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@߈;![;"I"@return [String];T;#0;$@߈;.F;Bi;C0;7[;$@߈;![;"I"Returns the replacement string. ec = Encoding::Converter.new("euc-jp", "us-ascii") p ec.replacement #=> "?" ec = Encoding::Converter.new("euc-jp", "utf-8") p ec.replacement #=> "\uFFFD" @overload replacement @return [String];T;#0;$@߈;.F;/o;0;1T;2i`;3ij;%@چ;9I"static VALUE econv_get_replacement(VALUE self) { rb_econv_t *ec = check_econv(self); int ret; rb_encoding *enc; ret = make_replacement(ec); if (ret == -1) { rb_raise(rb_eUndefinedConversionError, "replacement character setup failed"); } enc = rb_enc_find(ec->replacement_enc); return rb_enc_str_new((const char *)ec->replacement_str, (long)ec->replacement_len, enc); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%Encoding::Converter#replacement=;T;7[[I"arg;T0;[[@,i;T;:replacement=;0;[;{;IC; "Sets the replacement string. ec = Encoding::Converter.new("utf-8", "us-ascii", :undef => :replace) ec.replacement = "" p ec.convert("a \u3042 b") #=> "a b" ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"replacement=(string);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;T0;$@;![;"I"Sets the replacement string. ec = Encoding::Converter.new("utf-8", "us-ascii", :undef => :replace) ec.replacement = "" p ec.convert("a \u3042 b") #=> "a b" @overload replacement=(string);T;#0;$@;.F;/o;0;1T;2i|;3i;%@چ;9I",static VALUE econv_set_replacement(VALUE self, VALUE arg) { rb_econv_t *ec = check_econv(self); VALUE string = arg; int ret; rb_encoding *enc; StringValue(string); enc = rb_enc_get(string); ret = rb_econv_set_replacement(ec, (const unsigned char *)RSTRING_PTR(string), RSTRING_LEN(string), rb_enc_name(enc)); if (ret == -1) { /* xxx: rb_eInvalidByteSequenceError? */ rb_raise(rb_eUndefinedConversionError, "replacement character setup failed"); } return arg; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Encoding::Converter#==;T;7[[I" other;T0;[[@,i ;T;;F;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" other;T0;$@;![;"I"- @overload ==(other) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@چ;9I"static VALUE econv_equal(VALUE self, VALUE other) { rb_econv_t *ec1 = check_econv(self); rb_econv_t *ec2; int i; if (!rb_typeddata_is_kind_of(other, &econv_data_type)) { return Qnil; } ec2 = DATA_PTR(other); if (!ec2) return Qfalse; if (ec1->source_encoding_name != ec2->source_encoding_name && strcmp(ec1->source_encoding_name, ec2->source_encoding_name)) return Qfalse; if (ec1->destination_encoding_name != ec2->destination_encoding_name && strcmp(ec1->destination_encoding_name, ec2->destination_encoding_name)) return Qfalse; if (ec1->flags != ec2->flags) return Qfalse; if (ec1->replacement_enc != ec2->replacement_enc && strcmp(ec1->replacement_enc, ec2->replacement_enc)) return Qfalse; if (ec1->replacement_len != ec2->replacement_len) return Qfalse; if (ec1->replacement_str != ec2->replacement_str && memcmp(ec1->replacement_str, ec2->replacement_str, ec2->replacement_len)) return Qfalse; if (ec1->num_trans != ec2->num_trans) return Qfalse; for (i = 0; i < ec1->num_trans; i++) { if (ec1->elems[i].tc->transcoder != ec2->elems[i].tc->transcoder) return Qfalse; } return Qtrue; };T;:I"static VALUE;T;;To;u;[[@,i;F;:INVALID_MASK;;w;;;[;{;IC; "$Mask for invalid byte sequences ;T;[;![;"I"& Mask for invalid byte sequences ;T;#0;$@3;.F;/o;0;1T;2i;3i;%@چ;&I"&Encoding::Converter::INVALID_MASK;T;xI" INT2FIX(ECONV_INVALID_MASK);To;u;[[@,i;F;:INVALID_REPLACE;;w;;;[;{;IC; "#Replace invalid byte sequences ;T;[;![;"I"% Replace invalid byte sequences ;T;#0;$@?;.F;/o;0;1T;2i;3i;%@چ;&I")Encoding::Converter::INVALID_REPLACE;T;xI"#INT2FIX(ECONV_INVALID_REPLACE);To;u;[[@,i;F;:UNDEF_MASK;;w;;;[;{;IC; "kMask for a valid character in the source encoding but no related character(s) in destination encoding. ;T;[;![;"I"m Mask for a valid character in the source encoding but no related character(s) in destination encoding. ;T;#0;$@K;.F;/o;0;1T;2i;3i;%@چ;&I"$Encoding::Converter::UNDEF_MASK;T;xI"INT2FIX(ECONV_UNDEF_MASK);To;u;[[@,i;F;:UNDEF_REPLACE;;w;;;[;{;IC; "KReplace byte sequences that are undefined in the destination encoding. ;T;[;![;"I"M Replace byte sequences that are undefined in the destination encoding. ;T;#0;$@W;.F;/o;0;1T;2i;3i;%@چ;&I"'Encoding::Converter::UNDEF_REPLACE;T;xI"!INT2FIX(ECONV_UNDEF_REPLACE);To;u;[[@,i;F;:UNDEF_HEX_CHARREF;;w;;;[;{;IC; "Replace byte sequences that are undefined in the destination encoding with an XML hexadecimal character reference. This is valid for XML conversion. ;T;[;![;"I" Replace byte sequences that are undefined in the destination encoding with an XML hexadecimal character reference. This is valid for XML conversion. ;T;#0;$@c;.F;/o;0;1T;2i;3i;%@چ;&I"+Encoding::Converter::UNDEF_HEX_CHARREF;T;xI"%INT2FIX(ECONV_UNDEF_HEX_CHARREF);To;u;[[@,i;F;:PARTIAL_INPUT;;w;;;[;{;IC; "`Indicates the source may be part of a larger string. See primitive_convert for an example. ;T;[;![;"I"b Indicates the source may be part of a larger string. See primitive_convert for an example. ;T;#0;$@o;.F;/o;0;1T;2i;3i;%@چ;&I"'Encoding::Converter::PARTIAL_INPUT;T;xI"!INT2FIX(ECONV_PARTIAL_INPUT);To;u;[[@,i;F;:AFTER_OUTPUT;;w;;;[;{;IC; "~Stop converting after some output is complete but before all of the input was consumed. See primitive_convert for an example. ;T;[;![;"I" Stop converting after some output is complete but before all of the input was consumed. See primitive_convert for an example. ;T;#0;$@{;.F;/o;0;1T;2i;3i;%@چ;&I"&Encoding::Converter::AFTER_OUTPUT;T;xI" INT2FIX(ECONV_AFTER_OUTPUT);To;u;[[@,i;F;: UNIVERSAL_NEWLINE_DECORATOR;;w;;;[;{;IC; "/Decorator for converting CRLF and CR to LF ;T;[;![;"I"1 Decorator for converting CRLF and CR to LF ;T;#0;$@;.F;/o;0;1T;2i;3i;%@چ;&I"5Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR;T;xI"/INT2FIX(ECONV_UNIVERSAL_NEWLINE_DECORATOR);To;u;[[@,i;F;:CRLF_NEWLINE_DECORATOR;;w;;;[;{;IC; "(Decorator for converting LF to CRLF ;T;[;![;"I"* Decorator for converting LF to CRLF ;T;#0;$@;.F;/o;0;1T;2i;3i;%@چ;&I"0Encoding::Converter::CRLF_NEWLINE_DECORATOR;T;xI"*INT2FIX(ECONV_CRLF_NEWLINE_DECORATOR);To;u;[[@,i;F;:CR_NEWLINE_DECORATOR;;w;;;[;{;IC; "&Decorator for converting LF to CR ;T;[;![;"I"( Decorator for converting LF to CR ;T;#0;$@;.F;/o;0;1T;2i;3i;%@چ;&I".Encoding::Converter::CR_NEWLINE_DECORATOR;T;xI"(INT2FIX(ECONV_CR_NEWLINE_DECORATOR);To;u;[[@,i;F;:XML_TEXT_DECORATOR;;w;;;[;{;IC; "Escape as XML CharData ;T;[;![;"I" Escape as XML CharData ;T;#0;$@;.F;/o;0;1T;2i;3i;%@چ;&I",Encoding::Converter::XML_TEXT_DECORATOR;T;xI"&INT2FIX(ECONV_XML_TEXT_DECORATOR);To;u;[[@,i;F;:XML_ATTR_CONTENT_DECORATOR;;w;;;[;{;IC; "Escape as XML AttValue ;T;[;![;"I" Escape as XML AttValue ;T;#0;$@;.F;/o;0;1T;2i;3i;%@چ;&I"4Encoding::Converter::XML_ATTR_CONTENT_DECORATOR;T;xI".INT2FIX(ECONV_XML_ATTR_CONTENT_DECORATOR);To;u;[[@,i;F;:XML_ATTR_QUOTE_DECORATOR;;w;;;[;{;IC; "Escape as XML AttValue ;T;[;![;"I" Escape as XML AttValue ;T;#0;$@É;.F;/o;0;1T;2i;3i;%@چ;&I"2Encoding::Converter::XML_ATTR_QUOTE_DECORATOR;T;xI",INT2FIX(ECONV_XML_ATTR_QUOTE_DECORATOR);T; @چ; IC;[; @چ; IC;[; @چ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@,io [@,i;T;:Converter;;;;;[;{;IC; "Encoding conversion class.;T;[;![;"I"! Encoding conversion class. ;T;#0;$@چ;.F;/o;0;1T;2io ;3iq ;Bi;%o;( ;)0;*0;+0;; ;%@;-@҄;0;&I"Encoding::Converter;T;'@o; ;IC;[ o;4;5F;6;;;;&I"I" overload;F;?0;; ;@0;:I"source_encoding_name;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"fReturns the source encoding name as a string. @overload source_encoding_name @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"sstatic VALUE ecerr_source_encoding_name(VALUE self) { return rb_attr_get(self, id_source_encoding_name); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"AEncoding::UndefinedConversionError#destination_encoding_name;F;7[;[[@,i;T;:destination_encoding_name;0;[;{;IC; "7Returns the destination encoding name as a string. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"destination_encoding_name;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"pReturns the destination encoding name as a string. @overload destination_encoding_name @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"}static VALUE ecerr_destination_encoding_name(VALUE self) { return rb_attr_get(self, id_destination_encoding_name); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"7Encoding::UndefinedConversionError#source_encoding;F;7[;[[@,i;T;; ;0;[;{;IC; "oReturns the source encoding as an encoding object. Note that the result may not be equal to the source encoding of the encoding converter if the conversion has multiple steps. ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP") # ISO-8859-1 -> UTF-8 -> EUC-JP begin ec.convert("\xa0") # NO-BREAK SPACE, which is available in UTF-8 but not in EUC-JP. rescue Encoding::UndefinedConversionError p $!.source_encoding #=> # p $!.destination_encoding #=> # p $!.source_encoding_name #=> "UTF-8" p $!.destination_encoding_name #=> "EUC-JP" end ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"source_encoding;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Encoding;T;$@;![;"I"@return [Encoding];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the source encoding as an encoding object. Note that the result may not be equal to the source encoding of the encoding converter if the conversion has multiple steps. ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP") # ISO-8859-1 -> UTF-8 -> EUC-JP begin ec.convert("\xa0") # NO-BREAK SPACE, which is available in UTF-8 but not in EUC-JP. rescue Encoding::UndefinedConversionError p $!.source_encoding #=> # p $!.destination_encoding #=> # p $!.source_encoding_name #=> "UTF-8" p $!.destination_encoding_name #=> "EUC-JP" end @overload source_encoding @return [Encoding];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"istatic VALUE ecerr_source_encoding(VALUE self) { return rb_attr_get(self, id_source_encoding); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"I" overload;F;?0;; ;@0;:I"destination_encoding;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@5;![;"I"@return [String];T;#0;$@5;.F;Bi;C0;7[;$@5;![;"I"pReturns the destination encoding as an encoding object. @overload destination_encoding @return [String];T;#0;$@5;.F;/o;0;1T;2i;3i;%@;9I"sstatic VALUE ecerr_destination_encoding(VALUE self) { return rb_attr_get(self, id_destination_encoding); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"2Encoding::UndefinedConversionError#error_char;F;7[;[[@,i;T;:error_char;0;[;{;IC; "3Returns the one-character string which cause Encoding::UndefinedConversionError. ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP") begin ec.convert("\xa0") rescue Encoding::UndefinedConversionError puts $!.error_char.dump #=> "\xC2\xA0" p $!.error_char.encoding #=> # end ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"error_char;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@P;![;"I"@return [String];T;#0;$@P;.F;Bi;C0;7[;$@P;![;"I"^Returns the one-character string which cause Encoding::UndefinedConversionError. ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP") begin ec.convert("\xa0") rescue Encoding::UndefinedConversionError puts $!.error_char.dump #=> "\xC2\xA0" p $!.error_char.encoding #=> # end @overload error_char @return [String];T;#0;$@P;.F;/o;0;1T;2i;3i;%@;9I"_static VALUE ecerr_error_char(VALUE self) { return rb_attr_get(self, id_error_char); };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@,iA[@,i;T;:UndefinedConversionError;;;;;[;{;IC; "NRaised by Encoding and String methods when a transcoding operation fails.;T;[;![;"I"P Raised by Encoding and String methods when a transcoding operation fails. ;T;#0;$@;.F;/o;0;1T;2iA;3iD;Bi;%o;( ;)0;*0;+0;; ;%@;-@҄;0;&I"'Encoding::UndefinedConversionError;F;'@po; ;IC;[ o;4;5F;6;;;;&I"I" overload;F;?0;; ;@0;:I"source_encoding_name;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2i;3i;%@~;9I"sstatic VALUE ecerr_source_encoding_name(VALUE self) { return rb_attr_get(self, id_source_encoding_name); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"AEncoding::InvalidByteSequenceError#destination_encoding_name;F;7[;[[@,i;T;; ;0;[;{;IC; "7Returns the destination encoding name as a string. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"destination_encoding_name;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2i;3i;%@~;9I"}static VALUE ecerr_destination_encoding_name(VALUE self) { return rb_attr_get(self, id_destination_encoding_name); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"7Encoding::InvalidByteSequenceError#source_encoding;F;7[;[[@,i;T;; ;0;[;{;IC; "oReturns the source encoding as an encoding object. Note that the result may not be equal to the source encoding of the encoding converter if the conversion has multiple steps. ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP") # ISO-8859-1 -> UTF-8 -> EUC-JP begin ec.convert("\xa0") # NO-BREAK SPACE, which is available in UTF-8 but not in EUC-JP. rescue Encoding::UndefinedConversionError p $!.source_encoding #=> # p $!.destination_encoding #=> # p $!.source_encoding_name #=> "UTF-8" p $!.destination_encoding_name #=> "EUC-JP" end ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"source_encoding;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Encoding;T;$@;![;"I"@return [Encoding];T;#0;$@;.F;Bi;C0;7[;$@;![;"@1;#0;$@;.F;/o;0;1T;2i;3i;%@~;9I"istatic VALUE ecerr_source_encoding(VALUE self) { return rb_attr_get(self, id_source_encoding); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"I" overload;F;?0;; ;@0;:I"destination_encoding;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@Ί;![;"I"@return [String];T;#0;$@Ί;.F;Bi;C0;7[;$@Ί;![;"@L;#0;$@Ί;.F;/o;0;1T;2i;3i;%@~;9I"sstatic VALUE ecerr_destination_encoding(VALUE self) { return rb_attr_get(self, id_destination_encoding); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"3Encoding::InvalidByteSequenceError#error_bytes;F;7[;[[@,i;T;:error_bytes;0;[;{;IC; "Returns the discarded bytes when Encoding::InvalidByteSequenceError occurs. ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") begin ec.convert("abc\xA1\xFFdef") rescue Encoding::InvalidByteSequenceError p $! #=> # puts $!.error_bytes.dump #=> "\xA1" puts $!.readagain_bytes.dump #=> "\xFF" end ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"error_bytes;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the discarded bytes when Encoding::InvalidByteSequenceError occurs. ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") begin ec.convert("abc\xA1\xFFdef") rescue Encoding::InvalidByteSequenceError p $! #=> # puts $!.error_bytes.dump #=> "\xA1" puts $!.readagain_bytes.dump #=> "\xFF" end @overload error_bytes @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@~;9I"astatic VALUE ecerr_error_bytes(VALUE self) { return rb_attr_get(self, id_error_bytes); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"7Encoding::InvalidByteSequenceError#readagain_bytes;F;7[;[[@,i;T;:readagain_bytes;0;[;{;IC; "WReturns the bytes to be read again when Encoding::InvalidByteSequenceError occurs. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"readagain_bytes;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the bytes to be read again when Encoding::InvalidByteSequenceError occurs. @overload readagain_bytes @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@~;9I"istatic VALUE ecerr_readagain_bytes(VALUE self) { return rb_attr_get(self, id_readagain_bytes); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"9Encoding::InvalidByteSequenceError#incomplete_input?;F;7[;[[@,i;;T;:incomplete_input?;0;[;{;IC; "6Returns true if the invalid byte sequence error is caused by premature end of string. ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") begin ec.convert("abc\xA1z") rescue Encoding::InvalidByteSequenceError p $! #=> # p $!.incomplete_input? #=> false end begin ec.convert("abc\xA1") ec.finish rescue Encoding::InvalidByteSequenceError p $! #=> # p $!.incomplete_input? #=> true end;T;[o;= ;>I" overload;F;?0;; ;@0;:I"incomplete_input?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"hReturns true if the invalid byte sequence error is caused by premature end of string. ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") begin ec.convert("abc\xA1z") rescue Encoding::InvalidByteSequenceError p $! #=> # p $!.incomplete_input? #=> false end begin ec.convert("abc\xA1") ec.finish rescue Encoding::InvalidByteSequenceError p $! #=> # p $!.incomplete_input? #=> true end @overload incomplete_input? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i#;3i9;Bi;%@~;9I"kstatic VALUE ecerr_incomplete_input(VALUE self) { return rb_attr_get(self, id_incomplete_input); };T;:I"static VALUE;T;;T; @~; IC;[; @~; IC;[; @~; IC;{;IC;{;T;IC;{;T;T;{;[;[[@,iH[@,i;T;:InvalidByteSequenceError;;;;;[;{;IC; "Raised by Encoding and String methods when the string being transcoded contains a byte invalid for the either the source or target encoding.;T;[;![;"I" Raised by Encoding and String methods when the string being transcoded contains a byte invalid for the either the source or target encoding. ;T;#0;$@~;.F;/o;0;1T;2iH;3iL;Bi;%o;( ;)0;*0;+0;; ;%@;-@҄;0;&I"'Encoding::InvalidByteSequenceError;F;'@po; ;IC;[; @L; IC;[; @L; IC;[; @L; IC;{;IC;{;T;IC;{;T;T;{;[;[[@,iP[@,i;T;:ConverterNotFoundError;;;;;[;{;IC; "dRaised by transcoding methods when a named encoding does not correspond with a known converter. ;T;[;![;"I"f Raised by transcoding methods when a named encoding does not correspond with a known converter. ;T;#0;$@L;.F;/o;0;1T;2iP;3iS;%o;( ;)0;*0;+0;; ;%@;-@҄;0;&I"%Encoding::ConverterNotFoundError;F;'@p; @҄; IC;[; @҄; IC;[; @҄; IC;{;IC;{;T;IC;{;T;T;{;[;[[@pCia;F;; ;;;;;[;{;IC; "qAn Encoding instance represents a character encoding usable in Ruby. It is defined as a constant under the Encoding namespace. It has a name and optionally, aliases: Encoding::ISO_8859_1.name #=> "ISO-8859-1" Encoding::ISO_8859_1.names #=> ["ISO-8859-1", "ISO8859-1"] Ruby methods dealing with encodings return or accept Encoding instances as arguments (when a method accepts an Encoding instance as an argument, it can be passed an Encoding name or alias instead). "some string".encoding #=> # string = "some string".encode(Encoding::ISO_8859_1) #=> "some string" string.encoding #=> # "some string".encode "ISO-8859-1" #=> "some string" Encoding::ASCII_8BIT is a special encoding that is usually used for a byte string, not a character string. But as the name insists, its characters in the range of ASCII are considered as ASCII characters. This is useful when you use ASCII-8BIT characters with other ASCII compatible characters. == Changing an encoding The associated Encoding of a String can be changed in two different ways. First, it is possible to set the Encoding of a string to a new Encoding without changing the internal byte representation of the string, with String#force_encoding. This is how you can tell Ruby the correct encoding of a string. string #=> "R\xC3\xA9sum\xC3\xA9" string.encoding #=> # string.force_encoding(Encoding::UTF_8) #=> "R\u00E9sum\u00E9" Second, it is possible to transcode a string, i.e. translate its internal byte representation to another encoding. Its associated encoding is also set to the other encoding. See String#encode for the various forms of transcoding, and the Encoding::Converter class for additional control over the transcoding process. string #=> "R\u00E9sum\u00E9" string.encoding #=> # string = string.encode!(Encoding::ISO_8859_1) #=> "R\xE9sum\xE9" string.encoding #=> # == Script encoding All Ruby script code has an associated Encoding which any String literal created in the source code will be associated to. The default script encoding is Encoding::UTF_8 after v2.0, but it can be changed by a magic comment on the first line of the source code file (or second line, if there is a shebang line on the first). The comment must contain the word coding or encoding, followed by a colon, space and the Encoding name or alias: # encoding: UTF-8 "some string".encoding #=> # The __ENCODING__ keyword returns the script encoding of the file which the keyword is written: # encoding: ISO-8859-1 __ENCODING__ #=> # ruby -K will change the default locale encoding, but this is not recommended. Ruby source files should declare its script encoding by a magic comment even when they only depend on US-ASCII strings or regular expressions. == Locale encoding The default encoding of the environment. Usually derived from locale. see Encoding.locale_charmap, Encoding.find('locale') == Filesystem encoding The default encoding of strings from the filesystem of the environment. This is used for strings of file names or paths. see Encoding.find('filesystem') == External encoding Each IO object has an external encoding which indicates the encoding that Ruby will use to read its data. By default Ruby sets the external encoding of an IO object to the default external encoding. The default external encoding is set by locale encoding or the interpreter -E option. Encoding.default_external returns the current value of the external encoding. ENV["LANG"] #=> "UTF-8" Encoding.default_external #=> # $ ruby -E ISO-8859-1 -e "p Encoding.default_external" # $ LANG=C ruby -e 'p Encoding.default_external' # The default external encoding may also be set through Encoding.default_external=, but you should not do this as strings created before and after the change will have inconsistent encodings. Instead use ruby -E to invoke ruby with the correct external encoding. When you know that the actual encoding of the data of an IO object is not the default external encoding, you can reset its external encoding with IO#set_encoding or set it at IO object creation (see IO.new options). == Internal encoding To process the data of an IO object which has an encoding different from its external encoding, you can set its internal encoding. Ruby will use this internal encoding to transcode the data when it is read from the IO object. Conversely, when data is written to the IO object it is transcoded from the internal encoding to the external encoding of the IO object. The internal encoding of an IO object can be set with IO#set_encoding or at IO object creation (see IO.new options). The internal encoding is optional and when not set, the Ruby default internal encoding is used. If not explicitly set this default internal encoding is +nil+ meaning that by default, no transcoding occurs. The default internal encoding can be set with the interpreter option -E. Encoding.default_internal returns the current internal encoding. $ ruby -e 'p Encoding.default_internal' nil $ ruby -E ISO-8859-1:UTF-8 -e "p [Encoding.default_external, \ Encoding.default_internal]" [#, #] The default internal encoding may also be set through Encoding.default_internal=, but you should not do this as strings created before and after the change will have inconsistent encodings. Instead use ruby -E to invoke ruby with the correct internal encoding. == IO encoding example In the following example a UTF-8 encoded string "R\u00E9sum\u00E9" is transcoded for output to ISO-8859-1 encoding, then read back in and transcoded to UTF-8: string = "R\u00E9sum\u00E9" open("transcoded.txt", "w:ISO-8859-1") do |io| io.write(string) end puts "raw text:" p File.binread("transcoded.txt") puts open("transcoded.txt", "r:ISO-8859-1:UTF-8") do |io| puts "transcoded text:" p io.read end While writing the file, the internal encoding is not specified as it is only necessary for reading. While reading the file both the internal and external encoding must be specified to obtain the correct result. $ ruby t.rb raw text: "R\xE9sum\xE9" transcoded text: "R\u00E9sum\u00E9";T;[;![;"I"sAn Encoding instance represents a character encoding usable in Ruby. It is defined as a constant under the Encoding namespace. It has a name and optionally, aliases: Encoding::ISO_8859_1.name #=> "ISO-8859-1" Encoding::ISO_8859_1.names #=> ["ISO-8859-1", "ISO8859-1"] Ruby methods dealing with encodings return or accept Encoding instances as arguments (when a method accepts an Encoding instance as an argument, it can be passed an Encoding name or alias instead). "some string".encoding #=> # string = "some string".encode(Encoding::ISO_8859_1) #=> "some string" string.encoding #=> # "some string".encode "ISO-8859-1" #=> "some string" Encoding::ASCII_8BIT is a special encoding that is usually used for a byte string, not a character string. But as the name insists, its characters in the range of ASCII are considered as ASCII characters. This is useful when you use ASCII-8BIT characters with other ASCII compatible characters. == Changing an encoding The associated Encoding of a String can be changed in two different ways. First, it is possible to set the Encoding of a string to a new Encoding without changing the internal byte representation of the string, with String#force_encoding. This is how you can tell Ruby the correct encoding of a string. string #=> "R\xC3\xA9sum\xC3\xA9" string.encoding #=> # string.force_encoding(Encoding::UTF_8) #=> "R\u00E9sum\u00E9" Second, it is possible to transcode a string, i.e. translate its internal byte representation to another encoding. Its associated encoding is also set to the other encoding. See String#encode for the various forms of transcoding, and the Encoding::Converter class for additional control over the transcoding process. string #=> "R\u00E9sum\u00E9" string.encoding #=> # string = string.encode!(Encoding::ISO_8859_1) #=> "R\xE9sum\xE9" string.encoding #=> # == Script encoding All Ruby script code has an associated Encoding which any String literal created in the source code will be associated to. The default script encoding is Encoding::UTF_8 after v2.0, but it can be changed by a magic comment on the first line of the source code file (or second line, if there is a shebang line on the first). The comment must contain the word coding or encoding, followed by a colon, space and the Encoding name or alias: # encoding: UTF-8 "some string".encoding #=> # The __ENCODING__ keyword returns the script encoding of the file which the keyword is written: # encoding: ISO-8859-1 __ENCODING__ #=> # ruby -K will change the default locale encoding, but this is not recommended. Ruby source files should declare its script encoding by a magic comment even when they only depend on US-ASCII strings or regular expressions. == Locale encoding The default encoding of the environment. Usually derived from locale. see Encoding.locale_charmap, Encoding.find('locale') == Filesystem encoding The default encoding of strings from the filesystem of the environment. This is used for strings of file names or paths. see Encoding.find('filesystem') == External encoding Each IO object has an external encoding which indicates the encoding that Ruby will use to read its data. By default Ruby sets the external encoding of an IO object to the default external encoding. The default external encoding is set by locale encoding or the interpreter -E option. Encoding.default_external returns the current value of the external encoding. ENV["LANG"] #=> "UTF-8" Encoding.default_external #=> # $ ruby -E ISO-8859-1 -e "p Encoding.default_external" # $ LANG=C ruby -e 'p Encoding.default_external' # The default external encoding may also be set through Encoding.default_external=, but you should not do this as strings created before and after the change will have inconsistent encodings. Instead use ruby -E to invoke ruby with the correct external encoding. When you know that the actual encoding of the data of an IO object is not the default external encoding, you can reset its external encoding with IO#set_encoding or set it at IO object creation (see IO.new options). == Internal encoding To process the data of an IO object which has an encoding different from its external encoding, you can set its internal encoding. Ruby will use this internal encoding to transcode the data when it is read from the IO object. Conversely, when data is written to the IO object it is transcoded from the internal encoding to the external encoding of the IO object. The internal encoding of an IO object can be set with IO#set_encoding or at IO object creation (see IO.new options). The internal encoding is optional and when not set, the Ruby default internal encoding is used. If not explicitly set this default internal encoding is +nil+ meaning that by default, no transcoding occurs. The default internal encoding can be set with the interpreter option -E. Encoding.default_internal returns the current internal encoding. $ ruby -e 'p Encoding.default_internal' nil $ ruby -E ISO-8859-1:UTF-8 -e "p [Encoding.default_external, \ Encoding.default_internal]" [#, #] The default internal encoding may also be set through Encoding.default_internal=, but you should not do this as strings created before and after the change will have inconsistent encodings. Instead use ruby -E to invoke ruby with the correct internal encoding. == IO encoding example In the following example a UTF-8 encoded string "R\u00E9sum\u00E9" is transcoded for output to ISO-8859-1 encoding, then read back in and transcoded to UTF-8: string = "R\u00E9sum\u00E9" open("transcoded.txt", "w:ISO-8859-1") do |io| io.write(string) end puts "raw text:" p File.binread("transcoded.txt") puts open("transcoded.txt", "r:ISO-8859-1:UTF-8") do |io| puts "transcoded text:" p io.read end While writing the file, the internal encoding is not specified as it is only necessary for reading. While reading the file both the internal and external encoding must be specified to obtain the correct result. $ ruby t.rb raw text: "R\xE9sum\xE9" transcoded text: "R\u00E9sum\u00E9" ;T;#0;$@҄;.F;/o;0;1T;2i;3iX;Bi;%@;&I" Encoding;F;'@@Go; ;IC;[; @r; IC;[; @r; IC;[; @r; IC;{;IC;{;T;IC;{;T;T;{;[;[[@\"i [@\"i8;T;:ClosedQueueError;;;;;[;{;IC; "The exception class which will be raised when pushing into a closed Queue. See Thread::Queue#close and Thread::SizedQueue#close. ;T;[;![;"I" The exception class which will be raised when pushing into a closed Queue. See Thread::Queue#close and Thread::SizedQueue#close. ;T;#0;$@r;.F;/o;0;1T;2i ;3i;%@;&I"ClosedQueueError;F;'@^ko; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i;F;:TracePoint;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"TracePoint;F;'@o; ;IC;[o;4;5F;6;;;;&I"Continuation#call;F;7[[@90;[[@(i;T;;;0;[;{;IC; "Invokes the continuation. The program continues from the end of the #callcc block. If no arguments are given, the original #callcc returns +nil+. If one argument is given, #callcc returns it. Otherwise, an array containing args is returned. callcc {|cont| cont.call } #=> nil callcc {|cont| cont.call 1 } #=> 1 callcc {|cont| cont.call 1, 2, 3 } #=> [1, 2, 3] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"call(args, ...);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" args;T0[I"...;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"[](args, ...);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" args;T0[I"...;T0;$@;![;"I"Invokes the continuation. The program continues from the end of the #callcc block. If no arguments are given, the original #callcc returns +nil+. If one argument is given, #callcc returns it. Otherwise, an array containing args is returned. callcc {|cont| cont.call } #=> nil callcc {|cont| cont.call 1 } #=> 1 callcc {|cont| cont.call 1, 2, 3 } #=> [1, 2, 3] @overload call(args, ...) @overload [](args, ...);T;#0;$@;.F;/o;0;1T;2i|;3i;%@;9I"static VALUE rb_cont_call(int argc, VALUE *argv, VALUE contval) { rb_context_t *cont = cont_ptr(contval); rb_thread_t *th = GET_THREAD(); if (cont_thread_value(cont) != th->self) { rb_raise(rb_eRuntimeError, "continuation called across threads"); } if (cont->saved_ec.fiber_ptr) { if (th->ec->fiber_ptr != cont->saved_ec.fiber_ptr) { rb_raise(rb_eRuntimeError, "continuation called across fiber"); } } rollback_ensure_stack(contval, th->ec->ensure_list, cont->ensure_array); cont->argc = argc; cont->value = make_passing_arg(argc, argv); cont_restore_0(cont, &contval); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Continuation#[];F;7[[@90;[[@(i;T;;;0;[;{;IC; "Invokes the continuation. The program continues from the end of the #callcc block. If no arguments are given, the original #callcc returns +nil+. If one argument is given, #callcc returns it. Otherwise, an array containing args is returned. callcc {|cont| cont.call } #=> nil callcc {|cont| cont.call 1 } #=> 1 callcc {|cont| cont.call 1, 2, 3 } #=> [1, 2, 3] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"call(args, ...);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" args;T0[I"...;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"[](args, ...);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" args;T0[I"...;T0;$@;![;"@;#0;$@;.F;/o;0;1T;2i|;3i;%@;9I"static VALUE rb_cont_call(int argc, VALUE *argv, VALUE contval) { rb_context_t *cont = cont_ptr(contval); rb_thread_t *th = GET_THREAD(); if (cont_thread_value(cont) != th->self) { rb_raise(rb_eRuntimeError, "continuation called across threads"); } if (cont->saved_ec.fiber_ptr) { if (th->ec->fiber_ptr != cont->saved_ec.fiber_ptr) { rb_raise(rb_eRuntimeError, "continuation called across fiber"); } } rollback_ensure_stack(contval, th->ec->ensure_list, cont->ensure_array); cont->argc = argc; cont->value = make_passing_arg(argc, argv); cont_restore_0(cont, &contval); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@(i[@(i ;T;:Continuation;;;;;[;{;IC; ";Continuation objects are generated by Kernel#callcc, after having +require+d continuation. They hold a return address and execution context, allowing a nonlocal return to the end of the #callcc block from anywhere within a program. Continuations are somewhat analogous to a structured version of C's setjmp/longjmp (although they contain more state, so you might consider them closer to threads). For instance: require "continuation" arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ] callcc{|cc| $cc = cc} puts(message = arr.shift) $cc.call unless message =~ /Max/ produces: Freddie Herbie Ron Max Also you can call callcc in other methods: require "continuation" def g arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ] cc = callcc { |cc| cc } puts arr.shift return cc, arr.size end def f c, size = g c.call(c) if size > 1 end f This (somewhat contrived) example allows the inner loop to abandon processing early: require "continuation" callcc {|cont| for i in 0..4 print "#{i}: " for j in i*5...(i+1)*5 cont.call() if j == 17 printf "%3d", j end end } puts produces: 0: 0 1 2 3 4 1: 5 6 7 8 9 2: 10 11 12 13 14 3: 15 16;T;[;![;"I"= Continuation objects are generated by Kernel#callcc, after having +require+d continuation. They hold a return address and execution context, allowing a nonlocal return to the end of the #callcc block from anywhere within a program. Continuations are somewhat analogous to a structured version of C's setjmp/longjmp (although they contain more state, so you might consider them closer to threads). For instance: require "continuation" arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ] callcc{|cc| $cc = cc} puts(message = arr.shift) $cc.call unless message =~ /Max/ produces: Freddie Herbie Ron Max Also you can call callcc in other methods: require "continuation" def g arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ] cc = callcc { |cc| cc } puts arr.shift return cc, arr.size end def f c, size = g c.call(c) if size > 1 end f This (somewhat contrived) example allows the inner loop to abandon processing early: require "continuation" callcc {|cont| for i in 0..4 print "#{i}: " for j in i*5...(i+1)*5 cont.call() if j == 17 printf "%3d", j end end } puts produces: 0: 0 1 2 3 4 1: 5 6 7 8 9 2: 10 11 12 13 14 3: 15 16 ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;&I"Continuation;F;'@o; ;IC;[o; ;IC;[o;4;5F;6;;;;&I"$Fiber::SchedulerInterface#close;F;7[;[[@(i ;T;;;0;[;{;IC; "Called when the current thread exits. The scheduler is expected to implement this method in order to allow all waiting fibers to finalize their execution. The suggested pattern is to implement the main event loop in the #close method. ;T;[;![;"I" Called when the current thread exits. The scheduler is expected to implement this method in order to allow all waiting fibers to finalize their execution. The suggested pattern is to implement the main event loop in the #close method. ;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"Dstatic VALUE rb_fiber_scheduler_interface_close(VALUE self) { };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+Fiber::SchedulerInterface#process_wait;F;7[;[[@(i ;T;:process_wait;0;[;{;IC; "Invoked by Process::Status.wait in order to wait for a specified process. See that method description for arguments description. Suggested minimal implementation: Thread.new do Process::Status.wait(pid, flags) end.value This hook is optional: if it is not present in the current scheduler, Process::Status.wait will behave as a blocking method. Expected to return a Process::Status instance. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"process_wait(pid, flags);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I"pid;T0[I" flags;T0;$@ ;![;"I"Invoked by Process::Status.wait in order to wait for a specified process. See that method description for arguments description. Suggested minimal implementation: Thread.new do Process::Status.wait(pid, flags) end.value This hook is optional: if it is not present in the current scheduler, Process::Status.wait will behave as a blocking method. Expected to return a Process::Status instance. @overload process_wait(pid, flags);T;#0;$@ ;.F;/o;0;1T;2i ;3i ;%@;9I"Kstatic VALUE rb_fiber_scheduler_interface_process_wait(VALUE self) { };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&Fiber::SchedulerInterface#io_wait;F;7[;[[@(i ;T;;;0;[;{;IC; "HInvoked by IO#wait, IO#wait_readable, IO#wait_writable to ask whether the specified descriptor is ready for specified events within the specified +timeout+. +events+ is a bit mask of IO::READABLE, IO::WRITABLE, and IO::PRIORITY. Suggested implementation should register which Fiber is waiting for which resources and immediately calling Fiber.yield to pass control to other fibers. Then, in the #close method, the scheduler might dispatch all the I/O resources to fibers waiting for it. Expected to return the subset of events that are ready immediately. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"!io_wait(io, events, timeout);T;IC; ";T;[;![;"I";T;#0;$@$;.F;Bi;C0;7[[I"io;T0[I" events;T0[I" timeout;T0;$@$;![;"I"rInvoked by IO#wait, IO#wait_readable, IO#wait_writable to ask whether the specified descriptor is ready for specified events within the specified +timeout+. +events+ is a bit mask of IO::READABLE, IO::WRITABLE, and IO::PRIORITY. Suggested implementation should register which Fiber is waiting for which resources and immediately calling Fiber.yield to pass control to other fibers. Then, in the #close method, the scheduler might dispatch all the I/O resources to fibers waiting for it. Expected to return the subset of events that are ready immediately. @overload io_wait(io, events, timeout);T;#0;$@$;.F;/o;0;1T;2i ;3i ;%@;9I"Fstatic VALUE rb_fiber_scheduler_interface_io_wait(VALUE self) { };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&Fiber::SchedulerInterface#io_read;F;7[;[[@(i ;T;: io_read;0;[;{;IC; "Invoked by IO#read to read +length+ bytes from +io+ into a specified +buffer+ (see IO::Buffer). The +length+ argument is the "minimum length to be read". If the IO buffer size is 8KiB, but the +length+ is +1024+ (1KiB), up to 8KiB might be read, but at least 1KiB will be. Generally, the only case where less data than +length+ will be read is if there is an error reading the data. Specifying a +length+ of 0 is valid and means try reading at least once and return any available data. Suggested implementation should try to read from +io+ in a non-blocking manner and call #io_wait if the +io+ is not ready (which will yield control to other fibers). See IO::Buffer for an interface available to return data. Expected to return number of bytes read, or, in case of an error, -errno (negated number corresponding to system's error code). The method should be considered _experimental_. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" io_read(io, buffer, length);T;IC; ";T;[;![;"I";T;#0;$@@;.F;Bi;C0;7[[I"io;T0[I" buffer;T0[I" length;T0;$@@;![;"I"Invoked by IO#read to read +length+ bytes from +io+ into a specified +buffer+ (see IO::Buffer). The +length+ argument is the "minimum length to be read". If the IO buffer size is 8KiB, but the +length+ is +1024+ (1KiB), up to 8KiB might be read, but at least 1KiB will be. Generally, the only case where less data than +length+ will be read is if there is an error reading the data. Specifying a +length+ of 0 is valid and means try reading at least once and return any available data. Suggested implementation should try to read from +io+ in a non-blocking manner and call #io_wait if the +io+ is not ready (which will yield control to other fibers). See IO::Buffer for an interface available to return data. Expected to return number of bytes read, or, in case of an error, -errno (negated number corresponding to system's error code). The method should be considered _experimental_. @overload io_read(io, buffer, length);T;#0;$@@;.F;/o;0;1T;2i ;3i ;%@;9I"Fstatic VALUE rb_fiber_scheduler_interface_io_read(VALUE self) { };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'Fiber::SchedulerInterface#io_write;F;7[;[[@(i ;T;: io_write;0;[;{;IC; "Invoked by IO#write to write +length+ bytes to +io+ from from a specified +buffer+ (see IO::Buffer). The +length+ argument is the "(minimum) length to be written". If the IO buffer size is 8KiB, but the +length+ specified is 1024 (1KiB), at most 8KiB will be written, but at least 1KiB will be. Generally, the only case where less data than +length+ will be written is if there is an error writing the data. Specifying a +length+ of 0 is valid and means try writing at least once, as much data as possible. Suggested implementation should try to write to +io+ in a non-blocking manner and call #io_wait if the +io+ is not ready (which will yield control to other fibers). See IO::Buffer for an interface available to get data from buffer efficiently. Expected to return number of bytes written, or, in case of an error, -errno (negated number corresponding to system's error code). The method should be considered _experimental_. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"!io_write(io, buffer, length);T;IC; ";T;[;![;"I";T;#0;$@\;.F;Bi;C0;7[[I"io;T0[I" buffer;T0[I" length;T0;$@\;![;"I"Invoked by IO#write to write +length+ bytes to +io+ from from a specified +buffer+ (see IO::Buffer). The +length+ argument is the "(minimum) length to be written". If the IO buffer size is 8KiB, but the +length+ specified is 1024 (1KiB), at most 8KiB will be written, but at least 1KiB will be. Generally, the only case where less data than +length+ will be written is if there is an error writing the data. Specifying a +length+ of 0 is valid and means try writing at least once, as much data as possible. Suggested implementation should try to write to +io+ in a non-blocking manner and call #io_wait if the +io+ is not ready (which will yield control to other fibers). See IO::Buffer for an interface available to get data from buffer efficiently. Expected to return number of bytes written, or, in case of an error, -errno (negated number corresponding to system's error code). The method should be considered _experimental_. @overload io_write(io, buffer, length);T;#0;$@\;.F;/o;0;1T;2i ;3i ;%@;9I"Gstatic VALUE rb_fiber_scheduler_interface_io_write(VALUE self) { };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+Fiber::SchedulerInterface#kernel_sleep;F;7[;[[@(i ;T;:kernel_sleep;0;[;{;IC; "CInvoked by Kernel#sleep and Mutex#sleep and is expected to provide an implementation of sleeping in a non-blocking way. Implementation might register the current fiber in some list of "which fiber wait until what moment", call Fiber.yield to pass control, and then in #close resume the fibers whose wait period has elapsed. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"!kernel_sleep(duration = nil);T;IC; ";T;[;![;"I";T;#0;$@x;.F;Bi;C0;7[[I" duration;TI"nil;T;$@x;![;"I"mInvoked by Kernel#sleep and Mutex#sleep and is expected to provide an implementation of sleeping in a non-blocking way. Implementation might register the current fiber in some list of "which fiber wait until what moment", call Fiber.yield to pass control, and then in #close resume the fibers whose wait period has elapsed. @overload kernel_sleep(duration = nil);T;#0;$@x;.F;/o;0;1T;2i ;3i ;%@;9I"Kstatic VALUE rb_fiber_scheduler_interface_kernel_sleep(VALUE self) { };T;:I"static VALUE;T;;To;4;5F;6;;;;&I".Fiber::SchedulerInterface#address_resolve;F;7[;[[@(i/ ;T;:address_resolve;0;[;{;IC; "Invoked by any method that performs a non-reverse DNS lookup. The most notable method is Addrinfo.getaddrinfo, but there are many other. The method is expected to return an array of strings corresponding to ip addresses the +hostname+ is resolved to, or +nil+ if it can not be resolved. Fairly exhaustive list of all possible call-sites: - Addrinfo.getaddrinfo - Addrinfo.tcp - Addrinfo.udp - Addrinfo.ip - Addrinfo.new - Addrinfo.marshal_load - SOCKSSocket.new - TCPServer.new - TCPSocket.new - IPSocket.getaddress - TCPSocket.gethostbyname - UDPSocket#connect - UDPSocket#bind - UDPSocket#send - Socket.getaddrinfo - Socket.gethostbyname - Socket.pack_sockaddr_in - Socket.sockaddr_in - Socket.unpack_sockaddr_in ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"address_resolve(hostname);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I" hostname;T0;$@;![;"I"Invoked by any method that performs a non-reverse DNS lookup. The most notable method is Addrinfo.getaddrinfo, but there are many other. The method is expected to return an array of strings corresponding to ip addresses the +hostname+ is resolved to, or +nil+ if it can not be resolved. Fairly exhaustive list of all possible call-sites: - Addrinfo.getaddrinfo - Addrinfo.tcp - Addrinfo.udp - Addrinfo.ip - Addrinfo.new - Addrinfo.marshal_load - SOCKSSocket.new - TCPServer.new - TCPSocket.new - IPSocket.getaddress - TCPSocket.gethostbyname - UDPSocket#connect - UDPSocket#bind - UDPSocket#send - Socket.getaddrinfo - Socket.gethostbyname - Socket.pack_sockaddr_in - Socket.sockaddr_in - Socket.unpack_sockaddr_in @overload address_resolve(hostname) @return [nil];T;#0;$@;.F;/o;0;1T;2i ;3i- ;%@;9I"Nstatic VALUE rb_fiber_scheduler_interface_address_resolve(VALUE self) { };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",Fiber::SchedulerInterface#timeout_after;F;7[;[[@(iP ;T;:timeout_after;0;[;{;IC; "Invoked by Timeout.timeout to execute the given +block+ within the given +duration+. It can also be invoked directly by the scheduler or user code. Attempt to limit the execution time of a given +block+ to the given +duration+ if possible. When a non-blocking operation causes the +block+'s execution time to exceed the specified +duration+, that non-blocking operation should be interrupted by raising the specified +exception_class+ constructed with the given +exception_arguments+. General execution timeouts are often considered risky. This implementation will only interrupt non-blocking operations. This is by design because it's expected that non-blocking operations can fail for a variety of unpredictable reasons, so applications should already be robust in handling these conditions and by implication timeouts. However, as a result of this design, if the +block+ does not invoke any non-blocking operations, it will be impossible to interrupt it. If you desire to provide predictable points for timeouts, consider adding +sleep(0)+. If the block is executed successfully, its result will be returned. The exception will typically be raised using Fiber#raise. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"Ktimeout_after(duration, exception_class, *exception_arguments, &block);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[ [I" duration;T0[I"exception_class;T0[I"*exception_arguments;T0[I" &block;T0;$@;![;"I"Invoked by Timeout.timeout to execute the given +block+ within the given +duration+. It can also be invoked directly by the scheduler or user code. Attempt to limit the execution time of a given +block+ to the given +duration+ if possible. When a non-blocking operation causes the +block+'s execution time to exceed the specified +duration+, that non-blocking operation should be interrupted by raising the specified +exception_class+ constructed with the given +exception_arguments+. General execution timeouts are often considered risky. This implementation will only interrupt non-blocking operations. This is by design because it's expected that non-blocking operations can fail for a variety of unpredictable reasons, so applications should already be robust in handling these conditions and by implication timeouts. However, as a result of this design, if the +block+ does not invoke any non-blocking operations, it will be impossible to interrupt it. If you desire to provide predictable points for timeouts, consider adding +sleep(0)+. If the block is executed successfully, its result will be returned. The exception will typically be raised using Fiber#raise. @overload timeout_after(duration, exception_class, *exception_arguments, &block);T;#0;$@;.F;/o;0;1T;2i4 ;3iM ;%@;9I"Lstatic VALUE rb_fiber_scheduler_interface_timeout_after(VALUE self) { };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$Fiber::SchedulerInterface#block;F;7[;[[@(ic ;T;: block;0;[;{;IC; "|Invoked by methods like Thread.join, and by Mutex, to signify that current Fiber is blocked until further notice (e.g. #unblock) or until +timeout+ has elapsed. +blocker+ is what we are waiting on, informational only (for debugging and logging). There are no guarantee about its value. Expected to return boolean, specifying whether the blocking operation was successful or not. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I""block(blocker, timeout = nil);T;IC; ";T;[;![;"I";T;#0;$@̌;.F;Bi;C0;7[[I" blocker;T0[I" timeout;TI"nil;T;$@̌;![;"I"Invoked by methods like Thread.join, and by Mutex, to signify that current Fiber is blocked until further notice (e.g. #unblock) or until +timeout+ has elapsed. +blocker+ is what we are waiting on, informational only (for debugging and logging). There are no guarantee about its value. Expected to return boolean, specifying whether the blocking operation was successful or not. @overload block(blocker, timeout = nil);T;#0;$@̌;.F;/o;0;1T;2iU ;3i` ;%@;9I"Dstatic VALUE rb_fiber_scheduler_interface_block(VALUE self) { };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&Fiber::SchedulerInterface#unblock;F;7[;[[@(iu ;T;: unblock;0;[;{;IC; "Invoked to wake up Fiber previously blocked with #block (for example, Mutex#lock calls #block and Mutex#unlock calls #unblock). The scheduler should use the +fiber+ parameter to understand which fiber is unblocked. +blocker+ is what was awaited for, but it is informational only (for debugging and logging), and it is not guaranteed to be the same value as the +blocker+ for #block. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"unblock(blocker, fiber);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" blocker;T0[I" fiber;T0;$@;![;"I"Invoked to wake up Fiber previously blocked with #block (for example, Mutex#lock calls #block and Mutex#unlock calls #unblock). The scheduler should use the +fiber+ parameter to understand which fiber is unblocked. +blocker+ is what was awaited for, but it is informational only (for debugging and logging), and it is not guaranteed to be the same value as the +blocker+ for #block. @overload unblock(blocker, fiber);T;#0;$@;.F;/o;0;1T;2ih ;3ir ;%@;9I"Fstatic VALUE rb_fiber_scheduler_interface_unblock(VALUE self) { };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$Fiber::SchedulerInterface#fiber;F;7[;[[@(i ;T;: fiber;0;[;{;IC; "<Implementation of the Fiber.schedule. The method is expected to immediately run the given block of code in a separate non-blocking fiber, and to return that Fiber. Minimal suggested implementation is: def fiber(&block) fiber = Fiber.new(blocking: false, &block) fiber.resume fiber end ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"fiber(&block);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" &block;T0;$@;![;"I"VImplementation of the Fiber.schedule. The method is expected to immediately run the given block of code in a separate non-blocking fiber, and to return that Fiber. Minimal suggested implementation is: def fiber(&block) fiber = Fiber.new(blocking: false, &block) fiber.resume fiber end @overload fiber(&block);T;#0;$@;.F;/o;0;1T;2iz ;3i ;%@;9I"Dstatic VALUE rb_fiber_scheduler_interface_fiber(VALUE self) { };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@(iL [@(i ;T;:SchedulerInterface;;;;;[;{;IC; "This is not an existing class, but documentation of the interface that Scheduler object should comply to in order to be used as argument to Fiber.scheduler and handle non-blocking fibers. See also the "Non-blocking fibers" section in Fiber class docs for explanations of some concepts. Scheduler's behavior and usage are expected to be as follows: * When the execution in the non-blocking Fiber reaches some blocking operation (like sleep, wait for a process, or a non-ready I/O), it calls some of the scheduler's hook methods, listed below. * Scheduler somehow registers what the current fiber is waiting on, and yields control to other fibers with Fiber.yield (so the fiber would be suspended while expecting its wait to end, and other fibers in the same thread can perform) * At the end of the current thread execution, the scheduler's method #close is called * The scheduler runs into a wait loop, checking all the blocked fibers (which it has registered on hook calls) and resuming them when the awaited resource is ready (e.g. I/O ready or sleep time elapsed). A typical implementation would probably rely for this closing loop on a gem like EventMachine[https://github.com/eventmachine/eventmachine] or Async[https://github.com/socketry/async]. This way concurrent execution will be achieved transparently for every individual Fiber's code. Hook methods are: * #io_wait, #io_read, and #io_write * #process_wait * #kernel_sleep * #timeout_after * #address_resolve * #block and #unblock * (the list is expanded as Ruby developers make more methods having non-blocking calls) When not specified otherwise, the hook implementations are mandatory: if they are not implemented, the methods trying to call hook will fail. To provide backward compatibility, in the future hooks will be optional (if they are not implemented, due to the scheduler being created for the older Ruby version, the code which needs this hook will not fail, and will just behave in a blocking fashion). It is also strongly recommended that the scheduler implements the #fiber method, which is delegated to by Fiber.schedule. Sample _toy_ implementation of the scheduler can be found in Ruby's code, in test/fiber/scheduler.rb;T;[;![;"I" This is not an existing class, but documentation of the interface that Scheduler object should comply to in order to be used as argument to Fiber.scheduler and handle non-blocking fibers. See also the "Non-blocking fibers" section in Fiber class docs for explanations of some concepts. Scheduler's behavior and usage are expected to be as follows: * When the execution in the non-blocking Fiber reaches some blocking operation (like sleep, wait for a process, or a non-ready I/O), it calls some of the scheduler's hook methods, listed below. * Scheduler somehow registers what the current fiber is waiting on, and yields control to other fibers with Fiber.yield (so the fiber would be suspended while expecting its wait to end, and other fibers in the same thread can perform) * At the end of the current thread execution, the scheduler's method #close is called * The scheduler runs into a wait loop, checking all the blocked fibers (which it has registered on hook calls) and resuming them when the awaited resource is ready (e.g. I/O ready or sleep time elapsed). A typical implementation would probably rely for this closing loop on a gem like EventMachine[https://github.com/eventmachine/eventmachine] or Async[https://github.com/socketry/async]. This way concurrent execution will be achieved transparently for every individual Fiber's code. Hook methods are: * #io_wait, #io_read, and #io_write * #process_wait * #kernel_sleep * #timeout_after * #address_resolve * #block and #unblock * (the list is expanded as Ruby developers make more methods having non-blocking calls) When not specified otherwise, the hook implementations are mandatory: if they are not implemented, the methods trying to call hook will fail. To provide backward compatibility, in the future hooks will be optional (if they are not implemented, due to the scheduler being created for the older Ruby version, the code which needs this hook will not fail, and will just behave in a blocking fashion). It is also strongly recommended that the scheduler implements the #fiber method, which is delegated to by Fiber.schedule. Sample _toy_ implementation of the scheduler can be found in Ruby's code, in test/fiber/scheduler.rb ;T;#0;$@;.F;/o;0;1T;2iL ;3i| ;Bi;%o;( ;)0;*0;+0;: Fiber;%@;-@;0;&I"Fiber::SchedulerInterface;F;'@o;4;5F;6;;;;&I"Fiber.yield;F;7[[@90;[[@(i ;T;;W ;0;[;{;IC; "$Yields control back to the context that resumed the fiber, passing along any arguments that were passed to it. The fiber will resume processing at this point when #resume is called next. Any arguments passed to the next #resume will be the value that this Fiber.yield expression evaluates to. ;T;[o;= ;>I" overload;F;?0;;W ;@0;:I"yield(args, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@,;![;"I"@return [Object];T;#0;$@,;.F;Bi;C0;7[[I" args;T0[I"...;T0;$@,;![;"I"TYields control back to the context that resumed the fiber, passing along any arguments that were passed to it. The fiber will resume processing at this point when #resume is called next. Any arguments passed to the next #resume will be the value that this Fiber.yield expression evaluates to. @overload yield(args, ...) @return [Object];T;#0;$@,;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE rb_fiber_s_yield(int argc, VALUE *argv, VALUE klass) { return rb_fiber_yield_kw(argc, argv, rb_keyword_given_p()); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiber.current;F;7[;[[@(i ;T;;&;0;[;{;IC; "xReturns the current fiber. If you are not running in the context of a fiber this method will return the root fiber. ;T;[o;= ;>I" overload;F;?0;;&;@0;:I" current;T;IC; ";T;[;![;"I";T;#0;$@L;.F;Bi;C0;7[;$@L;![;"I"Returns the current fiber. If you are not running in the context of a fiber this method will return the root fiber. @overload current;T;#0;$@L;.F;/o;0;1T;2i ;3i ;%@;9I"Tstatic VALUE rb_fiber_s_current(VALUE klass) { return rb_fiber_current(); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiber#initialize;F;7[[@90;[[@(iz;T;;D;0;[;{;IC; "Creates new Fiber. Initially, the fiber is not running and can be resumed with #resume. Arguments to the first #resume call will be passed to the block: f = Fiber.new do |initial| current = initial loop do puts "current: #{current.inspect}" current = Fiber.yield end end f.resume(100) # prints: current: 100 f.resume(1, 2, 3) # prints: current: [1, 2, 3] f.resume # prints: current: nil # ... and so on ... If blocking: false is passed to Fiber.new, _and_ current thread has a Fiber.scheduler defined, the Fiber becomes non-blocking (see "Non-blocking Fibers" section in class docs). ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(blocking: false);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" *args;T;$@b;![;"I"@yield [*args];T;#0;$@b;.F;Bi;C0;7[[I"blocking:;TI" false;T;$@b;![;"I"Creates new Fiber. Initially, the fiber is not running and can be resumed with #resume. Arguments to the first #resume call will be passed to the block: f = Fiber.new do |initial| current = initial loop do puts "current: #{current.inspect}" current = Fiber.yield end end f.resume(100) # prints: current: 100 f.resume(1, 2, 3) # prints: current: [1, 2, 3] f.resume # prints: current: nil # ... and so on ... If blocking: false is passed to Fiber.new, _and_ current thread has a Fiber.scheduler defined, the Fiber becomes non-blocking (see "Non-blocking Fibers" section in class docs). @overload new(blocking: false) @yield [*args];T;#0;$@b;.F;/o;0;1T;2ic;3ix;%@;9I"static VALUE rb_fiber_initialize(int argc, VALUE* argv, VALUE self) { return rb_fiber_initialize_kw(argc, argv, self, rb_keyword_given_p()); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiber#blocking?;F;7[;[[@(i. ;T;:blocking?;0;[;{;IC; "tReturns +true+ if +fiber+ is blocking and +false+ otherwise. Fiber is non-blocking if it was created via passing blocking: false to Fiber.new, or via Fiber.schedule. Note that, even if the method returns +false+, the fiber behaves differently only if Fiber.scheduler is set in the current thread. See the "Non-blocking fibers" section in class docs for details.;T;[o;= ;>I" overload;F;?0;; ;@0;:I"blocking?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns +true+ if +fiber+ is blocking and +false+ otherwise. Fiber is non-blocking if it was created via passing blocking: false to Fiber.new, or via Fiber.schedule. Note that, even if the method returns +false+, the fiber behaves differently only if Fiber.scheduler is set in the current thread. See the "Non-blocking fibers" section in class docs for details. @overload blocking? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i ;3i, ;Bi;%@;9I"bVALUE rb_fiber_blocking_p(VALUE fiber) { return RBOOL(fiber_ptr(fiber)->blocking != 0); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Fiber#resume;F;7[[@90;[[@(i ;T;;;0;[;{;IC; "Resumes the fiber from the point at which the last Fiber.yield was called, or starts running it if it is the first call to #resume. Arguments passed to resume will be the value of the Fiber.yield expression or will be passed as block parameters to the fiber's block if this is the first #resume. Alternatively, when resume is called it evaluates to the arguments passed to the next Fiber.yield statement inside the fiber's block or to the block value if it runs to completion without any Fiber.yield ;T;[o;= ;>I" overload;F;?0;;;@0;:I"resume(args, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I" args;T0[I"...;T0;$@;![;"I"%Resumes the fiber from the point at which the last Fiber.yield was called, or starts running it if it is the first call to #resume. Arguments passed to resume will be the value of the Fiber.yield expression or will be passed as block parameters to the fiber's block if this is the first #resume. Alternatively, when resume is called it evaluates to the arguments passed to the next Fiber.yield statement inside the fiber's block or to the block value if it runs to completion without any Fiber.yield @overload resume(args, ...) @return [Object];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE rb_fiber_m_resume(int argc, VALUE *argv, VALUE fiber) { return rb_fiber_resume_kw(fiber, argc, argv, rb_keyword_given_p()); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiber#raise;F;7[[@90;[[@(i ;T;;;0;[;{;IC; "5Raises an exception in the fiber at the point at which the last +Fiber.yield+ was called. If the fiber has not been started or has already run to completion, raises +FiberError+. If the fiber is yielding, it is resumed. If it is transferring, it is transferred into. But if it is resuming, raises +FiberError+. With no arguments, raises a +RuntimeError+. With a single +String+ argument, raises a +RuntimeError+ with the string as a message. Otherwise, the first parameter should be the name of an +Exception+ class (or an object that returns an +Exception+ object when sent an +exception+ message). The optional second parameter sets the message associated with the exception, and the third parameter is an array of callback information. Exceptions are caught by the +rescue+ clause of begin...end blocks. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" raise;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"raise(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I" string;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"*raise(exception [, string [, array]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I""exception[, string [, array]];T0;$@;![;"I"Raises an exception in the fiber at the point at which the last +Fiber.yield+ was called. If the fiber has not been started or has already run to completion, raises +FiberError+. If the fiber is yielding, it is resumed. If it is transferring, it is transferred into. But if it is resuming, raises +FiberError+. With no arguments, raises a +RuntimeError+. With a single +String+ argument, raises a +RuntimeError+ with the string as a message. Otherwise, the first parameter should be the name of an +Exception+ class (or an object that returns an +Exception+ object when sent an +exception+ message). The optional second parameter sets the message associated with the exception, and the third parameter is an array of callback information. Exceptions are caught by the +rescue+ clause of begin...end blocks. @overload raise @return [Object] @overload raise(string) @return [Object] @overload raise(exception [, string [, array]]) @return [Object];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"vstatic VALUE rb_fiber_m_raise(int argc, VALUE *argv, VALUE self) { return rb_fiber_raise(self, argc, argv); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiber#backtrace;F;7[[@90;[[@(i ;T;;K;0;[;{;IC; "Returns the current execution stack of the fiber. +start+, +count+ and +end+ allow to select only parts of the backtrace. def level3 Fiber.yield end def level2 level3 end def level1 level2 end f = Fiber.new { level1 } # It is empty before the fiber started f.backtrace #=> [] f.resume f.backtrace #=> ["test.rb:2:in `yield'", "test.rb:2:in `level3'", "test.rb:6:in `level2'", "test.rb:10:in `level1'", "test.rb:13:in `block in
'"] p f.backtrace(1) # start from the item 1 #=> ["test.rb:2:in `level3'", "test.rb:6:in `level2'", "test.rb:10:in `level1'", "test.rb:13:in `block in
'"] p f.backtrace(2, 2) # start from item 2, take 2 #=> ["test.rb:6:in `level2'", "test.rb:10:in `level1'"] p f.backtrace(1..3) # take items from 1 to 3 #=> ["test.rb:2:in `level3'", "test.rb:6:in `level2'", "test.rb:10:in `level1'"] f.resume # It is nil after the fiber is finished f.backtrace #=> nil ;T;[ o;= ;>I" overload;F;?0;;K;@0;:I"backtrace;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;K;@0;:I"backtrace(start);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" start;T0;$@o;= ;>I" overload;F;?0;;K;@0;:I"backtrace(start, count);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" start;T0[I" count;T0;$@o;= ;>I" overload;F;?0;;K;@0;:I"backtrace(start..end);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"start..end;T0;$@;![;"I"Returns the current execution stack of the fiber. +start+, +count+ and +end+ allow to select only parts of the backtrace. def level3 Fiber.yield end def level2 level3 end def level1 level2 end f = Fiber.new { level1 } # It is empty before the fiber started f.backtrace #=> [] f.resume f.backtrace #=> ["test.rb:2:in `yield'", "test.rb:2:in `level3'", "test.rb:6:in `level2'", "test.rb:10:in `level1'", "test.rb:13:in `block in
'"] p f.backtrace(1) # start from the item 1 #=> ["test.rb:2:in `level3'", "test.rb:6:in `level2'", "test.rb:10:in `level1'", "test.rb:13:in `block in
'"] p f.backtrace(2, 2) # start from item 2, take 2 #=> ["test.rb:6:in `level2'", "test.rb:10:in `level1'"] p f.backtrace(1..3) # take items from 1 to 3 #=> ["test.rb:2:in `level3'", "test.rb:6:in `level2'", "test.rb:10:in `level1'"] f.resume # It is nil after the fiber is finished f.backtrace #=> nil @overload backtrace @return [Array] @overload backtrace(start) @return [Array] @overload backtrace(start, count) @return [Array] @overload backtrace(start..end) @return [Array];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE rb_fiber_backtrace(int argc, VALUE *argv, VALUE fiber) { return rb_vm_backtrace(argc, argv, &fiber_ptr(fiber)->cont.saved_ec); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiber#backtrace_locations;F;7[[@90;[[@(i ;T;;L;0;[;{;IC; " Like #backtrace, but returns each line of the execution stack as a Thread::Backtrace::Location. Accepts the same arguments as #backtrace. f = Fiber.new { Fiber.yield } f.resume loc = f.backtrace_locations.first loc.label #=> "yield" loc.path #=> "test.rb" loc.lineno #=> 1 ;T;[ o;= ;>I" overload;F;?0;;L;@0;:I"backtrace_locations;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@A;![;"I"@return [Array];T;#0;$@A;.F;Bi;C0;7[;$@Ao;= ;>I" overload;F;?0;;L;@0;:I"backtrace_locations(start);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@A;![;"I"@return [Array];T;#0;$@A;.F;Bi;C0;7[[I" start;T0;$@Ao;= ;>I" overload;F;?0;;L;@0;:I"&backtrace_locations(start, count);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@A;![;"I"@return [Array];T;#0;$@A;.F;Bi;C0;7[[I" start;T0[I" count;T0;$@Ao;= ;>I" overload;F;?0;;L;@0;:I"$backtrace_locations(start..end);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@A;![;"I"@return [Array];T;#0;$@A;.F;Bi;C0;7[[I"start..end;T0;$@A;![;"I"Like #backtrace, but returns each line of the execution stack as a Thread::Backtrace::Location. Accepts the same arguments as #backtrace. f = Fiber.new { Fiber.yield } f.resume loc = f.backtrace_locations.first loc.label #=> "yield" loc.path #=> "test.rb" loc.lineno #=> 1 @overload backtrace_locations @return [Array] @overload backtrace_locations(start) @return [Array] @overload backtrace_locations(start, count) @return [Array] @overload backtrace_locations(start..end) @return [Array];T;#0;$@A;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE rb_fiber_backtrace_locations(int argc, VALUE *argv, VALUE fiber) { return rb_vm_backtrace_locations(argc, argv, &fiber_ptr(fiber)->cont.saved_ec); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiber#to_s;F;7[;[[@(i ;T;;G;0;[;{;IC; " ;T;[;![;"@;#0;$o;4;5F;6;;;;&I"Fiber#inspect;F;7[;[[@(i ;F;;J;;;[;{;@;%@;9I"static VALUE fiber_to_s(VALUE fiber_value) { const rb_fiber_t *fiber = fiber_ptr(fiber_value); const rb_proc_t *proc; char status_info[0x20]; if (fiber->resuming_fiber) { snprintf(status_info, 0x20, " (%s by resuming)", fiber_status_name(fiber->status)); } else { snprintf(status_info, 0x20, " (%s)", fiber_status_name(fiber->status)); } if (!rb_obj_is_proc(fiber->first_proc)) { VALUE str = rb_any_to_s(fiber_value); strlcat(status_info, ">", sizeof(status_info)); rb_str_set_len(str, RSTRING_LEN(str)-1); rb_str_cat_cstr(str, status_info); return str; } GetProcPtr(fiber->first_proc, proc); return rb_block_to_s(fiber_value, &proc->block, status_info); };T;:I"static VALUE;T;%@;9I"static VALUE fiber_to_s(VALUE fiber_value) { const rb_fiber_t *fiber = fiber_ptr(fiber_value); const rb_proc_t *proc; char status_info[0x20]; if (fiber->resuming_fiber) { snprintf(status_info, 0x20, " (%s by resuming)", fiber_status_name(fiber->status)); } else { snprintf(status_info, 0x20, " (%s)", fiber_status_name(fiber->status)); } if (!rb_obj_is_proc(fiber->first_proc)) { VALUE str = rb_any_to_s(fiber_value); strlcat(status_info, ">", sizeof(status_info)); rb_str_set_len(str, RSTRING_LEN(str)-1); rb_str_cat_cstr(str, status_info); return str; } GetProcPtr(fiber->first_proc, proc); return rb_block_to_s(fiber_value, &proc->block, status_info); };T;:@;;T@o;4;5F;6;;;;&I"Fiber#transfer;F;7[[@90;[[@(im ;T;;;0;[;{;IC; "g Transfer control to another fiber, resuming it from where it last stopped or starting it if it was not resumed before. The calling fiber will be suspended much like in a call to Fiber.yield. The fiber which receives the transfer call treats it much like a resume call. Arguments passed to transfer are treated like those passed to resume. The two style of control passing to and from fiber (one is #resume and Fiber::yield, another is #transfer to and from fiber) can't be freely mixed. * If the Fiber's lifecycle had started with transfer, it will never be able to yield or be resumed control passing, only finish or transfer back. (It still can resume other fibers that are allowed to be resumed.) * If the Fiber's lifecycle had started with resume, it can yield or transfer to another Fiber, but can receive control back only the way compatible with the way it was given away: if it had transferred, it only can be transferred back, and if it had yielded, it only can be resumed back. After that, it again can transfer or yield. If those rules are broken FiberError is raised. For an individual Fiber design, yield/resume is easier to use (the Fiber just gives away control, it doesn't need to think about who the control is given to), while transfer is more flexible for complex cases, allowing to build arbitrary graphs of Fibers dependent on each other. Example: manager = nil # For local var to be visible inside worker block # This fiber would be started with transfer # It can't yield, and can't be resumed worker = Fiber.new { |work| puts "Worker: starts" puts "Worker: Performed #{work.inspect}, transferring back" # Fiber.yield # this would raise FiberError: attempt to yield on a not resumed fiber # manager.resume # this would raise FiberError: attempt to resume a resumed fiber (double resume) manager.transfer(work.capitalize) } # This fiber would be started with resume # It can yield or transfer, and can be transferred # back or resumed manager = Fiber.new { puts "Manager: starts" puts "Manager: transferring 'something' to worker" result = worker.transfer('something') puts "Manager: worker returned #{result.inspect}" # worker.resume # this would raise FiberError: attempt to resume a transferring fiber Fiber.yield # this is OK, the fiber transferred from and to, now it can yield puts "Manager: finished" } puts "Starting the manager" manager.resume puts "Resuming the manager" # manager.transfer # this would raise FiberError: attempt to transfer to a yielding fiber manager.resume produces Starting the manager Manager: starts Manager: transferring 'something' to worker Worker: starts Worker: Performed "something", transferring back Manager: worker returned "Something" Resuming the manager Manager: finished ;T;[o;= ;>I" overload;F;?0;;;@0;:I"transfer(args, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I" args;T0[I"...;T0;$@;![;"I" Transfer control to another fiber, resuming it from where it last stopped or starting it if it was not resumed before. The calling fiber will be suspended much like in a call to Fiber.yield. The fiber which receives the transfer call treats it much like a resume call. Arguments passed to transfer are treated like those passed to resume. The two style of control passing to and from fiber (one is #resume and Fiber::yield, another is #transfer to and from fiber) can't be freely mixed. * If the Fiber's lifecycle had started with transfer, it will never be able to yield or be resumed control passing, only finish or transfer back. (It still can resume other fibers that are allowed to be resumed.) * If the Fiber's lifecycle had started with resume, it can yield or transfer to another Fiber, but can receive control back only the way compatible with the way it was given away: if it had transferred, it only can be transferred back, and if it had yielded, it only can be resumed back. After that, it again can transfer or yield. If those rules are broken FiberError is raised. For an individual Fiber design, yield/resume is easier to use (the Fiber just gives away control, it doesn't need to think about who the control is given to), while transfer is more flexible for complex cases, allowing to build arbitrary graphs of Fibers dependent on each other. Example: manager = nil # For local var to be visible inside worker block # This fiber would be started with transfer # It can't yield, and can't be resumed worker = Fiber.new { |work| puts "Worker: starts" puts "Worker: Performed #{work.inspect}, transferring back" # Fiber.yield # this would raise FiberError: attempt to yield on a not resumed fiber # manager.resume # this would raise FiberError: attempt to resume a resumed fiber (double resume) manager.transfer(work.capitalize) } # This fiber would be started with resume # It can yield or transfer, and can be transferred # back or resumed manager = Fiber.new { puts "Manager: starts" puts "Manager: transferring 'something' to worker" result = worker.transfer('something') puts "Manager: worker returned #{result.inspect}" # worker.resume # this would raise FiberError: attempt to resume a transferring fiber Fiber.yield # this is OK, the fiber transferred from and to, now it can yield puts "Manager: finished" } puts "Starting the manager" manager.resume puts "Resuming the manager" # manager.transfer # this would raise FiberError: attempt to transfer to a yielding fiber manager.resume produces Starting the manager Manager: starts Manager: transferring 'something' to worker Worker: starts Worker: Performed "something", transferring back Manager: worker returned "Something" Resuming the manager Manager: finished @overload transfer(args, ...) @return [Object];T;#0;$@;.F;/o;0;1T;2i ;3ik ;%@;9I"static VALUE rb_fiber_m_transfer(int argc, VALUE *argv, VALUE self) { return rb_fiber_transfer_kw(self, argc, argv, rb_keyword_given_p()); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiber#alive?;F;7[;[[@(i ;T;;C;0;[;{;IC; "Returns true if the fiber can still be resumed (or transferred to). After finishing execution of the fiber block this method will always return +false+.;T;[o;= ;>I" overload;F;?0;;C;@0;:I" alive?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns true if the fiber can still be resumed (or transferred to). After finishing execution of the fiber block this method will always return +false+. @overload alive? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i ;3i ;Bi;%@;9I"zVALUE rb_fiber_alive_p(VALUE fiber_value) { return FIBER_TERMINATED_P(fiber_ptr(fiber_value)) ? Qfalse : Qtrue; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Fiber.blocking?;F;7[;[[@(iF ;T;; ;0;[;{;IC; "Returns +false+ if the current fiber is non-blocking. Fiber is non-blocking if it was created via passing blocking: false to Fiber.new, or via Fiber.schedule. If the current Fiber is blocking, the method returns 1. Future developments may allow for situations where larger integers could be returned. Note that, even if the method returns +false+, Fiber behaves differently only if Fiber.scheduler is set in the current thread. See the "Non-blocking fibers" section in class docs for details.;T;[o;= ;>I" overload;F;?0;; ;@0;:I"blocking?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" false;TI"1;T;$@ێ;![;"I"@return [false, 1];T;#0;$@ێ;.F;Bi;C0;7[;$@ێ;![;"I"$Returns +false+ if the current fiber is non-blocking. Fiber is non-blocking if it was created via passing blocking: false to Fiber.new, or via Fiber.schedule. If the current Fiber is blocking, the method returns 1. Future developments may allow for situations where larger integers could be returned. Note that, even if the method returns +false+, Fiber behaves differently only if Fiber.scheduler is set in the current thread. See the "Non-blocking fibers" section in class docs for details. @overload blocking? @return [false, 1];T;#0;$@ێ;.F;/o;0;1T;2i4 ;3iD ;Bi;%@;9I"static VALUE rb_fiber_s_blocking_p(VALUE klass) { rb_thread_t *thread = GET_THREAD(); unsigned blocking = thread->blocking; if (blocking == 0) return Qfalse; return INT2NUM(blocking); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiber.scheduler;F;7[;[[@(i;T;:scheduler;0;[;{;IC; "5Returns the Fiber scheduler, that was last set for the current thread with Fiber.set_scheduler. Returns +nil+ if no scheduler is set (which is the default), and non-blocking fibers' # behavior is the same as blocking. (see "Non-blocking fibers" section in class docs for details about the scheduler concept). ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"scheduler;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@;![;"I"@return [Object, nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"dReturns the Fiber scheduler, that was last set for the current thread with Fiber.set_scheduler. Returns +nil+ if no scheduler is set (which is the default), and non-blocking fibers' # behavior is the same as blocking. (see "Non-blocking fibers" section in class docs for details about the scheduler concept). @overload scheduler @return [Object, nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"\static VALUE rb_fiber_s_scheduler(VALUE klass) { return rb_fiber_scheduler_get(); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiber.set_scheduler;F;7[[I"scheduler;T0;[[@(i;T;:set_scheduler;0;[;{;IC; "8Sets the Fiber scheduler for the current thread. If the scheduler is set, non-blocking fibers (created by Fiber.new with blocking: false, or by Fiber.schedule) call that scheduler's hook methods on potentially blocking operations, and the current thread will call scheduler's +close+ method on finalization (allowing the scheduler to properly manage all non-finished fibers). +scheduler+ can be an object of any class corresponding to Fiber::SchedulerInterface. Its implementation is up to the user. See also the "Non-blocking fibers" section in class docs. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"set_scheduler(scheduler);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"scheduler;T0;$@;![;"I"^Sets the Fiber scheduler for the current thread. If the scheduler is set, non-blocking fibers (created by Fiber.new with blocking: false, or by Fiber.schedule) call that scheduler's hook methods on potentially blocking operations, and the current thread will call scheduler's +close+ method on finalization (allowing the scheduler to properly manage all non-finished fibers). +scheduler+ can be an object of any class corresponding to Fiber::SchedulerInterface. Its implementation is up to the user. See also the "Non-blocking fibers" section in class docs. @overload set_scheduler(scheduler);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"xstatic VALUE rb_fiber_set_scheduler(VALUE klass, VALUE scheduler) { return rb_fiber_scheduler_set(scheduler); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiber.current_scheduler;F;7[;[[@(i;T;:current_scheduler;0;[;{;IC; "Returns the Fiber scheduler, that was last set for the current thread with Fiber.set_scheduler if and only if the current fiber is non-blocking. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"current_scheduler;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;TI"nil;T;$@-;![;"I"@return [Object, nil];T;#0;$@-;.F;Bi;C0;7[;$@-;![;"I"Returns the Fiber scheduler, that was last set for the current thread with Fiber.set_scheduler if and only if the current fiber is non-blocking. @overload current_scheduler @return [Object, nil];T;#0;$@-;.F;/o;0;1T;2i;3i;%@;9I"fstatic VALUE rb_fiber_current_scheduler(VALUE klass) { return rb_fiber_scheduler_current(); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiber.schedule;F;7[[@90;[[@(i;T;: schedule;0;[;{;IC; "HThe method is expected to immediately run the provided block of code in a separate non-blocking fiber. puts "Go to sleep!" Fiber.set_scheduler(MyScheduler.new) Fiber.schedule do puts "Going to sleep" sleep(1) puts "I slept well" end puts "Wakey-wakey, sleepyhead" Assuming MyScheduler is properly implemented, this program will produce: Go to sleep! Going to sleep Wakey-wakey, sleepyhead ...1 sec pause here... I slept well ...e.g. on the first blocking operation inside the Fiber (sleep(1)), the control is yielded to the outside code (main fiber), and at the end of that execution, the scheduler takes care of properly resuming all the blocked fibers. Note that the behavior described above is how the method is expected to behave, actual behavior is up to the current scheduler's implementation of Fiber::SchedulerInterface#fiber method. Ruby doesn't enforce this method to behave in any particular way. If the scheduler is not set, the method raises RuntimeError (No scheduler is available!). ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" schedule;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" *args;T;$@I;![;"I"@yield [*args];T;#0;$@I;.F;Bi;C0;7[;$@I;![;"I"oThe method is expected to immediately run the provided block of code in a separate non-blocking fiber. puts "Go to sleep!" Fiber.set_scheduler(MyScheduler.new) Fiber.schedule do puts "Going to sleep" sleep(1) puts "I slept well" end puts "Wakey-wakey, sleepyhead" Assuming MyScheduler is properly implemented, this program will produce: Go to sleep! Going to sleep Wakey-wakey, sleepyhead ...1 sec pause here... I slept well ...e.g. on the first blocking operation inside the Fiber (sleep(1)), the control is yielded to the outside code (main fiber), and at the end of that execution, the scheduler takes care of properly resuming all the blocked fibers. Note that the behavior described above is how the method is expected to behave, actual behavior is up to the current scheduler's implementation of Fiber::SchedulerInterface#fiber method. Ruby doesn't enforce this method to behave in any particular way. If the scheduler is not set, the method raises RuntimeError (No scheduler is available!). @overload schedule @yield [*args];T;#0;$@I;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_fiber_s_schedule(int argc, VALUE *argv, VALUE obj) { return rb_fiber_s_schedule_kw(argc, argv, rb_keyword_given_p()); };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{@;G;[;[[@(i[@(i ;T;; ;;;;;[;{;IC; "7 Fibers are primitives for implementing light weight cooperative concurrency in Ruby. Basically they are a means of creating code blocks that can be paused and resumed, much like threads. The main difference is that they are never preempted and that the scheduling must be done by the programmer and not the VM. As opposed to other stackless light weight concurrency models, each fiber comes with a stack. This enables the fiber to be paused from deeply nested function calls within the fiber block. See the ruby(1) manpage to configure the size of the fiber stack(s). When a fiber is created it will not run automatically. Rather it must be explicitly asked to run using the Fiber#resume method. The code running inside the fiber can give up control by calling Fiber.yield in which case it yields control back to caller (the caller of the Fiber#resume). Upon yielding or termination the Fiber returns the value of the last executed expression For instance: fiber = Fiber.new do Fiber.yield 1 2 end puts fiber.resume puts fiber.resume puts fiber.resume produces 1 2 FiberError: dead fiber called The Fiber#resume method accepts an arbitrary number of parameters, if it is the first call to #resume then they will be passed as block arguments. Otherwise they will be the return value of the call to Fiber.yield Example: fiber = Fiber.new do |first| second = Fiber.yield first + 2 end puts fiber.resume 10 puts fiber.resume 1_000_000 puts fiber.resume "The fiber will be dead before I can cause trouble" produces 12 1000000 FiberError: dead fiber called == Non-blocking Fibers The concept of non-blocking fiber was introduced in Ruby 3.0. A non-blocking fiber, when reaching a operation that would normally block the fiber (like sleep, or wait for another process or I/O) will yield control to other fibers and allow the scheduler to handle blocking and waking up (resuming) this fiber when it can proceed. For a Fiber to behave as non-blocking, it need to be created in Fiber.new with blocking: false (which is the default), and Fiber.scheduler should be set with Fiber.set_scheduler. If Fiber.scheduler is not set in the current thread, blocking and non-blocking fibers' behavior is identical. Ruby doesn't provide a scheduler class: it is expected to be implemented by the user and correspond to Fiber::SchedulerInterface. There is also Fiber.schedule method, which is expected to immediately perform the given block in a non-blocking manner. Its actual implementation is up to the scheduler.;T;[;![;"I": Fibers are primitives for implementing light weight cooperative concurrency in Ruby. Basically they are a means of creating code blocks that can be paused and resumed, much like threads. The main difference is that they are never preempted and that the scheduling must be done by the programmer and not the VM. As opposed to other stackless light weight concurrency models, each fiber comes with a stack. This enables the fiber to be paused from deeply nested function calls within the fiber block. See the ruby(1) manpage to configure the size of the fiber stack(s). When a fiber is created it will not run automatically. Rather it must be explicitly asked to run using the Fiber#resume method. The code running inside the fiber can give up control by calling Fiber.yield in which case it yields control back to caller (the caller of the Fiber#resume). Upon yielding or termination the Fiber returns the value of the last executed expression For instance: fiber = Fiber.new do Fiber.yield 1 2 end puts fiber.resume puts fiber.resume puts fiber.resume produces 1 2 FiberError: dead fiber called The Fiber#resume method accepts an arbitrary number of parameters, if it is the first call to #resume then they will be passed as block arguments. Otherwise they will be the return value of the call to Fiber.yield Example: fiber = Fiber.new do |first| second = Fiber.yield first + 2 end puts fiber.resume 10 puts fiber.resume 1_000_000 puts fiber.resume "The fiber will be dead before I can cause trouble" produces 12 1000000 FiberError: dead fiber called == Non-blocking Fibers The concept of non-blocking fiber was introduced in Ruby 3.0. A non-blocking fiber, when reaching a operation that would normally block the fiber (like sleep, or wait for another process or I/O) will yield control to other fibers and allow the scheduler to handle blocking and waking up (resuming) this fiber when it can proceed. For a Fiber to behave as non-blocking, it need to be created in Fiber.new with blocking: false (which is the default), and Fiber.scheduler should be set with Fiber.set_scheduler. If Fiber.scheduler is not set in the current thread, blocking and non-blocking fibers' behavior is identical. Ruby doesn't provide a scheduler class: it is expected to be implemented by the user and correspond to Fiber::SchedulerInterface. There is also Fiber.schedule method, which is expected to immediately perform the given block in a non-blocking manner. Its actual implementation is up to the scheduler. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;&I" Fiber;F;'@o; ;IC;[; @w; IC;[; @w; IC;[; @w; IC;{;IC;{;T;IC;{;T;T;{;[;[[@(i? [@(i ;T;:FiberError;;;;;[;{;IC; ""Raised when an invalid operation is attempted on a Fiber, in particular when attempting to call/resume a dead fiber, attempting to yield from the root fiber, or calling a fiber across threads. fiber = Fiber.new{} fiber.resume #=> nil fiber.resume #=> FiberError: dead fiber called ;T;[;![;"I"$ Raised when an invalid operation is attempted on a Fiber, in particular when attempting to call/resume a dead fiber, attempting to yield from the root fiber, or calling a fiber across threads. fiber = Fiber.new{} fiber.resume #=> nil fiber.resume #=> FiberError: dead fiber called ;T;#0;$@w;.F;/o;0;1T;2i? ;3iH ;%@;&I"FiberError;F;'@o; ;IC;[o;4;5F;6;;;;&I"Pool#initialize;F;7[[@90;[[@(i! ;T;;D;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"-static VALUE rb_fiber_pool_initialize(int argc, VALUE* argv, VALUE self) { rb_thread_t *th = GET_THREAD(); VALUE size = Qnil, count = Qnil, vm_stack_size = Qnil; struct fiber_pool * fiber_pool = NULL; // Maybe these should be keyword arguments. rb_scan_args(argc, argv, "03", &size, &count, &vm_stack_size); if (NIL_P(size)) { size = INT2NUM(th->vm->default_params.fiber_machine_stack_size); } if (NIL_P(count)) { count = INT2NUM(128); } if (NIL_P(vm_stack_size)) { vm_stack_size = INT2NUM(th->vm->default_params.fiber_vm_stack_size); } TypedData_Get_Struct(self, struct fiber_pool, &FiberPoolDataType, fiber_pool); fiber_pool_initialize(fiber_pool, NUM2SIZET(size), NUM2SIZET(count), NUM2SIZET(vm_stack_size)); return self; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@(i ;F;: Pool;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I" Pool;F;'@o;;IC;[o;u;[[@?i4;F;:INTERNAL_CONSTANTS;;w;;;[;{;IC; "internal constants ;T;[;![;"I"internal constants;T;#0;$@;.F;/o;0;1T;2i4;3i4;%@;&I"GC::INTERNAL_CONSTANTS;F;xI"gc_constants;To;4;5F;6;;;;&I"#GC.verify_internal_consistency;F;7[;[;F;: verify_internal_consistency;;;[;{;IC; "internal methods ;T;[;![;"I"internal methods;T;#0;$@;.F;/o;0;1T;2i5;3i5;%@;;To;4;5F;6;;;;&I"2GC.verify_transient_heap_internal_consistency;F;7[;[;F;:/verify_transient_heap_internal_consistency;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;;To;4;5F;6;;;;&I"GC.malloc_allocated_size;F;7[;[;F;:malloc_allocated_size;;;[;{;IC; " ;T;[;![;"@;#0;$@ˏ;%@;;To;4;5F;6;;;;&I"GC.malloc_allocations;F;7[;[;F;:malloc_allocations;;;[;{;IC; " ;T;[;![;"@;#0;$@ԏ;%@;;To;4;5F;6;;;;&I"GC.add_stress_to_class;F;7[;[;F;:add_stress_to_class;;;[;{;IC; " ;T;[;![;"@;#0;$@ݏ;%@;;To;4;5F;6;;;;&I"GC.remove_stress_to_class;F;7[;[;F;:remove_stress_to_class;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;;To;u;[[@?i'5;F;;;;w;;;[;{;IC; "GC build options ;T;[;![;"I"GC build options;T;#0;$@;.F;/o;0;1T;2i&5;3i&5;%@;&I" GC::OPTS;F;xI"opts = rb_ary_new();To; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@?i4;T;: Profiler;;;;;[;{;IC; "The GC profiler provides access to information on GC runs including time, length and object space size. Example: GC::Profiler.enable require 'rdoc/rdoc' GC::Profiler.report GC::Profiler.disable See also GC.count, GC.malloc_allocated_size and GC.malloc_allocations ;T;[;![;"I" The GC profiler provides access to information on GC runs including time, length and object space size. Example: GC::Profiler.enable require 'rdoc/rdoc' GC::Profiler.report GC::Profiler.disable See also GC.count, GC.malloc_allocated_size and GC.malloc_allocations ;T;#0;$@;.F;/o;0;1T;2i4;3i4;%o;( ;)0;*0;+0;:GC;%@;-@;0;&I"GC::Profiler;F;'o;( ;)0;*0;+0;;;%@;-@;0; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@?i4;F;; ;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I"GC;Fo;;IC;[So; ;IC;[o;4;5F;6;;;;&I"Fiddle::Closure#initialize;F;7[[I" argv[];T0[I" self;T0;[[I"ext/fiddle/closure.c;Ti;T;;D;0;[;{;IC; "Ccall-seq: new(ret, args, abi = Fiddle::DEFAULT) Construct a new Closure object. * +ret+ is the C type to be returned * +args+ is an Array of arguments, passed to the callback function * +abi+ is the abi of the closure If there is an error in preparing the ffi_cif or ffi_prep_closure, then a RuntimeError will be raised. ;T;[;![;"I"E call-seq: new(ret, args, abi = Fiddle::DEFAULT) Construct a new Closure object. * +ret+ is the C type to be returned * +args+ is an Array of arguments, passed to the callback function * +abi+ is the abi of the closure If there is an error in preparing the ffi_cif or ffi_prep_closure, then a RuntimeError will be raised. ;T;#0;$@#;.F;/o;0;1T;2iQ;3i\;%@!;9I"static VALUE initialize(int rbargc, VALUE argv[], VALUE self) { VALUE ret; VALUE args; VALUE normalized_args; VALUE abi; fiddle_closure * cl; ffi_cif * cif; ffi_closure *pcl; ffi_status result; int i, argc; if (2 == rb_scan_args(rbargc, argv, "21", &ret, &args, &abi)) abi = INT2NUM(FFI_DEFAULT_ABI); Check_Type(args, T_ARRAY); argc = RARRAY_LENINT(args); TypedData_Get_Struct(self, fiddle_closure, &closure_data_type, cl); cl->argv = (ffi_type **)xcalloc(argc + 1, sizeof(ffi_type *)); normalized_args = rb_ary_new_capa(argc); for (i = 0; i < argc; i++) { VALUE arg = rb_fiddle_type_ensure(RARRAY_AREF(args, i)); rb_ary_push(normalized_args, arg); cl->argv[i] = rb_fiddle_int_to_ffi_type(NUM2INT(arg)); } cl->argv[argc] = NULL; ret = rb_fiddle_type_ensure(ret); rb_iv_set(self, "@ctype", ret); rb_iv_set(self, "@args", normalized_args); cif = &cl->cif; pcl = cl->pcl; result = ffi_prep_cif(cif, NUM2INT(abi), argc, rb_fiddle_int_to_ffi_type(NUM2INT(ret)), cl->argv); if (FFI_OK != result) rb_raise(rb_eRuntimeError, "error prepping CIF %d", result); #if USE_FFI_CLOSURE_ALLOC result = ffi_prep_closure_loc(pcl, cif, callback, (void *)self, cl->code); #else result = ffi_prep_closure(pcl, cif, callback, (void *)self); cl->code = (void *)pcl; i = mprotect(pcl, sizeof(*pcl), PROT_READ | PROT_EXEC); if (i) { rb_sys_fail("mprotect"); } #endif if (FFI_OK != result) rb_raise(rb_eRuntimeError, "error prepping closure %d", result); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Closure#to_i;F;7[;[[@,i%;T;;;0;[;{;IC; "0Returns the memory address for this closure ;T;[;![;"I"2 Returns the memory address for this closure ;T;#0;$@6;.F;/o;0;1T;2ia;3ic;%@!;9I"static VALUE to_i(VALUE self) { fiddle_closure * cl; void *code; TypedData_Get_Struct(self, fiddle_closure, &closure_data_type, cl); code = cl->code; return PTR2NUM(code); };T;:I"static VALUE;T;;T; @!; IC;[; @!; IC;[; @!; IC;{;IC;{;T;IC;{;T;T;{;[;[[@,i9[@,iM;T;: Closure;;;;;[;{;IC; "h== Description An FFI closure wrapper, for handling callbacks. == Example closure = Class.new(Fiddle::Closure) { def call 10 end }.new(Fiddle::TYPE_INT, []) #=> #<#:0x0000000150d240> func = Fiddle::Function.new(closure, [], Fiddle::TYPE_INT) #=> # func.call #=> 10 ;T;[;![;"I"j == Description An FFI closure wrapper, for handling callbacks. == Example closure = Class.new(Fiddle::Closure) { def call 10 end }.new(Fiddle::TYPE_INT, []) #=> #<#:0x0000000150d240> func = Fiddle::Function.new(closure, [], Fiddle::TYPE_INT) #=> # func.call #=> 10 ;T;#0;$@!;.F;/o;0;1T;2i9;3iJ;%@;&I"Fiddle::Closure;F;'@o; ;IC;[!o;4;5F;6;;;;&I"Fiddle::Pointer.malloc;F;7[[I" argv[];T0[I" klass;T0;[[I"ext/fiddle/pointer.c;Ti(;T;: malloc;0;[;{;IC; "K== Examples # Automatically freeing the pointer when the block is exited - recommended Fiddle::Pointer.malloc(size, Fiddle::RUBY_FREE) do |pointer| ... end # Manually freeing but relying on the garbage collector otherwise pointer = Fiddle::Pointer.malloc(size, Fiddle::RUBY_FREE) ... pointer.call_free # Relying on the garbage collector - may lead to unlimited memory allocated before freeing any, but safe pointer = Fiddle::Pointer.malloc(size, Fiddle::RUBY_FREE) ... # Only manually freeing pointer = Fiddle::Pointer.malloc(size) begin ... ensure Fiddle.free pointer end # No free function and no call to free - the native memory will leak if the pointer is garbage collected pointer = Fiddle::Pointer.malloc(size) ... Allocate +size+ bytes of memory and associate it with an optional +freefunc+. If a block is supplied, the pointer will be yielded to the block instead of being returned, and the return value of the block will be returned. A +freefunc+ must be supplied if a block is. If a +freefunc+ is supplied it will be called once, when the pointer is garbage collected or when the block is left if a block is supplied or when the user calls +call_free+, whichever happens first. +freefunc+ must be an address pointing to a function or an instance of +Fiddle::Function+. ;T;[o;= ;>I" overload;F;?0;:Fiddle::Pointer.malloc;@0;:I"1Fiddle::Pointer.malloc(size, freefunc = nil);T;IC; ";T;[;![;"I";T;#0;$@X;.F;Bi;C0;7[[I" size;T0[I" freefunc;TI"nil;T;$@Xo;= ;>I" overload;F;?0;; ;@0;:I"+Fiddle::Pointer.malloc(size, freefunc);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" pointer;T;$@X;![;"I"@yield [pointer];T;#0;$@X;.F;Bi;C0;7[[I" size;T0[I" freefunc;T0;$@X;![;"I"== Examples # Automatically freeing the pointer when the block is exited - recommended Fiddle::Pointer.malloc(size, Fiddle::RUBY_FREE) do |pointer| ... end # Manually freeing but relying on the garbage collector otherwise pointer = Fiddle::Pointer.malloc(size, Fiddle::RUBY_FREE) ... pointer.call_free # Relying on the garbage collector - may lead to unlimited memory allocated before freeing any, but safe pointer = Fiddle::Pointer.malloc(size, Fiddle::RUBY_FREE) ... # Only manually freeing pointer = Fiddle::Pointer.malloc(size) begin ... ensure Fiddle.free pointer end # No free function and no call to free - the native memory will leak if the pointer is garbage collected pointer = Fiddle::Pointer.malloc(size) ... Allocate +size+ bytes of memory and associate it with an optional +freefunc+. If a block is supplied, the pointer will be yielded to the block instead of being returned, and the return value of the block will be returned. A +freefunc+ must be supplied if a block is. If a +freefunc+ is supplied it will be called once, when the pointer is garbage collected or when the block is left if a block is supplied or when the user calls +call_free+, whichever happens first. +freefunc+ must be an address pointing to a function or an instance of +Fiddle::Function+. @overload Fiddle::Pointer.malloc(size, freefunc = nil) @overload Fiddle::Pointer.malloc(size, freefunc) @yield [pointer];T;#0;$@X;.F;/o;0;1T;2i;3i&;%@V;9I"static VALUE rb_fiddle_ptr_s_malloc(int argc, VALUE argv[], VALUE klass) { VALUE size, sym, obj, wrap = 0; long s; freefunc_t f; switch (rb_scan_args(argc, argv, "11", &size, &sym)) { case 1: s = NUM2LONG(size); f = NULL; break; case 2: s = NUM2LONG(size); f = get_freefunc(sym, &wrap); break; default: rb_bug("rb_fiddle_ptr_s_malloc"); } obj = rb_fiddle_ptr_malloc(klass, s,f); if (wrap) RPTR_DATA(obj)->wrap[1] = wrap; if (rb_block_given_p()) { if (!f) { rb_raise(rb_eArgError, "a free function must be supplied to Fiddle::Pointer.malloc when it is called with a block"); } return rb_ensure(rb_yield, obj, rb_fiddle_ptr_call_free, obj); } else { return obj; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer.to_ptr;F;7[[I"val;T0;[[@ai;T;: to_ptr;0;[;{;IC; "`Get the underlying pointer for ruby object +val+ and return it as a Fiddle::Pointer object. ;T;[o;= ;>I" overload;F;?0;:Fiddle::Pointer;@0;:I"Fiddle::Pointer[val];T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;; ;@0;:I"to_ptr(val);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"val;T0;$@;![;"I"Get the underlying pointer for ruby object +val+ and return it as a Fiddle::Pointer object. @overload Fiddle::Pointer[val] @overload to_ptr(val);T;#0;$@;.F;/o;0;1T;2i;3i;%@V;9I"nstatic VALUE rb_fiddle_ptr_s_to_ptr(VALUE self, VALUE val) { VALUE ptr, wrap = val, vptr; if (RTEST(rb_obj_is_kind_of(val, rb_cIO))){ rb_io_t *fptr; FILE *fp; GetOpenFile(val, fptr); fp = rb_io_stdio_file(fptr); ptr = rb_fiddle_ptr_new(fp, 0, NULL); } else if (RTEST(rb_obj_is_kind_of(val, rb_cString))){ char *str = StringValuePtr(val); wrap = val; ptr = rb_fiddle_ptr_new(str, RSTRING_LEN(val), NULL); } else if ((vptr = rb_check_funcall(val, id_to_ptr, 0, 0)) != Qundef){ if (rb_obj_is_kind_of(vptr, rb_cPointer)){ ptr = vptr; wrap = 0; } else{ rb_raise(rb_eFiddleDLError, "to_ptr should return a Fiddle::Pointer object"); } } else{ VALUE num = rb_Integer(val); if (num == val) wrap = 0; ptr = rb_fiddle_ptr_new(NUM2PTR(num), 0, NULL); } if (wrap) RPTR_DATA(ptr)->wrap[0] = wrap; return ptr; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer.[];F;7[[I"val;T0;[[@ai;T;;;0;[;{;IC; "`Get the underlying pointer for ruby object +val+ and return it as a Fiddle::Pointer object. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"Fiddle::Pointer[val];T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;; ;@0;:I"to_ptr(val);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"val;T0;$@;![;"@;#0;$@;.F;/o;0;1T;2i;3i;%@V;9I"nstatic VALUE rb_fiddle_ptr_s_to_ptr(VALUE self, VALUE val) { VALUE ptr, wrap = val, vptr; if (RTEST(rb_obj_is_kind_of(val, rb_cIO))){ rb_io_t *fptr; FILE *fp; GetOpenFile(val, fptr); fp = rb_io_stdio_file(fptr); ptr = rb_fiddle_ptr_new(fp, 0, NULL); } else if (RTEST(rb_obj_is_kind_of(val, rb_cString))){ char *str = StringValuePtr(val); wrap = val; ptr = rb_fiddle_ptr_new(str, RSTRING_LEN(val), NULL); } else if ((vptr = rb_check_funcall(val, id_to_ptr, 0, 0)) != Qundef){ if (rb_obj_is_kind_of(vptr, rb_cPointer)){ ptr = vptr; wrap = 0; } else{ rb_raise(rb_eFiddleDLError, "to_ptr should return a Fiddle::Pointer object"); } } else{ VALUE num = rb_Integer(val); if (num == val) wrap = 0; ptr = rb_fiddle_ptr_new(NUM2PTR(num), 0, NULL); } if (wrap) RPTR_DATA(ptr)->wrap[0] = wrap; return ptr; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#initialize;F;7[[I" argv[];T0[I" self;T0;[[@ai;T;;D;0;[;{;IC; "Create a new pointer to +address+ with an optional +size+ and +freefunc+. +freefunc+ will be called when the instance is garbage collected. ;T;[o;= ;>I" overload;F;?0;:Fiddle::Pointer.new;@0;:I"!Fiddle::Pointer.new(address);T;IC; ";T;[;![;"I";T;#0;$@̐;.F;Bi;C0;7[[I" address;T0;$@̐o;= ;>I" overload;F;?0;;E;@0;:I"'new(address, size) => fiddle_cptr;T;IC; ";T;[;![;"I";T;#0;$@̐;.F;Bi;C0;7[[I" address;T0[I" size;T0;$@̐o;= ;>I" overload;F;?0;;E;@0;:I"0new(address, size, freefunc) => fiddle_cptr;T;IC; ";T;[;![;"I";T;#0;$@̐;.F;Bi;C0;7[[I" address;T0[I" size;T0[I" freefunc;T0;$@̐;![;"I"Create a new pointer to +address+ with an optional +size+ and +freefunc+. +freefunc+ will be called when the instance is garbage collected. @overload Fiddle::Pointer.new(address) @overload new(address, size) => fiddle_cptr @overload new(address, size, freefunc) => fiddle_cptr;T;#0;$@̐;.F;/o;0;1T;2i;3i;%@V;9I"Sstatic VALUE rb_fiddle_ptr_initialize(int argc, VALUE argv[], VALUE self) { VALUE ptr, sym, size, wrap = 0, funcwrap = 0; struct ptr_data *data; void *p = NULL; freefunc_t f = NULL; long s = 0; if (rb_scan_args(argc, argv, "12", &ptr, &size, &sym) >= 1) { VALUE addrnum = rb_Integer(ptr); if (addrnum != ptr) wrap = ptr; p = NUM2PTR(addrnum); } if (argc >= 2) { s = NUM2LONG(size); } if (argc >= 3) { f = get_freefunc(sym, &funcwrap); } if (p) { TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data); if (data->ptr && data->free) { /* Free previous memory. Use of inappropriate initialize may cause SEGV. */ (*(data->free))(data->ptr); } data->wrap[0] = wrap; data->wrap[1] = funcwrap; data->ptr = p; data->size = s; data->free = f; } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#free=;F;7[[I"val;T0;[[@ai;T;: free=;0;[;{;IC; "XSet the free function for this pointer to +function+ in the given Fiddle::Function. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"free=(function);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" function;T0;$@;![;"I"tSet the free function for this pointer to +function+ in the given Fiddle::Function. @overload free=(function);T;#0;$@;.F;/o;0;1T;2i;3i;%@V;9I"static VALUE rb_fiddle_ptr_free_set(VALUE self, VALUE val) { struct ptr_data *data; TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data); data->free = get_freefunc(val, &data->wrap[1]); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#free;F;7[;[[@ai;T;;;0;[;{;IC; "sGet the free function for this pointer. Returns a new instance of Fiddle::Function. See Fiddle::Function.new ;T;[o;= ;>I" overload;F;?0;;;@0;:I" free;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Fiddle::Function;T;$@;![;"I"@return [Fiddle::Function];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Get the free function for this pointer. Returns a new instance of Fiddle::Function. See Fiddle::Function.new @overload free @return [Fiddle::Function];T;#0;$@;.F;/o;0;1T;2i;3i;%@V;9I"static VALUE rb_fiddle_ptr_free_get(VALUE self) { struct ptr_data *pdata; VALUE address; VALUE arg_types; VALUE ret_type; TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, pdata); if (!pdata->free) return Qnil; address = PTR2NUM(pdata->free); ret_type = INT2NUM(TYPE_VOID); arg_types = rb_ary_new(); rb_ary_push(arg_types, INT2NUM(TYPE_VOIDP)); return rb_fiddle_new_function(address, arg_types, ret_type); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#call_free;F;7[;[[@ai;T;:call_free;0;[;{;IC; "Call the free function for this pointer. Calling more than once will do nothing. Does nothing if there is no free function attached. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"call_free;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@7;![;"I"@return [nil];T;#0;$@7;.F;Bi;C0;7[;$@7;![;"I"Call the free function for this pointer. Calling more than once will do nothing. Does nothing if there is no free function attached. @overload call_free @return [nil];T;#0;$@7;.F;/o;0;1T;2i;3i;%@V;9I"static VALUE rb_fiddle_ptr_call_free(VALUE self) { struct ptr_data *pdata; TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, pdata); fiddle_ptr_free_ptr(pdata); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#freed?;F;7[;[[@ai;T;: freed?;0;[;{;IC; "CReturns if the free function for this pointer has been called.;T;[o;= ;>I" overload;F;?0;; ;@0;:I" freed?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@R;![;"I"@return [Boolean];T;#0;$@R;.F;Bi;C0;7[;$@R;![;"I"jReturns if the free function for this pointer has been called. @overload freed? @return [Boolean];T;#0;$@R;.F;/o;0;1T;2i;3i;Bi;%@V;9I"static VALUE rb_fiddle_ptr_freed_p(VALUE self) { struct ptr_data *pdata; TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, pdata); return pdata->freed ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#to_i;F;7[;[[@aiN;T;;;0;[;{;IC; "9Returns the integer memory location of this pointer. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_i;T;IC; ";T;[;![;"I";T;#0;$@m;.F;Bi;C0;7[;$@m;![;"I"JReturns the integer memory location of this pointer. @overload to_i;T;#0;$@m;.F;/o;0;1T;2iI;3iL;%@V;9I"static VALUE rb_fiddle_ptr_to_i(VALUE self) { struct ptr_data *data; TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data); return PTR2NUM(data->ptr); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#to_int;F;7[;[[@aiN;T;;;0;[;{;IC; "9Returns the integer memory location of this pointer. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_i;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2iI;3iL;%@V;9I"static VALUE rb_fiddle_ptr_to_i(VALUE self) { struct ptr_data *data; TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data); return PTR2NUM(data->ptr); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#to_value;F;7[;[[@ai\;T;: to_value;0;[;{;IC; "(Cast this pointer to a ruby object. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" to_value;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"=Cast this pointer to a ruby object. @overload to_value;T;#0;$@;.F;/o;0;1T;2iW;3iZ;%@V;9I"static VALUE rb_fiddle_ptr_to_value(VALUE self) { struct ptr_data *data; TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data); return (VALUE)(data->ptr); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#ptr;F;7[;[[@ail;T;:ptr;0;[;{;IC; "}Returns a new Fiddle::Pointer instance that is a dereferenced pointer for this pointer. Analogous to the star operator in C. ;T;[o;= ;>I" overload;F;?0;;! ;@0;:I"ptr;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a new Fiddle::Pointer instance that is a dereferenced pointer for this pointer. Analogous to the star operator in C. @overload ptr;T;#0;$@;.F;/o;0;1T;2id;3ij;%@V;9I"static VALUE rb_fiddle_ptr_ptr(VALUE self) { struct ptr_data *data; TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data); return rb_fiddle_ptr_new(*((void**)(data->ptr)),0,0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#+@;F;7[;[[@ail;T;;;0;[;{;IC; "}Returns a new Fiddle::Pointer instance that is a dereferenced pointer for this pointer. Analogous to the star operator in C. ;T;[o;= ;>I" overload;F;?0;;! ;@0;:I"ptr;T;IC; ";T;[;![;"I";T;#0;$@đ;.F;Bi;C0;7[;$@đ;![;"@;#0;$@đ;.F;/o;0;1T;2id;3ij;%@V;9I"static VALUE rb_fiddle_ptr_ptr(VALUE self) { struct ptr_data *data; TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data); return rb_fiddle_ptr_new(*((void**)(data->ptr)),0,0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#ref;F;7[;[[@ai};T;:ref;0;[;{;IC; "Returns a new Fiddle::Pointer instance that is a reference pointer for this pointer. Analogous to the ampersand operator in C. ;T;[o;= ;>I" overload;F;?0;;" ;@0;:I"ref;T;IC; ";T;[;![;"I";T;#0;$@ّ;.F;Bi;C0;7[;$@ّ;![;"I"Returns a new Fiddle::Pointer instance that is a reference pointer for this pointer. Analogous to the ampersand operator in C. @overload ref;T;#0;$@ّ;.F;/o;0;1T;2iu;3i{;%@V;9I"static VALUE rb_fiddle_ptr_ref(VALUE self) { struct ptr_data *data; TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data); return rb_fiddle_ptr_new(&(data->ptr),0,0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#-@;F;7[;[[@ai};T;;;0;[;{;IC; "Returns a new Fiddle::Pointer instance that is a reference pointer for this pointer. Analogous to the ampersand operator in C. ;T;[o;= ;>I" overload;F;?0;;" ;@0;:I"ref;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2iu;3i{;%@V;9I"static VALUE rb_fiddle_ptr_ref(VALUE self) { struct ptr_data *data; TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data); return rb_fiddle_ptr_new(&(data->ptr),0,0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#null?;F;7[;[[@ai;T;;;0;[;{;IC; ".Returns +true+ if this is a null pointer.;T;[o;= ;>I" overload;F;?0;;;@0;:I" null?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"@Returns +true+ if this is a null pointer. @overload null?;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@V;9I"static VALUE rb_fiddle_ptr_null_p(VALUE self) { struct ptr_data *data; TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data); return data->ptr ? Qfalse : Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#to_s;F;7[[I" argv[];T0[I" self;T0;[[@ai;T;;G;0;[;{;IC; "Returns the pointer contents as a string. When called with no arguments, this method will return the contents until the first NULL byte. When called with +len+, a string of +len+ bytes will be returned. See to_str ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;G;@0;:I"to_s(len);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I"len;T0;$@;![;"I"#Returns the pointer contents as a string. When called with no arguments, this method will return the contents until the first NULL byte. When called with +len+, a string of +len+ bytes will be returned. See to_str @overload to_s @return [String] @overload to_s(len) @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@V;9I"static VALUE rb_fiddle_ptr_to_s(int argc, VALUE argv[], VALUE self) { struct ptr_data *data; VALUE arg1, val; int len; TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data); switch (rb_scan_args(argc, argv, "01", &arg1)) { case 0: val = rb_str_new2((char*)(data->ptr)); break; case 1: len = NUM2INT(arg1); val = rb_str_new((char*)(data->ptr), len); break; default: rb_bug("rb_fiddle_ptr_to_s"); } return val; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#to_str;F;7[[I" argv[];T0[I" self;T0;[[@ai;T;;p ;0;[;{;IC; "Returns the pointer contents as a string. When called with no arguments, this method will return the contents with the length of this pointer's +size+. When called with +len+, a string of +len+ bytes will be returned. See to_s ;T;[o;= ;>I" overload;F;?0;;p ;@0;:I" to_str;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@K;![;"I"@return [String];T;#0;$@K;.F;Bi;C0;7[;$@Ko;= ;>I" overload;F;?0;;p ;@0;:I"to_str(len);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@K;![;"I"@return [String];T;#0;$@K;.F;Bi;C0;7[[I"len;T0;$@K;![;"I"4Returns the pointer contents as a string. When called with no arguments, this method will return the contents with the length of this pointer's +size+. When called with +len+, a string of +len+ bytes will be returned. See to_s @overload to_str @return [String] @overload to_str(len) @return [String];T;#0;$@K;.F;/o;0;1T;2i;3i;%@V;9I"static VALUE rb_fiddle_ptr_to_str(int argc, VALUE argv[], VALUE self) { struct ptr_data *data; VALUE arg1, val; int len; TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data); switch (rb_scan_args(argc, argv, "01", &arg1)) { case 0: val = rb_str_new((char*)(data->ptr),data->size); break; case 1: len = NUM2INT(arg1); val = rb_str_new((char*)(data->ptr), len); break; default: rb_bug("rb_fiddle_ptr_to_str"); } return val; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#inspect;F;7[;[[@ai1;T;;J;0;[;{;IC; "lReturns a string formatted with an easily readable representation of the internal state of the pointer. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[;![;"I";T;#0;$@y;.F;Bi;C0;7[;$@y;![;"I"{Returns a string formatted with an easily readable representation of the internal state of the pointer. @overload inspect;T;#0;$@y;.F;/o;0;1T;2i+;3i/;%@V;9I":static VALUE rb_fiddle_ptr_inspect(VALUE self) { struct ptr_data *data; TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data); return rb_sprintf("#<%"PRIsVALUE":%p ptr=%p size=%ld free=%p>", RB_OBJ_CLASSNAME(self), (void *)data, data->ptr, data->size, (void *)data->free); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#<=>;F;7[[I" other;T0;[[@aiX;T;;Y;0;[;{;IC; "|Returns -1 if less than, 0 if equal to, 1 if greater than +other+. Returns nil if +ptr+ cannot be compared to +other+. ;T;[o;= ;>I" overload;F;?0;;Y;@0;:I"<=>(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[ I"-1;TI"0;TI"1;TI"nil;T;$@;![;"I"@return [-1, 0, 1, nil];T;#0;$@;.F;Bi;C0;7[[I" other;T0;$@;![;"I"Returns -1 if less than, 0 if equal to, 1 if greater than +other+. Returns nil if +ptr+ cannot be compared to +other+. @overload <=>(other) @return [-1, 0, 1, nil];T;#0;$@;.F;/o;0;1T;2iP;3iV;%@V;9I"xstatic VALUE rb_fiddle_ptr_cmp(VALUE self, VALUE other) { void *ptr1, *ptr2; SIGNED_VALUE diff; if(!rb_obj_is_kind_of(other, rb_cPointer)) return Qnil; ptr1 = rb_fiddle_ptr2cptr(self); ptr2 = rb_fiddle_ptr2cptr(other); diff = (SIGNED_VALUE)ptr1 - (SIGNED_VALUE)ptr2; if (!diff) return INT2FIX(0); return diff > 0 ? INT2NUM(1) : INT2NUM(-1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#==;F;7[[I" other;T0;[[@aiC;T;;F;0;[;{;IC; "MReturns true if +other+ wraps the same pointer, otherwise returns false. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" other;T0;$@o;= ;>I" overload;F;?0;;V;@0;:I"eql?(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" other;T0;$@;![;"I"Returns true if +other+ wraps the same pointer, otherwise returns false. @overload ==(other) @return [Boolean] @overload eql?(other) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;;3iB;%@V;9I"static VALUE rb_fiddle_ptr_eql(VALUE self, VALUE other) { void *ptr1, *ptr2; if(!rb_obj_is_kind_of(other, rb_cPointer)) return Qfalse; ptr1 = rb_fiddle_ptr2cptr(self); ptr2 = rb_fiddle_ptr2cptr(other); return ptr1 == ptr2 ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#eql?;F;7[[I" other;T0;[[@aiC;T;;V;0;[;{;IC; "MReturns true if +other+ wraps the same pointer, otherwise returns false.;T;[o;= ;>I" overload;F;?0;;F;@0;:I"==(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ߒ;![;"I"@return [Boolean];T;#0;$@ߒ;.F;Bi;C0;7[[I" other;T0;$@ߒo;= ;>I" overload;F;?0;;V;@0;:I"eql?(other);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@ߒ;![;"I"@return [Boolean];T;#0;$@ߒ;.F;Bi;C0;7[[I" other;T0;$@ߒ;![;"@ے;#0;$@ߒ;.F;/o;0;1T;2i;;3iB;Bi;%@V;9I"static VALUE rb_fiddle_ptr_eql(VALUE self, VALUE other) { void *ptr1, *ptr2; if(!rb_obj_is_kind_of(other, rb_cPointer)) return Qfalse; ptr1 = rb_fiddle_ptr2cptr(self); ptr2 = rb_fiddle_ptr2cptr(other); return ptr1 == ptr2 ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#+;F;7[[I" other;T0;[[@aim;T;;;0;[;{;IC; "EReturns a new pointer instance that has been advanced +n+ bytes. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" +(n);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I"n;T0;$@ ;![;"I"VReturns a new pointer instance that has been advanced +n+ bytes. @overload +(n);T;#0;$@ ;.F;/o;0;1T;2ig;3ij;%@V;9I"static VALUE rb_fiddle_ptr_plus(VALUE self, VALUE other) { void *ptr; long num, size; ptr = rb_fiddle_ptr2cptr(self); size = RPTR_DATA(self)->size; num = NUM2LONG(other); return rb_fiddle_ptr_new((char *)ptr + num, size - num, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#-;F;7[[I" other;T0;[[@ai;T;;;0;[;{;IC; "GReturns a new pointer instance that has been moved back +n+ bytes. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" -(n);T;IC; ";T;[;![;"I";T;#0;$@&;.F;Bi;C0;7[[I"n;T0;$@&;![;"I"XReturns a new pointer instance that has been moved back +n+ bytes. @overload -(n);T;#0;$@&;.F;/o;0;1T;2iy;3i|;%@V;9I"static VALUE rb_fiddle_ptr_minus(VALUE self, VALUE other) { void *ptr; long num, size; ptr = rb_fiddle_ptr2cptr(self); size = RPTR_DATA(self)->size; num = NUM2LONG(other); return rb_fiddle_ptr_new((char *)ptr - num, size + num, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#[];F;7[[I" argv[];T0[I" self;T0;[[@ai;T;;;0;[;{;IC; "Returns integer stored at _index_. If _start_ and _length_ are given, a string containing the bytes from _start_ of _length_ will be returned. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"[](index);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@@;![;"I"@return [Integer];T;#0;$@@;.F;Bi;C0;7[[I" index;T0;$@@o;= ;>I" overload;F;?0;;;@0;:I"[](start, length);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@@;![;"I"@return [String];T;#0;$@@;.F;Bi;C0;7[[I" start;T0[I" length;T0;$@@;![;"I"Returns integer stored at _index_. If _start_ and _length_ are given, a string containing the bytes from _start_ of _length_ will be returned. @overload [](index) @return [Integer] @overload [](start, length) @return [String];T;#0;$@@;.F;/o;0;1T;2i;3i;%@V;9I"static VALUE rb_fiddle_ptr_aref(int argc, VALUE argv[], VALUE self) { VALUE arg0, arg1; VALUE retval = Qnil; size_t offset, len; struct ptr_data *data; TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data); if (!data->ptr) rb_raise(rb_eFiddleDLError, "NULL pointer dereference"); switch( rb_scan_args(argc, argv, "11", &arg0, &arg1) ){ case 1: offset = NUM2ULONG(arg0); retval = INT2NUM(*((char *)data->ptr + offset)); break; case 2: offset = NUM2ULONG(arg0); len = NUM2ULONG(arg1); retval = rb_str_new((char *)data->ptr + offset, len); break; default: rb_bug("rb_fiddle_ptr_aref()"); } return retval; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#[]=;F;7[[I" argv[];T0[I" self;T0;[[@ai;T;;8;0;[;{;IC; "Set the value at +index+ to +int+. Or, set the memory at +start+ until +length+ with the contents of +string+, the memory from +dl_cptr+, or the memory pointed at by the memory address +addr+. ;T;[o;= ;>I" overload;F;?0;;8;@0;:I"[]=(index);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@r;![;"I"@return [Integer];T;#0;$@r;.F;Bi;C0;7[[I" index;T0;$@ro;= ;>I" overload;F;?0;;8;@0;:I"[]=(start, length);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@r;![;"I"@return [String];T;#0;$@r;.F;Bi;C0;7[[I" start;T0[I" length;T0;$@r;![;"I"Set the value at +index+ to +int+. Or, set the memory at +start+ until +length+ with the contents of +string+, the memory from +dl_cptr+, or the memory pointed at by the memory address +addr+. @overload []=(index) @return [Integer] @overload []=(start, length) @return [String];T;#0;$@r;.F;/o;0;1T;2i;3i;%@V;9I"static VALUE rb_fiddle_ptr_aset(int argc, VALUE argv[], VALUE self) { VALUE arg0, arg1, arg2; VALUE retval = Qnil; size_t offset, len; void *mem; struct ptr_data *data; TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data); if (!data->ptr) rb_raise(rb_eFiddleDLError, "NULL pointer dereference"); switch( rb_scan_args(argc, argv, "21", &arg0, &arg1, &arg2) ){ case 2: offset = NUM2ULONG(arg0); ((char*)data->ptr)[offset] = NUM2UINT(arg1); retval = arg1; break; case 3: offset = NUM2ULONG(arg0); len = NUM2ULONG(arg1); if (RB_TYPE_P(arg2, T_STRING)) { mem = StringValuePtr(arg2); } else if( rb_obj_is_kind_of(arg2, rb_cPointer) ){ mem = rb_fiddle_ptr2cptr(arg2); } else{ mem = NUM2PTR(arg2); } memcpy((char *)data->ptr + offset, mem, len); retval = arg2; break; default: rb_bug("rb_fiddle_ptr_aset()"); } return retval; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#size;F;7[;[[@ai;T;;;0;[;{;IC; ""Get the size of this pointer. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"3Get the size of this pointer. @overload size;T;#0;$@;.F;/o;0;1T;2i;3i;%@V;9I"dstatic VALUE rb_fiddle_ptr_size_get(VALUE self) { return LONG2NUM(RPTR_DATA(self)->size); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pointer#size=;F;7[[I" size;T0;[[@ai;T;: size=;0;[;{;IC; "+Set the size of this pointer to +size+ ;T;[o;= ;>I" overload;F;?0;;# ;@0;:I"size=(size);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" size;T0;$@;![;"I"CSet the size of this pointer to +size+ @overload size=(size);T;#0;$@;.F;/o;0;1T;2i;3i;%@V;9I"|static VALUE rb_fiddle_ptr_size_set(VALUE self, VALUE size) { RPTR_DATA(self)->size = NUM2LONG(size); return size; };T;:I"static VALUE;T;;T; @V; IC;[; @V; IC;[; @V; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ai([@ai-;T;: Pointer;;;;;[;{;IC; "4Fiddle::Pointer is a class to handle C pointers ;T;[;![;"I"7 Fiddle::Pointer is a class to handle C pointers ;T;#0;$@V;.F;/o;0;1T;2i(;3i+;%@;&I"Fiddle::Pointer;F;'@o;u;[[@aiT;F;;";;w;;;[;{;IC; "A NULL pointer ;T;[;![;"I" A NULL pointer ;T;#0;$@;.F;/o;0;1T;2iP;3iR;%@;&I"Fiddle::NULL;F;xI"rb_fiddle_ptr_new(0, 0, 0);To; ;IC;[ o;u;[[I"ext/fiddle/function.c;Ti;F;;;;w;;;[;{;IC; "Default ABI ;T;[;![;"I" Default ABI ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::Function::DEFAULT;F;xI"INT2NUM(FFI_DEFAULT_ABI);To;u;[[@i;F;: STDCALL;;w;;;[;{;IC; "3FFI implementation of WIN32 stdcall convention ;T;[;![;"I"6 FFI implementation of WIN32 stdcall convention ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::Function::STDCALL;F;xI"INT2NUM(FFI_STDCALL);To;4;5F;6;;;;&I"Fiddle::Function#call;F;7[[I" argv[];T0[I" self;T0;[[@i;T;;;0;[;{;IC; "tCalls the constructed Function, with +args+. Caller must ensure the underlying function is called in a thread-safe manner if running in a multi-threaded process. Note that it is not thread-safe to use this method to directly or indirectly call many Ruby C-extension APIs unless you don't pass +need_gvl: true+ to Fiddle::Function#new. For an example see Fiddle::Function ;T;[;![;"I"w Calls the constructed Function, with +args+. Caller must ensure the underlying function is called in a thread-safe manner if running in a multi-threaded process. Note that it is not thread-safe to use this method to directly or indirectly call many Ruby C-extension APIs unless you don't pass +need_gvl: true+ to Fiddle::Function#new. For an example see Fiddle::Function ;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;9I"static VALUE function_call(int argc, VALUE argv[], VALUE self) { struct nogvl_ffi_call_args args = { 0 }; fiddle_generic *generic_args; VALUE cfunc; VALUE abi; VALUE arg_types; VALUE cPointer; VALUE is_variadic; VALUE need_gvl; int n_arg_types; int n_fixed_args = 0; int n_call_args = 0; int i; int i_call; VALUE converted_args = Qnil; VALUE alloc_buffer = 0; cfunc = rb_iv_get(self, "@ptr"); abi = rb_iv_get(self, "@abi"); arg_types = rb_iv_get(self, "@argument_types"); cPointer = rb_const_get(mFiddle, rb_intern("Pointer")); is_variadic = rb_iv_get(self, "@is_variadic"); need_gvl = rb_iv_get(self, "@need_gvl"); n_arg_types = RARRAY_LENINT(arg_types); n_fixed_args = n_arg_types; if (RTEST(is_variadic)) { if (argc < n_arg_types) { rb_error_arity(argc, n_arg_types, UNLIMITED_ARGUMENTS); } if (((argc - n_arg_types) % 2) != 0) { rb_raise(rb_eArgError, "variadic arguments must be type and value pairs: " "%"PRIsVALUE, rb_ary_new_from_values(argc, argv)); } n_call_args = n_arg_types + ((argc - n_arg_types) / 2); } else { if (argc != n_arg_types) { rb_error_arity(argc, n_arg_types, n_arg_types); } n_call_args = n_arg_types; } Check_Max_Args("the number of arguments", n_call_args); TypedData_Get_Struct(self, ffi_cif, &function_data_type, args.cif); if (is_variadic && args.cif->arg_types) { xfree(args.cif->arg_types); args.cif->arg_types = NULL; } if (!args.cif->arg_types) { VALUE fixed_arg_types = arg_types; VALUE return_type; int c_return_type; ffi_type *ffi_return_type; ffi_type **ffi_arg_types; ffi_status result; arg_types = rb_ary_dup(fixed_arg_types); for (i = n_fixed_args; i < argc; i += 2) { VALUE arg_type = argv[i]; int c_arg_type; arg_type = rb_fiddle_type_ensure(arg_type); c_arg_type = NUM2INT(arg_type); (void)INT2FFI_TYPE(c_arg_type); /* raise */ rb_ary_push(arg_types, INT2FIX(c_arg_type)); } return_type = rb_iv_get(self, "@return_type"); c_return_type = FIX2INT(return_type); ffi_return_type = INT2FFI_TYPE(c_return_type); ffi_arg_types = xcalloc(n_call_args + 1, sizeof(ffi_type *)); for (i_call = 0; i_call < n_call_args; i_call++) { VALUE arg_type; int c_arg_type; arg_type = RARRAY_AREF(arg_types, i_call); c_arg_type = FIX2INT(arg_type); ffi_arg_types[i_call] = INT2FFI_TYPE(c_arg_type); } ffi_arg_types[i_call] = NULL; if (is_variadic) { #ifdef HAVE_FFI_PREP_CIF_VAR result = ffi_prep_cif_var(args.cif, FIX2INT(abi), n_fixed_args, n_call_args, ffi_return_type, ffi_arg_types); #else /* This code is never used because ffi_prep_cif_var() * availability check is done in #initialize. */ result = FFI_BAD_TYPEDEF; #endif } else { result = ffi_prep_cif(args.cif, FIX2INT(abi), n_call_args, ffi_return_type, ffi_arg_types); } if (result != FFI_OK) { xfree(ffi_arg_types); args.cif->arg_types = NULL; rb_raise(rb_eRuntimeError, "error creating CIF %d", result); } } generic_args = ALLOCV(alloc_buffer, sizeof(fiddle_generic) * n_call_args + sizeof(void *) * (n_call_args + 1)); args.values = (void **)((char *)generic_args + sizeof(fiddle_generic) * n_call_args); for (i = 0, i_call = 0; i < argc && i_call < n_call_args; i++, i_call++) { VALUE arg_type; int c_arg_type; VALUE original_src; VALUE src; arg_type = RARRAY_AREF(arg_types, i_call); c_arg_type = FIX2INT(arg_type); if (i >= n_fixed_args) { i++; } src = argv[i]; if (c_arg_type == TYPE_VOIDP) { if (NIL_P(src)) { src = INT2FIX(0); } else if (cPointer != CLASS_OF(src)) { src = rb_funcall(cPointer, rb_intern("[]"), 1, src); if (NIL_P(converted_args)) { converted_args = rb_ary_new(); } rb_ary_push(converted_args, src); } src = rb_Integer(src); } original_src = src; VALUE2GENERIC(c_arg_type, src, &generic_args[i_call]); if (src != original_src) { if (NIL_P(converted_args)) { converted_args = rb_ary_new(); } rb_ary_push(converted_args, src); } args.values[i_call] = (void *)&generic_args[i_call]; } args.values[i_call] = NULL; args.fn = (void(*)(void))NUM2PTR(cfunc); if (RTEST(need_gvl)) { ffi_call(args.cif, args.fn, &(args.retval), args.values); } else { (void)rb_thread_call_without_gvl(nogvl_ffi_call, &args, 0, 0); } { int errno_keep = errno; #if defined(_WIN32) DWORD error = WSAGetLastError(); int socket_error = WSAGetLastError(); rb_funcall(mFiddle, rb_intern("win32_last_error="), 1, ULONG2NUM(error)); rb_funcall(mFiddle, rb_intern("win32_last_socket_error="), 1, INT2NUM(socket_error)); #endif rb_funcall(mFiddle, rb_intern("last_error="), 1, INT2NUM(errno_keep)); } ALLOCV_END(alloc_buffer); return GENERIC2VALUE(rb_iv_get(self, "@return_type"), args.retval); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Fiddle::Function#initialize;F;7[[I" argv[];T0[I" self;T0;[[@i~;T;;D;0;[;{;IC; "FConstructs a Function object. * +ptr+ is a referenced function, of a Fiddle::Handle * +args+ is an Array of arguments, passed to the +ptr+ function * +ret_type+ is the return type of the function * +abi+ is the ABI of the function * +name+ is the name of the function * +need_gvl+ is whether GVL is needed to call the function ;T;[ o;= ;>I" overload;F;?0;;E;@0;:I" new(ptr,;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"ptr;T0;$@o;= ;>I" overload;F;?0;;q ;@0;:I" args,;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;: ret_type;@0;:I"ret_type,;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;: abi=;@0;:I"abi=(DEFAULT);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" DEFAULT;T0;$@o;= ;>I" overload;F;?0;;F;@0;:I"name: nil,;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;: need_gvl;@0;:I"need_gvl: false);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Constructs a Function object. * +ptr+ is a referenced function, of a Fiddle::Handle * +args+ is an Array of arguments, passed to the +ptr+ function * +ret_type+ is the return type of the function * +abi+ is the ABI of the function * +name+ is the name of the function * +need_gvl+ is whether GVL is needed to call the function @overload new(ptr, @overload args, @overload ret_type, @overload abi=(DEFAULT) @overload name: nil, @overload need_gvl: false);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"%static VALUE initialize(int argc, VALUE argv[], VALUE self) { ffi_cif * cif; VALUE ptr, arg_types, ret_type, abi, kwargs; VALUE name = Qnil; VALUE need_gvl = Qfalse; int c_ret_type; bool is_variadic = false; ffi_abi c_ffi_abi; void *cfunc; rb_scan_args(argc, argv, "31:", &ptr, &arg_types, &ret_type, &abi, &kwargs); rb_iv_set(self, "@closure", ptr); if (!NIL_P(kwargs)) { enum { kw_name, kw_need_gvl, kw_max_, }; static ID kw[kw_max_]; VALUE args[kw_max_]; if (!kw[0]) { kw[kw_name] = rb_intern_const("name"); kw[kw_need_gvl] = rb_intern_const("need_gvl"); } rb_get_kwargs(kwargs, kw, 0, kw_max_, args); if (args[kw_name] != Qundef) { name = args[kw_name]; } if (args[kw_need_gvl] != Qundef) { need_gvl = args[kw_need_gvl]; } } rb_iv_set(self, "@name", name); rb_iv_set(self, "@need_gvl", need_gvl); ptr = rb_Integer(ptr); cfunc = NUM2PTR(ptr); PTR2NUM(cfunc); c_ffi_abi = NIL_P(abi) ? FFI_DEFAULT_ABI : NUM2INT(abi); abi = INT2FIX(c_ffi_abi); ret_type = rb_fiddle_type_ensure(ret_type); c_ret_type = NUM2INT(ret_type); (void)INT2FFI_TYPE(c_ret_type); /* raise */ ret_type = INT2FIX(c_ret_type); arg_types = normalize_argument_types("argument types", arg_types, &is_variadic); #ifndef HAVE_FFI_PREP_CIF_VAR if (is_variadic) { rb_raise(rb_eNotImpError, "ffi_prep_cif_var() is required in libffi " "for variadic arguments"); } #endif rb_iv_set(self, "@ptr", ptr); rb_iv_set(self, "@argument_types", arg_types); rb_iv_set(self, "@return_type", ret_type); rb_iv_set(self, "@abi", abi); rb_iv_set(self, "@is_variadic", is_variadic ? Qtrue : Qfalse); TypedData_Get_Struct(self, ffi_cif, &function_data_type, cif); cif->arg_types = NULL; return self; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;: Function;;;;;[;{;IC; "== Description A representation of a C function == Examples === 'strcpy' @libc = Fiddle.dlopen "/lib/libc.so.6" #=> # f = Fiddle::Function.new( @libc['strcpy'], [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP], Fiddle::TYPE_VOIDP) #=> # buff = "000" #=> "000" str = f.call(buff, "123") #=> # str.to_s => "123" === ABI check @libc = Fiddle.dlopen "/lib/libc.so.6" #=> # f = Fiddle::Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP) #=> # f.abi == Fiddle::Function::DEFAULT #=> true ;T;[;![;"I" == Description A representation of a C function == Examples === 'strcpy' @libc = Fiddle.dlopen "/lib/libc.so.6" #=> # f = Fiddle::Function.new( @libc['strcpy'], [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP], Fiddle::TYPE_VOIDP) #=> # buff = "000" #=> "000" str = f.call(buff, "123") #=> # str.to_s => "123" === ABI check @libc = Fiddle.dlopen "/lib/libc.so.6" #=> # f = Fiddle::Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP) #=> # f.abi == Fiddle::Function::DEFAULT #=> true ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::Function;F;'@o; ;IC;[; @w; IC;[; @w; IC;[; @w; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"ext/fiddle/fiddle.c;Ti[@i;T;;;;;;;[;{;IC; "#Generic error class for Fiddle ;T;[;![;"I"% Generic error class for Fiddle ;T;#0;$@w;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::Error;F;'@o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;: DLError;;;;;[;{;IC; "$standard dynamic load exception ;T;[;![;"I"& standard dynamic load exception ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::DLError;F;'@wo;u;[[@i;F;:TYPE_VOID;;w;;;[;{;IC; "C type - void ;T;[;![;"I" C type - void ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::TYPE_VOID;F;xI"INT2NUM(TYPE_VOID);To;u;[[@i;F;:TYPE_VOIDP;;w;;;[;{;IC; "C type - void* ;T;[;![;"I" C type - void* ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::TYPE_VOIDP;F;xI"INT2NUM(TYPE_VOIDP);To;u;[[@i;F;:TYPE_CHAR;;w;;;[;{;IC; "C type - char ;T;[;![;"I" C type - char ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::TYPE_CHAR;F;xI"INT2NUM(TYPE_CHAR);To;u;[[@i;F;:TYPE_SHORT;;w;;;[;{;IC; "C type - short ;T;[;![;"I" C type - short ;T;#0;$@Ĕ;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::TYPE_SHORT;F;xI"INT2NUM(TYPE_SHORT);To;u;[[@i;F;: TYPE_INT;;w;;;[;{;IC; "C type - int ;T;[;![;"I" C type - int ;T;#0;$@Д;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::TYPE_INT;F;xI"INT2NUM(TYPE_INT);To;u;[[@i;F;:TYPE_LONG;;w;;;[;{;IC; "C type - long ;T;[;![;"I" C type - long ;T;#0;$@ܔ;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::TYPE_LONG;F;xI"INT2NUM(TYPE_LONG);To;u;[[@i;F;:TYPE_LONG_LONG;;w;;;[;{;IC; "C type - long long ;T;[;![;"I" C type - long long ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::TYPE_LONG_LONG;F;xI"INT2NUM(TYPE_LONG_LONG);To;u;[[@i;F;:TYPE_INT8_T;;w;;;[;{;IC; "C type - int8_t ;T;[;![;"I" C type - int8_t ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::TYPE_INT8_T;F;xI"INT2NUM(TYPE_INT8_T);To;u;[[@i;F;:TYPE_INT16_T;;w;;;[;{;IC; "C type - int16_t ;T;[;![;"I" C type - int16_t ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::TYPE_INT16_T;F;xI"INT2NUM(TYPE_INT16_T);To;u;[[@i;F;:TYPE_INT32_T;;w;;;[;{;IC; "C type - int32_t ;T;[;![;"I" C type - int32_t ;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::TYPE_INT32_T;F;xI"INT2NUM(TYPE_INT32_T);To;u;[[@i;F;:TYPE_INT64_T;;w;;;[;{;IC; "C type - int64_t ;T;[;![;"I" C type - int64_t ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::TYPE_INT64_T;F;xI"INT2NUM(TYPE_INT64_T);To;u;[[@i;F;:TYPE_FLOAT;;w;;;[;{;IC; "C type - float ;T;[;![;"I" C type - float ;T;#0;$@$;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::TYPE_FLOAT;F;xI"INT2NUM(TYPE_FLOAT);To;u;[[@i;F;:TYPE_DOUBLE;;w;;;[;{;IC; "C type - double ;T;[;![;"I" C type - double ;T;#0;$@0;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::TYPE_DOUBLE;F;xI"INT2NUM(TYPE_DOUBLE);To;u;[[@i;F;:TYPE_VARIADIC;;w;;;[;{;IC; "C type - ... ;T;[;![;"I" C type - ... ;T;#0;$@<;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::TYPE_VARIADIC;F;xI"INT2NUM(TYPE_VARIADIC);To;u;[[@i ;F;:TYPE_CONST_STRING;;w;;;[;{;IC; "7C type - const char* ('\0' terminated const char*) ;T;[;![;"I"9 C type - const char* ('\0' terminated const char*) ;T;#0;$@H;.F;/o;0;1T;2i;3i ;%@;&I"Fiddle::TYPE_CONST_STRING;F;xI"INT2NUM(TYPE_CONST_STRING);To;u;[[@i;F;:TYPE_SIZE_T;;w;;;[;{;IC; "C type - size_t ;T;[;![;"I" C type - size_t ;T;#0;$@T;.F;/o;0;1T;2i ;3i;%@;&I"Fiddle::TYPE_SIZE_T;F;xI"INT2NUM(TYPE_SIZE_T);To;u;[[@i;F;:TYPE_SSIZE_T;;w;;;[;{;IC; "C type - ssize_t ;T;[;![;"I" C type - ssize_t ;T;#0;$@`;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::TYPE_SSIZE_T;F;xI"INT2NUM(TYPE_SSIZE_T);To;u;[[@i;F;:TYPE_PTRDIFF_T;;w;;;[;{;IC; "C type - ptrdiff_t ;T;[;![;"I" C type - ptrdiff_t ;T;#0;$@l;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::TYPE_PTRDIFF_T;F;xI"INT2NUM(TYPE_PTRDIFF_T);To;u;[[@i#;F;:TYPE_INTPTR_T;;w;;;[;{;IC; "C type - intptr_t ;T;[;![;"I" C type - intptr_t ;T;#0;$@x;.F;/o;0;1T;2i;3i!;%@;&I"Fiddle::TYPE_INTPTR_T;F;xI"INT2NUM(TYPE_INTPTR_T);To;u;[[@i);F;:TYPE_UINTPTR_T;;w;;;[;{;IC; "C type - uintptr_t ;T;[;![;"I" C type - uintptr_t ;T;#0;$@;.F;/o;0;1T;2i%;3i';%@;&I"Fiddle::TYPE_UINTPTR_T;F;xI"INT2NUM(TYPE_UINTPTR_T);To;u;[[@i/;F;:ALIGN_VOIDP;;w;;;[;{;IC; ""The alignment size of a void* ;T;[;![;"I"$ The alignment size of a void* ;T;#0;$@;.F;/o;0;1T;2i+;3i-;%@;&I"Fiddle::ALIGN_VOIDP;F;xI"INT2NUM(ALIGN_VOIDP);To;u;[[@i5;F;:ALIGN_CHAR;;w;;;[;{;IC; "!The alignment size of a char ;T;[;![;"I"# The alignment size of a char ;T;#0;$@;.F;/o;0;1T;2i1;3i3;%@;&I"Fiddle::ALIGN_CHAR;F;xI"INT2NUM(ALIGN_CHAR);To;u;[[@i;;F;:ALIGN_SHORT;;w;;;[;{;IC; ""The alignment size of a short ;T;[;![;"I"$ The alignment size of a short ;T;#0;$@;.F;/o;0;1T;2i7;3i9;%@;&I"Fiddle::ALIGN_SHORT;F;xI"INT2NUM(ALIGN_SHORT);To;u;[[@iA;F;:ALIGN_INT;;w;;;[;{;IC; "!The alignment size of an int ;T;[;![;"I"# The alignment size of an int ;T;#0;$@;.F;/o;0;1T;2i=;3i?;%@;&I"Fiddle::ALIGN_INT;F;xI"INT2NUM(ALIGN_INT);To;u;[[@iG;F;:ALIGN_LONG;;w;;;[;{;IC; "!The alignment size of a long ;T;[;![;"I"# The alignment size of a long ;T;#0;$@;.F;/o;0;1T;2iC;3iE;%@;&I"Fiddle::ALIGN_LONG;F;xI"INT2NUM(ALIGN_LONG);To;u;[[@iN;F;:ALIGN_LONG_LONG;;w;;;[;{;IC; "&The alignment size of a long long ;T;[;![;"I"( The alignment size of a long long ;T;#0;$@̕;.F;/o;0;1T;2iJ;3iL;%@;&I"Fiddle::ALIGN_LONG_LONG;F;xI"INT2NUM(ALIGN_LONG_LONG);To;u;[[@iU;F;:ALIGN_INT8_T;;w;;;[;{;IC; "#The alignment size of a int8_t ;T;[;![;"I"% The alignment size of a int8_t ;T;#0;$@ؕ;.F;/o;0;1T;2iQ;3iS;%@;&I"Fiddle::ALIGN_INT8_T;F;xI"INT2NUM(ALIGN_INT8_T);To;u;[[@i[;F;:ALIGN_INT16_T;;w;;;[;{;IC; "$The alignment size of a int16_t ;T;[;![;"I"& The alignment size of a int16_t ;T;#0;$@;.F;/o;0;1T;2iW;3iY;%@;&I"Fiddle::ALIGN_INT16_T;F;xI"INT2NUM(ALIGN_INT16_T);To;u;[[@ia;F;:ALIGN_INT32_T;;w;;;[;{;IC; "$The alignment size of a int32_t ;T;[;![;"I"& The alignment size of a int32_t ;T;#0;$@;.F;/o;0;1T;2i];3i_;%@;&I"Fiddle::ALIGN_INT32_T;F;xI"INT2NUM(ALIGN_INT32_T);To;u;[[@ig;F;:ALIGN_INT64_T;;w;;;[;{;IC; "$The alignment size of a int64_t ;T;[;![;"I"& The alignment size of a int64_t ;T;#0;$@;.F;/o;0;1T;2ic;3ie;%@;&I"Fiddle::ALIGN_INT64_T;F;xI"INT2NUM(ALIGN_INT64_T);To;u;[[@im;F;:ALIGN_FLOAT;;w;;;[;{;IC; ""The alignment size of a float ;T;[;![;"I"$ The alignment size of a float ;T;#0;$@;.F;/o;0;1T;2ii;3ik;%@;&I"Fiddle::ALIGN_FLOAT;F;xI"INT2NUM(ALIGN_FLOAT);To;u;[[@is;F;:ALIGN_DOUBLE;;w;;;[;{;IC; "#The alignment size of a double ;T;[;![;"I"% The alignment size of a double ;T;#0;$@;.F;/o;0;1T;2io;3iq;%@;&I"Fiddle::ALIGN_DOUBLE;F;xI"INT2NUM(ALIGN_DOUBLE);To;u;[[@iy;F;:ALIGN_SIZE_T;;w;;;[;{;IC; "#The alignment size of a size_t ;T;[;![;"I"% The alignment size of a size_t ;T;#0;$@ ;.F;/o;0;1T;2iu;3iw;%@;&I"Fiddle::ALIGN_SIZE_T;F;xI"INT2NUM(ALIGN_OF(size_t));To;u;[[@i;F;:ALIGN_SSIZE_T;;w;;;[;{;IC; "same as size_t ;T;[;![;"I"same as size_t;T;#0;$@,;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::ALIGN_SSIZE_T;F;xI"INT2NUM(ALIGN_OF(size_t));To;u;[[@i;F;:ALIGN_PTRDIFF_T;;w;;;[;{;IC; "&The alignment size of a ptrdiff_t ;T;[;![;"I"( The alignment size of a ptrdiff_t ;T;#0;$@8;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::ALIGN_PTRDIFF_T;F;xI"!INT2NUM(ALIGN_OF(ptrdiff_t));To;u;[[@i;F;:ALIGN_INTPTR_T;;w;;;[;{;IC; "%The alignment size of a intptr_t ;T;[;![;"I"' The alignment size of a intptr_t ;T;#0;$@D;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::ALIGN_INTPTR_T;F;xI" INT2NUM(ALIGN_OF(intptr_t));To;u;[[@i;F;:ALIGN_UINTPTR_T;;w;;;[;{;IC; "&The alignment size of a uintptr_t ;T;[;![;"I"( The alignment size of a uintptr_t ;T;#0;$@P;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::ALIGN_UINTPTR_T;F;xI"!INT2NUM(ALIGN_OF(uintptr_t));To;u;[[@i[@i;F;: WINDOWS;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@\;%@;&I"Fiddle::WINDOWS;F;xI" Qfalse;To;u;[[@i;F;:SIZEOF_VOIDP;;w;;;[;{;IC; "size of a void* ;T;[;![;"I" size of a void* ;T;#0;$@g;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::SIZEOF_VOIDP;F;xI"INT2NUM(sizeof(void*));To;u;[[@i;F;:SIZEOF_CHAR;;w;;;[;{;IC; "size of a char ;T;[;![;"I" size of a char ;T;#0;$@s;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::SIZEOF_CHAR;F;xI"INT2NUM(sizeof(char));To;u;[[@i;F;:SIZEOF_SHORT;;w;;;[;{;IC; "size of a short ;T;[;![;"I" size of a short ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::SIZEOF_SHORT;F;xI"INT2NUM(sizeof(short));To;u;[[@i;F;:SIZEOF_INT;;w;;;[;{;IC; "size of an int ;T;[;![;"I" size of an int ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::SIZEOF_INT;F;xI"INT2NUM(sizeof(int));To;u;[[@i;F;:SIZEOF_LONG;;w;;;[;{;IC; "size of a long ;T;[;![;"I" size of a long ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::SIZEOF_LONG;F;xI"INT2NUM(sizeof(long));To;u;[[@i;F;:SIZEOF_LONG_LONG;;w;;;[;{;IC; "size of a long long ;T;[;![;"I" size of a long long ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::SIZEOF_LONG_LONG;F;xI"INT2NUM(sizeof(LONG_LONG));To;u;[[@i;F;:SIZEOF_INT8_T;;w;;;[;{;IC; "size of a int8_t ;T;[;![;"I" size of a int8_t ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::SIZEOF_INT8_T;F;xI"INT2NUM(sizeof(int8_t));To;u;[[@i;F;:SIZEOF_INT16_T;;w;;;[;{;IC; "size of a int16_t ;T;[;![;"I" size of a int16_t ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::SIZEOF_INT16_T;F;xI"INT2NUM(sizeof(int16_t));To;u;[[@i;F;:SIZEOF_INT32_T;;w;;;[;{;IC; "size of a int32_t ;T;[;![;"I" size of a int32_t ;T;#0;$@ǖ;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::SIZEOF_INT32_T;F;xI"INT2NUM(sizeof(int32_t));To;u;[[@i;F;:SIZEOF_INT64_T;;w;;;[;{;IC; "size of a int64_t ;T;[;![;"I" size of a int64_t ;T;#0;$@Ӗ;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::SIZEOF_INT64_T;F;xI"INT2NUM(sizeof(int64_t));To;u;[[@i;F;:SIZEOF_FLOAT;;w;;;[;{;IC; "size of a float ;T;[;![;"I" size of a float ;T;#0;$@ߖ;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::SIZEOF_FLOAT;F;xI"INT2NUM(sizeof(float));To;u;[[@i;F;:SIZEOF_DOUBLE;;w;;;[;{;IC; "size of a double ;T;[;![;"I" size of a double ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::SIZEOF_DOUBLE;F;xI"INT2NUM(sizeof(double));To;u;[[@i;F;:SIZEOF_SIZE_T;;w;;;[;{;IC; "size of a size_t ;T;[;![;"I" size of a size_t ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::SIZEOF_SIZE_T;F;xI"INT2NUM(sizeof(size_t));To;u;[[@i;F;:SIZEOF_SSIZE_T;;w;;;[;{;IC; "same as size_t ;T;[;![;"I"same as size_t;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::SIZEOF_SSIZE_T;F;xI"INT2NUM(sizeof(size_t));To;u;[[@i;F;:SIZEOF_PTRDIFF_T;;w;;;[;{;IC; "size of a ptrdiff_t ;T;[;![;"I" size of a ptrdiff_t ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::SIZEOF_PTRDIFF_T;F;xI"INT2NUM(sizeof(ptrdiff_t));To;u;[[@i;F;:SIZEOF_INTPTR_T;;w;;;[;{;IC; "size of a intptr_t ;T;[;![;"I" size of a intptr_t ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::SIZEOF_INTPTR_T;F;xI"INT2NUM(sizeof(intptr_t));To;u;[[@i;F;:SIZEOF_UINTPTR_T;;w;;;[;{;IC; "size of a uintptr_t ;T;[;![;"I" size of a uintptr_t ;T;#0;$@';.F;/o;0;1T;2i;3i;%@;&I"Fiddle::SIZEOF_UINTPTR_T;F;xI"INT2NUM(sizeof(uintptr_t));To;u;[[@i ;F;:SIZEOF_CONST_STRING;;w;;;[;{;IC; "size of a const char* ;T;[;![;"I" size of a const char* ;T;#0;$@3;.F;/o;0;1T;2i;3i;%@;&I" Fiddle::SIZEOF_CONST_STRING;F;xI"!INT2NUM(sizeof(const char*));To;u;[[@i;F;:RUBY_FREE;;w;;;[;{;IC; ")Address of the ruby_xfree() function ;T;[;![;"I"+ Address of the ruby_xfree() function ;T;#0;$@?;.F;/o;0;1T;2i ;3i ;%@;&I"Fiddle::RUBY_FREE;F;xI"PTR2NUM(ruby_xfree);To;u;[[@i;F;:BUILD_RUBY_PLATFORM;;w;;;[;{;IC; "OPlatform built against (i.e. "x86_64-linux", etc.) See also RUBY_PLATFORM ;T;[;![;"I"Q Platform built against (i.e. "x86_64-linux", etc.) See also RUBY_PLATFORM ;T;#0;$@K;.F;/o;0;1T;2i;3i;%@;&I" Fiddle::BUILD_RUBY_PLATFORM;F;xI"rb_str_new2(RUBY_PLATFORM);To;4;5F;6;;;;&I"Fiddle#dlwrap;F;7[[I"val;T0;[[@ib;T;: dlwrap;0;[;{;IC; "Returns a memory pointer of a function's hexadecimal address location +val+ Example: lib = Fiddle.dlopen('/lib64/libc-2.15.so') => # Fiddle.dlwrap(lib['strcpy'].to_s(16)) => 25522520 ;T;[o;= ;>I" overload;F;?0;;e ;@0;:I"dlwrap(val);T;IC; ";T;[;![;"I";T;#0;$@W;.F;Bi;C0;7[[I"val;T0;$@W;![;"I"Returns a memory pointer of a function's hexadecimal address location +val+ Example: lib = Fiddle.dlopen('/lib64/libc-2.15.so') => # Fiddle.dlwrap(lib['strcpy'].to_s(16)) => 25522520 @overload dlwrap(val) ;T;#0;$@W;.F;C0;%@;9I"`static VALUE rb_fiddle_value2ptr(VALUE self, VALUE val) { return PTR2NUM((void*)val); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Fiddle.dlwrap;F;7@Y;@\;T;;e ;0;@^;{;IC; "Returns a memory pointer of a function's hexadecimal address location +val+ Example: lib = Fiddle.dlopen('/lib64/libc-2.15.so') => # Fiddle.dlwrap(lib['strcpy'].to_s(16)) => 25522520;T;[o;= ;>I" overload;F;?0;;e ;@0;:I"dlwrap(val);T;IC; ";T;[;![;"I";T;#0;$@p;.F;Bi;C0;7[[I"val;T0;$@p;![;"I"Returns a memory pointer of a function's hexadecimal address location +val+ Example: lib = Fiddle.dlopen('/lib64/libc-2.15.so') => # Fiddle.dlwrap(lib['strcpy'].to_s(16)) => 25522520 @overload dlwrap(val);T;#0;$@p;.F;/o;0;1T;2iU;3i`;Bi;%@;9@n;:@o;;To;4;5F;6;;;;&I"Fiddle#dlunwrap;F;7[[I" addr;T0;[[@iO;T;: dlunwrap;0;[;{;IC; "%Returns the hexadecimal representation of a memory pointer address +addr+ Example: lib = Fiddle.dlopen('/lib64/libc-2.15.so') => # lib['strcpy'].to_s(16) => "7f59de6dd240" Fiddle.dlunwrap(Fiddle.dlwrap(lib['strcpy'].to_s(16))) => "7f59de6dd240" ;T;[o;= ;>I" overload;F;?0;;f ;@0;:I"dlunwrap(addr);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" addr;T0;$@;![;"I"?Returns the hexadecimal representation of a memory pointer address +addr+ Example: lib = Fiddle.dlopen('/lib64/libc-2.15.so') => # lib['strcpy'].to_s(16) => "7f59de6dd240" Fiddle.dlunwrap(Fiddle.dlwrap(lib['strcpy'].to_s(16))) => "7f59de6dd240" @overload dlunwrap(addr) ;T;#0;$@;.F;C0;%@;9I"[VALUE rb_fiddle_ptr2value(VALUE self, VALUE addr) { return (VALUE)NUM2PTR(addr); };T;:I" VALUE;T;;To;4;5T;6;;;;&I"Fiddle.dlunwrap;F;7@;@;T;;f ;0;@;{;IC; "%Returns the hexadecimal representation of a memory pointer address +addr+ Example: lib = Fiddle.dlopen('/lib64/libc-2.15.so') => # lib['strcpy'].to_s(16) => "7f59de6dd240" Fiddle.dlunwrap(Fiddle.dlwrap(lib['strcpy'].to_s(16))) => "7f59de6dd240";T;[o;= ;>I" overload;F;?0;;f ;@0;:I"dlunwrap(addr);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" addr;T0;$@;![;"I"@Returns the hexadecimal representation of a memory pointer address +addr+ Example: lib = Fiddle.dlopen('/lib64/libc-2.15.so') => # lib['strcpy'].to_s(16) => "7f59de6dd240" Fiddle.dlunwrap(Fiddle.dlwrap(lib['strcpy'].to_s(16))) => "7f59de6dd240" @overload dlunwrap(addr);T;#0;$@;.F;/o;0;1T;2i?;3iM;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Fiddle#malloc;F;7[[I" size;T0;[[@i;T;; ;0;[;{;IC; "dAllocate +size+ bytes of memory and return the integer memory address for the allocated memory. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"malloc(size);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" size;T0;$@;![;"I"|Allocate +size+ bytes of memory and return the integer memory address for the allocated memory. @overload malloc(size) ;T;#0;$@;.F;C0;%@;9I"static VALUE rb_fiddle_malloc(VALUE self, VALUE size) { void *ptr; ptr = (void*)ruby_xcalloc(1, NUM2SIZET(size)); return PTR2NUM(ptr); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Fiddle.malloc;F;7@;@;T;; ;0;@;{;IC; "dAllocate +size+ bytes of memory and return the integer memory address for the allocated memory.;T;[o;= ;>I" overload;F;?0;; ;@0;:I"malloc(size);T;IC; ";T;[;![;"I";T;#0;$@Ɨ;.F;Bi;C0;7[[I" size;T0;$@Ɨ;![;"I"}Allocate +size+ bytes of memory and return the integer memory address for the allocated memory. @overload malloc(size);T;#0;$@Ɨ;.F;/o;0;1T;2i;3i;Bi;%@;9@ė;:@ŗ;;To;4;5F;6;;;;&I"Fiddle#realloc;F;7[[I" addr;T0[I" size;T0;[[@i(;T;: realloc;0;[;{;IC; "Change the size of the memory allocated at the memory location +addr+ to +size+ bytes. Returns the memory address of the reallocated memory, which may be different than the address passed in. ;T;[o;= ;>I" overload;F;?0;;g ;@0;:I"realloc(addr, size);T;IC; ";T;[;![;"I";T;#0;$@ؗ;.F;Bi;C0;7[[I" addr;T0[I" size;T0;$@ؗ;![;"I"Change the size of the memory allocated at the memory location +addr+ to +size+ bytes. Returns the memory address of the reallocated memory, which may be different than the address passed in. @overload realloc(addr, size) ;T;#0;$@ؗ;.F;C0;%@;9I"static VALUE rb_fiddle_realloc(VALUE self, VALUE addr, VALUE size) { void *ptr = NUM2PTR(addr); ptr = (void*)ruby_xrealloc(ptr, NUM2SIZET(size)); return PTR2NUM(ptr); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Fiddle.realloc;F;7@ڗ;@ߗ;T;;g ;0;@;{;IC; "Change the size of the memory allocated at the memory location +addr+ to +size+ bytes. Returns the memory address of the reallocated memory, which may be different than the address passed in.;T;[o;= ;>I" overload;F;?0;;g ;@0;:I"realloc(addr, size);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" addr;T0[I" size;T0;$@;![;"I"Change the size of the memory allocated at the memory location +addr+ to +size+ bytes. Returns the memory address of the reallocated memory, which may be different than the address passed in. @overload realloc(addr, size);T;#0;$@;.F;/o;0;1T;2i!;3i&;Bi;%@;9@;:@;;To;4;5F;6;;;;&I"Fiddle#free;F;7[[I" addr;T0;[[@i6;T;;;0;[;{;IC; "&Free the memory at address +addr+ ;T;[o;= ;>I" overload;F;?0;;;@0;:I"free(addr);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I" addr;T0;$@ ;![;"I"I" overload;F;?0;;;@0;:I"free(addr);T;IC; ";T;[;![;"I";T;#0;$@";.F;Bi;C0;7[[I" addr;T0;$@";![;"I"=Free the memory at address +addr+ @overload free(addr);T;#0;$@";.F;/o;0;1T;2i1;3i4;Bi;%@;9@ ;:@!;;To; ;IC;[o;4;5F;6;;;;&I"Fiddle::MemoryView.export;F;7[[I" target;T0;[[I"ext/fiddle/memory_view.c;Tic;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@6;%@4;9I"static VALUE rb_fiddle_memview_s_export(VALUE klass, VALUE target) { ID id_new; CONST_ID(id_new, "new"); VALUE memview = rb_funcall(klass, id_new, 1, target); return rb_ensure(rb_yield, memview, rb_fiddle_memview_release, memview); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""Fiddle::MemoryView#initialize;F;7[[I" target;T0;[[@=il;T;;D;0;[;{;IC; " ;T;[;![;"@;#0;$@E;%@4;9I"static VALUE rb_fiddle_memview_initialize(VALUE obj, VALUE target) { struct memview_data *data; TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data); if (!rb_memory_view_get(target, &data->view, 0)) { data->view.obj = Qnil; rb_raise(rb_eArgError, "Unable to get a memory view from %+"PRIsVALUE, target); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::MemoryView#release;F;7[;[[@=iX;T;: release;0;[;{;IC; " ;T;[;![;"@;#0;$@S;%@4;9I" static VALUE rb_fiddle_memview_release(VALUE obj) { struct memview_data *data; TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data); if (NIL_P(data->view.obj)) return Qnil; fiddle_memview_release(data); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::MemoryView#obj;F;7[;[[@=iz;T;;U ;0;[;{;IC; " ;T;[;![;"@;#0;$@_;%@4;9I"static VALUE rb_fiddle_memview_get_obj(VALUE obj) { struct memview_data *data; TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data); return data->view.obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Fiddle::MemoryView#byte_size;F;7[;[[@=i~;T;:byte_size;0;[;{;IC; " ;T;[;![;"@;#0;$@k;%@4;9I" static VALUE rb_fiddle_memview_get_byte_size(VALUE obj) { struct memview_data *data; TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data); if (NIL_P(data->view.obj)) return Qnil; return SSIZET2NUM(data->view.byte_size); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Fiddle::MemoryView#readonly?;F;7[;[[@=i;T;;;0;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@w;![;"@;#0;$@w;Bi;%@4;9I" static VALUE rb_fiddle_memview_get_readonly(VALUE obj) { struct memview_data *data; TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data); if (NIL_P(data->view.obj)) return Qnil; return data->view.readonly ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::MemoryView#format;F;7[;[[@=i;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@4;9I"+static VALUE rb_fiddle_memview_get_format(VALUE obj) { struct memview_data *data; TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data); if (NIL_P(data->view.obj)) return Qnil; return data->view.format == NULL ? Qnil : rb_str_new_cstr(data->view.format); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Fiddle::MemoryView#item_size;F;7[;[[@=i;T;:item_size;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@4;9I" static VALUE rb_fiddle_memview_get_item_size(VALUE obj) { struct memview_data *data; TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data); if (NIL_P(data->view.obj)) return Qnil; return SSIZET2NUM(data->view.item_size); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::MemoryView#ndim;F;7[;[[@=i;T;: ndim;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@4;9I"static VALUE rb_fiddle_memview_get_ndim(VALUE obj) { struct memview_data *data; TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data); if (NIL_P(data->view.obj)) return Qnil; return SSIZET2NUM(data->view.ndim); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::MemoryView#shape;F;7[;[[@=i;T;: shape;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@4;9I"static VALUE rb_fiddle_memview_get_shape(VALUE obj) { struct memview_data *data; TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data); if (NIL_P(data->view.obj)) return Qnil; if (data->view.shape == NULL) return Qnil; const ssize_t ndim = data->view.ndim; VALUE shape = rb_ary_new_capa(ndim); ssize_t i; for (i = 0; i < ndim; ++i) { rb_ary_push(shape, SSIZET2NUM(data->view.shape[i])); } return shape; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::MemoryView#strides;F;7[;[[@=i;T;: strides;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@4;9I"static VALUE rb_fiddle_memview_get_strides(VALUE obj) { struct memview_data *data; TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data); if (NIL_P(data->view.obj)) return Qnil; if (data->view.strides == NULL) return Qnil; const ssize_t ndim = data->view.ndim; VALUE strides = rb_ary_new_capa(ndim); ssize_t i; for (i = 0; i < ndim; ++i) { rb_ary_push(strides, SSIZET2NUM(data->view.strides[i])); } return strides; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#Fiddle::MemoryView#sub_offsets;F;7[;[[@=i;T;:sub_offsets;0;[;{;IC; " ;T;[;![;"@;#0;$@˜;%@4;9I"static VALUE rb_fiddle_memview_get_sub_offsets(VALUE obj) { struct memview_data *data; TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data); if (NIL_P(data->view.obj)) return Qnil; if (data->view.sub_offsets == NULL) return Qnil; const ssize_t ndim = data->view.ndim; VALUE sub_offsets = rb_ary_new_capa(ndim); ssize_t i; for (i = 0; i < ndim; ++i) { rb_ary_push(sub_offsets, SSIZET2NUM(data->view.sub_offsets[i])); } return sub_offsets; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::MemoryView#[];F;7[[@90;[[@=i;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@Θ;%@4;9I"static VALUE rb_fiddle_memview_aref(int argc, VALUE *argv, VALUE obj) { struct memview_data *data; TypedData_Get_Struct(obj, struct memview_data, &fiddle_memview_data_type, data); if (NIL_P(data->view.obj)) return Qnil; const ssize_t ndim = data->view.ndim; if (argc != ndim) { rb_raise(rb_eIndexError, "wrong number of index (%d for %"PRIdSIZE")", argc, ndim); } VALUE indices_v = 0; ssize_t *indices = ALLOCV_N(ssize_t, indices_v, ndim); ssize_t i; for (i = 0; i < ndim; ++i) { ssize_t x = NUM2SSIZET(argv[i]); indices[i] = x; } uint8_t *ptr = rb_memory_view_get_item_pointer(&data->view, indices); ALLOCV_END(indices_v); if (data->view.format == NULL) { return INT2FIX(*ptr); } if (!data->members) { const char *err; if (rb_memory_view_parse_item_format(data->view.format, &data->members, &data->n_members, &err) < 0) { rb_raise(rb_eRuntimeError, "Unable to recognize item format at %"PRIdSIZE" in \"%s\"", err - data->view.format, data->view.format); } } return rb_memory_view_extract_item_members(ptr, data->members, data->n_members); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::MemoryView#to_s;F;7[;[[@=i;T;;G;0;[;{;IC; " ;T;[;![;"@;#0;$@ۘ;%@4;9I"static VALUE rb_fiddle_memview_to_s(VALUE self) { struct memview_data *data; const char *raw_data; long byte_size; VALUE string; TypedData_Get_Struct(self, struct memview_data, &fiddle_memview_data_type, data); if (NIL_P(data->view.obj)) { raw_data = NULL; byte_size = 0; } else { raw_data = data->view.data; byte_size = data->view.byte_size; } string = rb_enc_str_new_static(raw_data, byte_size, rb_ascii8bit_encoding()); { ID id_memory_view; CONST_ID(id_memory_view, "memory_view"); rb_ivar_set(string, id_memory_view, self); } return rb_obj_freeze(string); };T;:I"static VALUE;T;;T; @4; IC;[; @4; IC;[; @4; IC;{;IC;{;T;IC;{;T;T;{;[;[[@=i/;F;:MemoryView;;;;;[;{;IC; " ;T;[;![;"@;#0;$@4;%@;&I"Fiddle::MemoryView;F;'@o; ;IC;[ o;4;5F;6;;;;&I"Fiddle::Pinned#initialize;F;7[[@90;[[I"ext/psych/psych_emitter.c;TiO;T;;D;0;[;{;IC; "5Create a new Psych::Emitter that writes to +io+. ;T;[o;= ;>I" overload;F;?0;:Psych::Emitter.new;@0;:I">Psych::Emitter.new(io, options = Psych::Emitter::OPTIONS);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"io;T0[I" options;TI"Psych::Emitter::OPTIONS;T;$@;![;"I"{Create a new Psych::Emitter that writes to +io+. @overload Psych::Emitter.new(io, options = Psych::Emitter::OPTIONS);T;#0;$@;.F;/o;0;1T;2iK;3iN;%@;9I"static VALUE initialize(int argc, VALUE *argv, VALUE self) { yaml_emitter_t * emitter; VALUE io, options; VALUE line_width; VALUE indent; VALUE canonical; TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter); if (rb_scan_args(argc, argv, "11", &io, &options) == 2) { line_width = rb_funcall(options, id_line_width, 0); indent = rb_funcall(options, id_indentation, 0); canonical = rb_funcall(options, id_canonical, 0); yaml_emitter_set_width(emitter, NUM2INT(line_width)); yaml_emitter_set_indent(emitter, NUM2INT(indent)); yaml_emitter_set_canonical(emitter, Qtrue == canonical ? 1 : 0); } rb_ivar_set(self, id_io, io); yaml_emitter_set_output(emitter, writer, (void *)self); return self; };T;:I"?static VALUE initialize(int argc, VALUE *argv, VALUE self);T;;To;4;5F;6;;;;&I"Fiddle::Pinned#ref;F;7[;[[I"ext/fiddle/pinned.c;TiC;T;;" ;0;[;{;IC; "I" overload;F;?0;;" ;@0;:I"ref;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"LReturn the object that this pinned instance references. @overload ref;T;#0;$@;.F;/o;0;1T;2i>;3iA;%@;9I" static VALUE ref(VALUE self) { struct pinned_data *data; TypedData_Get_Struct(self, struct pinned_data, &pinned_data_type, data); if (data->ptr) { return data->ptr; } else { rb_raise(rb_eFiddleClearedReferenceError, "`ref` called on a cleared object"); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pinned#clear;F;7[;[[@iT;T;;;0;[;{;IC; "7Clear the reference to the object this is pinning. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" clear;T;IC; ";T;[;![;"I";T;#0;$@,;.F;Bi;C0;7[;$@,;![;"I"IClear the reference to the object this is pinning. @overload clear;T;#0;$@,;.F;/o;0;1T;2iO;3iR;%@;9I"static VALUE clear(VALUE self) { struct pinned_data *data; TypedData_Get_Struct(self, struct pinned_data, &pinned_data_type, data); data->ptr = 0; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Pinned#cleared?;F;7[;[[@ib;T;: cleared?;0;[;{;IC; "MReturns true if the reference has been cleared, otherwise returns false.;T;[o;= ;>I" overload;F;?0;;q ;@0;:I" cleared?;T;IC; ";T;[;![;"I";T;#0;$@B;.F;Bi;C0;7[;$@Bo;A ;>I" return;F;?@;0;@[@L;$@B;![;"I"bReturns true if the reference has been cleared, otherwise returns false. @overload cleared?;T;#0;$@B;.F;/o;0;1T;2i];3i`;Bi;%@;9I"static VALUE cleared_p(VALUE self) { struct pinned_data *data; TypedData_Get_Struct(self, struct pinned_data, &pinned_data_type, data); if (data->ptr) { return Qfalse; } else { return Qtrue; } };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@is;F;: Pinned;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I"Fiddle::Pinned;F;'@o; ;IC;[; @j; IC;[; @j; IC;[; @j; IC;{;IC;{;T;IC;{;T;T;{;[;[[@iz[@i;T;:ClearedReferenceError;;;;;[;{;IC; " Cleared reference exception ;T;[;![;"I"" Cleared reference exception ;T;#0;$@j;.F;/o;0;1T;2iz;3i|;%@;&I""Fiddle::ClearedReferenceError;F;'@wo; ;IC;[o;4;5F;6;;;;&I"Fiddle::Handle.sym;F;7[[I"sym;T0;[[I"ext/fiddle/handle.c;Ti>;T;:sym;0;[;{;IC; "call-seq: sym(name) Get the address as an Integer for the function named +name+. The function is searched via dlsym on RTLD_NEXT. See man(3) dlsym() for more info. ;T;[;![;"I" call-seq: sym(name) Get the address as an Integer for the function named +name+. The function is searched via dlsym on RTLD_NEXT. See man(3) dlsym() for more info. ;T;#0;$@;.F;/o;0;1T;2i4;3i;;%@~;9I"qstatic VALUE rb_fiddle_handle_s_sym(VALUE self, VALUE sym) { return fiddle_handle_sym(RTLD_NEXT, sym); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Handle.[];F;7[[I"sym;T0;[[@i>;T;;;0;[;{;IC; "call-seq: sym(name) Get the address as an Integer for the function named +name+. The function is searched via dlsym on RTLD_NEXT. See man(3) dlsym() for more info. ;T;[;![;"@;#0;$@;.F;/o;0;1T;2i4;3i;;%@~;9I"qstatic VALUE rb_fiddle_handle_s_sym(VALUE self, VALUE sym) { return fiddle_handle_sym(RTLD_NEXT, sym); };T;:I"static VALUE;T;;To;u;[[@i;F;: NEXT;;w;;;[;{;IC; "A predefined pseudo-handle of RTLD_NEXT Which will find the next occurrence of a function in the search order after the current library. ;T;[;![;"I" A predefined pseudo-handle of RTLD_NEXT Which will find the next occurrence of a function in the search order after the current library. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@~;&I"Fiddle::Handle::NEXT;F;xI"(predefined_fiddle_handle(RTLD_NEXT);To;u;[[@i;F;;;;w;;;[;{;IC; "A predefined pseudo-handle of RTLD_DEFAULT Which will find the first occurrence of the desired symbol using the default library search order ;T;[;![;"I" A predefined pseudo-handle of RTLD_DEFAULT Which will find the first occurrence of the desired symbol using the default library search order ;T;#0;$@;.F;/o;0;1T;2i;3i;%@~;&I"Fiddle::Handle::DEFAULT;F;xI"+predefined_fiddle_handle(RTLD_DEFAULT);To;u;[[@i;F;:RTLD_GLOBAL;;w;;;[;{;IC; ":Handle flag. The symbols defined by this library will be made available for symbol resolution of subsequently loaded libraries. ;T;[;![;"I":Handle flag. The symbols defined by this library will be made available for symbol resolution of subsequently loaded libraries. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@~;&I" Fiddle::Handle::RTLD_GLOBAL;F;xI"rtld Fiddle;To;u;[[@i;F;:RTLD_LAZY;;w;;;[;{;IC; "4:Handle flag. Perform lazy binding. Only resolve symbols as the code that references them is executed. If the symbol is never referenced, then it is never resolved. (Lazy binding is only performed for function references; references to variables are always immediately bound when the library is loaded.) ;T;[;![;"I"5:Handle flag. Perform lazy binding. Only resolve symbols as the code that references them is executed. If the symbol is never referenced, then it is never resolved. (Lazy binding is only performed for function references; references to variables are always immediately bound when the library is loaded.) ;T;#0;$@ę;.F;/o;0;1T;2i;3i;%@~;&I"Fiddle::Handle::RTLD_LAZY;F;xI"rtld Fiddle;To;u;[[@i ;F;: RTLD_NOW;;w;;;[;{;IC; ":Handle flag. If this value is specified or the environment variable LD_BIND_NOW is set to a nonempty string, all undefined symbols in the library are resolved before Fiddle.dlopen returns. If this cannot be done an error is returned. ;T;[;![;"I":Handle flag. If this value is specified or the environment variable LD_BIND_NOW is set to a nonempty string, all undefined symbols in the library are resolved before Fiddle.dlopen returns. If this cannot be done an error is returned. ;T;#0;$@Й;.F;/o;0;1T;2i;3i;%@~;&I"Fiddle::Handle::RTLD_NOW;F;xI"rtld Fiddle;To;4;5F;6;;;;&I"Fiddle::Handle#initialize;F;7[[I" argv[];T0[I" self;T0;[[@i;T;;D;0;[;{;IC; "Create a new handler that opens +library+ with +flags+. If no +library+ is specified or +nil+ is given, DEFAULT is used, which is the equivalent to RTLD_DEFAULT. See man 3 dlopen for more. lib = Fiddle::Handle.new The default is dependent on OS, and provide a handle for all libraries already loaded. For example, in most cases you can use this to access +libc+ functions, or ruby functions like +rb_str_new+. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"Hnew(library = nil, flags = Fiddle::RTLD_LAZY | Fiddle::RTLD_GLOBAL);T;IC; ";T;[;![;"I";T;#0;$@ܙ;.F;Bi;C0;7[[I" library;TI"nil;T[I" flags;TI"*Fiddle::RTLD_LAZY|Fiddle::RTLD_GLOBAL;T;$@ܙ;![;"I"Create a new handler that opens +library+ with +flags+. If no +library+ is specified or +nil+ is given, DEFAULT is used, which is the equivalent to RTLD_DEFAULT. See man 3 dlopen for more. lib = Fiddle::Handle.new The default is dependent on OS, and provide a handle for all libraries already loaded. For example, in most cases you can use this to access +libc+ functions, or ruby functions like +rb_str_new+. @overload new(library = nil, flags = Fiddle::RTLD_LAZY | Fiddle::RTLD_GLOBAL);T;#0;$@ܙ;.F;/o;0;1T;2ix;3i;%@~;9I"tstatic VALUE rb_fiddle_handle_initialize(int argc, VALUE argv[], VALUE self) { void *ptr; struct dl_handle *fiddle_handle; VALUE lib, flag; char *clib; int cflag; const char *err; switch( rb_scan_args(argc, argv, "02", &lib, &flag) ){ case 0: clib = NULL; cflag = RTLD_LAZY | RTLD_GLOBAL; break; case 1: clib = NIL_P(lib) ? NULL : StringValueCStr(lib); cflag = RTLD_LAZY | RTLD_GLOBAL; break; case 2: clib = NIL_P(lib) ? NULL : StringValueCStr(lib); cflag = NUM2INT(flag); break; default: rb_bug("rb_fiddle_handle_new"); } #if defined(_WIN32) if( !clib ){ HANDLE rb_libruby_handle(void); ptr = rb_libruby_handle(); } else if( STRCASECMP(clib, "libc") == 0 # ifdef RUBY_COREDLL || STRCASECMP(clib, RUBY_COREDLL) == 0 || STRCASECMP(clib, RUBY_COREDLL".dll") == 0 # endif ){ # ifdef _WIN32_WCE ptr = dlopen("coredll.dll", cflag); # else (void)cflag; ptr = w32_coredll(); # endif } else #endif ptr = dlopen(clib, cflag); #if defined(HAVE_DLERROR) if( !ptr && (err = dlerror()) ){ rb_raise(rb_eFiddleDLError, "%s", err); } #else if( !ptr ){ err = dlerror(); rb_raise(rb_eFiddleDLError, "%s", err); } #endif TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle); if( fiddle_handle->ptr && fiddle_handle->open && fiddle_handle->enable_close ){ dlclose(fiddle_handle->ptr); } fiddle_handle->ptr = ptr; fiddle_handle->open = 1; fiddle_handle->enable_close = 0; if( rb_block_given_p() ){ rb_ensure(rb_yield, self, rb_fiddle_handle_close, self); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Handle#to_i;F;7[;[[@i;T;;;0;[;{;IC; "0Returns the memory address for this handle. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_i;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"AReturns the memory address for this handle. @overload to_i;T;#0;$@;.F;/o;0;1T;2i;3i;%@~;9I"static VALUE rb_fiddle_handle_to_i(VALUE self) { struct dl_handle *fiddle_handle; TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle); return PTR2NUM(fiddle_handle->ptr); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Handle#to_ptr;F;7[;[[@i;T;; ;0;[;{;IC; "0Returns the Fiddle::Pointer of this handle. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" to_ptr;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"CReturns the Fiddle::Pointer of this handle. @overload to_ptr;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@~;9I"static VALUE rb_fiddle_handle_to_ptr(VALUE self) { struct dl_handle *fiddle_handle; TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle); return rb_fiddle_ptr_new_wrap(fiddle_handle->ptr, 0, 0, self, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Handle#close;F;7[;[[@iE;T;;;0;[;{;IC; "]Close this handle. Calling close more than once will raise a Fiddle::DLError exception. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" close;T;IC; ";T;[;![;"I";T;#0;$@(;.F;Bi;C0;7[;$@(;![;"I"oClose this handle. Calling close more than once will raise a Fiddle::DLError exception. @overload close;T;#0;$@(;.F;/o;0;1T;2i>;3iC;%@~;9I"\static VALUE rb_fiddle_handle_close(VALUE self) { struct dl_handle *fiddle_handle; TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle); if(fiddle_handle->open) { int ret = dlclose(fiddle_handle->ptr); fiddle_handle->open = 0; /* Check dlclose for successful return value */ if(ret) { #if defined(HAVE_DLERROR) rb_raise(rb_eFiddleDLError, "%s", dlerror()); #else rb_raise(rb_eFiddleDLError, "could not close handle"); #endif } return INT2NUM(ret); } rb_raise(rb_eFiddleDLError, "dlclose() called too many times"); UNREACHABLE; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Handle#sym;F;7[[I"sym;T0;[[@i ;T;;t ;0;[;{;IC; "Vcall-seq: sym(name) Get the address as an Integer for the function named +name+. ;T;[;![;"I"X call-seq: sym(name) Get the address as an Integer for the function named +name+. ;T;#0;$@>;.F;/o;0;1T;2i;3i;%@~;9I"Kstatic VALUE rb_fiddle_handle_sym(VALUE self, VALUE sym) { struct dl_handle *fiddle_handle; TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle); if( ! fiddle_handle->open ){ rb_raise(rb_eFiddleDLError, "closed handle"); } return fiddle_handle_sym(fiddle_handle->ptr, sym); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Handle#[];F;7[[I"sym;T0;[[@i ;T;;;0;[;{;IC; "Vcall-seq: sym(name) Get the address as an Integer for the function named +name+. ;T;[;![;"@J;#0;$@N;.F;/o;0;1T;2i;3i;%@~;9I"Kstatic VALUE rb_fiddle_handle_sym(VALUE self, VALUE sym) { struct dl_handle *fiddle_handle; TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle); if( ! fiddle_handle->open ){ rb_raise(rb_eFiddleDLError, "closed handle"); } return fiddle_handle_sym(fiddle_handle->ptr, sym); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Fiddle::Handle#file_name;F;7[;[[@i;T;:file_name;0;[;{;IC; "*Returns the file name of this handle. ;T;[o;= ;>I" overload;F;?0;;y ;@0;:I"file_name;T;IC; ";T;[;![;"I";T;#0;$@];.F;Bi;C0;7[;$@];![;"I"@Returns the file name of this handle. @overload file_name;T;#0;$@];.F;/o;0;1T;2i;3i;%@~;9I"static VALUE rb_fiddle_handle_file_name(VALUE self) { struct dl_handle *fiddle_handle; TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle); #if defined(HAVE_DLINFO) && defined(HAVE_CONST_RTLD_DI_LINKMAP) { struct link_map *lm = NULL; int res = dlinfo(fiddle_handle->ptr, RTLD_DI_LINKMAP, &lm); if (res == 0 && lm != NULL) { return rb_str_new_cstr(lm->l_name); } else { #if defined(HAVE_DLERROR) rb_raise(rb_eFiddleDLError, "could not get handle file name: %s", dlerror()); #else rb_raise(rb_eFiddleDLError, "could not get handle file name"); #endif } } #elif defined(HAVE_GETMODULEFILENAME) { char filename[MAX_PATH]; DWORD res = GetModuleFileName(fiddle_handle->ptr, filename, MAX_PATH); if (res == 0) { rb_raise(rb_eFiddleDLError, "could not get handle file name: %s", dlerror()); } return rb_str_new_cstr(filename); } #else (void)fiddle_handle; return Qnil; #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Fiddle::Handle#disable_close;F;7[;[[@i;T;:disable_close;0;[;{;IC; "GDisable a call to dlclose() when this handle is garbage collected. ;T;[o;= ;>I" overload;F;?0;;z ;@0;:I"disable_close;T;IC; ";T;[;![;"I";T;#0;$@s;.F;Bi;C0;7[;$@s;![;"I"aDisable a call to dlclose() when this handle is garbage collected. @overload disable_close;T;#0;$@s;.F;/o;0;1T;2i;3i;%@~;9I"static VALUE rb_fiddle_handle_disable_close(VALUE self) { struct dl_handle *fiddle_handle; TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle); fiddle_handle->enable_close = 0; return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Fiddle::Handle#enable_close;F;7[;[[@i;T;:enable_close;0;[;{;IC; "FEnable a call to dlclose() when this handle is garbage collected. ;T;[o;= ;>I" overload;F;?0;;{ ;@0;:I"enable_close;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"_Enable a call to dlclose() when this handle is garbage collected. @overload enable_close;T;#0;$@;.F;/o;0;1T;2i;3i;%@~;9I"static VALUE rb_fiddle_handle_enable_close(VALUE self) { struct dl_handle *fiddle_handle; TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle); fiddle_handle->enable_close = 1; return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""Fiddle::Handle#close_enabled?;F;7[;[[@i;T;:close_enabled?;0;[;{;IC; "{Returns +true+ if dlclose() will be called when this handle is garbage collected. See man(3) dlclose() for more info.;T;[o;= ;>I" overload;F;?0;;| ;@0;:I"close_enabled?;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"Returns +true+ if dlclose() will be called when this handle is garbage collected. See man(3) dlclose() for more info. @overload close_enabled?;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@~;9I"static VALUE rb_fiddle_handle_close_enabled_p(VALUE self) { struct dl_handle *fiddle_handle; TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle); if(fiddle_handle->enable_close) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;T; @~; IC;[; @~; IC;[; @~; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;: Handle;;;;;[;{;IC; "VThe Fiddle::Handle is the manner to access the dynamic library == Example === Setup libc_so = "/lib64/libc.so.6" => "/lib64/libc.so.6" @handle = Fiddle::Handle.new(libc_so) => # === Setup, with flags libc_so = "/lib64/libc.so.6" => "/lib64/libc.so.6" @handle = Fiddle::Handle.new(libc_so, Fiddle::RTLD_LAZY | Fiddle::RTLD_GLOBAL) => # See RTLD_LAZY and RTLD_GLOBAL === Addresses to symbols strcpy_addr = @handle['strcpy'] => 140062278451968 or strcpy_addr = @handle.sym('strcpy') => 140062278451968 ;T;[;![;"I"Y The Fiddle::Handle is the manner to access the dynamic library == Example === Setup libc_so = "/lib64/libc.so.6" => "/lib64/libc.so.6" @handle = Fiddle::Handle.new(libc_so) => # === Setup, with flags libc_so = "/lib64/libc.so.6" => "/lib64/libc.so.6" @handle = Fiddle::Handle.new(libc_so, Fiddle::RTLD_LAZY | Fiddle::RTLD_GLOBAL) => # See RTLD_LAZY and RTLD_GLOBAL === Addresses to symbols strcpy_addr = @handle['strcpy'] => 140062278451968 or strcpy_addr = @handle.sym('strcpy') => 140062278451968 ;T;#0;$@~;.F;/o;0;1T;2i;3i;%@;&I"Fiddle::Handle;F;'@; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@im[@,i6[@i;T;: Fiddle;;;;;[;{;IC; "A libffi wrapper for Ruby. == Description Fiddle is an extension to translate a foreign function interface (FFI) with ruby. It wraps {libffi}[http://sourceware.org/libffi/], a popular C library which provides a portable interface that allows code written in one language to call code written in another language. == Example Here we will use Fiddle::Function to wrap {floor(3) from libm}[http://linux.die.net/man/3/floor] require 'fiddle' libm = Fiddle.dlopen('/lib/libm.so.6') floor = Fiddle::Function.new( libm['floor'], [Fiddle::TYPE_DOUBLE], Fiddle::TYPE_DOUBLE ) puts floor.call(3.14159) #=> 3.0;T;[;![;"I" A libffi wrapper for Ruby. == Description Fiddle is an extension to translate a foreign function interface (FFI) with ruby. It wraps {libffi}[http://sourceware.org/libffi/], a popular C library which provides a portable interface that allows code written in one language to call code written in another language. == Example Here we will use Fiddle::Function to wrap {floor(3) from libm}[http://linux.die.net/man/3/floor] require 'fiddle' libm = Fiddle.dlopen('/lib/libm.so.6') floor = Fiddle::Function.new( libm['floor'], [Fiddle::TYPE_DOUBLE], Fiddle::TYPE_DOUBLE ) puts floor.call(3.14159) #=> 3.0 ;T;#0;$@;.F;/o;0;1T;2im;3i;Bi;%@;&I" Fiddle;Fo;;IC;[Jo; ;IC;[o;4;5F;6;;;;&I"Zlib::ZStream#avail_out;F;7[;[[I"ext/zlib/zlib.c;Ti;T;:avail_out;0;[;{;IC; "Returns number of bytes of free spaces in output buffer. Because the free space is allocated automatically, this method returns 0 normally. ;T;[;![;"I"Returns number of bytes of free spaces in output buffer. Because the free space is allocated automatically, this method returns 0 normally. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@ߚ;9I"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;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::ZStream#avail_out=;F;7[[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;0;1T;2i;3i;%@ߚ;9I"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;4;5F;6;;;;&I"Zlib::ZStream#avail_in;F;7[;[[@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;0;1T;2i;3i;%@ߚ;9I"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;4;5F;6;;;;&I"Zlib::ZStream#total_in;F;7[;[[@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;$@;.F;/o;0;1T;2i;3i;%@ߚ;9I"pstatic VALUE rb_zstream_total_in(VALUE obj) { return rb_uint2inum(get_zstream(obj)->stream.total_in); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::ZStream#total_out;F;7[;[[@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;$@;.F;/o;0;1T;2i;3i;%@ߚ;9I"rstatic VALUE rb_zstream_total_out(VALUE obj) { return rb_uint2inum(get_zstream(obj)->stream.total_out); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::ZStream#data_type;F;7[;[[@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;$@*;.F;/o;0;1T;2i;3i;%@ߚ;9I"mstatic VALUE rb_zstream_data_type(VALUE obj) { return INT2FIX(get_zstream(obj)->stream.data_type); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::ZStream#adler;F;7[;[[@i;T;: adler;0;[;{;IC; "#Returns the adler-32 checksum. ;T;[;![;"I"$Returns the adler-32 checksum. ;T;#0;$@8;.F;/o;0;1T;2i;3i;%@ߚ;9I"jstatic VALUE rb_zstream_adler(VALUE obj) { return rb_uint2inum(get_zstream(obj)->stream.adler); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::ZStream#finished?;F;7[;[[@i;T;:finished?;0;[;{;IC; ",Returns true if the stream is finished.;T;[o;A ;>I" return;F;?@;0;@[@L;$@F;![;"I"-Returns true if the stream is finished. ;T;#0;$@F;.F;/o;0;1T;2i;3i;Bi;%@ߚ;9I"ystatic VALUE rb_zstream_finished_p(VALUE obj) { return ZSTREAM_IS_FINISHED(get_zstream(obj)) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::ZStream#stream_end?;F;7[;[[@i;T;:stream_end?;0;[;{;IC; ",Returns true if the stream is finished.;T;[o;A ;>I" return;F;?@;0;@[@L;$@W;![;"@S;#0;$@W;.F;/o;0;1T;2i;3i;Bi;%@ߚ;9I"ystatic VALUE rb_zstream_finished_p(VALUE obj) { return ZSTREAM_IS_FINISHED(get_zstream(obj)) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::ZStream#closed?;F;7[;[[@i;T;;\;0;[;{;IC; "*Returns true if the stream is closed.;T;[o;A ;>I" return;F;?@;0;@[@L;$@g;![;"I"+Returns true if the stream is closed. ;T;#0;$@g;.F;/o;0;1T;2i;3i;Bi;%@ߚ;9I"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;4;5F;6;;;;&I"Zlib::ZStream#ended?;F;7[;[[@i;T;: ended?;0;[;{;IC; "*Returns true if the stream is closed.;T;[o;A ;>I" return;F;?@;0;@[@L;$@x;![;"@t;#0;$@x;.F;/o;0;1T;2i;3i;Bi;%@ߚ;9I"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;4;5F;6;;;;&I"Zlib::ZStream#close;F;7[;[[@iY;T;;;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;0;1T;2iU;3iW;%@ߚ;9I"cstatic VALUE rb_zstream_end(VALUE obj) { zstream_end(get_zstream(obj)); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::ZStream#end;F;7[;[[@iY;T;;3;0;[;{;IC; "TCloses the stream. All operations on the closed stream will raise an exception. ;T;[;![;"@;#0;$@;.F;/o;0;1T;2iU;3iW;%@ߚ;9I"cstatic VALUE rb_zstream_end(VALUE obj) { zstream_end(get_zstream(obj)); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::ZStream#reset;F;7[;[[@id;T;;;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;0;1T;2i`;3ib;%@ߚ;9I"gstatic VALUE rb_zstream_reset(VALUE obj) { zstream_reset(get_zstream(obj)); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::ZStream#finish;F;7[;[[@it;T;;!;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;= ;>I" overload;F;?0;;!;@0;:I" finish;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;!;@0;:I" finish;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" chunk;T;$@o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"!@yield [chunk] @return [nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"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;0;1T;2ik;3it;%@ߚ;9I"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;4;5F;6;;;;&I" Zlib::ZStream#flush_next_in;F;7[;[[@i;T;:flush_next_in;0;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"flush_next_in;T;IC; ";T;[;![;"I";T;#0;$@ޛ;.F;Bi;C0;7[;$@ޛ;![;"I" @overload flush_next_in;T;#0;$@ޛ;.F;/o;0;1T;2i~;3i;%@ߚ;9I"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;4;5F;6;;;;&I"!Zlib::ZStream#flush_next_out;F;7[;[[@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;= ;>I" overload;F;?0;; ;@0;:I"flush_next_out;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;; ;@0;:I"flush_next_out;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" chunk;T;$@o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"!@yield [chunk] @return [nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"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;0;1T;2i;3i;%@ߚ;9I"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; @ߚ; IC;[; @ߚ; IC;[; @ߚ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i-;T;: ZStream;;;;;[;{;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;0;1T;2i;3iQ;Bi;%o;( ;)0;*0;+0;: Zlib;%@;-@ݚ;0;&I"Zlib::ZStream;F;'@o; ;IC;[ o;4;5F;6;;;;&I"Zlib::Deflate.deflate;F;7[[@90;[[@i;T;: deflate;0;[;{;IC; "call-seq: Zlib.deflate(string[, level]) Zlib::Deflate.deflate(string[, level]) Compresses the given +string+. Valid values of level are Zlib::NO_COMPRESSION, Zlib::BEST_SPEED, Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, or an integer from 0 to 9. This method is almost equivalent to the following code: def deflate(string, level) z = Zlib::Deflate.new(level) dst = z.deflate(string, Zlib::FINISH) z.close dst end See also Zlib.inflate ;T;[;![;"I" call-seq: Zlib.deflate(string[, level]) Zlib::Deflate.deflate(string[, level]) Compresses the given +string+. Valid values of level are Zlib::NO_COMPRESSION, Zlib::BEST_SPEED, Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, or an integer from 0 to 9. This method is almost equivalent to the following code: def deflate(string, level) z = Zlib::Deflate.new(level) dst = z.deflate(string, Zlib::FINISH) z.close dst end See also Zlib.inflate ;T;#0;$@6;.F;/o;0;1T;2i;3i;%@4;9I"&static VALUE rb_deflate_s_deflate(int argc, VALUE *argv, VALUE klass) { struct zstream z; VALUE src, level, dst, args[2]; int err, lev; rb_scan_args(argc, argv, "11", &src, &level); lev = ARG_LEVEL(level); StringValue(src); zstream_init_deflate(&z); err = deflateInit(&z.stream, lev); if (err != Z_OK) { raise_zlib_error(err, z.stream.msg); } ZSTREAM_READY(&z); args[0] = (VALUE)&z; args[1] = src; dst = rb_ensure(deflate_run, (VALUE)args, zstream_ensure_end, (VALUE)&z); return dst; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::Deflate#initialize;F;7[[@90;[[@ie;T;;D;0;[;{;IC; "call-seq: Zlib::Deflate.new(level=DEFAULT_COMPRESSION, window_bits=MAX_WBITS, mem_level=DEF_MEM_LEVEL, strategy=DEFAULT_STRATEGY) Creates a new deflate stream for compression. If a given argument is nil, the default value of that argument is used. The +level+ sets the compression level for the deflate stream between 0 (no compression) and 9 (best compression). The following constants have been defined to make code more readable: * Zlib::DEFAULT_COMPRESSION * Zlib::NO_COMPRESSION * Zlib::BEST_SPEED * Zlib::BEST_COMPRESSION See http://www.zlib.net/manual.html#Constants for further information. The +window_bits+ sets the size of the history buffer and should be between 8 and 15. Larger values of this parameter result in better compression at the expense of memory usage. The +mem_level+ specifies how much memory should be allocated for the internal compression state. 1 uses minimum memory but is slow and reduces compression ratio while 9 uses maximum memory for optimal speed. The default value is 8. Two constants are defined: * Zlib::DEF_MEM_LEVEL * Zlib::MAX_MEM_LEVEL The +strategy+ sets the deflate compression strategy. The following strategies are available: Zlib::DEFAULT_STRATEGY:: For normal data Zlib::FILTERED:: For data produced by a filter or predictor Zlib::FIXED:: Prevents dynamic Huffman codes Zlib::HUFFMAN_ONLY:: Prevents string matching Zlib::RLE:: Designed for better compression of PNG image data See the constants for further description. == Examples === Basic open "compressed.file", "w+" do |io| io << Zlib::Deflate.new.deflate(File.read("big.file")) end === Custom compression open "compressed.file", "w+" do |compressed_io| deflate = Zlib::Deflate.new(Zlib::BEST_COMPRESSION, Zlib::MAX_WBITS, Zlib::MAX_MEM_LEVEL, Zlib::HUFFMAN_ONLY) begin open "big.file" do |big_io| until big_io.eof? do compressed_io << zd.deflate(big_io.read(16384)) end end ensure deflate.close end end While this example will work, for best optimization review the flags for your specific time, memory usage and output space requirements. ;T;[;![;"I" call-seq: Zlib::Deflate.new(level=DEFAULT_COMPRESSION, window_bits=MAX_WBITS, mem_level=DEF_MEM_LEVEL, strategy=DEFAULT_STRATEGY) Creates a new deflate stream for compression. If a given argument is nil, the default value of that argument is used. The +level+ sets the compression level for the deflate stream between 0 (no compression) and 9 (best compression). The following constants have been defined to make code more readable: * Zlib::DEFAULT_COMPRESSION * Zlib::NO_COMPRESSION * Zlib::BEST_SPEED * Zlib::BEST_COMPRESSION See http://www.zlib.net/manual.html#Constants for further information. The +window_bits+ sets the size of the history buffer and should be between 8 and 15. Larger values of this parameter result in better compression at the expense of memory usage. The +mem_level+ specifies how much memory should be allocated for the internal compression state. 1 uses minimum memory but is slow and reduces compression ratio while 9 uses maximum memory for optimal speed. The default value is 8. Two constants are defined: * Zlib::DEF_MEM_LEVEL * Zlib::MAX_MEM_LEVEL The +strategy+ sets the deflate compression strategy. The following strategies are available: Zlib::DEFAULT_STRATEGY:: For normal data Zlib::FILTERED:: For data produced by a filter or predictor Zlib::FIXED:: Prevents dynamic Huffman codes Zlib::HUFFMAN_ONLY:: Prevents string matching Zlib::RLE:: Designed for better compression of PNG image data See the constants for further description. == Examples === Basic open "compressed.file", "w+" do |io| io << Zlib::Deflate.new.deflate(File.read("big.file")) end === Custom compression open "compressed.file", "w+" do |compressed_io| deflate = Zlib::Deflate.new(Zlib::BEST_COMPRESSION, Zlib::MAX_WBITS, Zlib::MAX_MEM_LEVEL, Zlib::HUFFMAN_ONLY) begin open "big.file" do |big_io| until big_io.eof? do compressed_io << zd.deflate(big_io.read(16384)) end end ensure deflate.close end end While this example will work, for best optimization review the flags for your specific time, memory usage and output space requirements. ;T;#0;$@E;.F;/o;0;1T;2i;3ib;%@4;9I"+static VALUE rb_deflate_initialize(int argc, VALUE *argv, VALUE obj) { struct zstream *z; VALUE level, wbits, memlevel, strategy; int err; rb_scan_args(argc, argv, "04", &level, &wbits, &memlevel, &strategy); TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z); err = deflateInit2(&z->stream, ARG_LEVEL(level), Z_DEFLATED, ARG_WBITS(wbits), ARG_MEMLEVEL(memlevel), ARG_STRATEGY(strategy)); if (err != Z_OK) { raise_zlib_error(err, z->stream.msg); } ZSTREAM_READY(z); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""Zlib::Deflate#initialize_copy;F;7[[I" orig;T0;[[@i;T;;];0;[;{;IC; "#Duplicates the deflate stream. ;T;[;![;"I"% Duplicates the deflate stream. ;T;#0;$@T;.F;/o;0;1T;2iz;3i|;%@4;9I"static VALUE rb_deflate_init_copy(VALUE self, VALUE orig) { struct zstream *z1, *z2; int err; TypedData_Get_Struct(self, struct zstream, &zstream_data_type, z1); z2 = get_zstream(orig); if (z1 == z2) return self; err = deflateCopy(&z1->stream, &z2->stream); if (err != Z_OK) { raise_zlib_error(err, 0); } z1->input = NIL_P(z2->input) ? Qnil : rb_str_dup(z2->input); z1->buf = NIL_P(z2->buf) ? Qnil : rb_str_dup(z2->buf); z1->flags = z2->flags; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::Deflate#deflate;F;7[[@90;[[@i;T;; ;0;[;{;IC; "ccall-seq: z.deflate(string, flush = Zlib::NO_FLUSH) -> String z.deflate(string, flush = Zlib::NO_FLUSH) { |chunk| ... } -> nil Inputs +string+ into the deflate stream and returns the output from the stream. On calling this method, both the input and the output buffers of the stream are flushed. If +string+ is nil, this method finishes the stream, just like Zlib::ZStream#finish. If a block is given consecutive deflated chunks from the +string+ are yielded to the block and +nil+ is returned. The +flush+ parameter specifies the flush mode. The following constants may be used: Zlib::NO_FLUSH:: The default Zlib::SYNC_FLUSH:: Flushes the output to a byte boundary Zlib::FULL_FLUSH:: SYNC_FLUSH + resets the compression state Zlib::FINISH:: Pending input is processed, pending output is flushed. See the constants for further description. ;T;[;![;"I"f call-seq: z.deflate(string, flush = Zlib::NO_FLUSH) -> String z.deflate(string, flush = Zlib::NO_FLUSH) { |chunk| ... } -> nil Inputs +string+ into the deflate stream and returns the output from the stream. On calling this method, both the input and the output buffers of the stream are flushed. If +string+ is nil, this method finishes the stream, just like Zlib::ZStream#finish. If a block is given consecutive deflated chunks from the +string+ are yielded to the block and +nil+ is returned. The +flush+ parameter specifies the flush mode. The following constants may be used: Zlib::NO_FLUSH:: The default Zlib::SYNC_FLUSH:: Flushes the output to a byte boundary Zlib::FULL_FLUSH:: SYNC_FLUSH + resets the compression state Zlib::FINISH:: Pending input is processed, pending output is flushed. See the constants for further description. ;T;#0;$@d;.F;/o;0;1T;2i;3i;%@4;9I"static VALUE rb_deflate_deflate(int argc, VALUE *argv, VALUE obj) { struct zstream *z = get_zstream(obj); VALUE src, flush; rb_scan_args(argc, argv, "11", &src, &flush); do_deflate(z, src, ARG_FLUSH(flush)); return zstream_detach_buffer(z); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::Deflate#<<;F;7[[I"src;T0;[[@i ;T;;;0;[;{;IC; "call-seq: << string Inputs +string+ into the deflate stream just like Zlib::Deflate#deflate, but returns the Zlib::Deflate object itself. The output from the stream is preserved in output buffer. ;T;[;![;"I" call-seq: << string Inputs +string+ into the deflate stream just like Zlib::Deflate#deflate, but returns the Zlib::Deflate object itself. The output from the stream is preserved in output buffer. ;T;#0;$@s;.F;/o;0;1T;2i;3i;%@4;9I"{static VALUE rb_deflate_addstr(VALUE obj, VALUE src) { do_deflate(get_zstream(obj), src, Z_NO_FLUSH); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::Deflate#flush;F;7[[@90;[[@i ;T;;;0;[;{;IC; "call-seq: flush(flush = Zlib::SYNC_FLUSH) -> String flush(flush = Zlib::SYNC_FLUSH) { |chunk| ... } -> nil This method is equivalent to deflate('', flush). This method is just provided to improve the readability of your Ruby program. If a block is given chunks of deflate output are yielded to the block until the buffer is flushed. See Zlib::Deflate#deflate for detail on the +flush+ constants NO_FLUSH, SYNC_FLUSH, FULL_FLUSH and FINISH. ;T;[;![;"I" call-seq: flush(flush = Zlib::SYNC_FLUSH) -> String flush(flush = Zlib::SYNC_FLUSH) { |chunk| ... } -> nil This method is equivalent to deflate('', flush). This method is just provided to improve the readability of your Ruby program. If a block is given chunks of deflate output are yielded to the block until the buffer is flushed. See Zlib::Deflate#deflate for detail on the +flush+ constants NO_FLUSH, SYNC_FLUSH, FULL_FLUSH and FINISH. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@4;9I"ystatic VALUE rb_deflate_flush(int argc, VALUE *argv, VALUE obj) { struct zstream *z = get_zstream(obj); VALUE v_flush; int flush; rb_scan_args(argc, argv, "01", &v_flush); flush = FIXNUMARG(v_flush, Z_SYNC_FLUSH); if (flush != Z_NO_FLUSH) { /* prevent Z_BUF_ERROR */ zstream_run(z, (Bytef*)"", 0, flush); } return zstream_detach_buffer(z); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::Deflate#params;F;7[[I" v_level;T0[I"v_strategy;T0;[[@i<;T;;;0;[;{;IC; ".call-seq: params(level, strategy) Changes the parameters of the deflate stream to allow changes between different types of data that require different types of compression. Any unprocessed data is flushed before changing the params. See Zlib::Deflate.new for a description of +level+ and +strategy+. ;T;[;![;"I"1 call-seq: params(level, strategy) Changes the parameters of the deflate stream to allow changes between different types of data that require different types of compression. Any unprocessed data is flushed before changing the params. See Zlib::Deflate.new for a description of +level+ and +strategy+. ;T;#0;$@;.F;/o;0;1T;2i0;3i9;%@4;9I"-static VALUE rb_deflate_params(VALUE obj, VALUE v_level, VALUE v_strategy) { struct zstream *z = get_zstream(obj); int level, strategy; int err; uInt n; long filled; level = ARG_LEVEL(v_level); strategy = ARG_STRATEGY(v_strategy); n = z->stream.avail_out; err = deflateParams(&z->stream, level, strategy); filled = n - z->stream.avail_out; while (err == Z_BUF_ERROR) { rb_warning("deflateParams() returned Z_BUF_ERROR"); zstream_expand_buffer(z); rb_str_set_len(z->buf, RSTRING_LEN(z->buf) + filled); n = z->stream.avail_out; err = deflateParams(&z->stream, level, strategy); filled = n - z->stream.avail_out; } if (err != Z_OK) { raise_zlib_error(err, z->stream.msg); } rb_str_set_len(z->buf, RSTRING_LEN(z->buf) + filled); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Zlib::Deflate#set_dictionary;F;7[[I"dic;T0;[[@ii;T;:set_dictionary;0;[;{;IC; "call-seq: set_dictionary(string) Sets the preset dictionary and returns +string+. This method is available just only after Zlib::Deflate.new or Zlib::ZStream#reset method was called. See zlib.h for details. Can raise errors of Z_STREAM_ERROR if a parameter is invalid (such as NULL dictionary) or the stream state is inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the expected one (incorrect adler32 value) ;T;[;![;"I" call-seq: set_dictionary(string) Sets the preset dictionary and returns +string+. This method is available just only after Zlib::Deflate.new or Zlib::ZStream#reset method was called. See zlib.h for details. Can raise errors of Z_STREAM_ERROR if a parameter is invalid (such as NULL dictionary) or the stream state is inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the expected one (incorrect adler32 value) ;T;#0;$@;.F;/o;0;1T;2i[;3if;%@4;9I"]static VALUE rb_deflate_set_dictionary(VALUE obj, VALUE dic) { struct zstream *z = get_zstream(obj); VALUE src = dic; int err; StringValue(src); err = deflateSetDictionary(&z->stream, (Bytef*)RSTRING_PTR(src), RSTRING_LENINT(src)); if (err != Z_OK) { raise_zlib_error(err, z->stream.msg); } return dic; };T;:I"static VALUE;T;;T; @4; IC;[; @4; IC;[; @4; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@iZ;T;: Deflate;;;;;[;{;IC; "^Zlib::Deflate is the class for compressing data. See Zlib::ZStream for more information.;T;[;![;"I"` Zlib::Deflate is the class for compressing data. See Zlib::ZStream for more information. ;T;#0;$@4;.F;/o;0;1T;2i;3i;Bi;%o;( ;)0;*0;+0;; ;%@;-@ݚ;0;&I"Zlib::Deflate;F;'@ߚo; ;IC;[ o;4;5F;6;;;;&I"Zlib::Inflate.inflate;F;7[[I"src;T0;[[@i;T;: inflate;0;[;{;IC; "call-seq: Zlib.inflate(string) Zlib::Inflate.inflate(string) Decompresses +string+. Raises a Zlib::NeedDict exception if a preset dictionary is needed for decompression. This method is almost equivalent to the following code: def inflate(string) zstream = Zlib::Inflate.new buf = zstream.inflate(string) zstream.finish zstream.close buf end See also Zlib.deflate ;T;[;![;"I" call-seq: Zlib.inflate(string) Zlib::Inflate.inflate(string) Decompresses +string+. Raises a Zlib::NeedDict exception if a preset dictionary is needed for decompression. This method is almost equivalent to the following code: def inflate(string) zstream = Zlib::Inflate.new buf = zstream.inflate(string) zstream.finish zstream.close buf end See also Zlib.deflate ;T;#0;$@ɜ;.F;/o;0;1T;2i;3i;%@ǜ;9I"static VALUE rb_inflate_s_inflate(VALUE obj, VALUE src) { struct zstream z; VALUE dst, args[2]; int err; StringValue(src); zstream_init_inflate(&z); err = inflateInit(&z.stream); if (err != Z_OK) { raise_zlib_error(err, z.stream.msg); } ZSTREAM_READY(&z); args[0] = (VALUE)&z; args[1] = src; dst = rb_ensure(inflate_run, (VALUE)args, zstream_ensure_end, (VALUE)&z); return dst; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::Inflate#initialize;F;7[[@90;[[@i;T;;D;0;[;{;IC; "call-seq: Zlib::Inflate.new(window_bits = Zlib::MAX_WBITS) Creates a new inflate stream for decompression. +window_bits+ sets the size of the history buffer and can have the following values: 0:: Have inflate use the window size from the zlib header of the compressed stream. (8..15):: Overrides the window size of the inflate header in the compressed stream. The window size must be greater than or equal to the window size of the compressed stream. Greater than 15:: Add 32 to window_bits to enable zlib and gzip decoding with automatic header detection, or add 16 to decode only the gzip format (a Zlib::DataError will be raised for a non-gzip stream). (-8..-15):: Enables raw deflate mode which will not generate a check value, and will not look for any check values for comparison at the end of the stream. This is for use with other formats that use the deflate compressed data format such as zip which provide their own check values. == Example open "compressed.file" do |compressed_io| zi = Zlib::Inflate.new(Zlib::MAX_WBITS + 32) begin open "uncompressed.file", "w+" do |uncompressed_io| uncompressed_io << zi.inflate(compressed_io.read) end ensure zi.close end end ;T;[;![;"I" call-seq: Zlib::Inflate.new(window_bits = Zlib::MAX_WBITS) Creates a new inflate stream for decompression. +window_bits+ sets the size of the history buffer and can have the following values: 0:: Have inflate use the window size from the zlib header of the compressed stream. (8..15):: Overrides the window size of the inflate header in the compressed stream. The window size must be greater than or equal to the window size of the compressed stream. Greater than 15:: Add 32 to window_bits to enable zlib and gzip decoding with automatic header detection, or add 16 to decode only the gzip format (a Zlib::DataError will be raised for a non-gzip stream). (-8..-15):: Enables raw deflate mode which will not generate a check value, and will not look for any check values for comparison at the end of the stream. This is for use with other formats that use the deflate compressed data format such as zip which provide their own check values. == Example open "compressed.file" do |compressed_io| zi = Zlib::Inflate.new(Zlib::MAX_WBITS + 32) begin open "uncompressed.file", "w+" do |uncompressed_io| uncompressed_io << zi.inflate(compressed_io.read) end ensure zi.close end end ;T;#0;$@ٜ;.F;/o;0;1T;2i;3i;%@ǜ;9I"static VALUE rb_inflate_initialize(int argc, VALUE *argv, VALUE obj) { struct zstream *z; VALUE wbits; int err; rb_scan_args(argc, argv, "01", &wbits); TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z); err = inflateInit2(&z->stream, ARG_WBITS(wbits)); if (err != Z_OK) { raise_zlib_error(err, z->stream.msg); } ZSTREAM_READY(z); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Zlib::Inflate#add_dictionary;F;7[[I"dictionary;T0;[[@i;T;:add_dictionary;0;[;{;IC; "call-seq: add_dictionary(string) Provide the inflate stream with a dictionary that may be required in the future. Multiple dictionaries may be provided. The inflate stream will automatically choose the correct user-provided dictionary based on the stream's required dictionary. ;T;[;![;"I" call-seq: add_dictionary(string) Provide the inflate stream with a dictionary that may be required in the future. Multiple dictionaries may be provided. The inflate stream will automatically choose the correct user-provided dictionary based on the stream's required dictionary. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@ǜ;9I"static VALUE rb_inflate_add_dictionary(VALUE obj, VALUE dictionary) { VALUE dictionaries = rb_ivar_get(obj, id_dictionaries); VALUE checksum = do_checksum(1, &dictionary, adler32); rb_hash_aset(dictionaries, checksum, dictionary); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::Inflate#inflate;F;7[[@90;[[@iT;T;; ;0;[;{;IC; "call-seq: inflate(deflate_string, buffer: nil) -> String inflate(deflate_string, buffer: nil) { |chunk| ... } -> nil Inputs +deflate_string+ into the inflate stream and returns the output from the stream. Calling this method, both the input and the output buffer of the stream are flushed. If string is +nil+, this method finishes the stream, just like Zlib::ZStream#finish. If a block is given consecutive inflated chunks from the +deflate_string+ are yielded to the block and +nil+ is returned. If a :buffer keyword argument is given and not nil: * The :buffer keyword should be a String, and will used as the output buffer. Using this option can reuse the memory required during inflation. * When not passing a block, the return value will be the same object as the :buffer keyword argument. * When passing a block, the yielded chunks will be the same value as the :buffer keyword argument. Raises a Zlib::NeedDict exception if a preset dictionary is needed to decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then call this method again with an empty string to flush the stream: inflater = Zlib::Inflate.new begin out = inflater.inflate compressed rescue Zlib::NeedDict # ensure the dictionary matches the stream's required dictionary raise unless inflater.adler == Zlib.adler32(dictionary) inflater.set_dictionary dictionary inflater.inflate '' end # ... inflater.close See also Zlib::Inflate.new ;T;[;![;"I" call-seq: inflate(deflate_string, buffer: nil) -> String inflate(deflate_string, buffer: nil) { |chunk| ... } -> nil Inputs +deflate_string+ into the inflate stream and returns the output from the stream. Calling this method, both the input and the output buffer of the stream are flushed. If string is +nil+, this method finishes the stream, just like Zlib::ZStream#finish. If a block is given consecutive inflated chunks from the +deflate_string+ are yielded to the block and +nil+ is returned. If a :buffer keyword argument is given and not nil: * The :buffer keyword should be a String, and will used as the output buffer. Using this option can reuse the memory required during inflation. * When not passing a block, the return value will be the same object as the :buffer keyword argument. * When passing a block, the yielded chunks will be the same value as the :buffer keyword argument. Raises a Zlib::NeedDict exception if a preset dictionary is needed to decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then call this method again with an empty string to flush the stream: inflater = Zlib::Inflate.new begin out = inflater.inflate compressed rescue Zlib::NeedDict # ensure the dictionary matches the stream's required dictionary raise unless inflater.adler == Zlib.adler32(dictionary) inflater.set_dictionary dictionary inflater.inflate '' end # ... inflater.close See also Zlib::Inflate.new ;T;#0;$@;.F;/o;0;1T;2i&;3iQ;%@ǜ;9I"static VALUE rb_inflate_inflate(int argc, VALUE* argv, VALUE obj) { struct zstream *z = get_zstream(obj); VALUE dst, src, opts, buffer = Qnil; if (OPTHASH_GIVEN_P(opts)) { VALUE buf; rb_get_kwargs(opts, &id_buffer, 0, 1, &buf); if (buf != Qundef && buf != Qnil) { buffer = StringValue(buf); } } if (buffer != Qnil) { if (!(ZSTREAM_REUSE_BUFFER_P(z) && z->buf == buffer)) { long len = RSTRING_LEN(buffer); if (len >= ZSTREAM_AVAIL_OUT_STEP_MAX) { rb_str_modify(buffer); } else { len = ZSTREAM_AVAIL_OUT_STEP_MAX - len; rb_str_modify_expand(buffer, len); } rb_str_set_len(buffer, 0); z->flags |= ZSTREAM_REUSE_BUFFER; z->buf = buffer; } } else if (ZSTREAM_REUSE_BUFFER_P(z)) { z->flags &= ~ZSTREAM_REUSE_BUFFER; z->buf = Qnil; } rb_scan_args(argc, argv, "10", &src); if (ZSTREAM_IS_FINISHED(z)) { if (NIL_P(src)) { dst = zstream_detach_buffer(z); } else { StringValue(src); zstream_append_buffer2(z, src); if (ZSTREAM_REUSE_BUFFER_P(z)) { dst = rb_str_resize(buffer, 0); } else { dst = rb_str_new(0, 0); } } } else { do_inflate(z, src); dst = zstream_detach_buffer(z); if (ZSTREAM_IS_FINISHED(z)) { zstream_passthrough_input(z); } } return dst; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::Inflate#<<;F;7[[I"src;T0;[[@i;T;;;0;[;{;IC; "Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate, but returns the Zlib::Inflate object itself. The output from the stream is preserved in output buffer. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"<< string;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;T0;$@;![;"I"Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate, but returns the Zlib::Inflate object itself. The output from the stream is preserved in output buffer. @overload << string;T;#0;$@;.F;/o;0;1T;2i;3i;%@ǜ;9I"Zstatic VALUE rb_inflate_addstr(VALUE obj, VALUE src) { struct zstream *z = get_zstream(obj); if (ZSTREAM_IS_FINISHED(z)) { if (!NIL_P(src)) { StringValue(src); zstream_append_buffer2(z, src); } } else { do_inflate(z, src); if (ZSTREAM_IS_FINISHED(z)) { zstream_passthrough_input(z); } } return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::Inflate#sync;F;7[[I"src;T0;[[@i;T;;;0;[;{;IC; "Inputs +string+ into the end of input buffer and skips data until a full flush point can be found. If the point is found in the buffer, this method flushes the buffer and returns false. Otherwise it returns +true+ and the following data of full flush point is preserved in the buffer. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"sync(string);T;IC; ";T;[;![;"I";T;#0;$@!;.F;Bi;C0;7[[I" string;T0;$@!;![;"I"7Inputs +string+ into the end of input buffer and skips data until a full flush point can be found. If the point is found in the buffer, this method flushes the buffer and returns false. Otherwise it returns +true+ and the following data of full flush point is preserved in the buffer. @overload sync(string);T;#0;$@!;.F;/o;0;1T;2i;3i;%@ǜ;9I"static VALUE rb_inflate_sync(VALUE obj, VALUE src) { struct zstream *z = get_zstream(obj); StringValue(src); return zstream_sync(z, (Bytef*)RSTRING_PTR(src), RSTRING_LEN(src)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::Inflate#sync_point?;F;7[;[[@i;T;:sync_point?;0;[;{;IC; "OQuoted verbatim from original documentation: What is this? :);T;[o;A ;>I" return;F;?@;0;@[@L;$@;;![;"I"PQuoted verbatim from original documentation: What is this? :) ;T;#0;$@;;.F;/o;0;1T;2i;3i;Bi;%@ǜ;9I"static VALUE rb_inflate_sync_point_p(VALUE obj) { struct zstream *z = get_zstream(obj); int err; err = inflateSyncPoint(&z->stream); if (err == 1) { return Qtrue; } if (err != Z_OK) { raise_zlib_error(err, z->stream.msg); } return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Zlib::Inflate#set_dictionary;F;7[[I"dic;T0;[[@i;T;; ;0;[;{;IC; "Sets the preset dictionary and returns +string+. This method is available just only after a Zlib::NeedDict exception was raised. See zlib.h for details. ;T;[;![;"I" Sets the preset dictionary and returns +string+. This method is available just only after a Zlib::NeedDict exception was raised. See zlib.h for details. ;T;#0;$@L;.F;/o;0;1T;2i;3i;%@ǜ;9I"]static VALUE rb_inflate_set_dictionary(VALUE obj, VALUE dic) { struct zstream *z = get_zstream(obj); VALUE src = dic; int err; StringValue(src); err = inflateSetDictionary(&z->stream, (Bytef*)RSTRING_PTR(src), RSTRING_LENINT(src)); if (err != Z_OK) { raise_zlib_error(err, z->stream.msg); } return dic; };T;:I"static VALUE;T;;T; @ǜ; IC;[; @ǜ; IC;[; @ǜ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i}[@if;T;: Inflate;;;;;[;{;IC; "Zlib:Inflate is the class for decompressing compressed data. Unlike Zlib::Deflate, an instance of this class is not able to duplicate (clone, dup) itself.;T;[;![;"I" Zlib:Inflate is the class for decompressing compressed data. Unlike Zlib::Deflate, an instance of this class is not able to duplicate (clone, dup) itself. ;T;#0;$@ǜ;.F;/o;0;1T;2i};3i;Bi;%o;( ;)0;*0;+0;; ;%@;-@ݚ;0;&I"Zlib::Inflate;F;'@ߚo; ;IC;[o; ;IC;[o;4;5F;6;;;;&I" Zlib::GzipFile::Error#input;F;7[;[[@i;F;: input;;;[;{;IC; "input gzipped string ;T;[;![;"I"input gzipped string;T;#0;$@s;.F;/o;0;1T;2i;3i;%@q;;To;4;5F;6;;;;&I""Zlib::GzipFile::Error#inspect;F;7[;[[@i; ;T;;J;0;[;{;IC; ".Constructs a String of the GzipFile Error ;T;[;![;"I"0 Constructs a String of the GzipFile Error ;T;#0;$@;.F;/o;0;1T;2i6 ;3i8 ;%@q;9I"Cstatic VALUE gzfile_error_inspect(VALUE error) { VALUE str = rb_call_super(0, 0); VALUE input = rb_attr_get(error, id_input); if (!NIL_P(input)) { rb_str_resize(str, RSTRING_LEN(str)-1); rb_str_cat2(str, ", input="); rb_str_append(str, rb_str_inspect(input)); rb_str_cat2(str, ">"); } return str; };T;:I"static VALUE;T;;T; @q; IC;[; @q; IC;[; @q; IC;{;IC;{;T;IC;{; IC;{;q@s;s0;T;T;T;{;[;[[@i[@i;T;;;;;;;[;{;IC; "@Base class of errors that occur when processing GZIP files. ;T;[;![;"I"B Base class of errors that occur when processing GZIP files. ;T;#0;$@q;.F;/o;0;1T;2i;3i;%@o;&I"Zlib::GzipFile::Error;F;'o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@iC[@i;T;;;;;;;[;{;IC; "hThe superclass for all exceptions raised by Ruby/zlib. The following exceptions are defined as subclasses of Zlib::Error. These exceptions are raised when zlib library functions return with an error status. - Zlib::StreamEnd - Zlib::NeedDict - Zlib::DataError - Zlib::StreamError - Zlib::MemError - Zlib::BufError - Zlib::VersionError - Zlib::InProgressError ;T;[;![;"I"k The superclass for all exceptions raised by Ruby/zlib. The following exceptions are defined as subclasses of Zlib::Error. These exceptions are raised when zlib library functions return with an error status. - Zlib::StreamEnd - Zlib::NeedDict - Zlib::DataError - Zlib::StreamError - Zlib::MemError - Zlib::BufError - Zlib::VersionError - Zlib::InProgressError ;T;#0;$@;.F;/o;0;1T;2iC;3iS;%@ݚ;&I"Zlib::Error;F;'@o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;: NoFooter;;;;;[;{;IC; "/Raised when gzip file footer is not found. ;T;[;![;"I"1 Raised when gzip file footer is not found. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@o;&I"Zlib::GzipFile::NoFooter;F;'@qo; ;IC;[; @ȝ; IC;[; @ȝ; IC;[; @ȝ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;: CRCError;;;;;[;{;IC; "Raised when the CRC checksum recorded in gzip file footer is not equivalent to the CRC checksum of the actual uncompressed data. ;T;[;![;"I" Raised when the CRC checksum recorded in gzip file footer is not equivalent to the CRC checksum of the actual uncompressed data. ;T;#0;$@ȝ;.F;/o;0;1T;2i;3i;%@o;&I"Zlib::GzipFile::CRCError;F;'@qo; ;IC;[; @ܝ; IC;[; @ܝ; IC;[; @ܝ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;:LengthError;;;;;[;{;IC; "}Raised when the data length recorded in the gzip file footer is not equivalent to the length of the actual uncompressed data. ;T;[;![;"I" Raised when the data length recorded in the gzip file footer is not equivalent to the length of the actual uncompressed data. ;T;#0;$@ܝ;.F;/o;0;1T;2i;3i;%@o;&I" Zlib::GzipFile::LengthError;F;'@qo;4;5F;6;;;;&I"Zlib::GzipFile.wrap;F;7[[@90;[[@i ;T;: wrap;0;[;{;IC; "call-seq: Zlib::GzipReader.wrap(io, ...) { |gz| ... } Zlib::GzipWriter.wrap(io, ...) { |gz| ... } Creates a GzipReader or GzipWriter associated with +io+, passing in any necessary extra options, and executes the block with the newly created object just like File.open. The GzipFile object will be closed automatically after executing the block. If you want to keep the associated IO object open, you may call Zlib::GzipFile#finish method in the block. ;T;[;![;"I" call-seq: Zlib::GzipReader.wrap(io, ...) { |gz| ... } Zlib::GzipWriter.wrap(io, ...) { |gz| ... } Creates a GzipReader or GzipWriter associated with +io+, passing in any necessary extra options, and executes the block with the newly created object just like File.open. The GzipFile object will be closed automatically after executing the block. If you want to keep the associated IO object open, you may call Zlib::GzipFile#finish method in the block. ;T;#0;$@;.F;/o;0;1T;2iz ;3i ;%@o;9I"xstatic VALUE rb_gzfile_s_wrap(int argc, VALUE *argv, VALUE klass) { return gzfile_wrap(argc, argv, klass, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipFile#to_io;F;7[;[[@i ;T;;;0;[;{;IC; "Same as IO. ;T;[;![;"I" Same as IO. ;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@o;9I"Pstatic VALUE rb_gzfile_to_io(VALUE obj) { return get_gzfile(obj)->io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipFile#crc;F;7[;[[@i ;T;:crc;0;[;{;IC; "0Returns CRC value of the uncompressed data. ;T;[;![;"I"2 Returns CRC value of the uncompressed data. ;T;#0;$@ ;.F;/o;0;1T;2i ;3i ;%@o;9I"]static VALUE rb_gzfile_crc(VALUE obj) { return rb_uint2inum(get_gzfile(obj)->crc); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipFile#mtime;F;7[;[[@i ;T;;4;0;[;{;IC; "EReturns last modification time recorded in the gzip file header. ;T;[;![;"I"G Returns last modification time recorded in the gzip file header. ;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@o;9I"kstatic VALUE rb_gzfile_mtime(VALUE obj) { return rb_time_new(get_gzfile(obj)->mtime, (time_t)0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipFile#level;F;7[;[[@i ;T;: level;0;[;{;IC; "Returns compression level. ;T;[;![;"I"! Returns compression level. ;T;#0;$@);.F;/o;0;1T;2i ;3i ;%@o;9I"\static VALUE rb_gzfile_level(VALUE obj) { return INT2FIX(get_gzfile(obj)->level); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipFile#os_code;F;7[;[[@i ;T;: os_code;0;[;{;IC; "=Returns OS code number recorded in the gzip file header. ;T;[;![;"I"? Returns OS code number recorded in the gzip file header. ;T;#0;$@7;.F;/o;0;1T;2i ;3i ;%@o;9I"`static VALUE rb_gzfile_os_code(VALUE obj) { return INT2FIX(get_gzfile(obj)->os_code); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipFile#orig_name;F;7[;[[@i ;T;:orig_name;0;[;{;IC; "nReturns original filename recorded in the gzip file header, or +nil+ if original filename is not present. ;T;[;![;"I"p Returns original filename recorded in the gzip file header, or +nil+ if original filename is not present. ;T;#0;$@E;.F;/o;0;1T;2i ;3i ;%@o;9I"static VALUE rb_gzfile_orig_name(VALUE obj) { VALUE str = get_gzfile(obj)->orig_name; if (!NIL_P(str)) { str = rb_str_dup(str); } return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipFile#comment;F;7[;[[@i ;T;: comment;0;[;{;IC; "^Returns comments recorded in the gzip file header, or nil if the comments is not present. ;T;[;![;"I"` Returns comments recorded in the gzip file header, or nil if the comments is not present. ;T;#0;$@S;.F;/o;0;1T;2i ;3i ;%@o;9I"static VALUE rb_gzfile_comment(VALUE obj) { VALUE str = get_gzfile(obj)->comment; if (!NIL_P(str)) { str = rb_str_dup(str); } return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipFile#close;F;7[;[[@ii ;T;;;0;[;{;IC; "~Closes the GzipFile object. This method calls close method of the associated IO object. Returns the associated IO object. ;T;[;![;"I"{ Closes the GzipFile object. This method calls close method of the associated IO object. Returns the associated IO object. ;T;#0;$@a;.F;/o;0;1T;2ic ;3if ;%@o;9I"static VALUE rb_gzfile_close(VALUE obj) { struct gzfile *gz; VALUE io; TypedData_Get_Struct(obj, struct gzfile, &gzfile_data_type, gz); if (!ZSTREAM_IS_READY(&gz->z)) { return Qnil; } io = gz->io; gzfile_close(gz, 1); return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipFile#finish;F;7[;[[@i ;T;;!;0;[;{;IC; "Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method never calls the close method of the associated IO object. Returns the associated IO object. ;T;[;![;"I" Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method never calls the close method of the associated IO object. Returns the associated IO object. ;T;#0;$@o;.F;/o;0;1T;2ix ;3i| ;%@o;9I"static VALUE rb_gzfile_finish(VALUE obj) { struct gzfile *gz = get_gzfile(obj); VALUE io; io = gz->io; gzfile_close(gz, 0); return io; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipFile#closed?;F;7[;[[@i ;T;;\;0;[;{;IC; "Same as IO#closed?;T;[o;A ;>I" return;F;?@;0;@[@L;$@};![;"I" Same as IO#closed? ;T;#0;$@};.F;/o;0;1T;2i ;3i ;Bi;%@o;9I"static VALUE rb_gzfile_closed_p(VALUE obj) { struct gzfile *gz; TypedData_Get_Struct(obj, struct gzfile, &gzfile_data_type, gz); return NIL_P(gz->io) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipFile#sync;F;7[;[[@i ;T;;;0;[;{;IC; "Same as IO#sync ;T;[;![;"I" Same as IO#sync ;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@o;9I"zstatic VALUE rb_gzfile_sync(VALUE obj) { return (get_gzfile(obj)->z.flags & GZFILE_FLAG_SYNC) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipFile#sync=;F;7[[I" mode;T0;[[@i ;T;;;0;[;{;IC; "call-seq: sync = flag Same as IO. If flag is +true+, the associated IO object must respond to the +flush+ method. While +sync+ mode is +true+, the compression ratio decreases sharply. ;T;[;![;"I" call-seq: sync = flag Same as IO. If flag is +true+, the associated IO object must respond to the +flush+ method. While +sync+ mode is +true+, the compression ratio decreases sharply. ;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@o;9I"static VALUE rb_gzfile_set_sync(VALUE obj, VALUE mode) { struct gzfile *gz = get_gzfile(obj); if (RTEST(mode)) { gz->z.flags |= GZFILE_FLAG_SYNC; } else { gz->z.flags &= ~GZFILE_FLAG_SYNC; } return mode; };T;:I"static VALUE;T;;T; @o; IC;[; @o; IC;[; @o; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i [@i;T;: GzipFile;;;;;[;{;IC; "AZlib::GzipFile is an abstract class for handling a gzip formatted compressed file. The operations are defined in the subclasses, Zlib::GzipReader for reading, and Zlib::GzipWriter for writing. GzipReader should be used by associating an IO, or IO-like, object. == Method Catalogue - ::wrap - ::open (Zlib::GzipReader::open and Zlib::GzipWriter::open) - #close - #closed? - #comment - comment= (Zlib::GzipWriter#comment=) - #crc - eof? (Zlib::GzipReader#eof?) - #finish - #level - lineno (Zlib::GzipReader#lineno) - lineno= (Zlib::GzipReader#lineno=) - #mtime - mtime= (Zlib::GzipWriter#mtime=) - #orig_name - orig_name (Zlib::GzipWriter#orig_name=) - #os_code - path (when the underlying IO supports #path) - #sync - #sync= - #to_io (due to internal structure, documentation may appear under Zlib::GzipReader or Zlib::GzipWriter);T;[;![;"I"C Zlib::GzipFile is an abstract class for handling a gzip formatted compressed file. The operations are defined in the subclasses, Zlib::GzipReader for reading, and Zlib::GzipWriter for writing. GzipReader should be used by associating an IO, or IO-like, object. == Method Catalogue - ::wrap - ::open (Zlib::GzipReader::open and Zlib::GzipWriter::open) - #close - #closed? - #comment - comment= (Zlib::GzipWriter#comment=) - #crc - eof? (Zlib::GzipReader#eof?) - #finish - #level - lineno (Zlib::GzipReader#lineno) - lineno= (Zlib::GzipReader#lineno=) - #mtime - mtime= (Zlib::GzipWriter#mtime=) - #orig_name - orig_name (Zlib::GzipWriter#orig_name=) - #os_code - path (when the underlying IO supports #path) - #sync - #sync= - #to_io (due to internal structure, documentation may appear under Zlib::GzipReader or Zlib::GzipWriter) ;T;#0;$@o;.F;/o;0;1T;2i ;3i? ;Bi;%o;( ;)0;*0;+0;; ;%@;-@ݚ;0;&I"Zlib::GzipFile;F;'@o; ;IC;[o;4;5F;6;;;;&I"Zlib::GzipWriter#mtime=;F;7[[I" mtime;T0;[[@i" ;T;: mtime=;0;[;{;IC; "}Specify the modification time (+mtime+) in the gzip header. Using an Integer. Setting the mtime in the gzip header does not effect the mtime of the file generated. Different utilities that expand the gzipped files may use the mtime header. For example the gunzip utility can use the `-N` flag which will set the resultant file's mtime to the value in the header. By default many tools will set the mtime of the expanded file to the mtime of the gzipped file, not the mtime in the header. If you do not set an mtime, the default value will be the time when compression started. Setting a value of 0 indicates no time stamp is available. ;T;[;![;"I" Specify the modification time (+mtime+) in the gzip header. Using an Integer. Setting the mtime in the gzip header does not effect the mtime of the file generated. Different utilities that expand the gzipped files may use the mtime header. For example the gunzip utility can use the `-N` flag which will set the resultant file's mtime to the value in the header. By default many tools will set the mtime of the expanded file to the mtime of the gzipped file, not the mtime in the header. If you do not set an mtime, the default value will be the time when compression started. Setting a value of 0 indicates no time stamp is available. ;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"_static VALUE rb_gzfile_set_mtime(VALUE obj, VALUE mtime) { struct gzfile *gz = get_gzfile(obj); VALUE val; if (gz->z.flags & GZFILE_FLAG_HEADER_FINISHED) { rb_raise(cGzError, "header is already written"); } val = rb_Integer(mtime); gz->mtime = NUM2UINT(val); gz->z.flags |= GZFILE_FLAG_MTIME_IS_SET; return mtime; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Zlib::GzipWriter#orig_name=;F;7[[I"str;T0;[[@i8 ;T;:orig_name=;0;[;{;IC; ":Specify the original name (+str+) in the gzip header. ;T;[;![;"I"< Specify the original name (+str+) in the gzip header. ;T;#0;$@ў;.F;/o;0;1T;2i3 ;3i5 ;%@;9I"static VALUE rb_gzfile_set_orig_name(VALUE obj, VALUE str) { struct gzfile *gz = get_gzfile(obj); VALUE s; char *p; if (gz->z.flags & GZFILE_FLAG_HEADER_FINISHED) { rb_raise(cGzError, "header is already written"); } s = rb_str_dup(rb_str_to_str(str)); p = memchr(RSTRING_PTR(s), '\0', RSTRING_LEN(s)); if (p) { rb_str_resize(s, p - RSTRING_PTR(s)); } gz->orig_name = s; return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipWriter#comment=;F;7[[I"str;T0;[[@iP ;T;: comment=;0;[;{;IC; "4Specify the comment (+str+) in the gzip header. ;T;[;![;"I"6 Specify the comment (+str+) in the gzip header. ;T;#0;$@;.F;/o;0;1T;2iK ;3iM ;%@;9I"static VALUE rb_gzfile_set_comment(VALUE obj, VALUE str) { struct gzfile *gz = get_gzfile(obj); VALUE s; char *p; if (gz->z.flags & GZFILE_FLAG_HEADER_FINISHED) { rb_raise(cGzError, "header is already written"); } s = rb_str_dup(rb_str_to_str(str)); p = memchr(RSTRING_PTR(s), '\0', RSTRING_LEN(s)); if (p) { rb_str_resize(s, p - RSTRING_PTR(s)); } gz->comment = s; return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipWriter#pos;F;7[;[[@i ;T;;;0;[;{;IC; "-Total number of input bytes read so far. ;T;[;![;"I"/ Total number of input bytes read so far. ;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"pstatic VALUE rb_gzfile_total_in(VALUE obj) { return rb_uint2inum(get_gzfile(obj)->z.stream.total_in); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipWriter#tell;F;7[;[[@i ;T;;;0;[;{;IC; "-Total number of input bytes read so far. ;T;[;![;"@;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"pstatic VALUE rb_gzfile_total_in(VALUE obj) { return rb_uint2inum(get_gzfile(obj)->z.stream.total_in); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipWriter.open;F;7[[@90;[[@i=;T;;;0;[;{;IC; "Opens a file specified by +filename+ for writing gzip compressed data, and returns a GzipWriter object associated with that file. Further details of this method are found in Zlib::GzipWriter.new and Zlib::GzipFile.wrap. ;T;[o;= ;>I" overload;F;?0;:Zlib::GzipWriter.open;@0;:I"=Zlib::GzipWriter.open(filename, level=nil, strategy=nil);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"gz;T;$@ ;![;"I"@yield [gz];T;#0;$@ ;.F;Bi;C0;7[[I" filename;T0[I" level;TI"nil;T[I" strategy;TI"nil;T;$@ ;![;"I"/Opens a file specified by +filename+ for writing gzip compressed data, and returns a GzipWriter object associated with that file. Further details of this method are found in Zlib::GzipWriter.new and Zlib::GzipFile.wrap. @overload Zlib::GzipWriter.open(filename, level=nil, strategy=nil) @yield [gz];T;#0;$@ ;.F;/o;0;1T;2i6;3i<;%@;9I"static VALUE rb_gzwriter_s_open(int argc, VALUE *argv, VALUE klass) { return gzfile_s_open(argc, argv, klass, "wb"); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Zlib::GzipWriter#initialize;F;7[[@90;[[@iP;T;;D;0;[;{;IC; "Creates a GzipWriter object associated with +io+. +level+ and +strategy+ should be the same as the arguments of Zlib::Deflate.new. The GzipWriter object writes gzipped data to +io+. +io+ must respond to the +write+ method that behaves the same as IO#write. The +options+ hash may be used to set the encoding of the data. +:external_encoding+, +:internal_encoding+ and +:encoding+ may be set as in IO::new. ;T;[o;= ;>I" overload;F;?0;:Zlib::GzipWriter.new;@0;:I"HZlib::GzipWriter.new(io, level = nil, strategy = nil, options = {});T;IC; ";T;[;![;"I";T;#0;$@0;.F;Bi;C0;7[ [I"io;T0[I" level;TI"nil;T[I" strategy;TI"nil;T[I" options;TI"{};T;$@0;![;"I"Creates a GzipWriter object associated with +io+. +level+ and +strategy+ should be the same as the arguments of Zlib::Deflate.new. The GzipWriter object writes gzipped data to +io+. +io+ must respond to the +write+ method that behaves the same as IO#write. The +options+ hash may be used to set the encoding of the data. +:external_encoding+, +:internal_encoding+ and +:encoding+ may be set as in IO::new. @overload Zlib::GzipWriter.new(io, level = nil, strategy = nil, options = {});T;#0;$@0;.F;/o;0;1T;2iC;3iM;%@;9I"static VALUE rb_gzwriter_initialize(int argc, VALUE *argv, VALUE obj) { struct gzfile *gz; VALUE io, level, strategy, opt = Qnil; int err; if (argc > 1) { opt = rb_check_convert_type(argv[argc-1], T_HASH, "Hash", "to_hash"); if (!NIL_P(opt)) argc--; } rb_scan_args(argc, argv, "12", &io, &level, &strategy); TypedData_Get_Struct(obj, struct gzfile, &gzfile_data_type, gz); /* this is undocumented feature of zlib */ gz->level = ARG_LEVEL(level); err = deflateInit2(&gz->z.stream, gz->level, Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, ARG_STRATEGY(strategy)); if (err != Z_OK) { raise_zlib_error(err, gz->z.stream.msg); } gz->io = io; ZSTREAM_READY(&gz->z); rb_gzfile_ecopts(gz, opt); if (rb_respond_to(io, id_path)) { /* File#path may raise IOError in case when a path is unavailable */ rb_rescue2(gzfile_initialize_path_partial, obj, NULL, Qnil, rb_eIOError, (VALUE)0); } return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipWriter#flush;F;7[[@90;[[@iy;T;;;0;[;{;IC; "Flushes all the internal buffers of the GzipWriter object. The meaning of +flush+ is same as in Zlib::Deflate#deflate. Zlib::SYNC_FLUSH is used if +flush+ is omitted. It is no use giving flush Zlib::NO_FLUSH. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"flush(flush=nil);T;IC; ";T;[;![;"I";T;#0;$@R;.F;Bi;C0;7[[I" flush;TI"nil;T;$@R;![;"I"Flushes all the internal buffers of the GzipWriter object. The meaning of +flush+ is same as in Zlib::Deflate#deflate. Zlib::SYNC_FLUSH is used if +flush+ is omitted. It is no use giving flush Zlib::NO_FLUSH. @overload flush(flush=nil);T;#0;$@R;.F;/o;0;1T;2ir;3iw;%@;9I"static VALUE rb_gzwriter_flush(int argc, VALUE *argv, VALUE obj) { struct gzfile *gz = get_gzfile(obj); VALUE v_flush; int flush; rb_scan_args(argc, argv, "01", &v_flush); flush = FIXNUMARG(v_flush, Z_SYNC_FLUSH); if (flush != Z_NO_FLUSH) { /* prevent Z_BUF_ERROR */ zstream_run(&gz->z, (Bytef*)"", 0, flush); } gzfile_write_raw(gz); if (rb_respond_to(gz->io, id_flush)) { rb_funcall(gz->io, id_flush, 0); } return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipWriter#write;F;7[[@90;[[@i;T;;s;0;[;{;IC; "Same as IO. ;T;[;![;"I"Same as IO. ;T;#0;$@l;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_gzwriter_write(int argc, VALUE *argv, VALUE obj) { struct gzfile *gz = get_gzfile(obj); size_t total = 0; while (argc-- > 0) { VALUE str = *argv++; if (!RB_TYPE_P(str, T_STRING)) str = rb_obj_as_string(str); if (gz->enc2 && gz->enc2 != rb_ascii8bit_encoding()) { str = rb_str_conv_enc(str, rb_enc_get(str), gz->enc2); } gzfile_write(gz, (Bytef*)RSTRING_PTR(str), RSTRING_LEN(str)); total += RSTRING_LEN(str); RB_GC_GUARD(str); } return SIZET2NUM(total); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipWriter#putc;F;7[[I"ch;T0;[[@i;T;;;0;[;{;IC; "Same as IO. ;T;[;![;"I"Same as IO. ;T;#0;$@{;.F;/o;0;1T;2i;3i;%@;9I"static VALUE rb_gzwriter_putc(VALUE obj, VALUE ch) { struct gzfile *gz = get_gzfile(obj); char c = NUM2CHR(ch); gzfile_write(gz, (Bytef*)&c, 1); return ch; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipWriter#<<;F;7[;[;F;;;;;[;{;IC; "Same as IO. ;T;[;![;"I"Same as IO. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"Zlib::GzipWriter#printf;F;7[;[;F;;;;;[;{;IC; "Same as IO. ;T;[;![;"I"Same as IO. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"Zlib::GzipWriter#print;F;7[;[;F;;;;;[;{;IC; "Same as IO. ;T;[;![;"I"Same as IO. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"Zlib::GzipWriter#puts;F;7[;[;F;;;;;[;{;IC; "Same as IO. ;T;[;![;"I"Same as IO. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;:GzipWriter;;;;;[;{;IC; "HZlib::GzipWriter is a class for writing gzipped files. GzipWriter should be used with an instance of IO, or IO-like, object. Following two example generate the same result. Zlib::GzipWriter.open('hoge.gz') do |gz| gz.write 'jugemu jugemu gokou no surikire...' end File.open('hoge.gz', 'w') do |f| gz = Zlib::GzipWriter.new(f) gz.write 'jugemu jugemu gokou no surikire...' gz.close end To make like gzip(1) does, run following: orig = 'hoge.txt' Zlib::GzipWriter.open('hoge.gz') do |gz| gz.mtime = File.mtime(orig) gz.orig_name = orig gz.write IO.binread(orig) end NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter will be not able to write the gzip footer and will generate a broken gzip file.;T;[;![;"I"J Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should be used with an instance of IO, or IO-like, object. Following two example generate the same result. Zlib::GzipWriter.open('hoge.gz') do |gz| gz.write 'jugemu jugemu gokou no surikire...' end File.open('hoge.gz', 'w') do |f| gz = Zlib::GzipWriter.new(f) gz.write 'jugemu jugemu gokou no surikire...' gz.close end To make like gzip(1) does, run following: orig = 'hoge.txt' Zlib::GzipWriter.open('hoge.gz') do |gz| gz.mtime = File.mtime(orig) gz.orig_name = orig gz.write IO.binread(orig) end NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter will be not able to write the gzip footer and will generate a broken gzip file. ;T;#0;$@;.F;/o;0;1T;2i;3i,;Bi;%o;( ;)0;*0;+0;; ;%@;-@ݚ;0;&I"Zlib::GzipWriter;F;'@oo; ;IC;[ o;4;5F;6;;;;&I"Zlib::GzipReader#lineno;F;7[;[[@i ;T;;L;0;[;{;IC; "9The line number of the last row read from this file. ;T;[;![;"I"; The line number of the last row read from this file. ;T;#0;$@̟;.F;/o;0;1T;2i ;3i ;%@ʟ;9I"^static VALUE rb_gzfile_lineno(VALUE obj) { return INT2NUM(get_gzfile(obj)->lineno); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#lineno=;F;7[[I" lineno;T0;[[@i ;T;;;0;[;{;IC; "=Specify line number of the last row read from this file. ;T;[;![;"I"? Specify line number of the last row read from this file. ;T;#0;$@ڟ;.F;/o;0;1T;2i ;3i ;%@ʟ;9I"static VALUE rb_gzfile_set_lineno(VALUE obj, VALUE lineno) { struct gzfile *gz = get_gzfile(obj); gz->lineno = NUM2INT(lineno); return lineno; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#eof;F;7[;[[@i ;T;;;0;[;{;IC; "FReturns +true+ or +false+ whether the stream has reached the end. ;T;[;![;"I"H Returns +true+ or +false+ whether the stream has reached the end. ;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@ʟ;9I"static VALUE rb_gzfile_eof_p(VALUE obj) { struct gzfile *gz = get_gzfile(obj); return GZFILE_IS_FINISHED(gz) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#eof?;F;7[;[[@i ;T;;;0;[;{;IC; "FReturns +true+ or +false+ whether the stream has reached the end.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"@;#0;$@;.F;/o;0;1T;2i ;3i ;Bi;%@ʟ;9I"static VALUE rb_gzfile_eof_p(VALUE obj) { struct gzfile *gz = get_gzfile(obj); return GZFILE_IS_FINISHED(gz) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#pos;F;7[;[[@i ;T;;;0;[;{;IC; "0Total number of output bytes output so far. ;T;[;![;"I"2 Total number of output bytes output so far. ;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@ʟ;9I"estatic VALUE rb_gzfile_total_out(VALUE obj) { struct gzfile *gz = get_gzfile(obj); uLong total_out = gz->z.stream.total_out; long buf_filled = ZSTREAM_BUF_FILLED(&gz->z); if (total_out >= (uLong)buf_filled) { return rb_uint2inum(total_out - buf_filled); } else { return LONG2FIX(-(buf_filled - (long)total_out)); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#tell;F;7[;[[@i ;T;;;0;[;{;IC; "0Total number of output bytes output so far. ;T;[;![;"@;#0;$@;.F;/o;0;1T;2i ;3i ;%@ʟ;9I"estatic VALUE rb_gzfile_total_out(VALUE obj) { struct gzfile *gz = get_gzfile(obj); uLong total_out = gz->z.stream.total_out; long buf_filled = ZSTREAM_BUF_FILLED(&gz->z); if (total_out >= (uLong)buf_filled) { return rb_uint2inum(total_out - buf_filled); } else { return LONG2FIX(-(buf_filled - (long)total_out)); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader.open;F;7[[@90;[[@i;T;;;0;[;{;IC; "call-seq: Zlib::GzipReader.open(filename) {|gz| ... } Opens a file specified by +filename+ as a gzipped file, and returns a GzipReader object associated with that file. Further details of this method are in Zlib::GzipReader.new and ZLib::GzipFile.wrap. ;T;[;![;"I" call-seq: Zlib::GzipReader.open(filename) {|gz| ... } Opens a file specified by +filename+ as a gzipped file, and returns a GzipReader object associated with that file. Further details of this method are in Zlib::GzipReader.new and ZLib::GzipFile.wrap. ;T;#0;$@#;.F;/o;0;1T;2i;3i ;%@ʟ;9I"static VALUE rb_gzreader_s_open(int argc, VALUE *argv, VALUE klass) { return gzfile_s_open(argc, argv, klass, "rb"); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader.zcat;F;7[[@90;[[@i%;T;: zcat;0;[;{;IC; "call-seq: Zlib::GzipReader.zcat(io, options = {}, &block) => nil Zlib::GzipReader.zcat(io, options = {}) => string Decompresses all gzip data in the +io+, handling multiple gzip streams until the end of the +io+. There should not be any non-gzip data after the gzip streams. If a block is given, it is yielded strings of uncompressed data, and the method returns +nil+. If a block is not given, the method returns the concatenation of all uncompressed data in all gzip streams. ;T;[;![;"I" call-seq: Zlib::GzipReader.zcat(io, options = {}, &block) => nil Zlib::GzipReader.zcat(io, options = {}) => string Decompresses all gzip data in the +io+, handling multiple gzip streams until the end of the +io+. There should not be any non-gzip data after the gzip streams. If a block is given, it is yielded strings of uncompressed data, and the method returns +nil+. If a block is not given, the method returns the concatenation of all uncompressed data in all gzip streams. ;T;#0;$@2;.F;/o;0;1T;2i;3i";%@ʟ;9I"!static VALUE rb_gzreader_s_zcat(int argc, VALUE *argv, VALUE klass) { VALUE io, unused, obj, buf=0, tmpbuf; long pos; rb_check_arity(argc, 1, 2); io = argv[0]; do { obj = rb_funcallv(klass, rb_intern("new"), argc, argv); if (rb_block_given_p()) { rb_gzreader_each(0, 0, obj); } else { if (!buf) { buf = rb_str_new(0, 0); } tmpbuf = gzfile_read_all(get_gzfile(obj)); rb_str_cat(buf, RSTRING_PTR(tmpbuf), RSTRING_LEN(tmpbuf)); } rb_gzreader_read(0, 0, obj); pos = NUM2LONG(rb_funcall(io, rb_intern("pos"), 0)); unused = rb_gzreader_unused(obj); rb_gzfile_finish(obj); if (!NIL_P(unused)) { pos -= NUM2LONG(rb_funcall(unused, rb_intern("length"), 0)); rb_funcall(io, rb_intern("pos="), 1, LONG2NUM(pos)); } } while (pos < NUM2LONG(rb_funcall(io, rb_intern("size"), 0))); if (rb_block_given_p()) { return Qnil; } return buf; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Zlib::GzipReader#initialize;F;7[[@90;[[@i\;T;;D;0;[;{;IC; "call-seq: Zlib::GzipReader.new(io, options = {}) Creates a GzipReader object associated with +io+. The GzipReader object reads gzipped data from +io+, and parses/decompresses it. The +io+ must have a +read+ method that behaves same as the IO#read. The +options+ hash may be used to set the encoding of the data. +:external_encoding+, +:internal_encoding+ and +:encoding+ may be set as in IO::new. If the gzip file header is incorrect, raises an Zlib::GzipFile::Error exception. ;T;[;![;"I" call-seq: Zlib::GzipReader.new(io, options = {}) Creates a GzipReader object associated with +io+. The GzipReader object reads gzipped data from +io+, and parses/decompresses it. The +io+ must have a +read+ method that behaves same as the IO#read. The +options+ hash may be used to set the encoding of the data. +:external_encoding+, +:internal_encoding+ and +:encoding+ may be set as in IO::new. If the gzip file header is incorrect, raises an Zlib::GzipFile::Error exception. ;T;#0;$@A;.F;/o;0;1T;2iK;3iY;%@ʟ;9I"static VALUE rb_gzreader_initialize(int argc, VALUE *argv, VALUE obj) { VALUE io, opt = Qnil; struct gzfile *gz; int err; TypedData_Get_Struct(obj, struct gzfile, &gzfile_data_type, gz); rb_scan_args(argc, argv, "1:", &io, &opt); /* this is undocumented feature of zlib */ err = inflateInit2(&gz->z.stream, -MAX_WBITS); if (err != Z_OK) { raise_zlib_error(err, gz->z.stream.msg); } gz->io = io; ZSTREAM_READY(&gz->z); gzfile_read_header(gz, Qnil); rb_gzfile_ecopts(gz, opt); if (rb_respond_to(io, id_path)) { /* File#path may raise IOError in case when a path is unavailable */ rb_rescue2(gzfile_initialize_path_partial, obj, NULL, Qnil, rb_eIOError, (VALUE)0); } return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#rewind;F;7[;[[@i~;T;;;0;[;{;IC; "Resets the position of the file pointer to the point created the GzipReader object. The associated IO object needs to respond to the +seek+ method. ;T;[;![;"I" Resets the position of the file pointer to the point created the GzipReader object. The associated IO object needs to respond to the +seek+ method. ;T;#0;$@P;.F;/o;0;1T;2ix;3i{;%@ʟ;9I"static VALUE rb_gzreader_rewind(VALUE obj) { struct gzfile *gz = get_gzfile(obj); gzfile_reader_rewind(gz); return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#unused;F;7[;[[@i;T;: unused;0;[;{;IC; "|Returns the rest of the data which had read for parsing gzip format, or +nil+ if the whole gzip file is not parsed yet. ;T;[;![;"I"~ Returns the rest of the data which had read for parsing gzip format, or +nil+ if the whole gzip file is not parsed yet. ;T;#0;$@^;.F;/o;0;1T;2i;3i;%@ʟ;9I"static VALUE rb_gzreader_unused(VALUE obj) { struct gzfile *gz; TypedData_Get_Struct(obj, struct gzfile, &gzfile_data_type, gz); return gzfile_reader_get_unused(gz); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#read;F;7[[@90;[[@i;T;;q;0;[;{;IC; ":See Zlib::GzipReader documentation for a description. ;T;[;![;"I"< See Zlib::GzipReader documentation for a description. ;T;#0;$@l;.F;/o;0;1T;2i;3i;%@ʟ;9I"static VALUE rb_gzreader_read(int argc, VALUE *argv, VALUE obj) { struct gzfile *gz = get_gzfile(obj); VALUE vlen; long len; rb_scan_args(argc, argv, "01", &vlen); if (NIL_P(vlen)) { return gzfile_read_all(gz); } len = NUM2INT(vlen); if (len < 0) { rb_raise(rb_eArgError, "negative length %ld given", len); } return gzfile_read(gz, len); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Zlib::GzipReader#readpartial;F;7[[@90;[[@i;T;;;0;[;{;IC; "qcall-seq: gzipreader.readpartial(maxlen [, outbuf]) => string, outbuf Reads at most maxlen bytes from the gziped stream but it blocks only if gzipreader has no data immediately available. If the optional outbuf argument is present, it must reference a String, which will receive the data. It raises EOFError on end of file. ;T;[;![;"I"t call-seq: gzipreader.readpartial(maxlen [, outbuf]) => string, outbuf Reads at most maxlen bytes from the gziped stream but it blocks only if gzipreader has no data immediately available. If the optional outbuf argument is present, it must reference a String, which will receive the data. It raises EOFError on end of file. ;T;#0;$@{;.F;/o;0;1T;2i;3i;%@ʟ;9I"static VALUE rb_gzreader_readpartial(int argc, VALUE *argv, VALUE obj) { struct gzfile *gz = get_gzfile(obj); VALUE vlen, outbuf; long len; rb_scan_args(argc, argv, "11", &vlen, &outbuf); len = NUM2INT(vlen); if (len < 0) { rb_raise(rb_eArgError, "negative length %ld given", len); } if (!NIL_P(outbuf)) Check_Type(outbuf, T_STRING); return gzfile_readpartial(gz, len, outbuf); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#getc;F;7[;[[@i;T;;;0;[;{;IC; ":See Zlib::GzipReader documentation for a description. ;T;[;![;"I"< See Zlib::GzipReader documentation for a description. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@ʟ;9I"wstatic VALUE rb_gzreader_getc(VALUE obj) { struct gzfile *gz = get_gzfile(obj); return gzfile_getc(gz); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#getbyte;F;7[;[[@i;T;;;0;[;{;IC; ":See Zlib::GzipReader documentation for a description. ;T;[;![;"I"< See Zlib::GzipReader documentation for a description. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@ʟ;9I"static VALUE rb_gzreader_getbyte(VALUE obj) { struct gzfile *gz = get_gzfile(obj); VALUE dst; dst = gzfile_read(gz, 1); if (!NIL_P(dst)) { dst = INT2FIX((unsigned int)(RSTRING_PTR(dst)[0]) & 0xff); } return dst; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#readchar;F;7[;[[@i;T;;;0;[;{;IC; ":See Zlib::GzipReader documentation for a description. ;T;[;![;"I"< See Zlib::GzipReader documentation for a description. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@ʟ;9I"static VALUE rb_gzreader_readchar(VALUE obj) { VALUE dst; dst = rb_gzreader_getc(obj); if (NIL_P(dst)) { rb_raise(rb_eEOFError, "end of file reached"); } return dst; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#readbyte;F;7[;[[@i;T;;;0;[;{;IC; ":See Zlib::GzipReader documentation for a description. ;T;[;![;"I"< See Zlib::GzipReader documentation for a description. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@ʟ;9I"static VALUE rb_gzreader_readbyte(VALUE obj) { VALUE dst; dst = rb_gzreader_getbyte(obj); if (NIL_P(dst)) { rb_raise(rb_eEOFError, "end of file reached"); } return dst; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#each_byte;F;7[;[[@i ;T;;y;0;[;{;IC; ":See Zlib::GzipReader documentation for a description. ;T;[;![;"I"< See Zlib::GzipReader documentation for a description. ;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@ʟ;9I"static VALUE rb_gzreader_each_byte(VALUE obj) { VALUE c; RETURN_ENUMERATOR(obj, 0, 0); while (!NIL_P(c = rb_gzreader_getbyte(obj))) { rb_yield(c); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#each_char;F;7[;[[@i;T;;z;0;[;{;IC; ":See Zlib::GzipReader documentation for a description. ;T;[;![;"I"< See Zlib::GzipReader documentation for a description. ;T;#0;$@Р;.F;/o;0;1T;2i ;3i ;%@ʟ;9I"static VALUE rb_gzreader_each_char(VALUE obj) { VALUE c; RETURN_ENUMERATOR(obj, 0, 0); while (!NIL_P(c = rb_gzreader_getc(obj))) { rb_yield(c); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#ungetc;F;7[[I"s;T0;[[@i2;T;;;0;[;{;IC; ":See Zlib::GzipReader documentation for a description. ;T;[;![;"I"< See Zlib::GzipReader documentation for a description. ;T;#0;$@ޠ;.F;/o;0;1T;2i-;3i/;%@ʟ;9I"static VALUE rb_gzreader_ungetc(VALUE obj, VALUE s) { struct gzfile *gz; if (FIXNUM_P(s)) return rb_gzreader_ungetbyte(obj, s); gz = get_gzfile(obj); StringValue(s); if (gz->enc2 && gz->enc2 != rb_ascii8bit_encoding()) { s = rb_str_conv_enc(s, rb_enc_get(s), gz->enc2); } gzfile_ungets(gz, (const Bytef*)RSTRING_PTR(s), RSTRING_LEN(s)); RB_GC_GUARD(s); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#ungetbyte;F;7[[I"ch;T0;[[@iH;T;;;0;[;{;IC; ":See Zlib::GzipReader documentation for a description. ;T;[;![;"I"< See Zlib::GzipReader documentation for a description. ;T;#0;$@;.F;/o;0;1T;2iC;3iE;%@ʟ;9I"static VALUE rb_gzreader_ungetbyte(VALUE obj, VALUE ch) { struct gzfile *gz = get_gzfile(obj); gzfile_ungetbyte(gz, NUM2CHR(ch)); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#gets;F;7[[@90;[[@i;T;;;0;[;{;IC; "See Zlib::GzipReader documentation for a description. However, note that this method can return +nil+ even if #eof? returns false, unlike the behavior of File#gets. ;T;[;![;"I" See Zlib::GzipReader documentation for a description. However, note that this method can return +nil+ even if #eof? returns false, unlike the behavior of File#gets. ;T;#0;$@;.F;/o;0;1T;2i ;3i;%@ʟ;9I"static VALUE rb_gzreader_gets(int argc, VALUE *argv, VALUE obj) { VALUE dst; dst = gzreader_gets(argc, argv, obj); if (!NIL_P(dst)) { rb_lastline_set(dst); } return dst; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#readline;F;7[[@90;[[@i";T;;;0;[;{;IC; ":See Zlib::GzipReader documentation for a description. ;T;[;![;"I"< See Zlib::GzipReader documentation for a description. ;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@ʟ;9I"static VALUE rb_gzreader_readline(int argc, VALUE *argv, VALUE obj) { VALUE dst; dst = rb_gzreader_gets(argc, argv, obj); if (NIL_P(dst)) { rb_raise(rb_eEOFError, "end of file reached"); } return dst; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#each;F;7[[@90;[[@i2;T;;;0;[;{;IC; ":See Zlib::GzipReader documentation for a description. ;T;[;![;"I"< See Zlib::GzipReader documentation for a description. ;T;#0;$@;.F;/o;0;1T;2i-;3i/;%@ʟ;9I"static VALUE rb_gzreader_each(int argc, VALUE *argv, VALUE obj) { VALUE str; RETURN_ENUMERATOR(obj, 0, 0); while (!NIL_P(str = gzreader_gets(argc, argv, obj))) { rb_yield(str); } return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#each_line;F;7[[@90;[[@i2;T;;x;0;[;{;IC; ":See Zlib::GzipReader documentation for a description. ;T;[;![;"@';#0;$@+;.F;/o;0;1T;2i-;3i/;%@ʟ;9I"static VALUE rb_gzreader_each(int argc, VALUE *argv, VALUE obj) { VALUE str; RETURN_ENUMERATOR(obj, 0, 0); while (!NIL_P(str = gzreader_gets(argc, argv, obj))) { rb_yield(str); } return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib::GzipReader#readlines;F;7[[@90;[[@iD;T;;;0;[;{;IC; ":See Zlib::GzipReader documentation for a description. ;T;[;![;"I"< See Zlib::GzipReader documentation for a description. ;T;#0;$@9;.F;/o;0;1T;2i?;3iA;%@ʟ;9I"static VALUE rb_gzreader_readlines(int argc, VALUE *argv, VALUE obj) { VALUE str, dst; dst = rb_ary_new(); while (!NIL_P(str = gzreader_gets(argc, argv, obj))) { rb_ary_push(dst, str); } return dst; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'Zlib::GzipReader#external_encoding;F;7[;[[@iT;T;;;0;[;{;IC; ":See Zlib::GzipReader documentation for a description. ;T;[;![;"I"< See Zlib::GzipReader documentation for a description. ;T;#0;$@H;.F;/o;0;1T;2iO;3iQ;%@ʟ;9I"wstatic VALUE rb_gzreader_external_encoding(VALUE self) { return rb_enc_from_encoding(get_gzfile(self)->enc); };T;:I"static VALUE;T;;T; @ʟ; IC;[; @ʟ; IC;[@y,; @ʟ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;:GzipReader;;;;;[;{;IC; "Zlib::GzipReader is the class for reading a gzipped file. GzipReader should be used as an IO, or -IO-like, object. Zlib::GzipReader.open('hoge.gz') {|gz| print gz.read } File.open('hoge.gz') do |f| gz = Zlib::GzipReader.new(f) print gz.read gz.close end == Method Catalogue The following methods in Zlib::GzipReader are just like their counterparts in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an error was found in the gzip file. - #each - #each_line - #each_byte - #gets - #getc - #lineno - #lineno= - #read - #readchar - #readline - #readlines - #ungetc Be careful of the footer of the gzip file. A gzip file has the checksum of pre-compressed data in its footer. GzipReader checks all uncompressed data against that checksum at the following cases, and if it fails, raises Zlib::GzipFile::NoFooter, Zlib::GzipFile::CRCError, or Zlib::GzipFile::LengthError exception. - When an reading request is received beyond the end of file (the end of compressed data). That is, when Zlib::GzipReader#read, Zlib::GzipReader#gets, or some other methods for reading returns nil. - When Zlib::GzipFile#close method is called after the object reaches the end of file. - When Zlib::GzipReader#unused method is called after the object reaches the end of file. The rest of the methods are adequately described in their own documentation.;T;[;![;"I" Zlib::GzipReader is the class for reading a gzipped file. GzipReader should be used as an IO, or -IO-like, object. Zlib::GzipReader.open('hoge.gz') {|gz| print gz.read } File.open('hoge.gz') do |f| gz = Zlib::GzipReader.new(f) print gz.read gz.close end == Method Catalogue The following methods in Zlib::GzipReader are just like their counterparts in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an error was found in the gzip file. - #each - #each_line - #each_byte - #gets - #getc - #lineno - #lineno= - #read - #readchar - #readline - #readlines - #ungetc Be careful of the footer of the gzip file. A gzip file has the checksum of pre-compressed data in its footer. GzipReader checks all uncompressed data against that checksum at the following cases, and if it fails, raises Zlib::GzipFile::NoFooter, Zlib::GzipFile::CRCError, or Zlib::GzipFile::LengthError exception. - When an reading request is received beyond the end of file (the end of compressed data). That is, when Zlib::GzipReader#read, Zlib::GzipReader#gets, or some other methods for reading returns nil. - When Zlib::GzipFile#close method is called after the object reaches the end of file. - When Zlib::GzipReader#unused method is called after the object reaches the end of file. The rest of the methods are adequately described in their own documentation. ;T;#0;$@ʟ;.F;/o;0;1T;2i;3i;Bi;%o;( ;)0;*0;+0;; ;%@;-@ݚ;0;&I"Zlib::GzipReader;F;'@o@o; ;IC;[; @i; IC;[; @i; IC;[; @i; IC;{;IC;{;T;IC;{;T;T;{;[;[[@iW[@i;T;:StreamEnd;;;;;[;{;IC; "Subclass of Zlib::Error When zlib returns a Z_STREAM_END is return if the end of the compressed data has been reached and all uncompressed out put has been produced. ;T;[;![;"I" Subclass of Zlib::Error When zlib returns a Z_STREAM_END is return if the end of the compressed data has been reached and all uncompressed out put has been produced. ;T;#0;$@i;.F;/o;0;1T;2iW;3i^;%@ݚ;&I"Zlib::StreamEnd;F;'@o; ;IC;[; @}; IC;[; @}; IC;[; @}; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ib[@i;T;: NeedDict;;;;;[;{;IC; "Subclass of Zlib::Error When zlib returns a Z_NEED_DICT if a preset dictionary is needed at this point. Used by Zlib::Inflate.inflate and Zlib.inflate ;T;[;![;"I" Subclass of Zlib::Error When zlib returns a Z_NEED_DICT if a preset dictionary is needed at this point. Used by Zlib::Inflate.inflate and Zlib.inflate ;T;#0;$@};.F;/o;0;1T;2ib;3ii;%@ݚ;&I"Zlib::NeedDict;F;'@o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;;;;;;;[;{;IC; "jSubclass of Zlib::Error when zlib returns a Z_DATA_ERROR. Usually if a stream was prematurely freed. ;T;[;![;"I"m Subclass of Zlib::Error when zlib returns a Z_DATA_ERROR. Usually if a stream was prematurely freed. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@ݚ;&I"Zlib::DataError;F;'@o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;:StreamError;;;;;[;{;IC; "oSubclass of Zlib::Error When zlib returns a Z_STREAM_ERROR, usually if the stream state was inconsistent. ;T;[;![;"I"r Subclass of Zlib::Error When zlib returns a Z_STREAM_ERROR, usually if the stream state was inconsistent. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@ݚ;&I"Zlib::StreamError;F;'@o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ix[@i;T;: MemError;;;;;[;{;IC; "fSubclass of Zlib::Error When zlib returns a Z_MEM_ERROR, usually if there was not enough memory. ;T;[;![;"I"i Subclass of Zlib::Error When zlib returns a Z_MEM_ERROR, usually if there was not enough memory. ;T;#0;$@;.F;/o;0;1T;2ix;3i~;%@ݚ;&I"Zlib::MemError;F;'@o; ;IC;[; @͡; IC;[; @͡; IC;[; @͡; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;: BufError;;;;;[;{;IC; "bSubclass of Zlib::Error when zlib returns a Z_BUF_ERROR. Usually if no progress is possible. ;T;[;![;"I"e Subclass of Zlib::Error when zlib returns a Z_BUF_ERROR. Usually if no progress is possible. ;T;#0;$@͡;.F;/o;0;1T;2i;3i;%@ݚ;&I"Zlib::BufError;F;'@o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@im[@i;T;:VersionError;;;;;[;{;IC; "Subclass of Zlib::Error When zlib returns a Z_VERSION_ERROR, usually if the zlib library version is incompatible with the version assumed by the caller. ;T;[;![;"I" Subclass of Zlib::Error When zlib returns a Z_VERSION_ERROR, usually if the zlib library version is incompatible with the version assumed by the caller. ;T;#0;$@;.F;/o;0;1T;2im;3it;%@ݚ;&I"Zlib::VersionError;F;'@o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;:InProgressError;;;;;[;{;IC; "Subclass of Zlib::Error. This error is raised when the zlib stream is currently in progress. For example: inflater = Zlib::Inflate.new inflater.inflate(compressed) do inflater.inflate(compressed) # Raises Zlib::InProgressError end ;T;[;![;"I" Subclass of Zlib::Error. This error is raised when the zlib stream is currently in progress. For example: inflater = Zlib::Inflate.new inflater.inflate(compressed) do inflater.inflate(compressed) # Raises Zlib::InProgressError end ;T;#0;$@;.F;/o;0;1T;2i;3i;%@ݚ;&I"Zlib::InProgressError;F;'@o;4;5F;6;;;;&I"Zlib#zlib_version;F;7[;[[@is;T;:zlib_version;0;[;{;IC; "EReturns the string which represents the version of zlib library. ;T;[;![;"I"EReturns the string which represents the version of zlib library.;T;#0;$@ ;.F;C0;%@ݚ;9I"Ystatic VALUE rb_zlib_version(VALUE klass) { return rb_str_new2(zlibVersion()); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Zlib.zlib_version;F;7@ ;@ ;T;; ;0;@;{;IC; "EReturns the string which represents the version of zlib library.;T;[;![;"I"G Returns the string which represents the version of zlib library. ;T;#0;$@;.F;/o;0;1T;2in;3ip;Bi;%@ݚ;9@;:@;;To;4;5F;6;;;;&I"Zlib#adler32;F;7[[@90;[[@i;T;: adler32;0;[;{;IC; "call-seq: Zlib.adler32(string, adler) Calculates Adler-32 checksum for +string+, and returns updated value of +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If +adler+ is omitted, it assumes that the initial value is given to +adler+. If +string+ is an IO instance, reads from the IO until the IO returns nil and returns Adler-32 of all read data. Example usage: require "zlib" data = "foo" puts "Adler32 checksum: #{Zlib.adler32(data).to_s(16)}" #=> Adler32 checksum: 2820145 ;T;[;![;"I"call-seq: Zlib.adler32(string, adler) Calculates Adler-32 checksum for +string+, and returns updated value of +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If +adler+ is omitted, it assumes that the initial value is given to +adler+. If +string+ is an IO instance, reads from the IO until the IO returns nil and returns Adler-32 of all read data. Example usage: require "zlib" data = "foo" puts "Adler32 checksum: #{Zlib.adler32(data).to_s(16)}" #=> Adler32 checksum: 2820145;T;#0;$@;.F;C0;%@ݚ;9I"vstatic VALUE rb_zlib_adler32(int argc, VALUE *argv, VALUE klass) { return do_checksum(argc, argv, adler32); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Zlib.adler32;F;7@ ;@";T;; ;0;@$;{;IC; "call-seq: Zlib.adler32(string, adler) Calculates Adler-32 checksum for +string+, and returns updated value of +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If +adler+ is omitted, it assumes that the initial value is given to +adler+. If +string+ is an IO instance, reads from the IO until the IO returns nil and returns Adler-32 of all read data. Example usage: require "zlib" data = "foo" puts "Adler32 checksum: #{Zlib.adler32(data).to_s(16)}" #=> Adler32 checksum: 2820145;T;[;![;"I" call-seq: Zlib.adler32(string, adler) Calculates Adler-32 checksum for +string+, and returns updated value of +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If +adler+ is omitted, it assumes that the initial value is given to +adler+. If +string+ is an IO instance, reads from the IO until the IO returns nil and returns Adler-32 of all read data. Example usage: require "zlib" data = "foo" puts "Adler32 checksum: #{Zlib.adler32(data).to_s(16)}" #=> Adler32 checksum: 2820145 ;T;#0;$@,;.F;/o;0;1T;2i;3i;Bi;%@ݚ;9@*;:@+;;To;4;5F;6;;;;&I"Zlib#adler32_combine;F;7[[I" adler1;T0[I" adler2;T0[I" len2;T0;[[@i;T;:adler32_combine;0;[;{;IC; "call-seq: Zlib.adler32_combine(adler1, adler2, len2) Combine two Adler-32 check values in to one. +alder1+ is the first Adler-32 value, +adler2+ is the second Adler-32 value. +len2+ is the length of the string used to generate +adler2+. ;T;[;![;"I"call-seq: Zlib.adler32_combine(adler1, adler2, len2) Combine two Adler-32 check values in to one. +alder1+ is the first Adler-32 value, +adler2+ is the second Adler-32 value. +len2+ is the length of the string used to generate +adler2+.;T;#0;$@4;.F;C0;%@ݚ;9I"static VALUE rb_zlib_adler32_combine(VALUE klass, VALUE adler1, VALUE adler2, VALUE len2) { return ULONG2NUM( adler32_combine(NUM2ULONG(adler1), NUM2ULONG(adler2), NUM2LONG(len2))); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Zlib.adler32_combine;F;7@6;@=;T;; ;0;@?;{;IC; "call-seq: Zlib.adler32_combine(adler1, adler2, len2) Combine two Adler-32 check values in to one. +alder1+ is the first Adler-32 value, +adler2+ is the second Adler-32 value. +len2+ is the length of the string used to generate +adler2+.;T;[;![;"I" call-seq: Zlib.adler32_combine(adler1, adler2, len2) Combine two Adler-32 check values in to one. +alder1+ is the first Adler-32 value, +adler2+ is the second Adler-32 value. +len2+ is the length of the string used to generate +adler2+. ;T;#0;$@G;.F;/o;0;1T;2i;3i;Bi;%@ݚ;9@E;:@F;;To;4;5F;6;;;;&I"Zlib#crc32;F;7[[@90;[[@i;T;: crc32;0;[;{;IC; "ycall-seq: Zlib.crc32(string, crc) Calculates CRC checksum for +string+, and returns updated value of +crc+. If +string+ is omitted, it returns the CRC initial value. If +crc+ is omitted, it assumes that the initial value is given to +crc+. If +string+ is an IO instance, reads from the IO until the IO returns nil and returns CRC checksum of all read data. FIXME: expression. ;T;[;![;"I"ycall-seq: Zlib.crc32(string, crc) Calculates CRC checksum for +string+, and returns updated value of +crc+. If +string+ is omitted, it returns the CRC initial value. If +crc+ is omitted, it assumes that the initial value is given to +crc+. If +string+ is an IO instance, reads from the IO until the IO returns nil and returns CRC checksum of all read data. FIXME: expression.;T;#0;$@O;.F;C0;%@ݚ;9I"rstatic VALUE rb_zlib_crc32(int argc, VALUE *argv, VALUE klass) { return do_checksum(argc, argv, crc32); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Zlib.crc32;F;7@Q;@S;T;; ;0;@U;{;IC; "ycall-seq: Zlib.crc32(string, crc) Calculates CRC checksum for +string+, and returns updated value of +crc+. If +string+ is omitted, it returns the CRC initial value. If +crc+ is omitted, it assumes that the initial value is given to +crc+. If +string+ is an IO instance, reads from the IO until the IO returns nil and returns CRC checksum of all read data. FIXME: expression.;T;[;![;"I"{ call-seq: Zlib.crc32(string, crc) Calculates CRC checksum for +string+, and returns updated value of +crc+. If +string+ is omitted, it returns the CRC initial value. If +crc+ is omitted, it assumes that the initial value is given to +crc+. If +string+ is an IO instance, reads from the IO until the IO returns nil and returns CRC checksum of all read data. FIXME: expression. ;T;#0;$@];.F;/o;0;1T;2i;3i;Bi;%@ݚ;9@[;:@\;;To;4;5F;6;;;;&I"Zlib#crc32_combine;F;7[[I" crc1;T0[I" crc2;T0[I" len2;T0;[[@i;T;:crc32_combine;0;[;{;IC; "call-seq: Zlib.crc32_combine(crc1, crc2, len2) Combine two CRC-32 check values in to one. +crc1+ is the first CRC-32 value, +crc2+ is the second CRC-32 value. +len2+ is the length of the string used to generate +crc2+. ;T;[;![;"I"call-seq: Zlib.crc32_combine(crc1, crc2, len2) Combine two CRC-32 check values in to one. +crc1+ is the first CRC-32 value, +crc2+ is the second CRC-32 value. +len2+ is the length of the string used to generate +crc2+.;T;#0;$@e;.F;C0;%@ݚ;9I"static VALUE rb_zlib_crc32_combine(VALUE klass, VALUE crc1, VALUE crc2, VALUE len2) { return ULONG2NUM( crc32_combine(NUM2ULONG(crc1), NUM2ULONG(crc2), NUM2LONG(len2))); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Zlib.crc32_combine;F;7@g;@n;T;; ;0;@p;{;IC; "call-seq: Zlib.crc32_combine(crc1, crc2, len2) Combine two CRC-32 check values in to one. +crc1+ is the first CRC-32 value, +crc2+ is the second CRC-32 value. +len2+ is the length of the string used to generate +crc2+.;T;[;![;"I" call-seq: Zlib.crc32_combine(crc1, crc2, len2) Combine two CRC-32 check values in to one. +crc1+ is the first CRC-32 value, +crc2+ is the second CRC-32 value. +len2+ is the length of the string used to generate +crc2+. ;T;#0;$@x;.F;/o;0;1T;2i;3i;Bi;%@ݚ;9@v;:@w;;To;4;5F;6;;;;&I"Zlib#crc_table;F;7[;[[@i ;T;:crc_table;0;[;{;IC; "@Returns the table for calculating CRC checksum as an array. ;T;[;![;"I"@Returns the table for calculating CRC checksum as an array.;T;#0;$@;.F;C0;%@ݚ;9I"ystatic VALUE rb_zlib_crc_table(VALUE obj) { #if !defined(HAVE_TYPE_Z_CRC_T) /* z_crc_t is defined since zlib-1.2.7. */ typedef unsigned long z_crc_t; #endif const z_crc_t *crctbl; VALUE dst; int i; crctbl = get_crc_table(); dst = rb_ary_new2(256); for (i = 0; i < 256; i++) { rb_ary_push(dst, rb_uint2inum(crctbl[i])); } return dst; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Zlib.crc_table;F;7@;@;T;; ;0;@;{;IC; "@Returns the table for calculating CRC checksum as an array.;T;[;![;"I"B Returns the table for calculating CRC checksum as an array. ;T;#0;$@;.F;/o;0;1T;2i;3i ;Bi;%@ݚ;9@;:@;;To;u;[[@i);F;;;;w;;;[;{;IC; ""The Ruby/zlib version string. ;T;[;![;"I""The Ruby/zlib version string.;T;#0;$@;.F;/o;0;1T;2i(;3i(;%@ݚ;&I"Zlib::VERSION;F;xI"#rb_str_new2(RUBY_ZLIB_VERSION);To;u;[[@i+;F;:ZLIB_VERSION;;w;;;[;{;IC; "6The string which represents the version of zlib.h ;T;[;![;"I"6The string which represents the version of zlib.h;T;#0;$@;.F;/o;0;1T;2i*;3i*;%@ݚ;&I"Zlib::ZLIB_VERSION;F;xI"rb_str_new2(ZLIB_VERSION);To;u;[[@iD;F;;;;w;;;[;{;IC; ":Deflate#data_type. ;T;[;![;"I":Deflate#data_type.;T;#0;$@;.F;/o;0;1T;2iA;3iC;%@ݚ;&I"Zlib::BINARY;F;xI"I" overload;F;?0;; ;@0;:I")gzip(src, level: nil, strategy: nil);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I"src;T0[I" level:;TI"nil;T[I"strategy:;TI"nil;T;$@;![;"I"Gzip the given +string+. Valid values of level are Zlib::NO_COMPRESSION, Zlib::BEST_SPEED, Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION (default), or an integer from 0 to 9. This method is almost equivalent to the following code: def gzip(string, level: nil, strategy: nil) sio = StringIO.new sio.binmode gz = Zlib::GzipWriter.new(sio, level, strategy) gz.write(string) gz.close sio.string end See also Zlib.gunzip @overload gzip(src, level: nil, strategy: nil) @return [String];T;#0;$@;.F;/o;0;1T;2it;3i;%@ݚ;9I"static VALUE zlib_s_gzip(int argc, VALUE *argv, VALUE klass) { struct gzfile gz0; struct gzfile *gz = &gz0; int err; VALUE src, opts, level=Qnil, strategy=Qnil, args[2]; if (OPTHASH_GIVEN_P(opts)) { ID keyword_ids[2]; VALUE kwargs[2]; keyword_ids[0] = id_level; keyword_ids[1] = id_strategy; rb_get_kwargs(opts, keyword_ids, 0, 2, kwargs); if (kwargs[0] != Qundef) { level = kwargs[0]; } if (kwargs[1] != Qundef) { strategy = kwargs[1]; } } rb_scan_args(argc, argv, "10", &src); StringValue(src); gzfile_init(gz, &deflate_funcs, zlib_gzip_end); gz->level = ARG_LEVEL(level); err = deflateInit2(&gz->z.stream, gz->level, Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, ARG_STRATEGY(strategy)); if (err != Z_OK) { zlib_gzip_end(gz); raise_zlib_error(err, gz->z.stream.msg); } ZSTREAM_READY(&gz->z); args[0] = (VALUE)gz; args[1] = src; return rb_ensure(zlib_gzip_run, (VALUE)args, zlib_gzip_ensure, (VALUE)gz); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Zlib.gunzip;F;7[[I"src;T0;[[@i;T;: gunzip;0;[;{;IC; "Decode the given gzipped +string+. This method is almost equivalent to the following code: def gunzip(string) sio = StringIO.new(string) gz = Zlib::GzipReader.new(sio, encoding: Encoding::ASCII_8BIT) gz.read ensure gz&.close end See also Zlib.gzip ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"gunzip(src);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ޣ;![;"I"@return [String];T;#0;$@ޣ;.F;Bi;C0;7[[I"src;T0;$@ޣ;![;"I";Decode the given gzipped +string+. This method is almost equivalent to the following code: def gunzip(string) sio = StringIO.new(string) gz = Zlib::GzipReader.new(sio, encoding: Encoding::ASCII_8BIT) gz.read ensure gz&.close end See also Zlib.gzip @overload gunzip(src) @return [String];T;#0;$@ޣ;.F;/o;0;1T;2i;3i;%@ݚ;9I"static VALUE zlib_gunzip(VALUE klass, VALUE src) { struct gzfile gz0; struct gzfile *gz = &gz0; int err; StringValue(src); gzfile_init(gz, &inflate_funcs, zlib_gunzip_end); err = inflateInit2(&gz->z.stream, -MAX_WBITS); if (err != Z_OK) { raise_zlib_error(err, gz->z.stream.msg); } gz->io = Qundef; gz->z.input = src; ZSTREAM_READY(&gz->z); return rb_ensure(zlib_gunzip_run, (VALUE)gz, zlib_gzip_ensure, (VALUE)gz); };T;:I"static VALUE;T;;To;u;[[@i;F;: OS_CODE;;w;;;[;{;IC; " The OS code of current host ;T;[;![;"I" The OS code of current host;T;#0;$@;.F;/o;0;1T;2i;3i;%@ݚ;&I"Zlib::OS_CODE;F;xI"INT2FIX(OS_CODE);To;u;[[@i;F;: OS_MSDOS;;w;;;[;{;IC; "OS code for MSDOS hosts ;T;[;![;"I"OS code for MSDOS hosts;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@ݚ;&I"Zlib::OS_MSDOS;F;xI"INT2FIX(OS_MSDOS);To;u;[[@i;F;: OS_AMIGA;;w;;;[;{;IC; "OS code for Amiga hosts ;T;[;![;"I"OS code for Amiga hosts;T;#0;$@;.F;/o;0;1T;2i;3i;%@ݚ;&I"Zlib::OS_AMIGA;F;xI"INT2FIX(OS_AMIGA);To;u;[[@i!;F;: OS_VMS;;w;;;[;{;IC; "OS code for VMS hosts ;T;[;![;"I"OS code for VMS hosts;T;#0;$@!;.F;/o;0;1T;2i ;3i ;%@ݚ;&I"Zlib::OS_VMS;F;xI"INT2FIX(OS_VMS);To;u;[[@i#;F;: OS_UNIX;;w;;;[;{;IC; "OS code for UNIX hosts ;T;[;![;"I"OS code for UNIX hosts;T;#0;$@-;.F;/o;0;1T;2i";3i";%@ݚ;&I"Zlib::OS_UNIX;F;xI"INT2FIX(OS_UNIX);To;u;[[@i%;F;: OS_ATARI;;w;;;[;{;IC; "OS code for Atari hosts ;T;[;![;"I"OS code for Atari hosts;T;#0;$@9;.F;/o;0;1T;2i$;3i$;%@ݚ;&I"Zlib::OS_ATARI;F;xI"INT2FIX(OS_ATARI);To;u;[[@i';F;: OS_OS2;;w;;;[;{;IC; "OS code for OS2 hosts ;T;[;![;"I"OS code for OS2 hosts;T;#0;$@E;.F;/o;0;1T;2i&;3i&;%@ݚ;&I"Zlib::OS_OS2;F;xI"INT2FIX(OS_OS2);To;u;[[@i);F;: OS_MACOS;;w;;;[;{;IC; "OS code for Mac OS hosts ;T;[;![;"I"OS code for Mac OS hosts;T;#0;$@Q;.F;/o;0;1T;2i(;3i(;%@ݚ;&I"Zlib::OS_MACOS;F;xI"INT2FIX(OS_MACOS);To;u;[[@i+;F;:OS_TOPS20;;w;;;[;{;IC; "OS code for TOPS-20 hosts ;T;[;![;"I"OS code for TOPS-20 hosts;T;#0;$@];.F;/o;0;1T;2i*;3i*;%@ݚ;&I"Zlib::OS_TOPS20;F;xI"INT2FIX(OS_TOPS20);To;u;[[@i-;F;: OS_WIN32;;w;;;[;{;IC; "OS code for Win32 hosts ;T;[;![;"I"OS code for Win32 hosts;T;#0;$@i;.F;/o;0;1T;2i,;3i,;%@ݚ;&I"Zlib::OS_WIN32;F;xI"INT2FIX(OS_WIN32);To;u;[[@i/;F;: OS_VMCMS;;w;;;[;{;IC; "OS code for VM OS hosts ;T;[;![;"I"OS code for VM OS hosts;T;#0;$@u;.F;/o;0;1T;2i.;3i.;%@ݚ;&I"Zlib::OS_VMCMS;F;xI"INT2FIX(OS_VMCMS);To;u;[[@i1;F;:OS_ZSYSTEM;;w;;;[;{;IC; "OS code for Z-System hosts ;T;[;![;"I"OS code for Z-System hosts;T;#0;$@;.F;/o;0;1T;2i0;3i0;%@ݚ;&I"Zlib::OS_ZSYSTEM;F;xI"INT2FIX(OS_ZSYSTEM);To;u;[[@i3;F;: OS_CPM;;w;;;[;{;IC; "OS code for CP/M hosts ;T;[;![;"I"OS code for CP/M hosts;T;#0;$@;.F;/o;0;1T;2i2;3i2;%@ݚ;&I"Zlib::OS_CPM;F;xI"INT2FIX(OS_CPM);To;u;[[@i5;F;: OS_QDOS;;w;;;[;{;IC; "OS code for QDOS hosts ;T;[;![;"I"OS code for QDOS hosts;T;#0;$@;.F;/o;0;1T;2i4;3i4;%@ݚ;&I"Zlib::OS_QDOS;F;xI"INT2FIX(OS_QDOS);To;u;[[@i7;F;:OS_RISCOS;;w;;;[;{;IC; "OS code for RISC OS hosts ;T;[;![;"I"OS code for RISC OS hosts;T;#0;$@;.F;/o;0;1T;2i6;3i6;%@ݚ;&I"Zlib::OS_RISCOS;F;xI"INT2FIX(OS_RISCOS);To;u;[[@i9;F;:OS_UNKNOWN;;w;;;[;{;IC; "OS code for unknown hosts ;T;[;![;"I"OS code for unknown hosts;T;#0;$@;.F;/o;0;1T;2i8;3i8;%@ݚ;&I"Zlib::OS_UNKNOWN;F;xI"INT2FIX(OS_UNKNOWN);T; @ݚ; IC;[; @ݚ; IC;[; @ݚ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;; ;;;;;[;{;IC; "ZThis module provides access to the {zlib library}[http://zlib.net]. Zlib is designed to be a portable, free, general-purpose, legally unencumbered -- that is, not covered by any patents -- lossless data-compression library for use on virtually any computer hardware and operating system. The zlib compression library provides in-memory compression and decompression functions, including integrity checks of the uncompressed data. The zlib compressed data format is described in RFC 1950, which is a wrapper around a deflate stream which is described in RFC 1951. The library also supports reading and writing files in gzip (.gz) format with an interface similar to that of IO. The gzip format is described in RFC 1952 which is also a wrapper around a deflate stream. The zlib format was designed to be compact and fast for use in memory and on communications channels. The gzip format was designed for single-file compression on file systems, has a larger header than zlib to maintain directory information, and uses a different, slower check method than zlib. See your system's zlib.h for further information about zlib == Sample usage Using the wrapper to compress strings with default parameters is quite simple: require "zlib" data_to_compress = File.read("don_quixote.txt") puts "Input size: #{data_to_compress.size}" #=> Input size: 2347740 data_compressed = Zlib::Deflate.deflate(data_to_compress) puts "Compressed size: #{data_compressed.size}" #=> Compressed size: 887238 uncompressed_data = Zlib::Inflate.inflate(data_compressed) puts "Uncompressed data is: #{uncompressed_data}" #=> Uncompressed data is: The Project Gutenberg EBook of Don Quixote... == Class tree - Zlib::Deflate - Zlib::Inflate - Zlib::ZStream - Zlib::Error - Zlib::StreamEnd - Zlib::NeedDict - Zlib::DataError - Zlib::StreamError - Zlib::MemError - Zlib::BufError - Zlib::VersionError - Zlib::InProgressError (if you have GZIP_SUPPORT) - Zlib::GzipReader - Zlib::GzipWriter - Zlib::GzipFile - Zlib::GzipFile::Error - Zlib::GzipFile::LengthError - Zlib::GzipFile::CRCError - Zlib::GzipFile::NoFooter;T;[;![;"I"] This module provides access to the {zlib library}[http://zlib.net]. Zlib is designed to be a portable, free, general-purpose, legally unencumbered -- that is, not covered by any patents -- lossless data-compression library for use on virtually any computer hardware and operating system. The zlib compression library provides in-memory compression and decompression functions, including integrity checks of the uncompressed data. The zlib compressed data format is described in RFC 1950, which is a wrapper around a deflate stream which is described in RFC 1951. The library also supports reading and writing files in gzip (.gz) format with an interface similar to that of IO. The gzip format is described in RFC 1952 which is also a wrapper around a deflate stream. The zlib format was designed to be compact and fast for use in memory and on communications channels. The gzip format was designed for single-file compression on file systems, has a larger header than zlib to maintain directory information, and uses a different, slower check method than zlib. See your system's zlib.h for further information about zlib == Sample usage Using the wrapper to compress strings with default parameters is quite simple: require "zlib" data_to_compress = File.read("don_quixote.txt") puts "Input size: #{data_to_compress.size}" #=> Input size: 2347740 data_compressed = Zlib::Deflate.deflate(data_to_compress) puts "Compressed size: #{data_compressed.size}" #=> Compressed size: 887238 uncompressed_data = Zlib::Inflate.inflate(data_compressed) puts "Uncompressed data is: #{uncompressed_data}" #=> Uncompressed data is: The Project Gutenberg EBook of Don Quixote... == Class tree - Zlib::Deflate - Zlib::Inflate - Zlib::ZStream - Zlib::Error - Zlib::StreamEnd - Zlib::NeedDict - Zlib::DataError - Zlib::StreamError - Zlib::MemError - Zlib::BufError - Zlib::VersionError - Zlib::InProgressError (if you have GZIP_SUPPORT) - Zlib::GzipReader - Zlib::GzipWriter - Zlib::GzipFile - Zlib::GzipFile::Error - Zlib::GzipFile::LengthError - Zlib::GzipFile::CRCError - Zlib::GzipFile::NoFooter ;T;#0;$@ݚ;.F;/o;0;1T;2i;3i,;Bi;%@;&I" Zlib;Fo;;IC;[ o; ;IC;[o;4;5F;6;;;;&I""Psych::ClassLoader#path2class;F;7[[I" path;T0;[[I"ext/psych/psych_to_ruby.c;Ti;T;:path2class;0;[;{;IC; "%Convert +path+ string to a class ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"path2class(path);T;IC; ";T;[;![;"I";T;#0;$@Ӥ;.F;Bi;C0;7[[I" path;T0;$@Ӥ;![;"I"BConvert +path+ string to a class @overload path2class(path);T;#0;$@Ӥ;.F;/o;0;1T;2i;3i;%@Ѥ;9I"[static VALUE path2class(VALUE self, VALUE path) { return rb_path_to_class(path); };T;:I"4static VALUE path2class(VALUE self, VALUE path);T;;T; @Ѥ; IC;[; @Ѥ; IC;[; @Ѥ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ڤi#;F;:ClassLoader;;;;;[;{;IC; " ;T;[;![;"@;#0;$@Ѥ;Bi;%@Ϥ;&I"Psych::ClassLoader;F;'@o;;IC;[o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ڤi&[I" ext/psych/psych_yaml_tree.c;Ti;F;: Visitor;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"Psych::Visitors::Visitor;F;'@o; ;IC;[o;4;5F;6;;;;&I",Psych::Visitors::ToRuby#build_exception;F;7[[I" klass;T0[I" mesg;T0;[[@ڤi;T;:build_exception;0;[;{;IC; "9Create an exception with class +klass+ and +message+ ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"$build_exception(klass, message);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" klass;T0[I" message;T0;$@;![;"I"eCreate an exception with class +klass+ and +message+ @overload build_exception(klass, message);T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE build_exception(VALUE self, VALUE klass, VALUE mesg) { VALUE e = rb_obj_alloc(klass); rb_iv_set(e, "mesg", mesg); return e; };T;:I"Fstatic VALUE build_exception(VALUE self, VALUE klass, VALUE mesg);T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ڤi';F;: ToRuby;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I"Psych::Visitors::ToRuby;F;'@o; ;IC;[; @A; IC;[; @A; IC;[; @A; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ i;F;: YAMLTree;;;;;[;{;IC; " ;T;[;![;"@;#0;$@A;%@;&I"Psych::Visitors::YAMLTree;F;'@; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ڤi%[@ i ;F;: Visitors;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@Ϥ;&I"Psych::Visitors;Fo; ;IC;[; @b; IC;[; @b; IC;[; @b; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i;F;: Handler;;;;;[;{;IC; " ;T;[;![;"@;#0;$@b;%@Ϥ;&I"Psych::Handler;F;'@o; ;IC;[o;4;5F;6;;;;&I"Psych::Emitter#initialize;F;7[[@90;[[@iO;T;;D;0;[;{;IC; "5Create a new Psych::Emitter that writes to +io+. ;T;[o;= ;>I" overload;F;?0;;p ;@0;:I">Psych::Emitter.new(io, options = Psych::Emitter::OPTIONS);T;IC; ";T;[;![;"I";T;#0;$@u;.F;Bi;C0;7[[I"io;T0[I" options;TI"Psych::Emitter::OPTIONS;T;$@u;![;"@;#0;$@u;.F;/o;0;1T;2iK;3iN;%@s;9I"static VALUE initialize(int argc, VALUE *argv, VALUE self) { yaml_emitter_t * emitter; VALUE io, options; VALUE line_width; VALUE indent; VALUE canonical; TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter); if (rb_scan_args(argc, argv, "11", &io, &options) == 2) { line_width = rb_funcall(options, id_line_width, 0); indent = rb_funcall(options, id_indentation, 0); canonical = rb_funcall(options, id_canonical, 0); yaml_emitter_set_width(emitter, NUM2INT(line_width)); yaml_emitter_set_indent(emitter, NUM2INT(indent)); yaml_emitter_set_canonical(emitter, Qtrue == canonical ? 1 : 0); } rb_ivar_set(self, id_io, io); yaml_emitter_set_output(emitter, writer, (void *)self); return self; };T;:I"?static VALUE initialize(int argc, VALUE *argv, VALUE self);T;;To;4;5F;6;;;;&I" Psych::Emitter#start_stream;F;7[[I" encoding;T0;[[@io;T;:start_stream;0;[;{;IC; "MStart a stream emission with +encoding+ See Psych::Handler#start_stream ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"start_stream(encoding);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" encoding;T0;$@;![;"I"pStart a stream emission with +encoding+ See Psych::Handler#start_stream @overload start_stream(encoding);T;#0;$@;.F;/o;0;1T;2ii;3in;%@s;9I"dstatic VALUE start_stream(VALUE self, VALUE encoding) { yaml_emitter_t * emitter; yaml_event_t event; TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter); Check_Type(encoding, T_FIXNUM); yaml_stream_start_event_initialize(&event, (yaml_encoding_t)NUM2INT(encoding)); emit(emitter, &event); return self; };T;:I":static VALUE start_stream(VALUE self, VALUE encoding);T;;To;4;5F;6;;;;&I"Psych::Emitter#end_stream;F;7[;[[@i~;T;:end_stream;0;[;{;IC; "9End a stream emission See Psych::Handler#end_stream ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"end_stream;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"PEnd a stream emission See Psych::Handler#end_stream @overload end_stream;T;#0;$@;.F;/o;0;1T;2i};3i};%@s;9I"static VALUE end_stream(VALUE self) { yaml_emitter_t * emitter; yaml_event_t event; TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter); yaml_stream_end_event_initialize(&event); emit(emitter, &event); return self; };T;:I"(static VALUE end_stream(VALUE self);T;;To;4;5F;6;;;;&I""Psych::Emitter#start_document;F;7[[I" version;T0[I" tags;T0[I"imp;T0;[[@i;T;:start_document;0;[;{;IC; "wStart a document emission with YAML +version+, +tags+, and an +implicit+ start. See Psych::Handler#start_document ;T;[o;= ;>I" overload;F;?0;; ;@0;:I",start_document(version, tags, implicit);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" version;T0[I" tags;T0[I" implicit;T0;$@;![;"I"Start a document emission with YAML +version+, +tags+, and an +implicit+ start. See Psych::Handler#start_document @overload start_document(version, tags, implicit);T;#0;$@;.F;/o;0;1T;2i;3i;%@s;9I"static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp) { yaml_emitter_t * emitter; yaml_tag_directive_t * head = NULL; yaml_tag_directive_t * tail = NULL; yaml_event_t event; yaml_version_directive_t version_directive; TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter); Check_Type(version, T_ARRAY); if(RARRAY_LEN(version) > 0) { VALUE major = rb_ary_entry(version, (long)0); VALUE minor = rb_ary_entry(version, (long)1); version_directive.major = NUM2INT(major); version_directive.minor = NUM2INT(minor); } if(RTEST(tags)) { long i = 0; long len; rb_encoding * encoding = rb_utf8_encoding(); Check_Type(tags, T_ARRAY); len = RARRAY_LEN(tags); head = xcalloc((size_t)len, sizeof(yaml_tag_directive_t)); tail = head; for(i = 0; i < len && i < RARRAY_LEN(tags); i++) { VALUE tuple = RARRAY_AREF(tags, i); VALUE name; VALUE value; Check_Type(tuple, T_ARRAY); if(RARRAY_LEN(tuple) < 2) { xfree(head); rb_raise(rb_eRuntimeError, "tag tuple must be of length 2"); } name = RARRAY_AREF(tuple, 0); value = RARRAY_AREF(tuple, 1); StringValue(name); StringValue(value); name = rb_str_export_to_enc(name, encoding); value = rb_str_export_to_enc(value, encoding); tail->handle = (yaml_char_t *)StringValueCStr(name); tail->prefix = (yaml_char_t *)StringValueCStr(value); tail++; } } yaml_document_start_event_initialize( &event, (RARRAY_LEN(version) > 0) ? &version_directive : NULL, head, tail, imp ? 1 : 0 ); emit(emitter, &event); if(head) xfree(head); return self; };T;:I"Rstatic VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp);T;;To;4;5F;6;;;;&I" Psych::Emitter#end_document;F;7[[I"imp;T0;[[@i;T;:end_document;0;[;{;IC; "XEnd a document emission with an +implicit+ ending. See Psych::Handler#end_document ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"end_document(implicit);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" implicit;T0;$@;![;"I"{End a document emission with an +implicit+ ending. See Psych::Handler#end_document @overload end_document(implicit);T;#0;$@;.F;/o;0;1T;2i;3i;%@s;9I"$static VALUE end_document(VALUE self, VALUE imp) { yaml_emitter_t * emitter; yaml_event_t event; TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter); yaml_document_end_event_initialize(&event, imp ? 1 : 0); emit(emitter, &event); return self; };T;:I"5static VALUE end_document(VALUE self, VALUE imp);T;;To;4;5F;6;;;;&I"Psych::Emitter#scalar;F;7[ [I" value;T0[I" anchor;T0[I"tag;T0[I" plain;T0[I" quoted;T0[I" style;T0;[[@i;T;: scalar;0;[;{;IC; "{Emit a scalar with +value+, +anchor+, +tag+, and a +plain+ or +quoted+ string type with +style+. See Psych::Handler#scalar ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"5scalar(value, anchor, tag, plain, quoted, style);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[ [I" value;T0[I" anchor;T0[I"tag;T0[I" plain;T0[I" quoted;T0[I" style;T0;$@;![;"I"Emit a scalar with +value+, +anchor+, +tag+, and a +plain+ or +quoted+ string type with +style+. See Psych::Handler#scalar @overload scalar(value, anchor, tag, plain, quoted, style);T;#0;$@;.F;/o;0;1T;2i;3i;%@s;9I"static VALUE scalar( VALUE self, VALUE value, VALUE anchor, VALUE tag, VALUE plain, VALUE quoted, VALUE style ) { yaml_emitter_t * emitter; yaml_event_t event; rb_encoding *encoding; TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter); Check_Type(value, T_STRING); encoding = rb_utf8_encoding(); value = rb_str_export_to_enc(value, encoding); if(!NIL_P(anchor)) { Check_Type(anchor, T_STRING); anchor = rb_str_export_to_enc(anchor, encoding); } if(!NIL_P(tag)) { Check_Type(tag, T_STRING); tag = rb_str_export_to_enc(tag, encoding); } yaml_scalar_event_initialize( &event, (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)), (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)), (yaml_char_t*)StringValuePtr(value), (int)RSTRING_LEN(value), plain ? 1 : 0, quoted ? 1 : 0, (yaml_scalar_style_t)NUM2INT(style) ); emit(emitter, &event); return self; };T;:I"static VALUE scalar(;T;;To;4;5F;6;;;;&I""Psych::Emitter#start_sequence;F;7[ [I" anchor;T0[I"tag;T0[I" implicit;T0[I" style;T0;[[@i(;T;:start_sequence;0;[;{;IC; "Start emitting a sequence with +anchor+, a +tag+, +implicit+ sequence start and end, along with +style+. See Psych::Handler#start_sequence ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"1start_sequence(anchor, tag, implicit, style);T;IC; ";T;[;![;"I";T;#0;$@*;.F;Bi;C0;7[ [I" anchor;T0[I"tag;T0[I" implicit;T0[I" style;T0;$@*;![;"I"Start emitting a sequence with +anchor+, a +tag+, +implicit+ sequence start and end, along with +style+. See Psych::Handler#start_sequence @overload start_sequence(anchor, tag, implicit, style);T;#0;$@*;.F;/o;0;1T;2i!;3i';%@s;9I",static VALUE start_sequence( VALUE self, VALUE anchor, VALUE tag, VALUE implicit, VALUE style ) { yaml_emitter_t * emitter; yaml_event_t event; rb_encoding * encoding = rb_utf8_encoding(); if(!NIL_P(anchor)) { Check_Type(anchor, T_STRING); anchor = rb_str_export_to_enc(anchor, encoding); } if(!NIL_P(tag)) { Check_Type(tag, T_STRING); tag = rb_str_export_to_enc(tag, encoding); } TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter); yaml_sequence_start_event_initialize( &event, (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)), (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)), implicit ? 1 : 0, (yaml_sequence_style_t)NUM2INT(style) ); emit(emitter, &event); return self; };T;:I"!static VALUE start_sequence(;T;;To;4;5F;6;;;;&I" Psych::Emitter#end_sequence;F;7[;[[@iS;T;:end_sequence;0;[;{;IC; "I" overload;F;?0;; ;@0;:I"end_sequence;T;IC; ";T;[;![;"I";T;#0;$@P;.F;Bi;C0;7[;$@P;![;"I"UEnd sequence emission. See Psych::Handler#end_sequence @overload end_sequence;T;#0;$@P;.F;/o;0;1T;2iM;3iR;%@s;9I" static VALUE end_sequence(VALUE self) { yaml_emitter_t * emitter; yaml_event_t event; TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter); yaml_sequence_end_event_initialize(&event); emit(emitter, &event); return self; };T;:I"*static VALUE end_sequence(VALUE self);T;;To;4;5F;6;;;;&I"!Psych::Emitter#start_mapping;F;7[ [I" anchor;T0[I"tag;T0[I" implicit;T0[I" style;T0;[[@ig;T;:start_mapping;0;[;{;IC; "{Start emitting a YAML map with +anchor+, +tag+, an +implicit+ start and end, and +style+. See Psych::Handler#start_mapping ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"0start_mapping(anchor, tag, implicit, style);T;IC; ";T;[;![;"I";T;#0;$@f;.F;Bi;C0;7[ [I" anchor;T0[I"tag;T0[I" implicit;T0[I" style;T0;$@f;![;"I"Start emitting a YAML map with +anchor+, +tag+, an +implicit+ start and end, and +style+. See Psych::Handler#start_mapping @overload start_mapping(anchor, tag, implicit, style);T;#0;$@f;.F;/o;0;1T;2i`;3if;%@s;9I"6static VALUE start_mapping( VALUE self, VALUE anchor, VALUE tag, VALUE implicit, VALUE style ) { yaml_emitter_t * emitter; yaml_event_t event; rb_encoding *encoding; TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter); encoding = rb_utf8_encoding(); if(!NIL_P(anchor)) { Check_Type(anchor, T_STRING); anchor = rb_str_export_to_enc(anchor, encoding); } if(!NIL_P(tag)) { Check_Type(tag, T_STRING); tag = rb_str_export_to_enc(tag, encoding); } yaml_mapping_start_event_initialize( &event, (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)), (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)), implicit ? 1 : 0, (yaml_mapping_style_t)NUM2INT(style) ); emit(emitter, &event); return self; };T;:I" static VALUE start_mapping(;T;;To;4;5F;6;;;;&I"Psych::Emitter#end_mapping;F;7[;[[@i;T;:end_mapping;0;[;{;IC; "?Emit the end of a mapping. See Psych::Handler#end_mapping ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"end_mapping;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"WEmit the end of a mapping. See Psych::Handler#end_mapping @overload end_mapping;T;#0;$@;.F;/o;0;1T;2i;3i;%@s;9I" static VALUE end_mapping(VALUE self) { yaml_emitter_t * emitter; yaml_event_t event; TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter); yaml_mapping_end_event_initialize(&event); emit(emitter, &event); return self; };T;:I")static VALUE end_mapping(VALUE self);T;;To;4;5F;6;;;;&I"Psych::Emitter#alias;F;7[[I" anchor;T0;[[@i;T;: alias;0;[;{;IC; ";Emit an alias with +anchor+. See Psych::Handler#alias ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"alias(anchor);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" anchor;T0;$@;![;"I"UEmit an alias with +anchor+. See Psych::Handler#alias @overload alias(anchor);T;#0;$@;.F;/o;0;1T;2i;3i;%@s;9I"static VALUE alias(VALUE self, VALUE anchor) { yaml_emitter_t * emitter; yaml_event_t event; TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter); if(!NIL_P(anchor)) { Check_Type(anchor, T_STRING); anchor = rb_str_export_to_enc(anchor, rb_utf8_encoding()); } yaml_alias_event_initialize( &event, (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)) ); emit(emitter, &event); return self; };T;:I"1static VALUE alias(VALUE self, VALUE anchor);T;;To;4;5F;6;;;;&I"Psych::Emitter#canonical;F;7[;[[@i;T;:canonical;0;[;{;IC; ",Get the output style, canonical or not. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"canonical;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"BGet the output style, canonical or not. @overload canonical;T;#0;$@;.F;/o;0;1T;2i;3i;%@s;9I"static VALUE canonical(VALUE self) { yaml_emitter_t * emitter; TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter); return (emitter->canonical == 0) ? Qfalse : Qtrue; };T;:I"'static VALUE canonical(VALUE self);T;;To;4;5F;6;;;;&I"Psych::Emitter#canonical=;F;7[[I" style;T0;[[@i;T;:canonical=;0;[;{;IC; "/Set the output style to canonical, or not. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"canonical=(true);T;IC; ";T;[;![;"I";T;#0;$@Ҧ;.F;Bi;C0;7[[I" true;T0;$@Ҧ;![;"I"LSet the output style to canonical, or not. @overload canonical=(true);T;#0;$@Ҧ;.F;/o;0;1T;2i;3i;%@s;9I"static VALUE set_canonical(VALUE self, VALUE style) { yaml_emitter_t * emitter; TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter); yaml_emitter_set_canonical(emitter, Qtrue == style ? 1 : 0); return style; };T;:I"8static VALUE set_canonical(VALUE self, VALUE style);T;;To;4;5F;6;;;;&I"Psych::Emitter#indentation;F;7[;[[@i;T;:indentation;0;[;{;IC; "Get the indentation level. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"indentation;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"7Get the indentation level. @overload indentation;T;#0;$@;.F;/o;0;1T;2i;3i;%@s;9I"static VALUE indentation(VALUE self) { yaml_emitter_t * emitter; TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter); return INT2NUM(emitter->best_indent); };T;:I")static VALUE indentation(VALUE self);T;;To;4;5F;6;;;;&I" Psych::Emitter#indentation=;F;7[[I" level;T0;[[@i;T;:indentation=;0;[;{;IC; "^Set the indentation level to +level+. The level must be less than 10 and greater than 1. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"indentation=(level);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" level;T0;$@;![;"I"~Set the indentation level to +level+. The level must be less than 10 and greater than 1. @overload indentation=(level);T;#0;$@;.F;/o;0;1T;2i;3i;%@s;9I"static VALUE set_indentation(VALUE self, VALUE level) { yaml_emitter_t * emitter; TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter); yaml_emitter_set_indent(emitter, NUM2INT(level)); return level; };T;:I":static VALUE set_indentation(VALUE self, VALUE level);T;;To;4;5F;6;;;;&I"Psych::Emitter#line_width;F;7[;[[@i;T;:line_width;0;[;{;IC; ""Get the preferred line width. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"line_width;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"9Get the preferred line width. @overload line_width;T;#0;$@;.F;/o;0;1T;2i;3i;%@s;9I"static VALUE line_width(VALUE self) { yaml_emitter_t * emitter; TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter); return INT2NUM(emitter->best_width); };T;:I"(static VALUE line_width(VALUE self);T;;To;4;5F;6;;;;&I"Psych::Emitter#line_width=;F;7[[I" width;T0;[[@i;T;:line_width=;0;[;{;IC; ",Set the preferred line with to +width+. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"line_width=(width);T;IC; ";T;[;![;"I";T;#0;$@2;.F;Bi;C0;7[[I" width;T0;$@2;![;"I"KSet the preferred line with to +width+. @overload line_width=(width);T;#0;$@2;.F;/o;0;1T;2i;3i;%@s;9I"static VALUE set_line_width(VALUE self, VALUE width) { yaml_emitter_t * emitter; TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter); yaml_emitter_set_width(emitter, NUM2INT(width)); return width; };T;:I"9static VALUE set_line_width(VALUE self, VALUE width);T;;T; @s; IC;[; @s; IC;[; @s; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i;F;: Emitter;;;;;[;{;IC; " ;T;[;![;"@;#0;$@s;Bi;%@Ϥ;&I"Psych::Emitter;F;'@bo;4;5F;6;;;;&I"Psych.libyaml_version;F;7[;[[I"ext/psych/psych.c;Ti ;T;:libyaml_version;0;[;{;IC; ".Returns the version of libyaml being used ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"libyaml_version;T;IC; ";T;[;![;"I";T;#0;$@[;.F;Bi;C0;7[;$@[;![;"I"JReturns the version of libyaml being used @overload libyaml_version;T;#0;$@[;.F;/o;0;1T;2i;3i ;%@Ϥ;9I"static VALUE libyaml_version(VALUE module) { int major, minor, patch; VALUE list[3]; yaml_get_version(&major, &minor, &patch); list[0] = INT2NUM(major); list[1] = INT2NUM(minor); list[2] = INT2NUM(patch); return rb_ary_new4((long)3, list); };T;:I"/static VALUE libyaml_version(VALUE module);T;;To; ;IC;[ o;u;[[I"ext/psych/psych_parser.c;Ti$;F;:ANY;;w;;;[;{;IC; "'Let the parser choose the encoding ;T;[;![;"I"'Let the parser choose the encoding;T;#0;$@t;.F;/o;0;1T;2i#;3i#;%@r;&I"Psych::Parser::ANY;F;xI"Any encoding;To;u;[[@wi';F;;;;w;;;[;{;IC; "UTF-8 Encoding ;T;[;![;"I"UTF-8 Encoding;T;#0;$@;.F;/o;0;1T;2i&;3i&;%@r;&I"Psych::Parser::UTF8;F;xI" INT2NUM(YAML_UTF8_ENCODING);To;u;[[@wi*;F;: UTF16LE;;w;;;[;{;IC; " UTF-16-LE Encoding with BOM ;T;[;![;"I" UTF-16-LE Encoding with BOM;T;#0;$@;.F;/o;0;1T;2i);3i);%@r;&I"Psych::Parser::UTF16LE;F;xI"#INT2NUM(YAML_UTF16LE_ENCODING);To;u;[[@wi-;F;: UTF16BE;;w;;;[;{;IC; " UTF-16-BE Encoding with BOM ;T;[;![;"I" UTF-16-BE Encoding with BOM;T;#0;$@;.F;/o;0;1T;2i,;3i,;%@r;&I"Psych::Parser::UTF16BE;F;xI"#INT2NUM(YAML_UTF16BE_ENCODING);To;4;5F;6;;;;&I"Psych::Parser#parse;F;7[[@90;[[@wi;T;;+;0;[;{;IC; "Parse the YAML document contained in +yaml+. Events will be called on the handler set on the parser instance. See Psych::Parser and Psych::Parser#handler ;T;[o;= ;>I" overload;F;?0;;+;@0;:I"parse(yaml);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" yaml;T0;$@;![;"I"Parse the YAML document contained in +yaml+. Events will be called on the handler set on the parser instance. See Psych::Parser and Psych::Parser#handler @overload parse(yaml);T;#0;$@;.F;/o;0;1T;2i;3i;%@r;9I"static VALUE parse(int argc, VALUE *argv, VALUE self) { VALUE yaml, path; yaml_parser_t * parser; yaml_event_t event; int done = 0; int state = 0; int parser_encoding = YAML_ANY_ENCODING; int encoding = rb_utf8_encindex(); rb_encoding * internal_enc = rb_default_internal_encoding(); VALUE handler = rb_iv_get(self, "@handler"); if (rb_scan_args(argc, argv, "11", &yaml, &path) == 1) { if(rb_respond_to(yaml, id_path)) path = rb_funcall(yaml, id_path, 0); else path = rb_str_new2(""); } TypedData_Get_Struct(self, yaml_parser_t, &psych_parser_type, parser); yaml_parser_delete(parser); yaml_parser_initialize(parser); if (rb_respond_to(yaml, id_read)) { yaml = transcode_io(yaml, &parser_encoding); yaml_parser_set_encoding(parser, parser_encoding); yaml_parser_set_input(parser, io_reader, (void *)yaml); } else { StringValue(yaml); yaml = transcode_string(yaml, &parser_encoding); yaml_parser_set_encoding(parser, parser_encoding); yaml_parser_set_input_string( parser, (const unsigned char *)RSTRING_PTR(yaml), (size_t)RSTRING_LEN(yaml) ); } while(!done) { VALUE event_args[5]; VALUE start_line, start_column, end_line, end_column; if(!yaml_parser_parse(parser, &event)) { VALUE exception; exception = make_exception(parser, path); yaml_parser_delete(parser); yaml_parser_initialize(parser); rb_exc_raise(exception); } start_line = SIZET2NUM(event.start_mark.line); start_column = SIZET2NUM(event.start_mark.column); end_line = SIZET2NUM(event.end_mark.line); end_column = SIZET2NUM(event.end_mark.column); event_args[0] = handler; event_args[1] = start_line; event_args[2] = start_column; event_args[3] = end_line; event_args[4] = end_column; rb_protect(protected_event_location, (VALUE)event_args, &state); switch(event.type) { case YAML_STREAM_START_EVENT: { VALUE args[2]; args[0] = handler; args[1] = INT2NUM(event.data.stream_start.encoding); rb_protect(protected_start_stream, (VALUE)args, &state); } break; case YAML_DOCUMENT_START_EVENT: { VALUE args[4]; /* Get a list of tag directives (if any) */ VALUE tag_directives = rb_ary_new(); /* Grab the document version */ VALUE version = event.data.document_start.version_directive ? rb_ary_new3( (long)2, INT2NUM(event.data.document_start.version_directive->major), INT2NUM(event.data.document_start.version_directive->minor) ) : rb_ary_new(); if(event.data.document_start.tag_directives.start) { yaml_tag_directive_t *start = event.data.document_start.tag_directives.start; yaml_tag_directive_t *end = event.data.document_start.tag_directives.end; for(; start != end; start++) { VALUE handle = Qnil; VALUE prefix = Qnil; if(start->handle) { handle = rb_str_new2((const char *)start->handle); PSYCH_TRANSCODE(handle, encoding, internal_enc); } if(start->prefix) { prefix = rb_str_new2((const char *)start->prefix); PSYCH_TRANSCODE(prefix, encoding, internal_enc); } rb_ary_push(tag_directives, rb_ary_new3((long)2, handle, prefix)); } } args[0] = handler; args[1] = version; args[2] = tag_directives; args[3] = event.data.document_start.implicit == 1 ? Qtrue : Qfalse; rb_protect(protected_start_document, (VALUE)args, &state); } break; case YAML_DOCUMENT_END_EVENT: { VALUE args[2]; args[0] = handler; args[1] = event.data.document_end.implicit == 1 ? Qtrue : Qfalse; rb_protect(protected_end_document, (VALUE)args, &state); } break; case YAML_ALIAS_EVENT: { VALUE args[2]; VALUE alias = Qnil; if(event.data.alias.anchor) { alias = rb_str_new2((const char *)event.data.alias.anchor); PSYCH_TRANSCODE(alias, encoding, internal_enc); } args[0] = handler; args[1] = alias; rb_protect(protected_alias, (VALUE)args, &state); } break; case YAML_SCALAR_EVENT: { VALUE args[7]; VALUE anchor = Qnil; VALUE tag = Qnil; VALUE plain_implicit, quoted_implicit, style; VALUE val = rb_str_new( (const char *)event.data.scalar.value, (long)event.data.scalar.length ); PSYCH_TRANSCODE(val, encoding, internal_enc); if(event.data.scalar.anchor) { anchor = rb_str_new2((const char *)event.data.scalar.anchor); PSYCH_TRANSCODE(anchor, encoding, internal_enc); } if(event.data.scalar.tag) { tag = rb_str_new2((const char *)event.data.scalar.tag); PSYCH_TRANSCODE(tag, encoding, internal_enc); } plain_implicit = event.data.scalar.plain_implicit == 0 ? Qfalse : Qtrue; quoted_implicit = event.data.scalar.quoted_implicit == 0 ? Qfalse : Qtrue; style = INT2NUM(event.data.scalar.style); args[0] = handler; args[1] = val; args[2] = anchor; args[3] = tag; args[4] = plain_implicit; args[5] = quoted_implicit; args[6] = style; rb_protect(protected_scalar, (VALUE)args, &state); } break; case YAML_SEQUENCE_START_EVENT: { VALUE args[5]; VALUE anchor = Qnil; VALUE tag = Qnil; VALUE implicit, style; if(event.data.sequence_start.anchor) { anchor = rb_str_new2((const char *)event.data.sequence_start.anchor); PSYCH_TRANSCODE(anchor, encoding, internal_enc); } tag = Qnil; if(event.data.sequence_start.tag) { tag = rb_str_new2((const char *)event.data.sequence_start.tag); PSYCH_TRANSCODE(tag, encoding, internal_enc); } implicit = event.data.sequence_start.implicit == 0 ? Qfalse : Qtrue; style = INT2NUM(event.data.sequence_start.style); args[0] = handler; args[1] = anchor; args[2] = tag; args[3] = implicit; args[4] = style; rb_protect(protected_start_sequence, (VALUE)args, &state); } break; case YAML_SEQUENCE_END_EVENT: rb_protect(protected_end_sequence, handler, &state); break; case YAML_MAPPING_START_EVENT: { VALUE args[5]; VALUE anchor = Qnil; VALUE tag = Qnil; VALUE implicit, style; if(event.data.mapping_start.anchor) { anchor = rb_str_new2((const char *)event.data.mapping_start.anchor); PSYCH_TRANSCODE(anchor, encoding, internal_enc); } if(event.data.mapping_start.tag) { tag = rb_str_new2((const char *)event.data.mapping_start.tag); PSYCH_TRANSCODE(tag, encoding, internal_enc); } implicit = event.data.mapping_start.implicit == 0 ? Qfalse : Qtrue; style = INT2NUM(event.data.mapping_start.style); args[0] = handler; args[1] = anchor; args[2] = tag; args[3] = implicit; args[4] = style; rb_protect(protected_start_mapping, (VALUE)args, &state); } break; case YAML_MAPPING_END_EVENT: rb_protect(protected_end_mapping, handler, &state); break; case YAML_NO_EVENT: rb_protect(protected_empty, handler, &state); break; case YAML_STREAM_END_EVENT: rb_protect(protected_end_stream, handler, &state); done = 1; break; } yaml_event_delete(&event); if (state) rb_jump_tag(state); } return self; };T;:I":static VALUE parse(int argc, VALUE *argv, VALUE self);T;;To;4;5F;6;;;;&I"Psych::Parser#mark;F;7[;[[@wi ;T;: mark;0;[;{;IC; "\Returns a Psych::Parser::Mark object that contains line, column, and index information. ;T;[;![;"I"_ Returns a Psych::Parser::Mark object that contains line, column, and index information. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@r;9I"static VALUE mark(VALUE self) { VALUE mark_klass; VALUE args[3]; yaml_parser_t * parser; TypedData_Get_Struct(self, yaml_parser_t, &psych_parser_type, parser); mark_klass = rb_const_get_at(cPsychParser, rb_intern("Mark")); args[0] = SIZET2NUM(parser->mark.index); args[1] = SIZET2NUM(parser->mark.line); args[2] = SIZET2NUM(parser->mark.column); return rb_class_new_instance(3, args, mark_klass); };T;:I""static VALUE mark(VALUE self);T;;T; @r; IC;[; @r; IC;[; @r; IC;{;IC;{;T;IC;{;T;T;{;[;[[@wi ;F;: Parser;;;;;[;{;IC; " ;T;[;![;"@;#0;$@r;Bi;%@Ϥ;&I"Psych::Parser;F;'@; @Ϥ; IC;[; @Ϥ; IC;[; @Ϥ; IC;{;IC;{;T;IC;{;T;T;{;[;[ [@ڤi"[@ i [@i [@`i![@wi;F;: Psych;;;;;[;{;IC; " ;T;[;![;"@;#0;$@Ϥ;Bi;%@;&I" Psych;Fo; ;IC;[o;;IC;[ o;4;5F;6;;;;&I"CGI::Escape#escapeHTML;F;7[[I"str;T0;[[I"ext/cgi/escape/escape.c;Ti:;T;:escapeHTML;0;[;{;IC; "!Returns HTML-escaped string. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"escapeHTML(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I" string;T0;$@;![;"I"TReturns HTML-escaped string. @overload escapeHTML(string) @return [String];T;#0;$@;.F;/o;0;1T;2i3;3i8;%@;9I"static VALUE cgiesc_escape_html(VALUE self, VALUE str) { StringValue(str); if (rb_enc_str_asciicompat_p(str)) { return optimized_escape_html(str); } else { return rb_call_super(1, &str); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"CGI::Escape#unescapeHTML;F;7[[I"str;T0;[[@iN;T;:unescapeHTML;0;[;{;IC; "#Returns HTML-unescaped string. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"unescapeHTML(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I" string;T0;$@;![;"I"XReturns HTML-unescaped string. @overload unescapeHTML(string) @return [String];T;#0;$@;.F;/o;0;1T;2iG;3iL;%@;9I"static VALUE cgiesc_unescape_html(VALUE self, VALUE str) { StringValue(str); if (rb_enc_str_asciicompat_p(str)) { return optimized_unescape_html(str); } else { return rb_call_super(1, &str); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"CGI::Escape#escape;F;7[[I"str;T0;[[@ib;T;;E;0;[;{;IC; " Returns URL-escaped string. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"escape(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@1;![;"I"@return [String];T;#0;$@1;.F;Bi;C0;7[[I" string;T0;$@1;![;"I"OReturns URL-escaped string. @overload escape(string) @return [String];T;#0;$@1;.F;/o;0;1T;2i[;3i`;%@;9I"static VALUE cgiesc_escape(VALUE self, VALUE str) { StringValue(str); if (rb_enc_str_asciicompat_p(str)) { return optimized_escape(str); } else { return rb_call_super(1, &str); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"CGI::Escape#unescape;F;7[[@90;[[@i~;T;: unescape;0;[;{;IC; ""Returns URL-unescaped string. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"0unescape(string, encoding=@@accept_charset);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@P;![;"I"@return [String];T;#0;$@P;.F;Bi;C0;7[[I" string;T0[I" encoding;TI"@@accept_charset;T;$@P;![;"I"nReturns URL-unescaped string. @overload unescape(string, encoding=@@accept_charset) @return [String];T;#0;$@P;.F;/o;0;1T;2iw;3i|;%@;9I"Nstatic VALUE cgiesc_unescape(int argc, VALUE *argv, VALUE self) { VALUE str = (rb_check_arity(argc, 1, 2), argv[0]); StringValue(str); if (rb_enc_str_asciicompat_p(str)) { VALUE enc = accept_charset(argc-1, argv+1, self); return optimized_unescape(str, enc); } else { return rb_call_super(argc, argv); } };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i;F;: Escape;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I"CGI::Escape;Fo;;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i;F;: Util;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"CGI::Util;F; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i;F;:CGI;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"CGI;F;'@o; ;IC;[;o;u;[[@Nci;F;;;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"StringIO::VERSION;F;xI"&rb_str_new_cstr(STRINGIO_VERSION);To;4;5F;6;;;;&I"StringIO.new;F;7[[@90;[[@Nci;T;;E;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"Estatic VALUE strio_s_new(int argc, VALUE *argv, VALUE klass) { if (rb_block_given_p()) { VALUE cname = rb_obj_as_string(klass); rb_warn("%"PRIsVALUE"::new() does not take block; use %"PRIsVALUE"::open() instead", cname, cname); } return rb_class_new_instance_kw(argc, argv, klass, RB_PASS_CALLED_KEYWORDS); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO.open;F;7[[@90;[[@Nci;T;;;0;[;{;IC; "Equivalent to StringIO.new except that when it is called with a block, it yields with the new instance and closes it, and returns the result which returned from the block. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"open(string=""[, mode]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" strio;T;$@;![;"I"@yield [strio];T;#0;$@;.F;Bi;C0;7[[I" string;TI"""[, mode];T;$@;![;"I"Equivalent to StringIO.new except that when it is called with a block, it yields with the new instance and closes it, and returns the result which returned from the block. @overload open(string=""[, mode]) @yield [strio];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strio_s_open(int argc, VALUE *argv, VALUE klass) { VALUE obj = rb_class_new_instance_kw(argc, argv, klass, RB_PASS_CALLED_KEYWORDS); if (!rb_block_given_p()) return obj; return rb_ensure(rb_yield, obj, strio_finalize, obj); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#initialize;F;7[[@90;[[@Nci;T;;D;0;[;{;IC; "ACreates new StringIO instance from with _string_ and _mode_. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(string=""[, mode]);T;IC; ";T;[;![;"I";T;#0;$@ڨ;.F;Bi;C0;7[[I" string;TI"""[, mode];T;$@ڨ;![;"I"dCreates new StringIO instance from with _string_ and _mode_. @overload new(string=""[, mode]);T;#0;$@ڨ;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strio_initialize(int argc, VALUE *argv, VALUE self) { struct StringIO *ptr = check_strio(self); if (!ptr) { DATA_PTR(self) = ptr = strio_alloc(); } rb_call_super(0, 0); return strio_init(argc, argv, ptr, self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#initialize_copy;F;7[[I" orig;T0;[[@Ncis;T;;];0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2ir;3ir;%@;9I"static VALUE strio_copy(VALUE copy, VALUE orig) { struct StringIO *ptr; orig = rb_convert_type(orig, T_DATA, "StringIO", "to_strio"); if (copy == orig) return copy; ptr = StringIO(orig); if (check_strio(copy)) { strio_free(DATA_PTR(copy)); } DATA_PTR(copy) = ptr; RBASIC(copy)->flags &= ~STRIO_READWRITE; RBASIC(copy)->flags |= RBASIC(orig)->flags & STRIO_READWRITE; ++ptr->count; return copy; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#reopen;F;7[[@90;[[@Nci;T;;;0;[;{;IC; "jReinitializes the stream with the given other_StrIO or _string_ and _mode_ (see StringIO#new). ;T;[o;= ;>I" overload;F;?0;;;@0;:I"reopen(other_StrIO);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"other_StrIO;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"reopen(string, mode);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" string;T0[I" mode;T0;$@;![;"I"Reinitializes the stream with the given other_StrIO or _string_ and _mode_ (see StringIO#new). @overload reopen(other_StrIO) @overload reopen(string, mode);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strio_reopen(int argc, VALUE *argv, VALUE self) { rb_io_taint_check(self); if (argc == 1 && !RB_TYPE_P(*argv, T_STRING)) { return strio_copy(self, *argv); } return strio_init(argc, argv, StringIO(self), self); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#string;F;7[;[[@Nci;T;;;0;[;{;IC; "9Returns underlying String object, the subject of IO. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" string;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@);![;"I"@return [String];T;#0;$@);.F;Bi;C0;7[;$@);![;"I"_Returns underlying String object, the subject of IO. @overload string @return [String];T;#0;$@);.F;/o;0;1T;2i;3i;%@;9I"Ustatic VALUE strio_get_string(VALUE self) { return StringIO(self)->string; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#string=;F;7[[I" string;T0;[[@Nci;T;;;0;[;{;IC; "9Changes underlying String object, the subject of IO. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"string=(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@D;![;"I"@return [String];T;#0;$@D;.F;Bi;C0;7[[I" string;T0;$@D;![;"I"hChanges underlying String object, the subject of IO. @overload string=(string) @return [String];T;#0;$@D;.F;/o;0;1T;2i;3i;%@;9I"Qstatic VALUE strio_set_string(VALUE self, VALUE string) { struct StringIO *ptr = StringIO(self); rb_io_taint_check(self); ptr->flags &= ~FMODE_READWRITE; StringValue(string); ptr->flags = OBJ_FROZEN(string) ? FMODE_READABLE : FMODE_READWRITE; ptr->pos = 0; ptr->lineno = 0; return ptr->string = string; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#lineno;F;7[;[[@Nci;T;;L;0;[;{;IC; "-Returns the current line number. The stream must be opened for reading. +lineno+ counts the number of times +gets+ is called, rather than the number of newlines encountered. The two values will differ if +gets+ is called with a separator other than newline. See also the $. variable. ;T;[o;= ;>I" overload;F;?0;;L;@0;:I" lineno;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@c;![;"I"@return [Integer];T;#0;$@c;.F;Bi;C0;7[;$@c;![;"I"TReturns the current line number. The stream must be opened for reading. +lineno+ counts the number of times +gets+ is called, rather than the number of newlines encountered. The two values will differ if +gets+ is called with a separator other than newline. See also the $. variable. @overload lineno @return [Integer];T;#0;$@c;.F;/o;0;1T;2i;3i;%@;9I"_static VALUE strio_get_lineno(VALUE self) { return LONG2NUM(StringIO(self)->lineno); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#lineno=;F;7[[I" lineno;T0;[[@Nci;T;;;0;[;{;IC; "pManually sets the current line number to the given value. $. is updated only on the next read. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"lineno=(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@~;![;"I"@return [Integer];T;#0;$@~;.F;Bi;C0;7[[I" integer;T0;$@~;![;"I"Manually sets the current line number to the given value. $. is updated only on the next read. @overload lineno=(integer) @return [Integer];T;#0;$@~;.F;/o;0;1T;2i;3i;%@;9I"}static VALUE strio_set_lineno(VALUE self, VALUE lineno) { StringIO(self)->lineno = NUM2LONG(lineno); return lineno; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#binmode;F;7[;[[@Nci;T;;;0;[;{;IC; "2Puts stream into binary mode. See IO#binmode. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" binmode;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"GPuts stream into binary mode. See IO#binmode. @overload binmode;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strio_binmode(VALUE self) { struct StringIO *ptr = StringIO(self); rb_encoding *enc = rb_ascii8bit_encoding(); ptr->enc = enc; if (WRITABLE(self)) { rb_enc_associate(ptr->string, enc); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#close;F;7[;[[@Nci;T;;;0;[;{;IC; "Closes a StringIO. The stream is unavailable for any further data operations; an +IOError+ is raised if such an attempt is made. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" close;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Closes a StringIO. The stream is unavailable for any further data operations; an +IOError+ is raised if such an attempt is made. @overload close @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strio_close(VALUE self) { StringIO(self); RBASIC(self)->flags &= ~STRIO_READWRITE; return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#close_read;F;7[;[[@Nci;T;;;0;[;{;IC; "aCloses the read end of a StringIO. Will raise an +IOError+ if the receiver is not readable. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"close_read;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@Ω;![;"I"@return [nil];T;#0;$@Ω;.F;Bi;C0;7[;$@Ω;![;"I"Closes the read end of a StringIO. Will raise an +IOError+ if the receiver is not readable. @overload close_read @return [nil];T;#0;$@Ω;.F;/o;0;1T;2i ;3i;%@;9I"static VALUE strio_close_read(VALUE self) { struct StringIO *ptr = StringIO(self); if (!(ptr->flags & FMODE_READABLE)) { rb_raise(rb_eIOError, "closing non-duplex IO for reading"); } RBASIC(self)->flags &= ~STRIO_READABLE; return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#close_write;F;7[;[[@Nci&;T;;;0;[;{;IC; "dCloses the write end of a StringIO. Will raise an +IOError+ if the receiver is not writeable. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"close_write;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Closes the write end of a StringIO. Will raise an +IOError+ if the receiver is not writeable. @overload close_write @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i$;%@;9I"static VALUE strio_close_write(VALUE self) { struct StringIO *ptr = StringIO(self); if (!(ptr->flags & FMODE_WRITABLE)) { rb_raise(rb_eIOError, "closing non-duplex IO for writing"); } RBASIC(self)->flags &= ~STRIO_WRITABLE; return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#closed?;F;7[;[[@Nci7;T;;\;0;[;{;IC; "JReturns +true+ if the stream is completely closed, +false+ otherwise.;T;[o;= ;>I" overload;F;?0;;\;@0;:I" closed?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"rReturns +true+ if the stream is completely closed, +false+ otherwise. @overload closed? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i1;3i5;Bi;%@;9I"zstatic VALUE strio_closed(VALUE self) { StringIO(self); if (!CLOSED(self)) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#closed_read?;F;7[;[[@NciE;T;:closed_read?;0;[;{;IC; "EReturns +true+ if the stream is not readable, +false+ otherwise.;T;[o;= ;>I" overload;F;?0;; ;@0;:I"closed_read?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"rReturns +true+ if the stream is not readable, +false+ otherwise. @overload closed_read? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i?;3iC;Bi;%@;9I"{static VALUE strio_closed_read(VALUE self) { StringIO(self); if (READABLE(self)) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#closed_write?;F;7[;[[@NciS;T;:closed_write?;0;[;{;IC; "EReturns +true+ if the stream is not writable, +false+ otherwise.;T;[o;= ;>I" overload;F;?0;; ;@0;:I"closed_write?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@:;![;"I"@return [Boolean];T;#0;$@:;.F;Bi;C0;7[;$@:;![;"I"sReturns +true+ if the stream is not writable, +false+ otherwise. @overload closed_write? @return [Boolean];T;#0;$@:;.F;/o;0;1T;2iM;3iQ;Bi;%@;9I"|static VALUE strio_closed_write(VALUE self) { StringIO(self); if (WRITABLE(self)) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#eof;F;7[;[[@Ncik;T;;;0;[;{;IC; "Returns true if the stream is at the end of the data (underlying string). The stream must be opened for reading or an +IOError+ will be raised. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"eof;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@U;![;"I"@return [Boolean];T;#0;$@U;.F;Bi;C0;7[;$@Uo;= ;>I" overload;F;?0;;;@0;:I" eof?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@U;![;"I"@return [Boolean];T;#0;$@U;.F;Bi;C0;7[;$@U;![;"I"Returns true if the stream is at the end of the data (underlying string). The stream must be opened for reading or an +IOError+ will be raised. @overload eof @return [Boolean] @overload eof? @return [Boolean];T;#0;$@U;.F;/o;0;1T;2ic;3ij;%@;9I"istatic VALUE strio_eof(VALUE self) { if (strio_to_read(self)) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#eof?;F;7[;[[@Ncik;T;;;0;[;{;IC; "Returns true if the stream is at the end of the data (underlying string). The stream must be opened for reading or an +IOError+ will be raised.;T;[o;= ;>I" overload;F;?0;;;@0;:I"eof;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@};![;"I"@return [Boolean];T;#0;$@};.F;Bi;C0;7[;$@}o;= ;>I" overload;F;?0;;;@0;:I" eof?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@};![;"I"@return [Boolean];T;#0;$@};.F;Bi;C0;7[;$@};![;"@y;#0;$@};.F;/o;0;1T;2ic;3ij;Bi;%@;9I"istatic VALUE strio_eof(VALUE self) { if (strio_to_read(self)) return Qfalse; return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#fcntl;F;7[;[;F;;;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I" fcntl;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I" @overload fcntl;T;#0;$@;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"StringIO#flush;F;7[;[;F;;;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I" flush;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I" @overload flush;T;#0;$@;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"StringIO#fsync;F;7[;[;F;;;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I" fsync;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@ʪ;![;"I"@return [0];T;#0;$@ʪ;.F;Bi;C0;7[;$@ʪ;![;"I"# @overload fsync @return [0];T;#0;$@ʪ;.F;/o;0;1T;2i;3i;%@;;To;4;5F;6;;;;&I"StringIO#pos;F;7[;[[@Nci;T;;;0;[;{;IC; "+Returns the current offset (in bytes). ;T;[o;= ;>I" overload;F;?0;;;@0;:I"pos;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" tell;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"rReturns the current offset (in bytes). @overload pos @return [Integer] @overload tell @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"Ystatic VALUE strio_get_pos(VALUE self) { return LONG2NUM(StringIO(self)->pos); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#pos=;F;7[[I"pos;T0;[[@Nci;T;;;0;[;{;IC; ",Seeks to the given position (in bytes). ;T;[o;= ;>I" overload;F;?0;;;@0;:I"pos=(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[[I" integer;T0;$@ ;![;"I"ZSeeks to the given position (in bytes). @overload pos=(integer) @return [Integer];T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strio_set_pos(VALUE self, VALUE pos) { struct StringIO *ptr = StringIO(self); long p = NUM2LONG(pos); if (p < 0) { error_inval(0); } ptr->pos = p; return pos; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#rewind;F;7[;[[@Nci;T;;;0;[;{;IC; "PPositions the stream to the beginning of input, resetting +lineno+ to zero. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" rewind;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@);![;"I"@return [0];T;#0;$@);.F;Bi;C0;7[;$@);![;"I"qPositions the stream to the beginning of input, resetting +lineno+ to zero. @overload rewind @return [0];T;#0;$@);.F;/o;0;1T;2i;3i;%@;9I"static VALUE strio_rewind(VALUE self) { struct StringIO *ptr = StringIO(self); ptr->pos = 0; ptr->lineno = 0; return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#seek;F;7[[@90;[[@Nci;T;;;0;[;{;IC; "eSeeks to a given offset _amount_ in the stream according to the value of _whence_ (see IO#seek). ;T;[o;= ;>I" overload;F;?0;;;@0;:I""seek(amount, whence=SEEK_SET);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@D;![;"I"@return [0];T;#0;$@D;.F;Bi;C0;7[[I" amount;T0[I" whence;TI" SEEK_SET;T;$@D;![;"I"Seeks to a given offset _amount_ in the stream according to the value of _whence_ (see IO#seek). @overload seek(amount, whence=SEEK_SET) @return [0];T;#0;$@D;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strio_seek(int argc, VALUE *argv, VALUE self) { VALUE whence; struct StringIO *ptr = StringIO(self); long amount, offset; rb_scan_args(argc, argv, "11", NULL, &whence); amount = NUM2LONG(argv[0]); if (CLOSED(self)) { rb_raise(rb_eIOError, "closed stream"); } switch (NIL_P(whence) ? 0 : NUM2LONG(whence)) { case 0: offset = 0; break; case 1: offset = ptr->pos; break; case 2: offset = RSTRING_LEN(ptr->string); break; default: error_inval("invalid whence"); } if (amount > LONG_MAX - offset || amount + offset < 0) { error_inval(0); } ptr->pos = amount + offset; return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#sync;F;7[;[[@Nci+;T;;;0;[;{;IC; "Returns +true+ always. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" sync;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" true;T;$@e;![;"I"@return [true];T;#0;$@e;.F;Bi;C0;7[;$@e;![;"I"=Returns +true+ always. @overload sync @return [true];T;#0;$@e;.F;/o;0;1T;2i%;3i);%@;9I"Vstatic VALUE strio_get_sync(VALUE self) { StringIO(self); return Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#sync=;F;7[;[;F;;;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"sync=(boolean);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" boolean;T0;$@;![;"I"2 @overload sync=(boolean) @return [Boolean];T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;;To;4;5F;6;;;;&I"StringIO#tell;F;7[;[;F;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;;To;4;5F;6;;;;&I"StringIO#each;F;7[[@90;[[@Nci#;T;;;0;[;{;IC; "&strio.each_line(sep=$/, chomp: false) {|line| block } -> strio strio.each_line(limit, chomp: false) {|line| block } -> strio strio.each_line(sep, limit, chomp: false) {|line| block } -> strio strio.each_line(...) -> anEnumerator See IO#each. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"each(sep=$/, chomp: false);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@;![;"I"@yield [line];T;#0;$@;.F;Bi;C0;7[[I"sep;TI"$/;T[I" chomp:;TI" false;T;$@o;= ;>I" overload;F;?0;;;@0;:I"each(limit, chomp: false);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@;![;"I"@yield [line];T;#0;$@;.F;Bi;C0;7[[I" limit;T0[I" chomp:;TI" false;T;$@o;= ;>I" overload;F;?0;;;@0;:I"#each(sep, limit, chomp: false);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@;![;"I"@yield [line];T;#0;$@;.F;Bi;C0;7[[I"sep;T0[I" limit;T0[I" chomp:;TI" false;T;$@o;= ;>I" overload;F;?0;;;@0;:I"each(...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@;![;"I"@return [Enumerator];T;#0;$@;.F;Bi;C0;7[[I"...;T0;$@;![;"I" strio.each_line(sep=$/, chomp: false) {|line| block } -> strio strio.each_line(limit, chomp: false) {|line| block } -> strio strio.each_line(sep, limit, chomp: false) {|line| block } -> strio strio.each_line(...) -> anEnumerator See IO#each. @overload each(sep=$/, chomp: false) @yield [line] @overload each(limit, chomp: false) @yield [line] @overload each(sep, limit, chomp: false) @yield [line] @overload each(...) @return [Enumerator];T;#0;$@;.F;/o;0;1T;2i;3i$;%@;9I"static VALUE strio_each(int argc, VALUE *argv, VALUE self) { VALUE line; struct getline_arg arg; StringIO(self); RETURN_ENUMERATOR(self, argc, argv); if (prepare_getline_args(&arg, argc, argv)->limit == 0) { rb_raise(rb_eArgError, "invalid limit: 0 for each_line"); } while (!NIL_P(line = strio_getline(&arg, readable(self)))) { rb_yield(line); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#each_line;F;7[[@90;[[@Nci#;T;;x;0;[;{;IC; "&strio.each_line(sep=$/, chomp: false) {|line| block } -> strio strio.each_line(limit, chomp: false) {|line| block } -> strio strio.each_line(sep, limit, chomp: false) {|line| block } -> strio strio.each_line(...) -> anEnumerator See IO#each. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"each(sep=$/, chomp: false);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@;![;"I"@yield [line];T;#0;$@;.F;Bi;C0;7[[I"sep;TI"$/;T[I" chomp:;TI" false;T;$@o;= ;>I" overload;F;?0;;;@0;:I"each(limit, chomp: false);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@;![;"I"@yield [line];T;#0;$@;.F;Bi;C0;7[[I" limit;T0[I" chomp:;TI" false;T;$@o;= ;>I" overload;F;?0;;;@0;:I"#each(sep, limit, chomp: false);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@;![;"I"@yield [line];T;#0;$@;.F;Bi;C0;7[[I"sep;T0[I" limit;T0[I" chomp:;TI" false;T;$@o;= ;>I" overload;F;?0;;;@0;:I"each(...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@;![;"I"@return [Enumerator];T;#0;$@;.F;Bi;C0;7[[I"...;T0;$@;![;"@;#0;$@;.F;/o;0;1T;2i;3i$;%@;9I"static VALUE strio_each(int argc, VALUE *argv, VALUE self) { VALUE line; struct getline_arg arg; StringIO(self); RETURN_ENUMERATOR(self, argc, argv); if (prepare_getline_args(&arg, argc, argv)->limit == 0) { rb_raise(rb_eArgError, "invalid limit: 0 for each_line"); } while (!NIL_P(line = strio_getline(&arg, readable(self)))) { rb_yield(line); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#each_byte;F;7[;[[@Nci=;T;;y;0;[;{;IC; "See IO#each_byte. ;T;[o;= ;>I" overload;F;?0;;y;@0;:I"each_byte;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" byte;T;$@P;![;"I"@yield [byte];T;#0;$@P;.F;Bi;C0;7[;$@Po;= ;>I" overload;F;?0;;y;@0;:I"each_byte;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@P;![;"I"@return [Enumerator];T;#0;$@P;.F;Bi;C0;7[;$@P;![;"I"gSee IO#each_byte. @overload each_byte @yield [byte] @overload each_byte @return [Enumerator];T;#0;$@P;.F;/o;0;1T;2i6;3i<;%@;9I"static VALUE strio_each_byte(VALUE self) { struct StringIO *ptr; RETURN_ENUMERATOR(self, 0, 0); while ((ptr = strio_to_read(self)) != NULL) { char c = RSTRING_PTR(ptr->string)[ptr->pos++]; rb_yield(CHR2FIX(c)); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#each_char;F;7[;[[@Nci;T;;z;0;[;{;IC; "See IO#each_char. ;T;[o;= ;>I" overload;F;?0;;z;@0;:I"each_char;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" char;T;$@x;![;"I"@yield [char];T;#0;$@x;.F;Bi;C0;7[;$@xo;= ;>I" overload;F;?0;;z;@0;:I"each_char;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@x;![;"I"@return [Enumerator];T;#0;$@x;.F;Bi;C0;7[;$@x;![;"I"gSee IO#each_char. @overload each_char @yield [char] @overload each_char @return [Enumerator];T;#0;$@x;.F;/o;0;1T;2i ;3i;%@;9I"static VALUE strio_each_char(VALUE self) { VALUE c; RETURN_ENUMERATOR(self, 0, 0); while (!NIL_P(c = strio_getc(self))) { rb_yield(c); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#each_codepoint;F;7[;[[@Nci';T;;{;0;[;{;IC; "See IO#each_codepoint. ;T;[o;= ;>I" overload;F;?0;;{;@0;:I"each_codepoint;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"c;T;$@;![;"I"@yield [c];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;{;@0;:I"each_codepoint;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Enumerator;T;$@;![;"I"@return [Enumerator];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"sSee IO#each_codepoint. @overload each_codepoint @yield [c] @overload each_codepoint @return [Enumerator];T;#0;$@;.F;/o;0;1T;2i ;3i&;%@;9I"static VALUE strio_each_codepoint(VALUE self) { struct StringIO *ptr; rb_encoding *enc; unsigned int c; int n; RETURN_ENUMERATOR(self, 0, 0); ptr = readable(self); enc = get_enc(ptr); while ((ptr = strio_to_read(self)) != NULL) { c = rb_enc_codepoint_len(RSTRING_PTR(ptr->string)+ptr->pos, RSTRING_END(ptr->string), &n, enc); ptr->pos += n; rb_yield(UINT2NUM(c)); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#getc;F;7[;[[@NciQ;T;;;0;[;{;IC; "See IO#getc. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" getc;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@Ȭ;![;"I"@return [String, nil];T;#0;$@Ȭ;.F;Bi;C0;7[;$@Ȭ;![;"I":See IO#getc. @overload getc @return [String, nil];T;#0;$@Ȭ;.F;/o;0;1T;2iK;3iO;%@;9I"static VALUE strio_getc(VALUE self) { struct StringIO *ptr = readable(self); rb_encoding *enc = get_enc(ptr); VALUE str = ptr->string; long pos = ptr->pos; int len; char *p; if (pos >= RSTRING_LEN(str)) { return Qnil; } p = RSTRING_PTR(str)+pos; len = rb_enc_mbclen(p, RSTRING_END(str), enc); ptr->pos += len; return enc_subseq(str, pos, len, enc); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#ungetc;F;7[[I"c;T0;[[@Nci;T;;;0;[;{;IC; "Pushes back one character (passed as a parameter) such that a subsequent buffered read will return it. There is no limitation for multiple pushbacks including pushing back behind the beginning of the buffer string. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ungetc(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I" string;T0;$@;![;"I"Pushes back one character (passed as a parameter) such that a subsequent buffered read will return it. There is no limitation for multiple pushbacks including pushing back behind the beginning of the buffer string. @overload ungetc(string) @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strio_ungetc(VALUE self, VALUE c) { struct StringIO *ptr = readable(self); rb_encoding *enc, *enc2; check_modifiable(ptr); if (NIL_P(c)) return Qnil; if (RB_INTEGER_TYPE_P(c)) { int len, cc = NUM2INT(c); char buf[16]; enc = rb_enc_get(ptr->string); len = rb_enc_codelen(cc, enc); if (len <= 0) rb_enc_uint_chr(cc, enc); rb_enc_mbcput(cc, buf, enc); return strio_unget_bytes(ptr, buf, len); } else { SafeStringValue(c); enc = rb_enc_get(ptr->string); enc2 = rb_enc_get(c); if (enc != enc2 && enc != rb_ascii8bit_encoding()) { c = rb_str_conv_enc(c, enc2, enc); } strio_unget_bytes(ptr, RSTRING_PTR(c), RSTRING_LEN(c)); RB_GC_GUARD(c); return Qnil; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#ungetbyte;F;7[[I"c;T0;[[@Nci;T;;;0;[;{;IC; "See IO#ungetbyte ;T;[o;= ;>I" overload;F;?0;;;@0;:I"ungetbyte(fixnum);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I" fixnum;T0;$@;![;"I"CSee IO#ungetbyte @overload ungetbyte(fixnum) @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I",static VALUE strio_ungetbyte(VALUE self, VALUE c) { struct StringIO *ptr = readable(self); check_modifiable(ptr); if (NIL_P(c)) return Qnil; if (RB_INTEGER_TYPE_P(c)) { /* rb_int_and() not visible from exts */ VALUE v = rb_funcall(c, '&', 1, INT2FIX(0xff)); const char cc = NUM2INT(v) & 0xFF; strio_unget_bytes(ptr, &cc, 1); } else { long cl; SafeStringValue(c); cl = RSTRING_LEN(c); if (cl > 0) { strio_unget_bytes(ptr, RSTRING_PTR(c), cl); RB_GC_GUARD(c); } } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#getbyte;F;7[;[[@Ncij;T;;;0;[;{;IC; "See IO#getbyte. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" getbyte;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;TI"nil;T;$@";![;"I"@return [Fixnum, nil];T;#0;$@";.F;Bi;C0;7[;$@";![;"I"@See IO#getbyte. @overload getbyte @return [Fixnum, nil];T;#0;$@";.F;/o;0;1T;2id;3ih;%@;9I"static VALUE strio_getbyte(VALUE self) { struct StringIO *ptr = readable(self); int c; if (ptr->pos >= RSTRING_LEN(ptr->string)) { return Qnil; } c = RSTRING_PTR(ptr->string)[ptr->pos++]; return CHR2FIX(c); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#gets;F;7[[@90;[[@Nci;T;;;0;[;{;IC; "See IO#gets. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"gets(sep=$/, chomp: false);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@>;![;"I"@return [String, nil];T;#0;$@>;.F;Bi;C0;7[[I"sep;TI"$/;T[I" chomp:;TI" false;T;$@>o;= ;>I" overload;F;?0;;;@0;:I"gets(limit, chomp: false);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@>;![;"I"@return [String, nil];T;#0;$@>;.F;Bi;C0;7[[I" limit;T0[I" chomp:;TI" false;T;$@>o;= ;>I" overload;F;?0;;;@0;:I"#gets(sep, limit, chomp: false);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@>;![;"I"@return [String, nil];T;#0;$@>;.F;Bi;C0;7[[I"sep;T0[I" limit;T0[I" chomp:;TI" false;T;$@>;![;"I"See IO#gets. @overload gets(sep=$/, chomp: false) @return [String, nil] @overload gets(limit, chomp: false) @return [String, nil] @overload gets(sep, limit, chomp: false) @return [String, nil];T;#0;$@>;.F;/o;0;1T;2i;3i;%@;9I"\static VALUE strio_gets(int argc, VALUE *argv, VALUE self) { struct getline_arg arg; VALUE str; if (prepare_getline_args(&arg, argc, argv)->limit == 0) { struct StringIO *ptr = readable(self); return rb_enc_str_new(0, 0, get_enc(ptr)); } str = strio_getline(&arg, readable(self)); rb_lastline_set(str); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#readlines;F;7[[@90;[[@Nci>;T;;;0;[;{;IC; "See IO#readlines. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"$readlines(sep=$/, chomp: false);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"sep;TI"$/;T[I" chomp:;TI" false;T;$@o;= ;>I" overload;F;?0;;;@0;:I"#readlines(limit, chomp: false);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" limit;T0[I" chomp:;TI" false;T;$@o;= ;>I" overload;F;?0;;;@0;:I"(readlines(sep, limit, chomp: false);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"sep;T0[I" limit;T0[I" chomp:;TI" false;T;$@;![;"I"See IO#readlines. @overload readlines(sep=$/, chomp: false) @return [Array] @overload readlines(limit, chomp: false) @return [Array] @overload readlines(sep, limit, chomp: false) @return [Array];T;#0;$@;.F;/o;0;1T;2i6;3i>;%@;9I"static VALUE strio_readlines(int argc, VALUE *argv, VALUE self) { VALUE ary, line; struct getline_arg arg; StringIO(self); ary = rb_ary_new(); if (prepare_getline_args(&arg, argc, argv)->limit == 0) { rb_raise(rb_eArgError, "invalid limit: 0 for readlines"); } while (!NIL_P(line = strio_getline(&arg, readable(self)))) { rb_ary_push(ary, line); } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#read;F;7[[@90;[[@Nci;T;;q;0;[;{;IC; "See IO#read. ;T;[o;= ;>I" overload;F;?0;;q;@0;:I"read([length [, outbuf]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@ѭ;![;"I"@return [String, nil];T;#0;$@ѭ;.F;Bi;C0;7[[I"[length [, outbuf]];T0;$@ѭ;![;"I"OSee IO#read. @overload read([length [, outbuf]]) @return [String, nil];T;#0;$@ѭ;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strio_read(int argc, VALUE *argv, VALUE self) { struct StringIO *ptr = readable(self); VALUE str = Qnil; long len; int binary = 0; switch (argc) { case 2: str = argv[1]; if (!NIL_P(str)) { StringValue(str); rb_str_modify(str); } /* fall through */ case 1: if (!NIL_P(argv[0])) { len = NUM2LONG(argv[0]); if (len < 0) { rb_raise(rb_eArgError, "negative length %ld given", len); } if (len > 0 && ptr->pos >= RSTRING_LEN(ptr->string)) { if (!NIL_P(str)) rb_str_resize(str, 0); return Qnil; } binary = 1; break; } /* fall through */ case 0: len = RSTRING_LEN(ptr->string); if (len <= ptr->pos) { rb_encoding *enc = get_enc(ptr); if (NIL_P(str)) { str = rb_str_new(0, 0); } else { rb_str_resize(str, 0); } rb_enc_associate(str, enc); return str; } else { len -= ptr->pos; } break; default: rb_error_arity(argc, 0, 2); } if (NIL_P(str)) { rb_encoding *enc = binary ? rb_ascii8bit_encoding() : get_enc(ptr); str = strio_substr(ptr, ptr->pos, len, enc); } else { long rest = RSTRING_LEN(ptr->string) - ptr->pos; if (len > rest) len = rest; rb_str_resize(str, len); MEMCPY(RSTRING_PTR(str), RSTRING_PTR(ptr->string) + ptr->pos, char, len); if (binary) rb_enc_associate(str, rb_ascii8bit_encoding()); else rb_enc_copy(str, ptr->string); } ptr->pos += RSTRING_LEN(str); return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#write;F;7[[@90;[[@NciZ;T;;s;0;[;{;IC; "Appends the given string to the underlying buffer string. The stream must be opened for writing. If the argument is not a string, it will be converted to a string using to_s. Returns the number of bytes written. See IO#write. ;T;[o;= ;>I" overload;F;?0;;s;@0;:I"write(string, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I" string;T0[I"...;T0;$@o;= ;>I" overload;F;?0;;|;@0;:I"syswrite(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I" string;T0;$@;![;"I"RAppends the given string to the underlying buffer string. The stream must be opened for writing. If the argument is not a string, it will be converted to a string using to_s. Returns the number of bytes written. See IO#write. @overload write(string, ...) @return [Integer] @overload syswrite(string) @return [Integer];T;#0;$@;.F;/o;0;1T;2iP;3iY;%@;9I"static VALUE strio_write_m(int argc, VALUE *argv, VALUE self) { long len = 0; while (argc-- > 0) { /* StringIO can't exceed long limit */ len += strio_write(self, *argv++); } return LONG2NUM(len); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#putc;F;7[[I"ch;T0;[[@Nci;T;;;0;[;{;IC; "See IO#putc. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"putc(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I"obj;T0;$@;![;"I":See IO#putc. @overload putc(obj) @return [Object];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"=static VALUE strio_putc(VALUE self, VALUE ch) { struct StringIO *ptr = writable(self); VALUE str; check_modifiable(ptr); if (RB_TYPE_P(ch, T_STRING)) { str = rb_str_substr(ch, 0, 1); } else { char c = NUM2CHR(ch); str = rb_str_new(&c, 1); } strio_write(self, str); return ch; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#isatty;F;7[;[;F;;;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I" isatty;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@>;![;"I"@return [nil];T;#0;$@>;.F;Bi;C0;7[;$@>o;= ;>I" overload;F;?0;;;@0;:I" tty?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@>;![;"I"@return [nil];T;#0;$@>;.F;Bi;C0;7[;$@>;![;"I"F @overload isatty @return [nil] @overload tty? @return [nil];T;#0;$@>;.F;/o;0;1T;2i;3i";%@;;To;4;5F;6;;;;&I"StringIO#tty?;F;7[;[;F;;;;;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@c;![;"@;#0;$@c;Bi;%@;;To;4;5F;6;;;;&I"StringIO#pid;F;7[;[;F;;;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I"pid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@o;![;"I"@return [nil];T;#0;$@o;.F;Bi;C0;7[;$@o;![;"I"# @overload pid @return [nil];T;#0;$@o;.F;/o;0;1T;2i&;3i(;%@;;To;4;5F;6;;;;&I"StringIO#fileno;F;7[;[;F;;;;;[;{;IC; " ;T;[o;= ;>I" overload;F;?0;;;@0;:I" fileno;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"& @overload fileno @return [nil];T;#0;$@;.F;/o;0;1T;2i);3i+;%@;;To;4;5F;6;;;;&I"StringIO#size;F;7[;[[@Nci\;T;;;0;[;{;IC; "+Returns the size of the buffer string. ;T;[o;= ;>I" overload;F;?0;;b;@0;:I" length;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"uReturns the size of the buffer string. @overload length @return [Integer] @overload size @return [Integer];T;#0;$@;.F;/o;0;1T;2iU;3i[;%@;9I"static VALUE strio_size(VALUE self) { VALUE string = StringIO(self)->string; if (NIL_P(string)) { rb_raise(rb_eIOError, "not opened"); } return ULONG2NUM(RSTRING_LEN(string)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#length;F;7[;[[@Nci\;T;;b;0;[;{;IC; "+Returns the size of the buffer string. ;T;[o;= ;>I" overload;F;?0;;b;@0;:I" length;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@Ǯ;![;"I"@return [Integer];T;#0;$@Ǯ;.F;Bi;C0;7[;$@Ǯo;= ;>I" overload;F;?0;;;@0;:I" size;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@Ǯ;![;"I"@return [Integer];T;#0;$@Ǯ;.F;Bi;C0;7[;$@Ǯ;![;"@î;#0;$@Ǯ;.F;/o;0;1T;2iU;3i[;%@;9I"static VALUE strio_size(VALUE self) { VALUE string = StringIO(self)->string; if (NIL_P(string)) { rb_raise(rb_eIOError, "not opened"); } return ULONG2NUM(RSTRING_LEN(string)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#truncate;F;7[[I"len;T0;[[@Ncim;T;;_;0;[;{;IC; "cTruncates the buffer string to at most _integer_ bytes. The stream must be opened for writing. ;T;[o;= ;>I" overload;F;?0;;_;@0;:I"truncate(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@;![;"I"@return [0];T;#0;$@;.F;Bi;C0;7[[I" integer;T0;$@;![;"I"Truncates the buffer string to at most _integer_ bytes. The stream must be opened for writing. @overload truncate(integer) @return [0];T;#0;$@;.F;/o;0;1T;2if;3ik;%@;9I"Xstatic VALUE strio_truncate(VALUE self, VALUE len) { VALUE string = writable(self)->string; long l = NUM2LONG(len); long plen = RSTRING_LEN(string); if (l < 0) { error_inval("negative length"); } rb_str_resize(string, l); if (plen < l) { MEMZERO(RSTRING_PTR(string) + plen, char, l - plen); } return len; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#external_encoding;F;7[;[[@Nci;T;;;0;[;{;IC; "Returns the Encoding object that represents the encoding of the file. If the stream is write mode and no encoding is specified, returns +nil+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"external_encoding;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Encoding;T;$@ ;![;"I"@return [Encoding];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Returns the Encoding object that represents the encoding of the file. If the stream is write mode and no encoding is specified, returns +nil+. @overload external_encoding @return [Encoding];T;#0;$@ ;.F;/o;0;1T;2i};3i;%@;9I"static VALUE strio_external_encoding(VALUE self) { struct StringIO *ptr = StringIO(self); return rb_enc_from_encoding(get_enc(ptr)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#internal_encoding;F;7[;[[@Nci;T;;;0;[;{;IC; "fReturns the Encoding of the internal string if conversion is specified. Otherwise returns +nil+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"internal_encoding;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Encoding;T;$@(;![;"I"@return [Encoding];T;#0;$@(;.F;Bi;C0;7[;$@(;![;"I"Returns the Encoding of the internal string if conversion is specified. Otherwise returns +nil+. @overload internal_encoding @return [Encoding];T;#0;$@(;.F;/o;0;1T;2i;3i;%@;9I"Jstatic VALUE strio_internal_encoding(VALUE self) { return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"StringIO#set_encoding;F;7[[@90;[[@Nci;T;;;0;[;{;IC; "Specify the encoding of the StringIO as ext_enc. Use the default external encoding if ext_enc is nil. 2nd argument int_enc and optional hash opt argument are ignored; they are for API compatibility to IO. ;T;[o;= ;>I" overload;F;?0;;;@0;:I",set_encoding(ext_enc, [int_enc[, opt]]);T;IC; ";T;[;![;"I";T;#0;$@C;.F;Bi;C0;7[[I" ext_enc;T0[I"[int_enc[, opt]];T0;$@C;![;"I"Specify the encoding of the StringIO as ext_enc. Use the default external encoding if ext_enc is nil. 2nd argument int_enc and optional hash opt argument are ignored; they are for API compatibility to IO. @overload set_encoding(ext_enc, [int_enc[, opt]]);T;#0;$@C;.F;/o;0;1T;2i;3i;%@;9I"static VALUE strio_set_encoding(int argc, VALUE *argv, VALUE self) { rb_encoding* enc; struct StringIO *ptr = StringIO(self); VALUE ext_enc, int_enc, opt; argc = rb_scan_args(argc, argv, "11:", &ext_enc, &int_enc, &opt); if (NIL_P(ext_enc)) { enc = rb_default_external_encoding(); } else { enc = rb_to_encoding(ext_enc); } ptr->enc = enc; if (WRITABLE(self)) { rb_enc_associate(ptr->string, enc); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!StringIO#set_encoding_by_bom;F;7[;[[@Nci;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@^;%@;9I"static VALUE strio_set_encoding_by_bom(VALUE self) { struct StringIO *ptr = StringIO(self); if (!set_encoding_by_bom(ptr)) return Qnil; return rb_enc_from_encoding(ptr->enc); };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[@y,@c@5e; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Nci;F;: StringIO;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I" StringIO;F;'@o;;IC;[o; ;IC;[ o;4;5F;6;;;;&I""Racc::Parser#_racc_do_parse_c;F;7[[I"arg;T0[I" sysdebug;T0;[[I"ext/racc/cparse/cparse.c;Ti;T;:_racc_do_parse_c;0;[;{;IC; " ;T;[;![;"@;#0;$@};%@{;9I"static VALUE racc_cparse(VALUE parser, VALUE arg, VALUE sysdebug) { VALUE vparams; struct cparse_params *v; vparams = TypedData_Make_Struct(CparseParams, struct cparse_params, &cparse_params_type, v); D_puts("starting cparse"); v->sys_debug = RTEST(sysdebug); vparams = initialize_params(vparams, parser, arg, Qnil, Qnil); v->lex_is_iterator = FALSE; parse_main(v, Qnil, Qnil, 0); RB_GC_GUARD(vparams); return v->retval; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Racc::Parser#_racc_yyparse_c;F;7[ [I" lexer;T0[I" lexmid;T0[I"arg;T0[I" sysdebug;T0;[[@i;T;:_racc_yyparse_c;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@{;9I"static VALUE racc_yyparse(VALUE parser, VALUE lexer, VALUE lexmid, VALUE arg, VALUE sysdebug) { VALUE vparams; struct cparse_params *v; vparams = TypedData_Make_Struct(CparseParams, struct cparse_params, &cparse_params_type, v); v->sys_debug = RTEST(sysdebug); D_puts("start C yyparse"); vparams = initialize_params(vparams, parser, arg, lexer, lexmid); v->lex_is_iterator = TRUE; D_puts("params initialized"); parse_main(v, Qnil, Qnil, 0); call_lexer(v); if (!v->fin) { rb_raise(rb_eArgError, "%s() is finished before EndOfToken", rb_id2name(v->lexmid)); } RB_GC_GUARD(vparams); return v->retval; };T;:I"static VALUE;T;;To;u;[[@iG;F;: Racc_Runtime_Core_Version_C;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@{;&I".Racc::Parser::Racc_Runtime_Core_Version_C;F;xI"rb_str_new2(RACC_VERSION);To;u;[[@iI;F;:Racc_Runtime_Core_Id_C;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@{;&I")Racc::Parser::Racc_Runtime_Core_Id_C;F;xI"Prb_str_new2("$originalId: cparse.c,v 1.8 2006/07/06 11:39:46 aamine Exp $");T; @{; IC;[; @{; IC;[; @{; IC;{;IC;{;T;IC;{;T;T;{;[;[[@iC;F;; ;;;;;[;{;IC; " ;T;[;![;"@;#0;$@{;%@y;&I"Racc::Parser;F;'@o; ;IC;[; @ů; IC;[; @ů; IC;[; @ů; IC;{;IC;{;T;IC;{;T;T;{;[;[[@iL;F;:CparseParams;;;;;[;{;IC; " ;T;[;![;"@;#0;$@ů;%@y;&I"Racc::CparseParams;F;'@; @y; IC;[; @y; IC;[; @y; IC;{;IC;{;T;IC;{;T;T;{;[;[[@iB;F;: Racc;;;;;[;{;IC; " ;T;[;![;"@;#0;$@y;%@;&I" Racc;Fo;;IC;[o;;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"ext/win32/resolv/resolv.c;Ti=;F;: Resolv;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I"Win32::Resolv;F; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i<;F;;;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I" Win32;Fo;;IC;[o;u;[[I"ext/fcntl/fcntl.c;TiS;F;: F_DUPFD;;w;;;[;{;IC; "-Duplicate a file descriptor to the minimum unused file descriptor greater than or equal to the argument. The close-on-exec flag of the duplicated file descriptor is set. (Ruby uses F_DUPFD_CLOEXEC internally if available to avoid race condition. F_SETFD is used if F_DUPFD_CLOEXEC is not available.) ;T;[;![;"I"/ Duplicate a file descriptor to the minimum unused file descriptor greater than or equal to the argument. The close-on-exec flag of the duplicated file descriptor is set. (Ruby uses F_DUPFD_CLOEXEC internally if available to avoid race condition. F_SETFD is used if F_DUPFD_CLOEXEC is not available.) ;T;#0;$@ ;.F;/o;0;1T;2iJ;3iQ;%@;&I"Fcntl::F_DUPFD;F;xI"INT2NUM(F_DUPFD);To;u;[[@ iZ;F;: F_GETFD;;w;;;[;{;IC; "6Read the close-on-exec flag of a file descriptor. ;T;[;![;"I"8 Read the close-on-exec flag of a file descriptor. ;T;#0;$@;.F;/o;0;1T;2iV;3iX;%@;&I"Fcntl::F_GETFD;F;xI"INT2NUM(F_GETFD);To;u;[[@ ib;F;: F_GETLK;;w;;;[;{;IC; "]Determine whether a given region of a file is locked. This uses one of the F_*LK flags. ;T;[;![;"I"_ Determine whether a given region of a file is locked. This uses one of the F_*LK flags. ;T;#0;$@#;.F;/o;0;1T;2i];3i`;%@;&I"Fcntl::F_GETLK;F;xI"INT2NUM(F_GETLK);To;u;[[@ ii;F;: F_SETFD;;w;;;[;{;IC; "5Set the close-on-exec flag of a file descriptor. ;T;[;![;"I"7 Set the close-on-exec flag of a file descriptor. ;T;#0;$@/;.F;/o;0;1T;2ie;3ig;%@;&I"Fcntl::F_SETFD;F;xI"INT2NUM(F_SETFD);To;u;[[@ iq;F;: F_GETFL;;w;;;[;{;IC; "OGet the file descriptor flags. This will be one or more of the O_* flags. ;T;[;![;"I"Q Get the file descriptor flags. This will be one or more of the O_* flags. ;T;#0;$@;;.F;/o;0;1T;2il;3io;%@;&I"Fcntl::F_GETFL;F;xI"INT2NUM(F_GETFL);To;u;[[@ iy;F;: F_SETFL;;w;;;[;{;IC; "OSet the file descriptor flags. This will be one or more of the O_* flags. ;T;[;![;"I"Q Set the file descriptor flags. This will be one or more of the O_* flags. ;T;#0;$@G;.F;/o;0;1T;2it;3iw;%@;&I"Fcntl::F_SETFL;F;xI"INT2NUM(F_SETFL);To;u;[[@ i|;F;: F_SETLK;;w;;;[;{;IC; "NAcquire a lock on a region of a file. This uses one of the F_*LCK flags. ;T;[;![;"I"P Acquire a lock on a region of a file. This uses one of the F_*LCK flags. ;T;#0;$@S;.F;/o;0;1T;2i|;3i;%@;&I"Fcntl::F_SETLK;F;xI"INT2NUM(F_SETLK);To;u;[[@ i;F;: F_SETLKW;;w;;;[;{;IC; "cAcquire a lock on a region of a file, waiting if necessary. This uses one of the F_*LCK flags ;T;[;![;"I"e Acquire a lock on a region of a file, waiting if necessary. This uses one of the F_*LCK flags ;T;#0;$@_;.F;/o;0;1T;2i;3i;%@;&I"Fcntl::F_SETLKW;F;xI"INT2NUM(F_SETLKW);To;u;[[@ i;F;:FD_CLOEXEC;;w;;;[;{;IC; ")the value of the close-on-exec flag. ;T;[;![;"I"+ the value of the close-on-exec flag. ;T;#0;$@k;.F;/o;0;1T;2i;3i;%@;&I"Fcntl::FD_CLOEXEC;F;xI"INT2NUM(FD_CLOEXEC);To;u;[[@ i;F;: F_RDLCK;;w;;;[;{;IC; "%Read lock for a region of a file ;T;[;![;"I"' Read lock for a region of a file ;T;#0;$@w;.F;/o;0;1T;2i;3i;%@;&I"Fcntl::F_RDLCK;F;xI"INT2NUM(F_RDLCK);To;u;[[@ i;F;: F_UNLCK;;w;;;[;{;IC; "'Remove lock for a region of a file ;T;[;![;"I") Remove lock for a region of a file ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fcntl::F_UNLCK;F;xI"INT2NUM(F_UNLCK);To;u;[[@ i;F;: F_WRLCK;;w;;;[;{;IC; "&Write lock for a region of a file ;T;[;![;"I"( Write lock for a region of a file ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fcntl::F_WRLCK;F;xI"INT2NUM(F_WRLCK);To;u;[[@ i;F;:F_SETPIPE_SZ;;w;;;[;{;IC; "PChange the capacity of the pipe referred to by fd to be at least arg bytes. ;T;[;![;"I"R Change the capacity of the pipe referred to by fd to be at least arg bytes. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fcntl::F_SETPIPE_SZ;F;xI"INT2NUM(F_SETPIPE_SZ);To;u;[[@ i;F;:F_GETPIPE_SZ;;w;;;[;{;IC; "PReturn (as the function result) the capacity of the pipe referred to by fd. ;T;[;![;"I"R Return (as the function result) the capacity of the pipe referred to by fd. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fcntl::F_GETPIPE_SZ;F;xI"INT2NUM(F_GETPIPE_SZ);To;u;[[@ i;F;: O_CREAT;;w;;;[;{;IC; "(Create the file if it doesn't exist ;T;[;![;"I"* Create the file if it doesn't exist ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fcntl::O_CREAT;F;xI"INT2NUM(O_CREAT);To;u;[[@ i;F;: O_EXCL;;w;;;[;{;IC; "/Used with O_CREAT, fail if the file exists ;T;[;![;"I"1 Used with O_CREAT, fail if the file exists ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fcntl::O_EXCL;F;xI"INT2NUM(O_EXCL);To;u;[[@ i;F;: O_NOCTTY;;w;;;[;{;IC; "5Open TTY without it becoming the controlling TTY ;T;[;![;"I"7 Open TTY without it becoming the controlling TTY ;T;#0;$@˰;.F;/o;0;1T;2i;3i;%@;&I"Fcntl::O_NOCTTY;F;xI"INT2NUM(O_NOCTTY);To;u;[[@ i;F;: O_TRUNC;;w;;;[;{;IC; "Truncate the file on open ;T;[;![;"I" Truncate the file on open ;T;#0;$@װ;.F;/o;0;1T;2i;3i;%@;&I"Fcntl::O_TRUNC;F;xI"INT2NUM(O_TRUNC);To;u;[[@ i;F;: O_APPEND;;w;;;[;{;IC; "!Open the file in append mode ;T;[;![;"I"# Open the file in append mode ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fcntl::O_APPEND;F;xI"INT2NUM(O_APPEND);To;u;[[@ i;F;:O_NONBLOCK;;w;;;[;{;IC; "'Open the file in non-blocking mode ;T;[;![;"I") Open the file in non-blocking mode ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fcntl::O_NONBLOCK;F;xI"INT2NUM(O_NONBLOCK);To;u;[[@ i;F;: O_NDELAY;;w;;;[;{;IC; "'Open the file in non-blocking mode ;T;[;![;"I") Open the file in non-blocking mode ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fcntl::O_NDELAY;F;xI"INT2NUM(O_NDELAY);To;u;[[@ i;F;: O_RDONLY;;w;;;[;{;IC; "$Open the file in read-only mode ;T;[;![;"I"& Open the file in read-only mode ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fcntl::O_RDONLY;F;xI"INT2NUM(O_RDONLY);To;u;[[@ i;F;: O_RDWR;;w;;;[;{;IC; "%Open the file in read-write mode ;T;[;![;"I"' Open the file in read-write mode ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fcntl::O_RDWR;F;xI"INT2NUM(O_RDWR);To;u;[[@ i;F;: O_WRONLY;;w;;;[;{;IC; "&Open the file in write-only mode. ;T;[;![;"I"( Open the file in write-only mode. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Fcntl::O_WRONLY;F;xI"INT2NUM(O_WRONLY);To;u;[[@ i[@ i;F;:O_ACCMODE;;w;;;[;{;IC; ")Mask to extract the read/write flags ;T;[;![;"I"+ Mask to extract the read/write flags ;T;#0;$@+;.F;/o;0;1T;2i;3i;%@;&I"Fcntl::O_ACCMODE;F;xI"*INT2FIX(O_RDONLY | O_WRONLY | O_RDWR);T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ iH;F;: Fcntl;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I" Fcntl;F@GHo; ;IC;[Yo;4;5F;6;;;;&I"Pathname#initialize;F;7[[I"arg;T0;[[@Zid;T;;D;0;[;{;IC; "Create a Pathname object from the given String (or String-like object). If +path+ contains a NULL character (\0), an ArgumentError is raised. ;T;[;![;"I"Create a Pathname object from the given String (or String-like object). If +path+ contains a NULL character (\0), an ArgumentError is raised. ;T;#0;$@I;.F;/o;0;1T;2i`;3ib;%@G;9I"static VALUE path_initialize(VALUE self, VALUE arg) { VALUE str; if (RB_TYPE_P(arg, T_STRING)) { str = arg; } else { str = rb_check_funcall(arg, id_to_path, 0, NULL); if (str == Qundef) str = arg; StringValue(str); } if (memchr(RSTRING_PTR(str), '\0', RSTRING_LEN(str))) rb_raise(rb_eArgError, "pathname contains null byte"); str = rb_obj_dup(str); set_strpath(self, str); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#freeze;F;7[;[[@Zi|;T;;f;0;[;{;IC; "/Freezes this Pathname. See Object.freeze. ;T;[o;= ;>I" overload;F;?0;;f;@0;:I" freeze;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@Y;![;"I"@return [Object];T;#0;$@Y;.F;Bi;C0;7[;$@Y;![;"I"UFreezes this Pathname. See Object.freeze. @overload freeze @return [Object];T;#0;$@Y;.F;/o;0;1T;2iy;3i;%@G;9I"}static VALUE path_freeze(VALUE self) { rb_call_super(0, 0); rb_str_freeze(get_strpath(self)); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#taint;F;7[;[[@Zi;T;;`;0;[;{;IC; "RReturns pathname. This method is deprecated and will be removed in Ruby 3.2. ;T;[o;= ;>I" overload;F;?0;;`;@0;:I" taint;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@t;![;"I"@return [Object];T;#0;$@t;.F;Bi;C0;7[;$@t;![;"I"wReturns pathname. This method is deprecated and will be removed in Ruby 3.2. @overload taint @return [Object];T;#0;$@t;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_taint(VALUE self) { rb_warn("Pathname#taint is deprecated and will be removed in Ruby 3.2."); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#untaint;F;7[;[[@Zi;T;;b;0;[;{;IC; "RReturns pathname. This method is deprecated and will be removed in Ruby 3.2. ;T;[o;= ;>I" overload;F;?0;;b;@0;:I" untaint;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"yReturns pathname. This method is deprecated and will be removed in Ruby 3.2. @overload untaint @return [Object];T;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_untaint(VALUE self) { rb_warn("Pathname#untaint is deprecated and will be removed in Ruby 3.2."); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#==;F;7[[I" other;T0;[[@Zi;T;;F;0;[;{;IC; "Compare this pathname with +other+. The comparison is string-based. Be aware that two different paths (foo.txt and ./foo.txt) can refer to the same file. ;T;[;![;"I"Compare this pathname with +other+. The comparison is string-based. Be aware that two different paths (foo.txt and ./foo.txt) can refer to the same file. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_eq(VALUE self, VALUE other) { if (!rb_obj_is_kind_of(other, rb_cPathname)) return Qfalse; return rb_str_equal(get_strpath(self), get_strpath(other)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#===;F;7[[I" other;T0;[[@Zi;T;;S;0;[;{;IC; "Compare this pathname with +other+. The comparison is string-based. Be aware that two different paths (foo.txt and ./foo.txt) can refer to the same file. ;T;[;![;"@;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_eq(VALUE self, VALUE other) { if (!rb_obj_is_kind_of(other, rb_cPathname)) return Qfalse; return rb_str_equal(get_strpath(self), get_strpath(other)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#eql?;F;7[[I" other;T0;[[@Zi;T;;V;0;[;{;IC; "Compare this pathname with +other+. The comparison is string-based. Be aware that two different paths (foo.txt and ./foo.txt) can refer to the same file.;T;[o;A ;>I" return;F;?@;0;@[@L;$@ɱ;![;"@;#0;$@ɱ;.F;/o;0;1T;2i;3i;Bi;%@G;9I"static VALUE path_eq(VALUE self, VALUE other) { if (!rb_obj_is_kind_of(other, rb_cPathname)) return Qfalse; return rb_str_equal(get_strpath(self), get_strpath(other)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#<=>;F;7[[I" other;T0;[[@Zi;T;;Y;0;[;{;IC; "Provides a case-sensitive comparison operator for pathnames. Pathname.new('/usr') <=> Pathname.new('/usr/bin') #=> -1 Pathname.new('/usr/bin') <=> Pathname.new('/usr/bin') #=> 0 Pathname.new('/usr/bin') <=> Pathname.new('/USR/BIN') #=> 1 It will return +-1+, +0+ or +1+ depending on the value of the left argument relative to the right argument. Or it will return +nil+ if the arguments are not comparable. ;T;[;![;"I"Provides a case-sensitive comparison operator for pathnames. Pathname.new('/usr') <=> Pathname.new('/usr/bin') #=> -1 Pathname.new('/usr/bin') <=> Pathname.new('/usr/bin') #=> 0 Pathname.new('/usr/bin') <=> Pathname.new('/USR/BIN') #=> 1 It will return +-1+, +0+ or +1+ depending on the value of the left argument relative to the right argument. Or it will return +nil+ if the arguments are not comparable. ;T;#0;$@۱;.F;/o;0;1T;2i;3i;%@G;9I"#static VALUE path_cmp(VALUE self, VALUE other) { VALUE s1, s2; char *p1, *p2; char *e1, *e2; if (!rb_obj_is_kind_of(other, rb_cPathname)) return Qnil; s1 = get_strpath(self); s2 = get_strpath(other); p1 = RSTRING_PTR(s1); p2 = RSTRING_PTR(s2); e1 = p1 + RSTRING_LEN(s1); e2 = p2 + RSTRING_LEN(s2); while (p1 < e1 && p2 < e2) { int c1, c2; c1 = (unsigned char)*p1++; c2 = (unsigned char)*p2++; if (c1 == '/') c1 = '\0'; if (c2 == '/') c2 = '\0'; if (c1 != c2) { if (c1 < c2) return INT2FIX(-1); else return INT2FIX(1); } } if (p1 < e1) return INT2FIX(1); if (p2 < e2) return INT2FIX(-1); return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#hash;F;7[;[[@Zi;T;;X;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"^static VALUE path_hash(VALUE self) { return ST2FIX(rb_str_hash(get_strpath(self))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#to_s;F;7[;[[@Zi;T;;G;0;[;{;IC; "mReturn the path as a String. to_path is implemented so Pathname objects are usable with File.open, etc. ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;n;@0;:I" to_path;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Return the path as a String. to_path is implemented so Pathname objects are usable with File.open, etc. @overload to_s @return [String] @overload to_path @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"Ustatic VALUE path_to_s(VALUE self) { return rb_obj_dup(get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#to_path;F;7[;[[@Zi;T;;n;0;[;{;IC; "mReturn the path as a String. to_path is implemented so Pathname objects are usable with File.open, etc. ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@!;![;"I"@return [String];T;#0;$@!;.F;Bi;C0;7[;$@!o;= ;>I" overload;F;?0;;n;@0;:I" to_path;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@!;![;"I"@return [String];T;#0;$@!;.F;Bi;C0;7[;$@!;![;"@;#0;$@!;.F;/o;0;1T;2i;3i;%@G;9I"Ustatic VALUE path_to_s(VALUE self) { return rb_obj_dup(get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#inspect;F;7[;[[@Zi;T;;J;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@H;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_inspect(VALUE self) { const char *c = rb_obj_classname(self); VALUE str = get_strpath(self); return rb_sprintf("#<%s:%"PRIsVALUE">", c, str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#sub;F;7[[@90;[[@Zi;T;; ;0;[;{;IC; "Return a pathname which is substituted by String#sub. path1 = Pathname.new('/usr/bin/perl') path1.sub('perl', 'ruby') #=> # ;T;[;![;"I"Return a pathname which is substituted by String#sub. path1 = Pathname.new('/usr/bin/perl') path1.sub('perl', 'ruby') #=> # ;T;#0;$@V;.F;/o;0;1T;2i;3i;%@G;9I"Dstatic VALUE path_sub(int argc, VALUE *argv, VALUE self) { VALUE str = get_strpath(self); if (rb_block_given_p()) { str = rb_block_call(str, id_sub, argc, argv, 0, 0); } else { str = rb_funcallv(str, id_sub, argc, argv); } return rb_class_new_instance(1, &str, rb_obj_class(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#sub_ext;F;7[[I" repl;T0;[[@Zi;T;: sub_ext;0;[;{;IC; "Return a pathname with +repl+ added as a suffix to the basename. If self has no extension part, +repl+ is appended. Pathname.new('/usr/bin/shutdown').sub_ext('.rb') #=> # ;T;[;![;"I"Return a pathname with +repl+ added as a suffix to the basename. If self has no extension part, +repl+ is appended. Pathname.new('/usr/bin/shutdown').sub_ext('.rb') #=> # ;T;#0;$@e;.F;/o;0;1T;2i;3i;%@G;9I"2static VALUE path_sub_ext(VALUE self, VALUE repl) { VALUE str = get_strpath(self); VALUE str2; long extlen; const char *ext; const char *p; StringValue(repl); p = RSTRING_PTR(str); extlen = RSTRING_LEN(str); ext = ruby_enc_find_extname(p, &extlen, rb_enc_get(str)); if (ext == NULL) { ext = p + RSTRING_LEN(str); } else if (extlen <= 1) { ext += extlen; } str2 = rb_str_subseq(str, 0, ext-p); rb_str_append(str2, repl); return rb_class_new_instance(1, &str2, rb_obj_class(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#realpath;F;7[[@90;[[@Zi?;T;;c;0;[;{;IC; "Returns the real (absolute) pathname for +self+ in the actual filesystem. Does not contain symlinks or useless dots, +..+ and +.+. All components of the pathname must exist when this method is called. ;T;[;![;"I"Returns the real (absolute) pathname for +self+ in the actual filesystem. Does not contain symlinks or useless dots, +..+ and +.+. All components of the pathname must exist when this method is called. ;T;#0;$@u;.F;/o;0;1T;2i5;3i=;%@G;9I"static VALUE path_realpath(int argc, VALUE *argv, VALUE self) { VALUE basedir, str; rb_scan_args(argc, argv, "01", &basedir); str = rb_funcall(rb_cFile, id_realpath, 2, get_strpath(self), basedir); return rb_class_new_instance(1, &str, rb_obj_class(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#realdirpath;F;7[[@90;[[@ZiO;T;;d;0;[;{;IC; "Returns the real (absolute) pathname of +self+ in the actual filesystem. Does not contain symlinks or useless dots, +..+ and +.+. The last component of the real pathname can be nonexistent. ;T;[;![;"I"Returns the real (absolute) pathname of +self+ in the actual filesystem. Does not contain symlinks or useless dots, +..+ and +.+. The last component of the real pathname can be nonexistent. ;T;#0;$@;.F;/o;0;1T;2iH;3iM;%@G;9I"static VALUE path_realdirpath(int argc, VALUE *argv, VALUE self) { VALUE basedir, str; rb_scan_args(argc, argv, "01", &basedir); str = rb_funcall(rb_cFile, id_realdirpath, 2, get_strpath(self), basedir); return rb_class_new_instance(1, &str, rb_obj_class(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#each_line;F;7[[@90;[[@Zib;T;;x;0;[;{;IC; "MIterates over each line in the file and yields a String object for each. ;T;[ o;= ;>I" overload;F;?0;;x;@0;:I"each_line;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@;![;"I"@yield [line];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;x;@0;:I"$each_line(sep=$/ [, open_args]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I" @yield [line] @return [nil];T;#0;$@;.F;Bi;C0;7[[I"sep;TI"$/[, open_args];T;$@o;= ;>I" overload;F;?0;;x;@0;:I"#each_line(limit [, open_args]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I" @yield [line] @return [nil];T;#0;$@;.F;Bi;C0;7[[I"limit[, open_args];T0;$@o;= ;>I" overload;F;?0;;x;@0;:I"(each_line(sep, limit [, open_args]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I" @yield [line] @return [nil];T;#0;$@;.F;Bi;C0;7[[I"sep;T0[I"limit[, open_args];T0;$@o;= ;>I" overload;F;?0;;x;@0;:I"each_line(...);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"...;T0;$@;![;"I"hIterates over each line in the file and yields a String object for each. @overload each_line @yield [line] @overload each_line(sep=$/ [, open_args]) @yield [line] @return [nil] @overload each_line(limit [, open_args]) @yield [line] @return [nil] @overload each_line(sep, limit [, open_args]) @yield [line] @return [nil] @overload each_line(...);T;#0;$@;.F;/o;0;1T;2iX;3if;%@G;9I"static VALUE path_each_line(int argc, VALUE *argv, VALUE self) { VALUE args[4]; int n; args[0] = get_strpath(self); n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]); if (rb_block_given_p()) { return rb_block_call_kw(rb_cFile, id_foreach, 1+n, args, 0, 0, RB_PASS_CALLED_KEYWORDS); } else { return rb_funcallv_kw(rb_cFile, id_foreach, 1+n, args, RB_PASS_CALLED_KEYWORDS); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#read;F;7[[@90;[[@Zi|;T;;q;0;[;{;IC; "YReturns all data from the file, or the first +N+ bytes if specified. See File.read. ;T;[o;= ;>I" overload;F;?0;;q;@0;:I"read([length [, offset]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I"[length [, offset]];T0;$@o;= ;>I" overload;F;?0;;q;@0;:I")read([length [, offset]], open_args);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[[I"[length [, offset]];T0[I"open_args;T0;$@;![;"I"Returns all data from the file, or the first +N+ bytes if specified. See File.read. @overload read([length [, offset]]) @return [String] @overload read([length [, offset]], open_args) @return [String];T;#0;$@;.F;/o;0;1T;2ir;3i{;%@G;9I"static VALUE path_read(int argc, VALUE *argv, VALUE self) { VALUE args[4]; int n; args[0] = get_strpath(self); n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]); return rb_funcallv_kw(rb_cFile, id_read, 1+n, args, RB_PASS_CALLED_KEYWORDS); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#binread;F;7[[@90;[[@Zi;T;;r;0;[;{;IC; "[Returns all the bytes from the file, or the first +N+ if specified. See File.binread. ;T;[o;= ;>I" overload;F;?0;;r;@0;:I"!binread([length [, offset]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@';![;"I"@return [String];T;#0;$@';.F;Bi;C0;7[[I"[length [, offset]];T0;$@';![;"I"Returns all the bytes from the file, or the first +N+ if specified. See File.binread. @overload binread([length [, offset]]) @return [String];T;#0;$@';.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_binread(int argc, VALUE *argv, VALUE self) { VALUE args[3]; int n; args[0] = get_strpath(self); n = rb_scan_args(argc, argv, "02", &args[1], &args[2]); return rb_funcallv(rb_cFile, id_binread, 1+n, args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#readlines;F;7[[@90;[[@Zi;T;;;0;[;{;IC; ">Returns all the lines from the file. See File.readlines. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"$readlines(sep=$/ [, open_args]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@E;![;"I"@return [Array];T;#0;$@E;.F;Bi;C0;7[[I"sep;TI"$/[, open_args];T;$@Eo;= ;>I" overload;F;?0;;;@0;:I"#readlines(limit [, open_args]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@E;![;"I"@return [Array];T;#0;$@E;.F;Bi;C0;7[[I"limit[, open_args];T0;$@Eo;= ;>I" overload;F;?0;;;@0;:I"(readlines(sep, limit [, open_args]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@E;![;"I"@return [Array];T;#0;$@E;.F;Bi;C0;7[[I"sep;T0[I"limit[, open_args];T0;$@E;![;"I"Returns all the lines from the file. See File.readlines. @overload readlines(sep=$/ [, open_args]) @return [Array] @overload readlines(limit [, open_args]) @return [Array] @overload readlines(sep, limit [, open_args]) @return [Array];T;#0;$@E;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_readlines(int argc, VALUE *argv, VALUE self) { VALUE args[4]; int n; args[0] = get_strpath(self); n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]); return rb_funcallv_kw(rb_cFile, id_readlines, 1+n, args, RB_PASS_CALLED_KEYWORDS); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#write;F;7[[@90;[[@Zi;T;;s;0;[;{;IC; "4Writes +contents+ to the file. See File.write. ;T;[o;= ;>I" overload;F;?0;;s;@0;:I"write(string, [offset] );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@;![;"I"@return [Fixnum];T;#0;$@;.F;Bi;C0;7[[I" string;T0[I" [offset];T0;$@o;= ;>I" overload;F;?0;;s;@0;:I"(write(string, [offset], open_args );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@;![;"I"@return [Fixnum];T;#0;$@;.F;Bi;C0;7[[I" string;T0[I" [offset];T0[I"open_args;T0;$@;![;"I"Writes +contents+ to the file. See File.write. @overload write(string, [offset] ) @return [Fixnum] @overload write(string, [offset], open_args ) @return [Fixnum];T;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_write(int argc, VALUE *argv, VALUE self) { VALUE args[4]; int n; args[0] = get_strpath(self); n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]); return rb_funcallv_kw(rb_cFile, id_write, 1+n, args, RB_PASS_CALLED_KEYWORDS); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#binwrite;F;7[[@90;[[@Zi;T;;t;0;[;{;IC; "RWrites +contents+ to the file, opening it in binary mode. See File.binwrite. ;T;[o;= ;>I" overload;F;?0;;t;@0;:I" binwrite(string, [offset] );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@;![;"I"@return [Fixnum];T;#0;$@;.F;Bi;C0;7[[I" string;T0[I" [offset];T0;$@o;= ;>I" overload;F;?0;;t;@0;:I"+binwrite(string, [offset], open_args );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@;![;"I"@return [Fixnum];T;#0;$@;.F;Bi;C0;7[[I" string;T0[I" [offset];T0[I"open_args;T0;$@;![;"I"Writes +contents+ to the file, opening it in binary mode. See File.binwrite. @overload binwrite(string, [offset] ) @return [Fixnum] @overload binwrite(string, [offset], open_args ) @return [Fixnum];T;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_binwrite(int argc, VALUE *argv, VALUE self) { VALUE args[4]; int n; args[0] = get_strpath(self); n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]); return rb_funcallv_kw(rb_cFile, id_binwrite, 1+n, args, RB_PASS_CALLED_KEYWORDS); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#sysopen;F;7[[@90;[[@Zi;T;;m;0;[;{;IC; "See IO.sysopen. ;T;[o;= ;>I" overload;F;?0;;m;@0;:I"sysopen([mode, [perm]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Fixnum;T;$@;![;"I"@return [Fixnum];T;#0;$@;.F;Bi;C0;7[[I"[mode, [perm]];T0;$@;![;"I"LSee IO.sysopen. @overload sysopen([mode, [perm]]) @return [Fixnum];T;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_sysopen(int argc, VALUE *argv, VALUE self) { VALUE args[3]; int n; args[0] = get_strpath(self); n = rb_scan_args(argc, argv, "02", &args[1], &args[2]); return rb_funcallv(rb_cIO, id_sysopen, 1+n, args); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#atime;F;7[;[[@Zi;T;;3;0;[;{;IC; "@Returns the last access time for the file. See File.atime. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" ->(time);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"UReturns the last access time for the file. See File.atime. @overload ->(time);T;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"mstatic VALUE path_atime(VALUE self) { return rb_funcall(rb_cFile, id_atime, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#birthtime;F;7[;[[@Zi;T;;6;0;[;{;IC; "}Returns the birth time for the file. If the platform doesn't have birthtime, raises NotImplementedError. See File.birthtime. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" ->(time);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the birth time for the file. If the platform doesn't have birthtime, raises NotImplementedError. See File.birthtime. @overload ->(time);T;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"ustatic VALUE path_birthtime(VALUE self) { return rb_funcall(rb_cFile, id_birthtime, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#ctime;F;7[;[[@Zi;T;;5;0;[;{;IC; "eReturns the last change time, using directory information, not the file itself. See File.ctime. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" ->(time);T;IC; ";T;[;![;"I";T;#0;$@4;.F;Bi;C0;7[;$@4;![;"I"zReturns the last change time, using directory information, not the file itself. See File.ctime. @overload ->(time);T;#0;$@4;.F;/o;0;1T;2i;3i;%@G;9I"mstatic VALUE path_ctime(VALUE self) { return rb_funcall(rb_cFile, id_ctime, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#mtime;F;7[;[[@Zi%;T;;4;0;[;{;IC; "AReturns the last modified time of the file. See File.mtime. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" ->(time);T;IC; ";T;[;![;"I";T;#0;$@J;.F;Bi;C0;7[;$@J;![;"I"VReturns the last modified time of the file. See File.mtime. @overload ->(time);T;#0;$@J;.F;/o;0;1T;2i;3i";%@G;9I"mstatic VALUE path_mtime(VALUE self) { return rb_funcall(rb_cFile, id_mtime, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#chmod;F;7[[I" mode;T0;[[@Zi3;T;;S;0;[;{;IC; "/Changes file permissions. See File.chmod. ;T;[o;= ;>I" overload;F;?0;;S;@0;:I"chmod(mode_int) -> integer;T;IC; ";T;[;![;"I";T;#0;$@`;.F;Bi;C0;7[[I" mode_int;T0;$@`;![;"I"VChanges file permissions. See File.chmod. @overload chmod(mode_int) -> integer;T;#0;$@`;.F;/o;0;1T;2i+;3i0;%@G;9I"static VALUE path_chmod(VALUE self, VALUE mode) { return rb_funcall(rb_cFile, id_chmod, 2, mode, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#lchmod;F;7[[I" mode;T0;[[@ZiA;T;;U;0;[;{;IC; "RSame as Pathname.chmod, but does not follow symbolic links. See File.lchmod. ;T;[o;= ;>I" overload;F;?0;;U;@0;:I" lchmod(mode_int) -> integer;T;IC; ";T;[;![;"I";T;#0;$@z;.F;Bi;C0;7[[I" mode_int;T0;$@z;![;"I"zSame as Pathname.chmod, but does not follow symbolic links. See File.lchmod. @overload lchmod(mode_int) -> integer;T;#0;$@z;.F;/o;0;1T;2i9;3i>;%@G;9I"|static VALUE path_lchmod(VALUE self, VALUE mode) { return rb_funcall(rb_cFile, id_lchmod, 2, mode, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#chown;F;7[[I" owner;T0[I" group;T0;[[@ZiO;T;;T;0;[;{;IC; "9Change owner and group of the file. See File.chown. ;T;[o;= ;>I" overload;F;?0;;T;@0;:I"+chown(owner_int, group_int) -> integer;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"owner_int;T0[I"group_int;T0;$@;![;"I"lChange owner and group of the file. See File.chown. @overload chown(owner_int, group_int) -> integer;T;#0;$@;.F;/o;0;1T;2iG;3iL;%@G;9I"static VALUE path_chown(VALUE self, VALUE owner, VALUE group) { return rb_funcall(rb_cFile, id_chown, 3, owner, group, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#lchown;F;7[[I" owner;T0[I" group;T0;[[@Zi];T;;V;0;[;{;IC; "RSame as Pathname.chown, but does not follow symbolic links. See File.lchown. ;T;[o;= ;>I" overload;F;?0;;V;@0;:I",lchown(owner_int, group_int) -> integer;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"owner_int;T0[I"group_int;T0;$@;![;"I"Same as Pathname.chown, but does not follow symbolic links. See File.lchown. @overload lchown(owner_int, group_int) -> integer;T;#0;$@;.F;/o;0;1T;2iU;3iZ;%@G;9I"static VALUE path_lchown(VALUE self, VALUE owner, VALUE group) { return rb_funcall(rb_cFile, id_lchown, 3, owner, group, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#fnmatch;F;7[[@90;[[@Zil;T;;#;0;[;{;IC; "PReturn +true+ if the receiver matches the given pattern. See File.fnmatch. ;T;[o;= ;>I" overload;F;?0;;#;@0;:I"fnmatch(pattern, [flags]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@д;![;"I"@return [Boolean];T;#0;$@д;.F;Bi;C0;7[[I" pattern;T0[I" [flags];T0;$@дo;= ;>I" overload;F;?0;;$;@0;:I"fnmatch?(pattern, [flags]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@д;![;"I"@return [Boolean];T;#0;$@д;.F;Bi;C0;7[[I" pattern;T0[I" [flags];T0;$@д;![;"I"Return +true+ if the receiver matches the given pattern. See File.fnmatch. @overload fnmatch(pattern, [flags]) @return [Boolean] @overload fnmatch?(pattern, [flags]) @return [Boolean];T;#0;$@д;.F;/o;0;1T;2ic;3ik;%@G;9I"Pstatic VALUE path_fnmatch(int argc, VALUE *argv, VALUE self) { VALUE str = get_strpath(self); VALUE pattern, flags; if (rb_scan_args(argc, argv, "11", &pattern, &flags) == 1) return rb_funcall(rb_cFile, id_fnmatch, 2, pattern, str); else return rb_funcall(rb_cFile, id_fnmatch, 3, pattern, str, flags); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#fnmatch?;F;7[[@90;[[@Zil;T;;$;0;[;{;IC; "PReturn +true+ if the receiver matches the given pattern. See File.fnmatch.;T;[o;= ;>I" overload;F;?0;;#;@0;:I"fnmatch(pattern, [flags]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" pattern;T0[I" [flags];T0;$@o;= ;>I" overload;F;?0;;$;@0;:I"fnmatch?(pattern, [flags]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[[I" pattern;T0[I" [flags];T0;$@;![;"@;#0;$@;.F;/o;0;1T;2ic;3ik;Bi;%@G;9I"Pstatic VALUE path_fnmatch(int argc, VALUE *argv, VALUE self) { VALUE str = get_strpath(self); VALUE pattern, flags; if (rb_scan_args(argc, argv, "11", &pattern, &flags) == 1) return rb_funcall(rb_cFile, id_fnmatch, 2, pattern, str); else return rb_funcall(rb_cFile, id_fnmatch, 3, pattern, str, flags); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#ftype;F;7[;[[@Zi;T;;7;0;[;{;IC; "HReturns "type" of file ("file", "directory", etc). See File.ftype. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"->(string);T;IC; ";T;[;![;"I";T;#0;$@1;.F;Bi;C0;7[;$@1;![;"I"_Returns "type" of file ("file", "directory", etc). See File.ftype. @overload ->(string);T;#0;$@1;.F;/o;0;1T;2iw;3i|;%@G;9I"mstatic VALUE path_ftype(VALUE self) { return rb_funcall(rb_cFile, id_ftype, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#make_link;F;7[[I"old;T0;[[@Zi;T;:make_link;0;[;{;IC; "7Creates a hard link at _pathname_. See File.link. ;T;[o;= ;>I" overload;F;?0;;$ ;@0;:I"make_link(old);T;IC; ";T;[;![;"I";T;#0;$@G;.F;Bi;C0;7[[I"old;T0;$@G;![;"I"RCreates a hard link at _pathname_. See File.link. @overload make_link(old);T;#0;$@G;.F;/o;0;1T;2i;3i;%@G;9I"{static VALUE path_make_link(VALUE self, VALUE old) { return rb_funcall(rb_cFile, id_link, 2, old, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#open;F;7[[@90;[[@Zi;T;;;0;[;{;IC; ";Opens the file for reading or writing. See File.open. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I" open();T;IC; ";T;[;![;"I";T;#0;$@a;.F;Bi;C0;7[;$@ao;= ;>I" overload;F;?0;;;@0;:I"open(mode="r" [, opt]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" File;T;$@a;![;"I"@return [File];T;#0;$@a;.F;Bi;C0;7[[I" mode;TI""r"[, opt];T;$@ao;= ;>I" overload;F;?0;;;@0;:I""open([mode [, perm]] [, opt]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" File;T;$@a;![;"I"@return [File];T;#0;$@a;.F;Bi;C0;7[[I"ode [, perm]][, opt];T0;$@ao;= ;>I" overload;F;?0;;;@0;:I"open(mode="r" [, opt]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" file;T;$@ao;A ;>I" return;F;?I";T;0;@[I" Object;T;$@a;![;"I"#@yield [file] @return [Object];T;#0;$@a;.F;Bi;C0;7[[I" mode;TI""r"[, opt];T;$@ao;= ;>I" overload;F;?0;;;@0;:I""open([mode [, perm]] [, opt]);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" file;T;$@ao;A ;>I" return;F;?I";T;0;@[I" Object;T;$@a;![;"I"#@yield [file] @return [Object];T;#0;$@a;.F;Bi;C0;7[[I"ode [, perm]][, opt];T0;$@a;![;"I"COpens the file for reading or writing. See File.open. @overload open() @overload open(mode="r" [, opt]) @return [File] @overload open([mode [, perm]] [, opt]) @return [File] @overload open(mode="r" [, opt]) @yield [file] @return [Object] @overload open([mode [, perm]] [, opt]) @yield [file] @return [Object];T;#0;$@a;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_open(int argc, VALUE *argv, VALUE self) { VALUE args[4]; int n; args[0] = get_strpath(self); n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]); if (rb_block_given_p()) { return rb_block_call_kw(rb_cFile, id_open, 1+n, args, 0, 0, RB_PASS_CALLED_KEYWORDS); } else { return rb_funcallv_kw(rb_cFile, id_open, 1+n, args, RB_PASS_CALLED_KEYWORDS); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#readlink;F;7[;[[@Zi;T;;Z;0;[;{;IC; ",Read symbolic link. See File.readlink. ;T;[;![;"I"-Read symbolic link. See File.readlink. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_readlink(VALUE self) { VALUE str; str = rb_funcall(rb_cFile, id_readlink, 1, get_strpath(self)); return rb_class_new_instance(1, &str, rb_obj_class(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#rename;F;7[[I"to;T0;[[@Zi;T;;];0;[;{;IC; "'Rename the file. See File.rename. ;T;[;![;"I"(Rename the file. See File.rename. ;T;#0;$@ε;.F;/o;0;1T;2i;3i;%@G;9I"}static VALUE path_rename(VALUE self, VALUE to) { return rb_funcall(rb_cFile, id_rename, 2, get_strpath(self), to); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#stat;F;7[;[[@Zi;T;;;0;[;{;IC; "1Returns a File::Stat object. See File.stat. ;T;[;![;"I"2Returns a File::Stat object. See File.stat. ;T;#0;$@޵;.F;/o;0;1T;2i;3i;%@G;9I"kstatic VALUE path_stat(VALUE self) { return rb_funcall(rb_cFile, id_stat, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#lstat;F;7[;[[@Zi;T;;Q;0;[;{;IC; "See File.lstat. ;T;[;![;"I"See File.lstat. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"mstatic VALUE path_lstat(VALUE self) { return rb_funcall(rb_cFile, id_lstat, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#make_symlink;F;7[[I"old;T0;[[@Zi;T;:make_symlink;0;[;{;IC; "0Creates a symbolic link. See File.symlink. ;T;[o;= ;>I" overload;F;?0;;% ;@0;:I"make_symlink(old);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"old;T0;$@;![;"I"NCreates a symbolic link. See File.symlink. @overload make_symlink(old);T;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_make_symlink(VALUE self, VALUE old) { return rb_funcall(rb_cFile, id_symlink, 2, old, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#truncate;F;7[[I" length;T0;[[@Zi;T;;_;0;[;{;IC; ">Truncates the file to +length+ bytes. See File.truncate. ;T;[;![;"I"?Truncates the file to +length+ bytes. See File.truncate. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_truncate(VALUE self, VALUE length) { return rb_funcall(rb_cFile, id_truncate, 2, get_strpath(self), length); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#utime;F;7[[I" atime;T0[I" mtime;T0;[[@Zi;T;;R;0;[;{;IC; "KUpdate the access and modification times of the file. See File.utime. ;T;[;![;"I"LUpdate the access and modification times of the file. See File.utime. ;T;#0;$@$;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_utime(VALUE self, VALUE atime, VALUE mtime) { return rb_funcall(rb_cFile, id_utime, 3, atime, mtime, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#basename;F;7[[@90;[[@Zi;T;;e;0;[;{;IC; "@Returns the last component of the path. See File.basename. ;T;[;![;"I"AReturns the last component of the path. See File.basename. ;T;#0;$@6;.F;/o;0;1T;2i;3i;%@G;9I"hstatic VALUE path_basename(int argc, VALUE *argv, VALUE self) { VALUE str = get_strpath(self); VALUE fext; if (rb_scan_args(argc, argv, "01", &fext) == 0) str = rb_funcall(rb_cFile, id_basename, 1, str); else str = rb_funcall(rb_cFile, id_basename, 2, str, fext); return rb_class_new_instance(1, &str, rb_obj_class(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#dirname;F;7[;[[@Zi;T;;f;0;[;{;IC; "GReturns all but the last component of the path. See File.dirname. ;T;[;![;"I"HReturns all but the last component of the path. See File.dirname. ;T;#0;$@E;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_dirname(VALUE self) { VALUE str = get_strpath(self); str = rb_funcall(rb_cFile, id_dirname, 1, str); return rb_class_new_instance(1, &str, rb_obj_class(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#extname;F;7[;[[@Zi";T;;g;0;[;{;IC; "5Returns the file's extension. See File.extname. ;T;[;![;"I"6Returns the file's extension. See File.extname. ;T;#0;$@S;.F;/o;0;1T;2i;3i ;%@G;9I"static VALUE path_extname(VALUE self) { VALUE str = get_strpath(self); return rb_funcall(rb_cFile, id_extname, 1, str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#expand_path;F;7[[@90;[[@Zi.;T;;a;0;[;{;IC; "CReturns the absolute path for the file. See File.expand_path. ;T;[;![;"I"DReturns the absolute path for the file. See File.expand_path. ;T;#0;$@a;.F;/o;0;1T;2i);3i,;%@G;9I"tstatic VALUE path_expand_path(int argc, VALUE *argv, VALUE self) { VALUE str = get_strpath(self); VALUE dname; if (rb_scan_args(argc, argv, "01", &dname) == 0) str = rb_funcall(rb_cFile, id_expand_path, 1, str); else str = rb_funcall(rb_cFile, id_expand_path, 2, str, dname); return rb_class_new_instance(1, &str, rb_obj_class(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#split;F;7[;[[@Zi?;T;;j;0;[;{;IC; "IReturns the #dirname and the #basename in an Array. See File.split. ;T;[;![;"I"JReturns the #dirname and the #basename in an Array. See File.split. ;T;#0;$@p;.F;/o;0;1T;2i:;3i=;%@G;9I"static VALUE path_split(VALUE self) { VALUE str = get_strpath(self); VALUE ary, dirname, basename; ary = rb_funcall(rb_cFile, id_split, 1, str); Check_Type(ary, T_ARRAY); dirname = rb_ary_entry(ary, 0); basename = rb_ary_entry(ary, 1); dirname = rb_class_new_instance(1, &dirname, rb_obj_class(self)); basename = rb_class_new_instance(1, &basename, rb_obj_class(self)); return rb_ary_new3(2, dirname, basename); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#blockdev?;F;7[;[[@ZiP;T;;H;0;[;{;IC; "See FileTest.blockdev?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@~;![;"I"See FileTest.blockdev?. ;T;#0;$@~;.F;/o;0;1T;2iM;3iN;Bi;%@G;9I"{static VALUE path_blockdev_p(VALUE self) { return rb_funcall(rb_mFileTest, id_blockdev_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#chardev?;F;7[;[[@ZiY;T;;I;0;[;{;IC; "See FileTest.chardev?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"See FileTest.chardev?. ;T;#0;$@;.F;/o;0;1T;2iV;3iW;Bi;%@G;9I"ystatic VALUE path_chardev_p(VALUE self) { return rb_funcall(rb_mFileTest, id_chardev_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#executable?;F;7[;[[@Zib;T;;?;0;[;{;IC; "See FileTest.executable?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"See FileTest.executable?. ;T;#0;$@;.F;/o;0;1T;2i_;3i`;Bi;%@G;9I"static VALUE path_executable_p(VALUE self) { return rb_funcall(rb_mFileTest, id_executable_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#executable_real?;F;7[;[[@Zik;T;;@;0;[;{;IC; "#See FileTest.executable_real?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"$See FileTest.executable_real?. ;T;#0;$@;.F;/o;0;1T;2ih;3ii;Bi;%@G;9I"static VALUE path_executable_real_p(VALUE self) { return rb_funcall(rb_mFileTest, id_executable_real_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#exist?;F;7[;[[@Zit;T;;;0;[;{;IC; "See FileTest.exist?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@¶;![;"I"See FileTest.exist?. ;T;#0;$@¶;.F;/o;0;1T;2iq;3ir;Bi;%@G;9I"ustatic VALUE path_exist_p(VALUE self) { return rb_funcall(rb_mFileTest, id_exist_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#grpowned?;F;7[;[[@Zi};T;;D;0;[;{;IC; "See FileTest.grpowned?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@Ӷ;![;"I"See FileTest.grpowned?. ;T;#0;$@Ӷ;.F;/o;0;1T;2iz;3i{;Bi;%@G;9I"{static VALUE path_grpowned_p(VALUE self) { return rb_funcall(rb_mFileTest, id_grpowned_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#directory?;F;7[;[[@Zi;T;;8;0;[;{;IC; "See FileTest.directory?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"See FileTest.directory?. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@G;9I"}static VALUE path_directory_p(VALUE self) { return rb_funcall(rb_mFileTest, id_directory_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#file?;F;7[;[[@Zi;T;;A;0;[;{;IC; "See FileTest.file?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"See FileTest.file?. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@G;9I"sstatic VALUE path_file_p(VALUE self) { return rb_funcall(rb_mFileTest, id_file_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#pipe?;F;7[;[[@Zi;T;;E;0;[;{;IC; "See FileTest.pipe?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"See FileTest.pipe?. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@G;9I"sstatic VALUE path_pipe_p(VALUE self) { return rb_funcall(rb_mFileTest, id_pipe_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#socket?;F;7[;[[@Zi;T;;G;0;[;{;IC; "See FileTest.socket?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"See FileTest.socket?. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@G;9I"wstatic VALUE path_socket_p(VALUE self) { return rb_funcall(rb_mFileTest, id_socket_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#owned?;F;7[;[[@Zi;T;;X;0;[;{;IC; "See FileTest.owned?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@(;![;"I"See FileTest.owned?. ;T;#0;$@(;.F;/o;0;1T;2i;3i;Bi;%@G;9I"ustatic VALUE path_owned_p(VALUE self) { return rb_funcall(rb_mFileTest, id_owned_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#readable?;F;7[;[[@Zi;T;;9;0;[;{;IC; "See FileTest.readable?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@9;![;"I"See FileTest.readable?. ;T;#0;$@9;.F;/o;0;1T;2i;3i;Bi;%@G;9I"{static VALUE path_readable_p(VALUE self) { return rb_funcall(rb_mFileTest, id_readable_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#world_readable?;F;7[;[[@Zi;T;;;;0;[;{;IC; ""See FileTest.world_readable?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@J;![;"I"#See FileTest.world_readable?. ;T;#0;$@J;.F;/o;0;1T;2i;3i;Bi;%@G;9I"static VALUE path_world_readable_p(VALUE self) { return rb_funcall(rb_mFileTest, id_world_readable_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#readable_real?;F;7[;[[@Zi;T;;:;0;[;{;IC; "!See FileTest.readable_real?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@[;![;"I""See FileTest.readable_real?. ;T;#0;$@[;.F;/o;0;1T;2i;3i;Bi;%@G;9I"static VALUE path_readable_real_p(VALUE self) { return rb_funcall(rb_mFileTest, id_readable_real_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#setuid?;F;7[;[[@Zi;T;;J;0;[;{;IC; "See FileTest.setuid?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@l;![;"I"See FileTest.setuid?. ;T;#0;$@l;.F;/o;0;1T;2i;3i;Bi;%@G;9I"wstatic VALUE path_setuid_p(VALUE self) { return rb_funcall(rb_mFileTest, id_setuid_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#setgid?;F;7[;[[@Zi;T;;K;0;[;{;IC; "See FileTest.setgid?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@};![;"I"See FileTest.setgid?. ;T;#0;$@};.F;/o;0;1T;2i;3i;Bi;%@G;9I"wstatic VALUE path_setgid_p(VALUE self) { return rb_funcall(rb_mFileTest, id_setgid_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#size;F;7[;[[@Zi;T;;;0;[;{;IC; "See FileTest.size. ;T;[;![;"I"See FileTest.size. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"ostatic VALUE path_size(VALUE self) { return rb_funcall(rb_mFileTest, id_size, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#size?;F;7[;[[@Zi;T;;C;0;[;{;IC; "See FileTest.size?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"See FileTest.size?. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@G;9I"sstatic VALUE path_size_p(VALUE self) { return rb_funcall(rb_mFileTest, id_size_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#sticky?;F;7[;[[@Zi;T;;L;0;[;{;IC; "See FileTest.sticky?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"See FileTest.sticky?. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@G;9I"wstatic VALUE path_sticky_p(VALUE self) { return rb_funcall(rb_mFileTest, id_sticky_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#symlink?;F;7[;[[@Zi;T;;F;0;[;{;IC; "See FileTest.symlink?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"See FileTest.symlink?. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@G;9I"ystatic VALUE path_symlink_p(VALUE self) { return rb_funcall(rb_mFileTest, id_symlink_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#writable?;F;7[;[[@Zi;T;;<;0;[;{;IC; "See FileTest.writable?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@Ϸ;![;"I"See FileTest.writable?. ;T;#0;$@Ϸ;.F;/o;0;1T;2i;3i;Bi;%@G;9I"{static VALUE path_writable_p(VALUE self) { return rb_funcall(rb_mFileTest, id_writable_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#world_writable?;F;7[;[[@Zi ;T;;>;0;[;{;IC; ""See FileTest.world_writable?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"#See FileTest.world_writable?. ;T;#0;$@;.F;/o;0;1T;2i ;3i ;Bi;%@G;9I"static VALUE path_world_writable_p(VALUE self) { return rb_funcall(rb_mFileTest, id_world_writable_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#writable_real?;F;7[;[[@Zi;T;;=;0;[;{;IC; "!See FileTest.writable_real?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I""See FileTest.writable_real?. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@G;9I"static VALUE path_writable_real_p(VALUE self) { return rb_funcall(rb_mFileTest, id_writable_real_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#zero?;F;7[;[[@Zi;T;;B;0;[;{;IC; "See FileTest.zero?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"See FileTest.zero?. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@G;9I"sstatic VALUE path_zero_p(VALUE self) { return rb_funcall(rb_mFileTest, id_zero_p, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#empty?;F;7[;[[@Zi*;T;;;0;[;{;IC; "BTests the file is empty. See Dir#empty? and FileTest.empty?.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"CTests the file is empty. See Dir#empty? and FileTest.empty?. ;T;#0;$@;.F;/o;0;1T;2i%;3i(;Bi;%@G;9I"static VALUE path_empty_p(VALUE self) { VALUE path = get_strpath(self); if (RTEST(rb_funcall(rb_mFileTest, id_directory_p, 1, path))) return rb_funcall(rb_cDir, id_empty_p, 1, path); else return rb_funcall(rb_mFileTest, id_empty_p, 1, path); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname.glob;F;7[[@90;[[@ZiC;T;: glob;0;[;{;IC; "Returns or yields Pathname objects. Pathname.glob("lib/i*.rb") #=> [#, #] See Dir.glob. ;T;[;![;"I"Returns or yields Pathname objects. Pathname.glob("lib/i*.rb") #=> [#, #] See Dir.glob. ;T;#0;$@$;.F;/o;0;1T;2i;;3iA;%@G;9I"static VALUE path_s_glob(int argc, VALUE *argv, VALUE klass) { VALUE args[3]; int n; n = rb_scan_args(argc, argv, "12", &args[0], &args[1], &args[2]); if (rb_block_given_p()) { return rb_block_call_kw(rb_cDir, id_glob, n, args, s_glob_i, klass, RB_PASS_CALLED_KEYWORDS); } else { VALUE ary; long i; ary = rb_funcallv_kw(rb_cDir, id_glob, n, args, RB_PASS_CALLED_KEYWORDS); ary = rb_convert_type(ary, T_ARRAY, "Array", "to_ary"); for (i = 0; i < RARRAY_LEN(ary); i++) { VALUE elt = RARRAY_AREF(ary, i); elt = rb_class_new_instance(1, &elt, klass); rb_ary_store(ary, i, elt); } return ary; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname.getwd;F;7[;[[@Zi;T;;# ;0;[;{;IC; "Returns the current working directory as a Pathname. Pathname.getwd #=> # See Dir.getwd. ;T;[;![;"I"Returns the current working directory as a Pathname. Pathname.getwd #=> # See Dir.getwd. ;T;#0;$@3;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_s_getwd(VALUE klass) { VALUE str; str = rb_funcall(rb_cDir, id_getwd, 0); return rb_class_new_instance(1, &str, klass); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname.pwd;F;7[;[[@Zi;T;;$ ;0;[;{;IC; "Returns the current working directory as a Pathname. Pathname.getwd #=> # See Dir.getwd. ;T;[;![;"@=;#0;$@A;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_s_getwd(VALUE klass) { VALUE str; str = rb_funcall(rb_cDir, id_getwd, 0); return rb_class_new_instance(1, &str, klass); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#glob;F;7[[@90;[[@Zik;T;;& ;0;[;{;IC; "Returns or yields Pathname objects. Pathname("ruby-2.4.2").glob("R*.md") #=> [#, #] See Dir.glob. This method uses the +base+ keyword argument of Dir.glob. ;T;[;![;"I"Returns or yields Pathname objects. Pathname("ruby-2.4.2").glob("R*.md") #=> [#, #] See Dir.glob. This method uses the +base+ keyword argument of Dir.glob. ;T;#0;$@N;.F;/o;0;1T;2ib;3ii;%@G;9I"@static VALUE path_glob(int argc, VALUE *argv, VALUE self) { VALUE args[3]; int n; n = rb_scan_args(argc, argv, "11", &args[0], &args[1]); if (n == 1) args[1] = INT2FIX(0); args[2] = rb_hash_new(); rb_hash_aset(args[2], ID2SYM(id_base), get_strpath(self)); n = 3; if (rb_block_given_p()) { return rb_block_call_kw(rb_cDir, id_glob, n, args, glob_i, self, RB_PASS_KEYWORDS); } else { VALUE ary; long i; ary = rb_funcallv_kw(rb_cDir, id_glob, n, args, RB_PASS_KEYWORDS); ary = rb_convert_type(ary, T_ARRAY, "Array", "to_ary"); for (i = 0; i < RARRAY_LEN(ary); i++) { VALUE elt = RARRAY_AREF(ary, i); elt = rb_funcall(self, '+', 1, elt); rb_ary_store(ary, i, elt); } return ary; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#entries;F;7[;[[@Zi;T;;;0;[;{;IC; "Return the entries (files and subdirectories) in the directory, each as a Pathname object. The results contains just the names in the directory, without any trailing slashes or recursive look-up. pp Pathname.new('/usr/local').entries #=> [#, # #, # #, # #, # #, # #, # #, # #, # #, # #, # #] The result may contain the current directory # and the parent directory #. If you don't want +.+ and +..+ and want directories, consider Pathname#children. ;T;[;![;"I"Return the entries (files and subdirectories) in the directory, each as a Pathname object. The results contains just the names in the directory, without any trailing slashes or recursive look-up. pp Pathname.new('/usr/local').entries #=> [#, # #, # #, # #, # #, # #, # #, # #, # #, # #, # #] The result may contain the current directory # and the parent directory #. If you don't want +.+ and +..+ and want directories, consider Pathname#children. ;T;#0;$@];.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_entries(VALUE self) { VALUE klass, str, ary; long i; klass = rb_obj_class(self); str = get_strpath(self); ary = rb_funcall(rb_cDir, id_entries, 1, str); ary = rb_convert_type(ary, T_ARRAY, "Array", "to_ary"); for (i = 0; i < RARRAY_LEN(ary); i++) { VALUE elt = RARRAY_AREF(ary, i); elt = rb_class_new_instance(1, &elt, klass); rb_ary_store(ary, i, elt); } return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#mkdir;F;7[[@90;[[@Zi;T;;& ;0;[;{;IC; "5Create the referenced directory. See Dir.mkdir. ;T;[;![;"I"6Create the referenced directory. See Dir.mkdir. ;T;#0;$@k;.F;/o;0;1T;2i;3i;%@G;9I"#static VALUE path_mkdir(int argc, VALUE *argv, VALUE self) { VALUE str = get_strpath(self); VALUE vmode; if (rb_scan_args(argc, argv, "01", &vmode) == 0) return rb_funcall(rb_cDir, id_mkdir, 1, str); else return rb_funcall(rb_cDir, id_mkdir, 2, str, vmode); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#rmdir;F;7[;[[@Zi;T;;' ;0;[;{;IC; "5Remove the referenced directory. See Dir.rmdir. ;T;[;![;"I"6Remove the referenced directory. See Dir.rmdir. ;T;#0;$@z;.F;/o;0;1T;2i;3i;%@G;9I"lstatic VALUE path_rmdir(VALUE self) { return rb_funcall(rb_cDir, id_rmdir, 1, get_strpath(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#opendir;F;7[;[[@Zi;T;: opendir;0;[;{;IC; "3Opens the referenced directory. See Dir.open. ;T;[;![;"I"4Opens the referenced directory. See Dir.open. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_opendir(VALUE self) { VALUE args[1]; args[0] = get_strpath(self); return rb_block_call(rb_cDir, id_open, 1, args, 0, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#each_entry;F;7[;[[@Zi;T;;;0;[;{;IC; "vIterates over the entries (files and subdirectories) in the directory, yielding a Pathname object for each entry. ;T;[;![;"I"wIterates over the entries (files and subdirectories) in the directory, yielding a Pathname object for each entry. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_each_entry(VALUE self) { VALUE args[1]; args[0] = get_strpath(self); return rb_block_call(rb_cDir, id_foreach, 1, args, each_entry_i, rb_obj_class(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#unlink;F;7[;[[@Zi;T;;[;0;[;{;IC; "dRemoves a file or directory, using File.unlink if +self+ is a file, or Dir.unlink as necessary. ;T;[;![;"I"eRemoves a file or directory, using File.unlink if +self+ is a file, or Dir.unlink as necessary. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_unlink(VALUE self) { VALUE eENOTDIR = rb_const_get_at(rb_mErrno, id_ENOTDIR); VALUE str = get_strpath(self); return rb_rescue2(unlink_body, str, unlink_rescue, str, eENOTDIR, (VALUE)0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Pathname#delete;F;7[;[[@Zi;T;;\;0;[;{;IC; "dRemoves a file or directory, using File.unlink if +self+ is a file, or Dir.unlink as necessary. ;T;[;![;"@;#0;$@;.F;/o;0;1T;2i;3i;%@G;9I"static VALUE path_unlink(VALUE self) { VALUE eENOTDIR = rb_const_get_at(rb_mErrno, id_ENOTDIR); VALUE str = get_strpath(self); return rb_rescue2(unlink_body, str, unlink_rescue, str, eENOTDIR, (VALUE)0); };T;:I"static VALUE;T;;T; @G; IC;[; @G; IC;[; @G; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Zi;F;;;;;;;[;{;IC; " ;T;[;![;"@;#0;$@G;Bi;%@;&I" Pathname;F;'@o;;IC;[o;4;5F;6;;;;&I"Coverage#setup;F;7[[@90;[[I"ext/coverage/coverage.c;Ti-;T;;{;0;[;{;IC; "Set up the coverage measurement. Note that this method does not start the measurement itself. Use Coverage.resume to start the measurement. You may want to use Coverage.start to setup and then start the measurement. ;T;[ o;= ;>I" overload;F;?0;;{;@0;:I" setup;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@и;![;"I"@return [nil];T;#0;$@и;.F;Bi;C0;7[;$@иo;= ;>I" overload;F;?0;;{;@0;:I"setup(:all);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@и;![;"I"@return [nil];T;#0;$@и;.F;Bi;C0;7[[I":;TI"all;T;$@иo;= ;>I" overload;F;?0;;{;@0;:I"6setup(lines: bool, branches: bool, methods: bool);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@и;![;"I"@return [nil];T;#0;$@и;.F;Bi;C0;7[[I" lines:;TI" bool;T[I"branches:;TI" bool;T[I" methods:;TI" bool;T;$@иo;= ;>I" overload;F;?0;;{;@0;:I"setup(oneshot_lines: true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@и;![;"I"@return [nil];T;#0;$@и;.F;Bi;C0;7[[I"oneshot_lines:;TI" true;T;$@и;![;"I"Set up the coverage measurement. Note that this method does not start the measurement itself. Use Coverage.resume to start the measurement. You may want to use Coverage.start to setup and then start the measurement. @overload setup @return [nil] @overload setup(:all) @return [nil] @overload setup(lines: bool, branches: bool, methods: bool) @return [nil] @overload setup(oneshot_lines: true) @return [nil];T;#0;$@и;.F;C0;%@θ;9I"static VALUE rb_coverage_setup(int argc, VALUE *argv, VALUE klass) { VALUE coverages, opt; int mode; if (current_state != IDLE) { rb_raise(rb_eRuntimeError, "coverage measurement is already setup"); } rb_scan_args(argc, argv, "01", &opt); if (argc == 0) { mode = 0; /* compatible mode */ } else if (opt == ID2SYM(rb_intern("all"))) { mode = COVERAGE_TARGET_LINES | COVERAGE_TARGET_BRANCHES | COVERAGE_TARGET_METHODS; } else { mode = 0; opt = rb_convert_type(opt, T_HASH, "Hash", "to_hash"); if (RTEST(rb_hash_lookup(opt, ID2SYM(rb_intern("lines"))))) mode |= COVERAGE_TARGET_LINES; if (RTEST(rb_hash_lookup(opt, ID2SYM(rb_intern("branches"))))) mode |= COVERAGE_TARGET_BRANCHES; if (RTEST(rb_hash_lookup(opt, ID2SYM(rb_intern("methods"))))) mode |= COVERAGE_TARGET_METHODS; if (RTEST(rb_hash_lookup(opt, ID2SYM(rb_intern("oneshot_lines"))))) { if (mode & COVERAGE_TARGET_LINES) rb_raise(rb_eRuntimeError, "cannot enable lines and oneshot_lines simultaneously"); mode |= COVERAGE_TARGET_LINES; mode |= COVERAGE_TARGET_ONESHOT_LINES; } } if (mode & COVERAGE_TARGET_METHODS) { me2counter = rb_ident_hash_new(); } else { me2counter = Qnil; } coverages = rb_get_coverages(); if (!RTEST(coverages)) { coverages = rb_hash_new(); rb_obj_hide(coverages); current_mode = mode; if (mode == 0) mode = COVERAGE_TARGET_LINES; rb_set_coverages(coverages, mode, me2counter); current_state = SUSPENDED; } else if (current_mode != mode) { rb_raise(rb_eRuntimeError, "cannot change the measuring target during coverage measurement"); } return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Coverage.setup;F;7@Ҹ;@Ը;T;;{;0;@׸;{;IC; "Set up the coverage measurement. Note that this method does not start the measurement itself. Use Coverage.resume to start the measurement. You may want to use Coverage.start to setup and then start the measurement.;T;[ o;= ;>I" overload;F;?0;;{;@0;:I" setup;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@";![;"I"@return [nil];T;#0;$@";.F;Bi;C0;7[;$@"o;= ;>I" overload;F;?0;;{;@0;:I"setup(:all);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@";![;"I"@return [nil];T;#0;$@";.F;Bi;C0;7[[I":;TI"all;T;$@"o;= ;>I" overload;F;?0;;{;@0;:I"6setup(lines: bool, branches: bool, methods: bool);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@";![;"I"@return [nil];T;#0;$@";.F;Bi;C0;7[[I" lines:;TI" bool;T[I"branches:;TI" bool;T[I" methods:;TI" bool;T;$@"o;= ;>I" overload;F;?0;;{;@0;:I"setup(oneshot_lines: true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@";![;"I"@return [nil];T;#0;$@";.F;Bi;C0;7[[I"oneshot_lines:;TI" true;T;$@";![;"I"Set up the coverage measurement. Note that this method does not start the measurement itself. Use Coverage.resume to start the measurement. You may want to use Coverage.start to setup and then start the measurement. @overload setup @return [nil] @overload setup(:all) @return [nil] @overload setup(lines: bool, branches: bool, methods: bool) @return [nil] @overload setup(oneshot_lines: true) @return [nil];T;#0;$@";.F;/o;0;1T;2i;3i.;Bi;%@θ;9@ ;:@!;;To;4;5F;6;;;;&I"Coverage#start;F;7[[@90;[[@ָi;T;;$;0;[;{;IC; "Enables the coverage measurement. See the documentation of Coverage class in detail. This is equivalent to Coverage.setup and Coverage.resume. ;T;[ o;= ;>I" overload;F;?0;;$;@0;:I" start;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@m;![;"I"@return [nil];T;#0;$@m;.F;Bi;C0;7[;$@mo;= ;>I" overload;F;?0;;$;@0;:I"start(:all);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@m;![;"I"@return [nil];T;#0;$@m;.F;Bi;C0;7[[I":;TI"all;T;$@mo;= ;>I" overload;F;?0;;$;@0;:I"6start(lines: bool, branches: bool, methods: bool);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@m;![;"I"@return [nil];T;#0;$@m;.F;Bi;C0;7[[I" lines:;TI" bool;T[I"branches:;TI" bool;T[I" methods:;TI" bool;T;$@mo;= ;>I" overload;F;?0;;$;@0;:I"start(oneshot_lines: true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@m;![;"I"@return [nil];T;#0;$@m;.F;Bi;C0;7[[I"oneshot_lines:;TI" true;T;$@m;![;"I"YEnables the coverage measurement. See the documentation of Coverage class in detail. This is equivalent to Coverage.setup and Coverage.resume. @overload start @return [nil] @overload start(:all) @return [nil] @overload start(lines: bool, branches: bool, methods: bool) @return [nil] @overload start(oneshot_lines: true) @return [nil];T;#0;$@m;.F;C0;%@θ;9I"static VALUE rb_coverage_start(int argc, VALUE *argv, VALUE klass) { rb_coverage_setup(argc, argv, klass); rb_coverage_resume(klass); return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Coverage.start;F;7@o;@q;T;;$;0;@s;{;IC; "Enables the coverage measurement. See the documentation of Coverage class in detail. This is equivalent to Coverage.setup and Coverage.resume.;T;[ o;= ;>I" overload;F;?0;;$;@0;:I" start;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;$;@0;:I"start(:all);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I":;TI"all;T;$@o;= ;>I" overload;F;?0;;$;@0;:I"6start(lines: bool, branches: bool, methods: bool);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I" lines:;TI" bool;T[I"branches:;TI" bool;T[I" methods:;TI" bool;T;$@o;= ;>I" overload;F;?0;;$;@0;:I"start(oneshot_lines: true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I"oneshot_lines:;TI" true;T;$@;![;"I"WEnables the coverage measurement. See the documentation of Coverage class in detail. This is equivalent to Coverage.setup and Coverage.resume. @overload start @return [nil] @overload start(:all) @return [nil] @overload start(lines: bool, branches: bool, methods: bool) @return [nil] @overload start(oneshot_lines: true) @return [nil];T;#0;$@;.F;/o;0;1T;2i};3i;Bi;%@θ;9@;:@;;To;4;5F;6;;;;&I"Coverage#resume;F;7[;[[@ָit;T;;;0;[;{;IC; "<Start/resume the coverage measurement. Caveat: Currently, only process-global coverage measurement is supported. You cannot measure per-thread covearge. If your process has multiple thread, using Coverage.resume/suspend to capture code coverage executed from only a limited code block, may yield misleading results. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" resume;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@ ;![;"I"@return [nil];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"^Start/resume the coverage measurement. Caveat: Currently, only process-global coverage measurement is supported. You cannot measure per-thread covearge. If your process has multiple thread, using Coverage.resume/suspend to capture code coverage executed from only a limited code block, may yield misleading results. @overload resume @return [nil];T;#0;$@ ;.F;C0;%@θ;9I"RVALUE rb_coverage_resume(VALUE klass) { if (current_state == IDLE) { rb_raise(rb_eRuntimeError, "coverage measurement is not set up yet"); } if (current_state == RUNNING) { rb_raise(rb_eRuntimeError, "coverage measurement is already running"); } rb_resume_coverages(); current_state = RUNNING; return Qnil; };T;:I" VALUE;T;;To;4;5T;6;;;;&I"Coverage.resume;F;7@ ;@ ;T;;;0;@;{;IC; "<Start/resume the coverage measurement. Caveat: Currently, only process-global coverage measurement is supported. You cannot measure per-thread covearge. If your process has multiple thread, using Coverage.resume/suspend to capture code coverage executed from only a limited code block, may yield misleading results.;T;[o;= ;>I" overload;F;?0;;;@0;:I" resume;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@#;![;"I"@return [nil];T;#0;$@#;.F;Bi;C0;7[;$@#;![;"I"_Start/resume the coverage measurement. Caveat: Currently, only process-global coverage measurement is supported. You cannot measure per-thread covearge. If your process has multiple thread, using Coverage.resume/suspend to capture code coverage executed from only a limited code block, may yield misleading results. @overload resume @return [nil];T;#0;$@#;.F;/o;0;1T;2ii;3ir;Bi;%@θ;9@!;:@";;To;4;5F;6;;;;&I"Coverage#suspend;F;7[;[[@ָia;T;: suspend;0;[;{;IC; "^Suspend the coverage measurement. You can use Coverage.resume to restart the measurement. ;T;[o;= ;>I" overload;F;?0;;( ;@0;:I" suspend;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@8;![;"I"@return [nil];T;#0;$@8;.F;Bi;C0;7[;$@8;![;"I"|Suspend the coverage measurement. You can use Coverage.resume to restart the measurement. @overload suspend @return [nil];T;#0;$@8;.F;C0;%@θ;9I"VALUE rb_coverage_suspend(VALUE klass) { if (current_state != RUNNING) { rb_raise(rb_eRuntimeError, "coverage measurement is not running"); } rb_suspend_coverages(); current_state = SUSPENDED; return Qnil; };T;:I" VALUE;T;;To;4;5T;6;;;;&I"Coverage.suspend;F;7@:;@;;T;;( ;0;@=;{;IC; "^Suspend the coverage measurement. You can use Coverage.resume to restart the measurement.;T;[o;= ;>I" overload;F;?0;;( ;@0;:I" suspend;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@R;![;"I"@return [nil];T;#0;$@R;.F;Bi;C0;7[;$@R;![;"I"}Suspend the coverage measurement. You can use Coverage.resume to restart the measurement. @overload suspend @return [nil];T;#0;$@R;.F;/o;0;1T;2iZ;3i_;Bi;%@θ;9@P;:@Q;;To;4;5F;6;;;;&I"Coverage#result;F;7[[@90;[[@ָit;T;;[ ;0;[;{;IC; "Returns a hash that contains filename as key and coverage array as value. If +clear+ is true, it clears the counters to zero. If +stop+ is true, it disables coverage measurement. ;T;[o;= ;>I" overload;F;?0;;[ ;@0;:I"$result(stop: true, clear: true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@g;![;"I"@return [Hash];T;#0;$@g;.F;Bi;C0;7[[I" stop:;TI" true;T[I" clear:;TI" true;T;$@g;![;"I"Returns a hash that contains filename as key and coverage array as value. If +clear+ is true, it clears the counters to zero. If +stop+ is true, it disables coverage measurement. @overload result(stop: true, clear: true) @return [Hash];T;#0;$@g;.F;C0;%@θ;9I"static VALUE rb_coverage_result(int argc, VALUE *argv, VALUE klass) { VALUE ncoverages; VALUE opt; int stop = 1, clear = 1; if (current_state == IDLE) { rb_raise(rb_eRuntimeError, "coverage measurement is not enabled"); } rb_scan_args(argc, argv, "01", &opt); if (argc == 1) { opt = rb_convert_type(opt, T_HASH, "Hash", "to_hash"); stop = RTEST(rb_hash_lookup(opt, ID2SYM(rb_intern("stop")))); clear = RTEST(rb_hash_lookup(opt, ID2SYM(rb_intern("clear")))); } ncoverages = rb_coverage_peek_result(klass); if (stop && !clear) { rb_warn("stop implies clear"); clear = 1; } if (clear) { rb_clear_coverages(); if (!NIL_P(me2counter)) rb_hash_foreach(me2counter, clear_me2counter_i, Qnil); } if (stop) { if (current_state == RUNNING) { rb_coverage_suspend(klass); } rb_reset_coverages(); me2counter = Qnil; current_state = IDLE; } return ncoverages; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Coverage.result;F;7@i;@k;T;;[ ;0;@m;{;IC; "Returns a hash that contains filename as key and coverage array as value. If +clear+ is true, it clears the counters to zero. If +stop+ is true, it disables coverage measurement.;T;[o;= ;>I" overload;F;?0;;[ ;@0;:I"$result(stop: true, clear: true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@;![;"I"@return [Hash];T;#0;$@;.F;Bi;C0;7[[I" stop:;TI" true;T[I" clear:;TI" true;T;$@;![;"I"Returns a hash that contains filename as key and coverage array as value. If +clear+ is true, it clears the counters to zero. If +stop+ is true, it disables coverage measurement. @overload result(stop: true, clear: true) @return [Hash];T;#0;$@;.F;/o;0;1T;2il;3ir;Bi;%@θ;9@;:@;;To;4;5F;6;;;;&I"Coverage#peek_result;F;7[;[[@ָi?;T;:peek_result;0;[;{;IC; "Returns a hash that contains filename as key and coverage array as value. This is the same as `Coverage.result(stop: false, clear: false)`. { "file.rb" => [1, 2, nil], ... } ;T;[o;= ;>I" overload;F;?0;;) ;@0;:I"peek_result;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@;![;"I"@return [Hash];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a hash that contains filename as key and coverage array as value. This is the same as `Coverage.result(stop: false, clear: false)`. { "file.rb" => [1, 2, nil], ... } @overload peek_result @return [Hash];T;#0;$@;.F;C0;%@θ;9I"static VALUE rb_coverage_peek_result(VALUE klass) { VALUE coverages = rb_get_coverages(); VALUE ncoverages = rb_hash_new(); if (!RTEST(coverages)) { rb_raise(rb_eRuntimeError, "coverage measurement is not enabled"); } OBJ_WB_UNPROTECT(coverages); st_foreach(RHASH_TBL_RAW(coverages), coverage_peek_result_i, ncoverages); if (current_mode & COVERAGE_TARGET_METHODS) { rb_objspace_each_objects(method_coverage_i, &ncoverages); } rb_hash_freeze(ncoverages); return ncoverages; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Coverage.peek_result;F;7@;@;T;;) ;0;@;{;IC; "Returns a hash that contains filename as key and coverage array as value. This is the same as `Coverage.result(stop: false, clear: false)`. { "file.rb" => [1, 2, nil], ... };T;[o;= ;>I" overload;F;?0;;) ;@0;:I"peek_result;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Hash;T;$@;![;"I"@return [Hash];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a hash that contains filename as key and coverage array as value. This is the same as `Coverage.result(stop: false, clear: false)`. { "file.rb" => [1, 2, nil], ... } @overload peek_result @return [Hash];T;#0;$@;.F;/o;0;1T;2i3;3i=;Bi;%@θ;9@;:@;;To;4;5F;6;;;;&I"Coverage#state;F;7[;[[@ָi;T;;;0;[;{;IC; "3Returns the state of the coverage measurement. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" state;T;IC; ";T;[;![;"I";T;#0;$@Һ;.F;Bi;C0;7[;$@Һ;![;"I"DReturns the state of the coverage measurement. @overload state ;T;#0;$@Һ;.F;C0;%@θ;9I"static VALUE rb_coverage_state(VALUE klass) { switch (current_state) { case IDLE: return ID2SYM(rb_intern("idle")); case SUSPENDED: return ID2SYM(rb_intern("suspended")); case RUNNING: return ID2SYM(rb_intern("running")); } return Qnil; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Coverage.state;F;7@Ժ;@պ;T;;;0;@׺;{;IC; "3Returns the state of the coverage measurement.;T;[o;= ;>I" overload;F;?0;;;@0;:I" state;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"EReturns the state of the coverage measurement. @overload state;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@θ;9@;:@;;To;4;5F;6;;;;&I"Coverage#running?;F;7[;[[@ָi;T;: running?;0;[;{;IC; "~Returns true if coverage stats are currently being collected (after Coverage.start call, but before Coverage.result call) ;T;[o;= ;>I" overload;F;?0;;* ;@0;:I" running?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns true if coverage stats are currently being collected (after Coverage.start call, but before Coverage.result call) @overload running? @return [Boolean];T;#0;$@;.F;C0;%@θ;9I"lstatic VALUE rb_coverage_running(VALUE klass) { return current_state == RUNNING ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Coverage.running?;F;7@;@;T;;* ;0;@;{;IC; "~Returns true if coverage stats are currently being collected (after Coverage.start call, but before Coverage.result call);T;[o;= ;>I" overload;F;?0;;* ;@0;:I" running?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns true if coverage stats are currently being collected (after Coverage.start call, but before Coverage.result call) @overload running? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@θ;9@;:@;;T; @θ; IC;[; @θ; IC;[; @θ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ָiO;F;: Coverage;;;;;[;{;IC; " ;T;[;![;"@;#0;$@θ;Bi;%@;&I" Coverage;Fo; ;IC;[o;4;5F;6;;;;&I"&BasicSocket.do_not_reverse_lookup;F;7[;[[I"ext/socket/basicsocket.c;Ti;T;:do_not_reverse_lookup;0;[;{;IC; "`Gets the global do_not_reverse_lookup flag. BasicSocket.do_not_reverse_lookup #=> false ;T;[o;= ;>I" overload;F;?0;;, ;@0;:I"do_not_reverse_lookup;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@7;![;"I"@return [Boolean];T;#0;$@7;.F;Bi;C0;7[;$@7;![;"I"Gets the global do_not_reverse_lookup flag. BasicSocket.do_not_reverse_lookup #=> false @overload do_not_reverse_lookup @return [Boolean];T;#0;$@7;.F;/o;0;1T;2i;3i;%@5;9I"kstatic VALUE bsock_do_not_rev_lookup(VALUE _) { return rsock_do_not_reverse_lookup?Qtrue:Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'BasicSocket.do_not_reverse_lookup=;F;7[[I"val;T0;[[@<i;T;:do_not_reverse_lookup=;0;[;{;IC; "Sets the global do_not_reverse_lookup flag. The flag is used for initial value of do_not_reverse_lookup for each socket. s1 = TCPSocket.new("localhost", 80) p s1.do_not_reverse_lookup #=> true BasicSocket.do_not_reverse_lookup = false s2 = TCPSocket.new("localhost", 80) p s2.do_not_reverse_lookup #=> false p s1.do_not_reverse_lookup #=> true ;T;[o;= ;>I" overload;F;?0;;- ;@0;:I"!do_not_reverse_lookup=(bool);T;IC; ";T;[;![;"I";T;#0;$@S;.F;Bi;C0;7[[I" bool;T0;$@S;![;"I"Sets the global do_not_reverse_lookup flag. The flag is used for initial value of do_not_reverse_lookup for each socket. s1 = TCPSocket.new("localhost", 80) p s1.do_not_reverse_lookup #=> true BasicSocket.do_not_reverse_lookup = false s2 = TCPSocket.new("localhost", 80) p s2.do_not_reverse_lookup #=> false p s1.do_not_reverse_lookup #=> true @overload do_not_reverse_lookup=(bool);T;#0;$@S;.F;/o;0;1T;2i;3i;%@5;9I"static VALUE bsock_do_not_rev_lookup_set(VALUE self, VALUE val) { rsock_do_not_reverse_lookup = RTEST(val); return val; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BasicSocket.for_fd;F;7[[I"_descriptor;T0;[[@<i3;T;;n;0;[;{;IC; "Returns a socket object which contains the file descriptor, _fd_. # If invoked by inetd, STDIN/STDOUT/STDERR is a socket. STDIN_SOCK = Socket.for_fd(STDIN.fileno) p STDIN_SOCK.remote_address ;T;[o;= ;>I" overload;F;?0;;n;@0;:I"for_fd(fd);T;IC; ";T;[;![;"I";T;#0;$@m;.F;Bi;C0;7[[I"fd;T0;$@m;![;"I"Returns a socket object which contains the file descriptor, _fd_. # If invoked by inetd, STDIN/STDOUT/STDERR is a socket. STDIN_SOCK = Socket.for_fd(STDIN.fileno) p STDIN_SOCK.remote_address @overload for_fd(fd);T;#0;$@m;.F;/o;0;1T;2i(;3i0;%@5;9I" static VALUE bsock_s_for_fd(VALUE klass, VALUE _descriptor) { rb_io_t *fptr; int descriptor = RB_NUM2INT(_descriptor); rsock_validate_descriptor(descriptor); VALUE sock = rsock_init_sock(rb_obj_alloc(klass), descriptor); GetOpenFile(sock, fptr); return sock; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BasicSocket#close_read;F;7[;[[@<i~;T;;;0;[;{;IC; "Disallows further read using shutdown system call. s1, s2 = UNIXSocket.pair s1.close_read s2.puts #=> Broken pipe (Errno::EPIPE) ;T;[o;= ;>I" overload;F;?0;;;@0;:I"close_read;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Disallows further read using shutdown system call. s1, s2 = UNIXSocket.pair s1.close_read s2.puts #=> Broken pipe (Errno::EPIPE) @overload close_read @return [nil];T;#0;$@;.F;/o;0;1T;2it;3i|;%@5;9I"static VALUE bsock_close_read(VALUE sock) { rb_io_t *fptr; GetOpenFile(sock, fptr); shutdown(fptr->fd, 0); if (!(fptr->mode & FMODE_WRITABLE)) { return rb_io_close(sock); } fptr->mode &= ~FMODE_READABLE; return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BasicSocket#close_write;F;7[;[[@<i;T;;;0;[;{;IC; "Disallows further write using shutdown system call. UNIXSocket.pair {|s1, s2| s1.print "ping" s1.close_write p s2.read #=> "ping" s2.print "pong" s2.close p s1.read #=> "pong" } ;T;[o;= ;>I" overload;F;?0;;;@0;:I"close_write;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Disallows further write using shutdown system call. UNIXSocket.pair {|s1, s2| s1.print "ping" s1.close_write p s2.read #=> "ping" s2.print "pong" s2.close p s1.read #=> "pong" } @overload close_write @return [nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@5;9I"static VALUE bsock_close_write(VALUE sock) { rb_io_t *fptr; GetOpenFile(sock, fptr); if (!(fptr->mode & FMODE_READABLE)) { return rb_io_close(sock); } shutdown(fptr->fd, 1); fptr->mode &= ~FMODE_WRITABLE; return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BasicSocket#shutdown;F;7[[@90;[[@<i];T;: shutdown;0;[;{;IC; "tCalls shutdown(2) system call. s.shutdown(Socket::SHUT_RD) disallows further read. s.shutdown(Socket::SHUT_WR) disallows further write. s.shutdown(Socket::SHUT_RDWR) disallows further read and write. _how_ can be symbol or string: - :RD, :SHUT_RD, "RD" and "SHUT_RD" are accepted as Socket::SHUT_RD. - :WR, :SHUT_WR, "WR" and "SHUT_WR" are accepted as Socket::SHUT_WR. - :RDWR, :SHUT_RDWR, "RDWR" and "SHUT_RDWR" are accepted as Socket::SHUT_RDWR. UNIXSocket.pair {|s1, s2| s1.puts "ping" s1.shutdown(:WR) p s2.read #=> "ping\n" s2.puts "pong" s2.close p s1.read #=> "pong\n" } ;T;[o;= ;>I" overload;F;?0;;. ;@0;:I"shutdown([how]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@;![;"I"@return [0];T;#0;$@;.F;Bi;C0;7[[I" [how];T0;$@;![;"I"Calls shutdown(2) system call. s.shutdown(Socket::SHUT_RD) disallows further read. s.shutdown(Socket::SHUT_WR) disallows further write. s.shutdown(Socket::SHUT_RDWR) disallows further read and write. _how_ can be symbol or string: - :RD, :SHUT_RD, "RD" and "SHUT_RD" are accepted as Socket::SHUT_RD. - :WR, :SHUT_WR, "WR" and "SHUT_WR" are accepted as Socket::SHUT_WR. - :RDWR, :SHUT_RDWR, "RDWR" and "SHUT_RDWR" are accepted as Socket::SHUT_RDWR. UNIXSocket.pair {|s1, s2| s1.puts "ping" s1.shutdown(:WR) p s2.read #=> "ping\n" s2.puts "pong" s2.close p s1.read #=> "pong\n" } @overload shutdown([how]) @return [0];T;#0;$@;.F;/o;0;1T;2iB;3i[;%@5;9I"static VALUE bsock_shutdown(int argc, VALUE *argv, VALUE sock) { VALUE howto; int how; rb_io_t *fptr; rb_scan_args(argc, argv, "01", &howto); if (howto == Qnil) how = SHUT_RDWR; else { how = rsock_shutdown_how_arg(howto); if (how != SHUT_WR && how != SHUT_RD && how != SHUT_RDWR) { rb_raise(rb_eArgError, "`how' should be either :SHUT_RD, :SHUT_WR, :SHUT_RDWR"); } } GetOpenFile(sock, fptr); if (shutdown(fptr->fd, how) == -1) rb_sys_fail("shutdown(2)"); return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BasicSocket#setsockopt;F;7[[@90;[[@<i;T;:setsockopt;0;[;{;IC; "eSets a socket option. These are protocol and system specific, see your local system documentation for details. === Parameters * +level+ is an integer, usually one of the SOL_ constants such as Socket::SOL_SOCKET, or a protocol level. A string or symbol of the name, possibly without prefix, is also accepted. * +optname+ is an integer, usually one of the SO_ constants, such as Socket::SO_REUSEADDR. A string or symbol of the name, possibly without prefix, is also accepted. * +optval+ is the value of the option, it is passed to the underlying setsockopt() as a pointer to a certain number of bytes. How this is done depends on the type: - Integer: value is assigned to an int, and a pointer to the int is passed, with length of sizeof(int). - true or false: 1 or 0 (respectively) is assigned to an int, and the int is passed as for an Integer. Note that +false+ must be passed, not +nil+. - String: the string's data and length is passed to the socket. * +socketoption+ is an instance of Socket::Option === Examples Some socket options are integers with boolean values, in this case #setsockopt could be called like this: sock.setsockopt(:SOCKET, :REUSEADDR, true) sock.setsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR, true) sock.setsockopt(Socket::Option.bool(:INET, :SOCKET, :REUSEADDR, true)) Some socket options are integers with numeric values, in this case #setsockopt could be called like this: sock.setsockopt(:IP, :TTL, 255) sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_TTL, 255) sock.setsockopt(Socket::Option.int(:INET, :IP, :TTL, 255)) Option values may be structs. Passing them can be complex as it involves examining your system headers to determine the correct definition. An example is an +ip_mreq+, which may be defined in your system headers as: struct ip_mreq { struct in_addr imr_multiaddr; struct in_addr imr_interface; }; In this case #setsockopt could be called like this: optval = IPAddr.new("224.0.0.251").hton + IPAddr.new(Socket::INADDR_ANY, Socket::AF_INET).hton sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, optval) ;T;[o;= ;>I" overload;F;?0;;/ ;@0;:I"'setsockopt(level, optname, optval);T;IC; ";T;[;![;"I";T;#0;$@ۻ;.F;Bi;C0;7[[I" level;T0[I" optname;T0[I" optval;T0;$@ۻo;= ;>I" overload;F;?0;;/ ;@0;:I"setsockopt(socketoption);T;IC; ";T;[;![;"I";T;#0;$@ۻ;.F;Bi;C0;7[[I"socketoption;T0;$@ۻ;![;"I"Sets a socket option. These are protocol and system specific, see your local system documentation for details. === Parameters * +level+ is an integer, usually one of the SOL_ constants such as Socket::SOL_SOCKET, or a protocol level. A string or symbol of the name, possibly without prefix, is also accepted. * +optname+ is an integer, usually one of the SO_ constants, such as Socket::SO_REUSEADDR. A string or symbol of the name, possibly without prefix, is also accepted. * +optval+ is the value of the option, it is passed to the underlying setsockopt() as a pointer to a certain number of bytes. How this is done depends on the type: - Integer: value is assigned to an int, and a pointer to the int is passed, with length of sizeof(int). - true or false: 1 or 0 (respectively) is assigned to an int, and the int is passed as for an Integer. Note that +false+ must be passed, not +nil+. - String: the string's data and length is passed to the socket. * +socketoption+ is an instance of Socket::Option === Examples Some socket options are integers with boolean values, in this case #setsockopt could be called like this: sock.setsockopt(:SOCKET, :REUSEADDR, true) sock.setsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR, true) sock.setsockopt(Socket::Option.bool(:INET, :SOCKET, :REUSEADDR, true)) Some socket options are integers with numeric values, in this case #setsockopt could be called like this: sock.setsockopt(:IP, :TTL, 255) sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_TTL, 255) sock.setsockopt(Socket::Option.int(:INET, :IP, :TTL, 255)) Option values may be structs. Passing them can be complex as it involves examining your system headers to determine the correct definition. An example is an +ip_mreq+, which may be defined in your system headers as: struct ip_mreq { struct in_addr imr_multiaddr; struct in_addr imr_interface; }; In this case #setsockopt could be called like this: optval = IPAddr.new("224.0.0.251").hton + IPAddr.new(Socket::INADDR_ANY, Socket::AF_INET).hton sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, optval) @overload setsockopt(level, optname, optval) @overload setsockopt(socketoption);T;#0;$@ۻ;.F;/o;0;1T;2i;3i;%@5;9I"^static VALUE bsock_setsockopt(int argc, VALUE *argv, VALUE sock) { VALUE lev, optname, val; int family, level, option; rb_io_t *fptr; int i; char *v; int vlen; if (argc == 1) { lev = rb_funcall(argv[0], rb_intern("level"), 0); optname = rb_funcall(argv[0], rb_intern("optname"), 0); val = rb_funcall(argv[0], rb_intern("data"), 0); } else { rb_scan_args(argc, argv, "30", &lev, &optname, &val); } GetOpenFile(sock, fptr); family = rsock_getfamily(fptr); level = rsock_level_arg(family, lev); option = rsock_optname_arg(family, level, optname); switch (TYPE(val)) { case T_FIXNUM: i = FIX2INT(val); goto numval; case T_FALSE: i = 0; goto numval; case T_TRUE: i = 1; numval: v = (char*)&i; vlen = (int)sizeof(i); break; default: StringValue(val); v = RSTRING_PTR(val); vlen = RSTRING_SOCKLEN(val); break; } rb_io_check_closed(fptr); if (setsockopt(fptr->fd, level, option, v, vlen) < 0) rsock_sys_fail_path("setsockopt(2)", fptr->pathv); return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BasicSocket#getsockopt;F;7[[I"lev;T0[I" optname;T0;[[@<iI;T;:getsockopt;0;[;{;IC; "Gets a socket option. These are protocol and system specific, see your local system documentation for details. The option is returned as a Socket::Option object. === Parameters * +level+ is an integer, usually one of the SOL_ constants such as Socket::SOL_SOCKET, or a protocol level. A string or symbol of the name, possibly without prefix, is also accepted. * +optname+ is an integer, usually one of the SO_ constants, such as Socket::SO_REUSEADDR. A string or symbol of the name, possibly without prefix, is also accepted. === Examples Some socket options are integers with boolean values, in this case #getsockopt could be called like this: reuseaddr = sock.getsockopt(:SOCKET, :REUSEADDR).bool optval = sock.getsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR) optval = optval.unpack "i" reuseaddr = optval[0] == 0 ? false : true Some socket options are integers with numeric values, in this case #getsockopt could be called like this: ipttl = sock.getsockopt(:IP, :TTL).int optval = sock.getsockopt(Socket::IPPROTO_IP, Socket::IP_TTL) ipttl = optval.unpack1("i") Option values may be structs. Decoding them can be complex as it involves examining your system headers to determine the correct definition. An example is a +struct linger+, which may be defined in your system headers as: struct linger { int l_onoff; int l_linger; }; In this case #getsockopt could be called like this: # Socket::Option knows linger structure. onoff, linger = sock.getsockopt(:SOCKET, :LINGER).linger optval = sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER) onoff, linger = optval.unpack "ii" onoff = onoff == 0 ? false : true ;T;[o;= ;>I" overload;F;?0;;0 ;@0;:I"getsockopt(level, optname);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" level;T0[I" optname;T0;$@;![;"I"Gets a socket option. These are protocol and system specific, see your local system documentation for details. The option is returned as a Socket::Option object. === Parameters * +level+ is an integer, usually one of the SOL_ constants such as Socket::SOL_SOCKET, or a protocol level. A string or symbol of the name, possibly without prefix, is also accepted. * +optname+ is an integer, usually one of the SO_ constants, such as Socket::SO_REUSEADDR. A string or symbol of the name, possibly without prefix, is also accepted. === Examples Some socket options are integers with boolean values, in this case #getsockopt could be called like this: reuseaddr = sock.getsockopt(:SOCKET, :REUSEADDR).bool optval = sock.getsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR) optval = optval.unpack "i" reuseaddr = optval[0] == 0 ? false : true Some socket options are integers with numeric values, in this case #getsockopt could be called like this: ipttl = sock.getsockopt(:IP, :TTL).int optval = sock.getsockopt(Socket::IPPROTO_IP, Socket::IP_TTL) ipttl = optval.unpack1("i") Option values may be structs. Decoding them can be complex as it involves examining your system headers to determine the correct definition. An example is a +struct linger+, which may be defined in your system headers as: struct linger { int l_onoff; int l_linger; }; In this case #getsockopt could be called like this: # Socket::Option knows linger structure. onoff, linger = sock.getsockopt(:SOCKET, :LINGER).linger optval = sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER) onoff, linger = optval.unpack "ii" onoff = onoff == 0 ? false : true @overload getsockopt(level, optname);T;#0;$@;.F;/o;0;1T;2i;3iE;%@5;9I"bstatic VALUE bsock_getsockopt(VALUE sock, VALUE lev, VALUE optname) { int level, option; socklen_t len; char *buf; rb_io_t *fptr; int family; GetOpenFile(sock, fptr); family = rsock_getfamily(fptr); level = rsock_level_arg(family, lev); option = rsock_optname_arg(family, level, optname); len = 256; #ifdef _AIX switch (option) { case SO_DEBUG: case SO_REUSEADDR: case SO_KEEPALIVE: case SO_DONTROUTE: case SO_BROADCAST: case SO_OOBINLINE: /* AIX doesn't set len for boolean options */ len = sizeof(int); } #endif buf = ALLOCA_N(char,len); rb_io_check_closed(fptr); if (getsockopt(fptr->fd, level, option, buf, &len) < 0) rsock_sys_fail_path("getsockopt(2)", fptr->pathv); return rsock_sockopt_new(family, level, option, rb_str_new(buf, len)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BasicSocket#getsockname;F;7[;[[@<iz;T;:getsockname;0;[;{;IC; ""Returns the local address of the socket as a sockaddr string. TCPServer.open("127.0.0.1", 15120) {|serv| p serv.getsockname #=> "\x02\x00;\x10\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" } If Addrinfo object is preferred over the binary string, use BasicSocket#local_address. ;T;[o;= ;>I" overload;F;?0;;1 ;@0;:I"getsockname;T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I":Returns the local address of the socket as a sockaddr string. TCPServer.open("127.0.0.1", 15120) {|serv| p serv.getsockname #=> "\x02\x00;\x10\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" } If Addrinfo object is preferred over the binary string, use BasicSocket#local_address. @overload getsockname;T;#0;$@ ;.F;/o;0;1T;2im;3iw;%@5;9I"Ystatic VALUE bsock_getsockname(VALUE sock) { union_sockaddr buf; socklen_t len = (socklen_t)sizeof buf; socklen_t len0 = len; rb_io_t *fptr; GetOpenFile(sock, fptr); if (getsockname(fptr->fd, &buf.addr, &len) < 0) rb_sys_fail("getsockname(2)"); if (len0 < len) len = len0; return rb_str_new((char*)&buf, len); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BasicSocket#getpeername;F;7[;[[@<i;T;:getpeername;0;[;{;IC; "]Returns the remote address of the socket as a sockaddr string. TCPServer.open("127.0.0.1", 1440) {|serv| c = TCPSocket.new("127.0.0.1", 1440) s = serv.accept p s.getpeername #=> "\x02\x00\x82u\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" } If Addrinfo object is preferred over the binary string, use BasicSocket#remote_address. ;T;[o;= ;>I" overload;F;?0;;2 ;@0;:I"getpeername;T;IC; ";T;[;![;"I";T;#0;$@6;.F;Bi;C0;7[;$@6;![;"I"vReturns the remote address of the socket as a sockaddr string. TCPServer.open("127.0.0.1", 1440) {|serv| c = TCPSocket.new("127.0.0.1", 1440) s = serv.accept p s.getpeername #=> "\x02\x00\x82u\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" } If Addrinfo object is preferred over the binary string, use BasicSocket#remote_address. @overload getpeername;T;#0;$@6;.F;/o;0;1T;2i;3i;%@5;9I"Ystatic VALUE bsock_getpeername(VALUE sock) { union_sockaddr buf; socklen_t len = (socklen_t)sizeof buf; socklen_t len0 = len; rb_io_t *fptr; GetOpenFile(sock, fptr); if (getpeername(fptr->fd, &buf.addr, &len) < 0) rb_sys_fail("getpeername(2)"); if (len0 < len) len = len0; return rb_str_new((char*)&buf, len); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BasicSocket#getpeereid;F;7[;[[@<i;T;:getpeereid;0;[;{;IC; "Returns the user and group on the peer of the UNIX socket. The result is a two element array which contains the effective uid and the effective gid. Socket.unix_server_loop("/tmp/sock") {|s| begin euid, egid = s.getpeereid # Check the connected client is myself or not. next if euid != Process.uid # do something about my resource. ensure s.close end } ;T;[o;= ;>I" overload;F;?0;;3 ;@0;:I"getpeereid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@L;![;"I"@return [Array];T;#0;$@L;.F;Bi;C0;7[;$@L;![;"I"Returns the user and group on the peer of the UNIX socket. The result is a two element array which contains the effective uid and the effective gid. Socket.unix_server_loop("/tmp/sock") {|s| begin euid, egid = s.getpeereid # Check the connected client is myself or not. next if euid != Process.uid # do something about my resource. ensure s.close end } @overload getpeereid @return [Array];T;#0;$@L;.F;/o;0;1T;2i;3i;%@5;9I"static VALUE bsock_getpeereid(VALUE self) { #if defined(HAVE_GETPEEREID) rb_io_t *fptr; uid_t euid; gid_t egid; GetOpenFile(self, fptr); if (getpeereid(fptr->fd, &euid, &egid) == -1) rb_sys_fail("getpeereid(3)"); return rb_assoc_new(UIDT2NUM(euid), GIDT2NUM(egid)); #elif defined(SO_PEERCRED) /* GNU/Linux */ rb_io_t *fptr; struct ucred cred; socklen_t len = sizeof(cred); GetOpenFile(self, fptr); if (getsockopt(fptr->fd, SOL_SOCKET, SO_PEERCRED, &cred, &len) == -1) rb_sys_fail("getsockopt(SO_PEERCRED)"); return rb_assoc_new(UIDT2NUM(cred.uid), GIDT2NUM(cred.gid)); #elif defined(HAVE_GETPEERUCRED) /* Solaris */ rb_io_t *fptr; ucred_t *uc = NULL; VALUE ret; GetOpenFile(self, fptr); if (getpeerucred(fptr->fd, &uc) == -1) rb_sys_fail("getpeerucred(3C)"); ret = rb_assoc_new(UIDT2NUM(ucred_geteuid(uc)), GIDT2NUM(ucred_getegid(uc))); ucred_free(uc); return ret; #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BasicSocket#local_address;F;7[;[[@<i;T;:local_address;0;[;{;IC; "SReturns an Addrinfo object for local address obtained by getsockname. Note that addrinfo.protocol is filled by 0. TCPSocket.open("www.ruby-lang.org", 80) {|s| p s.local_address #=> # } TCPServer.open("127.0.0.1", 1512) {|serv| p serv.local_address #=> # } ;T;[o;= ;>I" overload;F;?0;;4 ;@0;:I"local_address;T;IC; ";T;[;![;"I";T;#0;$@g;.F;Bi;C0;7[;$@g;![;"I"nReturns an Addrinfo object for local address obtained by getsockname. Note that addrinfo.protocol is filled by 0. TCPSocket.open("www.ruby-lang.org", 80) {|s| p s.local_address #=> # } TCPServer.open("127.0.0.1", 1512) {|serv| p serv.local_address #=> # } @overload local_address;T;#0;$@g;.F;/o;0;1T;2i;3i;%@5;9I"qstatic VALUE bsock_local_address(VALUE sock) { union_sockaddr buf; socklen_t len = (socklen_t)sizeof buf; socklen_t len0 = len; rb_io_t *fptr; GetOpenFile(sock, fptr); if (getsockname(fptr->fd, &buf.addr, &len) < 0) rb_sys_fail("getsockname(2)"); if (len0 < len) len = len0; return rsock_fd_socket_addrinfo(fptr->fd, &buf.addr, len); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BasicSocket#remote_address;F;7[;[[@<i;T;:remote_address;0;[;{;IC; "Returns an Addrinfo object for remote address obtained by getpeername. Note that addrinfo.protocol is filled by 0. TCPSocket.open("www.ruby-lang.org", 80) {|s| p s.remote_address #=> # } TCPServer.open("127.0.0.1", 1728) {|serv| c = TCPSocket.new("127.0.0.1", 1728) s = serv.accept p s.remote_address #=> # } ;T;[o;= ;>I" overload;F;?0;;5 ;@0;:I"remote_address;T;IC; ";T;[;![;"I";T;#0;$@};.F;Bi;C0;7[;$@};![;"I"Returns an Addrinfo object for remote address obtained by getpeername. Note that addrinfo.protocol is filled by 0. TCPSocket.open("www.ruby-lang.org", 80) {|s| p s.remote_address #=> # } TCPServer.open("127.0.0.1", 1728) {|serv| c = TCPSocket.new("127.0.0.1", 1728) s = serv.accept p s.remote_address #=> # } @overload remote_address;T;#0;$@};.F;/o;0;1T;2i;3i;%@5;9I"rstatic VALUE bsock_remote_address(VALUE sock) { union_sockaddr buf; socklen_t len = (socklen_t)sizeof buf; socklen_t len0 = len; rb_io_t *fptr; GetOpenFile(sock, fptr); if (getpeername(fptr->fd, &buf.addr, &len) < 0) rb_sys_fail("getpeername(2)"); if (len0 < len) len = len0; return rsock_fd_socket_addrinfo(fptr->fd, &buf.addr, len); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"BasicSocket#send;F;7[[@90;[[@<i5;T;;{;0;[;{;IC; "send _mesg_ via _basicsocket_. _mesg_ should be a string. _flags_ should be a bitwise OR of Socket::MSG_* constants. _dest_sockaddr_ should be a packed sockaddr string or an addrinfo. TCPSocket.open("localhost", 80) {|s| s.send "GET / HTTP/1.0\r\n\r\n", 0 p s.read } ;T;[o;= ;>I" overload;F;?0;;{;@0;:I"(send(mesg, flags [, dest_sockaddr]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" mesg;T0[I"flags[, dest_sockaddr];T0;$@;![;"I"Jsend _mesg_ via _basicsocket_. _mesg_ should be a string. _flags_ should be a bitwise OR of Socket::MSG_* constants. _dest_sockaddr_ should be a packed sockaddr string or an addrinfo. TCPSocket.open("localhost", 80) {|s| s.send "GET / HTTP/1.0\r\n\r\n", 0 p s.read } @overload send(mesg, flags [, dest_sockaddr]);T;#0;$@;.F;/o;0;1T;2i$;3i2;%@5;9I"2VALUE rsock_bsock_send(int argc, VALUE *argv, VALUE socket) { struct rsock_send_arg arg; VALUE flags, to; rb_io_t *fptr; rb_blocking_function_t *func; const char *funcname; rb_scan_args(argc, argv, "21", &arg.mesg, &flags, &to); StringValue(arg.mesg); if (!NIL_P(to)) { SockAddrStringValue(to); to = rb_str_new4(to); arg.to = (struct sockaddr *)RSTRING_PTR(to); arg.tolen = RSTRING_SOCKLEN(to); func = rsock_sendto_blocking; funcname = "sendto(2)"; } else { func = rsock_send_blocking; funcname = "send(2)"; } RB_IO_POINTER(socket, fptr); arg.fd = fptr->fd; arg.flags = NUM2INT(flags); while (true) { #ifdef RSOCK_WAIT_BEFORE_BLOCKING rb_io_wait(socket, RB_INT2NUM(RUBY_IO_WRITABLE), Qnil); #endif ssize_t n = (ssize_t)BLOCKING_REGION_FD(func, &arg); if (n >= 0) return SSIZET2NUM(n); if (rb_io_maybe_wait_writable(errno, socket, Qnil)) { continue; } rb_sys_fail(funcname); } };T;:I" VALUE;T;;To;4;5F;6;;;;&I"BasicSocket#recv;F;7[[@90;[[@<i;T;: recv;0;[;{;IC; "Receives a message. _maxlen_ is the maximum number of bytes to receive. _flags_ should be a bitwise OR of Socket::MSG_* constants. _outbuf_ will contain only the received data after the method call even if it is not empty at the beginning. UNIXSocket.pair {|s1, s2| s1.puts "Hello World" p s2.recv(4) #=> "Hell" p s2.recv(4, Socket::MSG_PEEK) #=> "o Wo" p s2.recv(4) #=> "o Wo" p s2.recv(10) #=> "rld\n" } ;T;[o;= ;>I" overload;F;?0;;6 ;@0;:I"$recv(maxlen[, flags[, outbuf]]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"maxlen[, flags[, outbuf]];T0;$@;![;"I"Receives a message. _maxlen_ is the maximum number of bytes to receive. _flags_ should be a bitwise OR of Socket::MSG_* constants. _outbuf_ will contain only the received data after the method call even if it is not empty at the beginning. UNIXSocket.pair {|s1, s2| s1.puts "Hello World" p s2.recv(4) #=> "Hell" p s2.recv(4, Socket::MSG_PEEK) #=> "o Wo" p s2.recv(4) #=> "o Wo" p s2.recv(10) #=> "rld\n" } @overload recv(maxlen[, flags[, outbuf]]);T;#0;$@;.F;/o;0;1T;2i;3i;%@5;9I"}static VALUE bsock_recv(int argc, VALUE *argv, VALUE sock) { return rsock_s_recvfrom(sock, argc, argv, RECV_RECV); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&BasicSocket#do_not_reverse_lookup;F;7[;[[@<iu;T;;, ;0;[;{;IC; "lGets the do_not_reverse_lookup flag of _basicsocket_. require 'socket' BasicSocket.do_not_reverse_lookup = false TCPSocket.open("www.ruby-lang.org", 80) {|sock| p sock.do_not_reverse_lookup #=> false } BasicSocket.do_not_reverse_lookup = true TCPSocket.open("www.ruby-lang.org", 80) {|sock| p sock.do_not_reverse_lookup #=> true } ;T;[o;= ;>I" overload;F;?0;;, ;@0;:I"do_not_reverse_lookup;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@Ǽ;![;"I"@return [Boolean];T;#0;$@Ǽ;.F;Bi;C0;7[;$@Ǽ;![;"I"Gets the do_not_reverse_lookup flag of _basicsocket_. require 'socket' BasicSocket.do_not_reverse_lookup = false TCPSocket.open("www.ruby-lang.org", 80) {|sock| p sock.do_not_reverse_lookup #=> false } BasicSocket.do_not_reverse_lookup = true TCPSocket.open("www.ruby-lang.org", 80) {|sock| p sock.do_not_reverse_lookup #=> true } @overload do_not_reverse_lookup @return [Boolean];T;#0;$@Ǽ;.F;/o;0;1T;2id;3is;%@5;9I"static VALUE bsock_do_not_reverse_lookup(VALUE sock) { rb_io_t *fptr; GetOpenFile(sock, fptr); return (fptr->mode & FMODE_NOREVLOOKUP) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'BasicSocket#do_not_reverse_lookup=;F;7[[I" state;T0;[[@<i;T;;- ;0;[;{;IC; "Sets the do_not_reverse_lookup flag of _basicsocket_. TCPSocket.open("www.ruby-lang.org", 80) {|sock| p sock.do_not_reverse_lookup #=> true p sock.peeraddr #=> ["AF_INET", 80, "221.186.184.68", "221.186.184.68"] sock.do_not_reverse_lookup = false p sock.peeraddr #=> ["AF_INET", 80, "carbon.ruby-lang.org", "54.163.249.195"] } ;T;[o;= ;>I" overload;F;?0;;- ;@0;:I"!do_not_reverse_lookup=(bool);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" bool;T0;$@;![;"I"Sets the do_not_reverse_lookup flag of _basicsocket_. TCPSocket.open("www.ruby-lang.org", 80) {|sock| p sock.do_not_reverse_lookup #=> true p sock.peeraddr #=> ["AF_INET", 80, "221.186.184.68", "221.186.184.68"] sock.do_not_reverse_lookup = false p sock.peeraddr #=> ["AF_INET", 80, "carbon.ruby-lang.org", "54.163.249.195"] } @overload do_not_reverse_lookup=(bool);T;#0;$@;.F;/o;0;1T;2i~;3i;%@5;9I"static VALUE bsock_do_not_reverse_lookup_set(VALUE sock, VALUE state) { rb_io_t *fptr; GetOpenFile(sock, fptr); if (RTEST(state)) { fptr->mode |= FMODE_NOREVLOOKUP; } else { fptr->mode &= ~FMODE_NOREVLOOKUP; } return sock; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" BasicSocket#__recv_nonblock;F;7[ [I"len;T0[I"flg;T0[I"str;T0[I"ex;T0;[[@<i;T;:__recv_nonblock;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2i;3i;%@5;9I"static VALUE bsock_recv_nonblock(VALUE sock, VALUE len, VALUE flg, VALUE str, VALUE ex) { return rsock_s_recvfrom_nonblock(sock, len, flg, str, ex, RECV_RECV); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" BasicSocket#__read_nonblock;F;7[;[;F;:__read_nonblock;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@5;;To;4;5F;6;;;;&I"!BasicSocket#__write_nonblock;F;7[;[;F;:__write_nonblock;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@5;;To;4;5F;6;;;;&I"BasicSocket#__sendmsg;F;7[;[;F;:__sendmsg;;;[;{;IC; " ;T;[;![;"@;#0;$@$;%@5;;To;4;5F;6;;;;&I"#BasicSocket#__sendmsg_nonblock;F;7[;[;F;:__sendmsg_nonblock;;;[;{;IC; " ;T;[;![;"@;#0;$@-;%@5;;To;4;5F;6;;;;&I"BasicSocket#__recvmsg;F;7[;[;F;:__recvmsg;;;[;{;IC; " ;T;[;![;"@;#0;$@6;%@5;;To;4;5F;6;;;;&I"#BasicSocket#__recvmsg_nonblock;F;7[;[;F;:__recvmsg_nonblock;;;[;{;IC; " ;T;[;![;"@;#0;$@?;%@5;;T; @5; IC;[; @5; IC;[; @5; IC;{;IC;{;T;IC;{;T;T;{;[;[[@<i[@<i;T;:BasicSocket;;;;;[;{;IC; "?BasicSocket is the super class for all the Socket classes. ;T;[;![;"I"A BasicSocket is the super class for all the Socket classes. ;T;#0;$@5;.F;/o;0;1T;2i;3i;%@;&I"BasicSocket;F;'o;( ;)0;*0;+0;;;%@;-@kL;0o; ;IC;[ o;4;5F;6;;;;&I"UNIXServer#initialize;F;7[[I" path;T0;[[I"ext/socket/unixserver.c;Ti;T;;D;0;[;{;IC; "Creates a new UNIX server socket bound to _path_. require 'socket' serv = UNIXServer.new("/tmp/sock") s = serv.accept p s.read ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(path);T;IC; ";T;[;![;"I";T;#0;$@];.F;Bi;C0;7[[I" path;T0;$@];![;"I"Creates a new UNIX server socket bound to _path_. require 'socket' serv = UNIXServer.new("/tmp/sock") s = serv.accept p s.read @overload new(path);T;#0;$@];.F;/o;0;1T;2i;3i;%@[;9I"jstatic VALUE unix_svr_init(VALUE sock, VALUE path) { return rsock_init_unixsock(sock, path, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UNIXServer#accept;F;7[;[[@di6;T;;;0;[;{;IC; "Accepts an incoming connection. It returns a new UNIXSocket object. UNIXServer.open("/tmp/sock") {|serv| UNIXSocket.open("/tmp/sock") {|c| s = serv.accept s.puts "hi" s.close p c.read #=> "hi\n" } } ;T;[o;= ;>I" overload;F;?0;;;@0;:I" accept;T;IC; ";T;[;![;"I";T;#0;$@x;.F;Bi;C0;7[;$@x;![;"I"Accepts an incoming connection. It returns a new UNIXSocket object. UNIXServer.open("/tmp/sock") {|serv| UNIXSocket.open("/tmp/sock") {|c| s = serv.accept s.puts "hi" s.close p c.read #=> "hi\n" } } @overload accept;T;#0;$@x;.F;/o;0;1T;2i%;3i3;%@[;9I"static VALUE unix_accept(VALUE server) { struct sockaddr_un buffer; socklen_t length = sizeof(buffer); return rsock_s_accept(rb_cUNIXSocket, server, (struct sockaddr*)&buffer, &length); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!UNIXServer#__accept_nonblock;F;7[[I"ex;T0;[[@di@;T;:__accept_nonblock;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2i?;3i?;%@[;9I"7static VALUE unix_accept_nonblock(VALUE sock, VALUE ex) { rb_io_t *fptr; struct sockaddr_un from; socklen_t fromlen; GetOpenFile(sock, fptr); fromlen = (socklen_t)sizeof(from); return rsock_s_accept_nonblock(rb_cUNIXSocket, ex, fptr, (struct sockaddr *)&from, &fromlen); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UNIXServer#sysaccept;F;7[;[[@di_;T;:sysaccept;0;[;{;IC; "Accepts a new connection. It returns the new file descriptor which is an integer. UNIXServer.open("/tmp/sock") {|serv| UNIXSocket.open("/tmp/sock") {|c| fd = serv.sysaccept s = IO.new(fd) s.puts "hi" s.close p c.read #=> "hi\n" } } ;T;[o;= ;>I" overload;F;?0;;@ ;@0;:I"sysaccept;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I")Accepts a new connection. It returns the new file descriptor which is an integer. UNIXServer.open("/tmp/sock") {|serv| UNIXSocket.open("/tmp/sock") {|c| fd = serv.sysaccept s = IO.new(fd) s.puts "hi" s.close p c.read #=> "hi\n" } } @overload sysaccept;T;#0;$@;.F;/o;0;1T;2iM;3i\;%@[;9I"static VALUE unix_sysaccept(VALUE server) { struct sockaddr_un buffer; socklen_t length = sizeof(buffer); return rsock_s_accept(0, server, (struct sockaddr*)&buffer, &length); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UNIXServer#listen;F;7[;[;F;: listen;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@[;;T; @[; IC;[; @[; IC;[; @[; IC;{;IC;{;T;IC;{;T;T;{;[;[[@din[@dit;T;:UNIXServer;;;;;[;{;IC; ">UNIXServer represents a UNIX domain stream server socket. ;T;[;![;"I"A UNIXServer represents a UNIX domain stream server socket. ;T;#0;$@[;.F;/o;0;1T;2in;3iq;%@;&I"UNIXServer;F;'o;( ;)0;*0;+0;:UNIXSocket;%@;-o; ;IC;[o;4;5F;6;;;;&I"UNIXSocket#initialize;F;7[[I" path;T0;[[I"ext/socket/unixsocket.c;Ti{;T;;D;0;[;{;IC; "Creates a new UNIX client socket connected to _path_. require 'socket' s = UNIXSocket.new("/tmp/sock") s.send "hello", 0 ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(path);T;IC; ";T;[;![;"I";T;#0;$@ҽ;.F;Bi;C0;7[[I" path;T0;$@ҽ;![;"I"Creates a new UNIX client socket connected to _path_. require 'socket' s = UNIXSocket.new("/tmp/sock") s.send "hello", 0 @overload new(path);T;#0;$@ҽ;.F;/o;0;1T;2it;3i};%@н;9I"fstatic VALUE unix_init(VALUE sock, VALUE path) { return rsock_init_unixsock(sock, path, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UNIXSocket#path;F;7[;[[@ٽi;T;;O;0;[;{;IC; "wReturns the path of the local address of unixsocket. s = UNIXServer.new("/tmp/sock") p s.path #=> "/tmp/sock" ;T;[o;= ;>I" overload;F;?0;;O;@0;:I" path;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the path of the local address of unixsocket. s = UNIXServer.new("/tmp/sock") p s.path #=> "/tmp/sock" @overload path;T;#0;$@;.F;/o;0;1T;2i;3i;%@н;9I"static VALUE unix_path(VALUE sock) { rb_io_t *fptr; GetOpenFile(sock, fptr); if (NIL_P(fptr->pathv)) { struct sockaddr_un addr; socklen_t len = (socklen_t)sizeof(addr); socklen_t len0 = len; if (getsockname(fptr->fd, (struct sockaddr*)&addr, &len) < 0) rsock_sys_fail_path("getsockname(2)", fptr->pathv); if (len0 < len) len = len0; fptr->pathv = rb_obj_freeze(rsock_unixpath_str(&addr, len)); } return rb_str_dup(fptr->pathv); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UNIXSocket#addr;F;7[;[[@ٽi;T;: addr;0;[;{;IC; "Returns the local address as an array which contains address_family and unix_path. Example serv = UNIXServer.new("/tmp/sock") p serv.addr #=> ["AF_UNIX", "/tmp/sock"] ;T;[o;= ;>I" overload;F;?0;;D ;@0;:I" addr;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the local address as an array which contains address_family and unix_path. Example serv = UNIXServer.new("/tmp/sock") p serv.addr #=> ["AF_UNIX", "/tmp/sock"] @overload addr @return [Array];T;#0;$@;.F;/o;0;1T;2i;3i;%@н;9I"static VALUE unix_addr(VALUE sock) { rb_io_t *fptr; struct sockaddr_un addr; socklen_t len = (socklen_t)sizeof addr; socklen_t len0 = len; GetOpenFile(sock, fptr); if (getsockname(fptr->fd, (struct sockaddr*)&addr, &len) < 0) rsock_sys_fail_path("getsockname(2)", fptr->pathv); if (len0 < len) len = len0; return rsock_unixaddr(&addr, len); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UNIXSocket#peeraddr;F;7[;[[@ٽi;T;: peeraddr;0;[;{;IC; "Returns the remote address as an array which contains address_family and unix_path. Example serv = UNIXServer.new("/tmp/sock") c = UNIXSocket.new("/tmp/sock") p c.peeraddr #=> ["AF_UNIX", "/tmp/sock"] ;T;[o;= ;>I" overload;F;?0;;E ;@0;:I" peeraddr;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the remote address as an array which contains address_family and unix_path. Example serv = UNIXServer.new("/tmp/sock") c = UNIXSocket.new("/tmp/sock") p c.peeraddr #=> ["AF_UNIX", "/tmp/sock"] @overload peeraddr @return [Array];T;#0;$@;.F;/o;0;1T;2i;3i;%@н;9I"static VALUE unix_peeraddr(VALUE sock) { rb_io_t *fptr; struct sockaddr_un addr; socklen_t len = (socklen_t)sizeof addr; socklen_t len0 = len; GetOpenFile(sock, fptr); if (getpeername(fptr->fd, (struct sockaddr*)&addr, &len) < 0) rsock_sys_fail_path("getpeername(2)", fptr->pathv); if (len0 < len) len = len0; return rsock_unixaddr(&addr, len); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UNIXSocket#recvfrom;F;7[[@90;[[@ٽi;T;: recvfrom;0;[;{;IC; "1Receives a message via _unixsocket_. _maxlen_ is the maximum number of bytes to receive. _flags_ should be a bitwise OR of Socket::MSG_* constants. _outbuf_ will contain only the received data after the method call even if it is not empty at the beginning. s1 = Socket.new(:UNIX, :DGRAM, 0) s1_ai = Addrinfo.unix("/tmp/sock1") s1.bind(s1_ai) s2 = Socket.new(:UNIX, :DGRAM, 0) s2_ai = Addrinfo.unix("/tmp/sock2") s2.bind(s2_ai) s3 = UNIXSocket.for_fd(s2.fileno) s1.send "a", 0, s2_ai p s3.recvfrom(10) #=> ["a", ["AF_UNIX", "/tmp/sock1"]] ;T;[o;= ;>I" overload;F;?0;;F ;@0;:I")recvfrom(maxlen [, flags[, outbuf]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@9;![;"I"@return [Array];T;#0;$@9;.F;Bi;C0;7[[I"maxlen[, flags[, outbuf]];T0;$@9;![;"I"uReceives a message via _unixsocket_. _maxlen_ is the maximum number of bytes to receive. _flags_ should be a bitwise OR of Socket::MSG_* constants. _outbuf_ will contain only the received data after the method call even if it is not empty at the beginning. s1 = Socket.new(:UNIX, :DGRAM, 0) s1_ai = Addrinfo.unix("/tmp/sock1") s1.bind(s1_ai) s2 = Socket.new(:UNIX, :DGRAM, 0) s2_ai = Addrinfo.unix("/tmp/sock2") s2.bind(s2_ai) s3 = UNIXSocket.for_fd(s2.fileno) s1.send "a", 0, s2_ai p s3.recvfrom(10) #=> ["a", ["AF_UNIX", "/tmp/sock1"]] @overload recvfrom(maxlen [, flags[, outbuf]]) @return [Array];T;#0;$@9;.F;/o;0;1T;2i;3i;%@н;9I"{static VALUE unix_recvfrom(int argc, VALUE *argv, VALUE sock) { return rsock_s_recvfrom(sock, argc, argv, RECV_UNIX); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UNIXSocket#send_io;F;7[[I"val;T0;[[@ٽi;T;: send_io;0;[;{;IC; "Sends _io_ as file descriptor passing. s1, s2 = UNIXSocket.pair s1.send_io STDOUT stdout = s2.recv_io p STDOUT.fileno #=> 1 p stdout.fileno #=> 6 stdout.puts "hello" # outputs "hello\n" to standard output. _io_ may be any kind of IO object or integer file descriptor. ;T;[o;= ;>I" overload;F;?0;;G ;@0;:I"send_io(io);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@W;![;"I"@return [nil];T;#0;$@W;.F;Bi;C0;7[[I"io;T0;$@W;![;"I"DSends _io_ as file descriptor passing. s1, s2 = UNIXSocket.pair s1.send_io STDOUT stdout = s2.recv_io p STDOUT.fileno #=> 1 p stdout.fileno #=> 6 stdout.puts "hello" # outputs "hello\n" to standard output. _io_ may be any kind of IO object or integer file descriptor. @overload send_io(io) @return [nil];T;#0;$@W;.F;/o;0;1T;2i;3i;%@н;9I"static VALUE unix_send_io(VALUE sock, VALUE val) { int fd; rb_io_t *fptr; struct iomsg_arg arg; struct iovec vec[1]; char buf[1]; #if FD_PASSING_BY_MSG_CONTROL union { struct cmsghdr hdr; char pad[sizeof(struct cmsghdr)+8+sizeof(int)+8]; } cmsg; #endif if (rb_obj_is_kind_of(val, rb_cIO)) { rb_io_t *valfptr; GetOpenFile(val, valfptr); fd = valfptr->fd; } else if (FIXNUM_P(val)) { fd = FIX2INT(val); } else { rb_raise(rb_eTypeError, "neither IO nor file descriptor"); } GetOpenFile(sock, fptr); arg.msg.msg_name = NULL; arg.msg.msg_namelen = 0; /* Linux and Solaris doesn't work if msg_iov is NULL. */ buf[0] = '\0'; vec[0].iov_base = buf; vec[0].iov_len = 1; arg.msg.msg_iov = vec; arg.msg.msg_iovlen = 1; #if FD_PASSING_BY_MSG_CONTROL arg.msg.msg_control = (caddr_t)&cmsg; arg.msg.msg_controllen = (socklen_t)CMSG_LEN(sizeof(int)); arg.msg.msg_flags = 0; MEMZERO((char*)&cmsg, char, sizeof(cmsg)); cmsg.hdr.cmsg_len = (socklen_t)CMSG_LEN(sizeof(int)); cmsg.hdr.cmsg_level = SOL_SOCKET; cmsg.hdr.cmsg_type = SCM_RIGHTS; memcpy(CMSG_DATA(&cmsg.hdr), &fd, sizeof(int)); #else arg.msg.msg_accrights = (caddr_t)&fd; arg.msg.msg_accrightslen = sizeof(fd); #endif arg.fd = fptr->fd; while ((int)BLOCKING_REGION_FD(sendmsg_blocking, &arg) == -1) { if (!rb_io_wait_writable(arg.fd)) rsock_sys_fail_path("sendmsg(2)", fptr->pathv); } return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UNIXSocket#recv_io;F;7[[@90;[[@ٽiM;T;: recv_io;0;[;{;IC; "Example UNIXServer.open("/tmp/sock") {|serv| UNIXSocket.open("/tmp/sock") {|c| s = serv.accept c.send_io STDOUT stdout = s.recv_io p STDOUT.fileno #=> 1 p stdout.fileno #=> 7 stdout.puts "hello" # outputs "hello\n" to standard output. } } _klass_ will determine the class of _io_ returned (using the IO.for_fd singleton method or similar). If _klass_ is +nil+, an integer file descriptor is returned. _mode_ is the same as the argument passed to IO.for_fd ;T;[o;= ;>I" overload;F;?0;;H ;@0;:I"recv_io([klass [, mode]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"IO;T;$@v;![;"I"@return [IO];T;#0;$@v;.F;Bi;C0;7[[I"[klass [, mode]];T0;$@v;![;"I"2Example UNIXServer.open("/tmp/sock") {|serv| UNIXSocket.open("/tmp/sock") {|c| s = serv.accept c.send_io STDOUT stdout = s.recv_io p STDOUT.fileno #=> 1 p stdout.fileno #=> 7 stdout.puts "hello" # outputs "hello\n" to standard output. } } _klass_ will determine the class of _io_ returned (using the IO.for_fd singleton method or similar). If _klass_ is +nil+, an integer file descriptor is returned. _mode_ is the same as the argument passed to IO.for_fd @overload recv_io([klass [, mode]]) @return [IO];T;#0;$@v;.F;/o;0;1T;2i3;3iK;%@н;9I"ystatic VALUE unix_recv_io(int argc, VALUE *argv, VALUE sock) { VALUE klass, mode; rb_io_t *fptr; struct iomsg_arg arg; struct iovec vec[2]; char buf[1]; unsigned int gc_reason = 0; enum { GC_REASON_EMSGSIZE = 0x1, GC_REASON_TRUNCATE = 0x2, GC_REASON_ENOMEM = 0x4 }; int fd; #if FD_PASSING_BY_MSG_CONTROL union { struct cmsghdr hdr; char pad[sizeof(struct cmsghdr)+8+sizeof(int)+8]; } cmsg; #endif rb_scan_args(argc, argv, "02", &klass, &mode); if (argc == 0) klass = rb_cIO; if (argc <= 1) mode = Qnil; retry: GetOpenFile(sock, fptr); arg.msg.msg_name = NULL; arg.msg.msg_namelen = 0; vec[0].iov_base = buf; vec[0].iov_len = sizeof(buf); arg.msg.msg_iov = vec; arg.msg.msg_iovlen = 1; #if FD_PASSING_BY_MSG_CONTROL arg.msg.msg_control = (caddr_t)&cmsg; arg.msg.msg_controllen = (socklen_t)CMSG_SPACE(sizeof(int)); arg.msg.msg_flags = 0; cmsg.hdr.cmsg_len = (socklen_t)CMSG_LEN(sizeof(int)); cmsg.hdr.cmsg_level = SOL_SOCKET; cmsg.hdr.cmsg_type = SCM_RIGHTS; fd = -1; memcpy(CMSG_DATA(&cmsg.hdr), &fd, sizeof(int)); #else arg.msg.msg_accrights = (caddr_t)&fd; arg.msg.msg_accrightslen = sizeof(fd); fd = -1; #endif arg.fd = fptr->fd; while ((int)BLOCKING_REGION_FD(recvmsg_blocking, &arg) == -1) { int e = errno; if (e == EMSGSIZE && !(gc_reason & GC_REASON_EMSGSIZE)) { /* FreeBSD gets here when we're out of FDs */ gc_reason |= GC_REASON_EMSGSIZE; rb_gc_for_fd(EMFILE); goto retry; } else if (e == ENOMEM && !(gc_reason & GC_REASON_ENOMEM)) { /* ENOMEM is documented in recvmsg manpages */ gc_reason |= GC_REASON_ENOMEM; rb_gc_for_fd(e); goto retry; } if (!rb_io_wait_readable(arg.fd)) rsock_syserr_fail_path(e, "recvmsg(2)", fptr->pathv); } #if FD_PASSING_BY_MSG_CONTROL if (arg.msg.msg_controllen < (socklen_t)sizeof(struct cmsghdr)) { /* FreeBSD and Linux both get here when we're out of FDs */ if (!(gc_reason & GC_REASON_TRUNCATE)) { gc_reason |= GC_REASON_TRUNCATE; rb_gc_for_fd(EMFILE); goto retry; } rb_raise(rb_eSocket, "file descriptor was not passed (msg_controllen=%d smaller than sizeof(struct cmsghdr)=%d)", (int)arg.msg.msg_controllen, (int)sizeof(struct cmsghdr)); } if (cmsg.hdr.cmsg_level != SOL_SOCKET) { rb_raise(rb_eSocket, "file descriptor was not passed (cmsg_level=%d, %d expected)", cmsg.hdr.cmsg_level, SOL_SOCKET); } if (cmsg.hdr.cmsg_type != SCM_RIGHTS) { rb_raise(rb_eSocket, "file descriptor was not passed (cmsg_type=%d, %d expected)", cmsg.hdr.cmsg_type, SCM_RIGHTS); } if (arg.msg.msg_controllen < (socklen_t)CMSG_LEN(sizeof(int))) { rb_raise(rb_eSocket, "file descriptor was not passed (msg_controllen=%d smaller than CMSG_LEN(sizeof(int))=%d)", (int)arg.msg.msg_controllen, (int)CMSG_LEN(sizeof(int))); } if ((socklen_t)CMSG_SPACE(sizeof(int)) < arg.msg.msg_controllen) { rb_raise(rb_eSocket, "file descriptor was not passed (msg_controllen=%d bigger than CMSG_SPACE(sizeof(int))=%d)", (int)arg.msg.msg_controllen, (int)CMSG_SPACE(sizeof(int))); } if (cmsg.hdr.cmsg_len != CMSG_LEN(sizeof(int))) { rsock_discard_cmsg_resource(&arg.msg, 0); rb_raise(rb_eSocket, "file descriptor was not passed (cmsg_len=%d, %d expected)", (int)cmsg.hdr.cmsg_len, (int)CMSG_LEN(sizeof(int))); } #else if (arg.msg.msg_accrightslen != sizeof(fd)) { rb_raise(rb_eSocket, "file descriptor was not passed (accrightslen=%d, %d expected)", arg.msg.msg_accrightslen, (int)sizeof(fd)); } #endif #if FD_PASSING_BY_MSG_CONTROL memcpy(&fd, CMSG_DATA(&cmsg.hdr), sizeof(int)); #endif rb_update_max_fd(fd); rb_maygvl_fd_fix_cloexec(fd); if (klass == Qnil) return INT2FIX(fd); else { ID for_fd; int ff_argc; VALUE ff_argv[2]; CONST_ID(for_fd, "for_fd"); ff_argc = mode == Qnil ? 1 : 2; ff_argv[0] = INT2FIX(fd); ff_argv[1] = mode; return rb_funcallv(klass, for_fd, ff_argc, ff_argv); } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UNIXSocket.socketpair;F;7[[@90;[[@ٽi&;T;:socketpair;0;[;{;IC; "0Creates a pair of sockets connected to each other. _socktype_ should be a socket type such as: :STREAM, :DGRAM, :RAW, etc. _protocol_ should be a protocol defined in the domain. 0 is default protocol for the domain. s1, s2 = UNIXSocket.pair s1.send "a", 0 s1.send "b", 0 p s2.recv(10) #=> "ab" ;T;[o;= ;>I" overload;F;?0;: pair;@0;:I"pair([type [, protocol]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"[type [, protocol]];T0;$@o;= ;>I" overload;F;?0;;I ;@0;:I"$socketpair([type [, protocol]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"[type [, protocol]];T0;$@;![;"I"Creates a pair of sockets connected to each other. _socktype_ should be a socket type such as: :STREAM, :DGRAM, :RAW, etc. _protocol_ should be a protocol defined in the domain. 0 is default protocol for the domain. s1, s2 = UNIXSocket.pair s1.send "a", 0 s1.send "b", 0 p s2.recv(10) #=> "ab" @overload pair([type [, protocol]]) @return [Array] @overload socketpair([type [, protocol]]) @return [Array];T;#0;$@;.F;/o;0;1T;2i;3i%;%@н;9I"static VALUE unix_s_socketpair(int argc, VALUE *argv, VALUE klass) { VALUE domain, type, protocol; VALUE args[3]; domain = INT2FIX(PF_UNIX); rb_scan_args(argc, argv, "02", &type, &protocol); if (argc == 0) type = INT2FIX(SOCK_STREAM); if (argc <= 1) protocol = INT2FIX(0); args[0] = domain; args[1] = type; args[2] = protocol; return rsock_sock_s_socketpair(3, args, klass); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UNIXSocket.pair;F;7[[@90;[[@ٽi&;T;;J ;0;[;{;IC; "0Creates a pair of sockets connected to each other. _socktype_ should be a socket type such as: :STREAM, :DGRAM, :RAW, etc. _protocol_ should be a protocol defined in the domain. 0 is default protocol for the domain. s1, s2 = UNIXSocket.pair s1.send "a", 0 s1.send "b", 0 p s2.recv(10) #=> "ab" ;T;[o;= ;>I" overload;F;?0;;J ;@0;:I"pair([type [, protocol]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"[type [, protocol]];T0;$@o;= ;>I" overload;F;?0;;I ;@0;:I"$socketpair([type [, protocol]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"[type [, protocol]];T0;$@;![;"@;#0;$@;.F;/o;0;1T;2i;3i%;%@н;9I"static VALUE unix_s_socketpair(int argc, VALUE *argv, VALUE klass) { VALUE domain, type, protocol; VALUE args[3]; domain = INT2FIX(PF_UNIX); rb_scan_args(argc, argv, "02", &type, &protocol); if (argc == 0) type = INT2FIX(SOCK_STREAM); if (argc <= 1) protocol = INT2FIX(0); args[0] = domain; args[1] = type; args[2] = protocol; return rsock_sock_s_socketpair(3, args, klass); };T;:I"static VALUE;T;;T; @н; IC;[; @н; IC;[; @н; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ٽi?[@ٽiD;T;;C ;;;;;[;{;IC; ">UNIXSocket represents a UNIX domain stream client socket. ;T;[;![;"I"@ UNIXSocket represents a UNIX domain stream client socket. ;T;#0;$@н;.F;/o;0;1T;2i?;3iA;%@;&I"UNIXSocket;F;'o;( ;)0;*0;+0;;> ;%@;-@5;0;0@нo; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[I"ext/socket/init.c;Ti;F;:SocketError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"SocketError;F;'@o; ;IC;[0o;4;5F;6;;;;&I"Addrinfo#initialize;F;7[[@90;[[I"ext/socket/raddrinfo.c;TiH;T;;D;0;[;{;IC; "returns a new instance of Addrinfo. The instance contains sockaddr, family, socktype, protocol. sockaddr means struct sockaddr which can be used for connect(2), etc. family, socktype and protocol are integers which is used for arguments of socket(2). sockaddr is specified as an array or a string. The array should be compatible to the value of IPSocket#addr or UNIXSocket#addr. The string should be struct sockaddr as generated by Socket.sockaddr_in or Socket.unpack_sockaddr_un. sockaddr examples: - ["AF_INET", 46102, "localhost.localdomain", "127.0.0.1"] - ["AF_INET6", 42304, "ip6-localhost", "::1"] - ["AF_UNIX", "/tmp/sock"] - Socket.sockaddr_in("smtp", "2001:DB8::1") - Socket.sockaddr_in(80, "172.18.22.42") - Socket.sockaddr_in(80, "www.ruby-lang.org") - Socket.sockaddr_un("/tmp/sock") In an AF_INET/AF_INET6 sockaddr array, the 4th element, numeric IP address, is used to construct socket address in the Addrinfo instance. If the 3rd element, textual host name, is non-nil, it is also recorded but used only for Addrinfo#inspect. family is specified as an integer to specify the protocol family such as Socket::PF_INET. It can be a symbol or a string which is the constant name with or without PF_ prefix such as :INET, :INET6, :UNIX, "PF_INET", etc. If omitted, PF_UNSPEC is assumed. socktype is specified as an integer to specify the socket type such as Socket::SOCK_STREAM. It can be a symbol or a string which is the constant name with or without SOCK_ prefix such as :STREAM, :DGRAM, :RAW, "SOCK_STREAM", etc. If omitted, 0 is assumed. protocol is specified as an integer to specify the protocol such as Socket::IPPROTO_TCP. It must be an integer, unlike family and socktype. If omitted, 0 is assumed. Note that 0 is reasonable value for most protocols, except raw socket. ;T;[ o;= ;>I" overload;F;?0;;E;@0;:I"new(sockaddr);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" sockaddr;T0;$@o;= ;>I" overload;F;?0;;E;@0;:I"new(sockaddr, family);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" sockaddr;T0[I" family;T0;$@o;= ;>I" overload;F;?0;;E;@0;:I"$new(sockaddr, family, socktype);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" sockaddr;T0[I" family;T0[I" socktype;T0;$@o;= ;>I" overload;F;?0;;E;@0;:I".new(sockaddr, family, socktype, protocol);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[ [I" sockaddr;T0[I" family;T0[I" socktype;T0[I" protocol;T0;$@;![;"I"returns a new instance of Addrinfo. The instance contains sockaddr, family, socktype, protocol. sockaddr means struct sockaddr which can be used for connect(2), etc. family, socktype and protocol are integers which is used for arguments of socket(2). sockaddr is specified as an array or a string. The array should be compatible to the value of IPSocket#addr or UNIXSocket#addr. The string should be struct sockaddr as generated by Socket.sockaddr_in or Socket.unpack_sockaddr_un. sockaddr examples: - ["AF_INET", 46102, "localhost.localdomain", "127.0.0.1"] - ["AF_INET6", 42304, "ip6-localhost", "::1"] - ["AF_UNIX", "/tmp/sock"] - Socket.sockaddr_in("smtp", "2001:DB8::1") - Socket.sockaddr_in(80, "172.18.22.42") - Socket.sockaddr_in(80, "www.ruby-lang.org") - Socket.sockaddr_un("/tmp/sock") In an AF_INET/AF_INET6 sockaddr array, the 4th element, numeric IP address, is used to construct socket address in the Addrinfo instance. If the 3rd element, textual host name, is non-nil, it is also recorded but used only for Addrinfo#inspect. family is specified as an integer to specify the protocol family such as Socket::PF_INET. It can be a symbol or a string which is the constant name with or without PF_ prefix such as :INET, :INET6, :UNIX, "PF_INET", etc. If omitted, PF_UNSPEC is assumed. socktype is specified as an integer to specify the socket type such as Socket::SOCK_STREAM. It can be a symbol or a string which is the constant name with or without SOCK_ prefix such as :STREAM, :DGRAM, :RAW, "SOCK_STREAM", etc. If omitted, 0 is assumed. protocol is specified as an integer to specify the protocol such as Socket::IPPROTO_TCP. It must be an integer, unlike family and socktype. If omitted, 0 is assumed. Note that 0 is reasonable value for most protocols, except raw socket. @overload new(sockaddr) @overload new(sockaddr, family) @overload new(sockaddr, family, socktype) @overload new(sockaddr, family, socktype, protocol);T;#0;$@;.F;/o;0;1T;2i;3iE;%@;9I" static VALUE addrinfo_initialize(int argc, VALUE *argv, VALUE self) { rb_addrinfo_t *rai; VALUE sockaddr_arg, sockaddr_ary, pfamily, socktype, protocol; int i_pfamily, i_socktype, i_protocol; struct sockaddr *sockaddr_ptr; socklen_t sockaddr_len; VALUE canonname = Qnil, inspectname = Qnil; if (check_addrinfo(self)) rb_raise(rb_eTypeError, "already initialized socket address"); DATA_PTR(self) = rai = alloc_addrinfo(); rb_scan_args(argc, argv, "13", &sockaddr_arg, &pfamily, &socktype, &protocol); i_pfamily = NIL_P(pfamily) ? PF_UNSPEC : rsock_family_arg(pfamily); i_socktype = NIL_P(socktype) ? 0 : rsock_socktype_arg(socktype); i_protocol = NIL_P(protocol) ? 0 : NUM2INT(protocol); sockaddr_ary = rb_check_array_type(sockaddr_arg); if (!NIL_P(sockaddr_ary)) { VALUE afamily = rb_ary_entry(sockaddr_ary, 0); int af; StringValue(afamily); if (rsock_family_to_int(RSTRING_PTR(afamily), RSTRING_LEN(afamily), &af) == -1) rb_raise(rb_eSocket, "unknown address family: %s", StringValueCStr(afamily)); switch (af) { case AF_INET: /* ["AF_INET", 46102, "localhost.localdomain", "127.0.0.1"] */ #ifdef INET6 case AF_INET6: /* ["AF_INET6", 42304, "ip6-localhost", "::1"] */ #endif { VALUE service = rb_ary_entry(sockaddr_ary, 1); VALUE nodename = rb_ary_entry(sockaddr_ary, 2); VALUE numericnode = rb_ary_entry(sockaddr_ary, 3); int flags; service = INT2NUM(NUM2INT(service)); if (!NIL_P(nodename)) StringValue(nodename); StringValue(numericnode); flags = AI_NUMERICHOST; #ifdef AI_NUMERICSERV flags |= AI_NUMERICSERV; #endif init_addrinfo_getaddrinfo(rai, numericnode, service, INT2NUM(i_pfamily ? i_pfamily : af), INT2NUM(i_socktype), INT2NUM(i_protocol), INT2NUM(flags), nodename, service); break; } #ifdef HAVE_SYS_UN_H case AF_UNIX: /* ["AF_UNIX", "/tmp/sock"] */ { VALUE path = rb_ary_entry(sockaddr_ary, 1); StringValue(path); init_unix_addrinfo(rai, path, SOCK_STREAM); break; } #endif default: rb_raise(rb_eSocket, "unexpected address family"); } } else { StringValue(sockaddr_arg); sockaddr_ptr = (struct sockaddr *)RSTRING_PTR(sockaddr_arg); sockaddr_len = RSTRING_SOCKLEN(sockaddr_arg); init_addrinfo(rai, sockaddr_ptr, sockaddr_len, i_pfamily, i_socktype, i_protocol, canonname, inspectname); } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#inspect;F;7[;[[@i;T;;J;0;[;{;IC; "returns a string which shows addrinfo in human-readable form. Addrinfo.tcp("localhost", 80).inspect #=> "#" Addrinfo.unix("/tmp/sock").inspect #=> "#" ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@X;![;"I"@return [String];T;#0;$@X;.F;Bi;C0;7[;$@X;![;"I"returns a string which shows addrinfo in human-readable form. Addrinfo.tcp("localhost", 80).inspect #=> "#" Addrinfo.unix("/tmp/sock").inspect #=> "#" @overload inspect @return [String];T;#0;$@X;.F;/o;0;1T;2i;3i;%@;9I"static VALUE addrinfo_inspect(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); int internet_p; VALUE ret; ret = rb_sprintf("#<%s: ", rb_obj_classname(self)); inspect_sockaddr(self, ret); if (rai->pfamily && ai_get_afamily(rai) != rai->pfamily) { ID id = rsock_intern_protocol_family(rai->pfamily); if (id) rb_str_catf(ret, " %s", rb_id2name(id)); else rb_str_catf(ret, " PF_\?\?\?(%d)", rai->pfamily); } internet_p = rai->pfamily == PF_INET; #ifdef INET6 internet_p = internet_p || rai->pfamily == PF_INET6; #endif if (internet_p && rai->socktype == SOCK_STREAM && (rai->protocol == 0 || rai->protocol == IPPROTO_TCP)) { rb_str_cat2(ret, " TCP"); } else if (internet_p && rai->socktype == SOCK_DGRAM && (rai->protocol == 0 || rai->protocol == IPPROTO_UDP)) { rb_str_cat2(ret, " UDP"); } else { if (rai->socktype) { ID id = rsock_intern_socktype(rai->socktype); if (id) rb_str_catf(ret, " %s", rb_id2name(id)); else rb_str_catf(ret, " SOCK_\?\?\?(%d)", rai->socktype); } if (rai->protocol) { if (internet_p) { ID id = rsock_intern_ipproto(rai->protocol); if (id) rb_str_catf(ret, " %s", rb_id2name(id)); else goto unknown_protocol; } else { unknown_protocol: rb_str_catf(ret, " UNKNOWN_PROTOCOL(%d)", rai->protocol); } } } if (!NIL_P(rai->canonname)) { VALUE name = rai->canonname; rb_str_catf(ret, " %s", StringValueCStr(name)); } if (!NIL_P(rai->inspectname)) { VALUE name = rai->inspectname; rb_str_catf(ret, " (%s)", StringValueCStr(name)); } rb_str_buf_cat2(ret, ">"); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#inspect_sockaddr;F;7[;[[@i';T;:inspect_sockaddr;0;[;{;IC; "#returns a string which shows the sockaddr in _addrinfo_ with human-readable form. Addrinfo.tcp("localhost", 80).inspect_sockaddr #=> "127.0.0.1:80" Addrinfo.tcp("ip6-localhost", 80).inspect_sockaddr #=> "[::1]:80" Addrinfo.unix("/tmp/sock").inspect_sockaddr #=> "/tmp/sock" ;T;[o;= ;>I" overload;F;?0;;L ;@0;:I"inspect_sockaddr;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@s;![;"I"@return [String];T;#0;$@s;.F;Bi;C0;7[;$@s;![;"I"Treturns a string which shows the sockaddr in _addrinfo_ with human-readable form. Addrinfo.tcp("localhost", 80).inspect_sockaddr #=> "127.0.0.1:80" Addrinfo.tcp("ip6-localhost", 80).inspect_sockaddr #=> "[::1]:80" Addrinfo.unix("/tmp/sock").inspect_sockaddr #=> "/tmp/sock" @overload inspect_sockaddr @return [String];T;#0;$@s;.F;/o;0;1T;2i;3i%;%@;9I"pVALUE rsock_addrinfo_inspect_sockaddr(VALUE self) { return inspect_sockaddr(self, rb_str_new("", 0)); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Addrinfo.getaddrinfo;F;7[[@90;[[@iz ;T;:getaddrinfo;0;[;{;IC; "returns a list of addrinfo objects as an array. This method converts nodename (hostname) and service (port) to addrinfo. Since the conversion is not unique, the result is a list of addrinfo objects. nodename or service can be nil if no conversion intended. family, socktype and protocol are hint for preferred protocol. If the result will be used for a socket with SOCK_STREAM, SOCK_STREAM should be specified as socktype. If so, Addrinfo.getaddrinfo returns addrinfo list appropriate for SOCK_STREAM. If they are omitted or nil is given, the result is not restricted. Similarly, PF_INET6 as family restricts for IPv6. flags should be bitwise OR of Socket::AI_??? constants such as follows. Note that the exact list of the constants depends on OS. AI_PASSIVE Get address to use with bind() AI_CANONNAME Fill in the canonical name AI_NUMERICHOST Prevent host name resolution AI_NUMERICSERV Prevent service name resolution AI_V4MAPPED Accept IPv4-mapped IPv6 addresses AI_ALL Allow all addresses AI_ADDRCONFIG Accept only if any address is assigned Note that socktype should be specified whenever application knows the usage of the address. Some platform causes an error when socktype is omitted and servname is specified as an integer because some port numbers, 512 for example, are ambiguous without socktype. Addrinfo.getaddrinfo("www.kame.net", 80, nil, :STREAM) #=> [#, # #] ;T;[ o;= ;>I" overload;F;?0;;M ;@0;:I"Fgetaddrinfo(nodename, service, family, socktype, protocol, flags);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[ [I" nodename;T0[I" service;T0[I" family;T0[I" socktype;T0[I" protocol;T0[I" flags;T0;$@o;= ;>I" overload;F;?0;;M ;@0;:I"?getaddrinfo(nodename, service, family, socktype, protocol);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[ [I" nodename;T0[I" service;T0[I" family;T0[I" socktype;T0[I" protocol;T0;$@o;= ;>I" overload;F;?0;;M ;@0;:I"5getaddrinfo(nodename, service, family, socktype);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[ [I" nodename;T0[I" service;T0[I" family;T0[I" socktype;T0;$@o;= ;>I" overload;F;?0;;M ;@0;:I"+getaddrinfo(nodename, service, family);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" nodename;T0[I" service;T0[I" family;T0;$@o;= ;>I" overload;F;?0;;M ;@0;:I"#getaddrinfo(nodename, service);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" nodename;T0[I" service;T0;$@;![;"I"returns a list of addrinfo objects as an array. This method converts nodename (hostname) and service (port) to addrinfo. Since the conversion is not unique, the result is a list of addrinfo objects. nodename or service can be nil if no conversion intended. family, socktype and protocol are hint for preferred protocol. If the result will be used for a socket with SOCK_STREAM, SOCK_STREAM should be specified as socktype. If so, Addrinfo.getaddrinfo returns addrinfo list appropriate for SOCK_STREAM. If they are omitted or nil is given, the result is not restricted. Similarly, PF_INET6 as family restricts for IPv6. flags should be bitwise OR of Socket::AI_??? constants such as follows. Note that the exact list of the constants depends on OS. AI_PASSIVE Get address to use with bind() AI_CANONNAME Fill in the canonical name AI_NUMERICHOST Prevent host name resolution AI_NUMERICSERV Prevent service name resolution AI_V4MAPPED Accept IPv4-mapped IPv6 addresses AI_ALL Allow all addresses AI_ADDRCONFIG Accept only if any address is assigned Note that socktype should be specified whenever application knows the usage of the address. Some platform causes an error when socktype is omitted and servname is specified as an integer because some port numbers, 512 for example, are ambiguous without socktype. Addrinfo.getaddrinfo("www.kame.net", 80, nil, :STREAM) #=> [#, # #] @overload getaddrinfo(nodename, service, family, socktype, protocol, flags) @return [Array] @overload getaddrinfo(nodename, service, family, socktype, protocol) @return [Array] @overload getaddrinfo(nodename, service, family, socktype) @return [Array] @overload getaddrinfo(nodename, service, family) @return [Array] @overload getaddrinfo(nodename, service) @return [Array];T;#0;$@;.F;/o;0;1T;2iO ;3i| ;%@;9I"static VALUE addrinfo_s_getaddrinfo(int argc, VALUE *argv, VALUE self) { VALUE node, service, family, socktype, protocol, flags, opts, timeout; rb_scan_args(argc, argv, "24:", &node, &service, &family, &socktype, &protocol, &flags, &opts); rb_get_kwargs(opts, &id_timeout, 0, 1, &timeout); if (timeout == Qundef) { timeout = Qnil; } return addrinfo_list_new(node, service, family, socktype, protocol, flags, timeout); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo.ip;F;7[[I" host;T0;[[@i ;T;:ip;0;[;{;IC; "returns an addrinfo object for IP address. The port, socktype, protocol of the result is filled by zero. So, it is not appropriate to create a socket. Addrinfo.ip("localhost") #=> # ;T;[o;= ;>I" overload;F;?0;;N ;@0;:I" ip(host);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" host;T0;$@;![;"I"returns an addrinfo object for IP address. The port, socktype, protocol of the result is filled by zero. So, it is not appropriate to create a socket. Addrinfo.ip("localhost") #=> # @overload ip(host);T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"*static VALUE addrinfo_s_ip(VALUE self, VALUE host) { VALUE ret; rb_addrinfo_t *rai; ret = addrinfo_firstonly_new(host, Qnil, INT2NUM(PF_UNSPEC), INT2FIX(0), INT2FIX(0), INT2FIX(0)); rai = get_addrinfo(ret); rai->socktype = 0; rai->protocol = 0; return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo.tcp;F;7[[I" host;T0[I" port;T0;[[@i ;T;:tcp;0;[;{;IC; "returns an addrinfo object for TCP address. Addrinfo.tcp("localhost", "smtp") #=> # ;T;[o;= ;>I" overload;F;?0;;O ;@0;:I"tcp(host, port);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I" host;T0[I" port;T0;$@ ;![;"I"returns an addrinfo object for TCP address. Addrinfo.tcp("localhost", "smtp") #=> # @overload tcp(host, port);T;#0;$@ ;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE addrinfo_s_tcp(VALUE self, VALUE host, VALUE port) { return addrinfo_firstonly_new(host, port, INT2NUM(PF_UNSPEC), INT2NUM(SOCK_STREAM), INT2NUM(IPPROTO_TCP), INT2FIX(0)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo.udp;F;7[[I" host;T0[I" port;T0;[[@i ;T;:udp;0;[;{;IC; "returns an addrinfo object for UDP address. Addrinfo.udp("localhost", "daytime") #=> # ;T;[o;= ;>I" overload;F;?0;;P ;@0;:I"udp(host, port);T;IC; ";T;[;![;"I";T;#0;$@>;.F;Bi;C0;7[[I" host;T0[I" port;T0;$@>;![;"I"returns an addrinfo object for UDP address. Addrinfo.udp("localhost", "daytime") #=> # @overload udp(host, port);T;#0;$@>;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE addrinfo_s_udp(VALUE self, VALUE host, VALUE port) { return addrinfo_firstonly_new(host, port, INT2NUM(PF_UNSPEC), INT2NUM(SOCK_DGRAM), INT2NUM(IPPROTO_UDP), INT2FIX(0)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo.unix;F;7[[@90;[[@i ;T;: unix;0;[;{;IC; "returns an addrinfo object for UNIX socket address. _socktype_ specifies the socket type. If it is omitted, :STREAM is used. Addrinfo.unix("/tmp/sock") #=> # Addrinfo.unix("/tmp/sock", :DGRAM) #=> # ;T;[o;= ;>I" overload;F;?0;;Q ;@0;:I"unix(path [, socktype]);T;IC; ";T;[;![;"I";T;#0;$@\;.F;Bi;C0;7[[I"path[, socktype];T0;$@\;![;"I"9returns an addrinfo object for UNIX socket address. _socktype_ specifies the socket type. If it is omitted, :STREAM is used. Addrinfo.unix("/tmp/sock") #=> # Addrinfo.unix("/tmp/sock", :DGRAM) #=> # @overload unix(path [, socktype]);T;#0;$@\;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE addrinfo_s_unix(int argc, VALUE *argv, VALUE self) { VALUE path, vsocktype, addr; int socktype; rb_addrinfo_t *rai; rb_scan_args(argc, argv, "11", &path, &vsocktype); if (NIL_P(vsocktype)) socktype = SOCK_STREAM; else socktype = rsock_socktype_arg(vsocktype); addr = addrinfo_s_allocate(rb_cAddrinfo); DATA_PTR(addr) = rai = alloc_addrinfo(); init_unix_addrinfo(rai, path, socktype); return addr; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#afamily;F;7[;[[@i;T;: afamily;0;[;{;IC; "sreturns the address family as an integer. Addrinfo.tcp("localhost", 80).afamily == Socket::AF_INET #=> true ;T;[o;= ;>I" overload;F;?0;;R ;@0;:I" afamily;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@u;![;"I"@return [Integer];T;#0;$@u;.F;Bi;C0;7[;$@u;![;"I"returns the address family as an integer. Addrinfo.tcp("localhost", 80).afamily == Socket::AF_INET #=> true @overload afamily @return [Integer];T;#0;$@u;.F;/o;0;1T;2i;3i;%@;9I"static VALUE addrinfo_afamily(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); return INT2NUM(ai_get_afamily(rai)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#pfamily;F;7[;[[@i;T;: pfamily;0;[;{;IC; "treturns the protocol family as an integer. Addrinfo.tcp("localhost", 80).pfamily == Socket::PF_INET #=> true ;T;[o;= ;>I" overload;F;?0;;S ;@0;:I" pfamily;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"returns the protocol family as an integer. Addrinfo.tcp("localhost", 80).pfamily == Socket::PF_INET #=> true @overload pfamily @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"|static VALUE addrinfo_pfamily(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); return INT2NUM(rai->pfamily); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#socktype;F;7[;[[@i ;T;: socktype;0;[;{;IC; "ureturns the socket type as an integer. Addrinfo.tcp("localhost", 80).socktype == Socket::SOCK_STREAM #=> true ;T;[o;= ;>I" overload;F;?0;;T ;@0;:I" socktype;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"returns the socket type as an integer. Addrinfo.tcp("localhost", 80).socktype == Socket::SOCK_STREAM #=> true @overload socktype @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i ;%@;9I"~static VALUE addrinfo_socktype(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); return INT2NUM(rai->socktype); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#protocol;F;7[;[[@i;T;: protocol;0;[;{;IC; "ureturns the socket type as an integer. Addrinfo.tcp("localhost", 80).protocol == Socket::IPPROTO_TCP #=> true ;T;[o;= ;>I" overload;F;?0;;U ;@0;:I" protocol;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"returns the socket type as an integer. Addrinfo.tcp("localhost", 80).protocol == Socket::IPPROTO_TCP #=> true @overload protocol @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"~static VALUE addrinfo_protocol(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); return INT2NUM(rai->protocol); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#canonname;F;7[;[[@iF;T;:canonname;0;[;{;IC; "returns the canonical name as a string. nil is returned if no canonical name. The canonical name is set by Addrinfo.getaddrinfo when AI_CANONNAME is specified. list = Addrinfo.getaddrinfo("www.ruby-lang.org", 80, :INET, :STREAM, nil, Socket::AI_CANONNAME) p list[0] #=> # p list[0].canonname #=> "carbon.ruby-lang.org" ;T;[o;= ;>I" overload;F;?0;;V ;@0;:I"canonname;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@;![;"I"@return [String, nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"returns the canonical name as a string. nil is returned if no canonical name. The canonical name is set by Addrinfo.getaddrinfo when AI_CANONNAME is specified. list = Addrinfo.getaddrinfo("www.ruby-lang.org", 80, :INET, :STREAM, nil, Socket::AI_CANONNAME) p list[0] #=> # p list[0].canonname #=> "carbon.ruby-lang.org" @overload canonname @return [String, nil];T;#0;$@;.F;/o;0;1T;2i7;3iD;%@;9I"|static VALUE addrinfo_canonname(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); return rai->canonname; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#ipv4?;F;7[;[[@im;T;: ipv4?;0;[;{;IC; "returns true if addrinfo is IPv4 address. returns false otherwise. Addrinfo.tcp("127.0.0.1", 80).ipv4? #=> true Addrinfo.tcp("::1", 80).ipv4? #=> false Addrinfo.unix("/tmp/sock").ipv4? #=> false;T;[o;= ;>I" overload;F;?0;;W ;@0;:I" ipv4?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"returns true if addrinfo is IPv4 address. returns false otherwise. Addrinfo.tcp("127.0.0.1", 80).ipv4? #=> true Addrinfo.tcp("::1", 80).ipv4? #=> false Addrinfo.unix("/tmp/sock").ipv4? #=> false @overload ipv4? @return [Boolean];T;#0;$@;.F;/o;0;1T;2ia;3ik;Bi;%@;9I"static VALUE addrinfo_ipv4_p(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); return ai_get_afamily(rai) == AF_INET ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#ipv6?;F;7[;[[@i;T;: ipv6?;0;[;{;IC; "returns true if addrinfo is IPv6 address. returns false otherwise. Addrinfo.tcp("127.0.0.1", 80).ipv6? #=> false Addrinfo.tcp("::1", 80).ipv6? #=> true Addrinfo.unix("/tmp/sock").ipv6? #=> false;T;[o;= ;>I" overload;F;?0;;X ;@0;:I" ipv6?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"returns true if addrinfo is IPv6 address. returns false otherwise. Addrinfo.tcp("127.0.0.1", 80).ipv6? #=> false Addrinfo.tcp("::1", 80).ipv6? #=> true Addrinfo.unix("/tmp/sock").ipv6? #=> false @overload ipv6? @return [Boolean];T;#0;$@;.F;/o;0;1T;2it;3i~;Bi;%@;9I"static VALUE addrinfo_ipv6_p(VALUE self) { #ifdef AF_INET6 rb_addrinfo_t *rai = get_addrinfo(self); return ai_get_afamily(rai) == AF_INET6 ? Qtrue : Qfalse; #else return Qfalse; #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#unix?;F;7[;[[@i;T;: unix?;0;[;{;IC; "returns true if addrinfo is UNIX address. returns false otherwise. Addrinfo.tcp("127.0.0.1", 80).unix? #=> false Addrinfo.tcp("::1", 80).unix? #=> false Addrinfo.unix("/tmp/sock").unix? #=> true;T;[o;= ;>I" overload;F;?0;;Y ;@0;:I" unix?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@3;![;"I"@return [Boolean];T;#0;$@3;.F;Bi;C0;7[;$@3;![;"I"returns true if addrinfo is UNIX address. returns false otherwise. Addrinfo.tcp("127.0.0.1", 80).unix? #=> false Addrinfo.tcp("::1", 80).unix? #=> false Addrinfo.unix("/tmp/sock").unix? #=> true @overload unix? @return [Boolean];T;#0;$@3;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE addrinfo_unix_p(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); #ifdef AF_UNIX return ai_get_afamily(rai) == AF_UNIX ? Qtrue : Qfalse; #else return Qfalse; #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#ip?;F;7[;[[@iY;T;:ip?;0;[;{;IC; "returns true if addrinfo is internet (IPv4/IPv6) address. returns false otherwise. Addrinfo.tcp("127.0.0.1", 80).ip? #=> true Addrinfo.tcp("::1", 80).ip? #=> true Addrinfo.unix("/tmp/sock").ip? #=> false;T;[o;= ;>I" overload;F;?0;;Z ;@0;:I"ip?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@N;![;"I"@return [Boolean];T;#0;$@N;.F;Bi;C0;7[;$@N;![;"I"returns true if addrinfo is internet (IPv4/IPv6) address. returns false otherwise. Addrinfo.tcp("127.0.0.1", 80).ip? #=> true Addrinfo.tcp("::1", 80).ip? #=> true Addrinfo.unix("/tmp/sock").ip? #=> false @overload ip? @return [Boolean];T;#0;$@N;.F;/o;0;1T;2iM;3iW;Bi;%@;9I"static VALUE addrinfo_ip_p(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); int family = ai_get_afamily(rai); return IS_IP_FAMILY(family) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#ip_unpack;F;7[;[[@i;T;:ip_unpack;0;[;{;IC; "Returns the IP address and port number as 2-element array. Addrinfo.tcp("127.0.0.1", 80).ip_unpack #=> ["127.0.0.1", 80] Addrinfo.tcp("::1", 80).ip_unpack #=> ["::1", 80] ;T;[o;= ;>I" overload;F;?0;;[ ;@0;:I"ip_unpack;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@i;![;"I"@return [Array];T;#0;$@i;.F;Bi;C0;7[;$@i;![;"I"Returns the IP address and port number as 2-element array. Addrinfo.tcp("127.0.0.1", 80).ip_unpack #=> ["127.0.0.1", 80] Addrinfo.tcp("::1", 80).ip_unpack #=> ["::1", 80] @overload ip_unpack @return [Array];T;#0;$@i;.F;/o;0;1T;2i;3i;%@;9I"static VALUE addrinfo_ip_unpack(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); int family = ai_get_afamily(rai); VALUE vflags; VALUE ret, portstr; if (!IS_IP_FAMILY(family)) rb_raise(rb_eSocket, "need IPv4 or IPv6 address"); vflags = INT2NUM(NI_NUMERICHOST|NI_NUMERICSERV); ret = addrinfo_getnameinfo(1, &vflags, self); portstr = rb_ary_entry(ret, 1); rb_ary_store(ret, 1, INT2NUM(atoi(StringValueCStr(portstr)))); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#ip_address;F;7[;[[@i;T;:ip_address;0;[;{;IC; "Returns the IP address as a string. Addrinfo.tcp("127.0.0.1", 80).ip_address #=> "127.0.0.1" Addrinfo.tcp("::1", 80).ip_address #=> "::1" ;T;[o;= ;>I" overload;F;?0;;\ ;@0;:I"ip_address;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the IP address as a string. Addrinfo.tcp("127.0.0.1", 80).ip_address #=> "127.0.0.1" Addrinfo.tcp("::1", 80).ip_address #=> "::1" @overload ip_address @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE addrinfo_ip_address(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); int family = ai_get_afamily(rai); VALUE vflags; VALUE ret; if (!IS_IP_FAMILY(family)) rb_raise(rb_eSocket, "need IPv4 or IPv6 address"); vflags = INT2NUM(NI_NUMERICHOST|NI_NUMERICSERV); ret = addrinfo_getnameinfo(1, &vflags, self); return rb_ary_entry(ret, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#ip_port;F;7[;[[@i;T;: ip_port;0;[;{;IC; "Returns the port number as an integer. Addrinfo.tcp("127.0.0.1", 80).ip_port #=> 80 Addrinfo.tcp("::1", 80).ip_port #=> 80 ;T;[o;= ;>I" overload;F;?0;;] ;@0;:I" ip_port;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the port number as an integer. Addrinfo.tcp("127.0.0.1", 80).ip_port #=> 80 Addrinfo.tcp("::1", 80).ip_port #=> 80 @overload ip_port;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"cstatic VALUE addrinfo_ip_port(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); int family = ai_get_afamily(rai); int port; if (!IS_IP_FAMILY(family)) { bad_family: #ifdef AF_INET6 rb_raise(rb_eSocket, "need IPv4 or IPv6 address"); #else rb_raise(rb_eSocket, "need IPv4 address"); #endif } switch (family) { case AF_INET: if (rai->sockaddr_len != sizeof(struct sockaddr_in)) rb_raise(rb_eSocket, "unexpected sockaddr size for IPv4"); port = ntohs(rai->addr.in.sin_port); break; #ifdef AF_INET6 case AF_INET6: if (rai->sockaddr_len != sizeof(struct sockaddr_in6)) rb_raise(rb_eSocket, "unexpected sockaddr size for IPv6"); port = ntohs(rai->addr.in6.sin6_port); break; #endif default: goto bad_family; } return INT2NUM(port); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#ipv4_private?;F;7[;[[@i;;T;:ipv4_private?;0;[;{;IC; "sReturns true for IPv4 private address (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16). It returns false otherwise.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"tReturns true for IPv4 private address (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16). It returns false otherwise. ;T;#0;$@;.F;/o;0;1T;2i7;3i9;Bi;%@;9I"Xstatic VALUE addrinfo_ipv4_private_p(VALUE self) { uint32_t a; if (!extract_in_addr(self, &a)) return Qfalse; if ((a & 0xff000000) == 0x0a000000 || /* 10.0.0.0/8 */ (a & 0xfff00000) == 0xac100000 || /* 172.16.0.0/12 */ (a & 0xffff0000) == 0xc0a80000) /* 192.168.0.0/16 */ return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#ipv4_loopback?;F;7[;[[@iK;T;:ipv4_loopback?;0;[;{;IC; "VReturns true for IPv4 loopback address (127.0.0.0/8). It returns false otherwise.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"WReturns true for IPv4 loopback address (127.0.0.0/8). It returns false otherwise. ;T;#0;$@;.F;/o;0;1T;2iG;3iI;Bi;%@;9I"static VALUE addrinfo_ipv4_loopback_p(VALUE self) { uint32_t a; if (!extract_in_addr(self, &a)) return Qfalse; if ((a & 0xff000000) == 0x7f000000) /* 127.0.0.0/8 */ return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#ipv4_multicast?;F;7[;[[@iY;T;:ipv4_multicast?;0;[;{;IC; "WReturns true for IPv4 multicast address (224.0.0.0/4). It returns false otherwise.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"XReturns true for IPv4 multicast address (224.0.0.0/4). It returns false otherwise. ;T;#0;$@;.F;/o;0;1T;2iU;3iW;Bi;%@;9I"static VALUE addrinfo_ipv4_multicast_p(VALUE self) { uint32_t a; if (!extract_in_addr(self, &a)) return Qfalse; if ((a & 0xf0000000) == 0xe0000000) /* 224.0.0.0/4 */ return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#ipv6_unspecified?;F;7[;[[@ir;T;:ipv6_unspecified?;0;[;{;IC; "PReturns true for IPv6 unspecified address (::). It returns false otherwise.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"QReturns true for IPv6 unspecified address (::). It returns false otherwise. ;T;#0;$@;.F;/o;0;1T;2in;3ip;Bi;%@;9I"static VALUE addrinfo_ipv6_unspecified_p(VALUE self) { struct in6_addr *addr = extract_in6_addr(self); if (addr && IN6_IS_ADDR_UNSPECIFIED(addr)) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#ipv6_loopback?;F;7[;[[@i~;T;:ipv6_loopback?;0;[;{;IC; "NReturns true for IPv6 loopback address (::1). It returns false otherwise.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"OReturns true for IPv6 loopback address (::1). It returns false otherwise. ;T;#0;$@;.F;/o;0;1T;2iz;3i|;Bi;%@;9I"static VALUE addrinfo_ipv6_loopback_p(VALUE self) { struct in6_addr *addr = extract_in6_addr(self); if (addr && IN6_IS_ADDR_LOOPBACK(addr)) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#ipv6_multicast?;F;7[;[[@i;T;:ipv6_multicast?;0;[;{;IC; "TReturns true for IPv6 multicast address (ff00::/8). It returns false otherwise.;T;[o;A ;>I" return;F;?@;0;@[@L;$@ ;![;"I"UReturns true for IPv6 multicast address (ff00::/8). It returns false otherwise. ;T;#0;$@ ;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE addrinfo_ipv6_multicast_p(VALUE self) { struct in6_addr *addr = extract_in6_addr(self); if (addr && IN6_IS_ADDR_MULTICAST(addr)) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#ipv6_linklocal?;F;7[;[[@i;T;:ipv6_linklocal?;0;[;{;IC; "VReturns true for IPv6 link local address (ff80::/10). It returns false otherwise.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"WReturns true for IPv6 link local address (ff80::/10). It returns false otherwise. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE addrinfo_ipv6_linklocal_p(VALUE self) { struct in6_addr *addr = extract_in6_addr(self); if (addr && IN6_IS_ADDR_LINKLOCAL(addr)) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#ipv6_sitelocal?;F;7[;[[@i;T;:ipv6_sitelocal?;0;[;{;IC; "VReturns true for IPv6 site local address (ffc0::/10). It returns false otherwise.;T;[o;A ;>I" return;F;?@;0;@[@L;$@,;![;"I"WReturns true for IPv6 site local address (ffc0::/10). It returns false otherwise. ;T;#0;$@,;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE addrinfo_ipv6_sitelocal_p(VALUE self) { struct in6_addr *addr = extract_in6_addr(self); if (addr && IN6_IS_ADDR_SITELOCAL(addr)) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Addrinfo#ipv6_unique_local?;F;7[;[[@i;T;:ipv6_unique_local?;0;[;{;IC; "`Returns true for IPv6 unique local address (fc00::/7, RFC4193). It returns false otherwise.;T;[o;A ;>I" return;F;?@;0;@[@L;$@=;![;"I"aReturns true for IPv6 unique local address (fc00::/7, RFC4193). It returns false otherwise. ;T;#0;$@=;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE addrinfo_ipv6_unique_local_p(VALUE self) { struct in6_addr *addr = extract_in6_addr(self); if (addr && IN6_IS_ADDR_UNIQUE_LOCAL(addr)) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#ipv6_v4mapped?;F;7[;[[@i;T;:ipv6_v4mapped?;0;[;{;IC; "[Returns true for IPv4-mapped IPv6 address (::ffff:0:0/80). It returns false otherwise.;T;[o;A ;>I" return;F;?@;0;@[@L;$@N;![;"I"\Returns true for IPv4-mapped IPv6 address (::ffff:0:0/80). It returns false otherwise. ;T;#0;$@N;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE addrinfo_ipv6_v4mapped_p(VALUE self) { struct in6_addr *addr = extract_in6_addr(self); if (addr && IN6_IS_ADDR_V4MAPPED(addr)) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#ipv6_v4compat?;F;7[;[[@i;T;:ipv6_v4compat?;0;[;{;IC; "WReturns true for IPv4-compatible IPv6 address (::/80). It returns false otherwise.;T;[o;A ;>I" return;F;?@;0;@[@L;$@_;![;"I"XReturns true for IPv4-compatible IPv6 address (::/80). It returns false otherwise. ;T;#0;$@_;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE addrinfo_ipv6_v4compat_p(VALUE self) { struct in6_addr *addr = extract_in6_addr(self); if (addr && IN6_IS_ADDR_V4COMPAT(addr)) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Addrinfo#ipv6_mc_nodelocal?;F;7[;[[@i;T;:ipv6_mc_nodelocal?;0;[;{;IC; "ZReturns true for IPv6 multicast node-local scope address. It returns false otherwise.;T;[o;A ;>I" return;F;?@;0;@[@L;$@p;![;"I"[Returns true for IPv6 multicast node-local scope address. It returns false otherwise. ;T;#0;$@p;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE addrinfo_ipv6_mc_nodelocal_p(VALUE self) { struct in6_addr *addr = extract_in6_addr(self); if (addr && IN6_IS_ADDR_MC_NODELOCAL(addr)) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Addrinfo#ipv6_mc_linklocal?;F;7[;[[@i;T;:ipv6_mc_linklocal?;0;[;{;IC; "ZReturns true for IPv6 multicast link-local scope address. It returns false otherwise.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"[Returns true for IPv6 multicast link-local scope address. It returns false otherwise. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE addrinfo_ipv6_mc_linklocal_p(VALUE self) { struct in6_addr *addr = extract_in6_addr(self); if (addr && IN6_IS_ADDR_MC_LINKLOCAL(addr)) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Addrinfo#ipv6_mc_sitelocal?;F;7[;[[@i;T;:ipv6_mc_sitelocal?;0;[;{;IC; "ZReturns true for IPv6 multicast site-local scope address. It returns false otherwise.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"[Returns true for IPv6 multicast site-local scope address. It returns false otherwise. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE addrinfo_ipv6_mc_sitelocal_p(VALUE self) { struct in6_addr *addr = extract_in6_addr(self); if (addr && IN6_IS_ADDR_MC_SITELOCAL(addr)) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#ipv6_mc_orglocal?;F;7[;[[@i;T;:ipv6_mc_orglocal?;0;[;{;IC; "bReturns true for IPv6 multicast organization-local scope address. It returns false otherwise.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"cReturns true for IPv6 multicast organization-local scope address. It returns false otherwise. ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@;9I"static VALUE addrinfo_ipv6_mc_orglocal_p(VALUE self) { struct in6_addr *addr = extract_in6_addr(self); if (addr && IN6_IS_ADDR_MC_ORGLOCAL(addr)) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#ipv6_mc_global?;F;7[;[[@i ;T;:ipv6_mc_global?;0;[;{;IC; "VReturns true for IPv6 multicast global scope address. It returns false otherwise.;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"WReturns true for IPv6 multicast global scope address. It returns false otherwise. ;T;#0;$@;.F;/o;0;1T;2i;3i ;Bi;%@;9I"static VALUE addrinfo_ipv6_mc_global_p(VALUE self) { struct in6_addr *addr = extract_in6_addr(self); if (addr && IN6_IS_ADDR_MC_GLOBAL(addr)) return Qtrue; return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#ipv6_to_ipv4;F;7[;[[@i ;T;:ipv6_to_ipv4;0;[;{;IC; "Returns IPv4 address of IPv4 mapped/compatible IPv6 address. It returns nil if +self+ is not IPv4 mapped/compatible IPv6 address. Addrinfo.ip("::192.0.2.3").ipv6_to_ipv4 #=> # Addrinfo.ip("::ffff:192.0.2.3").ipv6_to_ipv4 #=> # Addrinfo.ip("::1").ipv6_to_ipv4 #=> nil Addrinfo.ip("192.0.2.3").ipv6_to_ipv4 #=> nil Addrinfo.unix("/tmp/sock").ipv6_to_ipv4 #=> nil ;T;[;![;"I"Returns IPv4 address of IPv4 mapped/compatible IPv6 address. It returns nil if +self+ is not IPv4 mapped/compatible IPv6 address. Addrinfo.ip("::192.0.2.3").ipv6_to_ipv4 #=> # Addrinfo.ip("::ffff:192.0.2.3").ipv6_to_ipv4 #=> # Addrinfo.ip("::1").ipv6_to_ipv4 #=> nil Addrinfo.ip("192.0.2.3").ipv6_to_ipv4 #=> nil Addrinfo.unix("/tmp/sock").ipv6_to_ipv4 #=> nil ;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"static VALUE addrinfo_ipv6_to_ipv4(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); struct in6_addr *addr; int family = ai_get_afamily(rai); if (family != AF_INET6) return Qnil; addr = &rai->addr.in6.sin6_addr; if (IN6_IS_ADDR_V4MAPPED(addr) || IN6_IS_ADDR_V4COMPAT(addr)) { struct sockaddr_in sin4; INIT_SOCKADDR_IN(&sin4, sizeof(sin4)); memcpy(&sin4.sin_addr, (char*)addr + sizeof(*addr) - sizeof(sin4.sin_addr), sizeof(sin4.sin_addr)); return rsock_addrinfo_new((struct sockaddr *)&sin4, (socklen_t)sizeof(sin4), PF_INET, rai->socktype, rai->protocol, rai->canonname, rai->inspectname); } else { return Qnil; } };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#unix_path;F;7[;[[@i4 ;T;:unix_path;0;[;{;IC; "gReturns the socket path as a string. Addrinfo.unix("/tmp/sock").unix_path #=> "/tmp/sock" ;T;[o;= ;>I" overload;F;?0;;o ;@0;:I"unix_path;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"}Returns the socket path as a string. Addrinfo.unix("/tmp/sock").unix_path #=> "/tmp/sock" @overload unix_path;T;#0;$@;.F;/o;0;1T;2i, ;3i1 ;%@;9I"static VALUE addrinfo_unix_path(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); int family = ai_get_afamily(rai); struct sockaddr_un *addr; long n; if (family != AF_UNIX) rb_raise(rb_eSocket, "need AF_UNIX address"); addr = &rai->addr.un; n = rai_unixsocket_len(rai); if (n < 0) rb_raise(rb_eSocket, "too short AF_UNIX address: %"PRIuSIZE" bytes given for minimum %"PRIuSIZE" bytes.", (size_t)rai->sockaddr_len, offsetof(struct sockaddr_un, sun_path)); if ((long)sizeof(addr->sun_path) < n) rb_raise(rb_eSocket, "too long AF_UNIX path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)", (size_t)n, sizeof(addr->sun_path)); return rb_str_new(addr->sun_path, n); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#to_sockaddr;F;7[;[[@i.;T;:to_sockaddr;0;[;{;IC; "returns the socket address as packed struct sockaddr string. Addrinfo.tcp("localhost", 80).to_sockaddr #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" ;T;[o;= ;>I" overload;F;?0;;p ;@0;:I"to_sockaddr;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"returns the socket address as packed struct sockaddr string. Addrinfo.tcp("localhost", 80).to_sockaddr #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" @overload to_sockaddr @return [String] @overload to_s @return [String];T;#0;$@;.F;/o;0;1T;2i#;3i-;%@;9I"static VALUE addrinfo_to_sockaddr(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); VALUE ret; ret = rb_str_new((char*)&rai->addr, rai->sockaddr_len); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#to_s;F;7[;[[@i.;T;;G;0;[;{;IC; "returns the socket address as packed struct sockaddr string. Addrinfo.tcp("localhost", 80).to_sockaddr #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" ;T;[o;= ;>I" overload;F;?0;;p ;@0;:I"to_sockaddr;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"@ ;#0;$@;.F;/o;0;1T;2i#;3i-;%@;9I"static VALUE addrinfo_to_sockaddr(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); VALUE ret; ret = rb_str_new((char*)&rai->addr, rai->sockaddr_len); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#getnameinfo;F;7[[@90;[[@i;T;:getnameinfo;0;[;{;IC; "Ureturns nodename and service as a pair of strings. This converts struct sockaddr in addrinfo to textual representation. flags should be bitwise OR of Socket::NI_??? constants. Addrinfo.tcp("127.0.0.1", 80).getnameinfo #=> ["localhost", "www"] Addrinfo.tcp("127.0.0.1", 80).getnameinfo(Socket::NI_NUMERICSERV) #=> ["localhost", "80"] ;T;[o;= ;>I" overload;F;?0;;q ;@0;:I"getnameinfo;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@8;![;"I"@return [Array];T;#0;$@8;.F;Bi;C0;7[;$@8o;= ;>I" overload;F;?0;;q ;@0;:I"getnameinfo(flags);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@8;![;"I"@return [Array];T;#0;$@8;.F;Bi;C0;7[[I" flags;T0;$@8;![;"I"returns nodename and service as a pair of strings. This converts struct sockaddr in addrinfo to textual representation. flags should be bitwise OR of Socket::NI_??? constants. Addrinfo.tcp("127.0.0.1", 80).getnameinfo #=> ["localhost", "www"] Addrinfo.tcp("127.0.0.1", 80).getnameinfo(Socket::NI_NUMERICSERV) #=> ["localhost", "80"] @overload getnameinfo @return [Array] @overload getnameinfo(flags) @return [Array];T;#0;$@8;.F;/o;0;1T;2i;3i;%@;9I"static VALUE addrinfo_getnameinfo(int argc, VALUE *argv, VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); VALUE vflags; char hbuf[1024], pbuf[1024]; int flags, error; rb_scan_args(argc, argv, "01", &vflags); flags = NIL_P(vflags) ? 0 : NUM2INT(vflags); if (rai->socktype == SOCK_DGRAM) flags |= NI_DGRAM; error = getnameinfo(&rai->addr.addr, rai->sockaddr_len, hbuf, (socklen_t)sizeof(hbuf), pbuf, (socklen_t)sizeof(pbuf), flags); if (error) { rsock_raise_socket_error("getnameinfo", error); } return rb_assoc_new(rb_str_new2(hbuf), rb_str_new2(pbuf)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#marshal_dump;F;7[;[[@i.;T;;[;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@c;.F;/o;0;1T;2i-;3i-;%@;9I"static VALUE addrinfo_mdump(VALUE self) { rb_addrinfo_t *rai = get_addrinfo(self); VALUE sockaddr, afamily, pfamily, socktype, protocol, canonname, inspectname; int afamily_int = ai_get_afamily(rai); ID id; id = rsock_intern_protocol_family(rai->pfamily); if (id == 0) rb_raise(rb_eSocket, "unknown protocol family: %d", rai->pfamily); pfamily = rb_id2str(id); if (rai->socktype == 0) socktype = INT2FIX(0); else { id = rsock_intern_socktype(rai->socktype); if (id == 0) rb_raise(rb_eSocket, "unknown socktype: %d", rai->socktype); socktype = rb_id2str(id); } if (rai->protocol == 0) protocol = INT2FIX(0); else if (IS_IP_FAMILY(afamily_int)) { id = rsock_intern_ipproto(rai->protocol); if (id == 0) rb_raise(rb_eSocket, "unknown IP protocol: %d", rai->protocol); protocol = rb_id2str(id); } else { rb_raise(rb_eSocket, "unknown protocol: %d", rai->protocol); } canonname = rai->canonname; inspectname = rai->inspectname; id = rsock_intern_family(afamily_int); if (id == 0) rb_raise(rb_eSocket, "unknown address family: %d", afamily_int); afamily = rb_id2str(id); switch(afamily_int) { #ifdef HAVE_SYS_UN_H case AF_UNIX: { sockaddr = rb_str_new(rai->addr.un.sun_path, rai_unixsocket_len(rai)); break; } #endif default: { char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV]; int error; error = getnameinfo(&rai->addr.addr, rai->sockaddr_len, hbuf, (socklen_t)sizeof(hbuf), pbuf, (socklen_t)sizeof(pbuf), NI_NUMERICHOST|NI_NUMERICSERV); if (error) { rsock_raise_socket_error("getnameinfo", error); } sockaddr = rb_assoc_new(rb_str_new_cstr(hbuf), rb_str_new_cstr(pbuf)); break; } } return rb_ary_new3(7, afamily, sockaddr, pfamily, socktype, protocol, canonname, inspectname); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Addrinfo#marshal_load;F;7[[I"ary;T0;[[@iu;T;;;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@q;.F;/o;0;1T;2it;3it;%@;9I"B static VALUE addrinfo_mload(VALUE self, VALUE ary) { VALUE v; VALUE canonname, inspectname; int afamily, pfamily, socktype, protocol; union_sockaddr ss; socklen_t len; rb_addrinfo_t *rai; if (check_addrinfo(self)) rb_raise(rb_eTypeError, "already initialized socket address"); ary = rb_convert_type(ary, T_ARRAY, "Array", "to_ary"); v = rb_ary_entry(ary, 0); StringValue(v); if (rsock_family_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &afamily) == -1) rb_raise(rb_eTypeError, "unexpected address family"); v = rb_ary_entry(ary, 2); StringValue(v); if (rsock_family_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &pfamily) == -1) rb_raise(rb_eTypeError, "unexpected protocol family"); v = rb_ary_entry(ary, 3); if (v == INT2FIX(0)) socktype = 0; else { StringValue(v); if (rsock_socktype_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &socktype) == -1) rb_raise(rb_eTypeError, "unexpected socktype"); } v = rb_ary_entry(ary, 4); if (v == INT2FIX(0)) protocol = 0; else { StringValue(v); if (IS_IP_FAMILY(afamily)) { if (rsock_ipproto_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &protocol) == -1) rb_raise(rb_eTypeError, "unexpected protocol"); } else { rb_raise(rb_eTypeError, "unexpected protocol"); } } v = rb_ary_entry(ary, 5); if (NIL_P(v)) canonname = Qnil; else { StringValue(v); canonname = v; } v = rb_ary_entry(ary, 6); if (NIL_P(v)) inspectname = Qnil; else { StringValue(v); inspectname = v; } v = rb_ary_entry(ary, 1); switch(afamily) { #ifdef HAVE_SYS_UN_H case AF_UNIX: { struct sockaddr_un uaddr; INIT_SOCKADDR_UN(&uaddr, sizeof(struct sockaddr_un)); StringValue(v); if (sizeof(uaddr.sun_path) < (size_t)RSTRING_LEN(v)) rb_raise(rb_eSocket, "too long AF_UNIX path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)", (size_t)RSTRING_LEN(v), sizeof(uaddr.sun_path)); memcpy(uaddr.sun_path, RSTRING_PTR(v), RSTRING_LEN(v)); len = (socklen_t)sizeof(uaddr); memcpy(&ss, &uaddr, len); break; } #endif default: { VALUE pair = rb_convert_type(v, T_ARRAY, "Array", "to_ary"); struct rb_addrinfo *res; int flags = AI_NUMERICHOST; #ifdef AI_NUMERICSERV flags |= AI_NUMERICSERV; #endif res = call_getaddrinfo(rb_ary_entry(pair, 0), rb_ary_entry(pair, 1), INT2NUM(pfamily), INT2NUM(socktype), INT2NUM(protocol), INT2NUM(flags), 1, Qnil); len = res->ai->ai_addrlen; memcpy(&ss, res->ai->ai_addr, res->ai->ai_addrlen); rb_freeaddrinfo(res); break; } } DATA_PTR(self) = rai = alloc_addrinfo(); init_addrinfo(rai, &ss.addr, len, pfamily, socktype, protocol, canonname, inspectname); return self; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i@ ;F;: Addrinfo;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I" Addrinfo;F;'@o; ;IC;[o;4;5F;6;;;;&I"Socket#initialize;F;7[[@90;[[I"ext/socket/socket.c;Ti;T;;D;0;[;{;IC; "Creates a new socket object. _domain_ should be a communications domain such as: :INET, :INET6, :UNIX, etc. _socktype_ should be a socket type such as: :STREAM, :DGRAM, :RAW, etc. _protocol_ is optional and should be a protocol defined in the domain. If protocol is not given, 0 is used internally. Socket.new(:INET, :STREAM) # TCP socket Socket.new(:INET, :DGRAM) # UDP socket Socket.new(:UNIX, :STREAM) # UNIX stream socket Socket.new(:UNIX, :DGRAM) # UNIX datagram socket ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"'new(domain, socktype [, protocol]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" domain;T0[I"socktype[, protocol];T0;$@;![;"I"Creates a new socket object. _domain_ should be a communications domain such as: :INET, :INET6, :UNIX, etc. _socktype_ should be a socket type such as: :STREAM, :DGRAM, :RAW, etc. _protocol_ is optional and should be a protocol defined in the domain. If protocol is not given, 0 is used internally. Socket.new(:INET, :STREAM) # TCP socket Socket.new(:INET, :DGRAM) # UDP socket Socket.new(:UNIX, :STREAM) # UNIX stream socket Socket.new(:UNIX, :DGRAM) # UNIX datagram socket @overload new(domain, socktype [, protocol]);T;#0;$@;.F;/o;0;1T;2iw;3i;%@;9I"static VALUE sock_initialize(int argc, VALUE *argv, VALUE sock) { VALUE domain, type, protocol; int fd; int d, t; rb_scan_args(argc, argv, "21", &domain, &type, &protocol); if (NIL_P(protocol)) protocol = INT2FIX(0); setup_domain_and_type(domain, &d, type, &t); fd = rsock_socket(d, t, NUM2INT(protocol)); if (fd < 0) rb_sys_fail("socket(2)"); return rsock_init_sock(sock, fd); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket#connect;F;7[[I" addr;T0;[[@i;T;;;0;[;{;IC; "Requests a connection to be made on the given +remote_sockaddr+. Returns 0 if successful, otherwise an exception is raised. === Parameter * +remote_sockaddr+ - the +struct+ sockaddr contained in a string or Addrinfo object === Example: # Pull down Google's web page require 'socket' include Socket::Constants socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) sockaddr = Socket.pack_sockaddr_in( 80, 'www.google.com' ) socket.connect( sockaddr ) socket.write( "GET / HTTP/1.0\r\n\r\n" ) results = socket.read === Unix-based Exceptions On unix-based systems the following system exceptions may be raised if the call to _connect_ fails: * Errno::EACCES - search permission is denied for a component of the prefix path or write access to the +socket+ is denied * Errno::EADDRINUSE - the _sockaddr_ is already in use * Errno::EADDRNOTAVAIL - the specified _sockaddr_ is not available from the local machine * Errno::EAFNOSUPPORT - the specified _sockaddr_ is not a valid address for the address family of the specified +socket+ * Errno::EALREADY - a connection is already in progress for the specified socket * Errno::EBADF - the +socket+ is not a valid file descriptor * Errno::ECONNREFUSED - the target _sockaddr_ was not listening for connections refused the connection request * Errno::ECONNRESET - the remote host reset the connection request * Errno::EFAULT - the _sockaddr_ cannot be accessed * Errno::EHOSTUNREACH - the destination host cannot be reached (probably because the host is down or a remote router cannot reach it) * Errno::EINPROGRESS - the O_NONBLOCK is set for the +socket+ and the connection cannot be immediately established; the connection will be established asynchronously * Errno::EINTR - the attempt to establish the connection was interrupted by delivery of a signal that was caught; the connection will be established asynchronously * Errno::EISCONN - the specified +socket+ is already connected * Errno::EINVAL - the address length used for the _sockaddr_ is not a valid length for the address family or there is an invalid family in _sockaddr_ * Errno::ENAMETOOLONG - the pathname resolved had a length which exceeded PATH_MAX * Errno::ENETDOWN - the local interface used to reach the destination is down * Errno::ENETUNREACH - no route to the network is present * Errno::ENOBUFS - no buffer space is available * Errno::ENOSR - there were insufficient STREAMS resources available to complete the operation * Errno::ENOTSOCK - the +socket+ argument does not refer to a socket * Errno::EOPNOTSUPP - the calling +socket+ is listening and cannot be connected * Errno::EPROTOTYPE - the _sockaddr_ has a different type than the socket bound to the specified peer address * Errno::ETIMEDOUT - the attempt to connect timed out before a connection was made. On unix-based systems if the address family of the calling +socket+ is AF_UNIX the follow exceptions may be raised if the call to _connect_ fails: * Errno::EIO - an i/o error occurred while reading from or writing to the file system * Errno::ELOOP - too many symbolic links were encountered in translating the pathname in _sockaddr_ * Errno::ENAMETOOLLONG - a component of a pathname exceeded NAME_MAX characters, or an entire pathname exceeded PATH_MAX characters * Errno::ENOENT - a component of the pathname does not name an existing file or the pathname is an empty string * Errno::ENOTDIR - a component of the path prefix of the pathname in _sockaddr_ is not a directory === Windows Exceptions On Windows systems the following system exceptions may be raised if the call to _connect_ fails: * Errno::ENETDOWN - the network is down * Errno::EADDRINUSE - the socket's local address is already in use * Errno::EINTR - the socket was cancelled * Errno::EINPROGRESS - a blocking socket is in progress or the service provider is still processing a callback function. Or a nonblocking connect call is in progress on the +socket+. * Errno::EALREADY - see Errno::EINVAL * Errno::EADDRNOTAVAIL - the remote address is not a valid address, such as ADDR_ANY TODO check ADDRANY TO INADDR_ANY * Errno::EAFNOSUPPORT - addresses in the specified family cannot be used with with this +socket+ * Errno::ECONNREFUSED - the target _sockaddr_ was not listening for connections refused the connection request * Errno::EFAULT - the socket's internal address or address length parameter is too small or is not a valid part of the user space address * Errno::EINVAL - the +socket+ is a listening socket * Errno::EISCONN - the +socket+ is already connected * Errno::ENETUNREACH - the network cannot be reached from this host at this time * Errno::EHOSTUNREACH - no route to the network is present * Errno::ENOBUFS - no buffer space is available * Errno::ENOTSOCK - the +socket+ argument does not refer to a socket * Errno::ETIMEDOUT - the attempt to connect timed out before a connection was made. * Errno::EWOULDBLOCK - the socket is marked as nonblocking and the connection cannot be completed immediately * Errno::EACCES - the attempt to connect the datagram socket to the broadcast address failed === See * connect manual pages on unix-based systems * connect function in Microsoft's Winsock functions reference ;T;[o;= ;>I" overload;F;?0;;;@0;:I"connect(remote_sockaddr);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@;![;"I"@return [0];T;#0;$@;.F;Bi;C0;7[[I"remote_sockaddr;T0;$@;![;"I"Requests a connection to be made on the given +remote_sockaddr+. Returns 0 if successful, otherwise an exception is raised. === Parameter * +remote_sockaddr+ - the +struct+ sockaddr contained in a string or Addrinfo object === Example: # Pull down Google's web page require 'socket' include Socket::Constants socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) sockaddr = Socket.pack_sockaddr_in( 80, 'www.google.com' ) socket.connect( sockaddr ) socket.write( "GET / HTTP/1.0\r\n\r\n" ) results = socket.read === Unix-based Exceptions On unix-based systems the following system exceptions may be raised if the call to _connect_ fails: * Errno::EACCES - search permission is denied for a component of the prefix path or write access to the +socket+ is denied * Errno::EADDRINUSE - the _sockaddr_ is already in use * Errno::EADDRNOTAVAIL - the specified _sockaddr_ is not available from the local machine * Errno::EAFNOSUPPORT - the specified _sockaddr_ is not a valid address for the address family of the specified +socket+ * Errno::EALREADY - a connection is already in progress for the specified socket * Errno::EBADF - the +socket+ is not a valid file descriptor * Errno::ECONNREFUSED - the target _sockaddr_ was not listening for connections refused the connection request * Errno::ECONNRESET - the remote host reset the connection request * Errno::EFAULT - the _sockaddr_ cannot be accessed * Errno::EHOSTUNREACH - the destination host cannot be reached (probably because the host is down or a remote router cannot reach it) * Errno::EINPROGRESS - the O_NONBLOCK is set for the +socket+ and the connection cannot be immediately established; the connection will be established asynchronously * Errno::EINTR - the attempt to establish the connection was interrupted by delivery of a signal that was caught; the connection will be established asynchronously * Errno::EISCONN - the specified +socket+ is already connected * Errno::EINVAL - the address length used for the _sockaddr_ is not a valid length for the address family or there is an invalid family in _sockaddr_ * Errno::ENAMETOOLONG - the pathname resolved had a length which exceeded PATH_MAX * Errno::ENETDOWN - the local interface used to reach the destination is down * Errno::ENETUNREACH - no route to the network is present * Errno::ENOBUFS - no buffer space is available * Errno::ENOSR - there were insufficient STREAMS resources available to complete the operation * Errno::ENOTSOCK - the +socket+ argument does not refer to a socket * Errno::EOPNOTSUPP - the calling +socket+ is listening and cannot be connected * Errno::EPROTOTYPE - the _sockaddr_ has a different type than the socket bound to the specified peer address * Errno::ETIMEDOUT - the attempt to connect timed out before a connection was made. On unix-based systems if the address family of the calling +socket+ is AF_UNIX the follow exceptions may be raised if the call to _connect_ fails: * Errno::EIO - an i/o error occurred while reading from or writing to the file system * Errno::ELOOP - too many symbolic links were encountered in translating the pathname in _sockaddr_ * Errno::ENAMETOOLLONG - a component of a pathname exceeded NAME_MAX characters, or an entire pathname exceeded PATH_MAX characters * Errno::ENOENT - a component of the pathname does not name an existing file or the pathname is an empty string * Errno::ENOTDIR - a component of the path prefix of the pathname in _sockaddr_ is not a directory === Windows Exceptions On Windows systems the following system exceptions may be raised if the call to _connect_ fails: * Errno::ENETDOWN - the network is down * Errno::EADDRINUSE - the socket's local address is already in use * Errno::EINTR - the socket was cancelled * Errno::EINPROGRESS - a blocking socket is in progress or the service provider is still processing a callback function. Or a nonblocking connect call is in progress on the +socket+. * Errno::EALREADY - see Errno::EINVAL * Errno::EADDRNOTAVAIL - the remote address is not a valid address, such as ADDR_ANY TODO check ADDRANY TO INADDR_ANY * Errno::EAFNOSUPPORT - addresses in the specified family cannot be used with with this +socket+ * Errno::ECONNREFUSED - the target _sockaddr_ was not listening for connections refused the connection request * Errno::EFAULT - the socket's internal address or address length parameter is too small or is not a valid part of the user space address * Errno::EINVAL - the +socket+ is a listening socket * Errno::EISCONN - the +socket+ is already connected * Errno::ENETUNREACH - the network cannot be reached from this host at this time * Errno::EHOSTUNREACH - no route to the network is present * Errno::ENOBUFS - no buffer space is available * Errno::ENOTSOCK - the +socket+ argument does not refer to a socket * Errno::ETIMEDOUT - the attempt to connect timed out before a connection was made. * Errno::EWOULDBLOCK - the socket is marked as nonblocking and the connection cannot be completed immediately * Errno::EACCES - the attempt to connect the datagram socket to the broadcast address failed === See * connect manual pages on unix-based systems * connect function in Microsoft's Winsock functions reference @overload connect(remote_sockaddr) @return [0];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE sock_connect(VALUE sock, VALUE addr) { VALUE rai; rb_io_t *fptr; int fd, n; SockAddrStringValueWithAddrinfo(addr, rai); addr = rb_str_new4(addr); GetOpenFile(sock, fptr); fd = fptr->fd; n = rsock_connect(fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_SOCKLEN(addr), 0, NULL); if (n < 0) { rsock_sys_fail_raddrinfo_or_sockaddr("connect(2)", addr, rai); } return INT2FIX(n); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket#__connect_nonblock;F;7[[I" addr;T0[I"ex;T0;[[@i;T;:__connect_nonblock;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE sock_connect_nonblock(VALUE sock, VALUE addr, VALUE ex) { VALUE rai; rb_io_t *fptr; int n; SockAddrStringValueWithAddrinfo(addr, rai); addr = rb_str_new4(addr); GetOpenFile(sock, fptr); rb_io_set_nonblock(fptr); n = connect(fptr->fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_SOCKLEN(addr)); if (n < 0) { int e = errno; if (e == EINPROGRESS) { if (ex == Qfalse) { return sym_wait_writable; } rb_readwrite_syserr_fail(RB_IO_WAIT_WRITABLE, e, "connect(2) would block"); } if (e == EISCONN) { if (ex == Qfalse) { return INT2FIX(0); } } rsock_syserr_fail_raddrinfo_or_sockaddr(e, "connect(2)", addr, rai); } return INT2FIX(n); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket#bind;F;7[[I" addr;T0;[[@i ;T;; ;0;[;{;IC; "Binds to the given local address. === Parameter * +local_sockaddr+ - the +struct+ sockaddr contained in a string or an Addrinfo object === Example require 'socket' # use Addrinfo socket = Socket.new(:INET, :STREAM, 0) socket.bind(Addrinfo.tcp("127.0.0.1", 2222)) p socket.local_address #=> # # use struct sockaddr include Socket::Constants socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) socket.bind( sockaddr ) === Unix-based Exceptions On unix-based based systems the following system exceptions may be raised if the call to _bind_ fails: * Errno::EACCES - the specified _sockaddr_ is protected and the current user does not have permission to bind to it * Errno::EADDRINUSE - the specified _sockaddr_ is already in use * Errno::EADDRNOTAVAIL - the specified _sockaddr_ is not available from the local machine * Errno::EAFNOSUPPORT - the specified _sockaddr_ is not a valid address for the family of the calling +socket+ * Errno::EBADF - the _sockaddr_ specified is not a valid file descriptor * Errno::EFAULT - the _sockaddr_ argument cannot be accessed * Errno::EINVAL - the +socket+ is already bound to an address, and the protocol does not support binding to the new _sockaddr_ or the +socket+ has been shut down. * Errno::EINVAL - the address length is not a valid length for the address family * Errno::ENAMETOOLONG - the pathname resolved had a length which exceeded PATH_MAX * Errno::ENOBUFS - no buffer space is available * Errno::ENOSR - there were insufficient STREAMS resources available to complete the operation * Errno::ENOTSOCK - the +socket+ does not refer to a socket * Errno::EOPNOTSUPP - the socket type of the +socket+ does not support binding to an address On unix-based based systems if the address family of the calling +socket+ is Socket::AF_UNIX the follow exceptions may be raised if the call to _bind_ fails: * Errno::EACCES - search permission is denied for a component of the prefix path or write access to the +socket+ is denied * Errno::EDESTADDRREQ - the _sockaddr_ argument is a null pointer * Errno::EISDIR - same as Errno::EDESTADDRREQ * Errno::EIO - an i/o error occurred * Errno::ELOOP - too many symbolic links were encountered in translating the pathname in _sockaddr_ * Errno::ENAMETOOLLONG - a component of a pathname exceeded NAME_MAX characters, or an entire pathname exceeded PATH_MAX characters * Errno::ENOENT - a component of the pathname does not name an existing file or the pathname is an empty string * Errno::ENOTDIR - a component of the path prefix of the pathname in _sockaddr_ is not a directory * Errno::EROFS - the name would reside on a read only filesystem === Windows Exceptions On Windows systems the following system exceptions may be raised if the call to _bind_ fails: * Errno::ENETDOWN-- the network is down * Errno::EACCES - the attempt to connect the datagram socket to the broadcast address failed * Errno::EADDRINUSE - the socket's local address is already in use * Errno::EADDRNOTAVAIL - the specified address is not a valid address for this computer * Errno::EFAULT - the socket's internal address or address length parameter is too small or is not a valid part of the user space addressed * Errno::EINVAL - the +socket+ is already bound to an address * Errno::ENOBUFS - no buffer space is available * Errno::ENOTSOCK - the +socket+ argument does not refer to a socket === See * bind manual pages on unix-based systems * bind function in Microsoft's Winsock functions reference ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"bind(local_sockaddr);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@;![;"I"@return [0];T;#0;$@;.F;Bi;C0;7[[I"local_sockaddr;T0;$@;![;"I"=Binds to the given local address. === Parameter * +local_sockaddr+ - the +struct+ sockaddr contained in a string or an Addrinfo object === Example require 'socket' # use Addrinfo socket = Socket.new(:INET, :STREAM, 0) socket.bind(Addrinfo.tcp("127.0.0.1", 2222)) p socket.local_address #=> # # use struct sockaddr include Socket::Constants socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) socket.bind( sockaddr ) === Unix-based Exceptions On unix-based based systems the following system exceptions may be raised if the call to _bind_ fails: * Errno::EACCES - the specified _sockaddr_ is protected and the current user does not have permission to bind to it * Errno::EADDRINUSE - the specified _sockaddr_ is already in use * Errno::EADDRNOTAVAIL - the specified _sockaddr_ is not available from the local machine * Errno::EAFNOSUPPORT - the specified _sockaddr_ is not a valid address for the family of the calling +socket+ * Errno::EBADF - the _sockaddr_ specified is not a valid file descriptor * Errno::EFAULT - the _sockaddr_ argument cannot be accessed * Errno::EINVAL - the +socket+ is already bound to an address, and the protocol does not support binding to the new _sockaddr_ or the +socket+ has been shut down. * Errno::EINVAL - the address length is not a valid length for the address family * Errno::ENAMETOOLONG - the pathname resolved had a length which exceeded PATH_MAX * Errno::ENOBUFS - no buffer space is available * Errno::ENOSR - there were insufficient STREAMS resources available to complete the operation * Errno::ENOTSOCK - the +socket+ does not refer to a socket * Errno::EOPNOTSUPP - the socket type of the +socket+ does not support binding to an address On unix-based based systems if the address family of the calling +socket+ is Socket::AF_UNIX the follow exceptions may be raised if the call to _bind_ fails: * Errno::EACCES - search permission is denied for a component of the prefix path or write access to the +socket+ is denied * Errno::EDESTADDRREQ - the _sockaddr_ argument is a null pointer * Errno::EISDIR - same as Errno::EDESTADDRREQ * Errno::EIO - an i/o error occurred * Errno::ELOOP - too many symbolic links were encountered in translating the pathname in _sockaddr_ * Errno::ENAMETOOLLONG - a component of a pathname exceeded NAME_MAX characters, or an entire pathname exceeded PATH_MAX characters * Errno::ENOENT - a component of the pathname does not name an existing file or the pathname is an empty string * Errno::ENOTDIR - a component of the path prefix of the pathname in _sockaddr_ is not a directory * Errno::EROFS - the name would reside on a read only filesystem === Windows Exceptions On Windows systems the following system exceptions may be raised if the call to _bind_ fails: * Errno::ENETDOWN-- the network is down * Errno::EACCES - the attempt to connect the datagram socket to the broadcast address failed * Errno::EADDRINUSE - the socket's local address is already in use * Errno::EADDRNOTAVAIL - the specified address is not a valid address for this computer * Errno::EFAULT - the socket's internal address or address length parameter is too small or is not a valid part of the user space addressed * Errno::EINVAL - the +socket+ is already bound to an address * Errno::ENOBUFS - no buffer space is available * Errno::ENOTSOCK - the +socket+ argument does not refer to a socket === See * bind manual pages on unix-based systems * bind function in Microsoft's Winsock functions reference @overload bind(local_sockaddr) @return [0];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"Ostatic VALUE sock_bind(VALUE sock, VALUE addr) { VALUE rai; rb_io_t *fptr; SockAddrStringValueWithAddrinfo(addr, rai); GetOpenFile(sock, fptr); if (bind(fptr->fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_SOCKLEN(addr)) < 0) rsock_sys_fail_raddrinfo_or_sockaddr("bind(2)", addr, rai); return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket#listen;F;7[[I"log;T0;[[@i^;T;;A ;0;[;{;IC; "d Listens for connections, using the specified +int+ as the backlog. A call to _listen_ only applies if the +socket+ is of type SOCK_STREAM or SOCK_SEQPACKET. === Parameter * +backlog+ - the maximum length of the queue for pending connections. === Example 1 require 'socket' include Socket::Constants socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) socket.bind( sockaddr ) socket.listen( 5 ) === Example 2 (listening on an arbitrary port, unix-based systems only): require 'socket' include Socket::Constants socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) socket.listen( 1 ) === Unix-based Exceptions On unix based systems the above will work because a new +sockaddr+ struct is created on the address ADDR_ANY, for an arbitrary port number as handed off by the kernel. It will not work on Windows, because Windows requires that the +socket+ is bound by calling _bind_ before it can _listen_. If the _backlog_ amount exceeds the implementation-dependent maximum queue length, the implementation's maximum queue length will be used. On unix-based based systems the following system exceptions may be raised if the call to _listen_ fails: * Errno::EBADF - the _socket_ argument is not a valid file descriptor * Errno::EDESTADDRREQ - the _socket_ is not bound to a local address, and the protocol does not support listening on an unbound socket * Errno::EINVAL - the _socket_ is already connected * Errno::ENOTSOCK - the _socket_ argument does not refer to a socket * Errno::EOPNOTSUPP - the _socket_ protocol does not support listen * Errno::EACCES - the calling process does not have appropriate privileges * Errno::EINVAL - the _socket_ has been shut down * Errno::ENOBUFS - insufficient resources are available in the system to complete the call === Windows Exceptions On Windows systems the following system exceptions may be raised if the call to _listen_ fails: * Errno::ENETDOWN - the network is down * Errno::EADDRINUSE - the socket's local address is already in use. This usually occurs during the execution of _bind_ but could be delayed if the call to _bind_ was to a partially wildcard address (involving ADDR_ANY) and if a specific address needs to be committed at the time of the call to _listen_ * Errno::EINPROGRESS - a Windows Sockets 1.1 call is in progress or the service provider is still processing a callback function * Errno::EINVAL - the +socket+ has not been bound with a call to _bind_. * Errno::EISCONN - the +socket+ is already connected * Errno::EMFILE - no more socket descriptors are available * Errno::ENOBUFS - no buffer space is available * Errno::ENOTSOC - +socket+ is not a socket * Errno::EOPNOTSUPP - the referenced +socket+ is not a type that supports the _listen_ method === See * listen manual pages on unix-based systems * listen function in Microsoft's Winsock functions reference ;T;[o;= ;>I" overload;F;?0;;A ;@0;:I"listen( int );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@;![;"I"@return [0];T;#0;$@;.F;Bi;C0;7[[I"int;T0;$@;![;"I" Listens for connections, using the specified +int+ as the backlog. A call to _listen_ only applies if the +socket+ is of type SOCK_STREAM or SOCK_SEQPACKET. === Parameter * +backlog+ - the maximum length of the queue for pending connections. === Example 1 require 'socket' include Socket::Constants socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) socket.bind( sockaddr ) socket.listen( 5 ) === Example 2 (listening on an arbitrary port, unix-based systems only): require 'socket' include Socket::Constants socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) socket.listen( 1 ) === Unix-based Exceptions On unix based systems the above will work because a new +sockaddr+ struct is created on the address ADDR_ANY, for an arbitrary port number as handed off by the kernel. It will not work on Windows, because Windows requires that the +socket+ is bound by calling _bind_ before it can _listen_. If the _backlog_ amount exceeds the implementation-dependent maximum queue length, the implementation's maximum queue length will be used. On unix-based based systems the following system exceptions may be raised if the call to _listen_ fails: * Errno::EBADF - the _socket_ argument is not a valid file descriptor * Errno::EDESTADDRREQ - the _socket_ is not bound to a local address, and the protocol does not support listening on an unbound socket * Errno::EINVAL - the _socket_ is already connected * Errno::ENOTSOCK - the _socket_ argument does not refer to a socket * Errno::EOPNOTSUPP - the _socket_ protocol does not support listen * Errno::EACCES - the calling process does not have appropriate privileges * Errno::EINVAL - the _socket_ has been shut down * Errno::ENOBUFS - insufficient resources are available in the system to complete the call === Windows Exceptions On Windows systems the following system exceptions may be raised if the call to _listen_ fails: * Errno::ENETDOWN - the network is down * Errno::EADDRINUSE - the socket's local address is already in use. This usually occurs during the execution of _bind_ but could be delayed if the call to _bind_ was to a partially wildcard address (involving ADDR_ANY) and if a specific address needs to be committed at the time of the call to _listen_ * Errno::EINPROGRESS - a Windows Sockets 1.1 call is in progress or the service provider is still processing a callback function * Errno::EINVAL - the +socket+ has not been bound with a call to _bind_. * Errno::EISCONN - the +socket+ is already connected * Errno::EMFILE - no more socket descriptors are available * Errno::ENOBUFS - no buffer space is available * Errno::ENOTSOC - +socket+ is not a socket * Errno::EOPNOTSUPP - the referenced +socket+ is not a type that supports the _listen_ method === See * listen manual pages on unix-based systems * listen function in Microsoft's Winsock functions reference @overload listen( int ) @return [0];T;#0;$@;.F;/o;0;1T;2i;3i\;%@;9I"VALUE rsock_sock_listen(VALUE sock, VALUE log) { rb_io_t *fptr; int backlog; backlog = NUM2INT(log); GetOpenFile(sock, fptr); if (listen(fptr->fd, backlog) < 0) rb_sys_fail("listen(2)"); return INT2FIX(0); };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Socket#accept;F;7[;[[@i;T;;;0;[;{;IC; "Accepts a next connection. Returns a new Socket object and Addrinfo object. serv = Socket.new(:INET, :STREAM, 0) serv.listen(5) c = Socket.new(:INET, :STREAM, 0) c.connect(serv.connect_address) p serv.accept #=> [#, #] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" accept;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"7Accepts a next connection. Returns a new Socket object and Addrinfo object. serv = Socket.new(:INET, :STREAM, 0) serv.listen(5) c = Socket.new(:INET, :STREAM, 0) c.connect(serv.connect_address) p serv.accept #=> [#, #] @overload accept @return [Array];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE sock_accept(VALUE server) { union_sockaddr buffer; socklen_t length = (socklen_t)sizeof(buffer); VALUE peer = rsock_s_accept(rb_cSocket, server, &buffer.addr, &length); return rb_assoc_new(peer, rsock_io_socket_addrinfo(peer, &buffer.addr, length)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket#__accept_nonblock;F;7[[I"ex;T0;[[@i;T;;? ;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@8;.F;/o;0;1T;2i;3i;%@;9I"static VALUE sock_accept_nonblock(VALUE sock, VALUE ex) { rb_io_t *fptr; VALUE sock2; union_sockaddr buf; struct sockaddr *addr = &buf.addr; socklen_t len = (socklen_t)sizeof buf; GetOpenFile(sock, fptr); sock2 = rsock_s_accept_nonblock(rb_cSocket, ex, fptr, addr, &len); if (SYMBOL_P(sock2)) /* :wait_readable */ return sock2; return rb_assoc_new(sock2, rsock_io_socket_addrinfo(sock2, &buf.addr, len)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket#sysaccept;F;7[;[[@i3;T;;@ ;0;[;{;IC; "BAccepts an incoming connection returning an array containing the (integer) file descriptor for the incoming connection, _client_socket_fd_, and an Addrinfo, _client_addrinfo_. === Example # In one script, start this first require 'socket' include Socket::Constants socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) socket.bind( sockaddr ) socket.listen( 5 ) client_fd, client_addrinfo = socket.sysaccept client_socket = Socket.for_fd( client_fd ) puts "The client said, '#{client_socket.readline.chomp}'" client_socket.puts "Hello from script one!" socket.close # In another script, start this second require 'socket' include Socket::Constants socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) socket.connect( sockaddr ) socket.puts "Hello from script 2." puts "The server said, '#{socket.readline.chomp}'" socket.close Refer to Socket#accept for the exceptions that may be thrown if the call to _sysaccept_ fails. === See * Socket#accept ;T;[o;= ;>I" overload;F;?0;;@ ;@0;:I"sysaccept;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@H;![;"I"@return [Array];T;#0;$@H;.F;Bi;C0;7[;$@H;![;"I"jAccepts an incoming connection returning an array containing the (integer) file descriptor for the incoming connection, _client_socket_fd_, and an Addrinfo, _client_addrinfo_. === Example # In one script, start this first require 'socket' include Socket::Constants socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) socket.bind( sockaddr ) socket.listen( 5 ) client_fd, client_addrinfo = socket.sysaccept client_socket = Socket.for_fd( client_fd ) puts "The client said, '#{client_socket.readline.chomp}'" client_socket.puts "Hello from script one!" socket.close # In another script, start this second require 'socket' include Socket::Constants socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) socket.connect( sockaddr ) socket.puts "Hello from script 2." puts "The server said, '#{socket.readline.chomp}'" socket.close Refer to Socket#accept for the exceptions that may be thrown if the call to _sysaccept_ fails. === See * Socket#accept @overload sysaccept @return [Array];T;#0;$@H;.F;/o;0;1T;2i ;3i1;%@;9I"static VALUE sock_sysaccept(VALUE server) { union_sockaddr buffer; socklen_t length = (socklen_t)sizeof(buffer); VALUE peer = rsock_s_accept(0, server, &buffer.addr, &length); return rb_assoc_new(peer, rsock_io_socket_addrinfo(peer, &buffer.addr, length)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket#recvfrom;F;7[[@90;[[@i;T;;F ;0;[;{;IC; "1Receives up to _maxlen_ bytes from +socket+. _flags_ is zero or more of the +MSG_+ options. The first element of the results, _mesg_, is the data received. The second element, _sender_addrinfo_, contains protocol-specific address information of the sender. === Parameters * +maxlen+ - the maximum number of bytes to receive from the socket * +flags+ - zero or more of the +MSG_+ options === Example # In one file, start this first require 'socket' include Socket::Constants socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) socket.bind( sockaddr ) socket.listen( 5 ) client, client_addrinfo = socket.accept data = client.recvfrom( 20 )[0].chomp puts "I only received 20 bytes '#{data}'" sleep 1 socket.close # In another file, start this second require 'socket' include Socket::Constants socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) socket.connect( sockaddr ) socket.puts "Watch this get cut short!" socket.close === Unix-based Exceptions On unix-based based systems the following system exceptions may be raised if the call to _recvfrom_ fails: * Errno::EAGAIN - the +socket+ file descriptor is marked as O_NONBLOCK and no data is waiting to be received; or MSG_OOB is set and no out-of-band data is available and either the +socket+ file descriptor is marked as O_NONBLOCK or the +socket+ does not support blocking to wait for out-of-band-data * Errno::EWOULDBLOCK - see Errno::EAGAIN * Errno::EBADF - the +socket+ is not a valid file descriptor * Errno::ECONNRESET - a connection was forcibly closed by a peer * Errno::EFAULT - the socket's internal buffer, address or address length cannot be accessed or written * Errno::EINTR - a signal interrupted _recvfrom_ before any data was available * Errno::EINVAL - the MSG_OOB flag is set and no out-of-band data is available * Errno::EIO - an i/o error occurred while reading from or writing to the filesystem * Errno::ENOBUFS - insufficient resources were available in the system to perform the operation * Errno::ENOMEM - insufficient memory was available to fulfill the request * Errno::ENOSR - there were insufficient STREAMS resources available to complete the operation * Errno::ENOTCONN - a receive is attempted on a connection-mode socket that is not connected * Errno::ENOTSOCK - the +socket+ does not refer to a socket * Errno::EOPNOTSUPP - the specified flags are not supported for this socket type * Errno::ETIMEDOUT - the connection timed out during connection establishment or due to a transmission timeout on an active connection === Windows Exceptions On Windows systems the following system exceptions may be raised if the call to _recvfrom_ fails: * Errno::ENETDOWN - the network is down * Errno::EFAULT - the internal buffer and from parameters on +socket+ are not part of the user address space, or the internal fromlen parameter is too small to accommodate the peer address * Errno::EINTR - the (blocking) call was cancelled by an internal call to the WinSock function WSACancelBlockingCall * Errno::EINPROGRESS - a blocking Windows Sockets 1.1 call is in progress or the service provider is still processing a callback function * Errno::EINVAL - +socket+ has not been bound with a call to _bind_, or an unknown flag was specified, or MSG_OOB was specified for a socket with SO_OOBINLINE enabled, or (for byte stream-style sockets only) the internal len parameter on +socket+ was zero or negative * Errno::EISCONN - +socket+ is already connected. The call to _recvfrom_ is not permitted with a connected socket on a socket that is connection oriented or connectionless. * Errno::ENETRESET - the connection has been broken due to the keep-alive activity detecting a failure while the operation was in progress. * Errno::EOPNOTSUPP - MSG_OOB was specified, but +socket+ is not stream-style such as type SOCK_STREAM. OOB data is not supported in the communication domain associated with +socket+, or +socket+ is unidirectional and supports only send operations * Errno::ESHUTDOWN - +socket+ has been shutdown. It is not possible to call _recvfrom_ on a socket after _shutdown_ has been invoked. * Errno::EWOULDBLOCK - +socket+ is marked as nonblocking and a call to _recvfrom_ would block. * Errno::EMSGSIZE - the message was too large to fit into the specified buffer and was truncated. * Errno::ETIMEDOUT - the connection has been dropped, because of a network failure or because the system on the other end went down without notice * Errno::ECONNRESET - the virtual circuit was reset by the remote side executing a hard or abortive close. The application should close the socket; it is no longer usable. On a UDP-datagram socket this error indicates a previous send operation resulted in an ICMP Port Unreachable message. ;T;[o;= ;>I" overload;F;?0;;F ;@0;:I"recvfrom(maxlen);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@c;![;"I"@return [Array];T;#0;$@c;.F;Bi;C0;7[[I" maxlen;T0;$@co;= ;>I" overload;F;?0;;F ;@0;:I"recvfrom(maxlen, flags);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@c;![;"I"@return [Array];T;#0;$@c;.F;Bi;C0;7[[I" maxlen;T0[I" flags;T0;$@c;![;"I"Receives up to _maxlen_ bytes from +socket+. _flags_ is zero or more of the +MSG_+ options. The first element of the results, _mesg_, is the data received. The second element, _sender_addrinfo_, contains protocol-specific address information of the sender. === Parameters * +maxlen+ - the maximum number of bytes to receive from the socket * +flags+ - zero or more of the +MSG_+ options === Example # In one file, start this first require 'socket' include Socket::Constants socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) socket.bind( sockaddr ) socket.listen( 5 ) client, client_addrinfo = socket.accept data = client.recvfrom( 20 )[0].chomp puts "I only received 20 bytes '#{data}'" sleep 1 socket.close # In another file, start this second require 'socket' include Socket::Constants socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) socket.connect( sockaddr ) socket.puts "Watch this get cut short!" socket.close === Unix-based Exceptions On unix-based based systems the following system exceptions may be raised if the call to _recvfrom_ fails: * Errno::EAGAIN - the +socket+ file descriptor is marked as O_NONBLOCK and no data is waiting to be received; or MSG_OOB is set and no out-of-band data is available and either the +socket+ file descriptor is marked as O_NONBLOCK or the +socket+ does not support blocking to wait for out-of-band-data * Errno::EWOULDBLOCK - see Errno::EAGAIN * Errno::EBADF - the +socket+ is not a valid file descriptor * Errno::ECONNRESET - a connection was forcibly closed by a peer * Errno::EFAULT - the socket's internal buffer, address or address length cannot be accessed or written * Errno::EINTR - a signal interrupted _recvfrom_ before any data was available * Errno::EINVAL - the MSG_OOB flag is set and no out-of-band data is available * Errno::EIO - an i/o error occurred while reading from or writing to the filesystem * Errno::ENOBUFS - insufficient resources were available in the system to perform the operation * Errno::ENOMEM - insufficient memory was available to fulfill the request * Errno::ENOSR - there were insufficient STREAMS resources available to complete the operation * Errno::ENOTCONN - a receive is attempted on a connection-mode socket that is not connected * Errno::ENOTSOCK - the +socket+ does not refer to a socket * Errno::EOPNOTSUPP - the specified flags are not supported for this socket type * Errno::ETIMEDOUT - the connection timed out during connection establishment or due to a transmission timeout on an active connection === Windows Exceptions On Windows systems the following system exceptions may be raised if the call to _recvfrom_ fails: * Errno::ENETDOWN - the network is down * Errno::EFAULT - the internal buffer and from parameters on +socket+ are not part of the user address space, or the internal fromlen parameter is too small to accommodate the peer address * Errno::EINTR - the (blocking) call was cancelled by an internal call to the WinSock function WSACancelBlockingCall * Errno::EINPROGRESS - a blocking Windows Sockets 1.1 call is in progress or the service provider is still processing a callback function * Errno::EINVAL - +socket+ has not been bound with a call to _bind_, or an unknown flag was specified, or MSG_OOB was specified for a socket with SO_OOBINLINE enabled, or (for byte stream-style sockets only) the internal len parameter on +socket+ was zero or negative * Errno::EISCONN - +socket+ is already connected. The call to _recvfrom_ is not permitted with a connected socket on a socket that is connection oriented or connectionless. * Errno::ENETRESET - the connection has been broken due to the keep-alive activity detecting a failure while the operation was in progress. * Errno::EOPNOTSUPP - MSG_OOB was specified, but +socket+ is not stream-style such as type SOCK_STREAM. OOB data is not supported in the communication domain associated with +socket+, or +socket+ is unidirectional and supports only send operations * Errno::ESHUTDOWN - +socket+ has been shutdown. It is not possible to call _recvfrom_ on a socket after _shutdown_ has been invoked. * Errno::EWOULDBLOCK - +socket+ is marked as nonblocking and a call to _recvfrom_ would block. * Errno::EMSGSIZE - the message was too large to fit into the specified buffer and was truncated. * Errno::ETIMEDOUT - the connection has been dropped, because of a network failure or because the system on the other end went down without notice * Errno::ECONNRESET - the virtual circuit was reset by the remote side executing a hard or abortive close. The application should close the socket; it is no longer usable. On a UDP-datagram socket this error indicates a previous send operation resulted in an ICMP Port Unreachable message. @overload recvfrom(maxlen) @return [Array] @overload recvfrom(maxlen, flags) @return [Array];T;#0;$@c;.F;/o;0;1T;2il;3i;%@;9I"}static VALUE sock_recvfrom(int argc, VALUE *argv, VALUE sock) { return rsock_s_recvfrom(sock, argc, argv, RECV_SOCKET); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket#__recvfrom_nonblock;F;7[ [I"len;T0[I"flg;T0[I"str;T0[I"ex;T0;[[@i;T;:__recvfrom_nonblock;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE sock_recvfrom_nonblock(VALUE sock, VALUE len, VALUE flg, VALUE str, VALUE ex) { return rsock_s_recvfrom_nonblock(sock, len, flg, str, ex, RECV_SOCKET); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket.socketpair;F;7[[@90;[[@i;T;;I ;0;[;{;IC; "9Creates a pair of sockets connected each other. _domain_ should be a communications domain such as: :INET, :INET6, :UNIX, etc. _socktype_ should be a socket type such as: :STREAM, :DGRAM, :RAW, etc. _protocol_ should be a protocol defined in the domain, defaults to 0 for the domain. s1, s2 = Socket.pair(:UNIX, :STREAM, 0) s1.send "a", 0 s1.send "b", 0 s1.close p s2.recv(10) #=> "ab" p s2.recv(10) #=> "" p s2.recv(10) #=> "" s1, s2 = Socket.pair(:UNIX, :DGRAM, 0) s1.send "a", 0 s1.send "b", 0 p s2.recv(10) #=> "a" p s2.recv(10) #=> "b" ;T;[o;= ;>I" overload;F;?0;;J ;@0;:I"!pair(domain, type, protocol);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" domain;T0[I" type;T0[I" protocol;T0;$@o;= ;>I" overload;F;?0;;I ;@0;:I"'socketpair(domain, type, protocol);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" domain;T0[I" type;T0[I" protocol;T0;$@;![;"I"Creates a pair of sockets connected each other. _domain_ should be a communications domain such as: :INET, :INET6, :UNIX, etc. _socktype_ should be a socket type such as: :STREAM, :DGRAM, :RAW, etc. _protocol_ should be a protocol defined in the domain, defaults to 0 for the domain. s1, s2 = Socket.pair(:UNIX, :STREAM, 0) s1.send "a", 0 s1.send "b", 0 s1.close p s2.recv(10) #=> "ab" p s2.recv(10) #=> "" p s2.recv(10) #=> "" s1, s2 = Socket.pair(:UNIX, :DGRAM, 0) s1.send "a", 0 s1.send "b", 0 p s2.recv(10) #=> "a" p s2.recv(10) #=> "b" @overload pair(domain, type, protocol) @return [Array] @overload socketpair(domain, type, protocol) @return [Array];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"VALUE rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass) { VALUE domain, type, protocol; int d, t, p, sp[2]; int ret; VALUE s1, s2, r; rb_scan_args(argc, argv, "21", &domain, &type, &protocol); if (NIL_P(protocol)) protocol = INT2FIX(0); setup_domain_and_type(domain, &d, type, &t); p = NUM2INT(protocol); ret = rsock_socketpair(d, t, p, sp); if (ret < 0) { rb_sys_fail("socketpair(2)"); } s1 = rsock_init_sock(rb_obj_alloc(klass), sp[0]); s2 = rsock_init_sock(rb_obj_alloc(klass), sp[1]); r = rb_assoc_new(s1, s2); if (rb_block_given_p()) { return rb_ensure(pair_yield, r, io_close, s1); } return r; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Socket.pair;F;7[[@90;[[@i;T;;J ;0;[;{;IC; "9Creates a pair of sockets connected each other. _domain_ should be a communications domain such as: :INET, :INET6, :UNIX, etc. _socktype_ should be a socket type such as: :STREAM, :DGRAM, :RAW, etc. _protocol_ should be a protocol defined in the domain, defaults to 0 for the domain. s1, s2 = Socket.pair(:UNIX, :STREAM, 0) s1.send "a", 0 s1.send "b", 0 s1.close p s2.recv(10) #=> "ab" p s2.recv(10) #=> "" p s2.recv(10) #=> "" s1, s2 = Socket.pair(:UNIX, :DGRAM, 0) s1.send "a", 0 s1.send "b", 0 p s2.recv(10) #=> "a" p s2.recv(10) #=> "b" ;T;[o;= ;>I" overload;F;?0;;J ;@0;:I"!pair(domain, type, protocol);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" domain;T0[I" type;T0[I" protocol;T0;$@o;= ;>I" overload;F;?0;;I ;@0;:I"'socketpair(domain, type, protocol);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" domain;T0[I" type;T0[I" protocol;T0;$@;![;"@;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"VALUE rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass) { VALUE domain, type, protocol; int d, t, p, sp[2]; int ret; VALUE s1, s2, r; rb_scan_args(argc, argv, "21", &domain, &type, &protocol); if (NIL_P(protocol)) protocol = INT2FIX(0); setup_domain_and_type(domain, &d, type, &t); p = NUM2INT(protocol); ret = rsock_socketpair(d, t, p, sp); if (ret < 0) { rb_sys_fail("socketpair(2)"); } s1 = rsock_init_sock(rb_obj_alloc(klass), sp[0]); s2 = rsock_init_sock(rb_obj_alloc(klass), sp[1]); r = rb_assoc_new(s1, s2); if (rb_block_given_p()) { return rb_ensure(pair_yield, r, io_close, s1); } return r; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"Socket.gethostname;F;7[;[[@ip;T;:gethostname;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@;9I"~static VALUE sock_gethostname(VALUE obj) { struct utsname un; uname(&un); return rb_str_new2(un.nodename); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket.gethostbyname;F;7[[I" host;T0;[[@i;T;:gethostbyname;0;[;{;IC; "Use Addrinfo.getaddrinfo instead. This method is deprecated for the following reasons: - The 3rd element of the result is the address family of the first address. The address families of the rest of the addresses are not returned. - Uncommon address representation: 4/16-bytes binary string to represent IPv4/IPv6 address. - gethostbyname() may take a long time and it may block other threads. (GVL cannot be released since gethostbyname() is not thread safe.) - This method uses gethostbyname() function already removed from POSIX. This method obtains the host information for _hostname_. p Socket.gethostbyname("hal") #=> ["localhost", ["hal"], 2, "\x7F\x00\x00\x01"] ;T;[o;= ;>I" overload;F;?0;;v ;@0;:I"gethostbyname(hostname);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" hostname;T0;$@;![;"I"Use Addrinfo.getaddrinfo instead. This method is deprecated for the following reasons: - The 3rd element of the result is the address family of the first address. The address families of the rest of the addresses are not returned. - Uncommon address representation: 4/16-bytes binary string to represent IPv4/IPv6 address. - gethostbyname() may take a long time and it may block other threads. (GVL cannot be released since gethostbyname() is not thread safe.) - This method uses gethostbyname() function already removed from POSIX. This method obtains the host information for _hostname_. p Socket.gethostbyname("hal") #=> ["localhost", ["hal"], 2, "\x7F\x00\x00\x01"] @overload gethostbyname(hostname) @return [Array];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I",static VALUE sock_s_gethostbyname(VALUE obj, VALUE host) { rb_warn("Socket.gethostbyname is deprecated; use Addrinfo.getaddrinfo instead."); struct rb_addrinfo *res = rsock_addrinfo(host, Qnil, AF_UNSPEC, SOCK_STREAM, AI_CANONNAME); return rsock_make_hostent(host, res, sock_sockaddr); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket.gethostbyaddr;F;7[[@90;[[@i;T;:gethostbyaddr;0;[;{;IC; "KUse Addrinfo#getnameinfo instead. This method is deprecated for the following reasons: - Uncommon address representation: 4/16-bytes binary string to represent IPv4/IPv6 address. - gethostbyaddr() may take a long time and it may block other threads. (GVL cannot be released since gethostbyname() is not thread safe.) - This method uses gethostbyname() function already removed from POSIX. This method obtains the host information for _address_. p Socket.gethostbyaddr([221,186,184,68].pack("CCCC")) #=> ["carbon.ruby-lang.org", [], 2, "\xDD\xBA\xB8D"] p Socket.gethostbyaddr([127,0,0,1].pack("CCCC")) ["localhost", [], 2, "\x7F\x00\x00\x01"] p Socket.gethostbyaddr(([0]*15+[1]).pack("C"*16)) #=> ["localhost", ["ip6-localhost", "ip6-loopback"], 10, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"] ;T;[o;= ;>I" overload;F;?0;;w ;@0;:I"5gethostbyaddr(address_string [, address_family]);T;IC; ";T;[;![;"I";T;#0;$@<;.F;Bi;C0;7[[I"%address_string[, address_family];T0;$@<;![;"I"Use Addrinfo#getnameinfo instead. This method is deprecated for the following reasons: - Uncommon address representation: 4/16-bytes binary string to represent IPv4/IPv6 address. - gethostbyaddr() may take a long time and it may block other threads. (GVL cannot be released since gethostbyname() is not thread safe.) - This method uses gethostbyname() function already removed from POSIX. This method obtains the host information for _address_. p Socket.gethostbyaddr([221,186,184,68].pack("CCCC")) #=> ["carbon.ruby-lang.org", [], 2, "\xDD\xBA\xB8D"] p Socket.gethostbyaddr([127,0,0,1].pack("CCCC")) ["localhost", [], 2, "\x7F\x00\x00\x01"] p Socket.gethostbyaddr(([0]*15+[1]).pack("C"*16)) #=> ["localhost", ["ip6-localhost", "ip6-loopback"], 10, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"] @overload gethostbyaddr(address_string [, address_family]);T;#0;$@<;.F;/o;0;1T;2i;3i;%@;9I"static VALUE sock_s_gethostbyaddr(int argc, VALUE *argv, VALUE _) { VALUE addr, family; struct hostent *h; char **pch; VALUE ary, names; int t = AF_INET; rb_warn("Socket.gethostbyaddr is deprecated; use Addrinfo#getnameinfo instead."); rb_scan_args(argc, argv, "11", &addr, &family); StringValue(addr); if (!NIL_P(family)) { t = rsock_family_arg(family); } #ifdef AF_INET6 else if (RSTRING_LEN(addr) == 16) { t = AF_INET6; } #endif h = gethostbyaddr(RSTRING_PTR(addr), RSTRING_SOCKLEN(addr), t); if (h == NULL) { #ifdef HAVE_HSTRERROR extern int h_errno; rb_raise(rb_eSocket, "%s", (char*)hstrerror(h_errno)); #else rb_raise(rb_eSocket, "host not found"); #endif } ary = rb_ary_new(); rb_ary_push(ary, rb_str_new2(h->h_name)); names = rb_ary_new(); rb_ary_push(ary, names); if (h->h_aliases != NULL) { for (pch = h->h_aliases; *pch; pch++) { rb_ary_push(names, rb_str_new2(*pch)); } } rb_ary_push(ary, INT2NUM(h->h_addrtype)); #ifdef h_addr for (pch = h->h_addr_list; *pch; pch++) { rb_ary_push(ary, rb_str_new(*pch, h->h_length)); } #else rb_ary_push(ary, rb_str_new(h->h_addr, h->h_length)); #endif return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket.getservbyname;F;7[[@90;[[@i!;T;:getservbyname;0;[;{;IC; "Obtains the port number for _service_name_. If _protocol_name_ is not given, "tcp" is assumed. Socket.getservbyname("smtp") #=> 25 Socket.getservbyname("shell") #=> 514 Socket.getservbyname("syslog", "udp") #=> 514 ;T;[o;= ;>I" overload;F;?0;;x ;@0;:I" getservbyname(service_name);T;IC; ";T;[;![;"I";T;#0;$@U;.F;Bi;C0;7[[I"service_name;T0;$@Uo;= ;>I" overload;F;?0;;x ;@0;:I"/getservbyname(service_name, protocol_name);T;IC; ";T;[;![;"I";T;#0;$@U;.F;Bi;C0;7[[I"service_name;T0[I"protocol_name;T0;$@U;![;"I"LObtains the port number for _service_name_. If _protocol_name_ is not given, "tcp" is assumed. Socket.getservbyname("smtp") #=> 25 Socket.getservbyname("shell") #=> 514 Socket.getservbyname("syslog", "udp") #=> 514 @overload getservbyname(service_name) @overload getservbyname(service_name, protocol_name);T;#0;$@U;.F;/o;0;1T;2i;3i;%@;9I"static VALUE sock_s_getservbyname(int argc, VALUE *argv, VALUE _) { VALUE service, proto; struct servent *sp; long port; const char *servicename, *protoname = "tcp"; rb_scan_args(argc, argv, "11", &service, &proto); StringValue(service); if (!NIL_P(proto)) StringValue(proto); servicename = StringValueCStr(service); if (!NIL_P(proto)) protoname = StringValueCStr(proto); sp = getservbyname(servicename, protoname); if (sp) { port = ntohs(sp->s_port); } else { char *end; port = STRTOUL(servicename, &end, 0); if (*end != '\0') { rb_raise(rb_eSocket, "no such service %s/%s", servicename, protoname); } } return INT2FIX(port); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket.getservbyport;F;7[[@90;[[@iJ;T;:getservbyport;0;[;{;IC; "Obtains the port number for _port_. If _protocol_name_ is not given, "tcp" is assumed. Socket.getservbyport(80) #=> "www" Socket.getservbyport(514, "tcp") #=> "shell" Socket.getservbyport(514, "udp") #=> "syslog" ;T;[o;= ;>I" overload;F;?0;;y ;@0;:I"*getservbyport(port [, protocol_name]);T;IC; ";T;[;![;"I";T;#0;$@z;.F;Bi;C0;7[[I"port[, protocol_name];T0;$@z;![;"I"Obtains the port number for _port_. If _protocol_name_ is not given, "tcp" is assumed. Socket.getservbyport(80) #=> "www" Socket.getservbyport(514, "tcp") #=> "shell" Socket.getservbyport(514, "udp") #=> "syslog" @overload getservbyport(port [, protocol_name]);T;#0;$@z;.F;/o;0;1T;2i=;3iG;%@;9I"static VALUE sock_s_getservbyport(int argc, VALUE *argv, VALUE _) { VALUE port, proto; struct servent *sp; long portnum; const char *protoname = "tcp"; rb_scan_args(argc, argv, "11", &port, &proto); portnum = NUM2LONG(port); if (portnum != (uint16_t)portnum) { const char *s = portnum > 0 ? "big" : "small"; rb_raise(rb_eRangeError, "integer %ld too %s to convert into `int16_t'", portnum, s); } if (!NIL_P(proto)) protoname = StringValueCStr(proto); sp = getservbyport((int)htons((uint16_t)portnum), protoname); if (!sp) { rb_raise(rb_eSocket, "no such service for port %d/%s", (int)portnum, protoname); } return rb_str_new2(sp->s_name); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket.getaddrinfo;F;7[[@90;[[@i;T;;M ;0;[;{;IC; "aObtains address information for _nodename_:_servname_. Note that Addrinfo.getaddrinfo provides the same functionality in an object oriented style. _family_ should be an address family such as: :INET, :INET6, etc. _socktype_ should be a socket type such as: :STREAM, :DGRAM, :RAW, etc. _protocol_ should be a protocol defined in the family, and defaults to 0 for the family. _flags_ should be bitwise OR of Socket::AI_* constants. Socket.getaddrinfo("www.ruby-lang.org", "http", nil, :STREAM) #=> [["AF_INET", 80, "carbon.ruby-lang.org", "221.186.184.68", 2, 1, 6]] # PF_INET/SOCK_STREAM/IPPROTO_TCP Socket.getaddrinfo("localhost", nil) #=> [["AF_INET", 0, "localhost", "127.0.0.1", 2, 1, 6], # PF_INET/SOCK_STREAM/IPPROTO_TCP # ["AF_INET", 0, "localhost", "127.0.0.1", 2, 2, 17], # PF_INET/SOCK_DGRAM/IPPROTO_UDP # ["AF_INET", 0, "localhost", "127.0.0.1", 2, 3, 0]] # PF_INET/SOCK_RAW/IPPROTO_IP _reverse_lookup_ directs the form of the third element, and has to be one of below. If _reverse_lookup_ is omitted, the default value is +nil+. +true+, +:hostname+: hostname is obtained from numeric address using reverse lookup, which may take a time. +false+, +:numeric+: hostname is the same as numeric address. +nil+: obey to the current +do_not_reverse_lookup+ flag. If Addrinfo object is preferred, use Addrinfo.getaddrinfo. ;T;[o;= ;>I" overload;F;?0;;M ;@0;:I"agetaddrinfo(nodename, servname[, family[, socktype[, protocol[, flags[, reverse_lookup]]]]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" nodename;T0[I"Jservname[, family[, socktype[, protocol[, flags[, reverse_lookup]]]]];T0;$@;![;"I"Obtains address information for _nodename_:_servname_. Note that Addrinfo.getaddrinfo provides the same functionality in an object oriented style. _family_ should be an address family such as: :INET, :INET6, etc. _socktype_ should be a socket type such as: :STREAM, :DGRAM, :RAW, etc. _protocol_ should be a protocol defined in the family, and defaults to 0 for the family. _flags_ should be bitwise OR of Socket::AI_* constants. Socket.getaddrinfo("www.ruby-lang.org", "http", nil, :STREAM) #=> [["AF_INET", 80, "carbon.ruby-lang.org", "221.186.184.68", 2, 1, 6]] # PF_INET/SOCK_STREAM/IPPROTO_TCP Socket.getaddrinfo("localhost", nil) #=> [["AF_INET", 0, "localhost", "127.0.0.1", 2, 1, 6], # PF_INET/SOCK_STREAM/IPPROTO_TCP # ["AF_INET", 0, "localhost", "127.0.0.1", 2, 2, 17], # PF_INET/SOCK_DGRAM/IPPROTO_UDP # ["AF_INET", 0, "localhost", "127.0.0.1", 2, 3, 0]] # PF_INET/SOCK_RAW/IPPROTO_IP _reverse_lookup_ directs the form of the third element, and has to be one of below. If _reverse_lookup_ is omitted, the default value is +nil+. +true+, +:hostname+: hostname is obtained from numeric address using reverse lookup, which may take a time. +false+, +:numeric+: hostname is the same as numeric address. +nil+: obey to the current +do_not_reverse_lookup+ flag. If Addrinfo object is preferred, use Addrinfo.getaddrinfo. @overload getaddrinfo(nodename, servname[, family[, socktype[, protocol[, flags[, reverse_lookup]]]]]) @return [Array];T;#0;$@;.F;/o;0;1T;2ia;3i;%@;9I"static VALUE sock_s_getaddrinfo(int argc, VALUE *argv, VALUE _) { VALUE host, port, family, socktype, protocol, flags, ret, revlookup; struct addrinfo hints; struct rb_addrinfo *res; int norevlookup; rb_scan_args(argc, argv, "25", &host, &port, &family, &socktype, &protocol, &flags, &revlookup); MEMZERO(&hints, struct addrinfo, 1); hints.ai_family = NIL_P(family) ? PF_UNSPEC : rsock_family_arg(family); if (!NIL_P(socktype)) { hints.ai_socktype = rsock_socktype_arg(socktype); } if (!NIL_P(protocol)) { hints.ai_protocol = NUM2INT(protocol); } if (!NIL_P(flags)) { hints.ai_flags = NUM2INT(flags); } if (NIL_P(revlookup) || !rsock_revlookup_flag(revlookup, &norevlookup)) { norevlookup = rsock_do_not_reverse_lookup; } res = rsock_getaddrinfo(host, port, &hints, 0); ret = make_addrinfo(res, norevlookup); rb_freeaddrinfo(res); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket.getnameinfo;F;7[[@90;[[@i;T;;q ;0;[;{;IC; "Obtains name information for _sockaddr_. _sockaddr_ should be one of follows. - packed sockaddr string such as Socket.sockaddr_in(80, "127.0.0.1") - 3-elements array such as ["AF_INET", 80, "127.0.0.1"] - 4-elements array such as ["AF_INET", 80, ignored, "127.0.0.1"] _flags_ should be bitwise OR of Socket::NI_* constants. Note: The last form is compatible with IPSocket#addr and IPSocket#peeraddr. Socket.getnameinfo(Socket.sockaddr_in(80, "127.0.0.1")) #=> ["localhost", "www"] Socket.getnameinfo(["AF_INET", 80, "127.0.0.1"]) #=> ["localhost", "www"] Socket.getnameinfo(["AF_INET", 80, "localhost", "127.0.0.1"]) #=> ["localhost", "www"] If Addrinfo object is preferred, use Addrinfo#getnameinfo. ;T;[o;= ;>I" overload;F;?0;;q ;@0;:I"$getnameinfo(sockaddr [, flags]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"sockaddr[, flags];T0;$@;![;"I"Obtains name information for _sockaddr_. _sockaddr_ should be one of follows. - packed sockaddr string such as Socket.sockaddr_in(80, "127.0.0.1") - 3-elements array such as ["AF_INET", 80, "127.0.0.1"] - 4-elements array such as ["AF_INET", 80, ignored, "127.0.0.1"] _flags_ should be bitwise OR of Socket::NI_* constants. Note: The last form is compatible with IPSocket#addr and IPSocket#peeraddr. Socket.getnameinfo(Socket.sockaddr_in(80, "127.0.0.1")) #=> ["localhost", "www"] Socket.getnameinfo(["AF_INET", 80, "127.0.0.1"]) #=> ["localhost", "www"] Socket.getnameinfo(["AF_INET", 80, "localhost", "127.0.0.1"]) #=> ["localhost", "www"] If Addrinfo object is preferred, use Addrinfo#getnameinfo. @overload getnameinfo(sockaddr [, flags]) @return [Array];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"L static VALUE sock_s_getnameinfo(int argc, VALUE *argv, VALUE _) { VALUE sa, af = Qnil, host = Qnil, port = Qnil, flags, tmp; char hbuf[1024], pbuf[1024]; int fl; struct rb_addrinfo *res = NULL; struct addrinfo hints, *r; int error, saved_errno; union_sockaddr ss; struct sockaddr *sap; socklen_t salen; sa = flags = Qnil; rb_scan_args(argc, argv, "11", &sa, &flags); fl = 0; if (!NIL_P(flags)) { fl = NUM2INT(flags); } tmp = rb_check_sockaddr_string_type(sa); if (!NIL_P(tmp)) { sa = tmp; if (sizeof(ss) < (size_t)RSTRING_LEN(sa)) { rb_raise(rb_eTypeError, "sockaddr length too big"); } memcpy(&ss, RSTRING_PTR(sa), RSTRING_LEN(sa)); if (!VALIDATE_SOCKLEN(&ss.addr, RSTRING_LEN(sa))) { rb_raise(rb_eTypeError, "sockaddr size differs - should not happen"); } sap = &ss.addr; salen = RSTRING_SOCKLEN(sa); goto call_nameinfo; } tmp = rb_check_array_type(sa); if (!NIL_P(tmp)) { sa = tmp; MEMZERO(&hints, struct addrinfo, 1); if (RARRAY_LEN(sa) == 3) { af = RARRAY_AREF(sa, 0); port = RARRAY_AREF(sa, 1); host = RARRAY_AREF(sa, 2); } else if (RARRAY_LEN(sa) >= 4) { af = RARRAY_AREF(sa, 0); port = RARRAY_AREF(sa, 1); host = RARRAY_AREF(sa, 3); if (NIL_P(host)) { host = RARRAY_AREF(sa, 2); } else { /* * 4th element holds numeric form, don't resolve. * see rsock_ipaddr(). */ #ifdef AI_NUMERICHOST /* AIX 4.3.3 doesn't have AI_NUMERICHOST. */ hints.ai_flags |= AI_NUMERICHOST; #endif } } else { rb_raise(rb_eArgError, "array size should be 3 or 4, %ld given", RARRAY_LEN(sa)); } hints.ai_socktype = (fl & NI_DGRAM) ? SOCK_DGRAM : SOCK_STREAM; /* af */ hints.ai_family = NIL_P(af) ? PF_UNSPEC : rsock_family_arg(af); res = rsock_getaddrinfo(host, port, &hints, 0); sap = res->ai->ai_addr; salen = res->ai->ai_addrlen; } else { rb_raise(rb_eTypeError, "expecting String or Array"); } call_nameinfo: error = rb_getnameinfo(sap, salen, hbuf, sizeof(hbuf), pbuf, sizeof(pbuf), fl); if (error) goto error_exit_name; if (res) { for (r = res->ai->ai_next; r; r = r->ai_next) { char hbuf2[1024], pbuf2[1024]; sap = r->ai_addr; salen = r->ai_addrlen; error = rb_getnameinfo(sap, salen, hbuf2, sizeof(hbuf2), pbuf2, sizeof(pbuf2), fl); if (error) goto error_exit_name; if (strcmp(hbuf, hbuf2) != 0|| strcmp(pbuf, pbuf2) != 0) { rb_freeaddrinfo(res); rb_raise(rb_eSocket, "sockaddr resolved to multiple nodename"); } } rb_freeaddrinfo(res); } return rb_assoc_new(rb_str_new2(hbuf), rb_str_new2(pbuf)); error_exit_name: saved_errno = errno; if (res) rb_freeaddrinfo(res); errno = saved_errno; rsock_raise_socket_error("getnameinfo", error); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket.sockaddr_in;F;7[[I" port;T0[I" host;T0;[[@i3;T;:sockaddr_in;0;[;{;IC; "APacks _port_ and _host_ as an AF_INET/AF_INET6 sockaddr string. Socket.sockaddr_in(80, "127.0.0.1") #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" Socket.sockaddr_in(80, "::1") #=> "\n\x00\x00P\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00" ;T;[o;= ;>I" overload;F;?0;;z ;@0;:I"sockaddr_in(port, host);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" port;T0[I" host;T0;$@o;= ;>I" overload;F;?0;:pack_sockaddr_in;@0;:I"!pack_sockaddr_in(port, host);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" port;T0[I" host;T0;$@;![;"I"Packs _port_ and _host_ as an AF_INET/AF_INET6 sockaddr string. Socket.sockaddr_in(80, "127.0.0.1") #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" Socket.sockaddr_in(80, "::1") #=> "\n\x00\x00P\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00" @overload sockaddr_in(port, host) @overload pack_sockaddr_in(port, host);T;#0;$@;.F;/o;0;1T;2i%;3i0;%@;9I"static VALUE sock_s_pack_sockaddr_in(VALUE self, VALUE port, VALUE host) { struct rb_addrinfo *res = rsock_addrinfo(host, port, AF_UNSPEC, 0, 0); VALUE addr = rb_str_new((char*)res->ai->ai_addr, res->ai->ai_addrlen); rb_freeaddrinfo(res); return addr; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket.pack_sockaddr_in;F;7[[I" port;T0[I" host;T0;[[@i3;T;;{ ;0;[;{;IC; "APacks _port_ and _host_ as an AF_INET/AF_INET6 sockaddr string. Socket.sockaddr_in(80, "127.0.0.1") #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" Socket.sockaddr_in(80, "::1") #=> "\n\x00\x00P\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00" ;T;[o;= ;>I" overload;F;?0;;z ;@0;:I"sockaddr_in(port, host);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" port;T0[I" host;T0;$@o;= ;>I" overload;F;?0;;{ ;@0;:I"!pack_sockaddr_in(port, host);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" port;T0[I" host;T0;$@;![;"@;#0;$@;.F;/o;0;1T;2i%;3i0;%@;9I"static VALUE sock_s_pack_sockaddr_in(VALUE self, VALUE port, VALUE host) { struct rb_addrinfo *res = rsock_addrinfo(host, port, AF_UNSPEC, 0, 0); VALUE addr = rb_str_new((char*)res->ai->ai_addr, res->ai->ai_addrlen); rb_freeaddrinfo(res); return addr; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket.unpack_sockaddr_in;F;7[[I" addr;T0;[[@iK;T;:unpack_sockaddr_in;0;[;{;IC; "1Unpacks _sockaddr_ into port and ip_address. _sockaddr_ should be a string or an addrinfo for AF_INET/AF_INET6. sockaddr = Socket.sockaddr_in(80, "127.0.0.1") p sockaddr #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" p Socket.unpack_sockaddr_in(sockaddr) #=> [80, "127.0.0.1"] ;T;[o;= ;>I" overload;F;?0;;| ;@0;:I"!unpack_sockaddr_in(sockaddr);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@$;![;"I"@return [Array];T;#0;$@$;.F;Bi;C0;7[[I" sockaddr;T0;$@$;![;"I"mUnpacks _sockaddr_ into port and ip_address. _sockaddr_ should be a string or an addrinfo for AF_INET/AF_INET6. sockaddr = Socket.sockaddr_in(80, "127.0.0.1") p sockaddr #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" p Socket.unpack_sockaddr_in(sockaddr) #=> [80, "127.0.0.1"] @overload unpack_sockaddr_in(sockaddr) @return [Array];T;#0;$@$;.F;/o;0;1T;2i>;3iI;%@;9I"hstatic VALUE sock_s_unpack_sockaddr_in(VALUE self, VALUE addr) { struct sockaddr_in * sockaddr; VALUE host; sockaddr = (struct sockaddr_in*)SockAddrStringValuePtr(addr); if (RSTRING_LEN(addr) < (char*)&((struct sockaddr *)sockaddr)->sa_family + sizeof(((struct sockaddr *)sockaddr)->sa_family) - (char*)sockaddr) rb_raise(rb_eArgError, "too short sockaddr"); if (((struct sockaddr *)sockaddr)->sa_family != AF_INET #ifdef INET6 && ((struct sockaddr *)sockaddr)->sa_family != AF_INET6 #endif ) { #ifdef INET6 rb_raise(rb_eArgError, "not an AF_INET/AF_INET6 sockaddr"); #else rb_raise(rb_eArgError, "not an AF_INET sockaddr"); #endif } host = rsock_make_ipaddr((struct sockaddr*)sockaddr, RSTRING_SOCKLEN(addr)); return rb_assoc_new(INT2NUM(ntohs(sockaddr->sin_port)), host); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket.sockaddr_un;F;7[[I" path;T0;[[@ir;T;:sockaddr_un;0;[;{;IC; "vPacks _path_ as an AF_UNIX sockaddr string. Socket.sockaddr_un("/tmp/sock") #=> "\x01\x00/tmp/sock\x00\x00..." ;T;[o;= ;>I" overload;F;?0;;} ;@0;:I"sockaddr_un(path);T;IC; ";T;[;![;"I";T;#0;$@C;.F;Bi;C0;7[[I" path;T0;$@Co;= ;>I" overload;F;?0;:pack_sockaddr_un;@0;:I"pack_sockaddr_un(path);T;IC; ";T;[;![;"I";T;#0;$@C;.F;Bi;C0;7[[I" path;T0;$@C;![;"I"Packs _path_ as an AF_UNIX sockaddr string. Socket.sockaddr_un("/tmp/sock") #=> "\x01\x00/tmp/sock\x00\x00..." @overload sockaddr_un(path) @overload pack_sockaddr_un(path);T;#0;$@C;.F;/o;0;1T;2ih;3io;%@;9I"_static VALUE sock_s_pack_sockaddr_un(VALUE self, VALUE path) { struct sockaddr_un sockaddr; VALUE addr; StringValue(path); INIT_SOCKADDR_UN(&sockaddr, sizeof(struct sockaddr_un)); if (sizeof(sockaddr.sun_path) < (size_t)RSTRING_LEN(path)) { rb_raise(rb_eArgError, "too long unix socket path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)", (size_t)RSTRING_LEN(path), sizeof(sockaddr.sun_path)); } memcpy(sockaddr.sun_path, RSTRING_PTR(path), RSTRING_LEN(path)); addr = rb_str_new((char*)&sockaddr, rsock_unix_sockaddr_len(path)); return addr; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket.pack_sockaddr_un;F;7[[I" path;T0;[[@ir;T;;~ ;0;[;{;IC; "vPacks _path_ as an AF_UNIX sockaddr string. Socket.sockaddr_un("/tmp/sock") #=> "\x01\x00/tmp/sock\x00\x00..." ;T;[o;= ;>I" overload;F;?0;;} ;@0;:I"sockaddr_un(path);T;IC; ";T;[;![;"I";T;#0;$@g;.F;Bi;C0;7[[I" path;T0;$@go;= ;>I" overload;F;?0;;~ ;@0;:I"pack_sockaddr_un(path);T;IC; ";T;[;![;"I";T;#0;$@g;.F;Bi;C0;7[[I" path;T0;$@g;![;"@c;#0;$@g;.F;/o;0;1T;2ih;3io;%@;9I"_static VALUE sock_s_pack_sockaddr_un(VALUE self, VALUE path) { struct sockaddr_un sockaddr; VALUE addr; StringValue(path); INIT_SOCKADDR_UN(&sockaddr, sizeof(struct sockaddr_un)); if (sizeof(sockaddr.sun_path) < (size_t)RSTRING_LEN(path)) { rb_raise(rb_eArgError, "too long unix socket path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)", (size_t)RSTRING_LEN(path), sizeof(sockaddr.sun_path)); } memcpy(sockaddr.sun_path, RSTRING_PTR(path), RSTRING_LEN(path)); addr = rb_str_new((char*)&sockaddr, rsock_unix_sockaddr_len(path)); return addr; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket.unpack_sockaddr_un;F;7[[I" addr;T0;[[@i;T;:unpack_sockaddr_un;0;[;{;IC; "Unpacks _sockaddr_ into path. _sockaddr_ should be a string or an addrinfo for AF_UNIX. sockaddr = Socket.sockaddr_un("/tmp/sock") p Socket.unpack_sockaddr_un(sockaddr) #=> "/tmp/sock" ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"!unpack_sockaddr_un(sockaddr);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" sockaddr;T0;$@;![;"I"Unpacks _sockaddr_ into path. _sockaddr_ should be a string or an addrinfo for AF_UNIX. sockaddr = Socket.sockaddr_un("/tmp/sock") p Socket.unpack_sockaddr_un(sockaddr) #=> "/tmp/sock" @overload unpack_sockaddr_un(sockaddr);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"0static VALUE sock_s_unpack_sockaddr_un(VALUE self, VALUE addr) { struct sockaddr_un * sockaddr; VALUE path; sockaddr = (struct sockaddr_un*)SockAddrStringValuePtr(addr); if (RSTRING_LEN(addr) < (char*)&((struct sockaddr *)sockaddr)->sa_family + sizeof(((struct sockaddr *)sockaddr)->sa_family) - (char*)sockaddr) rb_raise(rb_eArgError, "too short sockaddr"); if (((struct sockaddr *)sockaddr)->sa_family != AF_UNIX) { rb_raise(rb_eArgError, "not an AF_UNIX sockaddr"); } if (sizeof(struct sockaddr_un) < (size_t)RSTRING_LEN(addr)) { rb_raise(rb_eTypeError, "too long sockaddr_un - %ld longer than %d", RSTRING_LEN(addr), (int)sizeof(struct sockaddr_un)); } path = rsock_unixpath_str(sockaddr, RSTRING_SOCKLEN(addr)); return path; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket.ip_address_list;F;7[;[[@i ;T;:ip_address_list;0;[;{;IC; "Returns local IP addresses as an array. The array contains Addrinfo objects. pp Socket.ip_address_list #=> [#, #, #, ...] ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"ip_address_list;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns local IP addresses as an array. The array contains Addrinfo objects. pp Socket.ip_address_list #=> [#, #, #, ...] @overload ip_address_list @return [Array];T;#0;$@;.F;/o;0;1T;2i;3i ;%@;9I" static VALUE socket_s_ip_address_list(VALUE self) { #if defined(HAVE_GETIFADDRS) struct ifaddrs *ifp = NULL; struct ifaddrs *p; int ret; VALUE list; ret = getifaddrs(&ifp); if (ret == -1) { rb_sys_fail("getifaddrs"); } list = rb_ary_new(); for (p = ifp; p; p = p->ifa_next) { if (p->ifa_addr != NULL && IS_IP_FAMILY(p->ifa_addr->sa_family)) { struct sockaddr *addr = p->ifa_addr; #if defined(AF_INET6) && defined(__sun) /* * OpenIndiana SunOS 5.11 getifaddrs() returns IPv6 link local * address with sin6_scope_id == 0. * So fill it from the interface name (ifa_name). */ struct sockaddr_in6 addr6; if (addr->sa_family == AF_INET6) { socklen_t len = (socklen_t)sizeof(struct sockaddr_in6); memcpy(&addr6, addr, len); addr = (struct sockaddr *)&addr6; if (IN6_IS_ADDR_LINKLOCAL(&addr6.sin6_addr) && addr6.sin6_scope_id == 0) { unsigned int ifindex = if_nametoindex(p->ifa_name); if (ifindex != 0) { addr6.sin6_scope_id = ifindex; } } } #endif rb_ary_push(list, sockaddr_obj(addr, sockaddr_len(addr))); } } freeifaddrs(ifp); return list; #elif defined(SIOCGLIFCONF) && defined(SIOCGLIFNUM) && !defined(__hpux) /* Solaris if_tcp(7P) */ /* HP-UX has SIOCGLIFCONF too. But it uses different struct */ int fd = -1; int ret; struct lifnum ln; struct lifconf lc; const char *reason = NULL; int save_errno; int i; VALUE list = Qnil; lc.lifc_buf = NULL; fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd == -1) rb_sys_fail("socket(2)"); memset(&ln, 0, sizeof(ln)); ln.lifn_family = AF_UNSPEC; ret = ioctl(fd, SIOCGLIFNUM, &ln); if (ret == -1) { reason = "SIOCGLIFNUM"; goto finish; } memset(&lc, 0, sizeof(lc)); lc.lifc_family = AF_UNSPEC; lc.lifc_flags = 0; lc.lifc_len = sizeof(struct lifreq) * ln.lifn_count; lc.lifc_req = xmalloc(lc.lifc_len); ret = ioctl(fd, SIOCGLIFCONF, &lc); if (ret == -1) { reason = "SIOCGLIFCONF"; goto finish; } list = rb_ary_new(); for (i = 0; i < ln.lifn_count; i++) { struct lifreq *req = &lc.lifc_req[i]; if (IS_IP_FAMILY(req->lifr_addr.ss_family)) { if (req->lifr_addr.ss_family == AF_INET6 && IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6 *)(&req->lifr_addr))->sin6_addr) && ((struct sockaddr_in6 *)(&req->lifr_addr))->sin6_scope_id == 0) { struct lifreq req2; memcpy(req2.lifr_name, req->lifr_name, LIFNAMSIZ); ret = ioctl(fd, SIOCGLIFINDEX, &req2); if (ret == -1) { reason = "SIOCGLIFINDEX"; goto finish; } ((struct sockaddr_in6 *)(&req->lifr_addr))->sin6_scope_id = req2.lifr_index; } rb_ary_push(list, sockaddr_obj((struct sockaddr *)&req->lifr_addr, req->lifr_addrlen)); } } finish: save_errno = errno; if (lc.lifc_buf != NULL) xfree(lc.lifc_req); if (fd != -1) close(fd); errno = save_errno; if (reason) rb_syserr_fail(save_errno, reason); return list; #elif defined(SIOCGIFCONF) int fd = -1; int ret; #define EXTRA_SPACE ((int)(sizeof(struct ifconf) + sizeof(union_sockaddr))) char initbuf[4096+EXTRA_SPACE]; char *buf = initbuf; int bufsize; struct ifconf conf; struct ifreq *req; VALUE list = Qnil; const char *reason = NULL; int save_errno; fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd == -1) rb_sys_fail("socket(2)"); bufsize = sizeof(initbuf); buf = initbuf; retry: conf.ifc_len = bufsize; conf.ifc_req = (struct ifreq *)buf; /* fprintf(stderr, "bufsize: %d\n", bufsize); */ ret = ioctl(fd, SIOCGIFCONF, &conf); if (ret == -1) { reason = "SIOCGIFCONF"; goto finish; } /* fprintf(stderr, "conf.ifc_len: %d\n", conf.ifc_len); */ if (bufsize - EXTRA_SPACE < conf.ifc_len) { if (bufsize < conf.ifc_len) { /* NetBSD returns required size for all interfaces. */ bufsize = conf.ifc_len + EXTRA_SPACE; } else { bufsize = bufsize << 1; } if (buf == initbuf) buf = NULL; buf = xrealloc(buf, bufsize); goto retry; } close(fd); fd = -1; list = rb_ary_new(); req = conf.ifc_req; while ((char*)req < (char*)conf.ifc_req + conf.ifc_len) { struct sockaddr *addr = &req->ifr_addr; if (IS_IP_FAMILY(addr->sa_family)) { rb_ary_push(list, sockaddr_obj(addr, sockaddr_len(addr))); } #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN # ifndef _SIZEOF_ADDR_IFREQ # define _SIZEOF_ADDR_IFREQ(r) \ (sizeof(struct ifreq) + \ (sizeof(struct sockaddr) < (r).ifr_addr.sa_len ? \ (r).ifr_addr.sa_len - sizeof(struct sockaddr) : \ 0)) # endif req = (struct ifreq *)((char*)req + _SIZEOF_ADDR_IFREQ(*req)); #else req = (struct ifreq *)((char*)req + sizeof(struct ifreq)); #endif } finish: save_errno = errno; if (buf != initbuf) xfree(buf); if (fd != -1) close(fd); errno = save_errno; if (reason) rb_syserr_fail(save_errno, reason); return list; #undef EXTRA_SPACE #elif defined(_WIN32) typedef struct ip_adapter_unicast_address_st { unsigned LONG_LONG dummy0; struct ip_adapter_unicast_address_st *Next; struct { struct sockaddr *lpSockaddr; int iSockaddrLength; } Address; int dummy1; int dummy2; int dummy3; long dummy4; long dummy5; long dummy6; } ip_adapter_unicast_address_t; typedef struct ip_adapter_anycast_address_st { unsigned LONG_LONG dummy0; struct ip_adapter_anycast_address_st *Next; struct { struct sockaddr *lpSockaddr; int iSockaddrLength; } Address; } ip_adapter_anycast_address_t; typedef struct ip_adapter_addresses_st { unsigned LONG_LONG dummy0; struct ip_adapter_addresses_st *Next; void *dummy1; ip_adapter_unicast_address_t *FirstUnicastAddress; ip_adapter_anycast_address_t *FirstAnycastAddress; void *dummy2; void *dummy3; void *dummy4; void *dummy5; void *dummy6; BYTE dummy7[8]; DWORD dummy8; DWORD dummy9; DWORD dummy10; DWORD IfType; int OperStatus; DWORD dummy12; DWORD dummy13[16]; void *dummy14; } ip_adapter_addresses_t; typedef ULONG (WINAPI *GetAdaptersAddresses_t)(ULONG, ULONG, PVOID, ip_adapter_addresses_t *, PULONG); HMODULE h; GetAdaptersAddresses_t pGetAdaptersAddresses; ULONG len; DWORD ret; ip_adapter_addresses_t *adapters; VALUE list; h = LoadLibrary("iphlpapi.dll"); if (!h) rb_notimplement(); pGetAdaptersAddresses = (GetAdaptersAddresses_t)GetProcAddress(h, "GetAdaptersAddresses"); if (!pGetAdaptersAddresses) { FreeLibrary(h); rb_notimplement(); } ret = pGetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &len); if (ret != ERROR_SUCCESS && ret != ERROR_BUFFER_OVERFLOW) { errno = rb_w32_map_errno(ret); FreeLibrary(h); rb_sys_fail("GetAdaptersAddresses"); } adapters = (ip_adapter_addresses_t *)ALLOCA_N(BYTE, len); ret = pGetAdaptersAddresses(AF_UNSPEC, 0, NULL, adapters, &len); if (ret != ERROR_SUCCESS) { errno = rb_w32_map_errno(ret); FreeLibrary(h); rb_sys_fail("GetAdaptersAddresses"); } list = rb_ary_new(); for (; adapters; adapters = adapters->Next) { ip_adapter_unicast_address_t *uni; ip_adapter_anycast_address_t *any; if (adapters->OperStatus != 1) /* 1 means IfOperStatusUp */ continue; for (uni = adapters->FirstUnicastAddress; uni; uni = uni->Next) { #ifndef INET6 if (uni->Address.lpSockaddr->sa_family == AF_INET) #else if (IS_IP_FAMILY(uni->Address.lpSockaddr->sa_family)) #endif rb_ary_push(list, sockaddr_obj(uni->Address.lpSockaddr, uni->Address.iSockaddrLength)); } for (any = adapters->FirstAnycastAddress; any; any = any->Next) { #ifndef INET6 if (any->Address.lpSockaddr->sa_family == AF_INET) #else if (IS_IP_FAMILY(any->Address.lpSockaddr->sa_family)) #endif rb_ary_push(list, sockaddr_obj(any->Address.lpSockaddr, any->Address.iSockaddrLength)); } } FreeLibrary(h); return list; #endif };T;:I"static VALUE;T;;To; ;IC;[o;4;5F;6;;;;&I"%Socket::AncillaryData#initialize;F;7[ [I" vfamily;T0[I" vlevel;T0[I" vtype;T0[I" data;T0;[[I"ext/socket/ancdata.c;TiO;T;;D;0;[;{;IC; "_family_ should be an integer, a string or a symbol. - Socket::AF_INET, "AF_INET", "INET", :AF_INET, :INET - Socket::AF_UNIX, "AF_UNIX", "UNIX", :AF_UNIX, :UNIX - etc. _cmsg_level_ should be an integer, a string or a symbol. - Socket::SOL_SOCKET, "SOL_SOCKET", "SOCKET", :SOL_SOCKET and :SOCKET - Socket::IPPROTO_IP, "IP" and :IP - Socket::IPPROTO_IPV6, "IPV6" and :IPV6 - Socket::IPPROTO_TCP, "TCP" and :TCP - etc. _cmsg_type_ should be an integer, a string or a symbol. If a string/symbol is specified, it is interpreted depend on _cmsg_level_. - Socket::SCM_RIGHTS, "SCM_RIGHTS", "RIGHTS", :SCM_RIGHTS, :RIGHTS for SOL_SOCKET - Socket::IP_RECVTTL, "RECVTTL" and :RECVTTL for IPPROTO_IP - Socket::IPV6_PKTINFO, "PKTINFO" and :PKTINFO for IPPROTO_IPV6 - etc. _cmsg_data_ should be a string. p Socket::AncillaryData.new(:INET, :TCP, :NODELAY, "") #=> # p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "") #=> # ;T;[o;= ;>I" overload;F;?0;:Socket::AncillaryData.new;@0;:I"HSocket::AncillaryData.new(family, cmsg_level, cmsg_type, cmsg_data);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[ [I" family;T0[I"cmsg_level;T0[I"cmsg_type;T0[I"cmsg_data;T0;$@;![;"I"K_family_ should be an integer, a string or a symbol. - Socket::AF_INET, "AF_INET", "INET", :AF_INET, :INET - Socket::AF_UNIX, "AF_UNIX", "UNIX", :AF_UNIX, :UNIX - etc. _cmsg_level_ should be an integer, a string or a symbol. - Socket::SOL_SOCKET, "SOL_SOCKET", "SOCKET", :SOL_SOCKET and :SOCKET - Socket::IPPROTO_IP, "IP" and :IP - Socket::IPPROTO_IPV6, "IPV6" and :IPV6 - Socket::IPPROTO_TCP, "TCP" and :TCP - etc. _cmsg_type_ should be an integer, a string or a symbol. If a string/symbol is specified, it is interpreted depend on _cmsg_level_. - Socket::SCM_RIGHTS, "SCM_RIGHTS", "RIGHTS", :SCM_RIGHTS, :RIGHTS for SOL_SOCKET - Socket::IP_RECVTTL, "RECVTTL" and :RECVTTL for IPPROTO_IP - Socket::IPV6_PKTINFO, "PKTINFO" and :PKTINFO for IPPROTO_IPV6 - etc. _cmsg_data_ should be a string. p Socket::AncillaryData.new(:INET, :TCP, :NODELAY, "") #=> # p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "") #=> # @overload Socket::AncillaryData.new(family, cmsg_level, cmsg_type, cmsg_data);T;#0;$@;.F;/o;0;1T;2i/;3iL;%@;9I"static VALUE ancillary_initialize(VALUE self, VALUE vfamily, VALUE vlevel, VALUE vtype, VALUE data) { int family = rsock_family_arg(vfamily); int level = rsock_level_arg(family, vlevel); int type = rsock_cmsg_type_arg(family, level, vtype); StringValue(data); rb_ivar_set(self, rb_intern("family"), INT2NUM(family)); rb_ivar_set(self, rb_intern("level"), INT2NUM(level)); rb_ivar_set(self, rb_intern("type"), INT2NUM(type)); rb_ivar_set(self, rb_intern("data"), data); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""Socket::AncillaryData#inspect;F;7[;[[@i;T;;J;0;[;{;IC; "returns a string which shows ancillarydata in human-readable form. p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").inspect #=> "#" ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"returns a string which shows ancillarydata in human-readable form. p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").inspect #=> "#" @overload inspect @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ancillary_inspect(VALUE self) { VALUE ret; int family, level, type; VALUE data; ID family_id, level_id, type_id; VALUE vtype; int inspected; family = ancillary_family(self); level = ancillary_level(self); type = ancillary_type(self); data = ancillary_data(self); ret = rb_sprintf("#<%s:", rb_obj_classname(self)); family_id = rsock_intern_family_noprefix(family); if (family_id) rb_str_catf(ret, " %s", rb_id2name(family_id)); else rb_str_catf(ret, " family:%d", family); if (level == SOL_SOCKET) { rb_str_cat2(ret, " SOCKET"); type_id = rsock_intern_scm_optname(type); if (type_id) rb_str_catf(ret, " %s", rb_id2name(type_id)); else rb_str_catf(ret, " cmsg_type:%d", type); } else if (IS_IP_FAMILY(family)) { level_id = rsock_intern_iplevel(level); if (level_id) rb_str_catf(ret, " %s", rb_id2name(level_id)); else rb_str_catf(ret, " cmsg_level:%d", level); vtype = ip_cmsg_type_to_sym(level, type); if (SYMBOL_P(vtype)) rb_str_catf(ret, " %"PRIsVALUE, rb_sym2str(vtype)); else rb_str_catf(ret, " cmsg_type:%d", type); } else { rb_str_catf(ret, " cmsg_level:%d", level); rb_str_catf(ret, " cmsg_type:%d", type); } inspected = 0; if (level == SOL_SOCKET) family = AF_UNSPEC; switch (family) { case AF_UNSPEC: switch (level) { # if defined(SOL_SOCKET) case SOL_SOCKET: switch (type) { # if defined(SCM_TIMESTAMP) /* GNU/Linux, FreeBSD, NetBSD, OpenBSD, MacOS X, Solaris */ case SCM_TIMESTAMP: inspected = inspect_timeval_as_abstime(level, type, data, ret); break; # endif # if defined(SCM_TIMESTAMPNS) /* GNU/Linux */ case SCM_TIMESTAMPNS: inspected = inspect_timespec_as_abstime(level, type, data, ret); break; # endif # if defined(SCM_BINTIME) /* FreeBSD */ case SCM_BINTIME: inspected = inspect_bintime_as_abstime(level, type, data, ret); break; # endif # if defined(SCM_RIGHTS) /* 4.4BSD */ case SCM_RIGHTS: inspected = anc_inspect_socket_rights(level, type, data, ret); break; # endif # if defined(SCM_CREDENTIALS) /* GNU/Linux */ case SCM_CREDENTIALS: inspected = anc_inspect_passcred_credentials(level, type, data, ret); break; # endif # if defined(INSPECT_SCM_CREDS) /* NetBSD */ case SCM_CREDS: inspected = anc_inspect_socket_creds(level, type, data, ret); break; # endif } break; # endif } break; case AF_INET: #ifdef INET6 case AF_INET6: #endif switch (level) { # if defined(IPPROTO_IP) case IPPROTO_IP: switch (type) { # if defined(IP_RECVDSTADDR) /* 4.4BSD */ case IP_RECVDSTADDR: inspected = anc_inspect_ip_recvdstaddr(level, type, data, ret); break; # endif # if defined(IP_PKTINFO) && defined(HAVE_STRUCT_IN_PKTINFO_IPI_SPEC_DST) /* GNU/Linux */ case IP_PKTINFO: inspected = anc_inspect_ip_pktinfo(level, type, data, ret); break; # endif } break; # endif # if defined(IPPROTO_IPV6) case IPPROTO_IPV6: switch (type) { # if defined(IPV6_PKTINFO) && defined(HAVE_TYPE_STRUCT_IN6_PKTINFO) /* RFC 3542 */ case IPV6_PKTINFO: inspected = anc_inspect_ipv6_pktinfo(level, type, data, ret); break; # endif } break; # endif } break; } if (!inspected) { rb_str_cat2(ret, " "); rb_str_append(ret, rb_str_dump(data)); } rb_str_cat2(ret, ">"); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Socket::AncillaryData#family;F;7[;[[@iv;T;: family;0;[;{;IC; "yreturns the socket family as an integer. p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").family #=> 10 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" family;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"returns the socket family as an integer. p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").family #=> 10 @overload family @return [Integer];T;#0;$@;.F;/o;0;1T;2im;3it;%@;9I"`static VALUE ancillary_family_m(VALUE self) { return INT2NUM(ancillary_family(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" Socket::AncillaryData#level;F;7[;[[@i;T;; ;0;[;{;IC; "ureturns the cmsg level as an integer. p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").level #=> 41 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" level;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"returns the cmsg level as an integer. p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").level #=> 41 @overload level @return [Integer];T;#0;$@;.F;/o;0;1T;2i~;3i;%@;9I"^static VALUE ancillary_level_m(VALUE self) { return INT2NUM(ancillary_level(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::AncillaryData#type;F;7[;[[@i;T;;;0;[;{;IC; "rreturns the cmsg type as an integer. p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").type #=> 2 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" type;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@9;![;"I"@return [Integer];T;#0;$@9;.F;Bi;C0;7[;$@9;![;"I"returns the cmsg type as an integer. p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").type #=> 2 @overload type @return [Integer];T;#0;$@9;.F;/o;0;1T;2i;3i;%@;9I"\static VALUE ancillary_type_m(VALUE self) { return INT2NUM(ancillary_type(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::AncillaryData#data;F;7[;[[@i;T;: data;0;[;{;IC; "qreturns the cmsg data as a string. p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").data #=> "" ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" data;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@T;![;"I"@return [String];T;#0;$@T;.F;Bi;C0;7[;$@T;![;"I"returns the cmsg data as a string. p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").data #=> "" @overload data @return [String];T;#0;$@T;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ancillary_data(VALUE self) { VALUE v = rb_attr_get(self, rb_intern("data")); StringValue(v); return v; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"#Socket::AncillaryData#cmsg_is?;F;7[[I" vlevel;T0[I" vtype;T0;[[@iI;T;: cmsg_is?;0;[;{;IC; "Stests the level and type of _ancillarydata_. ancdata = Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "") ancdata.cmsg_is?(Socket::IPPROTO_IPV6, Socket::IPV6_PKTINFO) #=> true ancdata.cmsg_is?(:IPV6, :PKTINFO) #=> true ancdata.cmsg_is?(:IP, :PKTINFO) #=> false ancdata.cmsg_is?(:SOCKET, :RIGHTS) #=> false;T;[o;= ;>I" overload;F;?0;; ;@0;:I"cmsg_is?(level, type);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@o;![;"I"@return [Boolean];T;#0;$@o;.F;Bi;C0;7[[I" level;T0[I" type;T0;$@o;![;"I"tests the level and type of _ancillarydata_. ancdata = Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "") ancdata.cmsg_is?(Socket::IPPROTO_IPV6, Socket::IPV6_PKTINFO) #=> true ancdata.cmsg_is?(:IPV6, :PKTINFO) #=> true ancdata.cmsg_is?(:IP, :PKTINFO) #=> false ancdata.cmsg_is?(:SOCKET, :RIGHTS) #=> false @overload cmsg_is?(level, type) @return [Boolean];T;#0;$@o;.F;/o;0;1T;2i=;3iG;Bi;%@;9I"fstatic VALUE ancillary_cmsg_is_p(VALUE self, VALUE vlevel, VALUE vtype) { int family = ancillary_family(self); int level = rsock_level_arg(family, vlevel); int type = rsock_cmsg_type_arg(family, level, vtype); if (ancillary_level(self) == level && ancillary_type(self) == type) return Qtrue; else return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::AncillaryData.int;F;7[ [I" vfamily;T0[I" vlevel;T0[I" vtype;T0[I" integer;T0;[[@io;T;:int;0;[;{;IC; "Creates a new Socket::AncillaryData object which contains a int as data. The size and endian is dependent on the host. require 'socket' p Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, STDERR.fileno) #=> # ;T;[o;= ;>I" overload;F;?0;:Socket::AncillaryData.int;@0;:I"FSocket::AncillaryData.int(family, cmsg_level, cmsg_type, integer);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[ [I" family;T0[I"cmsg_level;T0[I"cmsg_type;T0[I" integer;T0;$@;![;"I"UCreates a new Socket::AncillaryData object which contains a int as data. The size and endian is dependent on the host. require 'socket' p Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, STDERR.fileno) #=> # @overload Socket::AncillaryData.int(family, cmsg_level, cmsg_type, integer);T;#0;$@;.F;/o;0;1T;2ib;3il;%@;9I"jstatic VALUE ancillary_s_int(VALUE klass, VALUE vfamily, VALUE vlevel, VALUE vtype, VALUE integer) { int family = rsock_family_arg(vfamily); int level = rsock_level_arg(family, vlevel); int type = rsock_cmsg_type_arg(family, level, vtype); int i = NUM2INT(integer); return ancdata_new(family, level, type, rb_str_new((char*)&i, sizeof(i))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::AncillaryData#int;F;7[;[[@i;T;; ;0;[;{;IC; "Returns the data in _ancillarydata_ as an int. The size and endian is dependent on the host. ancdata = Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, STDERR.fileno) p ancdata.int #=> 2 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"int;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the data in _ancillarydata_ as an int. The size and endian is dependent on the host. ancdata = Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, STDERR.fileno) p ancdata.int #=> 2 @overload int @return [Integer];T;#0;$@;.F;/o;0;1T;2iy;3i;%@;9I"^static VALUE ancillary_int(VALUE self) { VALUE data; int i; data = ancillary_data(self); if (RSTRING_LEN(data) != sizeof(int)) rb_raise(rb_eTypeError, "size differ. expected as sizeof(int)=%d but %ld", (int)sizeof(int), (long)RSTRING_LEN(data)); memcpy((char*)&i, RSTRING_PTR(data), sizeof(int)); return INT2NUM(i); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&Socket::AncillaryData.unix_rights;F;7[[@90;[[@i;T;:unix_rights;0;[;{;IC; "Creates a new Socket::AncillaryData object which contains file descriptors as data. p Socket::AncillaryData.unix_rights(STDERR) #=> # ;T;[o;= ;>I" overload;F;?0;:&Socket::AncillaryData.unix_rights;@0;:I"5Socket::AncillaryData.unix_rights(io1, io2, ...);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"io1;T0[I"io2;T0[I"...;T0;$@;![;"I"Creates a new Socket::AncillaryData object which contains file descriptors as data. p Socket::AncillaryData.unix_rights(STDERR) #=> # @overload Socket::AncillaryData.unix_rights(io1, io2, ...);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ancillary_s_unix_rights(int argc, VALUE *argv, VALUE klass) { VALUE result, str, ary; int i; ary = rb_ary_new(); for (i = 0 ; i < argc; i++) { VALUE obj = argv[i]; if (!RB_TYPE_P(obj, T_FILE)) { rb_raise(rb_eTypeError, "IO expected"); } rb_ary_push(ary, obj); } str = rb_str_buf_new(sizeof(int) * argc); for (i = 0 ; i < argc; i++) { VALUE obj = RARRAY_AREF(ary, i); rb_io_t *fptr; int fd; GetOpenFile(obj, fptr); fd = fptr->fd; rb_str_buf_cat(str, (char *)&fd, sizeof(int)); } result = ancdata_new(AF_UNIX, SOL_SOCKET, SCM_RIGHTS, str); rb_ivar_set(result, rb_intern("unix_rights"), ary); return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&Socket::AncillaryData#unix_rights;F;7[;[[@i;T;; ;0;[;{;IC; "returns the array of IO objects for SCM_RIGHTS control message in UNIX domain socket. The class of the IO objects in the array is IO or Socket. The array is attached to _ancillarydata_ when it is instantiated. For example, BasicSocket#recvmsg attach the array when receives a SCM_RIGHTS control message and :scm_rights=>true option is given. # recvmsg needs :scm_rights=>true for unix_rights s1, s2 = UNIXSocket.pair p s1 #=> # s1.sendmsg "stdin and a socket", 0, nil, Socket::AncillaryData.unix_rights(STDIN, s1) _, _, _, ctl = s2.recvmsg(:scm_rights=>true) p ctl #=> # p ctl.unix_rights #=> [#, #] p File.identical?(STDIN, ctl.unix_rights[0]) #=> true p File.identical?(s1, ctl.unix_rights[1]) #=> true # If :scm_rights=>true is not given, unix_rights returns nil s1, s2 = UNIXSocket.pair s1.sendmsg "stdin and a socket", 0, nil, Socket::AncillaryData.unix_rights(STDIN, s1) _, _, _, ctl = s2.recvmsg p ctl #=> # p ctl.unix_rights #=> nil ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"unix_rights;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"array-of-IOs;TI"nil;T;$@;![;"I" @return [array-of-IOs, nil];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"returns the array of IO objects for SCM_RIGHTS control message in UNIX domain socket. The class of the IO objects in the array is IO or Socket. The array is attached to _ancillarydata_ when it is instantiated. For example, BasicSocket#recvmsg attach the array when receives a SCM_RIGHTS control message and :scm_rights=>true option is given. # recvmsg needs :scm_rights=>true for unix_rights s1, s2 = UNIXSocket.pair p s1 #=> # s1.sendmsg "stdin and a socket", 0, nil, Socket::AncillaryData.unix_rights(STDIN, s1) _, _, _, ctl = s2.recvmsg(:scm_rights=>true) p ctl #=> # p ctl.unix_rights #=> [#, #] p File.identical?(STDIN, ctl.unix_rights[0]) #=> true p File.identical?(s1, ctl.unix_rights[1]) #=> true # If :scm_rights=>true is not given, unix_rights returns nil s1, s2 = UNIXSocket.pair s1.sendmsg "stdin and a socket", 0, nil, Socket::AncillaryData.unix_rights(STDIN, s1) _, _, _, ctl = s2.recvmsg p ctl #=> # p ctl.unix_rights #=> nil @overload unix_rights @return [array-of-IOs, nil];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"@static VALUE ancillary_unix_rights(VALUE self) { int level, type; level = ancillary_level(self); type = ancillary_type(self); if (level != SOL_SOCKET || type != SCM_RIGHTS) rb_raise(rb_eTypeError, "SCM_RIGHTS ancillary data expected"); return rb_attr_get(self, rb_intern("unix_rights")); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"$Socket::AncillaryData#timestamp;F;7[;[[@i+;T;:timestamp;0;[;{;IC; "returns the timestamp as a time object. _ancillarydata_ should be one of following type: - SOL_SOCKET/SCM_TIMESTAMP (microsecond) GNU/Linux, FreeBSD, NetBSD, OpenBSD, Solaris, MacOS X - SOL_SOCKET/SCM_TIMESTAMPNS (nanosecond) GNU/Linux - SOL_SOCKET/SCM_BINTIME (2**(-64) second) FreeBSD Addrinfo.udp("127.0.0.1", 0).bind {|s1| Addrinfo.udp("127.0.0.1", 0).bind {|s2| s1.setsockopt(:SOCKET, :TIMESTAMP, true) s2.send "a", 0, s1.local_address ctl = s1.recvmsg.last p ctl #=> # t = ctl.timestamp p t #=> 2009-02-24 17:35:46 +0900 p t.usec #=> 775581 p t.nsec #=> 775581000 } } ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"timestamp;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Time;T;$@ ;![;"I"@return [Time];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"returns the timestamp as a time object. _ancillarydata_ should be one of following type: - SOL_SOCKET/SCM_TIMESTAMP (microsecond) GNU/Linux, FreeBSD, NetBSD, OpenBSD, Solaris, MacOS X - SOL_SOCKET/SCM_TIMESTAMPNS (nanosecond) GNU/Linux - SOL_SOCKET/SCM_BINTIME (2**(-64) second) FreeBSD Addrinfo.udp("127.0.0.1", 0).bind {|s1| Addrinfo.udp("127.0.0.1", 0).bind {|s2| s1.setsockopt(:SOCKET, :TIMESTAMP, true) s2.send "a", 0, s1.local_address ctl = s1.recvmsg.last p ctl #=> # t = ctl.timestamp p t #=> 2009-02-24 17:35:46 +0900 p t.usec #=> 775581 p t.nsec #=> 775581000 } } @overload timestamp @return [Time];T;#0;$@ ;.F;/o;0;1T;2i;3i);%@;9I"static VALUE ancillary_timestamp(VALUE self) { int level, type; VALUE data; VALUE result = Qnil; level = ancillary_level(self); type = ancillary_type(self); data = ancillary_data(self); # ifdef SCM_TIMESTAMP if (level == SOL_SOCKET && type == SCM_TIMESTAMP && RSTRING_LEN(data) == sizeof(struct timeval)) { struct timeval tv; memcpy((char*)&tv, RSTRING_PTR(data), sizeof(tv)); result = rb_time_new(tv.tv_sec, tv.tv_usec); } # endif # ifdef SCM_TIMESTAMPNS if (level == SOL_SOCKET && type == SCM_TIMESTAMPNS && RSTRING_LEN(data) == sizeof(struct timespec)) { struct timespec ts; memcpy((char*)&ts, RSTRING_PTR(data), sizeof(ts)); result = rb_time_nano_new(ts.tv_sec, ts.tv_nsec); } # endif #define add(x,y) (rb_funcall((x), '+', 1, (y))) #define mul(x,y) (rb_funcall((x), '*', 1, (y))) #define quo(x,y) (rb_funcall((x), rb_intern("quo"), 1, (y))) # ifdef SCM_BINTIME if (level == SOL_SOCKET && type == SCM_BINTIME && RSTRING_LEN(data) == sizeof(struct bintime)) { struct bintime bt; VALUE d, timev; memcpy((char*)&bt, RSTRING_PTR(data), sizeof(bt)); d = ULL2NUM(0x100000000ULL); d = mul(d,d); timev = add(TIMET2NUM(bt.sec), quo(ULL2NUM(bt.frac), d)); result = rb_time_num_new(timev, Qnil); } # endif if (result == Qnil) rb_raise(rb_eTypeError, "timestamp ancillary data expected"); return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%Socket::AncillaryData.ip_pktinfo;F;7[[@90;[[@i;T;:ip_pktinfo;0;[;{;IC; "{Returns new ancillary data for IP_PKTINFO. If spec_dst is not given, addr is used. IP_PKTINFO is not standard. Supported platform: GNU/Linux addr = Addrinfo.ip("127.0.0.1") ifindex = 0 spec_dst = Addrinfo.ip("127.0.0.1") p Socket::AncillaryData.ip_pktinfo(addr, ifindex, spec_dst) #=> # ;T;[o;= ;>I" overload;F;?0;:%Socket::AncillaryData.ip_pktinfo;@0;:I"4Socket::AncillaryData.ip_pktinfo(addr, ifindex);T;IC; ";T;[;![;"I";T;#0;$@';.F;Bi;C0;7[[I" addr;T0[I" ifindex;T0;$@'o;= ;>I" overload;F;?0;; ;@0;:I">Socket::AncillaryData.ip_pktinfo(addr, ifindex, spec_dst);T;IC; ";T;[;![;"I";T;#0;$@';.F;Bi;C0;7[[I" addr;T0[I" ifindex;T0[I" spec_dst;T0;$@';![;"I"Returns new ancillary data for IP_PKTINFO. If spec_dst is not given, addr is used. IP_PKTINFO is not standard. Supported platform: GNU/Linux addr = Addrinfo.ip("127.0.0.1") ifindex = 0 spec_dst = Addrinfo.ip("127.0.0.1") p Socket::AncillaryData.ip_pktinfo(addr, ifindex, spec_dst) #=> # @overload Socket::AncillaryData.ip_pktinfo(addr, ifindex) @overload Socket::AncillaryData.ip_pktinfo(addr, ifindex, spec_dst);T;#0;$@';.F;/o;0;1T;2i;3i;%@;9I"qstatic VALUE ancillary_s_ip_pktinfo(int argc, VALUE *argv, VALUE self) { VALUE v_addr, v_ifindex, v_spec_dst; unsigned int ifindex; struct sockaddr_in sa; struct in_pktinfo pktinfo; rb_scan_args(argc, argv, "21", &v_addr, &v_ifindex, &v_spec_dst); SockAddrStringValue(v_addr); ifindex = NUM2UINT(v_ifindex); if (NIL_P(v_spec_dst)) v_spec_dst = v_addr; else SockAddrStringValue(v_spec_dst); memset(&pktinfo, 0, sizeof(pktinfo)); memset(&sa, 0, sizeof(sa)); if (RSTRING_LEN(v_addr) != sizeof(sa)) rb_raise(rb_eArgError, "addr size different to AF_INET sockaddr"); memcpy(&sa, RSTRING_PTR(v_addr), sizeof(sa)); if (sa.sin_family != AF_INET) rb_raise(rb_eArgError, "addr is not AF_INET sockaddr"); memcpy(&pktinfo.ipi_addr, &sa.sin_addr, sizeof(pktinfo.ipi_addr)); pktinfo.ipi_ifindex = ifindex; memset(&sa, 0, sizeof(sa)); if (RSTRING_LEN(v_spec_dst) != sizeof(sa)) rb_raise(rb_eArgError, "spec_dat size different to AF_INET sockaddr"); memcpy(&sa, RSTRING_PTR(v_spec_dst), sizeof(sa)); if (sa.sin_family != AF_INET) rb_raise(rb_eArgError, "spec_dst is not AF_INET sockaddr"); memcpy(&pktinfo.ipi_spec_dst, &sa.sin_addr, sizeof(pktinfo.ipi_spec_dst)); return ancdata_new(AF_INET, IPPROTO_IP, IP_PKTINFO, rb_str_new((char *)&pktinfo, sizeof(pktinfo))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"%Socket::AncillaryData#ip_pktinfo;F;7[;[[@i;T;; ;0;[;{;IC; "oExtracts addr, ifindex and spec_dst from IP_PKTINFO ancillary data. IP_PKTINFO is not standard. Supported platform: GNU/Linux addr = Addrinfo.ip("127.0.0.1") ifindex = 0 spec_dest = Addrinfo.ip("127.0.0.1") ancdata = Socket::AncillaryData.ip_pktinfo(addr, ifindex, spec_dest) p ancdata.ip_pktinfo #=> [#, 0, #] ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"ip_pktinfo;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@P;![;"I"@return [Array];T;#0;$@P;.F;Bi;C0;7[;$@P;![;"I"Extracts addr, ifindex and spec_dst from IP_PKTINFO ancillary data. IP_PKTINFO is not standard. Supported platform: GNU/Linux addr = Addrinfo.ip("127.0.0.1") ifindex = 0 spec_dest = Addrinfo.ip("127.0.0.1") ancdata = Socket::AncillaryData.ip_pktinfo(addr, ifindex, spec_dest) p ancdata.ip_pktinfo #=> [#, 0, #] @overload ip_pktinfo @return [Array];T;#0;$@P;.F;/o;0;1T;2i;3i;%@;9I" static VALUE ancillary_ip_pktinfo(VALUE self) { int level, type; VALUE data; struct in_pktinfo pktinfo; struct sockaddr_in sa; VALUE v_spec_dst, v_addr; level = ancillary_level(self); type = ancillary_type(self); data = ancillary_data(self); if (level != IPPROTO_IP || type != IP_PKTINFO || RSTRING_LEN(data) != sizeof(struct in_pktinfo)) { rb_raise(rb_eTypeError, "IP_PKTINFO ancillary data expected"); } memcpy(&pktinfo, RSTRING_PTR(data), sizeof(struct in_pktinfo)); memset(&sa, 0, sizeof(sa)); sa.sin_family = AF_INET; memcpy(&sa.sin_addr, &pktinfo.ipi_addr, sizeof(sa.sin_addr)); v_addr = rsock_addrinfo_new((struct sockaddr *)&sa, sizeof(sa), PF_INET, 0, 0, Qnil, Qnil); sa.sin_family = AF_INET; memcpy(&sa.sin_addr, &pktinfo.ipi_spec_dst, sizeof(sa.sin_addr)); v_spec_dst = rsock_addrinfo_new((struct sockaddr *)&sa, sizeof(sa), PF_INET, 0, 0, Qnil, Qnil); return rb_ary_new3(3, v_addr, UINT2NUM(pktinfo.ipi_ifindex), v_spec_dst); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'Socket::AncillaryData.ipv6_pktinfo;F;7[[I" v_addr;T0[I"v_ifindex;T0;[[@i;T;:ipv6_pktinfo;0;[;{;IC; "Returns new ancillary data for IPV6_PKTINFO. IPV6_PKTINFO is defined by RFC 3542. addr = Addrinfo.ip("::1") ifindex = 0 p Socket::AncillaryData.ipv6_pktinfo(addr, ifindex) #=> # ;T;[o;= ;>I" overload;F;?0;:'Socket::AncillaryData.ipv6_pktinfo;@0;:I"6Socket::AncillaryData.ipv6_pktinfo(addr, ifindex);T;IC; ";T;[;![;"I";T;#0;$@k;.F;Bi;C0;7[[I" addr;T0[I" ifindex;T0;$@k;![;"I"3Returns new ancillary data for IPV6_PKTINFO. IPV6_PKTINFO is defined by RFC 3542. addr = Addrinfo.ip("::1") ifindex = 0 p Socket::AncillaryData.ipv6_pktinfo(addr, ifindex) #=> # @overload Socket::AncillaryData.ipv6_pktinfo(addr, ifindex);T;#0;$@k;.F;/o;0;1T;2i;3i;%@;9I"&static VALUE ancillary_s_ipv6_pktinfo(VALUE self, VALUE v_addr, VALUE v_ifindex) { unsigned int ifindex; struct sockaddr_in6 sa; struct in6_pktinfo pktinfo; SockAddrStringValue(v_addr); ifindex = NUM2UINT(v_ifindex); memset(&pktinfo, 0, sizeof(pktinfo)); memset(&sa, 0, sizeof(sa)); if (RSTRING_LEN(v_addr) != sizeof(sa)) rb_raise(rb_eArgError, "addr size different to AF_INET6 sockaddr"); memcpy(&sa, RSTRING_PTR(v_addr), sizeof(sa)); if (sa.sin6_family != AF_INET6) rb_raise(rb_eArgError, "addr is not AF_INET6 sockaddr"); memcpy(&pktinfo.ipi6_addr, &sa.sin6_addr, sizeof(pktinfo.ipi6_addr)); pktinfo.ipi6_ifindex = ifindex; return ancdata_new(AF_INET6, IPPROTO_IPV6, IPV6_PKTINFO, rb_str_new((char *)&pktinfo, sizeof(pktinfo))); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'Socket::AncillaryData#ipv6_pktinfo;F;7[;[[@iZ;T;; ;0;[;{;IC; "Extracts addr and ifindex from IPV6_PKTINFO ancillary data. IPV6_PKTINFO is defined by RFC 3542. addr = Addrinfo.ip("::1") ifindex = 0 ancdata = Socket::AncillaryData.ipv6_pktinfo(addr, ifindex) p ancdata.ipv6_pktinfo #=> [#, 0] ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"ipv6_pktinfo;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I")Extracts addr and ifindex from IPV6_PKTINFO ancillary data. IPV6_PKTINFO is defined by RFC 3542. addr = Addrinfo.ip("::1") ifindex = 0 ancdata = Socket::AncillaryData.ipv6_pktinfo(addr, ifindex) p ancdata.ipv6_pktinfo #=> [#, 0] @overload ipv6_pktinfo @return [Array];T;#0;$@;.F;/o;0;1T;2iL;3iX;%@;9I"`static VALUE ancillary_ipv6_pktinfo(VALUE self) { struct in6_pktinfo pktinfo; struct sockaddr_in6 sa; VALUE v_addr; extract_ipv6_pktinfo(self, &pktinfo, &sa); v_addr = rsock_addrinfo_new((struct sockaddr *)&sa, (socklen_t)sizeof(sa), PF_INET6, 0, 0, Qnil, Qnil); return rb_ary_new3(2, v_addr, UINT2NUM(pktinfo.ipi6_ifindex)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",Socket::AncillaryData#ipv6_pktinfo_addr;F;7[;[[@ix;T;:ipv6_pktinfo_addr;0;[;{;IC; "Extracts addr from IPV6_PKTINFO ancillary data. IPV6_PKTINFO is defined by RFC 3542. addr = Addrinfo.ip("::1") ifindex = 0 ancdata = Socket::AncillaryData.ipv6_pktinfo(addr, ifindex) p ancdata.ipv6_pktinfo_addr #=> # ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"ipv6_pktinfo_addr;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Extracts addr from IPV6_PKTINFO ancillary data. IPV6_PKTINFO is defined by RFC 3542. addr = Addrinfo.ip("::1") ifindex = 0 ancdata = Socket::AncillaryData.ipv6_pktinfo(addr, ifindex) p ancdata.ipv6_pktinfo_addr #=> # @overload ipv6_pktinfo_addr;T;#0;$@;.F;/o;0;1T;2ij;3iu;%@;9I" static VALUE ancillary_ipv6_pktinfo_addr(VALUE self) { struct in6_pktinfo pktinfo; struct sockaddr_in6 sa; extract_ipv6_pktinfo(self, &pktinfo, &sa); return rsock_addrinfo_new((struct sockaddr *)&sa, (socklen_t)sizeof(sa), PF_INET6, 0, 0, Qnil, Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"/Socket::AncillaryData#ipv6_pktinfo_ifindex;F;7[;[[@i;T;:ipv6_pktinfo_ifindex;0;[;{;IC; "Extracts ifindex from IPV6_PKTINFO ancillary data. IPV6_PKTINFO is defined by RFC 3542. addr = Addrinfo.ip("::1") ifindex = 0 ancdata = Socket::AncillaryData.ipv6_pktinfo(addr, ifindex) p ancdata.ipv6_pktinfo_ifindex #=> 0 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"ipv6_pktinfo_ifindex;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I" Extracts ifindex from IPV6_PKTINFO ancillary data. IPV6_PKTINFO is defined by RFC 3542. addr = Addrinfo.ip("::1") ifindex = 0 ancdata = Socket::AncillaryData.ipv6_pktinfo(addr, ifindex) p ancdata.ipv6_pktinfo_ifindex #=> 0 @overload ipv6_pktinfo_ifindex;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ancillary_ipv6_pktinfo_ifindex(VALUE self) { struct in6_pktinfo pktinfo; struct sockaddr_in6 sa; extract_ipv6_pktinfo(self, &pktinfo, &sa); return UINT2NUM(pktinfo.ipi6_ifindex); };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;:AncillaryData;;;;;[;{;IC; "Socket::AncillaryData represents the ancillary data (control information) used by sendmsg and recvmsg system call. It contains socket #family, control message (cmsg) #level, cmsg #type and cmsg #data. ;T;[;![;"I" Socket::AncillaryData represents the ancillary data (control information) used by sendmsg and recvmsg system call. It contains socket #family, control message (cmsg) #level, cmsg #type and cmsg #data. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::AncillaryData;F;'@o; ;IC;[o;4;5F;6;;;;&I"Socket::Ifaddr#inspect;F;7[;[[I"ext/socket/ifaddr.c;Tid;T;;J;0;[;{;IC; "3Returns a string to show contents of _ifaddr_. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"ZReturns a string to show contents of _ifaddr_. @overload inspect @return [String];T;#0;$@;.F;/o;0;1T;2i];3ia;%@;9I"static VALUE ifaddr_inspect(VALUE self) { struct ifaddrs *ifa = get_ifaddrs(self); VALUE result; result = rb_str_new_cstr("#<"); rb_str_append(result, rb_class_name(CLASS_OF(self))); rb_str_cat2(result, " "); rb_str_cat2(result, ifa->ifa_name); if (ifa->ifa_flags) ifaddr_inspect_flags(ifa->ifa_flags, result); if (ifa->ifa_addr) { rb_str_cat2(result, " "); rsock_inspect_sockaddr(ifa->ifa_addr, rsock_sockaddr_len(ifa->ifa_addr), result); } if (ifa->ifa_netmask) { rb_str_cat2(result, " netmask="); rsock_inspect_sockaddr(ifa->ifa_netmask, rsock_sockaddr_len(ifa->ifa_netmask), result); } if ((ifa->ifa_flags & IFF_BROADCAST) && ifa->ifa_broadaddr) { rb_str_cat2(result, " broadcast="); rsock_inspect_sockaddr(ifa->ifa_broadaddr, rsock_sockaddr_len(ifa->ifa_broadaddr), result); } if ((ifa->ifa_flags & IFF_POINTOPOINT) && ifa->ifa_dstaddr) { rb_str_cat2(result, " dstaddr="); rsock_inspect_sockaddr(ifa->ifa_dstaddr, rsock_sockaddr_len(ifa->ifa_dstaddr), result); } rb_str_cat2(result, ">"); return result; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Ifaddr#name;F;7[;[[@i;T;;F;0;[;{;IC; ",Returns the interface name of _ifaddr_. ;T;[o;= ;>I" overload;F;?0;;F;@0;:I" name;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"PReturns the interface name of _ifaddr_. @overload name @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ifaddr_name(VALUE self) { struct ifaddrs *ifa = get_ifaddrs(self); return rb_str_new_cstr(ifa->ifa_name); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Ifaddr#ifindex;F;7[;[[@i;T;: ifindex;0;[;{;IC; "-Returns the interface index of _ifaddr_. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" ifindex;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"UReturns the interface index of _ifaddr_. @overload ifindex @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ifaddr_ifindex(VALUE self) { struct ifaddrs *ifa = get_ifaddrs(self); unsigned int ifindex = if_nametoindex(ifa->ifa_name); if (ifindex == 0) { rb_raise(rb_eArgError, "invalid interface name: %s", ifa->ifa_name); } return UINT2NUM(ifindex); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Ifaddr#flags;F;7[;[[@i;T;: flags;0;[;{;IC; "#Returns the flags of _ifaddr_. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" flags;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@6;![;"I"@return [Integer];T;#0;$@6;.F;Bi;C0;7[;$@6;![;"I"IReturns the flags of _ifaddr_. @overload flags @return [Integer];T;#0;$@6;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ifaddr_flags(VALUE self) { struct ifaddrs *ifa = get_ifaddrs(self); return IFAFLAGS2NUM(ifa->ifa_flags); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Ifaddr#addr;F;7[;[[@i;T;;D ;0;[;{;IC; "^Returns the address of _ifaddr_. nil is returned if address is not available in _ifaddr_. ;T;[o;= ;>I" overload;F;?0;;D ;@0;:I" addr;T;IC; ";T;[;![;"I";T;#0;$@Q;.F;Bi;C0;7[;$@Q;![;"I"oReturns the address of _ifaddr_. nil is returned if address is not available in _ifaddr_. @overload addr;T;#0;$@Q;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ifaddr_addr(VALUE self) { struct ifaddrs *ifa = get_ifaddrs(self); if (ifa->ifa_addr) return rsock_sockaddr_obj(ifa->ifa_addr, rsock_sockaddr_len(ifa->ifa_addr)); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Ifaddr#netmask;F;7[;[[@i;T;: netmask;0;[;{;IC; "fReturns the netmask address of _ifaddr_. nil is returned if netmask is not available in _ifaddr_. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" netmask;T;IC; ";T;[;![;"I";T;#0;$@g;.F;Bi;C0;7[;$@g;![;"I"zReturns the netmask address of _ifaddr_. nil is returned if netmask is not available in _ifaddr_. @overload netmask;T;#0;$@g;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ifaddr_netmask(VALUE self) { struct ifaddrs *ifa = get_ifaddrs(self); if (ifa->ifa_netmask) return rsock_sockaddr_obj(ifa->ifa_netmask, rsock_sockaddr_len(ifa->ifa_netmask)); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Ifaddr#broadaddr;F;7[;[[@i;T;:broadaddr;0;[;{;IC; "hReturns the broadcast address of _ifaddr_. nil is returned if the flags doesn't have IFF_BROADCAST. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"broadaddr;T;IC; ";T;[;![;"I";T;#0;$@};.F;Bi;C0;7[;$@};![;"I"~Returns the broadcast address of _ifaddr_. nil is returned if the flags doesn't have IFF_BROADCAST. @overload broadaddr;T;#0;$@};.F;/o;0;1T;2i;3i;%@;9I" static VALUE ifaddr_broadaddr(VALUE self) { struct ifaddrs *ifa = get_ifaddrs(self); if ((ifa->ifa_flags & IFF_BROADCAST) && ifa->ifa_broadaddr) return rsock_sockaddr_obj(ifa->ifa_broadaddr, rsock_sockaddr_len(ifa->ifa_broadaddr)); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Ifaddr#dstaddr;F;7[;[[@i;T;: dstaddr;0;[;{;IC; "lReturns the destination address of _ifaddr_. nil is returned if the flags doesn't have IFF_POINTOPOINT. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" dstaddr;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"{Returns the destination address of _ifaddr_. nil is returned if the flags doesn't have IFF_POINTOPOINT. @overload dstaddr;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ifaddr_dstaddr(VALUE self) { struct ifaddrs *ifa = get_ifaddrs(self); if ((ifa->ifa_flags & IFF_POINTOPOINT) && ifa->ifa_dstaddr) return rsock_sockaddr_obj(ifa->ifa_dstaddr, rsock_sockaddr_len(ifa->ifa_dstaddr)); return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Ifaddr#vhid;F;7[;[[@i ;T;: vhid;0;[;{;IC; "OReturns the vhid address of _ifaddr_. nil is returned if there is no vhid. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" vhid;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"tReturns the vhid address of _ifaddr_. nil is returned if there is no vhid. @overload vhid @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ifaddr_vhid(VALUE self) { struct ifaddrs *ifa = get_ifaddrs(self); if (ifa->ifa_data) return (INT2FIX(((struct if_data*)ifa->ifa_data)->ifi_vhid)); else return Qnil; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;: Ifaddr;;;;;[;{;IC; "ASocket::Ifaddr represents a result of getifaddrs() function. ;T;[;![;"I"C Socket::Ifaddr represents a result of getifaddrs() function. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Ifaddr;F;'@o;4;5F;6;;;;&I"Socket.getifaddrs;F;7[;[[@i;T;:getifaddrs;0;[;{;IC; " Returns an array of interface addresses. An element of the array is an instance of Socket::Ifaddr. This method can be used to find multicast-enabled interfaces: pp Socket.getifaddrs.reject {|ifaddr| !ifaddr.addr.ip? || (ifaddr.flags & Socket::IFF_MULTICAST == 0) }.map {|ifaddr| [ifaddr.name, ifaddr.ifindex, ifaddr.addr] } #=> [["eth0", 2, #], # ["eth0", 2, #]] Example result on GNU/Linux: pp Socket.getifaddrs #=> [#, # #, # #, # #, # #, # #, # #] Example result on FreeBSD: pp Socket.getifaddrs #=> [#, # #, # #, # #, # #, # #, # #, # #, # #, # #] ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"getifaddrs;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I" Returns an array of interface addresses. An element of the array is an instance of Socket::Ifaddr. This method can be used to find multicast-enabled interfaces: pp Socket.getifaddrs.reject {|ifaddr| !ifaddr.addr.ip? || (ifaddr.flags & Socket::IFF_MULTICAST == 0) }.map {|ifaddr| [ifaddr.name, ifaddr.ifindex, ifaddr.addr] } #=> [["eth0", 2, #], # ["eth0", 2, #]] Example result on GNU/Linux: pp Socket.getifaddrs #=> [#, # #, # #, # #, # #, # #, # #] Example result on FreeBSD: pp Socket.getifaddrs #=> [#, # #, # #, # #, # #, # #, # #, # #, # #, # #] @overload getifaddrs @return [Array];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"Tstatic VALUE socket_s_getifaddrs(VALUE self) { return rsock_getifaddrs(); };T;:I"static VALUE;T;;To;;IC;[o;u;[[I"ext/socket/constdefs.c;Ti6;F;:SOCK_STREAM;;w;;;[;{;IC; "XA stream socket provides a sequenced, reliable two-way connection for a byte stream ;T;[;![;"I"XA stream socket provides a sequenced, reliable two-way connection for a byte stream;T;#0;$@;.F;/o;0;1T;2i5;3i5;%@;&I"#Socket::Constants::SOCK_STREAM;F;xI"INTEGER2NUM(SOCK_STREAM);To;u;[[@i<;F;:SOCK_DGRAM;;w;;;[;{;IC; "DA datagram socket provides connectionless, unreliable messaging ;T;[;![;"I"DA datagram socket provides connectionless, unreliable messaging;T;#0;$@;.F;/o;0;1T;2i;;3i;;%@;&I""Socket::Constants::SOCK_DGRAM;F;xI"INTEGER2NUM(SOCK_DGRAM);To;u;[[@iB;F;: SOCK_RAW;;w;;;[;{;IC; "_A raw socket provides low-level access for direct access or implementing network protocols ;T;[;![;"I"_A raw socket provides low-level access for direct access or implementing network protocols;T;#0;$@ ;.F;/o;0;1T;2iA;3iA;%@;&I" Socket::Constants::SOCK_RAW;F;xI"INTEGER2NUM(SOCK_RAW);To;u;[[@iH;F;: SOCK_RDM;;w;;;[;{;IC; "FA reliable datagram socket provides reliable delivery of messages ;T;[;![;"I"FA reliable datagram socket provides reliable delivery of messages;T;#0;$@;.F;/o;0;1T;2iG;3iG;%@;&I" Socket::Constants::SOCK_RDM;F;xI"INTEGER2NUM(SOCK_RDM);To;u;[[@iN;F;:SOCK_SEQPACKET;;w;;;[;{;IC; "]A sequential packet socket provides sequenced, reliable two-way connection for datagrams ;T;[;![;"I"]A sequential packet socket provides sequenced, reliable two-way connection for datagrams;T;#0;$@$;.F;/o;0;1T;2iM;3iM;%@;&I"&Socket::Constants::SOCK_SEQPACKET;F;xI" INTEGER2NUM(SOCK_SEQPACKET);To;u;[[@iT;F;:SOCK_PACKET;;w;;;[;{;IC; "Device-level packet access ;T;[;![;"I"Device-level packet access;T;#0;$@0;.F;/o;0;1T;2iS;3iS;%@;&I"#Socket::Constants::SOCK_PACKET;F;xI"INTEGER2NUM(SOCK_PACKET);To;u;[[@iZ;F;:SOCK_NONBLOCK;;w;;;[;{;IC; "{Set the O_NONBLOCK file status flag on the open file description (see open(2)) referred to by the new file descriptor. ;T;[;![;"I"{Set the O_NONBLOCK file status flag on the open file description (see open(2)) referred to by the new file descriptor.;T;#0;$@<;.F;/o;0;1T;2iY;3iY;%@;&I"%Socket::Constants::SOCK_NONBLOCK;F;xI"INTEGER2NUM(SOCK_NONBLOCK);To;u;[[@i`;F;:SOCK_CLOEXEC;;w;;;[;{;IC; "ISet the close-on-exec (FD_CLOEXEC) flag on the new file descriptor. ;T;[;![;"I"ISet the close-on-exec (FD_CLOEXEC) flag on the new file descriptor.;T;#0;$@H;.F;/o;0;1T;2i_;3i_;%@;&I"$Socket::Constants::SOCK_CLOEXEC;F;xI"INTEGER2NUM(SOCK_CLOEXEC);To;u;[[@if;F;:AF_UNSPEC;;w;;;[;{;IC; "7Unspecified protocol, any supported address family ;T;[;![;"I"7Unspecified protocol, any supported address family;T;#0;$@T;.F;/o;0;1T;2ie;3ie;%@;&I"!Socket::Constants::AF_UNSPEC;F;xI"INTEGER2NUM(AF_UNSPEC);To;u;[[@il;F;:PF_UNSPEC;;w;;;[;{;IC; "7Unspecified protocol, any supported address family ;T;[;![;"I"7Unspecified protocol, any supported address family;T;#0;$@`;.F;/o;0;1T;2ik;3ik;%@;&I"!Socket::Constants::PF_UNSPEC;F;xI"INTEGER2NUM(PF_UNSPEC);To;u;[[@ir;F;: AF_INET;;w;;;[;{;IC; "IPv4 protocol ;T;[;![;"I"IPv4 protocol;T;#0;$@l;.F;/o;0;1T;2iq;3iq;%@;&I"Socket::Constants::AF_INET;F;xI"INTEGER2NUM(AF_INET);To;u;[[@ix;F;: PF_INET;;w;;;[;{;IC; "IPv4 protocol ;T;[;![;"I"IPv4 protocol;T;#0;$@x;.F;/o;0;1T;2iw;3iw;%@;&I"Socket::Constants::PF_INET;F;xI"INTEGER2NUM(PF_INET);To;u;[[@i;F;: AF_INET6;;w;;;[;{;IC; "IPv6 protocol ;T;[;![;"I"IPv6 protocol;T;#0;$@;.F;/o;0;1T;2i~;3i~;%@;&I" Socket::Constants::AF_INET6;F;xI"INTEGER2NUM(AF_INET6);To;u;[[@i;F;: PF_INET6;;w;;;[;{;IC; "IPv6 protocol ;T;[;![;"I"IPv6 protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I" Socket::Constants::PF_INET6;F;xI"INTEGER2NUM(PF_INET6);To;u;[[@i;F;: AF_UNIX;;w;;;[;{;IC; "UNIX sockets ;T;[;![;"I"UNIX sockets;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_UNIX;F;xI"INTEGER2NUM(AF_UNIX);To;u;[[@i;F;: PF_UNIX;;w;;;[;{;IC; "UNIX sockets ;T;[;![;"I"UNIX sockets;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_UNIX;F;xI"INTEGER2NUM(PF_UNIX);To;u;[[@i;F;: AF_AX25;;w;;;[;{;IC; "AX.25 protocol ;T;[;![;"I"AX.25 protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_AX25;F;xI"INTEGER2NUM(AF_AX25);To;u;[[@i;F;: PF_AX25;;w;;;[;{;IC; "AX.25 protocol ;T;[;![;"I"AX.25 protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_AX25;F;xI"INTEGER2NUM(PF_AX25);To;u;[[@i;F;: AF_IPX;;w;;;[;{;IC; "IPX protocol ;T;[;![;"I"IPX protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_IPX;F;xI"INTEGER2NUM(AF_IPX);To;u;[[@i;F;: PF_IPX;;w;;;[;{;IC; "IPX protocol ;T;[;![;"I"IPX protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_IPX;F;xI"INTEGER2NUM(PF_IPX);To;u;[[@i;F;:AF_APPLETALK;;w;;;[;{;IC; "AppleTalk protocol ;T;[;![;"I"AppleTalk protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"$Socket::Constants::AF_APPLETALK;F;xI"INTEGER2NUM(AF_APPLETALK);To;u;[[@i;F;:PF_APPLETALK;;w;;;[;{;IC; "AppleTalk protocol ;T;[;![;"I"AppleTalk protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"$Socket::Constants::PF_APPLETALK;F;xI"INTEGER2NUM(PF_APPLETALK);To;u;[[@i;F;: AF_LOCAL;;w;;;[;{;IC; "Host-internal protocols ;T;[;![;"I"Host-internal protocols;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I" Socket::Constants::AF_LOCAL;F;xI"INTEGER2NUM(AF_LOCAL);To;u;[[@i;F;: PF_LOCAL;;w;;;[;{;IC; "Host-internal protocols ;T;[;![;"I"Host-internal protocols;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I" Socket::Constants::PF_LOCAL;F;xI"INTEGER2NUM(PF_LOCAL);To;u;[[@i;F;:AF_IMPLINK;;w;;;[;{;IC; "ARPANET IMP protocol ;T;[;![;"I"ARPANET IMP protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::AF_IMPLINK;F;xI"INTEGER2NUM(AF_IMPLINK);To;u;[[@i;F;:PF_IMPLINK;;w;;;[;{;IC; "ARPANET IMP protocol ;T;[;![;"I"ARPANET IMP protocol;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::PF_IMPLINK;F;xI"INTEGER2NUM(PF_IMPLINK);To;u;[[@i;F;: AF_PUP;;w;;;[;{;IC; "#PARC Universal Packet protocol ;T;[;![;"I"#PARC Universal Packet protocol;T;#0;$@,;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_PUP;F;xI"INTEGER2NUM(AF_PUP);To;u;[[@i;F;: PF_PUP;;w;;;[;{;IC; "#PARC Universal Packet protocol ;T;[;![;"I"#PARC Universal Packet protocol;T;#0;$@8;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_PUP;F;xI"INTEGER2NUM(PF_PUP);To;u;[[@i;F;: AF_CHAOS;;w;;;[;{;IC; "MIT CHAOS protocols ;T;[;![;"I"MIT CHAOS protocols;T;#0;$@D;.F;/o;0;1T;2i;3i;%@;&I" Socket::Constants::AF_CHAOS;F;xI"INTEGER2NUM(AF_CHAOS);To;u;[[@i;F;: PF_CHAOS;;w;;;[;{;IC; "MIT CHAOS protocols ;T;[;![;"I"MIT CHAOS protocols;T;#0;$@P;.F;/o;0;1T;2i;3i;%@;&I" Socket::Constants::PF_CHAOS;F;xI"INTEGER2NUM(PF_CHAOS);To;u;[[@i;F;: AF_NS;;w;;;[;{;IC; "XEROX NS protocols ;T;[;![;"I"XEROX NS protocols;T;#0;$@\;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_NS;F;xI"INTEGER2NUM(AF_NS);To;u;[[@i;F;: PF_NS;;w;;;[;{;IC; "XEROX NS protocols ;T;[;![;"I"XEROX NS protocols;T;#0;$@h;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_NS;F;xI"INTEGER2NUM(PF_NS);To;u;[[@i;F;: AF_ISO;;w;;;[;{;IC; "/ISO Open Systems Interconnection protocols ;T;[;![;"I"/ISO Open Systems Interconnection protocols;T;#0;$@t;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_ISO;F;xI"INTEGER2NUM(AF_ISO);To;u;[[@i;F;: PF_ISO;;w;;;[;{;IC; "/ISO Open Systems Interconnection protocols ;T;[;![;"I"/ISO Open Systems Interconnection protocols;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_ISO;F;xI"INTEGER2NUM(PF_ISO);To;u;[[@i;F;: AF_OSI;;w;;;[;{;IC; "/ISO Open Systems Interconnection protocols ;T;[;![;"I"/ISO Open Systems Interconnection protocols;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_OSI;F;xI"INTEGER2NUM(AF_OSI);To;u;[[@i;F;: PF_OSI;;w;;;[;{;IC; "/ISO Open Systems Interconnection protocols ;T;[;![;"I"/ISO Open Systems Interconnection protocols;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_OSI;F;xI"INTEGER2NUM(PF_OSI);To;u;[[@i ;F;: AF_ECMA;;w;;;[;{;IC; ".European Computer Manufacturers protocols ;T;[;![;"I".European Computer Manufacturers protocols;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::Constants::AF_ECMA;F;xI"INTEGER2NUM(AF_ECMA);To;u;[[@i;F;: PF_ECMA;;w;;;[;{;IC; ".European Computer Manufacturers protocols ;T;[;![;"I".European Computer Manufacturers protocols;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_ECMA;F;xI"INTEGER2NUM(PF_ECMA);To;u;[[@i;F;:AF_DATAKIT;;w;;;[;{;IC; "Datakit protocol ;T;[;![;"I"Datakit protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::AF_DATAKIT;F;xI"INTEGER2NUM(AF_DATAKIT);To;u;[[@i;F;:PF_DATAKIT;;w;;;[;{;IC; "Datakit protocol ;T;[;![;"I"Datakit protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::PF_DATAKIT;F;xI"INTEGER2NUM(PF_DATAKIT);To;u;[[@i%;F;: AF_CCITT;;w;;;[;{;IC; " CCITT (now ITU-T) protocols ;T;[;![;"I" CCITT (now ITU-T) protocols;T;#0;$@;.F;/o;0;1T;2i$;3i$;%@;&I" Socket::Constants::AF_CCITT;F;xI"INTEGER2NUM(AF_CCITT);To;u;[[@i+;F;: PF_CCITT;;w;;;[;{;IC; " CCITT (now ITU-T) protocols ;T;[;![;"I" CCITT (now ITU-T) protocols;T;#0;$@;.F;/o;0;1T;2i*;3i*;%@;&I" Socket::Constants::PF_CCITT;F;xI"INTEGER2NUM(PF_CCITT);To;u;[[@i1;F;: AF_SNA;;w;;;[;{;IC; "IBM SNA protocol ;T;[;![;"I"IBM SNA protocol;T;#0;$@;.F;/o;0;1T;2i0;3i0;%@;&I"Socket::Constants::AF_SNA;F;xI"INTEGER2NUM(AF_SNA);To;u;[[@i7;F;: PF_SNA;;w;;;[;{;IC; "IBM SNA protocol ;T;[;![;"I"IBM SNA protocol;T;#0;$@;.F;/o;0;1T;2i6;3i6;%@;&I"Socket::Constants::PF_SNA;F;xI"INTEGER2NUM(PF_SNA);To;u;[[@i=;F;: AF_DEC;;w;;;[;{;IC; "DECnet protocol ;T;[;![;"I"DECnet protocol;T;#0;$@;.F;/o;0;1T;2i<;3i<;%@;&I"Socket::Constants::AF_DEC;F;xI"INTEGER2NUM(AF_DEC);To;u;[[@iC;F;: PF_DEC;;w;;;[;{;IC; "DECnet protocol ;T;[;![;"I"DECnet protocol;T;#0;$@;.F;/o;0;1T;2iB;3iB;%@;&I"Socket::Constants::PF_DEC;F;xI"INTEGER2NUM(PF_DEC);To;u;[[@iI;F;:AF_DECnet;;w;;;[;{;IC; "DECnet protocol ;T;[;![;"I"DECnet protocol;T;#0;$@;.F;/o;0;1T;2iH;3iH;%@;&I"!Socket::Constants::AF_DECnet;F;xI"INTEGER2NUM(AF_DECnet);To;u;[[@iO;F;:PF_DECnet;;w;;;[;{;IC; "DECnet protocol ;T;[;![;"I"DECnet protocol;T;#0;$@(;.F;/o;0;1T;2iN;3iN;%@;&I"!Socket::Constants::PF_DECnet;F;xI"INTEGER2NUM(PF_DECnet);To;u;[[@iU;F;: AF_DLI;;w;;;[;{;IC; ",DEC Direct Data Link Interface protocol ;T;[;![;"I",DEC Direct Data Link Interface protocol;T;#0;$@4;.F;/o;0;1T;2iT;3iT;%@;&I"Socket::Constants::AF_DLI;F;xI"INTEGER2NUM(AF_DLI);To;u;[[@i[;F;: PF_DLI;;w;;;[;{;IC; ",DEC Direct Data Link Interface protocol ;T;[;![;"I",DEC Direct Data Link Interface protocol;T;#0;$@@;.F;/o;0;1T;2iZ;3iZ;%@;&I"Socket::Constants::PF_DLI;F;xI"INTEGER2NUM(PF_DLI);To;u;[[@ia;F;: AF_LAT;;w;;;[;{;IC; ""Local Area Transport protocol ;T;[;![;"I""Local Area Transport protocol;T;#0;$@L;.F;/o;0;1T;2i`;3i`;%@;&I"Socket::Constants::AF_LAT;F;xI"INTEGER2NUM(AF_LAT);To;u;[[@ig;F;: PF_LAT;;w;;;[;{;IC; ""Local Area Transport protocol ;T;[;![;"I""Local Area Transport protocol;T;#0;$@X;.F;/o;0;1T;2if;3if;%@;&I"Socket::Constants::PF_LAT;F;xI"INTEGER2NUM(PF_LAT);To;u;[[@im;F;:AF_HYLINK;;w;;;[;{;IC; "NSC Hyperchannel protocol ;T;[;![;"I"NSC Hyperchannel protocol;T;#0;$@d;.F;/o;0;1T;2il;3il;%@;&I"!Socket::Constants::AF_HYLINK;F;xI"INTEGER2NUM(AF_HYLINK);To;u;[[@is;F;:PF_HYLINK;;w;;;[;{;IC; "NSC Hyperchannel protocol ;T;[;![;"I"NSC Hyperchannel protocol;T;#0;$@p;.F;/o;0;1T;2ir;3ir;%@;&I"!Socket::Constants::PF_HYLINK;F;xI"INTEGER2NUM(PF_HYLINK);To;u;[[@iy;F;: AF_ROUTE;;w;;;[;{;IC; "Internal routing protocol ;T;[;![;"I"Internal routing protocol;T;#0;$@|;.F;/o;0;1T;2ix;3ix;%@;&I" Socket::Constants::AF_ROUTE;F;xI"INTEGER2NUM(AF_ROUTE);To;u;[[@i;F;: PF_ROUTE;;w;;;[;{;IC; "Internal routing protocol ;T;[;![;"I"Internal routing protocol;T;#0;$@;.F;/o;0;1T;2i~;3i~;%@;&I" Socket::Constants::PF_ROUTE;F;xI"INTEGER2NUM(PF_ROUTE);To;u;[[@i;F;: AF_LINK;;w;;;[;{;IC; "Link layer interface ;T;[;![;"I"Link layer interface;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_LINK;F;xI"INTEGER2NUM(AF_LINK);To;u;[[@i;F;: PF_LINK;;w;;;[;{;IC; "Link layer interface ;T;[;![;"I"Link layer interface;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_LINK;F;xI"INTEGER2NUM(PF_LINK);To;u;[[@i;F;: AF_COIP;;w;;;[;{;IC; "Connection-oriented IP ;T;[;![;"I"Connection-oriented IP;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_COIP;F;xI"INTEGER2NUM(AF_COIP);To;u;[[@i;F;: PF_COIP;;w;;;[;{;IC; "Connection-oriented IP ;T;[;![;"I"Connection-oriented IP;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_COIP;F;xI"INTEGER2NUM(PF_COIP);To;u;[[@i;F;: AF_CNT;;w;;;[;{;IC; " Computer Network Technology ;T;[;![;"I" Computer Network Technology;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_CNT;F;xI"INTEGER2NUM(AF_CNT);To;u;[[@i;F;: PF_CNT;;w;;;[;{;IC; " Computer Network Technology ;T;[;![;"I" Computer Network Technology;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_CNT;F;xI"INTEGER2NUM(PF_CNT);To;u;[[@i;F;: AF_SIP;;w;;;[;{;IC; "Simple Internet Protocol ;T;[;![;"I"Simple Internet Protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_SIP;F;xI"INTEGER2NUM(AF_SIP);To;u;[[@i;F;: PF_SIP;;w;;;[;{;IC; "Simple Internet Protocol ;T;[;![;"I"Simple Internet Protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_SIP;F;xI"INTEGER2NUM(PF_SIP);To;u;[[@i;F;: AF_NDRV;;w;;;[;{;IC; "Network driver raw access ;T;[;![;"I"Network driver raw access;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_NDRV;F;xI"INTEGER2NUM(AF_NDRV);To;u;[[@i;F;: PF_NDRV;;w;;;[;{;IC; "Network driver raw access ;T;[;![;"I"Network driver raw access;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_NDRV;F;xI"INTEGER2NUM(PF_NDRV);To;u;[[@i;F;: AF_ISDN;;w;;;[;{;IC; "(Integrated Services Digital Network ;T;[;![;"I"(Integrated Services Digital Network;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_ISDN;F;xI"INTEGER2NUM(AF_ISDN);To;u;[[@i;F;: PF_ISDN;;w;;;[;{;IC; "(Integrated Services Digital Network ;T;[;![;"I"(Integrated Services Digital Network;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_ISDN;F;xI"INTEGER2NUM(PF_ISDN);To;u;[[@i;F;: AF_NATM;;w;;;[;{;IC; "Native ATM access ;T;[;![;"I"Native ATM access;T;#0;$@$;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_NATM;F;xI"INTEGER2NUM(AF_NATM);To;u;[[@i;F;: PF_NATM;;w;;;[;{;IC; "Native ATM access ;T;[;![;"I"Native ATM access;T;#0;$@0;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_NATM;F;xI"INTEGER2NUM(PF_NATM);To;u;[[@i;F;:AF_SYSTEM;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@<;%@;&I"!Socket::Constants::AF_SYSTEM;F;xI"INTEGER2NUM(AF_SYSTEM);To;u;[[@i;F;:PF_SYSTEM;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@F;%@;&I"!Socket::Constants::PF_SYSTEM;F;xI"INTEGER2NUM(PF_SYSTEM);To;u;[[@i;F;:AF_NETBIOS;;w;;;[;{;IC; " NetBIOS ;T;[;![;"I" NetBIOS;T;#0;$@P;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::AF_NETBIOS;F;xI"INTEGER2NUM(AF_NETBIOS);To;u;[[@i;F;:PF_NETBIOS;;w;;;[;{;IC; " NetBIOS ;T;[;![;"I" NetBIOS;T;#0;$@\;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::PF_NETBIOS;F;xI"INTEGER2NUM(PF_NETBIOS);To;u;[[@i;F;: AF_PPP;;w;;;[;{;IC; "Point-to-Point Protocol ;T;[;![;"I"Point-to-Point Protocol;T;#0;$@h;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_PPP;F;xI"INTEGER2NUM(AF_PPP);To;u;[[@i;F;: PF_PPP;;w;;;[;{;IC; "Point-to-Point Protocol ;T;[;![;"I"Point-to-Point Protocol;T;#0;$@t;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_PPP;F;xI"INTEGER2NUM(PF_PPP);To;u;[[@i;F;: AF_ATM;;w;;;[;{;IC; "Asynchronous Transfer Mode ;T;[;![;"I"Asynchronous Transfer Mode;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_ATM;F;xI"INTEGER2NUM(AF_ATM);To;u;[[@i;F;: PF_ATM;;w;;;[;{;IC; "Asynchronous Transfer Mode ;T;[;![;"I"Asynchronous Transfer Mode;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_ATM;F;xI"INTEGER2NUM(PF_ATM);To;u;[[@i ;F;:AF_NETGRAPH;;w;;;[;{;IC; "Netgraph sockets ;T;[;![;"I"Netgraph sockets;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::AF_NETGRAPH;F;xI"INTEGER2NUM(AF_NETGRAPH);To;u;[[@i;F;:PF_NETGRAPH;;w;;;[;{;IC; "Netgraph sockets ;T;[;![;"I"Netgraph sockets;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::PF_NETGRAPH;F;xI"INTEGER2NUM(PF_NETGRAPH);To;u;[[@i;F;: AF_MAX;;w;;;[;{;IC; "-Maximum address family for this platform ;T;[;![;"I"-Maximum address family for this platform;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_MAX;F;xI"INTEGER2NUM(AF_MAX);To;u;[[@i;F;: PF_MAX;;w;;;[;{;IC; "-Maximum address family for this platform ;T;[;![;"I"-Maximum address family for this platform;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_MAX;F;xI"INTEGER2NUM(PF_MAX);To;u;[[@i!;F;:AF_PACKET;;w;;;[;{;IC; "Direct link-layer access ;T;[;![;"I"Direct link-layer access;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"!Socket::Constants::AF_PACKET;F;xI"INTEGER2NUM(AF_PACKET);To;u;[[@i';F;:PF_PACKET;;w;;;[;{;IC; "Direct link-layer access ;T;[;![;"I"Direct link-layer access;T;#0;$@;.F;/o;0;1T;2i&;3i&;%@;&I"!Socket::Constants::PF_PACKET;F;xI"INTEGER2NUM(PF_PACKET);To;u;[[@i-;F;: AF_E164;;w;;;[;{;IC; "'CCITT (ITU-T) E.164 recommendation ;T;[;![;"I"'CCITT (ITU-T) E.164 recommendation;T;#0;$@;.F;/o;0;1T;2i,;3i,;%@;&I"Socket::Constants::AF_E164;F;xI"INTEGER2NUM(AF_E164);To;u;[[@i3;F;: PF_XTP;;w;;;[;{;IC; "eXpress Transfer Protocol ;T;[;![;"I"eXpress Transfer Protocol;T;#0;$@;.F;/o;0;1T;2i2;3i2;%@;&I"Socket::Constants::PF_XTP;F;xI"INTEGER2NUM(PF_XTP);To;u;[[@i9;F;: PF_RTIP;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"Socket::Constants::PF_RTIP;F;xI"INTEGER2NUM(PF_RTIP);To;u;[[@i?;F;: PF_PIP;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"Socket::Constants::PF_PIP;F;xI"INTEGER2NUM(PF_PIP);To;u;[[@iE;F;: AF_KEY;;w;;;[;{;IC; "GKey management protocol, originally developed for usage with IPsec ;T;[;![;"I"GKey management protocol, originally developed for usage with IPsec;T;#0;$@ ;.F;/o;0;1T;2iD;3iD;%@;&I"Socket::Constants::AF_KEY;F;xI"INTEGER2NUM(AF_KEY);To;u;[[@iK;F;: PF_KEY;;w;;;[;{;IC; "GKey management protocol, originally developed for usage with IPsec ;T;[;![;"I"GKey management protocol, originally developed for usage with IPsec;T;#0;$@;.F;/o;0;1T;2iJ;3iJ;%@;&I"Socket::Constants::PF_KEY;F;xI"INTEGER2NUM(PF_KEY);To;u;[[@iQ;F;:AF_NETLINK;;w;;;[;{;IC; "!Kernel user interface device ;T;[;![;"I"!Kernel user interface device;T;#0;$@$;.F;/o;0;1T;2iP;3iP;%@;&I""Socket::Constants::AF_NETLINK;F;xI"INTEGER2NUM(AF_NETLINK);To;u;[[@iW;F;:PF_NETLINK;;w;;;[;{;IC; "!Kernel user interface device ;T;[;![;"I"!Kernel user interface device;T;#0;$@0;.F;/o;0;1T;2iV;3iV;%@;&I""Socket::Constants::PF_NETLINK;F;xI"INTEGER2NUM(PF_NETLINK);To;u;[[@i];F;: AF_RDS;;w;;;[;{;IC; "-Reliable Datagram Sockets (RDS) protocol ;T;[;![;"I"-Reliable Datagram Sockets (RDS) protocol;T;#0;$@<;.F;/o;0;1T;2i\;3i\;%@;&I"Socket::Constants::AF_RDS;F;xI"INTEGER2NUM(AF_RDS);To;u;[[@ic;F;: PF_RDS;;w;;;[;{;IC; "-Reliable Datagram Sockets (RDS) protocol ;T;[;![;"I"-Reliable Datagram Sockets (RDS) protocol;T;#0;$@H;.F;/o;0;1T;2ib;3ib;%@;&I"Socket::Constants::PF_RDS;F;xI"INTEGER2NUM(PF_RDS);To;u;[[@ii;F;: AF_PPPOX;;w;;;[;{;IC; "LGeneric PPP transport layer, for setting up L2 tunnels (L2TP and PPPoE) ;T;[;![;"I"LGeneric PPP transport layer, for setting up L2 tunnels (L2TP and PPPoE);T;#0;$@T;.F;/o;0;1T;2ih;3ih;%@;&I" Socket::Constants::AF_PPPOX;F;xI"INTEGER2NUM(AF_PPPOX);To;u;[[@io;F;: PF_PPPOX;;w;;;[;{;IC; "LGeneric PPP transport layer, for setting up L2 tunnels (L2TP and PPPoE) ;T;[;![;"I"LGeneric PPP transport layer, for setting up L2 tunnels (L2TP and PPPoE);T;#0;$@`;.F;/o;0;1T;2in;3in;%@;&I" Socket::Constants::PF_PPPOX;F;xI"INTEGER2NUM(PF_PPPOX);To;u;[[@iu;F;: AF_LLC;;w;;;[;{;IC; "4Logical link control (IEEE 802.2 LLC) protocol ;T;[;![;"I"4Logical link control (IEEE 802.2 LLC) protocol;T;#0;$@l;.F;/o;0;1T;2it;3it;%@;&I"Socket::Constants::AF_LLC;F;xI"INTEGER2NUM(AF_LLC);To;u;[[@i{;F;: PF_LLC;;w;;;[;{;IC; "4Logical link control (IEEE 802.2 LLC) protocol ;T;[;![;"I"4Logical link control (IEEE 802.2 LLC) protocol;T;#0;$@x;.F;/o;0;1T;2iz;3iz;%@;&I"Socket::Constants::PF_LLC;F;xI"INTEGER2NUM(PF_LLC);To;u;[[@i;F;: AF_IB;;w;;;[;{;IC; "!InfiniBand native addressing ;T;[;![;"I"!InfiniBand native addressing;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_IB;F;xI"INTEGER2NUM(AF_IB);To;u;[[@i;F;: PF_IB;;w;;;[;{;IC; "!InfiniBand native addressing ;T;[;![;"I"!InfiniBand native addressing;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_IB;F;xI"INTEGER2NUM(PF_IB);To;u;[[@i;F;: AF_MPLS;;w;;;[;{;IC; ""Multiprotocol Label Switching ;T;[;![;"I""Multiprotocol Label Switching;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_MPLS;F;xI"INTEGER2NUM(AF_MPLS);To;u;[[@i;F;: PF_MPLS;;w;;;[;{;IC; ""Multiprotocol Label Switching ;T;[;![;"I""Multiprotocol Label Switching;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_MPLS;F;xI"INTEGER2NUM(PF_MPLS);To;u;[[@i;F;: AF_CAN;;w;;;[;{;IC; "4Controller Area Network automotive bus protocol ;T;[;![;"I"4Controller Area Network automotive bus protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_CAN;F;xI"INTEGER2NUM(AF_CAN);To;u;[[@i;F;: PF_CAN;;w;;;[;{;IC; "4Controller Area Network automotive bus protocol ;T;[;![;"I"4Controller Area Network automotive bus protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_CAN;F;xI"INTEGER2NUM(PF_CAN);To;u;[[@i;F;: AF_TIPC;;w;;;[;{;IC; ",TIPC, "cluster domain sockets" protocol ;T;[;![;"I",TIPC, "cluster domain sockets" protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_TIPC;F;xI"INTEGER2NUM(AF_TIPC);To;u;[[@i;F;: PF_TIPC;;w;;;[;{;IC; ",TIPC, "cluster domain sockets" protocol ;T;[;![;"I",TIPC, "cluster domain sockets" protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_TIPC;F;xI"INTEGER2NUM(PF_TIPC);To;u;[[@i;F;:AF_BLUETOOTH;;w;;;[;{;IC; "(Bluetooth low-level socket protocol ;T;[;![;"I"(Bluetooth low-level socket protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"$Socket::Constants::AF_BLUETOOTH;F;xI"INTEGER2NUM(AF_BLUETOOTH);To;u;[[@i;F;:PF_BLUETOOTH;;w;;;[;{;IC; "(Bluetooth low-level socket protocol ;T;[;![;"I"(Bluetooth low-level socket protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"$Socket::Constants::PF_BLUETOOTH;F;xI"INTEGER2NUM(PF_BLUETOOTH);To;u;[[@i;F;: AF_ALG;;w;;;[;{;IC; "#Interface to kernel crypto API ;T;[;![;"I"#Interface to kernel crypto API;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_ALG;F;xI"INTEGER2NUM(AF_ALG);To;u;[[@i;F;: PF_ALG;;w;;;[;{;IC; "#Interface to kernel crypto API ;T;[;![;"I"#Interface to kernel crypto API;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_ALG;F;xI"INTEGER2NUM(PF_ALG);To;u;[[@i;F;: AF_VSOCK;;w;;;[;{;IC; "UVSOCK (originally "VMWare VSockets") protocol for hypervisor-guest communication ;T;[;![;"I"UVSOCK (originally "VMWare VSockets") protocol for hypervisor-guest communication;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I" Socket::Constants::AF_VSOCK;F;xI"INTEGER2NUM(AF_VSOCK);To;u;[[@i;F;: PF_VSOCK;;w;;;[;{;IC; "UVSOCK (originally "VMWare VSockets") protocol for hypervisor-guest communication ;T;[;![;"I"UVSOCK (originally "VMWare VSockets") protocol for hypervisor-guest communication;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;&I" Socket::Constants::PF_VSOCK;F;xI"INTEGER2NUM(PF_VSOCK);To;u;[[@i;F;: AF_KCM;;w;;;[;{;IC; "2KCM (kernel connection multiplexor) interface ;T;[;![;"I"2KCM (kernel connection multiplexor) interface;T;#0;$@,;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_KCM;F;xI"INTEGER2NUM(AF_KCM);To;u;[[@i;F;: PF_KCM;;w;;;[;{;IC; "2KCM (kernel connection multiplexor) interface ;T;[;![;"I"2KCM (kernel connection multiplexor) interface;T;#0;$@8;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_KCM;F;xI"INTEGER2NUM(PF_KCM);To;u;[[@i;F;: AF_XDP;;w;;;[;{;IC; "&XDP (express data path) interface ;T;[;![;"I"&XDP (express data path) interface;T;#0;$@D;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::AF_XDP;F;xI"INTEGER2NUM(AF_XDP);To;u;[[@i;F;: PF_XDP;;w;;;[;{;IC; "&XDP (express data path) interface ;T;[;![;"I"&XDP (express data path) interface;T;#0;$@P;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::PF_XDP;F;xI"INTEGER2NUM(PF_XDP);To;u;[[@i;F;: MSG_OOB;;w;;;[;{;IC; "Process out-of-band data ;T;[;![;"I"Process out-of-band data;T;#0;$@\;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::MSG_OOB;F;xI"INTEGER2NUM(MSG_OOB);To;u;[[@i;F;: MSG_PEEK;;w;;;[;{;IC; "Peek at incoming message ;T;[;![;"I"Peek at incoming message;T;#0;$@h;.F;/o;0;1T;2i;3i;%@;&I" Socket::Constants::MSG_PEEK;F;xI"INTEGER2NUM(MSG_PEEK);To;u;[[@i;F;:MSG_DONTROUTE;;w;;;[;{;IC; "*Send without using the routing tables ;T;[;![;"I"*Send without using the routing tables;T;#0;$@t;.F;/o;0;1T;2i;3i;%@;&I"%Socket::Constants::MSG_DONTROUTE;F;xI"INTEGER2NUM(MSG_DONTROUTE);To;u;[[@i;F;: MSG_EOR;;w;;;[;{;IC; "Data completes record ;T;[;![;"I"Data completes record;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::MSG_EOR;F;xI"INTEGER2NUM(MSG_EOR);To;u;[[@i;F;:MSG_TRUNC;;w;;;[;{;IC; "#Data discarded before delivery ;T;[;![;"I"#Data discarded before delivery;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"!Socket::Constants::MSG_TRUNC;F;xI"INTEGER2NUM(MSG_TRUNC);To;u;[[@i ;F;:MSG_CTRUNC;;w;;;[;{;IC; "&Control data lost before delivery ;T;[;![;"I"&Control data lost before delivery;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I""Socket::Constants::MSG_CTRUNC;F;xI"INTEGER2NUM(MSG_CTRUNC);To;u;[[@i;F;:MSG_WAITALL;;w;;;[;{;IC; "#Wait for full request or error ;T;[;![;"I"#Wait for full request or error;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::MSG_WAITALL;F;xI"INTEGER2NUM(MSG_WAITALL);To;u;[[@i;F;:MSG_DONTWAIT;;w;;;[;{;IC; "(This message should be non-blocking ;T;[;![;"I"(This message should be non-blocking;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"$Socket::Constants::MSG_DONTWAIT;F;xI"INTEGER2NUM(MSG_DONTWAIT);To;u;[[@i;F;: MSG_EOF;;w;;;[;{;IC; "Data completes connection ;T;[;![;"I"Data completes connection;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::MSG_EOF;F;xI"INTEGER2NUM(MSG_EOF);To;u;[[@i#;F;:MSG_FLUSH;;w;;;[;{;IC; "0Start of a hold sequence. Dumps to so_temp ;T;[;![;"I"0Start of a hold sequence. Dumps to so_temp;T;#0;$@;.F;/o;0;1T;2i";3i";%@;&I"!Socket::Constants::MSG_FLUSH;F;xI"INTEGER2NUM(MSG_FLUSH);To;u;[[@i);F;: MSG_HOLD;;w;;;[;{;IC; "Hold fragment in so_temp ;T;[;![;"I"Hold fragment in so_temp;T;#0;$@;.F;/o;0;1T;2i(;3i(;%@;&I" Socket::Constants::MSG_HOLD;F;xI"INTEGER2NUM(MSG_HOLD);To;u;[[@i/;F;: MSG_SEND;;w;;;[;{;IC; "Send the packet in so_temp ;T;[;![;"I"Send the packet in so_temp;T;#0;$@;.F;/o;0;1T;2i.;3i.;%@;&I" Socket::Constants::MSG_SEND;F;xI"INTEGER2NUM(MSG_SEND);To;u;[[@i5;F;:MSG_HAVEMORE;;w;;;[;{;IC; "Data ready to be read ;T;[;![;"I"Data ready to be read;T;#0;$@;.F;/o;0;1T;2i4;3i4;%@;&I"$Socket::Constants::MSG_HAVEMORE;F;xI"INTEGER2NUM(MSG_HAVEMORE);To;u;[[@i;;F;:MSG_RCVMORE;;w;;;[;{;IC; "'Data remains in the current packet ;T;[;![;"I"'Data remains in the current packet;T;#0;$@;.F;/o;0;1T;2i:;3i:;%@;&I"#Socket::Constants::MSG_RCVMORE;F;xI"INTEGER2NUM(MSG_RCVMORE);To;u;[[@iA;F;:MSG_COMPAT;;w;;;[;{;IC; "End of record ;T;[;![;"I"End of record;T;#0;$@;.F;/o;0;1T;2i@;3i@;%@;&I""Socket::Constants::MSG_COMPAT;F;xI"INTEGER2NUM(MSG_COMPAT);To;u;[[@iG;F;:MSG_PROXY;;w;;;[;{;IC; "Wait for full request ;T;[;![;"I"Wait for full request;T;#0;$@;.F;/o;0;1T;2iF;3iF;%@;&I"!Socket::Constants::MSG_PROXY;F;xI"INTEGER2NUM(MSG_PROXY);To;u;[[@iM;F;: MSG_FIN;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"Socket::Constants::MSG_FIN;F;xI"INTEGER2NUM(MSG_FIN);To;u;[[@iS;F;: MSG_SYN;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@&;%@;&I"Socket::Constants::MSG_SYN;F;xI"INTEGER2NUM(MSG_SYN);To;u;[[@iY;F;:MSG_CONFIRM;;w;;;[;{;IC; "Confirm path validity ;T;[;![;"I"Confirm path validity;T;#0;$@0;.F;/o;0;1T;2iX;3iX;%@;&I"#Socket::Constants::MSG_CONFIRM;F;xI"INTEGER2NUM(MSG_CONFIRM);To;u;[[@i_;F;: MSG_RST;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@<;%@;&I"Socket::Constants::MSG_RST;F;xI"INTEGER2NUM(MSG_RST);To;u;[[@ie;F;:MSG_ERRQUEUE;;w;;;[;{;IC; "#Fetch message from error queue ;T;[;![;"I"#Fetch message from error queue;T;#0;$@F;.F;/o;0;1T;2id;3id;%@;&I"$Socket::Constants::MSG_ERRQUEUE;F;xI"INTEGER2NUM(MSG_ERRQUEUE);To;u;[[@ik;F;:MSG_NOSIGNAL;;w;;;[;{;IC; "Do not generate SIGPIPE ;T;[;![;"I"Do not generate SIGPIPE;T;#0;$@R;.F;/o;0;1T;2ij;3ij;%@;&I"$Socket::Constants::MSG_NOSIGNAL;F;xI"INTEGER2NUM(MSG_NOSIGNAL);To;u;[[@iq;F;: MSG_MORE;;w;;;[;{;IC; "Sender will send more ;T;[;![;"I"Sender will send more;T;#0;$@^;.F;/o;0;1T;2ip;3ip;%@;&I" Socket::Constants::MSG_MORE;F;xI"INTEGER2NUM(MSG_MORE);To;u;[[@iw;F;:MSG_FASTOPEN;;w;;;[;{;IC; ")Reduce step of the handshake process ;T;[;![;"I")Reduce step of the handshake process;T;#0;$@j;.F;/o;0;1T;2iv;3iv;%@;&I"$Socket::Constants::MSG_FASTOPEN;F;xI"INTEGER2NUM(MSG_FASTOPEN);To;u;[[@i};F;:SOL_SOCKET;;w;;;[;{;IC; "Socket-level options ;T;[;![;"I"Socket-level options;T;#0;$@v;.F;/o;0;1T;2i|;3i|;%@;&I""Socket::Constants::SOL_SOCKET;F;xI"INTEGER2NUM(SOL_SOCKET);To;u;[[@i;F;: SOL_IP;;w;;;[;{;IC; "IP socket options ;T;[;![;"I"IP socket options;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::SOL_IP;F;xI"INTEGER2NUM(SOL_IP);To;u;[[@i;F;: SOL_IPX;;w;;;[;{;IC; "IPX socket options ;T;[;![;"I"IPX socket options;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::SOL_IPX;F;xI"INTEGER2NUM(SOL_IPX);To;u;[[@i;F;: SOL_AX25;;w;;;[;{;IC; "AX.25 socket options ;T;[;![;"I"AX.25 socket options;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I" Socket::Constants::SOL_AX25;F;xI"INTEGER2NUM(SOL_AX25);To;u;[[@i;F;:SOL_ATALK;;w;;;[;{;IC; "AppleTalk socket options ;T;[;![;"I"AppleTalk socket options;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"!Socket::Constants::SOL_ATALK;F;xI"INTEGER2NUM(SOL_ATALK);To;u;[[@i;F;: SOL_TCP;;w;;;[;{;IC; "TCP socket options ;T;[;![;"I"TCP socket options;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::SOL_TCP;F;xI"INTEGER2NUM(SOL_TCP);To;u;[[@i;F;: SOL_UDP;;w;;;[;{;IC; "UDP socket options ;T;[;![;"I"UDP socket options;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::SOL_UDP;F;xI"INTEGER2NUM(SOL_UDP);To;u;[[@i;F;:IPPROTO_IP;;w;;;[;{;IC; "Dummy protocol for IP ;T;[;![;"I"Dummy protocol for IP;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::IPPROTO_IP;F;xI"INTEGER2NUM(IPPROTO_IP);To;u;[[@i;F;:IPPROTO_ICMP;;w;;;[;{;IC; "Control message protocol ;T;[;![;"I"Control message protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"$Socket::Constants::IPPROTO_ICMP;F;xI"INTEGER2NUM(IPPROTO_ICMP);To;u;[[@i;F;:IPPROTO_IGMP;;w;;;[;{;IC; "Group Management Protocol ;T;[;![;"I"Group Management Protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"$Socket::Constants::IPPROTO_IGMP;F;xI"INTEGER2NUM(IPPROTO_IGMP);To;u;[[@i;F;:IPPROTO_GGP;;w;;;[;{;IC; " Gateway to Gateway Protocol ;T;[;![;"I" Gateway to Gateway Protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::IPPROTO_GGP;F;xI"INTEGER2NUM(IPPROTO_GGP);To;u;[[@i;F;:IPPROTO_TCP;;w;;;[;{;IC; "TCP ;T;[;![;"I"TCP;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::IPPROTO_TCP;F;xI"INTEGER2NUM(IPPROTO_TCP);To;u;[[@i;F;:IPPROTO_EGP;;w;;;[;{;IC; "Exterior Gateway Protocol ;T;[;![;"I"Exterior Gateway Protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::IPPROTO_EGP;F;xI"INTEGER2NUM(IPPROTO_EGP);To;u;[[@i;F;:IPPROTO_PUP;;w;;;[;{;IC; "#PARC Universal Packet protocol ;T;[;![;"I"#PARC Universal Packet protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::IPPROTO_PUP;F;xI"INTEGER2NUM(IPPROTO_PUP);To;u;[[@i;F;:IPPROTO_UDP;;w;;;[;{;IC; "UDP ;T;[;![;"I"UDP;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::IPPROTO_UDP;F;xI"INTEGER2NUM(IPPROTO_UDP);To;u;[[@i;F;:IPPROTO_IDP;;w;;;[;{;IC; " XNS IDP ;T;[;![;"I" XNS IDP;T;#0;$@*;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::IPPROTO_IDP;F;xI"INTEGER2NUM(IPPROTO_IDP);To;u;[[@i;F;:IPPROTO_HELLO;;w;;;[;{;IC; ""hello" routing protocol ;T;[;![;"I""hello" routing protocol;T;#0;$@6;.F;/o;0;1T;2i;3i;%@;&I"%Socket::Constants::IPPROTO_HELLO;F;xI"INTEGER2NUM(IPPROTO_HELLO);To;u;[[@i;F;:IPPROTO_ND;;w;;;[;{;IC; "Sun net disk protocol ;T;[;![;"I"Sun net disk protocol;T;#0;$@B;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::IPPROTO_ND;F;xI"INTEGER2NUM(IPPROTO_ND);To;u;[[@i;F;:IPPROTO_TP;;w;;;[;{;IC; "#ISO transport protocol class 4 ;T;[;![;"I"#ISO transport protocol class 4;T;#0;$@N;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::IPPROTO_TP;F;xI"INTEGER2NUM(IPPROTO_TP);To;u;[[@i;F;:IPPROTO_XTP;;w;;;[;{;IC; "Xpress Transport Protocol ;T;[;![;"I"Xpress Transport Protocol;T;#0;$@Z;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::IPPROTO_XTP;F;xI"INTEGER2NUM(IPPROTO_XTP);To;u;[[@i;F;:IPPROTO_EON;;w;;;[;{;IC; " ISO cnlp ;T;[;![;"I" ISO cnlp;T;#0;$@f;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::IPPROTO_EON;F;xI"INTEGER2NUM(IPPROTO_EON);To;u;[[@i;F;:IPPROTO_BIP;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@r;%@;&I"#Socket::Constants::IPPROTO_BIP;F;xI"INTEGER2NUM(IPPROTO_BIP);To;u;[[@i;F;:IPPROTO_AH;;w;;;[;{;IC; "IP6 auth header ;T;[;![;"I"IP6 auth header;T;#0;$@|;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::IPPROTO_AH;F;xI"INTEGER2NUM(IPPROTO_AH);To;u;[[@i;F;:IPPROTO_DSTOPTS;;w;;;[;{;IC; "IP6 destination option ;T;[;![;"I"IP6 destination option;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"'Socket::Constants::IPPROTO_DSTOPTS;F;xI"!INTEGER2NUM(IPPROTO_DSTOPTS);To;u;[[@i ;F;:IPPROTO_ESP;;w;;;[;{;IC; "&IP6 Encapsulated Security Payload ;T;[;![;"I"&IP6 Encapsulated Security Payload;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"#Socket::Constants::IPPROTO_ESP;F;xI"INTEGER2NUM(IPPROTO_ESP);To;u;[[@i;F;:IPPROTO_FRAGMENT;;w;;;[;{;IC; "IP6 fragmentation header ;T;[;![;"I"IP6 fragmentation header;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"(Socket::Constants::IPPROTO_FRAGMENT;F;xI""INTEGER2NUM(IPPROTO_FRAGMENT);To;u;[[@i;F;:IPPROTO_HOPOPTS;;w;;;[;{;IC; "IP6 hop-by-hop options ;T;[;![;"I"IP6 hop-by-hop options;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"'Socket::Constants::IPPROTO_HOPOPTS;F;xI"!INTEGER2NUM(IPPROTO_HOPOPTS);To;u;[[@i;F;:IPPROTO_ICMPV6;;w;;;[;{;IC; " ICMP6 ;T;[;![;"I" ICMP6;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"&Socket::Constants::IPPROTO_ICMPV6;F;xI" INTEGER2NUM(IPPROTO_ICMPV6);To;u;[[@i%;F;:IPPROTO_IPV6;;w;;;[;{;IC; "IP6 header ;T;[;![;"I"IP6 header;T;#0;$@;.F;/o;0;1T;2i$;3i$;%@;&I"$Socket::Constants::IPPROTO_IPV6;F;xI"INTEGER2NUM(IPPROTO_IPV6);To;u;[[@i+;F;:IPPROTO_NONE;;w;;;[;{;IC; "IP6 no next header ;T;[;![;"I"IP6 no next header;T;#0;$@;.F;/o;0;1T;2i*;3i*;%@;&I"$Socket::Constants::IPPROTO_NONE;F;xI"INTEGER2NUM(IPPROTO_NONE);To;u;[[@i1;F;:IPPROTO_ROUTING;;w;;;[;{;IC; "IP6 routing header ;T;[;![;"I"IP6 routing header;T;#0;$@;.F;/o;0;1T;2i0;3i0;%@;&I"'Socket::Constants::IPPROTO_ROUTING;F;xI"!INTEGER2NUM(IPPROTO_ROUTING);To;u;[[@i7;F;:IPPROTO_RAW;;w;;;[;{;IC; "Raw IP packet ;T;[;![;"I"Raw IP packet;T;#0;$@;.F;/o;0;1T;2i6;3i6;%@;&I"#Socket::Constants::IPPROTO_RAW;F;xI"INTEGER2NUM(IPPROTO_RAW);To;u;[[@i=;F;:IPPROTO_MAX;;w;;;[;{;IC; "Maximum IPPROTO constant ;T;[;![;"I"Maximum IPPROTO constant;T;#0;$@;.F;/o;0;1T;2i<;3i<;%@;&I"#Socket::Constants::IPPROTO_MAX;F;xI"INTEGER2NUM(IPPROTO_MAX);To;u;[[@iC;F;:IPPORT_RESERVED;;w;;;[;{;IC; "0Default minimum address for bind or connect ;T;[;![;"I"0Default minimum address for bind or connect;T;#0;$@;.F;/o;0;1T;2iB;3iB;%@;&I"'Socket::Constants::IPPORT_RESERVED;F;xI"!INTEGER2NUM(IPPORT_RESERVED);To;u;[[@iI;F;:IPPORT_USERRESERVED;;w;;;[;{;IC; "0Default maximum address for bind or connect ;T;[;![;"I"0Default maximum address for bind or connect;T;#0;$@ ;.F;/o;0;1T;2iH;3iH;%@;&I"+Socket::Constants::IPPORT_USERRESERVED;F;xI"%INTEGER2NUM(IPPORT_USERRESERVED);To;u;[[@iO;F;:INADDR_ANY;;w;;;[;{;IC; "lA socket bound to INADDR_ANY receives packets from all interfaces and sends from the default IP address ;T;[;![;"I"lA socket bound to INADDR_ANY receives packets from all interfaces and sends from the default IP address;T;#0;$@;.F;/o;0;1T;2iN;3iN;%@;&I""Socket::Constants::INADDR_ANY;F;xI"INTEGER2NUM(INADDR_ANY);To;u;[[@iU;F;:INADDR_BROADCAST;;w;;;[;{;IC; ""The network broadcast address ;T;[;![;"I""The network broadcast address;T;#0;$@$;.F;/o;0;1T;2iT;3iT;%@;&I"(Socket::Constants::INADDR_BROADCAST;F;xI""INTEGER2NUM(INADDR_BROADCAST);To;u;[[@i[;F;:INADDR_LOOPBACK;;w;;;[;{;IC; "The loopback address ;T;[;![;"I"The loopback address;T;#0;$@0;.F;/o;0;1T;2iZ;3iZ;%@;&I"'Socket::Constants::INADDR_LOOPBACK;F;xI"!INTEGER2NUM(INADDR_LOOPBACK);To;u;[[@ia;F;:INADDR_UNSPEC_GROUP;;w;;;[;{;IC; "!The reserved multicast group ;T;[;![;"I"!The reserved multicast group;T;#0;$@<;.F;/o;0;1T;2i`;3i`;%@;&I"+Socket::Constants::INADDR_UNSPEC_GROUP;F;xI"%INTEGER2NUM(INADDR_UNSPEC_GROUP);To;u;[[@ig;F;:INADDR_ALLHOSTS_GROUP;;w;;;[;{;IC; "3Multicast group for all systems on this subset ;T;[;![;"I"3Multicast group for all systems on this subset;T;#0;$@H;.F;/o;0;1T;2if;3if;%@;&I"-Socket::Constants::INADDR_ALLHOSTS_GROUP;F;xI"'INTEGER2NUM(INADDR_ALLHOSTS_GROUP);To;u;[[@im;F;:INADDR_MAX_LOCAL_GROUP;;w;;;[;{;IC; "+The last local network multicast group ;T;[;![;"I"+The last local network multicast group;T;#0;$@T;.F;/o;0;1T;2il;3il;%@;&I".Socket::Constants::INADDR_MAX_LOCAL_GROUP;F;xI"(INTEGER2NUM(INADDR_MAX_LOCAL_GROUP);To;u;[[@is;F;:INADDR_NONE;;w;;;[;{;IC; "/A bitmask for matching no valid IP address ;T;[;![;"I"/A bitmask for matching no valid IP address;T;#0;$@`;.F;/o;0;1T;2ir;3ir;%@;&I"#Socket::Constants::INADDR_NONE;F;xI"INTEGER2NUM(INADDR_NONE);To;u;[[@iy;F;:IP_OPTIONS;;w;;;[;{;IC; ")IP options to be included in packets ;T;[;![;"I")IP options to be included in packets;T;#0;$@l;.F;/o;0;1T;2ix;3ix;%@;&I""Socket::Constants::IP_OPTIONS;F;xI"INTEGER2NUM(IP_OPTIONS);To;u;[[@i;F;:IP_HDRINCL;;w;;;[;{;IC; "!Header is included with data ;T;[;![;"I"!Header is included with data;T;#0;$@x;.F;/o;0;1T;2i~;3i~;%@;&I""Socket::Constants::IP_HDRINCL;F;xI"INTEGER2NUM(IP_HDRINCL);To;u;[[@i;F;: IP_TOS;;w;;;[;{;IC; "IP type-of-service ;T;[;![;"I"IP type-of-service;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::IP_TOS;F;xI"INTEGER2NUM(IP_TOS);To;u;[[@i;F;: IP_TTL;;w;;;[;{;IC; "IP time-to-live ;T;[;![;"I"IP time-to-live;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::IP_TTL;F;xI"INTEGER2NUM(IP_TTL);To;u;[[@i;F;:IP_RECVOPTS;;w;;;[;{;IC; ")Receive all IP options with datagram ;T;[;![;"I")Receive all IP options with datagram;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::IP_RECVOPTS;F;xI"INTEGER2NUM(IP_RECVOPTS);To;u;[[@i;F;:IP_RECVRETOPTS;;w;;;[;{;IC; "(Receive all IP options for response ;T;[;![;"I"(Receive all IP options for response;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"&Socket::Constants::IP_RECVRETOPTS;F;xI" INTEGER2NUM(IP_RECVRETOPTS);To;u;[[@i;F;:IP_RECVDSTADDR;;w;;;[;{;IC; "1Receive IP destination address with datagram ;T;[;![;"I"1Receive IP destination address with datagram;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"&Socket::Constants::IP_RECVDSTADDR;F;xI" INTEGER2NUM(IP_RECVDSTADDR);To;u;[[@i;F;:IP_RETOPTS;;w;;;[;{;IC; "+IP options to be included in datagrams ;T;[;![;"I"+IP options to be included in datagrams;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::IP_RETOPTS;F;xI"INTEGER2NUM(IP_RETOPTS);To;u;[[@i;F;:IP_MINTTL;;w;;;[;{;IC; "-Minimum TTL allowed for received packets ;T;[;![;"I"-Minimum TTL allowed for received packets;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"!Socket::Constants::IP_MINTTL;F;xI"INTEGER2NUM(IP_MINTTL);To;u;[[@i;F;:IP_DONTFRAG;;w;;;[;{;IC; "Don't fragment packets ;T;[;![;"I"Don't fragment packets;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::IP_DONTFRAG;F;xI"INTEGER2NUM(IP_DONTFRAG);To;u;[[@i;F;:IP_SENDSRCADDR;;w;;;[;{;IC; ".Source address for outgoing UDP datagrams ;T;[;![;"I".Source address for outgoing UDP datagrams;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"&Socket::Constants::IP_SENDSRCADDR;F;xI" INTEGER2NUM(IP_SENDSRCADDR);To;u;[[@i;F;:IP_ONESBCAST;;w;;;[;{;IC; "PForce outgoing broadcast datagrams to have the undirected broadcast address ;T;[;![;"I"PForce outgoing broadcast datagrams to have the undirected broadcast address;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"$Socket::Constants::IP_ONESBCAST;F;xI"INTEGER2NUM(IP_ONESBCAST);To;u;[[@i;F;:IP_RECVTTL;;w;;;[;{;IC; ""Receive IP TTL with datagrams ;T;[;![;"I""Receive IP TTL with datagrams;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::IP_RECVTTL;F;xI"INTEGER2NUM(IP_RECVTTL);To;u;[[@i;F;:IP_RECVIF;;w;;;[;{;IC; "1Receive interface information with datagrams ;T;[;![;"I"1Receive interface information with datagrams;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"!Socket::Constants::IP_RECVIF;F;xI"INTEGER2NUM(IP_RECVIF);To;u;[[@i;F;:IP_RECVSLLA;;w;;;[;{;IC; ".Receive link-layer address with datagrams ;T;[;![;"I".Receive link-layer address with datagrams;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::IP_RECVSLLA;F;xI"INTEGER2NUM(IP_RECVSLLA);To;u;[[@i;F;:IP_PORTRANGE;;w;;;[;{;IC; "ASet the port range for sockets with unspecified port numbers ;T;[;![;"I"ASet the port range for sockets with unspecified port numbers;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;&I"$Socket::Constants::IP_PORTRANGE;F;xI"INTEGER2NUM(IP_PORTRANGE);To;u;[[@i;F;:IP_MULTICAST_IF;;w;;;[;{;IC; "IP multicast interface ;T;[;![;"I"IP multicast interface;T;#0;$@,;.F;/o;0;1T;2i;3i;%@;&I"'Socket::Constants::IP_MULTICAST_IF;F;xI"!INTEGER2NUM(IP_MULTICAST_IF);To;u;[[@i;F;:IP_MULTICAST_TTL;;w;;;[;{;IC; "IP multicast TTL ;T;[;![;"I"IP multicast TTL;T;#0;$@8;.F;/o;0;1T;2i;3i;%@;&I"(Socket::Constants::IP_MULTICAST_TTL;F;xI""INTEGER2NUM(IP_MULTICAST_TTL);To;u;[[@i;F;:IP_MULTICAST_LOOP;;w;;;[;{;IC; "IP multicast loopback ;T;[;![;"I"IP multicast loopback;T;#0;$@D;.F;/o;0;1T;2i;3i;%@;&I")Socket::Constants::IP_MULTICAST_LOOP;F;xI"#INTEGER2NUM(IP_MULTICAST_LOOP);To;u;[[@i;F;:IP_ADD_MEMBERSHIP;;w;;;[;{;IC; "%Add a multicast group membership ;T;[;![;"I"%Add a multicast group membership;T;#0;$@P;.F;/o;0;1T;2i;3i;%@;&I")Socket::Constants::IP_ADD_MEMBERSHIP;F;xI"#INTEGER2NUM(IP_ADD_MEMBERSHIP);To;u;[[@i;F;:IP_DROP_MEMBERSHIP;;w;;;[;{;IC; "&Drop a multicast group membership ;T;[;![;"I"&Drop a multicast group membership;T;#0;$@\;.F;/o;0;1T;2i;3i;%@;&I"*Socket::Constants::IP_DROP_MEMBERSHIP;F;xI"$INTEGER2NUM(IP_DROP_MEMBERSHIP);To;u;[[@i;F;:IP_DEFAULT_MULTICAST_TTL;;w;;;[;{;IC; "Default multicast TTL ;T;[;![;"I"Default multicast TTL;T;#0;$@h;.F;/o;0;1T;2i;3i;%@;&I"0Socket::Constants::IP_DEFAULT_MULTICAST_TTL;F;xI"*INTEGER2NUM(IP_DEFAULT_MULTICAST_TTL);To;u;[[@i;F;:IP_DEFAULT_MULTICAST_LOOP;;w;;;[;{;IC; "Default multicast loopback ;T;[;![;"I"Default multicast loopback;T;#0;$@t;.F;/o;0;1T;2i;3i;%@;&I"1Socket::Constants::IP_DEFAULT_MULTICAST_LOOP;F;xI"+INTEGER2NUM(IP_DEFAULT_MULTICAST_LOOP);To;u;[[@i;F;:IP_MAX_MEMBERSHIPS;;w;;;[;{;IC; "6Maximum number multicast groups a socket can join ;T;[;![;"I"6Maximum number multicast groups a socket can join;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"*Socket::Constants::IP_MAX_MEMBERSHIPS;F;xI"$INTEGER2NUM(IP_MAX_MEMBERSHIPS);To;u;[[@i ;F;:IP_ROUTER_ALERT;;w;;;[;{;IC; "PNotify transit routers to more closely examine the contents of an IP packet ;T;[;![;"I"PNotify transit routers to more closely examine the contents of an IP packet;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"'Socket::Constants::IP_ROUTER_ALERT;F;xI"!INTEGER2NUM(IP_ROUTER_ALERT);To;u;[[@i;F;:IP_PKTINFO;;w;;;[;{;IC; ".Receive packet information with datagrams ;T;[;![;"I".Receive packet information with datagrams;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::IP_PKTINFO;F;xI"INTEGER2NUM(IP_PKTINFO);To;u;[[@i;F;:IP_PKTOPTIONS;;w;;;[;{;IC; "*Receive packet options with datagrams ;T;[;![;"I"*Receive packet options with datagrams;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"%Socket::Constants::IP_PKTOPTIONS;F;xI"INTEGER2NUM(IP_PKTOPTIONS);To;u;[[@i;F;:IP_MTU_DISCOVER;;w;;;[;{;IC; "Path MTU discovery ;T;[;![;"I"Path MTU discovery;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"'Socket::Constants::IP_MTU_DISCOVER;F;xI"!INTEGER2NUM(IP_MTU_DISCOVER);To;u;[[@i!;F;:IP_RECVERR;;w;;;[;{;IC; "3Enable extended reliable error message passing ;T;[;![;"I"3Enable extended reliable error message passing;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I""Socket::Constants::IP_RECVERR;F;xI"INTEGER2NUM(IP_RECVERR);To;u;[[@i';F;:IP_RECVTOS;;w;;;[;{;IC; "&Receive TOS with incoming packets ;T;[;![;"I"&Receive TOS with incoming packets;T;#0;$@;.F;/o;0;1T;2i&;3i&;%@;&I""Socket::Constants::IP_RECVTOS;F;xI"INTEGER2NUM(IP_RECVTOS);To;u;[[@i-;F;: IP_MTU;;w;;;[;{;IC; "0The Maximum Transmission Unit of the socket ;T;[;![;"I"0The Maximum Transmission Unit of the socket;T;#0;$@;.F;/o;0;1T;2i,;3i,;%@;&I"Socket::Constants::IP_MTU;F;xI"INTEGER2NUM(IP_MTU);To;u;[[@i3;F;:IP_FREEBIND;;w;;;[;{;IC; ".Allow binding to nonexistent IP addresses ;T;[;![;"I".Allow binding to nonexistent IP addresses;T;#0;$@;.F;/o;0;1T;2i2;3i2;%@;&I"#Socket::Constants::IP_FREEBIND;F;xI"INTEGER2NUM(IP_FREEBIND);To;u;[[@i9;F;:IP_IPSEC_POLICY;;w;;;[;{;IC; "IPsec security policy ;T;[;![;"I"IPsec security policy;T;#0;$@;.F;/o;0;1T;2i8;3i8;%@;&I"'Socket::Constants::IP_IPSEC_POLICY;F;xI"!INTEGER2NUM(IP_IPSEC_POLICY);To;u;[[@i?;F;:IP_XFRM_POLICY;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"&Socket::Constants::IP_XFRM_POLICY;F;xI" INTEGER2NUM(IP_XFRM_POLICY);To;u;[[@iE;F;:IP_PASSSEC;;w;;;[;{;IC; ",Retrieve security context with datagram ;T;[;![;"I",Retrieve security context with datagram;T;#0;$@;.F;/o;0;1T;2iD;3iD;%@;&I""Socket::Constants::IP_PASSSEC;F;xI"INTEGER2NUM(IP_PASSSEC);To;u;[[@iK;F;:IP_TRANSPARENT;;w;;;[;{;IC; "Transparent proxy ;T;[;![;"I"Transparent proxy;T;#0;$@;.F;/o;0;1T;2iJ;3iJ;%@;&I"&Socket::Constants::IP_TRANSPARENT;F;xI" INTEGER2NUM(IP_TRANSPARENT);To;u;[[@iQ;F;:IP_PMTUDISC_DONT;;w;;;[;{;IC; "Never send DF frames ;T;[;![;"I"Never send DF frames;T;#0;$@;.F;/o;0;1T;2iP;3iP;%@;&I"(Socket::Constants::IP_PMTUDISC_DONT;F;xI""INTEGER2NUM(IP_PMTUDISC_DONT);To;u;[[@iW;F;:IP_PMTUDISC_WANT;;w;;;[;{;IC; "Use per-route hints ;T;[;![;"I"Use per-route hints;T;#0;$@&;.F;/o;0;1T;2iV;3iV;%@;&I"(Socket::Constants::IP_PMTUDISC_WANT;F;xI""INTEGER2NUM(IP_PMTUDISC_WANT);To;u;[[@i];F;:IP_PMTUDISC_DO;;w;;;[;{;IC; "Always send DF frames ;T;[;![;"I"Always send DF frames;T;#0;$@2;.F;/o;0;1T;2i\;3i\;%@;&I"&Socket::Constants::IP_PMTUDISC_DO;F;xI" INTEGER2NUM(IP_PMTUDISC_DO);To;u;[[@ic;F;:IP_UNBLOCK_SOURCE;;w;;;[;{;IC; ">Unblock IPv4 multicast packets with a give source address ;T;[;![;"I">Unblock IPv4 multicast packets with a give source address;T;#0;$@>;.F;/o;0;1T;2ib;3ib;%@;&I")Socket::Constants::IP_UNBLOCK_SOURCE;F;xI"#INTEGER2NUM(IP_UNBLOCK_SOURCE);To;u;[[@ii;F;:IP_BLOCK_SOURCE;;w;;;[;{;IC; "Receive buffer size without rmem_max limit (Linux 2.6.14) ;T;[;![;"I">Receive buffer size without rmem_max limit (Linux 2.6.14);T;#0;$@^;.F;/o;0;1T;2i;3i;%@;&I"&Socket::Constants::SO_RCVBUFFORCE;F;xI" INTEGER2NUM(SO_RCVBUFFORCE);To;u;[[@i;F;:SO_KEEPALIVE;;w;;;[;{;IC; "Keep connections alive ;T;[;![;"I"Keep connections alive;T;#0;$@j;.F;/o;0;1T;2i;3i;%@;&I"$Socket::Constants::SO_KEEPALIVE;F;xI"INTEGER2NUM(SO_KEEPALIVE);To;u;[[@i;F;:SO_OOBINLINE;;w;;;[;{;IC; ",Leave received out-of-band data in-line ;T;[;![;"I",Leave received out-of-band data in-line;T;#0;$@v;.F;/o;0;1T;2i;3i;%@;&I"$Socket::Constants::SO_OOBINLINE;F;xI"INTEGER2NUM(SO_OOBINLINE);To;u;[[@i;F;:SO_NO_CHECK;;w;;;[;{;IC; "Disable checksums ;T;[;![;"I"Disable checksums;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::SO_NO_CHECK;F;xI"INTEGER2NUM(SO_NO_CHECK);To;u;[[@i ;F;:SO_PRIORITY;;w;;;[;{;IC; "AThe protocol-defined priority for all packets on this socket ;T;[;![;"I"AThe protocol-defined priority for all packets on this socket;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"#Socket::Constants::SO_PRIORITY;F;xI"INTEGER2NUM(SO_PRIORITY);To;u;[[@i;F;:SO_LINGER;;w;;;[;{;IC; "'Linger on close if data is present ;T;[;![;"I"'Linger on close if data is present;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"!Socket::Constants::SO_LINGER;F;xI"INTEGER2NUM(SO_LINGER);To;u;[[@i;F;:SO_PASSCRED;;w;;;[;{;IC; "%Receive SCM_CREDENTIALS messages ;T;[;![;"I"%Receive SCM_CREDENTIALS messages;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::SO_PASSCRED;F;xI"INTEGER2NUM(SO_PASSCRED);To;u;[[@i;F;:SO_PEERCRED;;w;;;[;{;IC; "DThe credentials of the foreign process connected to this socket ;T;[;![;"I"DThe credentials of the foreign process connected to this socket;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::SO_PEERCRED;F;xI"INTEGER2NUM(SO_PEERCRED);To;u;[[@i#;F;:SO_RCVLOWAT;;w;;;[;{;IC; "Receive low-water mark ;T;[;![;"I"Receive low-water mark;T;#0;$@;.F;/o;0;1T;2i";3i";%@;&I"#Socket::Constants::SO_RCVLOWAT;F;xI"INTEGER2NUM(SO_RCVLOWAT);To;u;[[@i);F;:SO_SNDLOWAT;;w;;;[;{;IC; "Send low-water mark ;T;[;![;"I"Send low-water mark;T;#0;$@;.F;/o;0;1T;2i(;3i(;%@;&I"#Socket::Constants::SO_SNDLOWAT;F;xI"INTEGER2NUM(SO_SNDLOWAT);To;u;[[@i/;F;:SO_RCVTIMEO;;w;;;[;{;IC; "Receive timeout ;T;[;![;"I"Receive timeout;T;#0;$@;.F;/o;0;1T;2i.;3i.;%@;&I"#Socket::Constants::SO_RCVTIMEO;F;xI"INTEGER2NUM(SO_RCVTIMEO);To;u;[[@i5;F;:SO_SNDTIMEO;;w;;;[;{;IC; "Send timeout ;T;[;![;"I"Send timeout;T;#0;$@;.F;/o;0;1T;2i4;3i4;%@;&I"#Socket::Constants::SO_SNDTIMEO;F;xI"INTEGER2NUM(SO_SNDTIMEO);To;u;[[@i;;F;:SO_ACCEPTCONN;;w;;;[;{;IC; ")Socket has had listen() called on it ;T;[;![;"I")Socket has had listen() called on it;T;#0;$@;.F;/o;0;1T;2i:;3i:;%@;&I"%Socket::Constants::SO_ACCEPTCONN;F;xI"INTEGER2NUM(SO_ACCEPTCONN);To;u;[[@iA;F;:SO_USELOOPBACK;;w;;;[;{;IC; ""Bypass hardware when possible ;T;[;![;"I""Bypass hardware when possible;T;#0;$@;.F;/o;0;1T;2i@;3i@;%@;&I"&Socket::Constants::SO_USELOOPBACK;F;xI" INTEGER2NUM(SO_USELOOPBACK);To;u;[[@iG;F;:SO_ACCEPTFILTER;;w;;;[;{;IC; "There is an accept filter ;T;[;![;"I"There is an accept filter;T;#0;$@;.F;/o;0;1T;2iF;3iF;%@;&I"'Socket::Constants::SO_ACCEPTFILTER;F;xI"!INTEGER2NUM(SO_ACCEPTFILTER);To;u;[[@iM;F;:SO_DONTTRUNC;;w;;;[;{;IC; "Retain unread data ;T;[;![;"I"Retain unread data;T;#0;$@;.F;/o;0;1T;2iL;3iL;%@;&I"$Socket::Constants::SO_DONTTRUNC;F;xI"INTEGER2NUM(SO_DONTTRUNC);To;u;[[@iS;F;:SO_WANTMORE;;w;;;[;{;IC; "(Give a hint when more data is ready ;T;[;![;"I"(Give a hint when more data is ready;T;#0;$@;.F;/o;0;1T;2iR;3iR;%@;&I"#Socket::Constants::SO_WANTMORE;F;xI"INTEGER2NUM(SO_WANTMORE);To;u;[[@iY;F;:SO_WANTOOBFLAG;;w;;;[;{;IC; ".OOB data is wanted in MSG_FLAG on receive ;T;[;![;"I".OOB data is wanted in MSG_FLAG on receive;T;#0;$@*;.F;/o;0;1T;2iX;3iX;%@;&I"&Socket::Constants::SO_WANTOOBFLAG;F;xI" INTEGER2NUM(SO_WANTOOBFLAG);To;u;[[@i_;F;: SO_NREAD;;w;;;[;{;IC; " Get first packet byte count ;T;[;![;"I" Get first packet byte count;T;#0;$@6;.F;/o;0;1T;2i^;3i^;%@;&I" Socket::Constants::SO_NREAD;F;xI"INTEGER2NUM(SO_NREAD);To;u;[[@ie;F;: SO_NKE;;w;;;[;{;IC; "2Install socket-level Network Kernel Extension ;T;[;![;"I"2Install socket-level Network Kernel Extension;T;#0;$@B;.F;/o;0;1T;2id;3id;%@;&I"Socket::Constants::SO_NKE;F;xI"INTEGER2NUM(SO_NKE);To;u;[[@ik;F;:SO_NOSIGPIPE;;w;;;[;{;IC; "Don't SIGPIPE on EPIPE ;T;[;![;"I"Don't SIGPIPE on EPIPE;T;#0;$@N;.F;/o;0;1T;2ij;3ij;%@;&I"$Socket::Constants::SO_NOSIGPIPE;F;xI"INTEGER2NUM(SO_NOSIGPIPE);To;u;[[@iq;F;:SO_SECURITY_AUTHENTICATION;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@Z;%@;&I"2Socket::Constants::SO_SECURITY_AUTHENTICATION;F;xI",INTEGER2NUM(SO_SECURITY_AUTHENTICATION);To;u;[[@iw;F;:%SO_SECURITY_ENCRYPTION_TRANSPORT;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@d;%@;&I"8Socket::Constants::SO_SECURITY_ENCRYPTION_TRANSPORT;F;xI"2INTEGER2NUM(SO_SECURITY_ENCRYPTION_TRANSPORT);To;u;[[@i};F;:#SO_SECURITY_ENCRYPTION_NETWORK;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@n;%@;&I"6Socket::Constants::SO_SECURITY_ENCRYPTION_NETWORK;F;xI"0INTEGER2NUM(SO_SECURITY_ENCRYPTION_NETWORK);To;u;[[@i;F;:SO_BINDTODEVICE;;w;;;[;{;IC; "/Only send packets from the given interface ;T;[;![;"I"/Only send packets from the given interface;T;#0;$@x;.F;/o;0;1T;2i;3i;%@;&I"'Socket::Constants::SO_BINDTODEVICE;F;xI"!INTEGER2NUM(SO_BINDTODEVICE);To;u;[[@i;F;:SO_ATTACH_FILTER;;w;;;[;{;IC; "Attach an accept filter ;T;[;![;"I"Attach an accept filter;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"(Socket::Constants::SO_ATTACH_FILTER;F;xI""INTEGER2NUM(SO_ATTACH_FILTER);To;u;[[@i;F;:SO_DETACH_FILTER;;w;;;[;{;IC; "Detach an accept filter ;T;[;![;"I"Detach an accept filter;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"(Socket::Constants::SO_DETACH_FILTER;F;xI""INTEGER2NUM(SO_DETACH_FILTER);To;u;[[@i;F;:SO_GET_FILTER;;w;;;[;{;IC; "6Obtain filter set by SO_ATTACH_FILTER (Linux 3.8) ;T;[;![;"I"6Obtain filter set by SO_ATTACH_FILTER (Linux 3.8);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"%Socket::Constants::SO_GET_FILTER;F;xI"INTEGER2NUM(SO_GET_FILTER);To;u;[[@i;F;:SO_PEERNAME;;w;;;[;{;IC; " Name of the connecting user ;T;[;![;"I" Name of the connecting user;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::SO_PEERNAME;F;xI"INTEGER2NUM(SO_PEERNAME);To;u;[[@i;F;:SO_TIMESTAMP;;w;;;[;{;IC; "/Receive timestamp with datagrams (timeval) ;T;[;![;"I"/Receive timestamp with datagrams (timeval);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"$Socket::Constants::SO_TIMESTAMP;F;xI"INTEGER2NUM(SO_TIMESTAMP);To;u;[[@i;F;:SO_TIMESTAMPNS;;w;;;[;{;IC; ";Receive nanosecond timestamp with datagrams (timespec) ;T;[;![;"I";Receive nanosecond timestamp with datagrams (timespec);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"&Socket::Constants::SO_TIMESTAMPNS;F;xI" INTEGER2NUM(SO_TIMESTAMPNS);To;u;[[@i;F;:SO_BINTIME;;w;;;[;{;IC; "/Receive timestamp with datagrams (bintime) ;T;[;![;"I"/Receive timestamp with datagrams (bintime);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::SO_BINTIME;F;xI"INTEGER2NUM(SO_BINTIME);To;u;[[@i;F;:SO_RECVUCRED;;w;;;[;{;IC; "+Receive user credentials with datagram ;T;[;![;"I"+Receive user credentials with datagram;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"$Socket::Constants::SO_RECVUCRED;F;xI"INTEGER2NUM(SO_RECVUCRED);To;u;[[@i;F;:SO_MAC_EXEMPT;;w;;;[;{;IC; ";Mandatory Access Control exemption for unlabeled peers ;T;[;![;"I";Mandatory Access Control exemption for unlabeled peers;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"%Socket::Constants::SO_MAC_EXEMPT;F;xI"INTEGER2NUM(SO_MAC_EXEMPT);To;u;[[@i;F;:SO_ALLZONES;;w;;;[;{;IC; "Bypass zone boundaries ;T;[;![;"I"Bypass zone boundaries;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::SO_ALLZONES;F;xI"INTEGER2NUM(SO_ALLZONES);To;u;[[@i;F;:SO_PEERSEC;;w;;;[;{;IC; "2Obtain the security credentials (Linux 2.6.2) ;T;[;![;"I"2Obtain the security credentials (Linux 2.6.2);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::SO_PEERSEC;F;xI"INTEGER2NUM(SO_PEERSEC);To;u;[[@i;F;:SO_PASSSEC;;w;;;[;{;IC; "3Toggle security context passing (Linux 2.6.18) ;T;[;![;"I"3Toggle security context passing (Linux 2.6.18);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::SO_PASSSEC;F;xI"INTEGER2NUM(SO_PASSSEC);To;u;[[@i;F;: SO_MARK;;w;;;[;{;IC; "7Set the mark for mark-based routing (Linux 2.6.25) ;T;[;![;"I"7Set the mark for mark-based routing (Linux 2.6.25);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::SO_MARK;F;xI"INTEGER2NUM(SO_MARK);To;u;[[@i;F;:SO_TIMESTAMPING;;w;;;[;{;IC; "BTime stamping of incoming and outgoing packets (Linux 2.6.30) ;T;[;![;"I"BTime stamping of incoming and outgoing packets (Linux 2.6.30);T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;&I"'Socket::Constants::SO_TIMESTAMPING;F;xI"!INTEGER2NUM(SO_TIMESTAMPING);To;u;[[@i;F;:SO_PROTOCOL;;w;;;[;{;IC; "/Protocol given for socket() (Linux 2.6.32) ;T;[;![;"I"/Protocol given for socket() (Linux 2.6.32);T;#0;$@,;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::SO_PROTOCOL;F;xI"INTEGER2NUM(SO_PROTOCOL);To;u;[[@i;F;:SO_DOMAIN;;w;;;[;{;IC; "-Domain given for socket() (Linux 2.6.32) ;T;[;![;"I"-Domain given for socket() (Linux 2.6.32);T;#0;$@8;.F;/o;0;1T;2i;3i;%@;&I"!Socket::Constants::SO_DOMAIN;F;xI"INTEGER2NUM(SO_DOMAIN);To;u;[[@i;F;:SO_RXQ_OVFL;;w;;;[;{;IC; "=Toggle cmsg for number of packets dropped (Linux 2.6.33) ;T;[;![;"I"=Toggle cmsg for number of packets dropped (Linux 2.6.33);T;#0;$@D;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::SO_RXQ_OVFL;F;xI"INTEGER2NUM(SO_RXQ_OVFL);To;u;[[@i;F;:SO_WIFI_STATUS;;w;;;[;{;IC; ",Toggle cmsg for wifi status (Linux 3.3) ;T;[;![;"I",Toggle cmsg for wifi status (Linux 3.3);T;#0;$@P;.F;/o;0;1T;2i;3i;%@;&I"&Socket::Constants::SO_WIFI_STATUS;F;xI" INTEGER2NUM(SO_WIFI_STATUS);To;u;[[@i;F;:SO_PEEK_OFF;;w;;;[;{;IC; "$Set the peek offset (Linux 3.4) ;T;[;![;"I"$Set the peek offset (Linux 3.4);T;#0;$@\;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::SO_PEEK_OFF;F;xI"INTEGER2NUM(SO_PEEK_OFF);To;u;[[@i;F;: SO_NOFCS;;w;;;[;{;IC; "&Set netns of a socket (Linux 3.4) ;T;[;![;"I"&Set netns of a socket (Linux 3.4);T;#0;$@h;.F;/o;0;1T;2i;3i;%@;&I" Socket::Constants::SO_NOFCS;F;xI"INTEGER2NUM(SO_NOFCS);To;u;[[@i;F;:SO_LOCK_FILTER;;w;;;[;{;IC; "5Lock the filter attached to a socket (Linux 3.9) ;T;[;![;"I"5Lock the filter attached to a socket (Linux 3.9);T;#0;$@t;.F;/o;0;1T;2i;3i;%@;&I"&Socket::Constants::SO_LOCK_FILTER;F;xI" INTEGER2NUM(SO_LOCK_FILTER);To;u;[[@i;F;:SO_SELECT_ERR_QUEUE;;w;;;[;{;IC; "GMake select() detect socket error queue with errorfds (Linux 3.10) ;T;[;![;"I"GMake select() detect socket error queue with errorfds (Linux 3.10);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"+Socket::Constants::SO_SELECT_ERR_QUEUE;F;xI"%INTEGER2NUM(SO_SELECT_ERR_QUEUE);To;u;[[@i ;F;:SO_BUSY_POLL;;w;;;[;{;IC; "KSet the threshold in microseconds for low latency polling (Linux 3.11) ;T;[;![;"I"KSet the threshold in microseconds for low latency polling (Linux 3.11);T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"$Socket::Constants::SO_BUSY_POLL;F;xI"INTEGER2NUM(SO_BUSY_POLL);To;u;[[@i;F;:SO_MAX_PACING_RATE;;w;;;[;{;IC; "NCap the rate computed by transport layer. [bytes per second] (Linux 3.13) ;T;[;![;"I"NCap the rate computed by transport layer. [bytes per second] (Linux 3.13);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"*Socket::Constants::SO_MAX_PACING_RATE;F;xI"$INTEGER2NUM(SO_MAX_PACING_RATE);To;u;[[@i;F;:SO_BPF_EXTENSIONS;;w;;;[;{;IC; "0Query supported BPF extensions (Linux 3.14) ;T;[;![;"I"0Query supported BPF extensions (Linux 3.14);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I")Socket::Constants::SO_BPF_EXTENSIONS;F;xI"#INTEGER2NUM(SO_BPF_EXTENSIONS);To;u;[[@i;F;:SOPRI_INTERACTIVE;;w;;;[;{;IC; " Interactive socket priority ;T;[;![;"I" Interactive socket priority;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I")Socket::Constants::SOPRI_INTERACTIVE;F;xI"#INTEGER2NUM(SOPRI_INTERACTIVE);To;u;[[@i%;F;:SOPRI_NORMAL;;w;;;[;{;IC; "Normal socket priority ;T;[;![;"I"Normal socket priority;T;#0;$@;.F;/o;0;1T;2i$;3i$;%@;&I"$Socket::Constants::SOPRI_NORMAL;F;xI"INTEGER2NUM(SOPRI_NORMAL);To;u;[[@i+;F;:SOPRI_BACKGROUND;;w;;;[;{;IC; "Background socket priority ;T;[;![;"I"Background socket priority;T;#0;$@;.F;/o;0;1T;2i*;3i*;%@;&I"(Socket::Constants::SOPRI_BACKGROUND;F;xI""INTEGER2NUM(SOPRI_BACKGROUND);To;u;[[@i1;F;: IPX_TYPE;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I" Socket::Constants::IPX_TYPE;F;xI"INTEGER2NUM(IPX_TYPE);To;u;[[@i7;F;:TCP_NODELAY;;w;;;[;{;IC; ",Don't delay sending to coalesce packets ;T;[;![;"I",Don't delay sending to coalesce packets;T;#0;$@;.F;/o;0;1T;2i6;3i6;%@;&I"#Socket::Constants::TCP_NODELAY;F;xI"INTEGER2NUM(TCP_NODELAY);To;u;[[@i=;F;:TCP_MAXSEG;;w;;;[;{;IC; "Set maximum segment size ;T;[;![;"I"Set maximum segment size;T;#0;$@;.F;/o;0;1T;2i<;3i<;%@;&I""Socket::Constants::TCP_MAXSEG;F;xI"INTEGER2NUM(TCP_MAXSEG);To;u;[[@iC;F;: TCP_CORK;;w;;;[;{;IC; "5Don't send partial frames (Linux 2.2, glibc 2.2) ;T;[;![;"I"5Don't send partial frames (Linux 2.2, glibc 2.2);T;#0;$@;.F;/o;0;1T;2iB;3iB;%@;&I" Socket::Constants::TCP_CORK;F;xI"INTEGER2NUM(TCP_CORK);To;u;[[@iI;F;:TCP_DEFER_ACCEPT;;w;;;[;{;IC; "ODon't notify a listening socket until data is ready (Linux 2.4, glibc 2.2) ;T;[;![;"I"ODon't notify a listening socket until data is ready (Linux 2.4, glibc 2.2);T;#0;$@;.F;/o;0;1T;2iH;3iH;%@;&I"(Socket::Constants::TCP_DEFER_ACCEPT;F;xI""INTEGER2NUM(TCP_DEFER_ACCEPT);To;u;[[@iO;F;: TCP_INFO;;w;;;[;{;IC; "BRetrieve information about this socket (Linux 2.4, glibc 2.2) ;T;[;![;"I"BRetrieve information about this socket (Linux 2.4, glibc 2.2);T;#0;$@;.F;/o;0;1T;2iN;3iN;%@;&I" Socket::Constants::TCP_INFO;F;xI"INTEGER2NUM(TCP_INFO);To;u;[[@iU;F;:TCP_KEEPCNT;;w;;;[;{;IC; "cMaximum number of keepalive probes allowed before dropping a connection (Linux 2.4, glibc 2.2) ;T;[;![;"I"cMaximum number of keepalive probes allowed before dropping a connection (Linux 2.4, glibc 2.2);T;#0;$@;.F;/o;0;1T;2iT;3iT;%@;&I"#Socket::Constants::TCP_KEEPCNT;F;xI"INTEGER2NUM(TCP_KEEPCNT);To;u;[[@i[;F;:TCP_KEEPIDLE;;w;;;[;{;IC; "FIdle time before keepalive probes are sent (Linux 2.4, glibc 2.2) ;T;[;![;"I"FIdle time before keepalive probes are sent (Linux 2.4, glibc 2.2);T;#0;$@&;.F;/o;0;1T;2iZ;3iZ;%@;&I"$Socket::Constants::TCP_KEEPIDLE;F;xI"INTEGER2NUM(TCP_KEEPIDLE);To;u;[[@ia;F;:TCP_KEEPINTVL;;w;;;[;{;IC; "9Time between keepalive probes (Linux 2.4, glibc 2.2) ;T;[;![;"I"9Time between keepalive probes (Linux 2.4, glibc 2.2);T;#0;$@2;.F;/o;0;1T;2i`;3i`;%@;&I"%Socket::Constants::TCP_KEEPINTVL;F;xI"INTEGER2NUM(TCP_KEEPINTVL);To;u;[[@ig;F;:TCP_LINGER2;;w;;;[;{;IC; "BLifetime of orphaned FIN_WAIT2 sockets (Linux 2.4, glibc 2.2) ;T;[;![;"I"BLifetime of orphaned FIN_WAIT2 sockets (Linux 2.4, glibc 2.2);T;#0;$@>;.F;/o;0;1T;2if;3if;%@;&I"#Socket::Constants::TCP_LINGER2;F;xI"INTEGER2NUM(TCP_LINGER2);To;u;[[@im;F;:TCP_MD5SIG;;w;;;[;{;IC; "7Use MD5 digests (RFC2385, Linux 2.6.20, glibc 2.7) ;T;[;![;"I"7Use MD5 digests (RFC2385, Linux 2.6.20, glibc 2.7);T;#0;$@J;.F;/o;0;1T;2il;3il;%@;&I""Socket::Constants::TCP_MD5SIG;F;xI"INTEGER2NUM(TCP_MD5SIG);To;u;[[@is;F;:TCP_NOOPT;;w;;;[;{;IC; "Don't use TCP options ;T;[;![;"I"Don't use TCP options;T;#0;$@V;.F;/o;0;1T;2ir;3ir;%@;&I"!Socket::Constants::TCP_NOOPT;F;xI"INTEGER2NUM(TCP_NOOPT);To;u;[[@iy;F;:TCP_NOPUSH;;w;;;[;{;IC; "'Don't push the last block of write ;T;[;![;"I"'Don't push the last block of write;T;#0;$@b;.F;/o;0;1T;2ix;3ix;%@;&I""Socket::Constants::TCP_NOPUSH;F;xI"INTEGER2NUM(TCP_NOPUSH);To;u;[[@i;F;:TCP_QUICKACK;;w;;;[;{;IC; "2Enable quickack mode (Linux 2.4.4, glibc 2.3) ;T;[;![;"I"2Enable quickack mode (Linux 2.4.4, glibc 2.3);T;#0;$@n;.F;/o;0;1T;2i~;3i~;%@;&I"$Socket::Constants::TCP_QUICKACK;F;xI"INTEGER2NUM(TCP_QUICKACK);To;u;[[@i;F;:TCP_SYNCNT;;w;;;[;{;IC; "TNumber of SYN retransmits before a connection is dropped (Linux 2.4, glibc 2.2) ;T;[;![;"I"TNumber of SYN retransmits before a connection is dropped (Linux 2.4, glibc 2.2);T;#0;$@z;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::TCP_SYNCNT;F;xI"INTEGER2NUM(TCP_SYNCNT);To;u;[[@i;F;:TCP_WINDOW_CLAMP;;w;;;[;{;IC; "CClamp the size of the advertised window (Linux 2.4, glibc 2.2) ;T;[;![;"I"CClamp the size of the advertised window (Linux 2.4, glibc 2.2);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"(Socket::Constants::TCP_WINDOW_CLAMP;F;xI""INTEGER2NUM(TCP_WINDOW_CLAMP);To;u;[[@i;F;:TCP_FASTOPEN;;w;;;[;{;IC; "AReduce step of the handshake process (Linux 3.7, glibc 2.18) ;T;[;![;"I"AReduce step of the handshake process (Linux 3.7, glibc 2.18);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"$Socket::Constants::TCP_FASTOPEN;F;xI"INTEGER2NUM(TCP_FASTOPEN);To;u;[[@i;F;:TCP_CONGESTION;;w;;;[;{;IC; "?TCP congestion control algorithm (Linux 2.6.13, glibc 2.6) ;T;[;![;"I"?TCP congestion control algorithm (Linux 2.6.13, glibc 2.6);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"&Socket::Constants::TCP_CONGESTION;F;xI" INTEGER2NUM(TCP_CONGESTION);To;u;[[@i;F;:TCP_COOKIE_TRANSACTIONS;;w;;;[;{;IC; "7TCP Cookie Transactions (Linux 2.6.33, glibc 2.18) ;T;[;![;"I"7TCP Cookie Transactions (Linux 2.6.33, glibc 2.18);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"/Socket::Constants::TCP_COOKIE_TRANSACTIONS;F;xI")INTEGER2NUM(TCP_COOKIE_TRANSACTIONS);To;u;[[@i;F;:TCP_QUEUE_SEQ;;w;;;[;{;IC; "@Sequence of a queue for repair mode (Linux 3.5, glibc 2.18) ;T;[;![;"I"@Sequence of a queue for repair mode (Linux 3.5, glibc 2.18);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"%Socket::Constants::TCP_QUEUE_SEQ;F;xI"INTEGER2NUM(TCP_QUEUE_SEQ);To;u;[[@i;F;:TCP_REPAIR;;w;;;[;{;IC; "(Repair mode (Linux 3.5, glibc 2.18) ;T;[;![;"I"(Repair mode (Linux 3.5, glibc 2.18);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::TCP_REPAIR;F;xI"INTEGER2NUM(TCP_REPAIR);To;u;[[@i;F;:TCP_REPAIR_OPTIONS;;w;;;[;{;IC; "4Options for repair mode (Linux 3.5, glibc 2.18) ;T;[;![;"I"4Options for repair mode (Linux 3.5, glibc 2.18);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"*Socket::Constants::TCP_REPAIR_OPTIONS;F;xI"$INTEGER2NUM(TCP_REPAIR_OPTIONS);To;u;[[@i;F;:TCP_REPAIR_QUEUE;;w;;;[;{;IC; "2Queue for repair mode (Linux 3.5, glibc 2.18) ;T;[;![;"I"2Queue for repair mode (Linux 3.5, glibc 2.18);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"(Socket::Constants::TCP_REPAIR_QUEUE;F;xI""INTEGER2NUM(TCP_REPAIR_QUEUE);To;u;[[@i;F;:TCP_THIN_DUPACK;;w;;;[;{;IC; "TDuplicated acknowledgments handling for thin-streams (Linux 2.6.34, glibc 2.18) ;T;[;![;"I"TDuplicated acknowledgments handling for thin-streams (Linux 2.6.34, glibc 2.18);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"'Socket::Constants::TCP_THIN_DUPACK;F;xI"!INTEGER2NUM(TCP_THIN_DUPACK);To;u;[[@i;F;:TCP_THIN_LINEAR_TIMEOUTS;;w;;;[;{;IC; "@Linear timeouts for thin-streams (Linux 2.6.34, glibc 2.18) ;T;[;![;"I"@Linear timeouts for thin-streams (Linux 2.6.34, glibc 2.18);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"0Socket::Constants::TCP_THIN_LINEAR_TIMEOUTS;F;xI"*INTEGER2NUM(TCP_THIN_LINEAR_TIMEOUTS);To;u;[[@i;F;:TCP_TIMESTAMP;;w;;;[;{;IC; "*TCP timestamp (Linux 3.9, glibc 2.18) ;T;[;![;"I"*TCP timestamp (Linux 3.9, glibc 2.18);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"%Socket::Constants::TCP_TIMESTAMP;F;xI"INTEGER2NUM(TCP_TIMESTAMP);To;u;[[@i;F;:TCP_USER_TIMEOUT;;w;;;[;{;IC; "NMax timeout before a TCP connection is aborted (Linux 2.6.37, glibc 2.18) ;T;[;![;"I"NMax timeout before a TCP connection is aborted (Linux 2.6.37, glibc 2.18);T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;&I"(Socket::Constants::TCP_USER_TIMEOUT;F;xI""INTEGER2NUM(TCP_USER_TIMEOUT);To;u;[[@i;F;: UDP_CORK;;w;;;[;{;IC; "9Don't send partial frames (Linux 2.5.44, glibc 2.11) ;T;[;![;"I"9Don't send partial frames (Linux 2.5.44, glibc 2.11);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I" Socket::Constants::UDP_CORK;F;xI"INTEGER2NUM(UDP_CORK);To;u;[[@i;F;:EAI_ADDRFAMILY;;w;;;[;{;IC; ".Address family for hostname not supported ;T;[;![;"I".Address family for hostname not supported;T;#0;$@";.F;/o;0;1T;2i;3i;%@;&I"&Socket::Constants::EAI_ADDRFAMILY;F;xI" INTEGER2NUM(EAI_ADDRFAMILY);To;u;[[@i;F;:EAI_AGAIN;;w;;;[;{;IC; ")Temporary failure in name resolution ;T;[;![;"I")Temporary failure in name resolution;T;#0;$@.;.F;/o;0;1T;2i;3i;%@;&I"!Socket::Constants::EAI_AGAIN;F;xI"INTEGER2NUM(EAI_AGAIN);To;u;[[@i;F;:EAI_BADFLAGS;;w;;;[;{;IC; "Invalid flags ;T;[;![;"I"Invalid flags;T;#0;$@:;.F;/o;0;1T;2i;3i;%@;&I"$Socket::Constants::EAI_BADFLAGS;F;xI"INTEGER2NUM(EAI_BADFLAGS);To;u;[[@i;F;: EAI_FAIL;;w;;;[;{;IC; "/Non-recoverable failure in name resolution ;T;[;![;"I"/Non-recoverable failure in name resolution;T;#0;$@F;.F;/o;0;1T;2i;3i;%@;&I" Socket::Constants::EAI_FAIL;F;xI"INTEGER2NUM(EAI_FAIL);To;u;[[@i;F;:EAI_FAMILY;;w;;;[;{;IC; "!Address family not supported ;T;[;![;"I"!Address family not supported;T;#0;$@R;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::EAI_FAMILY;F;xI"INTEGER2NUM(EAI_FAMILY);To;u;[[@i;F;:EAI_MEMORY;;w;;;[;{;IC; "Memory allocation failure ;T;[;![;"I"Memory allocation failure;T;#0;$@^;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::EAI_MEMORY;F;xI"INTEGER2NUM(EAI_MEMORY);To;u;[[@i;F;:EAI_NODATA;;w;;;[;{;IC; "(No address associated with hostname ;T;[;![;"I"(No address associated with hostname;T;#0;$@j;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::EAI_NODATA;F;xI"INTEGER2NUM(EAI_NODATA);To;u;[[@i;F;:EAI_NONAME;;w;;;[;{;IC; "(Hostname nor servname, or not known ;T;[;![;"I"(Hostname nor servname, or not known;T;#0;$@v;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::EAI_NONAME;F;xI"INTEGER2NUM(EAI_NONAME);To;u;[[@i ;F;:EAI_OVERFLOW;;w;;;[;{;IC; "Argument buffer overflow ;T;[;![;"I"Argument buffer overflow;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"$Socket::Constants::EAI_OVERFLOW;F;xI"INTEGER2NUM(EAI_OVERFLOW);To;u;[[@i;F;:EAI_SERVICE;;w;;;[;{;IC; "+Servname not supported for socket type ;T;[;![;"I"+Servname not supported for socket type;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::EAI_SERVICE;F;xI"INTEGER2NUM(EAI_SERVICE);To;u;[[@i;F;:EAI_SOCKTYPE;;w;;;[;{;IC; "Socket type not supported ;T;[;![;"I"Socket type not supported;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"$Socket::Constants::EAI_SOCKTYPE;F;xI"INTEGER2NUM(EAI_SOCKTYPE);To;u;[[@i;F;:EAI_SYSTEM;;w;;;[;{;IC; "#System error returned in errno ;T;[;![;"I"#System error returned in errno;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I""Socket::Constants::EAI_SYSTEM;F;xI"INTEGER2NUM(EAI_SYSTEM);To;u;[[@i!;F;:EAI_BADHINTS;;w;;;[;{;IC; "Invalid value for hints ;T;[;![;"I"Invalid value for hints;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"$Socket::Constants::EAI_BADHINTS;F;xI"INTEGER2NUM(EAI_BADHINTS);To;u;[[@i';F;:EAI_PROTOCOL;;w;;;[;{;IC; "!Resolved protocol is unknown ;T;[;![;"I"!Resolved protocol is unknown;T;#0;$@;.F;/o;0;1T;2i&;3i&;%@;&I"$Socket::Constants::EAI_PROTOCOL;F;xI"INTEGER2NUM(EAI_PROTOCOL);To;u;[[@i-;F;: EAI_MAX;;w;;;[;{;IC; "(Maximum error code from getaddrinfo ;T;[;![;"I"(Maximum error code from getaddrinfo;T;#0;$@;.F;/o;0;1T;2i,;3i,;%@;&I"Socket::Constants::EAI_MAX;F;xI"INTEGER2NUM(EAI_MAX);To;u;[[@i3;F;:AI_PASSIVE;;w;;;[;{;IC; "#Get address to use with bind() ;T;[;![;"I"#Get address to use with bind();T;#0;$@;.F;/o;0;1T;2i2;3i2;%@;&I""Socket::Constants::AI_PASSIVE;F;xI"INTEGER2NUM(AI_PASSIVE);To;u;[[@i9;F;:AI_CANONNAME;;w;;;[;{;IC; "Fill in the canonical name ;T;[;![;"I"Fill in the canonical name;T;#0;$@;.F;/o;0;1T;2i8;3i8;%@;&I"$Socket::Constants::AI_CANONNAME;F;xI"INTEGER2NUM(AI_CANONNAME);To;u;[[@i?;F;:AI_NUMERICHOST;;w;;;[;{;IC; "!Prevent host name resolution ;T;[;![;"I"!Prevent host name resolution;T;#0;$@;.F;/o;0;1T;2i>;3i>;%@;&I"&Socket::Constants::AI_NUMERICHOST;F;xI" INTEGER2NUM(AI_NUMERICHOST);To;u;[[@iE;F;:AI_NUMERICSERV;;w;;;[;{;IC; "$Prevent service name resolution ;T;[;![;"I"$Prevent service name resolution;T;#0;$@;.F;/o;0;1T;2iD;3iD;%@;&I"&Socket::Constants::AI_NUMERICSERV;F;xI" INTEGER2NUM(AI_NUMERICSERV);To;u;[[@iK;F;: AI_MASK;;w;;;[;{;IC; ">Valid flag mask for getaddrinfo (not for application use) ;T;[;![;"I">Valid flag mask for getaddrinfo (not for application use);T;#0;$@;.F;/o;0;1T;2iJ;3iJ;%@;&I"Socket::Constants::AI_MASK;F;xI"INTEGER2NUM(AI_MASK);To;u;[[@iQ;F;: AI_ALL;;w;;;[;{;IC; "Allow all addresses ;T;[;![;"I"Allow all addresses;T;#0;$@;.F;/o;0;1T;2iP;3iP;%@;&I"Socket::Constants::AI_ALL;F;xI"INTEGER2NUM(AI_ALL);To;u;[[@iW;F;:AI_V4MAPPED_CFG;;w;;;[;{;IC; ";Accept IPv4 mapped addresses if the kernel supports it ;T;[;![;"I";Accept IPv4 mapped addresses if the kernel supports it;T;#0;$@;.F;/o;0;1T;2iV;3iV;%@;&I"'Socket::Constants::AI_V4MAPPED_CFG;F;xI"!INTEGER2NUM(AI_V4MAPPED_CFG);To;u;[[@i];F;:AI_ADDRCONFIG;;w;;;[;{;IC; "+Accept only if any address is assigned ;T;[;![;"I"+Accept only if any address is assigned;T;#0;$@*;.F;/o;0;1T;2i\;3i\;%@;&I"%Socket::Constants::AI_ADDRCONFIG;F;xI"INTEGER2NUM(AI_ADDRCONFIG);To;u;[[@ic;F;:AI_V4MAPPED;;w;;;[;{;IC; "&Accept IPv4-mapped IPv6 addresses ;T;[;![;"I"&Accept IPv4-mapped IPv6 addresses;T;#0;$@6;.F;/o;0;1T;2ib;3ib;%@;&I"#Socket::Constants::AI_V4MAPPED;F;xI"INTEGER2NUM(AI_V4MAPPED);To;u;[[@ii;F;:AI_DEFAULT;;w;;;[;{;IC; ""Default flags for getaddrinfo ;T;[;![;"I""Default flags for getaddrinfo;T;#0;$@B;.F;/o;0;1T;2ih;3ih;%@;&I""Socket::Constants::AI_DEFAULT;F;xI"INTEGER2NUM(AI_DEFAULT);To;u;[[@io;F;:NI_MAXHOST;;w;;;[;{;IC; "!Maximum length of a hostname ;T;[;![;"I"!Maximum length of a hostname;T;#0;$@N;.F;/o;0;1T;2in;3in;%@;&I""Socket::Constants::NI_MAXHOST;F;xI"INTEGER2NUM(NI_MAXHOST);To;u;[[@iu;F;:NI_MAXSERV;;w;;;[;{;IC; "%Maximum length of a service name ;T;[;![;"I"%Maximum length of a service name;T;#0;$@Z;.F;/o;0;1T;2it;3it;%@;&I""Socket::Constants::NI_MAXSERV;F;xI"INTEGER2NUM(NI_MAXSERV);To;u;[[@i{;F;:NI_NOFQDN;;w;;;[;{;IC; "HAn FQDN is not required for local hosts, return only the local part ;T;[;![;"I"HAn FQDN is not required for local hosts, return only the local part;T;#0;$@f;.F;/o;0;1T;2iz;3iz;%@;&I"!Socket::Constants::NI_NOFQDN;F;xI"INTEGER2NUM(NI_NOFQDN);To;u;[[@i;F;:NI_NUMERICHOST;;w;;;[;{;IC; "Return a numeric address ;T;[;![;"I"Return a numeric address;T;#0;$@r;.F;/o;0;1T;2i;3i;%@;&I"&Socket::Constants::NI_NUMERICHOST;F;xI" INTEGER2NUM(NI_NUMERICHOST);To;u;[[@i;F;:NI_NAMEREQD;;w;;;[;{;IC; "A name is required ;T;[;![;"I"A name is required;T;#0;$@~;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::NI_NAMEREQD;F;xI"INTEGER2NUM(NI_NAMEREQD);To;u;[[@i;F;:NI_NUMERICSERV;;w;;;[;{;IC; ".Return the service name as a digit string ;T;[;![;"I".Return the service name as a digit string;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"&Socket::Constants::NI_NUMERICSERV;F;xI" INTEGER2NUM(NI_NUMERICSERV);To;u;[[@i;F;: NI_DGRAM;;w;;;[;{;IC; "EThe service specified is a datagram service (looks up UDP ports) ;T;[;![;"I"EThe service specified is a datagram service (looks up UDP ports);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I" Socket::Constants::NI_DGRAM;F;xI"INTEGER2NUM(NI_DGRAM);To;u;[[@i;F;: SHUT_RD;;w;;;[;{;IC; "-Shut down the reading side of the socket ;T;[;![;"I"-Shut down the reading side of the socket;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::SHUT_RD;F;xI"INTEGER2NUM(SHUT_RD);To;u;[[@i;F;: SHUT_WR;;w;;;[;{;IC; "-Shut down the writing side of the socket ;T;[;![;"I"-Shut down the writing side of the socket;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::Constants::SHUT_WR;F;xI"INTEGER2NUM(SHUT_WR);To;u;[[@i;F;:SHUT_RDWR;;w;;;[;{;IC; "+Shut down the both sides of the socket ;T;[;![;"I"+Shut down the both sides of the socket;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"!Socket::Constants::SHUT_RDWR;F;xI"INTEGER2NUM(SHUT_RDWR);To;u;[[@i;F;:IPV6_JOIN_GROUP;;w;;;[;{;IC; "Join a group membership ;T;[;![;"I"Join a group membership;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"'Socket::Constants::IPV6_JOIN_GROUP;F;xI"!INTEGER2NUM(IPV6_JOIN_GROUP);To;u;[[@i;F;:IPV6_LEAVE_GROUP;;w;;;[;{;IC; "Leave a group membership ;T;[;![;"I"Leave a group membership;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"(Socket::Constants::IPV6_LEAVE_GROUP;F;xI""INTEGER2NUM(IPV6_LEAVE_GROUP);To;u;[[@i;F;:IPV6_MULTICAST_HOPS;;w;;;[;{;IC; "IP6 multicast hops ;T;[;![;"I"IP6 multicast hops;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"+Socket::Constants::IPV6_MULTICAST_HOPS;F;xI"%INTEGER2NUM(IPV6_MULTICAST_HOPS);To;u;[[@i;F;:IPV6_MULTICAST_IF;;w;;;[;{;IC; "IP6 multicast interface ;T;[;![;"I"IP6 multicast interface;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I")Socket::Constants::IPV6_MULTICAST_IF;F;xI"#INTEGER2NUM(IPV6_MULTICAST_IF);To;u;[[@i;F;:IPV6_MULTICAST_LOOP;;w;;;[;{;IC; "IP6 multicast loopback ;T;[;![;"I"IP6 multicast loopback;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"+Socket::Constants::IPV6_MULTICAST_LOOP;F;xI"%INTEGER2NUM(IPV6_MULTICAST_LOOP);To;u;[[@i;F;:IPV6_UNICAST_HOPS;;w;;;[;{;IC; "IP6 unicast hops ;T;[;![;"I"IP6 unicast hops;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I")Socket::Constants::IPV6_UNICAST_HOPS;F;xI"#INTEGER2NUM(IPV6_UNICAST_HOPS);To;u;[[@i;F;:IPV6_V6ONLY;;w;;;[;{;IC; "(Only bind IPv6 with a wildcard bind ;T;[;![;"I"(Only bind IPv6 with a wildcard bind;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"#Socket::Constants::IPV6_V6ONLY;F;xI"INTEGER2NUM(IPV6_V6ONLY);To;u;[[@i;F;:IPV6_CHECKSUM;;w;;;[;{;IC; "$Checksum offset for raw sockets ;T;[;![;"I"$Checksum offset for raw sockets;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"%Socket::Constants::IPV6_CHECKSUM;F;xI"INTEGER2NUM(IPV6_CHECKSUM);To;u;[[@i;F;:IPV6_DONTFRAG;;w;;;[;{;IC; "Don't fragment packets ;T;[;![;"I"Don't fragment packets;T;#0;$@&;.F;/o;0;1T;2i;3i;%@;&I"%Socket::Constants::IPV6_DONTFRAG;F;xI"INTEGER2NUM(IPV6_DONTFRAG);To;u;[[@i;F;:IPV6_DSTOPTS;;w;;;[;{;IC; "Destination option ;T;[;![;"I"Destination option;T;#0;$@2;.F;/o;0;1T;2i;3i;%@;&I"$Socket::Constants::IPV6_DSTOPTS;F;xI"INTEGER2NUM(IPV6_DSTOPTS);To;u;[[@i;F;:IPV6_HOPLIMIT;;w;;;[;{;IC; "Hop limit ;T;[;![;"I"Hop limit;T;#0;$@>;.F;/o;0;1T;2i;3i;%@;&I"%Socket::Constants::IPV6_HOPLIMIT;F;xI"INTEGER2NUM(IPV6_HOPLIMIT);To;u;[[@i ;F;:IPV6_HOPOPTS;;w;;;[;{;IC; "Hop-by-hop option ;T;[;![;"I"Hop-by-hop option;T;#0;$@J;.F;/o;0;1T;2i ;3i ;%@;&I"$Socket::Constants::IPV6_HOPOPTS;F;xI"INTEGER2NUM(IPV6_HOPOPTS);To;u;[[@i ;F;:IPV6_NEXTHOP;;w;;;[;{;IC; "Next hop address ;T;[;![;"I"Next hop address;T;#0;$@V;.F;/o;0;1T;2i ;3i ;%@;&I"$Socket::Constants::IPV6_NEXTHOP;F;xI"INTEGER2NUM(IPV6_NEXTHOP);To;u;[[@i ;F;:IPV6_PATHMTU;;w;;;[;{;IC; "Retrieve current path MTU ;T;[;![;"I"Retrieve current path MTU;T;#0;$@b;.F;/o;0;1T;2i ;3i ;%@;&I"$Socket::Constants::IPV6_PATHMTU;F;xI"INTEGER2NUM(IPV6_PATHMTU);To;u;[[@i ;F;:IPV6_PKTINFO;;w;;;[;{;IC; "-Receive packet information with datagram ;T;[;![;"I"-Receive packet information with datagram;T;#0;$@n;.F;/o;0;1T;2i ;3i ;%@;&I"$Socket::Constants::IPV6_PKTINFO;F;xI"INTEGER2NUM(IPV6_PKTINFO);To;u;[[@i$ ;F;:IPV6_RECVDSTOPTS;;w;;;[;{;IC; ")Receive all IP6 options for response ;T;[;![;"I")Receive all IP6 options for response;T;#0;$@z;.F;/o;0;1T;2i# ;3i# ;%@;&I"(Socket::Constants::IPV6_RECVDSTOPTS;F;xI""INTEGER2NUM(IPV6_RECVDSTOPTS);To;u;[[@i, ;F;:IPV6_RECVHOPLIMIT;;w;;;[;{;IC; "$Receive hop limit with datagram ;T;[;![;"I"$Receive hop limit with datagram;T;#0;$@;.F;/o;0;1T;2i+ ;3i+ ;%@;&I")Socket::Constants::IPV6_RECVHOPLIMIT;F;xI"#INTEGER2NUM(IPV6_RECVHOPLIMIT);To;u;[[@i4 ;F;:IPV6_RECVHOPOPTS;;w;;;[;{;IC; "Receive hop-by-hop options ;T;[;![;"I"Receive hop-by-hop options;T;#0;$@;.F;/o;0;1T;2i3 ;3i3 ;%@;&I"(Socket::Constants::IPV6_RECVHOPOPTS;F;xI""INTEGER2NUM(IPV6_RECVHOPOPTS);To;u;[[@i< ;F;:IPV6_RECVPKTINFO;;w;;;[;{;IC; ":Receive destination IP address and incoming interface ;T;[;![;"I":Receive destination IP address and incoming interface;T;#0;$@;.F;/o;0;1T;2i; ;3i; ;%@;&I"(Socket::Constants::IPV6_RECVPKTINFO;F;xI""INTEGER2NUM(IPV6_RECVPKTINFO);To;u;[[@iD ;F;:IPV6_RECVRTHDR;;w;;;[;{;IC; "Receive routing header ;T;[;![;"I"Receive routing header;T;#0;$@;.F;/o;0;1T;2iC ;3iC ;%@;&I"&Socket::Constants::IPV6_RECVRTHDR;F;xI" INTEGER2NUM(IPV6_RECVRTHDR);To;u;[[@iL ;F;:IPV6_RECVTCLASS;;w;;;[;{;IC; "Receive traffic class ;T;[;![;"I"Receive traffic class;T;#0;$@;.F;/o;0;1T;2iK ;3iK ;%@;&I"'Socket::Constants::IPV6_RECVTCLASS;F;xI"!INTEGER2NUM(IPV6_RECVTCLASS);To;u;[[@iT ;F;:IPV6_RTHDR;;w;;;[;{;IC; "-Allows removal of sticky routing headers ;T;[;![;"I"-Allows removal of sticky routing headers;T;#0;$@;.F;/o;0;1T;2iS ;3iS ;%@;&I""Socket::Constants::IPV6_RTHDR;F;xI"INTEGER2NUM(IPV6_RTHDR);To;u;[[@i\ ;F;:IPV6_RTHDRDSTOPTS;;w;;;[;{;IC; "8Allows removal of sticky destination options header ;T;[;![;"I"8Allows removal of sticky destination options header;T;#0;$@;.F;/o;0;1T;2i[ ;3i[ ;%@;&I")Socket::Constants::IPV6_RTHDRDSTOPTS;F;xI"#INTEGER2NUM(IPV6_RTHDRDSTOPTS);To;u;[[@id ;F;:IPV6_RTHDR_TYPE_0;;w;;;[;{;IC; "Routing header type 0 ;T;[;![;"I"Routing header type 0;T;#0;$@;.F;/o;0;1T;2ic ;3ic ;%@;&I")Socket::Constants::IPV6_RTHDR_TYPE_0;F;xI"#INTEGER2NUM(IPV6_RTHDR_TYPE_0);To;u;[[@il ;F;:IPV6_RECVPATHMTU;;w;;;[;{;IC; "+Receive current path MTU with datagram ;T;[;![;"I"+Receive current path MTU with datagram;T;#0;$@;.F;/o;0;1T;2ik ;3ik ;%@;&I"(Socket::Constants::IPV6_RECVPATHMTU;F;xI""INTEGER2NUM(IPV6_RECVPATHMTU);To;u;[[@it ;F;:IPV6_TCLASS;;w;;;[;{;IC; "Specify the traffic class ;T;[;![;"I"Specify the traffic class;T;#0;$@;.F;/o;0;1T;2is ;3is ;%@;&I"#Socket::Constants::IPV6_TCLASS;F;xI"INTEGER2NUM(IPV6_TCLASS);To;u;[[@i| ;F;:IPV6_USE_MIN_MTU;;w;;;[;{;IC; "Use the minimum MTU size ;T;[;![;"I"Use the minimum MTU size;T;#0;$@;.F;/o;0;1T;2i{ ;3i{ ;%@;&I"(Socket::Constants::IPV6_USE_MIN_MTU;F;xI""INTEGER2NUM(IPV6_USE_MIN_MTU);To;u;[[@i ;F;:INET_ADDRSTRLEN;;w;;;[;{;IC; "-Maximum length of an IPv4 address string ;T;[;![;"I"-Maximum length of an IPv4 address string;T;#0;$@ ;.F;/o;0;1T;2i ;3i ;%@;&I"'Socket::Constants::INET_ADDRSTRLEN;F;xI"!INTEGER2NUM(INET_ADDRSTRLEN);To;u;[[@i ;F;:INET6_ADDRSTRLEN;;w;;;[;{;IC; "-Maximum length of an IPv6 address string ;T;[;![;"I"-Maximum length of an IPv6 address string;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"(Socket::Constants::INET6_ADDRSTRLEN;F;xI""INTEGER2NUM(INET6_ADDRSTRLEN);To;u;[[@i ;F;: IFNAMSIZ;;w;;;[;{;IC; " Maximum interface name size ;T;[;![;"I" Maximum interface name size;T;#0;$@";.F;/o;0;1T;2i ;3i ;%@;&I" Socket::Constants::IFNAMSIZ;F;xI"INTEGER2NUM(IFNAMSIZ);To;u;[[@i ;F;:IF_NAMESIZE;;w;;;[;{;IC; " Maximum interface name size ;T;[;![;"I" Maximum interface name size;T;#0;$@.;.F;/o;0;1T;2i ;3i ;%@;&I"#Socket::Constants::IF_NAMESIZE;F;xI"INTEGER2NUM(IF_NAMESIZE);To;u;[[@i ;F;:SOMAXCONN;;w;;;[;{;IC; "@Maximum connection requests that may be queued for a socket ;T;[;![;"I"@Maximum connection requests that may be queued for a socket;T;#0;$@:;.F;/o;0;1T;2i ;3i ;%@;&I"!Socket::Constants::SOMAXCONN;F;xI"INTEGER2NUM(SOMAXCONN);To;u;[[@i ;F;:SCM_RIGHTS;;w;;;[;{;IC; "Access rights ;T;[;![;"I"Access rights;T;#0;$@F;.F;/o;0;1T;2i ;3i ;%@;&I""Socket::Constants::SCM_RIGHTS;F;xI"INTEGER2NUM(SCM_RIGHTS);To;u;[[@i ;F;:SCM_TIMESTAMP;;w;;;[;{;IC; "Timestamp (timeval) ;T;[;![;"I"Timestamp (timeval);T;#0;$@R;.F;/o;0;1T;2i ;3i ;%@;&I"%Socket::Constants::SCM_TIMESTAMP;F;xI"INTEGER2NUM(SCM_TIMESTAMP);To;u;[[@i ;F;:SCM_TIMESTAMPNS;;w;;;[;{;IC; "Timespec (timespec) ;T;[;![;"I"Timespec (timespec);T;#0;$@^;.F;/o;0;1T;2i ;3i ;%@;&I"'Socket::Constants::SCM_TIMESTAMPNS;F;xI"!INTEGER2NUM(SCM_TIMESTAMPNS);To;u;[[@i ;F;:SCM_TIMESTAMPING;;w;;;[;{;IC; "-Timestamp (timespec list) (Linux 2.6.30) ;T;[;![;"I"-Timestamp (timespec list) (Linux 2.6.30);T;#0;$@j;.F;/o;0;1T;2i ;3i ;%@;&I"(Socket::Constants::SCM_TIMESTAMPING;F;xI""INTEGER2NUM(SCM_TIMESTAMPING);To;u;[[@i ;F;:SCM_BINTIME;;w;;;[;{;IC; "Timestamp (bintime) ;T;[;![;"I"Timestamp (bintime);T;#0;$@v;.F;/o;0;1T;2i ;3i ;%@;&I"#Socket::Constants::SCM_BINTIME;F;xI"INTEGER2NUM(SCM_BINTIME);To;u;[[@i ;F;:SCM_CREDENTIALS;;w;;;[;{;IC; "The sender's credentials ;T;[;![;"I"The sender's credentials;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"'Socket::Constants::SCM_CREDENTIALS;F;xI"!INTEGER2NUM(SCM_CREDENTIALS);To;u;[[@i ;F;:SCM_CREDS;;w;;;[;{;IC; "Process credentials ;T;[;![;"I"Process credentials;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"!Socket::Constants::SCM_CREDS;F;xI"INTEGER2NUM(SCM_CREDS);To;u;[[@i ;F;:SCM_UCRED;;w;;;[;{;IC; "User credentials ;T;[;![;"I"User credentials;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"!Socket::Constants::SCM_UCRED;F;xI"INTEGER2NUM(SCM_UCRED);To;u;[[@i ;F;:SCM_WIFI_STATUS;;w;;;[;{;IC; "Wifi status (Linux 3.3) ;T;[;![;"I"Wifi status (Linux 3.3);T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"'Socket::Constants::SCM_WIFI_STATUS;F;xI"!INTEGER2NUM(SCM_WIFI_STATUS);To;u;[[@i ;F;:LOCAL_PEERCRED;;w;;;[;{;IC; "Retrieve peer credentials ;T;[;![;"I"Retrieve peer credentials;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"&Socket::Constants::LOCAL_PEERCRED;F;xI" INTEGER2NUM(LOCAL_PEERCRED);To;u;[[@i ;F;:LOCAL_CREDS;;w;;;[;{;IC; "!Pass credentials to receiver ;T;[;![;"I"!Pass credentials to receiver;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"#Socket::Constants::LOCAL_CREDS;F;xI"INTEGER2NUM(LOCAL_CREDS);To;u;[[@i ;F;:LOCAL_CONNWAIT;;w;;;[;{;IC; ""Connect blocks until accepted ;T;[;![;"I""Connect blocks until accepted;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"&Socket::Constants::LOCAL_CONNWAIT;F;xI" INTEGER2NUM(LOCAL_CONNWAIT);To;u;[[@i ;F;:IFF_802_1Q_VLAN;;w;;;[;{;IC; "802.1Q VLAN device ;T;[;![;"I"802.1Q VLAN device;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"'Socket::Constants::IFF_802_1Q_VLAN;F;xI"!INTEGER2NUM(IFF_802_1Q_VLAN);To;u;[[@i ;F;:IFF_ALLMULTI;;w;;;[;{;IC; ""receive all multicast packets ;T;[;![;"I""receive all multicast packets;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"$Socket::Constants::IFF_ALLMULTI;F;xI"INTEGER2NUM(IFF_ALLMULTI);To;u;[[@i ;F;:IFF_ALTPHYS;;w;;;[;{;IC; "&use alternate physical connection ;T;[;![;"I"&use alternate physical connection;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"#Socket::Constants::IFF_ALTPHYS;F;xI"INTEGER2NUM(IFF_ALTPHYS);To;u;[[@i ;F;:IFF_AUTOMEDIA;;w;;;[;{;IC; "auto media select active ;T;[;![;"I"auto media select active;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"%Socket::Constants::IFF_AUTOMEDIA;F;xI"INTEGER2NUM(IFF_AUTOMEDIA);To;u;[[@i ;F;:IFF_BONDING;;w;;;[;{;IC; "bonding master or slave ;T;[;![;"I"bonding master or slave;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"#Socket::Constants::IFF_BONDING;F;xI"INTEGER2NUM(IFF_BONDING);To;u;[[@i ;F;:IFF_BRIDGE_PORT;;w;;;[;{;IC; "device used as bridge port ;T;[;![;"I"device used as bridge port;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"'Socket::Constants::IFF_BRIDGE_PORT;F;xI"!INTEGER2NUM(IFF_BRIDGE_PORT);To;u;[[@i ;F;:IFF_BROADCAST;;w;;;[;{;IC; "broadcast address valid ;T;[;![;"I"broadcast address valid;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"%Socket::Constants::IFF_BROADCAST;F;xI"INTEGER2NUM(IFF_BROADCAST);To;u;[[@i ;F;:IFF_CANTCONFIG;;w;;;[;{;IC; ""unconfigurable using ioctl(2) ;T;[;![;"I""unconfigurable using ioctl(2);T;#0;$@*;.F;/o;0;1T;2i ;3i ;%@;&I"&Socket::Constants::IFF_CANTCONFIG;F;xI" INTEGER2NUM(IFF_CANTCONFIG);To;u;[[@i ;F;:IFF_DEBUG;;w;;;[;{;IC; "turn on debugging ;T;[;![;"I"turn on debugging;T;#0;$@6;.F;/o;0;1T;2i ;3i ;%@;&I"!Socket::Constants::IFF_DEBUG;F;xI"INTEGER2NUM(IFF_DEBUG);To;u;[[@i ;F;:IFF_DISABLE_NETPOLL;;w;;;[;{;IC; " disable netpoll at run-time ;T;[;![;"I" disable netpoll at run-time;T;#0;$@B;.F;/o;0;1T;2i ;3i ;%@;&I"+Socket::Constants::IFF_DISABLE_NETPOLL;F;xI"%INTEGER2NUM(IFF_DISABLE_NETPOLL);To;u;[[@i% ;F;:IFF_DONT_BRIDGE;;w;;;[;{;IC; "%disallow bridging this ether dev ;T;[;![;"I"%disallow bridging this ether dev;T;#0;$@N;.F;/o;0;1T;2i$ ;3i$ ;%@;&I"'Socket::Constants::IFF_DONT_BRIDGE;F;xI"!INTEGER2NUM(IFF_DONT_BRIDGE);To;u;[[@i+ ;F;:IFF_DORMANT;;w;;;[;{;IC; "driver signals dormant ;T;[;![;"I"driver signals dormant;T;#0;$@Z;.F;/o;0;1T;2i* ;3i* ;%@;&I"#Socket::Constants::IFF_DORMANT;F;xI"INTEGER2NUM(IFF_DORMANT);To;u;[[@i1 ;F;:IFF_DRV_OACTIVE;;w;;;[;{;IC; "tx hardware queue is full ;T;[;![;"I"tx hardware queue is full;T;#0;$@f;.F;/o;0;1T;2i0 ;3i0 ;%@;&I"'Socket::Constants::IFF_DRV_OACTIVE;F;xI"!INTEGER2NUM(IFF_DRV_OACTIVE);To;u;[[@i7 ;F;:IFF_DRV_RUNNING;;w;;;[;{;IC; "resources allocated ;T;[;![;"I"resources allocated;T;#0;$@r;.F;/o;0;1T;2i6 ;3i6 ;%@;&I"'Socket::Constants::IFF_DRV_RUNNING;F;xI"!INTEGER2NUM(IFF_DRV_RUNNING);To;u;[[@i= ;F;:IFF_DYING;;w;;;[;{;IC; "interface is winding down ;T;[;![;"I"interface is winding down;T;#0;$@~;.F;/o;0;1T;2i< ;3i< ;%@;&I"!Socket::Constants::IFF_DYING;F;xI"INTEGER2NUM(IFF_DYING);To;u;[[@iC ;F;:IFF_DYNAMIC;;w;;;[;{;IC; "*dialup device with changing addresses ;T;[;![;"I"*dialup device with changing addresses;T;#0;$@;.F;/o;0;1T;2iB ;3iB ;%@;&I"#Socket::Constants::IFF_DYNAMIC;F;xI"INTEGER2NUM(IFF_DYNAMIC);To;u;[[@iI ;F;:IFF_EBRIDGE;;w;;;[;{;IC; "ethernet bridging device ;T;[;![;"I"ethernet bridging device;T;#0;$@;.F;/o;0;1T;2iH ;3iH ;%@;&I"#Socket::Constants::IFF_EBRIDGE;F;xI"INTEGER2NUM(IFF_EBRIDGE);To;u;[[@iO ;F;: IFF_ECHO;;w;;;[;{;IC; "echo sent packets ;T;[;![;"I"echo sent packets;T;#0;$@;.F;/o;0;1T;2iN ;3iN ;%@;&I" Socket::Constants::IFF_ECHO;F;xI"INTEGER2NUM(IFF_ECHO);To;u;[[@iU ;F;:IFF_ISATAP;;w;;;[;{;IC; "ISATAP interface (RFC4214) ;T;[;![;"I"ISATAP interface (RFC4214);T;#0;$@;.F;/o;0;1T;2iT ;3iT ;%@;&I""Socket::Constants::IFF_ISATAP;F;xI"INTEGER2NUM(IFF_ISATAP);To;u;[[@i[ ;F;:IFF_LINK0;;w;;;[;{;IC; "!per link layer defined bit 0 ;T;[;![;"I"!per link layer defined bit 0;T;#0;$@;.F;/o;0;1T;2iZ ;3iZ ;%@;&I"!Socket::Constants::IFF_LINK0;F;xI"INTEGER2NUM(IFF_LINK0);To;u;[[@ia ;F;:IFF_LINK1;;w;;;[;{;IC; "!per link layer defined bit 1 ;T;[;![;"I"!per link layer defined bit 1;T;#0;$@;.F;/o;0;1T;2i` ;3i` ;%@;&I"!Socket::Constants::IFF_LINK1;F;xI"INTEGER2NUM(IFF_LINK1);To;u;[[@ig ;F;:IFF_LINK2;;w;;;[;{;IC; "!per link layer defined bit 2 ;T;[;![;"I"!per link layer defined bit 2;T;#0;$@;.F;/o;0;1T;2if ;3if ;%@;&I"!Socket::Constants::IFF_LINK2;F;xI"INTEGER2NUM(IFF_LINK2);To;u;[[@im ;F;:IFF_LIVE_ADDR_CHANGE;;w;;;[;{;IC; ".hardware address change when it's running ;T;[;![;"I".hardware address change when it's running;T;#0;$@;.F;/o;0;1T;2il ;3il ;%@;&I",Socket::Constants::IFF_LIVE_ADDR_CHANGE;F;xI"&INTEGER2NUM(IFF_LIVE_ADDR_CHANGE);To;u;[[@is ;F;:IFF_LOOPBACK;;w;;;[;{;IC; "loopback net ;T;[;![;"I"loopback net;T;#0;$@;.F;/o;0;1T;2ir ;3ir ;%@;&I"$Socket::Constants::IFF_LOOPBACK;F;xI"INTEGER2NUM(IFF_LOOPBACK);To;u;[[@iy ;F;:IFF_LOWER_UP;;w;;;[;{;IC; "driver signals L1 up ;T;[;![;"I"driver signals L1 up;T;#0;$@;.F;/o;0;1T;2ix ;3ix ;%@;&I"$Socket::Constants::IFF_LOWER_UP;F;xI"INTEGER2NUM(IFF_LOWER_UP);To;u;[[@i ;F;:IFF_MACVLAN_PORT;;w;;;[;{;IC; " device used as macvlan port ;T;[;![;"I" device used as macvlan port;T;#0;$@;.F;/o;0;1T;2i~ ;3i~ ;%@;&I"(Socket::Constants::IFF_MACVLAN_PORT;F;xI""INTEGER2NUM(IFF_MACVLAN_PORT);To;u;[[@i ;F;:IFF_MASTER;;w;;;[;{;IC; "master of a load balancer ;T;[;![;"I"master of a load balancer;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I""Socket::Constants::IFF_MASTER;F;xI"INTEGER2NUM(IFF_MASTER);To;u;[[@i ;F;:IFF_MASTER_8023AD;;w;;;[;{;IC; "bonding master, 802.3ad. ;T;[;![;"I"bonding master, 802.3ad.;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I")Socket::Constants::IFF_MASTER_8023AD;F;xI"#INTEGER2NUM(IFF_MASTER_8023AD);To;u;[[@i ;F;:IFF_MASTER_ALB;;w;;;[;{;IC; "!bonding master, balance-alb. ;T;[;![;"I"!bonding master, balance-alb.;T;#0;$@&;.F;/o;0;1T;2i ;3i ;%@;&I"&Socket::Constants::IFF_MASTER_ALB;F;xI" INTEGER2NUM(IFF_MASTER_ALB);To;u;[[@i ;F;:IFF_MASTER_ARPMON;;w;;;[;{;IC; "#bonding master, ARP mon in use ;T;[;![;"I"#bonding master, ARP mon in use;T;#0;$@2;.F;/o;0;1T;2i ;3i ;%@;&I")Socket::Constants::IFF_MASTER_ARPMON;F;xI"#INTEGER2NUM(IFF_MASTER_ARPMON);To;u;[[@i ;F;:IFF_MONITOR;;w;;;[;{;IC; " user-requested monitor mode ;T;[;![;"I" user-requested monitor mode;T;#0;$@>;.F;/o;0;1T;2i ;3i ;%@;&I"#Socket::Constants::IFF_MONITOR;F;xI"INTEGER2NUM(IFF_MONITOR);To;u;[[@i ;F;:IFF_MULTICAST;;w;;;[;{;IC; "supports multicast ;T;[;![;"I"supports multicast;T;#0;$@J;.F;/o;0;1T;2i ;3i ;%@;&I"%Socket::Constants::IFF_MULTICAST;F;xI"INTEGER2NUM(IFF_MULTICAST);To;u;[[@i ;F;:IFF_NOARP;;w;;;[;{;IC; "#no address resolution protocol ;T;[;![;"I"#no address resolution protocol;T;#0;$@V;.F;/o;0;1T;2i ;3i ;%@;&I"!Socket::Constants::IFF_NOARP;F;xI"INTEGER2NUM(IFF_NOARP);To;u;[[@i ;F;:IFF_NOTRAILERS;;w;;;[;{;IC; "avoid use of trailers ;T;[;![;"I"avoid use of trailers;T;#0;$@b;.F;/o;0;1T;2i ;3i ;%@;&I"&Socket::Constants::IFF_NOTRAILERS;F;xI" INTEGER2NUM(IFF_NOTRAILERS);To;u;[[@i ;F;:IFF_OACTIVE;;w;;;[;{;IC; "transmission in progress ;T;[;![;"I"transmission in progress;T;#0;$@n;.F;/o;0;1T;2i ;3i ;%@;&I"#Socket::Constants::IFF_OACTIVE;F;xI"INTEGER2NUM(IFF_OACTIVE);To;u;[[@i ;F;:IFF_OVS_DATAPATH;;w;;;[;{;IC; ".device used as Open vSwitch datapath port ;T;[;![;"I".device used as Open vSwitch datapath port;T;#0;$@z;.F;/o;0;1T;2i ;3i ;%@;&I"(Socket::Constants::IFF_OVS_DATAPATH;F;xI""INTEGER2NUM(IFF_OVS_DATAPATH);To;u;[[@i ;F;:IFF_POINTOPOINT;;w;;;[;{;IC; "point-to-point link ;T;[;![;"I"point-to-point link;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"'Socket::Constants::IFF_POINTOPOINT;F;xI"!INTEGER2NUM(IFF_POINTOPOINT);To;u;[[@i ;F;:IFF_PORTSEL;;w;;;[;{;IC; "can set media type ;T;[;![;"I"can set media type;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"#Socket::Constants::IFF_PORTSEL;F;xI"INTEGER2NUM(IFF_PORTSEL);To;u;[[@i ;F;:IFF_PPROMISC;;w;;;[;{;IC; " user-requested promisc mode ;T;[;![;"I" user-requested promisc mode;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"$Socket::Constants::IFF_PPROMISC;F;xI"INTEGER2NUM(IFF_PPROMISC);To;u;[[@i ;F;:IFF_PROMISC;;w;;;[;{;IC; "receive all packets ;T;[;![;"I"receive all packets;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"#Socket::Constants::IFF_PROMISC;F;xI"INTEGER2NUM(IFF_PROMISC);To;u;[[@i ;F;:IFF_RENAMING;;w;;;[;{;IC; "interface is being renamed ;T;[;![;"I"interface is being renamed;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"$Socket::Constants::IFF_RENAMING;F;xI"INTEGER2NUM(IFF_RENAMING);To;u;[[@i ;F;:IFF_ROUTE;;w;;;[;{;IC; "routing entry installed ;T;[;![;"I"routing entry installed;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"!Socket::Constants::IFF_ROUTE;F;xI"INTEGER2NUM(IFF_ROUTE);To;u;[[@i ;F;:IFF_RUNNING;;w;;;[;{;IC; "resources allocated ;T;[;![;"I"resources allocated;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"#Socket::Constants::IFF_RUNNING;F;xI"INTEGER2NUM(IFF_RUNNING);To;u;[[@i ;F;:IFF_SIMPLEX;;w;;;[;{;IC; "!can't hear own transmissions ;T;[;![;"I"!can't hear own transmissions;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"#Socket::Constants::IFF_SIMPLEX;F;xI"INTEGER2NUM(IFF_SIMPLEX);To;u;[[@i ;F;:IFF_SLAVE;;w;;;[;{;IC; "slave of a load balancer ;T;[;![;"I"slave of a load balancer;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"!Socket::Constants::IFF_SLAVE;F;xI"INTEGER2NUM(IFF_SLAVE);To;u;[[@i ;F;:IFF_SLAVE_INACTIVE;;w;;;[;{;IC; "'bonding slave not the curr. active ;T;[;![;"I"'bonding slave not the curr. active;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"*Socket::Constants::IFF_SLAVE_INACTIVE;F;xI"$INTEGER2NUM(IFF_SLAVE_INACTIVE);To;u;[[@i ;F;:IFF_SLAVE_NEEDARP;;w;;;[;{;IC; "need ARPs for validation ;T;[;![;"I"need ARPs for validation;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I")Socket::Constants::IFF_SLAVE_NEEDARP;F;xI"#INTEGER2NUM(IFF_SLAVE_NEEDARP);To;u;[[@i ;F;:IFF_SMART;;w;;;[;{;IC; "!interface manages own routes ;T;[;![;"I"!interface manages own routes;T;#0;$@ ;.F;/o;0;1T;2i ;3i ;%@;&I"!Socket::Constants::IFF_SMART;F;xI"INTEGER2NUM(IFF_SMART);To;u;[[@i ;F;:IFF_STATICARP;;w;;;[;{;IC; "static ARP ;T;[;![;"I"static ARP;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"%Socket::Constants::IFF_STATICARP;F;xI"INTEGER2NUM(IFF_STATICARP);To;u;[[@i ;F;:IFF_SUPP_NOFCS;;w;;;[;{;IC; "sending custom FCS ;T;[;![;"I"sending custom FCS;T;#0;$@";.F;/o;0;1T;2i ;3i ;%@;&I"&Socket::Constants::IFF_SUPP_NOFCS;F;xI" INTEGER2NUM(IFF_SUPP_NOFCS);To;u;[[@i ;F;:IFF_TEAM_PORT;;w;;;[;{;IC; "used as team port ;T;[;![;"I"used as team port;T;#0;$@.;.F;/o;0;1T;2i ;3i ;%@;&I"%Socket::Constants::IFF_TEAM_PORT;F;xI"INTEGER2NUM(IFF_TEAM_PORT);To;u;[[@i ;F;:IFF_TX_SKB_SHARING;;w;;;[;{;IC; "sharing skbs on transmit ;T;[;![;"I"sharing skbs on transmit;T;#0;$@:;.F;/o;0;1T;2i ;3i ;%@;&I"*Socket::Constants::IFF_TX_SKB_SHARING;F;xI"$INTEGER2NUM(IFF_TX_SKB_SHARING);To;u;[[@i! ;F;:IFF_UNICAST_FLT;;w;;;[;{;IC; "unicast filtering ;T;[;![;"I"unicast filtering;T;#0;$@F;.F;/o;0;1T;2i ;3i ;%@;&I"'Socket::Constants::IFF_UNICAST_FLT;F;xI"!INTEGER2NUM(IFF_UNICAST_FLT);To;u;[[@i' ;F;: IFF_UP;;w;;;[;{;IC; "interface is up ;T;[;![;"I"interface is up;T;#0;$@R;.F;/o;0;1T;2i& ;3i& ;%@;&I"Socket::Constants::IFF_UP;F;xI"INTEGER2NUM(IFF_UP);To;u;[[@i- ;F;:IFF_WAN_HDLC;;w;;;[;{;IC; "WAN HDLC device ;T;[;![;"I"WAN HDLC device;T;#0;$@^;.F;/o;0;1T;2i, ;3i, ;%@;&I"$Socket::Constants::IFF_WAN_HDLC;F;xI"INTEGER2NUM(IFF_WAN_HDLC);To;u;[[@i3 ;F;:IFF_XMIT_DST_RELEASE;;w;;;[;{;IC; "9dev_hard_start_xmit() is allowed to release skb->dst ;T;[;![;"I"9dev_hard_start_xmit() is allowed to release skb->dst;T;#0;$@j;.F;/o;0;1T;2i2 ;3i2 ;%@;&I",Socket::Constants::IFF_XMIT_DST_RELEASE;F;xI"&INTEGER2NUM(IFF_XMIT_DST_RELEASE);To;u;[[@i9 ;F;:IFF_VOLATILE;;w;;;[;{;IC; "volatile flags ;T;[;![;"I"volatile flags;T;#0;$@v;.F;/o;0;1T;2i8 ;3i8 ;%@;&I"$Socket::Constants::IFF_VOLATILE;F;xI"INTEGER2NUM(IFF_VOLATILE);To;u;[[@i? ;F;:IFF_CANTCHANGE;;w;;;[;{;IC; "flags not changeable ;T;[;![;"I"flags not changeable;T;#0;$@;.F;/o;0;1T;2i> ;3i> ;%@;&I"&Socket::Constants::IFF_CANTCHANGE;F;xI" INTEGER2NUM(IFF_CANTCHANGE);T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i%[@i0;T;;;;;;;[;{;IC; " Socket::Constants provides socket-related constants. All possible socket constants are listed in the documentation but they may not all be present on your platform. If the underlying platform doesn't define a constant the corresponding Ruby constant is not defined. ;T;[;![;"I" Socket::Constants provides socket-related constants. All possible socket constants are listed in the documentation but they may not all be present on your platform. If the underlying platform doesn't define a constant the corresponding Ruby constant is not defined. ;T;#0;$@;.F;/o;0;1T;2i%;3i-;%@;&I"Socket::Constants;Fo;u;[[@i4;F;; ;;w;;;[;{;IC; "XA stream socket provides a sequenced, reliable two-way connection for a byte stream ;T;[;![;"I"XA stream socket provides a sequenced, reliable two-way connection for a byte stream;T;#0;$@;.F;/o;0;1T;2i3;3i3;%@;&I"Socket::SOCK_STREAM;F;xI"INTEGER2NUM(SOCK_STREAM);To;u;[[@i:;F;; ;;w;;;[;{;IC; "DA datagram socket provides connectionless, unreliable messaging ;T;[;![;"I"DA datagram socket provides connectionless, unreliable messaging;T;#0;$@;.F;/o;0;1T;2i9;3i9;%@;&I"Socket::SOCK_DGRAM;F;xI"INTEGER2NUM(SOCK_DGRAM);To;u;[[@i@;F;; ;;w;;;[;{;IC; "_A raw socket provides low-level access for direct access or implementing network protocols ;T;[;![;"I"_A raw socket provides low-level access for direct access or implementing network protocols;T;#0;$@;.F;/o;0;1T;2i?;3i?;%@;&I"Socket::SOCK_RAW;F;xI"INTEGER2NUM(SOCK_RAW);To;u;[[@iF;F;; ;;w;;;[;{;IC; "FA reliable datagram socket provides reliable delivery of messages ;T;[;![;"I"FA reliable datagram socket provides reliable delivery of messages;T;#0;$@;.F;/o;0;1T;2iE;3iE;%@;&I"Socket::SOCK_RDM;F;xI"INTEGER2NUM(SOCK_RDM);To;u;[[@iL;F;; ;;w;;;[;{;IC; "]A sequential packet socket provides sequenced, reliable two-way connection for datagrams ;T;[;![;"I"]A sequential packet socket provides sequenced, reliable two-way connection for datagrams;T;#0;$@;.F;/o;0;1T;2iK;3iK;%@;&I"Socket::SOCK_SEQPACKET;F;xI" INTEGER2NUM(SOCK_SEQPACKET);To;u;[[@iR;F;; ;;w;;;[;{;IC; "Device-level packet access ;T;[;![;"I"Device-level packet access;T;#0;$@;.F;/o;0;1T;2iQ;3iQ;%@;&I"Socket::SOCK_PACKET;F;xI"INTEGER2NUM(SOCK_PACKET);To;u;[[@iX;F;; ;;w;;;[;{;IC; "{Set the O_NONBLOCK file status flag on the open file description (see open(2)) referred to by the new file descriptor. ;T;[;![;"I"{Set the O_NONBLOCK file status flag on the open file description (see open(2)) referred to by the new file descriptor.;T;#0;$@;.F;/o;0;1T;2iW;3iW;%@;&I"Socket::SOCK_NONBLOCK;F;xI"INTEGER2NUM(SOCK_NONBLOCK);To;u;[[@i^;F;; ;;w;;;[;{;IC; "ISet the close-on-exec (FD_CLOEXEC) flag on the new file descriptor. ;T;[;![;"I"ISet the close-on-exec (FD_CLOEXEC) flag on the new file descriptor.;T;#0;$@;.F;/o;0;1T;2i];3i];%@;&I"Socket::SOCK_CLOEXEC;F;xI"INTEGER2NUM(SOCK_CLOEXEC);To;u;[[@id;F;; ;;w;;;[;{;IC; "7Unspecified protocol, any supported address family ;T;[;![;"I"7Unspecified protocol, any supported address family;T;#0;$@;.F;/o;0;1T;2ic;3ic;%@;&I"Socket::AF_UNSPEC;F;xI"INTEGER2NUM(AF_UNSPEC);To;u;[[@ij;F;; ;;w;;;[;{;IC; "7Unspecified protocol, any supported address family ;T;[;![;"I"7Unspecified protocol, any supported address family;T;#0;$@ ;.F;/o;0;1T;2ii;3ii;%@;&I"Socket::PF_UNSPEC;F;xI"INTEGER2NUM(PF_UNSPEC);To;u;[[@ip;F;; ;;w;;;[;{;IC; "IPv4 protocol ;T;[;![;"I"IPv4 protocol;T;#0;$@;.F;/o;0;1T;2io;3io;%@;&I"Socket::AF_INET;F;xI"INTEGER2NUM(AF_INET);To;u;[[@iv;F;; ;;w;;;[;{;IC; "IPv4 protocol ;T;[;![;"I"IPv4 protocol;T;#0;$@$;.F;/o;0;1T;2iu;3iu;%@;&I"Socket::PF_INET;F;xI"INTEGER2NUM(PF_INET);To;u;[[@i};F;; ;;w;;;[;{;IC; "IPv6 protocol ;T;[;![;"I"IPv6 protocol;T;#0;$@0;.F;/o;0;1T;2i|;3i|;%@;&I"Socket::AF_INET6;F;xI"INTEGER2NUM(AF_INET6);To;u;[[@i;F;; ;;w;;;[;{;IC; "IPv6 protocol ;T;[;![;"I"IPv6 protocol;T;#0;$@<;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_INET6;F;xI"INTEGER2NUM(PF_INET6);To;u;[[@i;F;; ;;w;;;[;{;IC; "UNIX sockets ;T;[;![;"I"UNIX sockets;T;#0;$@H;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_UNIX;F;xI"INTEGER2NUM(AF_UNIX);To;u;[[@i;F;; ;;w;;;[;{;IC; "UNIX sockets ;T;[;![;"I"UNIX sockets;T;#0;$@T;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_UNIX;F;xI"INTEGER2NUM(PF_UNIX);To;u;[[@i;F;; ;;w;;;[;{;IC; "AX.25 protocol ;T;[;![;"I"AX.25 protocol;T;#0;$@`;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_AX25;F;xI"INTEGER2NUM(AF_AX25);To;u;[[@i;F;; ;;w;;;[;{;IC; "AX.25 protocol ;T;[;![;"I"AX.25 protocol;T;#0;$@l;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_AX25;F;xI"INTEGER2NUM(PF_AX25);To;u;[[@i;F;; ;;w;;;[;{;IC; "IPX protocol ;T;[;![;"I"IPX protocol;T;#0;$@x;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_IPX;F;xI"INTEGER2NUM(AF_IPX);To;u;[[@i;F;; ;;w;;;[;{;IC; "IPX protocol ;T;[;![;"I"IPX protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_IPX;F;xI"INTEGER2NUM(PF_IPX);To;u;[[@i;F;; ;;w;;;[;{;IC; "AppleTalk protocol ;T;[;![;"I"AppleTalk protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_APPLETALK;F;xI"INTEGER2NUM(AF_APPLETALK);To;u;[[@i;F;; ;;w;;;[;{;IC; "AppleTalk protocol ;T;[;![;"I"AppleTalk protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_APPLETALK;F;xI"INTEGER2NUM(PF_APPLETALK);To;u;[[@i;F;; ;;w;;;[;{;IC; "Host-internal protocols ;T;[;![;"I"Host-internal protocols;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_LOCAL;F;xI"INTEGER2NUM(AF_LOCAL);To;u;[[@i;F;; ;;w;;;[;{;IC; "Host-internal protocols ;T;[;![;"I"Host-internal protocols;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_LOCAL;F;xI"INTEGER2NUM(PF_LOCAL);To;u;[[@i;F;; ;;w;;;[;{;IC; "ARPANET IMP protocol ;T;[;![;"I"ARPANET IMP protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_IMPLINK;F;xI"INTEGER2NUM(AF_IMPLINK);To;u;[[@i;F;; ;;w;;;[;{;IC; "ARPANET IMP protocol ;T;[;![;"I"ARPANET IMP protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_IMPLINK;F;xI"INTEGER2NUM(PF_IMPLINK);To;u;[[@i;F;; ;;w;;;[;{;IC; "#PARC Universal Packet protocol ;T;[;![;"I"#PARC Universal Packet protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_PUP;F;xI"INTEGER2NUM(AF_PUP);To;u;[[@i;F;; ;;w;;;[;{;IC; "#PARC Universal Packet protocol ;T;[;![;"I"#PARC Universal Packet protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_PUP;F;xI"INTEGER2NUM(PF_PUP);To;u;[[@i;F;; ;;w;;;[;{;IC; "MIT CHAOS protocols ;T;[;![;"I"MIT CHAOS protocols;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_CHAOS;F;xI"INTEGER2NUM(AF_CHAOS);To;u;[[@i;F;; ;;w;;;[;{;IC; "MIT CHAOS protocols ;T;[;![;"I"MIT CHAOS protocols;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_CHAOS;F;xI"INTEGER2NUM(PF_CHAOS);To;u;[[@i;F;; ;;w;;;[;{;IC; "XEROX NS protocols ;T;[;![;"I"XEROX NS protocols;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_NS;F;xI"INTEGER2NUM(AF_NS);To;u;[[@i;F;; ;;w;;;[;{;IC; "XEROX NS protocols ;T;[;![;"I"XEROX NS protocols;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_NS;F;xI"INTEGER2NUM(PF_NS);To;u;[[@i;F;; ;;w;;;[;{;IC; "/ISO Open Systems Interconnection protocols ;T;[;![;"I"/ISO Open Systems Interconnection protocols;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_ISO;F;xI"INTEGER2NUM(AF_ISO);To;u;[[@i;F;; ;;w;;;[;{;IC; "/ISO Open Systems Interconnection protocols ;T;[;![;"I"/ISO Open Systems Interconnection protocols;T;#0;$@,;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_ISO;F;xI"INTEGER2NUM(PF_ISO);To;u;[[@i;F;; ;;w;;;[;{;IC; "/ISO Open Systems Interconnection protocols ;T;[;![;"I"/ISO Open Systems Interconnection protocols;T;#0;$@8;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_OSI;F;xI"INTEGER2NUM(AF_OSI);To;u;[[@i;F;; ;;w;;;[;{;IC; "/ISO Open Systems Interconnection protocols ;T;[;![;"I"/ISO Open Systems Interconnection protocols;T;#0;$@D;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_OSI;F;xI"INTEGER2NUM(PF_OSI);To;u;[[@i ;F;; ;;w;;;[;{;IC; ".European Computer Manufacturers protocols ;T;[;![;"I".European Computer Manufacturers protocols;T;#0;$@P;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::AF_ECMA;F;xI"INTEGER2NUM(AF_ECMA);To;u;[[@i;F;; ;;w;;;[;{;IC; ".European Computer Manufacturers protocols ;T;[;![;"I".European Computer Manufacturers protocols;T;#0;$@\;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_ECMA;F;xI"INTEGER2NUM(PF_ECMA);To;u;[[@i;F;; ;;w;;;[;{;IC; "Datakit protocol ;T;[;![;"I"Datakit protocol;T;#0;$@h;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_DATAKIT;F;xI"INTEGER2NUM(AF_DATAKIT);To;u;[[@i;F;; ;;w;;;[;{;IC; "Datakit protocol ;T;[;![;"I"Datakit protocol;T;#0;$@t;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_DATAKIT;F;xI"INTEGER2NUM(PF_DATAKIT);To;u;[[@i#;F;; ;;w;;;[;{;IC; " CCITT (now ITU-T) protocols ;T;[;![;"I" CCITT (now ITU-T) protocols;T;#0;$@;.F;/o;0;1T;2i";3i";%@;&I"Socket::AF_CCITT;F;xI"INTEGER2NUM(AF_CCITT);To;u;[[@i);F;; ;;w;;;[;{;IC; " CCITT (now ITU-T) protocols ;T;[;![;"I" CCITT (now ITU-T) protocols;T;#0;$@;.F;/o;0;1T;2i(;3i(;%@;&I"Socket::PF_CCITT;F;xI"INTEGER2NUM(PF_CCITT);To;u;[[@i/;F;; ;;w;;;[;{;IC; "IBM SNA protocol ;T;[;![;"I"IBM SNA protocol;T;#0;$@;.F;/o;0;1T;2i.;3i.;%@;&I"Socket::AF_SNA;F;xI"INTEGER2NUM(AF_SNA);To;u;[[@i5;F;; ;;w;;;[;{;IC; "IBM SNA protocol ;T;[;![;"I"IBM SNA protocol;T;#0;$@;.F;/o;0;1T;2i4;3i4;%@;&I"Socket::PF_SNA;F;xI"INTEGER2NUM(PF_SNA);To;u;[[@i;;F;; ;;w;;;[;{;IC; "DECnet protocol ;T;[;![;"I"DECnet protocol;T;#0;$@;.F;/o;0;1T;2i:;3i:;%@;&I"Socket::AF_DEC;F;xI"INTEGER2NUM(AF_DEC);To;u;[[@iA;F;; ;;w;;;[;{;IC; "DECnet protocol ;T;[;![;"I"DECnet protocol;T;#0;$@;.F;/o;0;1T;2i@;3i@;%@;&I"Socket::PF_DEC;F;xI"INTEGER2NUM(PF_DEC);To;u;[[@iG;F;; ;;w;;;[;{;IC; "DECnet protocol ;T;[;![;"I"DECnet protocol;T;#0;$@;.F;/o;0;1T;2iF;3iF;%@;&I"Socket::AF_DECnet;F;xI"INTEGER2NUM(AF_DECnet);To;u;[[@iM;F;; ;;w;;;[;{;IC; "DECnet protocol ;T;[;![;"I"DECnet protocol;T;#0;$@;.F;/o;0;1T;2iL;3iL;%@;&I"Socket::PF_DECnet;F;xI"INTEGER2NUM(PF_DECnet);To;u;[[@iS;F;; ;;w;;;[;{;IC; ",DEC Direct Data Link Interface protocol ;T;[;![;"I",DEC Direct Data Link Interface protocol;T;#0;$@;.F;/o;0;1T;2iR;3iR;%@;&I"Socket::AF_DLI;F;xI"INTEGER2NUM(AF_DLI);To;u;[[@iY;F;; ;;w;;;[;{;IC; ",DEC Direct Data Link Interface protocol ;T;[;![;"I",DEC Direct Data Link Interface protocol;T;#0;$@;.F;/o;0;1T;2iX;3iX;%@;&I"Socket::PF_DLI;F;xI"INTEGER2NUM(PF_DLI);To;u;[[@i_;F;; ;;w;;;[;{;IC; ""Local Area Transport protocol ;T;[;![;"I""Local Area Transport protocol;T;#0;$@;.F;/o;0;1T;2i^;3i^;%@;&I"Socket::AF_LAT;F;xI"INTEGER2NUM(AF_LAT);To;u;[[@ie;F;; ;;w;;;[;{;IC; ""Local Area Transport protocol ;T;[;![;"I""Local Area Transport protocol;T;#0;$@;.F;/o;0;1T;2id;3id;%@;&I"Socket::PF_LAT;F;xI"INTEGER2NUM(PF_LAT);To;u;[[@ik;F;; ;;w;;;[;{;IC; "NSC Hyperchannel protocol ;T;[;![;"I"NSC Hyperchannel protocol;T;#0;$@;.F;/o;0;1T;2ij;3ij;%@;&I"Socket::AF_HYLINK;F;xI"INTEGER2NUM(AF_HYLINK);To;u;[[@iq;F;; ;;w;;;[;{;IC; "NSC Hyperchannel protocol ;T;[;![;"I"NSC Hyperchannel protocol;T;#0;$@;.F;/o;0;1T;2ip;3ip;%@;&I"Socket::PF_HYLINK;F;xI"INTEGER2NUM(PF_HYLINK);To;u;[[@iw;F;; ;;w;;;[;{;IC; "Internal routing protocol ;T;[;![;"I"Internal routing protocol;T;#0;$@(;.F;/o;0;1T;2iv;3iv;%@;&I"Socket::AF_ROUTE;F;xI"INTEGER2NUM(AF_ROUTE);To;u;[[@i};F;; ;;w;;;[;{;IC; "Internal routing protocol ;T;[;![;"I"Internal routing protocol;T;#0;$@4;.F;/o;0;1T;2i|;3i|;%@;&I"Socket::PF_ROUTE;F;xI"INTEGER2NUM(PF_ROUTE);To;u;[[@i;F;; ;;w;;;[;{;IC; "Link layer interface ;T;[;![;"I"Link layer interface;T;#0;$@@;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_LINK;F;xI"INTEGER2NUM(AF_LINK);To;u;[[@i;F;; ;;w;;;[;{;IC; "Link layer interface ;T;[;![;"I"Link layer interface;T;#0;$@L;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_LINK;F;xI"INTEGER2NUM(PF_LINK);To;u;[[@i;F;; ;;w;;;[;{;IC; "Connection-oriented IP ;T;[;![;"I"Connection-oriented IP;T;#0;$@X;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_COIP;F;xI"INTEGER2NUM(AF_COIP);To;u;[[@i;F;; ;;w;;;[;{;IC; "Connection-oriented IP ;T;[;![;"I"Connection-oriented IP;T;#0;$@d;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_COIP;F;xI"INTEGER2NUM(PF_COIP);To;u;[[@i;F;; ;;w;;;[;{;IC; " Computer Network Technology ;T;[;![;"I" Computer Network Technology;T;#0;$@p;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_CNT;F;xI"INTEGER2NUM(AF_CNT);To;u;[[@i;F;; ;;w;;;[;{;IC; " Computer Network Technology ;T;[;![;"I" Computer Network Technology;T;#0;$@|;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_CNT;F;xI"INTEGER2NUM(PF_CNT);To;u;[[@i;F;; ;;w;;;[;{;IC; "Simple Internet Protocol ;T;[;![;"I"Simple Internet Protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_SIP;F;xI"INTEGER2NUM(AF_SIP);To;u;[[@i;F;; ;;w;;;[;{;IC; "Simple Internet Protocol ;T;[;![;"I"Simple Internet Protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_SIP;F;xI"INTEGER2NUM(PF_SIP);To;u;[[@i;F;; ;;w;;;[;{;IC; "Network driver raw access ;T;[;![;"I"Network driver raw access;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_NDRV;F;xI"INTEGER2NUM(AF_NDRV);To;u;[[@i;F;; ;;w;;;[;{;IC; "Network driver raw access ;T;[;![;"I"Network driver raw access;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_NDRV;F;xI"INTEGER2NUM(PF_NDRV);To;u;[[@i;F;; ;;w;;;[;{;IC; "(Integrated Services Digital Network ;T;[;![;"I"(Integrated Services Digital Network;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_ISDN;F;xI"INTEGER2NUM(AF_ISDN);To;u;[[@i;F;; ;;w;;;[;{;IC; "(Integrated Services Digital Network ;T;[;![;"I"(Integrated Services Digital Network;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_ISDN;F;xI"INTEGER2NUM(PF_ISDN);To;u;[[@i;F;; ;;w;;;[;{;IC; "Native ATM access ;T;[;![;"I"Native ATM access;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_NATM;F;xI"INTEGER2NUM(AF_NATM);To;u;[[@i;F;; ;;w;;;[;{;IC; "Native ATM access ;T;[;![;"I"Native ATM access;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_NATM;F;xI"INTEGER2NUM(PF_NATM);To;u;[[@i;F;; ;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"Socket::AF_SYSTEM;F;xI"INTEGER2NUM(AF_SYSTEM);To;u;[[@i;F;; ;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"Socket::PF_SYSTEM;F;xI"INTEGER2NUM(PF_SYSTEM);To;u;[[@i;F;; ;;w;;;[;{;IC; " NetBIOS ;T;[;![;"I" NetBIOS;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_NETBIOS;F;xI"INTEGER2NUM(AF_NETBIOS);To;u;[[@i;F;; ;;w;;;[;{;IC; " NetBIOS ;T;[;![;"I" NetBIOS;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_NETBIOS;F;xI"INTEGER2NUM(PF_NETBIOS);To;u;[[@i;F;; ;;w;;;[;{;IC; "Point-to-Point Protocol ;T;[;![;"I"Point-to-Point Protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_PPP;F;xI"INTEGER2NUM(AF_PPP);To;u;[[@i;F;; ;;w;;;[;{;IC; "Point-to-Point Protocol ;T;[;![;"I"Point-to-Point Protocol;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_PPP;F;xI"INTEGER2NUM(PF_PPP);To;u;[[@i;F;; ;;w;;;[;{;IC; "Asynchronous Transfer Mode ;T;[;![;"I"Asynchronous Transfer Mode;T;#0;$@,;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_ATM;F;xI"INTEGER2NUM(AF_ATM);To;u;[[@i;F;; ;;w;;;[;{;IC; "Asynchronous Transfer Mode ;T;[;![;"I"Asynchronous Transfer Mode;T;#0;$@8;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_ATM;F;xI"INTEGER2NUM(PF_ATM);To;u;[[@i;F;; ;;w;;;[;{;IC; "Netgraph sockets ;T;[;![;"I"Netgraph sockets;T;#0;$@D;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_NETGRAPH;F;xI"INTEGER2NUM(AF_NETGRAPH);To;u;[[@i ;F;; ;;w;;;[;{;IC; "Netgraph sockets ;T;[;![;"I"Netgraph sockets;T;#0;$@P;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::PF_NETGRAPH;F;xI"INTEGER2NUM(PF_NETGRAPH);To;u;[[@i;F;; ;;w;;;[;{;IC; "-Maximum address family for this platform ;T;[;![;"I"-Maximum address family for this platform;T;#0;$@\;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_MAX;F;xI"INTEGER2NUM(AF_MAX);To;u;[[@i;F;; ;;w;;;[;{;IC; "-Maximum address family for this platform ;T;[;![;"I"-Maximum address family for this platform;T;#0;$@h;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_MAX;F;xI"INTEGER2NUM(PF_MAX);To;u;[[@i;F;; ;;w;;;[;{;IC; "Direct link-layer access ;T;[;![;"I"Direct link-layer access;T;#0;$@t;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_PACKET;F;xI"INTEGER2NUM(AF_PACKET);To;u;[[@i%;F;; ;;w;;;[;{;IC; "Direct link-layer access ;T;[;![;"I"Direct link-layer access;T;#0;$@;.F;/o;0;1T;2i$;3i$;%@;&I"Socket::PF_PACKET;F;xI"INTEGER2NUM(PF_PACKET);To;u;[[@i+;F;; ;;w;;;[;{;IC; "'CCITT (ITU-T) E.164 recommendation ;T;[;![;"I"'CCITT (ITU-T) E.164 recommendation;T;#0;$@;.F;/o;0;1T;2i*;3i*;%@;&I"Socket::AF_E164;F;xI"INTEGER2NUM(AF_E164);To;u;[[@i1;F;; ;;w;;;[;{;IC; "eXpress Transfer Protocol ;T;[;![;"I"eXpress Transfer Protocol;T;#0;$@;.F;/o;0;1T;2i0;3i0;%@;&I"Socket::PF_XTP;F;xI"INTEGER2NUM(PF_XTP);To;u;[[@i7;F;; ;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"Socket::PF_RTIP;F;xI"INTEGER2NUM(PF_RTIP);To;u;[[@i=;F;; ;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"Socket::PF_PIP;F;xI"INTEGER2NUM(PF_PIP);To;u;[[@iC;F;; ;;w;;;[;{;IC; "GKey management protocol, originally developed for usage with IPsec ;T;[;![;"I"GKey management protocol, originally developed for usage with IPsec;T;#0;$@;.F;/o;0;1T;2iB;3iB;%@;&I"Socket::AF_KEY;F;xI"INTEGER2NUM(AF_KEY);To;u;[[@iI;F;; ;;w;;;[;{;IC; "GKey management protocol, originally developed for usage with IPsec ;T;[;![;"I"GKey management protocol, originally developed for usage with IPsec;T;#0;$@;.F;/o;0;1T;2iH;3iH;%@;&I"Socket::PF_KEY;F;xI"INTEGER2NUM(PF_KEY);To;u;[[@iO;F;; ;;w;;;[;{;IC; "!Kernel user interface device ;T;[;![;"I"!Kernel user interface device;T;#0;$@;.F;/o;0;1T;2iN;3iN;%@;&I"Socket::AF_NETLINK;F;xI"INTEGER2NUM(AF_NETLINK);To;u;[[@iU;F;; ;;w;;;[;{;IC; "!Kernel user interface device ;T;[;![;"I"!Kernel user interface device;T;#0;$@;.F;/o;0;1T;2iT;3iT;%@;&I"Socket::PF_NETLINK;F;xI"INTEGER2NUM(PF_NETLINK);To;u;[[@i[;F;; ;;w;;;[;{;IC; "-Reliable Datagram Sockets (RDS) protocol ;T;[;![;"I"-Reliable Datagram Sockets (RDS) protocol;T;#0;$@;.F;/o;0;1T;2iZ;3iZ;%@;&I"Socket::AF_RDS;F;xI"INTEGER2NUM(AF_RDS);To;u;[[@ia;F;; ;;w;;;[;{;IC; "-Reliable Datagram Sockets (RDS) protocol ;T;[;![;"I"-Reliable Datagram Sockets (RDS) protocol;T;#0;$@;.F;/o;0;1T;2i`;3i`;%@;&I"Socket::PF_RDS;F;xI"INTEGER2NUM(PF_RDS);To;u;[[@ig;F;; ;;w;;;[;{;IC; "LGeneric PPP transport layer, for setting up L2 tunnels (L2TP and PPPoE) ;T;[;![;"I"LGeneric PPP transport layer, for setting up L2 tunnels (L2TP and PPPoE);T;#0;$@;.F;/o;0;1T;2if;3if;%@;&I"Socket::AF_PPPOX;F;xI"INTEGER2NUM(AF_PPPOX);To;u;[[@im;F;; ;;w;;;[;{;IC; "LGeneric PPP transport layer, for setting up L2 tunnels (L2TP and PPPoE) ;T;[;![;"I"LGeneric PPP transport layer, for setting up L2 tunnels (L2TP and PPPoE);T;#0;$@ ;.F;/o;0;1T;2il;3il;%@;&I"Socket::PF_PPPOX;F;xI"INTEGER2NUM(PF_PPPOX);To;u;[[@is;F;; ;;w;;;[;{;IC; "4Logical link control (IEEE 802.2 LLC) protocol ;T;[;![;"I"4Logical link control (IEEE 802.2 LLC) protocol;T;#0;$@;.F;/o;0;1T;2ir;3ir;%@;&I"Socket::AF_LLC;F;xI"INTEGER2NUM(AF_LLC);To;u;[[@iy;F;; ;;w;;;[;{;IC; "4Logical link control (IEEE 802.2 LLC) protocol ;T;[;![;"I"4Logical link control (IEEE 802.2 LLC) protocol;T;#0;$@$;.F;/o;0;1T;2ix;3ix;%@;&I"Socket::PF_LLC;F;xI"INTEGER2NUM(PF_LLC);To;u;[[@i;F;; ;;w;;;[;{;IC; "!InfiniBand native addressing ;T;[;![;"I"!InfiniBand native addressing;T;#0;$@0;.F;/o;0;1T;2i~;3i~;%@;&I"Socket::AF_IB;F;xI"INTEGER2NUM(AF_IB);To;u;[[@i;F;; ;;w;;;[;{;IC; "!InfiniBand native addressing ;T;[;![;"I"!InfiniBand native addressing;T;#0;$@<;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_IB;F;xI"INTEGER2NUM(PF_IB);To;u;[[@i;F;; ;;w;;;[;{;IC; ""Multiprotocol Label Switching ;T;[;![;"I""Multiprotocol Label Switching;T;#0;$@H;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_MPLS;F;xI"INTEGER2NUM(AF_MPLS);To;u;[[@i;F;; ;;w;;;[;{;IC; ""Multiprotocol Label Switching ;T;[;![;"I""Multiprotocol Label Switching;T;#0;$@T;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_MPLS;F;xI"INTEGER2NUM(PF_MPLS);To;u;[[@i;F;; ;;w;;;[;{;IC; "4Controller Area Network automotive bus protocol ;T;[;![;"I"4Controller Area Network automotive bus protocol;T;#0;$@`;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_CAN;F;xI"INTEGER2NUM(AF_CAN);To;u;[[@i;F;; ;;w;;;[;{;IC; "4Controller Area Network automotive bus protocol ;T;[;![;"I"4Controller Area Network automotive bus protocol;T;#0;$@l;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_CAN;F;xI"INTEGER2NUM(PF_CAN);To;u;[[@i;F;; ;;w;;;[;{;IC; ",TIPC, "cluster domain sockets" protocol ;T;[;![;"I",TIPC, "cluster domain sockets" protocol;T;#0;$@x;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_TIPC;F;xI"INTEGER2NUM(AF_TIPC);To;u;[[@i;F;; ;;w;;;[;{;IC; ",TIPC, "cluster domain sockets" protocol ;T;[;![;"I",TIPC, "cluster domain sockets" protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_TIPC;F;xI"INTEGER2NUM(PF_TIPC);To;u;[[@i;F;; ;;w;;;[;{;IC; "(Bluetooth low-level socket protocol ;T;[;![;"I"(Bluetooth low-level socket protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_BLUETOOTH;F;xI"INTEGER2NUM(AF_BLUETOOTH);To;u;[[@i;F;; ;;w;;;[;{;IC; "(Bluetooth low-level socket protocol ;T;[;![;"I"(Bluetooth low-level socket protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_BLUETOOTH;F;xI"INTEGER2NUM(PF_BLUETOOTH);To;u;[[@i;F;; ;;w;;;[;{;IC; "#Interface to kernel crypto API ;T;[;![;"I"#Interface to kernel crypto API;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_ALG;F;xI"INTEGER2NUM(AF_ALG);To;u;[[@i;F;; ;;w;;;[;{;IC; "#Interface to kernel crypto API ;T;[;![;"I"#Interface to kernel crypto API;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_ALG;F;xI"INTEGER2NUM(PF_ALG);To;u;[[@i;F;; ;;w;;;[;{;IC; "UVSOCK (originally "VMWare VSockets") protocol for hypervisor-guest communication ;T;[;![;"I"UVSOCK (originally "VMWare VSockets") protocol for hypervisor-guest communication;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_VSOCK;F;xI"INTEGER2NUM(AF_VSOCK);To;u;[[@i;F;; ;;w;;;[;{;IC; "UVSOCK (originally "VMWare VSockets") protocol for hypervisor-guest communication ;T;[;![;"I"UVSOCK (originally "VMWare VSockets") protocol for hypervisor-guest communication;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_VSOCK;F;xI"INTEGER2NUM(PF_VSOCK);To;u;[[@i;F;; ;;w;;;[;{;IC; "2KCM (kernel connection multiplexor) interface ;T;[;![;"I"2KCM (kernel connection multiplexor) interface;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_KCM;F;xI"INTEGER2NUM(AF_KCM);To;u;[[@i;F;; ;;w;;;[;{;IC; "2KCM (kernel connection multiplexor) interface ;T;[;![;"I"2KCM (kernel connection multiplexor) interface;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_KCM;F;xI"INTEGER2NUM(PF_KCM);To;u;[[@i;F;; ;;w;;;[;{;IC; "&XDP (express data path) interface ;T;[;![;"I"&XDP (express data path) interface;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::AF_XDP;F;xI"INTEGER2NUM(AF_XDP);To;u;[[@i;F;; ;;w;;;[;{;IC; "&XDP (express data path) interface ;T;[;![;"I"&XDP (express data path) interface;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::PF_XDP;F;xI"INTEGER2NUM(PF_XDP);To;u;[[@i;F;; ;;w;;;[;{;IC; "Process out-of-band data ;T;[;![;"I"Process out-of-band data;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::MSG_OOB;F;xI"INTEGER2NUM(MSG_OOB);To;u;[[@i;F;; ;;w;;;[;{;IC; "Peek at incoming message ;T;[;![;"I"Peek at incoming message;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::MSG_PEEK;F;xI"INTEGER2NUM(MSG_PEEK);To;u;[[@i;F;; ;;w;;;[;{;IC; "*Send without using the routing tables ;T;[;![;"I"*Send without using the routing tables;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;&I"Socket::MSG_DONTROUTE;F;xI"INTEGER2NUM(MSG_DONTROUTE);To;u;[[@i;F;; ;;w;;;[;{;IC; "Data completes record ;T;[;![;"I"Data completes record;T;#0;$@,;.F;/o;0;1T;2i;3i;%@;&I"Socket::MSG_EOR;F;xI"INTEGER2NUM(MSG_EOR);To;u;[[@i;F;; ;;w;;;[;{;IC; "#Data discarded before delivery ;T;[;![;"I"#Data discarded before delivery;T;#0;$@8;.F;/o;0;1T;2i;3i;%@;&I"Socket::MSG_TRUNC;F;xI"INTEGER2NUM(MSG_TRUNC);To;u;[[@i ;F;; ;;w;;;[;{;IC; "&Control data lost before delivery ;T;[;![;"I"&Control data lost before delivery;T;#0;$@D;.F;/o;0;1T;2i;3i;%@;&I"Socket::MSG_CTRUNC;F;xI"INTEGER2NUM(MSG_CTRUNC);To;u;[[@i;F;; ;;w;;;[;{;IC; "#Wait for full request or error ;T;[;![;"I"#Wait for full request or error;T;#0;$@P;.F;/o;0;1T;2i;3i;%@;&I"Socket::MSG_WAITALL;F;xI"INTEGER2NUM(MSG_WAITALL);To;u;[[@i;F;; ;;w;;;[;{;IC; "(This message should be non-blocking ;T;[;![;"I"(This message should be non-blocking;T;#0;$@\;.F;/o;0;1T;2i;3i;%@;&I"Socket::MSG_DONTWAIT;F;xI"INTEGER2NUM(MSG_DONTWAIT);To;u;[[@i;F;; ;;w;;;[;{;IC; "Data completes connection ;T;[;![;"I"Data completes connection;T;#0;$@h;.F;/o;0;1T;2i;3i;%@;&I"Socket::MSG_EOF;F;xI"INTEGER2NUM(MSG_EOF);To;u;[[@i!;F;; ;;w;;;[;{;IC; "0Start of a hold sequence. Dumps to so_temp ;T;[;![;"I"0Start of a hold sequence. Dumps to so_temp;T;#0;$@t;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::MSG_FLUSH;F;xI"INTEGER2NUM(MSG_FLUSH);To;u;[[@i';F;; ;;w;;;[;{;IC; "Hold fragment in so_temp ;T;[;![;"I"Hold fragment in so_temp;T;#0;$@;.F;/o;0;1T;2i&;3i&;%@;&I"Socket::MSG_HOLD;F;xI"INTEGER2NUM(MSG_HOLD);To;u;[[@i-;F;; ;;w;;;[;{;IC; "Send the packet in so_temp ;T;[;![;"I"Send the packet in so_temp;T;#0;$@;.F;/o;0;1T;2i,;3i,;%@;&I"Socket::MSG_SEND;F;xI"INTEGER2NUM(MSG_SEND);To;u;[[@i3;F;; ;;w;;;[;{;IC; "Data ready to be read ;T;[;![;"I"Data ready to be read;T;#0;$@;.F;/o;0;1T;2i2;3i2;%@;&I"Socket::MSG_HAVEMORE;F;xI"INTEGER2NUM(MSG_HAVEMORE);To;u;[[@i9;F;; ;;w;;;[;{;IC; "'Data remains in the current packet ;T;[;![;"I"'Data remains in the current packet;T;#0;$@;.F;/o;0;1T;2i8;3i8;%@;&I"Socket::MSG_RCVMORE;F;xI"INTEGER2NUM(MSG_RCVMORE);To;u;[[@i?;F;; ;;w;;;[;{;IC; "End of record ;T;[;![;"I"End of record;T;#0;$@;.F;/o;0;1T;2i>;3i>;%@;&I"Socket::MSG_COMPAT;F;xI"INTEGER2NUM(MSG_COMPAT);To;u;[[@iE;F;; ;;w;;;[;{;IC; "Wait for full request ;T;[;![;"I"Wait for full request;T;#0;$@;.F;/o;0;1T;2iD;3iD;%@;&I"Socket::MSG_PROXY;F;xI"INTEGER2NUM(MSG_PROXY);To;u;[[@iK;F;; ;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"Socket::MSG_FIN;F;xI"INTEGER2NUM(MSG_FIN);To;u;[[@iQ;F;; ;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"Socket::MSG_SYN;F;xI"INTEGER2NUM(MSG_SYN);To;u;[[@iW;F;; ;;w;;;[;{;IC; "Confirm path validity ;T;[;![;"I"Confirm path validity;T;#0;$@;.F;/o;0;1T;2iV;3iV;%@;&I"Socket::MSG_CONFIRM;F;xI"INTEGER2NUM(MSG_CONFIRM);To;u;[[@i];F;; ;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"Socket::MSG_RST;F;xI"INTEGER2NUM(MSG_RST);To;u;[[@ic;F;;! ;;w;;;[;{;IC; "#Fetch message from error queue ;T;[;![;"I"#Fetch message from error queue;T;#0;$@;.F;/o;0;1T;2ib;3ib;%@;&I"Socket::MSG_ERRQUEUE;F;xI"INTEGER2NUM(MSG_ERRQUEUE);To;u;[[@ii;F;;" ;;w;;;[;{;IC; "Do not generate SIGPIPE ;T;[;![;"I"Do not generate SIGPIPE;T;#0;$@;.F;/o;0;1T;2ih;3ih;%@;&I"Socket::MSG_NOSIGNAL;F;xI"INTEGER2NUM(MSG_NOSIGNAL);To;u;[[@io;F;;# ;;w;;;[;{;IC; "Sender will send more ;T;[;![;"I"Sender will send more;T;#0;$@ ;.F;/o;0;1T;2in;3in;%@;&I"Socket::MSG_MORE;F;xI"INTEGER2NUM(MSG_MORE);To;u;[[@iu;F;;$ ;;w;;;[;{;IC; ")Reduce step of the handshake process ;T;[;![;"I")Reduce step of the handshake process;T;#0;$@;.F;/o;0;1T;2it;3it;%@;&I"Socket::MSG_FASTOPEN;F;xI"INTEGER2NUM(MSG_FASTOPEN);To;u;[[@i{;F;;% ;;w;;;[;{;IC; "Socket-level options ;T;[;![;"I"Socket-level options;T;#0;$@";.F;/o;0;1T;2iz;3iz;%@;&I"Socket::SOL_SOCKET;F;xI"INTEGER2NUM(SOL_SOCKET);To;u;[[@i;F;;& ;;w;;;[;{;IC; "IP socket options ;T;[;![;"I"IP socket options;T;#0;$@.;.F;/o;0;1T;2i;3i;%@;&I"Socket::SOL_IP;F;xI"INTEGER2NUM(SOL_IP);To;u;[[@i;F;;' ;;w;;;[;{;IC; "IPX socket options ;T;[;![;"I"IPX socket options;T;#0;$@:;.F;/o;0;1T;2i;3i;%@;&I"Socket::SOL_IPX;F;xI"INTEGER2NUM(SOL_IPX);To;u;[[@i;F;;( ;;w;;;[;{;IC; "AX.25 socket options ;T;[;![;"I"AX.25 socket options;T;#0;$@F;.F;/o;0;1T;2i;3i;%@;&I"Socket::SOL_AX25;F;xI"INTEGER2NUM(SOL_AX25);To;u;[[@i;F;;) ;;w;;;[;{;IC; "AppleTalk socket options ;T;[;![;"I"AppleTalk socket options;T;#0;$@R;.F;/o;0;1T;2i;3i;%@;&I"Socket::SOL_ATALK;F;xI"INTEGER2NUM(SOL_ATALK);To;u;[[@i;F;;* ;;w;;;[;{;IC; "TCP socket options ;T;[;![;"I"TCP socket options;T;#0;$@^;.F;/o;0;1T;2i;3i;%@;&I"Socket::SOL_TCP;F;xI"INTEGER2NUM(SOL_TCP);To;u;[[@i;F;;+ ;;w;;;[;{;IC; "UDP socket options ;T;[;![;"I"UDP socket options;T;#0;$@j;.F;/o;0;1T;2i;3i;%@;&I"Socket::SOL_UDP;F;xI"INTEGER2NUM(SOL_UDP);To;u;[[@i;F;;, ;;w;;;[;{;IC; "Dummy protocol for IP ;T;[;![;"I"Dummy protocol for IP;T;#0;$@v;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPPROTO_IP;F;xI"INTEGER2NUM(IPPROTO_IP);To;u;[[@i;F;;- ;;w;;;[;{;IC; "Control message protocol ;T;[;![;"I"Control message protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPPROTO_ICMP;F;xI"INTEGER2NUM(IPPROTO_ICMP);To;u;[[@i;F;;. ;;w;;;[;{;IC; "Group Management Protocol ;T;[;![;"I"Group Management Protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPPROTO_IGMP;F;xI"INTEGER2NUM(IPPROTO_IGMP);To;u;[[@i;F;;/ ;;w;;;[;{;IC; " Gateway to Gateway Protocol ;T;[;![;"I" Gateway to Gateway Protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPPROTO_GGP;F;xI"INTEGER2NUM(IPPROTO_GGP);To;u;[[@i;F;;0 ;;w;;;[;{;IC; "TCP ;T;[;![;"I"TCP;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPPROTO_TCP;F;xI"INTEGER2NUM(IPPROTO_TCP);To;u;[[@i;F;;1 ;;w;;;[;{;IC; "Exterior Gateway Protocol ;T;[;![;"I"Exterior Gateway Protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPPROTO_EGP;F;xI"INTEGER2NUM(IPPROTO_EGP);To;u;[[@i;F;;2 ;;w;;;[;{;IC; "#PARC Universal Packet protocol ;T;[;![;"I"#PARC Universal Packet protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPPROTO_PUP;F;xI"INTEGER2NUM(IPPROTO_PUP);To;u;[[@i;F;;3 ;;w;;;[;{;IC; "UDP ;T;[;![;"I"UDP;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPPROTO_UDP;F;xI"INTEGER2NUM(IPPROTO_UDP);To;u;[[@i;F;;4 ;;w;;;[;{;IC; " XNS IDP ;T;[;![;"I" XNS IDP;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPPROTO_IDP;F;xI"INTEGER2NUM(IPPROTO_IDP);To;u;[[@i;F;;5 ;;w;;;[;{;IC; ""hello" routing protocol ;T;[;![;"I""hello" routing protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPPROTO_HELLO;F;xI"INTEGER2NUM(IPPROTO_HELLO);To;u;[[@i;F;;6 ;;w;;;[;{;IC; "Sun net disk protocol ;T;[;![;"I"Sun net disk protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPPROTO_ND;F;xI"INTEGER2NUM(IPPROTO_ND);To;u;[[@i;F;;7 ;;w;;;[;{;IC; "#ISO transport protocol class 4 ;T;[;![;"I"#ISO transport protocol class 4;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPPROTO_TP;F;xI"INTEGER2NUM(IPPROTO_TP);To;u;[[@i;F;;8 ;;w;;;[;{;IC; "Xpress Transport Protocol ;T;[;![;"I"Xpress Transport Protocol;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPPROTO_XTP;F;xI"INTEGER2NUM(IPPROTO_XTP);To;u;[[@i;F;;9 ;;w;;;[;{;IC; " ISO cnlp ;T;[;![;"I" ISO cnlp;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPPROTO_EON;F;xI"INTEGER2NUM(IPPROTO_EON);To;u;[[@i;F;;: ;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"Socket::IPPROTO_BIP;F;xI"INTEGER2NUM(IPPROTO_BIP);To;u;[[@i;F;;; ;;w;;;[;{;IC; "IP6 auth header ;T;[;![;"I"IP6 auth header;T;#0;$@(;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPPROTO_AH;F;xI"INTEGER2NUM(IPPROTO_AH);To;u;[[@i;F;;< ;;w;;;[;{;IC; "IP6 destination option ;T;[;![;"I"IP6 destination option;T;#0;$@4;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPPROTO_DSTOPTS;F;xI"!INTEGER2NUM(IPPROTO_DSTOPTS);To;u;[[@i ;F;;= ;;w;;;[;{;IC; "&IP6 Encapsulated Security Payload ;T;[;![;"I"&IP6 Encapsulated Security Payload;T;#0;$@@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IPPROTO_ESP;F;xI"INTEGER2NUM(IPPROTO_ESP);To;u;[[@i;F;;> ;;w;;;[;{;IC; "IP6 fragmentation header ;T;[;![;"I"IP6 fragmentation header;T;#0;$@L;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPPROTO_FRAGMENT;F;xI""INTEGER2NUM(IPPROTO_FRAGMENT);To;u;[[@i;F;;? ;;w;;;[;{;IC; "IP6 hop-by-hop options ;T;[;![;"I"IP6 hop-by-hop options;T;#0;$@X;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPPROTO_HOPOPTS;F;xI"!INTEGER2NUM(IPPROTO_HOPOPTS);To;u;[[@i;F;;@ ;;w;;;[;{;IC; " ICMP6 ;T;[;![;"I" ICMP6;T;#0;$@d;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPPROTO_ICMPV6;F;xI" INTEGER2NUM(IPPROTO_ICMPV6);To;u;[[@i#;F;;A ;;w;;;[;{;IC; "IP6 header ;T;[;![;"I"IP6 header;T;#0;$@p;.F;/o;0;1T;2i";3i";%@;&I"Socket::IPPROTO_IPV6;F;xI"INTEGER2NUM(IPPROTO_IPV6);To;u;[[@i);F;;B ;;w;;;[;{;IC; "IP6 no next header ;T;[;![;"I"IP6 no next header;T;#0;$@|;.F;/o;0;1T;2i(;3i(;%@;&I"Socket::IPPROTO_NONE;F;xI"INTEGER2NUM(IPPROTO_NONE);To;u;[[@i/;F;;C ;;w;;;[;{;IC; "IP6 routing header ;T;[;![;"I"IP6 routing header;T;#0;$@;.F;/o;0;1T;2i.;3i.;%@;&I"Socket::IPPROTO_ROUTING;F;xI"!INTEGER2NUM(IPPROTO_ROUTING);To;u;[[@i5;F;;D ;;w;;;[;{;IC; "Raw IP packet ;T;[;![;"I"Raw IP packet;T;#0;$@;.F;/o;0;1T;2i4;3i4;%@;&I"Socket::IPPROTO_RAW;F;xI"INTEGER2NUM(IPPROTO_RAW);To;u;[[@i;;F;;E ;;w;;;[;{;IC; "Maximum IPPROTO constant ;T;[;![;"I"Maximum IPPROTO constant;T;#0;$@;.F;/o;0;1T;2i:;3i:;%@;&I"Socket::IPPROTO_MAX;F;xI"INTEGER2NUM(IPPROTO_MAX);To;u;[[@iA;F;;F ;;w;;;[;{;IC; "0Default minimum address for bind or connect ;T;[;![;"I"0Default minimum address for bind or connect;T;#0;$@;.F;/o;0;1T;2i@;3i@;%@;&I"Socket::IPPORT_RESERVED;F;xI"!INTEGER2NUM(IPPORT_RESERVED);To;u;[[@iG;F;;G ;;w;;;[;{;IC; "0Default maximum address for bind or connect ;T;[;![;"I"0Default maximum address for bind or connect;T;#0;$@;.F;/o;0;1T;2iF;3iF;%@;&I" Socket::IPPORT_USERRESERVED;F;xI"%INTEGER2NUM(IPPORT_USERRESERVED);To;u;[[@iM;F;;H ;;w;;;[;{;IC; "lA socket bound to INADDR_ANY receives packets from all interfaces and sends from the default IP address ;T;[;![;"I"lA socket bound to INADDR_ANY receives packets from all interfaces and sends from the default IP address;T;#0;$@;.F;/o;0;1T;2iL;3iL;%@;&I"Socket::INADDR_ANY;F;xI"INTEGER2NUM(INADDR_ANY);To;u;[[@iS;F;;I ;;w;;;[;{;IC; ""The network broadcast address ;T;[;![;"I""The network broadcast address;T;#0;$@;.F;/o;0;1T;2iR;3iR;%@;&I"Socket::INADDR_BROADCAST;F;xI""INTEGER2NUM(INADDR_BROADCAST);To;u;[[@iY;F;;J ;;w;;;[;{;IC; "The loopback address ;T;[;![;"I"The loopback address;T;#0;$@;.F;/o;0;1T;2iX;3iX;%@;&I"Socket::INADDR_LOOPBACK;F;xI"!INTEGER2NUM(INADDR_LOOPBACK);To;u;[[@i_;F;;K ;;w;;;[;{;IC; "!The reserved multicast group ;T;[;![;"I"!The reserved multicast group;T;#0;$@;.F;/o;0;1T;2i^;3i^;%@;&I" Socket::INADDR_UNSPEC_GROUP;F;xI"%INTEGER2NUM(INADDR_UNSPEC_GROUP);To;u;[[@ie;F;;L ;;w;;;[;{;IC; "3Multicast group for all systems on this subset ;T;[;![;"I"3Multicast group for all systems on this subset;T;#0;$@;.F;/o;0;1T;2id;3id;%@;&I""Socket::INADDR_ALLHOSTS_GROUP;F;xI"'INTEGER2NUM(INADDR_ALLHOSTS_GROUP);To;u;[[@ik;F;;M ;;w;;;[;{;IC; "+The last local network multicast group ;T;[;![;"I"+The last local network multicast group;T;#0;$@;.F;/o;0;1T;2ij;3ij;%@;&I"#Socket::INADDR_MAX_LOCAL_GROUP;F;xI"(INTEGER2NUM(INADDR_MAX_LOCAL_GROUP);To;u;[[@iq;F;;N ;;w;;;[;{;IC; "/A bitmask for matching no valid IP address ;T;[;![;"I"/A bitmask for matching no valid IP address;T;#0;$@ ;.F;/o;0;1T;2ip;3ip;%@;&I"Socket::INADDR_NONE;F;xI"INTEGER2NUM(INADDR_NONE);To;u;[[@iw;F;;O ;;w;;;[;{;IC; ")IP options to be included in packets ;T;[;![;"I")IP options to be included in packets;T;#0;$@;.F;/o;0;1T;2iv;3iv;%@;&I"Socket::IP_OPTIONS;F;xI"INTEGER2NUM(IP_OPTIONS);To;u;[[@i};F;;P ;;w;;;[;{;IC; "!Header is included with data ;T;[;![;"I"!Header is included with data;T;#0;$@$;.F;/o;0;1T;2i|;3i|;%@;&I"Socket::IP_HDRINCL;F;xI"INTEGER2NUM(IP_HDRINCL);To;u;[[@i;F;;Q ;;w;;;[;{;IC; "IP type-of-service ;T;[;![;"I"IP type-of-service;T;#0;$@0;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_TOS;F;xI"INTEGER2NUM(IP_TOS);To;u;[[@i;F;;R ;;w;;;[;{;IC; "IP time-to-live ;T;[;![;"I"IP time-to-live;T;#0;$@<;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_TTL;F;xI"INTEGER2NUM(IP_TTL);To;u;[[@i;F;;S ;;w;;;[;{;IC; ")Receive all IP options with datagram ;T;[;![;"I")Receive all IP options with datagram;T;#0;$@H;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_RECVOPTS;F;xI"INTEGER2NUM(IP_RECVOPTS);To;u;[[@i;F;;T ;;w;;;[;{;IC; "(Receive all IP options for response ;T;[;![;"I"(Receive all IP options for response;T;#0;$@T;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_RECVRETOPTS;F;xI" INTEGER2NUM(IP_RECVRETOPTS);To;u;[[@i;F;;U ;;w;;;[;{;IC; "1Receive IP destination address with datagram ;T;[;![;"I"1Receive IP destination address with datagram;T;#0;$@`;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_RECVDSTADDR;F;xI" INTEGER2NUM(IP_RECVDSTADDR);To;u;[[@i;F;;V ;;w;;;[;{;IC; "+IP options to be included in datagrams ;T;[;![;"I"+IP options to be included in datagrams;T;#0;$@l;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_RETOPTS;F;xI"INTEGER2NUM(IP_RETOPTS);To;u;[[@i;F;;W ;;w;;;[;{;IC; "-Minimum TTL allowed for received packets ;T;[;![;"I"-Minimum TTL allowed for received packets;T;#0;$@x;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_MINTTL;F;xI"INTEGER2NUM(IP_MINTTL);To;u;[[@i;F;;X ;;w;;;[;{;IC; "Don't fragment packets ;T;[;![;"I"Don't fragment packets;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_DONTFRAG;F;xI"INTEGER2NUM(IP_DONTFRAG);To;u;[[@i;F;;Y ;;w;;;[;{;IC; ".Source address for outgoing UDP datagrams ;T;[;![;"I".Source address for outgoing UDP datagrams;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_SENDSRCADDR;F;xI" INTEGER2NUM(IP_SENDSRCADDR);To;u;[[@i;F;;Z ;;w;;;[;{;IC; "PForce outgoing broadcast datagrams to have the undirected broadcast address ;T;[;![;"I"PForce outgoing broadcast datagrams to have the undirected broadcast address;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_ONESBCAST;F;xI"INTEGER2NUM(IP_ONESBCAST);To;u;[[@i;F;;[ ;;w;;;[;{;IC; ""Receive IP TTL with datagrams ;T;[;![;"I""Receive IP TTL with datagrams;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_RECVTTL;F;xI"INTEGER2NUM(IP_RECVTTL);To;u;[[@i;F;;\ ;;w;;;[;{;IC; "1Receive interface information with datagrams ;T;[;![;"I"1Receive interface information with datagrams;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_RECVIF;F;xI"INTEGER2NUM(IP_RECVIF);To;u;[[@i;F;;] ;;w;;;[;{;IC; ".Receive link-layer address with datagrams ;T;[;![;"I".Receive link-layer address with datagrams;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_RECVSLLA;F;xI"INTEGER2NUM(IP_RECVSLLA);To;u;[[@i;F;;^ ;;w;;;[;{;IC; "ASet the port range for sockets with unspecified port numbers ;T;[;![;"I"ASet the port range for sockets with unspecified port numbers;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_PORTRANGE;F;xI"INTEGER2NUM(IP_PORTRANGE);To;u;[[@i;F;;_ ;;w;;;[;{;IC; "IP multicast interface ;T;[;![;"I"IP multicast interface;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_MULTICAST_IF;F;xI"!INTEGER2NUM(IP_MULTICAST_IF);To;u;[[@i;F;;` ;;w;;;[;{;IC; "IP multicast TTL ;T;[;![;"I"IP multicast TTL;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_MULTICAST_TTL;F;xI""INTEGER2NUM(IP_MULTICAST_TTL);To;u;[[@i;F;;a ;;w;;;[;{;IC; "IP multicast loopback ;T;[;![;"I"IP multicast loopback;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_MULTICAST_LOOP;F;xI"#INTEGER2NUM(IP_MULTICAST_LOOP);To;u;[[@i;F;;b ;;w;;;[;{;IC; "%Add a multicast group membership ;T;[;![;"I"%Add a multicast group membership;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_ADD_MEMBERSHIP;F;xI"#INTEGER2NUM(IP_ADD_MEMBERSHIP);To;u;[[@i;F;;c ;;w;;;[;{;IC; "&Drop a multicast group membership ;T;[;![;"I"&Drop a multicast group membership;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_DROP_MEMBERSHIP;F;xI"$INTEGER2NUM(IP_DROP_MEMBERSHIP);To;u;[[@i;F;;d ;;w;;;[;{;IC; "Default multicast TTL ;T;[;![;"I"Default multicast TTL;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"%Socket::IP_DEFAULT_MULTICAST_TTL;F;xI"*INTEGER2NUM(IP_DEFAULT_MULTICAST_TTL);To;u;[[@i;F;;e ;;w;;;[;{;IC; "Default multicast loopback ;T;[;![;"I"Default multicast loopback;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;&I"&Socket::IP_DEFAULT_MULTICAST_LOOP;F;xI"+INTEGER2NUM(IP_DEFAULT_MULTICAST_LOOP);To;u;[[@i;F;;f ;;w;;;[;{;IC; "6Maximum number multicast groups a socket can join ;T;[;![;"I"6Maximum number multicast groups a socket can join;T;#0;$@,;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_MAX_MEMBERSHIPS;F;xI"$INTEGER2NUM(IP_MAX_MEMBERSHIPS);To;u;[[@i;F;;g ;;w;;;[;{;IC; "PNotify transit routers to more closely examine the contents of an IP packet ;T;[;![;"I"PNotify transit routers to more closely examine the contents of an IP packet;T;#0;$@8;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_ROUTER_ALERT;F;xI"!INTEGER2NUM(IP_ROUTER_ALERT);To;u;[[@i ;F;;h ;;w;;;[;{;IC; ".Receive packet information with datagrams ;T;[;![;"I".Receive packet information with datagrams;T;#0;$@D;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IP_PKTINFO;F;xI"INTEGER2NUM(IP_PKTINFO);To;u;[[@i;F;;i ;;w;;;[;{;IC; "*Receive packet options with datagrams ;T;[;![;"I"*Receive packet options with datagrams;T;#0;$@P;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_PKTOPTIONS;F;xI"INTEGER2NUM(IP_PKTOPTIONS);To;u;[[@i;F;;j ;;w;;;[;{;IC; "Path MTU discovery ;T;[;![;"I"Path MTU discovery;T;#0;$@\;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_MTU_DISCOVER;F;xI"!INTEGER2NUM(IP_MTU_DISCOVER);To;u;[[@i;F;;k ;;w;;;[;{;IC; "3Enable extended reliable error message passing ;T;[;![;"I"3Enable extended reliable error message passing;T;#0;$@h;.F;/o;0;1T;2i;3i;%@;&I"Socket::IP_RECVERR;F;xI"INTEGER2NUM(IP_RECVERR);To;u;[[@i%;F;;l ;;w;;;[;{;IC; "&Receive TOS with incoming packets ;T;[;![;"I"&Receive TOS with incoming packets;T;#0;$@t;.F;/o;0;1T;2i$;3i$;%@;&I"Socket::IP_RECVTOS;F;xI"INTEGER2NUM(IP_RECVTOS);To;u;[[@i+;F;;m ;;w;;;[;{;IC; "0The Maximum Transmission Unit of the socket ;T;[;![;"I"0The Maximum Transmission Unit of the socket;T;#0;$@;.F;/o;0;1T;2i*;3i*;%@;&I"Socket::IP_MTU;F;xI"INTEGER2NUM(IP_MTU);To;u;[[@i1;F;;n ;;w;;;[;{;IC; ".Allow binding to nonexistent IP addresses ;T;[;![;"I".Allow binding to nonexistent IP addresses;T;#0;$@;.F;/o;0;1T;2i0;3i0;%@;&I"Socket::IP_FREEBIND;F;xI"INTEGER2NUM(IP_FREEBIND);To;u;[[@i7;F;;o ;;w;;;[;{;IC; "IPsec security policy ;T;[;![;"I"IPsec security policy;T;#0;$@;.F;/o;0;1T;2i6;3i6;%@;&I"Socket::IP_IPSEC_POLICY;F;xI"!INTEGER2NUM(IP_IPSEC_POLICY);To;u;[[@i=;F;;p ;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"Socket::IP_XFRM_POLICY;F;xI" INTEGER2NUM(IP_XFRM_POLICY);To;u;[[@iC;F;;q ;;w;;;[;{;IC; ",Retrieve security context with datagram ;T;[;![;"I",Retrieve security context with datagram;T;#0;$@;.F;/o;0;1T;2iB;3iB;%@;&I"Socket::IP_PASSSEC;F;xI"INTEGER2NUM(IP_PASSSEC);To;u;[[@iI;F;;r ;;w;;;[;{;IC; "Transparent proxy ;T;[;![;"I"Transparent proxy;T;#0;$@;.F;/o;0;1T;2iH;3iH;%@;&I"Socket::IP_TRANSPARENT;F;xI" INTEGER2NUM(IP_TRANSPARENT);To;u;[[@iO;F;;s ;;w;;;[;{;IC; "Never send DF frames ;T;[;![;"I"Never send DF frames;T;#0;$@;.F;/o;0;1T;2iN;3iN;%@;&I"Socket::IP_PMTUDISC_DONT;F;xI""INTEGER2NUM(IP_PMTUDISC_DONT);To;u;[[@iU;F;;t ;;w;;;[;{;IC; "Use per-route hints ;T;[;![;"I"Use per-route hints;T;#0;$@;.F;/o;0;1T;2iT;3iT;%@;&I"Socket::IP_PMTUDISC_WANT;F;xI""INTEGER2NUM(IP_PMTUDISC_WANT);To;u;[[@i[;F;;u ;;w;;;[;{;IC; "Always send DF frames ;T;[;![;"I"Always send DF frames;T;#0;$@;.F;/o;0;1T;2iZ;3iZ;%@;&I"Socket::IP_PMTUDISC_DO;F;xI" INTEGER2NUM(IP_PMTUDISC_DO);To;u;[[@ia;F;;v ;;w;;;[;{;IC; ">Unblock IPv4 multicast packets with a give source address ;T;[;![;"I">Unblock IPv4 multicast packets with a give source address;T;#0;$@;.F;/o;0;1T;2i`;3i`;%@;&I"Socket::IP_UNBLOCK_SOURCE;F;xI"#INTEGER2NUM(IP_UNBLOCK_SOURCE);To;u;[[@ig;F;;w ;;w;;;[;{;IC; ";.F;/o;0;1T;2i;3i;%@;&I"!Socket::MCAST_UNBLOCK_SOURCE;F;xI"&INTEGER2NUM(MCAST_UNBLOCK_SOURCE);To;u;[[@i;F;;~ ;;w;;;[;{;IC; "Leave a multicast group ;T;[;![;"I"Leave a multicast group;T;#0;$@J;.F;/o;0;1T;2i;3i;%@;&I"Socket::MCAST_LEAVE_GROUP;F;xI"#INTEGER2NUM(MCAST_LEAVE_GROUP);To;u;[[@i;F;; ;;w;;;[;{;IC; ""Join a multicast source group ;T;[;![;"I""Join a multicast source group;T;#0;$@V;.F;/o;0;1T;2i;3i;%@;&I"$Socket::MCAST_JOIN_SOURCE_GROUP;F;xI")INTEGER2NUM(MCAST_JOIN_SOURCE_GROUP);To;u;[[@i;F;; ;;w;;;[;{;IC; "#Leave a multicast source group ;T;[;![;"I"#Leave a multicast source group;T;#0;$@b;.F;/o;0;1T;2i;3i;%@;&I"%Socket::MCAST_LEAVE_SOURCE_GROUP;F;xI"*INTEGER2NUM(MCAST_LEAVE_SOURCE_GROUP);To;u;[[@i;F;; ;;w;;;[;{;IC; "Multicast source filtering ;T;[;![;"I"Multicast source filtering;T;#0;$@n;.F;/o;0;1T;2i;3i;%@;&I"Socket::MCAST_MSFILTER;F;xI" INTEGER2NUM(MCAST_MSFILTER);To;u;[[@i;F;; ;;w;;;[;{;IC; "&Exclusive multicast source filter ;T;[;![;"I"&Exclusive multicast source filter;T;#0;$@z;.F;/o;0;1T;2i;3i;%@;&I"Socket::MCAST_EXCLUDE;F;xI"INTEGER2NUM(MCAST_EXCLUDE);To;u;[[@i;F;; ;;w;;;[;{;IC; "&Inclusive multicast source filter ;T;[;![;"I"&Inclusive multicast source filter;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::MCAST_INCLUDE;F;xI"INTEGER2NUM(MCAST_INCLUDE);To;u;[[@i;F;; ;;w;;;[;{;IC; "Debug info recording ;T;[;![;"I"Debug info recording;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_DEBUG;F;xI"INTEGER2NUM(SO_DEBUG);To;u;[[@i;F;; ;;w;;;[;{;IC; "Allow local address reuse ;T;[;![;"I"Allow local address reuse;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_REUSEADDR;F;xI"INTEGER2NUM(SO_REUSEADDR);To;u;[[@i;F;; ;;w;;;[;{;IC; "'Allow local address and port reuse ;T;[;![;"I"'Allow local address and port reuse;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_REUSEPORT;F;xI"INTEGER2NUM(SO_REUSEPORT);To;u;[[@i;F;; ;;w;;;[;{;IC; "Get the socket type ;T;[;![;"I"Get the socket type;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_TYPE;F;xI"INTEGER2NUM(SO_TYPE);To;u;[[@i;F;; ;;w;;;[;{;IC; "#Get and clear the error status ;T;[;![;"I"#Get and clear the error status;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_ERROR;F;xI"INTEGER2NUM(SO_ERROR);To;u;[[@i;F;; ;;w;;;[;{;IC; "Use interface addresses ;T;[;![;"I"Use interface addresses;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_DONTROUTE;F;xI"INTEGER2NUM(SO_DONTROUTE);To;u;[[@i;F;; ;;w;;;[;{;IC; ")Permit sending of broadcast messages ;T;[;![;"I")Permit sending of broadcast messages;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_BROADCAST;F;xI"INTEGER2NUM(SO_BROADCAST);To;u;[[@i;F;; ;;w;;;[;{;IC; "Send buffer size ;T;[;![;"I"Send buffer size;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_SNDBUF;F;xI"INTEGER2NUM(SO_SNDBUF);To;u;[[@i;F;; ;;w;;;[;{;IC; "Receive buffer size ;T;[;![;"I"Receive buffer size;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_RCVBUF;F;xI"INTEGER2NUM(SO_RCVBUF);To;u;[[@i;F;; ;;w;;;[;{;IC; ";Send buffer size without wmem_max limit (Linux 2.6.14) ;T;[;![;"I";Send buffer size without wmem_max limit (Linux 2.6.14);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_SNDBUFFORCE;F;xI" INTEGER2NUM(SO_SNDBUFFORCE);To;u;[[@i;F;; ;;w;;;[;{;IC; ">Receive buffer size without rmem_max limit (Linux 2.6.14) ;T;[;![;"I">Receive buffer size without rmem_max limit (Linux 2.6.14);T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_RCVBUFFORCE;F;xI" INTEGER2NUM(SO_RCVBUFFORCE);To;u;[[@i;F;; ;;w;;;[;{;IC; "Keep connections alive ;T;[;![;"I"Keep connections alive;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_KEEPALIVE;F;xI"INTEGER2NUM(SO_KEEPALIVE);To;u;[[@i;F;; ;;w;;;[;{;IC; ",Leave received out-of-band data in-line ;T;[;![;"I",Leave received out-of-band data in-line;T;#0;$@";.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_OOBINLINE;F;xI"INTEGER2NUM(SO_OOBINLINE);To;u;[[@i;F;; ;;w;;;[;{;IC; "Disable checksums ;T;[;![;"I"Disable checksums;T;#0;$@.;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_NO_CHECK;F;xI"INTEGER2NUM(SO_NO_CHECK);To;u;[[@i ;F;; ;;w;;;[;{;IC; "AThe protocol-defined priority for all packets on this socket ;T;[;![;"I"AThe protocol-defined priority for all packets on this socket;T;#0;$@:;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_PRIORITY;F;xI"INTEGER2NUM(SO_PRIORITY);To;u;[[@i;F;; ;;w;;;[;{;IC; "'Linger on close if data is present ;T;[;![;"I"'Linger on close if data is present;T;#0;$@F;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_LINGER;F;xI"INTEGER2NUM(SO_LINGER);To;u;[[@i;F;; ;;w;;;[;{;IC; "%Receive SCM_CREDENTIALS messages ;T;[;![;"I"%Receive SCM_CREDENTIALS messages;T;#0;$@R;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_PASSCRED;F;xI"INTEGER2NUM(SO_PASSCRED);To;u;[[@i;F;; ;;w;;;[;{;IC; "DThe credentials of the foreign process connected to this socket ;T;[;![;"I"DThe credentials of the foreign process connected to this socket;T;#0;$@^;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_PEERCRED;F;xI"INTEGER2NUM(SO_PEERCRED);To;u;[[@i!;F;; ;;w;;;[;{;IC; "Receive low-water mark ;T;[;![;"I"Receive low-water mark;T;#0;$@j;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::SO_RCVLOWAT;F;xI"INTEGER2NUM(SO_RCVLOWAT);To;u;[[@i';F;; ;;w;;;[;{;IC; "Send low-water mark ;T;[;![;"I"Send low-water mark;T;#0;$@v;.F;/o;0;1T;2i&;3i&;%@;&I"Socket::SO_SNDLOWAT;F;xI"INTEGER2NUM(SO_SNDLOWAT);To;u;[[@i-;F;; ;;w;;;[;{;IC; "Receive timeout ;T;[;![;"I"Receive timeout;T;#0;$@;.F;/o;0;1T;2i,;3i,;%@;&I"Socket::SO_RCVTIMEO;F;xI"INTEGER2NUM(SO_RCVTIMEO);To;u;[[@i3;F;; ;;w;;;[;{;IC; "Send timeout ;T;[;![;"I"Send timeout;T;#0;$@;.F;/o;0;1T;2i2;3i2;%@;&I"Socket::SO_SNDTIMEO;F;xI"INTEGER2NUM(SO_SNDTIMEO);To;u;[[@i9;F;; ;;w;;;[;{;IC; ")Socket has had listen() called on it ;T;[;![;"I")Socket has had listen() called on it;T;#0;$@;.F;/o;0;1T;2i8;3i8;%@;&I"Socket::SO_ACCEPTCONN;F;xI"INTEGER2NUM(SO_ACCEPTCONN);To;u;[[@i?;F;; ;;w;;;[;{;IC; ""Bypass hardware when possible ;T;[;![;"I""Bypass hardware when possible;T;#0;$@;.F;/o;0;1T;2i>;3i>;%@;&I"Socket::SO_USELOOPBACK;F;xI" INTEGER2NUM(SO_USELOOPBACK);To;u;[[@iE;F;; ;;w;;;[;{;IC; "There is an accept filter ;T;[;![;"I"There is an accept filter;T;#0;$@;.F;/o;0;1T;2iD;3iD;%@;&I"Socket::SO_ACCEPTFILTER;F;xI"!INTEGER2NUM(SO_ACCEPTFILTER);To;u;[[@iK;F;; ;;w;;;[;{;IC; "Retain unread data ;T;[;![;"I"Retain unread data;T;#0;$@;.F;/o;0;1T;2iJ;3iJ;%@;&I"Socket::SO_DONTTRUNC;F;xI"INTEGER2NUM(SO_DONTTRUNC);To;u;[[@iQ;F;; ;;w;;;[;{;IC; "(Give a hint when more data is ready ;T;[;![;"I"(Give a hint when more data is ready;T;#0;$@;.F;/o;0;1T;2iP;3iP;%@;&I"Socket::SO_WANTMORE;F;xI"INTEGER2NUM(SO_WANTMORE);To;u;[[@iW;F;; ;;w;;;[;{;IC; ".OOB data is wanted in MSG_FLAG on receive ;T;[;![;"I".OOB data is wanted in MSG_FLAG on receive;T;#0;$@;.F;/o;0;1T;2iV;3iV;%@;&I"Socket::SO_WANTOOBFLAG;F;xI" INTEGER2NUM(SO_WANTOOBFLAG);To;u;[[@i];F;; ;;w;;;[;{;IC; " Get first packet byte count ;T;[;![;"I" Get first packet byte count;T;#0;$@;.F;/o;0;1T;2i\;3i\;%@;&I"Socket::SO_NREAD;F;xI"INTEGER2NUM(SO_NREAD);To;u;[[@ic;F;; ;;w;;;[;{;IC; "2Install socket-level Network Kernel Extension ;T;[;![;"I"2Install socket-level Network Kernel Extension;T;#0;$@;.F;/o;0;1T;2ib;3ib;%@;&I"Socket::SO_NKE;F;xI"INTEGER2NUM(SO_NKE);To;u;[[@ii;F;; ;;w;;;[;{;IC; "Don't SIGPIPE on EPIPE ;T;[;![;"I"Don't SIGPIPE on EPIPE;T;#0;$@;.F;/o;0;1T;2ih;3ih;%@;&I"Socket::SO_NOSIGPIPE;F;xI"INTEGER2NUM(SO_NOSIGPIPE);To;u;[[@io;F;; ;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"'Socket::SO_SECURITY_AUTHENTICATION;F;xI",INTEGER2NUM(SO_SECURITY_AUTHENTICATION);To;u;[[@iu;F;; ;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"-Socket::SO_SECURITY_ENCRYPTION_TRANSPORT;F;xI"2INTEGER2NUM(SO_SECURITY_ENCRYPTION_TRANSPORT);To;u;[[@i{;F;; ;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"+Socket::SO_SECURITY_ENCRYPTION_NETWORK;F;xI"0INTEGER2NUM(SO_SECURITY_ENCRYPTION_NETWORK);To;u;[[@i;F;; ;;w;;;[;{;IC; "/Only send packets from the given interface ;T;[;![;"I"/Only send packets from the given interface;T;#0;$@$;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_BINDTODEVICE;F;xI"!INTEGER2NUM(SO_BINDTODEVICE);To;u;[[@i;F;; ;;w;;;[;{;IC; "Attach an accept filter ;T;[;![;"I"Attach an accept filter;T;#0;$@0;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_ATTACH_FILTER;F;xI""INTEGER2NUM(SO_ATTACH_FILTER);To;u;[[@i;F;; ;;w;;;[;{;IC; "Detach an accept filter ;T;[;![;"I"Detach an accept filter;T;#0;$@<;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_DETACH_FILTER;F;xI""INTEGER2NUM(SO_DETACH_FILTER);To;u;[[@i;F;; ;;w;;;[;{;IC; "6Obtain filter set by SO_ATTACH_FILTER (Linux 3.8) ;T;[;![;"I"6Obtain filter set by SO_ATTACH_FILTER (Linux 3.8);T;#0;$@H;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_GET_FILTER;F;xI"INTEGER2NUM(SO_GET_FILTER);To;u;[[@i;F;; ;;w;;;[;{;IC; " Name of the connecting user ;T;[;![;"I" Name of the connecting user;T;#0;$@T;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_PEERNAME;F;xI"INTEGER2NUM(SO_PEERNAME);To;u;[[@i;F;; ;;w;;;[;{;IC; "/Receive timestamp with datagrams (timeval) ;T;[;![;"I"/Receive timestamp with datagrams (timeval);T;#0;$@`;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_TIMESTAMP;F;xI"INTEGER2NUM(SO_TIMESTAMP);To;u;[[@i;F;; ;;w;;;[;{;IC; ";Receive nanosecond timestamp with datagrams (timespec) ;T;[;![;"I";Receive nanosecond timestamp with datagrams (timespec);T;#0;$@l;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_TIMESTAMPNS;F;xI" INTEGER2NUM(SO_TIMESTAMPNS);To;u;[[@i;F;; ;;w;;;[;{;IC; "/Receive timestamp with datagrams (bintime) ;T;[;![;"I"/Receive timestamp with datagrams (bintime);T;#0;$@x;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_BINTIME;F;xI"INTEGER2NUM(SO_BINTIME);To;u;[[@i;F;; ;;w;;;[;{;IC; "+Receive user credentials with datagram ;T;[;![;"I"+Receive user credentials with datagram;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_RECVUCRED;F;xI"INTEGER2NUM(SO_RECVUCRED);To;u;[[@i;F;; ;;w;;;[;{;IC; ";Mandatory Access Control exemption for unlabeled peers ;T;[;![;"I";Mandatory Access Control exemption for unlabeled peers;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_MAC_EXEMPT;F;xI"INTEGER2NUM(SO_MAC_EXEMPT);To;u;[[@i;F;; ;;w;;;[;{;IC; "Bypass zone boundaries ;T;[;![;"I"Bypass zone boundaries;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_ALLZONES;F;xI"INTEGER2NUM(SO_ALLZONES);To;u;[[@i;F;; ;;w;;;[;{;IC; "2Obtain the security credentials (Linux 2.6.2) ;T;[;![;"I"2Obtain the security credentials (Linux 2.6.2);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_PEERSEC;F;xI"INTEGER2NUM(SO_PEERSEC);To;u;[[@i;F;; ;;w;;;[;{;IC; "3Toggle security context passing (Linux 2.6.18) ;T;[;![;"I"3Toggle security context passing (Linux 2.6.18);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_PASSSEC;F;xI"INTEGER2NUM(SO_PASSSEC);To;u;[[@i;F;; ;;w;;;[;{;IC; "7Set the mark for mark-based routing (Linux 2.6.25) ;T;[;![;"I"7Set the mark for mark-based routing (Linux 2.6.25);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_MARK;F;xI"INTEGER2NUM(SO_MARK);To;u;[[@i;F;; ;;w;;;[;{;IC; "BTime stamping of incoming and outgoing packets (Linux 2.6.30) ;T;[;![;"I"BTime stamping of incoming and outgoing packets (Linux 2.6.30);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_TIMESTAMPING;F;xI"!INTEGER2NUM(SO_TIMESTAMPING);To;u;[[@i;F;; ;;w;;;[;{;IC; "/Protocol given for socket() (Linux 2.6.32) ;T;[;![;"I"/Protocol given for socket() (Linux 2.6.32);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_PROTOCOL;F;xI"INTEGER2NUM(SO_PROTOCOL);To;u;[[@i;F;; ;;w;;;[;{;IC; "-Domain given for socket() (Linux 2.6.32) ;T;[;![;"I"-Domain given for socket() (Linux 2.6.32);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_DOMAIN;F;xI"INTEGER2NUM(SO_DOMAIN);To;u;[[@i;F;; ;;w;;;[;{;IC; "=Toggle cmsg for number of packets dropped (Linux 2.6.33) ;T;[;![;"I"=Toggle cmsg for number of packets dropped (Linux 2.6.33);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_RXQ_OVFL;F;xI"INTEGER2NUM(SO_RXQ_OVFL);To;u;[[@i;F;; ;;w;;;[;{;IC; ",Toggle cmsg for wifi status (Linux 3.3) ;T;[;![;"I",Toggle cmsg for wifi status (Linux 3.3);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_WIFI_STATUS;F;xI" INTEGER2NUM(SO_WIFI_STATUS);To;u;[[@i;F;; ;;w;;;[;{;IC; "$Set the peek offset (Linux 3.4) ;T;[;![;"I"$Set the peek offset (Linux 3.4);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_PEEK_OFF;F;xI"INTEGER2NUM(SO_PEEK_OFF);To;u;[[@i;F;; ;;w;;;[;{;IC; "&Set netns of a socket (Linux 3.4) ;T;[;![;"I"&Set netns of a socket (Linux 3.4);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_NOFCS;F;xI"INTEGER2NUM(SO_NOFCS);To;u;[[@i;F;; ;;w;;;[;{;IC; "5Lock the filter attached to a socket (Linux 3.9) ;T;[;![;"I"5Lock the filter attached to a socket (Linux 3.9);T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_LOCK_FILTER;F;xI" INTEGER2NUM(SO_LOCK_FILTER);To;u;[[@i;F;; ;;w;;;[;{;IC; "GMake select() detect socket error queue with errorfds (Linux 3.10) ;T;[;![;"I"GMake select() detect socket error queue with errorfds (Linux 3.10);T;#0;$@,;.F;/o;0;1T;2i;3i;%@;&I" Socket::SO_SELECT_ERR_QUEUE;F;xI"%INTEGER2NUM(SO_SELECT_ERR_QUEUE);To;u;[[@i ;F;; ;;w;;;[;{;IC; "KSet the threshold in microseconds for low latency polling (Linux 3.11) ;T;[;![;"I"KSet the threshold in microseconds for low latency polling (Linux 3.11);T;#0;$@8;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::SO_BUSY_POLL;F;xI"INTEGER2NUM(SO_BUSY_POLL);To;u;[[@i;F;; ;;w;;;[;{;IC; "NCap the rate computed by transport layer. [bytes per second] (Linux 3.13) ;T;[;![;"I"NCap the rate computed by transport layer. [bytes per second] (Linux 3.13);T;#0;$@D;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_MAX_PACING_RATE;F;xI"$INTEGER2NUM(SO_MAX_PACING_RATE);To;u;[[@i;F;; ;;w;;;[;{;IC; "0Query supported BPF extensions (Linux 3.14) ;T;[;![;"I"0Query supported BPF extensions (Linux 3.14);T;#0;$@P;.F;/o;0;1T;2i;3i;%@;&I"Socket::SO_BPF_EXTENSIONS;F;xI"#INTEGER2NUM(SO_BPF_EXTENSIONS);To;u;[[@i;F;; ;;w;;;[;{;IC; " Interactive socket priority ;T;[;![;"I" Interactive socket priority;T;#0;$@\;.F;/o;0;1T;2i;3i;%@;&I"Socket::SOPRI_INTERACTIVE;F;xI"#INTEGER2NUM(SOPRI_INTERACTIVE);To;u;[[@i#;F;; ;;w;;;[;{;IC; "Normal socket priority ;T;[;![;"I"Normal socket priority;T;#0;$@h;.F;/o;0;1T;2i";3i";%@;&I"Socket::SOPRI_NORMAL;F;xI"INTEGER2NUM(SOPRI_NORMAL);To;u;[[@i);F;; ;;w;;;[;{;IC; "Background socket priority ;T;[;![;"I"Background socket priority;T;#0;$@t;.F;/o;0;1T;2i(;3i(;%@;&I"Socket::SOPRI_BACKGROUND;F;xI""INTEGER2NUM(SOPRI_BACKGROUND);To;u;[[@i/;F;; ;;w;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"Socket::IPX_TYPE;F;xI"INTEGER2NUM(IPX_TYPE);To;u;[[@i5;F;; ;;w;;;[;{;IC; ",Don't delay sending to coalesce packets ;T;[;![;"I",Don't delay sending to coalesce packets;T;#0;$@;.F;/o;0;1T;2i4;3i4;%@;&I"Socket::TCP_NODELAY;F;xI"INTEGER2NUM(TCP_NODELAY);To;u;[[@i;;F;; ;;w;;;[;{;IC; "Set maximum segment size ;T;[;![;"I"Set maximum segment size;T;#0;$@;.F;/o;0;1T;2i:;3i:;%@;&I"Socket::TCP_MAXSEG;F;xI"INTEGER2NUM(TCP_MAXSEG);To;u;[[@iA;F;; ;;w;;;[;{;IC; "5Don't send partial frames (Linux 2.2, glibc 2.2) ;T;[;![;"I"5Don't send partial frames (Linux 2.2, glibc 2.2);T;#0;$@;.F;/o;0;1T;2i@;3i@;%@;&I"Socket::TCP_CORK;F;xI"INTEGER2NUM(TCP_CORK);To;u;[[@iG;F;; ;;w;;;[;{;IC; "ODon't notify a listening socket until data is ready (Linux 2.4, glibc 2.2) ;T;[;![;"I"ODon't notify a listening socket until data is ready (Linux 2.4, glibc 2.2);T;#0;$@;.F;/o;0;1T;2iF;3iF;%@;&I"Socket::TCP_DEFER_ACCEPT;F;xI""INTEGER2NUM(TCP_DEFER_ACCEPT);To;u;[[@iM;F;; ;;w;;;[;{;IC; "BRetrieve information about this socket (Linux 2.4, glibc 2.2) ;T;[;![;"I"BRetrieve information about this socket (Linux 2.4, glibc 2.2);T;#0;$@;.F;/o;0;1T;2iL;3iL;%@;&I"Socket::TCP_INFO;F;xI"INTEGER2NUM(TCP_INFO);To;u;[[@iS;F;; ;;w;;;[;{;IC; "cMaximum number of keepalive probes allowed before dropping a connection (Linux 2.4, glibc 2.2) ;T;[;![;"I"cMaximum number of keepalive probes allowed before dropping a connection (Linux 2.4, glibc 2.2);T;#0;$@;.F;/o;0;1T;2iR;3iR;%@;&I"Socket::TCP_KEEPCNT;F;xI"INTEGER2NUM(TCP_KEEPCNT);To;u;[[@iY;F;; ;;w;;;[;{;IC; "FIdle time before keepalive probes are sent (Linux 2.4, glibc 2.2) ;T;[;![;"I"FIdle time before keepalive probes are sent (Linux 2.4, glibc 2.2);T;#0;$@;.F;/o;0;1T;2iX;3iX;%@;&I"Socket::TCP_KEEPIDLE;F;xI"INTEGER2NUM(TCP_KEEPIDLE);To;u;[[@i_;F;; ;;w;;;[;{;IC; "9Time between keepalive probes (Linux 2.4, glibc 2.2) ;T;[;![;"I"9Time between keepalive probes (Linux 2.4, glibc 2.2);T;#0;$@;.F;/o;0;1T;2i^;3i^;%@;&I"Socket::TCP_KEEPINTVL;F;xI"INTEGER2NUM(TCP_KEEPINTVL);To;u;[[@ie;F;; ;;w;;;[;{;IC; "BLifetime of orphaned FIN_WAIT2 sockets (Linux 2.4, glibc 2.2) ;T;[;![;"I"BLifetime of orphaned FIN_WAIT2 sockets (Linux 2.4, glibc 2.2);T;#0;$@;.F;/o;0;1T;2id;3id;%@;&I"Socket::TCP_LINGER2;F;xI"INTEGER2NUM(TCP_LINGER2);To;u;[[@ik;F;; ;;w;;;[;{;IC; "7Use MD5 digests (RFC2385, Linux 2.6.20, glibc 2.7) ;T;[;![;"I"7Use MD5 digests (RFC2385, Linux 2.6.20, glibc 2.7);T;#0;$@;.F;/o;0;1T;2ij;3ij;%@;&I"Socket::TCP_MD5SIG;F;xI"INTEGER2NUM(TCP_MD5SIG);To;u;[[@iq;F;; ;;w;;;[;{;IC; "Don't use TCP options ;T;[;![;"I"Don't use TCP options;T;#0;$@;.F;/o;0;1T;2ip;3ip;%@;&I"Socket::TCP_NOOPT;F;xI"INTEGER2NUM(TCP_NOOPT);To;u;[[@iw;F;; ;;w;;;[;{;IC; "'Don't push the last block of write ;T;[;![;"I"'Don't push the last block of write;T;#0;$@;.F;/o;0;1T;2iv;3iv;%@;&I"Socket::TCP_NOPUSH;F;xI"INTEGER2NUM(TCP_NOPUSH);To;u;[[@i};F;; ;;w;;;[;{;IC; "2Enable quickack mode (Linux 2.4.4, glibc 2.3) ;T;[;![;"I"2Enable quickack mode (Linux 2.4.4, glibc 2.3);T;#0;$@;.F;/o;0;1T;2i|;3i|;%@;&I"Socket::TCP_QUICKACK;F;xI"INTEGER2NUM(TCP_QUICKACK);To;u;[[@i;F;; ;;w;;;[;{;IC; "TNumber of SYN retransmits before a connection is dropped (Linux 2.4, glibc 2.2) ;T;[;![;"I"TNumber of SYN retransmits before a connection is dropped (Linux 2.4, glibc 2.2);T;#0;$@&;.F;/o;0;1T;2i;3i;%@;&I"Socket::TCP_SYNCNT;F;xI"INTEGER2NUM(TCP_SYNCNT);To;u;[[@i;F;; ;;w;;;[;{;IC; "CClamp the size of the advertised window (Linux 2.4, glibc 2.2) ;T;[;![;"I"CClamp the size of the advertised window (Linux 2.4, glibc 2.2);T;#0;$@2;.F;/o;0;1T;2i;3i;%@;&I"Socket::TCP_WINDOW_CLAMP;F;xI""INTEGER2NUM(TCP_WINDOW_CLAMP);To;u;[[@i;F;; ;;w;;;[;{;IC; "AReduce step of the handshake process (Linux 3.7, glibc 2.18) ;T;[;![;"I"AReduce step of the handshake process (Linux 3.7, glibc 2.18);T;#0;$@>;.F;/o;0;1T;2i;3i;%@;&I"Socket::TCP_FASTOPEN;F;xI"INTEGER2NUM(TCP_FASTOPEN);To;u;[[@i;F;; ;;w;;;[;{;IC; "?TCP congestion control algorithm (Linux 2.6.13, glibc 2.6) ;T;[;![;"I"?TCP congestion control algorithm (Linux 2.6.13, glibc 2.6);T;#0;$@J;.F;/o;0;1T;2i;3i;%@;&I"Socket::TCP_CONGESTION;F;xI" INTEGER2NUM(TCP_CONGESTION);To;u;[[@i;F;; ;;w;;;[;{;IC; "7TCP Cookie Transactions (Linux 2.6.33, glibc 2.18) ;T;[;![;"I"7TCP Cookie Transactions (Linux 2.6.33, glibc 2.18);T;#0;$@V;.F;/o;0;1T;2i;3i;%@;&I"$Socket::TCP_COOKIE_TRANSACTIONS;F;xI")INTEGER2NUM(TCP_COOKIE_TRANSACTIONS);To;u;[[@i;F;; ;;w;;;[;{;IC; "@Sequence of a queue for repair mode (Linux 3.5, glibc 2.18) ;T;[;![;"I"@Sequence of a queue for repair mode (Linux 3.5, glibc 2.18);T;#0;$@b;.F;/o;0;1T;2i;3i;%@;&I"Socket::TCP_QUEUE_SEQ;F;xI"INTEGER2NUM(TCP_QUEUE_SEQ);To;u;[[@i;F;; ;;w;;;[;{;IC; "(Repair mode (Linux 3.5, glibc 2.18) ;T;[;![;"I"(Repair mode (Linux 3.5, glibc 2.18);T;#0;$@n;.F;/o;0;1T;2i;3i;%@;&I"Socket::TCP_REPAIR;F;xI"INTEGER2NUM(TCP_REPAIR);To;u;[[@i;F;; ;;w;;;[;{;IC; "4Options for repair mode (Linux 3.5, glibc 2.18) ;T;[;![;"I"4Options for repair mode (Linux 3.5, glibc 2.18);T;#0;$@z;.F;/o;0;1T;2i;3i;%@;&I"Socket::TCP_REPAIR_OPTIONS;F;xI"$INTEGER2NUM(TCP_REPAIR_OPTIONS);To;u;[[@i;F;; ;;w;;;[;{;IC; "2Queue for repair mode (Linux 3.5, glibc 2.18) ;T;[;![;"I"2Queue for repair mode (Linux 3.5, glibc 2.18);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::TCP_REPAIR_QUEUE;F;xI""INTEGER2NUM(TCP_REPAIR_QUEUE);To;u;[[@i;F;; ;;w;;;[;{;IC; "TDuplicated acknowledgments handling for thin-streams (Linux 2.6.34, glibc 2.18) ;T;[;![;"I"TDuplicated acknowledgments handling for thin-streams (Linux 2.6.34, glibc 2.18);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::TCP_THIN_DUPACK;F;xI"!INTEGER2NUM(TCP_THIN_DUPACK);To;u;[[@i;F;; ;;w;;;[;{;IC; "@Linear timeouts for thin-streams (Linux 2.6.34, glibc 2.18) ;T;[;![;"I"@Linear timeouts for thin-streams (Linux 2.6.34, glibc 2.18);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"%Socket::TCP_THIN_LINEAR_TIMEOUTS;F;xI"*INTEGER2NUM(TCP_THIN_LINEAR_TIMEOUTS);To;u;[[@i;F;; ;;w;;;[;{;IC; "*TCP timestamp (Linux 3.9, glibc 2.18) ;T;[;![;"I"*TCP timestamp (Linux 3.9, glibc 2.18);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::TCP_TIMESTAMP;F;xI"INTEGER2NUM(TCP_TIMESTAMP);To;u;[[@i;F;; ;;w;;;[;{;IC; "NMax timeout before a TCP connection is aborted (Linux 2.6.37, glibc 2.18) ;T;[;![;"I"NMax timeout before a TCP connection is aborted (Linux 2.6.37, glibc 2.18);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::TCP_USER_TIMEOUT;F;xI""INTEGER2NUM(TCP_USER_TIMEOUT);To;u;[[@i;F;; ;;w;;;[;{;IC; "9Don't send partial frames (Linux 2.5.44, glibc 2.11) ;T;[;![;"I"9Don't send partial frames (Linux 2.5.44, glibc 2.11);T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::UDP_CORK;F;xI"INTEGER2NUM(UDP_CORK);To;u;[[@i;F;; ;;w;;;[;{;IC; ".Address family for hostname not supported ;T;[;![;"I".Address family for hostname not supported;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::EAI_ADDRFAMILY;F;xI" INTEGER2NUM(EAI_ADDRFAMILY);To;u;[[@i;F;; ;;w;;;[;{;IC; ")Temporary failure in name resolution ;T;[;![;"I")Temporary failure in name resolution;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::EAI_AGAIN;F;xI"INTEGER2NUM(EAI_AGAIN);To;u;[[@i;F;; ;;w;;;[;{;IC; "Invalid flags ;T;[;![;"I"Invalid flags;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::EAI_BADFLAGS;F;xI"INTEGER2NUM(EAI_BADFLAGS);To;u;[[@i;F;; ;;w;;;[;{;IC; "/Non-recoverable failure in name resolution ;T;[;![;"I"/Non-recoverable failure in name resolution;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::EAI_FAIL;F;xI"INTEGER2NUM(EAI_FAIL);To;u;[[@i;F;; ;;w;;;[;{;IC; "!Address family not supported ;T;[;![;"I"!Address family not supported;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::EAI_FAMILY;F;xI"INTEGER2NUM(EAI_FAMILY);To;u;[[@i;F;; ;;w;;;[;{;IC; "Memory allocation failure ;T;[;![;"I"Memory allocation failure;T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;&I"Socket::EAI_MEMORY;F;xI"INTEGER2NUM(EAI_MEMORY);To;u;[[@i;F;; ;;w;;;[;{;IC; "(No address associated with hostname ;T;[;![;"I"(No address associated with hostname;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::EAI_NODATA;F;xI"INTEGER2NUM(EAI_NODATA);To;u;[[@i;F;; ;;w;;;[;{;IC; "(Hostname nor servname, or not known ;T;[;![;"I"(Hostname nor servname, or not known;T;#0;$@";.F;/o;0;1T;2i;3i;%@;&I"Socket::EAI_NONAME;F;xI"INTEGER2NUM(EAI_NONAME);To;u;[[@i;F;; ;;w;;;[;{;IC; "Argument buffer overflow ;T;[;![;"I"Argument buffer overflow;T;#0;$@.;.F;/o;0;1T;2i;3i;%@;&I"Socket::EAI_OVERFLOW;F;xI"INTEGER2NUM(EAI_OVERFLOW);To;u;[[@i ;F;; ;;w;;;[;{;IC; "+Servname not supported for socket type ;T;[;![;"I"+Servname not supported for socket type;T;#0;$@:;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::EAI_SERVICE;F;xI"INTEGER2NUM(EAI_SERVICE);To;u;[[@i;F;; ;;w;;;[;{;IC; "Socket type not supported ;T;[;![;"I"Socket type not supported;T;#0;$@F;.F;/o;0;1T;2i;3i;%@;&I"Socket::EAI_SOCKTYPE;F;xI"INTEGER2NUM(EAI_SOCKTYPE);To;u;[[@i;F;; ;;w;;;[;{;IC; "#System error returned in errno ;T;[;![;"I"#System error returned in errno;T;#0;$@R;.F;/o;0;1T;2i;3i;%@;&I"Socket::EAI_SYSTEM;F;xI"INTEGER2NUM(EAI_SYSTEM);To;u;[[@i;F;; ;;w;;;[;{;IC; "Invalid value for hints ;T;[;![;"I"Invalid value for hints;T;#0;$@^;.F;/o;0;1T;2i;3i;%@;&I"Socket::EAI_BADHINTS;F;xI"INTEGER2NUM(EAI_BADHINTS);To;u;[[@i%;F;; ;;w;;;[;{;IC; "!Resolved protocol is unknown ;T;[;![;"I"!Resolved protocol is unknown;T;#0;$@j;.F;/o;0;1T;2i$;3i$;%@;&I"Socket::EAI_PROTOCOL;F;xI"INTEGER2NUM(EAI_PROTOCOL);To;u;[[@i+;F;; ;;w;;;[;{;IC; "(Maximum error code from getaddrinfo ;T;[;![;"I"(Maximum error code from getaddrinfo;T;#0;$@v;.F;/o;0;1T;2i*;3i*;%@;&I"Socket::EAI_MAX;F;xI"INTEGER2NUM(EAI_MAX);To;u;[[@i1;F;; ;;w;;;[;{;IC; "#Get address to use with bind() ;T;[;![;"I"#Get address to use with bind();T;#0;$@;.F;/o;0;1T;2i0;3i0;%@;&I"Socket::AI_PASSIVE;F;xI"INTEGER2NUM(AI_PASSIVE);To;u;[[@i7;F;; ;;w;;;[;{;IC; "Fill in the canonical name ;T;[;![;"I"Fill in the canonical name;T;#0;$@;.F;/o;0;1T;2i6;3i6;%@;&I"Socket::AI_CANONNAME;F;xI"INTEGER2NUM(AI_CANONNAME);To;u;[[@i=;F;; ;;w;;;[;{;IC; "!Prevent host name resolution ;T;[;![;"I"!Prevent host name resolution;T;#0;$@;.F;/o;0;1T;2i<;3i<;%@;&I"Socket::AI_NUMERICHOST;F;xI" INTEGER2NUM(AI_NUMERICHOST);To;u;[[@iC;F;; ;;w;;;[;{;IC; "$Prevent service name resolution ;T;[;![;"I"$Prevent service name resolution;T;#0;$@;.F;/o;0;1T;2iB;3iB;%@;&I"Socket::AI_NUMERICSERV;F;xI" INTEGER2NUM(AI_NUMERICSERV);To;u;[[@iI;F;; ;;w;;;[;{;IC; ">Valid flag mask for getaddrinfo (not for application use) ;T;[;![;"I">Valid flag mask for getaddrinfo (not for application use);T;#0;$@;.F;/o;0;1T;2iH;3iH;%@;&I"Socket::AI_MASK;F;xI"INTEGER2NUM(AI_MASK);To;u;[[@iO;F;; ;;w;;;[;{;IC; "Allow all addresses ;T;[;![;"I"Allow all addresses;T;#0;$@;.F;/o;0;1T;2iN;3iN;%@;&I"Socket::AI_ALL;F;xI"INTEGER2NUM(AI_ALL);To;u;[[@iU;F;; ;;w;;;[;{;IC; ";Accept IPv4 mapped addresses if the kernel supports it ;T;[;![;"I";Accept IPv4 mapped addresses if the kernel supports it;T;#0;$@;.F;/o;0;1T;2iT;3iT;%@;&I"Socket::AI_V4MAPPED_CFG;F;xI"!INTEGER2NUM(AI_V4MAPPED_CFG);To;u;[[@i[;F;; ;;w;;;[;{;IC; "+Accept only if any address is assigned ;T;[;![;"I"+Accept only if any address is assigned;T;#0;$@;.F;/o;0;1T;2iZ;3iZ;%@;&I"Socket::AI_ADDRCONFIG;F;xI"INTEGER2NUM(AI_ADDRCONFIG);To;u;[[@ia;F;; ;;w;;;[;{;IC; "&Accept IPv4-mapped IPv6 addresses ;T;[;![;"I"&Accept IPv4-mapped IPv6 addresses;T;#0;$@;.F;/o;0;1T;2i`;3i`;%@;&I"Socket::AI_V4MAPPED;F;xI"INTEGER2NUM(AI_V4MAPPED);To;u;[[@ig;F;; ;;w;;;[;{;IC; ""Default flags for getaddrinfo ;T;[;![;"I""Default flags for getaddrinfo;T;#0;$@;.F;/o;0;1T;2if;3if;%@;&I"Socket::AI_DEFAULT;F;xI"INTEGER2NUM(AI_DEFAULT);To;u;[[@im;F;; ;;w;;;[;{;IC; "!Maximum length of a hostname ;T;[;![;"I"!Maximum length of a hostname;T;#0;$@;.F;/o;0;1T;2il;3il;%@;&I"Socket::NI_MAXHOST;F;xI"INTEGER2NUM(NI_MAXHOST);To;u;[[@is;F;; ;;w;;;[;{;IC; "%Maximum length of a service name ;T;[;![;"I"%Maximum length of a service name;T;#0;$@;.F;/o;0;1T;2ir;3ir;%@;&I"Socket::NI_MAXSERV;F;xI"INTEGER2NUM(NI_MAXSERV);To;u;[[@iy;F;; ;;w;;;[;{;IC; "HAn FQDN is not required for local hosts, return only the local part ;T;[;![;"I"HAn FQDN is not required for local hosts, return only the local part;T;#0;$@;.F;/o;0;1T;2ix;3ix;%@;&I"Socket::NI_NOFQDN;F;xI"INTEGER2NUM(NI_NOFQDN);To;u;[[@i;F;; ;;w;;;[;{;IC; "Return a numeric address ;T;[;![;"I"Return a numeric address;T;#0;$@;.F;/o;0;1T;2i~;3i~;%@;&I"Socket::NI_NUMERICHOST;F;xI" INTEGER2NUM(NI_NUMERICHOST);To;u;[[@i;F;; ;;w;;;[;{;IC; "A name is required ;T;[;![;"I"A name is required;T;#0;$@*;.F;/o;0;1T;2i;3i;%@;&I"Socket::NI_NAMEREQD;F;xI"INTEGER2NUM(NI_NAMEREQD);To;u;[[@i;F;; ;;w;;;[;{;IC; ".Return the service name as a digit string ;T;[;![;"I".Return the service name as a digit string;T;#0;$@6;.F;/o;0;1T;2i;3i;%@;&I"Socket::NI_NUMERICSERV;F;xI" INTEGER2NUM(NI_NUMERICSERV);To;u;[[@i;F;; ;;w;;;[;{;IC; "EThe service specified is a datagram service (looks up UDP ports) ;T;[;![;"I"EThe service specified is a datagram service (looks up UDP ports);T;#0;$@B;.F;/o;0;1T;2i;3i;%@;&I"Socket::NI_DGRAM;F;xI"INTEGER2NUM(NI_DGRAM);To;u;[[@i;F;; ;;w;;;[;{;IC; "-Shut down the reading side of the socket ;T;[;![;"I"-Shut down the reading side of the socket;T;#0;$@N;.F;/o;0;1T;2i;3i;%@;&I"Socket::SHUT_RD;F;xI"INTEGER2NUM(SHUT_RD);To;u;[[@i;F;; ;;w;;;[;{;IC; "-Shut down the writing side of the socket ;T;[;![;"I"-Shut down the writing side of the socket;T;#0;$@Z;.F;/o;0;1T;2i;3i;%@;&I"Socket::SHUT_WR;F;xI"INTEGER2NUM(SHUT_WR);To;u;[[@i;F;; ;;w;;;[;{;IC; "+Shut down the both sides of the socket ;T;[;![;"I"+Shut down the both sides of the socket;T;#0;$@f;.F;/o;0;1T;2i;3i;%@;&I"Socket::SHUT_RDWR;F;xI"INTEGER2NUM(SHUT_RDWR);To;u;[[@i;F;; ;;w;;;[;{;IC; "Join a group membership ;T;[;![;"I"Join a group membership;T;#0;$@r;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPV6_JOIN_GROUP;F;xI"!INTEGER2NUM(IPV6_JOIN_GROUP);To;u;[[@i;F;; ;;w;;;[;{;IC; "Leave a group membership ;T;[;![;"I"Leave a group membership;T;#0;$@~;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPV6_LEAVE_GROUP;F;xI""INTEGER2NUM(IPV6_LEAVE_GROUP);To;u;[[@i;F;; ;;w;;;[;{;IC; "IP6 multicast hops ;T;[;![;"I"IP6 multicast hops;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I" Socket::IPV6_MULTICAST_HOPS;F;xI"%INTEGER2NUM(IPV6_MULTICAST_HOPS);To;u;[[@i;F;; ;;w;;;[;{;IC; "IP6 multicast interface ;T;[;![;"I"IP6 multicast interface;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPV6_MULTICAST_IF;F;xI"#INTEGER2NUM(IPV6_MULTICAST_IF);To;u;[[@i;F;; ;;w;;;[;{;IC; "IP6 multicast loopback ;T;[;![;"I"IP6 multicast loopback;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I" Socket::IPV6_MULTICAST_LOOP;F;xI"%INTEGER2NUM(IPV6_MULTICAST_LOOP);To;u;[[@i;F;; ;;w;;;[;{;IC; "IP6 unicast hops ;T;[;![;"I"IP6 unicast hops;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPV6_UNICAST_HOPS;F;xI"#INTEGER2NUM(IPV6_UNICAST_HOPS);To;u;[[@i;F;; ;;w;;;[;{;IC; "(Only bind IPv6 with a wildcard bind ;T;[;![;"I"(Only bind IPv6 with a wildcard bind;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPV6_V6ONLY;F;xI"INTEGER2NUM(IPV6_V6ONLY);To;u;[[@i;F;; ;;w;;;[;{;IC; "$Checksum offset for raw sockets ;T;[;![;"I"$Checksum offset for raw sockets;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPV6_CHECKSUM;F;xI"INTEGER2NUM(IPV6_CHECKSUM);To;u;[[@i;F;; ;;w;;;[;{;IC; "Don't fragment packets ;T;[;![;"I"Don't fragment packets;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPV6_DONTFRAG;F;xI"INTEGER2NUM(IPV6_DONTFRAG);To;u;[[@i;F;; ;;w;;;[;{;IC; "Destination option ;T;[;![;"I"Destination option;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPV6_DSTOPTS;F;xI"INTEGER2NUM(IPV6_DSTOPTS);To;u;[[@i;F;; ;;w;;;[;{;IC; "Hop limit ;T;[;![;"I"Hop limit;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"Socket::IPV6_HOPLIMIT;F;xI"INTEGER2NUM(IPV6_HOPLIMIT);To;u;[[@i ;F;; ;;w;;;[;{;IC; "Hop-by-hop option ;T;[;![;"I"Hop-by-hop option;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IPV6_HOPOPTS;F;xI"INTEGER2NUM(IPV6_HOPOPTS);To;u;[[@i ;F;; ;;w;;;[;{;IC; "Next hop address ;T;[;![;"I"Next hop address;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IPV6_NEXTHOP;F;xI"INTEGER2NUM(IPV6_NEXTHOP);To;u;[[@i ;F;; ;;w;;;[;{;IC; "Retrieve current path MTU ;T;[;![;"I"Retrieve current path MTU;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IPV6_PATHMTU;F;xI"INTEGER2NUM(IPV6_PATHMTU);To;u;[[@i ;F;; ;;w;;;[;{;IC; "-Receive packet information with datagram ;T;[;![;"I"-Receive packet information with datagram;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IPV6_PKTINFO;F;xI"INTEGER2NUM(IPV6_PKTINFO);To;u;[[@i" ;F;; ;;w;;;[;{;IC; ")Receive all IP6 options for response ;T;[;![;"I")Receive all IP6 options for response;T;#0;$@&;.F;/o;0;1T;2i! ;3i! ;%@;&I"Socket::IPV6_RECVDSTOPTS;F;xI""INTEGER2NUM(IPV6_RECVDSTOPTS);To;u;[[@i* ;F;; ;;w;;;[;{;IC; "$Receive hop limit with datagram ;T;[;![;"I"$Receive hop limit with datagram;T;#0;$@2;.F;/o;0;1T;2i) ;3i) ;%@;&I"Socket::IPV6_RECVHOPLIMIT;F;xI"#INTEGER2NUM(IPV6_RECVHOPLIMIT);To;u;[[@i2 ;F;; ;;w;;;[;{;IC; "Receive hop-by-hop options ;T;[;![;"I"Receive hop-by-hop options;T;#0;$@>;.F;/o;0;1T;2i1 ;3i1 ;%@;&I"Socket::IPV6_RECVHOPOPTS;F;xI""INTEGER2NUM(IPV6_RECVHOPOPTS);To;u;[[@i: ;F;; ;;w;;;[;{;IC; ":Receive destination IP address and incoming interface ;T;[;![;"I":Receive destination IP address and incoming interface;T;#0;$@J;.F;/o;0;1T;2i9 ;3i9 ;%@;&I"Socket::IPV6_RECVPKTINFO;F;xI""INTEGER2NUM(IPV6_RECVPKTINFO);To;u;[[@iB ;F;; ;;w;;;[;{;IC; "Receive routing header ;T;[;![;"I"Receive routing header;T;#0;$@V;.F;/o;0;1T;2iA ;3iA ;%@;&I"Socket::IPV6_RECVRTHDR;F;xI" INTEGER2NUM(IPV6_RECVRTHDR);To;u;[[@iJ ;F;; ;;w;;;[;{;IC; "Receive traffic class ;T;[;![;"I"Receive traffic class;T;#0;$@b;.F;/o;0;1T;2iI ;3iI ;%@;&I"Socket::IPV6_RECVTCLASS;F;xI"!INTEGER2NUM(IPV6_RECVTCLASS);To;u;[[@iR ;F;; ;;w;;;[;{;IC; "-Allows removal of sticky routing headers ;T;[;![;"I"-Allows removal of sticky routing headers;T;#0;$@n;.F;/o;0;1T;2iQ ;3iQ ;%@;&I"Socket::IPV6_RTHDR;F;xI"INTEGER2NUM(IPV6_RTHDR);To;u;[[@iZ ;F;; ;;w;;;[;{;IC; "8Allows removal of sticky destination options header ;T;[;![;"I"8Allows removal of sticky destination options header;T;#0;$@z;.F;/o;0;1T;2iY ;3iY ;%@;&I"Socket::IPV6_RTHDRDSTOPTS;F;xI"#INTEGER2NUM(IPV6_RTHDRDSTOPTS);To;u;[[@ib ;F;; ;;w;;;[;{;IC; "Routing header type 0 ;T;[;![;"I"Routing header type 0;T;#0;$@;.F;/o;0;1T;2ia ;3ia ;%@;&I"Socket::IPV6_RTHDR_TYPE_0;F;xI"#INTEGER2NUM(IPV6_RTHDR_TYPE_0);To;u;[[@ij ;F;; ;;w;;;[;{;IC; "+Receive current path MTU with datagram ;T;[;![;"I"+Receive current path MTU with datagram;T;#0;$@;.F;/o;0;1T;2ii ;3ii ;%@;&I"Socket::IPV6_RECVPATHMTU;F;xI""INTEGER2NUM(IPV6_RECVPATHMTU);To;u;[[@ir ;F;; ;;w;;;[;{;IC; "Specify the traffic class ;T;[;![;"I"Specify the traffic class;T;#0;$@;.F;/o;0;1T;2iq ;3iq ;%@;&I"Socket::IPV6_TCLASS;F;xI"INTEGER2NUM(IPV6_TCLASS);To;u;[[@iz ;F;; ;;w;;;[;{;IC; "Use the minimum MTU size ;T;[;![;"I"Use the minimum MTU size;T;#0;$@;.F;/o;0;1T;2iy ;3iy ;%@;&I"Socket::IPV6_USE_MIN_MTU;F;xI""INTEGER2NUM(IPV6_USE_MIN_MTU);To;u;[[@i ;F;; ;;w;;;[;{;IC; "-Maximum length of an IPv4 address string ;T;[;![;"I"-Maximum length of an IPv4 address string;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::INET_ADDRSTRLEN;F;xI"!INTEGER2NUM(INET_ADDRSTRLEN);To;u;[[@i ;F;; ;;w;;;[;{;IC; "-Maximum length of an IPv6 address string ;T;[;![;"I"-Maximum length of an IPv6 address string;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::INET6_ADDRSTRLEN;F;xI""INTEGER2NUM(INET6_ADDRSTRLEN);To;u;[[@i ;F;; ;;w;;;[;{;IC; " Maximum interface name size ;T;[;![;"I" Maximum interface name size;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFNAMSIZ;F;xI"INTEGER2NUM(IFNAMSIZ);To;u;[[@i ;F;; ;;w;;;[;{;IC; " Maximum interface name size ;T;[;![;"I" Maximum interface name size;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IF_NAMESIZE;F;xI"INTEGER2NUM(IF_NAMESIZE);To;u;[[@i ;F;;! ;;w;;;[;{;IC; "@Maximum connection requests that may be queued for a socket ;T;[;![;"I"@Maximum connection requests that may be queued for a socket;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::SOMAXCONN;F;xI"INTEGER2NUM(SOMAXCONN);To;u;[[@i ;F;;" ;;w;;;[;{;IC; "Access rights ;T;[;![;"I"Access rights;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::SCM_RIGHTS;F;xI"INTEGER2NUM(SCM_RIGHTS);To;u;[[@i ;F;;# ;;w;;;[;{;IC; "Timestamp (timeval) ;T;[;![;"I"Timestamp (timeval);T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::SCM_TIMESTAMP;F;xI"INTEGER2NUM(SCM_TIMESTAMP);To;u;[[@i ;F;;$ ;;w;;;[;{;IC; "Timespec (timespec) ;T;[;![;"I"Timespec (timespec);T;#0;$@ ;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::SCM_TIMESTAMPNS;F;xI"!INTEGER2NUM(SCM_TIMESTAMPNS);To;u;[[@i ;F;;% ;;w;;;[;{;IC; "-Timestamp (timespec list) (Linux 2.6.30) ;T;[;![;"I"-Timestamp (timespec list) (Linux 2.6.30);T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::SCM_TIMESTAMPING;F;xI""INTEGER2NUM(SCM_TIMESTAMPING);To;u;[[@i ;F;;& ;;w;;;[;{;IC; "Timestamp (bintime) ;T;[;![;"I"Timestamp (bintime);T;#0;$@";.F;/o;0;1T;2i ;3i ;%@;&I"Socket::SCM_BINTIME;F;xI"INTEGER2NUM(SCM_BINTIME);To;u;[[@i ;F;;' ;;w;;;[;{;IC; "The sender's credentials ;T;[;![;"I"The sender's credentials;T;#0;$@.;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::SCM_CREDENTIALS;F;xI"!INTEGER2NUM(SCM_CREDENTIALS);To;u;[[@i ;F;;( ;;w;;;[;{;IC; "Process credentials ;T;[;![;"I"Process credentials;T;#0;$@:;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::SCM_CREDS;F;xI"INTEGER2NUM(SCM_CREDS);To;u;[[@i ;F;;) ;;w;;;[;{;IC; "User credentials ;T;[;![;"I"User credentials;T;#0;$@F;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::SCM_UCRED;F;xI"INTEGER2NUM(SCM_UCRED);To;u;[[@i ;F;;* ;;w;;;[;{;IC; "Wifi status (Linux 3.3) ;T;[;![;"I"Wifi status (Linux 3.3);T;#0;$@R;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::SCM_WIFI_STATUS;F;xI"!INTEGER2NUM(SCM_WIFI_STATUS);To;u;[[@i ;F;;+ ;;w;;;[;{;IC; "Retrieve peer credentials ;T;[;![;"I"Retrieve peer credentials;T;#0;$@^;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::LOCAL_PEERCRED;F;xI" INTEGER2NUM(LOCAL_PEERCRED);To;u;[[@i ;F;;, ;;w;;;[;{;IC; "!Pass credentials to receiver ;T;[;![;"I"!Pass credentials to receiver;T;#0;$@j;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::LOCAL_CREDS;F;xI"INTEGER2NUM(LOCAL_CREDS);To;u;[[@i ;F;;- ;;w;;;[;{;IC; ""Connect blocks until accepted ;T;[;![;"I""Connect blocks until accepted;T;#0;$@v;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::LOCAL_CONNWAIT;F;xI" INTEGER2NUM(LOCAL_CONNWAIT);To;u;[[@i ;F;;. ;;w;;;[;{;IC; "802.1Q VLAN device ;T;[;![;"I"802.1Q VLAN device;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_802_1Q_VLAN;F;xI"!INTEGER2NUM(IFF_802_1Q_VLAN);To;u;[[@i ;F;;/ ;;w;;;[;{;IC; ""receive all multicast packets ;T;[;![;"I""receive all multicast packets;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_ALLMULTI;F;xI"INTEGER2NUM(IFF_ALLMULTI);To;u;[[@i ;F;;0 ;;w;;;[;{;IC; "&use alternate physical connection ;T;[;![;"I"&use alternate physical connection;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_ALTPHYS;F;xI"INTEGER2NUM(IFF_ALTPHYS);To;u;[[@i ;F;;1 ;;w;;;[;{;IC; "auto media select active ;T;[;![;"I"auto media select active;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_AUTOMEDIA;F;xI"INTEGER2NUM(IFF_AUTOMEDIA);To;u;[[@i ;F;;2 ;;w;;;[;{;IC; "bonding master or slave ;T;[;![;"I"bonding master or slave;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_BONDING;F;xI"INTEGER2NUM(IFF_BONDING);To;u;[[@i ;F;;3 ;;w;;;[;{;IC; "device used as bridge port ;T;[;![;"I"device used as bridge port;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_BRIDGE_PORT;F;xI"!INTEGER2NUM(IFF_BRIDGE_PORT);To;u;[[@i ;F;;4 ;;w;;;[;{;IC; "broadcast address valid ;T;[;![;"I"broadcast address valid;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_BROADCAST;F;xI"INTEGER2NUM(IFF_BROADCAST);To;u;[[@i ;F;;5 ;;w;;;[;{;IC; ""unconfigurable using ioctl(2) ;T;[;![;"I""unconfigurable using ioctl(2);T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_CANTCONFIG;F;xI" INTEGER2NUM(IFF_CANTCONFIG);To;u;[[@i ;F;;6 ;;w;;;[;{;IC; "turn on debugging ;T;[;![;"I"turn on debugging;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_DEBUG;F;xI"INTEGER2NUM(IFF_DEBUG);To;u;[[@i ;F;;7 ;;w;;;[;{;IC; " disable netpoll at run-time ;T;[;![;"I" disable netpoll at run-time;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I" Socket::IFF_DISABLE_NETPOLL;F;xI"%INTEGER2NUM(IFF_DISABLE_NETPOLL);To;u;[[@i# ;F;;8 ;;w;;;[;{;IC; "%disallow bridging this ether dev ;T;[;![;"I"%disallow bridging this ether dev;T;#0;$@;.F;/o;0;1T;2i" ;3i" ;%@;&I"Socket::IFF_DONT_BRIDGE;F;xI"!INTEGER2NUM(IFF_DONT_BRIDGE);To;u;[[@i) ;F;;9 ;;w;;;[;{;IC; "driver signals dormant ;T;[;![;"I"driver signals dormant;T;#0;$@;.F;/o;0;1T;2i( ;3i( ;%@;&I"Socket::IFF_DORMANT;F;xI"INTEGER2NUM(IFF_DORMANT);To;u;[[@i/ ;F;;: ;;w;;;[;{;IC; "tx hardware queue is full ;T;[;![;"I"tx hardware queue is full;T;#0;$@;.F;/o;0;1T;2i. ;3i. ;%@;&I"Socket::IFF_DRV_OACTIVE;F;xI"!INTEGER2NUM(IFF_DRV_OACTIVE);To;u;[[@i5 ;F;;; ;;w;;;[;{;IC; "resources allocated ;T;[;![;"I"resources allocated;T;#0;$@;.F;/o;0;1T;2i4 ;3i4 ;%@;&I"Socket::IFF_DRV_RUNNING;F;xI"!INTEGER2NUM(IFF_DRV_RUNNING);To;u;[[@i; ;F;;< ;;w;;;[;{;IC; "interface is winding down ;T;[;![;"I"interface is winding down;T;#0;$@*;.F;/o;0;1T;2i: ;3i: ;%@;&I"Socket::IFF_DYING;F;xI"INTEGER2NUM(IFF_DYING);To;u;[[@iA ;F;;= ;;w;;;[;{;IC; "*dialup device with changing addresses ;T;[;![;"I"*dialup device with changing addresses;T;#0;$@6;.F;/o;0;1T;2i@ ;3i@ ;%@;&I"Socket::IFF_DYNAMIC;F;xI"INTEGER2NUM(IFF_DYNAMIC);To;u;[[@iG ;F;;> ;;w;;;[;{;IC; "ethernet bridging device ;T;[;![;"I"ethernet bridging device;T;#0;$@B;.F;/o;0;1T;2iF ;3iF ;%@;&I"Socket::IFF_EBRIDGE;F;xI"INTEGER2NUM(IFF_EBRIDGE);To;u;[[@iM ;F;;? ;;w;;;[;{;IC; "echo sent packets ;T;[;![;"I"echo sent packets;T;#0;$@N;.F;/o;0;1T;2iL ;3iL ;%@;&I"Socket::IFF_ECHO;F;xI"INTEGER2NUM(IFF_ECHO);To;u;[[@iS ;F;;@ ;;w;;;[;{;IC; "ISATAP interface (RFC4214) ;T;[;![;"I"ISATAP interface (RFC4214);T;#0;$@Z;.F;/o;0;1T;2iR ;3iR ;%@;&I"Socket::IFF_ISATAP;F;xI"INTEGER2NUM(IFF_ISATAP);To;u;[[@iY ;F;;A ;;w;;;[;{;IC; "!per link layer defined bit 0 ;T;[;![;"I"!per link layer defined bit 0;T;#0;$@f;.F;/o;0;1T;2iX ;3iX ;%@;&I"Socket::IFF_LINK0;F;xI"INTEGER2NUM(IFF_LINK0);To;u;[[@i_ ;F;;B ;;w;;;[;{;IC; "!per link layer defined bit 1 ;T;[;![;"I"!per link layer defined bit 1;T;#0;$@r;.F;/o;0;1T;2i^ ;3i^ ;%@;&I"Socket::IFF_LINK1;F;xI"INTEGER2NUM(IFF_LINK1);To;u;[[@ie ;F;;C ;;w;;;[;{;IC; "!per link layer defined bit 2 ;T;[;![;"I"!per link layer defined bit 2;T;#0;$@~;.F;/o;0;1T;2id ;3id ;%@;&I"Socket::IFF_LINK2;F;xI"INTEGER2NUM(IFF_LINK2);To;u;[[@ik ;F;;D ;;w;;;[;{;IC; ".hardware address change when it's running ;T;[;![;"I".hardware address change when it's running;T;#0;$@;.F;/o;0;1T;2ij ;3ij ;%@;&I"!Socket::IFF_LIVE_ADDR_CHANGE;F;xI"&INTEGER2NUM(IFF_LIVE_ADDR_CHANGE);To;u;[[@iq ;F;;E ;;w;;;[;{;IC; "loopback net ;T;[;![;"I"loopback net;T;#0;$@;.F;/o;0;1T;2ip ;3ip ;%@;&I"Socket::IFF_LOOPBACK;F;xI"INTEGER2NUM(IFF_LOOPBACK);To;u;[[@iw ;F;;F ;;w;;;[;{;IC; "driver signals L1 up ;T;[;![;"I"driver signals L1 up;T;#0;$@;.F;/o;0;1T;2iv ;3iv ;%@;&I"Socket::IFF_LOWER_UP;F;xI"INTEGER2NUM(IFF_LOWER_UP);To;u;[[@i} ;F;;G ;;w;;;[;{;IC; " device used as macvlan port ;T;[;![;"I" device used as macvlan port;T;#0;$@;.F;/o;0;1T;2i| ;3i| ;%@;&I"Socket::IFF_MACVLAN_PORT;F;xI""INTEGER2NUM(IFF_MACVLAN_PORT);To;u;[[@i ;F;;H ;;w;;;[;{;IC; "master of a load balancer ;T;[;![;"I"master of a load balancer;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_MASTER;F;xI"INTEGER2NUM(IFF_MASTER);To;u;[[@i ;F;;I ;;w;;;[;{;IC; "bonding master, 802.3ad. ;T;[;![;"I"bonding master, 802.3ad.;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_MASTER_8023AD;F;xI"#INTEGER2NUM(IFF_MASTER_8023AD);To;u;[[@i ;F;;J ;;w;;;[;{;IC; "!bonding master, balance-alb. ;T;[;![;"I"!bonding master, balance-alb.;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_MASTER_ALB;F;xI" INTEGER2NUM(IFF_MASTER_ALB);To;u;[[@i ;F;;K ;;w;;;[;{;IC; "#bonding master, ARP mon in use ;T;[;![;"I"#bonding master, ARP mon in use;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_MASTER_ARPMON;F;xI"#INTEGER2NUM(IFF_MASTER_ARPMON);To;u;[[@i ;F;;L ;;w;;;[;{;IC; " user-requested monitor mode ;T;[;![;"I" user-requested monitor mode;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_MONITOR;F;xI"INTEGER2NUM(IFF_MONITOR);To;u;[[@i ;F;;M ;;w;;;[;{;IC; "supports multicast ;T;[;![;"I"supports multicast;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_MULTICAST;F;xI"INTEGER2NUM(IFF_MULTICAST);To;u;[[@i ;F;;N ;;w;;;[;{;IC; "#no address resolution protocol ;T;[;![;"I"#no address resolution protocol;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_NOARP;F;xI"INTEGER2NUM(IFF_NOARP);To;u;[[@i ;F;;O ;;w;;;[;{;IC; "avoid use of trailers ;T;[;![;"I"avoid use of trailers;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_NOTRAILERS;F;xI" INTEGER2NUM(IFF_NOTRAILERS);To;u;[[@i ;F;;P ;;w;;;[;{;IC; "transmission in progress ;T;[;![;"I"transmission in progress;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_OACTIVE;F;xI"INTEGER2NUM(IFF_OACTIVE);To;u;[[@i ;F;;Q ;;w;;;[;{;IC; ".device used as Open vSwitch datapath port ;T;[;![;"I".device used as Open vSwitch datapath port;T;#0;$@&;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_OVS_DATAPATH;F;xI""INTEGER2NUM(IFF_OVS_DATAPATH);To;u;[[@i ;F;;R ;;w;;;[;{;IC; "point-to-point link ;T;[;![;"I"point-to-point link;T;#0;$@2;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_POINTOPOINT;F;xI"!INTEGER2NUM(IFF_POINTOPOINT);To;u;[[@i ;F;;S ;;w;;;[;{;IC; "can set media type ;T;[;![;"I"can set media type;T;#0;$@>;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_PORTSEL;F;xI"INTEGER2NUM(IFF_PORTSEL);To;u;[[@i ;F;;T ;;w;;;[;{;IC; " user-requested promisc mode ;T;[;![;"I" user-requested promisc mode;T;#0;$@J;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_PPROMISC;F;xI"INTEGER2NUM(IFF_PPROMISC);To;u;[[@i ;F;;U ;;w;;;[;{;IC; "receive all packets ;T;[;![;"I"receive all packets;T;#0;$@V;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_PROMISC;F;xI"INTEGER2NUM(IFF_PROMISC);To;u;[[@i ;F;;V ;;w;;;[;{;IC; "interface is being renamed ;T;[;![;"I"interface is being renamed;T;#0;$@b;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_RENAMING;F;xI"INTEGER2NUM(IFF_RENAMING);To;u;[[@i ;F;;W ;;w;;;[;{;IC; "routing entry installed ;T;[;![;"I"routing entry installed;T;#0;$@n;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_ROUTE;F;xI"INTEGER2NUM(IFF_ROUTE);To;u;[[@i ;F;;X ;;w;;;[;{;IC; "resources allocated ;T;[;![;"I"resources allocated;T;#0;$@z;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_RUNNING;F;xI"INTEGER2NUM(IFF_RUNNING);To;u;[[@i ;F;;Y ;;w;;;[;{;IC; "!can't hear own transmissions ;T;[;![;"I"!can't hear own transmissions;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_SIMPLEX;F;xI"INTEGER2NUM(IFF_SIMPLEX);To;u;[[@i ;F;;Z ;;w;;;[;{;IC; "slave of a load balancer ;T;[;![;"I"slave of a load balancer;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_SLAVE;F;xI"INTEGER2NUM(IFF_SLAVE);To;u;[[@i ;F;;[ ;;w;;;[;{;IC; "'bonding slave not the curr. active ;T;[;![;"I"'bonding slave not the curr. active;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_SLAVE_INACTIVE;F;xI"$INTEGER2NUM(IFF_SLAVE_INACTIVE);To;u;[[@i ;F;;\ ;;w;;;[;{;IC; "need ARPs for validation ;T;[;![;"I"need ARPs for validation;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_SLAVE_NEEDARP;F;xI"#INTEGER2NUM(IFF_SLAVE_NEEDARP);To;u;[[@i ;F;;] ;;w;;;[;{;IC; "!interface manages own routes ;T;[;![;"I"!interface manages own routes;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_SMART;F;xI"INTEGER2NUM(IFF_SMART);To;u;[[@i ;F;;^ ;;w;;;[;{;IC; "static ARP ;T;[;![;"I"static ARP;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_STATICARP;F;xI"INTEGER2NUM(IFF_STATICARP);To;u;[[@i ;F;;_ ;;w;;;[;{;IC; "sending custom FCS ;T;[;![;"I"sending custom FCS;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_SUPP_NOFCS;F;xI" INTEGER2NUM(IFF_SUPP_NOFCS);To;u;[[@i ;F;;` ;;w;;;[;{;IC; "used as team port ;T;[;![;"I"used as team port;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_TEAM_PORT;F;xI"INTEGER2NUM(IFF_TEAM_PORT);To;u;[[@i ;F;;a ;;w;;;[;{;IC; "sharing skbs on transmit ;T;[;![;"I"sharing skbs on transmit;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_TX_SKB_SHARING;F;xI"$INTEGER2NUM(IFF_TX_SKB_SHARING);To;u;[[@i ;F;;b ;;w;;;[;{;IC; "unicast filtering ;T;[;![;"I"unicast filtering;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I"Socket::IFF_UNICAST_FLT;F;xI"!INTEGER2NUM(IFF_UNICAST_FLT);To;u;[[@i% ;F;;c ;;w;;;[;{;IC; "interface is up ;T;[;![;"I"interface is up;T;#0;$@;.F;/o;0;1T;2i$ ;3i$ ;%@;&I"Socket::IFF_UP;F;xI"INTEGER2NUM(IFF_UP);To;u;[[@i+ ;F;;d ;;w;;;[;{;IC; "WAN HDLC device ;T;[;![;"I"WAN HDLC device;T;#0;$@ ;.F;/o;0;1T;2i* ;3i* ;%@;&I"Socket::IFF_WAN_HDLC;F;xI"INTEGER2NUM(IFF_WAN_HDLC);To;u;[[@i1 ;F;;e ;;w;;;[;{;IC; "9dev_hard_start_xmit() is allowed to release skb->dst ;T;[;![;"I"9dev_hard_start_xmit() is allowed to release skb->dst;T;#0;$@;.F;/o;0;1T;2i0 ;3i0 ;%@;&I"!Socket::IFF_XMIT_DST_RELEASE;F;xI"&INTEGER2NUM(IFF_XMIT_DST_RELEASE);To;u;[[@i7 ;F;;f ;;w;;;[;{;IC; "volatile flags ;T;[;![;"I"volatile flags;T;#0;$@";.F;/o;0;1T;2i6 ;3i6 ;%@;&I"Socket::IFF_VOLATILE;F;xI"INTEGER2NUM(IFF_VOLATILE);To;u;[[@i= ;F;;g ;;w;;;[;{;IC; "flags not changeable ;T;[;![;"I"flags not changeable;T;#0;$@.;.F;/o;0;1T;2i< ;3i< ;%@;&I"Socket::IFF_CANTCHANGE;F;xI" INTEGER2NUM(IFF_CANTCHANGE);To; ;IC;[o;4;5F;6;;;;&I"Socket::Option#initialize;F;7[ [I" vfamily;T0[I" vlevel;T0[I" voptname;T0[I" data;T0;[[I"ext/socket/option.c;Tia;T;;D;0;[;{;IC; "Returns a new Socket::Option object. sockopt = Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, [1].pack("i")) p sockopt #=> # ;T;[o;= ;>I" overload;F;?0;:Socket::Option.new;@0;:I"5Socket::Option.new(family, level, optname, data);T;IC; ";T;[;![;"I";T;#0;$@<;.F;Bi;C0;7[ [I" family;T0[I" level;T0[I" optname;T0[I" data;T0;$@<;![;"I"Returns a new Socket::Option object. sockopt = Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, [1].pack("i")) p sockopt #=> # @overload Socket::Option.new(family, level, optname, data);T;#0;$@<;.F;/o;0;1T;2iW;3i^;%@:;9I"static VALUE sockopt_initialize(VALUE self, VALUE vfamily, VALUE vlevel, VALUE voptname, VALUE data) { int family = rsock_family_arg(vfamily); int level = rsock_level_arg(family, vlevel); int optname = rsock_optname_arg(family, level, voptname); StringValue(data); rb_ivar_set(self, rb_intern("family"), INT2NUM(family)); rb_ivar_set(self, rb_intern("level"), INT2NUM(level)); rb_ivar_set(self, rb_intern("optname"), INT2NUM(optname)); rb_ivar_set(self, rb_intern("data"), data); return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Option#family;F;7[;[[@Ii|;T;; ;0;[;{;IC; "}returns the socket family as an integer. p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).family #=> 10 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" family;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@c;![;"I"@return [Integer];T;#0;$@c;.F;Bi;C0;7[;$@c;![;"I"returns the socket family as an integer. p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).family #=> 10 @overload family @return [Integer];T;#0;$@c;.F;/o;0;1T;2ix;3i;%@:;9I"estatic VALUE sockopt_family_m(VALUE self) { return rb_attr_get(self, rb_intern("family")); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Option#level;F;7[;[[@Ii;T;; ;0;[;{;IC; "{returns the socket level as an integer. p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).level #=> 41 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" level;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@~;![;"I"@return [Integer];T;#0;$@~;.F;Bi;C0;7[;$@~;![;"I"returns the socket level as an integer. p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).level #=> 41 @overload level @return [Integer];T;#0;$@~;.F;/o;0;1T;2i;3i;%@:;9I"Zstatic VALUE sockopt_level_m(VALUE self) { return INT2NUM(sockopt_level(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Option#optname;F;7[;[[@Ii;T;: optname;0;[;{;IC; "returns the socket option name as an integer. p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).optname #=> 2 ;T;[o;= ;>I" overload;F;?0;;i ;@0;:I" optname;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"returns the socket option name as an integer. p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).optname #=> 2 @overload optname @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@:;9I"^static VALUE sockopt_optname_m(VALUE self) { return INT2NUM(sockopt_optname(self)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Option#data;F;7[;[[@Ii;T;; ;0;[;{;IC; "returns the socket option data as a string. p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).data #=> "\x01\x00\x00\x00" ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" data;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"returns the socket option data as a string. p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).data #=> "\x01\x00\x00\x00" @overload data @return [String] @overload to_s @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@:;9I"static VALUE sockopt_data(VALUE self) { VALUE v = rb_attr_get(self, rb_intern("data")); StringValue(v); return v; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Option#inspect;F;7[;[[@Ii;T;;J;0;[;{;IC; "Returns a string which shows sockopt in human-readable form. p Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, [1].pack("i")).inspect #=> "#" ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a string which shows sockopt in human-readable form. p Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, [1].pack("i")).inspect #=> "#" @overload inspect @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@:;9I") static VALUE sockopt_inspect(VALUE self) { int family = NUM2INT(sockopt_family_m(self)); int level = NUM2INT(sockopt_level_m(self)); int optname = NUM2INT(sockopt_optname_m(self)); VALUE data = sockopt_data(self); VALUE v, ret; ID family_id, level_id, optname_id; int inspected; StringValue(data); ret = rb_sprintf("#<%s:", rb_obj_classname(self)); family_id = rsock_intern_family_noprefix(family); if (family_id) rb_str_catf(ret, " %s", rb_id2name(family_id)); else rb_str_catf(ret, " family:%d", family); if (level == SOL_SOCKET) { rb_str_cat2(ret, " SOCKET"); optname_id = rsock_intern_so_optname(optname); if (optname_id) rb_str_catf(ret, " %s", rb_id2name(optname_id)); else rb_str_catf(ret, " optname:%d", optname); } #ifdef HAVE_SYS_UN_H else if (family == AF_UNIX) { rb_str_catf(ret, " level:%d", level); optname_id = rsock_intern_local_optname(optname); if (optname_id) rb_str_catf(ret, " %s", rb_id2name(optname_id)); else rb_str_catf(ret, " optname:%d", optname); } #endif else if (IS_IP_FAMILY(family)) { level_id = rsock_intern_iplevel(level); if (level_id) rb_str_catf(ret, " %s", rb_id2name(level_id)); else rb_str_catf(ret, " level:%d", level); v = optname_to_sym(level, optname); if (SYMBOL_P(v)) rb_str_catf(ret, " %"PRIsVALUE, rb_sym2str(v)); else rb_str_catf(ret, " optname:%d", optname); } else { rb_str_catf(ret, " level:%d", level); rb_str_catf(ret, " optname:%d", optname); } inspected = 0; if (level == SOL_SOCKET) family = AF_UNSPEC; switch (family) { case AF_UNSPEC: switch (level) { case SOL_SOCKET: switch (optname) { # if defined(SO_DEBUG) /* POSIX */ case SO_DEBUG: inspected = inspect_int(level, optname, data, ret); break; # endif # if defined(SO_ERROR) /* POSIX */ case SO_ERROR: inspected = inspect_errno(level, optname, data, ret); break; # endif # if defined(SO_TYPE) /* POSIX */ case SO_TYPE: inspected = inspect_socktype(level, optname, data, ret); break; # endif # if defined(SO_ACCEPTCONN) /* POSIX */ case SO_ACCEPTCONN: inspected = inspect_int(level, optname, data, ret); break; # endif # if defined(SO_BROADCAST) /* POSIX */ case SO_BROADCAST: inspected = inspect_int(level, optname, data, ret); break; # endif # if defined(SO_REUSEADDR) /* POSIX */ case SO_REUSEADDR: inspected = inspect_int(level, optname, data, ret); break; # endif # if defined(SO_KEEPALIVE) /* POSIX */ case SO_KEEPALIVE: inspected = inspect_int(level, optname, data, ret); break; # endif # if defined(SO_OOBINLINE) /* POSIX */ case SO_OOBINLINE: inspected = inspect_int(level, optname, data, ret); break; # endif # if defined(SO_SNDBUF) /* POSIX */ case SO_SNDBUF: inspected = inspect_int(level, optname, data, ret); break; # endif # if defined(SO_RCVBUF) /* POSIX */ case SO_RCVBUF: inspected = inspect_int(level, optname, data, ret); break; # endif # if defined(SO_DONTROUTE) /* POSIX */ case SO_DONTROUTE: inspected = inspect_int(level, optname, data, ret); break; # endif # if defined(SO_RCVLOWAT) /* POSIX */ case SO_RCVLOWAT: inspected = inspect_int(level, optname, data, ret); break; # endif # if defined(SO_SNDLOWAT) /* POSIX */ case SO_SNDLOWAT: inspected = inspect_int(level, optname, data, ret); break; # endif # if defined(SO_LINGER) /* POSIX */ case SO_LINGER: inspected = inspect_linger(level, optname, data, ret); break; # endif # if defined(SO_RCVTIMEO) /* POSIX */ case SO_RCVTIMEO: inspected = inspect_timeval_as_interval(level, optname, data, ret); break; # endif # if defined(SO_SNDTIMEO) /* POSIX */ case SO_SNDTIMEO: inspected = inspect_timeval_as_interval(level, optname, data, ret); break; # endif # if defined(SO_PEERCRED) /* GNU/Linux, OpenBSD */ case SO_PEERCRED: inspected = inspect_peercred(level, optname, data, ret); break; # endif } break; } break; case AF_INET: #ifdef INET6 case AF_INET6: #endif switch (level) { # if defined(IPPROTO_IP) case IPPROTO_IP: switch (optname) { # if defined(IP_MULTICAST_IF) && defined(HAVE_TYPE_STRUCT_IP_MREQN) /* 4.4BSD, GNU/Linux */ case IP_MULTICAST_IF: inspected = inspect_ipv4_multicast_if(level, optname, data, ret); break; # endif # if defined(IP_ADD_MEMBERSHIP) /* 4.4BSD, GNU/Linux */ case IP_ADD_MEMBERSHIP: inspected = inspect_ipv4_add_drop_membership(level, optname, data, ret); break; # endif # if defined(IP_DROP_MEMBERSHIP) /* 4.4BSD, GNU/Linux */ case IP_DROP_MEMBERSHIP: inspected = inspect_ipv4_add_drop_membership(level, optname, data, ret); break; # endif # if defined(IP_MULTICAST_LOOP) /* 4.4BSD, GNU/Linux */ case IP_MULTICAST_LOOP: inspected = inspect_ipv4_multicast_loop(level, optname, data, ret); break; # endif # if defined(IP_MULTICAST_TTL) /* 4.4BSD, GNU/Linux */ case IP_MULTICAST_TTL: inspected = inspect_ipv4_multicast_ttl(level, optname, data, ret); break; # endif } break; # endif # if defined(IPPROTO_IPV6) case IPPROTO_IPV6: switch (optname) { # if defined(IPV6_MULTICAST_HOPS) /* POSIX */ case IPV6_MULTICAST_HOPS: inspected = inspect_int(level, optname, data, ret); break; # endif # if defined(IPV6_MULTICAST_IF) /* POSIX */ case IPV6_MULTICAST_IF: inspected = inspect_ipv6_multicast_if(level, optname, data, ret); break; # endif # if defined(IPV6_MULTICAST_LOOP) /* POSIX */ case IPV6_MULTICAST_LOOP: inspected = inspect_uint(level, optname, data, ret); break; # endif # if defined(IPV6_JOIN_GROUP) /* POSIX */ case IPV6_JOIN_GROUP: inspected = inspect_ipv6_mreq(level, optname, data, ret); break; # endif # if defined(IPV6_LEAVE_GROUP) /* POSIX */ case IPV6_LEAVE_GROUP: inspected = inspect_ipv6_mreq(level, optname, data, ret); break; # endif # if defined(IPV6_UNICAST_HOPS) /* POSIX */ case IPV6_UNICAST_HOPS: inspected = inspect_int(level, optname, data, ret); break; # endif # if defined(IPV6_V6ONLY) /* POSIX */ case IPV6_V6ONLY: inspected = inspect_int(level, optname, data, ret); break; # endif } break; # endif # if defined(IPPROTO_TCP) case IPPROTO_TCP: switch (optname) { # if defined(TCP_NODELAY) /* POSIX */ case TCP_NODELAY: inspected = inspect_int(level, optname, data, ret); break; # endif # if defined(TCP_INFO) && defined(HAVE_TYPE_STRUCT_TCP_INFO) /* Linux, FreeBSD */ case TCP_INFO: inspected = inspect_tcp_info(level, optname, data, ret); break; # endif } break; # endif } break; #ifdef HAVE_SYS_UN_H case AF_UNIX: switch (level) { case 0: switch (optname) { # if defined(LOCAL_PEERCRED) case LOCAL_PEERCRED: inspected = inspect_local_peercred(level, optname, data, ret); break; # endif } break; } break; #endif } if (!inspected) { rb_str_cat2(ret, " "); rb_str_append(ret, rb_str_dump(data)); } rb_str_cat2(ret, ">"); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Option.int;F;7[ [I" vfamily;T0[I" vlevel;T0[I" voptname;T0[I" vint;T0;[[@Ii;T;; ;0;[;{;IC; "Creates a new Socket::Option object which contains an int as data. The size and endian is dependent on the platform. p Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1) #=> # ;T;[o;= ;>I" overload;F;?0;:Socket::Option.int;@0;:I"8Socket::Option.int(family, level, optname, integer);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[ [I" family;T0[I" level;T0[I" optname;T0[I" integer;T0;$@;![;"I"Creates a new Socket::Option object which contains an int as data. The size and endian is dependent on the platform. p Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1) #=> # @overload Socket::Option.int(family, level, optname, integer);T;#0;$@;.F;/o;0;1T;2i;3i;%@:;9I"Mstatic VALUE sockopt_s_int(VALUE klass, VALUE vfamily, VALUE vlevel, VALUE voptname, VALUE vint) { int family = rsock_family_arg(vfamily); int level = rsock_level_arg(family, vlevel); int optname = rsock_optname_arg(family, level, voptname); return rsock_sockopt_new(family, level, optname, sockopt_pack_int(vint)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Option#int;F;7[;[[@Ii;T;; ;0;[;{;IC; "Returns the data in _sockopt_ as an int. The size and endian is dependent on the platform. sockopt = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1) p sockopt.int => 1 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"int;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the data in _sockopt_ as an int. The size and endian is dependent on the platform. sockopt = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1) p sockopt.int => 1 @overload int @return [Integer];T;#0;$@;.F;/o;0;1T;2i;3i;%@:;9I"static VALUE sockopt_int(VALUE self) { int i; VALUE data = sockopt_data(self); StringValue(data); check_size(RSTRING_LEN(data), sizeof(int)); memcpy((char*)&i, RSTRING_PTR(data), sizeof(int)); return INT2NUM(i); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Option.byte;F;7[ [I" vfamily;T0[I" vlevel;T0[I" voptname;T0[I" vint;T0;[[@Ii;T;: byte;0;[;{;IC; "Creates a new Socket::Option object which contains a byte as data. p Socket::Option.byte(:INET, :SOCKET, :KEEPALIVE, 1) #=> # ;T;[o;= ;>I" overload;F;?0;:Socket::Option.byte;@0;:I"9Socket::Option.byte(family, level, optname, integer);T;IC; ";T;[;![;"I";T;#0;$@8;.F;Bi;C0;7[ [I" family;T0[I" level;T0[I" optname;T0[I" integer;T0;$@8;![;"I"Creates a new Socket::Option object which contains a byte as data. p Socket::Option.byte(:INET, :SOCKET, :KEEPALIVE, 1) #=> # @overload Socket::Option.byte(family, level, optname, integer);T;#0;$@8;.F;/o;0;1T;2i;3i;%@:;9I"Ostatic VALUE sockopt_s_byte(VALUE klass, VALUE vfamily, VALUE vlevel, VALUE voptname, VALUE vint) { int family = rsock_family_arg(vfamily); int level = rsock_level_arg(family, vlevel); int optname = rsock_optname_arg(family, level, voptname); return rsock_sockopt_new(family, level, optname, sockopt_pack_byte(vint)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Option#byte;F;7[;[[@Ii;T;;k ;0;[;{;IC; "Returns the data in _sockopt_ as an byte. sockopt = Socket::Option.byte(:INET, :SOCKET, :KEEPALIVE, 1) p sockopt.byte => 1 ;T;[o;= ;>I" overload;F;?0;;k ;@0;:I" byte;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@^;![;"I"@return [Integer];T;#0;$@^;.F;Bi;C0;7[;$@^;![;"I"Returns the data in _sockopt_ as an byte. sockopt = Socket::Option.byte(:INET, :SOCKET, :KEEPALIVE, 1) p sockopt.byte => 1 @overload byte @return [Integer];T;#0;$@^;.F;/o;0;1T;2i;3i;%@:;9I"static VALUE sockopt_byte(VALUE self) { VALUE data = sockopt_data(self); StringValue(data); check_size(RSTRING_LEN(data), sizeof(char)); return CHR2FIX(*RSTRING_PTR(data)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Option.bool;F;7[ [I" vfamily;T0[I" vlevel;T0[I" voptname;T0[I" vbool;T0;[[@Ii;T;: bool;0;[;{;IC; "SCreates a new Socket::Option object which contains boolean as data. Actually 0 or 1 as int is used. require 'socket' p Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, true) #=> # p Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, false) #=> # ;T;[o;= ;>I" overload;F;?0;:Socket::Option.bool;@0;:I"6Socket::Option.bool(family, level, optname, bool);T;IC; ";T;[;![;"I";T;#0;$@y;.F;Bi;C0;7[ [I" family;T0[I" level;T0[I" optname;T0[I" bool;T0;$@y;![;"I"Creates a new Socket::Option object which contains boolean as data. Actually 0 or 1 as int is used. require 'socket' p Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, true) #=> # p Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, false) #=> # @overload Socket::Option.bool(family, level, optname, bool);T;#0;$@y;.F;/o;0;1T;2i ;3i;%@:;9I"fstatic VALUE sockopt_s_bool(VALUE klass, VALUE vfamily, VALUE vlevel, VALUE voptname, VALUE vbool) { int family = rsock_family_arg(vfamily); int level = rsock_level_arg(family, vlevel); int optname = rsock_optname_arg(family, level, voptname); int i = RTEST(vbool) ? 1 : 0; return rsock_sockopt_new(family, level, optname, pack_var(i)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Option#bool;F;7[;[[@Ii/;T;;m ;0;[;{;IC; "Returns the data in _sockopt_ as an boolean value. sockopt = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1) p sockopt.bool => true ;T;[o;= ;>I" overload;F;?0;;m ;@0;:I" bool;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the data in _sockopt_ as an boolean value. sockopt = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1) p sockopt.bool => true @overload bool @return [Boolean];T;#0;$@;.F;/o;0;1T;2i&;3i-;%@:;9I"\static VALUE sockopt_bool(VALUE self) { int i; long len; VALUE data = sockopt_data(self); StringValue(data); len = RSTRING_LEN(data); if (len == 1) { return *RSTRING_PTR(data) == 0 ? Qfalse : Qtrue; } check_size(len, sizeof(int)); memcpy((char*)&i, RSTRING_PTR(data), len); return i == 0 ? Qfalse : Qtrue; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Option.linger;F;7[[I" vonoff;T0[I" vsecs;T0;[[@IiM;T;: linger;0;[;{;IC; "Creates a new Socket::Option object for SOL_SOCKET/SO_LINGER. _onoff_ should be an integer or a boolean. _secs_ should be the number of seconds. p Socket::Option.linger(true, 10) #=> # ;T;[o;= ;>I" overload;F;?0;:Socket::Option.linger;@0;:I"'Socket::Option.linger(onoff, secs);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" onoff;T0[I" secs;T0;$@;![;"I"Creates a new Socket::Option object for SOL_SOCKET/SO_LINGER. _onoff_ should be an integer or a boolean. _secs_ should be the number of seconds. p Socket::Option.linger(true, 10) #=> # @overload Socket::Option.linger(onoff, secs);T;#0;$@;.F;/o;0;1T;2i?;3iJ;%@:;9I"static VALUE sockopt_s_linger(VALUE klass, VALUE vonoff, VALUE vsecs) { VALUE tmp; struct linger l; memset(&l, 0, sizeof(l)); if (!NIL_P(tmp = rb_check_to_integer(vonoff, "to_int"))) l.l_onoff = NUM2INT(tmp); else l.l_onoff = RTEST(vonoff) ? 1 : 0; l.l_linger = NUM2INT(vsecs); return rsock_sockopt_new(AF_UNSPEC, SOL_SOCKET, SO_LINGER, pack_var(l)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Option#linger;F;7[;[[@Iid;T;;o ;0;[;{;IC; "Returns the linger data in _sockopt_ as a pair of boolean and integer. sockopt = Socket::Option.linger(true, 10) p sockopt.linger => [true, 10] ;T;[o;= ;>I" overload;F;?0;;o ;@0;:I" linger;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the linger data in _sockopt_ as a pair of boolean and integer. sockopt = Socket::Option.linger(true, 10) p sockopt.linger => [true, 10] @overload linger @return [Array];T;#0;$@;.F;/o;0;1T;2i[;3ib;%@:;9I"static VALUE sockopt_linger(VALUE self) { int level = sockopt_level(self); int optname = sockopt_optname(self); VALUE data = sockopt_data(self); struct linger l; VALUE vonoff, vsecs; if (level != SOL_SOCKET || optname != SO_LINGER) rb_raise(rb_eTypeError, "linger socket option expected"); check_size(RSTRING_LEN(data), sizeof(struct linger)); memcpy((char*)&l, RSTRING_PTR(data), sizeof(struct linger)); switch (l.l_onoff) { case 0: vonoff = Qfalse; break; case 1: vonoff = Qtrue; break; default: vonoff = INT2NUM(l.l_onoff); break; } vsecs = INT2NUM(l.l_linger); return rb_assoc_new(vonoff, vsecs); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&Socket::Option.ipv4_multicast_ttl;F;7[[I" value;T0;[[@Ii;T;:ipv4_multicast_ttl;0;[;{;IC; "Creates a new Socket::Option object for IP_MULTICAST_TTL. The size is dependent on the platform. p Socket::Option.ipv4_multicast_ttl(10) #=> # ;T;[o;= ;>I" overload;F;?0;:&Socket::Option.ipv4_multicast_ttl;@0;:I"/Socket::Option.ipv4_multicast_ttl(integer);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" integer;T0;$@;![;"I"Creates a new Socket::Option object for IP_MULTICAST_TTL. The size is dependent on the platform. p Socket::Option.ipv4_multicast_ttl(10) #=> # @overload Socket::Option.ipv4_multicast_ttl(integer);T;#0;$@;.F;/o;0;1T;2i;3i;%@:;9I"Kstatic VALUE sockopt_s_ipv4_multicast_ttl(VALUE klass, VALUE value) { #if defined(IPPROTO_IP) && defined(IP_MULTICAST_TTL) VALUE o = XCAT(sockopt_pack_,TYPE_IP_MULTICAST_TTL)(value); return rsock_sockopt_new(AF_INET, IPPROTO_IP, IP_MULTICAST_TTL, o); #else # error IPPROTO_IP or IP_MULTICAST_TTL is not implemented #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&Socket::Option#ipv4_multicast_ttl;F;7[;[[@Ii;T;;q ;0;[;{;IC; "Returns the ipv4_multicast_ttl data in _sockopt_ as an integer. sockopt = Socket::Option.ipv4_multicast_ttl(10) p sockopt.ipv4_multicast_ttl => 10 ;T;[o;= ;>I" overload;F;?0;;q ;@0;:I"ipv4_multicast_ttl;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Returns the ipv4_multicast_ttl data in _sockopt_ as an integer. sockopt = Socket::Option.ipv4_multicast_ttl(10) p sockopt.ipv4_multicast_ttl => 10 @overload ipv4_multicast_ttl @return [Integer];T;#0;$@ ;.F;/o;0;1T;2i;3i;%@:;9I"static VALUE sockopt_ipv4_multicast_ttl(VALUE self) { int family = NUM2INT(sockopt_family_m(self)); int level = sockopt_level(self); int optname = sockopt_optname(self); #if defined(IPPROTO_IP) && defined(IP_MULTICAST_TTL) if (family == AF_INET && level == IPPROTO_IP && optname == IP_MULTICAST_TTL) { return XCAT(sockopt_,TYPE_IP_MULTICAST_TTL)(self); } #endif rb_raise(rb_eTypeError, "ipv4_multicast_ttl socket option expected"); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'Socket::Option.ipv4_multicast_loop;F;7[[I" value;T0;[[@Ii;T;:ipv4_multicast_loop;0;[;{;IC; "!Creates a new Socket::Option object for IP_MULTICAST_LOOP. The size is dependent on the platform. sockopt = Socket::Option.int(:INET, :IPPROTO_IP, :IP_MULTICAST_LOOP, 1) p sockopt.int => 1 p Socket::Option.ipv4_multicast_loop(10) #=> # ;T;[o;= ;>I" overload;F;?0;:'Socket::Option.ipv4_multicast_loop;@0;:I"0Socket::Option.ipv4_multicast_loop(integer);T;IC; ";T;[;![;"I";T;#0;$@(;.F;Bi;C0;7[[I" integer;T0;$@(;![;"I"ZCreates a new Socket::Option object for IP_MULTICAST_LOOP. The size is dependent on the platform. sockopt = Socket::Option.int(:INET, :IPPROTO_IP, :IP_MULTICAST_LOOP, 1) p sockopt.int => 1 p Socket::Option.ipv4_multicast_loop(10) #=> # @overload Socket::Option.ipv4_multicast_loop(integer);T;#0;$@(;.F;/o;0;1T;2iz;3i;%@:;9I"Qstatic VALUE sockopt_s_ipv4_multicast_loop(VALUE klass, VALUE value) { #if defined(IPPROTO_IP) && defined(IP_MULTICAST_LOOP) VALUE o = XCAT(sockopt_pack_,TYPE_IP_MULTICAST_LOOP)(value); return rsock_sockopt_new(AF_INET, IPPROTO_IP, IP_MULTICAST_LOOP, o); #else # error IPPROTO_IP or IP_MULTICAST_LOOP is not implemented #endif };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'Socket::Option#ipv4_multicast_loop;F;7[;[[@Ii;T;;s ;0;[;{;IC; "Returns the ipv4_multicast_loop data in _sockopt_ as an integer. sockopt = Socket::Option.ipv4_multicast_loop(10) p sockopt.ipv4_multicast_loop => 10 ;T;[o;= ;>I" overload;F;?0;;s ;@0;:I"ipv4_multicast_loop;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@B;![;"I"@return [Integer];T;#0;$@B;.F;Bi;C0;7[;$@B;![;"I"Returns the ipv4_multicast_loop data in _sockopt_ as an integer. sockopt = Socket::Option.ipv4_multicast_loop(10) p sockopt.ipv4_multicast_loop => 10 @overload ipv4_multicast_loop @return [Integer];T;#0;$@B;.F;/o;0;1T;2i;3i;%@:;9I"static VALUE sockopt_ipv4_multicast_loop(VALUE self) { int family = NUM2INT(sockopt_family_m(self)); int level = sockopt_level(self); int optname = sockopt_optname(self); #if defined(IPPROTO_IP) && defined(IP_MULTICAST_LOOP) if (family == AF_INET && level == IPPROTO_IP && optname == IP_MULTICAST_LOOP) { return XCAT(sockopt_,TYPE_IP_MULTICAST_LOOP)(self); } #endif rb_raise(rb_eTypeError, "ipv4_multicast_loop socket option expected"); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Option#unpack;F;7[[I" template;T0;[[@Ii;T;: unpack;0;[;{;IC; "Calls String#unpack on sockopt.data. sockopt = Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, [1].pack("i")) p sockopt.unpack("i") #=> [1] p sockopt.data.unpack("i") #=> [1] ;T;[o;= ;>I" overload;F;?0;;u ;@0;:I"unpack(template);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@];![;"I"@return [Array];T;#0;$@];.F;Bi;C0;7[[I" template;T0;$@];![;"I"Calls String#unpack on sockopt.data. sockopt = Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, [1].pack("i")) p sockopt.unpack("i") #=> [1] p sockopt.data.unpack("i") #=> [1] @overload unpack(template) @return [Array];T;#0;$@];.F;/o;0;1T;2i;3i;%@:;9I"static VALUE sockopt_unpack(VALUE self, VALUE template) { return rb_funcall(sockopt_data(self), rb_intern("unpack"), 1, template); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Socket::Option#to_s;F;7[;[[@Ii;T;;G;0;[;{;IC; "returns the socket option data as a string. p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).data #=> "\x01\x00\x00\x00" ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" data;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@|;![;"I"@return [String];T;#0;$@|;.F;Bi;C0;7[;$@|o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@|;![;"I"@return [String];T;#0;$@|;.F;Bi;C0;7[;$@|;![;"@;#0;$@|;.F;/o;0;1T;2i;3i;%@:;9I"static VALUE sockopt_data(VALUE self) { VALUE v = rb_attr_get(self, rb_intern("data")); StringValue(v); return v; };T;:I"static VALUE;T;;T; @:; IC;[; @:; IC;[; @:; IC;{;IC;{;T;IC;{;T;T;{;[;[[@Ii[@Ii;T;; ;;;;;[;{;IC; "Socket::Option represents a socket option used by BasicSocket#getsockopt and BasicSocket#setsockopt. A socket option contains the socket #family, protocol #level, option name #optname and option value #data. ;T;[;![;"I" Socket::Option represents a socket option used by BasicSocket#getsockopt and BasicSocket#setsockopt. A socket option contains the socket #family, protocol #level, option name #optname and option value #data. ;T;#0;$@:;.F;/o;0;1T;2i;3i;%@;&I"Socket::Option;F;'@; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@iH[@i;T;: Socket;;;;;[;{;IC; " Class +Socket+ provides access to the underlying operating system socket implementations. It can be used to provide more operating system specific functionality than the protocol-specific socket classes. The constants defined under Socket::Constants are also defined under Socket. For example, Socket::AF_INET is usable as well as Socket::Constants::AF_INET. See Socket::Constants for the list of constants. === What's a socket? Sockets are endpoints of a bidirectional communication channel. Sockets can communicate within a process, between processes on the same machine or between different machines. There are many types of socket: TCPSocket, UDPSocket or UNIXSocket for example. Sockets have their own vocabulary: *domain:* The family of protocols: * Socket::PF_INET * Socket::PF_INET6 * Socket::PF_UNIX * etc. *type:* The type of communications between the two endpoints, typically * Socket::SOCK_STREAM * Socket::SOCK_DGRAM. *protocol:* Typically _zero_. This may be used to identify a variant of a protocol. *hostname:* The identifier of a network interface: * a string (hostname, IPv4 or IPv6 address or +broadcast+ which specifies a broadcast address) * a zero-length string which specifies INADDR_ANY * an integer (interpreted as binary address in host byte order). === Quick start Many of the classes, such as TCPSocket, UDPSocket or UNIXSocket, ease the use of sockets comparatively to the equivalent C programming interface. Let's create an internet socket using the IPv4 protocol in a C-like manner: require 'socket' s = Socket.new Socket::AF_INET, Socket::SOCK_STREAM s.connect Socket.pack_sockaddr_in(80, 'example.com') You could also use the TCPSocket class: s = TCPSocket.new 'example.com', 80 A simple server might look like this: require 'socket' server = TCPServer.new 2000 # Server bound to port 2000 loop do client = server.accept # Wait for a client to connect client.puts "Hello !" client.puts "Time is #{Time.now}" client.close end A simple client may look like this: require 'socket' s = TCPSocket.new 'localhost', 2000 while line = s.gets # Read lines from socket puts line # and print them end s.close # close socket when done === Exception Handling Ruby's Socket implementation raises exceptions based on the error generated by the system dependent implementation. This is why the methods are documented in a way that isolate Unix-based system exceptions from Windows based exceptions. If more information on a particular exception is needed, please refer to the Unix manual pages or the Windows WinSock reference. === Convenience methods Although the general way to create socket is Socket.new, there are several methods of socket creation for most cases. TCP client socket:: Socket.tcp, TCPSocket.open TCP server socket:: Socket.tcp_server_loop, TCPServer.open UNIX client socket:: Socket.unix, UNIXSocket.open UNIX server socket:: Socket.unix_server_loop, UNIXServer.open === Documentation by * Zach Dennis * Sam Roberts * Programming Ruby from The Pragmatic Bookshelf. Much material in this documentation is taken with permission from Programming Ruby from The Pragmatic Bookshelf.;T;[;![;"I" Class +Socket+ provides access to the underlying operating system socket implementations. It can be used to provide more operating system specific functionality than the protocol-specific socket classes. The constants defined under Socket::Constants are also defined under Socket. For example, Socket::AF_INET is usable as well as Socket::Constants::AF_INET. See Socket::Constants for the list of constants. === What's a socket? Sockets are endpoints of a bidirectional communication channel. Sockets can communicate within a process, between processes on the same machine or between different machines. There are many types of socket: TCPSocket, UDPSocket or UNIXSocket for example. Sockets have their own vocabulary: *domain:* The family of protocols: * Socket::PF_INET * Socket::PF_INET6 * Socket::PF_UNIX * etc. *type:* The type of communications between the two endpoints, typically * Socket::SOCK_STREAM * Socket::SOCK_DGRAM. *protocol:* Typically _zero_. This may be used to identify a variant of a protocol. *hostname:* The identifier of a network interface: * a string (hostname, IPv4 or IPv6 address or +broadcast+ which specifies a broadcast address) * a zero-length string which specifies INADDR_ANY * an integer (interpreted as binary address in host byte order). === Quick start Many of the classes, such as TCPSocket, UDPSocket or UNIXSocket, ease the use of sockets comparatively to the equivalent C programming interface. Let's create an internet socket using the IPv4 protocol in a C-like manner: require 'socket' s = Socket.new Socket::AF_INET, Socket::SOCK_STREAM s.connect Socket.pack_sockaddr_in(80, 'example.com') You could also use the TCPSocket class: s = TCPSocket.new 'example.com', 80 A simple server might look like this: require 'socket' server = TCPServer.new 2000 # Server bound to port 2000 loop do client = server.accept # Wait for a client to connect client.puts "Hello !" client.puts "Time is #{Time.now}" client.close end A simple client may look like this: require 'socket' s = TCPSocket.new 'localhost', 2000 while line = s.gets # Read lines from socket puts line # and print them end s.close # close socket when done === Exception Handling Ruby's Socket implementation raises exceptions based on the error generated by the system dependent implementation. This is why the methods are documented in a way that isolate Unix-based system exceptions from Windows based exceptions. If more information on a particular exception is needed, please refer to the Unix manual pages or the Windows WinSock reference. === Convenience methods Although the general way to create socket is Socket.new, there are several methods of socket creation for most cases. TCP client socket:: Socket.tcp, TCPSocket.open TCP server socket:: Socket.tcp_server_loop, TCPServer.open UNIX client socket:: Socket.unix, UNIXSocket.open UNIX server socket:: Socket.unix_server_loop, UNIXServer.open === Documentation by * Zach Dennis * Sam Roberts * Programming Ruby from The Pragmatic Bookshelf. Much material in this documentation is taken with permission from Programming Ruby from The Pragmatic Bookshelf. ;T;#0;$@;.F;/o;0;1T;2iH;3i;Bi;%@;&I" Socket;F;'o;( ;)0;*0;+0;;> ;%@;-@5;0o; ;IC;[ o;4;5F;6;;;;&I"IPSocket#inspect;F;7[;[[I"ext/socket/ipsocket.c;Ti;T;;J;0;[;{;IC; "5Return a string describing this IPSocket object. ;T;[o;= ;>I" overload;F;?0;;J;@0;:I" inspect;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"\Return a string describing this IPSocket object. @overload inspect @return [String];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ip_inspect(VALUE sock) { VALUE str = rb_call_super(0, 0); rb_io_t *fptr = RFILE(sock)->fptr; union_sockaddr addr; socklen_t len = (socklen_t)sizeof addr; ID id; if (fptr && fptr->fd >= 0 && getsockname(fptr->fd, &addr.addr, &len) >= 0 && (id = rsock_intern_family(addr.addr.sa_family)) != 0) { VALUE family = rb_id2str(id); char hbuf[1024], pbuf[1024]; long slen = RSTRING_LEN(str); const char last = (slen > 1 && RSTRING_PTR(str)[slen - 1] == '>') ? (--slen, '>') : 0; str = rb_str_subseq(str, 0, slen); rb_str_cat_cstr(str, ", "); rb_str_append(str, family); if (!rb_getnameinfo(&addr.addr, len, hbuf, sizeof(hbuf), pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV)) { rb_str_cat_cstr(str, ", "); rb_str_cat_cstr(str, hbuf); rb_str_cat_cstr(str, ", "); rb_str_cat_cstr(str, pbuf); } if (last) rb_str_cat(str, &last, 1); } return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IPSocket#addr;F;7[[@90;[[@i;T;;D ;0;[;{;IC; "8Returns the local address as an array which contains address_family, port, hostname and numeric_address. If +reverse_lookup+ is +true+ or +:hostname+, hostname is obtained from numeric_address using reverse lookup. Or if it is +false+, or +:numeric+, hostname is the same as numeric_address. Or if it is +nil+ or omitted, obeys to +ipsocket.do_not_reverse_lookup+. See +Socket.getaddrinfo+ also. TCPSocket.open("www.ruby-lang.org", 80) {|sock| p sock.addr #=> ["AF_INET", 49429, "hal", "192.168.0.128"] p sock.addr(true) #=> ["AF_INET", 49429, "hal", "192.168.0.128"] p sock.addr(false) #=> ["AF_INET", 49429, "192.168.0.128", "192.168.0.128"] p sock.addr(:hostname) #=> ["AF_INET", 49429, "hal", "192.168.0.128"] p sock.addr(:numeric) #=> ["AF_INET", 49429, "192.168.0.128", "192.168.0.128"] } ;T;[o;= ;>I" overload;F;?0;;D ;@0;:I"addr([reverse_lookup]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"[reverse_lookup];T0;$@;![;"I"nReturns the local address as an array which contains address_family, port, hostname and numeric_address. If +reverse_lookup+ is +true+ or +:hostname+, hostname is obtained from numeric_address using reverse lookup. Or if it is +false+, or +:numeric+, hostname is the same as numeric_address. Or if it is +nil+ or omitted, obeys to +ipsocket.do_not_reverse_lookup+. See +Socket.getaddrinfo+ also. TCPSocket.open("www.ruby-lang.org", 80) {|sock| p sock.addr #=> ["AF_INET", 49429, "hal", "192.168.0.128"] p sock.addr(true) #=> ["AF_INET", 49429, "hal", "192.168.0.128"] p sock.addr(false) #=> ["AF_INET", 49429, "192.168.0.128", "192.168.0.128"] p sock.addr(:hostname) #=> ["AF_INET", 49429, "hal", "192.168.0.128"] p sock.addr(:numeric) #=> ["AF_INET", 49429, "192.168.0.128", "192.168.0.128"] } @overload addr([reverse_lookup]) @return [Array];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ip_addr(int argc, VALUE *argv, VALUE sock) { rb_io_t *fptr; union_sockaddr addr; socklen_t len = (socklen_t)sizeof addr; int norevlookup; GetOpenFile(sock, fptr); if (argc < 1 || !rsock_revlookup_flag(argv[0], &norevlookup)) norevlookup = fptr->mode & FMODE_NOREVLOOKUP; if (getsockname(fptr->fd, &addr.addr, &len) < 0) rb_sys_fail("getsockname(2)"); return rsock_ipaddr(&addr.addr, len, norevlookup); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IPSocket#peeraddr;F;7[[@90;[[@i;;T;;E ;0;[;{;IC; "Returns the remote address as an array which contains address_family, port, hostname and numeric_address. It is defined for connection oriented socket such as TCPSocket. If +reverse_lookup+ is +true+ or +:hostname+, hostname is obtained from numeric_address using reverse lookup. Or if it is +false+, or +:numeric+, hostname is the same as numeric_address. Or if it is +nil+ or omitted, obeys to +ipsocket.do_not_reverse_lookup+. See +Socket.getaddrinfo+ also. TCPSocket.open("www.ruby-lang.org", 80) {|sock| p sock.peeraddr #=> ["AF_INET", 80, "carbon.ruby-lang.org", "221.186.184.68"] p sock.peeraddr(true) #=> ["AF_INET", 80, "carbon.ruby-lang.org", "221.186.184.68"] p sock.peeraddr(false) #=> ["AF_INET", 80, "221.186.184.68", "221.186.184.68"] p sock.peeraddr(:hostname) #=> ["AF_INET", 80, "carbon.ruby-lang.org", "221.186.184.68"] p sock.peeraddr(:numeric) #=> ["AF_INET", 80, "221.186.184.68", "221.186.184.68"] } ;T;[o;= ;>I" overload;F;?0;;E ;@0;:I"peeraddr([reverse_lookup]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"[reverse_lookup];T0;$@;![;"I"Returns the remote address as an array which contains address_family, port, hostname and numeric_address. It is defined for connection oriented socket such as TCPSocket. If +reverse_lookup+ is +true+ or +:hostname+, hostname is obtained from numeric_address using reverse lookup. Or if it is +false+, or +:numeric+, hostname is the same as numeric_address. Or if it is +nil+ or omitted, obeys to +ipsocket.do_not_reverse_lookup+. See +Socket.getaddrinfo+ also. TCPSocket.open("www.ruby-lang.org", 80) {|sock| p sock.peeraddr #=> ["AF_INET", 80, "carbon.ruby-lang.org", "221.186.184.68"] p sock.peeraddr(true) #=> ["AF_INET", 80, "carbon.ruby-lang.org", "221.186.184.68"] p sock.peeraddr(false) #=> ["AF_INET", 80, "221.186.184.68", "221.186.184.68"] p sock.peeraddr(:hostname) #=> ["AF_INET", 80, "carbon.ruby-lang.org", "221.186.184.68"] p sock.peeraddr(:numeric) #=> ["AF_INET", 80, "221.186.184.68", "221.186.184.68"] } @overload peeraddr([reverse_lookup]) @return [Array];T;#0;$@;.F;/o;0;1T;2i#;3i9;%@;9I"static VALUE ip_peeraddr(int argc, VALUE *argv, VALUE sock) { rb_io_t *fptr; union_sockaddr addr; socklen_t len = (socklen_t)sizeof addr; int norevlookup; GetOpenFile(sock, fptr); if (argc < 1 || !rsock_revlookup_flag(argv[0], &norevlookup)) norevlookup = fptr->mode & FMODE_NOREVLOOKUP; if (getpeername(fptr->fd, &addr.addr, &len) < 0) rb_sys_fail("getpeername(2)"); return rsock_ipaddr(&addr.addr, len, norevlookup); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IPSocket#recvfrom;F;7[[@90;[[@ia;T;;F ;0;[;{;IC; "Receives a message and return the message as a string and an address which the message come from. _maxlen_ is the maximum number of bytes to receive. _flags_ should be a bitwise OR of Socket::MSG_* constants. ipaddr is the same as IPSocket#{peeraddr,addr}. u1 = UDPSocket.new u1.bind("127.0.0.1", 4913) u2 = UDPSocket.new u2.send "uuuu", 0, "127.0.0.1", 4913 p u1.recvfrom(10) #=> ["uuuu", ["AF_INET", 33230, "localhost", "127.0.0.1"]] ;T;[o;= ;>I" overload;F;?0;;F ;@0;:I"recvfrom(maxlen);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@";![;"I"@return [Array];T;#0;$@";.F;Bi;C0;7[[I" maxlen;T0;$@"o;= ;>I" overload;F;?0;;F ;@0;:I"recvfrom(maxlen, flags);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@";![;"I"@return [Array];T;#0;$@";.F;Bi;C0;7[[I" maxlen;T0[I" flags;T0;$@";![;"I"%Receives a message and return the message as a string and an address which the message come from. _maxlen_ is the maximum number of bytes to receive. _flags_ should be a bitwise OR of Socket::MSG_* constants. ipaddr is the same as IPSocket#{peeraddr,addr}. u1 = UDPSocket.new u1.bind("127.0.0.1", 4913) u2 = UDPSocket.new u2.send "uuuu", 0, "127.0.0.1", 4913 p u1.recvfrom(10) #=> ["uuuu", ["AF_INET", 33230, "localhost", "127.0.0.1"]] @overload recvfrom(maxlen) @return [Array] @overload recvfrom(maxlen, flags) @return [Array];T;#0;$@";.F;/o;0;1T;2iL;3i`;%@;9I"|static VALUE ip_recvfrom(int argc, VALUE *argv, VALUE sock) { return rsock_s_recvfrom(sock, argc, argv, RECV_IP); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"IPSocket.getaddress;F;7[[I" host;T0;[[@is;T;:getaddress;0;[;{;IC; "Lookups the IP address of _host_. require 'socket' IPSocket.getaddress("localhost") #=> "127.0.0.1" IPSocket.getaddress("ip6-localhost") #=> "::1" ;T;[o;= ;>I" overload;F;?0;;w ;@0;:I"getaddress(host);T;IC; ";T;[;![;"I";T;#0;$@Q;.F;Bi;C0;7[[I" host;T0;$@Q;![;"I"Lookups the IP address of _host_. require 'socket' IPSocket.getaddress("localhost") #=> "127.0.0.1" IPSocket.getaddress("ip6-localhost") #=> "::1" @overload getaddress(host);T;#0;$@Q;.F;/o;0;1T;2ig;3ip;%@;9I"estatic VALUE ip_s_getaddress(VALUE obj, VALUE host) { union_sockaddr addr; struct rb_addrinfo *res = rsock_addrinfo(host, Qnil, AF_UNSPEC, SOCK_STREAM, 0); socklen_t len = res->ai->ai_addrlen; /* just take the first one */ memcpy(&addr, res->ai->ai_addr, len); rb_freeaddrinfo(res); return rsock_make_ipaddr(&addr.addr, len); };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;: IPSocket;;;;;[;{;IC; " IPSocket is the super class of TCPSocket and UDPSocket. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I" IPSocket;F;'o;( ;)0;*0;+0;;> ;%@;-@5;0o; ;IC;[o;4;5F;6;;;;&I"TCPSocket.gethostbyname;F;7[[I" host;T0;[[I"ext/socket/tcpsocket.c;TiS;T;;v ;0;[;{;IC; "GUse Addrinfo.getaddrinfo instead. This method is deprecated for the following reasons: - The 3rd element of the result is the address family of the first address. The address families of the rest of the addresses are not returned. - gethostbyname() may take a long time and it may block other threads. (GVL cannot be released since gethostbyname() is not thread safe.) - This method uses gethostbyname() function already removed from POSIX. This method lookups host information by _hostname_. TCPSocket.gethostbyname("localhost") #=> ["localhost", ["hal"], 2, "127.0.0.1"] ;T;[o;= ;>I" overload;F;?0;;v ;@0;:I"gethostbyname(hostname);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" hostname;T0;$@;![;"I"~Use Addrinfo.getaddrinfo instead. This method is deprecated for the following reasons: - The 3rd element of the result is the address family of the first address. The address families of the rest of the addresses are not returned. - gethostbyname() may take a long time and it may block other threads. (GVL cannot be released since gethostbyname() is not thread safe.) - This method uses gethostbyname() function already removed from POSIX. This method lookups host information by _hostname_. TCPSocket.gethostbyname("localhost") #=> ["localhost", ["hal"], 2, "127.0.0.1"] @overload gethostbyname(hostname) @return [Array];T;#0;$@;.F;/o;0;1T;2i@;3iQ;%@~;9I"-static VALUE tcp_s_gethostbyname(VALUE obj, VALUE host) { rb_warn("TCPSocket.gethostbyname is deprecated; use Addrinfo.getaddrinfo instead."); struct rb_addrinfo *res = rsock_addrinfo(host, Qnil, AF_UNSPEC, SOCK_STREAM, AI_CANONNAME); return rsock_make_hostent(host, res, tcp_sockaddr); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"TCPSocket#initialize;F;7[[@90;[[@i;T;;D;0;[;{;IC; "Opens a TCP connection to +remote_host+ on +remote_port+. If +local_host+ and +local_port+ are specified, then those parameters are used on the local end to establish the connection. [:connect_timeout] specify the timeout in seconds. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"Xnew(remote_host, remote_port, local_host=nil, local_port=nil, connect_timeout: nil);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[ [I"remote_host;T0[I"remote_port;T0[I"local_host;TI"nil;T[I"local_port;TI"nil;T[I"connect_timeout:;TI"nil;T;$@;![;"I"KOpens a TCP connection to +remote_host+ on +remote_port+. If +local_host+ and +local_port+ are specified, then those parameters are used on the local end to establish the connection. [:connect_timeout] specify the timeout in seconds. @overload new(remote_host, remote_port, local_host=nil, local_port=nil, connect_timeout: nil);T;#0;$@;.F;/o;0;1T;2i;3i;%@~;9I"Gstatic VALUE tcp_init(int argc, VALUE *argv, VALUE sock) { VALUE remote_host, remote_serv; VALUE local_host, local_serv; VALUE opt; static ID keyword_ids[2]; VALUE kwargs[2]; VALUE resolv_timeout = Qnil; VALUE connect_timeout = Qnil; if (!keyword_ids[0]) { CONST_ID(keyword_ids[0], "resolv_timeout"); CONST_ID(keyword_ids[1], "connect_timeout"); } rb_scan_args(argc, argv, "22:", &remote_host, &remote_serv, &local_host, &local_serv, &opt); if (!NIL_P(opt)) { rb_get_kwargs(opt, keyword_ids, 0, 2, kwargs); if (kwargs[0] != Qundef) { resolv_timeout = kwargs[0]; } if (kwargs[1] != Qundef) { connect_timeout = kwargs[1]; } } return rsock_init_inetsock(sock, remote_host, remote_serv, local_host, local_serv, INET_CLIENT, resolv_timeout, connect_timeout); };T;:I"static VALUE;T;;T; @~; IC;[; @~; IC;[; @~; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i_[@iq;T;:TCPSocket;;;;;[;{;IC; "TCPSocket represents a TCP/IP client socket. A simple client may look like: require 'socket' s = TCPSocket.new 'localhost', 2000 while line = s.gets # Read lines from socket puts line # and print them end s.close # close socket when done ;T;[;![;"I" TCPSocket represents a TCP/IP client socket. A simple client may look like: require 'socket' s = TCPSocket.new 'localhost', 2000 while line = s.gets # Read lines from socket puts line # and print them end s.close # close socket when done ;T;#0;$@~;.F;/o;0;1T;2i_;3in;%@;&I"TCPSocket;F;'o;( ;)0;*0;+0;;x ;%@;-@;0o; ;IC;[ o;4;5F;6;;;;&I"TCPServer#accept;F;7[;[[I"ext/socket/tcpserver.c;Ti<;T;;;0;[;{;IC; "Accepts an incoming connection. It returns a new TCPSocket object. TCPServer.open("127.0.0.1", 14641) {|serv| s = serv.accept s.puts Time.now s.close } ;T;[o;= ;>I" overload;F;?0;;;@0;:I" accept;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Accepts an incoming connection. It returns a new TCPSocket object. TCPServer.open("127.0.0.1", 14641) {|serv| s = serv.accept s.puts Time.now s.close } @overload accept;T;#0;$@;.F;/o;0;1T;2i/;3i9;%@;9I"static VALUE tcp_accept(VALUE server) { union_sockaddr buffer; socklen_t length = sizeof(buffer); return rsock_s_accept(rb_cTCPSocket, server, &buffer.addr, &length); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" TCPServer#__accept_nonblock;F;7[[I"ex;T0;[[@iF;T;;? ;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@;.F;/o;0;1T;2iE;3iE;%@;9I"static VALUE tcp_accept_nonblock(VALUE sock, VALUE ex) { rb_io_t *fptr; union_sockaddr from; socklen_t len = (socklen_t)sizeof(from); GetOpenFile(sock, fptr); return rsock_s_accept_nonblock(rb_cTCPSocket, ex, fptr, &from.addr, &len); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"TCPServer#sysaccept;F;7[;[[@i_;T;;@ ;0;[;{;IC; "Returns a file descriptor of a accepted connection. TCPServer.open("127.0.0.1", 28561) {|serv| fd = serv.sysaccept s = IO.for_fd(fd) s.puts Time.now s.close } ;T;[o;= ;>I" overload;F;?0;;@ ;@0;:I"sysaccept;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns a file descriptor of a accepted connection. TCPServer.open("127.0.0.1", 28561) {|serv| fd = serv.sysaccept s = IO.for_fd(fd) s.puts Time.now s.close } @overload sysaccept;T;#0;$@;.F;/o;0;1T;2iQ;3i\;%@;9I"static VALUE tcp_sysaccept(VALUE server) { union_sockaddr buffer; socklen_t length = sizeof(buffer); return rsock_s_accept(0, server, &buffer.addr, &length); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"TCPServer#initialize;F;7[[@90;[[@i&;T;;D;0;[;{;IC; "Creates a new server socket bound to _port_. If _hostname_ is given, the socket is bound to it. serv = TCPServer.new("127.0.0.1", 28561) s = serv.accept s.puts Time.now s.close Internally, TCPServer.new calls getaddrinfo() function to obtain addresses. If getaddrinfo() returns multiple addresses, TCPServer.new tries to create a server socket for each address and returns first one that is successful. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new([hostname,] port);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"[hostname,];T0;$@;![;"I"Creates a new server socket bound to _port_. If _hostname_ is given, the socket is bound to it. serv = TCPServer.new("127.0.0.1", 28561) s = serv.accept s.puts Time.now s.close Internally, TCPServer.new calls getaddrinfo() function to obtain addresses. If getaddrinfo() returns multiple addresses, TCPServer.new tries to create a server socket for each address and returns first one that is successful. @overload new([hostname,] port);T;#0;$@;.F;/o;0;1T;2i;3i#;%@;9I"static VALUE tcp_svr_init(int argc, VALUE *argv, VALUE sock) { VALUE hostname, port; rb_scan_args(argc, argv, "011", &hostname, &port); return rsock_init_inetsock(sock, hostname, port, Qnil, Qnil, INET_SERVER, Qnil, Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"TCPServer#listen;F;7[[I"log;T0;[[@i^;T;;A ;0;[;{;IC; "d Listens for connections, using the specified +int+ as the backlog. A call to _listen_ only applies if the +socket+ is of type SOCK_STREAM or SOCK_SEQPACKET. === Parameter * +backlog+ - the maximum length of the queue for pending connections. === Example 1 require 'socket' include Socket::Constants socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) socket.bind( sockaddr ) socket.listen( 5 ) === Example 2 (listening on an arbitrary port, unix-based systems only): require 'socket' include Socket::Constants socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) socket.listen( 1 ) === Unix-based Exceptions On unix based systems the above will work because a new +sockaddr+ struct is created on the address ADDR_ANY, for an arbitrary port number as handed off by the kernel. It will not work on Windows, because Windows requires that the +socket+ is bound by calling _bind_ before it can _listen_. If the _backlog_ amount exceeds the implementation-dependent maximum queue length, the implementation's maximum queue length will be used. On unix-based based systems the following system exceptions may be raised if the call to _listen_ fails: * Errno::EBADF - the _socket_ argument is not a valid file descriptor * Errno::EDESTADDRREQ - the _socket_ is not bound to a local address, and the protocol does not support listening on an unbound socket * Errno::EINVAL - the _socket_ is already connected * Errno::ENOTSOCK - the _socket_ argument does not refer to a socket * Errno::EOPNOTSUPP - the _socket_ protocol does not support listen * Errno::EACCES - the calling process does not have appropriate privileges * Errno::EINVAL - the _socket_ has been shut down * Errno::ENOBUFS - insufficient resources are available in the system to complete the call === Windows Exceptions On Windows systems the following system exceptions may be raised if the call to _listen_ fails: * Errno::ENETDOWN - the network is down * Errno::EADDRINUSE - the socket's local address is already in use. This usually occurs during the execution of _bind_ but could be delayed if the call to _bind_ was to a partially wildcard address (involving ADDR_ANY) and if a specific address needs to be committed at the time of the call to _listen_ * Errno::EINPROGRESS - a Windows Sockets 1.1 call is in progress or the service provider is still processing a callback function * Errno::EINVAL - the +socket+ has not been bound with a call to _bind_. * Errno::EISCONN - the +socket+ is already connected * Errno::EMFILE - no more socket descriptors are available * Errno::ENOBUFS - no buffer space is available * Errno::ENOTSOC - +socket+ is not a socket * Errno::EOPNOTSUPP - the referenced +socket+ is not a type that supports the _listen_ method === See * listen manual pages on unix-based systems * listen function in Microsoft's Winsock functions reference ;T;[o;= ;>I" overload;F;?0;;A ;@0;:I"listen( int );T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@/;![;"I"@return [0];T;#0;$@/;.F;Bi;C0;7[[I"int;T0;$@/;![;"@;#0;$@/;.F;/o;0;1T;2i;3i\;%@;9I"VALUE rsock_sock_listen(VALUE sock, VALUE log) { rb_io_t *fptr; int backlog; backlog = NUM2INT(log); GetOpenFile(sock, fptr); if (listen(fptr->fd, backlog) < 0) rb_sys_fail("listen(2)"); return INT2FIX(0); };T;:I" VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ik[@i;T;:TCPServer;;;;;[;{;IC; "<TCPServer represents a TCP/IP server socket. A simple TCP server may look like: require 'socket' server = TCPServer.new 2000 # Server bind to port 2000 loop do client = server.accept # Wait for a client to connect client.puts "Hello !" client.puts "Time is #{Time.now}" client.close end A more usable server (serving multiple clients): require 'socket' server = TCPServer.new 2000 loop do Thread.start(server.accept) do |client| client.puts "Hello !" client.puts "Time is #{Time.now}" client.close end end ;T;[;![;"I"? TCPServer represents a TCP/IP server socket. A simple TCP server may look like: require 'socket' server = TCPServer.new 2000 # Server bind to port 2000 loop do client = server.accept # Wait for a client to connect client.puts "Hello !" client.puts "Time is #{Time.now}" client.close end A more usable server (serving multiple clients): require 'socket' server = TCPServer.new 2000 loop do Thread.start(server.accept) do |client| client.puts "Hello !" client.puts "Time is #{Time.now}" client.close end end ;T;#0;$@;.F;/o;0;1T;2ik;3i;%@;&I"TCPServer;F;'o;( ;)0;*0;+0;;y ;%@;-@~;0o; ;IC;[o;4;5F;6;;;;&I"SOCKSSocket#initialize;F;7[[I" host;T0[I" port;T0;[[I"ext/socket/sockssocket.c;Ti ;T;;D;0;[;{;IC; "<Opens a SOCKS connection to +host+ via the SOCKS server. The SOCKS server configuration varies by implementation When using the Dante libsocks/libsocksd implementation it is configured as SOCKS_SERVER env var. See: https://manpages.debian.org/testing/dante-client/socksify.1.en.html for full env variable support. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(host, port);T;IC; ";T;[;![;"I";T;#0;$@b;.F;Bi;C0;7[[I" host;T0[I" port;T0;$@b;![;"I"YOpens a SOCKS connection to +host+ via the SOCKS server. The SOCKS server configuration varies by implementation When using the Dante libsocks/libsocksd implementation it is configured as SOCKS_SERVER env var. See: https://manpages.debian.org/testing/dante-client/socksify.1.en.html for full env variable support. @overload new(host, port);T;#0;$@b;.F;/o;0;1T;2i;3i;%@`;9I"static VALUE socks_init(VALUE sock, VALUE host, VALUE port) { static int init = 0; if (init == 0) { SOCKSinit("ruby"); init = 1; } return rsock_init_inetsock(sock, host, port, Qnil, Qnil, INET_SOCKS, Qnil, Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"SOCKSSocket#close;F;7[;[[@ki2;T;;;0;[;{;IC; "!Closes the SOCKS connection. ;T;[;![;"I"#Closes the SOCKS connection. ;T;#0;$@;.F;/o;0;1T;2i.;3i0;%@`;9I"static VALUE socks_s_close(VALUE sock) { rb_io_t *fptr; GetOpenFile(sock, fptr); shutdown(fptr->fd, 2); return rb_io_close(sock); };T;:I"static VALUE;T;;T; @`; IC;[; @`; IC;[; @`; IC;{;IC;{;T;IC;{;T;T;{;[;[[@kiB[@kiI;T;:SOCKSSocket;;;;;[;{;IC; "SOCKS is an Internet protocol that routes packets between a client and a server through a proxy server. SOCKS5, if supported, additionally provides authentication so only authorized users may access a server. ;T;[;![;"I" SOCKS is an Internet protocol that routes packets between a client and a server through a proxy server. SOCKS5, if supported, additionally provides authentication so only authorized users may access a server. ;T;#0;$@`;.F;/o;0;1T;2iB;3iF;%@;&I"SOCKSSocket;F;'o;( ;)0;*0;+0;;y ;%@;-@~;0o; ;IC;[ o;4;5F;6;;;;&I"UDPSocket#initialize;F;7[[@90;[[I"ext/socket/udpsocket.c;Ti!;T;;D;0;[;{;IC; " Creates a new UDPSocket object. _address_family_ should be an integer, a string or a symbol: Socket::AF_INET, "AF_INET", :INET, etc. require 'socket' UDPSocket.new #=> # UDPSocket.new(Socket::AF_INET6) #=> # ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new([address_family]);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"[address_family];T0;$@;![;"I"-Creates a new UDPSocket object. _address_family_ should be an integer, a string or a symbol: Socket::AF_INET, "AF_INET", :INET, etc. require 'socket' UDPSocket.new #=> # UDPSocket.new(Socket::AF_INET6) #=> # @overload new([address_family]);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"\static VALUE udp_init(int argc, VALUE *argv, VALUE sock) { VALUE arg; int family = AF_INET; int fd; if (rb_scan_args(argc, argv, "01", &arg) == 1) { family = rsock_family_arg(arg); } fd = rsock_socket(family, SOCK_DGRAM, 0); if (fd < 0) { rb_sys_fail("socket(2) - udp"); } return rsock_init_sock(sock, fd); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UDPSocket#connect;F;7[[I" host;T0[I" port;T0;[[@i[;T;;;0;[;{;IC; "+Connects _udpsocket_ to _host_:_port_. This makes possible to send without destination address. u1 = UDPSocket.new u1.bind("127.0.0.1", 4913) u2 = UDPSocket.new u2.connect("127.0.0.1", 4913) u2.send "uuuu", 0 p u1.recvfrom(10) #=> ["uuuu", ["AF_INET", 33230, "localhost", "127.0.0.1"]] ;T;[o;= ;>I" overload;F;?0;;;@0;:I"connect(host, port);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@;![;"I"@return [0];T;#0;$@;.F;Bi;C0;7[[I" host;T0[I" port;T0;$@;![;"I"ZConnects _udpsocket_ to _host_:_port_. This makes possible to send without destination address. u1 = UDPSocket.new u1.bind("127.0.0.1", 4913) u2 = UDPSocket.new u2.connect("127.0.0.1", 4913) u2.send "uuuu", 0 p u1.recvfrom(10) #=> ["uuuu", ["AF_INET", 33230, "localhost", "127.0.0.1"]] @overload connect(host, port) @return [0];T;#0;$@;.F;/o;0;1T;2iK;3iY;%@;9I"static VALUE udp_connect(VALUE sock, VALUE host, VALUE port) { struct udp_arg arg; VALUE ret; GetOpenFile(sock, arg.fptr); arg.res = rsock_addrinfo(host, port, rsock_fd_family(arg.fptr->fd), SOCK_DGRAM, 0); ret = rb_ensure(udp_connect_internal, (VALUE)&arg, rsock_freeaddrinfo, (VALUE)arg.res); if (!ret) rsock_sys_fail_host_port("connect(2)", host, port); return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UDPSocket#bind;F;7[[I" host;T0[I" port;T0;[[@i;T;; ;0;[;{;IC; "Binds _udpsocket_ to _host_:_port_. u1 = UDPSocket.new u1.bind("127.0.0.1", 4913) u1.send "message-to-self", 0, "127.0.0.1", 4913 p u1.recvfrom(10) #=> ["message-to", ["AF_INET", 4913, "localhost", "127.0.0.1"]] ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"bind(host, port) #=> 0;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" host;T0[I" port;T0;$@;![;"I"Binds _udpsocket_ to _host_:_port_. u1 = UDPSocket.new u1.bind("127.0.0.1", 4913) u1.send "message-to-self", 0, "127.0.0.1", 4913 p u1.recvfrom(10) #=> ["message-to", ["AF_INET", 4913, "localhost", "127.0.0.1"]] @overload bind(host, port) #=> 0;T;#0;$@;.F;/o;0;1T;2i|;3i;%@;9I"static VALUE udp_bind(VALUE sock, VALUE host, VALUE port) { struct udp_arg arg; VALUE ret; GetOpenFile(sock, arg.fptr); arg.res = rsock_addrinfo(host, port, rsock_fd_family(arg.fptr->fd), SOCK_DGRAM, 0); ret = rb_ensure(udp_bind_internal, (VALUE)&arg, rsock_freeaddrinfo, (VALUE)arg.res); if (!ret) rsock_sys_fail_host_port("bind(2)", host, port); return INT2FIX(0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"UDPSocket#send;F;7[[@90;[[@i;T;;{;0;[;{;IC; "&Sends _mesg_ via _udpsocket_. _flags_ should be a bitwise OR of Socket::MSG_* constants. u1 = UDPSocket.new u1.bind("127.0.0.1", 4913) u2 = UDPSocket.new u2.send "hi", 0, "127.0.0.1", 4913 mesg, addr = u1.recvfrom(10) u1.send mesg, 0, addr[3], addr[1] p u2.recv(100) #=> "hi" ;T;[o;= ;>I" overload;F;?0;;{;@0;:I""send(mesg, flags, host, port);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[ [I" mesg;T0[I" flags;T0[I" host;T0[I" port;T0;$@o;= ;>I" overload;F;?0;;{;@0;:I"#send(mesg, flags, sockaddr_to);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" mesg;T0[I" flags;T0[I"sockaddr_to;T0;$@o;= ;>I" overload;F;?0;;{;@0;:I"send(mesg, flags);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" mesg;T0[I" flags;T0;$@;![;"I"Sends _mesg_ via _udpsocket_. _flags_ should be a bitwise OR of Socket::MSG_* constants. u1 = UDPSocket.new u1.bind("127.0.0.1", 4913) u2 = UDPSocket.new u2.send "hi", 0, "127.0.0.1", 4913 mesg, addr = u1.recvfrom(10) u1.send mesg, 0, addr[3], addr[1] p u2.recv(100) #=> "hi" @overload send(mesg, flags, host, port) @overload send(mesg, flags, sockaddr_to) @overload send(mesg, flags);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE udp_send(int argc, VALUE *argv, VALUE sock) { VALUE flags, host, port; struct udp_send_arg arg; VALUE ret; if (argc == 2 || argc == 3) { return rsock_bsock_send(argc, argv, sock); } rb_scan_args(argc, argv, "4", &arg.sarg.mesg, &flags, &host, &port); StringValue(arg.sarg.mesg); GetOpenFile(sock, arg.fptr); arg.sarg.fd = arg.fptr->fd; arg.sarg.flags = NUM2INT(flags); arg.res = rsock_addrinfo(host, port, rsock_fd_family(arg.fptr->fd), SOCK_DGRAM, 0); ret = rb_ensure(udp_send_internal, (VALUE)&arg, rsock_freeaddrinfo, (VALUE)arg.res); if (!ret) rsock_sys_fail_host_port("sendto(2)", host, port); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""UDPSocket#__recvfrom_nonblock;F;7[ [I"len;T0[I"flg;T0[I"str;T0[I"ex;T0;[[@i;T;;t ;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@8;.F;/o;0;1T;2i;3i;%@;9I"static VALUE udp_recvfrom_nonblock(VALUE sock, VALUE len, VALUE flg, VALUE str, VALUE ex) { return rsock_s_recvfrom_nonblock(sock, len, flg, str, ex, RECV_IP); };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;:UDPSocket;;;;;[;{;IC; "*UDPSocket represents a UDP/IP socket. ;T;[;![;"I"- UDPSocket represents a UDP/IP socket. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I"UDPSocket;F;'o;( ;)0;*0;+0;;x ;%@;-@;0o;;IC;[o;;IC;[o;;IC;[o; ;IC;[%o;4;5F;6;;;;&I"+JSON::Ext::Generator::State.from_state;T;7[[I" opts;T0;[[I"#ext/json/generator/generator.c;Ti;T;:from_state;0;[;{;IC; "Creates a State object from _opts_, which ought to be Hash to create a new State instance configured by _opts_, something else to create an unconfigured instance. If _opts_ is a State object, it is just returned. ;T;[o;= ;>I" overload;F;?0;;} ;@0;:I"from_state(opts);T;IC; ";T;[;![;"I";T;#0;$@i;.F;Bi;C0;7[[I" opts;T0;$@i;![;"I"Creates a State object from _opts_, which ought to be Hash to create a new State instance configured by _opts_, something else to create an unconfigured instance. If _opts_ is a State object, it is just returned. @overload from_state(opts);T;#0;$@i;.F;/o;0;1T;2i;3i;%@g;9I")static VALUE cState_from_state_s(VALUE self, VALUE opts) { if (rb_obj_is_kind_of(opts, self)) { return opts; } else if (rb_obj_is_kind_of(opts, rb_cHash)) { return rb_funcall(self, i_new, 1, opts); } else { return rb_class_new_instance(0, NULL, cState); } };T;:I"=static VALUE cState_from_state_s(VALUE self, VALUE opts);T;;To;4;5F;6;;;;&I"+JSON::Ext::Generator::State#initialize;T;7[[@90;[[@pi\;T;;D;0;[;{;IC; "8Instantiates a new State object, configured by _opts_. _opts_ can have the following keys: * *indent*: a string used to indent levels (default: ''), * *space*: a string that is put after, a : or , delimiter (default: ''), * *space_before*: a string that is put before a : pair delimiter (default: ''), * *object_nl*: a string that is put at the end of a JSON object (default: ''), * *array_nl*: a string that is put at the end of a JSON array (default: ''), * *allow_nan*: true if NaN, Infinity, and -Infinity should be generated, otherwise an exception is thrown, if these values are encountered. This options defaults to false. * *ascii_only*: true if only ASCII characters should be generated. This option defaults to false. * *buffer_initial_length*: sets the initial length of the generator's internal buffer. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(opts = {});T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" opts;TI"{};T;$@;![;"I"SInstantiates a new State object, configured by _opts_. _opts_ can have the following keys: * *indent*: a string used to indent levels (default: ''), * *space*: a string that is put after, a : or , delimiter (default: ''), * *space_before*: a string that is put before a : pair delimiter (default: ''), * *object_nl*: a string that is put at the end of a JSON object (default: ''), * *array_nl*: a string that is put at the end of a JSON array (default: ''), * *allow_nan*: true if NaN, Infinity, and -Infinity should be generated, otherwise an exception is thrown, if these values are encountered. This options defaults to false. * *ascii_only*: true if only ASCII characters should be generated. This option defaults to false. * *buffer_initial_length*: sets the initial length of the generator's internal buffer. @overload new(opts = {});T;#0;$@;.F;/o;0;1T;2iH;3iZ;%@g;9I";static VALUE cState_initialize(int argc, VALUE *argv, VALUE self) { VALUE opts; GET_STATE(self); state->max_nesting = 100; state->buffer_initial_length = FBUFFER_INITIAL_LENGTH_DEFAULT; rb_scan_args(argc, argv, "01", &opts); if (!NIL_P(opts)) cState_configure(self, opts); return self; };T;:I"Fstatic VALUE cState_initialize(int argc, VALUE *argv, VALUE self);T;;To;4;5F;6;;;;&I"0JSON::Ext::Generator::State#initialize_copy;T;7[[I" orig;T0;[[@pim;T;;];0;[;{;IC; "UInitializes this object from orig if it can be duplicated/cloned and returns it. ;T;[o;= ;>I" overload;F;?0;;];@0;:I"initialize_copy(orig);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" orig;T0;$@;![;"I"wInitializes this object from orig if it can be duplicated/cloned and returns it. @overload initialize_copy(orig);T;#0;$@;.F;/o;0;1T;2ig;3ik;%@g;9I"static VALUE cState_init_copy(VALUE obj, VALUE orig) { JSON_Generator_State *objState, *origState; if (obj == orig) return obj; GET_STATE_TO(obj, objState); GET_STATE_TO(orig, origState); if (!objState) rb_raise(rb_eArgError, "unallocated JSON::State"); MEMCPY(objState, origState, JSON_Generator_State, 1); objState->indent = fstrndup(origState->indent, origState->indent_len); objState->space = fstrndup(origState->space, origState->space_len); objState->space_before = fstrndup(origState->space_before, origState->space_before_len); objState->object_nl = fstrndup(origState->object_nl, origState->object_nl_len); objState->array_nl = fstrndup(origState->array_nl, origState->array_nl_len); if (origState->array_delim) objState->array_delim = fbuffer_dup(origState->array_delim); if (origState->object_delim) objState->object_delim = fbuffer_dup(origState->object_delim); if (origState->object_delim2) objState->object_delim2 = fbuffer_dup(origState->object_delim2); return obj; };T;:I"9static VALUE cState_init_copy(VALUE obj, VALUE orig);T;;To;4;5F;6;;;;&I"'JSON::Ext::Generator::State#indent;T;7[;[[@pi;T;: indent;0;[;{;IC; "GReturns the string that is used to indent levels in the JSON text. ;T;[o;= ;>I" overload;F;?0;;~ ;@0;:I" indent();T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"\Returns the string that is used to indent levels in the JSON text. @overload indent();T;#0;$@;.F;/o;0;1T;2i;3i;%@g;9I"static VALUE cState_indent(VALUE self) { GET_STATE(self); return state->indent ? rb_str_new(state->indent, state->indent_len) : rb_str_new2(""); };T;:I"+static VALUE cState_indent(VALUE self);T;;To;4;5F;6;;;;&I"(JSON::Ext::Generator::State#indent=;T;7[[I" indent;T0;[[@pi;T;: indent=;0;[;{;IC; "DSets the string that is used to indent levels in the JSON text. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"indent=(indent);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" indent;T0;$@;![;"I"`Sets the string that is used to indent levels in the JSON text. @overload indent=(indent);T;#0;$@;.F;/o;0;1T;2i;3i;%@g;9I"static VALUE cState_indent_set(VALUE self, VALUE indent) { unsigned long len; GET_STATE(self); Check_Type(indent, T_STRING); len = RSTRING_LEN(indent); if (len == 0) { if (state->indent) { ruby_xfree(state->indent); state->indent = NULL; state->indent_len = 0; } } else { if (state->indent) ruby_xfree(state->indent); state->indent = fstrndup(RSTRING_PTR(indent), len); state->indent_len = len; } return Qnil; };T;:I"=static VALUE cState_indent_set(VALUE self, VALUE indent);T;;To;4;5F;6;;;;&I"&JSON::Ext::Generator::State#space;T;7[;[[@pi;T;: space;0;[;{;IC; "[Returns the string that is used to insert a space between the tokens in a JSON string. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" space();T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"oReturns the string that is used to insert a space between the tokens in a JSON string. @overload space();T;#0;$@;.F;/o;0;1T;2i;3i;%@g;9I"static VALUE cState_space(VALUE self) { GET_STATE(self); return state->space ? rb_str_new(state->space, state->space_len) : rb_str_new2(""); };T;:I"*static VALUE cState_space(VALUE self);T;;To;4;5F;6;;;;&I"'JSON::Ext::Generator::State#space=;T;7[[I" space;T0;[[@pi;T;: space=;0;[;{;IC; "cSets _space_ to the string that is used to insert a space between the tokens in a JSON string. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"space=(space);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" space;T0;$@;![;"I"}Sets _space_ to the string that is used to insert a space between the tokens in a JSON string. @overload space=(space);T;#0;$@;.F;/o;0;1T;2i;3i;%@g;9I"static VALUE cState_space_set(VALUE self, VALUE space) { unsigned long len; GET_STATE(self); Check_Type(space, T_STRING); len = RSTRING_LEN(space); if (len == 0) { if (state->space) { ruby_xfree(state->space); state->space = NULL; state->space_len = 0; } } else { if (state->space) ruby_xfree(state->space); state->space = fstrndup(RSTRING_PTR(space), len); state->space_len = len; } return Qnil; };T;:I";static VALUE cState_space_set(VALUE self, VALUE space);T;;To;4;5F;6;;;;&I"-JSON::Ext::Generator::State#space_before;T;7[;[[@pi;T;:space_before;0;[;{;IC; "VReturns the string that is used to insert a space before the ':' in JSON objects. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"space_before();T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"qReturns the string that is used to insert a space before the ':' in JSON objects. @overload space_before();T;#0;$@;.F;/o;0;1T;2i;3i;%@g;9I"static VALUE cState_space_before(VALUE self) { GET_STATE(self); return state->space_before ? rb_str_new(state->space_before, state->space_before_len) : rb_str_new2(""); };T;:I"1static VALUE cState_space_before(VALUE self);T;;To;4;5F;6;;;;&I".JSON::Ext::Generator::State#space_before=;T;7[[I"space_before;T0;[[@pi;T;:space_before=;0;[;{;IC; "SSets the string that is used to insert a space before the ':' in JSON objects. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" space_before=(space_before);T;IC; ";T;[;![;"I";T;#0;$@.;.F;Bi;C0;7[[I"space_before;T0;$@.;![;"I"{Sets the string that is used to insert a space before the ':' in JSON objects. @overload space_before=(space_before);T;#0;$@.;.F;/o;0;1T;2i;3i;%@g;9I"Ustatic VALUE cState_space_before_set(VALUE self, VALUE space_before) { unsigned long len; GET_STATE(self); Check_Type(space_before, T_STRING); len = RSTRING_LEN(space_before); if (len == 0) { if (state->space_before) { ruby_xfree(state->space_before); state->space_before = NULL; state->space_before_len = 0; } } else { if (state->space_before) ruby_xfree(state->space_before); state->space_before = fstrndup(RSTRING_PTR(space_before), len); state->space_before_len = len; } return Qnil; };T;:I"Istatic VALUE cState_space_before_set(VALUE self, VALUE space_before);T;;To;4;5F;6;;;;&I"*JSON::Ext::Generator::State#object_nl;T;7[;[[@pi;T;:object_nl;0;[;{;IC; "PThis string is put at the end of a line that holds a JSON object (or Hash). ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"object_nl();T;IC; ";T;[;![;"I";T;#0;$@H;.F;Bi;C0;7[;$@H;![;"I"hThis string is put at the end of a line that holds a JSON object (or Hash). @overload object_nl();T;#0;$@H;.F;/o;0;1T;2i;3i;%@g;9I"static VALUE cState_object_nl(VALUE self) { GET_STATE(self); return state->object_nl ? rb_str_new(state->object_nl, state->object_nl_len) : rb_str_new2(""); };T;:I".static VALUE cState_object_nl(VALUE self);T;;To;4;5F;6;;;;&I"+JSON::Ext::Generator::State#object_nl=;T;7[[I"object_nl;T0;[[@pi;T;:object_nl=;0;[;{;IC; "PThis string is put at the end of a line that holds a JSON object (or Hash). ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"object_nl=(object_nl);T;IC; ";T;[;![;"I";T;#0;$@^;.F;Bi;C0;7[[I"object_nl;T0;$@^;![;"I"rThis string is put at the end of a line that holds a JSON object (or Hash). @overload object_nl=(object_nl);T;#0;$@^;.F;/o;0;1T;2i;3i;%@g;9I"static VALUE cState_object_nl_set(VALUE self, VALUE object_nl) { unsigned long len; GET_STATE(self); Check_Type(object_nl, T_STRING); len = RSTRING_LEN(object_nl); if (len == 0) { if (state->object_nl) { ruby_xfree(state->object_nl); state->object_nl = NULL; } } else { if (state->object_nl) ruby_xfree(state->object_nl); state->object_nl = fstrndup(RSTRING_PTR(object_nl), len); state->object_nl_len = len; } return Qnil; };T;:I"Cstatic VALUE cState_object_nl_set(VALUE self, VALUE object_nl);T;;To;4;5F;6;;;;&I")JSON::Ext::Generator::State#array_nl;T;7[;[[@pi,;T;: array_nl;0;[;{;IC; "EThis string is put at the end of a line that holds a JSON array. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"array_nl();T;IC; ";T;[;![;"I";T;#0;$@x;.F;Bi;C0;7[;$@x;![;"I"\This string is put at the end of a line that holds a JSON array. @overload array_nl();T;#0;$@x;.F;/o;0;1T;2i';3i*;%@g;9I"static VALUE cState_array_nl(VALUE self) { GET_STATE(self); return state->array_nl ? rb_str_new(state->array_nl, state->array_nl_len) : rb_str_new2(""); };T;:I"-static VALUE cState_array_nl(VALUE self);T;;To;4;5F;6;;;;&I"*JSON::Ext::Generator::State#array_nl=;T;7[[I" array_nl;T0;[[@pi7;T;:array_nl=;0;[;{;IC; "EThis string is put at the end of a line that holds a JSON array. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"array_nl=(array_nl);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" array_nl;T0;$@;![;"I"eThis string is put at the end of a line that holds a JSON array. @overload array_nl=(array_nl);T;#0;$@;.F;/o;0;1T;2i2;3i5;%@g;9I"static VALUE cState_array_nl_set(VALUE self, VALUE array_nl) { unsigned long len; GET_STATE(self); Check_Type(array_nl, T_STRING); len = RSTRING_LEN(array_nl); if (len == 0) { if (state->array_nl) { ruby_xfree(state->array_nl); state->array_nl = NULL; } } else { if (state->array_nl) ruby_xfree(state->array_nl); state->array_nl = fstrndup(RSTRING_PTR(array_nl), len); state->array_nl_len = len; } return Qnil; };T;:I"Astatic VALUE cState_array_nl_set(VALUE self, VALUE array_nl);T;;To;4;5F;6;;;;&I",JSON::Ext::Generator::State#max_nesting;T;7[;[[@pi];T;:max_nesting;0;[;{;IC; "This integer returns the maximum level of data structure nesting in the generated JSON, max_nesting = 0 if no maximum is checked. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"max_nesting;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"This integer returns the maximum level of data structure nesting in the generated JSON, max_nesting = 0 if no maximum is checked. @overload max_nesting;T;#0;$@;.F;/o;0;1T;2iW;3i[;%@g;9I"rstatic VALUE cState_max_nesting(VALUE self) { GET_STATE(self); return LONG2FIX(state->max_nesting); };T;:I"0static VALUE cState_max_nesting(VALUE self);T;;To;4;5F;6;;;;&I"-JSON::Ext::Generator::State#max_nesting=;T;7[[I" depth;T0;[[@pii;T;:max_nesting=;0;[;{;IC; "This sets the maximum level of data structure nesting in the generated JSON to the integer depth, max_nesting = 0 if no maximum should be checked. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"max_nesting=(depth);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" depth;T0;$@;![;"I"This sets the maximum level of data structure nesting in the generated JSON to the integer depth, max_nesting = 0 if no maximum should be checked. @overload max_nesting=(depth);T;#0;$@;.F;/o;0;1T;2ic;3ig;%@g;9I"static VALUE cState_max_nesting_set(VALUE self, VALUE depth) { GET_STATE(self); Check_Type(depth, T_FIXNUM); return state->max_nesting = FIX2LONG(depth); };T;:I"Astatic VALUE cState_max_nesting_set(VALUE self, VALUE depth);T;;To;4;5F;6;;;;&I"-JSON::Ext::Generator::State#escape_slash;T;7[;[[@piv;T;:escape_slash;0;[;{;IC; "UIf this boolean is true, the forward slashes will be escaped in the json output. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"escape_slash;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"nIf this boolean is true, the forward slashes will be escaped in the json output. @overload escape_slash;T;#0;$@;.F;/o;0;1T;2ip;3it;%@g;9I"{static VALUE cState_escape_slash(VALUE self) { GET_STATE(self); return state->escape_slash ? Qtrue : Qfalse; };T;:I"1static VALUE cState_escape_slash(VALUE self);T;;To;4;5F;6;;;;&I".JSON::Ext::Generator::State#escape_slash?;T;7[;[[@piv;T;:escape_slash?;0;[;{;IC; "UIf this boolean is true, the forward slashes will be escaped in the json output.;T;[o;= ;>I" overload;F;?0;; ;@0;:I"escape_slash;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@o;A ;>I" return;F;?@;0;@[@L;$@;![;"@;#0;$@;.F;/o;0;1T;2ip;3it;Bi;%@g;9I"{static VALUE cState_escape_slash(VALUE self) { GET_STATE(self); return state->escape_slash ? Qtrue : Qfalse; };T;:I"1static VALUE cState_escape_slash(VALUE self);T;;To;4;5F;6;;;;&I".JSON::Ext::Generator::State#escape_slash=;T;7[[I" enable;T0;[[@pi;T;:escape_slash=;0;[;{;IC; "UThis sets whether or not the forward slashes will be escaped in the json output. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"escape_slash=(depth);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" depth;T0;$@;![;"I"vThis sets whether or not the forward slashes will be escaped in the json output. @overload escape_slash=(depth);T;#0;$@;.F;/o;0;1T;2i|;3i;%@g;9I"static VALUE cState_escape_slash_set(VALUE self, VALUE enable) { GET_STATE(self); state->escape_slash = RTEST(enable); return Qnil; };T;:I"Cstatic VALUE cState_escape_slash_set(VALUE self, VALUE enable);T;;To;4;5F;6;;;;&I"0JSON::Ext::Generator::State#check_circular?;T;7[;[[@piQ;T;:check_circular?;0;[;{;IC; "ZReturns true, if circular data structures should be checked, otherwise returns false.;T;[o;= ;>I" overload;F;?0;; ;@0;:I"check_circular?;T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[;$@ o;A ;>I" return;F;?@;0;@[@L;$@ ;![;"I"vReturns true, if circular data structures should be checked, otherwise returns false. @overload check_circular?;T;#0;$@ ;.F;/o;0;1T;2iK;3iO;Bi;%@g;9I"~static VALUE cState_check_circular_p(VALUE self) { GET_STATE(self); return state->max_nesting ? Qtrue : Qfalse; };T;:I"5static VALUE cState_check_circular_p(VALUE self);T;;To;4;5F;6;;;;&I"+JSON::Ext::Generator::State#allow_nan?;T;7[;[[@pi;T;:allow_nan?;0;[;{;IC; "`Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise returns false.;T;[o;= ;>I" overload;F;?0;; ;@0;:I"allow_nan?;T;IC; ";T;[;![;"I";T;#0;$@9;.F;Bi;C0;7[;$@9o;A ;>I" return;F;?@;0;@[@L;$@9;![;"I"wReturns true, if NaN, Infinity, and -Infinity should be generated, otherwise returns false. @overload allow_nan?;T;#0;$@9;.F;/o;0;1T;2i;3i;Bi;%@g;9I"wstatic VALUE cState_allow_nan_p(VALUE self) { GET_STATE(self); return state->allow_nan ? Qtrue : Qfalse; };T;:I"0static VALUE cState_allow_nan_p(VALUE self);T;;To;4;5F;6;;;;&I",JSON::Ext::Generator::State#ascii_only?;T;7[;[[@pi;T;:ascii_only?;0;[;{;IC; "YReturns true, if only ASCII characters should be generated. Otherwise returns false.;T;[o;= ;>I" overload;F;?0;; ;@0;:I"ascii_only?;T;IC; ";T;[;![;"I";T;#0;$@R;.F;Bi;C0;7[;$@Ro;A ;>I" return;F;?@;0;@[@L;$@R;![;"I"qReturns true, if only ASCII characters should be generated. Otherwise returns false. @overload ascii_only?;T;#0;$@R;.F;/o;0;1T;2i;3i;Bi;%@g;9I"ystatic VALUE cState_ascii_only_p(VALUE self) { GET_STATE(self); return state->ascii_only ? Qtrue : Qfalse; };T;:I"1static VALUE cState_ascii_only_p(VALUE self);T;;To;4;5F;6;;;;&I"&JSON::Ext::Generator::State#depth;T;7[;[[@pi;T;: depth;0;[;{;IC; "FThis integer returns the current depth of data structure nesting. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" depth;T;IC; ";T;[;![;"I";T;#0;$@k;.F;Bi;C0;7[;$@k;![;"I"XThis integer returns the current depth of data structure nesting. @overload depth;T;#0;$@k;.F;/o;0;1T;2i;3i;%@g;9I"fstatic VALUE cState_depth(VALUE self) { GET_STATE(self); return LONG2FIX(state->depth); };T;:I"*static VALUE cState_depth(VALUE self);T;;To;4;5F;6;;;;&I"'JSON::Ext::Generator::State#depth=;T;7[[I" depth;T0;[[@pi;T;: depth=;0;[;{;IC; "This sets the maximum level of data structure nesting in the generated JSON to the integer depth, max_nesting = 0 if no maximum should be checked. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"depth=(depth);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" depth;T0;$@;![;"I"This sets the maximum level of data structure nesting in the generated JSON to the integer depth, max_nesting = 0 if no maximum should be checked. @overload depth=(depth);T;#0;$@;.F;/o;0;1T;2i;3i;%@g;9I"static VALUE cState_depth_set(VALUE self, VALUE depth) { GET_STATE(self); Check_Type(depth, T_FIXNUM); state->depth = FIX2LONG(depth); return Qnil; };T;:I";static VALUE cState_depth_set(VALUE self, VALUE depth);T;;To;4;5F;6;;;;&I"6JSON::Ext::Generator::State#buffer_initial_length;T;7[;[[@pi;T;:buffer_initial_length;0;[;{;IC; "CThis integer returns the current initial length of the buffer. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"buffer_initial_length;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"eThis integer returns the current initial length of the buffer. @overload buffer_initial_length;T;#0;$@;.F;/o;0;1T;2i;3i;%@g;9I"static VALUE cState_buffer_initial_length(VALUE self) { GET_STATE(self); return LONG2FIX(state->buffer_initial_length); };T;:I":static VALUE cState_buffer_initial_length(VALUE self);T;;To;4;5F;6;;;;&I"7JSON::Ext::Generator::State#buffer_initial_length=;T;7[[I"buffer_initial_length;T0;[[@pi;T;:buffer_initial_length=;0;[;{;IC; "pThis sets the initial length of the buffer to +length+, if +length+ > 0, otherwise its value isn't changed. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"#buffer_initial_length=(length);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" length;T0;$@;![;"I"This sets the initial length of the buffer to +length+, if +length+ > 0, otherwise its value isn't changed. @overload buffer_initial_length=(length);T;#0;$@;.F;/o;0;1T;2i;3i;%@g;9I"[static VALUE cState_buffer_initial_length_set(VALUE self, VALUE buffer_initial_length) { long initial_length; GET_STATE(self); Check_Type(buffer_initial_length, T_FIXNUM); initial_length = FIX2LONG(buffer_initial_length); if (initial_length > 0) { state->buffer_initial_length = initial_length; } return Qnil; };T;:I"[static VALUE cState_buffer_initial_length_set(VALUE self, VALUE buffer_initial_length);T;;To;4;5F;6;;;;&I"*JSON::Ext::Generator::State#configure;T;7[[I" opts;T0;[[@pi;T;:configure;0;[;{;IC; "KConfigure this State instance with the Hash _opts_, and return itself. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"configure(opts);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" opts;T0;$@;![;"I"gConfigure this State instance with the Hash _opts_, and return itself. @overload configure(opts);T;#0;$o;4;5F;6;;;;&I"&JSON::Ext::Generator::State#merge;T;7[;[[@pi;F;;;;;[;{;@;%@g;9I" static VALUE cState_configure(VALUE self, VALUE opts) { VALUE tmp; GET_STATE(self); tmp = rb_check_convert_type(opts, T_HASH, "Hash", "to_hash"); if (NIL_P(tmp)) tmp = rb_convert_type(opts, T_HASH, "Hash", "to_h"); opts = tmp; tmp = rb_hash_aref(opts, ID2SYM(i_indent)); if (RTEST(tmp)) { unsigned long len; Check_Type(tmp, T_STRING); len = RSTRING_LEN(tmp); state->indent = fstrndup(RSTRING_PTR(tmp), len + 1); state->indent_len = len; } tmp = rb_hash_aref(opts, ID2SYM(i_space)); if (RTEST(tmp)) { unsigned long len; Check_Type(tmp, T_STRING); len = RSTRING_LEN(tmp); state->space = fstrndup(RSTRING_PTR(tmp), len + 1); state->space_len = len; } tmp = rb_hash_aref(opts, ID2SYM(i_space_before)); if (RTEST(tmp)) { unsigned long len; Check_Type(tmp, T_STRING); len = RSTRING_LEN(tmp); state->space_before = fstrndup(RSTRING_PTR(tmp), len + 1); state->space_before_len = len; } tmp = rb_hash_aref(opts, ID2SYM(i_array_nl)); if (RTEST(tmp)) { unsigned long len; Check_Type(tmp, T_STRING); len = RSTRING_LEN(tmp); state->array_nl = fstrndup(RSTRING_PTR(tmp), len + 1); state->array_nl_len = len; } tmp = rb_hash_aref(opts, ID2SYM(i_object_nl)); if (RTEST(tmp)) { unsigned long len; Check_Type(tmp, T_STRING); len = RSTRING_LEN(tmp); state->object_nl = fstrndup(RSTRING_PTR(tmp), len + 1); state->object_nl_len = len; } tmp = ID2SYM(i_max_nesting); state->max_nesting = 100; if (option_given_p(opts, tmp)) { VALUE max_nesting = rb_hash_aref(opts, tmp); if (RTEST(max_nesting)) { Check_Type(max_nesting, T_FIXNUM); state->max_nesting = FIX2LONG(max_nesting); } else { state->max_nesting = 0; } } tmp = ID2SYM(i_depth); state->depth = 0; if (option_given_p(opts, tmp)) { VALUE depth = rb_hash_aref(opts, tmp); if (RTEST(depth)) { Check_Type(depth, T_FIXNUM); state->depth = FIX2LONG(depth); } else { state->depth = 0; } } tmp = ID2SYM(i_buffer_initial_length); if (option_given_p(opts, tmp)) { VALUE buffer_initial_length = rb_hash_aref(opts, tmp); if (RTEST(buffer_initial_length)) { long initial_length; Check_Type(buffer_initial_length, T_FIXNUM); initial_length = FIX2LONG(buffer_initial_length); if (initial_length > 0) state->buffer_initial_length = initial_length; } } tmp = rb_hash_aref(opts, ID2SYM(i_allow_nan)); state->allow_nan = RTEST(tmp); tmp = rb_hash_aref(opts, ID2SYM(i_ascii_only)); state->ascii_only = RTEST(tmp); tmp = rb_hash_aref(opts, ID2SYM(i_escape_slash)); state->escape_slash = RTEST(tmp); return self; };T;:I":static VALUE cState_configure(VALUE self, VALUE opts);T;.F;/o;0;1T;2i;3i;%@g;9I" static VALUE cState_configure(VALUE self, VALUE opts) { VALUE tmp; GET_STATE(self); tmp = rb_check_convert_type(opts, T_HASH, "Hash", "to_hash"); if (NIL_P(tmp)) tmp = rb_convert_type(opts, T_HASH, "Hash", "to_h"); opts = tmp; tmp = rb_hash_aref(opts, ID2SYM(i_indent)); if (RTEST(tmp)) { unsigned long len; Check_Type(tmp, T_STRING); len = RSTRING_LEN(tmp); state->indent = fstrndup(RSTRING_PTR(tmp), len + 1); state->indent_len = len; } tmp = rb_hash_aref(opts, ID2SYM(i_space)); if (RTEST(tmp)) { unsigned long len; Check_Type(tmp, T_STRING); len = RSTRING_LEN(tmp); state->space = fstrndup(RSTRING_PTR(tmp), len + 1); state->space_len = len; } tmp = rb_hash_aref(opts, ID2SYM(i_space_before)); if (RTEST(tmp)) { unsigned long len; Check_Type(tmp, T_STRING); len = RSTRING_LEN(tmp); state->space_before = fstrndup(RSTRING_PTR(tmp), len + 1); state->space_before_len = len; } tmp = rb_hash_aref(opts, ID2SYM(i_array_nl)); if (RTEST(tmp)) { unsigned long len; Check_Type(tmp, T_STRING); len = RSTRING_LEN(tmp); state->array_nl = fstrndup(RSTRING_PTR(tmp), len + 1); state->array_nl_len = len; } tmp = rb_hash_aref(opts, ID2SYM(i_object_nl)); if (RTEST(tmp)) { unsigned long len; Check_Type(tmp, T_STRING); len = RSTRING_LEN(tmp); state->object_nl = fstrndup(RSTRING_PTR(tmp), len + 1); state->object_nl_len = len; } tmp = ID2SYM(i_max_nesting); state->max_nesting = 100; if (option_given_p(opts, tmp)) { VALUE max_nesting = rb_hash_aref(opts, tmp); if (RTEST(max_nesting)) { Check_Type(max_nesting, T_FIXNUM); state->max_nesting = FIX2LONG(max_nesting); } else { state->max_nesting = 0; } } tmp = ID2SYM(i_depth); state->depth = 0; if (option_given_p(opts, tmp)) { VALUE depth = rb_hash_aref(opts, tmp); if (RTEST(depth)) { Check_Type(depth, T_FIXNUM); state->depth = FIX2LONG(depth); } else { state->depth = 0; } } tmp = ID2SYM(i_buffer_initial_length); if (option_given_p(opts, tmp)) { VALUE buffer_initial_length = rb_hash_aref(opts, tmp); if (RTEST(buffer_initial_length)) { long initial_length; Check_Type(buffer_initial_length, T_FIXNUM); initial_length = FIX2LONG(buffer_initial_length); if (initial_length > 0) state->buffer_initial_length = initial_length; } } tmp = rb_hash_aref(opts, ID2SYM(i_allow_nan)); state->allow_nan = RTEST(tmp); tmp = rb_hash_aref(opts, ID2SYM(i_ascii_only)); state->ascii_only = RTEST(tmp); tmp = rb_hash_aref(opts, ID2SYM(i_escape_slash)); state->escape_slash = RTEST(tmp); return self; };T;:@;;T@o;4;5F;6;;;;&I"%JSON::Ext::Generator::State#to_h;T;7[;[[@pi;T;;;0;[;{;IC; "hReturns the configuration instance variables as a hash, that can be passed to the configure method. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_h;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"yReturns the configuration instance variables as a hash, that can be passed to the configure method. @overload to_h;T;#0;$o;4;5F;6;;;;&I"(JSON::Ext::Generator::State#to_hash;T;7[;[[@pi ;F;;;;;[;{;@;%@g;9I"hstatic VALUE cState_to_h(VALUE self) { VALUE result = rb_hash_new(); GET_STATE(self); set_state_ivars(result, self); rb_hash_aset(result, ID2SYM(i_indent), rb_str_new(state->indent, state->indent_len)); rb_hash_aset(result, ID2SYM(i_space), rb_str_new(state->space, state->space_len)); rb_hash_aset(result, ID2SYM(i_space_before), rb_str_new(state->space_before, state->space_before_len)); rb_hash_aset(result, ID2SYM(i_object_nl), rb_str_new(state->object_nl, state->object_nl_len)); rb_hash_aset(result, ID2SYM(i_array_nl), rb_str_new(state->array_nl, state->array_nl_len)); rb_hash_aset(result, ID2SYM(i_allow_nan), state->allow_nan ? Qtrue : Qfalse); rb_hash_aset(result, ID2SYM(i_ascii_only), state->ascii_only ? Qtrue : Qfalse); rb_hash_aset(result, ID2SYM(i_max_nesting), LONG2FIX(state->max_nesting)); rb_hash_aset(result, ID2SYM(i_escape_slash), state->escape_slash ? Qtrue : Qfalse); rb_hash_aset(result, ID2SYM(i_depth), LONG2FIX(state->depth)); rb_hash_aset(result, ID2SYM(i_buffer_initial_length), LONG2FIX(state->buffer_initial_length)); return result; };T;:I")static VALUE cState_to_h(VALUE self);T;.F;/o;0;1T;2i;3i;%@g;9I"hstatic VALUE cState_to_h(VALUE self) { VALUE result = rb_hash_new(); GET_STATE(self); set_state_ivars(result, self); rb_hash_aset(result, ID2SYM(i_indent), rb_str_new(state->indent, state->indent_len)); rb_hash_aset(result, ID2SYM(i_space), rb_str_new(state->space, state->space_len)); rb_hash_aset(result, ID2SYM(i_space_before), rb_str_new(state->space_before, state->space_before_len)); rb_hash_aset(result, ID2SYM(i_object_nl), rb_str_new(state->object_nl, state->object_nl_len)); rb_hash_aset(result, ID2SYM(i_array_nl), rb_str_new(state->array_nl, state->array_nl_len)); rb_hash_aset(result, ID2SYM(i_allow_nan), state->allow_nan ? Qtrue : Qfalse); rb_hash_aset(result, ID2SYM(i_ascii_only), state->ascii_only ? Qtrue : Qfalse); rb_hash_aset(result, ID2SYM(i_max_nesting), LONG2FIX(state->max_nesting)); rb_hash_aset(result, ID2SYM(i_escape_slash), state->escape_slash ? Qtrue : Qfalse); rb_hash_aset(result, ID2SYM(i_depth), LONG2FIX(state->depth)); rb_hash_aset(result, ID2SYM(i_buffer_initial_length), LONG2FIX(state->buffer_initial_length)); return result; };T;:@;;T@o;4;5F;6;;;;&I"#JSON::Ext::Generator::State#[];T;7[[I" name;T0;[[@pi;T;;;0;[;{;IC; "1Returns the value returned by method +name+. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" [](name);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I" name;T0;$@ ;![;"I"FReturns the value returned by method +name+. @overload [](name);T;#0;$@ ;.F;/o;0;1T;2i;3i;%@g;9I"5static VALUE cState_aref(VALUE self, VALUE name) { name = rb_funcall(name, i_to_s, 0); if (RTEST(rb_funcall(self, i_respond_to_p, 1, name))) { return rb_funcall(self, i_send, 1, name); } else { return rb_attr_get(self, rb_intern_str(rb_str_concat(rb_str_new2("@"), name))); } };T;:I"5static VALUE cState_aref(VALUE self, VALUE name);T;;To;4;5F;6;;;;&I"$JSON::Ext::Generator::State#[]=;T;7[[I" name;T0[I" value;T0;[[@pi;T;;8;0;[;{;IC; "&Sets the attribute name to value. ;T;[o;= ;>I" overload;F;?0;;8;@0;:I"[]=(name, value);T;IC; ";T;[;![;"I";T;#0;$@%;.F;Bi;C0;7[[I" name;T0[I" value;T0;$@%;![;"I"CSets the attribute name to value. @overload []=(name, value);T;#0;$@%;.F;/o;0;1T;2i;3i;%@g;9I"static VALUE cState_aset(VALUE self, VALUE name, VALUE value) { VALUE name_writer; name = rb_funcall(name, i_to_s, 0); name_writer = rb_str_cat2(rb_str_dup(name), "="); if (RTEST(rb_funcall(self, i_respond_to_p, 1, name_writer))) { return rb_funcall(self, i_send, 2, name_writer, value); } else { rb_ivar_set(self, rb_intern_str(rb_str_concat(rb_str_new2("@"), name)), value); } return Qnil; };T;:I"Bstatic VALUE cState_aset(VALUE self, VALUE name, VALUE value);T;;To;4;5F;6;;;;&I")JSON::Ext::Generator::State#generate;T;7[[I"obj;T0;[[@pi@;T;;;0;[;{;IC; "Generates a valid JSON document from object +obj+ and returns the result. If no valid JSON document can be created this method raises a GeneratorError exception. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"generate(obj);T;IC; ";T;[;![;"I";T;#0;$@C;.F;Bi;C0;7[[I"obj;T0;$@C;![;"I"Generates a valid JSON document from object +obj+ and returns the result. If no valid JSON document can be created this method raises a GeneratorError exception. @overload generate(obj);T;#0;$@C;.F;/o;0;1T;2i9;3i>;%@g;9I"static VALUE cState_generate(VALUE self, VALUE obj) { VALUE result = cState_partial_generate(self, obj); GET_STATE(self); (void)state; return result; };T;:I"8static VALUE cState_generate(VALUE self, VALUE obj);T;;T; @g; IC;[; @g; IC;[; @g; IC;{;IC;{;T;IC;{;T;T;{@; @;;[;[[@pi;F;: State;;;;;[;{;IC; " ;T;[;![;"@;#0;$@g;Bi;%@e;&I" JSON::Ext::Generator::State;T;'@o;;IC;[o;;IC;[o;4;5F;6;;;;&I";JSON::Ext::Generator::GeneratorMethods::Object#to_json;T;7[[@90;[[@piB;T;: to_json;0;[;{;IC; "Converts this object to a string (calling #to_s), converts it to a JSON string, and returns the result. This is a fallback, if no special method #to_json was defined for some object. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"to_json(*);T;IC; ";T;[;![;"I";T;#0;$@p;.F;Bi;C0;7[[I"*;T0;$@p;![;"I"Converts this object to a string (calling #to_s), converts it to a JSON string, and returns the result. This is a fallback, if no special method #to_json was defined for some object. @overload to_json(*);T;#0;$@p;.F;/o;0;1T;2i;;3i@;%@n;9I"5static VALUE mObject_to_json(int argc, VALUE *argv, VALUE self) { VALUE state; VALUE string = rb_funcall(self, i_to_s, 0); rb_scan_args(argc, argv, "01", &state); Check_Type(string, T_STRING); state = cState_from_state_s(cState, state); return cState_partial_generate(state, string); };T;:I"Dstatic VALUE mObject_to_json(int argc, VALUE *argv, VALUE self);T;;T; @n; IC;[; @n; IC;[; @n; IC;{;IC;{;T;IC;{;T;T;{;[;[[@pi[@pi;T;;;;;;;[;{;IC; " :nodoc:;T;[;![;"I" :nodoc: ;T;#0;$@n;.F;/o;0;1T;2i;3i;Bi;%o;( ;)@;*I"+JSON::Ext::Generator::GeneratorMethods;T;+0;:GeneratorMethods;%o;( ;)@;*I"JSON::Ext::Generator;T;+0;;V ;%o;( ;)@;*I"JSON::Ext;T;+0;:Ext;%@a;-@c;0;-@e;0;-@l;0;&I"3JSON::Ext::Generator::GeneratorMethods::Object;To;;IC;[o;4;5F;6;;;;&I"9JSON::Ext::Generator::GeneratorMethods::Hash#to_json;T;7[[@90;[[@pi;T;; ;0;[;{;IC; "Returns a JSON string containing a JSON object, that is generated from this Hash instance. _state_ is a JSON::State object, that can also be used to configure the produced JSON string output further. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"to_json(state = nil);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" state;TI"nil;T;$@;![;"I"Returns a JSON string containing a JSON object, that is generated from this Hash instance. _state_ is a JSON::State object, that can also be used to configure the produced JSON string output further. @overload to_json(state = nil);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"astatic VALUE mHash_to_json(int argc, VALUE *argv, VALUE self) { GENERATE_JSON(object); };T;:I"Bstatic VALUE mHash_to_json(int argc, VALUE *argv, VALUE self);T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@pis[@pi;T;;;;;;;[;{;IC; " :nodoc:;T;[;![;"I" :nodoc: ;T;#0;$@;.F;/o;0;1T;2is;3it;Bi;%o;( ;)@;*I"+JSON::Ext::Generator::GeneratorMethods;T;+0;; ;%@;-@l;0;&I"1JSON::Ext::Generator::GeneratorMethods::Hash;To;;IC;[o;4;5F;6;;;;&I":JSON::Ext::Generator::GeneratorMethods::Array#to_json;T;7[[@90;[[@pi;T;; ;0;[;{;IC; "Returns a JSON string containing a JSON array, that is generated from this Array instance. _state_ is a JSON::State object, that can also be used to configure the produced JSON string output further. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"to_json(state = nil);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" state;TI"nil;T;$@;![;"I"Returns a JSON string containing a JSON array, that is generated from this Array instance. _state_ is a JSON::State object, that can also be used to configure the produced JSON string output further. @overload to_json(state = nil);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"astatic VALUE mArray_to_json(int argc, VALUE *argv, VALUE self) { GENERATE_JSON(array); };T;:I"Estatic VALUE mArray_to_json(int argc, VALUE *argv, VALUE self) {;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@piZ[@pi;T;;;;;;;[;{;IC; " :nodoc:;T;[;![;"I" :nodoc: ;T;#0;$@;.F;/o;0;1T;2iZ;3i[;Bi;%o;( ;)@;*I"+JSON::Ext::Generator::GeneratorMethods;T;+0;; ;%@;-@l;0;&I"2JSON::Ext::Generator::GeneratorMethods::Array;To;;IC;[o;4;5F;6;;;;&I"I" overload;F;?0;; ;@0;:I"to_json(*);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"*;T0;$@;![;"I"YReturns a JSON string representation for this Integer number. @overload to_json(*);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"estatic VALUE mInteger_to_json(int argc, VALUE *argv, VALUE self) { GENERATE_JSON(integer); };T;:I"Estatic VALUE mInteger_to_json(int argc, VALUE *argv, VALUE self);T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@pix[@pi;T;;;;;;;[;{;IC; " :nodoc:;T;[;![;"I" :nodoc: ;T;#0;$@;.F;/o;0;1T;2ix;3iy;Bi;%o;( ;)@;*I"+JSON::Ext::Generator::GeneratorMethods;T;+0;; ;%@;-@l;0;&I"4JSON::Ext::Generator::GeneratorMethods::Integer;To;;IC;[o;4;5F;6;;;;&I";JSON::Ext::Generator::GeneratorMethods::Fixnum#to_json;T;7[[@90;[[@pi;T;; ;0;[;{;IC; "BReturns a JSON string representation for this Integer number. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"to_json(*);T;IC; ";T;[;![;"I";T;#0;$@2;.F;Bi;C0;7[[I"*;T0;$@2;![;"I"YReturns a JSON string representation for this Integer number. @overload to_json(*);T;#0;$@2;.F;/o;0;1T;2i;3i;%@0;9I"cstatic VALUE mFixnum_to_json(int argc, VALUE *argv, VALUE self) { GENERATE_JSON(fixnum); };T;:I"Dstatic VALUE mFixnum_to_json(int argc, VALUE *argv, VALUE self);T;;T; @0; IC;[; @0; IC;[; @0; IC;{;IC;{;T;IC;{;T;T;{;[;[[@pii[@pi;T;;~;;;;;[;{;IC; " :nodoc:;T;[;![;"I" :nodoc: ;T;#0;$@0;.F;/o;0;1T;2ii;3ij;Bi;%o;( ;)@;*I"+JSON::Ext::Generator::GeneratorMethods;T;+0;; ;%@;-@l;0;&I"3JSON::Ext::Generator::GeneratorMethods::Fixnum;To;;IC;[o;4;5F;6;;;;&I";JSON::Ext::Generator::GeneratorMethods::Bignum#to_json;T;7[[@90;[[@pi;T;; ;0;[;{;IC; "BReturns a JSON string representation for this Integer number. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"to_json(*);T;IC; ";T;[;![;"I";T;#0;$@a;.F;Bi;C0;7[[I"*;T0;$@a;![;"I"YReturns a JSON string representation for this Integer number. @overload to_json(*);T;#0;$@a;.F;/o;0;1T;2i;3i;%@_;9I"cstatic VALUE mBignum_to_json(int argc, VALUE *argv, VALUE self) { GENERATE_JSON(bignum); };T;:I"Dstatic VALUE mBignum_to_json(int argc, VALUE *argv, VALUE self);T;;T; @_; IC;[; @_; IC;[; @_; IC;{;IC;{;T;IC;{;T;T;{;[;[[@pi_[@pi;T;;v;;;;;[;{;IC; " :nodoc:;T;[;![;"I" :nodoc: ;T;#0;$@_;.F;/o;0;1T;2i_;3i`;Bi;%o;( ;)@;*I"+JSON::Ext::Generator::GeneratorMethods;T;+0;; ;%@;-@l;0;&I"3JSON::Ext::Generator::GeneratorMethods::Bignum;To;;IC;[o;4;5F;6;;;;&I":JSON::Ext::Generator::GeneratorMethods::Float#to_json;T;7[[@90;[[@pi;T;; ;0;[;{;IC; "@Returns a JSON string representation for this Float number. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"to_json(*);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"*;T0;$@;![;"I"WReturns a JSON string representation for this Float number. @overload to_json(*);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"astatic VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self) { GENERATE_JSON(float); };T;:I"Cstatic VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self);T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@pin[@pi;T;;;;;;;[;{;IC; " :nodoc:;T;[;![;"I" :nodoc: ;T;#0;$@;.F;/o;0;1T;2in;3io;Bi;%o;( ;)@;*I"+JSON::Ext::Generator::GeneratorMethods;T;+0;; ;%@;-@l;0;&I"2JSON::Ext::Generator::GeneratorMethods::Float;To;;IC;[ o;4;5F;6;;;;&I"I" overload;F;?0;; ;@0;:I"included(modul);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" modul;T0;$@;![;"I"PExtends _modul_ with the String::Extend module. @overload included(modul);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE mString_included_s(VALUE self, VALUE modul) { VALUE result = rb_funcall(modul, i_extend, 1, mString_Extend); return result; };T;:I"?static VALUE mString_included_s(VALUE self, VALUE modul) {;T;;To;4;5F;6;;;;&I";JSON::Ext::Generator::GeneratorMethods::String#to_json;T;7[[@90;[[@pi;T;; ;0;[;{;IC; "This string should be encoded with UTF-8 A call to this method returns a JSON string encoded with UTF16 big endian characters as \u????. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"to_json(*);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"*;T0;$@;![;"I"This string should be encoded with UTF-8 A call to this method returns a JSON string encoded with UTF16 big endian characters as \u????. @overload to_json(*);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"cstatic VALUE mString_to_json(int argc, VALUE *argv, VALUE self) { GENERATE_JSON(string); };T;:I"Dstatic VALUE mString_to_json(int argc, VALUE *argv, VALUE self);T;;To;4;5F;6;;;;&I"?JSON::Ext::Generator::GeneratorMethods::String#to_json_raw;T;7[[@90;[[@pi;T;:to_json_raw;0;[;{;IC; "dThis method creates a JSON text from the result of a call to to_json_raw_object of this String. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"to_json_raw(*args);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" *args;T0;$@;![;"I"~This method creates a JSON text from the result of a call to to_json_raw_object of this String. @overload to_json_raw(*args);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE mString_to_json_raw(int argc, VALUE *argv, VALUE self) { VALUE obj = mString_to_json_raw_object(self); Check_Type(obj, T_HASH); return mHash_to_json(argc, argv, obj); };T;:I"Hstatic VALUE mString_to_json_raw(int argc, VALUE *argv, VALUE self);T;;To;4;5F;6;;;;&I"FJSON::Ext::Generator::GeneratorMethods::String#to_json_raw_object;T;7[;[[@pi;T;:to_json_raw_object;0;[;{;IC; "This method creates a raw object hash, that can be nested into other data structures and will be generated as a raw string. This method should be used, if you want to convert raw strings to JSON instead of UTF-8 strings, e. g. binary data. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"to_json_raw_object();T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"This method creates a raw object hash, that can be nested into other data structures and will be generated as a raw string. This method should be used, if you want to convert raw strings to JSON instead of UTF-8 strings, e. g. binary data. @overload to_json_raw_object();T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;9I"Jstatic VALUE mString_to_json_raw_object(VALUE self) { VALUE ary; VALUE result = rb_hash_new(); rb_hash_aset(result, rb_funcall(mJSON, i_create_id, 0), rb_class_name(rb_obj_class(self))); ary = rb_funcall(self, i_unpack, 1, rb_str_new2("C*")); rb_hash_aset(result, rb_str_new2("raw"), ary); return result; };T;:I"8static VALUE mString_to_json_raw_object(VALUE self);T;;To;;IC;[o;4;5F;6;;;;&I"GJSON::Ext::Generator::GeneratorMethods::String::Extend#json_create;T;7[[I"o;T0;[[@pi;T;:json_create;0;[;{;IC; "Raw Strings are JSON Objects (the raw bytes are stored in an array for the key "raw"). The Ruby String can be created by this module method. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"json_create(o);T;IC; ";T;[;![;"I";T;#0;$@#;.F;Bi;C0;7[[I"o;T0;$@#;![;"I"Raw Strings are JSON Objects (the raw bytes are stored in an array for the key "raw"). The Ruby String can be created by this module method. @overload json_create(o);T;#0;$@#;.F;/o;0;1T;2i;3i;%@!;9I"static VALUE mString_Extend_json_create(VALUE self, VALUE o) { VALUE ary; Check_Type(o, T_HASH); ary = rb_hash_aref(o, rb_str_new2("raw")); return rb_funcall(ary, i_pack, 1, rb_str_new2("C*")); };T;:I"Astatic VALUE mString_Extend_json_create(VALUE self, VALUE o);T;;T; @!; IC;[; @!; IC;[; @!; IC;{;IC;{;T;IC;{;T;T;{;[;[[@pi[@pi&;T;: Extend;;;;;[;{;IC; " :nodoc:;T;[;![;"I" :nodoc: ;T;#0;$@!;.F;/o;0;1T;2i;3i;Bi;%o;( ;)@;*I"3JSON::Ext::Generator::GeneratorMethods::String;T;+0;;;%o;( ;)@;*I"+JSON::Ext::Generator::GeneratorMethods;T;+0;; ;%@;-@l;0;-@;0;&I";JSON::Ext::Generator::GeneratorMethods::String::Extend;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@pi[@pi!;T;;;;;;;[;{;IC; " :nodoc:;T;[;![;"I" :nodoc: ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@P;&I"3JSON::Ext::Generator::GeneratorMethods::String;To;;IC;[o;4;5F;6;;;;&I">JSON::Ext::Generator::GeneratorMethods::TrueClass#to_json;T;7[[@90;[[@pi";T;; ;0;[;{;IC; ",Returns a JSON string for true: 'true'. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"to_json(*);T;IC; ";T;[;![;"I";T;#0;$@g;.F;Bi;C0;7[[I"*;T0;$@g;![;"I"CReturns a JSON string for true: 'true'. @overload to_json(*);T;#0;$@g;.F;/o;0;1T;2i;3i ;%@e;9I"dstatic VALUE mTrueClass_to_json(int argc, VALUE *argv, VALUE self) { GENERATE_JSON(true); };T;:I"Gstatic VALUE mTrueClass_to_json(int argc, VALUE *argv, VALUE self);T;;T; @e; IC;[; @e; IC;[; @e; IC;{;IC;{;T;IC;{;T;T;{;[;[[@pi[@pi(;T;;;;;;;[;{;IC; " :nodoc:;T;[;![;"I" :nodoc: ;T;#0;$@e;.F;/o;0;1T;2i;3i;Bi;%o;( ;)@;*I"+JSON::Ext::Generator::GeneratorMethods;T;+0;; ;%@;-@l;0;&I"6JSON::Ext::Generator::GeneratorMethods::TrueClass;To;;IC;[o;4;5F;6;;;;&I"?JSON::Ext::Generator::GeneratorMethods::FalseClass#to_json;T;7[[@90;[[@pi,;T;; ;0;[;{;IC; ".Returns a JSON string for false: 'false'. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"to_json(*);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"*;T0;$@;![;"I"EReturns a JSON string for false: 'false'. @overload to_json(*);T;#0;$@;.F;/o;0;1T;2i';3i*;%@;9I"fstatic VALUE mFalseClass_to_json(int argc, VALUE *argv, VALUE self) { GENERATE_JSON(false); };T;:I"Hstatic VALUE mFalseClass_to_json(int argc, VALUE *argv, VALUE self);T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@pid[@pi*;T;;;;;;;[;{;IC; " :nodoc:;T;[;![;"I" :nodoc: ;T;#0;$@;.F;/o;0;1T;2id;3ie;Bi;%o;( ;)@;*I"+JSON::Ext::Generator::GeneratorMethods;T;+0;; ;%@;-@l;0;&I"7JSON::Ext::Generator::GeneratorMethods::FalseClass;To;;IC;[o;4;5F;6;;;;&I"=JSON::Ext::Generator::GeneratorMethods::NilClass#to_json;T;7[[@90;[[@pi6;T;; ;0;[;{;IC; "+Returns a JSON string for nil: 'null'. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"to_json(*);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I"*;T0;$@;![;"I"BReturns a JSON string for nil: 'null'. @overload to_json(*);T;#0;$@;.F;/o;0;1T;2i1;3i4;%@;9I"cstatic VALUE mNilClass_to_json(int argc, VALUE *argv, VALUE self) { GENERATE_JSON(null); };T;:I"Fstatic VALUE mNilClass_to_json(int argc, VALUE *argv, VALUE self);T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@pi}[@pi,;T;;;;;;;[;{;IC; " :nodoc:;T;[;![;"I" :nodoc: ;T;#0;$@;.F;/o;0;1T;2i};3i~;Bi;%o;( ;)@;*I"+JSON::Ext::Generator::GeneratorMethods;T;+0;; ;%@;-@l;0;&I"5JSON::Ext::Generator::GeneratorMethods::NilClass;T; @l; IC;[; @l; IC;[; @l; IC;{;IC;{;T;IC;{;T;T;{;[;[[@piU[@pi;T;; ;;;;;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc: ;T;#0;$@l;.F;/o;0;1T;2iU;3iV;%@;&I"+JSON::Ext::Generator::GeneratorMethods;T; @e; IC;[; @e; IC;[; @e; IC;{;IC;{;T;IC;{;T;T;{;[;[[@piD[@pi;T;;V ;;;;;[;{;IC; "This is the JSON generator implemented as a C extension. It can be configured to be used by setting JSON.generator = JSON::Ext::Generator with the method generator= in JSON. ;T;[;![;"I" This is the JSON generator implemented as a C extension. It can be configured to be used by setting JSON.generator = JSON::Ext::Generator with the method generator= in JSON. ;T;#0;$@e;.F;/o;0;1T;2iD;3iL;%@;&I"JSON::Ext::Generator;To; ;IC;[o;4;5F;6;;;;&I"!JSON::Ext::Parser#initialize;T;7[[@90;[[I"ext/json/parser/parser.c;Ti ;T;;D;0;[;{;IC; "Creates a new JSON::Ext::Parser instance for the string _source_. Creates a new JSON::Ext::Parser instance for the string _source_. It will be configured by the _opts_ hash. _opts_ can have the following keys: _opts_ can have the following keys: * *max_nesting*: The maximum depth of nesting allowed in the parsed data structures. Disable depth checking with :max_nesting => false|nil|0, it defaults to 100. * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in defiance of RFC 4627 to be parsed by the Parser. This option defaults to false. * *symbolize_names*: If set to true, returns symbols for the names (keys) in a JSON object. Otherwise strings are returned, which is also the default. It's not possible to use this option in conjunction with the *create_additions* option. * *create_additions*: If set to false, the Parser doesn't create additions even if a matching class and create_id was found. This option defaults to false. * *object_class*: Defaults to Hash * *array_class*: Defaults to Array ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"new(source, opts;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" source;T0[I" opts;T0;$@;![;"I".Creates a new JSON::Ext::Parser instance for the string _source_. Creates a new JSON::Ext::Parser instance for the string _source_. It will be configured by the _opts_ hash. _opts_ can have the following keys: _opts_ can have the following keys: * *max_nesting*: The maximum depth of nesting allowed in the parsed data structures. Disable depth checking with :max_nesting => false|nil|0, it defaults to 100. * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in defiance of RFC 4627 to be parsed by the Parser. This option defaults to false. * *symbolize_names*: If set to true, returns symbols for the names (keys) in a JSON object. Otherwise strings are returned, which is also the default. It's not possible to use this option in conjunction with the *create_additions* option. * *create_additions*: If set to false, the Parser doesn't create additions even if a matching class and create_id was found. This option defaults to false. * *object_class*: Defaults to Hash * *array_class*: Defaults to Array @overload new(source, opts;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;9I"p static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) { VALUE source, opts; GET_PARSER_INIT; if (json->Vsource) { rb_raise(rb_eTypeError, "already initialized instance"); } #ifdef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH rb_scan_args(argc, argv, "1:", &source, &opts); #else rb_scan_args(argc, argv, "11", &source, &opts); #endif if (!NIL_P(opts)) { #ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH opts = rb_convert_type(opts, T_HASH, "Hash", "to_hash"); if (NIL_P(opts)) { rb_raise(rb_eArgError, "opts needs to be like a hash"); } else { #endif VALUE tmp = ID2SYM(i_max_nesting); if (option_given_p(opts, tmp)) { VALUE max_nesting = rb_hash_aref(opts, tmp); if (RTEST(max_nesting)) { Check_Type(max_nesting, T_FIXNUM); json->max_nesting = FIX2INT(max_nesting); } else { json->max_nesting = 0; } } else { json->max_nesting = 100; } tmp = ID2SYM(i_allow_nan); if (option_given_p(opts, tmp)) { json->allow_nan = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0; } else { json->allow_nan = 0; } tmp = ID2SYM(i_symbolize_names); if (option_given_p(opts, tmp)) { json->symbolize_names = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0; } else { json->symbolize_names = 0; } tmp = ID2SYM(i_freeze); if (option_given_p(opts, tmp)) { json->freeze = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0; } else { json->freeze = 0; } tmp = ID2SYM(i_create_additions); if (option_given_p(opts, tmp)) { json->create_additions = RTEST(rb_hash_aref(opts, tmp)); } else { json->create_additions = 0; } if (json->symbolize_names && json->create_additions) { rb_raise(rb_eArgError, "options :symbolize_names and :create_additions cannot be " " used in conjunction"); } tmp = ID2SYM(i_create_id); if (option_given_p(opts, tmp)) { json->create_id = rb_hash_aref(opts, tmp); } else { json->create_id = rb_funcall(mJSON, i_create_id, 0); } tmp = ID2SYM(i_object_class); if (option_given_p(opts, tmp)) { json->object_class = rb_hash_aref(opts, tmp); } else { json->object_class = Qnil; } tmp = ID2SYM(i_array_class); if (option_given_p(opts, tmp)) { json->array_class = rb_hash_aref(opts, tmp); } else { json->array_class = Qnil; } tmp = ID2SYM(i_decimal_class); if (option_given_p(opts, tmp)) { json->decimal_class = rb_hash_aref(opts, tmp); } else { json->decimal_class = Qnil; } tmp = ID2SYM(i_match_string); if (option_given_p(opts, tmp)) { VALUE match_string = rb_hash_aref(opts, tmp); json->match_string = RTEST(match_string) ? match_string : Qnil; } else { json->match_string = Qnil; } #ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH } #endif } else { json->max_nesting = 100; json->allow_nan = 0; json->create_additions = 0; json->create_id = rb_funcall(mJSON, i_create_id, 0); json->object_class = Qnil; json->array_class = Qnil; json->decimal_class = Qnil; } source = convert_encoding(StringValue(source)); StringValue(source); json->len = RSTRING_LEN(source); json->source = RSTRING_PTR(source);; json->Vsource = source; return self; };T;:I"Gstatic VALUE cParser_initialize(int argc, VALUE *argv, VALUE self);T;;To;4;5F;6;;;;&I"JSON::Ext::Parser#parse;T;7[;[[@i ;T;;+;0;[;{;IC; "`Parses the current JSON text _source_ and returns the complete data structure as a result. ;T;[o;= ;>I" overload;F;?0;;+;@0;:I" parse();T;IC; ";T;[;![;"I";T;#0;$@4;.F;Bi;C0;7[;$@4;![;"I"u Parses the current JSON text _source_ and returns the complete data structure as a result. @overload parse();T;#0;$@4;.F;/o;0;1T;2i ;3i ;%@;9I"istatic VALUE cParser_parse(VALUE self) { char *p, *pe; int cs = EVIL; VALUE result = Qnil; GET_PARSER; { cs = (int)JSON_start; } #line 851 "parser.rl" p = json->source; pe = p + json->len; { if ( p == pe ) goto _test_eof; switch ( cs ) { case 1: goto st_case_1; case 0: goto st_case_0; case 10: goto st_case_10; case 2: goto st_case_2; case 3: goto st_case_3; case 4: goto st_case_4; case 5: goto st_case_5; case 6: goto st_case_6; case 7: goto st_case_7; case 8: goto st_case_8; case 9: goto st_case_9; } goto st_out; st1: p+= 1; if ( p == pe ) goto _test_eof1; st_case_1: switch( ( (*( p))) ) { case 13: { goto st1; } case 32: { goto st1; } case 34: { goto ctr2; } case 45: { goto ctr2; } case 47: { goto st6; } case 73: { goto ctr2; } case 78: { goto ctr2; } case 91: { goto ctr2; } case 102: { goto ctr2; } case 110: { goto ctr2; } case 116: { goto ctr2; } case 123: { goto ctr2; } } if ( ( (*( p))) > 10 ) { if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) { goto ctr2; } } else if ( ( (*( p))) >= 9 ) { goto st1; } { goto st0; } st_case_0: st0: cs = 0; goto _out; ctr2: { #line 827 "parser.rl" char *np = JSON_parse_value(json, p, pe, &result, 0); if (np == NULL) { {p = p - 1; } {p+= 1; cs = 10; goto _out;} } else {p = (( np))-1;} } goto st10; st10: p+= 1; if ( p == pe ) goto _test_eof10; st_case_10: switch( ( (*( p))) ) { case 13: { goto st10; } case 32: { goto st10; } case 47: { goto st2; } } if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) { goto st10; } { goto st0; } st2: p+= 1; if ( p == pe ) goto _test_eof2; st_case_2: switch( ( (*( p))) ) { case 42: { goto st3; } case 47: { goto st5; } } { goto st0; } st3: p+= 1; if ( p == pe ) goto _test_eof3; st_case_3: if ( ( (*( p))) == 42 ) { goto st4; } { goto st3; } st4: p+= 1; if ( p == pe ) goto _test_eof4; st_case_4: switch( ( (*( p))) ) { case 42: { goto st4; } case 47: { goto st10; } } { goto st3; } st5: p+= 1; if ( p == pe ) goto _test_eof5; st_case_5: if ( ( (*( p))) == 10 ) { goto st10; } { goto st5; } st6: p+= 1; if ( p == pe ) goto _test_eof6; st_case_6: switch( ( (*( p))) ) { case 42: { goto st7; } case 47: { goto st9; } } { goto st0; } st7: p+= 1; if ( p == pe ) goto _test_eof7; st_case_7: if ( ( (*( p))) == 42 ) { goto st8; } { goto st7; } st8: p+= 1; if ( p == pe ) goto _test_eof8; st_case_8: switch( ( (*( p))) ) { case 42: { goto st8; } case 47: { goto st1; } } { goto st7; } st9: p+= 1; if ( p == pe ) goto _test_eof9; st_case_9: if ( ( (*( p))) == 10 ) { goto st1; } { goto st9; } st_out: _test_eof1: cs = 1; goto _test_eof; _test_eof10: cs = 10; goto _test_eof; _test_eof2: cs = 2; goto _test_eof; _test_eof3: cs = 3; goto _test_eof; _test_eof4: cs = 4; goto _test_eof; _test_eof5: cs = 5; goto _test_eof; _test_eof6: cs = 6; goto _test_eof; _test_eof7: cs = 7; goto _test_eof; _test_eof8: cs = 8; goto _test_eof; _test_eof9: cs = 9; goto _test_eof; _test_eof: {} _out: {} } #line 854 "parser.rl" if (cs >= JSON_first_final && p == pe) { return result; } else { rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p); return Qnil; } };T;:I"+static VALUE cParser_parse(VALUE self);T;;To;4;5F;6;;;;&I"JSON::Ext::Parser#source;T;7[;[[@i ;T;;I;0;[;{;IC; "[Returns a copy of the current _source_ string, that was used to construct this Parser. ;T;[o;= ;>I" overload;F;?0;;I;@0;:I" source();T;IC; ";T;[;![;"I";T;#0;$@J;.F;Bi;C0;7[;$@J;![;"I"pReturns a copy of the current _source_ string, that was used to construct this Parser. @overload source();T;#0;$@J;.F;/o;0;1T;2i ;3i ;%@;9I"`static VALUE cParser_source(VALUE self) { GET_PARSER; return rb_str_dup(json->Vsource); };T;:I",static VALUE cParser_source(VALUE self);T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i [@i ;T;; ;;;;;[;{;IC; "This is the JSON parser implemented as a C extension. It can be configured to be used by setting JSON.parser = JSON::Ext::Parser with the method parser= in JSON.;T;[;![;"I" This is the JSON parser implemented as a C extension. It can be configured to be used by setting JSON.parser = JSON::Ext::Parser with the method parser= in JSON. ;T;#0;$@;.F;/o;0;1T;2i ;3i ;Bi;%o;( ;)@;*I"JSON::Ext;T;+0;; ;%@a;-@c;0;&I"JSON::Ext::Parser;T;'@; @c; IC;[; @c; IC;[; @c; IC;{;IC;{;T;IC;{;T;T;{;[;[[@pi[@i ;F;; ;;;;;[;{;IC; " ;T;[;![;"@;#0;$@c;Bi;%@a;&I"JSON::Ext;F; @a; IC;[; @a; IC;[; @a; IC;{;IC;{;T;IC;{;T;T;{;[;[[@pi[@i ;F;: JSON;;;;;[;{;IC; " ;T;[;![;"@;#0;$@a;%@;&I" JSON;Fo; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i [@)iN ;T;: fatal;;;;;[;{;IC; "`fatal is an Exception that is raised when Ruby has encountered a fatal error and must exit. ;T;[;![;"I"b fatal is an Exception that is raised when Ruby has encountered a fatal error and must exit. ;T;#0;$@;.F;/o;0;1T;2i ;3i ;%@;&I" fatal;F;'@3@3o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i ;F;:NoMatchingPatternError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"NoMatchingPatternError;F;'@o; ;IC;[o;4;5F;6;;;;&I")NoMatchingPatternKeyError#initialize;F;7[[@90;[[@)i;T;;D;0;[;{;IC; "cConstruct a new +NoMatchingPatternKeyError+ exception with the given message, matchee and key. ;T;[o;= ;>I" overload;F;?0;;E;@0;:I"-new(message=nil, matchee: nil, key: nil);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" message;TI"nil;T[I" matchee:;TI"nil;T[I" key:;TI"nil;T;$@;![;"I"Construct a new +NoMatchingPatternKeyError+ exception with the given message, matchee and key. @overload new(message=nil, matchee: nil, key: nil);T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"ostatic VALUE no_matching_pattern_key_err_initialize(int argc, VALUE *argv, VALUE self) { VALUE options; rb_call_super(rb_scan_args(argc, argv, "01:", NULL, &options), argv); if (!NIL_P(options)) { ID keywords[2]; VALUE values[numberof(keywords)]; int i; keywords[0] = id_matchee; keywords[1] = id_key; rb_get_kwargs(options, keywords, 0, numberof(values), values); for (i = 0; i < numberof(values); ++i) { if (values[i] != Qundef) { rb_ivar_set(self, keywords[i], values[i]); } } } return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&NoMatchingPatternKeyError#matchee;F;7[;[[@)i};T;: matchee;0;[;{;IC; "QReturn the matchee associated with this NoMatchingPatternKeyError exception. ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" matchee;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"xReturn the matchee associated with this NoMatchingPatternKeyError exception. @overload matchee @return [Object];T;#0;$@;.F;/o;0;1T;2iv;3iz;%@;9I"static VALUE no_matching_pattern_key_err_matchee(VALUE self) { VALUE matchee; matchee = rb_ivar_lookup(self, id_matchee, Qundef); if (matchee != Qundef) return matchee; rb_raise(rb_eArgError, "no matchee is available"); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I""NoMatchingPatternKeyError#key;F;7[;[[@)i;T;;;0;[;{;IC; "DReturn the key caused this NoMatchingPatternKeyError exception. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"key;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"gReturn the key caused this NoMatchingPatternKeyError exception. @overload key @return [Object];T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE no_matching_pattern_key_err_key(VALUE self) { VALUE key; key = rb_ivar_lookup(self, id_key, Qundef); if (key != Qundef) return key; rb_raise(rb_eArgError, "no key is available"); };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@)i ;F;:NoMatchingPatternKeyError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I"NoMatchingPatternKeyError;F;'@o;;IC;[produces: Math::DomainError: Numerical argument is out of domain - "acos" ;T;[;![;"I"< Raised when a mathematical function is evaluated outside of its domain of definition. For example, since +cos+ returns values in the range -1..1, its inverse function +acos+ is only defined on that interval: Math.acos(42) produces: Math::DomainError: Numerical argument is out of domain - "acos" ;T;#0;$@";.F;/o;0;1T;2i;3i;%o;( ;)0;*0;+0;: Math;%@;-@ ;0;&I"Math::DomainError;T;'@o;u;[[@-i;F;:PI;;w;;;[;{;IC; "BDefinition of the mathematical constant PI as a Float number. ;T;[;![;"I"BDefinition of the mathematical constant PI as a Float number.;T;#0;$@8;.F;/o;0;1T;2i;3i;%@ ;&I" Math::PI;F;xI"DBL2NUM(M_PI);To;u;[[@-i[@-i;F;;;;w;;;[;{;IC; "XDefinition of the mathematical constant E for Euler's number (e) as a Float number. ;T;[;![;"I"XDefinition of the mathematical constant E for Euler's number (e) as a Float number.;T;#0;$@D;.F;/o;0;1T;2i;3i;%@ ;&I" Math::E;F;xI"DBL2NUM(exp(1.0));To;4;5F;6;;;;&I"Math#atan2;F;7[[I"y;T0[I"x;T0;[[@-iL;T;: atan2;0;[;{;IC; "Computes the arc tangent given +y+ and +x+. Returns a Float in the range -PI..PI. Return value is a angle in radians between the positive x-axis of cartesian plane and the point given by the coordinates (+x+, +y+) on it. Domain: (-INFINITY, INFINITY) Codomain: [-PI, PI] Math.atan2(-0.0, -1.0) #=> -3.141592653589793 Math.atan2(-1.0, -1.0) #=> -2.356194490192345 Math.atan2(-1.0, 0.0) #=> -1.5707963267948966 Math.atan2(-1.0, 1.0) #=> -0.7853981633974483 Math.atan2(-0.0, 1.0) #=> -0.0 Math.atan2(0.0, 1.0) #=> 0.0 Math.atan2(1.0, 1.0) #=> 0.7853981633974483 Math.atan2(1.0, 0.0) #=> 1.5707963267948966 Math.atan2(1.0, -1.0) #=> 2.356194490192345 Math.atan2(0.0, -1.0) #=> 3.141592653589793 Math.atan2(INFINITY, INFINITY) #=> 0.7853981633974483 Math.atan2(INFINITY, -INFINITY) #=> 2.356194490192345 Math.atan2(-INFINITY, INFINITY) #=> -0.7853981633974483 Math.atan2(-INFINITY, -INFINITY) #=> -2.356194490192345 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"atan2(y, x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@Q;![;"I"@return [Float];T;#0;$@Q;.F;Bi;C0;7[[I"y;T0[I"x;T0;$@Q;![;"I"Computes the arc tangent given +y+ and +x+. Returns a Float in the range -PI..PI. Return value is a angle in radians between the positive x-axis of cartesian plane and the point given by the coordinates (+x+, +y+) on it. Domain: (-INFINITY, INFINITY) Codomain: [-PI, PI] Math.atan2(-0.0, -1.0) #=> -3.141592653589793 Math.atan2(-1.0, -1.0) #=> -2.356194490192345 Math.atan2(-1.0, 0.0) #=> -1.5707963267948966 Math.atan2(-1.0, 1.0) #=> -0.7853981633974483 Math.atan2(-0.0, 1.0) #=> -0.0 Math.atan2(0.0, 1.0) #=> 0.0 Math.atan2(1.0, 1.0) #=> 0.7853981633974483 Math.atan2(1.0, 0.0) #=> 1.5707963267948966 Math.atan2(1.0, -1.0) #=> 2.356194490192345 Math.atan2(0.0, -1.0) #=> 3.141592653589793 Math.atan2(INFINITY, INFINITY) #=> 0.7853981633974483 Math.atan2(INFINITY, -INFINITY) #=> 2.356194490192345 Math.atan2(-INFINITY, INFINITY) #=> -0.7853981633974483 Math.atan2(-INFINITY, -INFINITY) #=> -2.356194490192345 @overload atan2(y, x) @return [Float];T;#0;$@Q;.F;C0;%@ ;9I"static VALUE math_atan2(VALUE unused_obj, VALUE y, VALUE x) { double dx, dy; dx = Get_Double(x); dy = Get_Double(y); if (dx == 0.0 && dy == 0.0) { if (!signbit(dx)) return DBL2NUM(dy); if (!signbit(dy)) return DBL2NUM(M_PI); return DBL2NUM(-M_PI); } #ifndef ATAN2_INF_C99 if (isinf(dx) && isinf(dy)) { /* optimization for FLONUM */ if (dx < 0.0) { const double dz = (3.0 * M_PI / 4.0); return (dy < 0.0) ? DBL2NUM(-dz) : DBL2NUM(dz); } else { const double dz = (M_PI / 4.0); return (dy < 0.0) ? DBL2NUM(-dz) : DBL2NUM(dz); } } #endif return DBL2NUM(atan2(dy, dx)); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.atan2;F;7@S;@X;T;; ;0;@Z;{;IC; "Computes the arc tangent given +y+ and +x+. Returns a Float in the range -PI..PI. Return value is a angle in radians between the positive x-axis of cartesian plane and the point given by the coordinates (+x+, +y+) on it. Domain: (-INFINITY, INFINITY) Codomain: [-PI, PI] Math.atan2(-0.0, -1.0) #=> -3.141592653589793 Math.atan2(-1.0, -1.0) #=> -2.356194490192345 Math.atan2(-1.0, 0.0) #=> -1.5707963267948966 Math.atan2(-1.0, 1.0) #=> -0.7853981633974483 Math.atan2(-0.0, 1.0) #=> -0.0 Math.atan2(0.0, 1.0) #=> 0.0 Math.atan2(1.0, 1.0) #=> 0.7853981633974483 Math.atan2(1.0, 0.0) #=> 1.5707963267948966 Math.atan2(1.0, -1.0) #=> 2.356194490192345 Math.atan2(0.0, -1.0) #=> 3.141592653589793 Math.atan2(INFINITY, INFINITY) #=> 0.7853981633974483 Math.atan2(INFINITY, -INFINITY) #=> 2.356194490192345 Math.atan2(-INFINITY, INFINITY) #=> -0.7853981633974483 Math.atan2(-INFINITY, -INFINITY) #=> -2.356194490192345;T;[o;= ;>I" overload;F;?0;; ;@0;:I"atan2(y, x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@s;![;"I"@return [Float];T;#0;$@s;.F;Bi;C0;7[[I"y;T0[I"x;T0;$@s;![;"I"Computes the arc tangent given +y+ and +x+. Returns a Float in the range -PI..PI. Return value is a angle in radians between the positive x-axis of cartesian plane and the point given by the coordinates (+x+, +y+) on it. Domain: (-INFINITY, INFINITY) Codomain: [-PI, PI] Math.atan2(-0.0, -1.0) #=> -3.141592653589793 Math.atan2(-1.0, -1.0) #=> -2.356194490192345 Math.atan2(-1.0, 0.0) #=> -1.5707963267948966 Math.atan2(-1.0, 1.0) #=> -0.7853981633974483 Math.atan2(-0.0, 1.0) #=> -0.0 Math.atan2(0.0, 1.0) #=> 0.0 Math.atan2(1.0, 1.0) #=> 0.7853981633974483 Math.atan2(1.0, 0.0) #=> 1.5707963267948966 Math.atan2(1.0, -1.0) #=> 2.356194490192345 Math.atan2(0.0, -1.0) #=> 3.141592653589793 Math.atan2(INFINITY, INFINITY) #=> 0.7853981633974483 Math.atan2(INFINITY, -INFINITY) #=> 2.356194490192345 Math.atan2(-INFINITY, INFINITY) #=> -0.7853981633974483 Math.atan2(-INFINITY, -INFINITY) #=> -2.356194490192345 @overload atan2(y, x) @return [Float];T;#0;$@s;.F;/o;0;1T;2i.;3iI;Bi;%@ ;9@q;:@r;;To;4;5F;6;;;;&I" Math#cos;F;7[[I"x;T0;[[@-iy;T;:cos;0;[;{;IC; "Computes the cosine of +x+ (expressed in radians). Returns a Float in the range -1.0..1.0. Domain: (-INFINITY, INFINITY) Codomain: [-1, 1] Math.cos(Math::PI) #=> -1.0 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" cos(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Computes the cosine of +x+ (expressed in radians). Returns a Float in the range -1.0..1.0. Domain: (-INFINITY, INFINITY) Codomain: [-1, 1] Math.cos(Math::PI) #=> -1.0 @overload cos(x) @return [Float];T;#0;$@;.F;C0;%@ ;9I"astatic VALUE math_cos(VALUE unused_obj, VALUE x) { return DBL2NUM(cos(Get_Double(x))); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I" Math.cos;F;7@;@;T;; ;0;@;{;IC; "Computes the cosine of +x+ (expressed in radians). Returns a Float in the range -1.0..1.0. Domain: (-INFINITY, INFINITY) Codomain: [-1, 1] Math.cos(Math::PI) #=> -1.0;T;[o;= ;>I" overload;F;?0;; ;@0;:I" cos(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Computes the cosine of +x+ (expressed in radians). Returns a Float in the range -1.0..1.0. Domain: (-INFINITY, INFINITY) Codomain: [-1, 1] Math.cos(Math::PI) #=> -1.0 @overload cos(x) @return [Float];T;#0;$@;.F;/o;0;1T;2ij;3iv;Bi;%@ ;9@;:@;;To;4;5F;6;;;;&I" Math#sin;F;7[[I"x;T0;[[@-i;T;:sin;0;[;{;IC; "Computes the sine of +x+ (expressed in radians). Returns a Float in the range -1.0..1.0. Domain: (-INFINITY, INFINITY) Codomain: [-1, 1] Math.sin(Math::PI/2) #=> 1.0 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" sin(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Computes the sine of +x+ (expressed in radians). Returns a Float in the range -1.0..1.0. Domain: (-INFINITY, INFINITY) Codomain: [-1, 1] Math.sin(Math::PI/2) #=> 1.0 @overload sin(x) @return [Float];T;#0;$@;.F;C0;%@ ;9I"astatic VALUE math_sin(VALUE unused_obj, VALUE x) { return DBL2NUM(sin(Get_Double(x))); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I" Math.sin;F;7@;@;T;; ;0;@;{;IC; "Computes the sine of +x+ (expressed in radians). Returns a Float in the range -1.0..1.0. Domain: (-INFINITY, INFINITY) Codomain: [-1, 1] Math.sin(Math::PI/2) #=> 1.0;T;[o;= ;>I" overload;F;?0;; ;@0;:I" sin(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Computes the sine of +x+ (expressed in radians). Returns a Float in the range -1.0..1.0. Domain: (-INFINITY, INFINITY) Codomain: [-1, 1] Math.sin(Math::PI/2) #=> 1.0 @overload sin(x) @return [Float];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@ ;9@;:@;;To;4;5F;6;;;;&I" Math#tan;F;7[[I"x;T0;[[@-i;T;:tan;0;[;{;IC; "Computes the tangent of +x+ (expressed in radians). Domain: (-INFINITY, INFINITY) Codomain: (-INFINITY, INFINITY) Math.tan(0) #=> 0.0 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" tan(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Computes the tangent of +x+ (expressed in radians). Domain: (-INFINITY, INFINITY) Codomain: (-INFINITY, INFINITY) Math.tan(0) #=> 0.0 @overload tan(x) @return [Float];T;#0;$@;.F;C0;%@ ;9I"astatic VALUE math_tan(VALUE unused_obj, VALUE x) { return DBL2NUM(tan(Get_Double(x))); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I" Math.tan;F;7@;@;T;; ;0;@;{;IC; "Computes the tangent of +x+ (expressed in radians). Domain: (-INFINITY, INFINITY) Codomain: (-INFINITY, INFINITY) Math.tan(0) #=> 0.0;T;[o;= ;>I" overload;F;?0;; ;@0;:I" tan(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Computes the tangent of +x+ (expressed in radians). Domain: (-INFINITY, INFINITY) Codomain: (-INFINITY, INFINITY) Math.tan(0) #=> 0.0 @overload tan(x) @return [Float];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@ ;9@;:@;;To;4;5F;6;;;;&I"Math#acos;F;7[[I"x;T0;[[@-i;T;: acos;0;[;{;IC; "Computes the arc cosine of +x+. Returns 0..PI. Domain: [-1, 1] Codomain: [0, PI] Math.acos(0) == Math::PI/2 #=> true ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" acos(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@+;![;"I"@return [Float];T;#0;$@+;.F;Bi;C0;7[[I"x;T0;$@+;![;"I"Computes the arc cosine of +x+. Returns 0..PI. Domain: [-1, 1] Codomain: [0, PI] Math.acos(0) == Math::PI/2 #=> true @overload acos(x) @return [Float];T;#0;$@+;.F;C0;%@ ;9I"static VALUE math_acos(VALUE unused_obj, VALUE x) { double d; d = Get_Double(x); domain_check_range(d, -1.0, 1.0, "acos"); return DBL2NUM(acos(d)); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.acos;F;7@-;@0;T;; ;0;@2;{;IC; "Computes the arc cosine of +x+. Returns 0..PI. Domain: [-1, 1] Codomain: [0, PI] Math.acos(0) == Math::PI/2 #=> true;T;[o;= ;>I" overload;F;?0;; ;@0;:I" acos(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@I;![;"I"@return [Float];T;#0;$@I;.F;Bi;C0;7[[I"x;T0;$@I;![;"I"Computes the arc cosine of +x+. Returns 0..PI. Domain: [-1, 1] Codomain: [0, PI] Math.acos(0) == Math::PI/2 #=> true @overload acos(x) @return [Float];T;#0;$@I;.F;/o;0;1T;2i;3i;Bi;%@ ;9@G;:@H;;To;4;5F;6;;;;&I"Math#asin;F;7[[I"x;T0;[[@-i;T;: asin;0;[;{;IC; "Computes the arc sine of +x+. Returns -PI/2..PI/2. Domain: [-1, -1] Codomain: [-PI/2, PI/2] Math.asin(1) == Math::PI/2 #=> true ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" asin(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@`;![;"I"@return [Float];T;#0;$@`;.F;Bi;C0;7[[I"x;T0;$@`;![;"I"Computes the arc sine of +x+. Returns -PI/2..PI/2. Domain: [-1, -1] Codomain: [-PI/2, PI/2] Math.asin(1) == Math::PI/2 #=> true @overload asin(x) @return [Float];T;#0;$@`;.F;C0;%@ ;9I"static VALUE math_asin(VALUE unused_obj, VALUE x) { double d; d = Get_Double(x); domain_check_range(d, -1.0, 1.0, "asin"); return DBL2NUM(asin(d)); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.asin;F;7@b;@e;T;; ;0;@g;{;IC; "Computes the arc sine of +x+. Returns -PI/2..PI/2. Domain: [-1, -1] Codomain: [-PI/2, PI/2] Math.asin(1) == Math::PI/2 #=> true;T;[o;= ;>I" overload;F;?0;; ;@0;:I" asin(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@~;![;"I"@return [Float];T;#0;$@~;.F;Bi;C0;7[[I"x;T0;$@~;![;"I"Computes the arc sine of +x+. Returns -PI/2..PI/2. Domain: [-1, -1] Codomain: [-PI/2, PI/2] Math.asin(1) == Math::PI/2 #=> true @overload asin(x) @return [Float];T;#0;$@~;.F;/o;0;1T;2i;3i;Bi;%@ ;9@|;:@};;To;4;5F;6;;;;&I"Math#atan;F;7[[I"x;T0;[[@-i;T;: atan;0;[;{;IC; "Computes the arc tangent of +x+. Returns -PI/2..PI/2. Domain: (-INFINITY, INFINITY) Codomain: (-PI/2, PI/2) Math.atan(0) #=> 0.0 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" atan(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Computes the arc tangent of +x+. Returns -PI/2..PI/2. Domain: (-INFINITY, INFINITY) Codomain: (-PI/2, PI/2) Math.atan(0) #=> 0.0 @overload atan(x) @return [Float];T;#0;$@;.F;C0;%@ ;9I"cstatic VALUE math_atan(VALUE unused_obj, VALUE x) { return DBL2NUM(atan(Get_Double(x))); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.atan;F;7@;@;T;; ;0;@;{;IC; "Computes the arc tangent of +x+. Returns -PI/2..PI/2. Domain: (-INFINITY, INFINITY) Codomain: (-PI/2, PI/2) Math.atan(0) #=> 0.0;T;[o;= ;>I" overload;F;?0;; ;@0;:I" atan(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Computes the arc tangent of +x+. Returns -PI/2..PI/2. Domain: (-INFINITY, INFINITY) Codomain: (-PI/2, PI/2) Math.atan(0) #=> 0.0 @overload atan(x) @return [Float];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@ ;9@;:@;;To;4;5F;6;;;;&I"Math#cosh;F;7[[I"x;T0;[[@-i;T;: cosh;0;[;{;IC; "Computes the hyperbolic cosine of +x+ (expressed in radians). Domain: (-INFINITY, INFINITY) Codomain: [1, INFINITY) Math.cosh(0) #=> 1.0 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" cosh(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Computes the hyperbolic cosine of +x+ (expressed in radians). Domain: (-INFINITY, INFINITY) Codomain: [1, INFINITY) Math.cosh(0) #=> 1.0 @overload cosh(x) @return [Float];T;#0;$@;.F;C0;%@ ;9I"cstatic VALUE math_cosh(VALUE unused_obj, VALUE x) { return DBL2NUM(cosh(Get_Double(x))); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.cosh;F;7@;@;T;; ;0;@;{;IC; "Computes the hyperbolic cosine of +x+ (expressed in radians). Domain: (-INFINITY, INFINITY) Codomain: [1, INFINITY) Math.cosh(0) #=> 1.0;T;[o;= ;>I" overload;F;?0;; ;@0;:I" cosh(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Computes the hyperbolic cosine of +x+ (expressed in radians). Domain: (-INFINITY, INFINITY) Codomain: [1, INFINITY) Math.cosh(0) #=> 1.0 @overload cosh(x) @return [Float];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@ ;9@;:@;;To;4;5F;6;;;;&I"Math#sinh;F;7[[I"x;T0;[[@-i;T;: sinh;0;[;{;IC; "Computes the hyperbolic sine of +x+ (expressed in radians). Domain: (-INFINITY, INFINITY) Codomain: (-INFINITY, INFINITY) Math.sinh(0) #=> 0.0 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" sinh(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Computes the hyperbolic sine of +x+ (expressed in radians). Domain: (-INFINITY, INFINITY) Codomain: (-INFINITY, INFINITY) Math.sinh(0) #=> 0.0 @overload sinh(x) @return [Float];T;#0;$@;.F;C0;%@ ;9I"cstatic VALUE math_sinh(VALUE unused_obj, VALUE x) { return DBL2NUM(sinh(Get_Double(x))); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.sinh;F;7@;@;T;; ;0;@;{;IC; "Computes the hyperbolic sine of +x+ (expressed in radians). Domain: (-INFINITY, INFINITY) Codomain: (-INFINITY, INFINITY) Math.sinh(0) #=> 0.0;T;[o;= ;>I" overload;F;?0;; ;@0;:I" sinh(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Computes the hyperbolic sine of +x+ (expressed in radians). Domain: (-INFINITY, INFINITY) Codomain: (-INFINITY, INFINITY) Math.sinh(0) #=> 0.0 @overload sinh(x) @return [Float];T;#0;$@;.F;/o;0;1T;2i ;3i;Bi;%@ ;9@;:@;;To;4;5F;6;;;;&I"Math#tanh;F;7[[I"x;T0;[[@-i;;T;: tanh;0;[;{;IC; "Computes the hyperbolic tangent of +x+ (expressed in radians). Domain: (-INFINITY, INFINITY) Codomain: (-1, 1) Math.tanh(0) #=> 0.0 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" tanh(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@4;![;"I"@return [Float];T;#0;$@4;.F;Bi;C0;7[[I"x;T0;$@4;![;"I"Computes the hyperbolic tangent of +x+ (expressed in radians). Domain: (-INFINITY, INFINITY) Codomain: (-1, 1) Math.tanh(0) #=> 0.0 @overload tanh(x) @return [Float];T;#0;$@4;.F;C0;%@ ;9I"cstatic VALUE math_tanh(VALUE unused_obj, VALUE x) { return DBL2NUM(tanh(Get_Double(x))); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.tanh;F;7@6;@9;T;; ;0;@;;{;IC; "Computes the hyperbolic tangent of +x+ (expressed in radians). Domain: (-INFINITY, INFINITY) Codomain: (-1, 1) Math.tanh(0) #=> 0.0;T;[o;= ;>I" overload;F;?0;; ;@0;:I" tanh(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@R;![;"I"@return [Float];T;#0;$@R;.F;Bi;C0;7[[I"x;T0;$@R;![;"I"Computes the hyperbolic tangent of +x+ (expressed in radians). Domain: (-INFINITY, INFINITY) Codomain: (-1, 1) Math.tanh(0) #=> 0.0 @overload tanh(x) @return [Float];T;#0;$@R;.F;/o;0;1T;2i-;3i8;Bi;%@ ;9@P;:@Q;;To;4;5F;6;;;;&I"Math#acosh;F;7[[I"x;T0;[[@-iO;T;: acosh;0;[;{;IC; "|Computes the inverse hyperbolic cosine of +x+. Domain: [1, INFINITY) Codomain: [0, INFINITY) Math.acosh(1) #=> 0.0 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" acosh(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@i;![;"I"@return [Float];T;#0;$@i;.F;Bi;C0;7[[I"x;T0;$@i;![;"I"Computes the inverse hyperbolic cosine of +x+. Domain: [1, INFINITY) Codomain: [0, INFINITY) Math.acosh(1) #=> 0.0 @overload acosh(x) @return [Float];T;#0;$@i;.F;C0;%@ ;9I"static VALUE math_acosh(VALUE unused_obj, VALUE x) { double d; d = Get_Double(x); domain_check_min(d, 1.0, "acosh"); return DBL2NUM(acosh(d)); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.acosh;F;7@k;@n;T;; ;0;@p;{;IC; "|Computes the inverse hyperbolic cosine of +x+. Domain: [1, INFINITY) Codomain: [0, INFINITY) Math.acosh(1) #=> 0.0;T;[o;= ;>I" overload;F;?0;; ;@0;:I" acosh(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Computes the inverse hyperbolic cosine of +x+. Domain: [1, INFINITY) Codomain: [0, INFINITY) Math.acosh(1) #=> 0.0 @overload acosh(x) @return [Float];T;#0;$@;.F;/o;0;1T;2iA;3iL;Bi;%@ ;9@;:@;;To;4;5F;6;;;;&I"Math#asinh;F;7[[I"x;T0;[[@-ig;T;: asinh;0;[;{;IC; "Computes the inverse hyperbolic sine of +x+. Domain: (-INFINITY, INFINITY) Codomain: (-INFINITY, INFINITY) Math.asinh(1) #=> 0.881373587019543 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" asinh(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Computes the inverse hyperbolic sine of +x+. Domain: (-INFINITY, INFINITY) Codomain: (-INFINITY, INFINITY) Math.asinh(1) #=> 0.881373587019543 @overload asinh(x) @return [Float];T;#0;$@;.F;C0;%@ ;9I"estatic VALUE math_asinh(VALUE unused_obj, VALUE x) { return DBL2NUM(asinh(Get_Double(x))); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.asinh;F;7@;@;T;; ;0;@;{;IC; "Computes the inverse hyperbolic sine of +x+. Domain: (-INFINITY, INFINITY) Codomain: (-INFINITY, INFINITY) Math.asinh(1) #=> 0.881373587019543;T;[o;= ;>I" overload;F;?0;; ;@0;:I" asinh(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Computes the inverse hyperbolic sine of +x+. Domain: (-INFINITY, INFINITY) Codomain: (-INFINITY, INFINITY) Math.asinh(1) #=> 0.881373587019543 @overload asinh(x) @return [Float];T;#0;$@;.F;/o;0;1T;2iY;3id;Bi;%@ ;9@;:@;;To;4;5F;6;;;;&I"Math#atanh;F;7[[I"x;T0;[[@-i{;T;: atanh;0;[;{;IC; "~Computes the inverse hyperbolic tangent of +x+. Domain: (-1, 1) Codomain: (-INFINITY, INFINITY) Math.atanh(1) #=> Infinity ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" atanh(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Computes the inverse hyperbolic tangent of +x+. Domain: (-1, 1) Codomain: (-INFINITY, INFINITY) Math.atanh(1) #=> Infinity @overload atanh(x) @return [Float];T;#0;$@;.F;C0;%@ ;9I"%static VALUE math_atanh(VALUE unused_obj, VALUE x) { double d; d = Get_Double(x); domain_check_range(d, -1.0, +1.0, "atanh"); /* check for pole error */ if (d == -1.0) return DBL2NUM(-HUGE_VAL); if (d == +1.0) return DBL2NUM(+HUGE_VAL); return DBL2NUM(atanh(d)); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.atanh;F;7@;@;T;; ;0;@;{;IC; "~Computes the inverse hyperbolic tangent of +x+. Domain: (-1, 1) Codomain: (-INFINITY, INFINITY) Math.atanh(1) #=> Infinity;T;[o;= ;>I" overload;F;?0;; ;@0;:I" atanh(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Computes the inverse hyperbolic tangent of +x+. Domain: (-1, 1) Codomain: (-INFINITY, INFINITY) Math.atanh(1) #=> Infinity @overload atanh(x) @return [Float];T;#0;$@;.F;/o;0;1T;2im;3ix;Bi;%@ ;9@;:@;;To;4;5F;6;;;;&I" Math#exp;F;7[[I"x;T0;[[@-i;T;;';0;[;{;IC; "Returns e**x. Domain: (-INFINITY, INFINITY) Codomain: (0, INFINITY) Math.exp(0) #=> 1.0 Math.exp(1) #=> 2.718281828459045 Math.exp(1.5) #=> 4.4816890703380645 ;T;[o;= ;>I" overload;F;?0;;';@0;:I" exp(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Returns e**x. Domain: (-INFINITY, INFINITY) Codomain: (0, INFINITY) Math.exp(0) #=> 1.0 Math.exp(1) #=> 2.718281828459045 Math.exp(1.5) #=> 4.4816890703380645 @overload exp(x) @return [Float];T;#0;$@;.F;C0;%@ ;9I"astatic VALUE math_exp(VALUE unused_obj, VALUE x) { return DBL2NUM(exp(Get_Double(x))); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I" Math.exp;F;7@ ;@ ;T;;';0;@;{;IC; "Returns e**x. Domain: (-INFINITY, INFINITY) Codomain: (0, INFINITY) Math.exp(0) #=> 1.0 Math.exp(1) #=> 2.718281828459045 Math.exp(1.5) #=> 4.4816890703380645;T;[o;= ;>I" overload;F;?0;;';@0;:I" exp(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@&;![;"I"@return [Float];T;#0;$@&;.F;Bi;C0;7[[I"x;T0;$@&;![;"I"Returns e**x. Domain: (-INFINITY, INFINITY) Codomain: (0, INFINITY) Math.exp(0) #=> 1.0 Math.exp(1) #=> 2.718281828459045 Math.exp(1.5) #=> 4.4816890703380645 @overload exp(x) @return [Float];T;#0;$@&;.F;/o;0;1T;2i;3i;Bi;%@ ;9@$;:@%;;To;4;5F;6;;;;&I" Math#log;F;7[[@90;[[@-i;T;;;0;[;{;IC; "Returns the logarithm of +x+. If additional second argument is given, it will be the base of logarithm. Otherwise it is +e+ (for the natural logarithm). Domain: (0, INFINITY) Codomain: (-INFINITY, INFINITY) Math.log(0) #=> -Infinity Math.log(1) #=> 0.0 Math.log(Math::E) #=> 1.0 Math.log(Math::E**3) #=> 3.0 Math.log(12, 3) #=> 2.2618595071429146 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" log(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@=;![;"I"@return [Float];T;#0;$@=;.F;Bi;C0;7[[I"x;T0;$@=o;= ;>I" overload;F;?0;;;@0;:I"log(x, base);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@=;![;"I"@return [Float];T;#0;$@=;.F;Bi;C0;7[[I"x;T0[I" base;T0;$@=;![;"I"Returns the logarithm of +x+. If additional second argument is given, it will be the base of logarithm. Otherwise it is +e+ (for the natural logarithm). Domain: (0, INFINITY) Codomain: (-INFINITY, INFINITY) Math.log(0) #=> -Infinity Math.log(1) #=> 0.0 Math.log(Math::E) #=> 1.0 Math.log(Math::E**3) #=> 3.0 Math.log(12, 3) #=> 2.2618595071429146 @overload log(x) @return [Float] @overload log(x, base) @return [Float];T;#0;$@=;.F;C0;%@ ;9I"qstatic VALUE math_log(int argc, const VALUE *argv, VALUE unused_obj) { return rb_math_log(argc, argv); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I" Math.log;F;7@?;@A;T;;;0;@C;{;IC; "Returns the logarithm of +x+. If additional second argument is given, it will be the base of logarithm. Otherwise it is +e+ (for the natural logarithm). Domain: (0, INFINITY) Codomain: (-INFINITY, INFINITY) Math.log(0) #=> -Infinity Math.log(1) #=> 0.0 Math.log(Math::E) #=> 1.0 Math.log(Math::E**3) #=> 3.0 Math.log(12, 3) #=> 2.2618595071429146;T;[o;= ;>I" overload;F;?0;;;@0;:I" log(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@k;![;"I"@return [Float];T;#0;$@k;.F;Bi;C0;7[[I"x;T0;$@ko;= ;>I" overload;F;?0;;;@0;:I"log(x, base);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@k;![;"I"@return [Float];T;#0;$@k;.F;Bi;C0;7[[I"x;T0[I" base;T0;$@k;![;"I"Returns the logarithm of +x+. If additional second argument is given, it will be the base of logarithm. Otherwise it is +e+ (for the natural logarithm). Domain: (0, INFINITY) Codomain: (-INFINITY, INFINITY) Math.log(0) #=> -Infinity Math.log(1) #=> 0.0 Math.log(Math::E) #=> 1.0 Math.log(Math::E**3) #=> 3.0 Math.log(12, 3) #=> 2.2618595071429146 @overload log(x) @return [Float] @overload log(x, base) @return [Float];T;#0;$@k;.F;/o;0;1T;2i;3i;Bi;%@ ;9@i;:@j;;To;4;5F;6;;;;&I"Math#log2;F;7[[I"x;T0;[[@-i;T;: log2;0;[;{;IC; "Returns the base 2 logarithm of +x+. Domain: (0, INFINITY) Codomain: (-INFINITY, INFINITY) Math.log2(1) #=> 0.0 Math.log2(2) #=> 1.0 Math.log2(32768) #=> 15.0 Math.log2(65536) #=> 16.0 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" log2(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Returns the base 2 logarithm of +x+. Domain: (0, INFINITY) Codomain: (-INFINITY, INFINITY) Math.log2(1) #=> 0.0 Math.log2(2) #=> 1.0 Math.log2(32768) #=> 15.0 Math.log2(65536) #=> 16.0 @overload log2(x) @return [Float];T;#0;$@;.F;C0;%@ ;9I"0static VALUE math_log2(VALUE unused_obj, VALUE x) { size_t numbits; double d = get_double_rshift(x, &numbits); domain_check_min(d, 0.0, "log2"); /* check for pole error */ if (d == 0.0) return DBL2NUM(-HUGE_VAL); return DBL2NUM(log2(d) + numbits); /* log2(d * 2 ** numbits) */ };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.log2;F;7@;@;T;; ;0;@;{;IC; "Returns the base 2 logarithm of +x+. Domain: (0, INFINITY) Codomain: (-INFINITY, INFINITY) Math.log2(1) #=> 0.0 Math.log2(2) #=> 1.0 Math.log2(32768) #=> 15.0 Math.log2(65536) #=> 16.0;T;[o;= ;>I" overload;F;?0;; ;@0;:I" log2(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Returns the base 2 logarithm of +x+. Domain: (0, INFINITY) Codomain: (-INFINITY, INFINITY) Math.log2(1) #=> 0.0 Math.log2(2) #=> 1.0 Math.log2(32768) #=> 15.0 Math.log2(65536) #=> 16.0 @overload log2(x) @return [Float];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@ ;9@;:@;;To;4;5F;6;;;;&I"Math#log10;F;7[[I"x;T0;[[@-i2;T;: log10;0;[;{;IC; "Returns the base 10 logarithm of +x+. Domain: (0, INFINITY) Codomain: (-INFINITY, INFINITY) Math.log10(1) #=> 0.0 Math.log10(10) #=> 1.0 Math.log10(10**100) #=> 100.0 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" log10(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Returns the base 10 logarithm of +x+. Domain: (0, INFINITY) Codomain: (-INFINITY, INFINITY) Math.log10(1) #=> 0.0 Math.log10(10) #=> 1.0 Math.log10(10**100) #=> 100.0 @overload log10(x) @return [Float];T;#0;$@;.F;C0;%@ ;9I"?static VALUE math_log10(VALUE unused_obj, VALUE x) { size_t numbits; double d = get_double_rshift(x, &numbits); domain_check_min(d, 0.0, "log10"); /* check for pole error */ if (d == 0.0) return DBL2NUM(-HUGE_VAL); return DBL2NUM(log10(d) + numbits * log10(2)); /* log10(d * 2 ** numbits) */ };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.log10;F;7@;@;T;; ;0;@;{;IC; "Returns the base 10 logarithm of +x+. Domain: (0, INFINITY) Codomain: (-INFINITY, INFINITY) Math.log10(1) #=> 0.0 Math.log10(10) #=> 1.0 Math.log10(10**100) #=> 100.0;T;[o;= ;>I" overload;F;?0;; ;@0;:I" log10(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Returns the base 10 logarithm of +x+. Domain: (0, INFINITY) Codomain: (-INFINITY, INFINITY) Math.log10(1) #=> 0.0 Math.log10(10) #=> 1.0 Math.log10(10**100) #=> 100.0 @overload log10(x) @return [Float];T;#0;$@;.F;/o;0;1T;2i";3i/;Bi;%@ ;9@;:@;;To;4;5F;6;;;;&I"Math#sqrt;F;7[[I"x;T0;[[@-ib;T;;";0;[;{;IC; "Returns the non-negative square root of +x+. Domain: [0, INFINITY) Codomain:[0, INFINITY) 0.upto(10) {|x| p [x, Math.sqrt(x), Math.sqrt(x)**2] } #=> [0, 0.0, 0.0] # [1, 1.0, 1.0] # [2, 1.4142135623731, 2.0] # [3, 1.73205080756888, 3.0] # [4, 2.0, 4.0] # [5, 2.23606797749979, 5.0] # [6, 2.44948974278318, 6.0] # [7, 2.64575131106459, 7.0] # [8, 2.82842712474619, 8.0] # [9, 3.0, 9.0] # [10, 3.16227766016838, 10.0] Note that the limited precision of floating point arithmetic might lead to surprising results: Math.sqrt(10**46).to_i #=> 99999999999999991611392 (!) See also BigDecimal#sqrt and Integer.sqrt. ;T;[o;= ;>I" overload;F;?0;;";@0;:I" sqrt(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Returns the non-negative square root of +x+. Domain: [0, INFINITY) Codomain:[0, INFINITY) 0.upto(10) {|x| p [x, Math.sqrt(x), Math.sqrt(x)**2] } #=> [0, 0.0, 0.0] # [1, 1.0, 1.0] # [2, 1.4142135623731, 2.0] # [3, 1.73205080756888, 3.0] # [4, 2.0, 4.0] # [5, 2.23606797749979, 5.0] # [6, 2.44948974278318, 6.0] # [7, 2.64575131106459, 7.0] # [8, 2.82842712474619, 8.0] # [9, 3.0, 9.0] # [10, 3.16227766016838, 10.0] Note that the limited precision of floating point arithmetic might lead to surprising results: Math.sqrt(10**46).to_i #=> 99999999999999991611392 (!) See also BigDecimal#sqrt and Integer.sqrt. @overload sqrt(x) @return [Float];T;#0;$@;.F;C0;%@ ;9I"Vstatic VALUE math_sqrt(VALUE unused_obj, VALUE x) { return rb_math_sqrt(x); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.sqrt;F;7@;@;T;;";0;@;{;IC; "Returns the non-negative square root of +x+. Domain: [0, INFINITY) Codomain:[0, INFINITY) 0.upto(10) {|x| p [x, Math.sqrt(x), Math.sqrt(x)**2] } #=> [0, 0.0, 0.0] # [1, 1.0, 1.0] # [2, 1.4142135623731, 2.0] # [3, 1.73205080756888, 3.0] # [4, 2.0, 4.0] # [5, 2.23606797749979, 5.0] # [6, 2.44948974278318, 6.0] # [7, 2.64575131106459, 7.0] # [8, 2.82842712474619, 8.0] # [9, 3.0, 9.0] # [10, 3.16227766016838, 10.0] Note that the limited precision of floating point arithmetic might lead to surprising results: Math.sqrt(10**46).to_i #=> 99999999999999991611392 (!) See also BigDecimal#sqrt and Integer.sqrt.;T;[o;= ;>I" overload;F;?0;;";@0;:I" sqrt(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Returns the non-negative square root of +x+. Domain: [0, INFINITY) Codomain:[0, INFINITY) 0.upto(10) {|x| p [x, Math.sqrt(x), Math.sqrt(x)**2] } #=> [0, 0.0, 0.0] # [1, 1.0, 1.0] # [2, 1.4142135623731, 2.0] # [3, 1.73205080756888, 3.0] # [4, 2.0, 4.0] # [5, 2.23606797749979, 5.0] # [6, 2.44948974278318, 6.0] # [7, 2.64575131106459, 7.0] # [8, 2.82842712474619, 8.0] # [9, 3.0, 9.0] # [10, 3.16227766016838, 10.0] Note that the limited precision of floating point arithmetic might lead to surprising results: Math.sqrt(10**46).to_i #=> 99999999999999991611392 (!) See also BigDecimal#sqrt and Integer.sqrt. @overload sqrt(x) @return [Float];T;#0;$@;.F;/o;0;1T;2iA;3i_;Bi;%@ ;9@;:@;;To;4;5F;6;;;;&I"Math#cbrt;F;7[[I"x;T0;[[@-i;T;: cbrt;0;[;{;IC; "Returns the cube root of +x+. Domain: (-INFINITY, INFINITY) Codomain: (-INFINITY, INFINITY) -9.upto(9) {|x| p [x, Math.cbrt(x), Math.cbrt(x)**3] } #=> [-9, -2.0800838230519, -9.0] # [-8, -2.0, -8.0] # [-7, -1.91293118277239, -7.0] # [-6, -1.81712059283214, -6.0] # [-5, -1.7099759466767, -5.0] # [-4, -1.5874010519682, -4.0] # [-3, -1.44224957030741, -3.0] # [-2, -1.25992104989487, -2.0] # [-1, -1.0, -1.0] # [0, 0.0, 0.0] # [1, 1.0, 1.0] # [2, 1.25992104989487, 2.0] # [3, 1.44224957030741, 3.0] # [4, 1.5874010519682, 4.0] # [5, 1.7099759466767, 5.0] # [6, 1.81712059283214, 6.0] # [7, 1.91293118277239, 7.0] # [8, 2.0, 8.0] # [9, 2.0800838230519, 9.0] ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" cbrt(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@2;![;"I"@return [Float];T;#0;$@2;.F;Bi;C0;7[[I"x;T0;$@2;![;"I" Returns the cube root of +x+. Domain: (-INFINITY, INFINITY) Codomain: (-INFINITY, INFINITY) -9.upto(9) {|x| p [x, Math.cbrt(x), Math.cbrt(x)**3] } #=> [-9, -2.0800838230519, -9.0] # [-8, -2.0, -8.0] # [-7, -1.91293118277239, -7.0] # [-6, -1.81712059283214, -6.0] # [-5, -1.7099759466767, -5.0] # [-4, -1.5874010519682, -4.0] # [-3, -1.44224957030741, -3.0] # [-2, -1.25992104989487, -2.0] # [-1, -1.0, -1.0] # [0, 0.0, 0.0] # [1, 1.0, 1.0] # [2, 1.25992104989487, 2.0] # [3, 1.44224957030741, 3.0] # [4, 1.5874010519682, 4.0] # [5, 1.7099759466767, 5.0] # [6, 1.81712059283214, 6.0] # [7, 1.91293118277239, 7.0] # [8, 2.0, 8.0] # [9, 2.0800838230519, 9.0] @overload cbrt(x) @return [Float];T;#0;$@2;.F;C0;%@ ;9I"static VALUE math_cbrt(VALUE unused_obj, VALUE x) { double f = Get_Double(x); double r = cbrt(f); #if defined __GLIBC__ if (isfinite(r) && !(f == 0.0 && r == 0.0)) { r = (2.0 * r + (f / r / r)) / 3.0; } #endif return DBL2NUM(r); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.cbrt;F;7@4;@7;T;; ;0;@9;{;IC; "Returns the cube root of +x+. Domain: (-INFINITY, INFINITY) Codomain: (-INFINITY, INFINITY) -9.upto(9) {|x| p [x, Math.cbrt(x), Math.cbrt(x)**3] } #=> [-9, -2.0800838230519, -9.0] # [-8, -2.0, -8.0] # [-7, -1.91293118277239, -7.0] # [-6, -1.81712059283214, -6.0] # [-5, -1.7099759466767, -5.0] # [-4, -1.5874010519682, -4.0] # [-3, -1.44224957030741, -3.0] # [-2, -1.25992104989487, -2.0] # [-1, -1.0, -1.0] # [0, 0.0, 0.0] # [1, 1.0, 1.0] # [2, 1.25992104989487, 2.0] # [3, 1.44224957030741, 3.0] # [4, 1.5874010519682, 4.0] # [5, 1.7099759466767, 5.0] # [6, 1.81712059283214, 6.0] # [7, 1.91293118277239, 7.0] # [8, 2.0, 8.0] # [9, 2.0800838230519, 9.0];T;[o;= ;>I" overload;F;?0;; ;@0;:I" cbrt(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@P;![;"I"@return [Float];T;#0;$@P;.F;Bi;C0;7[[I"x;T0;$@P;![;"I" Returns the cube root of +x+. Domain: (-INFINITY, INFINITY) Codomain: (-INFINITY, INFINITY) -9.upto(9) {|x| p [x, Math.cbrt(x), Math.cbrt(x)**3] } #=> [-9, -2.0800838230519, -9.0] # [-8, -2.0, -8.0] # [-7, -1.91293118277239, -7.0] # [-6, -1.81712059283214, -6.0] # [-5, -1.7099759466767, -5.0] # [-4, -1.5874010519682, -4.0] # [-3, -1.44224957030741, -3.0] # [-2, -1.25992104989487, -2.0] # [-1, -1.0, -1.0] # [0, 0.0, 0.0] # [1, 1.0, 1.0] # [2, 1.25992104989487, 2.0] # [3, 1.44224957030741, 3.0] # [4, 1.5874010519682, 4.0] # [5, 1.7099759466767, 5.0] # [6, 1.81712059283214, 6.0] # [7, 1.91293118277239, 7.0] # [8, 2.0, 8.0] # [9, 2.0800838230519, 9.0] @overload cbrt(x) @return [Float];T;#0;$@P;.F;/o;0;1T;2i;3i;Bi;%@ ;9@N;:@O;;To;4;5F;6;;;;&I"Math#frexp;F;7[[I"x;T0;[[@-i;T;: frexp;0;[;{;IC; "Returns a two-element array containing the normalized fraction (a Float) and exponent (an Integer) of +x+. fraction, exponent = Math.frexp(1234) #=> [0.6025390625, 11] fraction * 2**exponent #=> 1234.0 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" frexp(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@g;![;"I"@return [Array];T;#0;$@g;.F;Bi;C0;7[[I"x;T0;$@g;![;"I" Returns a two-element array containing the normalized fraction (a Float) and exponent (an Integer) of +x+. fraction, exponent = Math.frexp(1234) #=> [0.6025390625, 11] fraction * 2**exponent #=> 1234.0 @overload frexp(x) @return [Array];T;#0;$@g;.F;C0;%@ ;9I"static VALUE math_frexp(VALUE unused_obj, VALUE x) { double d; int exp; d = frexp(Get_Double(x), &exp); return rb_assoc_new(DBL2NUM(d), INT2NUM(exp)); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.frexp;F;7@i;@l;T;; ;0;@n;{;IC; "Returns a two-element array containing the normalized fraction (a Float) and exponent (an Integer) of +x+. fraction, exponent = Math.frexp(1234) #=> [0.6025390625, 11] fraction * 2**exponent #=> 1234.0;T;[o;= ;>I" overload;F;?0;; ;@0;:I" frexp(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I" Returns a two-element array containing the normalized fraction (a Float) and exponent (an Integer) of +x+. fraction, exponent = Math.frexp(1234) #=> [0.6025390625, 11] fraction * 2**exponent #=> 1234.0 @overload frexp(x) @return [Array];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@ ;9@;:@;;To;4;5F;6;;;;&I"Math#ldexp;F;7[[I"x;T0[I"n;T0;[[@-i;T;: ldexp;0;[;{;IC; "Returns the value of +fraction+*(2**+exponent+). fraction, exponent = Math.frexp(1234) Math.ldexp(fraction, exponent) #=> 1234.0 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"ldexp(fraction, exponent);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I" fraction;T0[I" exponent;T0;$@;![;"I"Returns the value of +fraction+*(2**+exponent+). fraction, exponent = Math.frexp(1234) Math.ldexp(fraction, exponent) #=> 1234.0 @overload ldexp(fraction, exponent) @return [Float];T;#0;$@;.F;C0;%@ ;9I"zstatic VALUE math_ldexp(VALUE unused_obj, VALUE x, VALUE n) { return DBL2NUM(ldexp(Get_Double(x), NUM2INT(n))); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.ldexp;F;7@;@;T;; ;0;@;{;IC; "Returns the value of +fraction+*(2**+exponent+). fraction, exponent = Math.frexp(1234) Math.ldexp(fraction, exponent) #=> 1234.0;T;[o;= ;>I" overload;F;?0;; ;@0;:I"ldexp(fraction, exponent);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I" fraction;T0[I" exponent;T0;$@;![;"I"Returns the value of +fraction+*(2**+exponent+). fraction, exponent = Math.frexp(1234) Math.ldexp(fraction, exponent) #=> 1234.0 @overload ldexp(fraction, exponent) @return [Float];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@ ;9@;:@;;To;4;5F;6;;;;&I"Math#hypot;F;7[[I"x;T0[I"y;T0;[[@-i;T;: hypot;0;[;{;IC; "{Returns sqrt(x**2 + y**2), the hypotenuse of a right-angled triangle with sides +x+ and +y+. Math.hypot(3, 4) #=> 5.0 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"hypot(x, y);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0[I"y;T0;$@;![;"I"Returns sqrt(x**2 + y**2), the hypotenuse of a right-angled triangle with sides +x+ and +y+. Math.hypot(3, 4) #=> 5.0 @overload hypot(x, y) @return [Float];T;#0;$@;.F;C0;%@ ;9I"}static VALUE math_hypot(VALUE unused_obj, VALUE x, VALUE y) { return DBL2NUM(hypot(Get_Double(x), Get_Double(y))); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.hypot;F;7@;@;T;; ;0;@;{;IC; "{Returns sqrt(x**2 + y**2), the hypotenuse of a right-angled triangle with sides +x+ and +y+. Math.hypot(3, 4) #=> 5.0;T;[o;= ;>I" overload;F;?0;; ;@0;:I"hypot(x, y);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0[I"y;T0;$@;![;"I"Returns sqrt(x**2 + y**2), the hypotenuse of a right-angled triangle with sides +x+ and +y+. Math.hypot(3, 4) #=> 5.0 @overload hypot(x, y) @return [Float];T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@ ;9@;:@;;To;4;5F;6;;;;&I" Math#erf;F;7[[I"x;T0;[[@-i;T;:erf;0;[;{;IC; "vCalculates the error function of +x+. Domain: (-INFINITY, INFINITY) Codomain: (-1, 1) Math.erf(0) #=> 0.0 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" erf(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I"Calculates the error function of +x+. Domain: (-INFINITY, INFINITY) Codomain: (-1, 1) Math.erf(0) #=> 0.0 @overload erf(x) @return [Float];T;#0;$@;.F;C0;%@ ;9I"astatic VALUE math_erf(VALUE unused_obj, VALUE x) { return DBL2NUM(erf(Get_Double(x))); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I" Math.erf;F;7@;@;T;; ;0;@;{;IC; "vCalculates the error function of +x+. Domain: (-INFINITY, INFINITY) Codomain: (-1, 1) Math.erf(0) #=> 0.0;T;[o;= ;>I" overload;F;?0;; ;@0;:I" erf(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@0;![;"I"@return [Float];T;#0;$@0;.F;Bi;C0;7[[I"x;T0;$@0;![;"I" Calculates the error function of +x+. Domain: (-INFINITY, INFINITY) Codomain: (-1, 1) Math.erf(0) #=> 0.0 @overload erf(x) @return [Float];T;#0;$@0;.F;/o;0;1T;2i;3i;Bi;%@ ;9@.;:@/;;To;4;5F;6;;;;&I"Math#erfc;F;7[[I"x;T0;[[@-i;T;: erfc;0;[;{;IC; "}Calculates the complementary error function of x. Domain: (-INFINITY, INFINITY) Codomain: (0, 2) Math.erfc(0) #=> 1.0 ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" erfc(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@G;![;"I"@return [Float];T;#0;$@G;.F;Bi;C0;7[[I"x;T0;$@G;![;"I"Calculates the complementary error function of x. Domain: (-INFINITY, INFINITY) Codomain: (0, 2) Math.erfc(0) #=> 1.0 @overload erfc(x) @return [Float];T;#0;$@G;.F;C0;%@ ;9I"cstatic VALUE math_erfc(VALUE unused_obj, VALUE x) { return DBL2NUM(erfc(Get_Double(x))); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.erfc;F;7@I;@L;T;; ;0;@N;{;IC; "}Calculates the complementary error function of x. Domain: (-INFINITY, INFINITY) Codomain: (0, 2) Math.erfc(0) #=> 1.0;T;[o;= ;>I" overload;F;?0;; ;@0;:I" erfc(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@e;![;"I"@return [Float];T;#0;$@e;.F;Bi;C0;7[[I"x;T0;$@e;![;"I" Calculates the complementary error function of x. Domain: (-INFINITY, INFINITY) Codomain: (0, 2) Math.erfc(0) #=> 1.0 @overload erfc(x) @return [Float];T;#0;$@e;.F;/o;0;1T;2i;3i;Bi;%@ ;9@c;:@d;;To;4;5F;6;;;;&I"Math#gamma;F;7[[I"x;T0;[[@-iB;T;: gamma;0;[;{;IC; "Calculates the gamma function of x. Note that gamma(n) is the same as fact(n-1) for integer n > 0. However gamma(n) returns float and can be an approximation. def fact(n) (1..n).inject(1) {|r,i| r*i } end 1.upto(26) {|i| p [i, Math.gamma(i), fact(i-1)] } #=> [1, 1.0, 1] # [2, 1.0, 1] # [3, 2.0, 2] # [4, 6.0, 6] # [5, 24.0, 24] # [6, 120.0, 120] # [7, 720.0, 720] # [8, 5040.0, 5040] # [9, 40320.0, 40320] # [10, 362880.0, 362880] # [11, 3628800.0, 3628800] # [12, 39916800.0, 39916800] # [13, 479001600.0, 479001600] # [14, 6227020800.0, 6227020800] # [15, 87178291200.0, 87178291200] # [16, 1307674368000.0, 1307674368000] # [17, 20922789888000.0, 20922789888000] # [18, 355687428096000.0, 355687428096000] # [19, 6.402373705728e+15, 6402373705728000] # [20, 1.21645100408832e+17, 121645100408832000] # [21, 2.43290200817664e+18, 2432902008176640000] # [22, 5.109094217170944e+19, 51090942171709440000] # [23, 1.1240007277776077e+21, 1124000727777607680000] # [24, 2.5852016738885062e+22, 25852016738884976640000] # [25, 6.204484017332391e+23, 620448401733239439360000] # [26, 1.5511210043330954e+25, 15511210043330985984000000] ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" gamma(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@|;![;"I"@return [Float];T;#0;$@|;.F;Bi;C0;7[[I"x;T0;$@|;![;"I"Calculates the gamma function of x. Note that gamma(n) is the same as fact(n-1) for integer n > 0. However gamma(n) returns float and can be an approximation. def fact(n) (1..n).inject(1) {|r,i| r*i } end 1.upto(26) {|i| p [i, Math.gamma(i), fact(i-1)] } #=> [1, 1.0, 1] # [2, 1.0, 1] # [3, 2.0, 2] # [4, 6.0, 6] # [5, 24.0, 24] # [6, 120.0, 120] # [7, 720.0, 720] # [8, 5040.0, 5040] # [9, 40320.0, 40320] # [10, 362880.0, 362880] # [11, 3628800.0, 3628800] # [12, 39916800.0, 39916800] # [13, 479001600.0, 479001600] # [14, 6227020800.0, 6227020800] # [15, 87178291200.0, 87178291200] # [16, 1307674368000.0, 1307674368000] # [17, 20922789888000.0, 20922789888000] # [18, 355687428096000.0, 355687428096000] # [19, 6.402373705728e+15, 6402373705728000] # [20, 1.21645100408832e+17, 121645100408832000] # [21, 2.43290200817664e+18, 2432902008176640000] # [22, 5.109094217170944e+19, 51090942171709440000] # [23, 1.1240007277776077e+21, 1124000727777607680000] # [24, 2.5852016738885062e+22, 25852016738884976640000] # [25, 6.204484017332391e+23, 620448401733239439360000] # [26, 1.5511210043330954e+25, 15511210043330985984000000] @overload gamma(x) @return [Float];T;#0;$@|;.F;C0;%@ ;9I"3static VALUE math_gamma(VALUE unused_obj, VALUE x) { static const double fact_table[] = { /* fact(0) */ 1.0, /* fact(1) */ 1.0, /* fact(2) */ 2.0, /* fact(3) */ 6.0, /* fact(4) */ 24.0, /* fact(5) */ 120.0, /* fact(6) */ 720.0, /* fact(7) */ 5040.0, /* fact(8) */ 40320.0, /* fact(9) */ 362880.0, /* fact(10) */ 3628800.0, /* fact(11) */ 39916800.0, /* fact(12) */ 479001600.0, /* fact(13) */ 6227020800.0, /* fact(14) */ 87178291200.0, /* fact(15) */ 1307674368000.0, /* fact(16) */ 20922789888000.0, /* fact(17) */ 355687428096000.0, /* fact(18) */ 6402373705728000.0, /* fact(19) */ 121645100408832000.0, /* fact(20) */ 2432902008176640000.0, /* fact(21) */ 51090942171709440000.0, /* fact(22) */ 1124000727777607680000.0, /* fact(23)=25852016738884976640000 needs 56bit mantissa which is * impossible to represent exactly in IEEE 754 double which have * 53bit mantissa. */ }; enum {NFACT_TABLE = numberof(fact_table)}; double d; d = Get_Double(x); /* check for domain error */ if (isinf(d)) { if (signbit(d)) domain_error("gamma"); return DBL2NUM(HUGE_VAL); } if (d == 0.0) { return signbit(d) ? DBL2NUM(-HUGE_VAL) : DBL2NUM(HUGE_VAL); } if (d == floor(d)) { domain_check_min(d, 0.0, "gamma"); if (1.0 <= d && d <= (double)NFACT_TABLE) { return DBL2NUM(fact_table[(int)d - 1]); } } return DBL2NUM(tgamma(d)); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.gamma;F;7@~;@;T;; ;0;@;{;IC; "Calculates the gamma function of x. Note that gamma(n) is the same as fact(n-1) for integer n > 0. However gamma(n) returns float and can be an approximation. def fact(n) (1..n).inject(1) {|r,i| r*i } end 1.upto(26) {|i| p [i, Math.gamma(i), fact(i-1)] } #=> [1, 1.0, 1] # [2, 1.0, 1] # [3, 2.0, 2] # [4, 6.0, 6] # [5, 24.0, 24] # [6, 120.0, 120] # [7, 720.0, 720] # [8, 5040.0, 5040] # [9, 40320.0, 40320] # [10, 362880.0, 362880] # [11, 3628800.0, 3628800] # [12, 39916800.0, 39916800] # [13, 479001600.0, 479001600] # [14, 6227020800.0, 6227020800] # [15, 87178291200.0, 87178291200] # [16, 1307674368000.0, 1307674368000] # [17, 20922789888000.0, 20922789888000] # [18, 355687428096000.0, 355687428096000] # [19, 6.402373705728e+15, 6402373705728000] # [20, 1.21645100408832e+17, 121645100408832000] # [21, 2.43290200817664e+18, 2432902008176640000] # [22, 5.109094217170944e+19, 51090942171709440000] # [23, 1.1240007277776077e+21, 1124000727777607680000] # [24, 2.5852016738885062e+22, 25852016738884976640000] # [25, 6.204484017332391e+23, 620448401733239439360000] # [26, 1.5511210043330954e+25, 15511210043330985984000000];T;[o;= ;>I" overload;F;?0;; ;@0;:I" gamma(x);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Float;T;$@;![;"I"@return [Float];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I" Calculates the gamma function of x. Note that gamma(n) is the same as fact(n-1) for integer n > 0. However gamma(n) returns float and can be an approximation. def fact(n) (1..n).inject(1) {|r,i| r*i } end 1.upto(26) {|i| p [i, Math.gamma(i), fact(i-1)] } #=> [1, 1.0, 1] # [2, 1.0, 1] # [3, 2.0, 2] # [4, 6.0, 6] # [5, 24.0, 24] # [6, 120.0, 120] # [7, 720.0, 720] # [8, 5040.0, 5040] # [9, 40320.0, 40320] # [10, 362880.0, 362880] # [11, 3628800.0, 3628800] # [12, 39916800.0, 39916800] # [13, 479001600.0, 479001600] # [14, 6227020800.0, 6227020800] # [15, 87178291200.0, 87178291200] # [16, 1307674368000.0, 1307674368000] # [17, 20922789888000.0, 20922789888000] # [18, 355687428096000.0, 355687428096000] # [19, 6.402373705728e+15, 6402373705728000] # [20, 1.21645100408832e+17, 121645100408832000] # [21, 2.43290200817664e+18, 2432902008176640000] # [22, 5.109094217170944e+19, 51090942171709440000] # [23, 1.1240007277776077e+21, 1124000727777607680000] # [24, 2.5852016738885062e+22, 25852016738884976640000] # [25, 6.204484017332391e+23, 620448401733239439360000] # [26, 1.5511210043330954e+25, 15511210043330985984000000] @overload gamma(x) @return [Float];T;#0;$@;.F;/o;0;1T;2i;3i?;Bi;%@ ;9@;:@;;To;4;5F;6;;;;&I"Math#lgamma;F;7[[I"x;T0;[[@-i;T;: lgamma;0;[;{;IC; "Calculates the logarithmic gamma of +x+ and the sign of gamma of +x+. Math.lgamma(x) is the same as [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1] but avoids overflow by Math.gamma(x) for large x. Math.lgamma(0) #=> [Infinity, 1] ;T;[o;= ;>I" overload;F;?0;; ;@0;:I"lgamma(x);T;IC; ";T;[o;A ;>I" return;F;?I"];T;0;@[I" Array;TI"-1;TI"1;T;$@;![;"I"@return [Array, -1, 1]];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I")Calculates the logarithmic gamma of +x+ and the sign of gamma of +x+. Math.lgamma(x) is the same as [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1] but avoids overflow by Math.gamma(x) for large x. Math.lgamma(0) #=> [Infinity, 1] @overload lgamma(x) @return [Array, -1, 1]];T;#0;$@;.F;C0;%@ ;9I"static VALUE math_lgamma(VALUE unused_obj, VALUE x) { double d; int sign=1; VALUE v; d = Get_Double(x); /* check for domain error */ if (isinf(d)) { if (signbit(d)) domain_error("lgamma"); return rb_assoc_new(DBL2NUM(HUGE_VAL), INT2FIX(1)); } if (d == 0.0) { VALUE vsign = signbit(d) ? INT2FIX(-1) : INT2FIX(+1); return rb_assoc_new(DBL2NUM(HUGE_VAL), vsign); } v = DBL2NUM(lgamma_r(d, &sign)); return rb_assoc_new(v, INT2FIX(sign)); };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"Math.lgamma;F;7@;@;T;; ;0;@;{;IC; "Calculates the logarithmic gamma of +x+ and the sign of gamma of +x+. Math.lgamma(x) is the same as [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1] but avoids overflow by Math.gamma(x) for large x. Math.lgamma(0) #=> [Infinity, 1];T;[o;= ;>I" overload;F;?0;; ;@0;:I"lgamma(x);T;IC; ";T;[o;A ;>I" return;F;?I"];T;0;@[I" Array;TI"-1;TI"1;T;$@;![;"I"@return [Array, -1, 1]];T;#0;$@;.F;Bi;C0;7[[I"x;T0;$@;![;"I", Calculates the logarithmic gamma of +x+ and the sign of gamma of +x+. Math.lgamma(x) is the same as [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1] but avoids overflow by Math.gamma(x) for large x. Math.lgamma(0) #=> [Infinity, 1] @overload lgamma(x) @return [Array, -1, 1]];T;#0;$@;.F;/o;0;1T;2iu;3i;Bi;%@ ;9@;:@;;T; @ ; IC;[; @ ; IC;[; @ ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@-i;F;; ;;;;;[;{;IC; " ;T;[;![;"@;#0;$@ ;Bi;%@;&I" Math;Fo; ;IC;[ o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[I" ractor.c;Ti,;F;;;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;%@;&I"Ractor::Error;F;'@[o; ;IC;[; @ ; IC;[; @ ; IC;[; @ ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i-;F;:IsolationError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@ ;%@;&I"Ractor::IsolationError;F;'@o; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i.;T;:RemoteError;;;;;[;{;IC; "Raised on attempt to Ractor#take if there was an uncaught exception in the Ractor. Its +cause+ will contain the original exception, and +ractor+ is the original ractor it was raised in. r = Ractor.new { raise "Something weird happened" } begin r.take rescue => e p e # => # p e.ractor == r # => true p e.cause # => # end ;T;[;![;"I" Raised on attempt to Ractor#take if there was an uncaught exception in the Ractor. Its +cause+ will contain the original exception, and +ractor+ is the original ractor it was raised in. r = Ractor.new { raise "Something weird happened" } begin r.take rescue => e p e # => # p e.ractor == r # => true p e.cause # => # end ;T;#0;$@;.F;/o;0;1T;2i;3i;%o;( ;)0;*0;+0;: Ractor;%@;-@;0;&I"Ractor::RemoteError;T;'@o; ;IC;[; @3; IC;[; @3; IC;[; @3; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i/;T;:MovedError;;;;;[;{;IC; "Raised on an attempt to access an object which was moved in Ractor#send or Ractor.yield. r = Ractor.new { sleep } ary = [1, 2, 3] r.send(ary, move: true) ary.inspect # Ractor::MovedError (can not send any methods to a moved object) ;T;[;![;"I" Raised on an attempt to access an object which was moved in Ractor#send or Ractor.yield. r = Ractor.new { sleep } ary = [1, 2, 3] r.send(ary, move: true) ary.inspect # Ractor::MovedError (can not send any methods to a moved object) ;T;#0;$@3;.F;/o;0;1T;2i;3i ;%o;( ;)0;*0;+0;; ;%@;-@;0;&I"Ractor::MovedError;T;'@o; ;IC;[; @H; IC;[; @H; IC;[; @H; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i0;T;:ClosedError;;;;;[;{;IC; "0Raised when an attempt is made to send a message to a closed port, or to retrieve a message from a closed and empty port. Ports may be closed explicitly with Ractor#close_outgoing/close_incoming and are closed implicitly when a Ractor terminates. r = Ractor.new { sleep(500) } r.close_outgoing r.take # Ractor::ClosedError ClosedError is a descendant of StopIteration, so the closing of the ractor will break the loops without propagating the error: r = Ractor.new do loop do msg = receive # raises ClosedError and loop traps it puts "Received: #{msg}" end puts "loop exited" end 3.times{|i| r << i} r.close_incoming r.take puts "Continue successfully" This will print: Received: 0 Received: 1 Received: 2 loop exited Continue successfully ;T;[;![;"I"2 Raised when an attempt is made to send a message to a closed port, or to retrieve a message from a closed and empty port. Ports may be closed explicitly with Ractor#close_outgoing/close_incoming and are closed implicitly when a Ractor terminates. r = Ractor.new { sleep(500) } r.close_outgoing r.take # Ractor::ClosedError ClosedError is a descendant of StopIteration, so the closing of the ractor will break the loops without propagating the error: r = Ractor.new do loop do msg = receive # raises ClosedError and loop traps it puts "Received: #{msg}" end puts "loop exited" end 3.times{|i| r << i} r.close_incoming r.take puts "Continue successfully" This will print: Received: 0 Received: 1 Received: 2 loop exited Continue successfully ;T;#0;$@H;.F;/o;0;1T;2i;3i;%o;( ;)0;*0;+0;; ;%@;-@;0;&I"Ractor::ClosedError;T;'@^ko; ;IC;[; @]; IC;[; @]; IC;[; @]; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i1;F;:UnsafeError;;;;;[;{;IC; " ;T;[;![;"@;#0;$@];%@;&I"Ractor::UnsafeError;F;'@o; ;IC;[o;4;5F;6;;;;&I"'Ractor::MovedObject#method_missing;T;7[[@90;[[@i;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@p;%@n;9I"static VALUE ractor_moved_missing(int argc, VALUE *argv, VALUE self) { rb_raise(rb_eRactorMovedError, "can not send any methods to a moved object"); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"!Ractor::MovedObject#__send__;T;7[[@90;[[@i;T;;|;0;[;{;IC; ",override methods defined in BasicObject ;T;[;![;"I",override methods defined in BasicObject;T;#0;$@};.F;/o;0;1T;2i7;3i7;%@n;9I"static VALUE ractor_moved_missing(int argc, VALUE *argv, VALUE self) { rb_raise(rb_eRactorMovedError, "can not send any methods to a moved object"); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Ractor::MovedObject#!;T;7[[@90;[[@i;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@n;9I"static VALUE ractor_moved_missing(int argc, VALUE *argv, VALUE self) { rb_raise(rb_eRactorMovedError, "can not send any methods to a moved object"); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Ractor::MovedObject#==;T;7[[@90;[[@i;T;;F;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@n;9I"static VALUE ractor_moved_missing(int argc, VALUE *argv, VALUE self) { rb_raise(rb_eRactorMovedError, "can not send any methods to a moved object"); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Ractor::MovedObject#!=;T;7[[@90;[[@i;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@n;9I"static VALUE ractor_moved_missing(int argc, VALUE *argv, VALUE self) { rb_raise(rb_eRactorMovedError, "can not send any methods to a moved object"); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Ractor::MovedObject#__id__;T;7[[@90;[[@i;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@n;9I"static VALUE ractor_moved_missing(int argc, VALUE *argv, VALUE self) { rb_raise(rb_eRactorMovedError, "can not send any methods to a moved object"); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"Ractor::MovedObject#equal?;T;7[[@90;[[@i;T;;W;0;[;{;IC; " ;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"@;#0;$@;Bi;%@n;9I"static VALUE ractor_moved_missing(int argc, VALUE *argv, VALUE self) { rb_raise(rb_eRactorMovedError, "can not send any methods to a moved object"); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&Ractor::MovedObject#instance_eval;T;7[[@90;[[@i;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@n;9I"static VALUE ractor_moved_missing(int argc, VALUE *argv, VALUE self) { rb_raise(rb_eRactorMovedError, "can not send any methods to a moved object"); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&Ractor::MovedObject#instance_exec;T;7[[@90;[[@i;T;;;0;[;{;IC; " ;T;[;![;"@;#0;$@;%@n;9I"static VALUE ractor_moved_missing(int argc, VALUE *argv, VALUE self) { rb_raise(rb_eRactorMovedError, "can not send any methods to a moved object"); };T;:I"static VALUE;T;;T; @n; IC;[; @n; IC;[; @n; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i3;T;:MovedObject;;;;;[;{;IC; "zA special object which replaces any value that was moved to another ractor in Ractor#send or Ractor.yield. Any attempt to access the object results in Ractor::MovedError. r = Ractor.new { receive } ary = [1, 2, 3] r.send(ary, move: true) p Ractor::MovedObject === ary # => true ary.inspect # Ractor::MovedError (can not send any methods to a moved object);T;[;![;"I"| A special object which replaces any value that was moved to another ractor in Ractor#send or Ractor.yield. Any attempt to access the object results in Ractor::MovedError. r = Ractor.new { receive } ary = [1, 2, 3] r.send(ary, move: true) p Ractor::MovedObject === ary # => true ary.inspect # Ractor::MovedError (can not send any methods to a moved object) ;T;#0;$@n;.F;/o;0;1T;2i;3i;Bi;%o;( ;)0;*0;+0;; ;%@;-@;0;&I"Ractor::MovedObject;T;'@; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i);F;; ;;;;;[;{;IC; " ;T;[;![;"I" ;T;#0;$@;.F;/o;0;1T;2i!;3i";%@;&I" Ractor;F;'@o;;IC;[ o;4;5F;6;;;;&I"PTY#getpty;F;7[[@90;[[I"ext/pty/pty.c;Ti?;T;: getpty;0;[;{;IC; "Spawns the specified command on a newly allocated pty. You can also use the alias ::getpty. The command's controlling tty is set to the slave device of the pty and its standard input/output/error is redirected to the slave device. +command+ and +command_line+ are the full commands to run, given a String. Any additional +arguments+ will be passed to the command. === Return values In the non-block form this returns an array of size three, [r, w, pid]. In the block form these same values will be yielded to the block: +r+:: A readable IO that contains the command's standard output and standard error +w+:: A writable IO that is the command's standard input +pid+:: The process identifier for the command. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"spawn(command_line);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"r;TI"w;TI"pid;T;$@;![;"I"@yield [r, w, pid];T;#0;$@;.F;Bi;C0;7[[I"command_line;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"spawn(command_line);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"command_line;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"#spawn(command, arguments, ...);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"r;TI"w;TI"pid;T;$@;![;"I"@yield [r, w, pid];T;#0;$@;.F;Bi;C0;7[[I" command;T0[I"arguments;T0[I"...;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"#spawn(command, arguments, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" command;T0[I"arguments;T0[I"...;T0;$@;![;"I"Spawns the specified command on a newly allocated pty. You can also use the alias ::getpty. The command's controlling tty is set to the slave device of the pty and its standard input/output/error is redirected to the slave device. +command+ and +command_line+ are the full commands to run, given a String. Any additional +arguments+ will be passed to the command. === Return values In the non-block form this returns an array of size three, [r, w, pid]. In the block form these same values will be yielded to the block: +r+:: A readable IO that contains the command's standard output and standard error +w+:: A writable IO that is the command's standard input +pid+:: The process identifier for the command. @overload spawn(command_line) @yield [r, w, pid] @overload spawn(command_line) @return [Array] @overload spawn(command, arguments, ...) @yield [r, w, pid] @overload spawn(command, arguments, ...) @return [Array];T;#0;$@;.F;C0;%@;9I"static VALUE pty_getpty(int argc, VALUE *argv, VALUE self) { VALUE res; struct pty_info info; rb_io_t *wfptr,*rfptr; VALUE rport = rb_obj_alloc(rb_cFile); VALUE wport = rb_obj_alloc(rb_cFile); char SlaveName[DEVICELEN]; MakeOpenFile(rport, rfptr); MakeOpenFile(wport, wfptr); establishShell(argc, argv, &info, SlaveName); rfptr->mode = rb_io_modestr_fmode("r"); rfptr->fd = info.fd; rfptr->pathv = rb_obj_freeze(rb_str_new_cstr(SlaveName)); wfptr->mode = rb_io_modestr_fmode("w") | FMODE_SYNC; wfptr->fd = rb_cloexec_dup(info.fd); if (wfptr->fd == -1) rb_sys_fail("dup()"); rb_update_max_fd(wfptr->fd); wfptr->pathv = rfptr->pathv; res = rb_ary_new2(3); rb_ary_store(res,0,(VALUE)rport); rb_ary_store(res,1,(VALUE)wport); rb_ary_store(res,2,PIDT2NUM(info.child_pid)); if (rb_block_given_p()) { rb_ensure(rb_yield, res, pty_detach_process, (VALUE)&info); return Qnil; } return res; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"PTY.getpty;F;7@;@;T;; ;0;@;{;IC; "Spawns the specified command on a newly allocated pty. You can also use the alias ::getpty. The command's controlling tty is set to the slave device of the pty and its standard input/output/error is redirected to the slave device. +command+ and +command_line+ are the full commands to run, given a String. Any additional +arguments+ will be passed to the command. === Return values In the non-block form this returns an array of size three, [r, w, pid]. In the block form these same values will be yielded to the block: +r+:: A readable IO that contains the command's standard output and standard error +w+:: A writable IO that is the command's standard input +pid+:: The process identifier for the command.;T;[ o;= ;>I" overload;F;?0;;;@0;:I"spawn(command_line);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"r;TI"w;TI"pid;T;$@g;![;"I"@yield [r, w, pid];T;#0;$@g;.F;Bi;C0;7[[I"command_line;T0;$@go;= ;>I" overload;F;?0;;;@0;:I"spawn(command_line);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@g;![;"I"@return [Array];T;#0;$@g;.F;Bi;C0;7[[I"command_line;T0;$@go;= ;>I" overload;F;?0;;;@0;:I"#spawn(command, arguments, ...);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"r;TI"w;TI"pid;T;$@g;![;"I"@yield [r, w, pid];T;#0;$@g;.F;Bi;C0;7[[I" command;T0[I"arguments;T0[I"...;T0;$@go;= ;>I" overload;F;?0;;;@0;:I"#spawn(command, arguments, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@g;![;"I"@return [Array];T;#0;$@g;.F;Bi;C0;7[[I" command;T0[I"arguments;T0[I"...;T0;$@g;![;"I"Spawns the specified command on a newly allocated pty. You can also use the alias ::getpty. The command's controlling tty is set to the slave device of the pty and its standard input/output/error is redirected to the slave device. +command+ and +command_line+ are the full commands to run, given a String. Any additional +arguments+ will be passed to the command. === Return values In the non-block form this returns an array of size three, [r, w, pid]. In the block form these same values will be yielded to the block: +r+:: A readable IO that contains the command's standard output and standard error +w+:: A writable IO that is the command's standard input +pid+:: The process identifier for the command. @overload spawn(command_line) @yield [r, w, pid] @overload spawn(command_line) @return [Array] @overload spawn(command, arguments, ...) @yield [r, w, pid] @overload spawn(command, arguments, ...) @return [Array];T;#0;$@g;.F;/o;0;1T;2i#;3i@;Bi;%@;9@e;:@f;;To;4;5F;6;;;;&I"PTY#spawn;F;7[[@90;[[@i?;T;;;0;[;{;IC; "Spawns the specified command on a newly allocated pty. You can also use the alias ::getpty. The command's controlling tty is set to the slave device of the pty and its standard input/output/error is redirected to the slave device. +command+ and +command_line+ are the full commands to run, given a String. Any additional +arguments+ will be passed to the command. === Return values In the non-block form this returns an array of size three, [r, w, pid]. In the block form these same values will be yielded to the block: +r+:: A readable IO that contains the command's standard output and standard error +w+:: A writable IO that is the command's standard input +pid+:: The process identifier for the command. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"spawn(command_line);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"r;TI"w;TI"pid;T;$@;![;"I"@yield [r, w, pid];T;#0;$@;.F;Bi;C0;7[[I"command_line;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"spawn(command_line);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I"command_line;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"#spawn(command, arguments, ...);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"r;TI"w;TI"pid;T;$@;![;"I"@yield [r, w, pid];T;#0;$@;.F;Bi;C0;7[[I" command;T0[I"arguments;T0[I"...;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"#spawn(command, arguments, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@;![;"I"@return [Array];T;#0;$@;.F;Bi;C0;7[[I" command;T0[I"arguments;T0[I"...;T0;$@;![;"I"Spawns the specified command on a newly allocated pty. You can also use the alias ::getpty. The command's controlling tty is set to the slave device of the pty and its standard input/output/error is redirected to the slave device. +command+ and +command_line+ are the full commands to run, given a String. Any additional +arguments+ will be passed to the command. === Return values In the non-block form this returns an array of size three, [r, w, pid]. In the block form these same values will be yielded to the block: +r+:: A readable IO that contains the command's standard output and standard error +w+:: A writable IO that is the command's standard input +pid+:: The process identifier for the command. @overload spawn(command_line) @yield [r, w, pid] @overload spawn(command_line) @return [Array] @overload spawn(command, arguments, ...) @yield [r, w, pid] @overload spawn(command, arguments, ...) @return [Array];T;#0;$@;.F;C0;%@;9I"static VALUE pty_getpty(int argc, VALUE *argv, VALUE self) { VALUE res; struct pty_info info; rb_io_t *wfptr,*rfptr; VALUE rport = rb_obj_alloc(rb_cFile); VALUE wport = rb_obj_alloc(rb_cFile); char SlaveName[DEVICELEN]; MakeOpenFile(rport, rfptr); MakeOpenFile(wport, wfptr); establishShell(argc, argv, &info, SlaveName); rfptr->mode = rb_io_modestr_fmode("r"); rfptr->fd = info.fd; rfptr->pathv = rb_obj_freeze(rb_str_new_cstr(SlaveName)); wfptr->mode = rb_io_modestr_fmode("w") | FMODE_SYNC; wfptr->fd = rb_cloexec_dup(info.fd); if (wfptr->fd == -1) rb_sys_fail("dup()"); rb_update_max_fd(wfptr->fd); wfptr->pathv = rfptr->pathv; res = rb_ary_new2(3); rb_ary_store(res,0,(VALUE)rport); rb_ary_store(res,1,(VALUE)wport); rb_ary_store(res,2,PIDT2NUM(info.child_pid)); if (rb_block_given_p()) { rb_ensure(rb_yield, res, pty_detach_process, (VALUE)&info); return Qnil; } return res; };T;:I"static VALUE;T;;To;4;5T;6;;;;&I"PTY.spawn;F;7@;@;T;;;0;@;{;IC; "Spawns the specified command on a newly allocated pty. You can also use the alias ::getpty. The command's controlling tty is set to the slave device of the pty and its standard input/output/error is redirected to the slave device. +command+ and +command_line+ are the full commands to run, given a String. Any additional +arguments+ will be passed to the command. === Return values In the non-block form this returns an array of size three, [r, w, pid]. In the block form these same values will be yielded to the block: +r+:: A readable IO that contains the command's standard output and standard error +w+:: A writable IO that is the command's standard input +pid+:: The process identifier for the command.;T;[ o;= ;>I" overload;F;?0;;;@0;:I"spawn(command_line);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"r;TI"w;TI"pid;T;$@ ;![;"I"@yield [r, w, pid];T;#0;$@ ;.F;Bi;C0;7[[I"command_line;T0;$@ o;= ;>I" overload;F;?0;;;@0;:I"spawn(command_line);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@ ;![;"I"@return [Array];T;#0;$@ ;.F;Bi;C0;7[[I"command_line;T0;$@ o;= ;>I" overload;F;?0;;;@0;:I"#spawn(command, arguments, ...);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"r;TI"w;TI"pid;T;$@ ;![;"I"@yield [r, w, pid];T;#0;$@ ;.F;Bi;C0;7[[I" command;T0[I"arguments;T0[I"...;T0;$@ o;= ;>I" overload;F;?0;;;@0;:I"#spawn(command, arguments, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@ ;![;"I"@return [Array];T;#0;$@ ;.F;Bi;C0;7[[I" command;T0[I"arguments;T0[I"...;T0;$@ ;![;"@;#0;$@ ;.F;/o;0;1T;2i#;3i@;Bi;%@;9@ ;:@ ;;To;4;5F;6;;;;&I"PTY.check;F;7[[@90;[[@i;T;;;0;[;{;IC; "Checks the status of the child process specified by +pid+. Returns +nil+ if the process is still alive. If the process is not alive, and +raise+ was true, a PTY::ChildExited exception will be raised. Otherwise it will return a Process::Status instance. +pid+:: The process id of the process to check +raise+:: If +true+ and the process identified by +pid+ is no longer alive a PTY::ChildExited is raised. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"check(pid, raise = false);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"Process::Status;TI"nil;T;$@\ ;![;"I"#@return [Process::Status, nil];T;#0;$@\ ;.F;Bi;C0;7[[I"pid;T0[I" raise;TI" false;T;$@\ o;= ;>I" overload;F;?0;;;@0;:I"check(pid, true);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;TI"raises PTY::ChildExited;T;$@\ ;![;"I"+@return [nil, raises PTY::ChildExited];T;#0;$@\ ;.F;Bi;C0;7[[I"pid;T0[I" true;T0;$@\ ;![;"I",Checks the status of the child process specified by +pid+. Returns +nil+ if the process is still alive. If the process is not alive, and +raise+ was true, a PTY::ChildExited exception will be raised. Otherwise it will return a Process::Status instance. +pid+:: The process id of the process to check +raise+:: If +true+ and the process identified by +pid+ is no longer alive a PTY::ChildExited is raised. @overload check(pid, raise = false) @return [Process::Status, nil] @overload check(pid, true) @return [nil, raises PTY::ChildExited];T;#0;$@\ ;.F;/o;0;1T;2i;3i;%@;9I"static VALUE pty_check(int argc, VALUE *argv, VALUE self) { VALUE pid, exc; rb_pid_t cpid; int status; const int flag = #ifdef WNOHANG WNOHANG| #endif #ifdef WUNTRACED WUNTRACED| #endif 0; rb_scan_args(argc, argv, "11", &pid, &exc); cpid = rb_waitpid(NUM2PIDT(pid), &status, flag); if (cpid == -1 || cpid == 0) return Qnil; if (!RTEST(exc)) return rb_last_status_get(); raise_from_check(cpid, status); UNREACHABLE_RETURN(Qnil); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" PTY.open;F;7[;[[@i;T;;;0;[;{;IC; "Allocates a pty (pseudo-terminal). In the block form, yields an array of two elements (master_io, slave_file) and the value of the block is returned from +open+. The IO and File are both closed after the block completes if they haven't been already closed. PTY.open {|master, slave| p master #=> # p slave #=> # p slave.path #=> "/dev/pts/1" } In the non-block form, returns a two element array, [master_io, slave_file]. master, slave = PTY.open # do something with master for IO, or the slave file The arguments in both forms are: +master_io+:: the master of the pty, as an IO. +slave_file+:: the slave of the pty, as a File. The path to the terminal device is available via +slave_file.path+ IO#raw! is usable to disable newline conversions: require 'io/console' PTY.open {|m, s| s.raw! # ... } ;T;[o;= ;>I" overload;F;?0;;;@0;:I" open;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@ ;![;"I"@return [Array];T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;;;@0;:I" open;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"(master_io, slave_file);T;$@ ;![;"I"%@yield [(master_io, slave_file)];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Allocates a pty (pseudo-terminal). In the block form, yields an array of two elements (master_io, slave_file) and the value of the block is returned from +open+. The IO and File are both closed after the block completes if they haven't been already closed. PTY.open {|master, slave| p master #=> # p slave #=> # p slave.path #=> "/dev/pts/1" } In the non-block form, returns a two element array, [master_io, slave_file]. master, slave = PTY.open # do something with master for IO, or the slave file The arguments in both forms are: +master_io+:: the master of the pty, as an IO. +slave_file+:: the slave of the pty, as a File. The path to the terminal device is available via +slave_file.path+ IO#raw! is usable to disable newline conversions: require 'io/console' PTY.open {|m, s| s.raw! # ... } @overload open @return [Array] @overload open @yield [(master_io, slave_file)];T;#0;$@ ;.F;/o;0;1T;2i;3i;%@;9I"static VALUE pty_open(VALUE klass) { int master_fd, slave_fd; char slavename[DEVICELEN]; VALUE master_io, slave_file; rb_io_t *master_fptr, *slave_fptr; VALUE assoc; getDevice(&master_fd, &slave_fd, slavename, 1); master_io = rb_obj_alloc(rb_cIO); MakeOpenFile(master_io, master_fptr); master_fptr->mode = FMODE_READWRITE | FMODE_SYNC | FMODE_DUPLEX; master_fptr->fd = master_fd; master_fptr->pathv = rb_obj_freeze(rb_sprintf("masterpty:%s", slavename)); slave_file = rb_obj_alloc(rb_cFile); MakeOpenFile(slave_file, slave_fptr); slave_fptr->mode = FMODE_READWRITE | FMODE_SYNC | FMODE_DUPLEX | FMODE_TTY; slave_fptr->fd = slave_fd; slave_fptr->pathv = rb_obj_freeze(rb_str_new_cstr(slavename)); assoc = rb_assoc_new(master_io, slave_file); if (rb_block_given_p()) { return rb_ensure(rb_yield, assoc, pty_close_pty, assoc); } return assoc; };T;:I"static VALUE;T;;To; ;IC;[o;4;5F;6;;;;&I"PTY::ChildExited#status;T;7[;[[@iW;T;;>;0;[;{;IC; "SReturns the exit status of the child for which PTY#check raised this exception ;T;[;![;"I"TReturns the exit status of the child for which PTY#check raised this exception ;T;#0;$@ ;.F;/o;0;1T;2iT;3iV;%@ ;9I"bstatic VALUE echild_status(VALUE self) { return rb_ivar_get(self, rb_intern("status")); };T;:I"static VALUE;T;;T; @ ; IC;[; @ ; IC;[; @ ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i[@i;T;:ChildExited;;;;;[;{;IC; "ZThrown when PTY::check is called for a pid that represents a process that has exited.;T;[;![;"I"\ Thrown when PTY::check is called for a pid that represents a process that has exited. ;T;#0;$@ ;.F;/o;0;1T;2i;3i;Bi;%o;( ;)0;*0;+0;:PTY;%@;-@;0;&I"PTY::ChildExited;T;'@[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@i;F;; ;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@;&I"PTY;F; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[;F;;;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%0;&@;@:StringScanner::Error@ :StringScanner#initialize@:"StringScanner#initialize_copy@:!StringScanner.must_C_version@:StringScanner#reset@:StringScanner#terminate@:StringScanner#clear@":StringScanner#string@0:StringScanner#string=@>:StringScanner#concat@X:StringScanner#<<@|:StringScanner#pos@:StringScanner#pos=@:StringScanner#charpos@:StringScanner#pointer@:StringScanner#pointer=@:StringScanner#scan@:StringScanner#skip@:StringScanner#match?@4:StringScanner#check@R:StringScanner#scan_full@l:StringScanner#scan_until@:StringScanner#skip_until@:StringScanner#exist?@:StringScanner#check_until@:StringScanner#search_full@:StringScanner#getch@:StringScanner#get_byte@):StringScanner#getbyte@7:StringScanner#peek@E:StringScanner#peep@_:StringScanner#unscan@o:%StringScanner#beginning_of_line?@}:StringScanner#eos?@:StringScanner#empty?@:StringScanner#rest?@:StringScanner#matched?@:StringScanner#matched@:StringScanner#matched_size@:StringScanner#[]@:StringScanner#pre_match@:StringScanner#post_match@:StringScanner#size@$:StringScanner#captures@::StringScanner#values_at@P:StringScanner#rest@r:StringScanner#rest_size@:StringScanner#restsize@:StringScanner#inspect@: StringScanner#fixed_anchor?@; @:Monitor#try_enter@:Monitor#enter@:Monitor#exit@:Monitor#synchronize@:Monitor#mon_locked?@ :Monitor#mon_check_owner@:Monitor#mon_owned?@(:Monitor#wait_for_cond@7;@Y:Syslog::Constants@[:Syslog::Option@n:Syslog::Facility@:Syslog::Level@:Syslog::Macros@:Syslog#open@:Syslog.open@:Syslog#reopen@$:Syslog.reopen@@:Syslog#open!@V:Syslog.open!@r:Syslog#opened?@:Syslog.opened?@:Syslog#ident@:Syslog.ident@:Syslog#options@:Syslog.options@:Syslog#facility@:Syslog.facility@:Syslog#log@:Syslog.log@:Syslog#close@%:Syslog.close@2:Syslog#mask@::Syslog.mask@G:Syslog#mask=@O:Syslog.mask=@h:Syslog.inspect@z:Syslog#instance@:Syslog.instance@:Syslog::Macros#LOG_MASK@:Syslog::Macros#LOG_UPTO@:Syslog::Macros.included@:Syslog::Constants.included@]:PTY::ChildExited@ ;"@;#@3;Z@H:Thread.new@J:Thread.start@Y:Thread.fork@:Thread.main@:Thread.current@:Thread.stop@:Thread.kill@:Thread.exit@:Thread.pass@+:Thread.list@F:Thread.abort_on_exception@a:Thread.abort_on_exception=@|:Thread.report_on_exception@: Thread.report_on_exception=@:Thread.ignore_deadlock@:Thread.ignore_deadlock=@:Thread.DEBUG@:Thread.DEBUG=@*:Thread.handle_interrupt@D:Thread.pending_interrupt?@a:Thread#pending_interrupt?@~:Thread#initialize@:Thread#raise@:Thread#join@:Thread#value@:Thread#kill@:Thread#terminate@8:Thread#exit@]:Thread#run@:Thread#wakeup@:Thread#[]@:Thread#[]=@:Thread#fetch@:Thread#key?@0:Thread#keys@O:Thread#priority@j:Thread#priority=@:Thread#status@:Thread#thread_variable_get@:Thread#thread_variable_set@:Thread#thread_variables@:Thread#thread_variable?@ :Thread#alive?@4 :Thread#stop?@O :Thread#abort_on_exception@j :Thread#abort_on_exception=@ :Thread#report_on_exception@ : Thread#report_on_exception=@ :Thread#group@ :Thread#backtrace@ :Thread#backtrace_locations@!:Thread#name@/!:Thread#name=@J!:Thread#native_thread_id@i!:Thread#to_s@!:Thread#inspect@!:ThreadGroup#list@:ThreadGroup#enclose@:ThreadGroup#enclosed?@:ThreadGroup#add@:ThreadGroup::Default@;@&:)ObjectSpace#trace_object_allocations@&:)ObjectSpace.trace_object_allocations@&:/ObjectSpace#trace_object_allocations_start@&:/ObjectSpace.trace_object_allocations_start@&:.ObjectSpace#trace_object_allocations_stop@&:.ObjectSpace.trace_object_allocations_stop@&:/ObjectSpace#trace_object_allocations_clear@':/ObjectSpace.trace_object_allocations_clear@':5ObjectSpace#trace_object_allocations_debug_start@+':5ObjectSpace.trace_object_allocations_debug_start@8':&ObjectSpace#allocation_sourcefile@>':&ObjectSpace.allocation_sourcefile@\':&ObjectSpace#allocation_sourceline@s':&ObjectSpace.allocation_sourceline@':&ObjectSpace#allocation_class_path@':&ObjectSpace.allocation_class_path@':%ObjectSpace#allocation_method_id@':%ObjectSpace.allocation_method_id@':&ObjectSpace#allocation_generation@(:&ObjectSpace.allocation_generation@1(:ObjectSpace#memsize_of@I(:ObjectSpace.memsize_of@h(:ObjectSpace#memsize_of_all@(:ObjectSpace.memsize_of_all@(:#ObjectSpace#count_objects_size@(:#ObjectSpace.count_objects_size@(:ObjectSpace#count_symbols@(:ObjectSpace.count_symbols@):ObjectSpace#count_nodes@):ObjectSpace.count_nodes@8):$ObjectSpace#count_tdata_objects@O):$ObjectSpace.count_tdata_objects@l):$ObjectSpace#count_imemo_objects@):$ObjectSpace.count_imemo_objects@):'ObjectSpace#reachable_objects_from@):'ObjectSpace.reachable_objects_from@):,ObjectSpace#reachable_objects_from_root@):,ObjectSpace.reachable_objects_from_root@*:"ObjectSpace#internal_class_of@*:"ObjectSpace.internal_class_of@<*:"ObjectSpace#internal_super_of@T*:"ObjectSpace.internal_super_of@s*:'ObjectSpace::InternalObjectWrapper@*:,ObjectSpace::InternalObjectWrapper#type@*:/ObjectSpace::InternalObjectWrapper#inspect@*::ObjectSpace::InternalObjectWrapper#internal_object_id@*;@h:Kernel#raise@j:Kernel#fail@:Kernel#global_variables@ :Kernel#__method__@0 :Kernel#__callee__@F :Kernel#__dir__@\ ; @A7:Module#include@C7:Module#prepend@_7:Module#append_features@{7:Module#extend_object@7:Module#prepend_features@7:Module#refine@7:Module#using@7:Module.used_modules@8:Refinement#import_methods@E:ObjectSpace#_dump@*:ObjectSpace._dump@*:ObjectSpace#_dump_all@*:ObjectSpace._dump_all@*:Ractor::ClosedError@H;@C: NKF#nkf@C: NKF.nkf@(C:NKF#guess@AC:NKF.guess@_C:NKF::AUTO@vC:NKF::NOCONV@C:NKF::UNKNOWN@C:NKF::BINARY@C:NKF::ASCII@C: NKF::JIS@C: NKF::EUC@C:NKF::SJIS@C:NKF::UTF8@C:NKF::UTF16@C:NKF::UTF32@C:NKF::VERSION@C:NKF::NKF_VERSION@C:NKF::NKF_RELEASE_DATE@C;-@D:Digest::Instance@D:Digest::Class@?F:Digest#bubblebabble@F:Digest.bubblebabble@F:Digest::Class.bubblebabble@AF:"Digest::Instance#bubblebabble@D:Digest::MD5@F;@:Object#respond_to?@:Object#respond_to_missing?@:Module#remove_method@#8:Module#undef_method@P8:Module#alias_method@}8:Module#public@8:Module#protected@8:Module#private@+9:Module#module_function@s9:Module#ruby2_keywords@9:Module#method_defined?@9:"Module#public_method_defined?@9:#Module#private_method_defined?@2::%Module#protected_method_defined?@e::Module#public_class_method@:: Module#private_class_method@:;O@:Process::Status@:Process::Sys@:Process::UID@:Process::GID@:Kernel#exec@w :Kernel#fork@ :Kernel#exit!@ :Kernel#system@ :Kernel#spawn@ :Kernel#sleep@$ :Kernel#exit@B :Kernel#abort@u :Process::WNOHANG@:Process::WUNTRACED@:Process.exec@:Process.fork@:Process.spawn@E:Process.exit!@g:Process.exit@:Process.abort@:Process.last_status@߳:Process._fork@:Process#kill@:Process.kill@::Process#wait@U:Process.wait@:Process#wait2@Դ:Process.wait2@:Process#waitpid@6:Process.waitpid@z:Process#waitpid2@:Process.waitpid2@:Process#waitall@:Process.waitall@/:Process#detach@D:Process.detach@]:Process::Waiter@o:Process::Waiter#pid@q;D@:Process::Status#==@(:Process::Status#&@G:Process::Status#>>@f:Process::Status#to_i@:Process::Status#to_s@:Process::Status#inspect@:Process::Status#pid@ֱ:Process::Status#stopped?@:Process::Status#stopsig@ :Process::Status#signaled?@(:Process::Status#termsig@C:Process::Status#exited?@_:Process::Status#exitstatus@z:Process::Status#success?@:Process::Status#coredump?@:Process#pid@:Process.pid@:Process#ppid@:Process.ppid@ն:Process#getpgrp@:Process.getpgrp@:Process#setpgrp@:Process.setpgrp@3:Process#getpgid@H:Process.getpgid@f:Process#setpgid@}:Process.setpgid@:Process#getsid@:Process.getsid@:Process#setsid@:Process.setsid@ :Process#getpriority@5:Process.getpriority@W:Process#setpriority@p:Process.setpriority@:Process::PRIO_PROCESS@:Process::PRIO_PGRP@:Process::PRIO_USER@ɸ:Process#getrlimit@ո:Process.getrlimit@:Process#setrlimit@ :Process.setrlimit@<:Process::RLIM_SAVED_MAX@h:Process::RLIM_INFINITY@t:Process::RLIM_SAVED_CUR@:Process::RLIMIT_AS@:Process::RLIMIT_CORE@:Process::RLIMIT_CPU@:Process::RLIMIT_DATA@:Process::RLIMIT_FSIZE@:Process::RLIMIT_MEMLOCK@ȹ:Process::RLIMIT_MSGQUEUE@Թ:Process::RLIMIT_NICE@:Process::RLIMIT_NOFILE@:Process::RLIMIT_NPROC@:Process::RLIMIT_RSS@:Process::RLIMIT_RTPRIO@:Process::RLIMIT_RTTIME@:Process::RLIMIT_SBSIZE@(:Process::RLIMIT_SIGPENDING@4:Process::RLIMIT_STACK@@:Process#uid@L:Process.uid@:Process#uid=@:Process.uid=@ͺ:Process#gid@:Process.gid@:Process#gid=@G:Process.gid=@e:Process#euid@|:Process.euid@:Process#euid=@߻:Process.euid=@:Process#egid@ :Process.egid@>:Process#egid=@m:Process.egid=@w:Process#initgroups@}:Process.initgroups@:Process#groups@:Process.groups@Ҽ:Process#groups=@:Process.groups=@:Process#maxgroups@:Process.maxgroups@6:Process#maxgroups=@K:Process.maxgroups=@i:Process#daemon@:Process.daemon@:Process#times@ֽ:Process.times@:Process::CLOCK_REALTIME@:Process::CLOCK_MONOTONIC@:&Process::CLOCK_PROCESS_CPUTIME_ID@:%Process::CLOCK_THREAD_CPUTIME_ID@,:Process::CLOCK_VIRTUAL@8:Process::CLOCK_PROF@D:!Process::CLOCK_REALTIME_FAST@P:$Process::CLOCK_REALTIME_PRECISE@\:#Process::CLOCK_REALTIME_COARSE@h:"Process::CLOCK_REALTIME_ALARM@t:"Process::CLOCK_MONOTONIC_FAST@:%Process::CLOCK_MONOTONIC_PRECISE@:!Process::CLOCK_MONOTONIC_RAW@:(Process::CLOCK_MONOTONIC_RAW_APPROX@:$Process::CLOCK_MONOTONIC_COARSE@:Process::CLOCK_BOOTTIME@:"Process::CLOCK_BOOTTIME_ALARM@Ⱦ:Process::CLOCK_UPTIME@Ծ:Process::CLOCK_UPTIME_FAST@:"Process::CLOCK_UPTIME_PRECISE@:Process::CLOCK_UPTIME_RAW@:%Process::CLOCK_UPTIME_RAW_APPROX@:Process::CLOCK_SECOND@:Process::CLOCK_TAI@:Process#clock_gettime@(:Process.clock_gettime@E:Process#clock_getres@\:Process.clock_getres@y:Process::UID#rid@;{@ƿ:Process::GID#rid@;~@:Process::UID#eid@;@(:Process::GID#eid@;@P:"Process::UID#change_privilege@V;@t:"Process::GID#change_privilege@~;@:!Process::UID#grant_privilege@;@:!Process::GID#grant_privilege@;@:Process::UID#re_exchange@;@:Process::GID#re_exchange@;@":"Process::UID#re_exchangeable?@ ;@':"Process::GID#re_exchangeable?@7;@Q: Process::UID#sid_available?@<;@V: Process::GID#sid_available?@f;@:Process::UID#switch@k:Process::UID.switch@x:Process::GID#switch@:Process::GID.switch@:Process::UID#from_name@~;@:Process::GID#from_name@;@:Process::Sys#getuid@;|@:Process::Sys#geteuid@F;@z:Process::Sys#getgid@;@:Process::Sys#getegid@ :Process::Sys.getegid@>:Process::Sys#setuid@l;@:Process::Sys#setgid@;@:Process::Sys#setruid@;@:Process::Sys#setrgid@ ;@):Process::Sys#seteuid@@;@^:Process::Sys#setegid@u;@:Process::Sys#setreuid@;@:Process::Sys#setregid@;@:Process::Sys#setresuid@ ;@F:Process::Sys#setresgid@a;@:Process::Sys#issetugid@;@;@M;@q;@;+@~;@;@C:BasicObject#initialize@:BasicObject#==@:BasicObject#equal?@):BasicObject#!@e:BasicObject#!=@:'BasicObject#singleton_method_added@:)BasicObject#singleton_method_removed@:+BasicObject#singleton_method_undefined@:Class#inherited@:Module#included@::Module#extended@;:Module#prepended@;:Module#method_added@;:Module#method_removed@&;:Module#method_undefined@1;:Object#nil?@:Object#===@5:Object#=~@>:Object#!~@]:Object#eql?@|:Object#hash@;@j: Hash.[]@l:Hash.try_convert@:Hash#initialize@:Hash#initialize_copy@:Hash#rehash@:Hash#to_hash@#:Hash#to_h@>:Hash#to_a@g:Hash#inspect@}:Hash#to_s@:Hash#to_proc@: Hash#==@: Hash#[]@:Hash#hash@:Hash#eql?@ :Hash#fetch@): Hash#[]=@l:Hash#store@u:Hash#default@~:Hash#default=@:Hash#default_proc@:Hash#default_proc=@: Hash#key@:Hash#size@":Hash#length@J:Hash#empty?@q:Hash#each_value@:Hash#each_key@:Hash#each_pair@:Hash#each@ :Hash#transform_keys@c:Hash#transform_keys!@:Hash#transform_values@:Hash#transform_values!@:Hash#keys@7:Hash#values@M:Hash#values_at@c:Hash#fetch_values@|:Hash#shift@:Hash#delete@:Hash#delete_if@:Hash#keep_if@:Hash#select@D:Hash#select!@h:Hash#filter@:Hash#filter!@:Hash#reject@:Hash#reject!@:Hash#slice@,:Hash#except@E:Hash#clear@c:Hash#invert@~:Hash#update@:Hash#replace@:Hash#merge!@:Hash#merge@3:Hash#assoc@e:Hash#rassoc@:Hash#flatten@:Hash#compact@:Hash#compact!@:Hash#include?@:Hash#member?@B:Hash#has_key?@:Hash#has_value?@:Hash#key?@:Hash#value?@Q:Hash#compare_by_identity@~:Hash#compare_by_identity?@:Hash#any?@: Hash#dig@: Hash#<=@: Hash#<@1: Hash#>=@P: Hash#>@o:Hash#deconstruct_keys@:Hash.ruby2_keywords_hash?@:Hash.ruby2_keywords_hash@; @fT:Object#<=>@:Object#singleton_class@:Object#dup@:Object#itself@+:Object#initialize_copy@F:Object#initialize_dup@V:Object#initialize_clone@f:Object#taint@u:Object#tainted?@:Object#untaint@:Object#untrust@:Object#untrusted?@:Object#trust@:Object#freeze@:Object#to_s@2:Object#inspect@M:Object#methods@h:Object#singleton_methods@:Object#protected_methods@:Object#private_methods@:Object#public_methods@:Object#instance_variables@:!Object#instance_variable_get@ :!Object#instance_variable_set@N:&Object#instance_variable_defined?@:$Object#remove_instance_variable@:Object#instance_of?@:Object#kind_of?@:Object#is_a?@%:Kernel#sprintf@ :Kernel#format@ :Kernel#Integer@ :Kernel#String@' :Kernel#Array@F :Kernel#Hash@e :NilClass#to_s@O:NilClass#to_a@e:NilClass#to_h@s:NilClass#inspect@:NilClass#=~@:NilClass#&@:NilClass#|@:NilClass#^@:NilClass#===@:NilClass#nil?@:Module#freeze@<;:Module#===@R;:Module#==@q;:Module#<=>@;: Module#<@;:Module#<=@;: Module#>@<:Module#>=@2<:Module#initialize_copy@S<:Module#to_s@c<:Module#inspect@{<:Module#included_modules@<:Module#include?@<:Module#name@<:Module#ancestors@<:Module#attr@<:Module#attr_reader@6=:Module#attr_writer@=:Module#attr_accessor@=:Module#initialize@=:Module#initialize_clone@>:Module#instance_methods@>:#Module#public_instance_methods@<>:&Module#protected_instance_methods@[>:$Module#private_instance_methods@z>:Module#constants@>:Module#const_get@>:Module#const_set@>:Module#const_defined?@?:!Module#const_source_location@R?:Module#remove_const@?:Module#const_missing@?:Module#class_variables@?:!Module#remove_class_variable@?:Module#class_variable_get@@:Module#class_variable_set@1@:#Module#class_variable_defined?@e@:Module#public_constant@@:Module#private_constant@@:Module#deprecate_constant@@:Module#singleton_class?@@:Class#allocate@:Class#new@:Class#initialize@:Class#superclass@:Class#subclasses@:TrueClass#to_s@s:TrueClass#inspect@:TrueClass#&@:TrueClass#|@:TrueClass#^@:TrueClass#===@:FalseClass#to_s@:FalseClass#inspect@:FalseClass#&@$:FalseClass#|@Q:FalseClass#^@Z:FalseClass#===@c:Math::DomainError@":Digest::SHA1@G:Digest::RMD160@G:Digest::Base@F:Digest#hexencode@G:Digest.hexencode@G:Digest::Instance#update@*D:Digest::Instance#<<@OD:Digest::Instance#finish@rD:Digest::Instance#reset@D:#Digest::Instance#digest_length@D:"Digest::Instance#block_length@D:Digest::Instance#==@D:Digest::Instance#inspect@E:Digest::Instance#new@ E:Digest::Instance#digest@6E:Digest::Instance#digest!@aE:Digest::Instance#hexdigest@|E: Digest::Instance#hexdigest!@E:Digest::Instance#to_s@E:Digest::Instance#length@E:Digest::Instance#size@F:Digest::Class#initialize@PF;)@^F;*@yF:!Digest::Base#initialize_copy@F:Digest::Base#reset@F:Digest::Base#update@F:Digest::Base#<<@!G:Digest::Base#finish@DG:Digest::Base#digest_length@RG:Digest::Base#block_length@mG;@: Array.[]@:Array.try_convert@:Array#initialize@:Array#initialize_copy@d:Array#inspect@:Array#to_s@:Array#to_a@:Array#to_h@:Array#to_ary@: Array#==@:Array#eql?@:Array#hash@8: Array#[]@S:Array#[]=@: Array#at@$:Array#fetch@C:Array#first@w:Array#last@:Array#concat@:Array#union@:Array#difference@:Array#intersection@:Array#intersect?@.: Array#<<@M:Array#push@l:Array#append@:Array#pop@:Array#shift@:Array#unshift@:Array#prepend@:Array#insert@:Array#each@&:Array#each_index@S:Array#reverse_each@:Array#length@:Array#size@:Array#empty?@:Array#find_index@:Array#index@7:Array#rindex@p:Array#join@:Array#reverse@:Array#reverse!@:Array#rotate@:Array#rotate!@:Array#sort@I:Array#sort!@m:Array#sort_by!@:Array#collect@:Array#collect!@:Array#map@:Array#map!@0:Array#select@W:Array#select!@z:Array#filter@:Array#filter!@:Array#keep_if@:Array#values_at@:Array#delete@.:Array#delete_at@W:Array#delete_if@v:Array#reject@:Array#reject!@:Array#zip@:Array#transpose@:Array#replace@2:Array#clear@P:Array#fill@k:Array#include?@:Array#<=>@-:Array#slice@N:Array#slice!@:Array#assoc@:Array#rassoc@>: Array#+@]: Array#*@w: Array#-@: Array#&@: Array#|@:Array#max@:Array#min@(:Array#minmax@g:Array#uniq@:Array#uniq!@:Array#compact@:Array#compact!@:Array#flatten@:Array#flatten!@::Array#count@g:Array#cycle@:Array#permutation@:Array#combination@2:Array#repeated_permutation@`:Array#repeated_combination@:Array#product@:Array#take@:Array#take_while@:Array#drop@&:Array#drop_while@@:Array#bsearch@c:Array#bsearch_index@:Array#any?@:Array#all?@:Array#none?@.:Array#one?@k:Array#dig@:Array#sum@:Array#deconstruct@;@:Date::Error@:Date::MONTHNAMES@C:Date::ABBR_MONTHNAMES@O:Date::DAYNAMES@[:Date::ABBR_DAYNAMES@g:Date::ITALY@s:Date::ENGLAND@:Date::JULIAN@:Date::GREGORIAN@:Date.valid_jd?@:Date.valid_ordinal?@:Date.valid_civil?@:Date.valid_date?@:Date.valid_commercial?@P:Date.julian_leap?@s:Date.gregorian_leap?@:Date.leap?@:Date.new!@: Date.jd@:Date.ordinal@:Date.civil@.:Date.commercial@S:Date.weeknum@m:Date.nth_kday@z:Date.today@:Date._strptime@:Date.strptime@:Date._parse@:Date.parse@:Date._iso8601@:Date.iso8601@::Date._rfc3339@W:Date.rfc3339@x:Date._xmlschema@:Date.xmlschema@:Date._rfc2822@:Date._rfc822@:Date.rfc2822@8:Date.rfc822@c:Date._httpdate@:Date.httpdate@:Date._jisx0301@:Date.jisx0301@:Date#initialize@ :Date#initialize_copy@:Date#fill@&: Date#ajd@2:Date#amjd@H: Date#jd@^: Date#mjd@y: Date#ld@:Date#year@:Date#yday@: Date#mon@:Date#month@ :Date#mday@4: Date#day@\:Date#day_fraction@:Date#cwyear@:Date#cweek@:Date#cwday@:Date#wnum0@:Date#wnum1@:Date#wday@:Date#sunday?@:Date#monday?@8:Date#tuesday?@S:Date#wednesday?@n:Date#thursday?@:Date#friday?@:Date#saturday?@:Date#nth_kday?@:Date#hour@: Date#min@:Date#minute@: Date#sec@:Date#second@:Date#julian?@):Date#gregorian?@D:Date#leap?@_:Date#start@z:Date#new_start@:Date#italy@:Date#england@:Date#julian@:Date#gregorian@: Date#+@: Date#-@!:Date#next_day@;:Date#prev_day@U:Date#next@o:Date#succ@: Date#>>@: Date#<<@:Date#next_month@:Date#prev_month@:Date#next_year@:Date#prev_year@,:Date#step@F:Date#upto@u:Date#downto@: Date#<=>@: Date#===@:Date#eql?@:Date#hash@%:Date#to_s@3:Date#inspect_raw@N:Date#inspect@Z:Date#strftime@u:Date#asctime@:Date#ctime@:Date#iso8601@:Date#xmlschema@ :Date#rfc3339@2:Date#rfc2822@M:Date#rfc822@u:Date#httpdate@:Date#jisx0301@:Date#marshal_dump_old@:Date#marshal_dump@:Date#marshal_load@:Date._load@;@:DateTime.jd@:DateTime.ordinal@:DateTime.civil@:DateTime.new@:DateTime.commercial@=:DateTime.weeknum@W:DateTime.nth_kday@d:DateTime.now@q:DateTime._strptime@:DateTime.strptime@:DateTime.parse@:DateTime.iso8601@:DateTime.rfc3339@:DateTime.xmlschema@:DateTime.rfc2822@8:DateTime.rfc822@c:DateTime.httpdate@:DateTime.jisx0301@:DateTime#hour@:DateTime#min@:DateTime#minute@:DateTime#sec@.:DateTime#second@V:DateTime#sec_fraction@}:DateTime#second_fraction@:DateTime#offset@:DateTime#zone@:DateTime#new_offset@:DateTime#to_s@:DateTime#strftime@:DateTime#iso8601@=:DateTime#xmlschema@l:DateTime#rfc3339@:DateTime#jisx0301@;@3:Time#to_time@5:Time#to_date@P:Time#to_datetime@f:Date#to_time@ :Date#to_date@':Date#to_datetime@B:DateTime#to_time@:DateTime#to_date@:DateTime#to_datetime@ :Date.test_civil@X:Date.test_ordinal@f:Date.test_commercial@r:Date.test_weeknum@~:Date.test_nth_kday@:Date.test_unit_conv@:Date.test_all@;@:RubyVM.each_builtin@;@F;@[;@:Kernel#syscall@ :Kernel#open@ :Kernel#printf@ :Kernel#print@ :Kernel#putc@$ :Kernel#puts@C :Kernel#gets@c :Kernel#readline@ :Kernel#select@ :Kernel#readlines@ : Kernel#`@B : Kernel#p@_ :Object#display@N;@kL:IO::READABLE@mL:IO::WRITABLE@wL:IO::PRIORITY@L:IO::WaitReadable@ZL:IO::WaitWritable@L:IO::EAGAINWaitReadable@L:IO::EAGAINWaitWritable@L: IO::EWOULDBLOCKWaitReadable@L: IO::EWOULDBLOCKWaitWritable@L: IO::EINPROGRESSWaitReadable@L: IO::EINPROGRESSWaitWritable@L;N@f:File.open@f: IO.new@ M: IO.open@M:IO.sysopen@'M:IO.for_fd@GM: IO.popen@gM:IO.foreach@M:IO.readlines@LN: IO.read@N:IO.binread@N: IO.write@)O:IO.binwrite@|O:IO.select@O: IO.pipe@O:IO.try_convert@EP:IO.copy_stream@dP:IO#initialize@P:IO#initialize_copy@P:IO#reopen@P: IO#print@P: IO#putc@'Q: IO#puts@FQ:IO#printf@fQ: IO#each@Q:IO#each_line@Q:IO#each_byte@3R:IO#each_char@[R:IO#each_codepoint@R:IO#syswrite@R:IO#sysread@R: IO#pread@R:IO#pwrite@S:IO#fileno@+S: IO#to_i@CS: IO#to_io@NS: IO#fsync@iS:IO#fdatasync@S: IO#sync@S: IO#sync=@S:IO#lineno@S:IO#lineno=@S:IO#readlines@T:IO#readpartial@AT: IO#read@kT: IO#write@T: IO#gets@T:IO#readline@U: IO#getc@BU:IO#getbyte@^U:IO#readchar@zU:IO#readbyte@U:IO#ungetbyte@U:IO#ungetc@U: IO#<<@ V: IO#flush@+V: IO#tell@FV: IO#seek@aV:IO::SEEK_SET@V:IO::SEEK_CUR@V:IO::SEEK_END@V:IO::SEEK_DATA@V:IO::SEEK_HOLE@V:IO#rewind@V: IO#pos@V: IO#pos=@V: IO#eof@ W: IO#eof?@(W:IO#close_on_exec?@BW:IO#close_on_exec=@]W: IO#close@|W:IO#closed?@W:IO#close_read@W:IO#close_write@W:IO#isatty@W: IO#tty?@X:IO#binmode@7X:IO#binmode?@RX:IO#sysseek@mX:IO#advise@X: IO#ioctl@X: IO#fcntl@X: IO#pid@X:IO#inspect@Y:IO#external_encoding@)Y:IO#internal_encoding@DY:IO#set_encoding@_Y:IO#set_encoding_by_bom@Y:IO#autoclose?@Y:IO#autoclose=@Y;@o;@{;@:ARGF#initializeo;4;5F;6;;;;&I"ARGF#initialize;F;7[[I" argv;T0;[[@TiF#;T;;D;0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@ ;.F;/o;0;1T;2iE#;3iE#;%o; ;IC;[9@ o;4;5F;6;;;;&I"ARGF#initialize_copy;F;7[[I" orig;T0;[[@TiP#;T;;];0;[;{;IC; " :nodoc: ;T;[;![;"I" :nodoc:;T;#0;$@ ;.F;/o;0;1T;2iO#;3iO#;%@ ;9I"static VALUE argf_initialize_copy(VALUE argf, VALUE orig) { if (!OBJ_INIT_COPY(argf, orig)) return argf; ARGF = argf_of(orig); ARGF.argv = rb_obj_dup(ARGF.argv); return argf; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#to_s;F;7[;[[@Ti.4;T;;G;0;[;{;IC; "Returns "ARGF". ;T;[o;= ;>I" overload;F;?0;;G;@0;:I" to_s;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"8Returns "ARGF". @overload to_s @return [String];T;#0;$o;4;5F;6;;;;&I"ARGF#inspect;F;7[;[[@Ti:8;F;;J;;;[;{;@ ;%@ ;9I"Kstatic VALUE argf_to_s(VALUE argf) { return rb_str_new2("ARGF"); };T;:I"static VALUE;T;.F;/o;0;1T;2i(4;3i,4;%@ ;9I"Kstatic VALUE argf_to_s(VALUE argf) { return rb_str_new2("ARGF"); };T;:@7 ;;T@/ o;4;5F;6;;;;&I"ARGF#argv;F;7[;[[@Ti4;T;: argv;0;[;{;IC; "Returns the +ARGV+ array, which contains the arguments passed to your script, one per element. For example: $ ruby argf.rb -v glark.txt ARGF.argv #=> ["-v", "glark.txt"] ;T;[o;= ;>I" overload;F;?0;;;@0;:I" argv;T;IC; ";T;[;![;"I";T;#0;$@: ;.F;Bi;C0;7[;$@: ;![;"I"Returns the +ARGV+ array, which contains the arguments passed to your script, one per element. For example: $ ruby argf.rb -v glark.txt ARGF.argv #=> ["-v", "glark.txt"] @overload argv;T;#0;$@: ;.F;/o;0;1T;2iy4;3i4;%@ ;9I"Astatic VALUE argf_argv(VALUE argf) { return ARGF.argv; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#fileno;F;7[;[[@Ti,1;T;;;0;[;{;IC; "Returns an integer representing the numeric file descriptor for the current file. Raises an +ArgumentError+ if there isn't a current file. ARGF.fileno #=> 3 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" fileno;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@P ;![;"I"@return [Integer];T;#0;$@P ;.F;Bi;C0;7[;$@P o;= ;>I" overload;F;?0;;;@0;:I" to_i;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@P ;![;"I"@return [Integer];T;#0;$@P ;.F;Bi;C0;7[;$@P ;![;"I"Returns an integer representing the numeric file descriptor for the current file. Raises an +ArgumentError+ if there isn't a current file. ARGF.fileno #=> 3 @overload fileno @return [Integer] @overload to_i @return [Integer];T;#0;$@P ;.F;/o;0;1T;2i"1;3i+1;%@ ;9I"static VALUE argf_fileno(VALUE argf) { if (!next_argv()) { rb_raise(rb_eArgError, "no stream"); } ARGF_FORWARD(0, 0); return rb_io_fileno(ARGF.current_file); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#to_i;F;7[;[[@Ti,1;T;;;0;[;{;IC; "Returns an integer representing the numeric file descriptor for the current file. Raises an +ArgumentError+ if there isn't a current file. ARGF.fileno #=> 3 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" fileno;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@x ;![;"I"@return [Integer];T;#0;$@x ;.F;Bi;C0;7[;$@x o;= ;>I" overload;F;?0;;;@0;:I" to_i;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@x ;![;"I"@return [Integer];T;#0;$@x ;.F;Bi;C0;7[;$@x ;![;"@t ;#0;$@x ;.F;/o;0;1T;2i"1;3i+1;%@ ;9I"static VALUE argf_fileno(VALUE argf) { if (!next_argv()) { rb_raise(rb_eArgError, "no stream"); } ARGF_FORWARD(0, 0); return rb_io_fileno(ARGF.current_file); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#to_io;F;7[;[[@TiB1;T;;;0;[;{;IC; "Returns an +IO+ object representing the current file. This will be a +File+ object unless the current file is a stream such as STDIN. For example: ARGF.to_io #=> # ARGF.to_io #=> #> ;T;[o;= ;>I" overload;F;?0;;;@0;:I" to_io;T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Returns an +IO+ object representing the current file. This will be a +File+ object unless the current file is a stream such as STDIN. For example: ARGF.to_io #=> # ARGF.to_io #=> #> @overload to_io;T;#0;$@ ;.F;/o;0;1T;2i61;3i?1;%@ ;9I"sstatic VALUE argf_to_io(VALUE argf) { next_argv(); ARGF_FORWARD(0, 0); return ARGF.current_file; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#to_write_io;F;7[;[[@Ti4;T;:to_write_io;0;[;{;IC; "OReturns IO instance tied to _ARGF_ for writing if inplace mode is enabled. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"to_write_io;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"IO;T;$@ ;![;"I"@return [IO];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"vReturns IO instance tied to _ARGF_ for writing if inplace mode is enabled. @overload to_write_io @return [IO];T;#0;$@ ;.F;/o;0;1T;2i4;3i4;%@ ;9I"static VALUE argf_write_io(VALUE argf) { if (!RTEST(ARGF.current_file)) { rb_raise(rb_eIOError, "not opened for writing"); } return GetWriteIO(ARGF.current_file); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#each;F;7[[@90;[[@Ti#3;T;;;0;[;{;IC; "ARGF.each_line(sep=$/) {|line| block } -> ARGF ARGF.each_line(sep=$/, limit) {|line| block } -> ARGF ARGF.each_line(...) -> an_enumerator Returns an enumerator which iterates over each line (separated by _sep_, which defaults to your platform's newline character) of each file in +ARGV+. If a block is supplied, each line in turn will be yielded to the block, otherwise an enumerator is returned. The optional _limit_ argument is an +Integer+ specifying the maximum length of each line; longer lines will be split according to this limit. This method allows you to treat the files supplied on the command line as a single file consisting of the concatenation of each named file. After the last line of the first file has been returned, the first line of the second file is returned. The +ARGF.filename+ and +ARGF.lineno+ methods can be used to determine the filename of the current line and line number of the whole input, respectively. For example, the following code prints out each line of each named file prefixed with its line number, displaying the filename once per file: ARGF.each_line do |line| puts ARGF.filename if ARGF.file.lineno == 1 puts "#{ARGF.file.lineno}: #{line}" end While the following code prints only the first file's name at first, and the contents with line number counted through all named files. ARGF.each_line do |line| puts ARGF.filename if ARGF.lineno == 1 puts "#{ARGF.lineno}: #{line}" end ;T;[o;= ;>I" overload;F;?0;;;@0;:I"each(sep=$/);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@ ;![;"I"@yield [line];T;#0;$@ ;.F;Bi;C0;7[[I"sep;TI"$/;T;$@ o;= ;>I" overload;F;?0;;;@0;:I"each(sep=$/, limit);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@ ;![;"I"@yield [line];T;#0;$@ ;.F;Bi;C0;7[[I"sep;TI"$/;T[I" limit;T0;$@ o;= ;>I" overload;F;?0;;;@0;:I"each(...);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I"...;T0;$@ ;![;"I"L ARGF.each_line(sep=$/) {|line| block } -> ARGF ARGF.each_line(sep=$/, limit) {|line| block } -> ARGF ARGF.each_line(...) -> an_enumerator Returns an enumerator which iterates over each line (separated by _sep_, which defaults to your platform's newline character) of each file in +ARGV+. If a block is supplied, each line in turn will be yielded to the block, otherwise an enumerator is returned. The optional _limit_ argument is an +Integer+ specifying the maximum length of each line; longer lines will be split according to this limit. This method allows you to treat the files supplied on the command line as a single file consisting of the concatenation of each named file. After the last line of the first file has been returned, the first line of the second file is returned. The +ARGF.filename+ and +ARGF.lineno+ methods can be used to determine the filename of the current line and line number of the whole input, respectively. For example, the following code prints out each line of each named file prefixed with its line number, displaying the filename once per file: ARGF.each_line do |line| puts ARGF.filename if ARGF.file.lineno == 1 puts "#{ARGF.file.lineno}: #{line}" end While the following code prints only the first file's name at first, and the contents with line number counted through all named files. ARGF.each_line do |line| puts ARGF.filename if ARGF.lineno == 1 puts "#{ARGF.lineno}: #{line}" end @overload each(sep=$/) @yield [line] @overload each(sep=$/, limit) @yield [line] @overload each(...);T;#0;$@ ;.F;/o;0;1T;2i2;3i"3;%@ ;9I"static VALUE argf_each_line(int argc, VALUE *argv, VALUE argf) { RETURN_ENUMERATOR(argf, argc, argv); FOREACH_ARGF() { argf_block_call_line(rb_intern("each_line"), argc, argv, argf); } return argf; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#each_line;F;7[[@90;[[@Ti#3;T;;x;0;[;{;IC; "ARGF.each_line(sep=$/) {|line| block } -> ARGF ARGF.each_line(sep=$/, limit) {|line| block } -> ARGF ARGF.each_line(...) -> an_enumerator Returns an enumerator which iterates over each line (separated by _sep_, which defaults to your platform's newline character) of each file in +ARGV+. If a block is supplied, each line in turn will be yielded to the block, otherwise an enumerator is returned. The optional _limit_ argument is an +Integer+ specifying the maximum length of each line; longer lines will be split according to this limit. This method allows you to treat the files supplied on the command line as a single file consisting of the concatenation of each named file. After the last line of the first file has been returned, the first line of the second file is returned. The +ARGF.filename+ and +ARGF.lineno+ methods can be used to determine the filename of the current line and line number of the whole input, respectively. For example, the following code prints out each line of each named file prefixed with its line number, displaying the filename once per file: ARGF.each_line do |line| puts ARGF.filename if ARGF.file.lineno == 1 puts "#{ARGF.file.lineno}: #{line}" end While the following code prints only the first file's name at first, and the contents with line number counted through all named files. ARGF.each_line do |line| puts ARGF.filename if ARGF.lineno == 1 puts "#{ARGF.lineno}: #{line}" end ;T;[o;= ;>I" overload;F;?0;;;@0;:I"each(sep=$/);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@ ;![;"I"@yield [line];T;#0;$@ ;.F;Bi;C0;7[[I"sep;TI"$/;T;$@ o;= ;>I" overload;F;?0;;;@0;:I"each(sep=$/, limit);T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" line;T;$@ ;![;"I"@yield [line];T;#0;$@ ;.F;Bi;C0;7[[I"sep;TI"$/;T[I" limit;T0;$@ o;= ;>I" overload;F;?0;;;@0;:I"each(...);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I"...;T0;$@ ;![;"@ ;#0;$@ ;.F;/o;0;1T;2i2;3i"3;%@ ;9I"static VALUE argf_each_line(int argc, VALUE *argv, VALUE argf) { RETURN_ENUMERATOR(argf, argc, argv); FOREACH_ARGF() { argf_block_call_line(rb_intern("each_line"), argc, argv, argf); } return argf; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#each_byte;F;7[;[[@TiB3;T;;y;0;[;{;IC; "(Iterates over each byte of each file in +ARGV+. A byte is returned as an +Integer+ in the range 0..255. This method allows you to treat the files supplied on the command line as a single file consisting of the concatenation of each named file. After the last byte of the first file has been returned, the first byte of the second file is returned. The +ARGF.filename+ method can be used to determine the filename of the current byte. If no block is given, an enumerator is returned instead. For example: ARGF.bytes.to_a #=> [35, 32, ... 95, 10] ;T;[o;= ;>I" overload;F;?0;;y;@0;:I"each_byte;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" byte;T;$@E ;![;"I"@yield [byte];T;#0;$@E ;.F;Bi;C0;7[;$@E o;= ;>I" overload;F;?0;;y;@0;:I"each_byte;T;IC; ";T;[;![;"I";T;#0;$@E ;.F;Bi;C0;7[;$@E ;![;"I"cIterates over each byte of each file in +ARGV+. A byte is returned as an +Integer+ in the range 0..255. This method allows you to treat the files supplied on the command line as a single file consisting of the concatenation of each named file. After the last byte of the first file has been returned, the first byte of the second file is returned. The +ARGF.filename+ method can be used to determine the filename of the current byte. If no block is given, an enumerator is returned instead. For example: ARGF.bytes.to_a #=> [35, 32, ... 95, 10] @overload each_byte @yield [byte] @overload each_byte;T;#0;$@E ;.F;/o;0;1T;2i-3;3i@3;%@ ;9I"static VALUE argf_each_byte(VALUE argf) { RETURN_ENUMERATOR(argf, 0, 0); FOREACH_ARGF() { argf_block_call(rb_intern("each_byte"), 0, 0, argf); } return argf; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#each_char;F;7[;[[@Ti\3;T;;z;0;[;{;IC; "Iterates over each character of each file in +ARGF+. This method allows you to treat the files supplied on the command line as a single file consisting of the concatenation of each named file. After the last character of the first file has been returned, the first character of the second file is returned. The +ARGF.filename+ method can be used to determine the name of the file in which the current character appears. If no block is given, an enumerator is returned instead. ;T;[o;= ;>I" overload;F;?0;;z;@0;:I"each_char;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I" char;T;$@h ;![;"I"@yield [char];T;#0;$@h ;.F;Bi;C0;7[;$@h o;= ;>I" overload;F;?0;;z;@0;:I"each_char;T;IC; ";T;[;![;"I";T;#0;$@h ;.F;Bi;C0;7[;$@h ;![;"I"Iterates over each character of each file in +ARGF+. This method allows you to treat the files supplied on the command line as a single file consisting of the concatenation of each named file. After the last character of the first file has been returned, the first character of the second file is returned. The +ARGF.filename+ method can be used to determine the name of the file in which the current character appears. If no block is given, an enumerator is returned instead. @overload each_char @yield [char] @overload each_char;T;#0;$@h ;.F;/o;0;1T;2iL3;3iZ3;%@ ;9I"static VALUE argf_each_char(VALUE argf) { RETURN_ENUMERATOR(argf, 0, 0); FOREACH_ARGF() { argf_block_call(rb_intern("each_char"), 0, 0, argf); } return argf; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#each_codepoint;F;7[;[[@Tiv3;T;;{;0;[;{;IC; "Iterates over each codepoint of each file in +ARGF+. This method allows you to treat the files supplied on the command line as a single file consisting of the concatenation of each named file. After the last codepoint of the first file has been returned, the first codepoint of the second file is returned. The +ARGF.filename+ method can be used to determine the name of the file in which the current codepoint appears. If no block is given, an enumerator is returned instead. ;T;[o;= ;>I" overload;F;?0;;{;@0;:I"each_codepoint;T;IC; ";T;[o;A ;>I" yield;F;?I";T;0;@[I"codepoint;T;$@ ;![;"I"@yield [codepoint];T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;;{;@0;:I"each_codepoint;T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"'Iterates over each codepoint of each file in +ARGF+. This method allows you to treat the files supplied on the command line as a single file consisting of the concatenation of each named file. After the last codepoint of the first file has been returned, the first codepoint of the second file is returned. The +ARGF.filename+ method can be used to determine the name of the file in which the current codepoint appears. If no block is given, an enumerator is returned instead. @overload each_codepoint @yield [codepoint] @overload each_codepoint;T;#0;$@ ;.F;/o;0;1T;2if3;3it3;%@ ;9I"static VALUE argf_each_codepoint(VALUE argf) { RETURN_ENUMERATOR(argf, 0, 0); FOREACH_ARGF() { argf_block_call(rb_intern("each_codepoint"), 0, 0, argf); } return argf; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#read;F;7[[@90;[[@Ti1;T;;q;0;[;{;IC; "CReads _length_ bytes from ARGF. The files named on the command line are concatenated and treated as a single file by this method, so when called without arguments the contents of this pseudo file are returned in their entirety. _length_ must be a non-negative integer or +nil+. If _length_ is a positive integer, +read+ tries to read _length_ bytes without any conversion (binary mode). It returns +nil+ if an EOF is encountered before anything can be read. Fewer than _length_ bytes are returned if an EOF is encountered during the read. In the case of an integer _length_, the resulting string is always in ASCII-8BIT encoding. If _length_ is omitted or is +nil+, it reads until EOF and the encoding conversion is applied, if applicable. A string is returned even if EOF is encountered before any data is read. If _length_ is zero, it returns an empty string (""). If the optional _outbuf_ argument is present, it must reference a String, which will receive the data. The _outbuf_ will contain only the received data after the method call even if it is not empty at the beginning. For example: $ echo "small" > small.txt $ echo "large" > large.txt $ ./glark.rb small.txt large.txt ARGF.read #=> "small\nlarge" ARGF.read(200) #=> "small\nlarge" ARGF.read(2) #=> "sm" ARGF.read(0) #=> "" Note that this method behaves like the fread() function in C. This means it retries to invoke read(2) system calls to read data with the specified length. If you need the behavior like a single read(2) system call, consider ARGF#readpartial or ARGF#read_nonblock. ;T;[o;= ;>I" overload;F;?0;;q;@0;:I"read([length [, outbuf]]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@ ;![;"I"@return [String, nil];T;#0;$@ ;.F;Bi;C0;7[[I"[length [, outbuf]];T0;$@ ;![;"I"Reads _length_ bytes from ARGF. The files named on the command line are concatenated and treated as a single file by this method, so when called without arguments the contents of this pseudo file are returned in their entirety. _length_ must be a non-negative integer or +nil+. If _length_ is a positive integer, +read+ tries to read _length_ bytes without any conversion (binary mode). It returns +nil+ if an EOF is encountered before anything can be read. Fewer than _length_ bytes are returned if an EOF is encountered during the read. In the case of an integer _length_, the resulting string is always in ASCII-8BIT encoding. If _length_ is omitted or is +nil+, it reads until EOF and the encoding conversion is applied, if applicable. A string is returned even if EOF is encountered before any data is read. If _length_ is zero, it returns an empty string (""). If the optional _outbuf_ argument is present, it must reference a String, which will receive the data. The _outbuf_ will contain only the received data after the method call even if it is not empty at the beginning. For example: $ echo "small" > small.txt $ echo "large" > large.txt $ ./glark.rb small.txt large.txt ARGF.read #=> "small\nlarge" ARGF.read(200) #=> "small\nlarge" ARGF.read(2) #=> "sm" ARGF.read(0) #=> "" Note that this method behaves like the fread() function in C. This means it retries to invoke read(2) system calls to read data with the specified length. If you need the behavior like a single read(2) system call, consider ARGF#readpartial or ARGF#read_nonblock. @overload read([length [, outbuf]]) @return [String, nil];T;#0;$@ ;.F;/o;0;1T;2ik1;3i1;%@ ;9I"qstatic VALUE argf_read(int argc, VALUE *argv, VALUE argf) { VALUE tmp, str, length; long len = 0; rb_scan_args(argc, argv, "02", &length, &str); if (!NIL_P(length)) { len = NUM2LONG(argv[0]); } if (!NIL_P(str)) { StringValue(str); rb_str_resize(str,0); argv[1] = Qnil; } retry: if (!next_argv()) { return str; } if (ARGF_GENERIC_INPUT_P()) { tmp = argf_forward(argc, argv, argf); } else { tmp = io_read(argc, argv, ARGF.current_file); } if (NIL_P(str)) str = tmp; else if (!NIL_P(tmp)) rb_str_append(str, tmp); if (NIL_P(tmp) || NIL_P(length)) { if (ARGF.next_p != -1) { argf_close(argf); ARGF.next_p = 1; goto retry; } } else if (argc >= 1) { long slen = RSTRING_LEN(str); if (slen < len) { argv[0] = LONG2NUM(len - slen); goto retry; } } return str; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#readpartial;F;7[[@90;[[@Ti1;T;;;0;[;{;IC; "Reads at most _maxlen_ bytes from the ARGF stream. If the optional _outbuf_ argument is present, it must reference a String, which will receive the data. The _outbuf_ will contain only the received data after the method call even if it is not empty at the beginning. It raises EOFError on end of ARGF stream. Since ARGF stream is a concatenation of multiple files, internally EOF is occur for each file. ARGF.readpartial returns empty strings for EOFs except the last one and raises EOFError for the last one. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"readpartial(maxlen);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[[I" maxlen;T0;$@ o;= ;>I" overload;F;?0;;;@0;:I" readpartial(maxlen, outbuf);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I" maxlen;T0[I" outbuf;T0;$@ ;![;"I"YReads at most _maxlen_ bytes from the ARGF stream. If the optional _outbuf_ argument is present, it must reference a String, which will receive the data. The _outbuf_ will contain only the received data after the method call even if it is not empty at the beginning. It raises EOFError on end of ARGF stream. Since ARGF stream is a concatenation of multiple files, internally EOF is occur for each file. ARGF.readpartial returns empty strings for EOFs except the last one and raises EOFError for the last one. @overload readpartial(maxlen) @return [String] @overload readpartial(maxlen, outbuf);T;#0;$@ ;.F;/o;0;1T;2i1;3i1;%@ ;9I"{static VALUE argf_readpartial(int argc, VALUE *argv, VALUE argf) { return argf_getpartial(argc, argv, argf, Qnil, 0); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#read_nonblock;F;7[[@90;[[@Ti1;T;;;0;[;{;IC; "LReads at most _maxlen_ bytes from the ARGF stream in non-blocking mode. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"%read_nonblock(maxlen[, options]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[[I"maxlen[, options];T0;$@ o;= ;>I" overload;F;?0;;;@0;:I"-read_nonblock(maxlen, outbuf[, options]);T;IC; ";T;[;![;"I";T;#0;$@ ;.F;Bi;C0;7[[I" maxlen;T0[I"outbuf[, options];T0;$@ ;![;"I"Reads at most _maxlen_ bytes from the ARGF stream in non-blocking mode. @overload read_nonblock(maxlen[, options]) @return [String] @overload read_nonblock(maxlen, outbuf[, options]);T;#0;$@ ;.F;/o;0;1T;2i1;3i1;%@ ;9I"static VALUE argf_read_nonblock(int argc, VALUE *argv, VALUE argf) { VALUE opts; rb_scan_args(argc, argv, "11:", NULL, NULL, &opts); if (!NIL_P(opts)) argc--; return argf_getpartial(argc, argv, argf, opts, 1); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#readlines;F;7[[@90;[[@TiC%;T;;;0;[;{;IC; "DARGF.to_a(sep=$/) -> array ARGF.to_a(limit) -> array ARGF.to_a(sep, limit) -> array Reads +ARGF+'s current file in its entirety, returning an +Array+ of its lines, one line per element. Lines are assumed to be separated by _sep_. lines = ARGF.readlines lines[0] #=> "This is line one\n" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"readlines(sep=$/);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@! ;![;"I"@return [Array];T;#0;$@! ;.F;Bi;C0;7[[I"sep;TI"$/;T;$@! o;= ;>I" overload;F;?0;;;@0;:I"readlines(limit);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@! ;![;"I"@return [Array];T;#0;$@! ;.F;Bi;C0;7[[I" limit;T0;$@! o;= ;>I" overload;F;?0;;;@0;:I"readlines(sep, limit);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@! ;![;"I"@return [Array];T;#0;$@! ;.F;Bi;C0;7[[I"sep;T0[I" limit;T0;$@! ;![;"I" ARGF.to_a(sep=$/) -> array ARGF.to_a(limit) -> array ARGF.to_a(sep, limit) -> array Reads +ARGF+'s current file in its entirety, returning an +Array+ of its lines, one line per element. Lines are assumed to be separated by _sep_. lines = ARGF.readlines lines[0] #=> "This is line one\n" @overload readlines(sep=$/) @return [Array] @overload readlines(limit) @return [Array] @overload readlines(sep, limit) @return [Array];T;#0;$@! ;.F;/o;0;1T;2i3%;3iC%;%@ ;9I"static VALUE argf_readlines(int argc, VALUE *argv, VALUE argf) { long lineno = ARGF.lineno; VALUE lines, ary; ary = rb_ary_new(); while (next_argv()) { if (ARGF_GENERIC_INPUT_P()) { lines = forward_current(rb_intern("readlines"), argc, argv); } else { lines = rb_io_readlines(argc, argv, ARGF.current_file); argf_close(argf); } ARGF.next_p = 1; rb_ary_concat(ary, lines); ARGF.lineno = lineno + RARRAY_LEN(ary); ARGF.last_lineno = ARGF.lineno; } ARGF.init_p = 0; return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#to_a;F;7[[@90;[[@TiC%;T;;;0;[;{;IC; "DARGF.to_a(sep=$/) -> array ARGF.to_a(limit) -> array ARGF.to_a(sep, limit) -> array Reads +ARGF+'s current file in its entirety, returning an +Array+ of its lines, one line per element. Lines are assumed to be separated by _sep_. lines = ARGF.readlines lines[0] #=> "This is line one\n" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"readlines(sep=$/);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@` ;![;"I"@return [Array];T;#0;$@` ;.F;Bi;C0;7[[I"sep;TI"$/;T;$@` o;= ;>I" overload;F;?0;;;@0;:I"readlines(limit);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@` ;![;"I"@return [Array];T;#0;$@` ;.F;Bi;C0;7[[I" limit;T0;$@` o;= ;>I" overload;F;?0;;;@0;:I"readlines(sep, limit);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Array;T;$@` ;![;"I"@return [Array];T;#0;$@` ;.F;Bi;C0;7[[I"sep;T0[I" limit;T0;$@` ;![;"@\ ;#0;$@` ;.F;/o;0;1T;2i3%;3iC%;%@ ;9I"static VALUE argf_readlines(int argc, VALUE *argv, VALUE argf) { long lineno = ARGF.lineno; VALUE lines, ary; ary = rb_ary_new(); while (next_argv()) { if (ARGF_GENERIC_INPUT_P()) { lines = forward_current(rb_intern("readlines"), argc, argv); } else { lines = rb_io_readlines(argc, argv, ARGF.current_file); argf_close(argf); } ARGF.next_p = 1; rb_ary_concat(ary, lines); ARGF.lineno = lineno + RARRAY_LEN(ary); ARGF.last_lineno = ARGF.lineno; } ARGF.init_p = 0; return ary; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#gets;F;7[[@90;[[@Ti$;T;;;0;[;{;IC; "Returns the next line from the current file in +ARGF+. By default lines are assumed to be separated by $/; to use a different character as a separator, supply it as a +String+ for the _sep_ argument. The optional _limit_ argument specifies how many characters of each line to return. By default all characters are returned. See IO.readlines for details about getline_args. ;T;[o;= ;>I" overload;F;?0;;;@0;:I""gets(sep=$/ [, getline_args]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@ ;![;"I"@return [String, nil];T;#0;$@ ;.F;Bi;C0;7[[I"sep;TI"$/[, getline_args];T;$@ o;= ;>I" overload;F;?0;;;@0;:I"!gets(limit [, getline_args]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@ ;![;"I"@return [String, nil];T;#0;$@ ;.F;Bi;C0;7[[I"limit[, getline_args];T0;$@ o;= ;>I" overload;F;?0;;;@0;:I"&gets(sep, limit [, getline_args]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@ ;![;"I"@return [String, nil];T;#0;$@ ;.F;Bi;C0;7[[I"sep;T0[I"limit[, getline_args];T0;$@ ;![;"I"JReturns the next line from the current file in +ARGF+. By default lines are assumed to be separated by $/; to use a different character as a separator, supply it as a +String+ for the _sep_ argument. The optional _limit_ argument specifies how many characters of each line to return. By default all characters are returned. See IO.readlines for details about getline_args. @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;0;1T;2i$;3i$;%@ ;9I"static VALUE argf_gets(int argc, VALUE *argv, VALUE argf) { VALUE line; line = argf_getline(argc, argv, argf); rb_lastline_set(line); return line; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#readline;F;7[[@90;[[@Ti%;T;;;0;[;{;IC; "Returns the next line from the current file in +ARGF+. By default lines are assumed to be separated by $/; to use a different character as a separator, supply it as a +String+ for the _sep_ argument. The optional _limit_ argument specifies how many characters of each line to return. By default all characters are returned. An +EOFError+ is raised at the end of the file. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"readline(sep=$/);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[[I"sep;TI"$/;T;$@ o;= ;>I" overload;F;?0;;;@0;:I"readline(limit);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[[I" limit;T0;$@ o;= ;>I" overload;F;?0;;;@0;:I"readline(sep, limit);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@ ;![;"I"@return [String];T;#0;$@ ;.F;Bi;C0;7[[I"sep;T0[I" limit;T0;$@ ;![;"I"Returns the next line from the current file in +ARGF+. By default lines are assumed to be separated by $/; to use a different character as a separator, supply it as a +String+ for the _sep_ argument. The optional _limit_ argument specifies how many characters of each line to return. By default all characters are returned. An +EOFError+ is raised at the end of the file. @overload readline(sep=$/) @return [String] @overload readline(limit) @return [String] @overload readline(sep, limit) @return [String];T;#0;$@ ;.F;/o;0;1T;2i$;3i%;%@ ;9I"static VALUE argf_readline(int argc, VALUE *argv, VALUE argf) { VALUE line; if (!next_argv()) rb_eof_error(); ARGF_FORWARD(argc, argv); line = argf_gets(argc, argv, argf); if (NIL_P(line)) { rb_eof_error(); } return line; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#getc;F;7[;[[@TiN2;T;;;0;[;{;IC; "Reads the next character from +ARGF+ and returns it as a +String+. Returns +nil+ at the end of the stream. +ARGF+ treats the files named on the command line as a single file created by concatenating their contents. After returning the last character of the first file, it returns the first character of the second file, and so on. For example: $ echo "foo" > file $ ruby argf.rb file ARGF.getc #=> "f" ARGF.getc #=> "o" ARGF.getc #=> "o" ARGF.getc #=> "\n" ARGF.getc #=> nil ARGF.getc #=> nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I" getc;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@ ;![;"I"@return [String, nil];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"7Reads the next character from +ARGF+ and returns it as a +String+. Returns +nil+ at the end of the stream. +ARGF+ treats the files named on the command line as a single file created by concatenating their contents. After returning the last character of the first file, it returns the first character of the second file, and so on. For example: $ echo "foo" > file $ ruby argf.rb file ARGF.getc #=> "f" ARGF.getc #=> "o" ARGF.getc #=> "o" ARGF.getc #=> "\n" ARGF.getc #=> nil ARGF.getc #=> nil @overload getc @return [String, nil];T;#0;$@ ;.F;/o;0;1T;2i72;3iL2;%@ ;9I"astatic VALUE argf_getc(VALUE argf) { VALUE ch; retry: if (!next_argv()) return Qnil; if (ARGF_GENERIC_INPUT_P()) { ch = forward_current(rb_intern("getc"), 0, 0); } else { ch = rb_io_getc(ARGF.current_file); } if (NIL_P(ch) && ARGF.next_p != -1) { argf_close(argf); ARGF.next_p = 1; goto retry; } return ch; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#getbyte;F;7[;[[@Tiv2;T;;;0;[;{;IC; "Gets the next 8-bit byte (0..255) from +ARGF+. Returns +nil+ if called at the end of the stream. For example: $ echo "foo" > file $ ruby argf.rb file ARGF.getbyte #=> 102 ARGF.getbyte #=> 111 ARGF.getbyte #=> 111 ARGF.getbyte #=> 10 ARGF.getbyte #=> nil ;T;[o;= ;>I" overload;F;?0;;;@0;:I" getbyte;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;TI"nil;T;$@; ;![;"I"@return [Integer, nil];T;#0;$@; ;.F;Bi;C0;7[;$@; ;![;"I"BGets the next 8-bit byte (0..255) from +ARGF+. Returns +nil+ if called at the end of the stream. For example: $ echo "foo" > file $ ruby argf.rb file ARGF.getbyte #=> 102 ARGF.getbyte #=> 111 ARGF.getbyte #=> 111 ARGF.getbyte #=> 10 ARGF.getbyte #=> nil @overload getbyte @return [Integer, nil];T;#0;$@; ;.F;/o;0;1T;2id2;3it2;%@ ;9I"ystatic VALUE argf_getbyte(VALUE argf) { VALUE ch; retry: if (!next_argv()) return Qnil; if (!RB_TYPE_P(ARGF.current_file, T_FILE)) { ch = forward_current(rb_intern("getbyte"), 0, 0); } else { ch = rb_io_getbyte(ARGF.current_file); } if (NIL_P(ch) && ARGF.next_p != -1) { argf_close(argf); ARGF.next_p = 1; goto retry; } return ch; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#readchar;F;7[;[[@Ti2;T;;;0;[;{;IC; "lReads the next character from +ARGF+ and returns it as a +String+. Raises an +EOFError+ after the last character of the last file has been read. For example: $ echo "foo" > file $ ruby argf.rb file ARGF.readchar #=> "f" ARGF.readchar #=> "o" ARGF.readchar #=> "o" ARGF.readchar #=> "\n" ARGF.readchar #=> end of file reached (EOFError) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" readchar;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;TI"nil;T;$@W ;![;"I"@return [String, nil];T;#0;$@W ;.F;Bi;C0;7[;$@W ;![;"I"Reads the next character from +ARGF+ and returns it as a +String+. Raises an +EOFError+ after the last character of the last file has been read. For example: $ echo "foo" > file $ ruby argf.rb file ARGF.readchar #=> "f" ARGF.readchar #=> "o" ARGF.readchar #=> "o" ARGF.readchar #=> "\n" ARGF.readchar #=> end of file reached (EOFError) @overload readchar @return [String, nil];T;#0;$@W ;.F;/o;0;1T;2i2;3i2;%@ ;9I"wstatic VALUE argf_readchar(VALUE argf) { VALUE ch; retry: if (!next_argv()) rb_eof_error(); if (!RB_TYPE_P(ARGF.current_file, T_FILE)) { ch = forward_current(rb_intern("getc"), 0, 0); } else { ch = rb_io_getc(ARGF.current_file); } if (NIL_P(ch) && ARGF.next_p != -1) { argf_close(argf); ARGF.next_p = 1; goto retry; } return ch; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#readbyte;F;7[;[[@Ti2;T;;;0;[;{;IC; "fReads the next 8-bit byte from ARGF and returns it as an +Integer+. Raises an +EOFError+ after the last byte of the last file has been read. For example: $ echo "foo" > file $ ruby argf.rb file ARGF.readbyte #=> 102 ARGF.readbyte #=> 111 ARGF.readbyte #=> 111 ARGF.readbyte #=> 10 ARGF.readbyte #=> end of file reached (EOFError) ;T;[o;= ;>I" overload;F;?0;;;@0;:I" readbyte;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@s ;![;"I"@return [Integer];T;#0;$@s ;.F;Bi;C0;7[;$@s ;![;"I"Reads the next 8-bit byte from ARGF and returns it as an +Integer+. Raises an +EOFError+ after the last byte of the last file has been read. For example: $ echo "foo" > file $ ruby argf.rb file ARGF.readbyte #=> 102 ARGF.readbyte #=> 111 ARGF.readbyte #=> 111 ARGF.readbyte #=> 10 ARGF.readbyte #=> end of file reached (EOFError) @overload readbyte @return [Integer];T;#0;$@s ;.F;/o;0;1T;2i2;3i2;%@ ;9I"static VALUE argf_readbyte(VALUE argf) { VALUE c; NEXT_ARGF_FORWARD(0, 0); c = argf_getbyte(argf); if (NIL_P(c)) { rb_eof_error(); } return c; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#tell;F;7[;[[@Ti0;T;;;0;[;{;IC; "Returns the current offset (in bytes) of the current file in +ARGF+. ARGF.pos #=> 0 ARGF.gets #=> "This is line one\n" ARGF.pos #=> 17 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" tell;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;;;@0;:I"pos;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Returns the current offset (in bytes) of the current file in +ARGF+. ARGF.pos #=> 0 ARGF.gets #=> "This is line one\n" ARGF.pos #=> 17 @overload tell @return [Integer] @overload pos @return [Integer];T;#0;$@ ;.F;/o;0;1T;2i0;3i0;%@ ;9I"static VALUE argf_tell(VALUE argf) { if (!next_argv()) { rb_raise(rb_eArgError, "no stream to tell"); } ARGF_FORWARD(0, 0); return rb_io_tell(ARGF.current_file); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#seek;F;7[[@90;[[@Ti0;T;;;0;[;{;IC; "Seeks to offset _amount_ (an +Integer+) in the +ARGF+ stream according to the value of _whence_. See IO#seek for further details. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"&seek(amount, whence=IO::SEEK_SET);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@ ;![;"I"@return [0];T;#0;$@ ;.F;Bi;C0;7[[I" amount;T0[I" whence;TI"IO::SEEK_SET;T;$@ ;![;"I"Seeks to offset _amount_ (an +Integer+) in the +ARGF+ stream according to the value of _whence_. See IO#seek for further details. @overload seek(amount, whence=IO::SEEK_SET) @return [0];T;#0;$@ ;.F;/o;0;1T;2i0;3i0;%@ ;9I"static VALUE argf_seek_m(int argc, VALUE *argv, VALUE argf) { if (!next_argv()) { rb_raise(rb_eArgError, "no stream to seek"); } ARGF_FORWARD(argc, argv); return rb_io_seek_m(argc, argv, ARGF.current_file); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#rewind;F;7[;[[@Ti1;T;;;0;[;{;IC; "Positions the current file to the beginning of input, resetting +ARGF.lineno+ to zero. ARGF.readline #=> "This is line one\n" ARGF.rewind #=> 0 ARGF.lineno #=> 0 ARGF.readline #=> "This is line one\n" ;T;[o;= ;>I" overload;F;?0;;;@0;:I" rewind;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"0;T;$@ ;![;"I"@return [0];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"I"Positions the current file to the beginning of input, resetting +ARGF.lineno+ to zero. ARGF.readline #=> "This is line one\n" ARGF.rewind #=> 0 ARGF.lineno #=> 0 ARGF.readline #=> "This is line one\n" @overload rewind @return [0];T;#0;$@ ;.F;/o;0;1T;2i1;3i1;%@ ;9I"{static VALUE argf_rewind(VALUE argf) { VALUE ret; int old_lineno; if (!next_argv()) { rb_raise(rb_eArgError, "no stream to rewind"); } ARGF_FORWARD(0, 0); old_lineno = RFILE(ARGF.current_file)->fptr->lineno; ret = rb_io_rewind(ARGF.current_file); if (!global_argf_p(argf)) { ARGF.last_lineno = ARGF.lineno -= old_lineno; } return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" ARGF#pos;F;7[;[[@Ti0;T;;;0;[;{;IC; "Returns the current offset (in bytes) of the current file in +ARGF+. ARGF.pos #=> 0 ARGF.gets #=> "This is line one\n" ARGF.pos #=> 17 ;T;[o;= ;>I" overload;F;?0;;;@0;:I" tell;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ o;= ;>I" overload;F;?0;;;@0;:I"pos;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@ ;![;"I"@return [Integer];T;#0;$@ ;.F;Bi;C0;7[;$@ ;![;"@ ;#0;$@ ;.F;/o;0;1T;2i0;3i0;%@ ;9I"static VALUE argf_tell(VALUE argf) { if (!next_argv()) { rb_raise(rb_eArgError, "no stream to tell"); } ARGF_FORWARD(0, 0); return rb_io_tell(ARGF.current_file); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#pos=;F;7[[I" offset;T0;[[@Ti0;T;;;0;[;{;IC; "Seeks to the position given by _position_ (in bytes) in +ARGF+. For example: ARGF.pos = 17 ARGF.gets #=> "This is line two\n" ;T;[o;= ;>I" overload;F;?0;;;@0;:I"pos=(position);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I" position;T0;$@;![;"I"Seeks to the position given by _position_ (in bytes) in +ARGF+. For example: ARGF.pos = 17 ARGF.gets #=> "This is line two\n" @overload pos=(position) @return [Integer];T;#0;$@;.F;/o;0;1T;2i0;3i0;%@ ;9I"static VALUE argf_set_pos(VALUE argf, VALUE offset) { if (!next_argv()) { rb_raise(rb_eArgError, "no stream to set position"); } ARGF_FORWARD(1, &offset); return rb_io_set_pos(ARGF.current_file, offset); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I" ARGF#eof;F;7[;[[@Ti\1;T;;;0;[;{;IC; "xReturns true if the current file in +ARGF+ is at end of file, i.e. it has no data to read. The stream must be opened for reading or an +IOError+ will be raised. $ echo "eof" | ruby argf.rb ARGF.eof? #=> false 3.times { ARGF.readchar } ARGF.eof? #=> false ARGF.readchar #=> "\n" ARGF.eof? #=> true ;T;[o;= ;>I" overload;F;?0;;;@0;:I" eof?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@8;![;"I"@return [Boolean];T;#0;$@8;.F;Bi;C0;7[;$@8o;= ;>I" overload;F;?0;;;@0;:I"eof;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@8;![;"I"@return [Boolean];T;#0;$@8;.F;Bi;C0;7[;$@8;![;"I"Returns true if the current file in +ARGF+ is at end of file, i.e. it has no data to read. The stream must be opened for reading or an +IOError+ will be raised. $ echo "eof" | ruby argf.rb ARGF.eof? #=> false 3.times { ARGF.readchar } ARGF.eof? #=> false ARGF.readchar #=> "\n" ARGF.eof? #=> true @overload eof? @return [Boolean] @overload eof @return [Boolean];T;#0;$@8;.F;/o;0;1T;2iJ1;3iZ1;%@ ;9I"static VALUE argf_eof(VALUE argf) { next_argv(); if (RTEST(ARGF.current_file)) { if (ARGF.init_p == 0) return Qtrue; next_argv(); ARGF_FORWARD(0, 0); if (rb_io_eof(ARGF.current_file)) { return Qtrue; } } return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#eof?;F;7[;[[@Ti\1;T;;;0;[;{;IC; "xReturns true if the current file in +ARGF+ is at end of file, i.e. it has no data to read. The stream must be opened for reading or an +IOError+ will be raised. $ echo "eof" | ruby argf.rb ARGF.eof? #=> false 3.times { ARGF.readchar } ARGF.eof? #=> false ARGF.readchar #=> "\n" ARGF.eof? #=> true;T;[o;= ;>I" overload;F;?0;;;@0;:I" eof?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@`;![;"I"@return [Boolean];T;#0;$@`;.F;Bi;C0;7[;$@`o;= ;>I" overload;F;?0;;;@0;:I"eof;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@`;![;"I"@return [Boolean];T;#0;$@`;.F;Bi;C0;7[;$@`;![;"@\;#0;$@`;.F;/o;0;1T;2iJ1;3iZ1;Bi;%@ ;9I"static VALUE argf_eof(VALUE argf) { next_argv(); if (RTEST(ARGF.current_file)) { if (ARGF.init_p == 0) return Qtrue; next_argv(); ARGF_FORWARD(0, 0); if (rb_io_eof(ARGF.current_file)) { return Qtrue; } } return Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#binmode;F;7[;[[@Ti3;T;;;0;[;{;IC; "Puts +ARGF+ into binary mode. Once a stream is in binary mode, it cannot be reset to non-binary mode. This option has the following effects: * Newline conversion is disabled. * Encoding conversion is disabled. * Content is treated as ASCII-8BIT. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" binmode;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I" Puts +ARGF+ into binary mode. Once a stream is in binary mode, it cannot be reset to non-binary mode. This option has the following effects: * Newline conversion is disabled. * Encoding conversion is disabled. * Content is treated as ASCII-8BIT. @overload binmode;T;#0;$@;.F;/o;0;1T;2i3;3i3;%@ ;9I"static VALUE argf_binmode_m(VALUE argf) { ARGF.binmode = 1; next_argv(); ARGF_FORWARD(0, 0); rb_io_ascii8bit_binmode(ARGF.current_file); return argf; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#binmode?;F;7[;[[@Ti3;T;;;0;[;{;IC; "Returns true if +ARGF+ is being read in binary mode; false otherwise. To enable binary mode use +ARGF.binmode+. For example: ARGF.binmode? #=> false ARGF.binmode ARGF.binmode? #=> true;T;[o;= ;>I" overload;F;?0;;;@0;:I" binmode?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns true if +ARGF+ is being read in binary mode; false otherwise. To enable binary mode use +ARGF.binmode+. For example: ARGF.binmode? #=> false ARGF.binmode ARGF.binmode? #=> true @overload binmode? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i3;3i3;Bi;%@ ;9I"Pstatic VALUE argf_binmode_p(VALUE argf) { return RBOOL(ARGF.binmode); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#write;F;7[[I"str;T0;[[@Ti4;T;;s;0;[;{;IC; "%Writes _string_ if inplace mode. ;T;[o;= ;>I" overload;F;?0;;s;@0;:I"write(string);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[[I" string;T0;$@;![;"I"SWrites _string_ if inplace mode. @overload write(string) @return [Integer];T;#0;$@;.F;/o;0;1T;2i4;3i4;%@ ;9I"istatic VALUE argf_write(VALUE argf, VALUE str) { return rb_io_write(argf_write_io(argf), str); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#print;F;7[[@90;[[@Ti];T;;;0;[;{;IC; "&Writes the given object(s) to ios. Returns +nil+. The stream must be opened for writing. Each given object that isn't a string will be converted by calling its to_s method. When called without arguments, prints the contents of $_. If the output field separator ($,) is not +nil+, it is inserted between objects. If the output record separator ($\\) is not +nil+, it is appended to the output. $stdout.print("This is ", 100, " percent.\n") produces: This is 100 percent. ;T;[o;= ;>I" overload;F;?0;;;@0;:I" print;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;;@0;:I"print(obj, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@;![;"I"@return [nil];T;#0;$@;.F;Bi;C0;7[[I"obj;T0[I"...;T0;$@;![;"@#Q;#0;$@;.F;/o;0;1T;2iE;3i[;%@ ;9I"KVALUE rb_io_print(int argc, const VALUE *argv, VALUE out) { int i; VALUE line; /* if no argument given, print `$_' */ if (argc == 0) { argc = 1; line = rb_lastline_get(); argv = &line; } if (argc > 1 && !NIL_P(rb_output_fs)) { rb_category_warn(RB_WARN_CATEGORY_DEPRECATED, "$, is set to non-nil value"); } for (i=0; i0) { rb_io_write(out, rb_output_fs); } rb_io_write(out, argv[i]); } if (argc > 0 && !NIL_P(rb_output_rs)) { rb_io_write(out, rb_output_rs); } return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"ARGF#putc;F;7[[I"ch;T0;[[@Ti;T;;;0;[;{;IC; "If obj is Numeric, write the character whose code is the least-significant byte of obj. If obj is String, write the first character of obj to ios. Otherwise, raise TypeError. $stdout.putc "A" $stdout.putc 65 produces: AA ;T;[o;= ;>I" overload;F;?0;;;@0;:I"putc(obj);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Object;T;$@;![;"I"@return [Object];T;#0;$@;.F;Bi;C0;7[[I"obj;T0;$@;![;"@BQ;#0;$@;.F;/o;0;1T;2i;3i;%@ ;9I"static VALUE rb_io_putc(VALUE io, VALUE ch) { VALUE str; if (RB_TYPE_P(ch, T_STRING)) { str = rb_str_substr(ch, 0, 1); } else { char c = NUM2CHR(ch); str = rb_str_new(&c, 1); } rb_io_write(io, str); return ch; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#puts;F;7[[@90;[[@Ti ;T;;;0;[;{;IC; "UWrites the given object(s) to ios. Writes a newline after any that do not already end with a newline sequence. Returns +nil+. The stream must be opened for writing. If called with an array argument, writes each element on a new line. Each given object that isn't a string or array will be converted by calling its +to_s+ method. If called without arguments, outputs a single newline. $stdout.puts("this", "is", ["a", "test"]) produces: this is a test Note that +puts+ always uses newlines and is not affected by the output record separator ($\\). ;T;[o;= ;>I" overload;F;?0;;;@0;:I"puts(obj, ...);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@!;![;"I"@return [nil];T;#0;$@!;.F;Bi;C0;7[[I"obj;T0[I"...;T0;$@!;![;"@bQ;#0;$@!;.F;/o;0;1T;2i;3i ;%@ ;9I"VALUE rb_io_puts(int argc, const VALUE *argv, VALUE out) { int i, n; VALUE line, args[2]; /* if no argument given, print newline. */ if (argc == 0) { rb_io_write(out, rb_default_rs); return Qnil; } for (i=0; iios, converting parameters under control of the format string. See Kernel#sprintf for details. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"'printf(format_string [, obj, ...]);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"nil;T;$@@;![;"I"@return [nil];T;#0;$@@;.F;Bi;C0;7[[I"format_string[, obj, ...];T0;$@@;![;"@Q;#0;$@@;.F;/o;0;1T;2i;3i;%@ ;9I"VALUE rb_io_printf(int argc, const VALUE *argv, VALUE out) { rb_io_write(out, rb_f_sprintf(argc, argv)); return Qnil; };T;:I" VALUE;T;;To;4;5F;6;;;;&I"ARGF#filename;F;7[;[[@Ti3;T;; ;0;[;{;IC; "FReturns the current filename. "-" is returned when the current file is STDIN. For example: $ echo "foo" > foo $ echo "bar" > bar $ echo "glark" > glark $ ruby argf.rb foo bar glark ARGF.filename #=> "foo" ARGF.read(5) #=> "foo\nb" ARGF.filename #=> "bar" ARGF.skip ARGF.filename #=> "glark" ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" filename;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@];![;"I"@return [String];T;#0;$@];.F;Bi;C0;7[;$@]o;= ;>I" overload;F;?0;;O;@0;:I" path;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@];![;"I"@return [String];T;#0;$@];.F;Bi;C0;7[;$@];![;"I"Returns the current filename. "-" is returned when the current file is STDIN. For example: $ echo "foo" > foo $ echo "bar" > bar $ echo "glark" > glark $ ruby argf.rb foo bar glark ARGF.filename #=> "foo" ARGF.read(5) #=> "foo\nb" ARGF.filename #=> "bar" ARGF.skip ARGF.filename #=> "glark" @overload filename @return [String] @overload path @return [String];T;#0;$@];.F;/o;0;1T;2i3;3i3;%@ ;9I"Zstatic VALUE argf_filename(VALUE argf) { next_argv(); return ARGF.filename; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#path;F;7[;[[@Ti3;T;;O;0;[;{;IC; "FReturns the current filename. "-" is returned when the current file is STDIN. For example: $ echo "foo" > foo $ echo "bar" > bar $ echo "glark" > glark $ ruby argf.rb foo bar glark ARGF.filename #=> "foo" ARGF.read(5) #=> "foo\nb" ARGF.filename #=> "bar" ARGF.skip ARGF.filename #=> "glark" ;T;[o;= ;>I" overload;F;?0;; ;@0;:I" filename;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@o;= ;>I" overload;F;?0;;O;@0;:I" path;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@;![;"I"@return [String];T;#0;$@;.F;Bi;C0;7[;$@;![;"@;#0;$@;.F;/o;0;1T;2i3;3i3;%@ ;9I"Zstatic VALUE argf_filename(VALUE argf) { next_argv(); return ARGF.filename; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#file;F;7[;[[@Ti3;T;: file;0;[;{;IC; "/Returns the current file as an +IO+ or +File+ object. $stdin is returned when the current file is STDIN. For example: $ echo "foo" > foo $ echo "bar" > bar $ ruby argf.rb foo bar ARGF.file #=> # ARGF.read(5) #=> "foo\nb" ARGF.file #=> # ;T;[o;= ;>I" overload;F;?0;;;@0;:I" file;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I"File object;T;$@;![;"I"@return [File object];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"XReturns the current file as an +IO+ or +File+ object. $stdin is returned when the current file is STDIN. For example: $ echo "foo" > foo $ echo "bar" > bar $ ruby argf.rb foo bar ARGF.file #=> # ARGF.read(5) #=> "foo\nb" ARGF.file #=> # @overload file @return [File object];T;#0;$@;.F;/o;0;1T;2i3;3i3;%@ ;9I"Zstatic VALUE argf_file(VALUE argf) { next_argv(); return ARGF.current_file; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#skip;F;7[;[[@Ti3;T;;;0;[;{;IC; "Sets the current file to the next file in ARGV. If there aren't any more files it has no effect. For example: $ ruby argf.rb foo bar ARGF.filename #=> "foo" ARGF.skip ARGF.filename #=> "bar" ;T;[o;= ;>I" overload;F;?0;;;@0;:I" skip;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Sets the current file to the next file in ARGV. If there aren't any more files it has no effect. For example: $ ruby argf.rb foo bar ARGF.filename #=> "foo" ARGF.skip ARGF.filename #=> "bar" @overload skip;T;#0;$@;.F;/o;0;1T;2i3;3i3;%@ ;9I"static VALUE argf_skip(VALUE argf) { if (ARGF.init_p && ARGF.next_p == 0) { argf_close(argf); ARGF.next_p = 1; } return argf; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#close;F;7[;[[@Ti 4;T;;;0;[;{;IC; "Closes the current file and skips to the next file in ARGV. If there are no more files to open, just closes the current file. +STDIN+ will not be closed. For example: $ ruby argf.rb foo bar ARGF.filename #=> "foo" ARGF.close ARGF.filename #=> "bar" ARGF.close ;T;[o;= ;>I" overload;F;?0;;;@0;:I" close;T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[;$@;![;"I")Closes the current file and skips to the next file in ARGV. If there are no more files to open, just closes the current file. +STDIN+ will not be closed. For example: $ ruby argf.rb foo bar ARGF.filename #=> "foo" ARGF.close ARGF.filename #=> "bar" ARGF.close @overload close;T;#0;$@;.F;/o;0;1T;2i3;3i 4;%@ ;9I"static VALUE argf_close_m(VALUE argf) { next_argv(); argf_close(argf); if (ARGF.next_p != -1) { ARGF.next_p = 1; } ARGF.lineno = 0; return argf; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#closed?;F;7[;[[@Ti 4;T;;\;0;[;{;IC; "{Returns _true_ if the current file has been closed; _false_ otherwise. Use +ARGF.close+ to actually close the current file.;T;[o;= ;>I" overload;F;?0;;\;@0;:I" closed?;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Boolean;T;$@;![;"I"@return [Boolean];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns _true_ if the current file has been closed; _false_ otherwise. Use +ARGF.close+ to actually close the current file. @overload closed? @return [Boolean];T;#0;$@;.F;/o;0;1T;2i4;3i4;Bi;%@ ;9I"}static VALUE argf_closed(VALUE argf) { next_argv(); ARGF_FORWARD(0, 0); return rb_io_closed(ARGF.current_file); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#lineno;F;7[;[[@Ti#;T;;L;0;[;{;IC; "Returns the current line number of ARGF as a whole. This value can be set manually with +ARGF.lineno=+. For example: ARGF.lineno #=> 0 ARGF.readline #=> "This is line 1\n" ARGF.lineno #=> 1 ;T;[o;= ;>I" overload;F;?0;;L;@0;:I" lineno;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@;![;"I"@return [Integer];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the current line number of ARGF as a whole. This value can be set manually with +ARGF.lineno=+. For example: ARGF.lineno #=> 0 ARGF.readline #=> "This is line 1\n" ARGF.lineno #=> 1 @overload lineno @return [Integer];T;#0;$@;.F;/o;0;1T;2is#;3i~#;%@ ;9I"Nstatic VALUE argf_lineno(VALUE argf) { return INT2FIX(ARGF.lineno); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#lineno=;F;7[[I"val;T0;[[@Tik#;T;;;0;[;{;IC; "Sets the line number of +ARGF+ as a whole to the given +Integer+. +ARGF+ sets the line number automatically as you read data, so normally you will not need to set it explicitly. To access the current line number use +ARGF.lineno+. For example: ARGF.lineno #=> 0 ARGF.readline #=> "This is line 1\n" ARGF.lineno #=> 1 ARGF.lineno = 0 #=> 0 ARGF.lineno #=> 0 ;T;[o;= ;>I" overload;F;?0;;;@0;:I"lineno=(integer);T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Integer;T;$@);![;"I"@return [Integer];T;#0;$@);.F;Bi;C0;7[[I" integer;T0;$@);![;"I"Sets the line number of +ARGF+ as a whole to the given +Integer+. +ARGF+ sets the line number automatically as you read data, so normally you will not need to set it explicitly. To access the current line number use +ARGF.lineno+. For example: ARGF.lineno #=> 0 ARGF.readline #=> "This is line 1\n" ARGF.lineno #=> 1 ARGF.lineno = 0 #=> 0 ARGF.lineno #=> 0 @overload lineno=(integer) @return [Integer];T;#0;$@);.F;/o;0;1T;2iY#;3ii#;%@ ;9I"static VALUE argf_set_lineno(VALUE argf, VALUE val) { ARGF.lineno = NUM2INT(val); ARGF.last_lineno = ARGF.lineno; return Qnil; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#inplace_mode;F;7[;[[@Ti<4;T;:inplace_mode;0;[;{;IC; "Returns the file extension appended to the names of modified files under in-place edit mode. This value can be set using +ARGF.inplace_mode=+ or passing the +-i+ switch to the Ruby binary. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"inplace_mode;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" String;T;$@H;![;"I"@return [String];T;#0;$@H;.F;Bi;C0;7[;$@H;![;"I"Returns the file extension appended to the names of modified files under in-place edit mode. This value can be set using +ARGF.inplace_mode=+ or passing the +-i+ switch to the Ruby binary. @overload inplace_mode @return [String];T;#0;$@H;.F;/o;0;1T;2i44;3i:4;%@ ;9I"static VALUE argf_inplace_mode_get(VALUE argf) { if (!ARGF.inplace) return Qnil; if (NIL_P(ARGF.inplace)) return rb_str_new(0, 0); return rb_str_dup(ARGF.inplace); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#inplace_mode=;F;7[[I"val;T0;[[@Ti^4;T;:inplace_mode=;0;[;{;IC; "Sets the filename extension for in-place editing mode to the given String. Each file being edited has this value appended to its filename. The modified file is saved under this new name. For example: $ ruby argf.rb file.txt ARGF.inplace_mode = '.bak' ARGF.each_line do |line| print line.sub("foo","bar") end Each line of _file.txt_ has the first occurrence of "foo" replaced with "bar", then the new line is written out to _file.txt.bak_. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"inplace_mode=(ext);T;IC; ";T;[;![;"I";T;#0;$@c;.F;Bi;C0;7[[I"ext;T0;$@c;![;"I"Sets the filename extension for in-place editing mode to the given String. Each file being edited has this value appended to its filename. The modified file is saved under this new name. For example: $ ruby argf.rb file.txt ARGF.inplace_mode = '.bak' ARGF.each_line do |line| print line.sub("foo","bar") end Each line of _file.txt_ has the first occurrence of "foo" replaced with "bar", then the new line is written out to _file.txt.bak_. @overload inplace_mode=(ext);T;#0;$@c;.F;/o;0;1T;2iJ4;3i[4;%@ ;9I"static VALUE argf_inplace_mode_set(VALUE argf, VALUE val) { if (!RTEST(val)) { ARGF.inplace = Qfalse; } else if (StringValueCStr(val), !RSTRING_LEN(val)) { ARGF.inplace = Qnil; } else { ARGF.inplace = rb_str_new_frozen(val); } return argf; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#external_encoding;F;7[;[[@Ti|0;T;;;0;[;{;IC; "wReturns the external encoding for files read from +ARGF+ as an +Encoding+ object. The external encoding is the encoding of the text as stored in a file. Contrast with +ARGF.internal_encoding+, which is the encoding used to represent this text within Ruby. To set the external encoding use +ARGF.set_encoding+. For example: ARGF.external_encoding #=> # ;T;[o;= ;>I" overload;F;?0;;;@0;:I"external_encoding;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Encoding;T;$@};![;"I"@return [Encoding];T;#0;$@};.F;Bi;C0;7[;$@};![;"I"Returns the external encoding for files read from +ARGF+ as an +Encoding+ object. The external encoding is the encoding of the text as stored in a file. Contrast with +ARGF.internal_encoding+, which is the encoding used to represent this text within Ruby. To set the external encoding use +ARGF.set_encoding+. For example: ARGF.external_encoding #=> # @overload external_encoding @return [Encoding];T;#0;$@};.F;/o;0;1T;2il0;3iz0;%@ ;9I"static VALUE argf_external_encoding(VALUE argf) { if (!RTEST(ARGF.current_file)) { return rb_enc_from_encoding(rb_default_external_encoding()); } return rb_io_external_encoding(rb_io_check_io(ARGF.current_file)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#internal_encoding;F;7[;[[@Ti0;T;;;0;[;{;IC; "Returns the internal encoding for strings read from +ARGF+ as an +Encoding+ object. If +ARGF.set_encoding+ has been called with two encoding names, the second is returned. Otherwise, if +Encoding.default_external+ has been set, that value is returned. Failing that, if a default external encoding was specified on the command-line, that value is used. If the encoding is unknown, +nil+ is returned. ;T;[o;= ;>I" overload;F;?0;;;@0;:I"internal_encoding;T;IC; ";T;[o;A ;>I" return;F;?I";T;0;@[I" Encoding;T;$@;![;"I"@return [Encoding];T;#0;$@;.F;Bi;C0;7[;$@;![;"I"Returns the internal encoding for strings read from +ARGF+ as an +Encoding+ object. If +ARGF.set_encoding+ has been called with two encoding names, the second is returned. Otherwise, if +Encoding.default_external+ has been set, that value is returned. Failing that, if a default external encoding was specified on the command-line, that value is used. If the encoding is unknown, +nil+ is returned. @overload internal_encoding @return [Encoding];T;#0;$@;.F;/o;0;1T;2i0;3i0;%@ ;9I"static VALUE argf_internal_encoding(VALUE argf) { if (!RTEST(ARGF.current_file)) { return rb_enc_from_encoding(rb_default_external_encoding()); } return rb_io_internal_encoding(rb_io_check_io(ARGF.current_file)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"ARGF#set_encoding;F;7[[@90;[[@Ti0;T;;;0;[;{;IC; "If single argument is specified, strings read from ARGF are tagged with the encoding specified. If two encoding names separated by a colon are given, e.g. "ascii:utf-8", the read string is converted from the first encoding (external encoding) to the second encoding (internal encoding), then tagged with the second encoding. If two arguments are specified, they must be encoding objects or encoding names. Again, the first specifies the external encoding; the second specifies the internal encoding. If the external encoding and the internal encoding are specified, the optional +Hash+ argument can be used to adjust the conversion process. The structure of this hash is explained in the String#encode documentation. For example: ARGF.set_encoding('ascii') # Tag the input as US-ASCII text ARGF.set_encoding(Encoding::UTF_8) # Tag the input as UTF-8 text ARGF.set_encoding('utf-8','ascii') # Transcode the input from US-ASCII # to UTF-8. ;T;[ o;= ;>I" overload;F;?0;;;@0;:I"set_encoding(ext_enc);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" ext_enc;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"$set_encoding("ext_enc:int_enc");T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[""ext_enc:" int_enc";$@o;= ;>I" overload;F;?0;;;@0;:I"#set_encoding(ext_enc, int_enc);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" ext_enc;T0[I" int_enc;T0;$@o;= ;>I" overload;F;?0;;;@0;:I")set_encoding("ext_enc:int_enc", opt);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[""ext_enc:" int_enc"[I"opt;T0;$@o;= ;>I" overload;F;?0;;;@0;:I"(set_encoding(ext_enc, int_enc, opt);T;IC; ";T;[;![;"I";T;#0;$@;.F;Bi;C0;7[[I" ext_enc;T0[I" int_enc;T0[I"opt;T0;$@;![;"I"If single argument is specified, strings read from ARGF are tagged with the encoding specified. If two encoding names separated by a colon are given, e.g. "ascii:utf-8", the read string is converted from the first encoding (external encoding) to the second encoding (internal encoding), then tagged with the second encoding. If two arguments are specified, they must be encoding objects or encoding names. Again, the first specifies the external encoding; the second specifies the internal encoding. If the external encoding and the internal encoding are specified, the optional +Hash+ argument can be used to adjust the conversion process. The structure of this hash is explained in the String#encode documentation. For example: ARGF.set_encoding('ascii') # Tag the input as US-ASCII text ARGF.set_encoding(Encoding::UTF_8) # Tag the input as UTF-8 text ARGF.set_encoding('utf-8','ascii') # Transcode the input from US-ASCII # to UTF-8. @overload set_encoding(ext_enc) @overload set_encoding("ext_enc:int_enc") @overload set_encoding(ext_enc, int_enc) @overload set_encoding("ext_enc:int_enc", opt) @overload set_encoding(ext_enc, int_enc, opt);T;#0;$@;.F;/o;0;1T;2i0;3i0;%@ ;9I";static VALUE argf_set_encoding(int argc, VALUE *argv, VALUE argf) { rb_io_t *fptr; if (!next_argv()) { rb_raise(rb_eArgError, "no stream to set encoding"); } rb_io_set_encoding(argc, argv, ARGF.current_file); GetOpenFile(ARGF.current_file, fptr); ARGF.encs = fptr->encs; return argf; };T;:I"static VALUE;T;;T; @ ; IC;[; @ ; IC;[o;( ;)0;*0;+0;;;%@;-@y,;0; @ ; IC;{;IC;{;T;IC;{;T;T;{@/ ;G;[;[[@Ti5[@Ti.8;T;;;;;;;[;{;IC; "{+ARGF+ is a stream designed for use in scripts that process files given as command-line arguments or passed in via STDIN. The arguments passed to your script are stored in the +ARGV+ Array, one argument per element. +ARGF+ assumes that any arguments that aren't filenames have been removed from +ARGV+. For example: $ ruby argf.rb --verbose file1 file2 ARGV #=> ["--verbose", "file1", "file2"] option = ARGV.shift #=> "--verbose" ARGV #=> ["file1", "file2"] You can now use +ARGF+ to work with a concatenation of each of these named files. For instance, +ARGF.read+ will return the contents of _file1_ followed by the contents of _file2_. After a file in +ARGV+ has been read +ARGF+ removes it from the Array. Thus, after all files have been read +ARGV+ will be empty. You can manipulate +ARGV+ yourself to control what +ARGF+ operates on. If you remove a file from +ARGV+, it is ignored by +ARGF+; if you add files to +ARGV+, they are treated as if they were named on the command line. For example: ARGV.replace ["file1"] ARGF.readlines # Returns the contents of file1 as an Array ARGV #=> [] ARGV.replace ["file2", "file3"] ARGF.read # Returns the contents of file2 and file3 If +ARGV+ is empty, +ARGF+ acts as if it contained STDIN, i.e. the data piped to your script. For example: $ echo "glark" | ruby -e 'p ARGF.read' "glark\n";T;[;![;"I"} +ARGF+ is a stream designed for use in scripts that process files given as command-line arguments or passed in via STDIN. The arguments passed to your script are stored in the +ARGV+ Array, one argument per element. +ARGF+ assumes that any arguments that aren't filenames have been removed from +ARGV+. For example: $ ruby argf.rb --verbose file1 file2 ARGV #=> ["--verbose", "file1", "file2"] option = ARGV.shift #=> "--verbose" ARGV #=> ["file1", "file2"] You can now use +ARGF+ to work with a concatenation of each of these named files. For instance, +ARGF.read+ will return the contents of _file1_ followed by the contents of _file2_. After a file in +ARGV+ has been read +ARGF+ removes it from the Array. Thus, after all files have been read +ARGV+ will be empty. You can manipulate +ARGV+ yourself to control what +ARGF+ operates on. If you remove a file from +ARGV+, it is ignored by +ARGF+; if you add files to +ARGV+, they are treated as if they were named on the command line. For example: ARGV.replace ["file1"] ARGF.readlines # Returns the contents of file1 as an Array ARGV #=> [] ARGV.replace ["file2", "file3"] ARGF.read # Returns the contents of file2 and file3 If +ARGV+ is empty, +ARGF+ acts as if it contained STDIN, i.e. the data piped to your script. For example: $ echo "glark" | ruby -e 'p ARGF.read' "glark\n" ;T;#0;$@ ;.F;/o;0;1T;2i5;3i=5;Bi;%@;&I" ARGF;F;'@;9I"static VALUE argf_initialize(VALUE argf, VALUE argv) { memset(&ARGF, 0, sizeof(ARGF)); argf_init(&ARGF, argv); return argf; };T;:I"static VALUE;T;;T:ARGF#initialize_copy@ :ARGF#to_s@ :ARGF#inspect@/ :ARGF#argv@: :ARGF#fileno@P :ARGF#to_i@x :ARGF#to_io@ :ARGF#to_write_io@ :ARGF#each@ :ARGF#each_line@ :ARGF#each_byte@E :ARGF#each_char@h :ARGF#each_codepoint@ :ARGF#read@ :ARGF#readpartial@ :ARGF#read_nonblock@ :ARGF#readlines@! :ARGF#to_a@` :ARGF#gets@ :ARGF#readline@ :ARGF#getc@ :ARGF#getbyte@; :ARGF#readchar@W :ARGF#readbyte@s :ARGF#tell@ :ARGF#seek@ :ARGF#rewind@ : ARGF#pos@ :ARGF#pos=@: ARGF#eof@8:ARGF#eof?@`:ARGF#binmode@:ARGF#binmode?@:ARGF#write@:ARGF#print@:ARGF#putc@:ARGF#puts@!:ARGF#printf@@:ARGF#filename@]:ARGF#path@:ARGF#file@:ARGF#skip@:ARGF#close@:ARGF#closed?@:ARGF#lineno@:ARGF#lineno=@):ARGF#inplace_mode@H:ARGF#inplace_mode=@c:ARGF#external_encoding@}:ARGF#internal_encoding@:ARGF#set_encoding@:File#initialize@f;)@:Readline#readline@:Readline.readline@:Readline.input=@:Readline.output=@:Readline.completion_proc=@ :Readline.completion_proc@- :%Readline.quoting_detection_proc=@H :$Readline.quoting_detection_proc@b :#Readline.completion_case_fold=@} :"Readline.completion_case_fold@ :Readline.line_buffer@ :Readline.point@ :Readline.point=@ :Readline.set_screen_size@ :Readline.get_screen_size@% :Readline.vi_editing_mode@@ :Readline.vi_editing_mode?@[ : Readline.emacs_editing_mode@v :!Readline.emacs_editing_mode?@ :*Readline.completion_append_character=@ :)Readline.completion_append_character@ :(Readline.completion_quote_character@ :*Readline.basic_word_break_characters=@ :)Readline.basic_word_break_characters@ :.Readline.completer_word_break_characters=@1 :-Readline.completer_word_break_characters@K :%Readline.basic_quote_characters=@f :$Readline.basic_quote_characters@ :)Readline.completer_quote_characters=@ :(Readline.completer_quote_characters@ :(Readline.filename_quote_characters=@ :'Readline.filename_quote_characters@ :Readline.refresh_line@ :Readline.pre_input_hook=@ :Readline.pre_input_hook@: :Readline.insert_text@U :Readline.delete_text@t :Readline.redisplay@ :Readline.special_prefixes=@ :Readline.special_prefixes@ :Readline::HISTORY@ :'Readline::FILENAME_COMPLETION_PROC@ :'Readline::USERNAME_COMPLETION_PROC@ :Readline::VERSION@" : IO#nread@Z:IO#ready?@5Z: IO#wait@PZ:IO#wait_readable@yZ:IO#wait_writable@Z:IO#wait_priority@Z:IO#nonblock?@Z:IO#nonblock=@[:IO#nonblock@5[:IO::Buffer@j[:IO::Buffer::LockedError@l[: IO::Buffer::AllocationError@[:IO::Buffer::AccessError@[:!IO::Buffer::InvalidatedError@[;@[:IO::Buffer::PAGE_SIZE@[:IO::Buffer::DEFAULT_SIZE@[;@[:IO::Buffer#initialize@\:IO::Buffer#inspect@.\:IO::Buffer#hexdump@:\:IO::Buffer#to_s@F\:IO::Buffer#size@a\:IO::Buffer#valid?@|\:IO::Buffer#transfer@\:IO::Buffer::EXTERNAL@\:IO::Buffer::INTERNAL@\:IO::Buffer::MAPPED@\:IO::Buffer::LOCKED@\:IO::Buffer::PRIVATE@\:IO::Buffer::READONLY@\:IO::Buffer::LITTLE_ENDIAN@\:IO::Buffer::BIG_ENDIAN@\:IO::Buffer::HOST_ENDIAN@]:IO::Buffer::NETWORK_ENDIAN@ ]:IO::Buffer#null?@]:IO::Buffer#empty?@0]:IO::Buffer#external?@K]:IO::Buffer#internal?@Z]:IO::Buffer#mapped?@u]:IO::Buffer#locked?@]:IO::Buffer#readonly?@]:IO::Buffer#locked@]:IO::Buffer#slice@]:IO::Buffer#<=>@]:IO::Buffer#resize@^:IO::Buffer#clear@/^:IO::Buffer#free@P^:IO::Buffer#get_value@k^:IO::Buffer#set_value@^:IO::Buffer#copy@^:IO::Buffer#get_string@^:IO::Buffer#set_string@^:IO::Buffer#read@^:IO::Buffer#pread@_:IO::Buffer#write@_:IO::Buffer#pwrite@*_: IO#raw@Q`: IO#raw!@w`:IO#cooked@`:IO#cooked!@`: IO#getch@`: IO#echo=@`: IO#echo?@ a:IO#console_mode@'a:IO#console_mode=@=a:IO#noecho@Wa:IO#winsize@ra:IO#winsize=@a:IO#iflush@a:IO#oflush@a:IO#ioflush@a: IO#beep@a: IO#goto@a:IO#cursor@a:IO#cursor=@b:IO#cursor_up@b:IO#cursor_down@#b:IO#cursor_left@1b:IO#cursor_right@?b:IO#goto_column@Mb:IO#erase_line@[b:IO#erase_screen@ib:IO#scroll_forward@wb:IO#scroll_backward@b:IO#clear_screen@b:IO#pressed?@b:IO#check_winsize_changed@b:IO#getpass@b:IO.console@b:IO::generic_readable@c:IO::generic_readable#getch@c:!IO::generic_readable#getpass@*c:IO::ConsoleMode@Qd:$IO::ConsoleMode#initialize_copy@Sd:IO::ConsoleMode#echo=@ad:IO::ConsoleMode#raw!@od:IO::ConsoleMode#raw@|d:Process#argv0@:Process.argv0@:Process#setproctitle@:Process.setproctitle@$;*@= ;>@I :Etc::VERSION@K :Etc#getlogin@U :Etc.getlogin@b :Etc#getpwuid@j :Etc.getpwuid@x :Etc#getpwnam@ :Etc.getpwnam@ :Etc#setpwent@ :Etc.setpwent@ :Etc#endpwent@ :Etc.endpwent@ :Etc#getpwent@ :Etc.getpwent@ :Etc#passwd@ :Etc.passwd@ :Etc#getgrgid@ :Etc.getgrgid@ :Etc#getgrnam@:Etc.getgrnam@:Etc#group@:Etc.group@%:Etc#setgrent@-:Etc.setgrent@::Etc#endgrent@B:Etc.endgrent@O:Etc#getgrent@W:Etc.getgrent@d:Etc#sysconfdir@l:Etc.sysconfdir@y:Etc#systmpdir@:Etc.systmpdir@:Etc#uname@:Etc.uname@:Etc#sysconf@:Etc.sysconf@:Etc#confstr@:Etc.confstr@:IO#pathconf@d:Etc#nprocessors@:Etc.nprocessors@:Etc::Passwd@:Struct::Passwd@K:Encoding::Converter@چ;T@:WIN32OLE_TYPE.ole_classes@:WIN32OLE_TYPE.typelibs@2:WIN32OLE_TYPE.progids@H:WIN32OLE_TYPE#initialize@^:WIN32OLE_TYPE#name@:WIN32OLE_TYPE#ole_type@:WIN32OLE_TYPE#guid@:WIN32OLE_TYPE#progid@:WIN32OLE_TYPE#visible?@:WIN32OLE_TYPE#to_s@: WIN32OLE_TYPE#major_version@: WIN32OLE_TYPE#minor_version@:WIN32OLE_TYPE#typekind@:WIN32OLE_TYPE#helpstring@:WIN32OLE_TYPE#src_type@:WIN32OLE_TYPE#helpfile@+:WIN32OLE_TYPE#helpcontext@A:WIN32OLE_TYPE#variables@W:WIN32OLE_TYPE#ole_methods@m:WIN32OLE_TYPE#ole_typelib@{:(WIN32OLE_TYPE#implemented_ole_types@:#WIN32OLE_TYPE#source_ole_types@:(WIN32OLE_TYPE#default_event_sources@:$WIN32OLE_TYPE#default_ole_types@:WIN32OLE_TYPE#inspect@:RubyVM.stat@:RubyVM.keep_script_lines@:RubyVM.keep_script_lines=@6: RubyVM.reset_debug_counters@P:RubyVM.show_debug_counters@]:RubyVM::MJIT@i:RubyVM::MJIT.enabled?@k:RubyVM::MJIT.pause@|:RubyVM::MJIT.resume@:%RubyVM.USAGE_ANALYSIS_INSN_START@:(RubyVM.USAGE_ANALYSIS_OPERAND_START@:)RubyVM.USAGE_ANALYSIS_REGISTER_START@:$RubyVM.USAGE_ANALYSIS_INSN_STOP@:'RubyVM.USAGE_ANALYSIS_OPERAND_STOP@:(RubyVM.USAGE_ANALYSIS_REGISTER_STOP@:'RubyVM.USAGE_ANALYSIS_INSN_RUNNING@:*RubyVM.USAGE_ANALYSIS_OPERAND_RUNNING@:+RubyVM.USAGE_ANALYSIS_REGISTER_RUNNING@:%RubyVM.USAGE_ANALYSIS_INSN_CLEAR@:(RubyVM.USAGE_ANALYSIS_OPERAND_CLEAR@:)RubyVM.USAGE_ANALYSIS_REGISTER_CLEAR@':RubyVM::OPTS@3:RubyVM::INSTRUCTION_NAMES@?:RubyVM::DEFAULT_PARAMS@K:RubyVM.SDR@W:RubyVM.NSDR@e:RubyVM.mtbl@s:RubyVM.mtbl2@;U@;[@":WIN32OLE_PARAM#initialize@$:WIN32OLE_PARAM#name@H:WIN32OLE_PARAM#ole_type@f:#WIN32OLE_PARAM#ole_type_detail@|:WIN32OLE_PARAM#input?@:WIN32OLE_PARAM#output?@:WIN32OLE_PARAM#optional?@:WIN32OLE_PARAM#retval?@:WIN32OLE_PARAM#default@:WIN32OLE_PARAM#to_s@[:WIN32OLE_PARAM#inspect@ :RubyVM::YJIT@:RubyVM::YJIT#blocks_for@:RubyVM::YJIT.blocks_for@:RubyVM::YJIT::Block@: RubyVM::YJIT::Block#address@:RubyVM::YJIT::Block#id@:RubyVM::YJIT::Block#code@:)RubyVM::YJIT::Block#iseq_start_index@:'RubyVM::YJIT::Block#iseq_end_index@:%RubyVM::YJIT::Block#outgoing_ids@:RubyVM::YJIT::Disasm@": RubyVM::YJIT::Disasm#disasm@$;b@9:WIN32OLE_VARIANT.array@;: WIN32OLE_VARIANT#initialize@Z:WIN32OLE_VARIANT#value@v:WIN32OLE_VARIANT#value=@:WIN32OLE_VARIANT#vartype@:WIN32OLE_VARIANT#[]@:WIN32OLE_VARIANT#[]=@:WIN32OLE_VARIANT::Empty@:WIN32OLE_VARIANT::Null@:WIN32OLE_VARIANT::Nothing@:WIN32OLE_VARIANT::NoParam@ ;f@(:WIN32OLE_RECORD#initialize@*:WIN32OLE_RECORD#to_h@N:WIN32OLE_RECORD#typename@\:#WIN32OLE_RECORD#method_missing@j:.WIN32OLE_RECORD#ole_instance_variable_get@:.WIN32OLE_RECORD#ole_instance_variable_set@:WIN32OLE_RECORD#inspect@;r@:WIN32OLE_METHOD#initialize@:WIN32OLE_METHOD#name@: WIN32OLE_METHOD#return_type@,:!WIN32OLE_METHOD#return_vtype@B:'WIN32OLE_METHOD#return_type_detail@X: WIN32OLE_METHOD#invoke_kind@n:WIN32OLE_METHOD#invkind@:WIN32OLE_METHOD#visible?@:WIN32OLE_METHOD#event?@:$WIN32OLE_METHOD#event_interface@:WIN32OLE_METHOD#helpstring@:WIN32OLE_METHOD#helpfile@: WIN32OLE_METHOD#helpcontext@:WIN32OLE_METHOD#dispid@$: WIN32OLE_METHOD#offset_vtbl@:: WIN32OLE_METHOD#size_params@P:$WIN32OLE_METHOD#size_opt_params@f:WIN32OLE_METHOD#params@|:WIN32OLE_METHOD#to_s@!:WIN32OLE_METHOD#inspect@;u@:WIN32OLE_TYPELIB.typelibs@: WIN32OLE_TYPELIB#initialize@:WIN32OLE_TYPELIB#guid@:WIN32OLE_TYPELIB#name@:WIN32OLE_TYPELIB#version@5:#WIN32OLE_TYPELIB#major_version@P:#WIN32OLE_TYPELIB#minor_version@k:WIN32OLE_TYPELIB#path@:WIN32OLE_TYPELIB#ole_types@:!WIN32OLE_TYPELIB#ole_classes@:WIN32OLE_TYPELIB#visible?@:"WIN32OLE_TYPELIB#library_name@:WIN32OLE_TYPELIB#to_s@*:WIN32OLE_TYPELIB#inspect@;v@ ;w@6;z@G:WIN32OLE_VARIABLE#name@I:WIN32OLE_VARIABLE#ole_type@h:&WIN32OLE_VARIABLE#ole_type_detail@~:WIN32OLE_VARIABLE#value@:WIN32OLE_VARIABLE#visible?@:$WIN32OLE_VARIABLE#variable_kind@:WIN32OLE_VARIABLE#varkind@:WIN32OLE_VARIABLE#inspect@:WIN32OLE_VARIABLE#to_s@];@:WIN32OLE#initialize@:WIN32OLE.connect@Q:WIN32OLE.const_load@j:WIN32OLE.ole_free@:!WIN32OLE.ole_reference_count@:WIN32OLE.ole_show_help@:WIN32OLE.codepage@:WIN32OLE.codepage=@:WIN32OLE.locale@:WIN32OLE.locale=@:WIN32OLE.create_guid@3:WIN32OLE.ole_initialize@I:WIN32OLE.ole_uninitialize@W:WIN32OLE#invoke@e:WIN32OLE#[]@:WIN32OLE#_invoke@:WIN32OLE#_getproperty@:WIN32OLE#_setproperty@:WIN32OLE#[]=@:WIN32OLE#ole_free@ :WIN32OLE#each@6:WIN32OLE#method_missing@Q:WIN32OLE#setproperty@j:WIN32OLE#ole_methods@:WIN32OLE#ole_get_methods@:WIN32OLE#ole_put_methods@:WIN32OLE#ole_func_methods@:WIN32OLE#ole_method@:WIN32OLE#ole_method_help@:$WIN32OLE#ole_activex_initialize@:WIN32OLE#ole_type@:WIN32OLE#ole_obj_help@-:WIN32OLE#ole_typelib@8:!WIN32OLE#ole_query_interface@S:WIN32OLE#ole_respond_to?@r:WIN32OLE::VERSION@:WIN32OLE::ARGV@:WIN32OLE::CP_ACP@:WIN32OLE::CP_OEMCP@:WIN32OLE::CP_MACCP@:WIN32OLE::CP_THREAD_ACP@:WIN32OLE::CP_SYMBOL@:WIN32OLE::CP_UTF7@:WIN32OLE::CP_UTF8@:$WIN32OLE::LOCALE_SYSTEM_DEFAULT@:"WIN32OLE::LOCALE_USER_DEFAULT@ ;@t: WIN32OLE_EVENT.message_loop@v:WIN32OLE_EVENT#initialize@:WIN32OLE_EVENT#on_event@:)WIN32OLE_EVENT#on_event_with_outargs@:WIN32OLE_EVENT#off_event@:WIN32OLE_EVENT#unadvise@:WIN32OLE_EVENT#handler=@:WIN32OLE_EVENT#handler@,;@T;@i:Kernel#srand@ :Kernel#rand@ :Random#initialize_copy@k:Random#marshal_dump@{:Random#marshal_load@:Random#state@:Random#left@:Random#==@:Random#initialize@:Random#rand@:Random#bytes@(:Random#seed@G:Random::DEFAULT@b:Random.srand@l:Random.rand@:Random.bytes@:Random.seed@:Random.new_seed@:Random.urandom@ :Random::Formatter@3 :$Random::Formatter#random_number@5 :Random::Formatter#rand@ ;@!:Complex.rectangular@!:Complex.rect@!:Complex.polar@!:Kernel#Complex@ :Complex#real@!:Complex#imaginary@!:Complex#imag@":Complex#-@@2":Complex#+@H":Complex#-@b":Complex#*@|":Complex#/@":Complex#quo@":Complex#fdiv@":Complex#**@":Complex#==@":Complex#<=>@#:Complex#coerce@8#:Complex#abs@H#:Complex#magnitude@f#:Complex#abs2@#:Complex#arg@#:Complex#angle@#:Complex#phase@$:Complex#rectangular@6$:Complex#rect@^$:Complex#polar@$:Complex#conjugate@$:Complex#conj@$:Complex#real?@$:Complex#numerator@ %:Complex#denominator@$%:Complex#hash@?%:Complex#eql?@K%:Complex#to_s@^%:Complex#inspect@y%:Complex#finite?@%:Complex#infinite?@%:Complex#marshal_dump@%:Complex::compatible@%:%Complex::compatible#marshal_load@%:Complex#to_i@%:Complex#to_f@&:Complex#to_r@0&:Complex#rationalize@F&:Complex#to_c@_&:NilClass#to_c@;@&:Numeric#to_c@&;@},:String#to_c@,:Numeric#real@&:Numeric#imaginary@&:Numeric#imag@&:Numeric#abs2@':Numeric#arg@0':Numeric#angle@h':Numeric#phase@':Numeric#rectangular@':Numeric#rect@':Numeric#polar@%(:Numeric#conjugate@@(:Numeric#conj@h(;@0-:Float#arg@2-:Float#angle@j-:Float#phase@-:Complex::I@z&;@m2:Kernel#BigDecimal@ :!BigDecimal.interpret_loosely@o2:BigDecimal.mode@}2:BigDecimal.limit@2:BigDecimal.double_fig@2:BigDecimal._load@2:#BigDecimal.save_exception_mode@2:"BigDecimal.save_rounding_mode@2:BigDecimal.save_limit@ 3:BigDecimal::VERSION@#3:BigDecimal::BASE@/3:BigDecimal::EXCEPTION_ALL@;3:BigDecimal::EXCEPTION_NaN@G3:#BigDecimal::EXCEPTION_INFINITY@S3:$BigDecimal::EXCEPTION_UNDERFLOW@_3:#BigDecimal::EXCEPTION_OVERFLOW@k3:%BigDecimal::EXCEPTION_ZERODIVIDE@w3:BigDecimal::ROUND_MODE@3:BigDecimal::ROUND_UP@3:BigDecimal::ROUND_DOWN@3:BigDecimal::ROUND_HALF_UP@3: BigDecimal::ROUND_HALF_DOWN@3:BigDecimal::ROUND_CEILING@3:BigDecimal::ROUND_FLOOR@3: BigDecimal::ROUND_HALF_EVEN@3:BigDecimal::SIGN_NaN@3:#BigDecimal::SIGN_POSITIVE_ZERO@3:#BigDecimal::SIGN_NEGATIVE_ZERO@3:%BigDecimal::SIGN_POSITIVE_FINITE@4:%BigDecimal::SIGN_NEGATIVE_FINITE@4:'BigDecimal::SIGN_POSITIVE_INFINITE@4:'BigDecimal::SIGN_NEGATIVE_INFINITE@+4:BigDecimal::INFINITY@74:BigDecimal::NAN@C4:BigDecimal#precs@M4:BigDecimal#precision@h4:BigDecimal#scale@4:BigDecimal#precision_scale@4:$BigDecimal#n_significant_digits@4:BigDecimal#add@4:BigDecimal#sub@4:BigDecimal#mult@5:BigDecimal#div@"5:BigDecimal#hash@15:BigDecimal#to_s@L5:BigDecimal#to_i@[5:BigDecimal#to_int@i5:BigDecimal#to_r@v5:BigDecimal#split@5:BigDecimal#+@5:BigDecimal#-@5:BigDecimal#+@@5:BigDecimal#-@@5:BigDecimal#*@5:BigDecimal#/@6:BigDecimal#quo@6:BigDecimal#%@86:BigDecimal#modulo@F6:BigDecimal#remainder@S6:BigDecimal#divmod@a6:BigDecimal#clone@q6:BigDecimal#dup@}6:BigDecimal#to_f@6:BigDecimal#abs@6:BigDecimal#sqrt@6:BigDecimal#fix@6:BigDecimal#round@6:BigDecimal#frac@6:BigDecimal#floor@6:BigDecimal#ceil@6:BigDecimal#power@7:BigDecimal#**@7:BigDecimal#<=>@/7:BigDecimal#==@?7:BigDecimal#===@O7:BigDecimal#eql?@^7:BigDecimal#<@p7:BigDecimal#<=@7:BigDecimal#>@7:BigDecimal#>=@7:BigDecimal#zero?@7:BigDecimal#nonzero?@7:BigDecimal#coerce@8:BigDecimal#inspect@8:BigDecimal#exponent@,8:BigDecimal#sign@:8:BigDecimal#nan?@H8:BigDecimal#infinite?@Y8:BigDecimal#finite?@j8:BigDecimal#truncate@{8:BigDecimal#_dump@8;(@8:BigMath.exp@8:BigMath.log@8:Object::Bignum@n;@8:Integer#coerce@8:Integer::GMP_VERSION@9; @?:Bug::Proc@!?; @{T:#MemoryViewTestUtils#available?@}T:#MemoryViewTestUtils.available?@T:!MemoryViewTestUtils#register@T:!MemoryViewTestUtils.register@T:.MemoryViewTestUtils#item_size_from_format@T:.MemoryViewTestUtils.item_size_from_format@T:*MemoryViewTestUtils#parse_item_format@T:*MemoryViewTestUtils.parse_item_format@T:-MemoryViewTestUtils#get_memory_view_info@T:-MemoryViewTestUtils.get_memory_view_info@T:0MemoryViewTestUtils#fill_contiguous_strides@T:0MemoryViewTestUtils.fill_contiguous_strides@U:2MemoryViewTestUtils#ref_count_while_exporting@ U:2MemoryViewTestUtils.ref_count_while_exporting@U:-MemoryViewTestUtils#extract_item_members@!U:-MemoryViewTestUtils.extract_item_members@2U:*MemoryViewTestUtils::ExportableString@8U:5MemoryViewTestUtils::ExportableString#initialize@:U:.MemoryViewTestUtils::MultiDimensionalView@WU:9MemoryViewTestUtils::MultiDimensionalView#initialize@YU:1MemoryViewTestUtils::MultiDimensionalView#[]@mU:Bug::NotImplement@3?:Bug#funcall@R?:Bug.funcall@`?:Bug#notimplement@f?:Bug.notimplement@t?:#Bug::NotImplement#notimplement@5?; @U:Num2int#NUM2SHORT@U:Num2int.NUM2SHORT@U:Num2int#NUM2USHORT@U:Num2int.NUM2USHORT@U:Num2int#NUM2INT@U:Num2int.NUM2INT@U:Num2int#NUM2UINT@U:Num2int.NUM2UINT@U:Num2int#NUM2LONG@U:Num2int.NUM2LONG@U:Num2int#NUM2ULONG@V:Num2int.NUM2ULONG@V:Num2int#NUM2LL@V:Num2int.NUM2LL@)V:Num2int#NUM2ULL@/V:Num2int.NUM2ULL@>V:Num2int#FIX2SHORT@DV:Num2int.FIX2SHORT@SV:Num2int#FIX2INT@YV:Num2int.FIX2INT@hV:Num2int#FIX2UINT@nV:Num2int.FIX2UINT@}V:Num2int#FIX2LONG@V:Num2int.FIX2LONG@V:Num2int#FIX2ULONG@V:Num2int.FIX2ULONG@V;) @V:Dir.foreach@V:Dir.entries@W:Dir.each_child@?W:Dir.children@W:Dir#fileno@W: Dir#path@W:Dir#to_path@X:Dir#inspect@.X: Dir#read@IX: Dir#each@eX:Dir#each_child@X:Dir#children@X:Dir#rewind@X: Dir#tell@X: Dir#seek@Y: Dir#pos@2Y: Dir#pos=@YY:Dir#close@xY:Dir.chdir@Y:Dir.getwd@Y: Dir.pwd@Y:Dir.chroot@Z:Dir.mkdir@3Z:Dir.rmdir@QZ:Dir.delete@Z:Dir.unlink@Z: Dir.home@[:Dir.exist?@'[:Dir.exists?@D[:Dir.empty?@W[:File.fnmatch@f:File.fnmatch?@f:*RubyVM::InstructionSequence.iseq_load@:Bug::EnumeratorKw@z?:Bug::EnumeratorKw#m@|?:IO.io_wait@d:IO.io_maybe_wait@d:IO.io_maybe_wait_readable@d:IO.io_maybe_wait_writable@d:Kernel#at_exit@&:Bug::Thread@?:Bug::Thread.runnable_sleep@?:Bug::Thread.ubf_async_safe@?;0@[:Range#initialize@[:Range#initialize_copy@[: Range#==@[:Range#===@[:Range#eql?@[:Range#hash@ \:Range#each@(\:Range#step@P\: Range#%@\:Range#bsearch@\:Range#begin@\:Range#end@\:Range#first@\:Range#last@)]:Range#min@T]:Range#max@]:Range#minmax@]:Range#size@(^:Range#to_a@D^:Range#entries@_^:Range#to_s@y^:Range#inspect@^:Range#exclude_end?@^:Range#member?@^:Range#include?@^:Range#cover?@_:Range#count@5_:#Thread#__infinite_loop_dlsym__@!:Bug::Iter@?:Bug::Iter::Breakable@?:$Bug::Iter::Breakable#iter_break@?:$Bug::Iter::Breakable.iter_break@?:*Bug::Iter::Breakable#iter_break_value@?:*Bug::Iter::Breakable.iter_break_value@?;5 @_:Marshal#dump@_:Marshal.dump@_:Marshal::MAJOR_VERSION@_:Marshal::MINOR_VERSION@_:Bug::Iter::Yield@@:!Bug::Iter::Yield#yield_block@@;L @`:Enumerator::Lazy@`;\ @^k:Enumerator::Chain@ f:#Enumerator::ArithmeticSequence@f:Object#to_enum@{:Object#enum_for@:Enumerator#initialize@@h:Enumerator#initialize_copy@_h:Enumerator#each@oh:Enumerator#each_with_index@h: Enumerator#each_with_object@h:Enumerator#with_index@#i:Enumerator#with_object@Mi:Enumerator#next_values@i:Enumerator#peek_values@i:Enumerator#next@i:Enumerator#peek@i:Enumerator#feed@i:Enumerator#rewind@j:Enumerator#inspect@/j:Enumerator#size@Jj:Enumerator#+@gj;@y,:Enumerable#chain@{,:Enumerable#lazy@,:%Enumerator::Lazy#_enumerable_map@`:)Enumerator::Lazy#_enumerable_collect@`:*Enumerator::Lazy#_enumerable_flat_map@`:0Enumerator::Lazy#_enumerable_collect_concat@`:(Enumerator::Lazy#_enumerable_select@`:*Enumerator::Lazy#_enumerable_find_all@`:(Enumerator::Lazy#_enumerable_filter@`:,Enumerator::Lazy#_enumerable_filter_map@`:(Enumerator::Lazy#_enumerable_reject@`:&Enumerator::Lazy#_enumerable_grep@`:(Enumerator::Lazy#_enumerable_grep_v@`:%Enumerator::Lazy#_enumerable_zip@ a:&Enumerator::Lazy#_enumerable_take@a:,Enumerator::Lazy#_enumerable_take_while@a:&Enumerator::Lazy#_enumerable_drop@*a:,Enumerator::Lazy#_enumerable_drop_while@5a:&Enumerator::Lazy#_enumerable_uniq@@a:,Enumerator::Lazy#_enumerable_with_index@Ka: Enumerator::Lazy#initialize@va:Enumerator::Lazy#to_enum@a:Enumerator::Lazy#enum_for@a:Enumerator::Lazy#eager@1b:Enumerator::Lazy#map@Lb:Enumerator::Lazy#collect@tb:Enumerator::Lazy#flat_map@b:$Enumerator::Lazy#collect_concat@b:Enumerator::Lazy#select@b:Enumerator::Lazy#find_all@c:Enumerator::Lazy#filter@Sc: Enumerator::Lazy#filter_map@c:Enumerator::Lazy#reject@c:Enumerator::Lazy#grep@c:Enumerator::Lazy#grep_v@c:Enumerator::Lazy#zip@d:Enumerator::Lazy#take@@d: Enumerator::Lazy#take_while@Zd:Enumerator::Lazy#drop@ud: Enumerator::Lazy#drop_while@d:Enumerator::Lazy#lazy@d:Enumerator::Lazy#chunk@d:"Enumerator::Lazy#slice_before@d:!Enumerator::Lazy#slice_after@e: Enumerator::Lazy#slice_when@(e:!Enumerator::Lazy#chunk_while@Ee:Enumerator::Lazy#uniq@be:Enumerator::Lazy#compact@e: Enumerator::Lazy#with_index@e:Enumerator::Lazy#to_a@e:Enumerator::Lazy#force@e:StopIteration#result@`k:Enumerator::Generator@j:%Enumerator::Generator#initialize@j:*Enumerator::Generator#initialize_copy@j:Enumerator::Generator#each@j:Enumerator::Yielder@j:#Enumerator::Yielder#initialize@j:Enumerator::Yielder#yield@j:Enumerator::Yielder#<<@j: Enumerator::Yielder#to_proc@j:Enumerator::Producer@ k:Enumerator::Producer#each@k:Enumerator.produce@,k:!Enumerator::Chain#initialize@ f:&Enumerator::Chain#initialize_copy@*f:Enumerator::Chain#each@:f:Enumerator::Chain#size@gf:Enumerator::Chain#rewind@f:Enumerator::Chain#inspect@f:)Enumerator::ArithmeticSequence#begin@f:'Enumerator::ArithmeticSequence#end@f:0Enumerator::ArithmeticSequence#exclude_end?@f:(Enumerator::ArithmeticSequence#step@f:)Enumerator::ArithmeticSequence#first@f:(Enumerator::ArithmeticSequence#last@"g:+Enumerator::ArithmeticSequence#inspect@Ng:&Enumerator::ArithmeticSequence#==@ig:'Enumerator::ArithmeticSequence#===@g:(Enumerator::ArithmeticSequence#eql?@g:(Enumerator::ArithmeticSequence#hash@g:(Enumerator::ArithmeticSequence#each@g:(Enumerator::ArithmeticSequence#size@h: Bug::Iter.parse_depth_limit@"@:!Bug::Iter.parse_depth_limit=@/@:Thread::Backtrace@!:Thread::Backtrace.limit@!: Thread::Backtrace::Location@!:'Thread::Backtrace::Location#lineno@!:&Thread::Backtrace::Location#label@!:+Thread::Backtrace::Location#base_label@!:%Thread::Backtrace::Location#path@!:.Thread::Backtrace::Location#absolute_path@ ":%Thread::Backtrace::Location#to_s@":(Thread::Backtrace::Location#inspect@)":Kernel#caller@E:Kernel#caller_locations@y:Bug::Regexp@M@;_ @k:Kernel#eval@:Kernel#local_variables@:Kernel#iterator?@:Kernel#block_given?@:Kernel#catch@:Kernel#throw@2:Kernel#loop@K:BasicObject#instance_eval@:BasicObject#instance_exec@:BasicObject#method_missing@:BasicObject#__send__@,:Object#send@=:Object#public_send@:Module#module_exec@@:Module#class_exec@6A:Module#module_eval@lA:Module#class_eval@A:"UncaughtThrowError#initialize@k:UncaughtThrowError#tag@k:UncaughtThrowError#value@k:UncaughtThrowError#to_s@k:Bug#funcall_callback@&D:Bug.funcall_callback@6D:Bug::File@D:Bug::File::Fs#fsname@@D:Bug::File::Fs.fsname@PD:Bug::File::Fs#noatime?@VD:Bug::File::Fs.noatime?@jD: Time::tm@|: Time.utc@:Time.local@:Time#to_i@4:Time#to_f@\:Time#to_r@w: Time#<=>@:Time#eql?@:Time#hash@:Time#initialize_copy@:Time#localtime@:Time#gmtime@": Time#utc@J:Time#getlocal@q:Time#getgm@:Time#getutc@:Time#ctime@:Time#asctime@":Time#to_s@I:Time#inspect@d:Time#to_a@: Time#+@: Time#-@:Time#round@:Time#floor@:Time#ceil@#: Time#sec@A: Time#min@\:Time#hour@w:Time#mday@: Time#day@: Time#mon@:Time#month@ :Time#year@0:Time#wday@K:Time#yday@f:Time#isdst@:Time#dst?@:Time#zone@:Time#gmtoff@:Time#gmt_offset@ :Time#utc_offset@T:Time#utc?@:Time#gmt?@:Time#sunday?@:Time#monday?@:Time#tuesday?@ :Time#wednesday?@(:Time#thursday?@C:Time#friday?@^:Time#saturday?@y:Time#tv_sec@:Time#tv_usec@:Time#usec@:Time#tv_nsec@ :Time#nsec@2:Time#subsec@Y:Time#strftime@t:Time#_dump@:Time#marshal_dump@:Time#marshal_load@:Bug::File::Stat@D:Bug::File::Stat#for_fd@D:Bug::File::Stat.for_fd@D:Bug::File::Stat#for_path@D:Bug::File::Stat.for_path@D;b @l;c @l;,@;d @l;f @6m;g @m;h @m;5@/;] @k;j @m;k @)n;l @=n;m @Qn;n @~n;o @n;}@n;s @o;t @o;@[;u @Hp;v @\p;x @pp;y @p:!Encoding::CompatibilityError@ņ:Bug::Hash@gE;z @p;{ @q:#Numeric#singleton_method_added@(:Numeric#coerce@(:Numeric#clone@(:Numeric#dup@(:Numeric#i@(:Numeric#+@@):Numeric#-@@)):Numeric#<=>@D):Numeric#eql?@c):Numeric#fdiv@):Numeric#div@):Numeric#divmod@):Numeric#%@):Numeric#modulo@):Numeric#remainder@*:Numeric#abs@,*:Numeric#magnitude@G*:Numeric#to_int@a*:Numeric#zero?@|*:Numeric#nonzero?@*:Numeric#floor@*:Numeric#ceil@*:Numeric#round@*:Numeric#truncate@+:Numeric#step@3+:Numeric#positive?@+:Numeric#negative?@+:Integer.sqrt@9:Integer.try_convert@#9:Integer#to_s@39:Integer#inspect@O9:Integer#allbits?@Z9:Integer#anybits?@y9:Integer#nobits?@9:Integer#upto@9:Integer#downto@9:Integer#times@::Integer#succ@;::Integer#next@D::Integer#pred@M::Integer#chr@V::Integer#to_f@::Integer#floor@::Integer#ceil@::Integer#truncate@::Integer#round@::Integer#<=>@;:Integer#+@=;:Integer#-@W;:Integer#*@q;:Integer#/@;:Integer#div@;:Integer#%@;:Integer#modulo@;:Integer#remainder@;:Integer#divmod@<:Integer#fdiv@0<:Integer#**@O<:Integer#pow@i<:Integer#===@<:Integer#==@<:Integer#>@<:Integer#>=@<:Integer#<@=:Integer#<=@5=:Integer#&@T=:Integer#|@s=:Integer#^@=:Integer#[]@=:Integer#<<@=:Integer#>>@>:Integer#digits@1>:Object::Fixnum@:Float::RADIX@-:Float::MANT_DIG@-:Float::DIG@-:Float::MIN_EXP@-:Float::MAX_EXP@.:Float::MIN_10_EXP@.:Float::MAX_10_EXP@ .:Float::MIN@,.:Float::MAX@8.:Float::EPSILON@D.:Float::INFINITY@P.:Float::NAN@\.:Float#to_s@h.:Float#inspect@.:Float#coerce@.: Float#+@.: Float#-@.: Float#*@.: Float#/@/:Float#quo@&/:Float#fdiv@E/: Float#%@c/:Float#modulo@/:Float#divmod@/: Float#**@/: Float#==@/:Float#===@/:Float#<=>@/: Float#>@0: Float#>=@10: Float#<@P0: Float#<=@o0:Float#eql?@0:Float#hash@0:Float#to_i@0:Float#to_int@0:Float#floor@0:Float#ceil@ 1:Float#round@*1:Float#truncate@M1:Float#nan?@m1:Float#infinite?@1:Float#finite?@1:Float#next_float@1:Float#prev_float@1:Bug::Hash#delete!@iE:Enumerable#to_a@,:Enumerable#entries@,:Enumerable#to_h@,:Enumerable#sort@-:Enumerable#sort_by@>-:Enumerable#grep@f-:Enumerable#grep_v@-:Enumerable#count@-:Enumerable#find@ .:Enumerable#detect@9.:Enumerable#find_index@h.:Enumerable#find_all@.:Enumerable#select@.:Enumerable#filter@.:Enumerable#filter_map@/:Enumerable#reject@@/:Enumerable#collect@h/:Enumerable#map@/:Enumerable#flat_map@/:Enumerable#collect_concat@/:Enumerable#inject@0:Enumerable#reduce@]0:Enumerable#partition@0:Enumerable#group_by@0:Enumerable#tally@1:Enumerable#first@)1:Enumerable#all?@T1:Enumerable#any?@1:Enumerable#one?@1:Enumerable#none?@ 2:Enumerable#min@H2:Enumerable#max@2:Enumerable#minmax@2:Enumerable#min_by@3:Enumerable#max_by@J3:Enumerable#minmax_by@3:Enumerable#member?@3:Enumerable#include?@3:Enumerable#each_with_index@3:Enumerable#reverse_each@4:Enumerable#each_entry@L4:Enumerable#each_slice@y4:Enumerable#each_cons@4: Enumerable#each_with_object@4:Enumerable#zip@5:Enumerable#take@25:Enumerable#take_while@Q5:Enumerable#drop@y5:Enumerable#drop_while@5:Enumerable#cycle@5:Enumerable#chunk@5:Enumerable#slice_before@ 6:Enumerable#slice_after@06:Enumerable#slice_when@V6:Enumerable#chunk_while@r6:Enumerable#sum@6:Enumerable#uniq@6:Enumerable#compact@6: Bug::Bar@E:Bug::Bar#to_ary@E:Bug::Array@E:Bug::Array.__resize__@E:%Random::Formatter#exec_recursive@ :+Random::Formatter#exec_recursive_outer@ !;@q:Kernel#Rational@l:Rational#numerator@q:Rational#denominator@2q:Rational#-@@Mq:Rational#+@cq:Rational#-@q:Rational#*@q:Rational#/@q:Rational#quo@q:Rational#fdiv@r:Rational#**@:r:Rational#<=>@Cr:Rational#==@er:Rational#coerce@r:Rational#positive?@r:Rational#negative?@r:Rational#abs@r:Rational#magnitude@r:Rational#floor@s:Rational#ceil@#s:Rational#truncate@As:Rational#round@_s:Rational#to_i@~s:Rational#to_f@s:Rational#to_r@s:Rational#rationalize@s:Rational#hash@s:Rational#to_s@t:Rational#inspect@t:Rational#marshal_dump@7t:Rational::compatible@Et:&Rational::compatible#marshal_load@Gt:Integer#gcd@K>:Integer#lcm@j>:Integer#gcdlcm@>:Numeric#numerator@,:Numeric#denominator@+,:Numeric#quo@F,:Integer#numerator@>:Integer#denominator@>:Float#numerator@1:Float#denominator@2:NilClass#to_r@0:NilClass#rationalize@F:Integer#to_r@>:Integer#rationalize@>:Float#to_r@,2:Float#rationalize@B2:String#to_r@,:Bug::TypedData@E:Bug::TypedData.check@E:Bug::TypedData.make@E;| @wt:MemoryStatus#_updateo;4;5F;6;;;;&I"MemoryStatus#_update;T;7[;[[@ti;T;: _update;0;[;{;IC; " ;T;[;![;"@;#0;$@;%o;( ;)0;*0;+0;:MemoryStatus;%@;-0;0;9I"static VALUE read_status(VALUE self) { VALUE size = INT2FIX(0); #if defined __APPLE__ # define HAVE_RSS 1 VALUE rss; kern_return_t error; # if defined MACH_TASK_BASIC_INFO const task_flavor_t flavor = MACH_TASK_BASIC_INFO; mach_msg_type_number_t out_count = MACH_TASK_BASIC_INFO_COUNT; mach_task_basic_info_data_t taskinfo; # else const task_flavor_t flavor = TASK_BASIC_INFO; mach_msg_type_number_t out_count = TASK_BASIC_INFO_COUNT; task_basic_info_data_t taskinfo; # endif taskinfo.virtual_size = 0; taskinfo.resident_size = 0; error = task_info(mach_task_self(), flavor, (task_info_t)&taskinfo, &out_count); if (error != KERN_SUCCESS) return Qnil; #ifndef ULL2NUM /* "long long" does not exist here, use size_t instead. */ #define ULL2NUM SIZET2NUM #endif size = ULL2NUM(taskinfo.virtual_size); rss = ULL2NUM(taskinfo.resident_size); rb_struct_aset(self, INT2FIX(1), rss); #elif defined _WIN32 # define HAVE_RSS 1 # define HAVE_PEAK 1 VALUE rss, peak; PROCESS_MEMORY_COUNTERS c; c.cb = sizeof(c); if (!GetProcessMemoryInfo(GetCurrentProcess(), &c, c.cb)) return Qnil; size = SIZET2NUM(c.PagefileUsage); rss = SIZET2NUM(c.WorkingSetSize); peak = SIZET2NUM(c.PeakWorkingSetSize); rb_struct_aset(self, INT2FIX(2), peak); #endif #ifdef HAVE_RSS rb_struct_aset(self, INT2FIX(1), rss); #endif rb_struct_aset(self, INT2FIX(0), size); return self; };T;:I"static VALUE;T;;T:Bug#start@E:Bug.start@F:Bug#postponed_job_register@ F:Bug.postponed_job_register@F:#Bug#postponed_job_register_one@ F:#Bug.postponed_job_register_one@/F:"Bug#postponed_job_call_direct@5F:"Bug.postponed_job_call_direct@DF:+Bug#postponed_job_register_in_c_thread@JF:+Bug.postponed_job_register_in_c_thread@YF; @t; @w; @y; @y;3@y: Proc.new@y:Proc#call@z: Proc#[]@*z: Proc#===@8z:Proc#yield@Gz:Proc#to_proc@Uz:Proc#arity@pz:Proc#clone@z: Proc#dup@z:Proc#hash@z:Proc#to_s@z:Proc#inspect@z:Proc#lambda?@z:Proc#binding@z:Proc#curry@{: Proc#<<@D{: Proc#>>@c{: Proc#==@{:Proc#eql?@{:Proc#source_location@{:Proc#parameters@{:Proc#ruby2_keywords@|:LocalJumpError#exit_value@y:LocalJumpError#reason@y:Kernel#proc@:Kernel#lambda@:Method#==@t:Method#eql?@t:Method#hash@t:Method#clone@u:Method#call@u:Method#===@7u:Method#curry@Vu:Method#<<@u:Method#>>@u:Method#[]@u:Method#arity@u:Method#inspect@u:Method#to_s@!v:Method#to_proc@Hv:Method#receiver@cv:Method#name@~v:Method#original_name@v:Method#owner@v:Method#unbind@v:Method#source_location@v:Method#parameters@v:Method#super_method@ w:Method#public?@#w:Method#protected?@>w:Method#private?@Yw:Object#method@:Object#public_method@:Object#singleton_method@:UnboundMethod#==@w:UnboundMethod#eql?@w:UnboundMethod#hash@w:UnboundMethod#clone@w:UnboundMethod#arity@x:UnboundMethod#inspect@+x:UnboundMethod#to_s@Rx:UnboundMethod#name@yx: UnboundMethod#original_name@x:UnboundMethod#owner@x:UnboundMethod#bind@x:UnboundMethod#bind_call@x:"UnboundMethod#source_location@x:UnboundMethod#parameters@y:UnboundMethod#super_method@)y:UnboundMethod#public?@>y:UnboundMethod#protected?@Xy:UnboundMethod#private?@ry:Module#instance_method@ B:"Module#public_instance_method@'B:Module#define_method@AB:#Object#define_singleton_method@; @A|:Binding#clone@C|:Binding#dup@Q|:Binding#eval@_|:Binding#local_variables@}|:Binding#local_variable_get@|:Binding#local_variable_set@|:$Binding#local_variable_defined?@|:Binding#receiver@|:Binding#source_location@}:Kernel#binding@:Random::Formatter.s@!:Random::Formatter.v@*!:Random::Formatter.q@8!:Random::Formatter.call@F!:Random::Formatter.sncount@S!:Bug::Symbol@_F:Bug::Symbol.find@aF:Bug::Symbol.pinneddown?@pF:Bug::Symbol.iv_get@F;@?_:Comparable#==@A_:Comparable#>@a_:Comparable#>=@_:Comparable#<@_:Comparable#<=@_:Comparable#between?@_:Comparable#clamp@`:Bug::Symbol.attrset@F:Bug::Symbol.id2str@F:Bug::Symbol.static?@F:Bug::Symbol.dynamic?@F:Bug::Symbol.pindown@F; @A}; @N}; @Z}; @f}; @r}; @~}; @}; @}; @}:Bug::Time@F:%Bug::Time.reset_leap_second_info@F:Bug::Time.nano_new@F:Bug::Time.timespec_new@G:Bug::Time.timespec_now@G; @}:Kernel#trap@:Signal#trap@}:Signal.trap@}:Signal#list@~:Signal.list@)~:Signal#signame@>~:Signal.signame@]~:SignalException#initialize@8m:SignalException#signo@[m:Interrupt#initialize@m:Bug.unp_st_foreach_check@dG:Bug.unp_st_foreach@sG:Bug::File::Stat#st_update@D:Bug::File::Stat#initialize@D:Bug::File::Stat#[]@D:Bug::File::Stat#[]=@D:Bug::File::Stat#each@D:Bug::File::Stat#update@D:Bug::File::Stat#size@E: Bug::File::Stat#delete_safe@E; @~:File::Stat@ g:File.directory?@k:File.exist?@k:File.exists?@l:File.readable?@%l:File.readable_real?@Dl:File.world_readable?@cl:File.writable?@l:File.writable_real?@l:File.world_writable?@l:File.executable?@l:File.executable_real?@m:File.file?@m:File.zero?@>m:File.empty?@]m:File.size?@{m:File.size@m:File.owned?@m:File.grpowned?@m:File.pipe?@m:File.symlink?@n:File.socket?@6n:File.blockdev?@Un:File.chardev?@tn:File.setuid?@n:File.setgid?@n:File.sticky?@n:File.identical?@n:File.stat@o:File.lstat@-o:File.ftype@Go:File.atime@fo:File.mtime@o:File.ctime@o:File.birthtime@o:File.utime@o:File.chmod@o:File.chown@p:File.lchmod@;p:File.lchown@]p:File.lutime@p:File.link@p:File.symlink@p:File.readlink@p:File.unlink@q:File.delete@6q:File.rename@fq:File.umask@q:File.truncate@q:File.mkfifo@q:File.expand_path@q:File.absolute_path@r:File.absolute_path?@0r:File.realpath@Or:File.realdirpath@hr:File.basename@r:File.dirname@r:File.extname@r:File.path@r:File::Separator@r:File::SEPARATOR@s:File.split@ s:File.join@+s:File::ALT_SEPARATOR@Ls:File::PATH_SEPARATOR@Ys: IO#stat@d:File#lstat@es:File#atime@{s:File#mtime@s:File#ctime@s:File#birthtime@s:File#size@s:File#chmod@s:File#chown@t:File#truncate@5t:File#flock@Tt:File::Constants@e:File::Constants::RDONLY@e:File::Constants::WRONLY@e:File::Constants::RDWR@e:File::Constants::APPEND@e:File::Constants::CREAT@e:File::Constants::EXCL@e:File::Constants::NONBLOCK@e:File::Constants::TRUNC@e:File::Constants::NOCTTY@e:File::Constants::BINARY@e:"File::Constants::SHARE_DELETE@e:File::Constants::SYNC@ f:File::Constants::DSYNC@f:File::Constants::RSYNC@!f:File::Constants::NOFOLLOW@-f:File::Constants::NOATIME@9f:File::Constants::DIRECT@Ef:File::Constants::TMPFILE@Qf:File::Constants::LOCK_SH@]f:File::Constants::LOCK_EX@if:File::Constants::LOCK_UN@uf:File::Constants::LOCK_NB@f:File::Constants::NULL@f:File#path@tt:File#to_path@t:Kernel#test@2:File::Stat#initialize@ g:File::Stat#initialize_copy@'g:File::Stat#<=>@7g:File::Stat#dev@Yg:File::Stat#dev_major@tg:File::Stat#dev_minor@g:File::Stat#ino@g:File::Stat#mode@g:File::Stat#nlink@g:File::Stat#uid@g:File::Stat#gid@h:File::Stat#rdev@1h:File::Stat#rdev_major@Mh:File::Stat#rdev_minor@hh:File::Stat#size@h:File::Stat#blksize@h:File::Stat#blocks@h:File::Stat#atime@h:File::Stat#mtime@h:File::Stat#ctime@ i:File::Stat#birthtime@'i:File::Stat#inspect@Bi:File::Stat#ftype@]i:File::Stat#directory?@xi:File::Stat#readable?@i:File::Stat#readable_real?@i:File::Stat#world_readable?@i:File::Stat#writable?@i:File::Stat#writable_real?@j:File::Stat#world_writable?@j:File::Stat#executable?@7j: File::Stat#executable_real?@Rj:File::Stat#file?@mj:File::Stat#zero?@j:File::Stat#size?@j:File::Stat#owned?@j:File::Stat#grpowned?@j:File::Stat#pipe?@j:File::Stat#symlink?@k:File::Stat#socket?@+k:File::Stat#blockdev?@Fk:File::Stat#chardev?@ak:File::Stat#setuid?@|k:File::Stat#setgid?@k:File::Stat#sticky?@k:Bug::Time#rstruct_len@&G: RubyVM::InstructionSequence@R:(RubyVM::InstructionSequence#inspect@T:'RubyVM::InstructionSequence#disasm@c:,RubyVM::InstructionSequence#disassemble@:%RubyVM::InstructionSequence#to_a@:%RubyVM::InstructionSequence#eval@:*RubyVM::InstructionSequence#to_binary@;@;@:%RubyVM::InstructionSequence#path@;:.RubyVM::InstructionSequence#absolute_path@I:&RubyVM::InstructionSequence#label@W:+RubyVM::InstructionSequence#base_label@e:-RubyVM::InstructionSequence#first_lineno@s:-RubyVM::InstructionSequence#trace_points@:+RubyVM::InstructionSequence#each_child@:-RubyVM::InstructionSequence#marshal_dump@:-RubyVM::InstructionSequence#marshal_load@:%RubyVM::InstructionSequence.load@:(RubyVM::InstructionSequence.compile@:$RubyVM::InstructionSequence.new@:-RubyVM::InstructionSequence.compile_file@:/RubyVM::InstructionSequence.compile_option@6:0RubyVM::InstructionSequence.compile_option=@L:'RubyVM::InstructionSequence.disasm@f:,RubyVM::InstructionSequence.disassemble@:#RubyVM::InstructionSequence.of@:-RubyVM::InstructionSequence#script_lines@:Bug::Time.new_duplicate@3G:"Bug::Time.new_duplicate_under@DG; @~:Ripper::Version@~:Ripper#initialize@~:Ripper#parse@~:Ripper#column@~:Ripper#filename@~:Ripper#lineno@:Ripper#state@1:Ripper#token@M:Ripper#end_seen?@i:Ripper#encoding@:Ripper#yydebug@:Ripper#yydebug=@:Ripper#debug_output@:Ripper#debug_output=@:Ripper#error?@:Ripper#assert_Qundef@+:Ripper#rawVALUE@>:Ripper#validate_object@O:Ripper.dedent_string@`:Ripper#dedent_string@:Ripper.lex_state_name@; @:Bug::Struct@G; @; @;C@`@:Regexp.compile@b@:Regexp.quote@q@:Regexp.escape@@:Regexp.union@@:Regexp.last_match@@:Regexp.try_convert@*A:Regexp#initialize@IA:Regexp#initialize_copy@A:Regexp#hash@A:Regexp#eql?@A:Regexp#==@A:Regexp#=~@B:Regexp#===@>B: Regexp#~@]B:Regexp#match@{B:Regexp#match?@B:Regexp#to_s@B:Regexp#inspect@B:Regexp#source@C:Regexp#casefold?@5C:Regexp#options@PC:Regexp#encoding@kC; @҄:Encoding#to_s@Ԅ:Encoding#inspect@:Encoding#name@:Encoding#names@>:Encoding#dummy?@Y:Encoding#ascii_compatible?@t:Encoding#replicate@:Encoding.list@:Encoding.name_list@Ʌ:Encoding.aliases@:Encoding.find@:Encoding.compatible?@:Encoding#_dump@7:Encoding._load@F:Encoding.default_external@V:Encoding.default_external=@l:Encoding.default_internal@:Encoding.default_internal=@:Encoding.locale_charmap@:Regexp#fixed_encoding?@C:Regexp#names@C:Regexp#named_captures@C:Regexp::IGNORECASE@C:Regexp::EXTENDED@C:Regexp::MULTILINE@C:Regexp::FIXEDENCODING@C:Regexp::NOENCODING@D:MatchData#initialize_copy@:MatchData#regexp@΁:MatchData#names@:MatchData#size@:MatchData#length@,:MatchData#offset@S:MatchData#begin@r:MatchData#end@:MatchData#match@:MatchData#match_length@Ђ:MatchData#to_a@:MatchData#[]@ :MatchData#captures@Y:MatchData#named_captures@t:MatchData#values_at@:MatchData#pre_match@:MatchData#post_match@ʃ:MatchData#to_s@:MatchData#inspect@:MatchData#string@:MatchData#hash@6:MatchData#eql?@Q:MatchData#==@:Bug::Struct#get@G: Bug::VM@2K:Bug::VM.register_at_exit@4K:Bug.load_protect@RK:Kernel#load@S:Kernel#require@u:Kernel#require_relative@:Module#autoload@iB:Module#autoload?@B:Kernel#autoload@:Kernel#autoload?@:#Test_PathToClass.path_to_classo;4;5F;6;;;;&I"#Test_PathToClass.path_to_class;T;7[[I" path;T0;[[I"-ext/-test-/path_to_class/path_to_class.c;Ti;T;:path_to_class;0;[;{;IC; " ;T;[;![;"@;#0;$@ ;%o;( ;)0;*0;+0;:Test_PathToClass;%@;-0;0;9I"_static VALUE path_to_class(VALUE klass, VALUE path) { return rb_path_to_class(path); };T;:I"static VALUE;T;;T:Bug::Float@`K;v@G:Struct.new@G:Struct.keyword_init?@H:Struct.members@H:Struct#initialize@4H:Struct#initialize_copy@AH:Struct#==@QH:Struct#eql?@pH:Struct#hash@H:Struct#inspect@H:Struct#to_s@H:Struct#to_a@H:Struct#to_h@H:Struct#values@I:Struct#size@0I:Struct#length@KI:Struct#each@eI:Struct#each_pair@I:Struct#[]@I:Struct#[]=@I:Struct#select@ J:Struct#filter@2J:Struct#values_at@ZJ:Struct#members@J:Struct#dig@J:Struct#deconstruct@J:Struct#deconstruct_keys@J: Bug::Float.system_nextafter@bK:!Bug::Float.missing_nextafter@sK:Bug::Rational@K:Bug::Rational.gcd_normal@K:Bug::Rational.gcd_gmp@K:Bug::Rational.raw@K:/Enumerator::ArithmeticSequence.__extract__@h:)Bug#tracepoint_track_objspace_events@K:)Bug.tracepoint_track_objspace_events@K:6Bug#tracepoint_specify_normal_and_internal_events@K:6Bug.tracepoint_specify_normal_and_internal_events@L:#Bug::File#after_gc_start_hook=@,E:#Bug::File.after_gc_start_hook=@I" return;F;?@;0;@[@L;$@0;![;"@;#0;$@0;Bi;%o;;IC;[ @0o;4;5F;6;;;;&I"GC::Profiler.enable;F;7[;[;F;: enable;;;[;{;IC; " ;T;[;![;"@;#0;$@>;%@<;;To;4;5F;6;;;;&I"GC::Profiler.raw_data;F;7[;[;F;: raw_data;;;[;{;IC; " ;T;[;![;"@;#0;$@G;%@<;;To;4;5F;6;;;;&I"GC::Profiler.disable;F;7[;[;F;: disable;;;[;{;IC; " ;T;[;![;"@;#0;$@P;%@<;;To;4;5F;6;;;;&I"GC::Profiler.clear;F;7[;[;F;;;;;[;{;IC; " ;T;[;![;"@;#0;$@Y;%@<;;To;4;5F;6;;;;&I"GC::Profiler.result;F;7[;[;F;;[ ;;;[;{;IC; " ;T;[;![;"@;#0;$@b;%@<;;To;4;5F;6;;;;&I"GC::Profiler.report;F;7[;[;F;: report;;;[;{;IC; " ;T;[;![;"@;#0;$@k;%@<;;To;4;5F;6;;;;&I"GC::Profiler.total_time;F;7[;[;F;:total_time;;;[;{;IC; " ;T;[;![;"@;#0;$@t;%@<;;T; @<; IC;[; @<; IC;[; @<; IC;{;IC;{;T;IC;{;T;T;{;[;[[@?i4;F;; ;;;;;[;{;IC; " ;T;[;![;"@;#0;$@<;%@;&I"GC::Profiler;F;;T:GC::Profiler.enable@>:GC::Profiler.raw_data@G:GC::Profiler.disable@P:GC::Profiler.clear@Y:GC::Profiler.result@b:GC::Profiler.report@k:GC::Profiler.total_time@t:ObjectSpace#each_object@*:ObjectSpace.each_object@$+:!ObjectSpace#define_finalizer@J+:!ObjectSpace.define_finalizer@e+:#ObjectSpace#undefine_finalizer@z+:#ObjectSpace.undefine_finalizer@+:ObjectSpace#_id2ref@+:ObjectSpace._id2ref@+:BasicObject#__id__@v:Object#object_id@::ObjectSpace#count_objects@+:ObjectSpace.count_objects@+:ObjectSpace::WeakMap@+:ObjectSpace::WeakMap#[]=@+:ObjectSpace::WeakMap#[]@+:"ObjectSpace::WeakMap#include?@,:!ObjectSpace::WeakMap#member?@,:ObjectSpace::WeakMap#key?@,:!ObjectSpace::WeakMap#inspect@&,:ObjectSpace::WeakMap#each@/,:#ObjectSpace::WeakMap#each_pair@8,:"ObjectSpace::WeakMap#each_key@A,:$ObjectSpace::WeakMap#each_value@J,:ObjectSpace::WeakMap#keys@S,: ObjectSpace::WeakMap#values@\,:ObjectSpace::WeakMap#size@e,: ObjectSpace::WeakMap#length@n,:#GC.verify_internal_consistency@:2GC.verify_transient_heap_internal_consistency@:GC.malloc_allocated_size@ˏ:GC.malloc_allocations@ԏ:GC.add_stress_to_class@ݏ:GC.remove_stress_to_class@: GC::OPTS@: Bug::Integer::SIZEOF_BDIGIT@M:Bug::Integer::BITSPERDIG@M: Bug::Integer.big_mul_normal@M:Bug::Integer.big_sq_fast@+M:!Bug::Integer.big_mul_balance@9M:#Bug::Integer.big_mul_karatsuba@IM:Bug::Integer.big_mul_toom3@YM:Bug::Integer.big_mul_gmp@iM:Bug::Bignum@M:"Bug::Bignum.big_divrem_normal@M:Bug::Bignum.big_divrem_gmp@M:Bug::Bignum.test_pack_raw@M:Bug::Bignum.test_pack@M:Bug::Bignum.test_unpack@M:+Bug::Bignum::INTEGER_PACK_MSWORD_FIRST@M:+Bug::Bignum::INTEGER_PACK_LSWORD_FIRST@M:+Bug::Bignum::INTEGER_PACK_MSBYTE_FIRST@N:+Bug::Bignum::INTEGER_PACK_LSBYTE_FIRST@N:0Bug::Bignum::INTEGER_PACK_NATIVE_BYTE_ORDER@N:$Bug::Bignum::INTEGER_PACK_2COMP@#N:,Bug::Bignum::INTEGER_PACK_LITTLE_ENDIAN@-N:)Bug::Bignum::INTEGER_PACK_BIG_ENDIAN@7N:+Bug::Bignum::INTEGER_PACK_FORCE_BIGNUM@AN:'Bug::Bignum::INTEGER_PACK_NEGATIVE@KN:;Bug::Bignum::INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION@UN:0Bug::Bignum.test_numbits_2comp_without_sign@_N:.Bug::Bignum.test_numbytes_2comp_with_sign@mN: Bug::Bignum.big2str_generic@{N:#Bug::Bignum.big2str_poweroftwo@N:Bug::Bignum.big2str_gmp@N:Bug::Bignum.zero@N:Bug::Bignum.negzero@N:IO.thread_fd_close@ e:IO.thread_fd_wait@e:IO.thread_fd_writable@'e:Bug::Bignum#coderange@N:Bug::Bignum#coderange_scan@N:Bug::Bignum.capacity@N:Bug::Bignum.fstring@N:$Bug::Bignum.rb_enc_interned_str@O:Bug::Bignum.rb_enc_str_new@O:$Bug::Bignum.rb_interned_str_dup@ O:$Bug::Bignum#associate_encoding!@/O:Bug::Bignum.encoding_index@>O:Bug::String@\O:Bug::String.rb_str_dup@^O:Bug::String.shared_string?@mO:%Bug::String.sharing_with_shared?@~O:Bug::String#cstr_term@O:Bug::String#cstr_unterm@O:Bug::String#cstr_term_char@O:'Bug::String#unterminated_substring@O:Bug::String.cstr_term@O:Bug::String.cstr_unterm@O:Bug::String.cstr_term_char@O:Bug::String.cstr_noembed@O:Bug::String.cstr_embedded?@P:"Bug::String.rb_str_new_frozen@P:Bug::String#qsort!@P:Bug::String.nofree@-P:Bug::String#ellipsize@:P:!Bug::String#normalize_ospath@IP:Bug::String#modify!@VP:Bug::String#modify_expand!@cP:Bug::String#set_len@qP: Bug::String#enc_str_buf_cat@P:"Bug::String#str_conv_enc_opts@P:Bug::String.buf_new@P:Bug::String.external_new@P:Bug::RbCallSuperKw@P:Bug::RbCallSuperKw#m@P:Bug::Class::Loop@ L:Bug#test_select@Q:Bug.test_select@Q:Bug#test_fdset@Q:Bug.test_fdset@$Q:Bug#dlntest@*Q:Bug.dlntest@8Q:Bug::Win32@>Q:Bug::Win32.console_info@@Q:!Bug::Win32.console_attribute@OQ: Bug::Win32::FOREGROUND_MASK@_Q: Bug::Win32::FOREGROUND_BLUE@iQ:!Bug::Win32::FOREGROUND_GREEN@sQ:Bug::Win32::FOREGROUND_RED@}Q:%Bug::Win32::FOREGROUND_INTENSITY@Q: Bug::Win32::BACKGROUND_MASK@Q: Bug::Win32::BACKGROUND_BLUE@Q:!Bug::Win32::BACKGROUND_GREEN@Q:Bug::Win32::BACKGROUND_RED@Q:%Bug::Win32::BACKGROUND_INTENSITY@Q:Bug::Win32::REVERSE_VIDEO@Q:Bug#bug_14834@Q:Bug.bug_14834@Q:Bug::ScanArgs@Q:Bug::ScanArgs.lead@Q:Bug::ScanArgs.opt@Q:Bug::ScanArgs.lead_opt@ R:Bug::ScanArgs.var@R:Bug::ScanArgs.lead_var@&R:Bug::ScanArgs.opt_var@3R:Bug::ScanArgs.lead_opt_var@@R:Bug::ScanArgs.opt_trail@MR:!Bug::ScanArgs.lead_opt_trail@\R:Bug::ScanArgs.var_trail@iR:!Bug::ScanArgs.lead_var_trail@vR: Bug::ScanArgs.opt_var_trail@R:%Bug::ScanArgs.lead_opt_var_trail@R:Bug::ScanArgs.hash@R:Bug::ScanArgs.lead_hash@R:Bug::ScanArgs.opt_hash@R: Bug::ScanArgs.lead_opt_hash@R:Bug::ScanArgs.var_hash@R: Bug::ScanArgs.lead_var_hash@R:Bug::ScanArgs.opt_var_hash@R:$Bug::ScanArgs.lead_opt_var_hash@R:!Bug::ScanArgs.opt_trail_hash@S:&Bug::ScanArgs.lead_opt_trail_hash@S:!Bug::ScanArgs.var_trail_hash@!S:&Bug::ScanArgs.lead_var_trail_hash@.S:%Bug::ScanArgs.opt_var_trail_hash@;S:*Bug::ScanArgs.lead_opt_var_trail_hash@HS:"Bug::ScanArgs.k_lead_opt_hash@US:"Bug::ScanArgs.n_lead_opt_hash@bS:Bug::String::DataError@P:Bug::Exception@~S:Bug::Exception#enc_raise@S:Bug::Exception.enc_raise@S:Bug::Exception#ensured@S:Bug::Exception.ensured@S: Bug::Exception#ensure_raise@S: Bug::Exception.ensure_raise@S:Bug::Method@S: Bug::Class#obj_method_arity@L: Bug::Class.obj_method_arity@/L: Bug::Class#mod_method_arity@5L: Bug::Class.mod_method_arity@FL:Bug.rb_fatal@S:(Kernel#register_sample_bug_reporter@D:Bug::Method#inspector@S:Bug::Method.inspector@S:Bug::Debug@ T:Bug::Debug#profile_frames@ T:Bug::Debug.profile_frames@T;~ @:Fiddle::Closure@!:Fiddle::Closure#initialize@#:Fiddle::Closure#to_i@6; @V; @X:Fiddle::Pointer.to_ptr@:Fiddle::Pointer.[]@:Fiddle::Pointer#initialize@̐:Fiddle::Pointer#free=@:Fiddle::Pointer#free@:Fiddle::Pointer#call_free@7:Fiddle::Pointer#freed?@R:Fiddle::Pointer#to_i@m:Fiddle::Pointer#to_int@:Fiddle::Pointer#to_value@:Fiddle::Pointer#ptr@:Fiddle::Pointer#+@@đ:Fiddle::Pointer#ref@ّ:Fiddle::Pointer#-@@:Fiddle::Pointer#null?@:Fiddle::Pointer#to_s@:Fiddle::Pointer#to_str@K:Fiddle::Pointer#inspect@y:Fiddle::Pointer#<=>@:Fiddle::Pointer#==@:Fiddle::Pointer#eql?@ߒ:Fiddle::Pointer#+@ :Fiddle::Pointer#-@&:Fiddle::Pointer#[]@@:Fiddle::Pointer#[]=@r:Fiddle::Pointer#size@:Fiddle::Pointer#size=@:Fiddle::NULL@:Fiddle::Function@:Fiddle::Function::DEFAULT@:Fiddle::Function::STDCALL@:Fiddle::Function#call@ : Fiddle::Function#initialize@:Fiddle::Error@w:Fiddle::DLError@:Fiddle::TYPE_VOID@:Fiddle::TYPE_VOIDP@:Fiddle::TYPE_CHAR@:Fiddle::TYPE_SHORT@Ĕ:Fiddle::TYPE_INT@Д:Fiddle::TYPE_LONG@ܔ:Fiddle::TYPE_LONG_LONG@:Fiddle::TYPE_INT8_T@:Fiddle::TYPE_INT16_T@:Fiddle::TYPE_INT32_T@ :Fiddle::TYPE_INT64_T@:Fiddle::TYPE_FLOAT@$:Fiddle::TYPE_DOUBLE@0:Fiddle::TYPE_VARIADIC@<:Fiddle::TYPE_CONST_STRING@H:Fiddle::TYPE_SIZE_T@T:Fiddle::TYPE_SSIZE_T@`:Fiddle::TYPE_PTRDIFF_T@l:Fiddle::TYPE_INTPTR_T@x:Fiddle::TYPE_UINTPTR_T@:Fiddle::ALIGN_VOIDP@:Fiddle::ALIGN_CHAR@:Fiddle::ALIGN_SHORT@:Fiddle::ALIGN_INT@:Fiddle::ALIGN_LONG@:Fiddle::ALIGN_LONG_LONG@̕:Fiddle::ALIGN_INT8_T@ؕ:Fiddle::ALIGN_INT16_T@:Fiddle::ALIGN_INT32_T@:Fiddle::ALIGN_INT64_T@:Fiddle::ALIGN_FLOAT@:Fiddle::ALIGN_DOUBLE@:Fiddle::ALIGN_SIZE_T@ :Fiddle::ALIGN_SSIZE_T@,:Fiddle::ALIGN_PTRDIFF_T@8:Fiddle::ALIGN_INTPTR_T@D:Fiddle::ALIGN_UINTPTR_T@P:Fiddle::WINDOWS@\:Fiddle::SIZEOF_VOIDP@g:Fiddle::SIZEOF_CHAR@s:Fiddle::SIZEOF_SHORT@:Fiddle::SIZEOF_INT@:Fiddle::SIZEOF_LONG@:Fiddle::SIZEOF_LONG_LONG@:Fiddle::SIZEOF_INT8_T@:Fiddle::SIZEOF_INT16_T@:Fiddle::SIZEOF_INT32_T@ǖ:Fiddle::SIZEOF_INT64_T@Ӗ:Fiddle::SIZEOF_FLOAT@ߖ:Fiddle::SIZEOF_DOUBLE@:Fiddle::SIZEOF_SIZE_T@:Fiddle::SIZEOF_SSIZE_T@:Fiddle::SIZEOF_PTRDIFF_T@:Fiddle::SIZEOF_INTPTR_T@:Fiddle::SIZEOF_UINTPTR_T@': Fiddle::SIZEOF_CONST_STRING@3:Fiddle::RUBY_FREE@?: Fiddle::BUILD_RUBY_PLATFORM@K:Fiddle#dlwrap@W:Fiddle.dlwrap@p:Fiddle#dlunwrap@:Fiddle.dlunwrap@:Fiddle#malloc@:Fiddle.malloc@Ɨ:Fiddle#realloc@ؗ:Fiddle.realloc@:Fiddle#free@ :Fiddle.free@":Fiddle::MemoryView@4:Fiddle::MemoryView.export@6:"Fiddle::MemoryView#initialize@E:Fiddle::MemoryView#release@S:Fiddle::MemoryView#obj@_:!Fiddle::MemoryView#byte_size@k:!Fiddle::MemoryView#readonly?@w:Fiddle::MemoryView#format@:!Fiddle::MemoryView#item_size@:Fiddle::MemoryView#ndim@:Fiddle::MemoryView#shape@:Fiddle::MemoryView#strides@:#Fiddle::MemoryView#sub_offsets@˜:Fiddle::MemoryView#[]@Θ:Fiddle::MemoryView#to_s@ۘ; @ݚ:Zlib::ZStream@ߚ:Zlib::Deflate@4:Zlib::Inflate@ǜ:Zlib::GzipFile@o:Zlib::GzipWriter@:Zlib::GzipReader@ʟ:Zlib::Error@:Zlib::StreamEnd@i:Zlib::NeedDict@}:Zlib::DataError@:Zlib::StreamError@:Zlib::MemError@:Zlib::BufError@͡:Zlib::VersionError@:Zlib::InProgressError@:Zlib#zlib_version@ :Zlib.zlib_version@:Zlib#adler32@:Zlib.adler32@,:Zlib#adler32_combine@4:Zlib.adler32_combine@G:Zlib#crc32@O:Zlib.crc32@]:Zlib#crc32_combine@e:Zlib.crc32_combine@x:Zlib#crc_table@:Zlib.crc_table@:Zlib::VERSION@:Zlib::ZLIB_VERSION@:Zlib::ZStream#avail_out@:Zlib::ZStream#avail_out=@:Zlib::ZStream#avail_in@:Zlib::ZStream#total_in@:Zlib::ZStream#total_out@:Zlib::ZStream#data_type@*:Zlib::ZStream#adler@8:Zlib::ZStream#finished?@F:Zlib::ZStream#stream_end?@W:Zlib::ZStream#closed?@g:Zlib::ZStream#ended?@x:Zlib::ZStream#close@:Zlib::ZStream#end@:Zlib::ZStream#reset@:Zlib::ZStream#finish@: Zlib::ZStream#flush_next_in@ޛ:!Zlib::ZStream#flush_next_out@:Zlib::BINARY@:Zlib::ASCII@:Zlib::TEXT@Ţ:Zlib::UNKNOWN@Ѣ:Zlib::Deflate.deflate@6:Zlib.deflate@ݢ:Zlib::Deflate#initialize@E:"Zlib::Deflate#initialize_copy@T:Zlib::Deflate#deflate@d:Zlib::Deflate#<<@s:Zlib::Deflate#flush@:Zlib::Deflate#params@:!Zlib::Deflate#set_dictionary@:Zlib::Inflate.inflate@ɜ:Zlib.inflate@:Zlib::Inflate#initialize@ٜ:!Zlib::Inflate#add_dictionary@:Zlib::Inflate#inflate@:Zlib::Inflate#<<@:Zlib::Inflate#sync@!:Zlib::Inflate#sync_point?@;:!Zlib::Inflate#set_dictionary@L:Zlib::NO_COMPRESSION@:Zlib::BEST_SPEED@:Zlib::BEST_COMPRESSION@:Zlib::DEFAULT_COMPRESSION@:Zlib::FILTERED@*:Zlib::HUFFMAN_ONLY@6:Zlib::RLE@B:Zlib::FIXED@N:Zlib::DEFAULT_STRATEGY@Z:Zlib::MAX_WBITS@f:Zlib::DEF_MEM_LEVEL@r:Zlib::MAX_MEM_LEVEL@~:Zlib::NO_FLUSH@:Zlib::SYNC_FLUSH@:Zlib::FULL_FLUSH@:Zlib::FINISH@:Zlib::GzipFile::Error@q: Zlib::GzipFile::Error#input@s:"Zlib::GzipFile::Error#inspect@:Zlib::GzipFile::NoFooter@:Zlib::GzipFile::CRCError@ȝ: Zlib::GzipFile::LengthError@ܝ:Zlib::GzipFile.wrap@:Zlib::GzipFile#to_io@:Zlib::GzipFile#crc@ :Zlib::GzipFile#mtime@:Zlib::GzipFile#level@):Zlib::GzipFile#os_code@7:Zlib::GzipFile#orig_name@E:Zlib::GzipFile#comment@S:Zlib::GzipReader#lineno@̟:Zlib::GzipReader#lineno=@ڟ:Zlib::GzipWriter#mtime=@: Zlib::GzipWriter#orig_name=@ў:Zlib::GzipWriter#comment=@:Zlib::GzipFile#close@a:Zlib::GzipFile#finish@o:Zlib::GzipFile#closed?@}:Zlib::GzipReader#eof@:Zlib::GzipReader#eof?@:Zlib::GzipFile#sync@:Zlib::GzipFile#sync=@:Zlib::GzipReader#pos@:Zlib::GzipWriter#pos@:Zlib::GzipReader#tell@:Zlib::GzipWriter#tell@; @ : Zlib::GzipWriter#initialize@0:Zlib::GzipWriter#flush@R:Zlib::GzipWriter#write@l:Zlib::GzipWriter#putc@{:Zlib::GzipWriter#<<@:Zlib::GzipWriter#printf@:Zlib::GzipWriter#print@:Zlib::GzipWriter#puts@:Zlib::GzipReader.open@#:Zlib::GzipReader.zcat@2: Zlib::GzipReader#initialize@A:Zlib::GzipReader#rewind@P:Zlib::GzipReader#unused@^:Zlib::GzipReader#read@l:!Zlib::GzipReader#readpartial@{:Zlib::GzipReader#getc@:Zlib::GzipReader#getbyte@:Zlib::GzipReader#readchar@:Zlib::GzipReader#readbyte@:Zlib::GzipReader#each_byte@ :Zlib::GzipReader#each_char@Р:Zlib::GzipReader#ungetc@ޠ:Zlib::GzipReader#ungetbyte@:Zlib::GzipReader#gets@:Zlib::GzipReader#readline@ :Zlib::GzipReader#each@:Zlib::GzipReader#each_line@+:Zlib::GzipReader#readlines@9:'Zlib::GzipReader#external_encoding@H:Zlib.gzip@:Zlib.gunzip@ޣ:Zlib::OS_CODE@:Zlib::OS_MSDOS@ :Zlib::OS_AMIGA@:Zlib::OS_VMS@!:Zlib::OS_UNIX@-:Zlib::OS_ATARI@9:Zlib::OS_OS2@E:Zlib::OS_MACOS@Q:Zlib::OS_TOPS20@]:Zlib::OS_WIN32@i:Zlib::OS_VMCMS@u:Zlib::OS_ZSYSTEM@:Zlib::OS_CPM@:Zlib::OS_QDOS@:Zlib::OS_RISCOS@:Zlib::OS_UNKNOWN@; @Ϥ:Psych::ClassLoader@Ѥ:Psych::Visitors@:Psych::Visitors::Visitor@:Psych::Visitors::ToRuby@:,Psych::Visitors::ToRuby#build_exception@:"Psych::ClassLoader#path2class@Ӥ:Psych::Visitors::YAMLTree@A:Psych::Handler@b:Psych::Emitter@s:Psych::Emitter#initialize@u: Psych::Emitter#start_stream@:Psych::Emitter#end_stream@:"Psych::Emitter#start_document@: Psych::Emitter#end_document@:Psych::Emitter#scalar@:"Psych::Emitter#start_sequence@*: Psych::Emitter#end_sequence@P:!Psych::Emitter#start_mapping@f:Psych::Emitter#end_mapping@:Psych::Emitter#alias@:Psych::Emitter#canonical@:Psych::Emitter#canonical=@Ҧ:Psych::Emitter#indentation@: Psych::Emitter#indentation=@:Psych::Emitter#line_width@:Psych::Emitter#line_width=@2:Psych.libyaml_version@[:Psych::Parser@r:Psych::Parser::ANY@t:Psych::Parser::UTF8@:Psych::Parser::UTF16LE@:Psych::Parser::UTF16BE@:Psych::Parser#parse@:Psych::Parser#mark@; @:CGI::Escape@:CGI::Util@:CGI::Escape#escapeHTML@:CGI::Escape#unescapeHTML@:CGI::Escape#escape@1:CGI::Escape#unescape@P:JSON::Ext::Parser@:JSON::Ext::Generator@e; @:StringIO::VERSION@:StringIO.new@:StringIO.open@:StringIO#initialize@ڨ:StringIO#initialize_copy@:StringIO#reopen@:StringIO#string@):StringIO#string=@D:StringIO#lineno@c:StringIO#lineno=@~:StringIO#binmode@:StringIO#close@:StringIO#close_read@Ω:StringIO#close_write@:StringIO#closed?@:StringIO#closed_read?@:StringIO#closed_write?@::StringIO#eof@U:StringIO#eof?@}:StringIO#fcntl@:StringIO#flush@:StringIO#fsync@ʪ:StringIO#pos@:StringIO#pos=@ :StringIO#rewind@):StringIO#seek@D:StringIO#sync@e:StringIO#sync=@:StringIO#tell@:StringIO#each@:StringIO#each_line@:StringIO#each_byte@P:StringIO#each_char@x:StringIO#each_codepoint@:StringIO#getc@Ȭ:StringIO#ungetc@:StringIO#ungetbyte@:StringIO#getbyte@":StringIO#gets@>:StringIO#readlines@:StringIO#read@ѭ:StringIO#write@:StringIO#putc@:StringIO#isatty@>:StringIO#tty?@c:StringIO#pid@o:StringIO#fileno@:StringIO#size@:StringIO#length@Ǯ:StringIO#truncate@:StringIO#external_encoding@ :StringIO#internal_encoding@(:StringIO#set_encoding@C:!StringIO#set_encoding_by_bom@^:"IO::generic_readable#readchar@Ic:"IO::generic_readable#readbyte@ec:"IO::generic_readable#readline@c:!IO::generic_readable#sysread@c:%IO::generic_readable#readpartial@c:'IO::generic_readable#read_nonblock@#d:IO::generic_writable@5e:IO::generic_writable#<<@7e:IO::generic_writable#print@@e: IO::generic_writable#printf@Ie:IO::generic_writable#puts@Re:"IO::generic_writable#syswrite@[e:(IO::generic_writable#write_nonblock@de; @y:Racc::Parser@{:"Racc::Parser#_racc_do_parse_c@}:!Racc::Parser#_racc_yyparse_c@:.Racc::Parser::Racc_Runtime_Core_Version_C@:)Racc::Parser::Racc_Runtime_Core_Id_C@:Racc::CparseParams@ů;@:Win32::Resolv@;" @:Fcntl::F_DUPFD@ :Fcntl::F_GETFD@:Fcntl::F_GETLK@#:Fcntl::F_SETFD@/:Fcntl::F_GETFL@;:Fcntl::F_SETFL@G:Fcntl::F_SETLK@S:Fcntl::F_SETLKW@_:Fcntl::FD_CLOEXEC@k:Fcntl::F_RDLCK@w:Fcntl::F_UNLCK@:Fcntl::F_WRLCK@:Fcntl::F_SETPIPE_SZ@:Fcntl::F_GETPIPE_SZ@:Fcntl::O_CREAT@:Fcntl::O_EXCL@:Fcntl::O_NOCTTY@˰:Fcntl::O_TRUNC@װ:Fcntl::O_APPEND@:Fcntl::O_NONBLOCK@:Fcntl::O_NDELAY@:Fcntl::O_RDONLY@:Fcntl::O_RDWR@:Fcntl::O_WRONLY@:Fcntl::O_ACCMODE@+;@GH:OpenSSL::OpenSSLError@H:OpenSSL::PKCS7@IH:OpenSSL::PKCS7::PKCS7Error@KH:OpenSSL::PKCS7.read_smime@\H:OpenSSL::PKCS7.write_smime@vH:OpenSSL::PKCS7.sign@H:OpenSSL::PKCS7.encrypt@H:#OpenSSL::PKCS7#initialize_copy@H:OpenSSL::PKCS7#initialize@H:OpenSSL::PKCS7#type=@H:OpenSSL::PKCS7#type@I:OpenSSL::PKCS7#detached=@5I:OpenSSL::PKCS7#detached@CI:OpenSSL::PKCS7#detached?@OI:OpenSSL::PKCS7#cipher=@^I:OpenSSL::PKCS7#add_signer@lI:OpenSSL::PKCS7#signers@zI:!OpenSSL::PKCS7#add_recipient@I:OpenSSL::PKCS7#recipients@I:#OpenSSL::PKCS7#add_certificate@I:!OpenSSL::PKCS7#certificates=@I: OpenSSL::PKCS7#certificates@I:OpenSSL::PKCS7#add_crl@I:OpenSSL::PKCS7#crls=@I:OpenSSL::PKCS7#crls@I:OpenSSL::PKCS7#add_data@I:OpenSSL::PKCS7#data=@I:OpenSSL::PKCS7#verify@J:OpenSSL::PKCS7#decrypt@J:OpenSSL::PKCS7#to_pem@ J:OpenSSL::PKCS7#to_s@*J:OpenSSL::PKCS7#to_der@4J:OpenSSL::PKCS7::SignerInfo@@J:OpenSSL::PKCS7::Signer@J:*OpenSSL::PKCS7::SignerInfo#initialize@BJ:&OpenSSL::PKCS7::SignerInfo#issuer@TJ:&OpenSSL::PKCS7::SignerInfo#serial@`J:+OpenSSL::PKCS7::SignerInfo#signed_time@lJ:"OpenSSL::PKCS7::RecipientInfo@J:-OpenSSL::PKCS7::RecipientInfo#initialize@J:)OpenSSL::PKCS7::RecipientInfo#issuer@J:)OpenSSL::PKCS7::RecipientInfo#serial@J:*OpenSSL::PKCS7::RecipientInfo#enc_key@J:OpenSSL::SSL@J:OpenSSL::SSL::Session@J:(OpenSSL::SSL::Session::SessionError@J:%OpenSSL::SSL::Session#initialize@J:*OpenSSL::SSL::Session#initialize_copy@&K:OpenSSL::SSL::Session#==@4K:OpenSSL::SSL::Session#time@SK: OpenSSL::SSL::Session#time=@nK:"OpenSSL::SSL::Session#timeout@K:#OpenSSL::SSL::Session#timeout=@K:OpenSSL::SSL::Session#id@K:!OpenSSL::SSL::Session#to_der@K:!OpenSSL::SSL::Session#to_pem@K:"OpenSSL::SSL::Session#to_text@L:OpenSSL::HMACError@C}:OpenSSL::HMAC@T}:OpenSSL::HMAC#initialize@V}:"OpenSSL::HMAC#initialize_copy@t}:OpenSSL::HMAC#reset@}:OpenSSL::HMAC#update@}:OpenSSL::HMAC#<<@}:OpenSSL::HMAC#digest@}:OpenSSL::HMAC#hexdigest@}:OpenSSL::HMAC#inspect@~:OpenSSL::HMAC#to_s@}:OpenSSL::Netscape::SPKI@:OpenSSL::Random@~:!OpenSSL::Random::RandomError@~:OpenSSL::Random#seed@/~:OpenSSL::Random.seed@M~:OpenSSL::Random#random_add@d~:OpenSSL::Random.random_add@~:%OpenSSL::Random#load_random_file@~:%OpenSSL::Random.load_random_file@~:&OpenSSL::Random#write_random_file@~:&OpenSSL::Random.write_random_file@~:!OpenSSL::Random#random_bytes@ :!OpenSSL::Random.random_bytes@:OpenSSL::Random#egd@ :OpenSSL::Random.egd@>:OpenSSL::Random#egd_bytes@U:OpenSSL::Random.egd_bytes@w:OpenSSL::Random#status?@:OpenSSL::Random.status?@:OpenSSL::OCSP@:OpenSSL::OCSP::OCSPError@:OpenSSL::OCSP::Request@:+OpenSSL::OCSP::Request#initialize_copy@:&OpenSSL::OCSP::Request#initialize@:%OpenSSL::OCSP::Request#add_nonce@:'OpenSSL::OCSP::Request#check_nonce@*:&OpenSSL::OCSP::Request#add_certid@D:"OpenSSL::OCSP::Request#certid@^:#OpenSSL::OCSP::Request#signed?@y: OpenSSL::OCSP::Request#sign@:"OpenSSL::OCSP::Request#verify@:"OpenSSL::OCSP::Request#to_der@:OpenSSL::OCSP::Response@;@:,OpenSSL::OCSP::Response#initialize_copy@:'OpenSSL::OCSP::Response#initialize@,:#OpenSSL::OCSP::Response#status@M:*OpenSSL::OCSP::Response#status_string@h:"OpenSSL::OCSP::Response#basic@:#OpenSSL::OCSP::Response#to_der@:!OpenSSL::OCSP::BasicResponse@Á:1OpenSSL::OCSP::BasicResponse#initialize_copy@Ł:,OpenSSL::OCSP::BasicResponse#initialize@Ӂ:,OpenSSL::OCSP::BasicResponse#copy_nonce@:+OpenSSL::OCSP::BasicResponse#add_nonce@ :,OpenSSL::OCSP::BasicResponse#add_status@&:(OpenSSL::OCSP::BasicResponse#status@X:+OpenSSL::OCSP::BasicResponse#responses@n:/OpenSSL::OCSP::BasicResponse#find_response@:&OpenSSL::OCSP::BasicResponse#sign@:(OpenSSL::OCSP::BasicResponse#verify@т:(OpenSSL::OCSP::BasicResponse#to_der@:"OpenSSL::OCSP::SingleResponse@:2OpenSSL::OCSP::SingleResponse#initialize_copy@ :-OpenSSL::OCSP::SingleResponse#initialize@.:1OpenSSL::OCSP::SingleResponse#check_validity@M:)OpenSSL::OCSP::SingleResponse#certid@j:.OpenSSL::OCSP::SingleResponse#cert_status@:.OpenSSL::OCSP::SingleResponse#this_update@:.OpenSSL::OCSP::SingleResponse#next_update@:2OpenSSL::OCSP::SingleResponse#revocation_time@փ:4OpenSSL::OCSP::SingleResponse#revocation_reason@:-OpenSSL::OCSP::SingleResponse#extensions@ :)OpenSSL::OCSP::SingleResponse#to_der@':!OpenSSL::OCSP::CertificateId@Q:1OpenSSL::OCSP::CertificateId#initialize_copy@S:,OpenSSL::OCSP::CertificateId#initialize@a:%OpenSSL::OCSP::CertificateId#cmp@:,OpenSSL::OCSP::CertificateId#cmp_issuer@:(OpenSSL::OCSP::CertificateId#serial@ф:2OpenSSL::OCSP::CertificateId#issuer_name_hash@:1OpenSSL::OCSP::CertificateId#issuer_key_hash@:0OpenSSL::OCSP::CertificateId#hash_algorithm@":(OpenSSL::OCSP::CertificateId#to_der@=:1OpenSSL::OCSP::RESPONSE_STATUS_INTERNALERROR@g:4OpenSSL::OCSP::RESPONSE_STATUS_MALFORMEDREQUEST@s:+OpenSSL::OCSP::REVOKED_STATUS_NOSTATUS@:/OpenSSL::OCSP::RESPONSE_STATUS_SIGREQUIRED@:.OpenSSL::OCSP::RESPONSE_STATUS_SUCCESSFUL@:,OpenSSL::OCSP::RESPONSE_STATUS_TRYLATER@:5OpenSSL::OCSP::REVOKED_STATUS_AFFILIATIONCHANGED@:/OpenSSL::OCSP::REVOKED_STATUS_CACOMPROMISE@:2OpenSSL::OCSP::REVOKED_STATUS_CERTIFICATEHOLD@Dž:7OpenSSL::OCSP::REVOKED_STATUS_CESSATIONOFOPERATION@Ӆ:0OpenSSL::OCSP::REVOKED_STATUS_KEYCOMPROMISE@߅:0OpenSSL::OCSP::REVOKED_STATUS_REMOVEFROMCRL@:-OpenSSL::OCSP::REVOKED_STATUS_SUPERSEDED@:0OpenSSL::OCSP::RESPONSE_STATUS_UNAUTHORIZED@:.OpenSSL::OCSP::REVOKED_STATUS_UNSPECIFIED@:OpenSSL::OCSP::NOCERTS@:OpenSSL::OCSP::NOINTERN@':OpenSSL::OCSP::NOSIGS@3:OpenSSL::OCSP::NOCHAIN@?:OpenSSL::OCSP::NOVERIFY@K:OpenSSL::OCSP::NOEXPLICIT@W:OpenSSL::OCSP::NOCASIGN@c:OpenSSL::OCSP::NODELEGATED@o:OpenSSL::OCSP::NOCHECKS@{:OpenSSL::OCSP::TRUSTOTHER@:OpenSSL::OCSP::RESPID_KEY@:OpenSSL::OCSP::NOTIME@:%OpenSSL::OCSP::V_CERTSTATUS_GOOD@:(OpenSSL::OCSP::V_CERTSTATUS_REVOKED@:(OpenSSL::OCSP::V_CERTSTATUS_UNKNOWN@Æ:!OpenSSL::OCSP::V_RESPID_NAME@φ: OpenSSL::OCSP::V_RESPID_KEY@ۆ:(OpenSSL.fixed_length_secure_compare@:OpenSSL::OPENSSL_VERSION@:%OpenSSL::OPENSSL_LIBRARY_VERSION@ :$OpenSSL::OPENSSL_VERSION_NUMBER@:OpenSSL::OPENSSL_FIPS@":OpenSSL#fips_mode@,:OpenSSL.fips_mode@6:OpenSSL#fips_mode=@<:OpenSSL.fips_mode=@F:OpenSSL#debug@L:OpenSSL.debug@V:OpenSSL#debug=@\:OpenSSL.debug=@f:OpenSSL#errors@l:OpenSSL.errors@v:OpenSSL#mem_check_start@|:OpenSSL.mem_check_start@:OpenSSL#print_mem_leaks@:OpenSSL.print_mem_leaks@:OpenSSL::X509@: OpenSSL::X509::RequestError@:OpenSSL::X509::Request@:&OpenSSL::X509::Request#initialize@:+OpenSSL::X509::Request#initialize_copy@:"OpenSSL::X509::Request#to_pem@̇:"OpenSSL::X509::Request#to_der@: OpenSSL::X509::Request#to_s@և:#OpenSSL::X509::Request#to_text@:#OpenSSL::X509::Request#version@:$OpenSSL::X509::Request#version=@:#OpenSSL::X509::Request#subject@:$OpenSSL::X509::Request#subject=@:/OpenSSL::X509::Request#signature_algorithm@,:&OpenSSL::X509::Request#public_key@8:'OpenSSL::X509::Request#public_key=@D: OpenSSL::X509::Request#sign@T:"OpenSSL::X509::Request#verify@d:&OpenSSL::X509::Request#attributes@t:'OpenSSL::X509::Request#attributes=@:)OpenSSL::X509::Request#add_attribute@:OpenSSL::Timestamp@͔:'OpenSSL::Timestamp::TimestampErroro; ;IC;[; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ؔi:[@ؔi=;T;:TimestampError;;;;;[;{;IC; "5Generic exception class of the Timestamp module. ;T;[;![;"I"6Generic exception class of the Timestamp module. ;T;#0;$@;.F;/o;0;1T;2i:;3i;;%o;;IC;[ @o; ;IC;[o;4;5F;6;;;;&I",OpenSSL::Timestamp::Response#initialize;F;7[[I"der;T0;[[@ؔi;T;;D;0;[;{;IC; "sCreates a Response from a +File+ or +string+ parameter, the corresponding +File+ or +string+ must be DER-encoded. Please note that Response is an immutable read-only class. If you'd like to create timestamps please refer to Factory instead. call-seq: OpenSSL::Timestamp::Response.new(file) -> response OpenSSL::Timestamp::Response.new(string) -> response ;T;[;![;"I"tCreates a Response from a +File+ or +string+ parameter, the corresponding +File+ or +string+ must be DER-encoded. Please note that Response is an immutable read-only class. If you'd like to create timestamps please refer to Factory instead. call-seq: OpenSSL::Timestamp::Response.new(file) -> response OpenSSL::Timestamp::Response.new(string) -> response ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_ts_resp_initialize(VALUE self, VALUE der) { TS_RESP *ts_resp = DATA_PTR(self); BIO *in; der = ossl_to_der_if_possible(der); in = ossl_obj2bio(&der); ts_resp = d2i_TS_RESP_bio(in, &ts_resp); BIO_free(in); if (!ts_resp) { DATA_PTR(self) = NULL; ossl_raise(eTimestampError, "Error when decoding the timestamp response"); } DATA_PTR(self) = ts_resp; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(OpenSSL::Timestamp::Response#status;F;7[;[[@ؔi-;T;;>;0;[;{;IC; "Returns one of GRANTED, GRANTED_WITH_MODS, REJECTION, WAITING, REVOCATION_WARNING or REVOCATION_NOTIFICATION. A timestamp token has been created only in case +status+ is equal to GRANTED or GRANTED_WITH_MODS. call-seq: response.status -> BN (never nil) ;T;[;![;"I"Returns one of GRANTED, GRANTED_WITH_MODS, REJECTION, WAITING, REVOCATION_WARNING or REVOCATION_NOTIFICATION. A timestamp token has been created only in case +status+ is equal to GRANTED or GRANTED_WITH_MODS. call-seq: response.status -> BN (never nil) ;T;#0;$@;.F;/o;0;1T;2i%;3i+;%@;9I"static VALUE ossl_ts_resp_get_status(VALUE self) { TS_RESP *resp; TS_STATUS_INFO *si; const ASN1_INTEGER *st; GetTSResponse(self, resp); si = TS_RESP_get_status_info(resp); st = TS_STATUS_INFO_get0_status(si); return asn1integer_to_num(st); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I".OpenSSL::Timestamp::Response#failure_info;F;7[;[[@ؔiT;T;:failure_info;0;[;{;IC; "In cases no timestamp token has been created, this field contains further info about the reason why response creation failed. The method returns either nil (the request was successful and a timestamp token was created) or one of the following: * :BAD_ALG - Indicates that the timestamp server rejects the message imprint algorithm used in the Request * :BAD_REQUEST - Indicates that the timestamp server was not able to process the Request properly * :BAD_DATA_FORMAT - Indicates that the timestamp server was not able to parse certain data in the Request * :TIME_NOT_AVAILABLE - Indicates that the server could not access its time source * :UNACCEPTED_POLICY - Indicates that the requested policy identifier is not recognized or supported by the timestamp server * :UNACCEPTED_EXTENSIION - Indicates that an extension in the Request is not supported by the timestamp server * :ADD_INFO_NOT_AVAILABLE -Indicates that additional information requested is either not understood or currently not available * :SYSTEM_FAILURE - Timestamp creation failed due to an internal error that occurred on the timestamp server call-seq: response.failure_info -> nil or symbol ;T;[;![;"I"In cases no timestamp token has been created, this field contains further info about the reason why response creation failed. The method returns either nil (the request was successful and a timestamp token was created) or one of the following: * :BAD_ALG - Indicates that the timestamp server rejects the message imprint algorithm used in the Request * :BAD_REQUEST - Indicates that the timestamp server was not able to process the Request properly * :BAD_DATA_FORMAT - Indicates that the timestamp server was not able to parse certain data in the Request * :TIME_NOT_AVAILABLE - Indicates that the server could not access its time source * :UNACCEPTED_POLICY - Indicates that the requested policy identifier is not recognized or supported by the timestamp server * :UNACCEPTED_EXTENSIION - Indicates that an extension in the Request is not supported by the timestamp server * :ADD_INFO_NOT_AVAILABLE -Indicates that additional information requested is either not understood or currently not available * :SYSTEM_FAILURE - Timestamp creation failed due to an internal error that occurred on the timestamp server call-seq: response.failure_info -> nil or symbol ;T;#0;$@;.F;/o;0;1T;2i;;3iR;%@;9I"!static VALUE ossl_ts_resp_get_failure_info(VALUE self) { TS_RESP *resp; TS_STATUS_INFO *si; /* The ASN1_BIT_STRING_get_bit changed from 1.0.0. to 1.1.0, making this * const. */ #if defined(HAVE_TS_STATUS_INFO_GET0_FAILURE_INFO) const ASN1_BIT_STRING *fi; #else ASN1_BIT_STRING *fi; #endif GetTSResponse(self, resp); si = TS_RESP_get_status_info(resp); fi = TS_STATUS_INFO_get0_failure_info(si); if (!fi) return Qnil; if (ASN1_BIT_STRING_get_bit(fi, TS_INFO_BAD_ALG)) return sBAD_ALG; if (ASN1_BIT_STRING_get_bit(fi, TS_INFO_BAD_REQUEST)) return sBAD_REQUEST; if (ASN1_BIT_STRING_get_bit(fi, TS_INFO_BAD_DATA_FORMAT)) return sBAD_DATA_FORMAT; if (ASN1_BIT_STRING_get_bit(fi, TS_INFO_TIME_NOT_AVAILABLE)) return sTIME_NOT_AVAILABLE; if (ASN1_BIT_STRING_get_bit(fi, TS_INFO_UNACCEPTED_POLICY)) return sUNACCEPTED_POLICY; if (ASN1_BIT_STRING_get_bit(fi, TS_INFO_UNACCEPTED_EXTENSION)) return sUNACCEPTED_EXTENSION; if (ASN1_BIT_STRING_get_bit(fi, TS_INFO_ADD_INFO_NOT_AVAILABLE)) return sADD_INFO_NOT_AVAILABLE; if (ASN1_BIT_STRING_get_bit(fi, TS_INFO_SYSTEM_FAILURE)) return sSYSTEM_FAILURE; ossl_raise(eTimestampError, "Unrecognized failure info."); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"-OpenSSL::Timestamp::Response#status_text;F;7[;[[@ؔi;T;:status_text;0;[;{;IC; "In cases of failure this field may contain an array of strings further describing the origin of the failure. call-seq: response.status_text -> Array of strings or nil ;T;[;![;"I"In cases of failure this field may contain an array of strings further describing the origin of the failure. call-seq: response.status_text -> Array of strings or nil ;T;#0;$@;.F;/o;0;1T;2i{;3i;%@;9I"static VALUE ossl_ts_resp_get_status_text(VALUE self) { TS_RESP *resp; TS_STATUS_INFO *si; const STACK_OF(ASN1_UTF8STRING) *text; ASN1_UTF8STRING *current; int i; VALUE ret = rb_ary_new(); GetTSResponse(self, resp); si = TS_RESP_get_status_info(resp); if ((text = TS_STATUS_INFO_get0_text(si))) { for (i = 0; i < sk_ASN1_UTF8STRING_num(text); i++) { current = sk_ASN1_UTF8STRING_value(text, i); rb_ary_push(ret, asn1str_to_str(current)); } } return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::Timestamp::Response#token;F;7[;[[@ؔi;T;; ;0;[;{;IC; "If a timestamp token is present, this returns it in the form of a OpenSSL::PKCS7. call-seq: response.token -> nil or OpenSSL::PKCS7 ;T;[;![;"I"If a timestamp token is present, this returns it in the form of a OpenSSL::PKCS7. call-seq: response.token -> nil or OpenSSL::PKCS7 ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"^static VALUE ossl_ts_resp_get_token(VALUE self) { TS_RESP *resp; PKCS7 *p7, *copy; VALUE obj; GetTSResponse(self, resp); if (!(p7 = TS_RESP_get_token(resp))) return Qnil; obj = NewPKCS7(cPKCS7); if (!(copy = PKCS7_dup(p7))) ossl_raise(eTimestampError, NULL); SetPKCS7(obj, copy); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",OpenSSL::Timestamp::Response#token_info;F;7[;[[@ؔi;T;:token_info;0;[;{;IC; "{Get the response's token info if present. call-seq: response.token_info -> nil or OpenSSL::Timestamp::TokenInfo ;T;[;![;"I"|Get the response's token info if present. call-seq: response.token_info -> nil or OpenSSL::Timestamp::TokenInfo ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_ts_resp_get_token_info(VALUE self) { TS_RESP *resp; TS_TST_INFO *info, *copy; VALUE obj; GetTSResponse(self, resp); if (!(info = TS_RESP_get_tst_info(resp))) return Qnil; obj = NewTSTokenInfo(cTimestampTokenInfo); if (!(copy = TS_TST_INFO_dup(info))) ossl_raise(eTimestampError, NULL); SetTSTokenInfo(obj, copy); return obj; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"1OpenSSL::Timestamp::Response#tsa_certificate;F;7[;[[@ؔi;T;:tsa_certificate;0;[;{;IC; "If the Request specified to request the TSA certificate (Request#cert_requested = true), then this field contains the certificate of the timestamp authority. call-seq: response.tsa_certificate -> OpenSSL::X509::Certificate or nil ;T;[;![;"I"If the Request specified to request the TSA certificate (Request#cert_requested = true), then this field contains the certificate of the timestamp authority. call-seq: response.tsa_certificate -> OpenSSL::X509::Certificate or nil ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_ts_resp_get_tsa_certificate(VALUE self) { TS_RESP *resp; PKCS7 *p7; PKCS7_SIGNER_INFO *ts_info; X509 *cert; GetTSResponse(self, resp); if (!(p7 = TS_RESP_get_token(resp))) return Qnil; ts_info = sk_PKCS7_SIGNER_INFO_value(p7->d.sign->signer_info, 0); cert = PKCS7_cert_from_signer_info(p7, ts_info); if (!cert) return Qnil; return ossl_x509_new(cert); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(OpenSSL::Timestamp::Response#to_der;F;7[;[[@ؔi;T;;M;0;[;{;IC; "YReturns the Response in DER-encoded form. call-seq: response.to_der -> string ;T;[;![;"I"ZReturns the Response in DER-encoded form. call-seq: response.to_der -> string ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;9I"static VALUE ossl_ts_resp_to_der(VALUE self) { TS_RESP *resp; GetTSResponse(self, resp); return asn1_to_der((void *)resp, (int (*)(void *, unsigned char **))i2d_TS_RESP); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(OpenSSL::Timestamp::Response#verify;F;7[[@90;[[@ؔi ;T;;J;0;[;{;IC; "]Verifies a timestamp token by checking the signature, validating the certificate chain implied by tsa_certificate and by checking conformance to a given Request. Mandatory parameters are the Request associated to this Response, and an OpenSSL::X509::Store of trusted roots. Intermediate certificates can optionally be supplied for creating the certificate chain. These intermediate certificates must all be instances of OpenSSL::X509::Certificate. If validation fails, several kinds of exceptions can be raised: * TypeError if types don't fit * TimestampError if something is wrong with the timestamp token itself, if it is not conformant to the Request, or if validation of the timestamp certificate chain fails. call-seq: response.verify(Request, root_store) -> Response response.verify(Request, root_store, [intermediate_cert]) -> Response ;T;[;![;"I"^Verifies a timestamp token by checking the signature, validating the certificate chain implied by tsa_certificate and by checking conformance to a given Request. Mandatory parameters are the Request associated to this Response, and an OpenSSL::X509::Store of trusted roots. Intermediate certificates can optionally be supplied for creating the certificate chain. These intermediate certificates must all be instances of OpenSSL::X509::Certificate. If validation fails, several kinds of exceptions can be raised: * TypeError if types don't fit * TimestampError if something is wrong with the timestamp token itself, if it is not conformant to the Request, or if validation of the timestamp certificate chain fails. call-seq: response.verify(Request, root_store) -> Response response.verify(Request, root_store, [intermediate_cert]) -> Response ;T;#0;$@;.F;/o;0;1T;2i;3i ;%@;9I"static VALUE ossl_ts_resp_verify(int argc, VALUE *argv, VALUE self) { VALUE ts_req, store, intermediates; TS_RESP *resp; TS_REQ *req; X509_STORE *x509st; TS_VERIFY_CTX *ctx; STACK_OF(X509) *x509inter = NULL; PKCS7* p7; X509 *cert; int status, i, ok; rb_scan_args(argc, argv, "21", &ts_req, &store, &intermediates); GetTSResponse(self, resp); GetTSRequest(ts_req, req); x509st = GetX509StorePtr(store); if (!(ctx = TS_REQ_to_TS_VERIFY_CTX(req, NULL))) { ossl_raise(eTimestampError, "Error when creating the verification context."); } if (!NIL_P(intermediates)) { x509inter = ossl_protect_x509_ary2sk(intermediates, &status); if (status) { TS_VERIFY_CTX_free(ctx); rb_jump_tag(status); } } else if (!(x509inter = sk_X509_new_null())) { TS_VERIFY_CTX_free(ctx); ossl_raise(eTimestampError, "sk_X509_new_null"); } if (!(p7 = TS_RESP_get_token(resp))) { TS_VERIFY_CTX_free(ctx); sk_X509_pop_free(x509inter, X509_free); ossl_raise(eTimestampError, "TS_RESP_get_token"); } for (i=0; i < sk_X509_num(p7->d.sign->cert); i++) { cert = sk_X509_value(p7->d.sign->cert, i); if (!sk_X509_push(x509inter, cert)) { sk_X509_pop_free(x509inter, X509_free); TS_VERIFY_CTX_free(ctx); ossl_raise(eTimestampError, "sk_X509_push"); } X509_up_ref(cert); } TS_VERIFY_CTX_set_certs(ctx, x509inter); TS_VERIFY_CTX_add_flags(ctx, TS_VFY_SIGNATURE); TS_VERIFY_CTX_set_store(ctx, x509st); ok = TS_RESP_verify_response(ctx, resp); /* * TS_VERIFY_CTX_set_store() call above does not increment the reference * counter, so it must be unset before TS_VERIFY_CTX_free() is called. */ TS_VERIFY_CTX_set_store(ctx, NULL); TS_VERIFY_CTX_free(ctx); if (!ok) ossl_raise(eTimestampError, "TS_RESP_verify_response"); return self; };T;:I"static VALUE;T;;To;u;[[@ؔi~;F;: GRANTED;;w;;;[;{;IC; "3Indicates a successful response. Equal to +0+. ;T;[;![;"I"4Indicates a successful response. Equal to +0+. ;T;#0;$@$;.F;/o;0;1T;2i{;3i|;%@;&I"*OpenSSL::Timestamp::Response::GRANTED;F;xI"INT2NUM(TS_STATUS_GRANTED);To;u;[[@ؔi;F;:GRANTED_WITH_MODS;;w;;;[;{;IC; "qIndicates a successful response that probably contains modifications from the initial request. Equal to +1+. ;T;[;![;"I"rIndicates a successful response that probably contains modifications from the initial request. Equal to +1+. ;T;#0;$@0;.F;/o;0;1T;2i;3i;%@;&I"4OpenSSL::Timestamp::Response::GRANTED_WITH_MODS;F;xI")INT2NUM(TS_STATUS_GRANTED_WITH_MODS);To;u;[[@ؔi;F;:REJECTION;;w;;;[;{;IC; "GIndicates a failure. No timestamp token was created. Equal to +2+. ;T;[;![;"I"HIndicates a failure. No timestamp token was created. Equal to +2+. ;T;#0;$@<;.F;/o;0;1T;2i;3i;%@;&I",OpenSSL::Timestamp::Response::REJECTION;F;xI"!INT2NUM(TS_STATUS_REJECTION);To;u;[[@ؔi;F;: WAITING;;w;;;[;{;IC; "GIndicates a failure. No timestamp token was created. Equal to +3+. ;T;[;![;"I"HIndicates a failure. No timestamp token was created. Equal to +3+. ;T;#0;$@H;.F;/o;0;1T;2i;3i;%@;&I"*OpenSSL::Timestamp::Response::WAITING;F;xI"INT2NUM(TS_STATUS_WAITING);To;u;[[@ؔi;F;:REVOCATION_WARNING;;w;;;[;{;IC; "pIndicates a failure. No timestamp token was created. Revocation of a certificate is imminent. Equal to +4+. ;T;[;![;"I"qIndicates a failure. No timestamp token was created. Revocation of a certificate is imminent. Equal to +4+. ;T;#0;$@T;.F;/o;0;1T;2i;3i;%@;&I"5OpenSSL::Timestamp::Response::REVOCATION_WARNING;F;xI"*INT2NUM(TS_STATUS_REVOCATION_WARNING);To;u;[[@ؔi;F;:REVOCATION_NOTIFICATION;;w;;;[;{;IC; "gIndicates a failure. No timestamp token was created. A certificate has been revoked. Equal to +5+. ;T;[;![;"I"hIndicates a failure. No timestamp token was created. A certificate has been revoked. Equal to +5+. ;T;#0;$@`;.F;/o;0;1T;2i;3i;%@;&I":OpenSSL::Timestamp::Response::REVOCATION_NOTIFICATION;F;xI"/INT2NUM(TS_STATUS_REVOCATION_NOTIFICATION);T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ؔi?[@ؔiE;T;;;;;;;[;{;IC; "Immutable and read-only representation of a timestamp response returned from a timestamp server after receiving an associated Request. Allows access to specific information about the response but also allows to verify the Response. ;T;[;![;"I"Immutable and read-only representation of a timestamp response returned from a timestamp server after receiving an associated Request. Allows access to specific information about the response but also allows to verify the Response. ;T;#0;$@;.F;/o;0;1T;2i?;3iC;%@;&I"!OpenSSL::Timestamp::Response;F;'@o; ;IC;[o;4;5F;6;;;;&I"-OpenSSL::Timestamp::TokenInfo#initialize;F;7[[I"der;T0;[[@ؔig;T;;D;0;[;{;IC; "{Creates a TokenInfo from a +File+ or +string+ parameter, the corresponding +File+ or +string+ must be DER-encoded. Please note that TokenInfo is an immutable read-only class. If you'd like to create timestamps please refer to Factory instead. call-seq: OpenSSL::Timestamp::TokenInfo.new(file) -> token-info OpenSSL::Timestamp::TokenInfo.new(string) -> token-info ;T;[;![;"I"|Creates a TokenInfo from a +File+ or +string+ parameter, the corresponding +File+ or +string+ must be DER-encoded. Please note that TokenInfo is an immutable read-only class. If you'd like to create timestamps please refer to Factory instead. call-seq: OpenSSL::Timestamp::TokenInfo.new(file) -> token-info OpenSSL::Timestamp::TokenInfo.new(string) -> token-info ;T;#0;$@;.F;/o;0;1T;2i];3ie;%@~;9I"static VALUE ossl_ts_token_info_initialize(VALUE self, VALUE der) { TS_TST_INFO *info = DATA_PTR(self); BIO *in; der = ossl_to_der_if_possible(der); in = ossl_obj2bio(&der); info = d2i_TS_TST_INFO_bio(in, &info); BIO_free(in); if (!info) { DATA_PTR(self) = NULL; ossl_raise(eTimestampError, "Error when decoding the timestamp token info"); } DATA_PTR(self) = info; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*OpenSSL::Timestamp::TokenInfo#version;F;7[;[[@ؔi;T;;?;0;[;{;IC; "Returns the version number of the token info. With compliant servers, this value should be +1+ if present. If status is GRANTED or GRANTED_WITH_MODS. call-seq: token_info.version -> Integer or nil ;T;[;![;"I"Returns the version number of the token info. With compliant servers, this value should be +1+ if present. If status is GRANTED or GRANTED_WITH_MODS. call-seq: token_info.version -> Integer or nil ;T;#0;$@;.F;/o;0;1T;2iz;3i;%@~;9I"static VALUE ossl_ts_token_info_get_version(VALUE self) { TS_TST_INFO *info; GetTSTokenInfo(self, info); return LONG2NUM(TS_TST_INFO_get_version(info)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",OpenSSL::Timestamp::TokenInfo#policy_id;F;7[;[[@ؔi;T;:policy_id;0;[;{;IC; "-Returns the timestamp policy object identifier of the policy this timestamp was created under. If status is GRANTED or GRANTED_WITH_MODS, this is never +nil+. ===Example: id = token_info.policy_id puts id -> "1.2.3.4.5" call-seq: token_info.policy_id -> string or nil ;T;[;![;"I".Returns the timestamp policy object identifier of the policy this timestamp was created under. If status is GRANTED or GRANTED_WITH_MODS, this is never +nil+. ===Example: id = token_info.policy_id puts id -> "1.2.3.4.5" call-seq: token_info.policy_id -> string or nil ;T;#0;$@;.F;/o;0;1T;2i;3i;%@~;9I"static VALUE ossl_ts_token_info_get_policy_id(VALUE self) { TS_TST_INFO *info; GetTSTokenInfo(self, info); return get_asn1obj(TS_TST_INFO_get_policy_id(info)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I",OpenSSL::Timestamp::TokenInfo#algorithm;F;7[;[[@ؔi;T;:algorithm;0;[;{;IC; "Returns the 'short name' of the object identifier representing the algorithm that was used to derive the message imprint digest. For valid timestamps, this is the same value that was already given in the Request. If status is GRANTED or GRANTED_WITH_MODS, this is never +nil+. ===Example: algo = token_info.algorithm puts algo -> "SHA1" call-seq: token_info.algorithm -> string or nil ;T;[;![;"I"Returns the 'short name' of the object identifier representing the algorithm that was used to derive the message imprint digest. For valid timestamps, this is the same value that was already given in the Request. If status is GRANTED or GRANTED_WITH_MODS, this is never +nil+. ===Example: algo = token_info.algorithm puts algo -> "SHA1" call-seq: token_info.algorithm -> string or nil ;T;#0;$@;.F;/o;0;1T;2i;3i;%@~;9I" static VALUE ossl_ts_token_info_get_algorithm(VALUE self) { TS_TST_INFO *info; TS_MSG_IMPRINT *mi; X509_ALGOR *algo; GetTSTokenInfo(self, info); mi = TS_TST_INFO_get_msg_imprint(info); algo = TS_MSG_IMPRINT_get_algo(mi); return get_asn1obj(algo->algorithm); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"2OpenSSL::Timestamp::TokenInfo#message_imprint;F;7[;[[@ؔi;T;:message_imprint;0;[;{;IC; "BReturns the message imprint digest. For valid timestamps, this is the same value that was already given in the Request. If status is GRANTED or GRANTED_WITH_MODS, this is never +nil+. ===Example: mi = token_info.msg_imprint puts mi -> "DEADBEEF" call-seq: token_info.msg_imprint -> string. ;T;[;![;"I"CReturns the message imprint digest. For valid timestamps, this is the same value that was already given in the Request. If status is GRANTED or GRANTED_WITH_MODS, this is never +nil+. ===Example: mi = token_info.msg_imprint puts mi -> "DEADBEEF" call-seq: token_info.msg_imprint -> string. ;T;#0;$@;.F;/o;0;1T;2i;3i;%@~;9I"ustatic VALUE ossl_ts_token_info_get_msg_imprint(VALUE self) { TS_TST_INFO *info; TS_MSG_IMPRINT *mi; ASN1_OCTET_STRING *hashed_msg; VALUE ret; GetTSTokenInfo(self, info); mi = TS_TST_INFO_get_msg_imprint(info); hashed_msg = TS_MSG_IMPRINT_get_msg(mi); ret = rb_str_new((const char *)hashed_msg->data, hashed_msg->length); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"0OpenSSL::Timestamp::TokenInfo#serial_number;F;7[;[[@ؔi;T;:serial_number;0;[;{;IC; " Returns serial number of the timestamp token. This value shall never be the same for two timestamp tokens issued by a dedicated timestamp authority. If status is GRANTED or GRANTED_WITH_MODS, this is never +nil+. call-seq: token_info.serial_number -> BN or nil ;T;[;![;"I" Returns serial number of the timestamp token. This value shall never be the same for two timestamp tokens issued by a dedicated timestamp authority. If status is GRANTED or GRANTED_WITH_MODS, this is never +nil+. call-seq: token_info.serial_number -> BN or nil ;T;#0;$@;.F;/o;0;1T;2i;3i;%@~;9I"static VALUE ossl_ts_token_info_get_serial_number(VALUE self) { TS_TST_INFO *info; GetTSTokenInfo(self, info); return asn1integer_to_num(TS_TST_INFO_get_serial(info)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+OpenSSL::Timestamp::TokenInfo#gen_time;F;7[;[[@ؔi;T;: gen_time;0;[;{;IC; "Returns time when this timestamp token was created. If status is GRANTED or GRANTED_WITH_MODS, this is never +nil+. call-seq: token_info.gen_time -> Time ;T;[;![;"I"Returns time when this timestamp token was created. If status is GRANTED or GRANTED_WITH_MODS, this is never +nil+. call-seq: token_info.gen_time -> Time ;T;#0;$@;.F;/o;0;1T;2i;3i;%@~;9I"static VALUE ossl_ts_token_info_get_gen_time(VALUE self) { TS_TST_INFO *info; GetTSTokenInfo(self, info); return asn1time_to_time(TS_TST_INFO_get_time(info)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+OpenSSL::Timestamp::TokenInfo#ordering;F;7[;[[@ؔi;T;: ordering;0;[;{;IC; "If the ordering field is missing, or if the ordering field is present and set to false, then the genTime field only indicates the time at which the time-stamp token has been created by the TSA. In such a case, the ordering of time-stamp tokens issued by the same TSA or different TSAs is only possible when the difference between the genTime of the first time-stamp token and the genTime of the second time-stamp token is greater than the sum of the accuracies of the genTime for each time-stamp token. If the ordering field is present and set to true, every time-stamp token from the same TSA can always be ordered based on the genTime field, regardless of the genTime accuracy. call-seq: token_info.ordering -> true, falses or nil ;T;[;![;"I"If the ordering field is missing, or if the ordering field is present and set to false, then the genTime field only indicates the time at which the time-stamp token has been created by the TSA. In such a case, the ordering of time-stamp tokens issued by the same TSA or different TSAs is only possible when the difference between the genTime of the first time-stamp token and the genTime of the second time-stamp token is greater than the sum of the accuracies of the genTime for each time-stamp token. If the ordering field is present and set to true, every time-stamp token from the same TSA can always be ordered based on the genTime field, regardless of the genTime accuracy. call-seq: token_info.ordering -> true, falses or nil ;T;#0;$@;.F;/o;0;1T;2i;3i;%@~;9I"static VALUE ossl_ts_token_info_get_ordering(VALUE self) { TS_TST_INFO *info; GetTSTokenInfo(self, info); return TS_TST_INFO_get_ordering(info) ? Qtrue : Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(OpenSSL::Timestamp::TokenInfo#nonce;F;7[;[[@ؔi;T;: nonce;0;[;{;IC; "If the timestamp token is valid then this field contains the same nonce that was passed to the timestamp server in the initial Request. call-seq: token_info.nonce -> BN or nil ;T;[;![;"I"If the timestamp token is valid then this field contains the same nonce that was passed to the timestamp server in the initial Request. call-seq: token_info.nonce -> BN or nil ;T;#0;$@;.F;/o;0;1T;2i;3i;%@~;9I"static VALUE ossl_ts_token_info_get_nonce(VALUE self) { TS_TST_INFO *info; const ASN1_INTEGER *nonce; GetTSTokenInfo(self, info); if (!(nonce = TS_TST_INFO_get_nonce(info))) return Qnil; return asn1integer_to_num(nonce); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I")OpenSSL::Timestamp::TokenInfo#to_der;F;7[;[[@ؔi+;T;;M;0;[;{;IC; "\Returns the TokenInfo in DER-encoded form. call-seq: token_info.to_der -> string ;T;[;![;"I"]Returns the TokenInfo in DER-encoded form. call-seq: token_info.to_der -> string ;T;#0;$@;.F;/o;0;1T;2i%;3i);%@~;9I"static VALUE ossl_ts_token_info_to_der(VALUE self) { TS_TST_INFO *info; GetTSTokenInfo(self, info); return asn1_to_der((void *)info, (int (*)(void *, unsigned char **))i2d_TS_TST_INFO); };T;:I"static VALUE;T;;T; @~; IC;[; @~; IC;[; @~; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ؔiQ[@ؔiU;T;:TokenInfo;;;;;[;{;IC; "VImmutable and read-only representation of a timestamp token info from a Response. ;T;[;![;"I"WImmutable and read-only representation of a timestamp token info from a Response. ;T;#0;$@~;.F;/o;0;1T;2iQ;3iS;%@;&I""OpenSSL::Timestamp::TokenInfo;F;'@o; ;IC;[o;4;5F;6;;;;&I"+OpenSSL::Timestamp::Request#initialize;F;7[[@90;[[@ؔi;T;;D;0;[;{;IC; "7When creating a Request with the +File+ or +string+ parameter, the corresponding +File+ or +string+ must be DER-encoded. call-seq: OpenSSL::Timestamp::Request.new(file) -> request OpenSSL::Timestamp::Request.new(string) -> request OpenSSL::Timestamp::Request.new -> empty request ;T;[;![;"I"8When creating a Request with the +File+ or +string+ parameter, the corresponding +File+ or +string+ must be DER-encoded. call-seq: OpenSSL::Timestamp::Request.new(file) -> request OpenSSL::Timestamp::Request.new(string) -> request OpenSSL::Timestamp::Request.new -> empty request ;T;#0;$@";.F;/o;0;1T;2i;3i;%@ ;9I"static VALUE ossl_ts_req_initialize(int argc, VALUE *argv, VALUE self) { TS_REQ *ts_req = DATA_PTR(self); BIO *in; VALUE arg; if(rb_scan_args(argc, argv, "01", &arg) == 0) { return self; } arg = ossl_to_der_if_possible(arg); in = ossl_obj2bio(&arg); ts_req = d2i_TS_REQ_bio(in, &ts_req); BIO_free(in); if (!ts_req) { DATA_PTR(self) = NULL; ossl_raise(eTimestampError, "Error when decoding the timestamp request"); } DATA_PTR(self) = ts_req; return self; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I")OpenSSL::Timestamp::Request#version=;F;7[[I" version;T0;[[@ؔiS;T;;@;0;[;{;IC; "Sets the version number for this Request. This should be +1+ for compliant servers. call-seq: request.version = number -> Integer ;T;[;![;"I"Sets the version number for this Request. This should be +1+ for compliant servers. call-seq: request.version = number -> Integer ;T;#0;$@1;.F;/o;0;1T;2iL;3iQ;%@ ;9I"\static VALUE ossl_ts_req_set_version(VALUE self, VALUE version) { TS_REQ *req; long ver; if ((ver = NUM2LONG(version)) < 0) ossl_raise(eTimestampError, "version must be >= 0!"); GetTSRequest(self, req); if (!TS_REQ_set_version(req, ver)) ossl_raise(eTimestampError, "TS_REQ_set_version"); return version; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"(OpenSSL::Timestamp::Request#version;F;7[;[[@ؔiC;T;;?;0;[;{;IC; "oReturns the version of this request. +1+ is the default value. call-seq: request.version -> Integer ;T;[;![;"I"pReturns the version of this request. +1+ is the default value. call-seq: request.version -> Integer ;T;#0;$@A;.F;/o;0;1T;2i=;3iA;%@ ;9I"static VALUE ossl_ts_req_get_version(VALUE self) { TS_REQ *req; GetTSRequest(self, req); return LONG2NUM(TS_REQ_get_version(req)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+OpenSSL::Timestamp::Request#algorithm=;F;7[[I" algo;T0;[[@ؔi;T;:algorithm=;0;[;{;IC; "Allows to set the object identifier or the 'short name' of the algorithm that was used to create the message imprint digest. ===Example: request.algorithm = "SHA1" call-seq: request.algorithm = "string" -> string ;T;[;![;"I"Allows to set the object identifier or the 'short name' of the algorithm that was used to create the message imprint digest. ===Example: request.algorithm = "SHA1" call-seq: request.algorithm = "string" -> string ;T;#0;$@O;.F;/o;0;1T;2i;3i;%@ ;9I"static VALUE ossl_ts_req_set_algorithm(VALUE self, VALUE algo) { TS_REQ *req; TS_MSG_IMPRINT *mi; ASN1_OBJECT *obj; X509_ALGOR *algor; GetTSRequest(self, req); obj = obj_to_asn1obj(algo); mi = TS_REQ_get_msg_imprint(req); algor = TS_MSG_IMPRINT_get_algo(mi); if (!X509_ALGOR_set0(algor, obj, V_ASN1_NULL, NULL)) { ASN1_OBJECT_free(obj); ossl_raise(eTimestampError, "X509_ALGOR_set0"); } return algo; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*OpenSSL::Timestamp::Request#algorithm;F;7[;[[@ؔi;T;;8;0;[;{;IC; "Returns the 'short name' of the object identifier that represents the algorithm that was used to create the message imprint digest. call-seq: request.algorithm -> string ;T;[;![;"I"Returns the 'short name' of the object identifier that represents the algorithm that was used to create the message imprint digest. call-seq: request.algorithm -> string ;T;#0;$@_;.F;/o;0;1T;2i;3i;%@ ;9I" static VALUE ossl_ts_req_get_algorithm(VALUE self) { TS_REQ *req; TS_MSG_IMPRINT *mi; X509_ALGOR *algor; GetTSRequest(self, req); mi = TS_REQ_get_msg_imprint(req); algor = TS_MSG_IMPRINT_get_algo(mi); return get_asn1obj(algor->algorithm); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"1OpenSSL::Timestamp::Request#message_imprint=;F;7[[I" hash;T0;[[@ؔi.;T;:message_imprint=;0;[;{;IC; "fSet the message imprint digest. call-seq: request.message_imprint = "string" -> string ;T;[;![;"I"gSet the message imprint digest. call-seq: request.message_imprint = "string" -> string ;T;#0;$@m;.F;/o;0;1T;2i(;3i,;%@ ;9I"xstatic VALUE ossl_ts_req_set_msg_imprint(VALUE self, VALUE hash) { TS_REQ *req; TS_MSG_IMPRINT *mi; StringValue(hash); GetTSRequest(self, req); mi = TS_REQ_get_msg_imprint(req); if (!TS_MSG_IMPRINT_set_msg(mi, (unsigned char *)RSTRING_PTR(hash), RSTRING_LENINT(hash))) ossl_raise(eTimestampError, "TS_MSG_IMPRINT_set_msg"); return hash; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"0OpenSSL::Timestamp::Request#message_imprint;F;7[;[[@ؔi;T;;9;0;[;{;IC; "Returns the message imprint (digest) of the data to be timestamped. call-seq: request.message_imprint -> string or nil ;T;[;![;"I"Returns the message imprint (digest) of the data to be timestamped. call-seq: request.message_imprint -> string or nil ;T;#0;$@};.F;/o;0;1T;2i;3i;%@ ;9I"`static VALUE ossl_ts_req_get_msg_imprint(VALUE self) { TS_REQ *req; TS_MSG_IMPRINT *mi; ASN1_OCTET_STRING *hashed_msg; VALUE ret; GetTSRequest(self, req); mi = TS_REQ_get_msg_imprint(req); hashed_msg = TS_MSG_IMPRINT_get_msg(mi); ret = rb_str_new((const char *)hashed_msg->data, hashed_msg->length); return ret; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"+OpenSSL::Timestamp::Request#policy_id=;F;7[[I"oid;T0;[[@ؔi;T;:policy_id=;0;[;{;IC; "VAllows to set the object identifier that represents the timestamp policy under which the server shall create the timestamp. This may be left +nil+, implying that the timestamp server will issue the timestamp using some default policy. ===Example: request.policy_id = "1.2.3.4.5" call-seq: request.policy_id = "string" -> string ;T;[;![;"I"WAllows to set the object identifier that represents the timestamp policy under which the server shall create the timestamp. This may be left +nil+, implying that the timestamp server will issue the timestamp using some default policy. ===Example: request.policy_id = "1.2.3.4.5" call-seq: request.policy_id = "string" -> string ;T;#0;$@;.F;/o;0;1T;2it;3i~;%@ ;9I"Pstatic VALUE ossl_ts_req_set_policy_id(VALUE self, VALUE oid) { TS_REQ *req; ASN1_OBJECT *obj; int ok; GetTSRequest(self, req); obj = obj_to_asn1obj(oid); ok = TS_REQ_set_policy_id(req, obj); ASN1_OBJECT_free(obj); if (!ok) ossl_raise(eTimestampError, "TS_REQ_set_policy_id"); return oid; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"*OpenSSL::Timestamp::Request#policy_id;F;7[;[[@ؔii;T;;7;0;[;{;IC; "Returns the 'short name' of the object identifier that represents the timestamp policy under which the server shall create the timestamp. call-seq: request.policy_id -> string or nil ;T;[;![;"I"Returns the 'short name' of the object identifier that represents the timestamp policy under which the server shall create the timestamp. call-seq: request.policy_id -> string or nil ;T;#0;$@;.F;/o;0;1T;2ib;3ig;%@ ;9I"static VALUE ossl_ts_req_get_policy_id(VALUE self) { TS_REQ *req; GetTSRequest(self, req); if (!TS_REQ_get_policy_id(req)) return Qnil; return get_asn1obj(TS_REQ_get_policy_id(req)); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::Timestamp::Request#nonce=;F;7[[I"num;T0;[[@ؔi;T;: nonce=;0;[;{;IC; "Sets the nonce (number used once) that the server shall include in its response. If the nonce is set, the server must return the same nonce value in a valid Response. call-seq: request.nonce = number -> BN ;T;[;![;"I"Sets the nonce (number used once) that the server shall include in its response. If the nonce is set, the server must return the same nonce value in a valid Response. call-seq: request.nonce = number -> BN ;T;#0;$@;.F;/o;0;1T;2i;3i;%@ ;9I"Istatic VALUE ossl_ts_req_set_nonce(VALUE self, VALUE num) { TS_REQ *req; ASN1_INTEGER *nonce; int ok; GetTSRequest(self, req); nonce = num_to_asn1integer(num, NULL); ok = TS_REQ_set_nonce(req, nonce); ASN1_INTEGER_free(nonce); if (!ok) ossl_raise(eTimestampError, NULL); return num; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"&OpenSSL::Timestamp::Request#nonce;F;7[;[[@ؔi;T;;=;0;[;{;IC; "Returns the nonce (number used once) that the server shall include in its response. call-seq: request.nonce -> BN or nil ;T;[;![;"I"Returns the nonce (number used once) that the server shall include in its response. call-seq: request.nonce -> BN or nil ;T;#0;$@;.F;/o;0;1T;2i;3i;%@ ;9I"static VALUE ossl_ts_req_get_nonce(VALUE self) { TS_REQ *req; const ASN1_INTEGER * nonce; GetTSRequest(self, req); if (!(nonce = TS_REQ_get_nonce(req))) return Qnil; return asn1integer_to_num(nonce); };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"0OpenSSL::Timestamp::Request#cert_requested=;F;7[[I"requested;T0;[[@ؔi;T;:cert_requested=;0;[;{;IC; "Specify whether the response shall contain the timestamp authority's certificate or not. The default value is +true+. call-seq: request.cert_requested = boolean -> true or false ;T;[;![;"I"Specify whether the response shall contain the timestamp authority's certificate or not. The default value is +true+. call-seq: request.cert_requested = boolean -> true or false ;T;#0;$@;.F;/o;0;1T;2i;3i;%@ ;9I"static VALUE ossl_ts_req_set_cert_requested(VALUE self, VALUE requested) { TS_REQ *req; GetTSRequest(self, req); TS_REQ_set_cert_req(req, RTEST(requested)); return requested; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"0OpenSSL::Timestamp::Request#cert_requested?;F;7[;[[@ؔi;T;:cert_requested?;0;[;{;IC; "Indicates whether the response shall contain the timestamp authority's certificate or not. call-seq: request.cert_requested? -> true or false;T;[o;A ;>I" return;F;?@;0;@[@L;$@;![;"I"Indicates whether the response shall contain the timestamp authority's certificate or not. call-seq: request.cert_requested? -> true or false ;T;#0;$@;.F;/o;0;1T;2i;3i;Bi;%@ ;9I"static VALUE ossl_ts_req_get_cert_requested(VALUE self) { TS_REQ *req; GetTSRequest(self, req); return TS_REQ_get_cert_req(req) ? Qtrue: Qfalse; };T;:I"static VALUE;T;;To;4;5F;6;;;;&I"'OpenSSL::Timestamp::Request#to_der;F;7[;[[@ؔi;T;;M;0;[;{;IC; "WDER-encodes this Request. call-seq: request.to_der -> DER-encoded string ;T;[;![;"I"XDER-encodes this Request. call-seq: request.to_der -> DER-encoded string ;T;#0;$@;.F;/o;0;1T;2i;3i;%@ ;9I"jstatic VALUE ossl_ts_req_to_der(VALUE self) { TS_REQ *req; TS_MSG_IMPRINT *mi; X509_ALGOR *algo; ASN1_OCTET_STRING *hashed_msg; GetTSRequest(self, req); mi = TS_REQ_get_msg_imprint(req); algo = TS_MSG_IMPRINT_get_algo(mi); if (OBJ_obj2nid(algo->algorithm) == NID_undef) ossl_raise(eTimestampError, "Message imprint missing algorithm"); hashed_msg = TS_MSG_IMPRINT_get_msg(mi); if (!hashed_msg->length) ossl_raise(eTimestampError, "Message imprint missing hashed message"); return asn1_to_der((void *)req, (int (*)(void *, unsigned char **))i2d_TS_REQ); };T;:I"static VALUE;T;;T; @ ; IC;[; @ ; IC;[; @ ; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ؔib[@ؔij;T;;;;;;;[;{;IC; "?Allows to create timestamp requests or parse existing ones. A Request is also needed for creating timestamps from scratch with Factory. When created from scratch, some default values are set: * version is set to +1+ * cert_requested is set to +true+ * algorithm, message_imprint, policy_id, and nonce are set to +false+ ;T;[;![;"I"@Allows to create timestamp requests or parse existing ones. A Request is also needed for creating timestamps from scratch with Factory. When created from scratch, some default values are set: * version is set to +1+ * cert_requested is set to +true+ * algorithm, message_imprint, policy_id, and nonce are set to +false+ ;T;#0;$@ ;.F;/o;0;1T;2ib;3ih;%@;&I" OpenSSL::Timestamp::Request;F;'@o; ;IC;[o;4;5F;6;;;;&I"1OpenSSL::Timestamp::Factory#create_timestamp;F;7[[I"key;T0[I"certificate;T0[I" request;T0;[[@ؔim;T;:create_timestamp;0;[;{;IC; "rCreates a Response with the help of an OpenSSL::PKey, an OpenSSL::X509::Certificate and a Request. Mandatory parameters for timestamp creation that need to be set in the Request: * Request#algorithm * Request#message_imprint Mandatory parameters that need to be set in the Factory: * Factory#serial_number * Factory#gen_time * Factory#allowed_digests In addition one of either Request#policy_id or Factory#default_policy_id must be set. Raises a TimestampError if creation fails, though successfully created error responses may be returned. call-seq: factory.create_timestamp(key, certificate, request) -> Response ;T;[;![;"I"sCreates a Response with the help of an OpenSSL::PKey, an OpenSSL::X509::Certificate and a Request. Mandatory parameters for timestamp creation that need to be set in the Request: * Request#algorithm * Request#message_imprint Mandatory parameters that need to be set in the Factory: * Factory#serial_number * Factory#gen_time * Factory#allowed_digests In addition one of either Request#policy_id or Factory#default_policy_id must be set. Raises a TimestampError if creation fails, though successfully created error responses may be returned. call-seq: factory.create_timestamp(key, certificate, request) -> Response ;T;#0;$@ ;.F;/o;0;1T;2iU;3ik;%@;9I"static VALUE ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request) { VALUE serial_number, def_policy_id, gen_time, additional_certs, allowed_digests; VALUE str; STACK_OF(X509) *inter_certs; VALUE tsresp, ret = Qnil; EVP_PKEY *sign_key; X509 *tsa_cert; TS_REQ *req; TS_RESP *response = NULL; TS_RESP_CTX *ctx = NULL; BIO *req_bio; ASN1_INTEGER *asn1_serial = NULL; ASN1_OBJECT *def_policy_id_obj = NULL; long lgen_time; const char * err_msg = NULL; int status = 0; tsresp = NewTSResponse(cTimestampResponse); tsa_cert = GetX509CertPtr(certificate); sign_key = GetPrivPKeyPtr(key); GetTSRequest(request, req); gen_time = ossl_tsfac_get_gen_time(self); if (!rb_obj_is_instance_of(gen_time, rb_cTime)) { err_msg = "@gen_time must be a Time."; goto end; } lgen_time = NUM2LONG(rb_funcall(gen_time, rb_intern("to_i"), 0)); serial_number = ossl_tsfac_get_serial_number(self); if (NIL_P(serial_number)) { err_msg = "@serial_number must be set."; goto end; } asn1_serial = num_to_asn1integer(serial_number, NULL); def_policy_id = ossl_tsfac_get_default_policy_id(self); if (NIL_P(def_policy_id) && !TS_REQ_get_policy_id(req)) { err_msg = "No policy id in the request and no default policy set"; goto end; } if (!NIL_P(def_policy_id) && !TS_REQ_get_policy_id(req)) { def_policy_id_obj = (ASN1_OBJECT*)rb_protect(obj_to_asn1obj_i, (VALUE)def_policy_id, &status); if (status) goto end; } if (!(ctx = TS_RESP_CTX_new())) { err_msg = "Memory allocation failed."; goto end; } TS_RESP_CTX_set_serial_cb(ctx, ossl_tsfac_serial_cb, &asn1_serial); if (!TS_RESP_CTX_set_signer_cert(ctx, tsa_cert)) { err_msg = "Certificate does not contain the timestamping extension"; goto end; } additional_certs = ossl_tsfac_get_additional_certs(self); if (rb_obj_is_kind_of(additional_certs, rb_cArray)) { inter_certs = ossl_protect_x509_ary2sk(additional_certs, &status); if (status) goto end; /* this dups the sk_X509 and ups each cert's ref count */ TS_RESP_CTX_set_certs(ctx, inter_certs); sk_X509_pop_free(inter_certs, X509_free); } TS_RESP_CTX_set_signer_key(ctx, sign_key); if (!NIL_P(def_policy_id) && !TS_REQ_get_policy_id(req)) TS_RESP_CTX_set_def_policy(ctx, def_policy_id_obj); if (TS_REQ_get_policy_id(req)) TS_RESP_CTX_set_def_policy(ctx, TS_REQ_get_policy_id(req)); TS_RESP_CTX_set_time_cb(ctx, ossl_tsfac_time_cb, &lgen_time); allowed_digests = ossl_tsfac_get_allowed_digests(self); if (rb_obj_is_kind_of(allowed_digests, rb_cArray)) { int i; VALUE rbmd; const EVP_MD *md; for (i = 0; i < RARRAY_LEN(allowed_digests); i++) { rbmd = rb_ary_entry(allowed_digests, i); md = (const EVP_MD *)rb_protect(ossl_evp_get_digestbyname_i, rbmd, &status); if (status) goto end; TS_RESP_CTX_add_md(ctx, md); } } str = rb_protect(ossl_to_der, request, &status); if (status) goto end; req_bio = (BIO*)rb_protect(ossl_obj2bio_i, (VALUE)&str, &status); if (status) goto end; response = TS_RESP_create_response(ctx, req_bio); BIO_free(req_bio); if (!response) { err_msg = "Error during response generation"; goto end; } /* bad responses aren't exceptional, but openssl still sets error * information. */ ossl_clear_error(); SetTSResponse(tsresp, response); ret = tsresp; end: ASN1_INTEGER_free(asn1_serial); ASN1_OBJECT_free(def_policy_id_obj); TS_RESP_CTX_free(ctx); if (err_msg) rb_exc_raise(ossl_make_error(eTimestampError, rb_str_new_cstr(err_msg))); if (status) rb_jump_tag(status); return ret; };T;:I"static VALUE;T;;T; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ؔi[@ؔi;T;: Factory;;;;;[;{;IC; "Used to generate a Response from scratch. Please bear in mind that the implementation will always apply and prefer the policy object identifier given in the request over the default policy id specified in the Factory. As a consequence, +default_policy_id+ will only be applied if no Request#policy_id was given. But this also means that one needs to check the policy identifier in the request manually before creating the Response, e.g. to check whether it complies to a specific set of acceptable policies. There exists also the possibility to add certificates (instances of OpenSSL::X509::Certificate) besides the timestamping certificate that will be included in the resulting timestamp token if Request#cert_requested? is +true+. Ideally, one would also include any intermediate certificates (the root certificate can be left out - in order to trust it any verifying party will have to be in its possession anyway). This simplifies validation of the timestamp since these intermediate certificates are "already there" and need not be passed as external parameters to Response#verify anymore, thus minimizing external resources needed for verification. ===Example: Inclusion of (untrusted) intermediate certificates Assume we received a timestamp request that has set Request#policy_id to +nil+ and Request#cert_requested? to true. The raw request bytes are stored in a variable called +req_raw+. We'd still like to integrate the necessary intermediate certificates (in +inter1.cer+ and +inter2.cer+) to simplify validation of the resulting Response. +ts.p12+ is a PKCS#12-compatible file including the private key and the timestamping certificate. req = OpenSSL::Timestamp::Request.new(raw_bytes) p12 = OpenSSL::PKCS12.new(File.binread('ts.p12'), 'pwd') inter1 = OpenSSL::X509::Certificate.new(File.binread('inter1.cer')) inter2 = OpenSSL::X509::Certificate.new(File.binread('inter2.cer')) fac = OpenSSL::Timestamp::Factory.new fac.gen_time = Time.now fac.serial_number = 1 fac.allowed_digests = ["sha256", "sha384", "sha512"] #needed because the Request contained no policy identifier fac.default_policy_id = '1.2.3.4.5' fac.additional_certificates = [ inter1, inter2 ] timestamp = fac.create_timestamp(p12.key, p12.certificate, req) ==Attributes ===default_policy_id Request#policy_id will always be preferred over this if present in the Request, only if Request#policy_id is nil default_policy will be used. If none of both is present, a TimestampError will be raised when trying to create a Response. call-seq: factory.default_policy_id = "string" -> string factory.default_policy_id -> string or nil ===serial_number Sets or retrieves the serial number to be used for timestamp creation. Must be present for timestamp creation. call-seq: factory.serial_number = number -> number factory.serial_number -> number or nil ===gen_time Sets or retrieves the Time value to be used in the Response. Must be present for timestamp creation. call-seq: factory.gen_time = Time -> Time factory.gen_time -> Time or nil ===additional_certs Sets or retrieves additional certificates apart from the timestamp certificate (e.g. intermediate certificates) to be added to the Response. Must be an Array of OpenSSL::X509::Certificate. call-seq: factory.additional_certs = [cert1, cert2] -> [ cert1, cert2 ] factory.additional_certs -> array or nil ===allowed_digests Sets or retrieves the digest algorithms that the factory is allowed create timestamps for. Known vulnerable or weak algorithms should not be allowed where possible. Must be an Array of String or OpenSSL::Digest subclass instances. call-seq: factory.allowed_digests = ["sha1", OpenSSL::Digest.new('SHA256').new] -> [ "sha1", OpenSSL::Digest) ] factory.allowed_digests -> array or nil ;T;[;![;"I" Used to generate a Response from scratch. Please bear in mind that the implementation will always apply and prefer the policy object identifier given in the request over the default policy id specified in the Factory. As a consequence, +default_policy_id+ will only be applied if no Request#policy_id was given. But this also means that one needs to check the policy identifier in the request manually before creating the Response, e.g. to check whether it complies to a specific set of acceptable policies. There exists also the possibility to add certificates (instances of OpenSSL::X509::Certificate) besides the timestamping certificate that will be included in the resulting timestamp token if Request#cert_requested? is +true+. Ideally, one would also include any intermediate certificates (the root certificate can be left out - in order to trust it any verifying party will have to be in its possession anyway). This simplifies validation of the timestamp since these intermediate certificates are "already there" and need not be passed as external parameters to Response#verify anymore, thus minimizing external resources needed for verification. ===Example: Inclusion of (untrusted) intermediate certificates Assume we received a timestamp request that has set Request#policy_id to +nil+ and Request#cert_requested? to true. The raw request bytes are stored in a variable called +req_raw+. We'd still like to integrate the necessary intermediate certificates (in +inter1.cer+ and +inter2.cer+) to simplify validation of the resulting Response. +ts.p12+ is a PKCS#12-compatible file including the private key and the timestamping certificate. req = OpenSSL::Timestamp::Request.new(raw_bytes) p12 = OpenSSL::PKCS12.new(File.binread('ts.p12'), 'pwd') inter1 = OpenSSL::X509::Certificate.new(File.binread('inter1.cer')) inter2 = OpenSSL::X509::Certificate.new(File.binread('inter2.cer')) fac = OpenSSL::Timestamp::Factory.new fac.gen_time = Time.now fac.serial_number = 1 fac.allowed_digests = ["sha256", "sha384", "sha512"] #needed because the Request contained no policy identifier fac.default_policy_id = '1.2.3.4.5' fac.additional_certificates = [ inter1, inter2 ] timestamp = fac.create_timestamp(p12.key, p12.certificate, req) ==Attributes ===default_policy_id Request#policy_id will always be preferred over this if present in the Request, only if Request#policy_id is nil default_policy will be used. If none of both is present, a TimestampError will be raised when trying to create a Response. call-seq: factory.default_policy_id = "string" -> string factory.default_policy_id -> string or nil ===serial_number Sets or retrieves the serial number to be used for timestamp creation. Must be present for timestamp creation. call-seq: factory.serial_number = number -> number factory.serial_number -> number or nil ===gen_time Sets or retrieves the Time value to be used in the Response. Must be present for timestamp creation. call-seq: factory.gen_time = Time -> Time factory.gen_time -> Time or nil ===additional_certs Sets or retrieves additional certificates apart from the timestamp certificate (e.g. intermediate certificates) to be added to the Response. Must be an Array of OpenSSL::X509::Certificate. call-seq: factory.additional_certs = [cert1, cert2] -> [ cert1, cert2 ] factory.additional_certs -> array or nil ===allowed_digests Sets or retrieves the digest algorithms that the factory is allowed create timestamps for. Known vulnerable or weak algorithms should not be allowed where possible. Must be an Array of String or OpenSSL::Digest subclass instances. call-seq: factory.allowed_digests = ["sha1", OpenSSL::Digest.new('SHA256').new] -> [ "sha1", OpenSSL::Digest) ] factory.allowed_digests -> array or nil ;T;#0;$@;.F;/o;0;1T;2i;3i;%@;&I" OpenSSL::Timestamp::Factory;F;'@; @; IC;[; @; IC;[; @; IC;{;IC;{;T;IC;{;T;T;{;[;[[@ؔi8;F;;;;;;;[;{;IC; " ;T;[;![;"@;#0;$@;Bi;%@GH;&I"OpenSSL::Timestamp;F;&I"'OpenSSL::Timestamp::TimestampError;F;'@H:!OpenSSL::Timestamp::Response@:,OpenSSL::Timestamp::Response#initialize@:(OpenSSL::Timestamp::Response#status@:.OpenSSL::Timestamp::Response#failure_info@:-OpenSSL::Timestamp::Response#status_text@:'OpenSSL::Timestamp::Response#token@:,OpenSSL::Timestamp::Response#token_info@:1OpenSSL::Timestamp::Response#tsa_certificate@:(OpenSSL::Timestamp::Response#to_der@:(OpenSSL::Timestamp::Response#verify@:"OpenSSL::Timestamp::TokenInfo@~:-OpenSSL::Timestamp::TokenInfo#initialize@:*OpenSSL::Timestamp::TokenInfo#version@:,OpenSSL::Timestamp::TokenInfo#policy_id@:,OpenSSL::Timestamp::TokenInfo#algorithm@:2OpenSSL::Timestamp::TokenInfo#message_imprint@:0OpenSSL::Timestamp::TokenInfo#serial_number@:+OpenSSL::Timestamp::TokenInfo#gen_time@:+OpenSSL::Timestamp::TokenInfo#ordering@:(OpenSSL::Timestamp::TokenInfo#nonce@:)OpenSSL::Timestamp::TokenInfo#to_der@: OpenSSL::Timestamp::Request@ :+OpenSSL::Timestamp::Request#initialize@":)OpenSSL::Timestamp::Request#version=@1:(OpenSSL::Timestamp::Request#version@A:+OpenSSL::Timestamp::Request#algorithm=@O:*OpenSSL::Timestamp::Request#algorithm@_:1OpenSSL::Timestamp::Request#message_imprint=@m:0OpenSSL::Timestamp::Request#message_imprint@}:+OpenSSL::Timestamp::Request#policy_id=@:*OpenSSL::Timestamp::Request#policy_id@:'OpenSSL::Timestamp::Request#nonce=@:&OpenSSL::Timestamp::Request#nonce@:0OpenSSL::Timestamp::Request#cert_requested=@:0OpenSSL::Timestamp::Request#cert_requested?@:'OpenSSL::Timestamp::Request#to_der@:*OpenSSL::Timestamp::Response::GRANTED@$:4OpenSSL::Timestamp::Response::GRANTED_WITH_MODS@0:,OpenSSL::Timestamp::Response::REJECTION@<:*OpenSSL::Timestamp::Response::WAITING@H:5OpenSSL::Timestamp::Response::REVOCATION_WARNING@T::OpenSSL::Timestamp::Response::REVOCATION_NOTIFICATION@`: OpenSSL::Timestamp::Factory@:1OpenSSL::Timestamp::Factory#create_timestamp@ :OpenSSL::KDF@:OpenSSL::KDF::KDFError@:OpenSSL::KDF#pbkdf2_hmac@:OpenSSL::KDF.pbkdf2_hmac@:OpenSSL::KDF#scrypt@B:OpenSSL::KDF.scrypt@k:OpenSSL::KDF#hkdf@:OpenSSL::KDF.hkdf@:$OpenSSL::X509::CertificateError@:OpenSSL::X509::Certificate@;J@:*OpenSSL::X509::Certificate#initialize@:/OpenSSL::X509::Certificate#initialize_copy@ :&OpenSSL::X509::Certificate#to_der@:&OpenSSL::X509::Certificate#to_pem@6:$OpenSSL::X509::Certificate#to_s@N:'OpenSSL::X509::Certificate#to_text@Y:'OpenSSL::X509::Certificate#version@t:(OpenSSL::X509::Certificate#version=@:3OpenSSL::X509::Certificate#signature_algorithm@:&OpenSSL::X509::Certificate#serial@ɉ:'OpenSSL::X509::Certificate#serial=@:'OpenSSL::X509::Certificate#subject@:(OpenSSL::X509::Certificate#subject=@:&OpenSSL::X509::Certificate#issuer@3:'OpenSSL::X509::Certificate#issuer=@I:*OpenSSL::X509::Certificate#not_before@c:+OpenSSL::X509::Certificate#not_before=@~:)OpenSSL::X509::Certificate#not_after@:*OpenSSL::X509::Certificate#not_after=@:*OpenSSL::X509::Certificate#public_key@׊:+OpenSSL::X509::Certificate#public_key=@:$OpenSSL::X509::Certificate#sign@:&OpenSSL::X509::Certificate#verify@*:1OpenSSL::X509::Certificate#check_private_key@D:*OpenSSL::X509::Certificate#extensions@^:+OpenSSL::X509::Certificate#extensions=@y:-OpenSSL::X509::Certificate#add_extension@:'OpenSSL::X509::Certificate#inspect@:"OpenSSL::X509::Certificate#==@:OpenSSL::X509::StoreError@ۋ:OpenSSL::X509::Store@:$OpenSSL::X509::Store#initialize@:*OpenSSL::X509::Store#verify_callback=@: OpenSSL::X509::Store#flags=@:"OpenSSL::X509::Store#purpose=@/: OpenSSL::X509::Store#trust=@I:OpenSSL::X509::Store#time=@c:"OpenSSL::X509::Store#add_path@}:"OpenSSL::X509::Store#add_file@:+OpenSSL::X509::Store#set_default_paths@:"OpenSSL::X509::Store#add_cert@ь:!OpenSSL::X509::Store#add_crl@: OpenSSL::X509::Store#verify@: OpenSSL::X509::StoreContext@=:+OpenSSL::X509::StoreContext#initialize@?:'OpenSSL::X509::StoreContext#verify@^:&OpenSSL::X509::StoreContext#chain@t:&OpenSSL::X509::StoreContext#error@:'OpenSSL::X509::StoreContext#error=@:-OpenSSL::X509::StoreContext#error_string@č:,OpenSSL::X509::StoreContext#error_depth@ߍ:-OpenSSL::X509::StoreContext#current_cert@:,OpenSSL::X509::StoreContext#current_crl@:'OpenSSL::X509::StoreContext#flags=@0:)OpenSSL::X509::StoreContext#purpose=@J:'OpenSSL::X509::StoreContext#trust=@d:&OpenSSL::X509::StoreContext#time=@~:OpenSSL::PKey@:OpenSSL::PKey::PKey@:OpenSSL::PKey::PKeyError@ :OpenSSL::PKey::DHError@ :OpenSSL::PKey::DH@4:!OpenSSL::PKey::DH#initialize@6:&OpenSSL::PKey::DH#initialize_copy@a:OpenSSL::PKey::DH#public?@o:OpenSSL::PKey::DH#private?@:OpenSSL::PKey::DH#export@:OpenSSL::PKey::DH#to_pem@ޖ:OpenSSL::PKey::DH#to_s@Ӗ:OpenSSL::PKey::DH#to_der@:!OpenSSL::PKey::DH#params_ok?@:OpenSSL::PKey::DH#set_pqg@:OpenSSL::PKey::DH#set_key@8:OpenSSL::PKey::DH#params@T:OpenSSL::X509::CRLError@:OpenSSL::X509::CRL@:"OpenSSL::X509::CRL#initialize@:'OpenSSL::X509::CRL#initialize_copy@ʎ:OpenSSL::X509::CRL#version@؎: OpenSSL::X509::CRL#version=@:+OpenSSL::X509::CRL#signature_algorithm@:OpenSSL::X509::CRL#issuer@:OpenSSL::X509::CRL#issuer=@ :#OpenSSL::X509::CRL#last_update@:$OpenSSL::X509::CRL#last_update=@&:#OpenSSL::X509::CRL#next_update@4:$OpenSSL::X509::CRL#next_update=@@:OpenSSL::X509::CRL#revoked@N: OpenSSL::X509::CRL#revoked=@Z:#OpenSSL::X509::CRL#add_revoked@h:OpenSSL::X509::CRL#sign@v:OpenSSL::X509::CRL#verify@:OpenSSL::X509::CRL#to_der@:OpenSSL::X509::CRL#to_pem@:OpenSSL::X509::CRL#to_s@:OpenSSL::X509::CRL#to_text@:"OpenSSL::X509::CRL#extensions@:#OpenSSL::X509::CRL#extensions=@Ώ:%OpenSSL::X509::CRL#add_extension@ޏ:OpenSSL::PKey::ECError@:OpenSSL::PKey::EC@:OpenSSL::PKey::EC::Group@:OpenSSL::PKey::EC::Point@ș:$OpenSSL::PKey::EC::Group::Error@:$OpenSSL::PKey::EC::Point::Error@ʙ:#OpenSSL::PKey::EC::NAMED_CURVE@+:&OpenSSL::PKey::EC::EXPLICIT_CURVE@5:%OpenSSL::PKey::EC.builtin_curves@?:OpenSSL::PKey::EC.generate@Z:!OpenSSL::PKey::EC#initialize@~:&OpenSSL::PKey::EC#initialize_copy@Ǜ:OpenSSL::PKey::EC#group@՛:OpenSSL::PKey::EC#group=@:"OpenSSL::PKey::EC#private_key@:#OpenSSL::PKey::EC#private_key=@ :!OpenSSL::PKey::EC#public_key@::"OpenSSL::PKey::EC#public_key=@U:OpenSSL::PKey::EC#private?@o:OpenSSL::PKey::EC#public?@:#OpenSSL::PKey::EC#private_key?@:"OpenSSL::PKey::EC#public_key?@:$OpenSSL::PKey::EC#generate_key!@:#OpenSSL::PKey::EC#generate_key@͜: OpenSSL::PKey::EC#check_key@؜:OpenSSL::PKey::EC#export@:OpenSSL::PKey::EC#to_pem@:OpenSSL::PKey::EC#to_der@(:(OpenSSL::PKey::EC::Group#initialize@:-OpenSSL::PKey::EC::Group#initialize_copy@:"OpenSSL::PKey::EC::Group#eql?@: OpenSSL::PKey::EC::Group#==@:'OpenSSL::PKey::EC::Group#generator@):+OpenSSL::PKey::EC::Group#set_generator@?:#OpenSSL::PKey::EC::Group#order@f:&OpenSSL::PKey::EC::Group#cofactor@|:(OpenSSL::PKey::EC::Group#curve_name@:'OpenSSL::PKey::EC::Group#asn1_flag@:(OpenSSL::PKey::EC::Group#asn1_flag=@Ș:3OpenSSL::PKey::EC::Group#point_conversion_form@:4OpenSSL::PKey::EC::Group#point_conversion_form=@:"OpenSSL::PKey::EC::Group#seed@:#OpenSSL::PKey::EC::Group#seed=@3:$OpenSSL::PKey::EC::Group#degree@M:$OpenSSL::PKey::EC::Group#to_pem@h:$OpenSSL::PKey::EC::Group#to_der@:%OpenSSL::PKey::EC::Group#to_text@:(OpenSSL::PKey::EC::Point#initialize@ۙ:-OpenSSL::PKey::EC::Point#initialize_copy@:"OpenSSL::PKey::EC::Point#eql?@ : OpenSSL::PKey::EC::Point#==@0:'OpenSSL::PKey::EC::Point#infinity?@;:'OpenSSL::PKey::EC::Point#on_curve?@T:*OpenSSL::PKey::EC::Point#make_affine!@m:%OpenSSL::PKey::EC::Point#invert!@:.OpenSSL::PKey::EC::Point#set_to_infinity!@:-OpenSSL::PKey::EC::Point#to_octet_string@:!OpenSSL::PKey::EC::Point#add@ݚ:!OpenSSL::PKey::EC::Point#mul@:OpenSSL::PKey::RSAError@U:OpenSSL::PKey::RSA@i:"OpenSSL::PKey::RSA#initialize@k:'OpenSSL::PKey::RSA#initialize_copy@:OpenSSL::PKey::RSA#public?@: OpenSSL::PKey::RSA#private?@̝:OpenSSL::PKey::RSA#export@:OpenSSL::PKey::RSA#to_pem@):OpenSSL::PKey::RSA#to_s@:OpenSSL::PKey::RSA#to_der@1: OpenSSL::PKey::RSA#sign_pss@L:"OpenSSL::PKey::RSA#verify_pss@r:OpenSSL::PKey::RSA#set_key@:#OpenSSL::PKey::RSA#set_factors@:&OpenSSL::PKey::RSA#set_crt_params@Ϟ:OpenSSL::PKey::RSA#params@:OpenSSL::BNError@~:OpenSSL::BN@:OpenSSL::BN#initialize@: OpenSSL::BN#initialize_copy@Š:OpenSSL::BN#copy@Π:OpenSSL::BN#num_bytes@נ:OpenSSL::BN#num_bits@:OpenSSL::BN#+@@:OpenSSL::BN#-@@:OpenSSL::BN#abs@3:OpenSSL::BN#+@I:OpenSSL::BN#-@^:OpenSSL::BN#*@s:OpenSSL::BN#sqr@:OpenSSL::BN#/@:OpenSSL::BN#%@:OpenSSL::BN#mod_add@ϡ:OpenSSL::BN#mod_sub@:OpenSSL::BN#mod_mul@:OpenSSL::BN#mod_sqr@:OpenSSL::BN#**@):OpenSSL::BN#mod_exp@>:OpenSSL::BN#gcd@U:OpenSSL::BN#cmp@j:OpenSSL::BN#<=>@:OpenSSL::BN#ucmp@:OpenSSL::BN#eql?@:OpenSSL::BN#hash@Ţ:OpenSSL::BN#==@:OpenSSL::BN#===@:OpenSSL::BN#zero?@:OpenSSL::BN#one?@:OpenSSL::BN#odd?@:OpenSSL::BN#negative?@3:OpenSSL::BN.rand@?:OpenSSL::BN.rand_range@J:OpenSSL::BN.generate_prime@d:OpenSSL::BN#prime?@: OpenSSL::BN#prime_fasttest?@:OpenSSL::BN#set_bit!@ӣ:OpenSSL::BN#clear_bit!@:OpenSSL::BN#bit_set?@:OpenSSL::BN#mask_bits!@:OpenSSL::BN#<<@:OpenSSL::BN#>>@1:OpenSSL::BN#lshift!@F:OpenSSL::BN#rshift!@`:OpenSSL::BN#get_flags@z:OpenSSL::BN#set_flags@:OpenSSL::BN::CONSTTIME@:OpenSSL::BN#to_s@:OpenSSL::BN#to_i@ܤ:OpenSSL::BN#to_int@:OpenSSL::BN#to_bn@:OpenSSL::BN#coerce@ :OpenSSL::BN#mod_inverse@:OpenSSL::Cipher@3:!OpenSSL::Cipher::CipherError@5:$OpenSSL::Cipher#initialize_copy@F:OpenSSL::Cipher#ciphers@T;@i:OpenSSL::Cipher#initialize@y:OpenSSL::Cipher#reset@:OpenSSL::Cipher#encrypt@:OpenSSL::Cipher#decrypt@ʥ:#OpenSSL::Cipher#pkcs5_keyivgen@:OpenSSL::Cipher#update@ :OpenSSL::Cipher#final@+:OpenSSL::Cipher#name@F:OpenSSL::Cipher#key=@a:OpenSSL::Cipher#auth_data=@:OpenSSL::Cipher#auth_tag=@:OpenSSL::Cipher#auth_tag@:"OpenSSL::Cipher#auth_tag_len=@ݦ:#OpenSSL::Cipher#authenticated?@:OpenSSL::Cipher#key_len=@:OpenSSL::Cipher#key_len@4:OpenSSL::Cipher#iv=@O:OpenSSL::Cipher#iv_len=@n:OpenSSL::Cipher#iv_len@:OpenSSL::Cipher#block_size@:OpenSSL::Cipher#padding=@ç:"OpenSSL::Cipher#ccm_data_len=@:OpenSSL::PKCS12@:!OpenSSL::PKCS12::PKCS12Error@:OpenSSL::PKCS12.create@&:$OpenSSL::PKCS12#initialize_copy@E:OpenSSL::PKCS12#initialize@S:OpenSSL::PKCS12#to_der@:OpenSSL::PKey::DSAError@:OpenSSL::PKey::DSA@.:"OpenSSL::PKey::DSA#initialize@0:'OpenSSL::PKey::DSA#initialize_copy@[:OpenSSL::PKey::DSA#public?@i: OpenSSL::PKey::DSA#private?@:OpenSSL::PKey::DSA#export@:OpenSSL::PKey::DSA#to_pem@ߟ:OpenSSL::PKey::DSA#to_s@ԟ:OpenSSL::PKey::DSA#to_der@:OpenSSL::PKey::DSA#set_pqg@:OpenSSL::PKey::DSA#set_key@ :OpenSSL::PKey::DSA#params@<:Digest::DigestError@G:Digest#initialize@:Digest#initialize_copy@/:Digest#reset@=:Digest#update@X:Digest#<<@t:Digest#finish@:Digest#digest_length@:Digest#block_length@:Digest#name@Ѱ:OpenSSL::Digest@:!OpenSSL::Digest::DigestError@:OpenSSL::ASN1@ƨ:OpenSSL::ASN1::ASN1Error@Ȩ:OpenSSL::ASN1#traverse@ܨ;@:OpenSSL::ASN1#decode@;@/:OpenSSL::ASN1#decode_all@F;@d:&OpenSSL::ASN1::UNIVERSAL_TAG_NAME@{:OpenSSL::ASN1::ASN1Data@:,OpenSSL::ASN1::ASN1Data#infinite_length@:-OpenSSL::ASN1::ASN1Data#infinite_length=@:'OpenSSL::ASN1::ASN1Data#initialize@:#OpenSSL::ASN1::ASN1Data#to_der@Ʃ:OpenSSL::ASN1::Primitive@:(OpenSSL::ASN1::Primitive#initialize@:$OpenSSL::ASN1::Primitive#to_der@: OpenSSL::ASN1::Constructive@@:+OpenSSL::ASN1::Constructive#initialize@B:'OpenSSL::ASN1::Constructive#to_der@_:%OpenSSL::ASN1::Constructive#each@z:OpenSSL::ASN1::ObjectId@;!@:OpenSSL::ASN1::ObjectId#sn@˪:OpenSSL::ASN1::ObjectId#ln@: OpenSSL::ASN1::ObjectId#oid@+:'OpenSSL::ASN1::ObjectId#short_name@:&OpenSSL::ASN1::ObjectId#long_name@ :OpenSSL::ASN1::ObjectId#==@F: ASN1EndOfContent#initializeo;4;5F;6;;;;&I" ASN1EndOfContent#initialize;T;7[;[[@1HiX;T;;D;0;[;{;IC; " ;T;[;![;"@;#0;$@@;%o;( ;)0;*0;+0;:ASN1EndOfContent;%@;-0;0;9I"static VALUE ossl_asn1eoc_initialize(VALUE self) { VALUE tag, tagging, tag_class, value; tag = INT2FIX(0); tagging = Qnil; tag_class = sym_UNIVERSAL; value = rb_str_new("", 0); ossl_asn1_set_tag(self, tag); ossl_asn1_set_value(self, value); ossl_asn1_set_tagging(self, tagging); ossl_asn1_set_tag_class(self, tag_class); ossl_asn1_set_indefinite_length(self, Qfalse); return self; };T;:I"static VALUE;T;;T: OpenSSL::X509::RevokedError@:OpenSSL::X509::Revoked@ :&OpenSSL::X509::Revoked#initialize@:+OpenSSL::X509::Revoked#initialize_copy@:"OpenSSL::X509::Revoked#serial@):#OpenSSL::X509::Revoked#serial=@5: OpenSSL::X509::Revoked#time@C:!OpenSSL::X509::Revoked#time=@O:&OpenSSL::X509::Revoked#extensions@]:'OpenSSL::X509::Revoked#extensions=@k:)OpenSSL::X509::Revoked#add_extension@{:"OpenSSL::X509::Revoked#to_der@:OpenSSL::X509::Name@:OpenSSL::X509::NameError@:#OpenSSL::X509::Name#initialize@:(OpenSSL::X509::Name#initialize_copy@ݐ:"OpenSSL::X509::Name#add_entry@:OpenSSL::X509::Name#to_s@: OpenSSL::X509::Name#to_utf8@<: OpenSSL::X509::Name#inspect@W:OpenSSL::X509::Name#to_a@e:OpenSSL::X509::Name#cmp@:OpenSSL::X509::Name#<=>@:OpenSSL::X509::Name#eql?@:OpenSSL::X509::Name#hash@ӑ:!OpenSSL::X509::Name#hash_old@:OpenSSL::X509::Name#to_der@ :-OpenSSL::X509::Name::DEFAULT_OBJECT_TYPE@$:.OpenSSL::X509::Name::OBJECT_TYPE_TEMPLATE@0: OpenSSL::X509::Name::COMPAT@<:!OpenSSL::X509::Name::RFC2253@H:!OpenSSL::X509::Name::ONELINE@T:#OpenSSL::X509::Name::MULTILINE@`:"OpenSSL::X509::ExtensionError@:$OpenSSL::X509::ExtensionFactory@:/OpenSSL::X509::ExtensionFactory#initialize@:8OpenSSL::X509::ExtensionFactory#issuer_certificate=@:9OpenSSL::X509::ExtensionFactory#subject_certificate=@:5OpenSSL::X509::ExtensionFactory#subject_request=@͒:)OpenSSL::X509::ExtensionFactory#crl=@ے:/OpenSSL::X509::ExtensionFactory#create_ext@:OpenSSL::X509::Extension@,:(OpenSSL::X509::Extension#initialize@.:-OpenSSL::X509::Extension#initialize_copy@a:"OpenSSL::X509::Extension#oid=@o:$OpenSSL::X509::Extension#value=@}:'OpenSSL::X509::Extension#critical=@:!OpenSSL::X509::Extension#oid@:#OpenSSL::X509::Extension#value@:'OpenSSL::X509::Extension#value_der@:'OpenSSL::X509::Extension#critical?@:$OpenSSL::X509::Extension#to_der@̓:OpenSSL::ExtConfig@:OpenSSL::SSL::SSLError@BL:'OpenSSL::SSL::SSLErrorWaitReadable@VL:'OpenSSL::SSL::SSLErrorWaitWritable@t:OpenSSL::SSL::SSLContext@t:.OpenSSL::ExtConfig::HAVE_TLSEXT_HOST_NAME@:)OpenSSL::SSL::SSLContext#ssl_timeout@t:*OpenSSL::SSL::SSLContext#ssl_timeout=@t:6OpenSSL::SSL::SSLContext#set_minmax_proto_version@u:%OpenSSL::SSL::SSLContext#ciphers@*u:&OpenSSL::SSL::SSLContext#ciphers=@Eu:%OpenSSL::SSL::SSLContext#tmp_dh=@Uu:*OpenSSL::SSL::SSLContext#ecdh_curves=@ou:,OpenSSL::SSL::SSLContext#security_level@u:-OpenSSL::SSL::SSLContext#security_level=@u:2OpenSSL::SSL::SSLContext#enable_fallback_scsv@u:-OpenSSL::SSL::SSLContext#add_certificate@u:#OpenSSL::SSL::SSLContext#setup@u:$OpenSSL::SSL::SSLContext#freeze@v:0OpenSSL::SSL::SSLContext::SESSION_CACHE_OFF@$v:3OpenSSL::SSL::SSLContext::SESSION_CACHE_CLIENT@0v:3OpenSSL::SSL::SSLContext::SESSION_CACHE_SERVER@OpenSSL::SSL::SSLContext::SESSION_CACHE_NO_INTERNAL_STORE@lv:8OpenSSL::SSL::SSLContext::SESSION_CACHE_NO_INTERNAL@xv:)OpenSSL::SSL::SSLContext#session_add@v:,OpenSSL::SSL::SSLContext#session_remove@v:0OpenSSL::SSL::SSLContext#session_cache_mode@v:1OpenSSL::SSL::SSLContext#session_cache_mode=@v:0OpenSSL::SSL::SSLContext#session_cache_size@v:1OpenSSL::SSL::SSLContext#session_cache_size=@ w:1OpenSSL::SSL::SSLContext#session_cache_stats@,w:,OpenSSL::SSL::SSLContext#flush_sessions@Gw:%OpenSSL::SSL::SSLContext#options@ew:&OpenSSL::SSL::SSLContext#options=@sw:OpenSSL::SSL::SSLSocket@w:(OpenSSL::ExtConfig::OPENSSL_NO_SOCK@:'OpenSSL::SSL::SSLSocket#initialize@w:$OpenSSL::SSL::SSLSocket#connect@w:-OpenSSL::SSL::SSLSocket#connect_nonblock@w:#OpenSSL::SSL::SSLSocket#accept@x:,OpenSSL::SSL::SSLSocket#accept_nonblock@x:$OpenSSL::SSL::SSLSocket#sysread@9x:-OpenSSL::SSL::SSLSocket#sysread_nonblock@cx:%OpenSSL::SSL::SSLSocket#syswrite@x:.OpenSSL::SSL::SSLSocket#syswrite_nonblock@x:!OpenSSL::SSL::SSLSocket#stop@x:!OpenSSL::SSL::SSLSocket#cert@x:&OpenSSL::SSL::SSLSocket#peer_cert@ y:,OpenSSL::SSL::SSLSocket#peer_cert_chain@%y:(OpenSSL::SSL::SSLSocket#ssl_version@Ay:#OpenSSL::SSL::SSLSocket#cipher@\y:"OpenSSL::SSL::SSLSocket#state@xy:$OpenSSL::SSL::SSLSocket#pending@y:,OpenSSL::SSL::SSLSocket#session_reused?@y:%OpenSSL::SSL::SSLSocket#session=@y:*OpenSSL::SSL::SSLSocket#verify_result@y:&OpenSSL::SSL::SSLSocket#client_ca@y:&OpenSSL::SSL::SSLSocket#hostname=@z:-OpenSSL::SSL::SSLSocket#finished_message@1z:2OpenSSL::SSL::SSLSocket#peer_finished_message@Gz:$OpenSSL::SSL::SSLSocket#tmp_key@]z:*OpenSSL::SSL::SSLSocket#alpn_protocol@yz:)OpenSSL::SSL::SSLSocket#npn_protocol@z:OpenSSL::SSL::VERIFY_NONE@z:OpenSSL::SSL::VERIFY_PEER@z:.OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT@z:%OpenSSL::SSL::VERIFY_CLIENT_ONCE@z:OpenSSL::SSL::OP_ALL@z:'OpenSSL::SSL::OP_CLEANSE_PLAINTEXT@z:+OpenSSL::SSL::OP_LEGACY_SERVER_CONNECT@z:!OpenSSL::SSL::OP_ENABLE_KTLS@{:$OpenSSL::SSL::OP_TLSEXT_PADDING@{:,OpenSSL::SSL::OP_SAFARI_ECDHE_ECDSA_BUG@{:+OpenSSL::SSL::OP_IGNORE_UNEXPECTED_EOF@"{:0OpenSSL::SSL::OP_ALLOW_CLIENT_RENEGOTIATION@,{:-OpenSSL::SSL::OP_DISABLE_TLSEXT_CA_NAMES@6{:&OpenSSL::SSL::OP_ALLOW_NO_DHE_KEX@@{:1OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS@J{:OpenSSL::SSL::OP_NO_TICKET@T{:@۱:Pathname#hash@:Pathname#to_s@:Pathname#to_path@!:Pathname#inspect@H:Pathname#sub@V:Pathname#sub_ext@e:Pathname#realpath@u:Pathname#realdirpath@:Pathname#each_line@:Pathname#read@:Pathname#binread@':Pathname#readlines@E:Pathname#write@:Pathname#binwrite@:Pathname#sysopen@:Pathname#atime@:Pathname#birthtime@:Pathname#ctime@4:Pathname#mtime@J:Pathname#chmod@`:Pathname#lchmod@z:Pathname#chown@:Pathname#lchown@:Pathname#fnmatch@д:Pathname#fnmatch?@:Pathname#ftype@1:Pathname#make_link@G:Pathname#open@a:Pathname#readlink@:Pathname#rename@ε:Pathname#stat@޵:Pathname#lstat@:Pathname#make_symlink@:Pathname#truncate@:Pathname#utime@$:Pathname#basename@6:Pathname#dirname@E:Pathname#extname@S:Pathname#expand_path@a:Pathname#split@p:Pathname#blockdev?@~:Pathname#chardev?@:Pathname#executable?@:Pathname#executable_real?@:Pathname#exist?@¶:Pathname#grpowned?@Ӷ:Pathname#directory?@:Pathname#file?@:Pathname#pipe?@:Pathname#socket?@:Pathname#owned?@(:Pathname#readable?@9:Pathname#world_readable?@J:Pathname#readable_real?@[:Pathname#setuid?@l:Pathname#setgid?@}:Pathname#size@:Pathname#size?@:Pathname#sticky?@:Pathname#symlink?@:Pathname#writable?@Ϸ:Pathname#world_writable?@:Pathname#writable_real?@:Pathname#zero?@:Pathname#empty?@:Pathname.glob@$:Pathname.getwd@3:Pathname.pwd@A:Pathname#glob@N:Pathname#entries@]:Pathname#mkdir@k:Pathname#rmdir@z:Pathname#opendir@:Pathname#each_entry@:Pathname#unlink@:Pathname#delete@:Kernel#Pathname@S;+ @θ:Coverage#setup@и:Coverage.setup@":Coverage#start@m:Coverage.start@:Coverage#resume@ :Coverage.resume@#:Coverage#suspend@8:Coverage.suspend@R:Coverage#result@g:Coverage.result@:Coverage#peek_result@:Coverage.peek_result@:Coverage#state@Һ:Coverage.state@:Coverage#running?@:Coverage.running?@;> @5:&BasicSocket.do_not_reverse_lookup@7:'BasicSocket.do_not_reverse_lookup=@S:BasicSocket.for_fd@m:BasicSocket#close_read@:BasicSocket#close_write@:BasicSocket#shutdown@:BasicSocket#setsockopt@ۻ:BasicSocket#getsockopt@:BasicSocket#getsockname@ :BasicSocket#getpeername@6:BasicSocket#getpeereid@L:BasicSocket#local_address@g:BasicSocket#remote_address@}:BasicSocket#send@:BasicSocket#recv@:&BasicSocket#do_not_reverse_lookup@Ǽ:'BasicSocket#do_not_reverse_lookup=@: BasicSocket#__recv_nonblock@: BasicSocket#__read_nonblock@:!BasicSocket#__write_nonblock@:BasicSocket#__sendmsg@$:#BasicSocket#__sendmsg_nonblock@-:BasicSocket#__recvmsg@6:#BasicSocket#__recvmsg_nonblock@?;B @[:UNIXServer#initialize@]:UNIXServer#accept@x:!UNIXServer#__accept_nonblock@:UNIXServer#sysaccept@:UNIXServer#listen@;C @н:UNIXSocket#initialize@ҽ:UNIXSocket#path@:UNIXSocket#addr@:UNIXSocket#peeraddr@:UNIXSocket#recvfrom@9:UNIXSocket#send_io@W:UNIXSocket#recv_io@v:UNIXSocket.socketpair@:UNIXSocket.pair@;K @;r @:Addrinfo#initialize@:Addrinfo#inspect@X:Addrinfo#inspect_sockaddr@s:Addrinfo.getaddrinfo@:Addrinfo.ip@:Addrinfo.tcp@ :Addrinfo.udp@>:Addrinfo.unix@\:Addrinfo#afamily@u:Addrinfo#pfamily@:Addrinfo#socktype@:Addrinfo#protocol@:Addrinfo#canonname@:Addrinfo#ipv4?@:Addrinfo#ipv6?@:Addrinfo#unix?@3:Addrinfo#ip?@N:Addrinfo#ip_unpack@i:Addrinfo#ip_address@:Addrinfo#ip_port@:Addrinfo#ipv4_private?@:Addrinfo#ipv4_loopback?@:Addrinfo#ipv4_multicast?@:Addrinfo#ipv6_unspecified?@:Addrinfo#ipv6_loopback?@:Addrinfo#ipv6_multicast?@ :Addrinfo#ipv6_linklocal?@:Addrinfo#ipv6_sitelocal?@,: Addrinfo#ipv6_unique_local?@=:Addrinfo#ipv6_v4mapped?@N:Addrinfo#ipv6_v4compat?@_: Addrinfo#ipv6_mc_nodelocal?@p: Addrinfo#ipv6_mc_linklocal?@: Addrinfo#ipv6_mc_sitelocal?@:Addrinfo#ipv6_mc_orglocal?@:Addrinfo#ipv6_mc_global?@:Addrinfo#ipv6_to_ipv4@:Addrinfo#unix_path@:Addrinfo#to_sockaddr@:Addrinfo#to_s@:Addrinfo#getnameinfo@8:Addrinfo#marshal_dump@c:Addrinfo#marshal_load@q;v @:Socket#initialize@:Socket#connect@:Socket#__connect_nonblock@:Socket#bind@:Socket#listen@:Socket#accept@:Socket#__accept_nonblock@8:Socket#sysaccept@H:Socket#recvfrom@c:Socket#__recvfrom_nonblock@:Socket.socketpair@:Socket.pair@:Socket.gethostname@:Socket.gethostbyname@:Socket.gethostbyaddr@<:Socket.getservbyname@U:Socket.getservbyport@z:Socket.getaddrinfo@:Socket.getnameinfo@:Socket.sockaddr_in@:Socket.pack_sockaddr_in@:Socket.unpack_sockaddr_in@$:Socket.sockaddr_un@C:Socket.pack_sockaddr_un@g:Socket.unpack_sockaddr_un@:Socket.ip_address_list@;x @:IPSocket#inspect@:IPSocket#addr@:IPSocket#peeraddr@:IPSocket#recvfrom@":IPSocket.getaddress@Q;y @~:TCPSocket.gethostbyname@:TCPSocket#initialize@;z @:TCPServer#accept@: TCPServer#__accept_nonblock@:TCPServer#sysaccept@:TCPServer#initialize@:TCPServer#listen@/;{ @`:SOCKSSocket#initialize@b:SOCKSSocket#close@;| @:UDPSocket#initialize@:UDPSocket#connect@:UDPSocket#bind@:UDPSocket#send@:"UDPSocket#__recvfrom_nonblock@8:Socket::AncillaryData@:%Socket::AncillaryData#initialize@:"Socket::AncillaryData#inspect@:!Socket::AncillaryData#family@: Socket::AncillaryData#level@:Socket::AncillaryData#type@9:Socket::AncillaryData#data@T:#Socket::AncillaryData#cmsg_is?@o; @:Socket::AncillaryData#int@; @:&Socket::AncillaryData#unix_rights@:$Socket::AncillaryData#timestamp@ ; @':%Socket::AncillaryData#ip_pktinfo@P; @k:'Socket::AncillaryData#ipv6_pktinfo@:,Socket::AncillaryData#ipv6_pktinfo_addr@:/Socket::AncillaryData#ipv6_pktinfo_ifindex@:Socket::Ifaddr@:Socket::Ifaddr#inspect@:Socket::Ifaddr#name@:Socket::Ifaddr#ifindex@:Socket::Ifaddr#flags@6:Socket::Ifaddr#addr@Q:Socket::Ifaddr#netmask@g:Socket::Ifaddr#broadaddr@}:Socket::Ifaddr#dstaddr@:Socket::Ifaddr#vhid@:Socket.getifaddrs@:Socket::Constants@:Socket::SOCK_STREAM@:#Socket::Constants::SOCK_STREAM@:Socket::SOCK_DGRAM@:"Socket::Constants::SOCK_DGRAM@:Socket::SOCK_RAW@: Socket::Constants::SOCK_RAW@ :Socket::SOCK_RDM@: Socket::Constants::SOCK_RDM@:Socket::SOCK_SEQPACKET@:&Socket::Constants::SOCK_SEQPACKET@$:Socket::SOCK_PACKET@:#Socket::Constants::SOCK_PACKET@0:Socket::SOCK_NONBLOCK@:%Socket::Constants::SOCK_NONBLOCK@<:Socket::SOCK_CLOEXEC@:$Socket::Constants::SOCK_CLOEXEC@H:Socket::AF_UNSPEC@:!Socket::Constants::AF_UNSPEC@T:Socket::PF_UNSPEC@ :!Socket::Constants::PF_UNSPEC@`:Socket::AF_INET@:Socket::Constants::AF_INET@l:Socket::PF_INET@$:Socket::Constants::PF_INET@x:Socket::AF_INET6@0: Socket::Constants::AF_INET6@:Socket::PF_INET6@<: Socket::Constants::PF_INET6@:Socket::AF_UNIX@H:Socket::Constants::AF_UNIX@:Socket::PF_UNIX@T:Socket::Constants::PF_UNIX@:Socket::AF_AX25@`:Socket::Constants::AF_AX25@:Socket::PF_AX25@l:Socket::Constants::PF_AX25@:Socket::AF_IPX@x:Socket::Constants::AF_IPX@:Socket::PF_IPX@:Socket::Constants::PF_IPX@:Socket::AF_APPLETALK@:$Socket::Constants::AF_APPLETALK@:Socket::PF_APPLETALK@:$Socket::Constants::PF_APPLETALK@:Socket::AF_LOCAL@: Socket::Constants::AF_LOCAL@:Socket::PF_LOCAL@: Socket::Constants::PF_LOCAL@:Socket::AF_IMPLINK@:"Socket::Constants::AF_IMPLINK@:Socket::PF_IMPLINK@:"Socket::Constants::PF_IMPLINK@ :Socket::AF_PUP@:Socket::Constants::AF_PUP@,:Socket::PF_PUP@:Socket::Constants::PF_PUP@8:Socket::AF_CHAOS@: Socket::Constants::AF_CHAOS@D:Socket::PF_CHAOS@: Socket::Constants::PF_CHAOS@P:Socket::AF_NS@:Socket::Constants::AF_NS@\:Socket::PF_NS@:Socket::Constants::PF_NS@h:Socket::AF_ISO@ :Socket::Constants::AF_ISO@t:Socket::PF_ISO@,:Socket::Constants::PF_ISO@:Socket::AF_OSI@8:Socket::Constants::AF_OSI@:Socket::PF_OSI@D:Socket::Constants::PF_OSI@:Socket::AF_ECMA@P:Socket::Constants::AF_ECMA@:Socket::PF_ECMA@\:Socket::Constants::PF_ECMA@:Socket::AF_DATAKIT@h:"Socket::Constants::AF_DATAKIT@:Socket::PF_DATAKIT@t:"Socket::Constants::PF_DATAKIT@:Socket::AF_CCITT@: Socket::Constants::AF_CCITT@:Socket::PF_CCITT@: Socket::Constants::PF_CCITT@:Socket::AF_SNA@:Socket::Constants::AF_SNA@:Socket::PF_SNA@:Socket::Constants::PF_SNA@:Socket::AF_DEC@:Socket::Constants::AF_DEC@:Socket::PF_DEC@:Socket::Constants::PF_DEC@:Socket::AF_DECnet@:!Socket::Constants::AF_DECnet@:Socket::PF_DECnet@:!Socket::Constants::PF_DECnet@(:Socket::AF_DLI@:Socket::Constants::AF_DLI@4:Socket::PF_DLI@:Socket::Constants::PF_DLI@@:Socket::AF_LAT@:Socket::Constants::AF_LAT@L:Socket::PF_LAT@:Socket::Constants::PF_LAT@X:Socket::AF_HYLINK@:!Socket::Constants::AF_HYLINK@d:Socket::PF_HYLINK@:!Socket::Constants::PF_HYLINK@p:Socket::AF_ROUTE@(: Socket::Constants::AF_ROUTE@|:Socket::PF_ROUTE@4: Socket::Constants::PF_ROUTE@:Socket::AF_LINK@@:Socket::Constants::AF_LINK@:Socket::PF_LINK@L:Socket::Constants::PF_LINK@:Socket::AF_COIP@X:Socket::Constants::AF_COIP@:Socket::PF_COIP@d:Socket::Constants::PF_COIP@:Socket::AF_CNT@p:Socket::Constants::AF_CNT@:Socket::PF_CNT@|:Socket::Constants::PF_CNT@:Socket::AF_SIP@:Socket::Constants::AF_SIP@:Socket::PF_SIP@:Socket::Constants::PF_SIP@:Socket::AF_NDRV@:Socket::Constants::AF_NDRV@:Socket::PF_NDRV@:Socket::Constants::PF_NDRV@:Socket::AF_ISDN@:Socket::Constants::AF_ISDN@ :Socket::PF_ISDN@:Socket::Constants::PF_ISDN@:Socket::AF_NATM@:Socket::Constants::AF_NATM@$:Socket::PF_NATM@:Socket::Constants::PF_NATM@0:Socket::AF_SYSTEM@:!Socket::Constants::AF_SYSTEM@<:Socket::PF_SYSTEM@:!Socket::Constants::PF_SYSTEM@F:Socket::AF_NETBIOS@:"Socket::Constants::AF_NETBIOS@P:Socket::PF_NETBIOS@:"Socket::Constants::PF_NETBIOS@\:Socket::AF_PPP@:Socket::Constants::AF_PPP@h:Socket::PF_PPP@ :Socket::Constants::PF_PPP@t:Socket::AF_ATM@,:Socket::Constants::AF_ATM@:Socket::PF_ATM@8:Socket::Constants::PF_ATM@:Socket::AF_NETGRAPH@D:#Socket::Constants::AF_NETGRAPH@:Socket::PF_NETGRAPH@P:#Socket::Constants::PF_NETGRAPH@:Socket::AF_MAX@\:Socket::Constants::AF_MAX@:Socket::PF_MAX@h:Socket::Constants::PF_MAX@:Socket::AF_PACKET@t:!Socket::Constants::AF_PACKET@:Socket::PF_PACKET@:!Socket::Constants::PF_PACKET@:Socket::AF_E164@:Socket::Constants::AF_E164@:Socket::PF_XTP@:Socket::Constants::PF_XTP@:Socket::PF_RTIP@:Socket::Constants::PF_RTIP@:Socket::PF_PIP@:Socket::Constants::PF_PIP@:Socket::AF_KEY@:Socket::Constants::AF_KEY@ :Socket::PF_KEY@:Socket::Constants::PF_KEY@:Socket::AF_NETLINK@:"Socket::Constants::AF_NETLINK@$:Socket::PF_NETLINK@:"Socket::Constants::PF_NETLINK@0:Socket::AF_RDS@:Socket::Constants::AF_RDS@<:Socket::PF_RDS@:Socket::Constants::PF_RDS@H:Socket::AF_PPPOX@: Socket::Constants::AF_PPPOX@T:Socket::PF_PPPOX@ : Socket::Constants::PF_PPPOX@`:Socket::AF_LLC@:Socket::Constants::AF_LLC@l:Socket::PF_LLC@$:Socket::Constants::PF_LLC@x:Socket::AF_IB@0:Socket::Constants::AF_IB@:Socket::PF_IB@<:Socket::Constants::PF_IB@:Socket::AF_MPLS@H:Socket::Constants::AF_MPLS@:Socket::PF_MPLS@T:Socket::Constants::PF_MPLS@:Socket::AF_CAN@`:Socket::Constants::AF_CAN@:Socket::PF_CAN@l:Socket::Constants::PF_CAN@:Socket::AF_TIPC@x:Socket::Constants::AF_TIPC@:Socket::PF_TIPC@:Socket::Constants::PF_TIPC@:Socket::AF_BLUETOOTH@:$Socket::Constants::AF_BLUETOOTH@:Socket::PF_BLUETOOTH@:$Socket::Constants::PF_BLUETOOTH@:Socket::AF_ALG@:Socket::Constants::AF_ALG@:Socket::PF_ALG@:Socket::Constants::PF_ALG@:Socket::AF_VSOCK@: Socket::Constants::AF_VSOCK@:Socket::PF_VSOCK@: Socket::Constants::PF_VSOCK@ :Socket::AF_KCM@:Socket::Constants::AF_KCM@,:Socket::PF_KCM@:Socket::Constants::PF_KCM@8:Socket::AF_XDP@:Socket::Constants::AF_XDP@D:Socket::PF_XDP@:Socket::Constants::PF_XDP@P:Socket::MSG_OOB@:Socket::Constants::MSG_OOB@\:Socket::MSG_PEEK@: Socket::Constants::MSG_PEEK@h:Socket::MSG_DONTROUTE@ :%Socket::Constants::MSG_DONTROUTE@t:Socket::MSG_EOR@,:Socket::Constants::MSG_EOR@:Socket::MSG_TRUNC@8:!Socket::Constants::MSG_TRUNC@:Socket::MSG_CTRUNC@D:"Socket::Constants::MSG_CTRUNC@:Socket::MSG_WAITALL@P:#Socket::Constants::MSG_WAITALL@:Socket::MSG_DONTWAIT@\:$Socket::Constants::MSG_DONTWAIT@:Socket::MSG_EOF@h:Socket::Constants::MSG_EOF@:Socket::MSG_FLUSH@t:!Socket::Constants::MSG_FLUSH@:Socket::MSG_HOLD@: Socket::Constants::MSG_HOLD@:Socket::MSG_SEND@: Socket::Constants::MSG_SEND@:Socket::MSG_HAVEMORE@:$Socket::Constants::MSG_HAVEMORE@:Socket::MSG_RCVMORE@:#Socket::Constants::MSG_RCVMORE@:Socket::MSG_COMPAT@:"Socket::Constants::MSG_COMPAT@:Socket::MSG_PROXY@:!Socket::Constants::MSG_PROXY@:Socket::MSG_FIN@:Socket::Constants::MSG_FIN@:Socket::MSG_SYN@:Socket::Constants::MSG_SYN@&:Socket::MSG_CONFIRM@:#Socket::Constants::MSG_CONFIRM@0:Socket::MSG_RST@:Socket::Constants::MSG_RST@<:Socket::MSG_ERRQUEUE@:$Socket::Constants::MSG_ERRQUEUE@F:Socket::MSG_NOSIGNAL@:$Socket::Constants::MSG_NOSIGNAL@R:Socket::MSG_MORE@ : Socket::Constants::MSG_MORE@^:Socket::MSG_FASTOPEN@:$Socket::Constants::MSG_FASTOPEN@j:Socket::SOL_SOCKET@":"Socket::Constants::SOL_SOCKET@v:Socket::SOL_IP@.:Socket::Constants::SOL_IP@:Socket::SOL_IPX@::Socket::Constants::SOL_IPX@:Socket::SOL_AX25@F: Socket::Constants::SOL_AX25@:Socket::SOL_ATALK@R:!Socket::Constants::SOL_ATALK@:Socket::SOL_TCP@^:Socket::Constants::SOL_TCP@:Socket::SOL_UDP@j:Socket::Constants::SOL_UDP@:Socket::IPPROTO_IP@v:"Socket::Constants::IPPROTO_IP@:Socket::IPPROTO_ICMP@:$Socket::Constants::IPPROTO_ICMP@:Socket::IPPROTO_IGMP@:$Socket::Constants::IPPROTO_IGMP@:Socket::IPPROTO_GGP@:#Socket::Constants::IPPROTO_GGP@:Socket::IPPROTO_TCP@:#Socket::Constants::IPPROTO_TCP@:Socket::IPPROTO_EGP@:#Socket::Constants::IPPROTO_EGP@:Socket::IPPROTO_PUP@:#Socket::Constants::IPPROTO_PUP@:Socket::IPPROTO_UDP@:#Socket::Constants::IPPROTO_UDP@:Socket::IPPROTO_IDP@:#Socket::Constants::IPPROTO_IDP@*:Socket::IPPROTO_HELLO@:%Socket::Constants::IPPROTO_HELLO@6:Socket::IPPROTO_ND@:"Socket::Constants::IPPROTO_ND@B:Socket::IPPROTO_TP@:"Socket::Constants::IPPROTO_TP@N:Socket::IPPROTO_XTP@:#Socket::Constants::IPPROTO_XTP@Z:Socket::IPPROTO_EON@:#Socket::Constants::IPPROTO_EON@f:Socket::IPPROTO_BIP@:#Socket::Constants::IPPROTO_BIP@r:Socket::IPPROTO_AH@(:"Socket::Constants::IPPROTO_AH@|:Socket::IPPROTO_DSTOPTS@4:'Socket::Constants::IPPROTO_DSTOPTS@:Socket::IPPROTO_ESP@@:#Socket::Constants::IPPROTO_ESP@:Socket::IPPROTO_FRAGMENT@L:(Socket::Constants::IPPROTO_FRAGMENT@:Socket::IPPROTO_HOPOPTS@X:'Socket::Constants::IPPROTO_HOPOPTS@:Socket::IPPROTO_ICMPV6@d:&Socket::Constants::IPPROTO_ICMPV6@:Socket::IPPROTO_IPV6@p:$Socket::Constants::IPPROTO_IPV6@:Socket::IPPROTO_NONE@|:$Socket::Constants::IPPROTO_NONE@:Socket::IPPROTO_ROUTING@:'Socket::Constants::IPPROTO_ROUTING@:Socket::IPPROTO_RAW@:#Socket::Constants::IPPROTO_RAW@:Socket::IPPROTO_MAX@:#Socket::Constants::IPPROTO_MAX@:Socket::IPPORT_RESERVED@:'Socket::Constants::IPPORT_RESERVED@: Socket::IPPORT_USERRESERVED@:+Socket::Constants::IPPORT_USERRESERVED@ :Socket::INADDR_ANY@:"Socket::Constants::INADDR_ANY@:Socket::INADDR_BROADCAST@:(Socket::Constants::INADDR_BROADCAST@$:Socket::INADDR_LOOPBACK@:'Socket::Constants::INADDR_LOOPBACK@0: Socket::INADDR_UNSPEC_GROUP@:+Socket::Constants::INADDR_UNSPEC_GROUP@<:"Socket::INADDR_ALLHOSTS_GROUP@:-Socket::Constants::INADDR_ALLHOSTS_GROUP@H:#Socket::INADDR_MAX_LOCAL_GROUP@:.Socket::Constants::INADDR_MAX_LOCAL_GROUP@T:Socket::INADDR_NONE@ :#Socket::Constants::INADDR_NONE@`:Socket::IP_OPTIONS@:"Socket::Constants::IP_OPTIONS@l:Socket::IP_HDRINCL@$:"Socket::Constants::IP_HDRINCL@x:Socket::IP_TOS@0:Socket::Constants::IP_TOS@:Socket::IP_TTL@<:Socket::Constants::IP_TTL@:Socket::IP_RECVOPTS@H:#Socket::Constants::IP_RECVOPTS@:Socket::IP_RECVRETOPTS@T:&Socket::Constants::IP_RECVRETOPTS@:Socket::IP_RECVDSTADDR@`:&Socket::Constants::IP_RECVDSTADDR@:Socket::IP_RETOPTS@l:"Socket::Constants::IP_RETOPTS@:Socket::IP_MINTTL@x:!Socket::Constants::IP_MINTTL@:Socket::IP_DONTFRAG@:#Socket::Constants::IP_DONTFRAG@:Socket::IP_SENDSRCADDR@:&Socket::Constants::IP_SENDSRCADDR@:Socket::IP_ONESBCAST@:$Socket::Constants::IP_ONESBCAST@:Socket::IP_RECVTTL@:"Socket::Constants::IP_RECVTTL@:Socket::IP_RECVIF@:!Socket::Constants::IP_RECVIF@:Socket::IP_RECVSLLA@:#Socket::Constants::IP_RECVSLLA@:Socket::IP_PORTRANGE@:$Socket::Constants::IP_PORTRANGE@ :Socket::IP_MULTICAST_IF@:'Socket::Constants::IP_MULTICAST_IF@,:Socket::IP_MULTICAST_TTL@:(Socket::Constants::IP_MULTICAST_TTL@8:Socket::IP_MULTICAST_LOOP@:)Socket::Constants::IP_MULTICAST_LOOP@D:Socket::IP_ADD_MEMBERSHIP@:)Socket::Constants::IP_ADD_MEMBERSHIP@P:Socket::IP_DROP_MEMBERSHIP@:*Socket::Constants::IP_DROP_MEMBERSHIP@\:%Socket::IP_DEFAULT_MULTICAST_TTL@:0Socket::Constants::IP_DEFAULT_MULTICAST_TTL@h:&Socket::IP_DEFAULT_MULTICAST_LOOP@ :1Socket::Constants::IP_DEFAULT_MULTICAST_LOOP@t:Socket::IP_MAX_MEMBERSHIPS@,:*Socket::Constants::IP_MAX_MEMBERSHIPS@:Socket::IP_ROUTER_ALERT@8:'Socket::Constants::IP_ROUTER_ALERT@:Socket::IP_PKTINFO@D:"Socket::Constants::IP_PKTINFO@:Socket::IP_PKTOPTIONS@P:%Socket::Constants::IP_PKTOPTIONS@:Socket::IP_MTU_DISCOVER@\:'Socket::Constants::IP_MTU_DISCOVER@:Socket::IP_RECVERR@h:"Socket::Constants::IP_RECVERR@:Socket::IP_RECVTOS@t:"Socket::Constants::IP_RECVTOS@:Socket::IP_MTU@:Socket::Constants::IP_MTU@:Socket::IP_FREEBIND@:#Socket::Constants::IP_FREEBIND@:Socket::IP_IPSEC_POLICY@:'Socket::Constants::IP_IPSEC_POLICY@:Socket::IP_XFRM_POLICY@:&Socket::Constants::IP_XFRM_POLICY@:Socket::IP_PASSSEC@:"Socket::Constants::IP_PASSSEC@:Socket::IP_TRANSPARENT@:&Socket::Constants::IP_TRANSPARENT@:Socket::IP_PMTUDISC_DONT@:(Socket::Constants::IP_PMTUDISC_DONT@:Socket::IP_PMTUDISC_WANT@:(Socket::Constants::IP_PMTUDISC_WANT@&:Socket::IP_PMTUDISC_DO@:&Socket::Constants::IP_PMTUDISC_DO@2:Socket::IP_UNBLOCK_SOURCE@:)Socket::Constants::IP_UNBLOCK_SOURCE@>:Socket::IP_BLOCK_SOURCE@:'Socket::Constants::IP_BLOCK_SOURCE@J:%Socket::IP_ADD_SOURCE_MEMBERSHIP@:0Socket::Constants::IP_ADD_SOURCE_MEMBERSHIP@V:&Socket::IP_DROP_SOURCE_MEMBERSHIP@:1Socket::Constants::IP_DROP_SOURCE_MEMBERSHIP@b:Socket::IP_MSFILTER@:#Socket::Constants::IP_MSFILTER@n:Socket::MCAST_JOIN_GROUP@&:(Socket::Constants::MCAST_JOIN_GROUP@z:Socket::MCAST_BLOCK_SOURCE@2:*Socket::Constants::MCAST_BLOCK_SOURCE@:!Socket::MCAST_UNBLOCK_SOURCE@>:,Socket::Constants::MCAST_UNBLOCK_SOURCE@:Socket::MCAST_LEAVE_GROUP@J:)Socket::Constants::MCAST_LEAVE_GROUP@:$Socket::MCAST_JOIN_SOURCE_GROUP@V:/Socket::Constants::MCAST_JOIN_SOURCE_GROUP@:%Socket::MCAST_LEAVE_SOURCE_GROUP@b:0Socket::Constants::MCAST_LEAVE_SOURCE_GROUP@:Socket::MCAST_MSFILTER@n:&Socket::Constants::MCAST_MSFILTER@:Socket::MCAST_EXCLUDE@z:%Socket::Constants::MCAST_EXCLUDE@:Socket::MCAST_INCLUDE@:%Socket::Constants::MCAST_INCLUDE@:Socket::SO_DEBUG@: Socket::Constants::SO_DEBUG@:Socket::SO_REUSEADDR@:$Socket::Constants::SO_REUSEADDR@:Socket::SO_REUSEPORT@:$Socket::Constants::SO_REUSEPORT@:Socket::SO_TYPE@:Socket::Constants::SO_TYPE@ :Socket::SO_ERROR@: Socket::Constants::SO_ERROR@:Socket::SO_DONTROUTE@:$Socket::Constants::SO_DONTROUTE@":Socket::SO_BROADCAST@:$Socket::Constants::SO_BROADCAST@.:Socket::SO_SNDBUF@:!Socket::Constants::SO_SNDBUF@::Socket::SO_RCVBUF@:!Socket::Constants::SO_RCVBUF@F:Socket::SO_SNDBUFFORCE@:&Socket::Constants::SO_SNDBUFFORCE@R:Socket::SO_RCVBUFFORCE@ :&Socket::Constants::SO_RCVBUFFORCE@^:Socket::SO_KEEPALIVE@:$Socket::Constants::SO_KEEPALIVE@j:Socket::SO_OOBINLINE@":$Socket::Constants::SO_OOBINLINE@v:Socket::SO_NO_CHECK@.:#Socket::Constants::SO_NO_CHECK@:Socket::SO_PRIORITY@::#Socket::Constants::SO_PRIORITY@:Socket::SO_LINGER@F:!Socket::Constants::SO_LINGER@:Socket::SO_PASSCRED@R:#Socket::Constants::SO_PASSCRED@:Socket::SO_PEERCRED@^:#Socket::Constants::SO_PEERCRED@:Socket::SO_RCVLOWAT@j:#Socket::Constants::SO_RCVLOWAT@:Socket::SO_SNDLOWAT@v:#Socket::Constants::SO_SNDLOWAT@:Socket::SO_RCVTIMEO@:#Socket::Constants::SO_RCVTIMEO@:Socket::SO_SNDTIMEO@:#Socket::Constants::SO_SNDTIMEO@:Socket::SO_ACCEPTCONN@:%Socket::Constants::SO_ACCEPTCONN@:Socket::SO_USELOOPBACK@:&Socket::Constants::SO_USELOOPBACK@:Socket::SO_ACCEPTFILTER@:'Socket::Constants::SO_ACCEPTFILTER@:Socket::SO_DONTTRUNC@:$Socket::Constants::SO_DONTTRUNC@:Socket::SO_WANTMORE@:#Socket::Constants::SO_WANTMORE@:Socket::SO_WANTOOBFLAG@:&Socket::Constants::SO_WANTOOBFLAG@*:Socket::SO_NREAD@: Socket::Constants::SO_NREAD@6:Socket::SO_NKE@:Socket::Constants::SO_NKE@B:Socket::SO_NOSIGPIPE@:$Socket::Constants::SO_NOSIGPIPE@N:'Socket::SO_SECURITY_AUTHENTICATION@:2Socket::Constants::SO_SECURITY_AUTHENTICATION@Z:-Socket::SO_SECURITY_ENCRYPTION_TRANSPORT@:8Socket::Constants::SO_SECURITY_ENCRYPTION_TRANSPORT@d:+Socket::SO_SECURITY_ENCRYPTION_NETWORK@:6Socket::Constants::SO_SECURITY_ENCRYPTION_NETWORK@n:Socket::SO_BINDTODEVICE@$:'Socket::Constants::SO_BINDTODEVICE@x:Socket::SO_ATTACH_FILTER@0:(Socket::Constants::SO_ATTACH_FILTER@:Socket::SO_DETACH_FILTER@<:(Socket::Constants::SO_DETACH_FILTER@:Socket::SO_GET_FILTER@H:%Socket::Constants::SO_GET_FILTER@:Socket::SO_PEERNAME@T:#Socket::Constants::SO_PEERNAME@:Socket::SO_TIMESTAMP@`:$Socket::Constants::SO_TIMESTAMP@:Socket::SO_TIMESTAMPNS@l:&Socket::Constants::SO_TIMESTAMPNS@:Socket::SO_BINTIME@x:"Socket::Constants::SO_BINTIME@:Socket::SO_RECVUCRED@:$Socket::Constants::SO_RECVUCRED@:Socket::SO_MAC_EXEMPT@:%Socket::Constants::SO_MAC_EXEMPT@:Socket::SO_ALLZONES@:#Socket::Constants::SO_ALLZONES@:Socket::SO_PEERSEC@:"Socket::Constants::SO_PEERSEC@:Socket::SO_PASSSEC@:"Socket::Constants::SO_PASSSEC@:Socket::SO_MARK@:Socket::Constants::SO_MARK@:Socket::SO_TIMESTAMPING@:'Socket::Constants::SO_TIMESTAMPING@ :Socket::SO_PROTOCOL@:#Socket::Constants::SO_PROTOCOL@,:Socket::SO_DOMAIN@:!Socket::Constants::SO_DOMAIN@8:Socket::SO_RXQ_OVFL@:#Socket::Constants::SO_RXQ_OVFL@D:Socket::SO_WIFI_STATUS@:&Socket::Constants::SO_WIFI_STATUS@P:Socket::SO_PEEK_OFF@:#Socket::Constants::SO_PEEK_OFF@\:Socket::SO_NOFCS@: Socket::Constants::SO_NOFCS@h:Socket::SO_LOCK_FILTER@ :&Socket::Constants::SO_LOCK_FILTER@t: Socket::SO_SELECT_ERR_QUEUE@,:+Socket::Constants::SO_SELECT_ERR_QUEUE@:Socket::SO_BUSY_POLL@8:$Socket::Constants::SO_BUSY_POLL@:Socket::SO_MAX_PACING_RATE@D:*Socket::Constants::SO_MAX_PACING_RATE@:Socket::SO_BPF_EXTENSIONS@P:)Socket::Constants::SO_BPF_EXTENSIONS@:Socket::SOPRI_INTERACTIVE@\:)Socket::Constants::SOPRI_INTERACTIVE@:Socket::SOPRI_NORMAL@h:$Socket::Constants::SOPRI_NORMAL@:Socket::SOPRI_BACKGROUND@t:(Socket::Constants::SOPRI_BACKGROUND@:Socket::IPX_TYPE@: Socket::Constants::IPX_TYPE@:Socket::TCP_NODELAY@:#Socket::Constants::TCP_NODELAY@:Socket::TCP_MAXSEG@:"Socket::Constants::TCP_MAXSEG@:Socket::TCP_CORK@: Socket::Constants::TCP_CORK@:Socket::TCP_DEFER_ACCEPT@:(Socket::Constants::TCP_DEFER_ACCEPT@:Socket::TCP_INFO@: Socket::Constants::TCP_INFO@:Socket::TCP_KEEPCNT@:#Socket::Constants::TCP_KEEPCNT@:Socket::TCP_KEEPIDLE@:$Socket::Constants::TCP_KEEPIDLE@&:Socket::TCP_KEEPINTVL@:%Socket::Constants::TCP_KEEPINTVL@2:Socket::TCP_LINGER2@:#Socket::Constants::TCP_LINGER2@>:Socket::TCP_MD5SIG@:"Socket::Constants::TCP_MD5SIG@J:Socket::TCP_NOOPT@:!Socket::Constants::TCP_NOOPT@V:Socket::TCP_NOPUSH@:"Socket::Constants::TCP_NOPUSH@b:Socket::TCP_QUICKACK@:$Socket::Constants::TCP_QUICKACK@n:Socket::TCP_SYNCNT@&:"Socket::Constants::TCP_SYNCNT@z:Socket::TCP_WINDOW_CLAMP@2:(Socket::Constants::TCP_WINDOW_CLAMP@:Socket::TCP_FASTOPEN@>:$Socket::Constants::TCP_FASTOPEN@:Socket::TCP_CONGESTION@J:&Socket::Constants::TCP_CONGESTION@:$Socket::TCP_COOKIE_TRANSACTIONS@V:/Socket::Constants::TCP_COOKIE_TRANSACTIONS@:Socket::TCP_QUEUE_SEQ@b:%Socket::Constants::TCP_QUEUE_SEQ@:Socket::TCP_REPAIR@n:"Socket::Constants::TCP_REPAIR@:Socket::TCP_REPAIR_OPTIONS@z:*Socket::Constants::TCP_REPAIR_OPTIONS@:Socket::TCP_REPAIR_QUEUE@:(Socket::Constants::TCP_REPAIR_QUEUE@:Socket::TCP_THIN_DUPACK@:'Socket::Constants::TCP_THIN_DUPACK@:%Socket::TCP_THIN_LINEAR_TIMEOUTS@:0Socket::Constants::TCP_THIN_LINEAR_TIMEOUTS@:Socket::TCP_TIMESTAMP@:%Socket::Constants::TCP_TIMESTAMP@:Socket::TCP_USER_TIMEOUT@:(Socket::Constants::TCP_USER_TIMEOUT@ :Socket::UDP_CORK@: Socket::Constants::UDP_CORK@:Socket::EAI_ADDRFAMILY@:&Socket::Constants::EAI_ADDRFAMILY@":Socket::EAI_AGAIN@:!Socket::Constants::EAI_AGAIN@.:Socket::EAI_BADFLAGS@:$Socket::Constants::EAI_BADFLAGS@::Socket::EAI_FAIL@: Socket::Constants::EAI_FAIL@F:Socket::EAI_FAMILY@:"Socket::Constants::EAI_FAMILY@R:Socket::EAI_MEMORY@ :"Socket::Constants::EAI_MEMORY@^:Socket::EAI_NODATA@:"Socket::Constants::EAI_NODATA@j:Socket::EAI_NONAME@":"Socket::Constants::EAI_NONAME@v:Socket::EAI_OVERFLOW@.:$Socket::Constants::EAI_OVERFLOW@:Socket::EAI_SERVICE@::#Socket::Constants::EAI_SERVICE@:Socket::EAI_SOCKTYPE@F:$Socket::Constants::EAI_SOCKTYPE@:Socket::EAI_SYSTEM@R:"Socket::Constants::EAI_SYSTEM@:Socket::EAI_BADHINTS@^:$Socket::Constants::EAI_BADHINTS@:Socket::EAI_PROTOCOL@j:$Socket::Constants::EAI_PROTOCOL@:Socket::EAI_MAX@v:Socket::Constants::EAI_MAX@:Socket::AI_PASSIVE@:"Socket::Constants::AI_PASSIVE@:Socket::AI_CANONNAME@:$Socket::Constants::AI_CANONNAME@:Socket::AI_NUMERICHOST@:&Socket::Constants::AI_NUMERICHOST@:Socket::AI_NUMERICSERV@:&Socket::Constants::AI_NUMERICSERV@:Socket::AI_MASK@:Socket::Constants::AI_MASK@:Socket::AI_ALL@:Socket::Constants::AI_ALL@:Socket::AI_V4MAPPED_CFG@:'Socket::Constants::AI_V4MAPPED_CFG@:Socket::AI_ADDRCONFIG@:%Socket::Constants::AI_ADDRCONFIG@*:Socket::AI_V4MAPPED@:#Socket::Constants::AI_V4MAPPED@6:Socket::AI_DEFAULT@:"Socket::Constants::AI_DEFAULT@B:Socket::NI_MAXHOST@:"Socket::Constants::NI_MAXHOST@N:Socket::NI_MAXSERV@:"Socket::Constants::NI_MAXSERV@Z:Socket::NI_NOFQDN@:!Socket::Constants::NI_NOFQDN@f:Socket::NI_NUMERICHOST@:&Socket::Constants::NI_NUMERICHOST@r:Socket::NI_NAMEREQD@*:#Socket::Constants::NI_NAMEREQD@~:Socket::NI_NUMERICSERV@6:&Socket::Constants::NI_NUMERICSERV@:Socket::NI_DGRAM@B: Socket::Constants::NI_DGRAM@:Socket::SHUT_RD@N:Socket::Constants::SHUT_RD@:Socket::SHUT_WR@Z:Socket::Constants::SHUT_WR@:Socket::SHUT_RDWR@f:!Socket::Constants::SHUT_RDWR@:Socket::IPV6_JOIN_GROUP@r:'Socket::Constants::IPV6_JOIN_GROUP@:Socket::IPV6_LEAVE_GROUP@~:(Socket::Constants::IPV6_LEAVE_GROUP@: Socket::IPV6_MULTICAST_HOPS@:+Socket::Constants::IPV6_MULTICAST_HOPS@:Socket::IPV6_MULTICAST_IF@:)Socket::Constants::IPV6_MULTICAST_IF@: Socket::IPV6_MULTICAST_LOOP@:+Socket::Constants::IPV6_MULTICAST_LOOP@:Socket::IPV6_UNICAST_HOPS@:)Socket::Constants::IPV6_UNICAST_HOPS@:Socket::IPV6_V6ONLY@:#Socket::Constants::IPV6_V6ONLY@:Socket::IPV6_CHECKSUM@:%Socket::Constants::IPV6_CHECKSUM@:Socket::IPV6_DONTFRAG@:%Socket::Constants::IPV6_DONTFRAG@&:Socket::IPV6_DSTOPTS@:$Socket::Constants::IPV6_DSTOPTS@2:Socket::IPV6_HOPLIMIT@:%Socket::Constants::IPV6_HOPLIMIT@>:Socket::IPV6_HOPOPTS@:$Socket::Constants::IPV6_HOPOPTS@J:Socket::IPV6_NEXTHOP@:$Socket::Constants::IPV6_NEXTHOP@V:Socket::IPV6_PATHMTU@:$Socket::Constants::IPV6_PATHMTU@b:Socket::IPV6_PKTINFO@:$Socket::Constants::IPV6_PKTINFO@n:Socket::IPV6_RECVDSTOPTS@&:(Socket::Constants::IPV6_RECVDSTOPTS@z:Socket::IPV6_RECVHOPLIMIT@2:)Socket::Constants::IPV6_RECVHOPLIMIT@:Socket::IPV6_RECVHOPOPTS@>:(Socket::Constants::IPV6_RECVHOPOPTS@:Socket::IPV6_RECVPKTINFO@J:(Socket::Constants::IPV6_RECVPKTINFO@:Socket::IPV6_RECVRTHDR@V:&Socket::Constants::IPV6_RECVRTHDR@:Socket::IPV6_RECVTCLASS@b:'Socket::Constants::IPV6_RECVTCLASS@:Socket::IPV6_RTHDR@n:"Socket::Constants::IPV6_RTHDR@:Socket::IPV6_RTHDRDSTOPTS@z:)Socket::Constants::IPV6_RTHDRDSTOPTS@:Socket::IPV6_RTHDR_TYPE_0@:)Socket::Constants::IPV6_RTHDR_TYPE_0@:Socket::IPV6_RECVPATHMTU@:(Socket::Constants::IPV6_RECVPATHMTU@:Socket::IPV6_TCLASS@:#Socket::Constants::IPV6_TCLASS@:Socket::IPV6_USE_MIN_MTU@:(Socket::Constants::IPV6_USE_MIN_MTU@:Socket::INET_ADDRSTRLEN@:'Socket::Constants::INET_ADDRSTRLEN@ :Socket::INET6_ADDRSTRLEN@:(Socket::Constants::INET6_ADDRSTRLEN@:Socket::IFNAMSIZ@: Socket::Constants::IFNAMSIZ@":Socket::IF_NAMESIZE@:#Socket::Constants::IF_NAMESIZE@.:Socket::SOMAXCONN@:!Socket::Constants::SOMAXCONN@::Socket::SCM_RIGHTS@:"Socket::Constants::SCM_RIGHTS@F:Socket::SCM_TIMESTAMP@:%Socket::Constants::SCM_TIMESTAMP@R:Socket::SCM_TIMESTAMPNS@ :'Socket::Constants::SCM_TIMESTAMPNS@^:Socket::SCM_TIMESTAMPING@:(Socket::Constants::SCM_TIMESTAMPING@j:Socket::SCM_BINTIME@":#Socket::Constants::SCM_BINTIME@v:Socket::SCM_CREDENTIALS@.:'Socket::Constants::SCM_CREDENTIALS@:Socket::SCM_CREDS@::!Socket::Constants::SCM_CREDS@:Socket::SCM_UCRED@F:!Socket::Constants::SCM_UCRED@:Socket::SCM_WIFI_STATUS@R:'Socket::Constants::SCM_WIFI_STATUS@:Socket::LOCAL_PEERCRED@^:&Socket::Constants::LOCAL_PEERCRED@:Socket::LOCAL_CREDS@j:#Socket::Constants::LOCAL_CREDS@:Socket::LOCAL_CONNWAIT@v:&Socket::Constants::LOCAL_CONNWAIT@:Socket::IFF_802_1Q_VLAN@:'Socket::Constants::IFF_802_1Q_VLAN@:Socket::IFF_ALLMULTI@:$Socket::Constants::IFF_ALLMULTI@:Socket::IFF_ALTPHYS@:#Socket::Constants::IFF_ALTPHYS@:Socket::IFF_AUTOMEDIA@:%Socket::Constants::IFF_AUTOMEDIA@:Socket::IFF_BONDING@:#Socket::Constants::IFF_BONDING@:Socket::IFF_BRIDGE_PORT@:'Socket::Constants::IFF_BRIDGE_PORT@:Socket::IFF_BROADCAST@:%Socket::Constants::IFF_BROADCAST@:Socket::IFF_CANTCONFIG@:&Socket::Constants::IFF_CANTCONFIG@*:Socket::IFF_DEBUG@:!Socket::Constants::IFF_DEBUG@6: Socket::IFF_DISABLE_NETPOLL@:+Socket::Constants::IFF_DISABLE_NETPOLL@B:Socket::IFF_DONT_BRIDGE@:'Socket::Constants::IFF_DONT_BRIDGE@N:Socket::IFF_DORMANT@:#Socket::Constants::IFF_DORMANT@Z:Socket::IFF_DRV_OACTIVE@:'Socket::Constants::IFF_DRV_OACTIVE@f:Socket::IFF_DRV_RUNNING@:'Socket::Constants::IFF_DRV_RUNNING@r:Socket::IFF_DYING@*:!Socket::Constants::IFF_DYING@~:Socket::IFF_DYNAMIC@6:#Socket::Constants::IFF_DYNAMIC@:Socket::IFF_EBRIDGE@B:#Socket::Constants::IFF_EBRIDGE@:Socket::IFF_ECHO@N: Socket::Constants::IFF_ECHO@:Socket::IFF_ISATAP@Z:"Socket::Constants::IFF_ISATAP@:Socket::IFF_LINK0@f:!Socket::Constants::IFF_LINK0@:Socket::IFF_LINK1@r:!Socket::Constants::IFF_LINK1@:Socket::IFF_LINK2@~:!Socket::Constants::IFF_LINK2@:!Socket::IFF_LIVE_ADDR_CHANGE@:,Socket::Constants::IFF_LIVE_ADDR_CHANGE@:Socket::IFF_LOOPBACK@:$Socket::Constants::IFF_LOOPBACK@:Socket::IFF_LOWER_UP@:$Socket::Constants::IFF_LOWER_UP@:Socket::IFF_MACVLAN_PORT@:(Socket::Constants::IFF_MACVLAN_PORT@:Socket::IFF_MASTER@:"Socket::Constants::IFF_MASTER@:Socket::IFF_MASTER_8023AD@:)Socket::Constants::IFF_MASTER_8023AD@:Socket::IFF_MASTER_ALB@:&Socket::Constants::IFF_MASTER_ALB@&:Socket::IFF_MASTER_ARPMON@:)Socket::Constants::IFF_MASTER_ARPMON@2:Socket::IFF_MONITOR@:#Socket::Constants::IFF_MONITOR@>:Socket::IFF_MULTICAST@:%Socket::Constants::IFF_MULTICAST@J:Socket::IFF_NOARP@:!Socket::Constants::IFF_NOARP@V:Socket::IFF_NOTRAILERS@:&Socket::Constants::IFF_NOTRAILERS@b:Socket::IFF_OACTIVE@:#Socket::Constants::IFF_OACTIVE@n:Socket::IFF_OVS_DATAPATH@&:(Socket::Constants::IFF_OVS_DATAPATH@z:Socket::IFF_POINTOPOINT@2:'Socket::Constants::IFF_POINTOPOINT@:Socket::IFF_PORTSEL@>:#Socket::Constants::IFF_PORTSEL@:Socket::IFF_PPROMISC@J:$Socket::Constants::IFF_PPROMISC@:Socket::IFF_PROMISC@V:#Socket::Constants::IFF_PROMISC@:Socket::IFF_RENAMING@b:$Socket::Constants::IFF_RENAMING@:Socket::IFF_ROUTE@n:!Socket::Constants::IFF_ROUTE@:Socket::IFF_RUNNING@z:#Socket::Constants::IFF_RUNNING@:Socket::IFF_SIMPLEX@:#Socket::Constants::IFF_SIMPLEX@:Socket::IFF_SLAVE@:!Socket::Constants::IFF_SLAVE@:Socket::IFF_SLAVE_INACTIVE@:*Socket::Constants::IFF_SLAVE_INACTIVE@:Socket::IFF_SLAVE_NEEDARP@:)Socket::Constants::IFF_SLAVE_NEEDARP@:Socket::IFF_SMART@:!Socket::Constants::IFF_SMART@ :Socket::IFF_STATICARP@:%Socket::Constants::IFF_STATICARP@:Socket::IFF_SUPP_NOFCS@:&Socket::Constants::IFF_SUPP_NOFCS@":Socket::IFF_TEAM_PORT@:%Socket::Constants::IFF_TEAM_PORT@.:Socket::IFF_TX_SKB_SHARING@:*Socket::Constants::IFF_TX_SKB_SHARING@::Socket::IFF_UNICAST_FLT@:'Socket::Constants::IFF_UNICAST_FLT@F:Socket::IFF_UP@:Socket::Constants::IFF_UP@R:Socket::IFF_WAN_HDLC@ :$Socket::Constants::IFF_WAN_HDLC@^:!Socket::IFF_XMIT_DST_RELEASE@:,Socket::Constants::IFF_XMIT_DST_RELEASE@j:Socket::IFF_VOLATILE@":$Socket::Constants::IFF_VOLATILE@v:Socket::IFF_CANTCHANGE@.:&Socket::Constants::IFF_CANTCHANGE@:Socket::Option@::Socket::Option#initialize@<:Socket::Option#family@c:Socket::Option#level@~:Socket::Option#optname@:Socket::Option#data@:Socket::Option#inspect@;j @:Socket::Option#int@;l @8:Socket::Option#byte@^;n @y:Socket::Option#bool@;p @:Socket::Option#linger@;r @:&Socket::Option#ipv4_multicast_ttl@ ;t @(:'Socket::Option#ipv4_multicast_loop@B:Socket::Option#unpack@]:Socket::Option#to_s@|:ASN1EndOfContent#to_dero;4;5F;6;;;;&I"ASN1EndOfContent#to_der;T;7[;[[@1Hig;T;;M;0;[;{;IC; " ;T;[;![;"@;#0;$@M;%o;( ;)0;*0;+0;;;%@;-0;0;9I"Wstatic VALUE ossl_asn1eoc_to_der(VALUE self) { return rb_str_new("\0\0", 2); };T;:I"static VALUE;T;;T:OpenSSL::Netscape@:!OpenSSL::Netscape::SPKIError@:'OpenSSL::Netscape::SPKI#initialize@:#OpenSSL::Netscape::SPKI#to_der@̮:#OpenSSL::Netscape::SPKI#to_pem@:!OpenSSL::Netscape::SPKI#to_s@:$OpenSSL::Netscape::SPKI#to_text@:'OpenSSL::Netscape::SPKI#public_key@:(OpenSSL::Netscape::SPKI#public_key=@1:!OpenSSL::Netscape::SPKI#sign@K:#OpenSSL::Netscape::SPKI#verify@i:&OpenSSL::Netscape::SPKI#challenge@:'OpenSSL::Netscape::SPKI#challenge=@:+JSON::Ext::Generator::GeneratorMethods@l:2JSON::Ext::Generator::GeneratorMethods::Array@:3JSON::Ext::Generator::GeneratorMethods::Bignum@_:7JSON::Ext::Generator::GeneratorMethods::FalseClass@:3JSON::Ext::Generator::GeneratorMethods::Fixnum@0:2JSON::Ext::Generator::GeneratorMethods::Float@:1JSON::Ext::Generator::GeneratorMethods::Hash@:4JSON::Ext::Generator::GeneratorMethods::Integer@:5JSON::Ext::Generator::GeneratorMethods::NilClass@:3JSON::Ext::Generator::GeneratorMethods::Object@n:3JSON::Ext::Generator::GeneratorMethods::String@:;JSON::Ext::Generator::GeneratorMethods::String::Extend@!:6JSON::Ext::Generator::GeneratorMethods::TrueClass@e; @a:JSON::Ext@c: JSON::Ext::Generator::State@g:+JSON::Ext::Generator::State.from_state@i:+JSON::Ext::Generator::State#initialize@:0JSON::Ext::Generator::State#initialize_copy@:'JSON::Ext::Generator::State#indent@:(JSON::Ext::Generator::State#indent=@:&JSON::Ext::Generator::State#space@:'JSON::Ext::Generator::State#space=@:-JSON::Ext::Generator::State#space_before@:.JSON::Ext::Generator::State#space_before=@.:*JSON::Ext::Generator::State#object_nl@H:+JSON::Ext::Generator::State#object_nl=@^:)JSON::Ext::Generator::State#array_nl@x:*JSON::Ext::Generator::State#array_nl=@:,JSON::Ext::Generator::State#max_nesting@:-JSON::Ext::Generator::State#max_nesting=@:-JSON::Ext::Generator::State#escape_slash@:.JSON::Ext::Generator::State#escape_slash?@:.JSON::Ext::Generator::State#escape_slash=@:0JSON::Ext::Generator::State#check_circular?@ :+JSON::Ext::Generator::State#allow_nan?@9:,JSON::Ext::Generator::State#ascii_only?@R:&JSON::Ext::Generator::State#depth@k:'JSON::Ext::Generator::State#depth=@:6JSON::Ext::Generator::State#buffer_initial_length@:7JSON::Ext::Generator::State#buffer_initial_length=@:*JSON::Ext::Generator::State#configure@:&JSON::Ext::Generator::State#merge@:%JSON::Ext::Generator::State#to_h@:(JSON::Ext::Generator::State#to_hash@:#JSON::Ext::Generator::State#[]@ :$JSON::Ext::Generator::State#[]=@%:)JSON::Ext::Generator::State#generate@C:;JSON::Ext::Generator::GeneratorMethods::Object#to_json@p:9JSON::Ext::Generator::GeneratorMethods::Hash#to_json@::JSON::Ext::Generator::GeneratorMethods::Array#to_json@:JSON::Ext::Generator::GeneratorMethods::TrueClass#to_json@g:?JSON::Ext::Generator::GeneratorMethods::FalseClass#to_json@:=JSON::Ext::Generator::GeneratorMethods::NilClass#to_json@:!JSON::Ext::Parser#initialize@:JSON::Ext::Parser#parse@4:JSON::Ext::Parser#source@J:Fiddle::Pinned@:Fiddle::Pinned#initialize@:Fiddle::Pinned#ref@:Fiddle::Pinned#clear@,:Fiddle::Pinned#cleared?@B:"Fiddle::ClearedReferenceError@j:Fiddle::Handle@~:Fiddle::Handle.sym@:Fiddle::Handle.[]@:Fiddle::Handle::NEXT@:Fiddle::Handle::DEFAULT@: Fiddle::Handle::RTLD_GLOBAL@:Fiddle::Handle::RTLD_LAZY@ę:Fiddle::Handle::RTLD_NOW@Й:Fiddle::Handle#initialize@ܙ:Fiddle::Handle#to_i@:Fiddle::Handle#to_ptr@:Fiddle::Handle#close@(:Fiddle::Handle#sym@>:Fiddle::Handle#[]@N:Fiddle::Handle#file_name@]:!Fiddle::Handle#disable_close@s: Fiddle::Handle#enable_close@:"Fiddle::Handle#close_enabled?@:Relay.with_funcall2o;4;5F;6;;;;&I"Relay.with_funcall2;T;7[[@90;[[I"!ext/-test-/funcall/funcall.c;Ti;T;:with_funcall2;0;[;{;IC; " ;T;[;![;"@;#0;$@Z;%o;( ;)0;*0;+0;: Relay;%@;-0;0;9I"static VALUE with_funcall2(int argc, VALUE *argv, VALUE self) { return rb_funcallv(self, rb_intern("target"), argc, argv); };T;:I"static VALUE;T;;T:(Relay.with_funcall_passing_block_kwo;4;5F;6;;;;&I"(Relay.with_funcall_passing_block_kw;T;7[[@90;[[@`i;T;:"with_funcall_passing_block_kw;0;[;{;IC; " ;T;[;![;"@;#0;$@i;%o;( ;)0;*0;+0;;#;%@;-0;0;9I"static VALUE with_funcall_passing_block_kw(int argc, VALUE *argv, VALUE self) { return rb_funcall_passing_block_kw(self, rb_intern("target"), argc-1, argv+1, FIX2INT(argv[0])); };T;:I"static VALUE;T;;T:%Relay.with_funcall_passing_blocko;4;5F;6;;;;&I"%Relay.with_funcall_passing_block;T;7[[@90;[[@`i;T;:with_funcall_passing_block;0;[;{;IC; " ;T;[;![;"@;#0;$@w;%o;( ;)0;*0;+0;;#;%@;-0;0;9I"static VALUE with_funcall_passing_block(int argc, VALUE *argv, VALUE self) { return rb_funcall_passing_block(self, rb_intern("target"), argc, argv); };T;:I"static VALUE;T;;T:"Relay.with_funcallv_public_kwo;4;5F;6;;;;&I""Relay.with_funcallv_public_kw;T;7[[@90;[[@`i;T;:with_funcallv_public_kw;0;[;{;IC; " ;T;[;![;"@;#0;$@;%o;( ;)0;*0;+0;;#;%@;-0;0;9I"static VALUE with_funcallv_public_kw(int argc, VALUE *argv, VALUE self) { return rb_funcallv_public_kw(argv[0], SYM2ID(argv[1]), argc-3, argv+3, FIX2INT(argv[2])); };T;:I"static VALUE;T;;T:Relay.with_yield_splat_kwo;4;5F;6;;;;&I"Relay.with_yield_splat_kw;T;7[[@90;[[@`i ;T;:with_yield_splat_kw;0;[;{;IC; " ;T;[;![;"@;#0;$@;%o;( ;)0;*0;+0;;#;%@;-0;0;9I"static VALUE with_yield_splat_kw(int argc, VALUE *argv, VALUE self) { return rb_yield_splat_kw(argv[1], FIX2INT(argv[0])); };T;:I"static VALUE;T;;T: TestFuncall.extra_args_nameo;4;5F;6;;;;&I" TestFuncall.extra_args_name;T;7[;[[@`i&;T;:extra_args_name;0;[;{;IC; " ;T;[;![;"@;#0;$@;%o;( ;)0;*0;+0;:TestFuncall;%@;-0;0;9I"static VALUE extra_args_name(VALUE self) { /* * at least clang 5.x gets tripped by the extra 0 arg * [ruby-core:85266] [Bug #14425] */ return rb_funcall(self, rb_intern("name"), 0, 0); };T;:I"static VALUE;T;;T; @:NameError::message@n;O@3:Exception.exception@5:Exception.to_tty?@F:Exception#exception@a:Exception#initialize@o:Exception#==@:Exception#to_s@:Exception#message@:Exception#full_message@:Exception#inspect@:Exception#backtrace@+:"Exception#backtrace_locations@G:Exception#set_backtrace@c:Exception#cause@:SystemExit#initialize@l:SystemExit#status@l:SystemExit#success?@ m:KeyError#initialize@m:KeyError#receiver@m:KeyError#key@m:SyntaxError#initialize@Sn:NameError#initialize@ o:NameError#name@+o:NameError#receiver@Go:NameError#local_variables@bo:'NameError::message#initialize_copy@n:NameError::message#==@n:NameError::message#to_str@n:NameError::message#_dump@n:NameError::message._load@n:NoMethodError#initialize@o:NoMethodError#args@o: NoMethodError#private_call?@o:FrozenError#initialize@p:FrozenError#receiver@p; @; @:)NoMatchingPatternKeyError#initialize@:&NoMatchingPatternKeyError#matchee@:"NoMatchingPatternKeyError#key@:SystemCallError#initialize@rp:SystemCallError#errno@p:SystemCallError.===@p:Warning.[]@l:Warning.[]=@2l:Warning#warn@Nl:Warning::buffer@ol:Warning::buffer#write@ql:Marshal::InternalIVar@_:%Marshal::InternalIVar#initialize@_:!Marshal::InternalIVar#normal@_:#Marshal::InternalIVar#internal@_:)Marshal::InternalIVar#encoding_short@_:"Marshal::InternalIVar::compat@`:/Marshal::InternalIVar::compat#marshal_load@ `:Marshal::UsrMarshal@7`:#Marshal::UsrMarshal#initialize@9`:Marshal::UsrMarshal#value@H`:%Marshal::UsrMarshal#marshal_load@T`:%Marshal::UsrMarshal#marshal_dump@b`:WIN32OLE::VARIANT@: WIN32OLE::VARIANT::VT_EMPTY@:WIN32OLE::VARIANT::VT_NULL@$:WIN32OLE::VARIANT::VT_I2@0:WIN32OLE::VARIANT::VT_I4@<:WIN32OLE::VARIANT::VT_R4@H:WIN32OLE::VARIANT::VT_R8@T:WIN32OLE::VARIANT::VT_CY@`:WIN32OLE::VARIANT::VT_DATE@l:WIN32OLE::VARIANT::VT_BSTR@x:&WIN32OLE::VARIANT::VT_USERDEFINED@:WIN32OLE::VARIANT::VT_PTR@:#WIN32OLE::VARIANT::VT_DISPATCH@: WIN32OLE::VARIANT::VT_ERROR@:WIN32OLE::VARIANT::VT_BOOL@:"WIN32OLE::VARIANT::VT_VARIANT@:"WIN32OLE::VARIANT::VT_UNKNOWN@:WIN32OLE::VARIANT::VT_I1@:WIN32OLE::VARIANT::VT_UI1@:WIN32OLE::VARIANT::VT_UI2@:WIN32OLE::VARIANT::VT_UI4@:WIN32OLE::VARIANT::VT_I8@:WIN32OLE::VARIANT::VT_UI8@:WIN32OLE::VARIANT::VT_INT@ :WIN32OLE::VARIANT::VT_UINT@,: WIN32OLE::VARIANT::VT_ARRAY@8: WIN32OLE::VARIANT::VT_BYREF@D:'Encoding::UndefinedConversionError@:'Encoding::InvalidByteSequenceError@~:%Encoding::ConverterNotFoundError@L:String#encode@,:String#encode!@,; @܆; @ :#Encoding::Converter#initialize@?: Encoding::Converter#inspect@r:!Encoding::Converter#convpath@:(Encoding::Converter#source_encoding@:-Encoding::Converter#destination_encoding@Ç:*Encoding::Converter#primitive_convert@އ: Encoding::Converter#convert@):Encoding::Converter#finish@C:*Encoding::Converter#primitive_errinfo@^:&Encoding::Converter#insert_output@y: Encoding::Converter#putback@:#Encoding::Converter#last_error@È:$Encoding::Converter#replacement@߈:%Encoding::Converter#replacement=@:Encoding::Converter#==@:&Encoding::Converter::INVALID_MASK@3:)Encoding::Converter::INVALID_REPLACE@?:$Encoding::Converter::UNDEF_MASK@K:'Encoding::Converter::UNDEF_REPLACE@W:+Encoding::Converter::UNDEF_HEX_CHARREF@c:'Encoding::Converter::PARTIAL_INPUT@o:&Encoding::Converter::AFTER_OUTPUT@{:5Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR@:0Encoding::Converter::CRLF_NEWLINE_DECORATOR@:.Encoding::Converter::CR_NEWLINE_DECORATOR@:,Encoding::Converter::XML_TEXT_DECORATOR@:4Encoding::Converter::XML_ATTR_CONTENT_DECORATOR@:2Encoding::Converter::XML_ATTR_QUOTE_DECORATOR@É: Passwd Etc::Passwd.each -> Enumerator Iterates for each entry in the /etc/passwd file if a block is given. If no block is given, returns the Enumerator. The code block is passed an Passwd struct. See ::getpwent above for details. Example: require 'etc' Etc::Passwd.each {|u| puts u.name + " = " + u.gecos } Etc::Passwd.collect {|u| u.gecos} Etc::Passwd.collect {|u| u.gecos} ;T;[;![;"I"Etc::Passwd.each { |struct| block } -> Passwd Etc::Passwd.each -> Enumerator Iterates for each entry in the /etc/passwd file if a block is given. If no block is given, returns the Enumerator. The code block is passed an Passwd struct. See ::getpwent above for details. Example: require 'etc' Etc::Passwd.each {|u| puts u.name + " = " + u.gecos } Etc::Passwd.collect {|u| u.gecos} Etc::Passwd.collect {|u| u.gecos} ;T;#0;$@;.F;/o;0;1T;2iI;3i`;%o;( ;)0;*0;+0;;=;%@;-0;0;9I"static VALUE etc_each_passwd(VALUE obj) { #ifdef HAVE_GETPWENT RETURN_ENUMERATOR(obj, 0, 0); each_passwd(); #endif return obj; };T;:I"static VALUE;T;;T:Etc::Group@:Struct::Group@K:Group.eacho;4;5F;6;;;;&I"Group.each;T;7[;[[@diQ;T;;;0;[;{;IC; "Etc::Group.each { |group| block } -> obj Etc::Group.each -> Enumerator Iterates for each entry in the /etc/group file if a block is given. If no block is given, returns the Enumerator. The code block is passed a Group struct. Example: require 'etc' Etc::Group.each {|g| puts g.name + ": " + g.mem.join(', ') } Etc::Group.collect {|g| g.name} Etc::Group.select {|g| !g.mem.empty?} ;T;[;![;"I"Etc::Group.each { |group| block } -> obj Etc::Group.each -> Enumerator Iterates for each entry in the /etc/group file if a block is given. If no block is given, returns the Enumerator. The code block is passed a Group struct. Example: require 'etc' Etc::Group.each {|g| puts g.name + ": " + g.mem.join(', ') } Etc::Group.collect {|g| g.name} Etc::Group.select {|g| !g.mem.empty?} ;T;#0;$@;.F;/o;0;1T;2i;;3iP;%o;( ;)0;*0;+0;;;%@;-0;0;9I"sstatic VALUE etc_each_group(VALUE obj) { RETURN_ENUMERATOR(obj, 0, 0); each_group(); return obj; };T;:I"static VALUE;T;;T; @ : Math::PI@8: Math::E@D:Math#atan2@Q:Math.atan2@s: Math#cos@: Math.cos@: Math#sin@: Math.sin@: Math#tan@: Math.tan@:Math#acos@+:Math.acos@I:Math#asin@`:Math.asin@~:Math#atan@:Math.atan@:Math#cosh@:Math.cosh@:Math#sinh@:Math.sinh@:Math#tanh@4:Math.tanh@R:Math#acosh@i:Math.acosh@:Math#asinh@:Math.asinh@:Math#atanh@:Math.atanh@: Math#exp@: Math.exp@&: Math#log@=: Math.log@k:Math#log2@:Math.log2@:Math#log10@:Math.log10@:Math#sqrt@:Math.sqrt@:Math#cbrt@2:Math.cbrt@P:Math#frexp@g:Math.frexp@:Math#ldexp@:Math.ldexp@:Math#hypot@:Math.hypot@: Math#erf@: Math.erf@0:Math#erfc@G:Math.erfc@e:Math#gamma@|:Math.gamma@:Math#lgamma@:Math.lgamma@:Ractor::RemoteError@:Ractor::MovedError@3:Ractor::MovedObject@n; @:Ractor::Error@:Ractor::IsolationError@ :Ractor::UnsafeError@]:'Ractor::MovedObject#method_missing@p:!Ractor::MovedObject#__send__@}:Ractor::MovedObject#!@:Ractor::MovedObject#==@:Ractor::MovedObject#!=@:Ractor::MovedObject#__id__@:Ractor::MovedObject#equal?@:&Ractor::MovedObject#instance_eval@:&Ractor::MovedObject#instance_exec@:Module.nesting@B:Module.constants@B:Object#extend@I:Kernel#trace_var@d:Kernel#untrace_var@; @:PTY#getpty@:PTY.getpty@g:PTY#spawn@:PTY.spawn@ :PTY.check@\ : PTY.open@ :PTY::ChildExited#status@ :RubyVM::AbstractSyntaxTree@:%RubyVM::AbstractSyntaxTree::Node@